Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Lemma · Retained decimal value and exact sticky error
C'.take n,
that d.\mathit{truncated} is true exactly when N>768, and that
d.\mathit{decimal\_point}=P+E.Lean statement
Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.
import Tablet.DecimalGoalVocabularyDefault
import Tablet.NumberHelperDecimalPrefixInterval
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq
import Mathlib.Data.List.DropRight
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqRetainedValue]
theorem DecimalSeqRetainedValue :
forall (x : DecimalLexeme)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq),
x.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric x ->
let significand := x.integerDigits ++
match x.fractionDigits with | none => [] | some ds => ds
let significant := significand.dropWhile (fun digit => digit == 0)
let trimmed :=
(significant.reverse.dropWhile (fun digit => digit == 0)).reverse
let leadingZeros := significand.length - significant.length
let P : Int := (x.integerDigits.length : Int) - leadingZeros
let E : Int :=
DecimalGoalVocabularyDefault.accumulatedExplicitExponent x
d.num_digits.val = min trimmed.length 768 ->
(d.digits.val.take d.num_digits.val).map (fun z => z.val) =
trimmed.take d.num_digits.val ->
(d.truncated = true <-> 768 < trimmed.length) ->
d.decimal_point.val = P + E ->
d.num_digits.val <= 768 /\
(forall z, z ∈ d.digits.val.take d.num_digits.val -> z.val < 10) /\
let retainedDigits :=
(d.digits.val.take d.num_digits.val).map (fun z => z.val)
let retainedInteger : Nat :=
retainedDigits.foldl (fun n digit => 10 * n + digit) 0
let retainedValue : Real :=
retainedInteger * (10 : Real) ^
(d.decimal_point.val - (d.num_digits.val : Int))
let cutoff : Real :=
(10 : Real) ^ (d.decimal_point.val - (768 : Int))
exists eta : Real,
DecimalGoalVocabularyDefault.accumulatedMagnitude x =
retainedValue + eta /\
0 <= eta /\ eta < cutoff /\
(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
C'.take n, every retained
cell is below ten. The count equality immediately gives n\le768.accumulatedMagnitude in the cited vocabulary and using
(1)--(2) therefore yields
retainedInteger is exactly this I. Substitute (4) into (3), use
d.\mathit{decimal\_point}=P+E, and define
Lean proof
intro x d hsign hvalid
dsimp only
intro hnum hstored htruncated hpoint
let S : List Nat := x.integerDigits ++
match x.fractionDigits with | none => [] | some ds => ds
let C : List Nat := S.dropWhile (fun digit => digit == 0)
let T : List Nat := List.rdropWhile (fun digit => digit == 0) C
let F : Nat := match x.fractionDigits with | none => 0 | some ds => ds.length
let E : Int := DecimalGoalVocabularyDefault.accumulatedExplicitExponent x
change d.num_digits.val = min T.length 768 at hnum
change (d.digits.val.take d.num_digits.val).map (fun z => z.val) =
T.take d.num_digits.val at hstored
change (d.truncated = true ↔ 768 < T.length) at htruncated
change d.decimal_point.val =
(x.integerDigits.length : Int) - (S.length - C.length : Nat) + E at hpoint
have hCS : C <:+ S := by
exact List.dropWhile_suffix _
have hTC : T <+: C := by
exact List.rdropWhile_prefix _ _
have hSdigits : forall digit, digit ∈ S -> digit < 10 := by
intro digit hdigit
rcases hvalid with ⟨hinteger, hfraction, hnonempty, hexponent⟩
simp only [S, List.mem_append] at hdigit
rcases hdigit with hdigit | hdigit
· exact hinteger digit hdigit
· cases hfrac : x.fractionDigits with
| none => simp [hfrac] at hdigit
| some ds =>
simp only [hfrac] at hdigit hfraction
exact hfraction digit hdigit
have hTdigits : forall digit, digit ∈ T -> digit < 10 := by
intro digit hdigit
exact hSdigits digit (hCS.sublist.mem (hTC.sublist.mem hdigit))
have hnle : d.num_digits.val ≤ 768 := by omega
refine ⟨hnle, ?_, ?_⟩
· intro z hz
have hzmap : z.val ∈
(d.digits.val.take d.num_digits.val).map (fun z => z.val) :=
List.mem_map_of_mem hz
rw [hstored] at hzmap
exact hTdigits z.val (List.mem_of_mem_take hzmap)
· dsimp only
rw [hstored]
let step : Nat -> Nat -> Nat := fun a digit => 10 * a + digit
let n : Nat := d.num_digits.val
let U : List Nat := T.take n
let W : List Nat := T.drop n
let m : Nat := U.foldl step 0
let z : Nat := T.foldl step 0
let full : Real := (z : Real) *
(10 : Real) ^ (d.decimal_point.val - (T.length : Int))
let retained : Real := (m : Real) *
(10 : Real) ^ (d.decimal_point.val - (n : Int))
let cutoff : Real :=
(10 : Real) ^ (d.decimal_point.val - (768 : Int))
have hn : n = min T.length 768 := by exact hnum
have hnT : n ≤ T.length := by omega
have hsplit : U ++ W = T := by
exact List.take_append_drop n T
have hWdigits : forall digit, digit ∈ W -> digit < 10 := by
intro digit hdigit
exact hTdigits digit (List.mem_of_mem_drop hdigit)
have fold_shift : forall (ds : List Nat) (a : Nat),
ds.foldl step a = a * 10 ^ ds.length + ds.foldl step 0 := by
intro ds
induction ds with
| nil => intro a; simp
| cons digit ds ih =>
intro a
simp only [List.foldl_cons, List.length_cons]
rw [ih (step a digit), show step 0 digit = digit by simp [step], ih digit]
simp only [step, Nat.pow_succ]
ring
have fold_leading : forall ds : List Nat,
(ds.dropWhile (fun digit => digit == 0)).foldl step 0 =
ds.foldl step 0 := by
intro ds
induction ds with
| nil => rfl
| cons digit ds ih =>
by_cases hdigit : digit = 0
· subst digit
simpa [step] using ih
· have hb : (digit == 0) = false :=
beq_eq_false_iff_ne.mpr hdigit
simp [List.dropWhile, hb]
let Q : List Nat := List.rtakeWhile (fun digit => digit == 0) C
have hTCQ : T ++ Q = C := by
exact List.rdropWhile_append_rtakeWhile
have hQzero : forall digit, digit ∈ Q -> digit = 0 := by
intro digit hdigit
have hb := List.mem_rtakeWhile_imp hdigit
exact beq_iff_eq.mp hb
have fold_zero : forall ds : List Nat,
(forall digit, digit ∈ ds -> digit = 0) ->
ds.foldl step 0 = 0 := by
intro ds hzero
induction ds with
| nil => rfl
| cons digit ds ih =>
have hdigit := hzero digit List.mem_cons_self
subst digit
simp only [List.foldl_cons, step, Nat.mul_zero, Nat.zero_add]
apply ih
intro a ha
exact hzero a (List.mem_cons_of_mem 0 ha)
have hQfold : Q.foldl step 0 = 0 := fold_zero Q hQzero
have hfoldS : C.foldl step 0 = S.foldl step 0 := by
exact fold_leading S
have hfoldC : C.foldl step 0 = T.foldl step 0 * 10 ^ Q.length := by
rw [← hTCQ, List.foldl_append, fold_shift, hQfold]
omega
have hSlen : S.length = x.integerDigits.length + F := by
cases hfrac : x.fractionDigits with
| none => simp [S, F, hfrac]
| some ds => simp [S, F, hfrac]
have hCTlen : C.length = T.length + Q.length := by
rw [← hTCQ, List.length_append]
have hCLeS : C.length ≤ S.length := hCS.sublist.length_le
have hexponent :
(x.integerDigits.length : Int) - (S.length - C.length : Nat) + E -
(T.length : Int) =
(Q.length : Int) + (E - (F : Int)) := by
rw [Nat.cast_sub hCLeS]
push_cast at hSlen hCTlen ⊢
omega
have hmagnitude :
DecimalGoalVocabularyDefault.accumulatedMagnitude x =
((S.foldl step 0 : Nat) : Real) *
(10 : Real) ^ (E - (F : Int)) := by
cases hfrac : x.fractionDigits <;>
simp [DecimalGoalVocabularyDefault, S, step, E, F, hfrac]
have hfull :
DecimalGoalVocabularyDefault.accumulatedMagnitude x = full := by
rw [hmagnitude]
dsimp only [full, z]
rw [← hfoldS, hfoldC]
push_cast
rw [hpoint, hexponent, zpow_add₀ (by norm_num : (10 : Real) ≠ 0)]
norm_num
ring
have hWlen : W.length = T.length - n := by
simp [W]
have hscale :
d.decimal_point.val - (T.length : Int) + (W.length : Int) =
d.decimal_point.val - (n : Int) := by
rw [hWlen, Nat.cast_sub hnT]
omega
have hprefix := NumberHelperDecimalPrefixInterval U W hWdigits
(d.decimal_point.val - (T.length : Int))
dsimp only at hprefix
rw [hsplit, hscale] at hprefix
change retained ≤ full /\
full < (((m + 1 : Nat) : Real)) *
(10 : Real) ^ (d.decimal_point.val - (n : Int)) at hprefix
have hfoldSplit : z = m * 10 ^ W.length + W.foldl step 0 := by
dsimp only [z, m]
rw [← hsplit, List.foldl_append]
exact fold_shift W (U.foldl step 0)
have hdecomp : full = retained +
((W.foldl step 0 : Nat) : Real) *
(10 : Real) ^ (d.decimal_point.val - (T.length : Int)) := by
dsimp only [full, retained]
rw [hfoldSplit]
push_cast
rw [← hscale, zpow_add₀ (by norm_num : (10 : Real) ≠ 0)]
norm_num
ring
have hetaNonnegative : 0 ≤ full - retained := by
linarith [hprefix.1]
refine ⟨full - retained, ?_, hetaNonnegative, ?_, ?_⟩
· rw [hfull]
ring
· by_cases hlong : 768 < T.length
· have hn768 : n = 768 := by omega
have hmcast : (((m + 1 : Nat) : Real)) = (m : Real) + 1 := by
norm_num
calc
full - retained <
(((m + 1 : Nat) : Real)) *
(10 : Real) ^ (d.decimal_point.val - (n : Int)) -
retained := sub_lt_sub_right hprefix.2 retained
_ = cutoff := by
simp only [retained, cutoff, hn768, hmcast]
ring_nf
· have hnlength : n = T.length := by omega
have hWnil : W = [] := by simp [W, hnlength]
have heta : full - retained = 0 := by
rw [hdecomp, hWnil]
simp
rw [heta]
exact zpow_pos (by norm_num) _
· by_cases hlong : 768 < T.length
· have hn768 : n = 768 := by omega
have hWlenPos : 0 < W.length := by
rw [hWlen, hn768]
omega
have hWne : W ≠ [] := List.ne_nil_of_length_pos hWlenPos
have hTne : T ≠ [] := by
intro hnil
rw [hnil] at hlong
simp at hlong
have hlastNotZero : T.getLast hTne ≠ 0 := by
have hlast := List.rdropWhile_last_not
(fun digit : Nat => digit == 0) C
(by simpa only [T] using hTne)
simpa only [Bool.not_eq_true, beq_eq_false_iff_ne] using hlast
have hlastEq : T.getLast hTne = W.getLast hWne := by
simpa only [← hsplit] using
List.getLast_append_of_right_ne_nil U W hWne
have hWlastPos : 0 < W.getLast hWne := by
rw [← hlastEq]
omega
have hWfoldPos : 0 < W.foldl step 0 := by
rw [← List.dropLast_append_getLast hWne, List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, step]
omega
have hsuffixPos : 0 < ((W.foldl step 0 : Nat) : Real) *
(10 : Real) ^ (d.decimal_point.val - (T.length : Int)) :=
mul_pos (by exact_mod_cast hWfoldPos) (zpow_pos (by norm_num) _)
have hetaPos : 0 < full - retained := by
rw [hdecomp]
linarith
constructor
· intro hflag
exact hetaPos
· intro heta
exact htruncated.mpr hlong
· have hnlength : n = T.length := by omega
have hWnil : W = [] := by simp [W, hnlength]
have heta : full - retained = 0 := by
rw [hdecomp, hWnil]
simp
constructor
· intro hflag
have := htruncated.mp hflag
omega
· intro hpositive
rw [heta] at hpositive
linarith
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.DecimalGoalVocabularyDefault
import Tablet.NumberHelperDecimalPrefixInterval
import Tablet.num_imp_dec2flt_decimal_seq_DecimalSeq
import Mathlib.Data.List.DropRight
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalSeqRetainedValue]
theorem DecimalSeqRetainedValue :
forall (x : DecimalLexeme)
(d : num.imp.dec2flt.decimal_seq.DecimalSeq),
x.leadingSign = none ->
DecimalGoalVocabularyDefault.validNumeric x ->
let significand := x.integerDigits ++
match x.fractionDigits with | none => [] | some ds => ds
let significant := significand.dropWhile (fun digit => digit == 0)
let trimmed :=
(significant.reverse.dropWhile (fun digit => digit == 0)).reverse
let leadingZeros := significand.length - significant.length
let P : Int := (x.integerDigits.length : Int) - leadingZeros
let E : Int :=
DecimalGoalVocabularyDefault.accumulatedExplicitExponent x
d.num_digits.val = min trimmed.length 768 ->
(d.digits.val.take d.num_digits.val).map (fun z => z.val) =
trimmed.take d.num_digits.val ->
(d.truncated = true <-> 768 < trimmed.length) ->
d.decimal_point.val = P + E ->
d.num_digits.val <= 768 /\
(forall z, z ∈ d.digits.val.take d.num_digits.val -> z.val < 10) /\
let retainedDigits :=
(d.digits.val.take d.num_digits.val).map (fun z => z.val)
let retainedInteger : Nat :=
retainedDigits.foldl (fun n digit => 10 * n + digit) 0
let retainedValue : Real :=
retainedInteger * (10 : Real) ^
(d.decimal_point.val - (d.num_digits.val : Int))
let cutoff : Real :=
(10 : Real) ^ (d.decimal_point.val - (768 : Int))
exists eta : Real,
DecimalGoalVocabularyDefault.accumulatedMagnitude x =
retainedValue + eta /\
0 <= eta /\ eta < cutoff /\
(d.truncated = true <-> 0 < eta) := by
-- BODY
intro x d hsign hvalid
dsimp only
intro hnum hstored htruncated hpoint
let S : List Nat := x.integerDigits ++
match x.fractionDigits with | none => [] | some ds => ds
let C : List Nat := S.dropWhile (fun digit => digit == 0)
let T : List Nat := List.rdropWhile (fun digit => digit == 0) C
let F : Nat := match x.fractionDigits with | none => 0 | some ds => ds.length
let E : Int := DecimalGoalVocabularyDefault.accumulatedExplicitExponent x
change d.num_digits.val = min T.length 768 at hnum
change (d.digits.val.take d.num_digits.val).map (fun z => z.val) =
T.take d.num_digits.val at hstored
change (d.truncated = true ↔ 768 < T.length) at htruncated
change d.decimal_point.val =
(x.integerDigits.length : Int) - (S.length - C.length : Nat) + E at hpoint
have hCS : C <:+ S := by
exact List.dropWhile_suffix _
have hTC : T <+: C := by
exact List.rdropWhile_prefix _ _
have hSdigits : forall digit, digit ∈ S -> digit < 10 := by
intro digit hdigit
rcases hvalid with ⟨hinteger, hfraction, hnonempty, hexponent⟩
simp only [S, List.mem_append] at hdigit
rcases hdigit with hdigit | hdigit
· exact hinteger digit hdigit
· cases hfrac : x.fractionDigits with
| none => simp [hfrac] at hdigit
| some ds =>
simp only [hfrac] at hdigit hfraction
exact hfraction digit hdigit
have hTdigits : forall digit, digit ∈ T -> digit < 10 := by
intro digit hdigit
exact hSdigits digit (hCS.sublist.mem (hTC.sublist.mem hdigit))
have hnle : d.num_digits.val ≤ 768 := by omega
refine ⟨hnle, ?_, ?_⟩
· intro z hz
have hzmap : z.val ∈
(d.digits.val.take d.num_digits.val).map (fun z => z.val) :=
List.mem_map_of_mem hz
rw [hstored] at hzmap
exact hTdigits z.val (List.mem_of_mem_take hzmap)
· dsimp only
rw [hstored]
let step : Nat -> Nat -> Nat := fun a digit => 10 * a + digit
let n : Nat := d.num_digits.val
let U : List Nat := T.take n
let W : List Nat := T.drop n
let m : Nat := U.foldl step 0
let z : Nat := T.foldl step 0
let full : Real := (z : Real) *
(10 : Real) ^ (d.decimal_point.val - (T.length : Int))
let retained : Real := (m : Real) *
(10 : Real) ^ (d.decimal_point.val - (n : Int))
let cutoff : Real :=
(10 : Real) ^ (d.decimal_point.val - (768 : Int))
have hn : n = min T.length 768 := by exact hnum
have hnT : n ≤ T.length := by omega
have hsplit : U ++ W = T := by
exact List.take_append_drop n T
have hWdigits : forall digit, digit ∈ W -> digit < 10 := by
intro digit hdigit
exact hTdigits digit (List.mem_of_mem_drop hdigit)
have fold_shift : forall (ds : List Nat) (a : Nat),
ds.foldl step a = a * 10 ^ ds.length + ds.foldl step 0 := by
intro ds
induction ds with
| nil => intro a; simp
| cons digit ds ih =>
intro a
simp only [List.foldl_cons, List.length_cons]
rw [ih (step a digit), show step 0 digit = digit by simp [step], ih digit]
simp only [step, Nat.pow_succ]
ring
have fold_leading : forall ds : List Nat,
(ds.dropWhile (fun digit => digit == 0)).foldl step 0 =
ds.foldl step 0 := by
intro ds
induction ds with
| nil => rfl
| cons digit ds ih =>
by_cases hdigit : digit = 0
· subst digit
simpa [step] using ih
· have hb : (digit == 0) = false :=
beq_eq_false_iff_ne.mpr hdigit
simp [List.dropWhile, hb]
let Q : List Nat := List.rtakeWhile (fun digit => digit == 0) C
have hTCQ : T ++ Q = C := by
exact List.rdropWhile_append_rtakeWhile
have hQzero : forall digit, digit ∈ Q -> digit = 0 := by
intro digit hdigit
have hb := List.mem_rtakeWhile_imp hdigit
exact beq_iff_eq.mp hb
have fold_zero : forall ds : List Nat,
(forall digit, digit ∈ ds -> digit = 0) ->
ds.foldl step 0 = 0 := by
intro ds hzero
induction ds with
| nil => rfl
| cons digit ds ih =>
have hdigit := hzero digit List.mem_cons_self
subst digit
simp only [List.foldl_cons, step, Nat.mul_zero, Nat.zero_add]
apply ih
intro a ha
exact hzero a (List.mem_cons_of_mem 0 ha)
have hQfold : Q.foldl step 0 = 0 := fold_zero Q hQzero
have hfoldS : C.foldl step 0 = S.foldl step 0 := by
exact fold_leading S
have hfoldC : C.foldl step 0 = T.foldl step 0 * 10 ^ Q.length := by
rw [← hTCQ, List.foldl_append, fold_shift, hQfold]
omega
have hSlen : S.length = x.integerDigits.length + F := by
cases hfrac : x.fractionDigits with
| none => simp [S, F, hfrac]
| some ds => simp [S, F, hfrac]
have hCTlen : C.length = T.length + Q.length := by
rw [← hTCQ, List.length_append]
have hCLeS : C.length ≤ S.length := hCS.sublist.length_le
have hexponent :
(x.integerDigits.length : Int) - (S.length - C.length : Nat) + E -
(T.length : Int) =
(Q.length : Int) + (E - (F : Int)) := by
rw [Nat.cast_sub hCLeS]
push_cast at hSlen hCTlen ⊢
omega
have hmagnitude :
DecimalGoalVocabularyDefault.accumulatedMagnitude x =
((S.foldl step 0 : Nat) : Real) *
(10 : Real) ^ (E - (F : Int)) := by
cases hfrac : x.fractionDigits <;>
simp [DecimalGoalVocabularyDefault, S, step, E, F, hfrac]
have hfull :
DecimalGoalVocabularyDefault.accumulatedMagnitude x = full := by
rw [hmagnitude]
dsimp only [full, z]
rw [← hfoldS, hfoldC]
push_cast
rw [hpoint, hexponent, zpow_add₀ (by norm_num : (10 : Real) ≠ 0)]
norm_num
ring
have hWlen : W.length = T.length - n := by
simp [W]
have hscale :
d.decimal_point.val - (T.length : Int) + (W.length : Int) =
d.decimal_point.val - (n : Int) := by
rw [hWlen, Nat.cast_sub hnT]
omega
have hprefix := NumberHelperDecimalPrefixInterval U W hWdigits
(d.decimal_point.val - (T.length : Int))
dsimp only at hprefix
rw [hsplit, hscale] at hprefix
change retained ≤ full /\
full < (((m + 1 : Nat) : Real)) *
(10 : Real) ^ (d.decimal_point.val - (n : Int)) at hprefix
have hfoldSplit : z = m * 10 ^ W.length + W.foldl step 0 := by
dsimp only [z, m]
rw [← hsplit, List.foldl_append]
exact fold_shift W (U.foldl step 0)
have hdecomp : full = retained +
((W.foldl step 0 : Nat) : Real) *
(10 : Real) ^ (d.decimal_point.val - (T.length : Int)) := by
dsimp only [full, retained]
rw [hfoldSplit]
push_cast
rw [← hscale, zpow_add₀ (by norm_num : (10 : Real) ≠ 0)]
norm_num
ring
have hetaNonnegative : 0 ≤ full - retained := by
linarith [hprefix.1]
refine ⟨full - retained, ?_, hetaNonnegative, ?_, ?_⟩
· rw [hfull]
ring
· by_cases hlong : 768 < T.length
· have hn768 : n = 768 := by omega
have hmcast : (((m + 1 : Nat) : Real)) = (m : Real) + 1 := by
norm_num
calc
full - retained <
(((m + 1 : Nat) : Real)) *
(10 : Real) ^ (d.decimal_point.val - (n : Int)) -
retained := sub_lt_sub_right hprefix.2 retained
_ = cutoff := by
simp only [retained, cutoff, hn768, hmcast]
ring_nf
· have hnlength : n = T.length := by omega
have hWnil : W = [] := by simp [W, hnlength]
have heta : full - retained = 0 := by
rw [hdecomp, hWnil]
simp
rw [heta]
exact zpow_pos (by norm_num) _
· by_cases hlong : 768 < T.length
· have hn768 : n = 768 := by omega
have hWlenPos : 0 < W.length := by
rw [hWlen, hn768]
omega
have hWne : W ≠ [] := List.ne_nil_of_length_pos hWlenPos
have hTne : T ≠ [] := by
intro hnil
rw [hnil] at hlong
simp at hlong
have hlastNotZero : T.getLast hTne ≠ 0 := by
have hlast := List.rdropWhile_last_not
(fun digit : Nat => digit == 0) C
(by simpa only [T] using hTne)
simpa only [Bool.not_eq_true, beq_eq_false_iff_ne] using hlast
have hlastEq : T.getLast hTne = W.getLast hWne := by
simpa only [← hsplit] using
List.getLast_append_of_right_ne_nil U W hWne
have hWlastPos : 0 < W.getLast hWne := by
rw [← hlastEq]
omega
have hWfoldPos : 0 < W.foldl step 0 := by
rw [← List.dropLast_append_getLast hWne, List.foldl_append]
simp only [List.foldl_cons, List.foldl_nil, step]
omega
have hsuffixPos : 0 < ((W.foldl step 0 : Nat) : Real) *
(10 : Real) ^ (d.decimal_point.val - (T.length : Int)) :=
mul_pos (by exact_mod_cast hWfoldPos) (zpow_pos (by norm_num) _)
have hetaPos : 0 < full - retained := by
rw [hdecomp]
linarith
constructor
· intro hflag
exact hetaPos
· intro heta
exact htruncated.mpr hlong
· have hnlength : n = T.length := by omega
have hWnil : W = [] := by simp [W, hnlength]
have heta : full - retained = 0 := by
rw [hdecomp, hWnil]
simp
constructor
· intro hflag
have := htruncated.mp hflag
omega
· intro hpositive
rw [heta] at hpositive
linarith
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Uses
Inspect related source (44)
- DecimalSeq · dec2flt/decimal_seq.rs:21 Program Rust
- BiasedFp · dec2flt/common.rs:52 Program Rust
- Decimal · dec2flt/decimal.rs:32 Program Rust
More program dependencies (11)
- 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
- ByteSlice · dec2flt/common.rs:4 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
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
Technical checking records
Local closure summary
{
"node": "DecimalSeqRetainedValue",
"closure_version": "patch_c_v1",
"active_decl_hash": "1c41fa07782280e7c2a192caa29aef773933b345222356e2e71b61963e28efcb",
"active_statement_hash": "7c67dbbcda7652213d1bc0944c9431e47ae357c1e9c46643a49f05a40dc44085",
"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-165",
"boundary_theorems": {},
"strict_theorem_deps": {
"DecimalGoalVocabularyDefault": "94cb4c406f8efb78",
"NumberHelperDecimalPrefixInterval": "5c32858414034b55"
},
"strict_definition_deps": {
"DecimalGoalVocabulary": "c08dd4b4aea4abb4",
"DecimalGoalVocabularyDefault": "4634372c8f7a7f44",
"DecimalLexeme": "250be645520aec86",
"F64": "ec4e25fbaf4e11d4",
"num_imp_dec2flt_common_BiasedFp": "31d81cf1cf22709f",
"num_imp_dec2flt_decimal_Decimal": "63fd2f021dd0ef41",
"num_imp_dec2flt_decimal_seq_DecimalSeq": "c43614ff2149ecf2"
}
}Prose assessment
{
"label": "Recorded Sound: VerifierPass",
"assessment_status": "VerifierPass",
"fingerprint_relation": "matches current fingerprint",
"assessment_fingerprint": "sound-v2:4d117980194bd2fe48b38fef9e533639e2a37717c4230c5facf641b663b14c6b",
"current_fingerprint": "sound-v2:4d117980194bd2fe48b38fef9e533639e2a37717c4230c5facf641b663b14c6b",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"sound_status": "Pass",
"substantiveness_status": "Pass"
}