Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Theorem
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.F64
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64
import Tablet.F64_Insts_CoreOpsArithDivF64F64
import Tablet.F64_Insts_CoreOpsArithMulF64F64
import Tablet.F64_Insts_CoreOpsArithNegF64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.num_imp_dec2flt_dec2flt
import Tablet.num_imp_dec2flt_dec2flt_with_trace
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_parse_parse_inf_nan
import Tablet.num_imp_dec2flt_decimal_Decimal_try_fast_path
import Tablet.num_imp_dec2flt_lemire_compute_float
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_dec2flt_biased_fp_to_float
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: RoundingTotality]
theorem RoundingTotality :
∀ x : Real, 0 <= x -> ∃ target : F64, DecimalGoalVocabularyDefault.roundsMagnitude x target := 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
F64 word with value field
I, and there is an F64 word with value field n for every natural
n<I. Moreover, two such words having the same value field are equal by
extensionality of the unsigned-word structure.roundsMagnitude field of
DecimalGoalVocabularyDefault. Its infinity word is exactly I,
its overflow threshold is exactly T, and its finite-value function is
roundsMagnitude are then discharged
as follows: 0\leq x is the hypothesis, w.\mathit{val}\leq I is equality,
and the conditional selects its infinity branch because
w.\mathit{val}=I, where its required conclusion is exactly T\leq x.
This supplies a target in the overflow case.roundsMagnitude. The leading clause 0\leq x is the original
hypothesis. The target bound is
w.\mathit{val}=r<I, hence w.\mathit{val}\leq I. In particular
w.\mathit{val}\ne I, so the conditional takes the finite branch, whose
first clause is precisely the current assumption x<T.Lean proof
set_option maxHeartbeats 800000 in
exact (by
intro x hx
dsimp [DecimalGoalVocabularyDefault]
let unit : Nat := 2 ^ 52
let top : Nat := 9218868437227405312
let threshold : Real := (2 : Real) ^ 1024 - (2 : Real) ^ 970
let value : Nat → Real := fun n =>
let e := n / 4503599627370496
let m := n % 4503599627370496
if e = 0 then (m : Real) / (2 : Real) ^ 1074
else if 1075 ≤ e then
((4503599627370496 + m : Nat) : Real) * (2 : Real) ^ (e - 1075)
else ((4503599627370496 + m : Nat) : Real) / (2 : Real) ^ (1075 - e)
have step : ∀ n : Nat, n + 1 < top → value n < value (n + 1) := by
intro n hn
let e := n / unit
let m := n % unit
have unit_pos : 0 < unit := by norm_num [unit]
have rem_bound : m < unit := by exact Nat.mod_lt _ unit_pos
have decomp : unit * e + m = n := by exact Nat.div_add_mod n unit
have top_value : top = 9218868437227405312 := by norm_num [top, unit]
have n_bound : n + 1 < 9218868437227405312 := by simpa [top_value] using hn
norm_num [unit] at decomp rem_bound n_bound ⊢
by_cases small : m + 1 < 4503599627370496
· have next_decomp : 4503599627370496 * e + (m + 1) = n + 1 := by omega
have value_n : value n = if e = 0 then (m : Real) / (2 : Real)^1074 else
if 1075 ≤ e then ((4503599627370496 + m : Nat) : Real) * (2 : Real)^(e-1075)
else ((4503599627370496 + m : Nat) : Real) / (2 : Real)^(1075-e) := by
dsimp [value]
rw [← decomp]
have quotient : (4503599627370496 * e + m) / 4503599627370496 = e := by
rw [Nat.mul_add_div (by norm_num)]
simp [Nat.div_eq_of_lt rem_bound]
have remainder : (4503599627370496 * e + m) % 4503599627370496 = m := by
rw [Nat.mul_add_mod]
simp [Nat.mod_eq_of_lt rem_bound]
simp [quotient, remainder] <;> ring
have value_next : value (n+1) = if e = 0 then (m+1 : Real) / (2 : Real)^1074 else
if 1075 ≤ e then ((4503599627370496 + m + 1 : Nat) : Real) * (2 : Real)^(e-1075)
else ((4503599627370496 + m + 1 : Nat) : Real) / (2 : Real)^(1075-e) := by
dsimp [value]
rw [← next_decomp]
have quotient : (4503599627370496 * e + (m + 1)) / 4503599627370496 = e := by
rw [Nat.mul_add_div (by norm_num)]
simp [Nat.div_eq_of_lt (by omega)]
have remainder : (4503599627370496 * e + (m + 1)) % 4503599627370496 = m + 1 := by
rw [Nat.mul_add_mod]
simp [Nat.mod_eq_of_lt (by omega)]
simp only [quotient, remainder, Nat.cast_add]
by_cases z : e = 0
· simp [z] <;> ring
· by_cases h : 1075 ≤ e
· simp [z, h] <;> ring
· simp [z, h] <;> ring
rw [value_n, value_next]
by_cases zero : e = 0
· simp [zero]
apply (div_lt_div_iff_of_pos_right (by positivity)).2
norm_num
· by_cases high : 1075 ≤ e
· simp [zero, high]
· simp [zero, high]
apply (div_lt_div_iff_of_pos_right (by positivity)).2
norm_num
· have edge : m + 1 = 4503599627370496 := by omega
have next_decomp : 4503599627370496 * (e + 1) = n + 1 := by omega
have value_n : value n = if e = 0 then (m : Real) / (2 : Real)^1074 else
if 1075 ≤ e then ((4503599627370496 + m : Nat) : Real) * (2 : Real)^(e-1075)
else ((4503599627370496 + m : Nat) : Real) / (2 : Real)^(1075-e) := by
dsimp [value]
rw [← decomp]
have quotient : (4503599627370496 * e + m) / 4503599627370496 = e := by
rw [Nat.mul_add_div (by norm_num)]
simp [Nat.div_eq_of_lt rem_bound]
have remainder : (4503599627370496 * e + m) % 4503599627370496 = m := by
rw [Nat.mul_add_mod]
simp [Nat.mod_eq_of_lt rem_bound]
simp [quotient, remainder]
have value_next : value (n+1) = if e+1 = 0 then (0 : Real) / (2 : Real)^1074 else
if 1075 ≤ e+1 then ((4503599627370496 : Nat) : Real) * (2 : Real)^((e+1)-1075)
else ((4503599627370496 : Nat) : Real) / (2 : Real)^ (1075-(e+1)) := by
dsimp [value]
rw [← next_decomp]
have quotient : (4503599627370496 * (e + 1)) / 4503599627370496 = e + 1 := by
rw [show 4503599627370496 * (e + 1) = (e + 1) * 4503599627370496 by ring]
exact Nat.mul_div_left _ (by norm_num)
have remainder : (4503599627370496 * (e + 1)) % 4503599627370496 = 0 := by
exact Nat.mul_mod_right _ _
simp [quotient, remainder] <;> ring
rw [value_n, value_next]
by_cases zero : e = 0
· have m_edge : m = 4503599627370495 := by omega
have next_zero : ¬e + 1 = 0 := by omega
have next_high : ¬1075 ≤ e + 1 := by omega
simp only [if_pos zero, if_neg next_zero, if_neg next_high]
rw [m_edge]
rw [show 1075 - (e + 1) = 1074 by omega]
apply (div_lt_div_iff_of_pos_right (by positivity)).2
norm_num
· by_cases boundary : e = 1074
· have not_high : ¬1075 ≤ e := by omega
have next_zero : ¬e + 1 = 0 := by omega
have next_high : 1075 ≤ e + 1 := by omega
simp only [if_neg zero, if_neg not_high, if_neg next_zero, if_pos next_high]
rw [show 1075 - e = 1 by omega, show e + 1 - 1075 = 0 by omega]
have cast_bound : (m : Real) < 4503599627370496 := by exact_mod_cast rem_bound
norm_num at ⊢
linarith
· by_cases high : 1075 ≤ e
· have next_zero : ¬e + 1 = 0 := by omega
have next_high : 1075 ≤ e + 1 := by omega
simp only [if_neg zero, if_pos high, if_neg next_zero, if_pos next_high]
rw [show e + 1 - 1075 = e - 1074 by omega]
have pos : (0 : Real) < (2 : Real)^(e-1075) := by positivity
have cast_bound : (m : Real) < 4503599627370496 := by exact_mod_cast rem_bound
have cast_sum : ((4503599627370496 + m : Nat) : Real) =
(4503599627370496 : Real) + m := by norm_num
rw [cast_sum]
have nextpow : (2 : Real)^(e-1074) = 2 * (2 : Real)^(e-1075) := by
rw [show e-1074 = (e-1075)+1 by omega, pow_succ]
ring
rw [nextpow]
have base : (4503599627370496 : Real) + m < 2 * 4503599627370496 := by linarith
calc
(4503599627370496 + (m : Real)) * (2 : Real)^(e-1075) <
(2 * 4503599627370496 : Real) * (2 : Real)^(e-1075) :=
mul_lt_mul_of_pos_right base pos
_ = 4503599627370496 * (2 * (2 : Real)^(e-1075)) := by ring
· have next_zero : ¬e + 1 = 0 := by omega
have next_high : ¬1075 ≤ e + 1 := by omega
simp only [if_neg zero, if_neg high, if_neg next_zero, if_neg next_high]
rw [show 1075 - (e + 1) = 1074 - e by omega]
have cast_bound : (m : Real) < 4503599627370496 := by exact_mod_cast rem_bound
have cast_sum : ((4503599627370496 + m : Nat) : Real) =
(4503599627370496 : Real) + m := by norm_num
rw [cast_sum]
have denrel : (2 : Real)^(1075-e) = 2 * (2 : Real)^(1074-e) := by
rw [show 1075-e = (1074-e)+1 by omega, pow_succ]
ring
have rhs : (4503599627370496 : Real) / (2 : Real)^(1074-e) =
(2 * 4503599627370496 : Real) / (2 : Real)^(1075-e) := by
rw [denrel]
apply (div_eq_div_iff (by positivity) (by positivity)).2
ring
have base : (4503599627370496 : Real) + m < 2 * 4503599627370496 := by linarith
exact ((div_lt_div_iff_of_pos_right (by positivity)).2 base).trans_eq rhs.symm
have chain : ∀ p k : Nat, 0 < k → p + k < top → value p < value (p + k) := by
intro p k hk hbound
induction k with
| zero => omega
| succ k ih =>
by_cases base : k = 0
· subst k
simpa using step p (by omega)
· have prior : value p < value (p + k) := ih (by omega) (by omega)
have next : value (p + k) < value (p + k + 1) := by apply step; omega
exact prior.trans next
have monotone : ∀ p q : Nat, p < q → q < top → value p < value q := by
intro p q hp hq
obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le (Nat.le_of_lt hp)
exact chain p k (by omega) hq
have word_eq : ∀ u v : F64, (↑u : Nat) = ↑v → u = v := by
intro u v h
cases u with
| mk ub =>
cases v with
| mk vb =>
congr
apply BitVec.eq_of_toNat_eq
change ub.toNat = vb.toNat at h
exact h
have make_word : ∀ n : Nat, n < top → ∃ c : F64, (↑c : Nat) = n := by
intro n hn
have bound : n ≤ UScalar.cMax UScalarTy.U64 := by
apply le_trans (Nat.le_of_lt hn)
norm_num [top, unit, UScalar.cMax, UScalar.rMax, U64.rMax, UScalarTy.numBits]
refine ⟨UScalar.ofNat n bound, ?_⟩
rfl
have closer : ∀ A Z B : Real, A < Z → Z < B →
abs (x - A) = abs (x - B) → abs (x - Z) < abs (x - A) := by
intro A Z B hAZ hZB hEq
have between : A < x ∧ x < B := by
constructor
· by_contra h
have hxA : x ≤ A := le_of_not_gt h
have hxB : x ≤ B := le_trans hxA (le_of_lt (hAZ.trans hZB))
rw [abs_of_nonpos (sub_nonpos.mpr hxA), abs_of_nonpos (sub_nonpos.mpr hxB)] at hEq
linarith
· by_contra h
have hBx : B ≤ x := le_of_not_gt h
have hAx : A ≤ x := le_trans (le_of_lt hAZ) (le_trans (le_of_lt hZB) hBx)
rw [abs_of_nonneg (sub_nonneg.mpr hAx), abs_of_nonneg (sub_nonneg.mpr hBx)] at hEq
linarith
rcases le_total Z x with hZx | hxZ
· rw [abs_of_nonneg (sub_nonneg.mpr hZx), abs_of_nonneg (sub_nonneg.mpr between.1.le)]
linarith
· have hAeqB : abs (x - A) = B - x := by
rw [abs_of_nonpos (sub_nonpos.mpr between.2.le)] at hEq
simpa [sub_eq_add_neg] using hEq
calc
abs (x - Z) = Z - x := by rw [abs_of_nonpos (sub_nonpos.mpr hxZ)]; ring
_ < B - x := by linarith
_ = abs (x - A) := hAeqB.symm
by_cases high : threshold ≤ x
· have bound : top ≤ UScalar.cMax UScalarTy.U64 := by
have top_value : top = 9218868437227405312 := by norm_num [top, unit]
rw [top_value]
norm_num [UScalar.cMax, UScalar.rMax, U64.rMax, UScalarTy.numBits]
let w : F64 := UScalar.ofNat top bound
refine ⟨w, ?_⟩
change 0 ≤ x ∧ (↑w : Nat) ≤ top ∧
(if (↑w : Nat) = top then threshold ≤ x else
x < threshold ∧ ∀ v : F64, (↑v : Nat) < top → v ≠ w →
abs (x - value (↑w : Nat)) ≤ abs (x - value (↑v : Nat)) ∧
(abs (x - value (↑w : Nat)) = abs (x - value (↑v : Nat)) →
(↑w : Nat) % 2 = 0))
have hw : (↑w : Nat) = top := by rfl
refine ⟨hx, ?_, ?_⟩
· omega
· rw [if_pos hw]
exact high
· have low : x < threshold := lt_of_not_ge high
let dist : Nat → Real := fun n => abs (x - value n)
let candidates : Set Nat := {n | n < top}
have candidates_finite : candidates.Finite := by
exact Set.toFinite candidates
have candidates_nonempty : candidates.Nonempty := by
refine ⟨0, ?_⟩
change 0 < top
norm_num [top, unit]
obtain ⟨r0, hr0, hmin⟩ := Set.exists_min_image candidates dist candidates_finite candidates_nonempty
have hmin_nat : ∀ n : Nat, n < top → dist r0 ≤ dist n := by
intro n hn
exact hmin n hn
let property : Nat → Prop := fun n => n < top ∧ dist n = dist r0
have property_exists : ∃ n, property n := ⟨r0, hr0, rfl⟩
let r := Nat.find property_exists
have rprop : property r := by exact Nat.find_spec property_exists
have hr_lt : r < top := rprop.1
have rbase : dist r = dist r0 := rprop.2
have least_index : ∀ n : Nat, n < top → dist n = dist r0 → r ≤ n := by
intro n hn heq
exact Nat.find_min' property_exists ⟨hn, heq⟩
set_option maxHeartbeats 800000 in
have adjacent : ∀ p q : Nat, p < top → q < top →
dist p = dist r → dist q = dist r → p < q → q = p + 1 := by
intro p q hp hq pmin qmin hpq
by_contra gap
have left_step : value p < value (p + 1) := monotone p (p + 1) (by omega) (by omega)
have right_step : value (p + 1) < value q := monotone (p + 1) q (by omega) hq
have middle : dist (p + 1) < dist p := by
exact closer (value p) (value (p + 1)) (value q) left_step right_step
(pmin.trans qmin.symm)
have min_p : dist p ≤ dist (p + 1) := by
calc dist p = dist r0 := pmin.trans rbase
_ ≤ dist (p + 1) := hmin_nat (p + 1) (by omega)
exact (not_lt_of_ge min_p) middle
have minimum_property : ∀ n : Nat, n < top → dist r ≤ dist n := by
intro n hn
calc dist r = dist r0 := rbase
_ ≤ dist n := hmin_nat n hn
have finish : ∀ chosen : Nat, chosen < top →
(∀ n : Nat, n < top → dist chosen ≤ dist n) →
((chosen % 2 = 0) ∨ (∀ n : Nat, n < top → dist chosen = dist n → n = chosen)) →
∃ target : F64,
0 ≤ x ∧ (↑target : Nat) ≤ top ∧
(if (↑target : Nat) = top then threshold ≤ x else
x < threshold ∧ ∀ v : F64, (↑v : Nat) < top → v ≠ target →
abs (x - value (↑target : Nat)) ≤ abs (x - value (↑v : Nat)) ∧
(abs (x - value (↑target : Nat)) = abs (x - value (↑v : Nat)) →
(↑target : Nat) % 2 = 0)) := by
intro chosen chosen_lt chosen_min choice_rule
obtain ⟨w, hw⟩ := make_word chosen chosen_lt
refine ⟨w, ?_⟩
change 0 ≤ x ∧ (↑w : Nat) ≤ top ∧
(if (↑w : Nat) = top then threshold ≤ x else
x < threshold ∧ ∀ v : F64, (↑v : Nat) < top → v ≠ w →
abs (x - value (↑w : Nat)) ≤ abs (x - value (↑v : Nat)) ∧
(abs (x - value (↑w : Nat)) = abs (x - value (↑v : Nat)) →
(↑w : Nat) % 2 = 0))
have wval : (↑w : Nat) = chosen := hw
have wnot : (↑w : Nat) ≠ top := by omega
refine ⟨hx, ?_, ?_⟩
· omega
· rw [if_neg wnot]
refine ⟨low, ?_⟩
intro v hv hne
have vn : (↑v : Nat) < top := hv
have bound_dist := chosen_min (↑v : Nat) vn
constructor
· simpa [dist, wval] using bound_dist
· intro equal_dist
rcases choice_rule with even | unique
· simpa [wval] using even
· have index_equal : (↑v : Nat) = chosen := by
apply unique (↑v : Nat) vn
simpa [dist, wval] using equal_dist
have value_equal : (↑v : Nat) = (↑w : Nat) := index_equal.trans wval.symm
have word_equal : v = w := word_eq v w value_equal
exact (hne word_equal).elim
by_cases even : r % 2 = 0
· exact finish r hr_lt minimum_property (Or.inl even)
· by_cases next : r + 1 < top ∧ dist r = dist (r + 1)
· have next_min : ∀ n : Nat, n < top → dist (r + 1) ≤ dist n := by
intro n hn
rw [← next.2]
exact minimum_property n hn
have next_even : (r + 1) % 2 = 0 := by omega
exact finish (r + 1) next.1 next_min (Or.inl next_even)
· have unique : ∀ n : Nat, n < top → dist r = dist n → n = r := by
intro n hn heq
by_cases nr : n = r
· exact nr
· have nbase : dist n = dist r0 := by exact heq.symm.trans rbase
have rle : r ≤ n := least_index n hn nbase
have order : r < n := by omega
have adjacent_right : n = r + 1 := by
set_option maxRecDepth 1000000 in
exact adjacent r n hr_lt hn (by rfl) heq.symm order
exfalso
apply next
have next_value : dist r = dist (r + 1) := by
calc dist r = dist n := heq
_ = dist (r + 1) := by rw [adjacent_right]
exact ⟨by omega, next_value⟩
exact finish r hr_lt minimum_property (Or.inr unique)
)
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.DecimalGoalVocabularyDefault
import Tablet.F64
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64
import Tablet.F64_Insts_CoreOpsArithDivF64F64
import Tablet.F64_Insts_CoreOpsArithMulF64F64
import Tablet.F64_Insts_CoreOpsArithNegF64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.num_imp_dec2flt_dec2flt
import Tablet.num_imp_dec2flt_dec2flt_with_trace
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_parse_parse_inf_nan
import Tablet.num_imp_dec2flt_decimal_Decimal_try_fast_path
import Tablet.num_imp_dec2flt_lemire_compute_float
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_dec2flt_biased_fp_to_float
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: RoundingTotality]
theorem RoundingTotality :
∀ x : Real, 0 <= x -> ∃ target : F64, DecimalGoalVocabularyDefault.roundsMagnitude x target := by
-- BODY
set_option maxHeartbeats 800000 in
exact (by
intro x hx
dsimp [DecimalGoalVocabularyDefault]
let unit : Nat := 2 ^ 52
let top : Nat := 9218868437227405312
let threshold : Real := (2 : Real) ^ 1024 - (2 : Real) ^ 970
let value : Nat → Real := fun n =>
let e := n / 4503599627370496
let m := n % 4503599627370496
if e = 0 then (m : Real) / (2 : Real) ^ 1074
else if 1075 ≤ e then
((4503599627370496 + m : Nat) : Real) * (2 : Real) ^ (e - 1075)
else ((4503599627370496 + m : Nat) : Real) / (2 : Real) ^ (1075 - e)
have step : ∀ n : Nat, n + 1 < top → value n < value (n + 1) := by
intro n hn
let e := n / unit
let m := n % unit
have unit_pos : 0 < unit := by norm_num [unit]
have rem_bound : m < unit := by exact Nat.mod_lt _ unit_pos
have decomp : unit * e + m = n := by exact Nat.div_add_mod n unit
have top_value : top = 9218868437227405312 := by norm_num [top, unit]
have n_bound : n + 1 < 9218868437227405312 := by simpa [top_value] using hn
norm_num [unit] at decomp rem_bound n_bound ⊢
by_cases small : m + 1 < 4503599627370496
· have next_decomp : 4503599627370496 * e + (m + 1) = n + 1 := by omega
have value_n : value n = if e = 0 then (m : Real) / (2 : Real)^1074 else
if 1075 ≤ e then ((4503599627370496 + m : Nat) : Real) * (2 : Real)^(e-1075)
else ((4503599627370496 + m : Nat) : Real) / (2 : Real)^(1075-e) := by
dsimp [value]
rw [← decomp]
have quotient : (4503599627370496 * e + m) / 4503599627370496 = e := by
rw [Nat.mul_add_div (by norm_num)]
simp [Nat.div_eq_of_lt rem_bound]
have remainder : (4503599627370496 * e + m) % 4503599627370496 = m := by
rw [Nat.mul_add_mod]
simp [Nat.mod_eq_of_lt rem_bound]
simp [quotient, remainder] <;> ring
have value_next : value (n+1) = if e = 0 then (m+1 : Real) / (2 : Real)^1074 else
if 1075 ≤ e then ((4503599627370496 + m + 1 : Nat) : Real) * (2 : Real)^(e-1075)
else ((4503599627370496 + m + 1 : Nat) : Real) / (2 : Real)^(1075-e) := by
dsimp [value]
rw [← next_decomp]
have quotient : (4503599627370496 * e + (m + 1)) / 4503599627370496 = e := by
rw [Nat.mul_add_div (by norm_num)]
simp [Nat.div_eq_of_lt (by omega)]
have remainder : (4503599627370496 * e + (m + 1)) % 4503599627370496 = m + 1 := by
rw [Nat.mul_add_mod]
simp [Nat.mod_eq_of_lt (by omega)]
simp only [quotient, remainder, Nat.cast_add]
by_cases z : e = 0
· simp [z] <;> ring
· by_cases h : 1075 ≤ e
· simp [z, h] <;> ring
· simp [z, h] <;> ring
rw [value_n, value_next]
by_cases zero : e = 0
· simp [zero]
apply (div_lt_div_iff_of_pos_right (by positivity)).2
norm_num
· by_cases high : 1075 ≤ e
· simp [zero, high]
· simp [zero, high]
apply (div_lt_div_iff_of_pos_right (by positivity)).2
norm_num
· have edge : m + 1 = 4503599627370496 := by omega
have next_decomp : 4503599627370496 * (e + 1) = n + 1 := by omega
have value_n : value n = if e = 0 then (m : Real) / (2 : Real)^1074 else
if 1075 ≤ e then ((4503599627370496 + m : Nat) : Real) * (2 : Real)^(e-1075)
else ((4503599627370496 + m : Nat) : Real) / (2 : Real)^(1075-e) := by
dsimp [value]
rw [← decomp]
have quotient : (4503599627370496 * e + m) / 4503599627370496 = e := by
rw [Nat.mul_add_div (by norm_num)]
simp [Nat.div_eq_of_lt rem_bound]
have remainder : (4503599627370496 * e + m) % 4503599627370496 = m := by
rw [Nat.mul_add_mod]
simp [Nat.mod_eq_of_lt rem_bound]
simp [quotient, remainder]
have value_next : value (n+1) = if e+1 = 0 then (0 : Real) / (2 : Real)^1074 else
if 1075 ≤ e+1 then ((4503599627370496 : Nat) : Real) * (2 : Real)^((e+1)-1075)
else ((4503599627370496 : Nat) : Real) / (2 : Real)^ (1075-(e+1)) := by
dsimp [value]
rw [← next_decomp]
have quotient : (4503599627370496 * (e + 1)) / 4503599627370496 = e + 1 := by
rw [show 4503599627370496 * (e + 1) = (e + 1) * 4503599627370496 by ring]
exact Nat.mul_div_left _ (by norm_num)
have remainder : (4503599627370496 * (e + 1)) % 4503599627370496 = 0 := by
exact Nat.mul_mod_right _ _
simp [quotient, remainder] <;> ring
rw [value_n, value_next]
by_cases zero : e = 0
· have m_edge : m = 4503599627370495 := by omega
have next_zero : ¬e + 1 = 0 := by omega
have next_high : ¬1075 ≤ e + 1 := by omega
simp only [if_pos zero, if_neg next_zero, if_neg next_high]
rw [m_edge]
rw [show 1075 - (e + 1) = 1074 by omega]
apply (div_lt_div_iff_of_pos_right (by positivity)).2
norm_num
· by_cases boundary : e = 1074
· have not_high : ¬1075 ≤ e := by omega
have next_zero : ¬e + 1 = 0 := by omega
have next_high : 1075 ≤ e + 1 := by omega
simp only [if_neg zero, if_neg not_high, if_neg next_zero, if_pos next_high]
rw [show 1075 - e = 1 by omega, show e + 1 - 1075 = 0 by omega]
have cast_bound : (m : Real) < 4503599627370496 := by exact_mod_cast rem_bound
norm_num at ⊢
linarith
· by_cases high : 1075 ≤ e
· have next_zero : ¬e + 1 = 0 := by omega
have next_high : 1075 ≤ e + 1 := by omega
simp only [if_neg zero, if_pos high, if_neg next_zero, if_pos next_high]
rw [show e + 1 - 1075 = e - 1074 by omega]
have pos : (0 : Real) < (2 : Real)^(e-1075) := by positivity
have cast_bound : (m : Real) < 4503599627370496 := by exact_mod_cast rem_bound
have cast_sum : ((4503599627370496 + m : Nat) : Real) =
(4503599627370496 : Real) + m := by norm_num
rw [cast_sum]
have nextpow : (2 : Real)^(e-1074) = 2 * (2 : Real)^(e-1075) := by
rw [show e-1074 = (e-1075)+1 by omega, pow_succ]
ring
rw [nextpow]
have base : (4503599627370496 : Real) + m < 2 * 4503599627370496 := by linarith
calc
(4503599627370496 + (m : Real)) * (2 : Real)^(e-1075) <
(2 * 4503599627370496 : Real) * (2 : Real)^(e-1075) :=
mul_lt_mul_of_pos_right base pos
_ = 4503599627370496 * (2 * (2 : Real)^(e-1075)) := by ring
· have next_zero : ¬e + 1 = 0 := by omega
have next_high : ¬1075 ≤ e + 1 := by omega
simp only [if_neg zero, if_neg high, if_neg next_zero, if_neg next_high]
rw [show 1075 - (e + 1) = 1074 - e by omega]
have cast_bound : (m : Real) < 4503599627370496 := by exact_mod_cast rem_bound
have cast_sum : ((4503599627370496 + m : Nat) : Real) =
(4503599627370496 : Real) + m := by norm_num
rw [cast_sum]
have denrel : (2 : Real)^(1075-e) = 2 * (2 : Real)^(1074-e) := by
rw [show 1075-e = (1074-e)+1 by omega, pow_succ]
ring
have rhs : (4503599627370496 : Real) / (2 : Real)^(1074-e) =
(2 * 4503599627370496 : Real) / (2 : Real)^(1075-e) := by
rw [denrel]
apply (div_eq_div_iff (by positivity) (by positivity)).2
ring
have base : (4503599627370496 : Real) + m < 2 * 4503599627370496 := by linarith
exact ((div_lt_div_iff_of_pos_right (by positivity)).2 base).trans_eq rhs.symm
have chain : ∀ p k : Nat, 0 < k → p + k < top → value p < value (p + k) := by
intro p k hk hbound
induction k with
| zero => omega
| succ k ih =>
by_cases base : k = 0
· subst k
simpa using step p (by omega)
· have prior : value p < value (p + k) := ih (by omega) (by omega)
have next : value (p + k) < value (p + k + 1) := by apply step; omega
exact prior.trans next
have monotone : ∀ p q : Nat, p < q → q < top → value p < value q := by
intro p q hp hq
obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le (Nat.le_of_lt hp)
exact chain p k (by omega) hq
have word_eq : ∀ u v : F64, (↑u : Nat) = ↑v → u = v := by
intro u v h
cases u with
| mk ub =>
cases v with
| mk vb =>
congr
apply BitVec.eq_of_toNat_eq
change ub.toNat = vb.toNat at h
exact h
have make_word : ∀ n : Nat, n < top → ∃ c : F64, (↑c : Nat) = n := by
intro n hn
have bound : n ≤ UScalar.cMax UScalarTy.U64 := by
apply le_trans (Nat.le_of_lt hn)
norm_num [top, unit, UScalar.cMax, UScalar.rMax, U64.rMax, UScalarTy.numBits]
refine ⟨UScalar.ofNat n bound, ?_⟩
rfl
have closer : ∀ A Z B : Real, A < Z → Z < B →
abs (x - A) = abs (x - B) → abs (x - Z) < abs (x - A) := by
intro A Z B hAZ hZB hEq
have between : A < x ∧ x < B := by
constructor
· by_contra h
have hxA : x ≤ A := le_of_not_gt h
have hxB : x ≤ B := le_trans hxA (le_of_lt (hAZ.trans hZB))
rw [abs_of_nonpos (sub_nonpos.mpr hxA), abs_of_nonpos (sub_nonpos.mpr hxB)] at hEq
linarith
· by_contra h
have hBx : B ≤ x := le_of_not_gt h
have hAx : A ≤ x := le_trans (le_of_lt hAZ) (le_trans (le_of_lt hZB) hBx)
rw [abs_of_nonneg (sub_nonneg.mpr hAx), abs_of_nonneg (sub_nonneg.mpr hBx)] at hEq
linarith
rcases le_total Z x with hZx | hxZ
· rw [abs_of_nonneg (sub_nonneg.mpr hZx), abs_of_nonneg (sub_nonneg.mpr between.1.le)]
linarith
· have hAeqB : abs (x - A) = B - x := by
rw [abs_of_nonpos (sub_nonpos.mpr between.2.le)] at hEq
simpa [sub_eq_add_neg] using hEq
calc
abs (x - Z) = Z - x := by rw [abs_of_nonpos (sub_nonpos.mpr hxZ)]; ring
_ < B - x := by linarith
_ = abs (x - A) := hAeqB.symm
by_cases high : threshold ≤ x
· have bound : top ≤ UScalar.cMax UScalarTy.U64 := by
have top_value : top = 9218868437227405312 := by norm_num [top, unit]
rw [top_value]
norm_num [UScalar.cMax, UScalar.rMax, U64.rMax, UScalarTy.numBits]
let w : F64 := UScalar.ofNat top bound
refine ⟨w, ?_⟩
change 0 ≤ x ∧ (↑w : Nat) ≤ top ∧
(if (↑w : Nat) = top then threshold ≤ x else
x < threshold ∧ ∀ v : F64, (↑v : Nat) < top → v ≠ w →
abs (x - value (↑w : Nat)) ≤ abs (x - value (↑v : Nat)) ∧
(abs (x - value (↑w : Nat)) = abs (x - value (↑v : Nat)) →
(↑w : Nat) % 2 = 0))
have hw : (↑w : Nat) = top := by rfl
refine ⟨hx, ?_, ?_⟩
· omega
· rw [if_pos hw]
exact high
· have low : x < threshold := lt_of_not_ge high
let dist : Nat → Real := fun n => abs (x - value n)
let candidates : Set Nat := {n | n < top}
have candidates_finite : candidates.Finite := by
exact Set.toFinite candidates
have candidates_nonempty : candidates.Nonempty := by
refine ⟨0, ?_⟩
change 0 < top
norm_num [top, unit]
obtain ⟨r0, hr0, hmin⟩ := Set.exists_min_image candidates dist candidates_finite candidates_nonempty
have hmin_nat : ∀ n : Nat, n < top → dist r0 ≤ dist n := by
intro n hn
exact hmin n hn
let property : Nat → Prop := fun n => n < top ∧ dist n = dist r0
have property_exists : ∃ n, property n := ⟨r0, hr0, rfl⟩
let r := Nat.find property_exists
have rprop : property r := by exact Nat.find_spec property_exists
have hr_lt : r < top := rprop.1
have rbase : dist r = dist r0 := rprop.2
have least_index : ∀ n : Nat, n < top → dist n = dist r0 → r ≤ n := by
intro n hn heq
exact Nat.find_min' property_exists ⟨hn, heq⟩
set_option maxHeartbeats 800000 in
have adjacent : ∀ p q : Nat, p < top → q < top →
dist p = dist r → dist q = dist r → p < q → q = p + 1 := by
intro p q hp hq pmin qmin hpq
by_contra gap
have left_step : value p < value (p + 1) := monotone p (p + 1) (by omega) (by omega)
have right_step : value (p + 1) < value q := monotone (p + 1) q (by omega) hq
have middle : dist (p + 1) < dist p := by
exact closer (value p) (value (p + 1)) (value q) left_step right_step
(pmin.trans qmin.symm)
have min_p : dist p ≤ dist (p + 1) := by
calc dist p = dist r0 := pmin.trans rbase
_ ≤ dist (p + 1) := hmin_nat (p + 1) (by omega)
exact (not_lt_of_ge min_p) middle
have minimum_property : ∀ n : Nat, n < top → dist r ≤ dist n := by
intro n hn
calc dist r = dist r0 := rbase
_ ≤ dist n := hmin_nat n hn
have finish : ∀ chosen : Nat, chosen < top →
(∀ n : Nat, n < top → dist chosen ≤ dist n) →
((chosen % 2 = 0) ∨ (∀ n : Nat, n < top → dist chosen = dist n → n = chosen)) →
∃ target : F64,
0 ≤ x ∧ (↑target : Nat) ≤ top ∧
(if (↑target : Nat) = top then threshold ≤ x else
x < threshold ∧ ∀ v : F64, (↑v : Nat) < top → v ≠ target →
abs (x - value (↑target : Nat)) ≤ abs (x - value (↑v : Nat)) ∧
(abs (x - value (↑target : Nat)) = abs (x - value (↑v : Nat)) →
(↑target : Nat) % 2 = 0)) := by
intro chosen chosen_lt chosen_min choice_rule
obtain ⟨w, hw⟩ := make_word chosen chosen_lt
refine ⟨w, ?_⟩
change 0 ≤ x ∧ (↑w : Nat) ≤ top ∧
(if (↑w : Nat) = top then threshold ≤ x else
x < threshold ∧ ∀ v : F64, (↑v : Nat) < top → v ≠ w →
abs (x - value (↑w : Nat)) ≤ abs (x - value (↑v : Nat)) ∧
(abs (x - value (↑w : Nat)) = abs (x - value (↑v : Nat)) →
(↑w : Nat) % 2 = 0))
have wval : (↑w : Nat) = chosen := hw
have wnot : (↑w : Nat) ≠ top := by omega
refine ⟨hx, ?_, ?_⟩
· omega
· rw [if_neg wnot]
refine ⟨low, ?_⟩
intro v hv hne
have vn : (↑v : Nat) < top := hv
have bound_dist := chosen_min (↑v : Nat) vn
constructor
· simpa [dist, wval] using bound_dist
· intro equal_dist
rcases choice_rule with even | unique
· simpa [wval] using even
· have index_equal : (↑v : Nat) = chosen := by
apply unique (↑v : Nat) vn
simpa [dist, wval] using equal_dist
have value_equal : (↑v : Nat) = (↑w : Nat) := index_equal.trans wval.symm
have word_equal : v = w := word_eq v w value_equal
exact (hne word_equal).elim
by_cases even : r % 2 = 0
· exact finish r hr_lt minimum_property (Or.inl even)
· by_cases next : r + 1 < top ∧ dist r = dist (r + 1)
· have next_min : ∀ n : Nat, n < top → dist (r + 1) ≤ dist n := by
intro n hn
rw [← next.2]
exact minimum_property n hn
have next_even : (r + 1) % 2 = 0 := by omega
exact finish (r + 1) next.1 next_min (Or.inl next_even)
· have unique : ∀ n : Nat, n < top → dist r = dist n → n = r := by
intro n hn heq
by_cases nr : n = r
· exact nr
· have nbase : dist n = dist r0 := by exact heq.symm.trans rbase
have rle : r ≤ n := least_index n hn nbase
have order : r < n := by omega
have adjacent_right : n = r + 1 := by
set_option maxRecDepth 1000000 in
exact adjacent r n hr_lt hn (by rfl) heq.symm order
exfalso
apply next
have next_value : dist r = dist (r + 1) := by
calc dist r = dist n := heq
_ = dist (r + 1) := by rw [adjacent_right]
exact ⟨by omega, next_value⟩
exact finish r hr_lt minimum_property (Or.inr unique)
)
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Uses
- DecimalGoalVocabularyDefault
- F64
- F64 Insts CoreOpsArithDivF64F64
- F64 Insts CoreOpsArithMulF64F64
- F64 Insts CoreOpsArithNegF64
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64
All 15 entries
- DecimalGoalVocabularyDefault
- F64
- F64 Insts CoreOpsArithDivF64F64
- F64 Insts CoreOpsArithMulF64F64
- F64 Insts CoreOpsArithNegF64
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64
- F64 Insts Dec2flt modelNumImpTraitsFloatExtU64
- num imp dec2flt biased fp to float
- num imp dec2flt dec2flt
- num imp dec2flt dec2flt with trace
- num imp dec2flt decimal Decimal try fast path
- num imp dec2flt lemire compute float
- num imp dec2flt parse parse inf nan
- num imp dec2flt parse parse number
- num imp dec2flt slow parse long mantissa
Used by
No other declaration in this version lists this one as a dependency.
Inspect related source (201)
- Dec2flt_modelNumImpDec2fltLemireU64 · dec2flt/mod.rs:217 Program Rust
- Dec2flt_modelNumImpTraitsFloatExtU64 · traits.rs:339 Program Rust
- biased_fp_to_float · dec2flt/mod.rs:282 Program Rust
More program dependencies (159)
- dec2flt · dec2flt/mod.rs:508 Program Rust
- dec2flt_with_trace · dec2flt/mod.rs:355 Program Rust
- try_fast_path · dec2flt/decimal.rs:59 Program Rust
- compute_float · dec2flt/lemire.rs:26 Program Rust
- parse_inf_nan · dec2flt/parse.rs:241 Program Rust
- parse_number · dec2flt/parse.rs:231 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
- MAX_EXPONENT_DISGUISED_FAST_PATH · dec2flt/mod.rs:220 Program Rust
- MAX_EXPONENT_FAST_PATH · dec2flt/mod.rs:219 Program Rust
- pow10_fast_path · dec2flt/mod.rs:222 Program Rust
- from_u64_bits · traits.rs:341 Program Rust
- integer_decode · traits.rs:348 Program Rust
- Dec2flt_modelNumImpTraitsFloatU64 · traits.rs:309 Program Rust
- read_u64 · dec2flt/common.rs:18 Program Rust
- ParseFloatError · num/mod.rs:13 Program Rust
- Dec2FltTrace · dec2flt/mod.rs:295 Program Rust
- Lemire · dec2flt/mod.rs:115 Program Rust
- default · dec2flt/mod.rs:128 Program Rust
- default · dec2flt/mod.rs:121 Program Rust
- BiasedFp · dec2flt/common.rs:52 Program Rust
- eq · dec2flt/common.rs:51 Program Rust
- zero_pow2 · dec2flt/common.rs:62 Program Rust
- Decimal · dec2flt/decimal.rs:32 Program Rust
- can_use_fast_path · dec2flt/decimal.rs:42 Program Rust
- INT_POW10 · dec2flt/decimal.rs:8 Program Rust
- DecimalSeq · dec2flt/decimal_seq.rs:21 Program Rust
- DECIMAL_POINT_RANGE · dec2flt/decimal_seq.rs:67 Program Rust
- left_shift · dec2flt/decimal_seq.rs:129 Program Rust
- left_shift_loop0 · dec2flt/decimal_seq.rs:138 Program Rust
- body · dec2flt/decimal_seq.rs:138 Program Rust
- left_shift_loop1 · dec2flt/decimal_seq.rs:152 Program Rust
- body · dec2flt/decimal_seq.rs:152 Program Rust
- right_shift · dec2flt/decimal_seq.rs:175 Program Rust
- right_shift_loop0 · dec2flt/decimal_seq.rs:180 Program Rust
- body · dec2flt/decimal_seq.rs:180 Program Rust
- right_shift_loop0_loop0 · dec2flt/decimal_seq.rs:190 Program Rust
- body · dec2flt/decimal_seq.rs:190 Program Rust
- right_shift_loop1 · dec2flt/decimal_seq.rs:209 Program Rust
- body · dec2flt/decimal_seq.rs:209 Program Rust
- right_shift_loop2 · dec2flt/decimal_seq.rs:216 Program Rust
- body · dec2flt/decimal_seq.rs:216 Program Rust
- round · dec2flt/decimal_seq.rs:96 Program Rust
- round_loop · dec2flt/decimal_seq.rs:106 Program Rust
- body · dec2flt/decimal_seq.rs:106 Program Rust
- parse_decimal_seq · dec2flt/decimal_seq.rs:283 Program Rust
- parse_decimal_seq_loop0 · dec2flt/decimal_seq.rs:290 Program Rust
- body · dec2flt/decimal_seq.rs:290 Program Rust
- parse_decimal_seq_loop1 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- parse_decimal_seq_loop2 · dec2flt/decimal_seq.rs:303 Program Rust
- body · dec2flt/decimal_seq.rs:303 Program Rust
- parse_decimal_seq_loop3 · dec2flt/decimal_seq.rs:307 Program Rust
- body · dec2flt/decimal_seq.rs:307 Program Rust
- parse_decimal_seq_loop4 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- parse_decimal_seq_loop5 · dec2flt/decimal_seq.rs:307 Program Rust
- body · dec2flt/decimal_seq.rs:307 Program Rust
- parse_decimal_seq_loop6 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- parse_decimal_seq_loop7 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- set_precision · dec2flt/fpu.rs:99 Program Rust
- compute_product_approx · dec2flt/lemire.rs:134 Program Rust
- power · dec2flt/lemire.rs:121 Program Rust
- parse_partial_number · dec2flt/parse.rs:161 Program Rust
- pfe_empty · dec2flt/mod.rs:270 Program Rust
- pfe_invalid · dec2flt/mod.rs:277 Program Rust
- MAX_SHIFT · dec2flt/slow.rs:28 Program Rust
- call · dec2flt/slow.rs:33 Program Rust
- Float · traits.rs:74 Program Rust
- FloatExt · traits.rs:170 Program Rust
- from_u64 · dec2flt/mod.rs:263 Program Rust
- BITS · traits.rs:319 Program Rust
- EXP_MASK · traits.rs:321 Program Rust
- INFINITY · traits.rs:312 Program Rust
- LARGEST_POWER_OF_TEN · traits.rs:327 Program Rust
- MAX_EXPONENT_ROUND_TO_EVEN · traits.rs:325 Program Rust
- MIN_EXPONENT_ROUND_TO_EVEN · traits.rs:324 Program Rust
- NAN · traits.rs:314 Program Rust
- NEG_INFINITY · traits.rs:313 Program Rust
- NEG_NAN · traits.rs:317 Program Rust
- SIG_MASK · traits.rs:322 Program Rust
- SIG_TOTAL_BITS · traits.rs:320 Program Rust
- SMALLEST_POWER_OF_TEN · traits.rs:328 Program Rust
- classify · traits.rs:334 Program Rust
- to_bits · traits.rs:330 Program Rust
- offset_from · dec2flt/common.rs:30 Program Rust
- write_u64 · dec2flt/common.rs:25 Program Rust
- Dec2flt_modelNumImpTraitsInt · traits.rs:51 Program Rust
- FloatErrorKind · num/mod.rs:18 Program Rust
- Dec2FltAssemblyTrace · dec2flt/mod.rs:329 Program Rust
- ByteSlice · dec2flt/common.rs:4 Program Rust
- is_8digits · dec2flt/common.rs:40 Program Rust
- default · dec2flt/decimal_seq.rs:33 Program Rust
- MAX_DIGITS · dec2flt/decimal_seq.rs:63 Program Rust
- MAX_DIGITS_WITHOUT_OVERFLOW · dec2flt/decimal_seq.rs:66 Program Rust
- trim · dec2flt/decimal_seq.rs:82 Program Rust
- trim_loop · dec2flt/decimal_seq.rs:91 Program Rust
- body · dec2flt/decimal_seq.rs:91 Program Rust
- count_trailing_zeros · dec2flt/decimal_seq.rs:235 Program Rust
- count_trailing_zeros_loop · dec2flt/decimal_seq.rs:239 Program Rust
- body · dec2flt/decimal_seq.rs:239 Program Rust
- number_of_digits_decimal_left_shift · dec2flt/decimal_seq.rs:368 Program Rust
- number_of_digits_decimal_left_shift_loop · dec2flt/decimal_seq.rs:434 Program Rust
- body · dec2flt/decimal_seq.rs:434 Program Rust
- parse_decimal_exponent · dec2flt/decimal_seq.rs:269 Program Rust
- parse_decimal_exponent_loop · dec2flt/decimal_seq.rs:272 Program Rust
- body · dec2flt/decimal_seq.rs:272 Program Rust
- parse_digits_into_seq · dec2flt/decimal_seq.rs:256 Program Rust
- parse_digits_into_seq_loop · dec2flt/decimal_seq.rs:258 Program Rust
- body · dec2flt/decimal_seq.rs:258 Program Rust
- full_multiplication · dec2flt/lemire.rs:126 Program Rust
- adjust_many_digit_count · dec2flt/parse.rs:86 Program Rust
- adjust_many_digit_count_loop · dec2flt/parse.rs:89 Program Rust
- body · dec2flt/parse.rs:89 Program Rust
- parse_many_digits · dec2flt/parse.rs:104 Program Rust
- parse_scientific · dec2flt/parse.rs:121 Program Rust
- parse_scientific_loop · dec2flt/parse.rs:142 Program Rust
- body · dec2flt/parse.rs:142 Program Rust
- try_parse_digits · dec2flt/parse.rs:30 Program Rust
- try_parse_digits_loop0 · dec2flt/parse.rs:33 Program Rust
- body · dec2flt/parse.rs:33 Program Rust
- try_parse_digits_loop1 · dec2flt/parse.rs:50 Program Rust
- body · dec2flt/parse.rs:50 Program Rust
- NUM_POWERS · dec2flt/slow.rs:29 Program Rust
- POWERS · dec2flt/slow.rs:30 Program Rust
- closure · dec2flt/slow.rs:33 Program Rust
- LARGEST_POWER_OF_FIVE · dec2flt/table.rs:10 Program Rust
- POWER_OF_FIVE_128 · dec2flt/table.rs:19 Program Rust
- SMALLEST_POWER_OF_FIVE · dec2flt/table.rs:9 Program Rust
- CastInto · traits.rs:18 Program Rust
- default · traits.rs:116 Program Rust
- default · traits.rs:104 Program Rust
- default · traits.rs:119 Program Rust
- default · traits.rs:110 Program Rust
- default · traits.rs:113 Program Rust
- default · traits.rs:101 Program Rust
- Int · traits.rs:27 Program Rust
- Dec2flt_modelNumImpTraitsCastIntoI16 · traits.rs:45 Program Rust
- ONE · traits.rs:53 Program Rust
- ZERO · traits.rs:52 Program Rust
- try_add_digit · dec2flt/decimal_seq.rs:73 Program Rust
- TABLE · dec2flt/decimal_seq.rs:370 Program Rust
- TABLE_POW5 · dec2flt/decimal_seq.rs:379 Program Rust
- MIN_19DIGIT_INT · dec2flt/parse.rs:8 Program Rust
- parse_8digits · dec2flt/parse.rs:18 Program Rust
- try_parse_19digits · dec2flt/parse.rs:61 Program Rust
- try_parse_19digits_loop · dec2flt/parse.rs:64 Program Rust
- body · dec2flt/parse.rs:64 Program Rust
- cast · traits.rs:46 Program Rust
- MASK · dec2flt/parse.rs:19 Program Rust
- MUL1 · dec2flt/parse.rs:20 Program Rust
- MUL2 · dec2flt/parse.rs:21 Program Rust
Standard-library dependencies (39)
- clone · core/src/clone.rs:698 Rust library
- div · core/src/ops/arith.rs:515 Rust library
- mul · core/src/ops/arith.rs:350 Rust library
- neg · core/src/ops/arith.rs:719 Rust library
- bitand · core/src/ops/bit.rs:178 Rust library
- bitor · core/src/ops/bit.rs:282 Rust library
- shl · core/src/ops/bit.rs:489 Rust library
- shr · core/src/ops/bit.rs:612 Rust library
- EXPONENT_MASK · core/src/num/f64.rs:615 Rust library
- INFINITY · core/src/num/f64.rs:512 Rust library
- MANTISSA_DIGITS · core/src/num/f64.rs:412 Rust library
- MANTISSA_MASK · core/src/num/f64.rs:637 Rust library
- NAN · core/src/num/f64.rs:509 Rust library
- NEG_INFINITY · core/src/num/f64.rs:515 Rust library
- classify · core/src/num/f64.rs:782 Rust library
- from_bits · core/src/num/f64.rs:1269 Rust library
- to_bits · core/src/num/f64.rs:1223 Rust library
- is_ascii_digit · core/src/num/mod.rs:958 Rust library
- from_residual · core/src/option.rs:2793 Rust library
- branch · core/src/option.rs:2779 Rust library
- first · core/src/slice/mod.rs:155 Rust library
- split_first · core/src/slice/mod.rs:198 Rust library
- as_bytes · core/src/str/mod.rs:498 Rust library
- CoreOpsArithDivF64F64 · core/src/ops/arith.rs:511 Rust library
- CoreOpsArithMulF64F64 · core/src/ops/arith.rs:344 Rust library
- CoreOpsArithNegF64 · core/src/ops/arith.rs:713 Rust library
- 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
- CoreMarkerCopy · core/src/marker.rs:57 Rust library
- FpCategory · core/src/num/mod.rs:1522 Rust library
- BitOr · core/src/ops/bit.rs:254 Rust library
- Shl · core/src/ops/bit.rs:461 Rust library
- Shr · core/src/ops/bit.rs:584 Rust library
- CoreCloneClone · core/src/clone.rs:696 Rust library
- CoreOpsBitBitAndU64U64 · core/src/ops/bit.rs:174 Rust library
- CoreOpsBitBitOrU64U64 · core/src/ops/bit.rs:278 Rust library
- CoreOpsBitShlU32U64 · core/src/ops/bit.rs:483 Rust library
- CoreOpsBitShrU32U64 · core/src/ops/bit.rs:606 Rust library
Related source and models come from the extraction records and declared dependencies.
Proof assumptions and review
Lean checks the formal proof. Trellis also reviews how the statement corresponds to the intended requirement.
Transitive assumptions
- Classical.choice
- Quot.sound
- propext
This list combines the assumptions recorded for this declaration and its dependencies. It may include assumptions used by auxiliary declarations in those modules.
Helper theorems included
Technical checking records
Local closure summary
{
"node": "RoundingTotality",
"closure_version": "patch_c_v1",
"active_decl_hash": "c0b8a9b9c9d3b25686c2965069962cd76919be2f1ff2e3ce6c90f493d4ed59ce",
"active_statement_hash": "e4cdd447c193134c272074d2ee12cc99a2a5627ffe149c2c6de90e8a0d2c15ac",
"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": "sidecar-sc-20260929-112508-efd8a3-RoundingTotality-cycle-60",
"boundary_theorems": {},
"strict_theorem_deps": {
"DecimalGoalVocabularyDefault": "2bbf2be48b5a4a4b"
},
"strict_definition_deps": {
"DecimalGoalVocabulary": "f76c8174a4d58eb5",
"DecimalGoalVocabularyDefault": "512f8d0aea894250",
"F64": "ec4e25fbaf4e11d4"
}
}Prose assessment
{
"label": "Recorded Sound: VerifierPass",
"assessment_status": "VerifierPass",
"fingerprint_relation": "matches current fingerprint",
"assessment_fingerprint": "sound-v2:ad34df17ccc907c528630cebb39efcaa66cfb09b95e85e87b1a0abddabdce54a",
"current_fingerprint": "sound-v2:ad34df17ccc907c528630cebb39efcaa66cfb09b95e85e87b1a0abddabdce54a",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"sound_status": "Pass",
"substantiveness_status": "Pass"
}