Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Lemma · Canonical nonreset right-shift result
Lean statement
Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.
import Tablet.P472_T1_DecimalSeqDyadicShiftSemantics
import Tablet.P472_T1_DecimalRightShiftPrefixLoopSemantics
import Tablet.P472_T1_DecimalRightShiftMainLoopSemantics
import Tablet.P472_T1_DecimalRightShiftFinalLoopSemantics
import Tablet.DecimalSeqTrimSemantics
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P495_T1_RightShiftCanonical]
theorem P495_T1_RightShiftCanonical (X Y : Real)
(d d' : num.imp.dec2flt.decimal_seq.DecimalSeq) (shift : Std.Usize)
(hshift : shift.val <= 60) (hcap : d.num_digits.val <= 768)
(hdigits : forall b, b ∈ d.digits.val.take d.num_digits.val -> b.val < 10)
(hhead : exists h tail,
(d.digits.val.take d.num_digits.val).map (fun b => b.val) = h :: tail /\
1 <= h /\ h < 10 /\ (h :: tail).length = d.num_digits.val)
(hcall : num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift d shift = ok d')
(hnonzero : d'.num_digits.val ≠ 0) :
let V := fun a : num.imp.dec2flt.decimal_seq.DecimalSeq =>
((((a.digits.val.take a.num_digits.val).map (fun b => b.val)).foldl
(fun n z => 10 * n + z) 0 : Nat) : Real) *
(10 : Real) ^ (a.decimal_point.val - (a.num_digits.val : Int))
(exists eta u : Real, X = V d + eta /\ Y = V d + u /\
0 <= eta /\ eta < u /\ (d.truncated = true <-> 0 < eta)) ->
-2047 <= d'.decimal_point.val /\ d'.num_digits.val <= 768 /\
(forall b, b ∈ d'.digits.val.take d'.num_digits.val -> b.val < 10) /\
(exists h tail,
(d'.digits.val.take d'.num_digits.val).map (fun b => b.val) = h :: tail /\
1 <= h /\ h < 10 /\ (h :: tail).length = d'.num_digits.val) /\
d'.digits.val[d'.num_digits.val - 1]? ≠ some 0#u8 /\
(exists eta' u' : Real,
X / (2 : Real) ^ shift.val = V d' + eta' /\
Y / (2 : Real) ^ shift.val = V d' + 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
intro hWitness
rcases hWitness with ⟨eta, u, hX, hY, heta0, hetau, hsticky⟩
have hVpos : 0 <
((((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
(fun n z => 10 * n + z) 0 : Nat) : Real) *
(10 : Real) ^ (d.decimal_point.val - (d.num_digits.val : Int)) := by
rcases hhead with ⟨h, tail, hshape, hpositive, _, _⟩
have hfoldNat : 0 <
((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
(fun n z => 10 * n + z) (0 : Nat) := by
rw [hshape]
change 0 < (h :: tail).foldl (fun n z => 10 * n + z) 0
have fold_ge : forall (zs : List Nat) (n : Nat),
n <= zs.foldl (fun a z => 10 * a + z) n := by
intro zs
induction zs with
| nil => intro n; simp
| cons z zs ih =>
intro n
simp only [List.foldl_cons]
have := ih (10 * n + z)
omega
have hmore : h <= tail.foldl (fun n z => 10 * n + z) h :=
fold_ge tail h
have hs : 0 < tail.foldl (fun n z => 10 * n + z) h :=
lt_of_lt_of_le hpositive hmore
simpa [List.foldl_cons] using hs
have hfold : 0 <
(((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
(fun n z => 10 * n + z) 0 : Nat) := hfoldNat
exact mul_pos (by exact_mod_cast hfold)
(zpow_pos (by norm_num) _)
have hprefixFacts : exists read acc,
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop0
d shift 0#usize 0#u64 false = ok (d, read, acc, false) /\
1 <= read.val /\ read.val <= d.num_digits.val + shift.val /\
2 ^ shift.val <= acc.val /\ acc.val < 10 * 2 ^ shift.val := by
have hcallAux := hcall
unfold num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift at hcallAux
cases hloop0 : num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop0
d shift 0#usize 0#u64 false with
| fail e => simp [hloop0] at hcallAux
| div => simp [hloop0] at hcallAux
| ok out0 =>
rcases out0 with ⟨d0, read, acc, allZero⟩
simp only [hloop0, bind_tc_ok] at hcallAux
have hpref := P472_T1_DecimalRightShiftPrefixLoopSemantics
d d0 shift read acc allZero hshift (by
have hp10 : 0 < (10 : Real) ^
(d.decimal_point.val - (d.num_digits.val : Int)) :=
zpow_pos (by norm_num) _
have hfoldReal : 0 <
(((d.digits.val.take d.num_digits.val).map
(fun b => b.val)).foldl (fun n z => 10 * n + z) 0 : Nat) := by
by_contra hn
have hnle :
((((d.digits.val.take d.num_digits.val).map
(fun b => b.val)).foldl (fun n z => 10 * n + z) 0 : Nat) : Real) <= 0 := by
exact_mod_cast (le_of_not_gt hn)
have hprod := mul_nonpos_of_nonpos_of_nonneg hnle (le_of_lt hp10)
have hprod' :
((((d.digits.val.take d.num_digits.val).map
(fun b => b.val)).foldl (fun n z => 10 * n + z) 0 : Nat) : Real) *
(10 : Real) ^ (d.decimal_point.val - (d.num_digits.val : Int)) <= 0 := by
simpa [List.map_take] using hprod
exact (not_le_of_gt hVpos) hprod'
exact hfoldReal)
hdigits (by simpa using hloop0)
dsimp only at hpref
rcases hpref with ⟨rfl, rfl, hreadpos, hBacc, hacc10, hphase⟩
refine ⟨read, acc, (by simpa using hloop0), hreadpos, ?_, hBacc, hacc10⟩
rcases hphase with hphase | hphase <;> omega
rcases hprefixFacts with ⟨read, acc, hloop0, hreadpos, hreadBound,
hBacc, hacc10⟩
have hnormalRun : exists point negRange : Std.I32,
point.val = d.decimal_point.val - (read.val : Int) + 1 /\
¬ point < negRange /\
-. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE =
ok negRange /\
(do
let pow ← 1#u64 <<< shift
let mask ← pow - 1#u64
let (a, wi, n1) ←
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
d.num_digits d.digits shift read 0#usize acc mask
let (bc, a1, wi1) ←
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
d.truncated a shift wi n1 mask
num.imp.dec2flt.decimal_seq.DecimalSeq.trim
{ num_digits := wi1, decimal_point := point,
truncated := bc, digits := a1 }) = ok d' := by
let readI : Std.I32 := UScalar.hcast .I32 read
let reset : num.imp.dec2flt.decimal_seq.DecimalSeq :=
{ num_digits := 0#usize, decimal_point := 0#i32,
truncated := false, digits := d.digits }
have hread828 : read.val <= 828 := by omega
have hreadIVal : readI.val = (read.val : Int) := by
have hs := UScalar.hcast_inBounds_spec .I32 read (by
rw [IScalar.max_I32_eq]
omega)
simp only [lift, WP.spec_ok] at hs
exact hs
have hcallBody := hcall
unfold num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift at hcallBody
rw [hloop0] at hcallBody
simp only [bind_tc_ok] at hcallBody
change (do
let i ← lift (UScalar.hcast .I32 read)
let i1 ← i - 1#i32
let i2 ← d.decimal_point - i1
let i3 ← -. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
if i2 < i3 then ok reset
else
let i4 ← 1#u64 <<< shift
let mask ← i4 - 1#u64
let (a, wi, n1) ←
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
d.num_digits d.digits shift read 0#usize acc mask
let (bc, a1, wi1) ←
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
d.truncated a shift wi n1 mask
num.imp.dec2flt.decimal_seq.DecimalSeq.trim
{ num_digits := wi1, decimal_point := i2,
truncated := bc, digits := a1 }) = ok d' at hcallBody
rw [show UScalar.hcast .I32 read = readI by rfl] at hcallBody
simp only [lift, bind_tc_ok] at hcallBody
cases hsub : readI - 1#i32 with
| fail e => simp [hsub] at hcallBody
| div => simp [hsub] at hcallBody
| ok readMinus =>
rw [hsub] at hcallBody
simp only [bind_tc_ok] at hcallBody
cases hpoint : d.decimal_point - readMinus with
| fail e => simp [hpoint] at hcallBody
| div => simp [hpoint] at hcallBody
| ok point =>
rw [hpoint] at hcallBody
simp only [bind_tc_ok] at hcallBody
have hsubVal : readMinus.val = readI.val - 1 := by
have hs := IScalar.sub_equiv readI 1#i32
rw [hsub] at hs
exact hs.2.1
have hpointVal : point.val =
d.decimal_point.val - (read.val : Int) + 1 := by
have hs := IScalar.sub_equiv d.decimal_point readMinus
rw [hpoint, hsubVal, hreadIVal] at hs
omega
cases hnegRange : -.
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE with
| fail e => simp [hnegRange] at hcallBody
| div => simp [hnegRange] at hcallBody
| ok negRange =>
rw [hnegRange] at hcallBody
simp only [bind_tc_ok] at hcallBody
by_cases hreset : point < negRange
· simp only [hreset, if_true] at hcallBody
have hd' : d' = reset := by simpa using hcallBody.symm
rw [hd'] at hnonzero
simp [reset] at hnonzero
· simp only [hreset, if_false] at hcallBody
exact ⟨point, negRange, hpointVal, hreset, rfl, hcallBody⟩
rcases hnormalRun with ⟨point, negRange, hpointVal, hnotReset,
hnegRange, hrun⟩
have hoperations : exists pow mask : Std.U64,
exists a : Array Std.U8 768#usize,
exists write : Std.Usize,
exists acc1 : Std.U64,
exists bc : Bool,
exists a1 : Array Std.U8 768#usize,
exists write1 : Std.Usize,
1#u64 <<< shift = ok pow /\
pow - 1#u64 = ok mask /\
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
d.num_digits d.digits shift read 0#usize acc mask =
ok (a, write, acc1) /\
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
d.truncated a shift write acc1 mask = ok (bc, a1, write1) /\
num.imp.dec2flt.decimal_seq.DecimalSeq.trim
{ num_digits := write1, decimal_point := point,
truncated := bc, digits := a1 } = ok d' := by
cases hpow : 1#u64 <<< shift with
| fail e => simp [hpow] at hrun
| div => simp [hpow] at hrun
| ok pow =>
rw [hpow] at hrun
simp only [bind_tc_ok] at hrun
cases hmask : pow - 1#u64 with
| fail e => simp [hmask] at hrun
| div => simp [hmask] at hrun
| ok mask =>
rw [hmask] at hrun
simp only [bind_tc_ok] at hrun
cases hloop1 :
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
d.num_digits d.digits shift read 0#usize acc mask with
| fail e => simp [hloop1] at hrun
| div => simp [hloop1] at hrun
| ok out1 =>
rcases out1 with ⟨a, write, acc1⟩
rw [hloop1] at hrun
simp only [bind_tc_ok] at hrun
change (do
let (bc, a1, write1) ←
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
d.truncated a shift write acc1 mask
num.imp.dec2flt.decimal_seq.DecimalSeq.trim
{ num_digits := write1, decimal_point := point,
truncated := bc, digits := a1 }) = ok d' at hrun
cases hloop2 :
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
d.truncated a shift write acc1 mask with
| fail e => simp [hloop2] at hrun
| div => simp [hloop2] at hrun
| ok out2 =>
rcases out2 with ⟨bc, a1, write1⟩
rw [hloop2] at hrun
simp only [bind_tc_ok] at hrun
exact ⟨pow, mask, a, write, acc1, bc, a1, write1,
rfl, hmask, hloop1, hloop2, hrun⟩
rcases hoperations with ⟨pow, mask, a, write, acc1, bc, a1, write1,
hpow, hmask, hloop1, hloop2, htrim⟩
let F := fun ys : List Nat => ys.foldl (fun n z => 10 * n + z) 0
let B := 2 ^ shift.val
have hmain : d.num_digits.val <= 768 /\
exists low : List Nat,
low.length = d.num_digits.val - read.val /\
(forall z, z ∈ low -> z < 10) /\
write.val = d.num_digits.val - read.val /\
acc1.val < 10 * B /\
acc.val * 10 ^ (d.num_digits.val - read.val) +
F ((d.digits.val.map (fun z => z.val)).take d.num_digits.val |>.drop read.val) =
B * (10 * F low) + acc1.val /\
(forall j, j < low.length ->
(a.val.map (fun z : Std.U8 => z.val))[j]? = low[j]?) /\
(forall j, j < 768 -> write.val <= j -> a.val[j]? = d.digits.val[j]?) /\
(forall j, j < 768 -> d.num_digits.val <= j ->
a.val[j]? = d.digits.val[j]?) := by
by_cases hrlt : read.val < d.num_digits.val
· have hm := P472_T1_DecimalRightShiftMainLoopSemantics
d.digits a shift read d.num_digits write pow mask acc acc1
hshift hreadpos (by omega) (by omega) hacc10 hdigits hpow hmask hloop1
dsimp only at hm
simpa [F, B, List.map_take] using hm
· have hrge : d.num_digits.val <= read.val := by omega
have hrWord : ¬ read < d.num_digits := by
simpa [UScalar.lt_equiv] using hrlt
have hdirect :
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
d.num_digits d.digits shift read 0#usize acc mask =
ok (d.digits, 0#usize, acc) := by
unfold num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1.body,
hrWord]
rw [hdirect] at hloop1
cases hloop1
refine ⟨hcap, [], by simp [Nat.sub_eq_zero_of_le hrge], by simp,
by simp [Nat.sub_eq_zero_of_le hrge], ?_, ?_, ?_, ?_⟩
· simpa [B] using hacc10
· have hdrop :
((d.digits.val.map (fun z => z.val)).take d.num_digits.val).drop
read.val = [] := List.drop_eq_nil_of_le (by simp; omega)
simp [F, hdrop, Nat.sub_eq_zero_of_le hrge]
· intro j hj
simp at hj
· constructor <;> intro j hj _ <;> rfl
rcases hmain with ⟨hnumBound, low, hlowLen, hlowDigit, hwrite,
hacc1Bound, hmainNum, hlowArray, hmainBelow, hmainAbove⟩
have hfinal := P472_T1_DecimalRightShiftFinalLoopSemantics
a a1 d.truncated bc shift write write1 pow mask acc1 hshift
(by omega) (by simpa [B] using hacc1Bound) hpow hmask hloop2
dsimp only at hfinal
rcases hfinal with ⟨high, hhighDigit, hfinalNum, hwrite1,
hhighArray, hbelow, houtside, hstickyFinal⟩
have hcellDecimal : forall j, j < write1.val ->
exists z : Nat, (a1.val.map (fun z : Std.U8 => z.val))[j]? = some z /\
z < 10 := by
intro j hj
have hj768 : j < 768 := by omega
by_cases hjwrite : j < write.val
· have hjlow : j < low.length := by omega
have hget : low[j]? = some low[j] :=
getElem?_eq_some_iff.mpr ⟨hjlow, rfl⟩
have hmem : low[j] ∈ low := List.getElem_mem hjlow
have hz := hlowDigit _ hmem
have hpreserve := hbelow j hj768 hjwrite
have hmapPreserve :
(a1.val.map (fun z : Std.U8 => z.val))[j]? =
(a.val.map (fun z : Std.U8 => z.val))[j]? := by
simp only [List.getElem?_map, hpreserve]
rw [hmapPreserve, hlowArray j hjlow, hget]
exact ⟨low[j], rfl, hz⟩
· have hjge : write.val <= j := by omega
have hjhigh : j - write.val < high.length := by
rw [hwrite1] at hj
have hmin : j < min (write.val + high.length) 768 := hj
have : j < write.val + high.length :=
lt_of_lt_of_le hmin (Nat.min_le_left _ _)
omega
have hdest : write.val + (j - write.val) = j := by omega
have hstored := hhighArray (j - write.val) hjhigh (by omega)
have hstored' :
(a1.val.map (fun z : Std.U8 => z.val))[j]? =
high[j - write.val]? := by
simpa [hdest] using hstored
have hget : high[j - write.val]? = some high[j - write.val] :=
getElem?_eq_some_iff.mpr ⟨hjhigh, rfl⟩
rw [hstored', hget]
exact ⟨high[j - write.val],
rfl, hhighDigit _ (List.getElem_mem hjhigh)⟩
have foldFrom (ys : List Nat) (n : Nat) :
ys.foldl (fun x z => 10 * x + z) n =
n * 10 ^ ys.length + F ys := by
induction ys generalizing n with
| nil => simp [F]
| cons y ys ih =>
simp only [List.foldl_cons, List.length_cons]
rw [ih, pow_succ]
change (10 * n + y) * 10 ^ ys.length + F ys =
n * (10 ^ ys.length * 10) +
(y :: ys).foldl (fun x z => 10 * x + z) 0
simp only [List.foldl_cons]
rw [ih]
ring
have foldBound (ys : List Nat)
(hd : forall z, z ∈ ys -> z < 10) : F ys < 10 ^ ys.length := by
induction ys with
| nil => simp [F]
| cons y ys ih =>
have hy : y < 10 := hd y (by simp)
have hys : forall z, z ∈ ys -> z < 10 := by
intro z hz
exact hd z (by simp [hz])
have hi := ih hys
have hform : F (y :: ys) = y * 10 ^ ys.length + F ys := by
simpa [F] using foldFrom ys y
rw [hform, List.length_cons, pow_succ]
have hm : y * 10 ^ ys.length <= 9 * 10 ^ ys.length :=
Nat.mul_le_mul_right _ (by omega)
calc
y * 10 ^ ys.length + F ys <
y * 10 ^ ys.length + 10 ^ ys.length := Nat.add_lt_add_left hi _
_ <= 9 * 10 ^ ys.length + 10 ^ ys.length :=
Nat.add_le_add_right hm _
_ = 10 ^ ys.length * 10 := by ring
have hlowLead : write.val > 0 ->
exists z tail, low = z :: tail /\ 0 < z := by
intro hwritePos
cases low with
| nil => simp at hlowLen; omega
| cons z tail =>
refine ⟨z, tail, rfl, ?_⟩
by_contra hz
have hz0 : z = 0 := by omega
have hmpos : 0 < (z :: tail).length := by simp
have hpowStep : 10 ^ (z :: tail).length =
10 * 10 ^ ((z :: tail).length - 1) := by
have heq : (z :: tail).length = ((z :: tail).length - 1) + 1 := by omega
calc
10 ^ (z :: tail).length =
10 ^ (((z :: tail).length - 1) + 1) :=
congrArg (fun n : Nat => 10 ^ n) heq
_ = 10 ^ ((z :: tail).length - 1) * 10 := by rw [pow_succ]
_ = _ := by ring
have htailDigit : forall q, q ∈ tail -> q < 10 := by
intro q hq
exact hlowDigit q (by simp [hq])
have htailBound := foldBound tail htailDigit
have hflow : F (z :: tail) = F tail := by
rw [show F (z :: tail) = z * 10 ^ tail.length + F tail by
simpa [F] using foldFrom tail z, hz0]
simp
have hmainEq := hmainNum
rw [← hlowLen] at hmainEq
have haccLower : B <= acc.val := by simpa [B] using hBacc
have hleftLower : B * 10 ^ (z :: tail).length <=
acc.val * 10 ^ (z :: tail).length +
F ((d.digits.val.map (fun q => q.val)).take d.num_digits.val |>.drop read.val) := by
calc
B * 10 ^ (z :: tail).length <=
acc.val * 10 ^ (z :: tail).length :=
Nat.mul_le_mul_right _ haccLower
_ <= _ := Nat.le_add_right _ _
rw [hmainEq] at hleftLower
have hFlt : F (z :: tail) < 10 ^ ((z :: tail).length - 1) := by
rw [hflow]
have hlenTail : (z :: tail).length - 1 = tail.length := by simp
simpa [hlenTail] using htailBound
have htenF : 10 * F (z :: tail) <
10 * 10 ^ ((z :: tail).length - 1) :=
Nat.mul_lt_mul_of_pos_left hFlt (by norm_num)
have hFplus : F (z :: tail) + 1 <=
10 ^ ((z :: tail).length - 1) := Nat.succ_le_of_lt hFlt
have htenFle : 10 * F (z :: tail) + 10 <=
10 * 10 ^ ((z :: tail).length - 1) := by
have := Nat.mul_le_mul_left 10 hFplus
nlinarith
have hBFle : B * (10 * F (z :: tail)) + 10 * B <=
B * (10 * 10 ^ ((z :: tail).length - 1)) := by
calc
_ = B * (10 * F (z :: tail) + 10) := by ring
_ <= _ := Nat.mul_le_mul_left B htenFle
have hupper : B * (10 * F (z :: tail)) + acc1.val <
B * 10 ^ (z :: tail).length := by
calc
_ < B * (10 * F (z :: tail)) + 10 * B :=
Nat.add_lt_add_left hacc1Bound _
_ <= _ := by rw [hpowStep]; exact hBFle
omega
have hhighLead : write.val = 0 ->
exists z tail, high = z :: tail /\ 0 < z := by
intro hwriteZero
have hrge : d.num_digits.val <= read.val := by
omega
have hnlow : low.length = 0 := by omega
have hlowNil : low = [] := List.eq_nil_of_length_eq_zero (by
exact hnlow)
have hdrop :
((d.digits.val.map (fun q => q.val)).take d.num_digits.val).drop
read.val = [] := List.drop_eq_nil_of_le (by simp; omega)
have hmainEq := hmainNum
rw [← hlowLen] at hmainEq
simp [hlowNil, hdrop, F] at hmainEq
have haccEq : acc.val = acc1.val := by omega
have hacc1Lower : B <= acc1.val := by
rw [← haccEq]
simpa [B] using hBacc
cases high with
| nil =>
simp [F] at hfinalNum
have hBpos : 0 < B := by simp [B]
omega
| cons z tail =>
refine ⟨z, tail, rfl, ?_⟩
by_contra hz
have hz0 : z = 0 := by omega
have htailDigit : forall q, q ∈ tail -> q < 10 := by
intro q hq
exact hhighDigit q (by simp [hq])
have htailBound := foldBound tail htailDigit
have hflow : F (z :: tail) = F tail := by
rw [show F (z :: tail) = z * 10 ^ tail.length + F tail by
simpa [F] using foldFrom tail z, hz0]
simp
have hquotMul := Nat.mul_le_mul_right (10 ^ (z :: tail).length)
hacc1Lower
rw [hfinalNum] at hquotMul
have hquot : 10 ^ (z :: tail).length <= 10 * F (z :: tail) :=
Nat.le_of_mul_le_mul_left hquotMul (by positivity : 0 < B)
have hpowStep : 10 ^ (z :: tail).length = 10 * 10 ^ tail.length := by
simp only [List.length_cons, pow_succ]
ring
have hupper : 10 * F (z :: tail) < 10 ^ (z :: tail).length := by
rw [hflow, hpowStep]
exact Nat.mul_lt_mul_of_pos_left htailBound (by norm_num)
omega
have hfirst : exists z : Nat,
(a1.val.map (fun b : Std.U8 => b.val))[0]? = some z /\
1 <= z /\ z < 10 := by
by_cases hwritePos : write.val > 0
· obtain ⟨z, tail, hlowEq, hz⟩ := hlowLead hwritePos
have hz10 : z < 10 := hlowDigit z (by simp [hlowEq])
have hzeroGet : low[0]? = some z := by simp [hlowEq]
have harrayMain := hlowArray 0 (by simp [hlowEq])
have harrayPreserve := hbelow 0 (by omega) hwritePos
have hmapPreserve :
(a1.val.map (fun b : Std.U8 => b.val))[0]? =
(a.val.map (fun b : Std.U8 => b.val))[0]? := by
simp only [List.getElem?_map, harrayPreserve]
rw [hmapPreserve, harrayMain, hzeroGet]
exact ⟨z, rfl, hz, hz10⟩
· have hwriteZero : write.val = 0 := by omega
obtain ⟨z, tail, hhighEq, hz⟩ := hhighLead hwriteZero
have hz10 : z < 10 := hhighDigit z (by simp [hhighEq])
have harrayHigh := hhighArray 0 (by simp [hhighEq]) (by omega)
have hzeroGet : high[0]? = some z := by simp [hhighEq]
have harrayHigh' :
(a1.val.map (fun b : Std.U8 => b.val))[0]? = some z := by
simpa [hwriteZero] using harrayHigh.trans hzeroGet
exact ⟨z, harrayHigh', hz, hz10⟩
let pre : num.imp.dec2flt.decimal_seq.DecimalSeq :=
{ num_digits := write1, decimal_point := point,
truncated := bc, digits := a1 }
have hpreBound : pre.num_digits.val <= pre.digits.val.length := by
simp [pre, a1.property]
rw [hwrite1]
exact Nat.min_le_right _ _
have htrimSem := DecimalSeqTrimSemantics pre d' hpreBound htrim
dsimp only at htrimSem
rcases htrimSem with ⟨hdigitsEq, hpointEq, htruncatedEq, htrimCount,
htrimZeros, htrimLast, htrimValue⟩
have hwrite1Bound : write1.val <= 768 := by
rw [hwrite1]
exact Nat.min_le_right _ _
have hcountBound : d'.num_digits.val <= 768 := by
exact le_trans htrimCount hwrite1Bound
have hlastNonzero :
d'.digits.val[d'.num_digits.val - 1]? ≠ some 0#u8 := by
rcases htrimLast with hzero | hlast
· exact False.elim (hnonzero hzero)
· simpa [pre, hdigitsEq] using hlast
let negRangeFixed : Std.I32 := (-2047)#i32
have hnegRangeFixed :
-. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE =
ok negRangeFixed := by
unfold num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
change IScalar.neg (2047#i32 : Std.I32) = _
unfold IScalar.neg IScalar.tryMk IScalar.tryMkOpt
norm_num [IScalar.check_bounds, IScalarTy.numBits, negRangeFixed]
have hnegEq : negRange = negRangeFixed := by
have heq := hnegRange.symm.trans hnegRangeFixed
exact Result.ok.inj heq
have hnegRangeVal : negRange.val = -2047 := by
simp [negRangeFixed, hnegEq]
have hpointLower : -2047 <= d'.decimal_point.val := by
have hd'point : d'.decimal_point.val = point.val := by
simpa [pre] using congrArg IScalar.val hpointEq
rw [hd'point]
have hnot : ¬ point.val < -2047 := by
simpa [IScalar.lt_equiv, hnegRangeVal] using hnotReset
omega
have hretainedDigits : forall b,
b ∈ d'.digits.val.take d'.num_digits.val -> b.val < 10 := by
intro b hb
rcases List.mem_iff_getElem.mp hb with ⟨j, hj, rfl⟩
have hj768 : j < d'.num_digits.val := by
simp only [List.length_take] at hj
omega
have hjwrite : j < write1.val := lt_of_lt_of_le hj768 htrimCount
obtain ⟨z, hcell, hz⟩ := hcellDecimal j hjwrite
have hjArr : j < d'.digits.val.length := by
simp [hdigitsEq, pre, a1.property]
omega
have hcell' : (d'.digits.val.map (fun b : Std.U8 => b.val))[j]? = some z := by
simpa [hdigitsEq, pre] using hcell
have hval : d'.digits.val[j].val = z := by
simpa [List.getElem?_map, List.getElem?_eq_getElem hjArr] using hcell'
simpa [hval] using hz
obtain ⟨first, hfirstCell, hfirstPos, hfirstLt⟩ := hfirst
let retained : List Nat :=
(d'.digits.val.take d'.num_digits.val).map (fun b => b.val)
have hretainedLen : retained.length = d'.num_digits.val := by
simp [retained, List.length_take, d'.digits.property]
omega
have hretainedFirst : retained[0]? = some first := by
have hcountPos : 0 < d'.num_digits.val := Nat.pos_of_ne_zero hnonzero
have hmapFirst :
(d'.digits.val.map (fun b : Std.U8 => b.val))[0]? = some first := by
simpa [hdigitsEq, pre] using hfirstCell
simpa [retained, List.getElem?_map, hcountPos] using hmapFirst
have hretainedHead : exists tail,
retained = first :: tail /\ (first :: tail).length = d'.num_digits.val := by
cases hlist : retained with
| nil =>
simp [hlist] at hretainedLen
exact False.elim (hnonzero hretainedLen)
| cons z tail =>
have hfirstEq : z = first := by
have heq : some z = some first := by simpa [hlist] using hretainedFirst
exact Option.some.inj heq
refine ⟨tail, ?_, ?_⟩
· simpa [hlist, hfirstEq]
· simpa [hlist, hfirstEq] using hretainedLen
have hdyad := (P472_T1_DecimalSeqDyadicShiftSemantics).2
d d' shift X eta u hshift hVpos hdigits hcall hX heta0 hetau hsticky
rcases hdyad with hreset | ⟨eta', u', hX', heta'0, heta'u', hsticky', hY', _⟩
· simp [hreset.1] at hnonzero
· have hY' : Y / (2 : Real) ^ shift.val =
((((d'.digits.val.take d'.num_digits.val).map (fun b => b.val)).foldl
(fun n z => 10 * n + z) 0 : Nat) : Real) *
(10 : Real) ^ (d'.decimal_point.val - (d'.num_digits.val : Int)) + u' := by
calc
Y / (2 : Real) ^ shift.val =
(((((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
(fun n z => 10 * n + z) 0 : Nat) : Real) *
(10 : Real) ^ (d.decimal_point.val - (d.num_digits.val : Int)) + u) /
(2 : Real) ^ shift.val := by
rw [hY]
_ = _ := hY'.symm
have hheadOut : exists first tail,
(d'.digits.val.take d'.num_digits.val).map (fun b => b.val) =
first :: tail /\
1 <= first /\ first < 10 /\
(first :: tail).length = d'.num_digits.val := by
rcases hretainedHead with ⟨tail, hlist, hlen⟩
exact ⟨first, tail, by simpa [retained] using hlist,
hfirstPos, hfirstLt, by simpa using hlen⟩
refine ⟨hpointLower, hcountBound, hretainedDigits, hheadOut,
hlastNonzero, ?_⟩
refine ⟨eta', u', ?_, hY', heta'0, heta'u', hsticky'⟩
simpa using hX'
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.P472_T1_DecimalSeqDyadicShiftSemantics
import Tablet.P472_T1_DecimalRightShiftPrefixLoopSemantics
import Tablet.P472_T1_DecimalRightShiftMainLoopSemantics
import Tablet.P472_T1_DecimalRightShiftFinalLoopSemantics
import Tablet.DecimalSeqTrimSemantics
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P495_T1_RightShiftCanonical]
theorem P495_T1_RightShiftCanonical (X Y : Real)
(d d' : num.imp.dec2flt.decimal_seq.DecimalSeq) (shift : Std.Usize)
(hshift : shift.val <= 60) (hcap : d.num_digits.val <= 768)
(hdigits : forall b, b ∈ d.digits.val.take d.num_digits.val -> b.val < 10)
(hhead : exists h tail,
(d.digits.val.take d.num_digits.val).map (fun b => b.val) = h :: tail /\
1 <= h /\ h < 10 /\ (h :: tail).length = d.num_digits.val)
(hcall : num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift d shift = ok d')
(hnonzero : d'.num_digits.val ≠ 0) :
let V := fun a : num.imp.dec2flt.decimal_seq.DecimalSeq =>
((((a.digits.val.take a.num_digits.val).map (fun b => b.val)).foldl
(fun n z => 10 * n + z) 0 : Nat) : Real) *
(10 : Real) ^ (a.decimal_point.val - (a.num_digits.val : Int))
(exists eta u : Real, X = V d + eta /\ Y = V d + u /\
0 <= eta /\ eta < u /\ (d.truncated = true <-> 0 < eta)) ->
-2047 <= d'.decimal_point.val /\ d'.num_digits.val <= 768 /\
(forall b, b ∈ d'.digits.val.take d'.num_digits.val -> b.val < 10) /\
(exists h tail,
(d'.digits.val.take d'.num_digits.val).map (fun b => b.val) = h :: tail /\
1 <= h /\ h < 10 /\ (h :: tail).length = d'.num_digits.val) /\
d'.digits.val[d'.num_digits.val - 1]? ≠ some 0#u8 /\
(exists eta' u' : Real,
X / (2 : Real) ^ shift.val = V d' + eta' /\
Y / (2 : Real) ^ shift.val = V d' + u' /\
0 <= eta' /\ eta' < u' /\ (d'.truncated = true <-> 0 < eta')) := by
-- BODY
dsimp only
intro hWitness
rcases hWitness with ⟨eta, u, hX, hY, heta0, hetau, hsticky⟩
have hVpos : 0 <
((((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
(fun n z => 10 * n + z) 0 : Nat) : Real) *
(10 : Real) ^ (d.decimal_point.val - (d.num_digits.val : Int)) := by
rcases hhead with ⟨h, tail, hshape, hpositive, _, _⟩
have hfoldNat : 0 <
((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
(fun n z => 10 * n + z) (0 : Nat) := by
rw [hshape]
change 0 < (h :: tail).foldl (fun n z => 10 * n + z) 0
have fold_ge : forall (zs : List Nat) (n : Nat),
n <= zs.foldl (fun a z => 10 * a + z) n := by
intro zs
induction zs with
| nil => intro n; simp
| cons z zs ih =>
intro n
simp only [List.foldl_cons]
have := ih (10 * n + z)
omega
have hmore : h <= tail.foldl (fun n z => 10 * n + z) h :=
fold_ge tail h
have hs : 0 < tail.foldl (fun n z => 10 * n + z) h :=
lt_of_lt_of_le hpositive hmore
simpa [List.foldl_cons] using hs
have hfold : 0 <
(((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
(fun n z => 10 * n + z) 0 : Nat) := hfoldNat
exact mul_pos (by exact_mod_cast hfold)
(zpow_pos (by norm_num) _)
have hprefixFacts : exists read acc,
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop0
d shift 0#usize 0#u64 false = ok (d, read, acc, false) /\
1 <= read.val /\ read.val <= d.num_digits.val + shift.val /\
2 ^ shift.val <= acc.val /\ acc.val < 10 * 2 ^ shift.val := by
have hcallAux := hcall
unfold num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift at hcallAux
cases hloop0 : num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop0
d shift 0#usize 0#u64 false with
| fail e => simp [hloop0] at hcallAux
| div => simp [hloop0] at hcallAux
| ok out0 =>
rcases out0 with ⟨d0, read, acc, allZero⟩
simp only [hloop0, bind_tc_ok] at hcallAux
have hpref := P472_T1_DecimalRightShiftPrefixLoopSemantics
d d0 shift read acc allZero hshift (by
have hp10 : 0 < (10 : Real) ^
(d.decimal_point.val - (d.num_digits.val : Int)) :=
zpow_pos (by norm_num) _
have hfoldReal : 0 <
(((d.digits.val.take d.num_digits.val).map
(fun b => b.val)).foldl (fun n z => 10 * n + z) 0 : Nat) := by
by_contra hn
have hnle :
((((d.digits.val.take d.num_digits.val).map
(fun b => b.val)).foldl (fun n z => 10 * n + z) 0 : Nat) : Real) <= 0 := by
exact_mod_cast (le_of_not_gt hn)
have hprod := mul_nonpos_of_nonpos_of_nonneg hnle (le_of_lt hp10)
have hprod' :
((((d.digits.val.take d.num_digits.val).map
(fun b => b.val)).foldl (fun n z => 10 * n + z) 0 : Nat) : Real) *
(10 : Real) ^ (d.decimal_point.val - (d.num_digits.val : Int)) <= 0 := by
simpa [List.map_take] using hprod
exact (not_le_of_gt hVpos) hprod'
exact hfoldReal)
hdigits (by simpa using hloop0)
dsimp only at hpref
rcases hpref with ⟨rfl, rfl, hreadpos, hBacc, hacc10, hphase⟩
refine ⟨read, acc, (by simpa using hloop0), hreadpos, ?_, hBacc, hacc10⟩
rcases hphase with hphase | hphase <;> omega
rcases hprefixFacts with ⟨read, acc, hloop0, hreadpos, hreadBound,
hBacc, hacc10⟩
have hnormalRun : exists point negRange : Std.I32,
point.val = d.decimal_point.val - (read.val : Int) + 1 /\
¬ point < negRange /\
-. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE =
ok negRange /\
(do
let pow ← 1#u64 <<< shift
let mask ← pow - 1#u64
let (a, wi, n1) ←
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
d.num_digits d.digits shift read 0#usize acc mask
let (bc, a1, wi1) ←
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
d.truncated a shift wi n1 mask
num.imp.dec2flt.decimal_seq.DecimalSeq.trim
{ num_digits := wi1, decimal_point := point,
truncated := bc, digits := a1 }) = ok d' := by
let readI : Std.I32 := UScalar.hcast .I32 read
let reset : num.imp.dec2flt.decimal_seq.DecimalSeq :=
{ num_digits := 0#usize, decimal_point := 0#i32,
truncated := false, digits := d.digits }
have hread828 : read.val <= 828 := by omega
have hreadIVal : readI.val = (read.val : Int) := by
have hs := UScalar.hcast_inBounds_spec .I32 read (by
rw [IScalar.max_I32_eq]
omega)
simp only [lift, WP.spec_ok] at hs
exact hs
have hcallBody := hcall
unfold num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift at hcallBody
rw [hloop0] at hcallBody
simp only [bind_tc_ok] at hcallBody
change (do
let i ← lift (UScalar.hcast .I32 read)
let i1 ← i - 1#i32
let i2 ← d.decimal_point - i1
let i3 ← -. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
if i2 < i3 then ok reset
else
let i4 ← 1#u64 <<< shift
let mask ← i4 - 1#u64
let (a, wi, n1) ←
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
d.num_digits d.digits shift read 0#usize acc mask
let (bc, a1, wi1) ←
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
d.truncated a shift wi n1 mask
num.imp.dec2flt.decimal_seq.DecimalSeq.trim
{ num_digits := wi1, decimal_point := i2,
truncated := bc, digits := a1 }) = ok d' at hcallBody
rw [show UScalar.hcast .I32 read = readI by rfl] at hcallBody
simp only [lift, bind_tc_ok] at hcallBody
cases hsub : readI - 1#i32 with
| fail e => simp [hsub] at hcallBody
| div => simp [hsub] at hcallBody
| ok readMinus =>
rw [hsub] at hcallBody
simp only [bind_tc_ok] at hcallBody
cases hpoint : d.decimal_point - readMinus with
| fail e => simp [hpoint] at hcallBody
| div => simp [hpoint] at hcallBody
| ok point =>
rw [hpoint] at hcallBody
simp only [bind_tc_ok] at hcallBody
have hsubVal : readMinus.val = readI.val - 1 := by
have hs := IScalar.sub_equiv readI 1#i32
rw [hsub] at hs
exact hs.2.1
have hpointVal : point.val =
d.decimal_point.val - (read.val : Int) + 1 := by
have hs := IScalar.sub_equiv d.decimal_point readMinus
rw [hpoint, hsubVal, hreadIVal] at hs
omega
cases hnegRange : -.
num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE with
| fail e => simp [hnegRange] at hcallBody
| div => simp [hnegRange] at hcallBody
| ok negRange =>
rw [hnegRange] at hcallBody
simp only [bind_tc_ok] at hcallBody
by_cases hreset : point < negRange
· simp only [hreset, if_true] at hcallBody
have hd' : d' = reset := by simpa using hcallBody.symm
rw [hd'] at hnonzero
simp [reset] at hnonzero
· simp only [hreset, if_false] at hcallBody
exact ⟨point, negRange, hpointVal, hreset, rfl, hcallBody⟩
rcases hnormalRun with ⟨point, negRange, hpointVal, hnotReset,
hnegRange, hrun⟩
have hoperations : exists pow mask : Std.U64,
exists a : Array Std.U8 768#usize,
exists write : Std.Usize,
exists acc1 : Std.U64,
exists bc : Bool,
exists a1 : Array Std.U8 768#usize,
exists write1 : Std.Usize,
1#u64 <<< shift = ok pow /\
pow - 1#u64 = ok mask /\
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
d.num_digits d.digits shift read 0#usize acc mask =
ok (a, write, acc1) /\
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
d.truncated a shift write acc1 mask = ok (bc, a1, write1) /\
num.imp.dec2flt.decimal_seq.DecimalSeq.trim
{ num_digits := write1, decimal_point := point,
truncated := bc, digits := a1 } = ok d' := by
cases hpow : 1#u64 <<< shift with
| fail e => simp [hpow] at hrun
| div => simp [hpow] at hrun
| ok pow =>
rw [hpow] at hrun
simp only [bind_tc_ok] at hrun
cases hmask : pow - 1#u64 with
| fail e => simp [hmask] at hrun
| div => simp [hmask] at hrun
| ok mask =>
rw [hmask] at hrun
simp only [bind_tc_ok] at hrun
cases hloop1 :
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
d.num_digits d.digits shift read 0#usize acc mask with
| fail e => simp [hloop1] at hrun
| div => simp [hloop1] at hrun
| ok out1 =>
rcases out1 with ⟨a, write, acc1⟩
rw [hloop1] at hrun
simp only [bind_tc_ok] at hrun
change (do
let (bc, a1, write1) ←
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
d.truncated a shift write acc1 mask
num.imp.dec2flt.decimal_seq.DecimalSeq.trim
{ num_digits := write1, decimal_point := point,
truncated := bc, digits := a1 }) = ok d' at hrun
cases hloop2 :
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop2
d.truncated a shift write acc1 mask with
| fail e => simp [hloop2] at hrun
| div => simp [hloop2] at hrun
| ok out2 =>
rcases out2 with ⟨bc, a1, write1⟩
rw [hloop2] at hrun
simp only [bind_tc_ok] at hrun
exact ⟨pow, mask, a, write, acc1, bc, a1, write1,
rfl, hmask, hloop1, hloop2, hrun⟩
rcases hoperations with ⟨pow, mask, a, write, acc1, bc, a1, write1,
hpow, hmask, hloop1, hloop2, htrim⟩
let F := fun ys : List Nat => ys.foldl (fun n z => 10 * n + z) 0
let B := 2 ^ shift.val
have hmain : d.num_digits.val <= 768 /\
exists low : List Nat,
low.length = d.num_digits.val - read.val /\
(forall z, z ∈ low -> z < 10) /\
write.val = d.num_digits.val - read.val /\
acc1.val < 10 * B /\
acc.val * 10 ^ (d.num_digits.val - read.val) +
F ((d.digits.val.map (fun z => z.val)).take d.num_digits.val |>.drop read.val) =
B * (10 * F low) + acc1.val /\
(forall j, j < low.length ->
(a.val.map (fun z : Std.U8 => z.val))[j]? = low[j]?) /\
(forall j, j < 768 -> write.val <= j -> a.val[j]? = d.digits.val[j]?) /\
(forall j, j < 768 -> d.num_digits.val <= j ->
a.val[j]? = d.digits.val[j]?) := by
by_cases hrlt : read.val < d.num_digits.val
· have hm := P472_T1_DecimalRightShiftMainLoopSemantics
d.digits a shift read d.num_digits write pow mask acc acc1
hshift hreadpos (by omega) (by omega) hacc10 hdigits hpow hmask hloop1
dsimp only at hm
simpa [F, B, List.map_take] using hm
· have hrge : d.num_digits.val <= read.val := by omega
have hrWord : ¬ read < d.num_digits := by
simpa [UScalar.lt_equiv] using hrlt
have hdirect :
num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
d.num_digits d.digits shift read 0#usize acc mask =
ok (d.digits, 0#usize, acc) := by
unfold num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1
rw [Aeneas.Std.loop.eq_1]
simp [num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift_loop1.body,
hrWord]
rw [hdirect] at hloop1
cases hloop1
refine ⟨hcap, [], by simp [Nat.sub_eq_zero_of_le hrge], by simp,
by simp [Nat.sub_eq_zero_of_le hrge], ?_, ?_, ?_, ?_⟩
· simpa [B] using hacc10
· have hdrop :
((d.digits.val.map (fun z => z.val)).take d.num_digits.val).drop
read.val = [] := List.drop_eq_nil_of_le (by simp; omega)
simp [F, hdrop, Nat.sub_eq_zero_of_le hrge]
· intro j hj
simp at hj
· constructor <;> intro j hj _ <;> rfl
rcases hmain with ⟨hnumBound, low, hlowLen, hlowDigit, hwrite,
hacc1Bound, hmainNum, hlowArray, hmainBelow, hmainAbove⟩
have hfinal := P472_T1_DecimalRightShiftFinalLoopSemantics
a a1 d.truncated bc shift write write1 pow mask acc1 hshift
(by omega) (by simpa [B] using hacc1Bound) hpow hmask hloop2
dsimp only at hfinal
rcases hfinal with ⟨high, hhighDigit, hfinalNum, hwrite1,
hhighArray, hbelow, houtside, hstickyFinal⟩
have hcellDecimal : forall j, j < write1.val ->
exists z : Nat, (a1.val.map (fun z : Std.U8 => z.val))[j]? = some z /\
z < 10 := by
intro j hj
have hj768 : j < 768 := by omega
by_cases hjwrite : j < write.val
· have hjlow : j < low.length := by omega
have hget : low[j]? = some low[j] :=
getElem?_eq_some_iff.mpr ⟨hjlow, rfl⟩
have hmem : low[j] ∈ low := List.getElem_mem hjlow
have hz := hlowDigit _ hmem
have hpreserve := hbelow j hj768 hjwrite
have hmapPreserve :
(a1.val.map (fun z : Std.U8 => z.val))[j]? =
(a.val.map (fun z : Std.U8 => z.val))[j]? := by
simp only [List.getElem?_map, hpreserve]
rw [hmapPreserve, hlowArray j hjlow, hget]
exact ⟨low[j], rfl, hz⟩
· have hjge : write.val <= j := by omega
have hjhigh : j - write.val < high.length := by
rw [hwrite1] at hj
have hmin : j < min (write.val + high.length) 768 := hj
have : j < write.val + high.length :=
lt_of_lt_of_le hmin (Nat.min_le_left _ _)
omega
have hdest : write.val + (j - write.val) = j := by omega
have hstored := hhighArray (j - write.val) hjhigh (by omega)
have hstored' :
(a1.val.map (fun z : Std.U8 => z.val))[j]? =
high[j - write.val]? := by
simpa [hdest] using hstored
have hget : high[j - write.val]? = some high[j - write.val] :=
getElem?_eq_some_iff.mpr ⟨hjhigh, rfl⟩
rw [hstored', hget]
exact ⟨high[j - write.val],
rfl, hhighDigit _ (List.getElem_mem hjhigh)⟩
have foldFrom (ys : List Nat) (n : Nat) :
ys.foldl (fun x z => 10 * x + z) n =
n * 10 ^ ys.length + F ys := by
induction ys generalizing n with
| nil => simp [F]
| cons y ys ih =>
simp only [List.foldl_cons, List.length_cons]
rw [ih, pow_succ]
change (10 * n + y) * 10 ^ ys.length + F ys =
n * (10 ^ ys.length * 10) +
(y :: ys).foldl (fun x z => 10 * x + z) 0
simp only [List.foldl_cons]
rw [ih]
ring
have foldBound (ys : List Nat)
(hd : forall z, z ∈ ys -> z < 10) : F ys < 10 ^ ys.length := by
induction ys with
| nil => simp [F]
| cons y ys ih =>
have hy : y < 10 := hd y (by simp)
have hys : forall z, z ∈ ys -> z < 10 := by
intro z hz
exact hd z (by simp [hz])
have hi := ih hys
have hform : F (y :: ys) = y * 10 ^ ys.length + F ys := by
simpa [F] using foldFrom ys y
rw [hform, List.length_cons, pow_succ]
have hm : y * 10 ^ ys.length <= 9 * 10 ^ ys.length :=
Nat.mul_le_mul_right _ (by omega)
calc
y * 10 ^ ys.length + F ys <
y * 10 ^ ys.length + 10 ^ ys.length := Nat.add_lt_add_left hi _
_ <= 9 * 10 ^ ys.length + 10 ^ ys.length :=
Nat.add_le_add_right hm _
_ = 10 ^ ys.length * 10 := by ring
have hlowLead : write.val > 0 ->
exists z tail, low = z :: tail /\ 0 < z := by
intro hwritePos
cases low with
| nil => simp at hlowLen; omega
| cons z tail =>
refine ⟨z, tail, rfl, ?_⟩
by_contra hz
have hz0 : z = 0 := by omega
have hmpos : 0 < (z :: tail).length := by simp
have hpowStep : 10 ^ (z :: tail).length =
10 * 10 ^ ((z :: tail).length - 1) := by
have heq : (z :: tail).length = ((z :: tail).length - 1) + 1 := by omega
calc
10 ^ (z :: tail).length =
10 ^ (((z :: tail).length - 1) + 1) :=
congrArg (fun n : Nat => 10 ^ n) heq
_ = 10 ^ ((z :: tail).length - 1) * 10 := by rw [pow_succ]
_ = _ := by ring
have htailDigit : forall q, q ∈ tail -> q < 10 := by
intro q hq
exact hlowDigit q (by simp [hq])
have htailBound := foldBound tail htailDigit
have hflow : F (z :: tail) = F tail := by
rw [show F (z :: tail) = z * 10 ^ tail.length + F tail by
simpa [F] using foldFrom tail z, hz0]
simp
have hmainEq := hmainNum
rw [← hlowLen] at hmainEq
have haccLower : B <= acc.val := by simpa [B] using hBacc
have hleftLower : B * 10 ^ (z :: tail).length <=
acc.val * 10 ^ (z :: tail).length +
F ((d.digits.val.map (fun q => q.val)).take d.num_digits.val |>.drop read.val) := by
calc
B * 10 ^ (z :: tail).length <=
acc.val * 10 ^ (z :: tail).length :=
Nat.mul_le_mul_right _ haccLower
_ <= _ := Nat.le_add_right _ _
rw [hmainEq] at hleftLower
have hFlt : F (z :: tail) < 10 ^ ((z :: tail).length - 1) := by
rw [hflow]
have hlenTail : (z :: tail).length - 1 = tail.length := by simp
simpa [hlenTail] using htailBound
have htenF : 10 * F (z :: tail) <
10 * 10 ^ ((z :: tail).length - 1) :=
Nat.mul_lt_mul_of_pos_left hFlt (by norm_num)
have hFplus : F (z :: tail) + 1 <=
10 ^ ((z :: tail).length - 1) := Nat.succ_le_of_lt hFlt
have htenFle : 10 * F (z :: tail) + 10 <=
10 * 10 ^ ((z :: tail).length - 1) := by
have := Nat.mul_le_mul_left 10 hFplus
nlinarith
have hBFle : B * (10 * F (z :: tail)) + 10 * B <=
B * (10 * 10 ^ ((z :: tail).length - 1)) := by
calc
_ = B * (10 * F (z :: tail) + 10) := by ring
_ <= _ := Nat.mul_le_mul_left B htenFle
have hupper : B * (10 * F (z :: tail)) + acc1.val <
B * 10 ^ (z :: tail).length := by
calc
_ < B * (10 * F (z :: tail)) + 10 * B :=
Nat.add_lt_add_left hacc1Bound _
_ <= _ := by rw [hpowStep]; exact hBFle
omega
have hhighLead : write.val = 0 ->
exists z tail, high = z :: tail /\ 0 < z := by
intro hwriteZero
have hrge : d.num_digits.val <= read.val := by
omega
have hnlow : low.length = 0 := by omega
have hlowNil : low = [] := List.eq_nil_of_length_eq_zero (by
exact hnlow)
have hdrop :
((d.digits.val.map (fun q => q.val)).take d.num_digits.val).drop
read.val = [] := List.drop_eq_nil_of_le (by simp; omega)
have hmainEq := hmainNum
rw [← hlowLen] at hmainEq
simp [hlowNil, hdrop, F] at hmainEq
have haccEq : acc.val = acc1.val := by omega
have hacc1Lower : B <= acc1.val := by
rw [← haccEq]
simpa [B] using hBacc
cases high with
| nil =>
simp [F] at hfinalNum
have hBpos : 0 < B := by simp [B]
omega
| cons z tail =>
refine ⟨z, tail, rfl, ?_⟩
by_contra hz
have hz0 : z = 0 := by omega
have htailDigit : forall q, q ∈ tail -> q < 10 := by
intro q hq
exact hhighDigit q (by simp [hq])
have htailBound := foldBound tail htailDigit
have hflow : F (z :: tail) = F tail := by
rw [show F (z :: tail) = z * 10 ^ tail.length + F tail by
simpa [F] using foldFrom tail z, hz0]
simp
have hquotMul := Nat.mul_le_mul_right (10 ^ (z :: tail).length)
hacc1Lower
rw [hfinalNum] at hquotMul
have hquot : 10 ^ (z :: tail).length <= 10 * F (z :: tail) :=
Nat.le_of_mul_le_mul_left hquotMul (by positivity : 0 < B)
have hpowStep : 10 ^ (z :: tail).length = 10 * 10 ^ tail.length := by
simp only [List.length_cons, pow_succ]
ring
have hupper : 10 * F (z :: tail) < 10 ^ (z :: tail).length := by
rw [hflow, hpowStep]
exact Nat.mul_lt_mul_of_pos_left htailBound (by norm_num)
omega
have hfirst : exists z : Nat,
(a1.val.map (fun b : Std.U8 => b.val))[0]? = some z /\
1 <= z /\ z < 10 := by
by_cases hwritePos : write.val > 0
· obtain ⟨z, tail, hlowEq, hz⟩ := hlowLead hwritePos
have hz10 : z < 10 := hlowDigit z (by simp [hlowEq])
have hzeroGet : low[0]? = some z := by simp [hlowEq]
have harrayMain := hlowArray 0 (by simp [hlowEq])
have harrayPreserve := hbelow 0 (by omega) hwritePos
have hmapPreserve :
(a1.val.map (fun b : Std.U8 => b.val))[0]? =
(a.val.map (fun b : Std.U8 => b.val))[0]? := by
simp only [List.getElem?_map, harrayPreserve]
rw [hmapPreserve, harrayMain, hzeroGet]
exact ⟨z, rfl, hz, hz10⟩
· have hwriteZero : write.val = 0 := by omega
obtain ⟨z, tail, hhighEq, hz⟩ := hhighLead hwriteZero
have hz10 : z < 10 := hhighDigit z (by simp [hhighEq])
have harrayHigh := hhighArray 0 (by simp [hhighEq]) (by omega)
have hzeroGet : high[0]? = some z := by simp [hhighEq]
have harrayHigh' :
(a1.val.map (fun b : Std.U8 => b.val))[0]? = some z := by
simpa [hwriteZero] using harrayHigh.trans hzeroGet
exact ⟨z, harrayHigh', hz, hz10⟩
let pre : num.imp.dec2flt.decimal_seq.DecimalSeq :=
{ num_digits := write1, decimal_point := point,
truncated := bc, digits := a1 }
have hpreBound : pre.num_digits.val <= pre.digits.val.length := by
simp [pre, a1.property]
rw [hwrite1]
exact Nat.min_le_right _ _
have htrimSem := DecimalSeqTrimSemantics pre d' hpreBound htrim
dsimp only at htrimSem
rcases htrimSem with ⟨hdigitsEq, hpointEq, htruncatedEq, htrimCount,
htrimZeros, htrimLast, htrimValue⟩
have hwrite1Bound : write1.val <= 768 := by
rw [hwrite1]
exact Nat.min_le_right _ _
have hcountBound : d'.num_digits.val <= 768 := by
exact le_trans htrimCount hwrite1Bound
have hlastNonzero :
d'.digits.val[d'.num_digits.val - 1]? ≠ some 0#u8 := by
rcases htrimLast with hzero | hlast
· exact False.elim (hnonzero hzero)
· simpa [pre, hdigitsEq] using hlast
let negRangeFixed : Std.I32 := (-2047)#i32
have hnegRangeFixed :
-. num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE =
ok negRangeFixed := by
unfold num.imp.dec2flt.decimal_seq.DecimalSeq.DECIMAL_POINT_RANGE
change IScalar.neg (2047#i32 : Std.I32) = _
unfold IScalar.neg IScalar.tryMk IScalar.tryMkOpt
norm_num [IScalar.check_bounds, IScalarTy.numBits, negRangeFixed]
have hnegEq : negRange = negRangeFixed := by
have heq := hnegRange.symm.trans hnegRangeFixed
exact Result.ok.inj heq
have hnegRangeVal : negRange.val = -2047 := by
simp [negRangeFixed, hnegEq]
have hpointLower : -2047 <= d'.decimal_point.val := by
have hd'point : d'.decimal_point.val = point.val := by
simpa [pre] using congrArg IScalar.val hpointEq
rw [hd'point]
have hnot : ¬ point.val < -2047 := by
simpa [IScalar.lt_equiv, hnegRangeVal] using hnotReset
omega
have hretainedDigits : forall b,
b ∈ d'.digits.val.take d'.num_digits.val -> b.val < 10 := by
intro b hb
rcases List.mem_iff_getElem.mp hb with ⟨j, hj, rfl⟩
have hj768 : j < d'.num_digits.val := by
simp only [List.length_take] at hj
omega
have hjwrite : j < write1.val := lt_of_lt_of_le hj768 htrimCount
obtain ⟨z, hcell, hz⟩ := hcellDecimal j hjwrite
have hjArr : j < d'.digits.val.length := by
simp [hdigitsEq, pre, a1.property]
omega
have hcell' : (d'.digits.val.map (fun b : Std.U8 => b.val))[j]? = some z := by
simpa [hdigitsEq, pre] using hcell
have hval : d'.digits.val[j].val = z := by
simpa [List.getElem?_map, List.getElem?_eq_getElem hjArr] using hcell'
simpa [hval] using hz
obtain ⟨first, hfirstCell, hfirstPos, hfirstLt⟩ := hfirst
let retained : List Nat :=
(d'.digits.val.take d'.num_digits.val).map (fun b => b.val)
have hretainedLen : retained.length = d'.num_digits.val := by
simp [retained, List.length_take, d'.digits.property]
omega
have hretainedFirst : retained[0]? = some first := by
have hcountPos : 0 < d'.num_digits.val := Nat.pos_of_ne_zero hnonzero
have hmapFirst :
(d'.digits.val.map (fun b : Std.U8 => b.val))[0]? = some first := by
simpa [hdigitsEq, pre] using hfirstCell
simpa [retained, List.getElem?_map, hcountPos] using hmapFirst
have hretainedHead : exists tail,
retained = first :: tail /\ (first :: tail).length = d'.num_digits.val := by
cases hlist : retained with
| nil =>
simp [hlist] at hretainedLen
exact False.elim (hnonzero hretainedLen)
| cons z tail =>
have hfirstEq : z = first := by
have heq : some z = some first := by simpa [hlist] using hretainedFirst
exact Option.some.inj heq
refine ⟨tail, ?_, ?_⟩
· simpa [hlist, hfirstEq]
· simpa [hlist, hfirstEq] using hretainedLen
have hdyad := (P472_T1_DecimalSeqDyadicShiftSemantics).2
d d' shift X eta u hshift hVpos hdigits hcall hX heta0 hetau hsticky
rcases hdyad with hreset | ⟨eta', u', hX', heta'0, heta'u', hsticky', hY', _⟩
· simp [hreset.1] at hnonzero
· have hY' : Y / (2 : Real) ^ shift.val =
((((d'.digits.val.take d'.num_digits.val).map (fun b => b.val)).foldl
(fun n z => 10 * n + z) 0 : Nat) : Real) *
(10 : Real) ^ (d'.decimal_point.val - (d'.num_digits.val : Int)) + u' := by
calc
Y / (2 : Real) ^ shift.val =
(((((d.digits.val.take d.num_digits.val).map (fun b => b.val)).foldl
(fun n z => 10 * n + z) 0 : Nat) : Real) *
(10 : Real) ^ (d.decimal_point.val - (d.num_digits.val : Int)) + u) /
(2 : Real) ^ shift.val := by
rw [hY]
_ = _ := hY'.symm
have hheadOut : exists first tail,
(d'.digits.val.take d'.num_digits.val).map (fun b => b.val) =
first :: tail /\
1 <= first /\ first < 10 /\
(first :: tail).length = d'.num_digits.val := by
rcases hretainedHead with ⟨tail, hlist, hlen⟩
exact ⟨first, tail, by simpa [retained] using hlist,
hfirstPos, hfirstLt, by simpa using hlen⟩
refine ⟨hpointLower, hcountBound, hretainedDigits, hheadOut,
hlastNonzero, ?_⟩
refine ⟨eta', u', ?_, hY', heta'0, heta'u', hsticky'⟩
simpa using hX'
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Uses
Inspect related source (117)
- DecimalSeq · dec2flt/decimal_seq.rs:22 Program Rust
- default · dec2flt/decimal_seq.rs:34 Program Rust
- MAX_DIGITS · dec2flt/decimal_seq.rs:64 Program Rust
More program dependencies (84)
- left_shift · dec2flt/decimal_seq.rs:130 Program Rust
- left_shift_loop0 · dec2flt/decimal_seq.rs:139 Program Rust
- body · dec2flt/decimal_seq.rs:139 Program Rust
- left_shift_loop1 · dec2flt/decimal_seq.rs:153 Program Rust
- body · dec2flt/decimal_seq.rs:153 Program Rust
- right_shift · dec2flt/decimal_seq.rs:176 Program Rust
- right_shift_loop0 · dec2flt/decimal_seq.rs:181 Program Rust
- body · dec2flt/decimal_seq.rs:181 Program Rust
- right_shift_loop0_loop0 · dec2flt/decimal_seq.rs:191 Program Rust
- body · dec2flt/decimal_seq.rs:191 Program Rust
- right_shift_loop1 · dec2flt/decimal_seq.rs:210 Program Rust
- body · dec2flt/decimal_seq.rs:210 Program Rust
- right_shift_loop2 · dec2flt/decimal_seq.rs:217 Program Rust
- body · dec2flt/decimal_seq.rs:217 Program Rust
- trim · dec2flt/decimal_seq.rs:83 Program Rust
- trim_loop · dec2flt/decimal_seq.rs:92 Program Rust
- body · dec2flt/decimal_seq.rs:92 Program Rust
- DECIMAL_POINT_RANGE · dec2flt/decimal_seq.rs:68 Program Rust
- number_of_digits_decimal_left_shift · dec2flt/decimal_seq.rs:375 Program Rust
- number_of_digits_decimal_left_shift_loop · dec2flt/decimal_seq.rs:441 Program Rust
- body · dec2flt/decimal_seq.rs:441 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:56 Program Rust
- zero_pow2 · dec2flt/common.rs:66 Program Rust
- ByteSlice · dec2flt/common.rs:4 Program Rust
- Decimal · dec2flt/decimal.rs:32 Program Rust
- round · dec2flt/decimal_seq.rs:97 Program Rust
- round_loop · dec2flt/decimal_seq.rs:107 Program Rust
- body · dec2flt/decimal_seq.rs:107 Program Rust
- TABLE · dec2flt/decimal_seq.rs:377 Program Rust
- TABLE_POW5 · dec2flt/decimal_seq.rs:386 Program Rust
- parse_decimal_seq · dec2flt/decimal_seq.rs:288 Program Rust
- parse_decimal_seq_loop0 · dec2flt/decimal_seq.rs:296 Program Rust
- body · dec2flt/decimal_seq.rs:296 Program Rust
- parse_decimal_seq_loop1 · dec2flt/decimal_seq.rs:368 Program Rust
- body · dec2flt/decimal_seq.rs:368 Program Rust
- parse_decimal_seq_loop2 · dec2flt/decimal_seq.rs:309 Program Rust
- body · dec2flt/decimal_seq.rs:309 Program Rust
- parse_decimal_seq_loop3 · dec2flt/decimal_seq.rs:313 Program Rust
- body · dec2flt/decimal_seq.rs:313 Program Rust
- parse_decimal_seq_loop4 · dec2flt/decimal_seq.rs:368 Program Rust
- body · dec2flt/decimal_seq.rs:368 Program Rust
- parse_decimal_seq_loop5 · dec2flt/decimal_seq.rs:313 Program Rust
- body · dec2flt/decimal_seq.rs:313 Program Rust
- parse_decimal_seq_loop6 · dec2flt/decimal_seq.rs:368 Program Rust
- body · dec2flt/decimal_seq.rs:368 Program Rust
- parse_decimal_seq_loop7 · dec2flt/decimal_seq.rs:368 Program Rust
- body · dec2flt/decimal_seq.rs:368 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:22 Program Rust
- write_u64 · dec2flt/common.rs:29 Program Rust
- is_8digits · dec2flt/common.rs:44 Program Rust
- MAX_DIGITS_WITHOUT_OVERFLOW · dec2flt/decimal_seq.rs:67 Program Rust
- count_trailing_zeros · dec2flt/decimal_seq.rs:236 Program Rust
- count_trailing_zeros_loop · dec2flt/decimal_seq.rs:240 Program Rust
- body · dec2flt/decimal_seq.rs:240 Program Rust
- final_decimal_point · dec2flt/decimal_seq.rs:269 Program Rust
- parse_digits_into_seq · dec2flt/decimal_seq.rs:257 Program Rust
- parse_digits_into_seq_loop · dec2flt/decimal_seq.rs:259 Program Rust
- body · dec2flt/decimal_seq.rs:259 Program Rust
- parse_scientific · dec2flt/parse.rs:121 Program Rust
- parse_scientific_loop · dec2flt/parse.rs:145 Program Rust
- body · dec2flt/parse.rs:145 Program Rust
- 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:74 Program Rust
Standard-library dependencies (30)
- bitand · core/src/ops/bit.rs:178 Rust library
- shl · core/src/ops/bit.rs:489 Rust library
- shr · core/src/ops/bit.rs:612 Rust library
- clone · core/src/clone.rs:698 Rust library
- div · core/src/ops/arith.rs:515 Rust library
- mul · core/src/ops/arith.rs:350 Rust library
- neg · core/src/ops/arith.rs:719 Rust library
- bitor · core/src/ops/bit.rs:282 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
- Dec2Flt.P340_T1_selected_target_numBits
- Quot.sound
- propext
This list combines the assumptions recorded for this declaration and its dependencies. It may include assumptions used by auxiliary declarations in those modules.
Helper theorems included
- DecimalDigitLexScale
- DecimalLeftShiftDigitGrowth
- DecimalLeftShiftFirstLoopSemantics
- DecimalLeftShiftLoopLex
- DecimalLeftShiftSecondLoopSemantics
- DecimalLeftShiftTableCertificate
All 26 entries
- DecimalDigitLexScale
- DecimalLeftShiftDigitGrowth
- DecimalLeftShiftFirstLoopSemantics
- DecimalLeftShiftLoopLex
- DecimalLeftShiftSecondLoopSemantics
- DecimalLeftShiftTableCertificate
- DecimalRightShiftU64DyadicBridge
- DecimalSeqLeftShiftRecordSemantics
- DecimalSeqTrimSemantics
- DecimalRightShiftFinalLoopSemantics
- DecimalRightShiftMainLoopSemantics
- DecimalRightShiftPrefixLoopSemantics
- DecimalSeqDyadicShiftSemantics
- DecimalSeqRightShiftRecordSemantics
- RightShiftCanonical
- PositiveScaleErrorTransport
- ResultLoopPartial
- num imp dec2flt decimal seq DecimalSeq
- num imp dec2flt decimal seq DecimalSeq DECIMAL POINT RANGE
- num imp dec2flt decimal seq DecimalSeq MAX DIGITS
- num imp dec2flt decimal seq DecimalSeq left shift
- num imp dec2flt decimal seq DecimalSeq right 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": "P495_T1_RightShiftCanonical",
"closure_version": "patch_c_v1",
"active_decl_hash": "030775dab3e100ecff1ba6b20e8851f85ca7d32a369ba986975e6700ca53a3d7",
"active_statement_hash": "874bacf5ca21d48a75e13ef9251a833d7e879811f45596b5fc1c99f4e1935723",
"kernel_axioms": [
"Classical.choice",
"Quot.sound",
"propext"
],
"toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
"lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
"checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
"approved_axioms_hash": "576e6bf9480cfd32f53c309c7ac8fb115c1ba6e413f299ed5ff9fa7c647e6769",
"axcheck_status": "Agreed",
"accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-181",
"boundary_theorems": {},
"strict_theorem_deps": {
"DecimalSeqTrimSemantics": "e4b2cbb62f7171af",
"P472_T1_DecimalRightShiftFinalLoopSemantics": "79a214a5ee500eac",
"P472_T1_DecimalRightShiftMainLoopSemantics": "647cdcc98ff47e21",
"P472_T1_DecimalRightShiftPrefixLoopSemantics": "0d5cb25f18eedbfb",
"P472_T1_DecimalSeqDyadicShiftSemantics": "9d844d655b9f8a27",
"num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE": "01b84a7a35e5bcf4",
"num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift": "5f4488c177675662"
},
"strict_definition_deps": {
"num_imp_dec2flt_decimal_seq_DecimalSeq": "6799fe6525ddb761",
"num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE": "0cc5155758bc976a",
"num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift": "fd298e37d5ae4f86",
"num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift": "4db7c37f5da1c6e0",
"num_imp_dec2flt_decimal_seq_DecimalSeq_trim": "faa9fd92b8c29c14"
}
}Prose assessment
{
"label": "Recorded Sound: VerifierPass",
"assessment_status": "VerifierPass",
"fingerprint_relation": "matches current fingerprint",
"assessment_fingerprint": "sound-v2:5e0c49d41b8e15850089ad6137f5149ef93e488aa433a65c4d9ac9e4fc437941",
"current_fingerprint": "sound-v2:5e0c49d41b8e15850089ad6137f5149ef93e488aa433a65c4d9ac9e4fc437941",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"sound_status": "Pass",
"substantiveness_status": "Pass"
}