Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Helper · Quantitative step of slow normalization loop one
Lean statement
Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.
import Tablet.DecimalLeftShiftLoop1Execution
import Tablet.DecimalSeqLeftShiftCanonical
import Tablet.P804_T1_LeftLeadingProgress
import Tablet.P804_T1_LeftShiftPointGrowth
import Tablet.P804_T1_PointMinusOneGrowth
import Tablet.P804_T1_PointZeroGrowth
import Tablet.P804_T1_SelectedLeftGrowth
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P804_T1_LeftLoopStep]
theorem P804_T1_LeftLoopStep
(X Y : Real) (d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(exp : Std.I32)
(hpointLo : -324 <= d.decimal_point.val)
(hpointHi : d.decimal_point.val <= 0)
(hexpLo : -1260 <= exp.val)
(hinput :
let digits :=
(d.digits.val.take d.num_digits.val).map (fun q => q.val)
d.num_digits.val <= 768 /\
(forall q, q ∈ d.digits.val.take d.num_digits.val -> q.val < 10) /\
(exists z zs, digits = z :: zs /\ 1 <= z /\ z < 10 /\
digits.length = d.num_digits.val))
(hend :
let digits :=
(d.digits.val.take d.num_digits.val).map (fun q => q.val)
let I : Nat := digits.foldl (fun n q => 10 * n + q) 0
let V : Real := I * (10 : Real) ^
(d.decimal_point.val - (d.num_digits.val : Int))
exists eta u : Real, X = V + eta /\ Y = V + u /\
0 <= eta /\ eta < u /\ (d.truncated = true <-> 0 < eta)) :
(num.imp.dec2flt.slow.parse_long_mantissa_loop1.body
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64
{ m := 0#u64, p_biased := 2047#i32 }
d.num_digits d.decimal_point d.truncated d.digits exp none =
ok (done (d.num_digits, d.decimal_point, d.truncated,
d.digits, exp, none)) /\
d.decimal_point.val = 0 /\
5 <= d.digits.val[0].val) \/
exists (d' : num.imp.dec2flt.decimal_seq.DecimalSeq)
(shift growth : Std.Usize) (exp' : Std.I32) (z z' : Nat)
(zs zs' : List Nat),
num.imp.dec2flt.slow.parse_long_mantissa_loop1.body
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64
{ m := 0#u64, p_biased := 2047#i32 }
d.num_digits d.decimal_point d.truncated d.digits exp none =
ok (cont (d'.num_digits, d'.decimal_point, d'.truncated,
d'.digits, exp', none)) /\
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift d shift = ok d' /\
num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift
d shift = ok growth /\
shift.val <= 60 /\
exp'.val = exp.val - (shift.val : Int) /\
(d.digits.val.take d.num_digits.val).map (fun q => q.val) = z :: zs /\
(d'.digits.val.take d'.num_digits.val).map (fun q => q.val) = z' :: zs' /\
1 <= z /\ z < 10 /\ 1 <= z' /\ z' < 10 /\
(d.decimal_point.val <= -19 ->
d'.decimal_point.val = d.decimal_point.val + 18 \/
d'.decimal_point.val = d.decimal_point.val + 19) /\
(-18 <= d.decimal_point.val -> d.decimal_point.val < 0 ->
d'.decimal_point.val = -1 \/ d'.decimal_point.val = 0) /\
(d.decimal_point.val = -1 -> d'.decimal_point.val = -1 -> 7 <= z') /\
(d.decimal_point.val = -1 -> 7 <= z ->
d'.decimal_point.val = 0 /\ 5 <= z') /\
(d.decimal_point.val = 0 -> z < 5) /\
(d.decimal_point.val = 0 ->
d'.decimal_point.val = 0 /\
(z <= 2 -> 3 <= z') /\ (3 <= z -> 5 <= z')) /\
(let digits' :=
(d'.digits.val.take d'.num_digits.val).map (fun q => q.val)
let I' : Nat := digits'.foldl (fun n q => 10 * n + q) 0
let V' : Real := I' * (10 : Real) ^
(d'.decimal_point.val - (d'.num_digits.val : Int))
d'.num_digits.val <= 768 /\
(forall q, q ∈ d'.digits.val.take d'.num_digits.val -> q.val < 10) /\
digits'.length = d'.num_digits.val /\
(exists eta' u' : Real,
(2 : Real) ^ shift.val * X = V' + eta' /\
(2 : Real) ^ shift.val * Y = V' + u' /\
0 <= eta' /\ eta' < u' /\
(d'.truncated = true <-> 0 < eta'))) := 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
dsimp only at hinput hend
rcases hinput with ⟨hcap, hdigit, z, zs, hshape, hzLo, hzHi, hlen⟩
have hnumPos : 0 < d.num_digits.val := by
rw [← hlen]
rw [hshape]
simp
have hnumNe : d.num_digits.val != 0 := by
simp only [bne_iff_ne]
omega
have hlenCons : (z :: zs).length = d.num_digits.val := by
rw [← hshape]
exact hlen
have hindexBound : (0 : Nat) < d.digits.val.length := by
rw [d.digits.property]
norm_num
obtain ⟨head, hread, hreadVal⟩ := Aeneas.Std.WP.spec_imp_exists
(Array.index_usize_spec d.digits 0#usize (by
simpa [Array.length] using hindexBound))
have hgetHead : d.digits.val[0]? = some head :=
getElem?_eq_some_iff.mpr ⟨hindexBound, hreadVal.symm⟩
have hheadVal : head.val = z := by
have hh := congrArg List.head? hshape
rw [List.head?_eq_getElem?] at hh
have ht : (d.digits.val.take d.num_digits.val)[0]? = some head := by
rw [List.getElem?_take, if_pos hnumPos]
exact hgetHead
simp only [List.getElem?_map, ht] at hh
simpa using Option.some.inj hh
have harrayHead : d.digits.val[0].val = z := by
have hv : d.digits.val[0] = head := by
exact getElem?_eq_some_iff.mp hgetHead |>.2
rw [hv, hheadVal]
let chooseShift (u : Std.U8) : Result Std.Usize :=
match u with
| 0#uscalar => ok 2#usize
| 1#uscalar => ok 2#usize
| _ => ok 1#usize
have chooseShift_eq (u : Std.U8) :
(match u with
| 0#uscalar => ok 2#usize
| 1#uscalar => ok 2#usize
| _ => ok 1#usize) = chooseShift u := by
rfl
have shiftRule (u : Std.U8) (w : Nat)
(hwLo : 1 <= w) (hwHi : w < 5) (hw : u.val = w) :
chooseShift u = ok (if w = 1 then 2#usize else 1#usize) := by
have hwCases : w = 1 \/ w = 2 \/ w = 3 \/ w = 4 := by omega
rcases hwCases with rfl | rfl | rfl | rfl
· have hu : u = 1#u8 := UScalar.eq_of_val_eq (by simpa using hw)
subst u
rfl
· have hu : u = 2#u8 := UScalar.eq_of_val_eq (by simpa using hw)
subst u
rfl
· have hu : u = 3#u8 := UScalar.eq_of_val_eq (by simpa using hw)
subst u
rfl
· have hu : u = 4#u8 := UScalar.eq_of_val_eq (by simpa using hw)
subst u
rfl
by_cases hexit : d.decimal_point.val = 0 /\ 5 <= z
· left
rcases hexit with ⟨hp0, hz5⟩
refine ⟨?_, hp0, by simpa [harrayHead] using hz5⟩
unfold num.imp.dec2flt.slow.parse_long_mantissa_loop1.body
have hple : d.decimal_point <= 0#i32 := by
change d.decimal_point.val <= 0
omega
have hpeq : d.decimal_point = 0#i32 :=
IScalar.eq_of_val_eq (by simpa using hp0)
have hge : head >= 5#u8 := by
change head.val >= 5
omega
have hnotlt : ¬ head.val < 5 := by omega
simp [hpeq, hread, hnotlt]
· right
have hcontinue : d.decimal_point.val < 0 \/
(d.decimal_point.val = 0 /\ z < 5) := by omega
obtain ⟨shift, growth, hk, hgrowth, hcontrol, hlargeGrowth,
hsmallGrowth, hzeroGrowth⟩ :
exists (shift growth : Std.Usize),
shift.val <= 60 /\
num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift
d shift = ok growth /\
((d.decimal_point.val < 0 /\
exists (negp : Std.I32) (n : Std.Usize),
(-. d.decimal_point) = ok negp /\
lift (IScalar.hcast .Usize negp) = ok n /\
n.val = -d.decimal_point.val /\
num.imp.dec2flt.slow.parse_long_mantissa.closure.Insts.CoreOpsFunctionFnTupleUsizeUsize.call
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 () n = ok shift) \/
(d.decimal_point.val = 0 /\ z < 5 /\
shift = if z = 1 then 2#usize else 1#usize)) /\
(d.decimal_point.val <= -19 -> growth.val = 18 \/ growth.val = 19) /\
(-18 <= d.decimal_point.val -> d.decimal_point.val < 0 ->
growth.val = (-d.decimal_point.val).toNat - 1 \/
growth.val = (-d.decimal_point.val).toNat) /\
(d.decimal_point.val = 0 -> growth.val = 0) := by
rcases hcontinue with hpneg | ⟨hp0, hz5⟩
· obtain ⟨negp, hneg, hnegVal⟩ := Aeneas.Std.WP.spec_imp_exists
(IScalar.sub_spec (x := (0#i32 : Std.I32))
(y := d.decimal_point) (by
rw [IScalar.min_I32_eq]
norm_num
omega)
(by
rw [IScalar.max_I32_eq]
norm_num
omega))
have hnegCall : (-. d.decimal_point) = ok negp := by
change IScalar.neg d.decimal_point = ok negp
unfold IScalar.neg
change IScalar.sub (0#i32 : Std.I32) d.decimal_point = ok negp at hneg
unfold IScalar.sub at hneg
norm_num at hneg ⊢
exact hneg
have hnegVal' : negp.val = -d.decimal_point.val := by
simpa using hnegVal
obtain ⟨n, hnCall, hnVal⟩ := Aeneas.Std.WP.spec_imp_exists
(IScalar.hcast_inBounds_spec .Usize negp (by
rw [hnegVal']
constructor <;> scalar_tac))
have hnVal' : n.val = (-d.decimal_point.val).toNat := by
have hnonneg : 0 <= -d.decimal_point.val := by omega
have hnInt : (n.val : Int) = -d.decimal_point.val := by
rw [hnegVal'] at hnVal
simpa using hnVal
have ht := congrArg Int.toNat hnInt
simpa [Int.toNat_of_nonneg hnonneg] using ht
obtain ⟨shift, growth, hselector, hk, hgrowth, hlarge, hsmall⟩ :=
P804_T1_SelectedLeftGrowth d n (by rw [hnVal']; omega)
(by rw [hnVal']; omega) ⟨hcap, hdigit, z, zs, hshape,
hzLo, hzHi, hlen⟩
refine ⟨shift, growth, hk, hgrowth, Or.inl ⟨hpneg, negp, n,
hnegCall, hnCall, ?_, hselector⟩, ?_, ?_, ?_⟩
· have hnInt : (n.val : Int) = -d.decimal_point.val := by
rw [hnegVal'] at hnVal
simpa using hnVal
exact hnInt
· intro hp19
exact hlarge (by rw [hnVal']; omega)
· intro hp18 hpneg'
simpa [hnVal'] using hsmall (by rw [hnVal']; omega)
· omega
· obtain ⟨growth, hgrowth, hgrowth0⟩ :=
P804_T1_PointZeroGrowth d z zs hcap hdigit hshape hzLo hz5
let shift : Std.Usize := if z = 1 then 2#usize else 1#usize
refine ⟨shift, growth, ?_, hgrowth, Or.inr ⟨hp0, hz5, rfl⟩,
?_, ?_, ?_⟩
· by_cases hz1 : z = 1 <;> simp [shift, hz1]
· omega
· omega
· exact fun _ => hgrowth0
obtain ⟨d', q, hleft, hq, hqPoint, hp'LoWide, hp'HiWide, hnonzero⟩ :=
DecimalLeftShiftLoop1Execution d shift hk hpointLo hpointHi
⟨hcap, hdigit, z, zs, hshape, hzLo, hzHi, hlenCons⟩
have hpoint := P804_T1_LeftShiftPointGrowth d d' shift growth hnumNe
hgrowth (by
rcases hcontrol with ⟨hp, negp, n, hneg, hn, hnval, hsel⟩ |
⟨hp, hz5, hshift⟩
· by_cases hn19 : 19 <= n.val
· rcases hlargeGrowth (by omega) with h | h <;> omega
· rcases hsmallGrowth (by omega) hp with h | h <;> omega
· rw [hzeroGrowth hp]
omega) hleft
have hlargePoint : d.decimal_point.val <= -19 ->
d'.decimal_point.val = d.decimal_point.val + 18 \/
d'.decimal_point.val = d.decimal_point.val + 19 := by
intro hp
rcases hlargeGrowth hp with h | h <;> rw [hpoint, h] <;> omega
have hsmallPoint : -18 <= d.decimal_point.val ->
d.decimal_point.val < 0 ->
d'.decimal_point.val = -1 \/ d'.decimal_point.val = 0 := by
intro hp18 hpneg
rcases hsmallGrowth hp18 hpneg with h | h
· left
rw [hpoint, h]
have : ((-d.decimal_point.val).toNat : Int) =
-d.decimal_point.val := Int.toNat_of_nonneg (by omega)
omega
· right
rw [hpoint, h]
have : ((-d.decimal_point.val).toNat : Int) =
-d.decimal_point.val := Int.toNat_of_nonneg (by omega)
omega
have hzeroPoint : d.decimal_point.val = 0 ->
d'.decimal_point.val = 0 := by
intro hp0
rw [hpoint, hzeroGrowth hp0]
omega
have hp'Hi : d'.decimal_point.val <= 0 := by
by_cases hp19 : d.decimal_point.val <= -19
· rcases hlargePoint hp19 with h | h <;> omega
· by_cases hpneg : d.decimal_point.val < 0
· rcases hsmallPoint (by omega) hpneg with h | h <;> omega
· have hz := hzeroPoint (by omega)
omega
have hcanon := DecimalSeqLeftShiftCanonical d d' shift X Y
⟨hcap, hdigit, Or.inr ⟨z, zs, hshape, hzLo, hzHi, hlen⟩⟩
hend hk hleft
dsimp only at hcanon
rcases hcanon with ⟨hcap', hdigit', hshapeOut, hend', q', hq', hpq'⟩
rcases hshapeOut with hzero | hpositive
· rcases hzero with ⟨hn0, hd0, ht0, hX0⟩
simp [hn0] at hnonzero
· rcases hpositive with
⟨z', zs', hshape', hz'Lo, hz'Hi, hlen', hlast'⟩
have hlenCons' : (z' :: zs').length = d'.num_digits.val := by
rw [← hshape']
exact hlen'
have hlead := P804_T1_LeftLeadingProgress d d' shift z z' zs zs'
hk hshape hzLo hdigit hlenCons hshape' hz'Lo hdigit' hlenCons' hleft
have hshiftMinusOne : d.decimal_point.val = -1 -> shift.val = 3 := by
intro hp
rcases hcontrol with ⟨hpneg, negp, n, hneg, hn, hnval, hsel⟩ |
⟨hp0, hz5, hshift⟩
· have hn1 : n.val = 1 := by omega
have hs := SlowShiftSelectorCertificate
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 n
dsimp only at hs
rcases hs with ⟨hsel', hk', hz0', hsmall', hlarge'⟩
rw [hsel] at hsel'
injection hsel' with heq
have heq' : shift = 3#usize := by simpa [hn1] using heq
simpa [heq']
· omega
have hstallLead : d.decimal_point.val = -1 ->
d'.decimal_point.val = -1 -> 7 <= z' := by
intro hp hp'
exact hlead.1 hp hp' (hshiftMinusOne hp)
have hminusRecovery : d.decimal_point.val = -1 -> 7 <= z ->
d'.decimal_point.val = 0 /\ 5 <= z' := by
intro hp hz7
have hshift3 : shift = 3#usize := by
apply UScalar.eq_of_val_eq
simpa using hshiftMinusOne hp
obtain ⟨growth1, hgrowth1, hgrowth1Val⟩ :=
P804_T1_PointMinusOneGrowth d z zs hcap hdigit hshape hz7
rw [hshift3] at hgrowth
rw [hgrowth] at hgrowth1
cases hgrowth1
have hg1 : growth.val = 1 := hgrowth1Val
have hp'0 : d'.decimal_point.val = 0 := by rw [hpoint, hp, hg1]; omega
exact ⟨hp'0, hlead.2.2.2 hp hp'0 hz7 (by simpa [hshift3])⟩
have hzeroProgress : d.decimal_point.val = 0 ->
d'.decimal_point.val = 0 /\
(z <= 2 -> 3 <= z') /\ (3 <= z -> 5 <= z') := by
intro hp0
have hp'0 := hzeroPoint hp0
have hshiftCases : (z = 1 /\ shift.val = 2) \/
(z = 2 /\ shift.val = 1) \/
(3 <= z /\ shift.val = 1) := by
rcases hcontrol with hneg | ⟨_, hz5, hshift⟩
· omega
· by_cases hz1 : z = 1
· left
exact ⟨hz1, by simp [hshift, hz1]⟩
· by_cases hz2 : z = 2
· right; left
exact ⟨hz2, by simp [hshift, hz1]⟩
· right; right
exact ⟨by omega, by simp [hshift, hz1]⟩
refine ⟨hp'0, ?_, ?_⟩
· intro hz2
rcases hshiftCases with h | h | h
· exact hlead.2.1 hp0 hp'0 (Or.inl h)
· exact hlead.2.1 hp0 hp'0 (Or.inr h)
· omega
· intro hz3
rcases hshiftCases with h | h | h
· omega
· omega
· exact hlead.2.2.1 hp0 hp'0 h.1 h.2
have hshiftCast : (UScalar.hcast .I32 shift).val =
(shift.val : Int) := by
have hs := UScalar.hcast_inBounds_spec .I32 shift (by
rw [IScalar.max_I32_eq]
omega)
simpa [lift, WP.spec_ok] using hs
let shiftI : Std.I32 := UScalar.hcast .I32 shift
have hshiftIVal : shiftI.val = (shift.val : Int) := by
simpa [shiftI] using hshiftCast
obtain ⟨exp', hexpSub, hexpVal⟩ := Aeneas.Std.WP.spec_imp_exists
(IScalar.sub_spec (x := exp) (y := shiftI) (by
rw [hshiftIVal, IScalar.min_I32_eq]
omega) (by
rw [hshiftIVal, IScalar.max_I32_eq]
have := exp.bv.isLt
scalar_tac))
have hexpVal' : exp'.val = exp.val - (shift.val : Int) := by
rw [hexpVal, hshiftIVal]
have hnotReset : ¬ d'.decimal_point >
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE := by
unfold num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
change ¬ d'.decimal_point.val > 2047
omega
have hnotResetVal : ¬
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE.val <
d'.decimal_point.val := by
unfold num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
change ¬ (2047 : Int) < d'.decimal_point.val
omega
have hzeroInput : d.decimal_point.val = 0 -> z < 5 := by
intro hp0
rcases hcontinue with hpneg | hzero
· omega
· exact hzero.2
refine ⟨d', shift, growth, exp', z, z', zs, zs', ?_, hleft,
hgrowth, hk, hexpVal', hshape, hshape', hzLo, hzHi, hz'Lo,
hz'Hi, hlargePoint, hsmallPoint, hstallLead, hminusRecovery,
hzeroInput, hzeroProgress, ?_⟩
· unfold num.imp.dec2flt.slow.parse_long_mantissa_loop1.body
have hple : d.decimal_point <= 0#i32 := by
change d.decimal_point.val <= 0
omega
simp only [hple, if_true, core.option.Option.is_none]
rcases hcontrol with ⟨hpneg, negp, n, hneg, hn, hnval, hsel⟩ |
⟨hp0, hz5, hshift⟩
· have hpne : ¬ d.decimal_point = 0#i32 := by
intro h
have := congrArg IScalar.val h
simp at this
omega
simp only [hpne, if_false, hneg, bind_tc_ok,
Bool.true_eq, if_true]
rw [hn]
simp only [bind_tc_ok]
rw [hsel]
simp only [bind_tc_ok]
have hdEta :
({ num_digits := d.num_digits,
decimal_point := d.decimal_point,
truncated := d.truncated,
digits := d.digits } :
num.imp.dec2flt.decimal_seq.DecimalSeq) = d := by
cases d
rfl
rw [hdEta, hleft]
simp only [bind_tc_ok, hnotReset, if_false, lift]
rw [show UScalar.hcast .I32 shift = shiftI by rfl]
simp only [hexpSub, bind_tc_ok]
simp only [show (none : Option num.imp.dec2flt.common.BiasedFp).isNone =
true by rfl, if_true]
· have hpeq : d.decimal_point = 0#i32 :=
IScalar.eq_of_val_eq (by simpa using hp0)
have hlt : ¬ head >= 5#u8 := by
change ¬ head.val >= 5
omega
have hshiftMatch := shiftRule head z hzLo hz5 hheadVal
rw [← hshift] at hshiftMatch
have hselector := (chooseShift_eq head).trans hshiftMatch
simp only [hpeq, if_true, hread, hlt, if_false, bind_tc_ok]
simp only [show (none : Option num.imp.dec2flt.common.BiasedFp).isNone =
true by rfl, if_true]
have hleadVal : d.digits.val[0].val = z := harrayHead
split
· change 0 = z at hheadVal
have hz0 : z = 0 := hheadVal.symm
omega
· change 1 = z at hheadVal
have hz1 : z = 1 := hheadVal.symm
simp only [hz1, if_true] at hshift hleft
subst shift
have hdZeroEta :
({ num_digits := d.num_digits,
decimal_point := 0#i32,
truncated := d.truncated,
digits := d.digits } :
num.imp.dec2flt.decimal_seq.DecimalSeq) = d := by
rw [← hpeq]
simp only [bind_tc_ok]
rw [hdZeroEta, hleft]
simp only [bind_tc_ok, hnotReset, if_false, lift]
rw [show UScalar.hcast .I32 2#usize = shiftI by rfl]
simp only [hexpSub, bind_tc_ok]
· have hz1 : z ≠ 1 := by
intro hz
subst z
have hu : head = 1#u8 := by
apply UScalar.eq_of_val_eq
scalar_tac
subst head
simp_all
simp only [hz1, if_false] at hshift
subst shift
have hdZeroEta :
({ num_digits := d.num_digits,
decimal_point := 0#i32,
truncated := d.truncated,
digits := d.digits } :
num.imp.dec2flt.decimal_seq.DecimalSeq) = d := by
rw [← hpeq]
simp only [bind_tc_ok]
rw [hdZeroEta, hleft]
simp only [bind_tc_ok, hnotReset, if_false, lift]
rw [show UScalar.hcast .I32 1#usize = shiftI by rfl]
simp only [hexpSub, bind_tc_ok]
· exact ⟨hcap', hdigit', hlen', hend'⟩
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.DecimalLeftShiftLoop1Execution
import Tablet.DecimalSeqLeftShiftCanonical
import Tablet.P804_T1_LeftLeadingProgress
import Tablet.P804_T1_LeftShiftPointGrowth
import Tablet.P804_T1_PointMinusOneGrowth
import Tablet.P804_T1_PointZeroGrowth
import Tablet.P804_T1_SelectedLeftGrowth
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P804_T1_LeftLoopStep]
theorem P804_T1_LeftLoopStep
(X Y : Real) (d : num.imp.dec2flt.decimal_seq.DecimalSeq)
(exp : Std.I32)
(hpointLo : -324 <= d.decimal_point.val)
(hpointHi : d.decimal_point.val <= 0)
(hexpLo : -1260 <= exp.val)
(hinput :
let digits :=
(d.digits.val.take d.num_digits.val).map (fun q => q.val)
d.num_digits.val <= 768 /\
(forall q, q ∈ d.digits.val.take d.num_digits.val -> q.val < 10) /\
(exists z zs, digits = z :: zs /\ 1 <= z /\ z < 10 /\
digits.length = d.num_digits.val))
(hend :
let digits :=
(d.digits.val.take d.num_digits.val).map (fun q => q.val)
let I : Nat := digits.foldl (fun n q => 10 * n + q) 0
let V : Real := I * (10 : Real) ^
(d.decimal_point.val - (d.num_digits.val : Int))
exists eta u : Real, X = V + eta /\ Y = V + u /\
0 <= eta /\ eta < u /\ (d.truncated = true <-> 0 < eta)) :
(num.imp.dec2flt.slow.parse_long_mantissa_loop1.body
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64
{ m := 0#u64, p_biased := 2047#i32 }
d.num_digits d.decimal_point d.truncated d.digits exp none =
ok (done (d.num_digits, d.decimal_point, d.truncated,
d.digits, exp, none)) /\
d.decimal_point.val = 0 /\
5 <= d.digits.val[0].val) \/
exists (d' : num.imp.dec2flt.decimal_seq.DecimalSeq)
(shift growth : Std.Usize) (exp' : Std.I32) (z z' : Nat)
(zs zs' : List Nat),
num.imp.dec2flt.slow.parse_long_mantissa_loop1.body
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64
{ m := 0#u64, p_biased := 2047#i32 }
d.num_digits d.decimal_point d.truncated d.digits exp none =
ok (cont (d'.num_digits, d'.decimal_point, d'.truncated,
d'.digits, exp', none)) /\
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift d shift = ok d' /\
num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift
d shift = ok growth /\
shift.val <= 60 /\
exp'.val = exp.val - (shift.val : Int) /\
(d.digits.val.take d.num_digits.val).map (fun q => q.val) = z :: zs /\
(d'.digits.val.take d'.num_digits.val).map (fun q => q.val) = z' :: zs' /\
1 <= z /\ z < 10 /\ 1 <= z' /\ z' < 10 /\
(d.decimal_point.val <= -19 ->
d'.decimal_point.val = d.decimal_point.val + 18 \/
d'.decimal_point.val = d.decimal_point.val + 19) /\
(-18 <= d.decimal_point.val -> d.decimal_point.val < 0 ->
d'.decimal_point.val = -1 \/ d'.decimal_point.val = 0) /\
(d.decimal_point.val = -1 -> d'.decimal_point.val = -1 -> 7 <= z') /\
(d.decimal_point.val = -1 -> 7 <= z ->
d'.decimal_point.val = 0 /\ 5 <= z') /\
(d.decimal_point.val = 0 -> z < 5) /\
(d.decimal_point.val = 0 ->
d'.decimal_point.val = 0 /\
(z <= 2 -> 3 <= z') /\ (3 <= z -> 5 <= z')) /\
(let digits' :=
(d'.digits.val.take d'.num_digits.val).map (fun q => q.val)
let I' : Nat := digits'.foldl (fun n q => 10 * n + q) 0
let V' : Real := I' * (10 : Real) ^
(d'.decimal_point.val - (d'.num_digits.val : Int))
d'.num_digits.val <= 768 /\
(forall q, q ∈ d'.digits.val.take d'.num_digits.val -> q.val < 10) /\
digits'.length = d'.num_digits.val /\
(exists eta' u' : Real,
(2 : Real) ^ shift.val * X = V' + eta' /\
(2 : Real) ^ shift.val * Y = V' + u' /\
0 <= eta' /\ eta' < u' /\
(d'.truncated = true <-> 0 < eta'))) := by
-- BODY
dsimp only at hinput hend
rcases hinput with ⟨hcap, hdigit, z, zs, hshape, hzLo, hzHi, hlen⟩
have hnumPos : 0 < d.num_digits.val := by
rw [← hlen]
rw [hshape]
simp
have hnumNe : d.num_digits.val != 0 := by
simp only [bne_iff_ne]
omega
have hlenCons : (z :: zs).length = d.num_digits.val := by
rw [← hshape]
exact hlen
have hindexBound : (0 : Nat) < d.digits.val.length := by
rw [d.digits.property]
norm_num
obtain ⟨head, hread, hreadVal⟩ := Aeneas.Std.WP.spec_imp_exists
(Array.index_usize_spec d.digits 0#usize (by
simpa [Array.length] using hindexBound))
have hgetHead : d.digits.val[0]? = some head :=
getElem?_eq_some_iff.mpr ⟨hindexBound, hreadVal.symm⟩
have hheadVal : head.val = z := by
have hh := congrArg List.head? hshape
rw [List.head?_eq_getElem?] at hh
have ht : (d.digits.val.take d.num_digits.val)[0]? = some head := by
rw [List.getElem?_take, if_pos hnumPos]
exact hgetHead
simp only [List.getElem?_map, ht] at hh
simpa using Option.some.inj hh
have harrayHead : d.digits.val[0].val = z := by
have hv : d.digits.val[0] = head := by
exact getElem?_eq_some_iff.mp hgetHead |>.2
rw [hv, hheadVal]
let chooseShift (u : Std.U8) : Result Std.Usize :=
match u with
| 0#uscalar => ok 2#usize
| 1#uscalar => ok 2#usize
| _ => ok 1#usize
have chooseShift_eq (u : Std.U8) :
(match u with
| 0#uscalar => ok 2#usize
| 1#uscalar => ok 2#usize
| _ => ok 1#usize) = chooseShift u := by
rfl
have shiftRule (u : Std.U8) (w : Nat)
(hwLo : 1 <= w) (hwHi : w < 5) (hw : u.val = w) :
chooseShift u = ok (if w = 1 then 2#usize else 1#usize) := by
have hwCases : w = 1 \/ w = 2 \/ w = 3 \/ w = 4 := by omega
rcases hwCases with rfl | rfl | rfl | rfl
· have hu : u = 1#u8 := UScalar.eq_of_val_eq (by simpa using hw)
subst u
rfl
· have hu : u = 2#u8 := UScalar.eq_of_val_eq (by simpa using hw)
subst u
rfl
· have hu : u = 3#u8 := UScalar.eq_of_val_eq (by simpa using hw)
subst u
rfl
· have hu : u = 4#u8 := UScalar.eq_of_val_eq (by simpa using hw)
subst u
rfl
by_cases hexit : d.decimal_point.val = 0 /\ 5 <= z
· left
rcases hexit with ⟨hp0, hz5⟩
refine ⟨?_, hp0, by simpa [harrayHead] using hz5⟩
unfold num.imp.dec2flt.slow.parse_long_mantissa_loop1.body
have hple : d.decimal_point <= 0#i32 := by
change d.decimal_point.val <= 0
omega
have hpeq : d.decimal_point = 0#i32 :=
IScalar.eq_of_val_eq (by simpa using hp0)
have hge : head >= 5#u8 := by
change head.val >= 5
omega
have hnotlt : ¬ head.val < 5 := by omega
simp [hpeq, hread, hnotlt]
· right
have hcontinue : d.decimal_point.val < 0 \/
(d.decimal_point.val = 0 /\ z < 5) := by omega
obtain ⟨shift, growth, hk, hgrowth, hcontrol, hlargeGrowth,
hsmallGrowth, hzeroGrowth⟩ :
exists (shift growth : Std.Usize),
shift.val <= 60 /\
num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift
d shift = ok growth /\
((d.decimal_point.val < 0 /\
exists (negp : Std.I32) (n : Std.Usize),
(-. d.decimal_point) = ok negp /\
lift (IScalar.hcast .Usize negp) = ok n /\
n.val = -d.decimal_point.val /\
num.imp.dec2flt.slow.parse_long_mantissa.closure.Insts.CoreOpsFunctionFnTupleUsizeUsize.call
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 () n = ok shift) \/
(d.decimal_point.val = 0 /\ z < 5 /\
shift = if z = 1 then 2#usize else 1#usize)) /\
(d.decimal_point.val <= -19 -> growth.val = 18 \/ growth.val = 19) /\
(-18 <= d.decimal_point.val -> d.decimal_point.val < 0 ->
growth.val = (-d.decimal_point.val).toNat - 1 \/
growth.val = (-d.decimal_point.val).toNat) /\
(d.decimal_point.val = 0 -> growth.val = 0) := by
rcases hcontinue with hpneg | ⟨hp0, hz5⟩
· obtain ⟨negp, hneg, hnegVal⟩ := Aeneas.Std.WP.spec_imp_exists
(IScalar.sub_spec (x := (0#i32 : Std.I32))
(y := d.decimal_point) (by
rw [IScalar.min_I32_eq]
norm_num
omega)
(by
rw [IScalar.max_I32_eq]
norm_num
omega))
have hnegCall : (-. d.decimal_point) = ok negp := by
change IScalar.neg d.decimal_point = ok negp
unfold IScalar.neg
change IScalar.sub (0#i32 : Std.I32) d.decimal_point = ok negp at hneg
unfold IScalar.sub at hneg
norm_num at hneg ⊢
exact hneg
have hnegVal' : negp.val = -d.decimal_point.val := by
simpa using hnegVal
obtain ⟨n, hnCall, hnVal⟩ := Aeneas.Std.WP.spec_imp_exists
(IScalar.hcast_inBounds_spec .Usize negp (by
rw [hnegVal']
constructor <;> scalar_tac))
have hnVal' : n.val = (-d.decimal_point.val).toNat := by
have hnonneg : 0 <= -d.decimal_point.val := by omega
have hnInt : (n.val : Int) = -d.decimal_point.val := by
rw [hnegVal'] at hnVal
simpa using hnVal
have ht := congrArg Int.toNat hnInt
simpa [Int.toNat_of_nonneg hnonneg] using ht
obtain ⟨shift, growth, hselector, hk, hgrowth, hlarge, hsmall⟩ :=
P804_T1_SelectedLeftGrowth d n (by rw [hnVal']; omega)
(by rw [hnVal']; omega) ⟨hcap, hdigit, z, zs, hshape,
hzLo, hzHi, hlen⟩
refine ⟨shift, growth, hk, hgrowth, Or.inl ⟨hpneg, negp, n,
hnegCall, hnCall, ?_, hselector⟩, ?_, ?_, ?_⟩
· have hnInt : (n.val : Int) = -d.decimal_point.val := by
rw [hnegVal'] at hnVal
simpa using hnVal
exact hnInt
· intro hp19
exact hlarge (by rw [hnVal']; omega)
· intro hp18 hpneg'
simpa [hnVal'] using hsmall (by rw [hnVal']; omega)
· omega
· obtain ⟨growth, hgrowth, hgrowth0⟩ :=
P804_T1_PointZeroGrowth d z zs hcap hdigit hshape hzLo hz5
let shift : Std.Usize := if z = 1 then 2#usize else 1#usize
refine ⟨shift, growth, ?_, hgrowth, Or.inr ⟨hp0, hz5, rfl⟩,
?_, ?_, ?_⟩
· by_cases hz1 : z = 1 <;> simp [shift, hz1]
· omega
· omega
· exact fun _ => hgrowth0
obtain ⟨d', q, hleft, hq, hqPoint, hp'LoWide, hp'HiWide, hnonzero⟩ :=
DecimalLeftShiftLoop1Execution d shift hk hpointLo hpointHi
⟨hcap, hdigit, z, zs, hshape, hzLo, hzHi, hlenCons⟩
have hpoint := P804_T1_LeftShiftPointGrowth d d' shift growth hnumNe
hgrowth (by
rcases hcontrol with ⟨hp, negp, n, hneg, hn, hnval, hsel⟩ |
⟨hp, hz5, hshift⟩
· by_cases hn19 : 19 <= n.val
· rcases hlargeGrowth (by omega) with h | h <;> omega
· rcases hsmallGrowth (by omega) hp with h | h <;> omega
· rw [hzeroGrowth hp]
omega) hleft
have hlargePoint : d.decimal_point.val <= -19 ->
d'.decimal_point.val = d.decimal_point.val + 18 \/
d'.decimal_point.val = d.decimal_point.val + 19 := by
intro hp
rcases hlargeGrowth hp with h | h <;> rw [hpoint, h] <;> omega
have hsmallPoint : -18 <= d.decimal_point.val ->
d.decimal_point.val < 0 ->
d'.decimal_point.val = -1 \/ d'.decimal_point.val = 0 := by
intro hp18 hpneg
rcases hsmallGrowth hp18 hpneg with h | h
· left
rw [hpoint, h]
have : ((-d.decimal_point.val).toNat : Int) =
-d.decimal_point.val := Int.toNat_of_nonneg (by omega)
omega
· right
rw [hpoint, h]
have : ((-d.decimal_point.val).toNat : Int) =
-d.decimal_point.val := Int.toNat_of_nonneg (by omega)
omega
have hzeroPoint : d.decimal_point.val = 0 ->
d'.decimal_point.val = 0 := by
intro hp0
rw [hpoint, hzeroGrowth hp0]
omega
have hp'Hi : d'.decimal_point.val <= 0 := by
by_cases hp19 : d.decimal_point.val <= -19
· rcases hlargePoint hp19 with h | h <;> omega
· by_cases hpneg : d.decimal_point.val < 0
· rcases hsmallPoint (by omega) hpneg with h | h <;> omega
· have hz := hzeroPoint (by omega)
omega
have hcanon := DecimalSeqLeftShiftCanonical d d' shift X Y
⟨hcap, hdigit, Or.inr ⟨z, zs, hshape, hzLo, hzHi, hlen⟩⟩
hend hk hleft
dsimp only at hcanon
rcases hcanon with ⟨hcap', hdigit', hshapeOut, hend', q', hq', hpq'⟩
rcases hshapeOut with hzero | hpositive
· rcases hzero with ⟨hn0, hd0, ht0, hX0⟩
simp [hn0] at hnonzero
· rcases hpositive with
⟨z', zs', hshape', hz'Lo, hz'Hi, hlen', hlast'⟩
have hlenCons' : (z' :: zs').length = d'.num_digits.val := by
rw [← hshape']
exact hlen'
have hlead := P804_T1_LeftLeadingProgress d d' shift z z' zs zs'
hk hshape hzLo hdigit hlenCons hshape' hz'Lo hdigit' hlenCons' hleft
have hshiftMinusOne : d.decimal_point.val = -1 -> shift.val = 3 := by
intro hp
rcases hcontrol with ⟨hpneg, negp, n, hneg, hn, hnval, hsel⟩ |
⟨hp0, hz5, hshift⟩
· have hn1 : n.val = 1 := by omega
have hs := SlowShiftSelectorCertificate
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 n
dsimp only at hs
rcases hs with ⟨hsel', hk', hz0', hsmall', hlarge'⟩
rw [hsel] at hsel'
injection hsel' with heq
have heq' : shift = 3#usize := by simpa [hn1] using heq
simpa [heq']
· omega
have hstallLead : d.decimal_point.val = -1 ->
d'.decimal_point.val = -1 -> 7 <= z' := by
intro hp hp'
exact hlead.1 hp hp' (hshiftMinusOne hp)
have hminusRecovery : d.decimal_point.val = -1 -> 7 <= z ->
d'.decimal_point.val = 0 /\ 5 <= z' := by
intro hp hz7
have hshift3 : shift = 3#usize := by
apply UScalar.eq_of_val_eq
simpa using hshiftMinusOne hp
obtain ⟨growth1, hgrowth1, hgrowth1Val⟩ :=
P804_T1_PointMinusOneGrowth d z zs hcap hdigit hshape hz7
rw [hshift3] at hgrowth
rw [hgrowth] at hgrowth1
cases hgrowth1
have hg1 : growth.val = 1 := hgrowth1Val
have hp'0 : d'.decimal_point.val = 0 := by rw [hpoint, hp, hg1]; omega
exact ⟨hp'0, hlead.2.2.2 hp hp'0 hz7 (by simpa [hshift3])⟩
have hzeroProgress : d.decimal_point.val = 0 ->
d'.decimal_point.val = 0 /\
(z <= 2 -> 3 <= z') /\ (3 <= z -> 5 <= z') := by
intro hp0
have hp'0 := hzeroPoint hp0
have hshiftCases : (z = 1 /\ shift.val = 2) \/
(z = 2 /\ shift.val = 1) \/
(3 <= z /\ shift.val = 1) := by
rcases hcontrol with hneg | ⟨_, hz5, hshift⟩
· omega
· by_cases hz1 : z = 1
· left
exact ⟨hz1, by simp [hshift, hz1]⟩
· by_cases hz2 : z = 2
· right; left
exact ⟨hz2, by simp [hshift, hz1]⟩
· right; right
exact ⟨by omega, by simp [hshift, hz1]⟩
refine ⟨hp'0, ?_, ?_⟩
· intro hz2
rcases hshiftCases with h | h | h
· exact hlead.2.1 hp0 hp'0 (Or.inl h)
· exact hlead.2.1 hp0 hp'0 (Or.inr h)
· omega
· intro hz3
rcases hshiftCases with h | h | h
· omega
· omega
· exact hlead.2.2.1 hp0 hp'0 h.1 h.2
have hshiftCast : (UScalar.hcast .I32 shift).val =
(shift.val : Int) := by
have hs := UScalar.hcast_inBounds_spec .I32 shift (by
rw [IScalar.max_I32_eq]
omega)
simpa [lift, WP.spec_ok] using hs
let shiftI : Std.I32 := UScalar.hcast .I32 shift
have hshiftIVal : shiftI.val = (shift.val : Int) := by
simpa [shiftI] using hshiftCast
obtain ⟨exp', hexpSub, hexpVal⟩ := Aeneas.Std.WP.spec_imp_exists
(IScalar.sub_spec (x := exp) (y := shiftI) (by
rw [hshiftIVal, IScalar.min_I32_eq]
omega) (by
rw [hshiftIVal, IScalar.max_I32_eq]
have := exp.bv.isLt
scalar_tac))
have hexpVal' : exp'.val = exp.val - (shift.val : Int) := by
rw [hexpVal, hshiftIVal]
have hnotReset : ¬ d'.decimal_point >
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE := by
unfold num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
change ¬ d'.decimal_point.val > 2047
omega
have hnotResetVal : ¬
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE.val <
d'.decimal_point.val := by
unfold num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
change ¬ (2047 : Int) < d'.decimal_point.val
omega
have hzeroInput : d.decimal_point.val = 0 -> z < 5 := by
intro hp0
rcases hcontinue with hpneg | hzero
· omega
· exact hzero.2
refine ⟨d', shift, growth, exp', z, z', zs, zs', ?_, hleft,
hgrowth, hk, hexpVal', hshape, hshape', hzLo, hzHi, hz'Lo,
hz'Hi, hlargePoint, hsmallPoint, hstallLead, hminusRecovery,
hzeroInput, hzeroProgress, ?_⟩
· unfold num.imp.dec2flt.slow.parse_long_mantissa_loop1.body
have hple : d.decimal_point <= 0#i32 := by
change d.decimal_point.val <= 0
omega
simp only [hple, if_true, core.option.Option.is_none]
rcases hcontrol with ⟨hpneg, negp, n, hneg, hn, hnval, hsel⟩ |
⟨hp0, hz5, hshift⟩
· have hpne : ¬ d.decimal_point = 0#i32 := by
intro h
have := congrArg IScalar.val h
simp at this
omega
simp only [hpne, if_false, hneg, bind_tc_ok,
Bool.true_eq, if_true]
rw [hn]
simp only [bind_tc_ok]
rw [hsel]
simp only [bind_tc_ok]
have hdEta :
({ num_digits := d.num_digits,
decimal_point := d.decimal_point,
truncated := d.truncated,
digits := d.digits } :
num.imp.dec2flt.decimal_seq.DecimalSeq) = d := by
cases d
rfl
rw [hdEta, hleft]
simp only [bind_tc_ok, hnotReset, if_false, lift]
rw [show UScalar.hcast .I32 shift = shiftI by rfl]
simp only [hexpSub, bind_tc_ok]
simp only [show (none : Option num.imp.dec2flt.common.BiasedFp).isNone =
true by rfl, if_true]
· have hpeq : d.decimal_point = 0#i32 :=
IScalar.eq_of_val_eq (by simpa using hp0)
have hlt : ¬ head >= 5#u8 := by
change ¬ head.val >= 5
omega
have hshiftMatch := shiftRule head z hzLo hz5 hheadVal
rw [← hshift] at hshiftMatch
have hselector := (chooseShift_eq head).trans hshiftMatch
simp only [hpeq, if_true, hread, hlt, if_false, bind_tc_ok]
simp only [show (none : Option num.imp.dec2flt.common.BiasedFp).isNone =
true by rfl, if_true]
have hleadVal : d.digits.val[0].val = z := harrayHead
split
· change 0 = z at hheadVal
have hz0 : z = 0 := hheadVal.symm
omega
· change 1 = z at hheadVal
have hz1 : z = 1 := hheadVal.symm
simp only [hz1, if_true] at hshift hleft
subst shift
have hdZeroEta :
({ num_digits := d.num_digits,
decimal_point := 0#i32,
truncated := d.truncated,
digits := d.digits } :
num.imp.dec2flt.decimal_seq.DecimalSeq) = d := by
rw [← hpeq]
simp only [bind_tc_ok]
rw [hdZeroEta, hleft]
simp only [bind_tc_ok, hnotReset, if_false, lift]
rw [show UScalar.hcast .I32 2#usize = shiftI by rfl]
simp only [hexpSub, bind_tc_ok]
· have hz1 : z ≠ 1 := by
intro hz
subst z
have hu : head = 1#u8 := by
apply UScalar.eq_of_val_eq
scalar_tac
subst head
simp_all
simp only [hz1, if_false] at hshift
subst shift
have hdZeroEta :
({ num_digits := d.num_digits,
decimal_point := 0#i32,
truncated := d.truncated,
digits := d.digits } :
num.imp.dec2flt.decimal_seq.DecimalSeq) = d := by
rw [← hpeq]
simp only [bind_tc_ok]
rw [hdZeroEta, hleft]
simp only [bind_tc_ok, hnotReset, if_false, lift]
rw [show UScalar.hcast .I32 1#usize = shiftI by rfl]
simp only [hexpSub, bind_tc_ok]
· exact ⟨hcap', hdigit', hlen', hend'⟩
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Uses
Inspect related source (151)
- DECIMAL_POINT_RANGE · dec2flt/decimal_seq.rs:67 Program Rust
- parse_long_mantissa · dec2flt/slow.rs:27 Program Rust
- parse_long_mantissa_loop0 · dec2flt/slow.rs:51 Program Rust
More program dependencies (109)
- body · dec2flt/slow.rs:51 Program Rust
- parse_long_mantissa_loop1 · dec2flt/slow.rs:69 Program Rust
- body · dec2flt/slow.rs:69 Program Rust
- parse_long_mantissa_loop2 · dec2flt/slow.rs:94 Program Rust
- body · dec2flt/slow.rs:94 Program Rust
- Dec2flt_modelNumImpTraitsFloatU64 · traits.rs:309 Program Rust
- BiasedFp · dec2flt/common.rs:52 Program Rust
- zero_pow2 · dec2flt/common.rs:62 Program Rust
- DecimalSeq · dec2flt/decimal_seq.rs:21 Program Rust
- left_shift · dec2flt/decimal_seq.rs:129 Program Rust
- left_shift_loop0 · dec2flt/decimal_seq.rs:138 Program Rust
- body · dec2flt/decimal_seq.rs:138 Program Rust
- left_shift_loop1 · dec2flt/decimal_seq.rs:152 Program Rust
- body · dec2flt/decimal_seq.rs:152 Program Rust
- right_shift · dec2flt/decimal_seq.rs:175 Program Rust
- right_shift_loop0 · dec2flt/decimal_seq.rs:180 Program Rust
- body · dec2flt/decimal_seq.rs:180 Program Rust
- right_shift_loop0_loop0 · dec2flt/decimal_seq.rs:190 Program Rust
- body · dec2flt/decimal_seq.rs:190 Program Rust
- right_shift_loop1 · dec2flt/decimal_seq.rs:209 Program Rust
- body · dec2flt/decimal_seq.rs:209 Program Rust
- right_shift_loop2 · dec2flt/decimal_seq.rs:216 Program Rust
- body · dec2flt/decimal_seq.rs:216 Program Rust
- round · dec2flt/decimal_seq.rs:96 Program Rust
- round_loop · dec2flt/decimal_seq.rs:106 Program Rust
- body · dec2flt/decimal_seq.rs:106 Program Rust
- parse_decimal_seq · dec2flt/decimal_seq.rs:283 Program Rust
- parse_decimal_seq_loop0 · dec2flt/decimal_seq.rs:290 Program Rust
- body · dec2flt/decimal_seq.rs:290 Program Rust
- parse_decimal_seq_loop1 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- parse_decimal_seq_loop2 · dec2flt/decimal_seq.rs:303 Program Rust
- body · dec2flt/decimal_seq.rs:303 Program Rust
- parse_decimal_seq_loop3 · dec2flt/decimal_seq.rs:307 Program Rust
- body · dec2flt/decimal_seq.rs:307 Program Rust
- parse_decimal_seq_loop4 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- parse_decimal_seq_loop5 · dec2flt/decimal_seq.rs:307 Program Rust
- body · dec2flt/decimal_seq.rs:307 Program Rust
- parse_decimal_seq_loop6 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- parse_decimal_seq_loop7 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- MAX_SHIFT · dec2flt/slow.rs:28 Program Rust
- call · dec2flt/slow.rs:33 Program Rust
- Float · traits.rs:74 Program Rust
- from_u64 · dec2flt/mod.rs:263 Program Rust
- BITS · traits.rs:319 Program Rust
- EXP_MASK · traits.rs:321 Program Rust
- INFINITY · traits.rs:312 Program Rust
- LARGEST_POWER_OF_TEN · traits.rs:327 Program Rust
- MAX_EXPONENT_ROUND_TO_EVEN · traits.rs:325 Program Rust
- MIN_EXPONENT_ROUND_TO_EVEN · traits.rs:324 Program Rust
- NAN · traits.rs:314 Program Rust
- NEG_INFINITY · traits.rs:313 Program Rust
- NEG_NAN · traits.rs:317 Program Rust
- SIG_MASK · traits.rs:322 Program Rust
- SIG_TOTAL_BITS · traits.rs:320 Program Rust
- SMALLEST_POWER_OF_TEN · traits.rs:328 Program Rust
- classify · traits.rs:334 Program Rust
- to_bits · traits.rs:330 Program Rust
- read_u64 · dec2flt/common.rs:18 Program Rust
- write_u64 · dec2flt/common.rs:25 Program Rust
- Dec2flt_modelNumImpTraitsInt · traits.rs:51 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
- ByteSlice · dec2flt/common.rs:4 Program Rust
- is_8digits · dec2flt/common.rs:40 Program Rust
- Decimal · dec2flt/decimal.rs:32 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
- trim · dec2flt/decimal_seq.rs:82 Program Rust
- trim_loop · dec2flt/decimal_seq.rs:91 Program Rust
- body · dec2flt/decimal_seq.rs:91 Program Rust
- count_trailing_zeros · dec2flt/decimal_seq.rs:235 Program Rust
- count_trailing_zeros_loop · dec2flt/decimal_seq.rs:239 Program Rust
- body · dec2flt/decimal_seq.rs:239 Program Rust
- number_of_digits_decimal_left_shift · dec2flt/decimal_seq.rs:368 Program Rust
- TABLE · dec2flt/decimal_seq.rs:370 Program Rust
- TABLE_POW5 · dec2flt/decimal_seq.rs:379 Program Rust
- number_of_digits_decimal_left_shift_loop · dec2flt/decimal_seq.rs:434 Program Rust
- body · dec2flt/decimal_seq.rs:434 Program Rust
- parse_decimal_exponent · dec2flt/decimal_seq.rs:269 Program Rust
- parse_decimal_exponent_loop · dec2flt/decimal_seq.rs:272 Program Rust
- body · dec2flt/decimal_seq.rs:272 Program Rust
- 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
- NUM_POWERS · dec2flt/slow.rs:29 Program Rust
- POWERS · dec2flt/slow.rs:30 Program Rust
- closure · dec2flt/slow.rs:33 Program Rust
- CastInto · traits.rs:18 Program Rust
- default · traits.rs:116 Program Rust
- default · traits.rs:104 Program Rust
- default · traits.rs:119 Program Rust
- default · traits.rs:110 Program Rust
- default · traits.rs:113 Program Rust
- default · traits.rs:101 Program Rust
- FloatExt · traits.rs:170 Program Rust
- Int · traits.rs:27 Program Rust
- Dec2flt_modelNumImpTraitsCastIntoI16 · traits.rs:45 Program Rust
- ONE · traits.rs:53 Program Rust
- ZERO · traits.rs:52 Program Rust
- try_add_digit · dec2flt/decimal_seq.rs:73 Program Rust
- cast · traits.rs:46 Program Rust
Standard-library dependencies (39)
- 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
- CoreMarkerCopy · core/src/marker.rs:57 Rust library
- CoreOpsArithDivF64F64 · core/src/ops/arith.rs:511 Rust library
- CoreOpsArithMulF64F64 · core/src/ops/arith.rs:344 Rust library
- CoreOpsArithNegF64 · core/src/ops/arith.rs:713 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
- CoreCloneClone · core/src/clone.rs:696 Rust library
- CoreOpsBitBitAndU64U64 · core/src/ops/bit.rs:174 Rust library
- CoreOpsBitBitOrU64U64 · core/src/ops/bit.rs:278 Rust library
- CoreOpsBitShlU32U64 · core/src/ops/bit.rs:483 Rust library
- CoreOpsBitShrU32U64 · core/src/ops/bit.rs:606 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
- Binary64Model
- Binary64ModelDefault
- DecimalDigitLexScale
- DecimalLeftShiftDigitGrowth
- DecimalLeftShiftFirstLoopSemantics
- DecimalLeftShiftLoop1Execution
All 126 entries
- Binary64Model
- Binary64ModelDefault
- DecimalDigitLexScale
- DecimalLeftShiftDigitGrowth
- DecimalLeftShiftFirstLoopSemantics
- DecimalLeftShiftLoop1Execution
- DecimalLeftShiftLoopLex
- DecimalLeftShiftSecondLoopSemantics
- DecimalLeftShiftTableCertificate
- DecimalRightShiftFinalLoopSemantics
- DecimalRightShiftMainLoopSemantics
- DecimalRightShiftPrefixLoopSemantics
- DecimalRightShiftU64DyadicBridge
- DecimalSeqDyadicShiftSemantics
- DecimalSeqLeftShiftCanonical
- DecimalSeqLeftShiftRecordSemantics
- DecimalSeqRightShiftRecordSemantics
- DecimalSeqTrimSemantics
- F64
- F64 Insts CoreCloneClone
- F64 Insts CoreMarkerCopy
- F64 Insts CoreOpsArithDivF64F64
- F64 Insts CoreOpsArithMulF64F64
- F64 Insts CoreOpsArithNegF64
- F64 Insts Dec2flt modelNumImpTraitsFloatU64
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 BITS
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 EXP MASK
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 INFINITY
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 LARGEST POWER OF TEN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 MAX EXPONENT ROUND TO EVEN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 MIN EXPONENT ROUND TO EVEN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 NAN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 NEG INFINITY
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 NEG NAN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 SIG MASK
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 SIG TOTAL BITS
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 SMALLEST POWER OF TEN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 classify
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 to bits
- ModelF64Classify
- ModelF64Clone
- ModelF64Div
- ModelF64ExponentMask
- ModelF64FromBits
- ModelF64FromU64
- ModelF64Infinity
- ModelF64MantissaDigits
- ModelF64MantissaMask
- ModelF64Mul
- ModelF64Nan
- ModelF64Neg
- ModelF64NegInfinity
- ModelF64ToBits
- ModelOptionBranch
- ModelOptionFromResidual
- ModelSliceFirst
- ModelSliceSplitFirst
- ModelStrAsBytes
- ModelU64BitAnd
- ModelU64BitOr
- ModelU64Shl
- ModelU64Shr
- ModelU8IsAsciiDigit
- DecimalLeadingInterval
- LeftLeadingProgress
- LeftLoopStep
- LeftShiftPointGrowth
- PointMinusOneGrowth
- PointZeroGrowth
- SelectedLeftGrowth
- PositiveScaleErrorTransport
- Preamble
- ResultLoopPartial
- SliceU8 Insts Dec2flt modelNumImpDec2fltCommonByteSlice read u64
- SliceU8 Insts Dec2flt modelNumImpDec2fltCommonByteSlice write u64
- SlowShiftSelectorCertificate
- U64 Insts CoreOpsBitBitAndU64U64
- U64 Insts CoreOpsBitBitOrU64U64
- U64 Insts CoreOpsBitShlU32U64
- U64 Insts CoreOpsBitShrU32U64
- U64 Insts Dec2flt modelNumImpTraitsCastIntoI16
- U64 Insts Dec2flt modelNumImpTraitsCastIntoI16 cast
- U64 Insts Dec2flt modelNumImpTraitsInt
- U64 Insts Dec2flt modelNumImpTraitsInt ONE
- U64 Insts Dec2flt modelNumImpTraitsInt ZERO
- core num FpCategory
- core ops arith Div
- core ops arith Mul
- core ops arith Neg
- core ops bit BitOr
- core ops bit Shl
- core ops bit Shr
- num imp dec2flt common BiasedFp
- num imp dec2flt common BiasedFp zero pow2
- 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 left shift
- num imp dec2flt decimal seq DecimalSeq right shift
- num imp dec2flt decimal seq DecimalSeq round
- num imp dec2flt decimal seq DecimalSeq trim
- num imp dec2flt decimal seq DecimalSeq try add digit
- num imp dec2flt decimal seq count trailing zeros
- num imp dec2flt decimal seq number of digits decimal left shift
- num imp dec2flt decimal seq number of digits decimal left shift TABLE
- num imp dec2flt decimal seq number of digits decimal left shift TABLE POW5
- num imp dec2flt decimal seq parse decimal exponent
- num imp dec2flt decimal seq parse decimal seq
- num imp dec2flt decimal seq parse digits into seq
- num imp dec2flt slow parse long mantissa
- num imp dec2flt slow parse long mantissa MAX SHIFT
- num imp dec2flt slow parse long mantissa NUM POWERS
- num imp dec2flt slow parse long mantissa POWERS
- num imp dec2flt slow parse long mantissa closure
- num imp dec2flt slow parse long mantissa closure Insts CoreOpsFunctionFnTupleUsizeUsize call
- num imp traits CastInto
- num imp traits Float
- num imp traits Float EXP BIAS default
- num imp traits Float EXP BITS default
- num imp traits Float EXP MIN default
- num imp traits Float EXP SAT default
- num imp traits Float SIG BITS default
- num imp traits Int
Technical checking records
Local closure summary
{
"node": "P804_T1_LeftLoopStep",
"closure_version": "patch_c_v1",
"active_decl_hash": "ded94ac66ca9e83bcd5644f89cda2b4e63112db0c198af36bbfa89a8daad23ec",
"active_statement_hash": "88d3a658c7d9eeeb77e0a25c6211fe2fd6ae04bcad2fed5349299d5f13c65c55",
"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-192",
"boundary_theorems": {},
"strict_theorem_deps": {
"DecimalLeftShiftLoop1Execution": "c945a26c8d67077b",
"DecimalSeqLeftShiftCanonical": "bcdb7c96b3a59e9d",
"P804_T1_LeftLeadingProgress": "fb2f46fb0f6f403d",
"P804_T1_LeftShiftPointGrowth": "6a9a6c7c27a2ac4e",
"P804_T1_PointMinusOneGrowth": "431f2d39adc7b497",
"P804_T1_PointZeroGrowth": "8e1fc1c4da087135",
"P804_T1_SelectedLeftGrowth": "22f870b26a133ec7",
"SlowShiftSelectorCertificate": "963b7a2e670856e8",
"num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE": "01b84a7a35e5bcf4",
"num_imp_dec2flt_slow_parse_long_mantissa": "adfe9a4161cd7fd6"
},
"strict_definition_deps": {
"F64": "ec4e25fbaf4e11d4",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64": "94095c9bf79da164",
"SlowShiftSelectorCertificate": "7ebc2b39d69850c4",
"num_imp_dec2flt_common_BiasedFp": "63baac539d218a81",
"num_imp_dec2flt_decimal_seq_DecimalSeq": "eaf981d0a5d9f472",
"num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE": "0cc5155758bc976a",
"num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift": "fd298e37d5ae4f86",
"num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift": "b3efbd0e6b3fe061",
"num_imp_dec2flt_slow_parse_long_mantissa": "c03771a4216d102f",
"num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call": "7df8a2c8e3717790"
}
}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:77ab2586467aa47274cfa124807948af1b97e4f82bdbd94d4412e6c1ad4ce7ac",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"substantiveness_status": "Pass"
}