Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Lemma · Bulk scan with exact residual and splice
Lean statement
Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.
import Tablet.P495_T1_BulkMixedStop
import Tablet.P495_T1_BulkStepExact
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P495_T1_BulkLoopExact]
theorem P495_T1_BulkLoopExact (s : Slice Std.U8) (i : Std.Usize)
(a : Array Std.U8 768#usize) (digits tail : List Nat)
(hs : s.val.map (fun b => b.val) =
digits.map (fun z => 48 + z) ++ tail)
(hdigits : forall z, z ∈ digits -> z < 10)
(htail : tail = [] \/ exists marker rest,
tail = marker :: rest /\ (marker = 46 \/ marker = 69 \/ marker = 101))
(hbound : i.val + digits.length + tail.length <= UScalar.max .Usize) :
exists (k : Nat) (rest : Slice Std.U8) (i' : Std.Usize)
(a' : Array Std.U8 768#usize) (written : List Std.U8),
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 s i a =
ok (rest, i', a') /\
k <= digits.length /\ k % 8 = 0 /\
rest.val.map (fun b => b.val) =
(digits.drop k).map (fun z => 48 + z) ++ tail /\
i'.val = i.val + k /\ written.length = k /\
written.map (fun b => b.val) = digits.take k /\
a'.val = a.val.take i.val ++ written ++ a.val.drop (i.val + k) := by
Proof
Natural-language proof
The status above describes the Lean proof. Its explanatory prose may remain a sketch after that proof closes.
Explanatory prose status
Prose retained as authored. The explanatory prose is preserved as it stood when captured.
Proof
Lean proof
let Inv := fun p : Slice Std.U8 × Std.Usize × Array Std.U8 768#usize =>
∃ k written,
k ≤ digits.length ∧ k % 8 = 0 ∧ written.length = k ∧
written.map (fun b => b.val) = digits.take k ∧
p.1.val.map (fun b => b.val) =
(digits.drop k).map (fun z => 48 + z) ++ tail ∧
p.2.1.val = i.val + k ∧
p.2.2.val = a.val.take i.val ++ written ++ a.val.drop (i.val + k)
let Post := fun out : Slice Std.U8 × Std.Usize × Array Std.U8 768#usize =>
∃ k written,
k ≤ digits.length ∧ k % 8 = 0 ∧
out.1.val.map (fun b => b.val) =
(digits.drop k).map (fun z => 48 + z) ++ tail ∧
out.2.1.val = i.val + k ∧ written.length = k ∧
written.map (fun b => b.val) = digits.take k ∧
out.2.2.val = a.val.take i.val ++ written ++ a.val.drop (i.val + k)
have hloop : Aeneas.Std.WP.spec
(num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 s i a) Post := by
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Slice Std.U8 × Std.Usize × Array Std.U8 768#usize => p.1.val.length)
Inv Post
(fun p => num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3.body
p.1 p.2.1 p.2.2)
(s, i, a)
· intro p hp
rcases p with ⟨s0, i0, a0⟩
rcases hp with ⟨k, written, hk, hmod, hwlen, hwmap, hs0, hi0, ha0⟩
simp only [Prod.fst, Prod.snd] at hs0 hi0 ha0 ⊢
have hlen : s0.val.length = (digits.drop k).length + tail.length := by
have h := congrArg List.length hs0
simpa using h
have hbodySpec :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3.body s0 i0 a0
⦃ r => match r with
| done y => Post y
| cont x' => Inv x' ∧ x'.1.val.length < s0.val.length ⦄ := by
by_cases hlen8 : 8 ≤ s0.val.length
· have hsum : i0.val + s0.val.length ≤ UScalar.max .Usize := by
calc
i0.val + s0.val.length =
i.val + k + ((digits.drop k).length + tail.length) := by
rw [hi0, hlen]
_ = i.val + digits.length + tail.length := by
rw [List.length_drop]
omega
_ ≤ UScalar.max .Usize := hbound
have hadd : i0.val + 8 ≤ UScalar.max .Usize := by
calc
i0.val + 8 ≤ i0.val + s0.val.length := Nat.add_le_add_left hlen8 _
_ ≤ UScalar.max .Usize := hsum
obtain ⟨i2, hi2, hi2val⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec (x := i0) (y := 8#usize) (by simpa using hadd))
change i2.val = i0.val + 8 at hi2val
by_cases hcap : i2.val <
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.val
· have hstrict : i0.val + 8 < 768 := by
have hc : i2.val < 768 := by
simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def] using hcap
rw [← hi2val]
exact hc
by_cases hrem8 : 8 ≤ (digits.drop k).length
· have htake :
(s0.val.take 8).map (fun b => b.val) =
((digits.drop k).take 8).map (fun z => 48 + z) := by
have h := congrArg (List.take 8) hs0
rw [← List.map_take] at h
rw [List.take_append_of_le_length (by simpa using hrem8)] at h
rw [← List.map_take] at h
exact h
have hbytes : ∀ (q : Nat) (hq : q < 8),
48 ≤ (s0.val[q]'(by omega)).val ∧
(s0.val[q]'(by omega)).val ≤ 57 := by
intro q hq
have hqrem : q < (digits.drop k).length := by omega
have hqTake : q < (s0.val.take 8).length := by
simp [List.length_take, hq, hlen8]
have hqGet : (s0.val.take 8)[q]'hqTake = s0.val[q]'(by omega) := by
simp [List.getElem_take, hq]
have hbyteMem : s0.val[q]'(by omega) ∈ s0.val.take 8 := by
rw [← hqGet]
exact List.getElem_mem hqTake
have hvalMem : (s0.val[q]'(by omega)).val ∈
(s0.val.take 8).map (fun b => b.val) :=
List.mem_map.mpr ⟨_, hbyteMem, rfl⟩
rw [htake] at hvalMem
rcases List.mem_map.mp hvalMem with ⟨z, hzTake, hval⟩
have hzDrop : z ∈ digits.drop k := List.mem_of_mem_take hzTake
have hzDigits : z ∈ digits := List.mem_of_mem_drop hzDrop
have hz := hdigits _ hzDigits
omega
obtain ⟨s1, i1, a1, w1, hbody, hs1, hi1, hwlen1,
hwmap1, ha1⟩ := P495_T1_BulkStepExact s0 i0 a0 hlen8 hstrict hbytes
rw [hbody]
simp only [WP.spec_ok]
refine ⟨⟨k + 8, written ++ w1, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩, ?_⟩
· have hdropLen : (digits.drop k).length = digits.length - k :=
List.length_drop
omega
· omega
· simp [hwlen, hwlen1]
· have hwmap8 : w1.map (fun b => b.val) = (digits.drop k).take 8 := by
rw [hwmap1]
calc
(s0.val.take 8).map (fun b => b.val - 48) =
((s0.val.take 8).map (fun b => b.val)).map
(fun z => z - 48) := by
induction s0.val.take 8 with
| nil => rfl
| cons b bs ih => simp [ih]
_ = (((digits.drop k).take 8).map (fun z => 48 + z)).map
(fun z => z - 48) := by rw [htake]
_ = (digits.drop k).take 8 := by
simp [List.map_map, Function.comp_def]
have htakeplus : digits.take k ++ (digits.drop k).take 8 =
digits.take (k + 8) := by
have h := congrArg (List.take (k + 8))
(List.take_append_drop k digits)
rw [List.take_append] at h
have hleft : (digits.take k).take (k + 8) = digits.take k := by
rw [List.take_take]
simp [Nat.min_eq_left hk]
have hlen : (digits.take k).length = k := by
simp [List.length_take, Nat.min_eq_left hk]
rw [hleft, hlen] at h
simpa using h
calc
(written ++ w1).map (fun b => b.val) =
written.map (fun b => b.val) ++ w1.map (fun b => b.val) := by
rw [List.map_append]
_ = digits.take k ++ (digits.drop k).take 8 := by
rw [hwmap, hwmap8]
_ = digits.take (k + 8) := htakeplus
· calc
s1.val.map (fun b => b.val) =
(s0.val.map (fun b => b.val)).drop 8 := by
rw [hs1, List.map_drop]
_ = ((digits.drop k).map (fun z => 48 + z) ++ tail).drop 8 := by
rw [hs0]
_ = (digits.drop (k + 8)).map (fun z => 48 + z) ++ tail := by
rw [List.drop_append_of_le_length (by simpa using hrem8)]
simp [List.map_drop, List.drop_drop, Nat.add_comm]
· rw [hi1, hi0]
omega
· rw [ha1, ha0, hi0]
have hi768 : i.val ≤ 768 := by omega
have hiBound : i.val ≤ a.val.length := by
rw [a.property]
simpa using hi768
have htakeArr :
(a.val.take i.val ++ written ++ a.val.drop (i.val + k)).take
(i.val + k) = a.val.take i.val ++ written := by
have hprefixlen : (a.val.take i.val).length = i.val := by
simp [List.length_take, Nat.min_eq_left hi768]
rw [List.take_append]
simp [hprefixlen, hwlen]
have hdropArr :
(a.val.take i.val ++ written ++ a.val.drop (i.val + k)).drop
(i.val + k + 8) = a.val.drop (i.val + k + 8) := by
have hprefixlen : (a.val.take i.val).length = i.val := by
simp [List.length_take, Nat.min_eq_left hi768]
simp [List.drop_append, hprefixlen, hwlen,
List.drop_drop, Nat.add_assoc]
rw [htakeArr, hdropArr]
simp [Nat.add_assoc]
· rw [hs1]
have hdec : (List.drop 8 s0.val).length < s0.val.length := by
rw [List.length_drop]
omega
simpa using hdec
· rcases htail with hnil | ⟨marker, rest, hmarkerTail, hmarker⟩
· have : s0.val.length < 8 := by
have hdropShort : (digits.drop k).length < 8 := by omega
rw [hlen, hnil]
simpa using hdropShort
omega
· have htailState : tail = marker :: rest := hmarkerTail
have hshortDigits : (digits.drop k).length < 8 := by omega
have hstate : s0.val.map (fun b => b.val) =
(digits.drop k).map (fun z => 48 + z) ++ marker :: rest := by
simpa [htailState, List.map_drop] using hs0
have hbody := P495_T1_BulkMixedStop s0 i0 a0
(digits.drop k) marker rest hstate hshortDigits hlen8 hmarker hstrict
rw [hbody]
simp only [WP.spec_ok, Post]
refine ⟨k, written, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;>
simp_all [hs0, hi0, ha0, hwlen, hwmap, hmod, htailState]
· have hbody :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3.body s0 i0 a0 =
ok (done (s0, i0, a0)) := by
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3.body
simp only [Slice.length, if_pos hlen8]
rw [hi2]
simp [hcap]
rw [hbody]
simp only [WP.spec_ok, Post]
refine ⟨k, written, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;>
simp_all [hs0, hi0, ha0, hwlen, hwmap, hmod]
· have hbody :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3.body s0 i0 a0 =
ok (done (s0, i0, a0)) := by
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3.body,
hlen8, Slice.length]
rw [hbody]
simp only [WP.spec_ok, Post]
refine ⟨k, written, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;>
simp_all [hs0, hi0, ha0, hwlen, hwmap, hmod]
convert hbodySpec using 1
funext r
cases r <;> rfl
· refine ⟨0, [], ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩
· simp
· simp
· simp
· simp
· simpa using hs
· simp
· simp [List.take_append_drop]
obtain ⟨out, hout, hpost⟩ := Aeneas.Std.WP.spec_imp_exists hloop
rcases hpost with ⟨k, written, hk, hmod, hrest, hi', hwlen, hwmap, ha'⟩
exact ⟨k, out.1, out.2.1, out.2.2, written, hout,
hk, hmod, hrest, hi', hwlen, hwmap, ha'⟩
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.P495_T1_BulkMixedStop
import Tablet.P495_T1_BulkStepExact
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P495_T1_BulkLoopExact]
theorem P495_T1_BulkLoopExact (s : Slice Std.U8) (i : Std.Usize)
(a : Array Std.U8 768#usize) (digits tail : List Nat)
(hs : s.val.map (fun b => b.val) =
digits.map (fun z => 48 + z) ++ tail)
(hdigits : forall z, z ∈ digits -> z < 10)
(htail : tail = [] \/ exists marker rest,
tail = marker :: rest /\ (marker = 46 \/ marker = 69 \/ marker = 101))
(hbound : i.val + digits.length + tail.length <= UScalar.max .Usize) :
exists (k : Nat) (rest : Slice Std.U8) (i' : Std.Usize)
(a' : Array Std.U8 768#usize) (written : List Std.U8),
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 s i a =
ok (rest, i', a') /\
k <= digits.length /\ k % 8 = 0 /\
rest.val.map (fun b => b.val) =
(digits.drop k).map (fun z => 48 + z) ++ tail /\
i'.val = i.val + k /\ written.length = k /\
written.map (fun b => b.val) = digits.take k /\
a'.val = a.val.take i.val ++ written ++ a.val.drop (i.val + k) := by
-- BODY
let Inv := fun p : Slice Std.U8 × Std.Usize × Array Std.U8 768#usize =>
∃ k written,
k ≤ digits.length ∧ k % 8 = 0 ∧ written.length = k ∧
written.map (fun b => b.val) = digits.take k ∧
p.1.val.map (fun b => b.val) =
(digits.drop k).map (fun z => 48 + z) ++ tail ∧
p.2.1.val = i.val + k ∧
p.2.2.val = a.val.take i.val ++ written ++ a.val.drop (i.val + k)
let Post := fun out : Slice Std.U8 × Std.Usize × Array Std.U8 768#usize =>
∃ k written,
k ≤ digits.length ∧ k % 8 = 0 ∧
out.1.val.map (fun b => b.val) =
(digits.drop k).map (fun z => 48 + z) ++ tail ∧
out.2.1.val = i.val + k ∧ written.length = k ∧
written.map (fun b => b.val) = digits.take k ∧
out.2.2.val = a.val.take i.val ++ written ++ a.val.drop (i.val + k)
have hloop : Aeneas.Std.WP.spec
(num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3 s i a) Post := by
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3
apply Aeneas.Std.loop.spec_decr_nat
(fun p : Slice Std.U8 × Std.Usize × Array Std.U8 768#usize => p.1.val.length)
Inv Post
(fun p => num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3.body
p.1 p.2.1 p.2.2)
(s, i, a)
· intro p hp
rcases p with ⟨s0, i0, a0⟩
rcases hp with ⟨k, written, hk, hmod, hwlen, hwmap, hs0, hi0, ha0⟩
simp only [Prod.fst, Prod.snd] at hs0 hi0 ha0 ⊢
have hlen : s0.val.length = (digits.drop k).length + tail.length := by
have h := congrArg List.length hs0
simpa using h
have hbodySpec :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3.body s0 i0 a0
⦃ r => match r with
| done y => Post y
| cont x' => Inv x' ∧ x'.1.val.length < s0.val.length ⦄ := by
by_cases hlen8 : 8 ≤ s0.val.length
· have hsum : i0.val + s0.val.length ≤ UScalar.max .Usize := by
calc
i0.val + s0.val.length =
i.val + k + ((digits.drop k).length + tail.length) := by
rw [hi0, hlen]
_ = i.val + digits.length + tail.length := by
rw [List.length_drop]
omega
_ ≤ UScalar.max .Usize := hbound
have hadd : i0.val + 8 ≤ UScalar.max .Usize := by
calc
i0.val + 8 ≤ i0.val + s0.val.length := Nat.add_le_add_left hlen8 _
_ ≤ UScalar.max .Usize := hsum
obtain ⟨i2, hi2, hi2val⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec (x := i0) (y := 8#usize) (by simpa using hadd))
change i2.val = i0.val + 8 at hi2val
by_cases hcap : i2.val <
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.val
· have hstrict : i0.val + 8 < 768 := by
have hc : i2.val < 768 := by
simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def] using hcap
rw [← hi2val]
exact hc
by_cases hrem8 : 8 ≤ (digits.drop k).length
· have htake :
(s0.val.take 8).map (fun b => b.val) =
((digits.drop k).take 8).map (fun z => 48 + z) := by
have h := congrArg (List.take 8) hs0
rw [← List.map_take] at h
rw [List.take_append_of_le_length (by simpa using hrem8)] at h
rw [← List.map_take] at h
exact h
have hbytes : ∀ (q : Nat) (hq : q < 8),
48 ≤ (s0.val[q]'(by omega)).val ∧
(s0.val[q]'(by omega)).val ≤ 57 := by
intro q hq
have hqrem : q < (digits.drop k).length := by omega
have hqTake : q < (s0.val.take 8).length := by
simp [List.length_take, hq, hlen8]
have hqGet : (s0.val.take 8)[q]'hqTake = s0.val[q]'(by omega) := by
simp [List.getElem_take, hq]
have hbyteMem : s0.val[q]'(by omega) ∈ s0.val.take 8 := by
rw [← hqGet]
exact List.getElem_mem hqTake
have hvalMem : (s0.val[q]'(by omega)).val ∈
(s0.val.take 8).map (fun b => b.val) :=
List.mem_map.mpr ⟨_, hbyteMem, rfl⟩
rw [htake] at hvalMem
rcases List.mem_map.mp hvalMem with ⟨z, hzTake, hval⟩
have hzDrop : z ∈ digits.drop k := List.mem_of_mem_take hzTake
have hzDigits : z ∈ digits := List.mem_of_mem_drop hzDrop
have hz := hdigits _ hzDigits
omega
obtain ⟨s1, i1, a1, w1, hbody, hs1, hi1, hwlen1,
hwmap1, ha1⟩ := P495_T1_BulkStepExact s0 i0 a0 hlen8 hstrict hbytes
rw [hbody]
simp only [WP.spec_ok]
refine ⟨⟨k + 8, written ++ w1, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩, ?_⟩
· have hdropLen : (digits.drop k).length = digits.length - k :=
List.length_drop
omega
· omega
· simp [hwlen, hwlen1]
· have hwmap8 : w1.map (fun b => b.val) = (digits.drop k).take 8 := by
rw [hwmap1]
calc
(s0.val.take 8).map (fun b => b.val - 48) =
((s0.val.take 8).map (fun b => b.val)).map
(fun z => z - 48) := by
induction s0.val.take 8 with
| nil => rfl
| cons b bs ih => simp [ih]
_ = (((digits.drop k).take 8).map (fun z => 48 + z)).map
(fun z => z - 48) := by rw [htake]
_ = (digits.drop k).take 8 := by
simp [List.map_map, Function.comp_def]
have htakeplus : digits.take k ++ (digits.drop k).take 8 =
digits.take (k + 8) := by
have h := congrArg (List.take (k + 8))
(List.take_append_drop k digits)
rw [List.take_append] at h
have hleft : (digits.take k).take (k + 8) = digits.take k := by
rw [List.take_take]
simp [Nat.min_eq_left hk]
have hlen : (digits.take k).length = k := by
simp [List.length_take, Nat.min_eq_left hk]
rw [hleft, hlen] at h
simpa using h
calc
(written ++ w1).map (fun b => b.val) =
written.map (fun b => b.val) ++ w1.map (fun b => b.val) := by
rw [List.map_append]
_ = digits.take k ++ (digits.drop k).take 8 := by
rw [hwmap, hwmap8]
_ = digits.take (k + 8) := htakeplus
· calc
s1.val.map (fun b => b.val) =
(s0.val.map (fun b => b.val)).drop 8 := by
rw [hs1, List.map_drop]
_ = ((digits.drop k).map (fun z => 48 + z) ++ tail).drop 8 := by
rw [hs0]
_ = (digits.drop (k + 8)).map (fun z => 48 + z) ++ tail := by
rw [List.drop_append_of_le_length (by simpa using hrem8)]
simp [List.map_drop, List.drop_drop, Nat.add_comm]
· rw [hi1, hi0]
omega
· rw [ha1, ha0, hi0]
have hi768 : i.val ≤ 768 := by omega
have hiBound : i.val ≤ a.val.length := by
rw [a.property]
simpa using hi768
have htakeArr :
(a.val.take i.val ++ written ++ a.val.drop (i.val + k)).take
(i.val + k) = a.val.take i.val ++ written := by
have hprefixlen : (a.val.take i.val).length = i.val := by
simp [List.length_take, Nat.min_eq_left hi768]
rw [List.take_append]
simp [hprefixlen, hwlen]
have hdropArr :
(a.val.take i.val ++ written ++ a.val.drop (i.val + k)).drop
(i.val + k + 8) = a.val.drop (i.val + k + 8) := by
have hprefixlen : (a.val.take i.val).length = i.val := by
simp [List.length_take, Nat.min_eq_left hi768]
simp [List.drop_append, hprefixlen, hwlen,
List.drop_drop, Nat.add_assoc]
rw [htakeArr, hdropArr]
simp [Nat.add_assoc]
· rw [hs1]
have hdec : (List.drop 8 s0.val).length < s0.val.length := by
rw [List.length_drop]
omega
simpa using hdec
· rcases htail with hnil | ⟨marker, rest, hmarkerTail, hmarker⟩
· have : s0.val.length < 8 := by
have hdropShort : (digits.drop k).length < 8 := by omega
rw [hlen, hnil]
simpa using hdropShort
omega
· have htailState : tail = marker :: rest := hmarkerTail
have hshortDigits : (digits.drop k).length < 8 := by omega
have hstate : s0.val.map (fun b => b.val) =
(digits.drop k).map (fun z => 48 + z) ++ marker :: rest := by
simpa [htailState, List.map_drop] using hs0
have hbody := P495_T1_BulkMixedStop s0 i0 a0
(digits.drop k) marker rest hstate hshortDigits hlen8 hmarker hstrict
rw [hbody]
simp only [WP.spec_ok, Post]
refine ⟨k, written, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;>
simp_all [hs0, hi0, ha0, hwlen, hwmap, hmod, htailState]
· have hbody :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3.body s0 i0 a0 =
ok (done (s0, i0, a0)) := by
unfold num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3.body
simp only [Slice.length, if_pos hlen8]
rw [hi2]
simp [hcap]
rw [hbody]
simp only [WP.spec_ok, Post]
refine ⟨k, written, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;>
simp_all [hs0, hi0, ha0, hwlen, hwmap, hmod]
· have hbody :
num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3.body s0 i0 a0 =
ok (done (s0, i0, a0)) := by
simp [num.imp.dec2flt.decimal_seq.parse_decimal_seq_loop3.body,
hlen8, Slice.length]
rw [hbody]
simp only [WP.spec_ok, Post]
refine ⟨k, written, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;>
simp_all [hs0, hi0, ha0, hwlen, hwmap, hmod]
convert hbodySpec using 1
funext r
cases r <;> rfl
· refine ⟨0, [], ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩
· simp
· simp
· simp
· simp
· simpa using hs
· simp
· simp [List.take_append_drop]
obtain ⟨out, hout, hpost⟩ := Aeneas.Std.WP.spec_imp_exists hloop
rcases hpost with ⟨k, written, hk, hmod, hrest, hi', hwlen, hwmap, ha'⟩
exact ⟨k, out.1, out.2.1, out.2.2, written, hout,
hk, hmod, hrest, hi', hwlen, hwmap, ha'⟩
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Used by
Inspect related source (79)
- parse_decimal_seq · dec2flt/decimal_seq.rs:288 Program Rust
- parse_decimal_seq_loop0 · dec2flt/decimal_seq.rs:296 Program Rust
- body · dec2flt/decimal_seq.rs:296 Program Rust
More program dependencies (46)
- parse_decimal_seq_loop1 · dec2flt/decimal_seq.rs:368 Program Rust
- body · dec2flt/decimal_seq.rs:368 Program Rust
- parse_decimal_seq_loop2 · dec2flt/decimal_seq.rs:309 Program Rust
- body · dec2flt/decimal_seq.rs:309 Program Rust
- parse_decimal_seq_loop3 · dec2flt/decimal_seq.rs:313 Program Rust
- body · dec2flt/decimal_seq.rs:313 Program Rust
- parse_decimal_seq_loop4 · dec2flt/decimal_seq.rs:368 Program Rust
- body · dec2flt/decimal_seq.rs:368 Program Rust
- parse_decimal_seq_loop5 · dec2flt/decimal_seq.rs:313 Program Rust
- body · dec2flt/decimal_seq.rs:313 Program Rust
- parse_decimal_seq_loop6 · dec2flt/decimal_seq.rs:368 Program Rust
- body · dec2flt/decimal_seq.rs:368 Program Rust
- parse_decimal_seq_loop7 · dec2flt/decimal_seq.rs:368 Program Rust
- body · dec2flt/decimal_seq.rs:368 Program Rust
- read_u64 · dec2flt/common.rs:22 Program Rust
- write_u64 · dec2flt/common.rs:29 Program Rust
- is_8digits · dec2flt/common.rs:44 Program Rust
- DecimalSeq · dec2flt/decimal_seq.rs:22 Program Rust
- default · dec2flt/decimal_seq.rs:34 Program Rust
- MAX_DIGITS · dec2flt/decimal_seq.rs:64 Program Rust
- MAX_DIGITS_WITHOUT_OVERFLOW · dec2flt/decimal_seq.rs:67 Program Rust
- count_trailing_zeros · dec2flt/decimal_seq.rs:236 Program Rust
- count_trailing_zeros_loop · dec2flt/decimal_seq.rs:240 Program Rust
- body · dec2flt/decimal_seq.rs:240 Program Rust
- final_decimal_point · dec2flt/decimal_seq.rs:269 Program Rust
- parse_digits_into_seq · dec2flt/decimal_seq.rs:257 Program Rust
- parse_digits_into_seq_loop · dec2flt/decimal_seq.rs:259 Program Rust
- body · dec2flt/decimal_seq.rs:259 Program Rust
- parse_scientific · dec2flt/parse.rs:121 Program Rust
- parse_scientific_loop · dec2flt/parse.rs:145 Program Rust
- body · dec2flt/parse.rs:145 Program Rust
- from_u64 · dec2flt/mod.rs:263 Program Rust
- FloatErrorKind · num/mod.rs:18 Program Rust
- ParseFloatError · num/mod.rs:13 Program Rust
- Dec2FltAssemblyTrace · dec2flt/mod.rs:329 Program Rust
- Dec2FltTrace · dec2flt/mod.rs:295 Program Rust
- Lemire · dec2flt/mod.rs:115 Program Rust
- BiasedFp · dec2flt/common.rs:56 Program Rust
- ByteSlice · dec2flt/common.rs:4 Program Rust
- Decimal · dec2flt/decimal.rs:32 Program Rust
- DECIMAL_POINT_RANGE · dec2flt/decimal_seq.rs:68 Program Rust
- try_add_digit · dec2flt/decimal_seq.rs:74 Program Rust
- CastInto · traits.rs:18 Program Rust
- Float · traits.rs:74 Program Rust
- FloatExt · traits.rs:170 Program Rust
- Int · traits.rs:27 Program Rust
Standard-library dependencies (30)
- clone · core/src/clone.rs:698 Rust library
- div · core/src/ops/arith.rs:515 Rust library
- mul · core/src/ops/arith.rs:350 Rust library
- neg · core/src/ops/arith.rs:719 Rust library
- bitand · core/src/ops/bit.rs:178 Rust library
- bitor · core/src/ops/bit.rs:282 Rust library
- shl · core/src/ops/bit.rs:489 Rust library
- shr · core/src/ops/bit.rs:612 Rust library
- EXPONENT_MASK · core/src/num/f64.rs:615 Rust library
- INFINITY · core/src/num/f64.rs:512 Rust library
- MANTISSA_DIGITS · core/src/num/f64.rs:412 Rust library
- MANTISSA_MASK · core/src/num/f64.rs:637 Rust library
- NAN · core/src/num/f64.rs:509 Rust library
- NEG_INFINITY · core/src/num/f64.rs:515 Rust library
- classify · core/src/num/f64.rs:782 Rust library
- from_bits · core/src/num/f64.rs:1269 Rust library
- to_bits · core/src/num/f64.rs:1223 Rust library
- is_ascii_digit · core/src/num/mod.rs:958 Rust library
- from_residual · core/src/option.rs:2793 Rust library
- branch · core/src/option.rs:2779 Rust library
- first · core/src/slice/mod.rs:155 Rust library
- split_first · core/src/slice/mod.rs:198 Rust library
- as_bytes · core/src/str/mod.rs:498 Rust library
- FpCategory · core/src/num/mod.rs:1522 Rust library
- Div · core/src/ops/arith.rs:460 Rust library
- Mul · core/src/ops/arith.rs:322 Rust library
- Neg · core/src/ops/arith.rs:690 Rust library
- BitOr · core/src/ops/bit.rs:254 Rust library
- Shl · core/src/ops/bit.rs:461 Rust library
- Shr · core/src/ops/bit.rs:584 Rust library
Related source and models come from the extraction records and declared dependencies.
Proof assumptions and review
Lean checks the formal proof. Trellis also reviews how the statement corresponds to the intended requirement.
Transitive assumptions
- Classical.choice
- Dec2Flt.P340_T1_selected_target_numBits
- Quot.sound
- propext
This list combines the assumptions recorded for this declaration and its dependencies. It may include assumptions used by auxiliary declarations in those modules.
Helper theorems included
- Binary64Model
- Binary64ModelDefault
- DecimalSeqBulkLaneSubtraction
- DecimalSeqLittleEndianLane
- DecimalSeqWriteU64Exact
- F64
All 52 entries
- Binary64Model
- Binary64ModelDefault
- DecimalSeqBulkLaneSubtraction
- DecimalSeqLittleEndianLane
- DecimalSeqWriteU64Exact
- F64
- ModelF64Classify
- ModelF64Clone
- ModelF64Div
- ModelF64ExponentMask
- ModelF64FromBits
- ModelF64FromU64
- ModelF64Infinity
- ModelF64MantissaDigits
- ModelF64MantissaMask
- ModelF64Mul
- ModelF64Nan
- ModelF64Neg
- ModelF64NegInfinity
- ModelF64ToBits
- ModelOptionBranch
- ModelOptionFromResidual
- ModelSliceFirst
- ModelSliceSplitFirst
- ModelStrAsBytes
- ModelU64BitAnd
- ModelU64BitOr
- ModelU64Shl
- ModelU64Shr
- ModelU8IsAsciiDigit
- NumberHelperEightDigitWord
- NumberHelperEightDigitWordAccepted
- NumberHelperReadEightBytes
- BulkLoopExact
- BulkMixedStop
- BulkStepExact
- Preamble
- SliceU8 Insts Dec2flt modelNumImpDec2fltCommonByteSlice read u64
- SliceU8 Insts Dec2flt modelNumImpDec2fltCommonByteSlice write u64
- core num FpCategory
- num imp dec2flt common is 8digits
- num imp dec2flt decimal seq DecimalSeq
- num imp dec2flt decimal seq DecimalSeq DECIMAL POINT RANGE
- num imp dec2flt decimal seq DecimalSeq Insts CoreDefaultDefault default
- num imp dec2flt decimal seq DecimalSeq MAX DIGITS
- num imp dec2flt decimal seq DecimalSeq MAX DIGITS WITHOUT OVERFLOW
- num imp dec2flt decimal seq DecimalSeq try add digit
- num imp dec2flt decimal seq count trailing zeros
- num imp dec2flt decimal seq final decimal point
- num imp dec2flt decimal seq parse decimal seq
- num imp dec2flt decimal seq parse digits into seq
- num imp dec2flt parse parse scientific
Technical checking records
Local closure summary
{
"node": "P495_T1_BulkLoopExact",
"closure_version": "patch_c_v1",
"active_decl_hash": "60cda08826e02bd2e3e018cc6782d1fe8aba09b741836d6f68446c0fecbd6cb8",
"active_statement_hash": "9a89ab66963efc9a4407fd5153a77745f492af91ba200047be01a3ece3d734c9",
"kernel_axioms": [
"Classical.choice",
"Quot.sound",
"propext"
],
"toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
"lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
"checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
"approved_axioms_hash": "576e6bf9480cfd32f53c309c7ac8fb115c1ba6e413f299ed5ff9fa7c647e6769",
"axcheck_status": "Agreed",
"accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-181",
"boundary_theorems": {},
"strict_theorem_deps": {
"P495_T1_BulkMixedStop": "22eade145488c507",
"P495_T1_BulkStepExact": "c220a06ddad2fe5e",
"num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS": "0eb6fb2627d0ff5c",
"num_imp_dec2flt_decimal_seq_parse_decimal_seq": "effb8a26907859a5"
},
"strict_definition_deps": {
"SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_read_u64": "279b0c1cd8ec9e39",
"SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_write_u64": "7bfa0dbe8c4d23de",
"num_imp_dec2flt_common_is_8digits": "53e9de5212d69bf5",
"num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS": "39f6cb231ef80388",
"num_imp_dec2flt_decimal_seq_parse_decimal_seq": "da95d2d9e37f0c9d"
}
}Prose assessment
{
"label": "Recorded Sound: VerifierPass",
"assessment_status": "VerifierPass",
"fingerprint_relation": "matches current fingerprint",
"assessment_fingerprint": "sound-v2:970ecc9bb825e4d89775005929efd90dcc12ec357ea6f614bbf07bd5a9402382",
"current_fingerprint": "sound-v2:970ecc9bb825e4d89775005929efd90dcc12ec357ea6f614bbf07bd5a9402382",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"sound_status": "Pass",
"substantiveness_status": "Pass"
}