Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Helper · Exact semantics of the first decimal left-shift loop
left_shift_loop0, started with Boolean b,
array a, shift k, read index n, write index w, and zero carry,
returns (b',a',q,c), then there is a list of natural digits
e=(e_0,\ldots,e_{n-1}) such that
Lean statement
Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.
import Tablet.ResultLoopPartial
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalLeftShiftFirstLoopSemantics]
theorem DecimalLeftShiftFirstLoopSemantics
(a a' : Array Std.U8 768#usize) (b b' : Bool)
(shift read write q : Std.Usize) (carry : Std.U64)
(hshift : shift.val <= 60)
(hread : read.val <= 768)
(hwrite : read.val <= write.val)
(hdigit : forall z, z ∈ a.val.take read.val -> z.val < 10)
(hloop :
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0
b a shift read write 0#u64 = ok (b', a', q, carry)) :
let xs := (a.val.take read.val).map (fun z => z.val)
let I := xs.foldl (fun acc z => 10 * acc + z) 0
exists outDigits : List Nat,
outDigits.length = read.val /\
(forall z, z ∈ outDigits -> z < 10) /\
q.val + read.val = write.val /\
carry.val < 2 ^ shift.val /\
2 ^ shift.val * I =
carry.val * 10 ^ read.val +
outDigits.foldl (fun acc z => 10 * acc + z) 0 /\
(forall j, j < outDigits.length -> q.val + j < 768 ->
(a'.val.map (fun z => z.val))[q.val + j]? = outDigits[j]?) /\
(forall j, j < 768 -> (j < q.val \/ write.val <= j) ->
a'.val[j]? = a.val[j]?) /\
(b' = true <-> b = true \/
exists j, j < outDigits.length /\ 768 <= q.val + j /\
outDigits[j]? ≠ some 0) := 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
let xs := (a.val.take read.val).map (fun z => z.val)
let F := fun ys : List Nat =>
ys.foldl (fun acc z => 10 * acc + z) 0
let B := 2 ^ shift.val
have hBpos : 0 < B := by simp [B]
have hBle : B <= 2 ^ 60 := by
exact Nat.pow_le_pow_right (by omega) hshift
have hxslen : xs.length = read.val := by
simp [xs, hread, a.property]
have hxdigit : forall z, z ∈ xs -> z < 10 := by
intro z hz
simp only [xs, List.mem_map] at hz
rcases hz with ⟨u, hu, rfl⟩
exact hdigit u hu
have foldlFrom (ys : List Nat) (acc : Nat) :
ys.foldl (fun n z => 10 * n + z) acc =
acc * 10 ^ ys.length + F ys := by
induction ys generalizing acc with
| nil => simp [F]
| cons y ys ih =>
simp only [List.foldl_cons, List.length_cons]
rw [ih, pow_succ]
change (10 * acc + y) * 10 ^ ys.length + F ys =
acc * (10 ^ ys.length * 10) +
(y :: ys).foldl (fun n z => 10 * n + z) 0
simp only [List.foldl_cons]
rw [ih]
ring
let Inv := fun (x : Bool × Array Std.U8 768#usize × Std.Usize ×
Std.Usize × Std.U64) =>
let (bc, ac, ri, wi, c) := x
ri.val <= read.val /\
wi.val + (read.val - ri.val) = write.val /\
c.val < B /\
exists outs : List Nat,
outs.length = read.val - ri.val /\
(forall z, z ∈ outs -> z < 10) /\
B * F (xs.drop ri.val) = c.val * 10 ^ outs.length + F outs /\
(forall j, j < outs.length -> wi.val + j < 768 ->
(ac.val.map (fun z : Std.U8 => z.val))[wi.val + j]? = outs[j]?) /\
(forall j, j < 768 -> (j < wi.val \/ write.val <= j) ->
ac.val[j]? = a.val[j]?) /\
(bc = true <-> b = true \/
exists j, j < outs.length /\ 768 <= wi.val + j /\
outs[j]? ≠ some 0)
let Post := fun (x : Bool × Array Std.U8 768#usize × Std.Usize × Std.U64) =>
let (bc, ac, wi, c) := x
exists outs : List Nat,
outs.length = read.val /\
(forall z, z ∈ outs -> z < 10) /\
wi.val + read.val = write.val /\
c.val < B /\
B * F xs = c.val * 10 ^ read.val + F outs /\
(forall j, j < outs.length -> wi.val + j < 768 ->
(ac.val.map (fun z : Std.U8 => z.val))[wi.val + j]? = outs[j]?) /\
(forall j, j < 768 -> (j < wi.val \/ write.val <= j) ->
ac.val[j]? = a.val[j]?) /\
(bc = true <-> b = true \/
exists j, j < outs.length /\ 768 <= wi.val + j /\
outs[j]? ≠ some 0)
let Body := fun (x : Bool × Array Std.U8 768#usize × Std.Usize ×
Std.Usize × Std.U64) =>
let (bc, ac, ri, wi, c) := x
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0.body
shift bc ac ri wi c
have hp : Post (b', a', q, carry) := by
refine ResultLoopPartial Inv Post Body ?_ (b, a, read, write, 0#u64)
(b', a', q, carry) ?_ ?_
· intro x hx r hr
rcases x with ⟨bc, ac, ri, wi, c⟩
simp only [Inv] at hx
rcases hx with ⟨hri, hwi, hcB, outs, houtslen, houtsdigit,
hnum, harr, houtside, hsticky⟩
simp only [Body,
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0.body] at hr
by_cases hri0 : ri.val = 0
· have hriEq : ri = 0#usize := UScalar.eq_of_val_eq (by simpa using hri0)
subst ri
simp at hr
subst r
simp only [Post]
refine ⟨outs, ?_, houtsdigit, ?_, hcB, ?_, harr, houtside, hsticky⟩
· omega
· omega
· simpa [xs, F, houtslen] using hnum
· have hripos : 0 < ri.val := by omega
have hrine : ri != 0#usize := by
simp only [bne_iff_ne]
intro h
apply hri0
simpa [h]
obtain ⟨ri1, hri1, hri1val⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := ri) (y := 1#usize) (by simpa using hripos))
norm_num at hri1val
have hriwi : ri.val <= wi.val := by omega
have hwipos : 0 < wi.val := by omega
obtain ⟨wi1, hwi1, hwi1val⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := wi) (y := 1#usize) (by simpa using hwipos))
norm_num at hwi1val
have hri1lt : ri1.val < ac.val.length := by
rw [ac.property]
norm_num
omega
obtain ⟨digit, hdigitRead, hdigitReadVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(Array.index_usize_spec ac ri1
(by simpa [Array.length] using hri1lt))
rw [hri1, hwi1] at hr
simp only [hrine, if_true, bind_tc_ok] at hr
rw [hdigitRead] at hr
have hri1ltRead : ri1.val < read.val := by omega
have hxdrop := List.drop_eq_getElem_cons
(l := xs) (i := ri1.val) (by omega)
have hriSucc : ri1.val + 1 = ri.val := by omega
rw [hriSucc] at hxdrop
have hxin : xs[ri1.val] < 10 := hxdigit _ (List.getElem_mem _)
have hdigitVal : digit.val = xs[ri1.val] := by
have hacOrig : ac.val[ri1.val]? = a.val[ri1.val]? := by
apply houtside ri1.val (by omega)
left
omega
have hacGet : ac.val[ri1.val]? = some digit :=
getElem?_eq_some_iff.mpr ⟨hri1lt, hdigitReadVal.symm⟩
have haGet : a.val[ri1.val]? = some digit := by
rw [← hacOrig]
exact hacGet
have haBound : ri1.val < a.val.length := by
have haLen : a.val.length = 768 := by simpa using a.property
rw [haLen]
omega
have haVal : a.val[ri1.val]'haBound = digit := by
have hsome := List.getElem?_eq_getElem haBound
rw [haGet] at hsome
exact Option.some.inj hsome.symm
have hxsVal : xs[ri1.val]'(by omega) =
(a.val[ri1.val]'haBound).val := by
simp [xs]
rw [hxsVal, haVal]
have hdigitLt : digit.val < 10 := by omega
let digit64 : Std.U64 := UScalar.cast .U64 digit
have hdigit64 : digit64.val = digit.val := by
simp [digit64, UScalar.cast_val_eq]
simp only [bind_tc_ok, lift] at hr
rw [show UScalar.cast .U64 digit = digit64 by rfl] at hr
have hshiftSpec := UScalar.ShiftLeft_spec digit64 shift (2 ^ 64)
(by norm_num [U64.numBits]; omega) (by norm_num [U64.size_eq])
cases hshiftEq : digit64 <<< shift with
| fail e => simp [hshiftEq] at hr
| div => simp [hshiftEq] at hr
| ok shifted =>
rw [hshiftEq] at hshiftSpec
have hshiftVal : shifted.val = digit.val * B := by
have hmulLt : digit.val * B < 2 ^ 64 := by
calc
digit.val * B <= 9 * 2 ^ 60 := Nat.mul_le_mul (by omega) hBle
_ < 2 ^ 64 := by norm_num
have hs := hshiftSpec.1
simp only [WP.spec_ok] at hs
rw [Nat.shiftLeft_eq, hdigit64, Nat.mod_eq_of_lt (by
simpa [B] using hmulLt)] at hs
simpa [B] using hs
simp only [hshiftEq, bind_tc_ok] at hr
have haddBound : c.val + shifted.val <= U64.max := by
rw [hshiftVal]
have hdigitMul : digit.val * B <= 9 * B :=
Nat.mul_le_mul_right B (by omega)
have : c.val + digit.val * B < 2 ^ 64 := by
calc
c.val + digit.val * B < B + 9 * B := by omega
_ = 10 * B := by ring
_ <= 10 * 2 ^ 60 := Nat.mul_le_mul_left 10 hBle
_ < 2 ^ 64 := by norm_num
norm_num [U64.max, U64.numBits]
omega
obtain ⟨total, htotal, htotalVal⟩ := Aeneas.Std.WP.spec_imp_exists
(U64.add_spec (x := c) (y := shifted) haddBound)
rw [htotal] at hr
simp only [bind_tc_ok] at hr
obtain ⟨quotient, hquotient, hquotientVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(U64.div_spec total (y := 10#u64) (by norm_num))
rw [hquotient] at hr
simp only [bind_tc_ok] at hr
have hmulBound : 10 * quotient.val <= U64.max := by
rw [hquotientVal]
have htotalLt : total.val < 2 ^ 64 := total.bv.isLt
have hqle : 10 * (total.val / 10) <= total.val :=
Nat.mul_div_le total.val 10
norm_num [U64.max, U64.numBits] at htotalLt ⊢
omega
obtain ⟨tenq, htenq, htenqVal⟩ := Aeneas.Std.WP.spec_imp_exists
(U64.mul_spec (x := 10#u64) (y := quotient) (by
simpa [Nat.mul_comm] using hmulBound))
rw [htenq] at hr
simp only [bind_tc_ok] at hr
have htenqLe : tenq.val <= total.val := by
rw [htenqVal, hquotientVal]
exact Nat.mul_div_le total.val 10
obtain ⟨rem, hrem, hremVal⟩ := Aeneas.Std.WP.spec_imp_exists
(U64.sub_spec (x := total) (y := tenq) htenqLe)
rw [hrem] at hr
simp only [bind_tc_ok] at hr
have htotalFormula : total.val = c.val + digit.val * B := by
rw [htotalVal, hshiftVal]
have hquotientFormula : quotient.val = total.val / 10 := hquotientVal
have hremFormula : rem.val = total.val % 10 := by
have htenqFormula : tenq.val = 10 * (total.val / 10) := by
rw [htenqVal, hquotientVal]
norm_num
have heuc := Nat.mod_add_div total.val 10
rw [hremVal.1, htenqFormula]
omega
have hremLt : rem.val < 10 := by
rw [hremFormula]
exact Nat.mod_lt _ (by omega)
have hquotientB : quotient.val < B := by
rw [hquotientFormula]
apply (Nat.div_lt_iff_lt_mul (by omega)).2
rw [htotalFormula]
have hdigitMul : digit.val * B <= 9 * B :=
Nat.mul_le_mul_right B (by omega)
omega
let newOuts := rem.val :: outs
have hnewlen : newOuts.length = read.val - ri1.val := by
simp [newOuts, houtslen]
omega
have hnewdigit : forall z, z ∈ newOuts -> z < 10 := by
intro z hz
simp only [newOuts, List.mem_cons] at hz
rcases hz with rfl | hz
· exact hremLt
· exact houtsdigit z hz
have hinputStep : F (xs.drop ri1.val) =
digit.val * 10 ^ outs.length + F (xs.drop ri.val) := by
have hdropLen : (xs.drop ri.val).length = outs.length := by
simp [hxslen, houtslen]
calc
F (xs.drop ri1.val) = F (xs[ri1.val] :: xs.drop ri.val) := by
rw [hxdrop]
_ = (xs.drop ri.val).foldl (fun n z => 10 * n + z)
xs[ri1.val] := by simp [F]
_ = xs[ri1.val] * 10 ^ (xs.drop ri.val).length +
F (xs.drop ri.val) := foldlFrom _ _
_ = digit.val * 10 ^ outs.length + F (xs.drop ri.val) := by
rw [hdigitVal, hdropLen]
have houtStep : F newOuts = rem.val * 10 ^ outs.length + F outs := by
simpa [newOuts, F] using foldlFrom outs rem.val
have hnumNew : B * F (xs.drop ri1.val) =
quotient.val * 10 ^ newOuts.length + F newOuts := by
have heuc : total.val = 10 * quotient.val + rem.val := by
rw [hquotientFormula, hremFormula]
have hmoddiv := Nat.mod_add_div total.val 10
omega
have hlenSucc : read.val - ri1.val = outs.length + 1 := by
rw [houtslen]
omega
calc
B * F (xs.drop ri1.val) =
(c.val + digit.val * B) * 10 ^ outs.length + F outs := by
rw [hinputStep]
calc
B * (digit.val * 10 ^ outs.length + F (xs.drop ri.val)) =
digit.val * B * 10 ^ outs.length +
B * F (xs.drop ri.val) := by ring
_ = (c.val + digit.val * B) * 10 ^ outs.length +
F outs := by rw [hnum]; ring
_ = total.val * 10 ^ outs.length + F outs := by
rw [htotalFormula]
_ = (10 * quotient.val + rem.val) * 10 ^ outs.length + F outs := by
rw [heuc]
_ = quotient.val * 10 ^ newOuts.length + F newOuts := by
rw [houtStep, hnewlen, hlenSucc, pow_succ]
ring
by_cases hcap : wi1.val < 768
· have hcastRem : (UScalar.cast .U8 rem).val = rem.val := by
simp [UScalar.cast_val_eq, Nat.mod_eq_of_lt (by omega : rem.val < 256)]
have hwibound : wi1.val < ac.val.length := by
have hacLen : ac.val.length = 768 := by simpa using ac.property
rw [hacLen]
exact hcap
obtain ⟨ac1, hac1, hac1Val⟩ := Aeneas.Std.WP.spec_imp_exists
(Array.update_spec ac wi1 (UScalar.cast .U8 rem)
(by simpa [Array.length] using hwibound))
have hcapWord : wi1 <
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def,
UScalar.lt_equiv] using hcap
simp only [hcapWord, if_true] at hr
rw [hac1] at hr
simp only [bind_tc_ok] at hr
cases hr
simp only [Inv]
refine ⟨?_, ?_, hquotientB, newOuts, hnewlen, hnewdigit,
hnumNew, ?_, ?_, ?_⟩
· omega
· omega
· intro j hj hpos
rw [hac1Val]
simp only [Aeneas.Std.Array.set, List.map_set, List.getElem?_set]
cases j with
| zero => simpa [newOuts, hcastRem] using hcap
| succ j =>
have hjold : j < outs.length := by
simp [newOuts] at hj
omega
have hidx : wi1.val + (j + 1) = wi.val + j := by omega
have hne : wi1.val ≠ wi.val + j := by omega
simp [newOuts, hidx, hne]
simpa using harr j hjold (by omega)
· intro j hj houtsideNew
rw [hac1Val]
simp only [Aeneas.Std.Array.set, List.getElem?_set]
have hne : wi1.val ≠ j := by omega
simp [hne]
apply houtside j hj
omega
· constructor
· intro htrue
have hold := hsticky.mp htrue
rcases hold with hb | ⟨j, hj, hjcap, hjnz⟩
· exact Or.inl hb
· right
refine ⟨j + 1, ?_, ?_, ?_⟩
· simp [newOuts]
omega
· omega
· simpa [newOuts]
· intro h
apply hsticky.mpr
rcases h with hb | ⟨j, hj, hjcap, hjnz⟩
· exact Or.inl hb
· right
cases j with
| zero => omega
| succ j =>
refine ⟨j, ?_, ?_, ?_⟩
· simp [newOuts] at hj
omega
· omega
· simpa [newOuts] using hjnz
· have hcapWord : ¬ wi1 <
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def,
UScalar.lt_equiv] using hcap
simp only [hcapWord, if_false] at hr
by_cases hrem0 : rem.val = 0
· have hremEq : rem = 0#u64 := UScalar.eq_of_val_eq (by simpa using hrem0)
have hnotgt : ¬ rem > 0#u64 := by simp [hremEq]
simp [hnotgt] at hr
subst r
simp only [Inv]
refine ⟨?_, ?_, hquotientB, newOuts, hnewlen, hnewdigit,
hnumNew, ?_, ?_, ?_⟩
· omega
· omega
· intro j hj hpos
cases j with
| zero => omega
| succ j =>
have hjold : j < outs.length := by
simp [newOuts] at hj
omega
have hidx : wi1.val + (j + 1) = wi.val + j := by omega
simpa [newOuts, hidx] using harr j hjold (by omega)
· intro j hj houtsideNew
apply houtside j hj
omega
· constructor
· intro htrue
have hold := hsticky.mp htrue
rcases hold with hb | ⟨j, hj, hjcap, hjnz⟩
· exact Or.inl hb
· right
refine ⟨j + 1, ?_, ?_, ?_⟩
· simp [newOuts]
omega
· omega
· simpa [newOuts]
· intro h
apply hsticky.mpr
rcases h with hb | ⟨j, hj, hjcap, hjnz⟩
· exact Or.inl hb
· right
cases j with
| zero => simp [newOuts, hrem0] at hjnz
| succ j =>
refine ⟨j, ?_, ?_, ?_⟩
· simp [newOuts] at hj
omega
· omega
· simpa [newOuts] using hjnz
· have hgt : rem > 0#u64 := by
change 0 < rem.val
omega
simp [hgt] at hr
subst r
simp only [Inv]
refine ⟨?_, ?_, hquotientB, newOuts, hnewlen, hnewdigit,
hnumNew, ?_, ?_, ?_⟩
· omega
· omega
· intro j hj hpos
cases j with
| zero => omega
| succ j =>
have hjold : j < outs.length := by
simp [newOuts] at hj
omega
have hidx : wi1.val + (j + 1) = wi.val + j := by omega
simpa [newOuts, hidx] using harr j hjold (by omega)
· intro j hj houtsideNew
apply houtside j hj
omega
· constructor
· intro _
right
refine ⟨0, by simp [newOuts], by omega, ?_⟩
simp [newOuts, hrem0]
· exact fun _ => True.intro
· simp only [Inv]
refine ⟨le_rfl, by simp, ?_, [], by simp, ?_, ?_, ?_, ?_, ?_⟩
· simpa [B] using hBpos
· intro z hz
simp at hz
· have hxdropAll : xs.drop read.val = [] :=
List.drop_eq_nil_of_le (by rw [hxslen])
simp [F, hxdropAll]
· intro j hj
simp at hj
· intro j hj houtside
trivial
· simp
· simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0, Body]
using hloop
simpa [Post, B, F, xs] using hp
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.ResultLoopPartial
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalLeftShiftFirstLoopSemantics]
theorem DecimalLeftShiftFirstLoopSemantics
(a a' : Array Std.U8 768#usize) (b b' : Bool)
(shift read write q : Std.Usize) (carry : Std.U64)
(hshift : shift.val <= 60)
(hread : read.val <= 768)
(hwrite : read.val <= write.val)
(hdigit : forall z, z ∈ a.val.take read.val -> z.val < 10)
(hloop :
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0
b a shift read write 0#u64 = ok (b', a', q, carry)) :
let xs := (a.val.take read.val).map (fun z => z.val)
let I := xs.foldl (fun acc z => 10 * acc + z) 0
exists outDigits : List Nat,
outDigits.length = read.val /\
(forall z, z ∈ outDigits -> z < 10) /\
q.val + read.val = write.val /\
carry.val < 2 ^ shift.val /\
2 ^ shift.val * I =
carry.val * 10 ^ read.val +
outDigits.foldl (fun acc z => 10 * acc + z) 0 /\
(forall j, j < outDigits.length -> q.val + j < 768 ->
(a'.val.map (fun z => z.val))[q.val + j]? = outDigits[j]?) /\
(forall j, j < 768 -> (j < q.val \/ write.val <= j) ->
a'.val[j]? = a.val[j]?) /\
(b' = true <-> b = true \/
exists j, j < outDigits.length /\ 768 <= q.val + j /\
outDigits[j]? ≠ some 0) := by
-- BODY
dsimp only
let xs := (a.val.take read.val).map (fun z => z.val)
let F := fun ys : List Nat =>
ys.foldl (fun acc z => 10 * acc + z) 0
let B := 2 ^ shift.val
have hBpos : 0 < B := by simp [B]
have hBle : B <= 2 ^ 60 := by
exact Nat.pow_le_pow_right (by omega) hshift
have hxslen : xs.length = read.val := by
simp [xs, hread, a.property]
have hxdigit : forall z, z ∈ xs -> z < 10 := by
intro z hz
simp only [xs, List.mem_map] at hz
rcases hz with ⟨u, hu, rfl⟩
exact hdigit u hu
have foldlFrom (ys : List Nat) (acc : Nat) :
ys.foldl (fun n z => 10 * n + z) acc =
acc * 10 ^ ys.length + F ys := by
induction ys generalizing acc with
| nil => simp [F]
| cons y ys ih =>
simp only [List.foldl_cons, List.length_cons]
rw [ih, pow_succ]
change (10 * acc + y) * 10 ^ ys.length + F ys =
acc * (10 ^ ys.length * 10) +
(y :: ys).foldl (fun n z => 10 * n + z) 0
simp only [List.foldl_cons]
rw [ih]
ring
let Inv := fun (x : Bool × Array Std.U8 768#usize × Std.Usize ×
Std.Usize × Std.U64) =>
let (bc, ac, ri, wi, c) := x
ri.val <= read.val /\
wi.val + (read.val - ri.val) = write.val /\
c.val < B /\
exists outs : List Nat,
outs.length = read.val - ri.val /\
(forall z, z ∈ outs -> z < 10) /\
B * F (xs.drop ri.val) = c.val * 10 ^ outs.length + F outs /\
(forall j, j < outs.length -> wi.val + j < 768 ->
(ac.val.map (fun z : Std.U8 => z.val))[wi.val + j]? = outs[j]?) /\
(forall j, j < 768 -> (j < wi.val \/ write.val <= j) ->
ac.val[j]? = a.val[j]?) /\
(bc = true <-> b = true \/
exists j, j < outs.length /\ 768 <= wi.val + j /\
outs[j]? ≠ some 0)
let Post := fun (x : Bool × Array Std.U8 768#usize × Std.Usize × Std.U64) =>
let (bc, ac, wi, c) := x
exists outs : List Nat,
outs.length = read.val /\
(forall z, z ∈ outs -> z < 10) /\
wi.val + read.val = write.val /\
c.val < B /\
B * F xs = c.val * 10 ^ read.val + F outs /\
(forall j, j < outs.length -> wi.val + j < 768 ->
(ac.val.map (fun z : Std.U8 => z.val))[wi.val + j]? = outs[j]?) /\
(forall j, j < 768 -> (j < wi.val \/ write.val <= j) ->
ac.val[j]? = a.val[j]?) /\
(bc = true <-> b = true \/
exists j, j < outs.length /\ 768 <= wi.val + j /\
outs[j]? ≠ some 0)
let Body := fun (x : Bool × Array Std.U8 768#usize × Std.Usize ×
Std.Usize × Std.U64) =>
let (bc, ac, ri, wi, c) := x
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0.body
shift bc ac ri wi c
have hp : Post (b', a', q, carry) := by
refine ResultLoopPartial Inv Post Body ?_ (b, a, read, write, 0#u64)
(b', a', q, carry) ?_ ?_
· intro x hx r hr
rcases x with ⟨bc, ac, ri, wi, c⟩
simp only [Inv] at hx
rcases hx with ⟨hri, hwi, hcB, outs, houtslen, houtsdigit,
hnum, harr, houtside, hsticky⟩
simp only [Body,
num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0.body] at hr
by_cases hri0 : ri.val = 0
· have hriEq : ri = 0#usize := UScalar.eq_of_val_eq (by simpa using hri0)
subst ri
simp at hr
subst r
simp only [Post]
refine ⟨outs, ?_, houtsdigit, ?_, hcB, ?_, harr, houtside, hsticky⟩
· omega
· omega
· simpa [xs, F, houtslen] using hnum
· have hripos : 0 < ri.val := by omega
have hrine : ri != 0#usize := by
simp only [bne_iff_ne]
intro h
apply hri0
simpa [h]
obtain ⟨ri1, hri1, hri1val⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := ri) (y := 1#usize) (by simpa using hripos))
norm_num at hri1val
have hriwi : ri.val <= wi.val := by omega
have hwipos : 0 < wi.val := by omega
obtain ⟨wi1, hwi1, hwi1val⟩ := Aeneas.Std.WP.spec_imp_exists
(UScalar.sub_spec (x := wi) (y := 1#usize) (by simpa using hwipos))
norm_num at hwi1val
have hri1lt : ri1.val < ac.val.length := by
rw [ac.property]
norm_num
omega
obtain ⟨digit, hdigitRead, hdigitReadVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(Array.index_usize_spec ac ri1
(by simpa [Array.length] using hri1lt))
rw [hri1, hwi1] at hr
simp only [hrine, if_true, bind_tc_ok] at hr
rw [hdigitRead] at hr
have hri1ltRead : ri1.val < read.val := by omega
have hxdrop := List.drop_eq_getElem_cons
(l := xs) (i := ri1.val) (by omega)
have hriSucc : ri1.val + 1 = ri.val := by omega
rw [hriSucc] at hxdrop
have hxin : xs[ri1.val] < 10 := hxdigit _ (List.getElem_mem _)
have hdigitVal : digit.val = xs[ri1.val] := by
have hacOrig : ac.val[ri1.val]? = a.val[ri1.val]? := by
apply houtside ri1.val (by omega)
left
omega
have hacGet : ac.val[ri1.val]? = some digit :=
getElem?_eq_some_iff.mpr ⟨hri1lt, hdigitReadVal.symm⟩
have haGet : a.val[ri1.val]? = some digit := by
rw [← hacOrig]
exact hacGet
have haBound : ri1.val < a.val.length := by
have haLen : a.val.length = 768 := by simpa using a.property
rw [haLen]
omega
have haVal : a.val[ri1.val]'haBound = digit := by
have hsome := List.getElem?_eq_getElem haBound
rw [haGet] at hsome
exact Option.some.inj hsome.symm
have hxsVal : xs[ri1.val]'(by omega) =
(a.val[ri1.val]'haBound).val := by
simp [xs]
rw [hxsVal, haVal]
have hdigitLt : digit.val < 10 := by omega
let digit64 : Std.U64 := UScalar.cast .U64 digit
have hdigit64 : digit64.val = digit.val := by
simp [digit64, UScalar.cast_val_eq]
simp only [bind_tc_ok, lift] at hr
rw [show UScalar.cast .U64 digit = digit64 by rfl] at hr
have hshiftSpec := UScalar.ShiftLeft_spec digit64 shift (2 ^ 64)
(by norm_num [U64.numBits]; omega) (by norm_num [U64.size_eq])
cases hshiftEq : digit64 <<< shift with
| fail e => simp [hshiftEq] at hr
| div => simp [hshiftEq] at hr
| ok shifted =>
rw [hshiftEq] at hshiftSpec
have hshiftVal : shifted.val = digit.val * B := by
have hmulLt : digit.val * B < 2 ^ 64 := by
calc
digit.val * B <= 9 * 2 ^ 60 := Nat.mul_le_mul (by omega) hBle
_ < 2 ^ 64 := by norm_num
have hs := hshiftSpec.1
simp only [WP.spec_ok] at hs
rw [Nat.shiftLeft_eq, hdigit64, Nat.mod_eq_of_lt (by
simpa [B] using hmulLt)] at hs
simpa [B] using hs
simp only [hshiftEq, bind_tc_ok] at hr
have haddBound : c.val + shifted.val <= U64.max := by
rw [hshiftVal]
have hdigitMul : digit.val * B <= 9 * B :=
Nat.mul_le_mul_right B (by omega)
have : c.val + digit.val * B < 2 ^ 64 := by
calc
c.val + digit.val * B < B + 9 * B := by omega
_ = 10 * B := by ring
_ <= 10 * 2 ^ 60 := Nat.mul_le_mul_left 10 hBle
_ < 2 ^ 64 := by norm_num
norm_num [U64.max, U64.numBits]
omega
obtain ⟨total, htotal, htotalVal⟩ := Aeneas.Std.WP.spec_imp_exists
(U64.add_spec (x := c) (y := shifted) haddBound)
rw [htotal] at hr
simp only [bind_tc_ok] at hr
obtain ⟨quotient, hquotient, hquotientVal⟩ :=
Aeneas.Std.WP.spec_imp_exists
(U64.div_spec total (y := 10#u64) (by norm_num))
rw [hquotient] at hr
simp only [bind_tc_ok] at hr
have hmulBound : 10 * quotient.val <= U64.max := by
rw [hquotientVal]
have htotalLt : total.val < 2 ^ 64 := total.bv.isLt
have hqle : 10 * (total.val / 10) <= total.val :=
Nat.mul_div_le total.val 10
norm_num [U64.max, U64.numBits] at htotalLt ⊢
omega
obtain ⟨tenq, htenq, htenqVal⟩ := Aeneas.Std.WP.spec_imp_exists
(U64.mul_spec (x := 10#u64) (y := quotient) (by
simpa [Nat.mul_comm] using hmulBound))
rw [htenq] at hr
simp only [bind_tc_ok] at hr
have htenqLe : tenq.val <= total.val := by
rw [htenqVal, hquotientVal]
exact Nat.mul_div_le total.val 10
obtain ⟨rem, hrem, hremVal⟩ := Aeneas.Std.WP.spec_imp_exists
(U64.sub_spec (x := total) (y := tenq) htenqLe)
rw [hrem] at hr
simp only [bind_tc_ok] at hr
have htotalFormula : total.val = c.val + digit.val * B := by
rw [htotalVal, hshiftVal]
have hquotientFormula : quotient.val = total.val / 10 := hquotientVal
have hremFormula : rem.val = total.val % 10 := by
have htenqFormula : tenq.val = 10 * (total.val / 10) := by
rw [htenqVal, hquotientVal]
norm_num
have heuc := Nat.mod_add_div total.val 10
rw [hremVal.1, htenqFormula]
omega
have hremLt : rem.val < 10 := by
rw [hremFormula]
exact Nat.mod_lt _ (by omega)
have hquotientB : quotient.val < B := by
rw [hquotientFormula]
apply (Nat.div_lt_iff_lt_mul (by omega)).2
rw [htotalFormula]
have hdigitMul : digit.val * B <= 9 * B :=
Nat.mul_le_mul_right B (by omega)
omega
let newOuts := rem.val :: outs
have hnewlen : newOuts.length = read.val - ri1.val := by
simp [newOuts, houtslen]
omega
have hnewdigit : forall z, z ∈ newOuts -> z < 10 := by
intro z hz
simp only [newOuts, List.mem_cons] at hz
rcases hz with rfl | hz
· exact hremLt
· exact houtsdigit z hz
have hinputStep : F (xs.drop ri1.val) =
digit.val * 10 ^ outs.length + F (xs.drop ri.val) := by
have hdropLen : (xs.drop ri.val).length = outs.length := by
simp [hxslen, houtslen]
calc
F (xs.drop ri1.val) = F (xs[ri1.val] :: xs.drop ri.val) := by
rw [hxdrop]
_ = (xs.drop ri.val).foldl (fun n z => 10 * n + z)
xs[ri1.val] := by simp [F]
_ = xs[ri1.val] * 10 ^ (xs.drop ri.val).length +
F (xs.drop ri.val) := foldlFrom _ _
_ = digit.val * 10 ^ outs.length + F (xs.drop ri.val) := by
rw [hdigitVal, hdropLen]
have houtStep : F newOuts = rem.val * 10 ^ outs.length + F outs := by
simpa [newOuts, F] using foldlFrom outs rem.val
have hnumNew : B * F (xs.drop ri1.val) =
quotient.val * 10 ^ newOuts.length + F newOuts := by
have heuc : total.val = 10 * quotient.val + rem.val := by
rw [hquotientFormula, hremFormula]
have hmoddiv := Nat.mod_add_div total.val 10
omega
have hlenSucc : read.val - ri1.val = outs.length + 1 := by
rw [houtslen]
omega
calc
B * F (xs.drop ri1.val) =
(c.val + digit.val * B) * 10 ^ outs.length + F outs := by
rw [hinputStep]
calc
B * (digit.val * 10 ^ outs.length + F (xs.drop ri.val)) =
digit.val * B * 10 ^ outs.length +
B * F (xs.drop ri.val) := by ring
_ = (c.val + digit.val * B) * 10 ^ outs.length +
F outs := by rw [hnum]; ring
_ = total.val * 10 ^ outs.length + F outs := by
rw [htotalFormula]
_ = (10 * quotient.val + rem.val) * 10 ^ outs.length + F outs := by
rw [heuc]
_ = quotient.val * 10 ^ newOuts.length + F newOuts := by
rw [houtStep, hnewlen, hlenSucc, pow_succ]
ring
by_cases hcap : wi1.val < 768
· have hcastRem : (UScalar.cast .U8 rem).val = rem.val := by
simp [UScalar.cast_val_eq, Nat.mod_eq_of_lt (by omega : rem.val < 256)]
have hwibound : wi1.val < ac.val.length := by
have hacLen : ac.val.length = 768 := by simpa using ac.property
rw [hacLen]
exact hcap
obtain ⟨ac1, hac1, hac1Val⟩ := Aeneas.Std.WP.spec_imp_exists
(Array.update_spec ac wi1 (UScalar.cast .U8 rem)
(by simpa [Array.length] using hwibound))
have hcapWord : wi1 <
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def,
UScalar.lt_equiv] using hcap
simp only [hcapWord, if_true] at hr
rw [hac1] at hr
simp only [bind_tc_ok] at hr
cases hr
simp only [Inv]
refine ⟨?_, ?_, hquotientB, newOuts, hnewlen, hnewdigit,
hnumNew, ?_, ?_, ?_⟩
· omega
· omega
· intro j hj hpos
rw [hac1Val]
simp only [Aeneas.Std.Array.set, List.map_set, List.getElem?_set]
cases j with
| zero => simpa [newOuts, hcastRem] using hcap
| succ j =>
have hjold : j < outs.length := by
simp [newOuts] at hj
omega
have hidx : wi1.val + (j + 1) = wi.val + j := by omega
have hne : wi1.val ≠ wi.val + j := by omega
simp [newOuts, hidx, hne]
simpa using harr j hjold (by omega)
· intro j hj houtsideNew
rw [hac1Val]
simp only [Aeneas.Std.Array.set, List.getElem?_set]
have hne : wi1.val ≠ j := by omega
simp [hne]
apply houtside j hj
omega
· constructor
· intro htrue
have hold := hsticky.mp htrue
rcases hold with hb | ⟨j, hj, hjcap, hjnz⟩
· exact Or.inl hb
· right
refine ⟨j + 1, ?_, ?_, ?_⟩
· simp [newOuts]
omega
· omega
· simpa [newOuts]
· intro h
apply hsticky.mpr
rcases h with hb | ⟨j, hj, hjcap, hjnz⟩
· exact Or.inl hb
· right
cases j with
| zero => omega
| succ j =>
refine ⟨j, ?_, ?_, ?_⟩
· simp [newOuts] at hj
omega
· omega
· simpa [newOuts] using hjnz
· have hcapWord : ¬ wi1 <
num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS := by
simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.MAX_DIGITS.eq_def,
UScalar.lt_equiv] using hcap
simp only [hcapWord, if_false] at hr
by_cases hrem0 : rem.val = 0
· have hremEq : rem = 0#u64 := UScalar.eq_of_val_eq (by simpa using hrem0)
have hnotgt : ¬ rem > 0#u64 := by simp [hremEq]
simp [hnotgt] at hr
subst r
simp only [Inv]
refine ⟨?_, ?_, hquotientB, newOuts, hnewlen, hnewdigit,
hnumNew, ?_, ?_, ?_⟩
· omega
· omega
· intro j hj hpos
cases j with
| zero => omega
| succ j =>
have hjold : j < outs.length := by
simp [newOuts] at hj
omega
have hidx : wi1.val + (j + 1) = wi.val + j := by omega
simpa [newOuts, hidx] using harr j hjold (by omega)
· intro j hj houtsideNew
apply houtside j hj
omega
· constructor
· intro htrue
have hold := hsticky.mp htrue
rcases hold with hb | ⟨j, hj, hjcap, hjnz⟩
· exact Or.inl hb
· right
refine ⟨j + 1, ?_, ?_, ?_⟩
· simp [newOuts]
omega
· omega
· simpa [newOuts]
· intro h
apply hsticky.mpr
rcases h with hb | ⟨j, hj, hjcap, hjnz⟩
· exact Or.inl hb
· right
cases j with
| zero => simp [newOuts, hrem0] at hjnz
| succ j =>
refine ⟨j, ?_, ?_, ?_⟩
· simp [newOuts] at hj
omega
· omega
· simpa [newOuts] using hjnz
· have hgt : rem > 0#u64 := by
change 0 < rem.val
omega
simp [hgt] at hr
subst r
simp only [Inv]
refine ⟨?_, ?_, hquotientB, newOuts, hnewlen, hnewdigit,
hnumNew, ?_, ?_, ?_⟩
· omega
· omega
· intro j hj hpos
cases j with
| zero => omega
| succ j =>
have hjold : j < outs.length := by
simp [newOuts] at hj
omega
have hidx : wi1.val + (j + 1) = wi.val + j := by omega
simpa [newOuts, hidx] using harr j hjold (by omega)
· intro j hj houtsideNew
apply houtside j hj
omega
· constructor
· intro _
right
refine ⟨0, by simp [newOuts], by omega, ?_⟩
simp [newOuts, hrem0]
· exact fun _ => True.intro
· simp only [Inv]
refine ⟨le_rfl, by simp, ?_, [], by simp, ?_, ?_, ?_, ?_, ?_⟩
· simpa [B] using hBpos
· intro z hz
simp at hz
· have hxdropAll : xs.drop read.val = [] :=
List.drop_eq_nil_of_le (by rw [hxslen])
simp [F, hxdropAll]
· intro j hj
simp at hj
· intro j hj houtside
trivial
· simp
· simpa [num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift_loop0, Body]
using hloop
simpa [Post, B, F, xs] using hp
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Inspect related source (116)
- 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
More program dependencies (83)
- left_shift_loop1 · dec2flt/decimal_seq.rs:152 Program Rust
- body · dec2flt/decimal_seq.rs:152 Program Rust
- DecimalSeq · dec2flt/decimal_seq.rs:21 Program Rust
- MAX_DIGITS · dec2flt/decimal_seq.rs:63 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
- number_of_digits_decimal_left_shift · dec2flt/decimal_seq.rs:368 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_long_mantissa · dec2flt/slow.rs:27 Program Rust
- parse_long_mantissa_loop0 · dec2flt/slow.rs:51 Program Rust
- 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
- from_u64 · dec2flt/mod.rs:263 Program Rust
- FloatErrorKind · num/mod.rs:18 Program Rust
- ParseFloatError · num/mod.rs:13 Program Rust
- Dec2FltAssemblyTrace · dec2flt/mod.rs:329 Program Rust
- Dec2FltTrace · dec2flt/mod.rs:295 Program Rust
- Lemire · dec2flt/mod.rs:115 Program Rust
- BiasedFp · dec2flt/common.rs:52 Program Rust
- zero_pow2 · dec2flt/common.rs:62 Program Rust
- ByteSlice · dec2flt/common.rs:4 Program Rust
- Decimal · dec2flt/decimal.rs:32 Program Rust
- DECIMAL_POINT_RANGE · dec2flt/decimal_seq.rs:67 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
- TABLE · dec2flt/decimal_seq.rs:370 Program Rust
- TABLE_POW5 · dec2flt/decimal_seq.rs:379 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
- CastInto · traits.rs:18 Program Rust
- Float · traits.rs:74 Program Rust
- FloatExt · traits.rs:170 Program Rust
- Int · traits.rs:27 Program Rust
- read_u64 · dec2flt/common.rs:18 Program Rust
- write_u64 · dec2flt/common.rs:25 Program Rust
- is_8digits · dec2flt/common.rs:40 Program Rust
- default · dec2flt/decimal_seq.rs:33 Program Rust
- MAX_DIGITS_WITHOUT_OVERFLOW · dec2flt/decimal_seq.rs:66 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
- 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
- try_add_digit · dec2flt/decimal_seq.rs:73 Program Rust
Standard-library dependencies (30)
- clone · core/src/clone.rs:698 Rust library
- div · core/src/ops/arith.rs:515 Rust library
- mul · core/src/ops/arith.rs:350 Rust library
- neg · core/src/ops/arith.rs:719 Rust library
- bitand · core/src/ops/bit.rs:178 Rust library
- bitor · core/src/ops/bit.rs:282 Rust library
- shl · core/src/ops/bit.rs:489 Rust library
- shr · core/src/ops/bit.rs:612 Rust library
- EXPONENT_MASK · core/src/num/f64.rs:615 Rust library
- INFINITY · core/src/num/f64.rs:512 Rust library
- MANTISSA_DIGITS · core/src/num/f64.rs:412 Rust library
- MANTISSA_MASK · core/src/num/f64.rs:637 Rust library
- NAN · core/src/num/f64.rs:509 Rust library
- NEG_INFINITY · core/src/num/f64.rs:515 Rust library
- classify · core/src/num/f64.rs:782 Rust library
- from_bits · core/src/num/f64.rs:1269 Rust library
- to_bits · core/src/num/f64.rs:1223 Rust library
- is_ascii_digit · core/src/num/mod.rs:958 Rust library
- from_residual · core/src/option.rs:2793 Rust library
- branch · core/src/option.rs:2779 Rust library
- first · core/src/slice/mod.rs:155 Rust library
- split_first · core/src/slice/mod.rs:198 Rust library
- as_bytes · core/src/str/mod.rs:498 Rust library
- FpCategory · core/src/num/mod.rs:1522 Rust library
- Div · core/src/ops/arith.rs:460 Rust library
- Mul · core/src/ops/arith.rs:322 Rust library
- Neg · core/src/ops/arith.rs:690 Rust library
- BitOr · core/src/ops/bit.rs:254 Rust library
- Shl · core/src/ops/bit.rs:461 Rust library
- Shr · core/src/ops/bit.rs:584 Rust library
Related source and models come from the extraction records and declared dependencies.
Proof assumptions and review
Lean checks the formal proof. Trellis also reviews how the statement corresponds to the intended requirement.
Transitive assumptions
- Classical.choice
- 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
- DecimalLeftShiftFirstLoopSemantics
- ResultLoopPartial
- num imp dec2flt decimal seq DecimalSeq
- num imp dec2flt decimal seq DecimalSeq MAX DIGITS
- num imp dec2flt decimal seq DecimalSeq left shift
- num imp dec2flt decimal seq DecimalSeq trim
All 9 entries
- DecimalLeftShiftFirstLoopSemantics
- ResultLoopPartial
- num imp dec2flt decimal seq DecimalSeq
- num imp dec2flt decimal seq DecimalSeq MAX DIGITS
- num imp dec2flt decimal seq DecimalSeq left shift
- num imp dec2flt decimal seq DecimalSeq trim
- 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
Technical checking records
Local closure summary
{
"node": "DecimalLeftShiftFirstLoopSemantics",
"closure_version": "patch_c_v1",
"active_decl_hash": "d4fdaa787b1e8e70d79c7e349b33444996a24393fa53d306e48b90a0eb02bb9e",
"active_statement_hash": "c13786246c0cff231a817b9b47bc015cb5d3c26d0640f03a9de1154756773aab",
"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-157",
"boundary_theorems": {},
"strict_theorem_deps": {
"ResultLoopPartial": "566d2aeb76ed9100",
"num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS": "0eb6fb2627d0ff5c",
"num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift": "0f3e5cc6a65d812e"
},
"strict_definition_deps": {
"ResultLoopPartial": "1b58e96ad00b23c2",
"num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS": "39f6cb231ef80388",
"num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift": "57f9712103d3acf6"
}
}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:77e6e79e483af23bd4706222f23916ebefde7155a716afa454651c721e203a6b",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"substantiveness_status": "Pass"
}