Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Lemma · Reverse on-normal lexical certificate
Lean statement
Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.
import Tablet.P435_T1_RenderedDigitBlocks
import Tablet.P435_T1_DigitPrefixUnique
import Tablet.P364_T1_NumberHelperDigitPrefix
import Tablet.P835_T1_PartialContinuationA
import Tablet.P835_T1_FinishOnNormalA
import Tablet.NumberHelperScientificPrefixSafeLength
import Tablet.ModelOptionBranch
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P835_T1_PartialRunReverseA]
theorem P835_T1_PartialRunReverseA
(s : Slice Std.U8) (hne : s.val ≠ [])
(hlen : s.val.length <= 3458764513820540928)
(result : Option (num.imp.dec2flt.decimal.Decimal × Std.Usize))
(hnormal : num.imp.dec2flt.parse.parse_partial_number s = ok result)
(x : DecimalLexeme) (r : List Std.U8)
(hsign : x.leadingSign = none)
(hvalid : DecimalGoalVocabularyDefault.validNumeric x)
(hrender : DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ++ r.map (fun b => b.val))
(hrt : forall b bs, r = b :: bs -> ¬ (48 <= b.val /\ b.val <= 57))
(hguards : x.exponent = none -> forall b bs, r = b :: bs ->
b ≠ 69#u8 /\ b ≠ 101#u8 /\ (x.fractionDigits = none -> b ≠ 46#u8)) :
exists d consumed, result = some (d, consumed) /\
consumed.val = (DecimalGoalVocabularyDefault.renderNumeric x).length := 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
ok(o).
Its successful case supplies e, leaving C(e,a,r)=\texttt{ok}(o).Lean proof
obtain ⟨integer, fraction, digits, hshape, him, hfm, hem, hd, hf, he⟩ :=
P435_T1_RenderedDigitBlocks s.val r x hsign hvalid hrender
let point := x.fractionDigits.isSome
let tail : List Std.U8 :=
(match (generalizing := false) x.exponent with
| none => []
| some (upper, sign, _) => (if upper then 69#u8 else 101#u8) ::
(match (generalizing := false) sign with
| none => [] | some neg => [if neg then 45#u8 else 43#u8]) ++ digits) ++ r
have hshape' : s.val =
integer ++ (if point then 46#u8 :: (fraction ++ tail) else tail) := by
rw [hshape]
cases hx : x.fractionDigits <;>
simp [point, tail, hx, List.append_assoc]
all_goals
cases x.exponent with
| none => rfl
| some p =>
rcases p with ⟨u, sg, ds⟩
cases sg <;> rfl
have hnoFraction : point = false -> fraction = [] := by
intro hp
cases hx : x.fractionDigits with
| none => simpa [hx] using hfm
| some ds => simp [point, hx] at hp
have ht : forall b bs, tail = b :: bs -> ¬ (48 <= b.val /\ b.val <= 57) := by
cases hx : x.exponent with
| none => simpa [tail, hx] using hrt
| some p =>
rcases p with ⟨upper, sign, ds⟩
intro b bs hb
have hhead : (if upper then 69#u8 else 101#u8) = b := by
simpa [tail, hx] using congrArg List.head? hb
rw [← hhead]
cases upper <;> norm_num
have hnoPoint : point = false -> forall b bs, tail = b :: bs -> b ≠ 46#u8 := by
intro hp b bs hb
cases hx : x.exponent with
| none =>
have hr : r = b :: bs := by simpa [tail, hx] using hb
have hfrac : x.fractionDigits = none := by
cases hf : x.fractionDigits <;> simp_all [point]
exact (hguards hx b bs hr).2.2 hfrac
| some p =>
rcases p with ⟨upper, sign, ds⟩
have hhead : (if upper then 69#u8 else 101#u8) = b := by
simpa [tail, hx] using congrArg List.head? hb
rw [← hhead]
cases upper <;> decide
have hpos : 0 < integer.length + fraction.length := by
have hiLen := congrArg List.length him
have hfLen := congrArg List.length hfm
simp only [List.length_map] at hiLen hfLen
have hv := hvalid
change _ ∧ _ ∧ _ ∧ _ at hv
rcases hv.2.2.1 with hi | hfr
· have hnonzero := List.length_pos_iff.mpr hi
omega
· cases hx : x.fractionDigits with
| none => simp [hx] at hfr
| some ds =>
have hnonzero : 0 < ds.length := List.length_pos_iff.mpr (by simpa [hx] using hfr)
simp only [hx] at hfLen
omega
have htailInteger : forall b bs,
(if point then 46#u8 :: (fraction ++ tail) else tail) = b :: bs ->
¬ (48 <= b.val /\ b.val <= 57) := by
cases point with
| false => exact ht
| true => intro b bs hb; cases hb; norm_num
obtain ⟨actualInteger, actualTail, hactual, haDigits, haTail⟩ :=
P364_T1_NumberHelperDigitPrefix s.val
have hunique := P435_T1_DigitPrefixUnique actualInteger actualTail integer
(if point then 46#u8 :: (fraction ++ tail) else tail)
(hactual.symm.trans hshape') haDigits haTail hd htailInteger
rcases hunique with ⟨hiUnique, htUnique⟩
subst actualInteger
subst actualTail
obtain ⟨actualFraction, actualFractionTail, hfActual, hfDigits, hfTail⟩ :=
P364_T1_NumberHelperDigitPrefix (fraction ++ tail)
have hfUnique := P435_T1_DigitPrefixUnique actualFraction actualFractionTail fraction tail
hfActual.symm hfDigits hfTail hf ht
rcases hfUnique with ⟨hfUnique, htUnique⟩
subst actualFraction
subst actualFractionTail
obtain ⟨intEnd, sigEnd, word, total, base, hsigEnd, htotal, hparser⟩ :=
P835_T1_PartialContinuationA s integer fraction tail point hne hlen
hshape' hnoFraction hd hf ht hnoPoint
let finish := fun (exponent explicit : Std.I64) (rest : Slice Std.U8) => do
let offset ← SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.offset_from rest s
let len ← lift (IScalar.hcast .Usize offset)
if total <= 19#isize then
ok (some (num.imp.dec2flt.decimal.Decimal.mk exponent word false false, len))
else
let more ← total - 19#isize
let adjusted ← num.imp.dec2flt.parse.adjust_many_digit_count s more
if adjusted > 0#isize then
let (manyWord, manyExp) ← num.imp.dec2flt.parse.parse_many_digits s intEnd explicit
ok (some (num.imp.dec2flt.decimal.Decimal.mk manyExp manyWord false true, len))
else
ok (some (num.imp.dec2flt.decimal.Decimal.mk exponent word false false, len))
let scientific := fun (next : Slice Std.U8) => do
let (value, rest) ← num.imp.dec2flt.parse.parse_scientific next
let cf ← core.option.Option.Insts.CoreOpsTry_traitTry.branch value
match cf with
| core.ops.control_flow.ControlFlow.Continue explicit => do
let exponent ← base + explicit
finish exponent explicit rest
| core.ops.control_flow.ControlFlow.Break residual =>
core.option.Option.Insts.CoreOpsTry_traitFromResidualOptionInfallible.from_residual
(num.imp.dec2flt.decimal.Decimal × Std.Usize) residual
let afterSignificand : Result (Option (num.imp.dec2flt.decimal.Decimal × Std.Usize)) := do
let o ← core.slice.Slice.split_first sigEnd
match o with
| none => finish base 0#i64 sigEnd
| some (c, next) =>
if c = 101#u8 then scientific next
else if c = 69#u8 then scientific next
else finish base 0#i64 sigEnd
change num.imp.dec2flt.parse.parse_partial_number s =
(if total = 0#isize then ok none else afterSignificand) at hparser
have htne : total ≠ 0#isize := by
intro hz
have hzero : total.val = 0 := by rw [hz]; simp
rw [htotal] at hzero
omega
have hafterNormal : afterSignificand = ok result := by
rw [hparser] at hnormal
simpa only [if_neg htne] using hnormal
have finishDone : forall (exponent explicit : Std.I64) (rest : Slice Std.U8)
(pref : List Std.U8), rest.val = r -> s.val = pref ++ rest.val ->
finish exponent explicit rest = ok result ->
exists d consumed, result = some (d, consumed) /\
consumed.val = (DecimalGoalVocabularyDefault.renderNumeric x).length := by
intro exponent explicit rest pref hr hp hn
obtain ⟨d, consumed, hres, hk⟩ :=
P835_T1_FinishOnNormalA s intEnd rest pref word total exponent explicit
result hlen hp hn
refine ⟨d, consumed, hres, ?_⟩
have hlength := congrArg List.length hrender
change (s.val.map (fun b => b.val)).length = _ at hlength
simp only [List.length_map, List.length_append] at hlength
have hlength' := congrArg List.length hp
simp only [List.length_append, hr] at hlength'
rw [hk]
omega
cases hx : x.exponent with
| none =>
have htail : tail = r := by simp [tail, hx]
have hfinish : finish base 0#i64 sigEnd = ok result := by
cases hr : r with
| nil =>
have hs : sigEnd = (⟨[], by simp⟩ : Slice Std.U8) :=
(Slice.eq_iff _ _).2 (by rw [hsigEnd, htail, hr])
have hsplit : core.slice.Slice.split_first sigEnd = ok none := by rw [hs]; rfl
simpa [afterSignificand, hsplit] using hafterNormal
| cons b bs =>
let next : Slice Std.U8 := ⟨bs, by
have hp := sigEnd.property
rw [hsigEnd, htail, hr] at hp
simp only [List.length_cons] at hp
omega⟩
have hs : sigEnd = (⟨b :: bs, by
rw [← hr, ← htail, ← hsigEnd]
exact sigEnd.property⟩ : Slice Std.U8) :=
(Slice.eq_iff _ _).2 (hsigEnd.trans (htail.trans hr))
have hsplit : core.slice.Slice.split_first sigEnd = ok (some (b, next)) := by
rw [hs]; rfl
have hg := hguards hx b bs hr
simpa [afterSignificand, hsplit, hg.1, hg.2.1] using hafterNormal
apply finishDone base 0#i64 sigEnd (integer ++ (if point then 46#u8 :: fraction else []))
· exact hsigEnd.trans htail
· rw [hshape', hsigEnd]
cases point <;> simp [List.append_assoc]
· exact hfinish
| some p =>
rcases p with ⟨upper, sign, ds⟩
let signBytes : List Std.U8 :=
match (generalizing := false) sign with
| none => [] | some neg => [if neg then 45#u8 else 43#u8]
let marker : Std.U8 := if upper then 69#u8 else 101#u8
have htail : tail = marker :: (signBytes ++ digits ++ r) := by
simp [tail, hx, marker, signBytes, List.append_assoc]
let next : Slice Std.U8 := ⟨signBytes ++ digits ++ r, by
have hp := sigEnd.property
rw [hsigEnd, htail] at hp
simp only [List.length_cons] at hp
omega⟩
have hs : sigEnd = (⟨marker :: next.val, by
change (marker :: (signBytes ++ digits ++ r)).length <= Usize.max
rw [← htail, ← hsigEnd]
exact sigEnd.property⟩ : Slice Std.U8) :=
(Slice.eq_iff _ _).2 (hsigEnd.trans htail)
have hsplit : core.slice.Slice.split_first sigEnd = ok (some (marker, next)) := by
rw [hs]; rfl
have hscient : scientific next = ok result := by
cases upper <;> simpa [afterSignificand, hsplit, marker] using hafterNormal
have hdigitsNe : digits ≠ [] := by
have hv := hvalid
change _ ∧ _ ∧ _ ∧ _ at hv
have hvexp : ds ≠ [] ∧ (forall d, d ∈ ds -> d < 10) := by
simpa only [hx] using hv.2.2.2
have hds := hvexp.1
have hm : digits.map (fun b => b.val) = ds.map (fun d => 48 + d) := by
simpa [hx] using hem
intro hz
simp [hz] at hm
exact hds hm
obtain ⟨explicit, rest, hparse, hrest, hlo, hhi, hshort, hpositive⟩ :=
NumberHelperScientificPrefixSafeLength next sign digits r
(by simpa only [bne_iff_ne] using hdigitsNe) he hrt rfl
cases haddExp : base + explicit with
| fail err =>
simp [scientific, hparse,
core.option.Option.Insts.CoreOpsTry_traitTry.branch, ModelOptionBranch, haddExp] at hscient
| div =>
simp [scientific, hparse,
core.option.Option.Insts.CoreOpsTry_traitTry.branch, ModelOptionBranch, haddExp] at hscient
| ok exponent =>
have hfinish : finish exponent explicit rest = ok result := by
simpa [scientific, hparse,
core.option.Option.Insts.CoreOpsTry_traitTry.branch, ModelOptionBranch, haddExp] using hscient
apply finishDone exponent explicit rest
(integer ++ (if point then 46#u8 :: fraction else []) ++ [marker] ++ signBytes ++ digits)
hrest
· rw [hshape', htail, hrest]
cases point <;> simp [List.append_assoc]
· exact hfinish
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.P435_T1_RenderedDigitBlocks
import Tablet.P435_T1_DigitPrefixUnique
import Tablet.P364_T1_NumberHelperDigitPrefix
import Tablet.P835_T1_PartialContinuationA
import Tablet.P835_T1_FinishOnNormalA
import Tablet.NumberHelperScientificPrefixSafeLength
import Tablet.ModelOptionBranch
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P835_T1_PartialRunReverseA]
theorem P835_T1_PartialRunReverseA
(s : Slice Std.U8) (hne : s.val ≠ [])
(hlen : s.val.length <= 3458764513820540928)
(result : Option (num.imp.dec2flt.decimal.Decimal × Std.Usize))
(hnormal : num.imp.dec2flt.parse.parse_partial_number s = ok result)
(x : DecimalLexeme) (r : List Std.U8)
(hsign : x.leadingSign = none)
(hvalid : DecimalGoalVocabularyDefault.validNumeric x)
(hrender : DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ++ r.map (fun b => b.val))
(hrt : forall b bs, r = b :: bs -> ¬ (48 <= b.val /\ b.val <= 57))
(hguards : x.exponent = none -> forall b bs, r = b :: bs ->
b ≠ 69#u8 /\ b ≠ 101#u8 /\ (x.fractionDigits = none -> b ≠ 46#u8)) :
exists d consumed, result = some (d, consumed) /\
consumed.val = (DecimalGoalVocabularyDefault.renderNumeric x).length := by
-- BODY
obtain ⟨integer, fraction, digits, hshape, him, hfm, hem, hd, hf, he⟩ :=
P435_T1_RenderedDigitBlocks s.val r x hsign hvalid hrender
let point := x.fractionDigits.isSome
let tail : List Std.U8 :=
(match (generalizing := false) x.exponent with
| none => []
| some (upper, sign, _) => (if upper then 69#u8 else 101#u8) ::
(match (generalizing := false) sign with
| none => [] | some neg => [if neg then 45#u8 else 43#u8]) ++ digits) ++ r
have hshape' : s.val =
integer ++ (if point then 46#u8 :: (fraction ++ tail) else tail) := by
rw [hshape]
cases hx : x.fractionDigits <;>
simp [point, tail, hx, List.append_assoc]
all_goals
cases x.exponent with
| none => rfl
| some p =>
rcases p with ⟨u, sg, ds⟩
cases sg <;> rfl
have hnoFraction : point = false -> fraction = [] := by
intro hp
cases hx : x.fractionDigits with
| none => simpa [hx] using hfm
| some ds => simp [point, hx] at hp
have ht : forall b bs, tail = b :: bs -> ¬ (48 <= b.val /\ b.val <= 57) := by
cases hx : x.exponent with
| none => simpa [tail, hx] using hrt
| some p =>
rcases p with ⟨upper, sign, ds⟩
intro b bs hb
have hhead : (if upper then 69#u8 else 101#u8) = b := by
simpa [tail, hx] using congrArg List.head? hb
rw [← hhead]
cases upper <;> norm_num
have hnoPoint : point = false -> forall b bs, tail = b :: bs -> b ≠ 46#u8 := by
intro hp b bs hb
cases hx : x.exponent with
| none =>
have hr : r = b :: bs := by simpa [tail, hx] using hb
have hfrac : x.fractionDigits = none := by
cases hf : x.fractionDigits <;> simp_all [point]
exact (hguards hx b bs hr).2.2 hfrac
| some p =>
rcases p with ⟨upper, sign, ds⟩
have hhead : (if upper then 69#u8 else 101#u8) = b := by
simpa [tail, hx] using congrArg List.head? hb
rw [← hhead]
cases upper <;> decide
have hpos : 0 < integer.length + fraction.length := by
have hiLen := congrArg List.length him
have hfLen := congrArg List.length hfm
simp only [List.length_map] at hiLen hfLen
have hv := hvalid
change _ ∧ _ ∧ _ ∧ _ at hv
rcases hv.2.2.1 with hi | hfr
· have hnonzero := List.length_pos_iff.mpr hi
omega
· cases hx : x.fractionDigits with
| none => simp [hx] at hfr
| some ds =>
have hnonzero : 0 < ds.length := List.length_pos_iff.mpr (by simpa [hx] using hfr)
simp only [hx] at hfLen
omega
have htailInteger : forall b bs,
(if point then 46#u8 :: (fraction ++ tail) else tail) = b :: bs ->
¬ (48 <= b.val /\ b.val <= 57) := by
cases point with
| false => exact ht
| true => intro b bs hb; cases hb; norm_num
obtain ⟨actualInteger, actualTail, hactual, haDigits, haTail⟩ :=
P364_T1_NumberHelperDigitPrefix s.val
have hunique := P435_T1_DigitPrefixUnique actualInteger actualTail integer
(if point then 46#u8 :: (fraction ++ tail) else tail)
(hactual.symm.trans hshape') haDigits haTail hd htailInteger
rcases hunique with ⟨hiUnique, htUnique⟩
subst actualInteger
subst actualTail
obtain ⟨actualFraction, actualFractionTail, hfActual, hfDigits, hfTail⟩ :=
P364_T1_NumberHelperDigitPrefix (fraction ++ tail)
have hfUnique := P435_T1_DigitPrefixUnique actualFraction actualFractionTail fraction tail
hfActual.symm hfDigits hfTail hf ht
rcases hfUnique with ⟨hfUnique, htUnique⟩
subst actualFraction
subst actualFractionTail
obtain ⟨intEnd, sigEnd, word, total, base, hsigEnd, htotal, hparser⟩ :=
P835_T1_PartialContinuationA s integer fraction tail point hne hlen
hshape' hnoFraction hd hf ht hnoPoint
let finish := fun (exponent explicit : Std.I64) (rest : Slice Std.U8) => do
let offset ← SliceU8.Insts.Dec2flt_modelNumImpDec2fltCommonByteSlice.offset_from rest s
let len ← lift (IScalar.hcast .Usize offset)
if total <= 19#isize then
ok (some (num.imp.dec2flt.decimal.Decimal.mk exponent word false false, len))
else
let more ← total - 19#isize
let adjusted ← num.imp.dec2flt.parse.adjust_many_digit_count s more
if adjusted > 0#isize then
let (manyWord, manyExp) ← num.imp.dec2flt.parse.parse_many_digits s intEnd explicit
ok (some (num.imp.dec2flt.decimal.Decimal.mk manyExp manyWord false true, len))
else
ok (some (num.imp.dec2flt.decimal.Decimal.mk exponent word false false, len))
let scientific := fun (next : Slice Std.U8) => do
let (value, rest) ← num.imp.dec2flt.parse.parse_scientific next
let cf ← core.option.Option.Insts.CoreOpsTry_traitTry.branch value
match cf with
| core.ops.control_flow.ControlFlow.Continue explicit => do
let exponent ← base + explicit
finish exponent explicit rest
| core.ops.control_flow.ControlFlow.Break residual =>
core.option.Option.Insts.CoreOpsTry_traitFromResidualOptionInfallible.from_residual
(num.imp.dec2flt.decimal.Decimal × Std.Usize) residual
let afterSignificand : Result (Option (num.imp.dec2flt.decimal.Decimal × Std.Usize)) := do
let o ← core.slice.Slice.split_first sigEnd
match o with
| none => finish base 0#i64 sigEnd
| some (c, next) =>
if c = 101#u8 then scientific next
else if c = 69#u8 then scientific next
else finish base 0#i64 sigEnd
change num.imp.dec2flt.parse.parse_partial_number s =
(if total = 0#isize then ok none else afterSignificand) at hparser
have htne : total ≠ 0#isize := by
intro hz
have hzero : total.val = 0 := by rw [hz]; simp
rw [htotal] at hzero
omega
have hafterNormal : afterSignificand = ok result := by
rw [hparser] at hnormal
simpa only [if_neg htne] using hnormal
have finishDone : forall (exponent explicit : Std.I64) (rest : Slice Std.U8)
(pref : List Std.U8), rest.val = r -> s.val = pref ++ rest.val ->
finish exponent explicit rest = ok result ->
exists d consumed, result = some (d, consumed) /\
consumed.val = (DecimalGoalVocabularyDefault.renderNumeric x).length := by
intro exponent explicit rest pref hr hp hn
obtain ⟨d, consumed, hres, hk⟩ :=
P835_T1_FinishOnNormalA s intEnd rest pref word total exponent explicit
result hlen hp hn
refine ⟨d, consumed, hres, ?_⟩
have hlength := congrArg List.length hrender
change (s.val.map (fun b => b.val)).length = _ at hlength
simp only [List.length_map, List.length_append] at hlength
have hlength' := congrArg List.length hp
simp only [List.length_append, hr] at hlength'
rw [hk]
omega
cases hx : x.exponent with
| none =>
have htail : tail = r := by simp [tail, hx]
have hfinish : finish base 0#i64 sigEnd = ok result := by
cases hr : r with
| nil =>
have hs : sigEnd = (⟨[], by simp⟩ : Slice Std.U8) :=
(Slice.eq_iff _ _).2 (by rw [hsigEnd, htail, hr])
have hsplit : core.slice.Slice.split_first sigEnd = ok none := by rw [hs]; rfl
simpa [afterSignificand, hsplit] using hafterNormal
| cons b bs =>
let next : Slice Std.U8 := ⟨bs, by
have hp := sigEnd.property
rw [hsigEnd, htail, hr] at hp
simp only [List.length_cons] at hp
omega⟩
have hs : sigEnd = (⟨b :: bs, by
rw [← hr, ← htail, ← hsigEnd]
exact sigEnd.property⟩ : Slice Std.U8) :=
(Slice.eq_iff _ _).2 (hsigEnd.trans (htail.trans hr))
have hsplit : core.slice.Slice.split_first sigEnd = ok (some (b, next)) := by
rw [hs]; rfl
have hg := hguards hx b bs hr
simpa [afterSignificand, hsplit, hg.1, hg.2.1] using hafterNormal
apply finishDone base 0#i64 sigEnd (integer ++ (if point then 46#u8 :: fraction else []))
· exact hsigEnd.trans htail
· rw [hshape', hsigEnd]
cases point <;> simp [List.append_assoc]
· exact hfinish
| some p =>
rcases p with ⟨upper, sign, ds⟩
let signBytes : List Std.U8 :=
match (generalizing := false) sign with
| none => [] | some neg => [if neg then 45#u8 else 43#u8]
let marker : Std.U8 := if upper then 69#u8 else 101#u8
have htail : tail = marker :: (signBytes ++ digits ++ r) := by
simp [tail, hx, marker, signBytes, List.append_assoc]
let next : Slice Std.U8 := ⟨signBytes ++ digits ++ r, by
have hp := sigEnd.property
rw [hsigEnd, htail] at hp
simp only [List.length_cons] at hp
omega⟩
have hs : sigEnd = (⟨marker :: next.val, by
change (marker :: (signBytes ++ digits ++ r)).length <= Usize.max
rw [← htail, ← hsigEnd]
exact sigEnd.property⟩ : Slice Std.U8) :=
(Slice.eq_iff _ _).2 (hsigEnd.trans htail)
have hsplit : core.slice.Slice.split_first sigEnd = ok (some (marker, next)) := by
rw [hs]; rfl
have hscient : scientific next = ok result := by
cases upper <;> simpa [afterSignificand, hsplit, marker] using hafterNormal
have hdigitsNe : digits ≠ [] := by
have hv := hvalid
change _ ∧ _ ∧ _ ∧ _ at hv
have hvexp : ds ≠ [] ∧ (forall d, d ∈ ds -> d < 10) := by
simpa only [hx] using hv.2.2.2
have hds := hvexp.1
have hm : digits.map (fun b => b.val) = ds.map (fun d => 48 + d) := by
simpa [hx] using hem
intro hz
simp [hz] at hm
exact hds hm
obtain ⟨explicit, rest, hparse, hrest, hlo, hhi, hshort, hpositive⟩ :=
NumberHelperScientificPrefixSafeLength next sign digits r
(by simpa only [bne_iff_ne] using hdigitsNe) he hrt rfl
cases haddExp : base + explicit with
| fail err =>
simp [scientific, hparse,
core.option.Option.Insts.CoreOpsTry_traitTry.branch, ModelOptionBranch, haddExp] at hscient
| div =>
simp [scientific, hparse,
core.option.Option.Insts.CoreOpsTry_traitTry.branch, ModelOptionBranch, haddExp] at hscient
| ok exponent =>
have hfinish : finish exponent explicit rest = ok result := by
simpa [scientific, hparse,
core.option.Option.Insts.CoreOpsTry_traitTry.branch, ModelOptionBranch, haddExp] using hscient
apply finishDone exponent explicit rest
(integer ++ (if point then 46#u8 :: fraction else []) ++ [marker] ++ signBytes ++ digits)
hrest
· rw [hshape', htail, hrest]
cases point <;> simp [List.append_assoc]
· exact hfinish
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Uses
Used by
Inspect related source (68)
- parse_partial_number · dec2flt/parse.rs:164 Program Rust
- parse_scientific · dec2flt/parse.rs:121 Program Rust
- parse_scientific_loop · dec2flt/parse.rs:145 Program Rust
More program dependencies (35)
- body · dec2flt/parse.rs:145 Program Rust
- from_u64 · dec2flt/mod.rs:263 Program Rust
- offset_from · dec2flt/common.rs:34 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
- DecimalSeq · dec2flt/decimal_seq.rs:22 Program Rust
- adjust_many_digit_count · dec2flt/parse.rs:86 Program Rust
- adjust_many_digit_count_loop · dec2flt/parse.rs:89 Program Rust
- body · dec2flt/parse.rs:89 Program Rust
- parse_many_digits · dec2flt/parse.rs:104 Program Rust
- try_parse_digits · dec2flt/parse.rs:30 Program Rust
- try_parse_digits_loop0 · dec2flt/parse.rs:33 Program Rust
- body · dec2flt/parse.rs:33 Program Rust
- try_parse_digits_loop1 · dec2flt/parse.rs:50 Program Rust
- body · dec2flt/parse.rs:50 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
- read_u64 · dec2flt/common.rs:22 Program Rust
- is_8digits · dec2flt/common.rs:44 Program Rust
- MIN_19DIGIT_INT · dec2flt/parse.rs:8 Program Rust
- parse_8digits · dec2flt/parse.rs:18 Program Rust
- try_parse_19digits · dec2flt/parse.rs:61 Program Rust
- try_parse_19digits_loop · dec2flt/parse.rs:64 Program Rust
- body · dec2flt/parse.rs:64 Program Rust
- MASK · dec2flt/parse.rs:19 Program Rust
- MUL1 · dec2flt/parse.rs:20 Program Rust
- MUL2 · dec2flt/parse.rs:21 Program Rust
Standard-library dependencies (30)
- branch · core/src/option.rs:2779 Rust library
- is_ascii_digit · core/src/num/mod.rs:958 Rust library
- split_first · core/src/slice/mod.rs:198 Rust library
- 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
- from_residual · core/src/option.rs:2793 Rust library
- first · core/src/slice/mod.rs:155 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
All 63 entries
- Binary64Model
- Binary64ModelDefault
- DecimalGoalVocabulary
- DecimalGoalVocabularyDefault
- DecimalLexeme
- 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
- NumberHelperDigitScanSourceLength
- NumberHelperEightDigitWord
- NumberHelperParseEightDigitsSafe
- NumberHelperReadEightBytes
- NumberHelperScientificPrefixSafeLength
- NumberHelperSplitExponentSuffix
- NumberHelperDigitPrefix
- NumberHelperOffsetSourceLength
- ByteValueBlocks
- DigitPrefixUnique
- RenderedDigitBlocks
- SignificandScanA
- FinishOnNormalA
- PartialContinuationA
- PartialRunReverseA
- Preamble
- SliceU8 Insts Dec2flt modelNumImpDec2fltCommonByteSlice offset from
- SliceU8 Insts Dec2flt modelNumImpDec2fltCommonByteSlice read u64
- core num FpCategory
- num imp dec2flt common BiasedFp
- num imp dec2flt common is 8digits
- num imp dec2flt decimal Decimal
- num imp dec2flt parse MIN 19DIGIT INT
- num imp dec2flt parse adjust many digit count
- num imp dec2flt parse parse 8digits
- num imp dec2flt parse parse 8digits MASK
- num imp dec2flt parse parse 8digits MUL1
- num imp dec2flt parse parse 8digits MUL2
- num imp dec2flt parse parse many digits
- num imp dec2flt parse parse partial number
- num imp dec2flt parse parse scientific
- num imp dec2flt parse try parse 19digits
- num imp dec2flt parse try parse digits
Technical checking records
Local closure summary
{
"node": "P835_T1_PartialRunReverseA",
"closure_version": "patch_c_v1",
"active_decl_hash": "85aec53da9febde64e330af4899d6dcbc22bcf95f8ca781241a98610f95a08fc",
"active_statement_hash": "07f5edc8d16bb3dfb2146b3ba3eeba719ebc8554e8b4dee9098a24ad44f9e1a1",
"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-194",
"boundary_theorems": {},
"strict_theorem_deps": {
"NumberHelperScientificPrefixSafeLength": "2081afb9bfe32845",
"P364_T1_NumberHelperDigitPrefix": "3426b4efc0d98c81",
"P435_T1_DigitPrefixUnique": "1a8f5be111c56ca1",
"P435_T1_RenderedDigitBlocks": "53c602364b85e70c",
"P835_T1_FinishOnNormalA": "4f130f3375cbb311",
"P835_T1_PartialContinuationA": "d026c1de5ccb78ec"
},
"strict_definition_deps": {
"DecimalGoalVocabulary": "c08dd4b4aea4abb4",
"DecimalGoalVocabularyDefault": "55eb6bce0e8a4131",
"DecimalLexeme": "8ad754cf2c272e73",
"ModelOptionBranch": "c55e273482c8c0a1",
"P435_T1_RenderedDigitBlocks": "3016c00221d29252",
"P835_T1_PartialContinuationA": "5712e484f99eb7aa",
"Preamble": "965f15fc36f80938",
"SliceU8_Insts_Dec2flt_modelNumImpDec2fltCommonByteSlice_offset_from": "7e7284dc9bc88830",
"num_imp_dec2flt_decimal_Decimal": "4da4ccbe640ef8e6",
"num_imp_dec2flt_parse_adjust_many_digit_count": "4e59e3776b6cfdaa",
"num_imp_dec2flt_parse_parse_many_digits": "50c9ef13b3ed7fe8",
"num_imp_dec2flt_parse_parse_partial_number": "94ed7b2ff71604ef",
"num_imp_dec2flt_parse_parse_scientific": "447f722d5841d2c5"
}
}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:053785d7eb9a5398898de1e41df96520f9b0ba244d11f861cb16b80b01a655df",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"substantiveness_status": "Pass"
}