Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Helper · Recovering a successful loop-1 continuation
Lean statement
Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.
import Tablet.P826_T1_RightBodySelector
import Tablet.P804_T1_LeftLoopStep
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P826_T1_LeftBodySelector]
theorem P826_T1_LeftBodySelector
(d d' : num.imp.dec2flt.decimal_seq.DecimalSeq)
(e e' : Std.I32) (z : Nat)
(hp : d.decimal_point.val <= 0)
(hzLo : 1 <= z) (hzHi : z < 10)
(hhead : d.digits.val[0].val = z)
(hbody :
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 e none =
ok (cont (d'.num_digits, d'.decimal_point, d'.truncated,
d'.digits, e', none))) :
exists shift : Std.Usize,
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift d shift = ok d' /\
shift.val <= 60 /\
e'.val = e.val - (shift.val : Int) /\
((d.decimal_point.val < 0 /\
exists n : Std.Usize,
(n.val : Int) = -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)) := by
Proof
Natural-language proof
The status above describes the Lean proof. Its explanatory prose may remain a sketch after that proof closes.
Explanatory prose status
Prose retained as authored. The explanatory prose is preserved as it stood when captured.
Proof
Lean proof
let 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 choose_spec (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
unfold num.imp.dec2flt.slow.parse_long_mantissa_loop1.body at hbody
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] at hbody
simp only [show (none : Option num.imp.dec2flt.common.BiasedFp).isNone =
true by rfl, if_true] at hbody
by_cases hp0 : d.decimal_point.val = 0
· have hpeq : d.decimal_point = 0#i32 :=
IScalar.eq_of_val_eq (by simpa using hp0)
rw [hpeq] at hbody
simp only [if_true] at hbody
cases hread : Array.index_usize d.digits 0#usize with
| fail err => simp [hread] at hbody
| div => simp [hread] at hbody
| ok head =>
rw [hread] at hbody
simp only [bind_tc_ok] at hbody
have hheadEq : head.val = z := by
have hs := Array.index_usize_spec d.digits 0#usize (by
simp [Array.length])
rw [hread] at hs
simp only [WP.spec_ok] at hs
rw [← hhead]
congr
have hnotge : ¬ head >= 5#u8 := by
by_contra hge
simp [hge] at hbody
simp only [hnotge, if_false] at hbody
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]
rw [hdZeroEta] at hbody
let State := Std.Usize × Std.I32 × Bool × Array Std.U8 768#usize ×
Std.I32 × Option num.imp.dec2flt.common.BiasedFp
have finish (shift : Std.Usize) (hshift60 : shift.val <= 60)
(hselect : shift = if z = 1 then 2#usize else 1#usize)
(htail :
(do
let q ←
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift d shift
if q.decimal_point >
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
then
ok (cont (q.num_digits, q.decimal_point, q.truncated,
q.digits, e,
some ({ m := 0#u64, p_biased := 2047#i32 } :
num.imp.dec2flt.common.BiasedFp)) : ControlFlow State State)
else
let shiftI ← lift (UScalar.hcast .I32 shift)
let eout ← e - shiftI
ok (cont (q.num_digits, q.decimal_point, q.truncated,
q.digits, eout, none) : ControlFlow State State)) =
ok (cont (d'.num_digits, d'.decimal_point, d'.truncated,
d'.digits, e', none) : ControlFlow State State)) :
exists shift : Std.Usize,
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift d shift = ok d' /\
shift.val <= 60 /\
e'.val = e.val - (shift.val : Int) /\
((d.decimal_point.val < 0 /\
exists n : Std.Usize,
(n.val : Int) = -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)) := by
cases hleft :
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift d shift with
| fail err => simp [hleft] at htail
| div => simp [hleft] at htail
| ok q =>
rw [hleft] at htail
simp only [bind_tc_ok] at htail
by_cases hover : q.decimal_point >
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
· simp only [hover, if_true] at htail
have hstate := Result.ok.inj htail
have htuple := ControlFlow.cont.inj hstate
have hopt := congrArg (fun x : State => x.2.2.2.2.2) htuple
simp at hopt
· simp only [hover, if_false] at htail
let shiftI : Std.I32 := UScalar.hcast .I32 shift
rw [show UScalar.hcast .I32 shift = shiftI by rfl] at htail
simp only [lift, bind_tc_ok] at htail
cases hsub : e - shiftI with
| fail err => simp [hsub] at htail
| div => simp [hsub] at htail
| ok eout =>
rw [hsub] at htail
simp only [bind_tc_ok] at htail
have hstate := Result.ok.inj htail
have htuple := ControlFlow.cont.inj hstate
have hq : q = d' := by
have hnum := congrArg (fun x : State => x.1) htuple
have hpnt := congrArg (fun x : State => x.2.1) htuple
have htr := congrArg (fun x : State => x.2.2.1) htuple
have hdig := congrArg (fun x : State => x.2.2.2.1) htuple
cases q
cases d'
simp_all only
have heout : eout = e' :=
congrArg (fun x : State => x.2.2.2.2.1) htuple
subst q
subst eout
have hcast := UScalar.hcast_inBounds_spec .I32 shift (by
rw [IScalar.max_I32_eq]
omega)
simp only [lift, WP.spec_ok] at hcast
have hsubVal := IScalar.sub_equiv e shiftI
rw [hsub] at hsubVal
refine ⟨shift, hleft, hshift60, ?_, Or.inr ⟨hp0, ?_,
hselect⟩⟩
· rw [hsubVal.2.1]
simpa [shiftI] using hcast
· change ¬ head.val >= 5 at hnotge
omega
split at hbody
· change 0 = z at hheadEq
omega
· have hz1 : z = 1 := by
change 1 = z at hheadEq
omega
simp only [bind_tc_ok] at hbody
exact finish 2#usize (by norm_num) (by rw [hz1]; rfl) hbody
· have hz1 : z ≠ 1 := by
intro hz
have hu : head = 1#u8 := by
apply UScalar.eq_of_val_eq
rw [hheadEq, hz]
norm_num [UScalar.cast_val_eq]
contradiction
simp only [bind_tc_ok] at hbody
exact finish 1#usize (by norm_num) (by simp only [if_neg hz1]) hbody
· have hpneg : d.decimal_point.val < 0 := by omega
have hpne : ¬ d.decimal_point = 0#i32 := by
intro h
have := congrArg IScalar.val h
simp at this
omega
simp only [hpne, if_false] at hbody
cases hneg : -. d.decimal_point with
| fail err => simp [hneg] at hbody
| div => simp [hneg] at hbody
| ok negp =>
rw [hneg] at hbody
simp only [bind_tc_ok, lift] at hbody
let n : Std.Usize := IScalar.hcast .Usize negp
rw [show IScalar.hcast .Usize negp = n by rfl] at hbody
cases hsel :
num.imp.dec2flt.slow.parse_long_mantissa.closure.Insts.CoreOpsFunctionFnTupleUsizeUsize.call
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 () n with
| fail err => simp [hsel] at hbody
| div => simp [hsel] at hbody
| ok shift =>
rw [hsel] at hbody
simp only [bind_tc_ok] at hbody
cases hleft : num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift d shift with
| fail err => simp [hleft] at hbody
| div => simp [hleft] at hbody
| ok q =>
rw [hleft] at hbody
simp only [bind_tc_ok] at hbody
by_cases hover : q.decimal_point >
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
· simp [hover] at hbody
· simp only [hover, if_false, lift] at hbody
let shiftI : Std.I32 := UScalar.hcast .I32 shift
rw [show UScalar.hcast .I32 shift = shiftI by rfl] at hbody
cases hsub : e - shiftI with
| fail err => simp [hsub] at hbody
| div => simp [hsub] at hbody
| ok eout =>
rw [hsub] at hbody
simp only [bind_tc_ok] at hbody
have hstate := Result.ok.inj hbody
simp only [ControlFlow.cont.injEq, Prod.mk.injEq] at hstate
have hq : q = d' := by
cases q
cases d'
simp only [num.imp.dec2flt.decimal_seq.DecimalSeq.mk.injEq]
tauto
have heout : eout = e' := by tauto
subst q
subst eout
have hcert := SlowShiftSelectorCertificate
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 n
let k : Std.Usize := match n.val with
| 0 => 0#usize | 1 => 3#usize | 2 => 6#usize
| 3 => 9#usize | 4 => 13#usize | 5 => 16#usize
| 6 => 19#usize | 7 => 23#usize | 8 => 26#usize
| 9 => 29#usize | 10 => 33#usize | 11 => 36#usize
| 12 => 39#usize | 13 => 43#usize | 14 => 46#usize
| 15 => 49#usize | 16 => 53#usize | 17 => 56#usize
| 18 => 59#usize | _ => 60#usize
change _ = ok k /\ k.val <= 60 /\ _ at hcert
have hk : k = shift := Result.ok.inj (hcert.1.symm.trans hsel)
rw [hk] at hcert
change IScalar.neg d.decimal_point = ok negp at hneg
unfold IScalar.neg at hneg
have hnegVal := IScalar.tryMk_eq .I32
(-d.decimal_point.val)
rw [hneg] at hnegVal
have hnval := IScalar.hcast_inBounds_spec .Usize negp (by
rw [hnegVal.1]
constructor <;> scalar_tac)
simp only [lift, WP.spec_ok] at hnval
have hnInt : (n.val : Int) = -d.decimal_point.val := by
simpa [n, hnegVal.1] using hnval
have hcast := UScalar.hcast_inBounds_spec .I32 shift (by
rw [IScalar.max_I32_eq]
omega)
simp only [lift, WP.spec_ok] at hcast
have hsubVal := IScalar.sub_equiv e shiftI
rw [hsub] at hsubVal
refine ⟨shift, hleft, hcert.2.1, ?_, Or.inl ⟨hpneg, n,
hnInt, hsel⟩⟩
rw [hsubVal.2.1]
simpa [shiftI] using hcast
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.P826_T1_RightBodySelector
import Tablet.P804_T1_LeftLoopStep
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P826_T1_LeftBodySelector]
theorem P826_T1_LeftBodySelector
(d d' : num.imp.dec2flt.decimal_seq.DecimalSeq)
(e e' : Std.I32) (z : Nat)
(hp : d.decimal_point.val <= 0)
(hzLo : 1 <= z) (hzHi : z < 10)
(hhead : d.digits.val[0].val = z)
(hbody :
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 e none =
ok (cont (d'.num_digits, d'.decimal_point, d'.truncated,
d'.digits, e', none))) :
exists shift : Std.Usize,
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift d shift = ok d' /\
shift.val <= 60 /\
e'.val = e.val - (shift.val : Int) /\
((d.decimal_point.val < 0 /\
exists n : Std.Usize,
(n.val : Int) = -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)) := by
-- BODY
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 choose_spec (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
unfold num.imp.dec2flt.slow.parse_long_mantissa_loop1.body at hbody
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] at hbody
simp only [show (none : Option num.imp.dec2flt.common.BiasedFp).isNone =
true by rfl, if_true] at hbody
by_cases hp0 : d.decimal_point.val = 0
· have hpeq : d.decimal_point = 0#i32 :=
IScalar.eq_of_val_eq (by simpa using hp0)
rw [hpeq] at hbody
simp only [if_true] at hbody
cases hread : Array.index_usize d.digits 0#usize with
| fail err => simp [hread] at hbody
| div => simp [hread] at hbody
| ok head =>
rw [hread] at hbody
simp only [bind_tc_ok] at hbody
have hheadEq : head.val = z := by
have hs := Array.index_usize_spec d.digits 0#usize (by
simp [Array.length])
rw [hread] at hs
simp only [WP.spec_ok] at hs
rw [← hhead]
congr
have hnotge : ¬ head >= 5#u8 := by
by_contra hge
simp [hge] at hbody
simp only [hnotge, if_false] at hbody
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]
rw [hdZeroEta] at hbody
let State := Std.Usize × Std.I32 × Bool × Array Std.U8 768#usize ×
Std.I32 × Option num.imp.dec2flt.common.BiasedFp
have finish (shift : Std.Usize) (hshift60 : shift.val <= 60)
(hselect : shift = if z = 1 then 2#usize else 1#usize)
(htail :
(do
let q ←
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift d shift
if q.decimal_point >
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
then
ok (cont (q.num_digits, q.decimal_point, q.truncated,
q.digits, e,
some ({ m := 0#u64, p_biased := 2047#i32 } :
num.imp.dec2flt.common.BiasedFp)) : ControlFlow State State)
else
let shiftI ← lift (UScalar.hcast .I32 shift)
let eout ← e - shiftI
ok (cont (q.num_digits, q.decimal_point, q.truncated,
q.digits, eout, none) : ControlFlow State State)) =
ok (cont (d'.num_digits, d'.decimal_point, d'.truncated,
d'.digits, e', none) : ControlFlow State State)) :
exists shift : Std.Usize,
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift d shift = ok d' /\
shift.val <= 60 /\
e'.val = e.val - (shift.val : Int) /\
((d.decimal_point.val < 0 /\
exists n : Std.Usize,
(n.val : Int) = -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)) := by
cases hleft :
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift d shift with
| fail err => simp [hleft] at htail
| div => simp [hleft] at htail
| ok q =>
rw [hleft] at htail
simp only [bind_tc_ok] at htail
by_cases hover : q.decimal_point >
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
· simp only [hover, if_true] at htail
have hstate := Result.ok.inj htail
have htuple := ControlFlow.cont.inj hstate
have hopt := congrArg (fun x : State => x.2.2.2.2.2) htuple
simp at hopt
· simp only [hover, if_false] at htail
let shiftI : Std.I32 := UScalar.hcast .I32 shift
rw [show UScalar.hcast .I32 shift = shiftI by rfl] at htail
simp only [lift, bind_tc_ok] at htail
cases hsub : e - shiftI with
| fail err => simp [hsub] at htail
| div => simp [hsub] at htail
| ok eout =>
rw [hsub] at htail
simp only [bind_tc_ok] at htail
have hstate := Result.ok.inj htail
have htuple := ControlFlow.cont.inj hstate
have hq : q = d' := by
have hnum := congrArg (fun x : State => x.1) htuple
have hpnt := congrArg (fun x : State => x.2.1) htuple
have htr := congrArg (fun x : State => x.2.2.1) htuple
have hdig := congrArg (fun x : State => x.2.2.2.1) htuple
cases q
cases d'
simp_all only
have heout : eout = e' :=
congrArg (fun x : State => x.2.2.2.2.1) htuple
subst q
subst eout
have hcast := UScalar.hcast_inBounds_spec .I32 shift (by
rw [IScalar.max_I32_eq]
omega)
simp only [lift, WP.spec_ok] at hcast
have hsubVal := IScalar.sub_equiv e shiftI
rw [hsub] at hsubVal
refine ⟨shift, hleft, hshift60, ?_, Or.inr ⟨hp0, ?_,
hselect⟩⟩
· rw [hsubVal.2.1]
simpa [shiftI] using hcast
· change ¬ head.val >= 5 at hnotge
omega
split at hbody
· change 0 = z at hheadEq
omega
· have hz1 : z = 1 := by
change 1 = z at hheadEq
omega
simp only [bind_tc_ok] at hbody
exact finish 2#usize (by norm_num) (by rw [hz1]; rfl) hbody
· have hz1 : z ≠ 1 := by
intro hz
have hu : head = 1#u8 := by
apply UScalar.eq_of_val_eq
rw [hheadEq, hz]
norm_num [UScalar.cast_val_eq]
contradiction
simp only [bind_tc_ok] at hbody
exact finish 1#usize (by norm_num) (by simp only [if_neg hz1]) hbody
· have hpneg : d.decimal_point.val < 0 := by omega
have hpne : ¬ d.decimal_point = 0#i32 := by
intro h
have := congrArg IScalar.val h
simp at this
omega
simp only [hpne, if_false] at hbody
cases hneg : -. d.decimal_point with
| fail err => simp [hneg] at hbody
| div => simp [hneg] at hbody
| ok negp =>
rw [hneg] at hbody
simp only [bind_tc_ok, lift] at hbody
let n : Std.Usize := IScalar.hcast .Usize negp
rw [show IScalar.hcast .Usize negp = n by rfl] at hbody
cases hsel :
num.imp.dec2flt.slow.parse_long_mantissa.closure.Insts.CoreOpsFunctionFnTupleUsizeUsize.call
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 () n with
| fail err => simp [hsel] at hbody
| div => simp [hsel] at hbody
| ok shift =>
rw [hsel] at hbody
simp only [bind_tc_ok] at hbody
cases hleft : num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift d shift with
| fail err => simp [hleft] at hbody
| div => simp [hleft] at hbody
| ok q =>
rw [hleft] at hbody
simp only [bind_tc_ok] at hbody
by_cases hover : q.decimal_point >
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
· simp [hover] at hbody
· simp only [hover, if_false, lift] at hbody
let shiftI : Std.I32 := UScalar.hcast .I32 shift
rw [show UScalar.hcast .I32 shift = shiftI by rfl] at hbody
cases hsub : e - shiftI with
| fail err => simp [hsub] at hbody
| div => simp [hsub] at hbody
| ok eout =>
rw [hsub] at hbody
simp only [bind_tc_ok] at hbody
have hstate := Result.ok.inj hbody
simp only [ControlFlow.cont.injEq, Prod.mk.injEq] at hstate
have hq : q = d' := by
cases q
cases d'
simp only [num.imp.dec2flt.decimal_seq.DecimalSeq.mk.injEq]
tauto
have heout : eout = e' := by tauto
subst q
subst eout
have hcert := SlowShiftSelectorCertificate
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 n
let k : Std.Usize := match n.val with
| 0 => 0#usize | 1 => 3#usize | 2 => 6#usize
| 3 => 9#usize | 4 => 13#usize | 5 => 16#usize
| 6 => 19#usize | 7 => 23#usize | 8 => 26#usize
| 9 => 29#usize | 10 => 33#usize | 11 => 36#usize
| 12 => 39#usize | 13 => 43#usize | 14 => 46#usize
| 15 => 49#usize | 16 => 53#usize | 17 => 56#usize
| 18 => 59#usize | _ => 60#usize
change _ = ok k /\ k.val <= 60 /\ _ at hcert
have hk : k = shift := Result.ok.inj (hcert.1.symm.trans hsel)
rw [hk] at hcert
change IScalar.neg d.decimal_point = ok negp at hneg
unfold IScalar.neg at hneg
have hnegVal := IScalar.tryMk_eq .I32
(-d.decimal_point.val)
rw [hneg] at hnegVal
have hnval := IScalar.hcast_inBounds_spec .Usize negp (by
rw [hnegVal.1]
constructor <;> scalar_tac)
simp only [lift, WP.spec_ok] at hnval
have hnInt : (n.val : Int) = -d.decimal_point.val := by
simpa [n, hnegVal.1] using hnval
have hcast := UScalar.hcast_inBounds_spec .I32 shift (by
rw [IScalar.max_I32_eq]
omega)
simp only [lift, WP.spec_ok] at hcast
have hsubVal := IScalar.sub_equiv e shiftI
rw [hsub] at hsubVal
refine ⟨shift, hleft, hcert.2.1, ?_, Or.inl ⟨hpneg, n,
hnInt, hsel⟩⟩
rw [hsubVal.2.1]
simpa [shiftI] using hcast
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
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
- 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
- F64
- F64 Insts CoreCloneClone
- F64 Insts CoreMarkerCopy
- F64 Insts CoreOpsArithDivF64F64
All 102 entries
- Binary64Model
- Binary64ModelDefault
- 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
- LeftBodySelector
- Preamble
- 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": "P826_T1_LeftBodySelector",
"closure_version": "patch_c_v1",
"active_decl_hash": "1e710d940b1810991a730f3111c006e451ec61be1d7a472f90e673920497d171",
"active_statement_hash": "2c34045ab60b4750e52196725b38dfb3abb310a8e06258f37b0191e3cb01804d",
"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": "revalidate-cycle-194",
"boundary_theorems": {},
"strict_theorem_deps": {
"SlowShiftSelectorCertificate": "963b7a2e670856e8",
"num_imp_dec2flt_decimal_seq_DecimalSeq": "3c283430b9003d37",
"num_imp_dec2flt_slow_parse_long_mantissa": "0eb6fb2627d0ff5c"
},
"strict_definition_deps": {
"F64": "ec4e25fbaf4e11d4",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64": "94095c9bf79da164",
"SlowShiftSelectorCertificate": "7ebc2b39d69850c4",
"num_imp_dec2flt_common_BiasedFp": "c43614ff2149ecf2",
"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_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:e183667c7947bcbb1a5f8822517f92f6d36b0ea4d0c6bca169198289f6630811",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"substantiveness_status": "Pass"
}