Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Helper · Exact maximal scalar digit scan
Lean statement
Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.
import Tablet.DecimalSeqPrimitiveSemantics
import Tablet.num_imp_dec2flt_decimal_seq_parse_digits_into_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqScalarScanExact]
theorem DecimalSeqScalarScanExact (s : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(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)
(hstop : tail = [] \/ tail[0]? = some 46 \/ tail[0]? = some 69 \/
tail[0]? = some 101)
(hbound : d.num_digits.val + digits.length <= UScalar.max .Usize) :
exists (rest : Slice Std.U8)
(d' : num.imp.dec2flt.decimal_seq.DecimalSeq),
num.imp.dec2flt.decimal_seq.parse_digits_into_seq s d = ok (rest, d') /\
rest.val.map (fun b => b.val) = tail /\
d'.num_digits.val = d.num_digits.val + digits.length /\
d'.decimal_point = d.decimal_point /\
d'.truncated = d.truncated /\
(forall j, j < min d.num_digits.val 768 ->
d'.digits.val[j]? = d.digits.val[j]?) /\
(forall j, d.num_digits.val <= j ->
j < min (d.num_digits.val + digits.length) 768 ->
(d'.digits.val[j]?).map (fun b => b.val) =
digits[j - d.num_digits.val]?) /\
(forall j, min (d.num_digits.val + digits.length) 768 <= j ->
j < 768 -> d'.digits.val[j]? = d.digits.val[j]?) := 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
take k D; and all later cells below 768 retain their input
values. The decreasing measure is |D|-k.try_add_digit increments the
logical count in all cases; below 768 its in-bounds array update writes
D[k], while at or above 768 it leaves the array unchanged and sets
truncation exactly as stated by
DecimalSeqPrimitiveSemantics. The assumed Usize sum justifies both
the record-count and cursor increments. The list update law then establishes
each of the three cell regions for k+1.Lean proof
let Inv := fun p : num.imp.dec2flt.decimal_seq.DecimalSeq × Std.Usize =>
p.2.val <= digits.length /\
p.1.num_digits.val = d.num_digits.val + p.2.val /\
p.1.decimal_point = d.decimal_point /\
p.1.truncated = d.truncated /\
(forall j, j < min d.num_digits.val 768 ->
p.1.digits.val[j]? = d.digits.val[j]?) /\
(forall j, d.num_digits.val <= j ->
j < min (d.num_digits.val + p.2.val) 768 ->
(p.1.digits.val[j]?).map (fun b => b.val) =
digits[j - d.num_digits.val]?) /\
(forall j, min (d.num_digits.val + p.2.val) 768 <= j ->
j < 768 -> p.1.digits.val[j]? = d.digits.val[j]?)
let Post := fun p : num.imp.dec2flt.decimal_seq.DecimalSeq × Std.Usize =>
p.2.val = digits.length /\ Inv p
have hloop : Aeneas.Std.WP.spec
(num.imp.dec2flt.decimal_seq.parse_digits_into_seq_loop s d 0#usize)
Post := by
unfold num.imp.dec2flt.decimal_seq.parse_digits_into_seq_loop
apply Aeneas.Std.loop.spec_decr_nat
(fun p : num.imp.dec2flt.decimal_seq.DecimalSeq × Std.Usize =>
digits.length - p.2.val)
Inv Post
(fun p =>
num.imp.dec2flt.decimal_seq.parse_digits_into_seq_loop.body s p.1 p.2)
(d, 0#usize)
· intro p hp
rcases p with ⟨e, count⟩
rcases hp with ⟨hcount, hecount, hepoint, hetrunc,
heold, hewritten, heoutside⟩
simp only [Prod.fst, Prod.snd] at hcount hecount hepoint hetrunc heold hewritten heoutside ⊢
unfold num.imp.dec2flt.decimal_seq.parse_digits_into_seq_loop.body
by_cases hk : count.val < digits.length
· have hks : count.val < s.val.length := by
have hlen := congrArg List.length hs
simp at hlen
omega
have hsindex : (s.val[count.val]'hks).val =
48 + digits[count.val] := by
have hm := congrArg (fun xs => xs[count.val]?) hs
simp only [List.getElem?_append, List.length_map] at hm
simp [hk] at hm
rcases hm with ⟨a, ha, haval⟩
rw [List.getElem?_eq_getElem hks] at ha
cases ha
exact haval
simp [Slice.length, hks]
step
have hi1 : i1 = s.val[count.val]'hks := by
exact i1_post
have hdigit := hdigits digits[count.val] (List.getElem_mem _)
step
have hi2val : i2.val = digits[count.val] := by
rw [i2_post, core.num.U8.wrapping_sub_val_eq, hi1, hsindex]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
omega
have hi2lt : i2.val < 10 := by omega
simp [hi2lt]
step
have hdigitval : digit.val = digits[count.val] := by
rw [digit_post, core.num.U8.wrapping_sub_val_eq, hi1, hsindex]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
omega
have headd : e.num_digits.val + 1 <= UScalar.max .Usize := by
rw [hecount]
omega
have hcountadd : count.val + 1 <= UScalar.max .Usize := by
omega
obtain ⟨d1, hd1⟩ : exists d1,
num.imp.dec2flt.decimal_seq.DecimalSeq.try_add_digit e digit =
ok d1 := by
unfold num.imp.dec2flt.decimal_seq.DecimalSeq.try_add_digit
by_cases hstore : e.num_digits.val < 768
· have hword : e.num_digits <
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def,
UScalar.lt_equiv] using hstore
simp only [hword, if_true]
obtain ⟨a, ha, _⟩ := Aeneas.Std.WP.spec_imp_exists
(Array.update_spec e.digits e.num_digits digit (by
simpa [Array.length] using hstore))
rw [ha]
obtain ⟨next, hnext, _⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec (x := e.num_digits) (y := 1#usize) (by
simpa using headd))
rw [hnext]
simp
· have hword : ¬ e.num_digits <
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def,
UScalar.lt_equiv] using hstore
simp only [hword, if_false]
obtain ⟨next, hnext, _⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec (x := e.num_digits) (y := 1#usize) (by
simpa using headd))
rw [hnext]
simp
rw [hd1]
obtain ⟨he'count, he'point, he'trunc, he'arr⟩ :=
DecimalSeqPrimitiveSemantics.2.2.2 e d1 digit hd1
obtain ⟨count', hcount', hcount'val⟩ :=
Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec (x := count) (y := 1#usize) (by
simpa using hcountadd))
rw [hcount']
change count'.val = count.val + 1 at hcount'val
refine ⟨?_, ?_⟩
· simp only [Inv, Prod.fst, Prod.snd]
refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩
· omega
· omega
· exact he'point.trans hepoint
· exact he'trunc.trans hetrunc
· intro j hj
by_cases hstore : e.num_digits.val < 768
· simp [hstore] at he'arr
rw [he'arr]
simp only [Aeneas.Std.Array.set, List.getElem?_set]
split
· rename_i heq
have : j = e.num_digits.val := by omega
omega
· exact heold j hj
· simp [hstore] at he'arr
rw [he'arr]
exact heold j hj
· intro j hjlo hjhi
by_cases hjnew : j = e.num_digits.val
· subst j
have hstore : e.num_digits.val < 768 := by omega
simp [hstore] at he'arr
rw [he'arr]
simp only [Aeneas.Std.Array.set, List.getElem?_set]
have hidx : e.num_digits.val - d.num_digits.val = count.val := by
omega
rw [hidx, List.getElem?_eq_getElem hk]
simp [hstore, hdigitval]
· have hjprev : j < min (d.num_digits.val + count.val) 768 := by
omega
have hprev := hewritten j hjlo hjprev
by_cases hstore : e.num_digits.val < 768
· simp [hstore] at he'arr
rw [he'arr]
simp only [Aeneas.Std.Array.set, List.getElem?_set]
have hne : e.num_digits.val ≠ j := Ne.symm hjnew
simp [hne, hprev]
· simp [hstore] at he'arr
rw [he'arr]
exact hprev
· intro j hjlo hj768
have hjne : j ≠ e.num_digits.val := by omega
by_cases hstore : e.num_digits.val < 768
· simp [hstore] at he'arr
rw [he'arr]
simp only [Aeneas.Std.Array.set, List.getElem?_set]
have hne : e.num_digits.val ≠ j := Ne.symm hjne
simp [hne]
exact heoutside j (by omega) hj768
· simp [hstore] at he'arr
rw [he'arr]
exact heoutside j (by omega) hj768
· simp only [Prod.fst, Prod.snd]
omega
· have hkEq : count.val = digits.length := by omega
have hlen := congrArg List.length hs
simp at hlen
by_cases htail : tail = []
· have hsend : count.val = s.val.length := by
rw [htail] at hlen
simp at hlen
omega
simp [hsend, WP.spec_ok]
exact ⟨hkEq, hcount, hecount, hepoint, hetrunc,
heold, hewritten, heoutside⟩
· have hlt : count.val < s.val.length := by
rw [hkEq]
have htlen : tail.length ≠ 0 := by simpa using htail
have : 0 < tail.length := by omega
omega
simp [Slice.length, hlt]
step
have hi1tail : i1.val = tail[0] := by
have hm := congrArg List.head?
(congrArg (List.drop count.val) hs)
simp [hkEq, List.map_drop] at hm
have htlen : tail.length ≠ 0 := by simpa using htail
have htpos : 0 < tail.length := by omega
have htailHead : tail.head? = some tail[0] := by
rw [List.head?_eq_getElem?, List.getElem?_eq_getElem htpos]
rw [← hkEq, List.getElem?_eq_getElem hlt, htailHead] at hm
simp only [Option.map_some, Option.some.injEq] at hm
rw [i1_post]
exact hm
step
have hi2nondigit : ¬ i2.val < 10 := by
rw [i2_post, core.num.U8.wrapping_sub_val_eq, hi1tail]
have htlen : tail.length ≠ 0 := by simpa using htail
have htpos : 0 < tail.length := by omega
rcases hstop with hnil | hpoint | he | hE
· contradiction
· rw [List.getElem?_eq_getElem htpos] at hpoint
simp only [Option.some.injEq] at hpoint
rw [hpoint]
norm_num [U8.size_eq]
· rw [List.getElem?_eq_getElem htpos] at he
simp only [Option.some.injEq] at he
rw [he]
norm_num [U8.size_eq]
· rw [List.getElem?_eq_getElem htpos] at hE
simp only [Option.some.injEq] at hE
rw [hE]
norm_num [U8.size_eq]
simp [hi2nondigit, WP.spec_ok]
exact ⟨hkEq, hcount, hecount, hepoint, hetrunc,
heold, hewritten, heoutside⟩
· simp [Inv]
intro j hjlo hjhi hj768
omega
obtain ⟨p, hp, hpPost⟩ := Aeneas.Std.WP.spec_imp_exists hloop
rcases p with ⟨d', count⟩
rcases hpPost with ⟨hcountEq, _, hd'count, hd'point, hd'trunc,
hd'old, hd'written, hd'outside⟩
simp only [Prod.fst, Prod.snd] at hcountEq hd'count hd'point hd'trunc hd'old hd'written hd'outside
unfold num.imp.dec2flt.decimal_seq.parse_digits_into_seq
rw [hp]
have hcountLe : count.val <= s.val.length := by
have hlen := congrArg List.length hs
simp at hlen
omega
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, hcountLe]
refine ⟨?_, ?_, hd'point, hd'trunc, ?_, ?_, ?_⟩
· rw [hs, hcountEq]
simp
· omega
· intro j hjlo hj768
apply hd'old j
omega
· intro j hjlo hjhi hj768
apply hd'written j hjlo
omega
· intro j hjlo hj768
apply hd'outside j
· rcases hjlo with hjlo | hjlo
· omega
· omega
· exact hj768
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.DecimalSeqPrimitiveSemantics
import Tablet.num_imp_dec2flt_decimal_seq_parse_digits_into_seq
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqScalarScanExact]
theorem DecimalSeqScalarScanExact (s : Slice Std.U8)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(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)
(hstop : tail = [] \/ tail[0]? = some 46 \/ tail[0]? = some 69 \/
tail[0]? = some 101)
(hbound : d.num_digits.val + digits.length <= UScalar.max .Usize) :
exists (rest : Slice Std.U8)
(d' : num.imp.dec2flt.decimal_seq.DecimalSeq),
num.imp.dec2flt.decimal_seq.parse_digits_into_seq s d = ok (rest, d') /\
rest.val.map (fun b => b.val) = tail /\
d'.num_digits.val = d.num_digits.val + digits.length /\
d'.decimal_point = d.decimal_point /\
d'.truncated = d.truncated /\
(forall j, j < min d.num_digits.val 768 ->
d'.digits.val[j]? = d.digits.val[j]?) /\
(forall j, d.num_digits.val <= j ->
j < min (d.num_digits.val + digits.length) 768 ->
(d'.digits.val[j]?).map (fun b => b.val) =
digits[j - d.num_digits.val]?) /\
(forall j, min (d.num_digits.val + digits.length) 768 <= j ->
j < 768 -> d'.digits.val[j]? = d.digits.val[j]?) := by
-- BODY
let Inv := fun p : num.imp.dec2flt.decimal_seq.DecimalSeq × Std.Usize =>
p.2.val <= digits.length /\
p.1.num_digits.val = d.num_digits.val + p.2.val /\
p.1.decimal_point = d.decimal_point /\
p.1.truncated = d.truncated /\
(forall j, j < min d.num_digits.val 768 ->
p.1.digits.val[j]? = d.digits.val[j]?) /\
(forall j, d.num_digits.val <= j ->
j < min (d.num_digits.val + p.2.val) 768 ->
(p.1.digits.val[j]?).map (fun b => b.val) =
digits[j - d.num_digits.val]?) /\
(forall j, min (d.num_digits.val + p.2.val) 768 <= j ->
j < 768 -> p.1.digits.val[j]? = d.digits.val[j]?)
let Post := fun p : num.imp.dec2flt.decimal_seq.DecimalSeq × Std.Usize =>
p.2.val = digits.length /\ Inv p
have hloop : Aeneas.Std.WP.spec
(num.imp.dec2flt.decimal_seq.parse_digits_into_seq_loop s d 0#usize)
Post := by
unfold num.imp.dec2flt.decimal_seq.parse_digits_into_seq_loop
apply Aeneas.Std.loop.spec_decr_nat
(fun p : num.imp.dec2flt.decimal_seq.DecimalSeq × Std.Usize =>
digits.length - p.2.val)
Inv Post
(fun p =>
num.imp.dec2flt.decimal_seq.parse_digits_into_seq_loop.body s p.1 p.2)
(d, 0#usize)
· intro p hp
rcases p with ⟨e, count⟩
rcases hp with ⟨hcount, hecount, hepoint, hetrunc,
heold, hewritten, heoutside⟩
simp only [Prod.fst, Prod.snd] at hcount hecount hepoint hetrunc heold hewritten heoutside ⊢
unfold num.imp.dec2flt.decimal_seq.parse_digits_into_seq_loop.body
by_cases hk : count.val < digits.length
· have hks : count.val < s.val.length := by
have hlen := congrArg List.length hs
simp at hlen
omega
have hsindex : (s.val[count.val]'hks).val =
48 + digits[count.val] := by
have hm := congrArg (fun xs => xs[count.val]?) hs
simp only [List.getElem?_append, List.length_map] at hm
simp [hk] at hm
rcases hm with ⟨a, ha, haval⟩
rw [List.getElem?_eq_getElem hks] at ha
cases ha
exact haval
simp [Slice.length, hks]
step
have hi1 : i1 = s.val[count.val]'hks := by
exact i1_post
have hdigit := hdigits digits[count.val] (List.getElem_mem _)
step
have hi2val : i2.val = digits[count.val] := by
rw [i2_post, core.num.U8.wrapping_sub_val_eq, hi1, hsindex]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
omega
have hi2lt : i2.val < 10 := by omega
simp [hi2lt]
step
have hdigitval : digit.val = digits[count.val] := by
rw [digit_post, core.num.U8.wrapping_sub_val_eq, hi1, hsindex]
simp only [UScalar.size_UScalarTyU8, U8.size_eq]
norm_num
omega
have headd : e.num_digits.val + 1 <= UScalar.max .Usize := by
rw [hecount]
omega
have hcountadd : count.val + 1 <= UScalar.max .Usize := by
omega
obtain ⟨d1, hd1⟩ : exists d1,
num.imp.dec2flt.decimal_seq.DecimalSeq.try_add_digit e digit =
ok d1 := by
unfold num.imp.dec2flt.decimal_seq.DecimalSeq.try_add_digit
by_cases hstore : e.num_digits.val < 768
· have hword : e.num_digits <
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def,
UScalar.lt_equiv] using hstore
simp only [hword, if_true]
obtain ⟨a, ha, _⟩ := Aeneas.Std.WP.spec_imp_exists
(Array.update_spec e.digits e.num_digits digit (by
simpa [Array.length] using hstore))
rw [ha]
obtain ⟨next, hnext, _⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec (x := e.num_digits) (y := 1#usize) (by
simpa using headd))
rw [hnext]
simp
· have hword : ¬ e.num_digits <
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def,
UScalar.lt_equiv] using hstore
simp only [hword, if_false]
obtain ⟨next, hnext, _⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec (x := e.num_digits) (y := 1#usize) (by
simpa using headd))
rw [hnext]
simp
rw [hd1]
obtain ⟨he'count, he'point, he'trunc, he'arr⟩ :=
DecimalSeqPrimitiveSemantics.2.2.2 e d1 digit hd1
obtain ⟨count', hcount', hcount'val⟩ :=
Aeneas.Std.WP.spec_imp_exists
(UScalar.add_spec (x := count) (y := 1#usize) (by
simpa using hcountadd))
rw [hcount']
change count'.val = count.val + 1 at hcount'val
refine ⟨?_, ?_⟩
· simp only [Inv, Prod.fst, Prod.snd]
refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩
· omega
· omega
· exact he'point.trans hepoint
· exact he'trunc.trans hetrunc
· intro j hj
by_cases hstore : e.num_digits.val < 768
· simp [hstore] at he'arr
rw [he'arr]
simp only [Aeneas.Std.Array.set, List.getElem?_set]
split
· rename_i heq
have : j = e.num_digits.val := by omega
omega
· exact heold j hj
· simp [hstore] at he'arr
rw [he'arr]
exact heold j hj
· intro j hjlo hjhi
by_cases hjnew : j = e.num_digits.val
· subst j
have hstore : e.num_digits.val < 768 := by omega
simp [hstore] at he'arr
rw [he'arr]
simp only [Aeneas.Std.Array.set, List.getElem?_set]
have hidx : e.num_digits.val - d.num_digits.val = count.val := by
omega
rw [hidx, List.getElem?_eq_getElem hk]
simp [hstore, hdigitval]
· have hjprev : j < min (d.num_digits.val + count.val) 768 := by
omega
have hprev := hewritten j hjlo hjprev
by_cases hstore : e.num_digits.val < 768
· simp [hstore] at he'arr
rw [he'arr]
simp only [Aeneas.Std.Array.set, List.getElem?_set]
have hne : e.num_digits.val ≠ j := Ne.symm hjnew
simp [hne, hprev]
· simp [hstore] at he'arr
rw [he'arr]
exact hprev
· intro j hjlo hj768
have hjne : j ≠ e.num_digits.val := by omega
by_cases hstore : e.num_digits.val < 768
· simp [hstore] at he'arr
rw [he'arr]
simp only [Aeneas.Std.Array.set, List.getElem?_set]
have hne : e.num_digits.val ≠ j := Ne.symm hjne
simp [hne]
exact heoutside j (by omega) hj768
· simp [hstore] at he'arr
rw [he'arr]
exact heoutside j (by omega) hj768
· simp only [Prod.fst, Prod.snd]
omega
· have hkEq : count.val = digits.length := by omega
have hlen := congrArg List.length hs
simp at hlen
by_cases htail : tail = []
· have hsend : count.val = s.val.length := by
rw [htail] at hlen
simp at hlen
omega
simp [hsend, WP.spec_ok]
exact ⟨hkEq, hcount, hecount, hepoint, hetrunc,
heold, hewritten, heoutside⟩
· have hlt : count.val < s.val.length := by
rw [hkEq]
have htlen : tail.length ≠ 0 := by simpa using htail
have : 0 < tail.length := by omega
omega
simp [Slice.length, hlt]
step
have hi1tail : i1.val = tail[0] := by
have hm := congrArg List.head?
(congrArg (List.drop count.val) hs)
simp [hkEq, List.map_drop] at hm
have htlen : tail.length ≠ 0 := by simpa using htail
have htpos : 0 < tail.length := by omega
have htailHead : tail.head? = some tail[0] := by
rw [List.head?_eq_getElem?, List.getElem?_eq_getElem htpos]
rw [← hkEq, List.getElem?_eq_getElem hlt, htailHead] at hm
simp only [Option.map_some, Option.some.injEq] at hm
rw [i1_post]
exact hm
step
have hi2nondigit : ¬ i2.val < 10 := by
rw [i2_post, core.num.U8.wrapping_sub_val_eq, hi1tail]
have htlen : tail.length ≠ 0 := by simpa using htail
have htpos : 0 < tail.length := by omega
rcases hstop with hnil | hpoint | he | hE
· contradiction
· rw [List.getElem?_eq_getElem htpos] at hpoint
simp only [Option.some.injEq] at hpoint
rw [hpoint]
norm_num [U8.size_eq]
· rw [List.getElem?_eq_getElem htpos] at he
simp only [Option.some.injEq] at he
rw [he]
norm_num [U8.size_eq]
· rw [List.getElem?_eq_getElem htpos] at hE
simp only [Option.some.injEq] at hE
rw [hE]
norm_num [U8.size_eq]
simp [hi2nondigit, WP.spec_ok]
exact ⟨hkEq, hcount, hecount, hepoint, hetrunc,
heold, hewritten, heoutside⟩
· simp [Inv]
intro j hjlo hjhi hj768
omega
obtain ⟨p, hp, hpPost⟩ := Aeneas.Std.WP.spec_imp_exists hloop
rcases p with ⟨d', count⟩
rcases hpPost with ⟨hcountEq, _, hd'count, hd'point, hd'trunc,
hd'old, hd'written, hd'outside⟩
simp only [Prod.fst, Prod.snd] at hcountEq hd'count hd'point hd'trunc hd'old hd'written hd'outside
unfold num.imp.dec2flt.decimal_seq.parse_digits_into_seq
rw [hp]
have hcountLe : count.val <= s.val.length := by
have hlen := congrArg List.length hs
simp at hlen
omega
simp [core.slice.index.SliceIndexRangeFromUsizeSlice.index,
Slice.drop, Slice.length, hcountLe]
refine ⟨?_, ?_, hd'point, hd'trunc, ?_, ?_, ?_⟩
· rw [hs, hcountEq]
simp
· omega
· intro j hjlo hj768
apply hd'old j
omega
· intro j hjlo hjhi hj768
apply hd'written j hjlo
omega
· intro j hjlo hj768
apply hd'outside j
· rcases hjlo with hjlo | hjlo
· omega
· omega
· exact hj768
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Used by
Inspect related source (51)
- parse_digits_into_seq · dec2flt/decimal_seq.rs:256 Program Rust
- parse_digits_into_seq_loop · dec2flt/decimal_seq.rs:258 Program Rust
- body · dec2flt/decimal_seq.rs:258 Program Rust
More program dependencies (18)
- DecimalSeq · dec2flt/decimal_seq.rs:21 Program Rust
- default · dec2flt/decimal_seq.rs:33 Program Rust
- MAX_DIGITS · dec2flt/decimal_seq.rs:63 Program Rust
- MAX_DIGITS_WITHOUT_OVERFLOW · dec2flt/decimal_seq.rs:66 Program Rust
- try_add_digit · dec2flt/decimal_seq.rs:73 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:52 Program Rust
- ByteSlice · dec2flt/common.rs:4 Program Rust
- Decimal · dec2flt/decimal.rs:32 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.configured_x86_64_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
- DecimalSeqPrimitiveSemantics
- DecimalSeqScalarScanExact
- num imp dec2flt decimal seq DecimalSeq
- 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
All 8 entries
- DecimalSeqPrimitiveSemantics
- DecimalSeqScalarScanExact
- num imp dec2flt decimal seq DecimalSeq
- 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 parse digits into seq
Technical checking records
Local closure summary
{
"node": "DecimalSeqScalarScanExact",
"closure_version": "patch_c_v1",
"active_decl_hash": "03a999f335834bcb695d0977846acbf0c66f57a17ed0cac74f566b88bc098d7a",
"active_statement_hash": "edd2eaf79149b722edb9bd69bdf3a65c68fa60a49c57d32940f294a368eca799",
"kernel_axioms": [
"Classical.choice",
"Quot.sound",
"propext"
],
"toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
"lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
"checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
"approved_axioms_hash": "ab64d13f256386ee0e494a5abcc6a5db49512cf3d90bbdfcabd6327793a31f95",
"axcheck_status": "Agreed",
"accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-167",
"boundary_theorems": {},
"strict_theorem_deps": {
"DecimalSeqPrimitiveSemantics": "d1871c68600bfbcd",
"num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS": "0eb6fb2627d0ff5c",
"num_imp_dec2flt_decimal_seq_DecimalSeq_try_add_digit": "0eb6fb2627d0ff5c",
"num_imp_dec2flt_decimal_seq_parse_digits_into_seq": "faf0081b4c91301b"
},
"strict_definition_deps": {
"num_imp_dec2flt_decimal_seq_DecimalSeq": "6799fe6525ddb761",
"num_imp_dec2flt_decimal_seq_DecimalSeq_Insts_CoreDefaultDefault_default": "7b9921904495bc2a",
"num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS": "39f6cb231ef80388",
"num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS_WITHOUT_OVERFLOW": "65634ac95536dcca",
"num_imp_dec2flt_decimal_seq_DecimalSeq_try_add_digit": "69a4869a11307175",
"num_imp_dec2flt_decimal_seq_parse_digits_into_seq": "8b2cc3a350f40ce1"
}
}Prose assessment
{
"label": "Lean proof closed; predictive prose review no longer required",
"assessment_status": null,
"fingerprint_relation": "unknown",
"assessment_fingerprint": null,
"current_fingerprint": "sound-v2:2fd02c19bcbd5096238f3b303c4a34cfc3dbd7d23dd76c9d09a8ab8def59d3d3",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"substantiveness_status": "Pass"
}