Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Lemma · Forward on-normal lexical certificate from significand runs
Lean statement
Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.
import Tablet.P835_T1_PartialContinuationA
import Tablet.P835_T1_FinishOnNormalA
import Tablet.P835_T1_DecodedRuns
import Tablet.P367_T1_NumberHelperScientificScan
import Tablet.ModelOptionBranch
import Tablet.ModelOptionFromResidual
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P835_T1_PartialRunForwardA]
theorem P835_T1_PartialRunForwardA
(s : Slice Std.U8) (integer fraction tail : List Std.U8) (point : Bool)
(hne : s.val ≠ []) (hlen : s.val.length <= 3458764513820540928)
(hshape : s.val = integer ++ (if point then 46#u8 :: (fraction ++ tail) else tail))
(hnoFraction : point = false -> fraction = [])
(hd : forall b, b ∈ integer -> 48 <= b.val /\ b.val <= 57)
(hf : forall b, b ∈ fraction -> 48 <= b.val /\ b.val <= 57)
(ht : forall b rest, tail = b :: rest -> ¬ (48 <= b.val /\ b.val <= 57))
(hnoPoint : point = false -> forall b rest, tail = b :: rest -> b ≠ 46#u8)
(result : Option (num.imp.dec2flt.decimal.Decimal × Std.Usize))
(hnormal : num.imp.dec2flt.parse.parse_partial_number s = ok result) :
forall d consumed, result = some (d, consumed) ->
exists (x : DecimalLexeme) (r : List Std.U8),
x.leadingSign = none /\ DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ++ r.map (fun b => b.val) /\
(forall b rest, r = b :: rest -> ¬ (48 <= b.val /\ b.val <= 57)) /\
(x.exponent = none -> forall b rest, r = b :: rest ->
b ≠ 69#u8 /\ b ≠ 101#u8 /\
(x.fractionDigits = none -> b ≠ 46#u8)) /\
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 None and
ok Some. Thus n\ne0, and its nonnegative count value
makes |I|+|F|>0. The continuation after splitting t equals
the given ok Some.Lean proof
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
intro d consumed hres
have htne : total ≠ 0#isize := by
intro hz
rw [hparser, hz] at hnormal
simp [hres] at hnormal
have hpos : 0 < integer.length + fraction.length := by
have hvalNe : total.val ≠ 0 := by
intro hz
apply htne
apply IScalar.eq_of_val_eq
simpa using hz
rw [htotal] at hvalNe
omega
have hafterNormal : afterSignificand = ok (some (d, consumed)) := by
rw [hparser] at hnormal
simpa [htne, hres] using hnormal
have emit : forall (exponent explicit : Std.I64) (rest : Slice Std.U8)
(exps : Option (Bool × Option Bool × List Std.U8)) (r : List Std.U8),
(forall upper sign digits, exps = some (upper, sign, digits) ->
digits ≠ [] /\ forall b, b ∈ digits -> 48 <= b.val /\ b.val <= 57) ->
s.val = (integer ++ (if point then 46#u8 :: fraction else []) ++
(match (generalizing := false) exps with
| none => []
| some (upper, sign, digits) => (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)) ++ rest.val ->
rest.val = r ->
(forall b bs, r = b :: bs -> ¬ (48 <= b.val /\ b.val <= 57)) ->
(exps = none -> forall b bs, r = b :: bs ->
b ≠ 69#u8 /\ b ≠ 101#u8 /\ (point = false -> b ≠ 46#u8)) ->
finish exponent explicit rest = ok (some (d, consumed)) ->
exists (x : DecimalLexeme) (r : List Std.U8),
x.leadingSign = none /\ DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ++ r.map (fun b => b.val) /\
(forall b bs, r = b :: bs -> ¬ (48 <= b.val /\ b.val <= 57)) /\
(x.exponent = none -> forall b bs, r = b :: bs ->
b ≠ 69#u8 /\ b ≠ 101#u8 /\ (x.fractionDigits = none -> b ≠ 46#u8)) /\
consumed.val = (DecimalGoalVocabularyDefault.renderNumeric x).length := by
intro exponent explicit rest exps r he hp hr hrt hguards hfinish
obtain ⟨x, hsign, hvalid, hfrac, hexp, hrender⟩ :=
P835_T1_DecodedRuns integer fraction point exps hnoFraction hd hf hpos he
obtain ⟨d', k, hresult, hk⟩ :=
P835_T1_FinishOnNormalA s intEnd rest _ word total exponent explicit
(some (d, consumed)) hlen hp hfinish
have hc : consumed = k := congrArg Prod.snd (Option.some.inj hresult)
refine ⟨x, r, hsign, hvalid, ?_, hrt, ?_, ?_⟩
· change s.val.map (fun b => b.val) = _
rw [hp, List.map_append, hr, hrender]
cases exps with
| none => rfl
| some p =>
rcases p with ⟨u, sg, ds⟩
cases sg <;> rfl
· intro hx b bs hb
have hg := hguards (hexp.mp hx) b bs hb
exact ⟨hg.1, hg.2.1, fun h => hg.2.2 (hfrac.mp h)⟩
· have hl := congrArg List.length hrender
simp only [List.length_map] at hl
rw [hc, hk, hl]
cases exps with
| none => rfl
| some p =>
rcases p with ⟨u, sg, ds⟩
cases sg <;> rfl
have noExponent : forall
(hm : forall b bs, tail = b :: bs -> b ≠ 69#u8 /\ b ≠ 101#u8),
finish base 0#i64 sigEnd = ok (some (d, consumed)) ->
exists (x : DecimalLexeme) (r : List Std.U8),
x.leadingSign = none /\ DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ++ r.map (fun b => b.val) /\
(forall b bs, r = b :: bs -> ¬ (48 <= b.val /\ b.val <= 57)) /\
(x.exponent = none -> forall b bs, r = b :: bs ->
b ≠ 69#u8 /\ b ≠ 101#u8 /\ (x.fractionDigits = none -> b ≠ 46#u8)) /\
consumed.val = (DecimalGoalVocabularyDefault.renderNumeric x).length := by
intro hm hfinish
apply emit base 0#i64 sigEnd none tail (by simp)
· rw [hshape, hsigEnd]
cases point <;> simp [List.append_assoc]
· exact hsigEnd
· exact ht
· intro _ b bs hb
exact ⟨(hm b bs hb).1, (hm b bs hb).2, fun hp => hnoPoint hp b bs hb⟩
· exact hfinish
cases htval : tail with
| nil =>
have hsplit : core.slice.Slice.split_first sigEnd = ok none := by
have he : sigEnd = (⟨[], by simp⟩ : Slice Std.U8) :=
(Slice.eq_iff _ _).2 (hsigEnd.trans htval)
rw [he]
rfl
apply noExponent (by simp [htval])
simpa [afterSignificand, hsplit] using hafterNormal
| cons b bs =>
let next : Slice Std.U8 := ⟨bs, by
have hp := sigEnd.property
rw [hsigEnd, htval] at hp
simp only [List.length_cons] at hp
omega⟩
have hsplit : core.slice.Slice.split_first sigEnd = ok (some (b, next)) := by
have he : sigEnd = (⟨b :: bs, by
rw [← htval, ← hsigEnd]
exact sigEnd.property⟩ : Slice Std.U8) :=
(Slice.eq_iff _ _).2 (hsigEnd.trans htval)
rw [he]
rfl
by_cases hm : b = 101#u8 ∨ b = 69#u8
· have hscient : scientific next = ok (some (d, consumed)) := by
rcases hm with hlow | hup
· simpa [afterSignificand, hsplit, hlow] using hafterNormal
· simpa [afterSignificand, hsplit, hup] using hafterNormal
obtain ⟨sign, digits, residual, value, rest, hbytesSci,
hdigits, hresidual, hparse, hrest, hnone, hvalue⟩ :=
P367_T1_NumberHelperScientificScan next
cases hv : value with
| none =>
simp [scientific, hparse, hv,
core.option.Option.Insts.CoreOpsTry_traitTry.branch,
ModelOptionBranch, ModelOptionFromResidual,
core.option.Option.Insts.CoreOpsTry_traitFromResidualOptionInfallible.from_residual] at hscient
| some explicit =>
have hdigitsNe : digits ≠ [] := by
intro he
have hnone' := hnone.mpr he
simp [hv] at hnone'
cases haddExp : base + explicit with
| fail err =>
simp [scientific, hparse, hv,
core.option.Option.Insts.CoreOpsTry_traitTry.branch,
ModelOptionBranch, haddExp] at hscient
| div =>
simp [scientific, hparse, hv,
core.option.Option.Insts.CoreOpsTry_traitTry.branch,
ModelOptionBranch, haddExp] at hscient
| ok exponent =>
have hfinish : finish exponent explicit rest = ok (some (d, consumed)) := by
simpa [scientific, hparse, hv,
core.option.Option.Insts.CoreOpsTry_traitTry.branch,
ModelOptionBranch, haddExp] using hscient
let upper : Bool := if b = 69#u8 then true else false
have hmarker : b = (if upper then 69#u8 else 101#u8) := by
rcases hm with hlow | hup
· simp [upper, hlow]
· simp [upper, hup]
apply emit exponent explicit rest (some (upper, sign, digits)) residual
· intro u sg ds heq
have hp := Option.some.inj heq
cases hp
exact ⟨hdigitsNe, hdigits⟩
· have hbs : bs =
(match (generalizing := false) sign with | none => [] | some neg => [if neg then 45#u8 else 43#u8]) ++
digits ++ residual := hbytesSci
rw [hshape, htval, hbs, hrest, hmarker]
cases point <;> simp [List.append_assoc]
· exact hrest
· exact hresidual
· simp
· exact hfinish
· have hlow : b ≠ 101#u8 := fun h => hm (Or.inl h)
have hup : b ≠ 69#u8 := fun h => hm (Or.inr h)
refine noExponent ?_ ?_
· intro c cs hc
have hh := htval.symm.trans hc
have heq : b = c := List.cons.inj hh |>.1
subst c
exact ⟨hup, hlow⟩
· simpa [afterSignificand, hsplit, hlow, hup] using hafterNormal
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.P835_T1_PartialContinuationA
import Tablet.P835_T1_FinishOnNormalA
import Tablet.P835_T1_DecodedRuns
import Tablet.P367_T1_NumberHelperScientificScan
import Tablet.ModelOptionBranch
import Tablet.ModelOptionFromResidual
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P835_T1_PartialRunForwardA]
theorem P835_T1_PartialRunForwardA
(s : Slice Std.U8) (integer fraction tail : List Std.U8) (point : Bool)
(hne : s.val ≠ []) (hlen : s.val.length <= 3458764513820540928)
(hshape : s.val = integer ++ (if point then 46#u8 :: (fraction ++ tail) else tail))
(hnoFraction : point = false -> fraction = [])
(hd : forall b, b ∈ integer -> 48 <= b.val /\ b.val <= 57)
(hf : forall b, b ∈ fraction -> 48 <= b.val /\ b.val <= 57)
(ht : forall b rest, tail = b :: rest -> ¬ (48 <= b.val /\ b.val <= 57))
(hnoPoint : point = false -> forall b rest, tail = b :: rest -> b ≠ 46#u8)
(result : Option (num.imp.dec2flt.decimal.Decimal × Std.Usize))
(hnormal : num.imp.dec2flt.parse.parse_partial_number s = ok result) :
forall d consumed, result = some (d, consumed) ->
exists (x : DecimalLexeme) (r : List Std.U8),
x.leadingSign = none /\ DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ++ r.map (fun b => b.val) /\
(forall b rest, r = b :: rest -> ¬ (48 <= b.val /\ b.val <= 57)) /\
(x.exponent = none -> forall b rest, r = b :: rest ->
b ≠ 69#u8 /\ b ≠ 101#u8 /\
(x.fractionDigits = none -> b ≠ 46#u8)) /\
consumed.val = (DecimalGoalVocabularyDefault.renderNumeric x).length := by
-- BODY
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
intro d consumed hres
have htne : total ≠ 0#isize := by
intro hz
rw [hparser, hz] at hnormal
simp [hres] at hnormal
have hpos : 0 < integer.length + fraction.length := by
have hvalNe : total.val ≠ 0 := by
intro hz
apply htne
apply IScalar.eq_of_val_eq
simpa using hz
rw [htotal] at hvalNe
omega
have hafterNormal : afterSignificand = ok (some (d, consumed)) := by
rw [hparser] at hnormal
simpa [htne, hres] using hnormal
have emit : forall (exponent explicit : Std.I64) (rest : Slice Std.U8)
(exps : Option (Bool × Option Bool × List Std.U8)) (r : List Std.U8),
(forall upper sign digits, exps = some (upper, sign, digits) ->
digits ≠ [] /\ forall b, b ∈ digits -> 48 <= b.val /\ b.val <= 57) ->
s.val = (integer ++ (if point then 46#u8 :: fraction else []) ++
(match (generalizing := false) exps with
| none => []
| some (upper, sign, digits) => (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)) ++ rest.val ->
rest.val = r ->
(forall b bs, r = b :: bs -> ¬ (48 <= b.val /\ b.val <= 57)) ->
(exps = none -> forall b bs, r = b :: bs ->
b ≠ 69#u8 /\ b ≠ 101#u8 /\ (point = false -> b ≠ 46#u8)) ->
finish exponent explicit rest = ok (some (d, consumed)) ->
exists (x : DecimalLexeme) (r : List Std.U8),
x.leadingSign = none /\ DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ++ r.map (fun b => b.val) /\
(forall b bs, r = b :: bs -> ¬ (48 <= b.val /\ b.val <= 57)) /\
(x.exponent = none -> forall b bs, r = b :: bs ->
b ≠ 69#u8 /\ b ≠ 101#u8 /\ (x.fractionDigits = none -> b ≠ 46#u8)) /\
consumed.val = (DecimalGoalVocabularyDefault.renderNumeric x).length := by
intro exponent explicit rest exps r he hp hr hrt hguards hfinish
obtain ⟨x, hsign, hvalid, hfrac, hexp, hrender⟩ :=
P835_T1_DecodedRuns integer fraction point exps hnoFraction hd hf hpos he
obtain ⟨d', k, hresult, hk⟩ :=
P835_T1_FinishOnNormalA s intEnd rest _ word total exponent explicit
(some (d, consumed)) hlen hp hfinish
have hc : consumed = k := congrArg Prod.snd (Option.some.inj hresult)
refine ⟨x, r, hsign, hvalid, ?_, hrt, ?_, ?_⟩
· change s.val.map (fun b => b.val) = _
rw [hp, List.map_append, hr, hrender]
cases exps with
| none => rfl
| some p =>
rcases p with ⟨u, sg, ds⟩
cases sg <;> rfl
· intro hx b bs hb
have hg := hguards (hexp.mp hx) b bs hb
exact ⟨hg.1, hg.2.1, fun h => hg.2.2 (hfrac.mp h)⟩
· have hl := congrArg List.length hrender
simp only [List.length_map] at hl
rw [hc, hk, hl]
cases exps with
| none => rfl
| some p =>
rcases p with ⟨u, sg, ds⟩
cases sg <;> rfl
have noExponent : forall
(hm : forall b bs, tail = b :: bs -> b ≠ 69#u8 /\ b ≠ 101#u8),
finish base 0#i64 sigEnd = ok (some (d, consumed)) ->
exists (x : DecimalLexeme) (r : List Std.U8),
x.leadingSign = none /\ DecimalGoalVocabularyDefault.validNumeric x /\
DecimalGoalVocabularyDefault.bytes s =
DecimalGoalVocabularyDefault.renderNumeric x ++ r.map (fun b => b.val) /\
(forall b bs, r = b :: bs -> ¬ (48 <= b.val /\ b.val <= 57)) /\
(x.exponent = none -> forall b bs, r = b :: bs ->
b ≠ 69#u8 /\ b ≠ 101#u8 /\ (x.fractionDigits = none -> b ≠ 46#u8)) /\
consumed.val = (DecimalGoalVocabularyDefault.renderNumeric x).length := by
intro hm hfinish
apply emit base 0#i64 sigEnd none tail (by simp)
· rw [hshape, hsigEnd]
cases point <;> simp [List.append_assoc]
· exact hsigEnd
· exact ht
· intro _ b bs hb
exact ⟨(hm b bs hb).1, (hm b bs hb).2, fun hp => hnoPoint hp b bs hb⟩
· exact hfinish
cases htval : tail with
| nil =>
have hsplit : core.slice.Slice.split_first sigEnd = ok none := by
have he : sigEnd = (⟨[], by simp⟩ : Slice Std.U8) :=
(Slice.eq_iff _ _).2 (hsigEnd.trans htval)
rw [he]
rfl
apply noExponent (by simp [htval])
simpa [afterSignificand, hsplit] using hafterNormal
| cons b bs =>
let next : Slice Std.U8 := ⟨bs, by
have hp := sigEnd.property
rw [hsigEnd, htval] at hp
simp only [List.length_cons] at hp
omega⟩
have hsplit : core.slice.Slice.split_first sigEnd = ok (some (b, next)) := by
have he : sigEnd = (⟨b :: bs, by
rw [← htval, ← hsigEnd]
exact sigEnd.property⟩ : Slice Std.U8) :=
(Slice.eq_iff _ _).2 (hsigEnd.trans htval)
rw [he]
rfl
by_cases hm : b = 101#u8 ∨ b = 69#u8
· have hscient : scientific next = ok (some (d, consumed)) := by
rcases hm with hlow | hup
· simpa [afterSignificand, hsplit, hlow] using hafterNormal
· simpa [afterSignificand, hsplit, hup] using hafterNormal
obtain ⟨sign, digits, residual, value, rest, hbytesSci,
hdigits, hresidual, hparse, hrest, hnone, hvalue⟩ :=
P367_T1_NumberHelperScientificScan next
cases hv : value with
| none =>
simp [scientific, hparse, hv,
core.option.Option.Insts.CoreOpsTry_traitTry.branch,
ModelOptionBranch, ModelOptionFromResidual,
core.option.Option.Insts.CoreOpsTry_traitFromResidualOptionInfallible.from_residual] at hscient
| some explicit =>
have hdigitsNe : digits ≠ [] := by
intro he
have hnone' := hnone.mpr he
simp [hv] at hnone'
cases haddExp : base + explicit with
| fail err =>
simp [scientific, hparse, hv,
core.option.Option.Insts.CoreOpsTry_traitTry.branch,
ModelOptionBranch, haddExp] at hscient
| div =>
simp [scientific, hparse, hv,
core.option.Option.Insts.CoreOpsTry_traitTry.branch,
ModelOptionBranch, haddExp] at hscient
| ok exponent =>
have hfinish : finish exponent explicit rest = ok (some (d, consumed)) := by
simpa [scientific, hparse, hv,
core.option.Option.Insts.CoreOpsTry_traitTry.branch,
ModelOptionBranch, haddExp] using hscient
let upper : Bool := if b = 69#u8 then true else false
have hmarker : b = (if upper then 69#u8 else 101#u8) := by
rcases hm with hlow | hup
· simp [upper, hlow]
· simp [upper, hup]
apply emit exponent explicit rest (some (upper, sign, digits)) residual
· intro u sg ds heq
have hp := Option.some.inj heq
cases hp
exact ⟨hdigitsNe, hdigits⟩
· have hbs : bs =
(match (generalizing := false) sign with | none => [] | some neg => [if neg then 45#u8 else 43#u8]) ++
digits ++ residual := hbytesSci
rw [hshape, htval, hbs, hrest, hmarker]
cases point <;> simp [List.append_assoc]
· exact hrest
· exact hresidual
· simp
· exact hfinish
· have hlow : b ≠ 101#u8 := fun h => hm (Or.inl h)
have hup : b ≠ 69#u8 := fun h => hm (Or.inr h)
refine noExponent ?_ ?_
· intro c cs hc
have hh := htval.symm.trans hc
have heq : b = c := List.cons.inj hh |>.1
subst c
exact ⟨hup, hlow⟩
· simpa [afterSignificand, hsplit, hlow, hup] using hafterNormal
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
- offset_from · dec2flt/common.rs:34 Program Rust
- Decimal · dec2flt/decimal.rs:32 Program Rust
More program dependencies (35)
- 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
- parse_scientific · dec2flt/parse.rs:121 Program Rust
- parse_scientific_loop · dec2flt/parse.rs:145 Program Rust
- body · dec2flt/parse.rs:145 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
- from_u64 · dec2flt/mod.rs:263 Program Rust
- read_u64 · dec2flt/common.rs:22 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
- is_8digits · dec2flt/common.rs:44 Program Rust
- DecimalSeq · dec2flt/decimal_seq.rs:22 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
- CastInto · traits.rs:18 Program Rust
- Float · traits.rs:74 Program Rust
- FloatExt · traits.rs:170 Program Rust
- Int · traits.rs:27 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)
- from_residual · core/src/option.rs:2793 Rust library
- 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
- 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 66 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
- NumberHelperScientificClassificationSourceLength
- NumberHelperScientificPrefixSafeLength
- NumberHelperDigitPrefix
- NumberHelperOffsetSourceLength
- NumberHelperScientificScan
- DigitDecoding
- SignificandScanA
- DecodedRuns
- FinishOnNormalA
- PartialContinuationA
- PartialRunForwardA
- ScientificLoopFold
- ScientificScannerFold
- ScientificVocabularyFold
- 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_PartialRunForwardA",
"closure_version": "patch_c_v1",
"active_decl_hash": "f548ce55978a65e570f55a46fc7a62732f0c9f6a595d8b53f0249f89d53d2f5e",
"active_statement_hash": "b2e94efcf48efb686380ffec457400b64cd6cee4fdf3ee7c517201c1aba15183",
"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": {
"P367_T1_NumberHelperScientificScan": "dd4ec9ae0f1aa797",
"P835_T1_DecodedRuns": "175be78737803884",
"P835_T1_FinishOnNormalA": "4f130f3375cbb311",
"P835_T1_PartialContinuationA": "d026c1de5ccb78ec"
},
"strict_definition_deps": {
"DecimalGoalVocabulary": "c08dd4b4aea4abb4",
"DecimalGoalVocabularyDefault": "71a18a6c119a3cdc",
"DecimalLexeme": "8ad754cf2c272e73",
"ModelOptionBranch": "2b227898dbe15e59",
"ModelOptionFromResidual": "99bee9493878565f",
"P367_T1_NumberHelperScientificScan": "28ca0a8ac503ee01",
"P835_T1_DecodedRuns": "8b6f991187c4d1e3",
"P835_T1_PartialContinuationA": "a4e982c388531a6e",
"Preamble": "4adf4172ae751d7d",
"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:71fc37364e5d6f86a4f5e78a7471df34faee851cf20e18c822c626ee4514f4ce",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"substantiveness_status": "Pass"
}