Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Theorem
Decimal record, any normal return of try_fast_path is either None, or Some of its sign applied to the binary64 rounding of the exact real value \mathit{mantissa}\,10^{\mathit{exponent}}; a Some return also has many_digits = false. This covers both ordinary and disguised native paths.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.Binary64ModelDefault
import Tablet.Binary64NativeCallDomain
import Tablet.Binary64ApplySign
import Tablet.Binary64ExactPositiveDivRounds
import Tablet.Binary64ExactPositiveMulRounds
import Tablet.Binary64FastPathGuard
import Tablet.Binary64FastPathIndexCasts
import Tablet.Binary64FromU64Exact
import Tablet.Binary64IntPow10Index
import Tablet.Binary64Pow10FastPathExact
import Tablet.Binary64ZeroDivRounds
import Tablet.Binary64ZeroMulRounds
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_FAST_PATH
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_DISGUISED_FAST_PATH
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_pow10_fast_path
import Tablet.F64_Insts_CoreOpsArithDivF64F64
import Tablet.F64_Insts_CoreOpsArithMulF64F64
import Tablet.F64_Insts_CoreOpsArithNegF64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS
import Tablet.ModelF64MantissaDigits
import Tablet.ModelF64FromBits
import Tablet.ModelF64FromU64
import Tablet.ModelF64Mul
import Tablet.ModelF64Div
import Tablet.ModelF64Neg
import Tablet.ModelOptionBranch
import Tablet.ModelOptionFromResidual
import Tablet.ModelU64Shl
import Tablet.num_imp_dec2flt_Lemire_MIN_EXPONENT_FAST_PATH_default
import Tablet.num_imp_dec2flt_Lemire_MAX_MANTISSA_FAST_PATH_default
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_can_use_fast_path
import Tablet.num_imp_dec2flt_decimal_Decimal_try_fast_path
import Tablet.num_imp_dec2flt_decimal_INT_POW10
import Tablet.num_imp_dec2flt_fpu_fpu_precision_set_precision
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
set_option maxRecDepth 1000000
set_option maxHeartbeats 1999999
namespace dec2flt_model
-- [TABLET NODE: NativeCorrectOrDefer]
theorem NativeCorrectOrDefer :
∀ (d : num.imp.dec2flt.decimal.Decimal) out,
num.imp.dec2flt.decimal.Decimal.try_fast_path
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 d = ok out ->
out = none ∨ ∃ (f magnitude : F64), out = some f ∧ d.many_digits = false ∧
DecimalGoalVocabularyDefault.roundsMagnitude (DecimalGoalVocabularyDefault.decimalMagnitude d) magnitude ∧
DecimalGoalVocabularyDefault.signedMagnitude d.negative magnitude f := 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
ok out. We first reduce all
constants and the outer guard, then follow the two executable arms of the
extracted body.Constants and the guard.
Unfolding the selectedLemire implementation
F64 Insts Dec2flt modelNumImpDec2fltLemireU64, its maximum ordinary
exponent is the literal 22 from
F64 Insts Dec2flt modelNumImpDec2fltLemireU64 MAX EXPONENT FAST PATH,
and its maximum disguised exponent is the literal 37 from
F64 Insts Dec2flt modelNumImpDec2fltLemireU64 MAX EXPONENT DISGUISED FAST PATH.
The minimum default num imp dec2flt Lemire MIN EXPONENT FAST PATH default
first obtains 22 and performs checked signed negation. Since 22 is not
-2^{63}, that operation succeeds and gives -22. For the mantissa bound,
the selected float-extension and float records
F64 Insts Dec2flt modelNumImpTraitsFloatExtU64 and
F64 Insts Dec2flt modelNumImpTraitsFloatU64 select
F64 Insts Dec2flt modelNumImpTraitsFloatU64 SIG TOTAL BITS; that
definition selects the modeled mantissa-digits operation, which is 53 by
ModelF64MantissaDigits. Thus the default
num imp dec2flt Lemire MAX MANTISSA FAST PATH default executes the
unsigned shift 1\ll53. The count 53<64, so the bounded-shift semantics
ModelU64Shl makes the operation succeed with exactly 2^{53},
without discarded high bits.can_use_fast_path using
num imp dec2flt decimal Decimal can use fast path. Its three
nested comparisons and final Boolean negation say exactly
try_fast_path from
num imp dec2flt decimal Decimal try fast path. Its initial precision
operation is unconditionally ok () by
num imp dec2flt fpu fpu precision set precision. If the guard is
false, the next branch is literally ok none; hence
out = none, proving the first disjunct. We may consequently assume
the guard is true and retain all four facts (1). At every later ordinary
monadic bind, a checked failure would propagate a fail result and
would contradict the assumed equality with ok out; below we identify
the stronger in-range reason for every operation that is reached. The sole
exception is the deliberately handled Option residual in the
disguised branch, which returns ok none rather than a failure.A rounding bridge used by both arms.
We record explicitly why the rounding operation below proves the relation in the theorem rather than merely producing some finite word. Unfold Binary64ModelDefault. Its nonnegative finite decoder is exactly the decoder in DecimalGoalVocabularyDefault: a word with exponent field zero and fraction a has value a2^{-1074}, while a word with exponent field E\in\{1,\ldots,2046\} and fraction a has value (2^{52}+a)2^{E-1075}. Its encoder first compares with the common overflow midpoint 2^{1024}-2^{970}. Below that midpoint, it either scales a subnormal input by 2^{1074} or chooses the unique normal field E withroundsMagnitude. The encoder returns positive infinity at and above
the shared midpoint. Consequently, for every nonnegative rational input,
the raw magnitude word returned by this encoder satisfies
DecimalGoalVocabularyDefault's
roundsMagnitude; below the midpoint it is finite and in particular
has raw word <2047\,2^{52}<2^{63}.from_bits operation on its displayed
constant. By ModelF64FromBits, that operation succeeds and returns
an F64 whose raw word is exactly the displayed constant; thus no
identity of raw words is being inferred from the weaker call-domain lemma.
Decoding those returned raw words with
Binary64ModelDefault's field formula then gives exactly 10^k:
equivalently, 10^k=5^k2^k, and for k\le22 the odd significand 5^k has at
most 52 bits, so the value is exactly representable; direct field division
and remainder of each listed word give that significand and scale. This
calculation strengthens the successful, positive, nonzero, finite, clear-sign
conclusion already stated by Binary64NativeCallDomain for every such
table call; that latter lemma supplies those domain properties, but not the
raw-word identity used in the decoding.The ordinary arm.
Suppose first e\le22. The extracted body callsfrom_u64 on m.
By (1), m\le2^{53}, so ModelF64FromU64 succeeds and returns the
exact positive-sign encoding of the integer m; this is also the first
clause of Binary64NativeCallDomain. The selected arithmetic
instances F64 Insts CoreOpsArithDivF64F64 and
F64 Insts CoreOpsArithMulF64F64 use respectively
ModelF64Div and ModelF64Mul. Their exact-rational and
IEEE zero branch semantics are those of Binary64ModelDefault; the
applicable division branch is determined below before any exact-rational
conclusion is drawn.usize succeeds and preserves k.
The power-table call therefore succeeds with exact value 10^k and returns a
positive-sign, finite, nonzero divisor. At this point split on the unsigned
mantissa m.roundsMagnitude at zero. Indeed,
0\le0, its raw word is below the infinity word, and zero is below the
positive overflow midpoint. Its decoded finite magnitude is zero. Every
finite competitor has nonnegative decoded magnitude, so its absolute distance
from zero is at least the selected word's distance 0; and whenever equality
holds, the required selected-word parity clause holds because
w.\mathit{val}\bmod2=0. These are exactly the zero-word minimizer and
even-tie clauses in DecimalGoalVocabularyDefault. Also
w.\mathit{val}<2^{63}, so the later sign branch leaves this positive zero
unchanged when d.\mathit{negative} is false and, by the cited modeled
negation, toggles bit 63 to negative zero when it is true; either result
satisfies the stated signedMagnitude relation.usize likewise
succeeds unchanged, the table gives exact 10^e, and modeled multiplication
encodes the exact product m10^e. These cases include e=0, where the table
entry is exactly one, and m=0, where the encoder argument and selected word
are both zero.decimalMagnitude d. The zero-numerator division already supplied
the same two conclusions directly, so (2) holds throughout the ordinary arm.The disguised arm.
It remains to treat the branch e>22. Combining this strict integer inequality with (1) gives 23\le e\le37. The checked signed subtraction s=e-22 cannot overflow and gives 1\le s\le15; its checked cast tousize is exact. Thus the index is within the length-16 extracted
table num imp dec2flt decimal INT POW10. Inspecting its displayed
entries at indices 0,\ldots,15 gives entry s exactly 10^s.U64.checked_mul returns
none. The exact option branch
ModelOptionBranch then returns Continue only for a present
product and returns Break none here; the residual conversion
ModelOptionFromResidual turns that residual into ok none.
Hence this case proves the theorem's first disjunct. If multiplication
succeeds, its present value n is exactly m10^s with no modular truncation.
The following comparison returns ok none when n>2^{53}, again
proving the first disjunct. We may therefore assume n\le2^{53}; (1) already
provides d.\mathit{many\_digits}=\mathsf{false}.usize; the power-table
call at index 22 succeeds with the exact positive nonzero finite value
10^{22} by the table calculation and
Binary64NativeCallDomain. The selected multiplication operation
ModelF64Mul therefore encodes the exact rational product
The sign and conclusion.
In either successful arm, before the final sign branch the body has produced the magnitude word w of (2). If d.\mathit{negative} is false, the body returnssome w. The definition of signedMagnitude in
DecimalGoalVocabularyDefault holds because w.\mathit{val}<2^{63}
and the required added sign contribution is zero. If it is true, the selected
negation instance F64 Insts CoreOpsArithNegF64 invokes
ModelF64Neg, which succeeds and toggles exactly bit 63. Since
w.\mathit{val}<2^{63}, that bit was clear, so toggling it gives the raw word
w.\mathit{val}+2^{63} while leaving all magnitude bits fixed. This is
precisely signedMagnitude true w f. No hypothesis from a parser or
from another theorem has been used.magnitude,
we have out = some f, the guard fact
d.\mathit{many\_digits}=\mathsf{false}, the rounding fact for
decimalMagnitude d, and the required signed-magnitude equation.
This proves the second disjunct in every Some case; all remaining
normal returns were shown to be None. The two disjuncts exhaust the
unrestricted record and every normal execution of the extracted body.Lean proof
intro d out hout
obtain ⟨guard, hguard, hguard_spec⟩ := Binary64FastPathGuard d
have hmax22 :
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.MAX_EXPONENT_FAST_PATH =
22#i64 := by
rw [F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.MAX_EXPONENT_FAST_PATH.eq_def]
have hmax22Field :
(F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64 :
num.imp.dec2flt.Lemire F64 Std.U64).MAX_EXPONENT_FAST_PATH =
ok 22#i64 := by
rw [F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.eq_def, hmax22]
have hmaxMantissaField :
(F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64 :
num.imp.dec2flt.Lemire F64 Std.U64).MAX_MANTISSA_FAST_PATH =
ok 9007199254740992#u64 := by
rw [F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.eq_def]
change (do
let i ← F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS
1#u64 <<< i) = ok 9007199254740992#u64
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def]
rfl
unfold num.imp.dec2flt.decimal.Decimal.try_fast_path at hout
rw [show num.imp.dec2flt.fpu.fpu_precision.set_precision F64 = ok () by rfl,
hguard] at hout
cases guard with
| false =>
left
have hnone : none = out := by simpa using hout
exact hnone.symm
| true =>
have hbounds := hguard_spec.mp rfl
obtain ⟨hmin, hmax, hmant, hmanyeq⟩ := hbounds
simp at hout
rw [hmax22] at hout
rw [show (22#i64).val = 22 by rfl] at hout
by_cases ordinary : d.exponent.val ≤ 22
· have ordinary' : d.exponent ≤ 22#i64 := by exact ordinary
rw [if_pos ordinary] at hout
obtain ⟨a, hfrom, haFinite, haDecode, haRound⟩ :=
Binary64FromU64Exact d.mantissa hmant
have haBound : a.val < 2 ^ 63 := by omega
have hfromField :
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
d.mantissa = ok a := by
exact hfrom
rw [hfromField] at hout
simp at hout
by_cases negativeExponent : d.exponent.val < 0
· rw [if_pos negativeExponent] at hout
obtain ⟨negated, i, hnegated, hcast, hnegatedVal, hiVal,
hiLower, hiUpper⟩ :=
Binary64FastPathIndexCasts.1 d.exponent hmin negativeExponent
rw [hnegated] at hout
simp at hout
rw [hcast] at hout
simp at hout
obtain ⟨p, hpow, hpBound, hpDecode⟩ :=
Binary64Pow10FastPathExact i hiUpper
rw [hpow] at hout
simp at hout
by_cases mantissaZero : d.mantissa.val = 0
· have haZero : a.val = 0 := by
have deq : d.mantissa = 0#u64 := UScalar.eq_of_val_eq mantissaZero
have hzero : ModelF64FromU64 0#u64 =
ok (⟨BitVec.ofNat 64 0⟩ : F64) := by
set_option exponentiation.threshold 2048 in
norm_num [ModelF64FromU64, Binary64ModelDefault, zpow_neg]
rw [deq, hzero] at hfrom
cases hfrom
rfl
have hpPositive : (0 : Rat) < (10 : Rat) ^ i.val := by positivity
obtain ⟨hdiv, hmagBound, hmagRound⟩ :=
Binary64ZeroDivRounds a p ((10 : Rat) ^ i.val)
haZero hpBound hpDecode hpPositive
have hdivField : F64.Insts.CoreOpsArithDivF64F64.div a p = ok a := by
change ModelF64Div a p = ok a
exact hdiv
rw [hdivField] at hout
simp at hout
obtain ⟨f, hsign, hsigned⟩ := Binary64ApplySign d.negative a hmagBound
have hsignField :
(if d.negative then
do let t ← F64.Insts.CoreOpsArithNegF64.neg a; ok (some t)
else ok (some a)) = ok (some f) := by
change (if d.negative then
do let t ← ModelF64Neg a; ok (some t)
else ok (some a)) = ok (some f)
exact hsign
rw [hsignField] at hout
have houtEq : out = some f := by cases hout; rfl
right
refine ⟨f, a, houtEq, hmanyeq, ?_, hsigned⟩
simpa [DecimalGoalVocabularyDefault, mantissaZero] using hmagRound
· have hmPositive : (0 : Rat) < (d.mantissa.val : Rat) := by
exact_mod_cast (Nat.zero_lt_of_ne_zero mantissaZero)
have hpPositive : (0 : Rat) < (10 : Rat) ^ i.val := by positivity
have hquotLower : (2 : Rat) ^ (-1022 : Int) ≤
(d.mantissa.val : Rat) / (10 : Rat) ^ i.val := by
apply (le_div_iff₀ hpPositive).2
have hpowLe : (10 : Rat) ^ i.val ≤ (10 : Rat) ^ (22 : Nat) :=
pow_le_pow_right₀ (by norm_num) hiUpper
have hbase : (2 : Rat) ^ (-1022 : Int) * (10 : Rat) ^ (22 : Nat) ≤ 1 := by
set_option exponentiation.threshold 2048 in
norm_num [zpow_neg]
calc
(2 : Rat) ^ (-1022 : Int) * (10 : Rat) ^ i.val ≤
(2 : Rat) ^ (-1022 : Int) * (10 : Rat) ^ (22 : Nat) :=
mul_le_mul_of_nonneg_left hpowLe (zpow_pos (by norm_num) _).le
_ ≤ 1 := hbase
_ ≤ (d.mantissa.val : Rat) := by exact_mod_cast
(Nat.one_le_iff_ne_zero.mpr mantissaZero)
have hquotUpper : (d.mantissa.val : Rat) / (10 : Rat) ^ i.val <
(2 : Rat) ^ (128 : Nat) := by
have hdenOne : (1 : Rat) ≤ (10 : Rat) ^ i.val := one_le_pow₀ (by norm_num)
calc
(d.mantissa.val : Rat) / (10 : Rat) ^ i.val ≤
(d.mantissa.val : Rat) := div_le_self hmPositive.le hdenOne
_ ≤ (2 : Rat) ^ (53 : Nat) := by exact_mod_cast hmant
_ < (2 : Rat) ^ (128 : Nat) := pow_lt_pow_right₀ (by norm_num) (by omega)
obtain ⟨magnitude, hdiv, hmagBound, hmagRound⟩ :=
Binary64ExactPositiveDivRounds a p (d.mantissa.val : Rat)
((10 : Rat) ^ i.val) haFinite hpBound haDecode hpDecode
hmPositive hpPositive hquotLower hquotUpper
have hdivField :
F64.Insts.CoreOpsArithDivF64F64.div a p = ok magnitude := by
change ModelF64Div a p = ok magnitude
exact hdiv
rw [hdivField] at hout
simp at hout
obtain ⟨f, hsign, hsigned⟩ :=
Binary64ApplySign d.negative magnitude hmagBound
have hsignField :
(if d.negative then
do let t ← F64.Insts.CoreOpsArithNegF64.neg magnitude; ok (some t)
else ok (some magnitude)) = ok (some f) := by
change (if d.negative then
do let t ← ModelF64Neg magnitude; ok (some t)
else ok (some magnitude)) = ok (some f)
exact hsign
rw [hsignField] at hout
have houtEq : out = some f := by cases hout; rfl
have hvalue : DecimalGoalVocabularyDefault.decimalMagnitude d =
(((d.mantissa.val : Rat) / (10 : Rat) ^ i.val : Rat) : Real) := by
dsimp [DecimalGoalVocabularyDefault]
have heq : d.exponent.val = -(i.val : Int) := by omega
rw [heq, zpow_neg, zpow_natCast]
push_cast
rw [div_eq_mul_inv]
right
refine ⟨f, magnitude, houtEq, hmanyeq, ?_, hsigned⟩
rw [hvalue]
exact hmagRound
· have nonnegativeExponent : 0 ≤ d.exponent.val := by omega
rw [if_neg negativeExponent] at hout
obtain ⟨i, hcast, hiVal, hiUpper⟩ :=
Binary64FastPathIndexCasts.2.1 d.exponent nonnegativeExponent ordinary
rw [hcast] at hout
simp at hout
obtain ⟨p, hpow, hpBound, hpDecode⟩ :=
Binary64Pow10FastPathExact i hiUpper
rw [hpow] at hout
simp at hout
by_cases mantissaZero : d.mantissa.val = 0
· have haZero : a.val = 0 := by
have deq : d.mantissa = 0#u64 := UScalar.eq_of_val_eq mantissaZero
have hzero : ModelF64FromU64 0#u64 =
ok (⟨BitVec.ofNat 64 0⟩ : F64) := by
set_option exponentiation.threshold 2048 in
norm_num [ModelF64FromU64, Binary64ModelDefault, zpow_neg]
rw [deq, hzero] at hfrom
cases hfrom
rfl
have hpPositive : (0 : Rat) < (10 : Rat) ^ i.val := by positivity
obtain ⟨hmul, hmagBound, hmagRound⟩ :=
Binary64ZeroMulRounds a p ((10 : Rat) ^ i.val)
haZero hpBound hpDecode hpPositive
have hmulField : F64.Insts.CoreOpsArithMulF64F64.mul a p = ok a := by
change ModelF64Mul a p = ok a
exact hmul
rw [hmulField] at hout
simp at hout
obtain ⟨f, hsign, hsigned⟩ := Binary64ApplySign d.negative a hmagBound
have hsignField :
(if d.negative then
do let t ← F64.Insts.CoreOpsArithNegF64.neg a; ok (some t)
else ok (some a)) = ok (some f) := by
change (if d.negative then
do let t ← ModelF64Neg a; ok (some t)
else ok (some a)) = ok (some f)
exact hsign
rw [hsignField] at hout
have houtEq : out = some f := by cases hout; rfl
right
refine ⟨f, a, houtEq, hmanyeq, ?_, hsigned⟩
simpa [DecimalGoalVocabularyDefault, mantissaZero] using hmagRound
· have hmPositive : (0 : Rat) < (d.mantissa.val : Rat) := by
exact_mod_cast (Nat.zero_lt_of_ne_zero mantissaZero)
have hpPositive : (0 : Rat) < (10 : Rat) ^ i.val := by positivity
have hprodLower : (2 : Rat) ^ (-1022 : Int) ≤
(d.mantissa.val : Rat) * (10 : Rat) ^ i.val := by
have hbase : (2 : Rat) ^ (-1022 : Int) ≤ 1 := by
rw [zpow_neg]
exact (inv_le_one₀ (pow_pos (by norm_num : (0 : Rat) < 2) _)).2
(one_le_pow₀ (by norm_num))
have hmOne : (1 : Rat) ≤ d.mantissa.val := by
exact_mod_cast (Nat.one_le_iff_ne_zero.mpr mantissaZero)
have hpOne : (1 : Rat) ≤ (10 : Rat) ^ i.val := one_le_pow₀ (by norm_num)
calc
(2 : Rat) ^ (-1022 : Int) ≤ 1 := hbase
_ = 1 * 1 := by ring
_ ≤ (d.mantissa.val : Rat) * (10 : Rat) ^ i.val :=
mul_le_mul hmOne hpOne (by norm_num) (by norm_num)
have hprodUpper : (d.mantissa.val : Rat) * (10 : Rat) ^ i.val <
(2 : Rat) ^ (128 : Nat) := by
have hmLe : (d.mantissa.val : Rat) ≤ (2 : Rat) ^ (53 : Nat) := by
exact_mod_cast hmant
have hpLe : (10 : Rat) ^ i.val ≤ (10 : Rat) ^ (22 : Nat) :=
pow_le_pow_right₀ (by norm_num) hiUpper
calc
(d.mantissa.val : Rat) * (10 : Rat) ^ i.val ≤
(2 : Rat) ^ (53 : Nat) * (10 : Rat) ^ (22 : Nat) :=
mul_le_mul hmLe hpLe (by positivity) (by positivity)
_ < (2 : Rat) ^ (128 : Nat) := by norm_num
obtain ⟨magnitude, hmul, hmagBound, hmagRound⟩ :=
Binary64ExactPositiveMulRounds a p (d.mantissa.val : Rat)
((10 : Rat) ^ i.val) haFinite hpBound haDecode hpDecode
hprodLower hprodUpper
have hmulField :
F64.Insts.CoreOpsArithMulF64F64.mul a p = ok magnitude := by
change ModelF64Mul a p = ok magnitude
exact hmul
rw [hmulField] at hout
simp at hout
obtain ⟨f, hsign, hsigned⟩ :=
Binary64ApplySign d.negative magnitude hmagBound
have hsignField :
(if d.negative then
do let t ← F64.Insts.CoreOpsArithNegF64.neg magnitude; ok (some t)
else ok (some magnitude)) = ok (some f) := by
change (if d.negative then
do let t ← ModelF64Neg magnitude; ok (some t)
else ok (some magnitude)) = ok (some f)
exact hsign
rw [hsignField] at hout
have houtEq : out = some f := by cases hout; rfl
have hvalue : DecimalGoalVocabularyDefault.decimalMagnitude d =
(((d.mantissa.val : Rat) * (10 : Rat) ^ i.val : Rat) : Real) := by
dsimp [DecimalGoalVocabularyDefault]
have heq : d.exponent.val = (i.val : Int) := by omega
rw [heq, zpow_natCast]
push_cast
rfl
right
refine ⟨f, magnitude, houtEq, hmanyeq, ?_, hsigned⟩
rw [hvalue]
exact hmagRound
· have ordinary' : ¬d.exponent ≤ 22#i64 := by exact ordinary
rw [if_neg ordinary] at hout
have exponentAbove22 : 22 < d.exponent.val := by omega
obtain ⟨shift, i, hsub, hcast, hshiftVal, hiVal, hiLower, hiUpper⟩ :=
Binary64FastPathIndexCasts.2.2 d.exponent exponentAbove22 hmax
rw [hsub] at hout
simp at hout
rw [hcast] at hout
simp at hout
obtain ⟨factor, hlookup, hfactorVal⟩ := Binary64IntPow10Index i hiUpper
rw [hlookup] at hout
simp at hout
cases hmul : d.mantissa.checked_mul factor with
| none =>
rw [hmul] at hout
have hlift : (lift (none : Option Std.U64) : Result (Option Std.U64)) =
ok none := by rfl
rw [hlift] at hout
simp [core.option.Option.Insts.CoreOpsTry_traitTry.branch,
core.option.Option.Insts.CoreOpsTry_traitFromResidualOptionInfallible.from_residual,
ModelOptionBranch, ModelOptionFromResidual] at hout
left
exact hout.symm
| some product =>
rw [hmul] at hout
have hlift : (lift (some product) : Result (Option Std.U64)) =
ok (some product) := by rfl
rw [hlift] at hout
simp [core.option.Option.Insts.CoreOpsTry_traitTry.branch,
ModelOptionBranch] at hout
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def] at hout
have hmantDigits : core.f64.F64.MANTISSA_DIGITS = ok 53#u32 := by rfl
rw [hmantDigits] at hout
simp at hout
have hshl : (1#u64 <<< 53#u32) = ok 9007199254740992#u64 := by rfl
rw [hshl] at hout
simp at hout
have hmulSpec := U64.checked_mul_bv_spec d.mantissa factor
rw [hmul] at hmulSpec
have hproductEq : product.val = d.mantissa.val * factor.val :=
hmulSpec.2.1
by_cases productLarge : 9007199254740992 < product.val
· rw [if_pos productLarge] at hout
left
cases hout
rfl
· rw [if_neg productLarge] at hout
have hproductSmall : product.val ≤ 2 ^ 53 := by norm_num at productLarge ⊢; omega
obtain ⟨a, hfrom, haFinite, haDecode, haRound⟩ :=
Binary64FromU64Exact product hproductSmall
have hfromField :
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
product = ok a := by
exact hfrom
rw [hfromField] at hout
simp at hout
obtain ⟨j, hcast22, hjVal, hjUpper⟩ :=
Binary64FastPathIndexCasts.2.1 22#i64 (by norm_num) (by norm_num)
rw [hcast22] at hout
simp at hout
obtain ⟨p, hpow, hpBound, hpDecode⟩ :=
Binary64Pow10FastPathExact j hjUpper
rw [hpow] at hout
simp at hout
have hjValNat : j.val = 22 := by
norm_num at hjVal
exact_mod_cast hjVal
by_cases productZero : product.val = 0
· have haZero : a.val = 0 := by
have peq : product = 0#u64 := UScalar.eq_of_val_eq productZero
have hzero : ModelF64FromU64 0#u64 =
ok (⟨BitVec.ofNat 64 0⟩ : F64) := by
set_option exponentiation.threshold 2048 in
norm_num [ModelF64FromU64, Binary64ModelDefault, zpow_neg]
rw [peq, hzero] at hfrom
cases hfrom
rfl
have hpPositive : (0 : Rat) < (10 : Rat) ^ j.val := by positivity
obtain ⟨hmulFloat, hmagBound, hmagRound⟩ :=
Binary64ZeroMulRounds a p ((10 : Rat) ^ j.val)
haZero hpBound hpDecode hpPositive
have hmulField :
F64.Insts.CoreOpsArithMulF64F64.mul a p = ok a := by
change ModelF64Mul a p = ok a
exact hmulFloat
rw [hmulField] at hout
simp at hout
obtain ⟨f, hsign, hsigned⟩ :=
Binary64ApplySign d.negative a hmagBound
have hsignField :
(if d.negative then
do let t ← F64.Insts.CoreOpsArithNegF64.neg a; ok (some t)
else ok (some a)) = ok (some f) := by
change (if d.negative then
do let t ← ModelF64Neg a; ok (some t)
else ok (some a)) = ok (some f)
exact hsign
rw [hsignField] at hout
have houtEq : out = some f := by cases hout; rfl
have hfactorPositive : 0 < factor.val := by
rw [hfactorVal]
positivity
have mantissaZero : d.mantissa.val = 0 := by
have hprodNat : d.mantissa.val * factor.val = 0 := by
rw [← hproductEq, productZero]
exact (Nat.mul_eq_zero.mp hprodNat).resolve_right
(Nat.ne_of_gt hfactorPositive)
right
refine ⟨f, a, houtEq, hmanyeq, ?_, hsigned⟩
simpa [DecimalGoalVocabularyDefault, mantissaZero] using hmagRound
· have hproductPositive : (0 : Rat) < (product.val : Rat) := by
exact_mod_cast (Nat.zero_lt_of_ne_zero productZero)
have hpPositive : (0 : Rat) < (10 : Rat) ^ j.val := by positivity
have hprodLower : (2 : Rat) ^ (-1022 : Int) ≤
(product.val : Rat) * (10 : Rat) ^ j.val := by
have hbase : (2 : Rat) ^ (-1022 : Int) ≤ 1 := by
rw [zpow_neg]
exact (inv_le_one₀ (pow_pos (by norm_num : (0 : Rat) < 2) _)).2
(one_le_pow₀ (by norm_num))
have hproductOne : (1 : Rat) ≤ product.val := by
exact_mod_cast (Nat.one_le_iff_ne_zero.mpr productZero)
have hpOne : (1 : Rat) ≤ (10 : Rat) ^ j.val :=
one_le_pow₀ (by norm_num)
calc
(2 : Rat) ^ (-1022 : Int) ≤ 1 := hbase
_ = 1 * 1 := by ring
_ ≤ (product.val : Rat) * (10 : Rat) ^ j.val :=
mul_le_mul hproductOne hpOne (by norm_num) (by norm_num)
have hprodUpper : (product.val : Rat) * (10 : Rat) ^ j.val <
(2 : Rat) ^ (128 : Nat) := by
have hproductLe : (product.val : Rat) ≤ (2 : Rat) ^ (53 : Nat) := by
exact_mod_cast hproductSmall
have hpLe : (10 : Rat) ^ j.val ≤ (10 : Rat) ^ (22 : Nat) :=
pow_le_pow_right₀ (by norm_num) hjUpper
calc
(product.val : Rat) * (10 : Rat) ^ j.val ≤
(2 : Rat) ^ (53 : Nat) * (10 : Rat) ^ (22 : Nat) :=
mul_le_mul hproductLe hpLe (by positivity) (by positivity)
_ < (2 : Rat) ^ (128 : Nat) := by norm_num
obtain ⟨magnitude, hmulFloat, hmagBound, hmagRound⟩ :=
Binary64ExactPositiveMulRounds a p (product.val : Rat)
((10 : Rat) ^ j.val) haFinite hpBound haDecode hpDecode
hprodLower hprodUpper
have hmulField :
F64.Insts.CoreOpsArithMulF64F64.mul a p = ok magnitude := by
change ModelF64Mul a p = ok magnitude
exact hmulFloat
rw [hmulField] at hout
simp at hout
obtain ⟨f, hsign, hsigned⟩ :=
Binary64ApplySign d.negative magnitude hmagBound
have hsignField :
(if d.negative then
do let t ← F64.Insts.CoreOpsArithNegF64.neg magnitude; ok (some t)
else ok (some magnitude)) = ok (some f) := by
change (if d.negative then
do let t ← ModelF64Neg magnitude; ok (some t)
else ok (some magnitude)) = ok (some f)
exact hsign
rw [hsignField] at hout
have houtEq : out = some f := by cases hout; rfl
have hproductReal : (product.val : Real) =
(d.mantissa.val : Real) * (10 : Real) ^ i.val := by
rw [hproductEq, hfactorVal]
push_cast
rfl
have hvalue : DecimalGoalVocabularyDefault.decimalMagnitude d =
(((product.val : Rat) * (10 : Rat) ^ j.val : Rat) : Real) := by
dsimp [DecimalGoalVocabularyDefault]
push_cast
have heq : d.exponent.val = (i.val : Int) + (j.val : Int) := by
omega
rw [heq, zpow_add₀ (by norm_num : (10 : Real) ≠ 0),
zpow_natCast, zpow_natCast, hproductReal]
ring
right
refine ⟨f, magnitude, houtEq, hmanyeq, ?_, hsigned⟩
rw [hvalue]
exact hmagRound
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.DecimalGoalVocabularyDefault
import Tablet.Binary64ModelDefault
import Tablet.Binary64NativeCallDomain
import Tablet.Binary64ApplySign
import Tablet.Binary64ExactPositiveDivRounds
import Tablet.Binary64ExactPositiveMulRounds
import Tablet.Binary64FastPathGuard
import Tablet.Binary64FastPathIndexCasts
import Tablet.Binary64FromU64Exact
import Tablet.Binary64IntPow10Index
import Tablet.Binary64Pow10FastPathExact
import Tablet.Binary64ZeroDivRounds
import Tablet.Binary64ZeroMulRounds
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_FAST_PATH
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_DISGUISED_FAST_PATH
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_pow10_fast_path
import Tablet.F64_Insts_CoreOpsArithDivF64F64
import Tablet.F64_Insts_CoreOpsArithMulF64F64
import Tablet.F64_Insts_CoreOpsArithNegF64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS
import Tablet.ModelF64MantissaDigits
import Tablet.ModelF64FromBits
import Tablet.ModelF64FromU64
import Tablet.ModelF64Mul
import Tablet.ModelF64Div
import Tablet.ModelF64Neg
import Tablet.ModelOptionBranch
import Tablet.ModelOptionFromResidual
import Tablet.ModelU64Shl
import Tablet.num_imp_dec2flt_Lemire_MIN_EXPONENT_FAST_PATH_default
import Tablet.num_imp_dec2flt_Lemire_MAX_MANTISSA_FAST_PATH_default
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_can_use_fast_path
import Tablet.num_imp_dec2flt_decimal_Decimal_try_fast_path
import Tablet.num_imp_dec2flt_decimal_INT_POW10
import Tablet.num_imp_dec2flt_fpu_fpu_precision_set_precision
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
set_option maxRecDepth 1000000
set_option maxHeartbeats 1999999
namespace dec2flt_model
-- [TABLET NODE: NativeCorrectOrDefer]
theorem NativeCorrectOrDefer :
∀ (d : num.imp.dec2flt.decimal.Decimal) out,
num.imp.dec2flt.decimal.Decimal.try_fast_path
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 d = ok out ->
out = none ∨ ∃ (f magnitude : F64), out = some f ∧ d.many_digits = false ∧
DecimalGoalVocabularyDefault.roundsMagnitude (DecimalGoalVocabularyDefault.decimalMagnitude d) magnitude ∧
DecimalGoalVocabularyDefault.signedMagnitude d.negative magnitude f := by
-- BODY
intro d out hout
obtain ⟨guard, hguard, hguard_spec⟩ := Binary64FastPathGuard d
have hmax22 :
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.MAX_EXPONENT_FAST_PATH =
22#i64 := by
rw [F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.MAX_EXPONENT_FAST_PATH.eq_def]
have hmax22Field :
(F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64 :
num.imp.dec2flt.Lemire F64 Std.U64).MAX_EXPONENT_FAST_PATH =
ok 22#i64 := by
rw [F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.eq_def, hmax22]
have hmaxMantissaField :
(F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64 :
num.imp.dec2flt.Lemire F64 Std.U64).MAX_MANTISSA_FAST_PATH =
ok 9007199254740992#u64 := by
rw [F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.eq_def]
change (do
let i ← F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS
1#u64 <<< i) = ok 9007199254740992#u64
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def]
rfl
unfold num.imp.dec2flt.decimal.Decimal.try_fast_path at hout
rw [show num.imp.dec2flt.fpu.fpu_precision.set_precision F64 = ok () by rfl,
hguard] at hout
cases guard with
| false =>
left
have hnone : none = out := by simpa using hout
exact hnone.symm
| true =>
have hbounds := hguard_spec.mp rfl
obtain ⟨hmin, hmax, hmant, hmanyeq⟩ := hbounds
simp at hout
rw [hmax22] at hout
rw [show (22#i64).val = 22 by rfl] at hout
by_cases ordinary : d.exponent.val ≤ 22
· have ordinary' : d.exponent ≤ 22#i64 := by exact ordinary
rw [if_pos ordinary] at hout
obtain ⟨a, hfrom, haFinite, haDecode, haRound⟩ :=
Binary64FromU64Exact d.mantissa hmant
have haBound : a.val < 2 ^ 63 := by omega
have hfromField :
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
d.mantissa = ok a := by
exact hfrom
rw [hfromField] at hout
simp at hout
by_cases negativeExponent : d.exponent.val < 0
· rw [if_pos negativeExponent] at hout
obtain ⟨negated, i, hnegated, hcast, hnegatedVal, hiVal,
hiLower, hiUpper⟩ :=
Binary64FastPathIndexCasts.1 d.exponent hmin negativeExponent
rw [hnegated] at hout
simp at hout
rw [hcast] at hout
simp at hout
obtain ⟨p, hpow, hpBound, hpDecode⟩ :=
Binary64Pow10FastPathExact i hiUpper
rw [hpow] at hout
simp at hout
by_cases mantissaZero : d.mantissa.val = 0
· have haZero : a.val = 0 := by
have deq : d.mantissa = 0#u64 := UScalar.eq_of_val_eq mantissaZero
have hzero : ModelF64FromU64 0#u64 =
ok (⟨BitVec.ofNat 64 0⟩ : F64) := by
set_option exponentiation.threshold 2048 in
norm_num [ModelF64FromU64, Binary64ModelDefault, zpow_neg]
rw [deq, hzero] at hfrom
cases hfrom
rfl
have hpPositive : (0 : Rat) < (10 : Rat) ^ i.val := by positivity
obtain ⟨hdiv, hmagBound, hmagRound⟩ :=
Binary64ZeroDivRounds a p ((10 : Rat) ^ i.val)
haZero hpBound hpDecode hpPositive
have hdivField : F64.Insts.CoreOpsArithDivF64F64.div a p = ok a := by
change ModelF64Div a p = ok a
exact hdiv
rw [hdivField] at hout
simp at hout
obtain ⟨f, hsign, hsigned⟩ := Binary64ApplySign d.negative a hmagBound
have hsignField :
(if d.negative then
do let t ← F64.Insts.CoreOpsArithNegF64.neg a; ok (some t)
else ok (some a)) = ok (some f) := by
change (if d.negative then
do let t ← ModelF64Neg a; ok (some t)
else ok (some a)) = ok (some f)
exact hsign
rw [hsignField] at hout
have houtEq : out = some f := by cases hout; rfl
right
refine ⟨f, a, houtEq, hmanyeq, ?_, hsigned⟩
simpa [DecimalGoalVocabularyDefault, mantissaZero] using hmagRound
· have hmPositive : (0 : Rat) < (d.mantissa.val : Rat) := by
exact_mod_cast (Nat.zero_lt_of_ne_zero mantissaZero)
have hpPositive : (0 : Rat) < (10 : Rat) ^ i.val := by positivity
have hquotLower : (2 : Rat) ^ (-1022 : Int) ≤
(d.mantissa.val : Rat) / (10 : Rat) ^ i.val := by
apply (le_div_iff₀ hpPositive).2
have hpowLe : (10 : Rat) ^ i.val ≤ (10 : Rat) ^ (22 : Nat) :=
pow_le_pow_right₀ (by norm_num) hiUpper
have hbase : (2 : Rat) ^ (-1022 : Int) * (10 : Rat) ^ (22 : Nat) ≤ 1 := by
set_option exponentiation.threshold 2048 in
norm_num [zpow_neg]
calc
(2 : Rat) ^ (-1022 : Int) * (10 : Rat) ^ i.val ≤
(2 : Rat) ^ (-1022 : Int) * (10 : Rat) ^ (22 : Nat) :=
mul_le_mul_of_nonneg_left hpowLe (zpow_pos (by norm_num) _).le
_ ≤ 1 := hbase
_ ≤ (d.mantissa.val : Rat) := by exact_mod_cast
(Nat.one_le_iff_ne_zero.mpr mantissaZero)
have hquotUpper : (d.mantissa.val : Rat) / (10 : Rat) ^ i.val <
(2 : Rat) ^ (128 : Nat) := by
have hdenOne : (1 : Rat) ≤ (10 : Rat) ^ i.val := one_le_pow₀ (by norm_num)
calc
(d.mantissa.val : Rat) / (10 : Rat) ^ i.val ≤
(d.mantissa.val : Rat) := div_le_self hmPositive.le hdenOne
_ ≤ (2 : Rat) ^ (53 : Nat) := by exact_mod_cast hmant
_ < (2 : Rat) ^ (128 : Nat) := pow_lt_pow_right₀ (by norm_num) (by omega)
obtain ⟨magnitude, hdiv, hmagBound, hmagRound⟩ :=
Binary64ExactPositiveDivRounds a p (d.mantissa.val : Rat)
((10 : Rat) ^ i.val) haFinite hpBound haDecode hpDecode
hmPositive hpPositive hquotLower hquotUpper
have hdivField :
F64.Insts.CoreOpsArithDivF64F64.div a p = ok magnitude := by
change ModelF64Div a p = ok magnitude
exact hdiv
rw [hdivField] at hout
simp at hout
obtain ⟨f, hsign, hsigned⟩ :=
Binary64ApplySign d.negative magnitude hmagBound
have hsignField :
(if d.negative then
do let t ← F64.Insts.CoreOpsArithNegF64.neg magnitude; ok (some t)
else ok (some magnitude)) = ok (some f) := by
change (if d.negative then
do let t ← ModelF64Neg magnitude; ok (some t)
else ok (some magnitude)) = ok (some f)
exact hsign
rw [hsignField] at hout
have houtEq : out = some f := by cases hout; rfl
have hvalue : DecimalGoalVocabularyDefault.decimalMagnitude d =
(((d.mantissa.val : Rat) / (10 : Rat) ^ i.val : Rat) : Real) := by
dsimp [DecimalGoalVocabularyDefault]
have heq : d.exponent.val = -(i.val : Int) := by omega
rw [heq, zpow_neg, zpow_natCast]
push_cast
rw [div_eq_mul_inv]
right
refine ⟨f, magnitude, houtEq, hmanyeq, ?_, hsigned⟩
rw [hvalue]
exact hmagRound
· have nonnegativeExponent : 0 ≤ d.exponent.val := by omega
rw [if_neg negativeExponent] at hout
obtain ⟨i, hcast, hiVal, hiUpper⟩ :=
Binary64FastPathIndexCasts.2.1 d.exponent nonnegativeExponent ordinary
rw [hcast] at hout
simp at hout
obtain ⟨p, hpow, hpBound, hpDecode⟩ :=
Binary64Pow10FastPathExact i hiUpper
rw [hpow] at hout
simp at hout
by_cases mantissaZero : d.mantissa.val = 0
· have haZero : a.val = 0 := by
have deq : d.mantissa = 0#u64 := UScalar.eq_of_val_eq mantissaZero
have hzero : ModelF64FromU64 0#u64 =
ok (⟨BitVec.ofNat 64 0⟩ : F64) := by
set_option exponentiation.threshold 2048 in
norm_num [ModelF64FromU64, Binary64ModelDefault, zpow_neg]
rw [deq, hzero] at hfrom
cases hfrom
rfl
have hpPositive : (0 : Rat) < (10 : Rat) ^ i.val := by positivity
obtain ⟨hmul, hmagBound, hmagRound⟩ :=
Binary64ZeroMulRounds a p ((10 : Rat) ^ i.val)
haZero hpBound hpDecode hpPositive
have hmulField : F64.Insts.CoreOpsArithMulF64F64.mul a p = ok a := by
change ModelF64Mul a p = ok a
exact hmul
rw [hmulField] at hout
simp at hout
obtain ⟨f, hsign, hsigned⟩ := Binary64ApplySign d.negative a hmagBound
have hsignField :
(if d.negative then
do let t ← F64.Insts.CoreOpsArithNegF64.neg a; ok (some t)
else ok (some a)) = ok (some f) := by
change (if d.negative then
do let t ← ModelF64Neg a; ok (some t)
else ok (some a)) = ok (some f)
exact hsign
rw [hsignField] at hout
have houtEq : out = some f := by cases hout; rfl
right
refine ⟨f, a, houtEq, hmanyeq, ?_, hsigned⟩
simpa [DecimalGoalVocabularyDefault, mantissaZero] using hmagRound
· have hmPositive : (0 : Rat) < (d.mantissa.val : Rat) := by
exact_mod_cast (Nat.zero_lt_of_ne_zero mantissaZero)
have hpPositive : (0 : Rat) < (10 : Rat) ^ i.val := by positivity
have hprodLower : (2 : Rat) ^ (-1022 : Int) ≤
(d.mantissa.val : Rat) * (10 : Rat) ^ i.val := by
have hbase : (2 : Rat) ^ (-1022 : Int) ≤ 1 := by
rw [zpow_neg]
exact (inv_le_one₀ (pow_pos (by norm_num : (0 : Rat) < 2) _)).2
(one_le_pow₀ (by norm_num))
have hmOne : (1 : Rat) ≤ d.mantissa.val := by
exact_mod_cast (Nat.one_le_iff_ne_zero.mpr mantissaZero)
have hpOne : (1 : Rat) ≤ (10 : Rat) ^ i.val := one_le_pow₀ (by norm_num)
calc
(2 : Rat) ^ (-1022 : Int) ≤ 1 := hbase
_ = 1 * 1 := by ring
_ ≤ (d.mantissa.val : Rat) * (10 : Rat) ^ i.val :=
mul_le_mul hmOne hpOne (by norm_num) (by norm_num)
have hprodUpper : (d.mantissa.val : Rat) * (10 : Rat) ^ i.val <
(2 : Rat) ^ (128 : Nat) := by
have hmLe : (d.mantissa.val : Rat) ≤ (2 : Rat) ^ (53 : Nat) := by
exact_mod_cast hmant
have hpLe : (10 : Rat) ^ i.val ≤ (10 : Rat) ^ (22 : Nat) :=
pow_le_pow_right₀ (by norm_num) hiUpper
calc
(d.mantissa.val : Rat) * (10 : Rat) ^ i.val ≤
(2 : Rat) ^ (53 : Nat) * (10 : Rat) ^ (22 : Nat) :=
mul_le_mul hmLe hpLe (by positivity) (by positivity)
_ < (2 : Rat) ^ (128 : Nat) := by norm_num
obtain ⟨magnitude, hmul, hmagBound, hmagRound⟩ :=
Binary64ExactPositiveMulRounds a p (d.mantissa.val : Rat)
((10 : Rat) ^ i.val) haFinite hpBound haDecode hpDecode
hprodLower hprodUpper
have hmulField :
F64.Insts.CoreOpsArithMulF64F64.mul a p = ok magnitude := by
change ModelF64Mul a p = ok magnitude
exact hmul
rw [hmulField] at hout
simp at hout
obtain ⟨f, hsign, hsigned⟩ :=
Binary64ApplySign d.negative magnitude hmagBound
have hsignField :
(if d.negative then
do let t ← F64.Insts.CoreOpsArithNegF64.neg magnitude; ok (some t)
else ok (some magnitude)) = ok (some f) := by
change (if d.negative then
do let t ← ModelF64Neg magnitude; ok (some t)
else ok (some magnitude)) = ok (some f)
exact hsign
rw [hsignField] at hout
have houtEq : out = some f := by cases hout; rfl
have hvalue : DecimalGoalVocabularyDefault.decimalMagnitude d =
(((d.mantissa.val : Rat) * (10 : Rat) ^ i.val : Rat) : Real) := by
dsimp [DecimalGoalVocabularyDefault]
have heq : d.exponent.val = (i.val : Int) := by omega
rw [heq, zpow_natCast]
push_cast
rfl
right
refine ⟨f, magnitude, houtEq, hmanyeq, ?_, hsigned⟩
rw [hvalue]
exact hmagRound
· have ordinary' : ¬d.exponent ≤ 22#i64 := by exact ordinary
rw [if_neg ordinary] at hout
have exponentAbove22 : 22 < d.exponent.val := by omega
obtain ⟨shift, i, hsub, hcast, hshiftVal, hiVal, hiLower, hiUpper⟩ :=
Binary64FastPathIndexCasts.2.2 d.exponent exponentAbove22 hmax
rw [hsub] at hout
simp at hout
rw [hcast] at hout
simp at hout
obtain ⟨factor, hlookup, hfactorVal⟩ := Binary64IntPow10Index i hiUpper
rw [hlookup] at hout
simp at hout
cases hmul : d.mantissa.checked_mul factor with
| none =>
rw [hmul] at hout
have hlift : (lift (none : Option Std.U64) : Result (Option Std.U64)) =
ok none := by rfl
rw [hlift] at hout
simp [core.option.Option.Insts.CoreOpsTry_traitTry.branch,
core.option.Option.Insts.CoreOpsTry_traitFromResidualOptionInfallible.from_residual,
ModelOptionBranch, ModelOptionFromResidual] at hout
left
exact hout.symm
| some product =>
rw [hmul] at hout
have hlift : (lift (some product) : Result (Option Std.U64)) =
ok (some product) := by rfl
rw [hlift] at hout
simp [core.option.Option.Insts.CoreOpsTry_traitTry.branch,
ModelOptionBranch] at hout
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def] at hout
have hmantDigits : core.f64.F64.MANTISSA_DIGITS = ok 53#u32 := by rfl
rw [hmantDigits] at hout
simp at hout
have hshl : (1#u64 <<< 53#u32) = ok 9007199254740992#u64 := by rfl
rw [hshl] at hout
simp at hout
have hmulSpec := U64.checked_mul_bv_spec d.mantissa factor
rw [hmul] at hmulSpec
have hproductEq : product.val = d.mantissa.val * factor.val :=
hmulSpec.2.1
by_cases productLarge : 9007199254740992 < product.val
· rw [if_pos productLarge] at hout
left
cases hout
rfl
· rw [if_neg productLarge] at hout
have hproductSmall : product.val ≤ 2 ^ 53 := by norm_num at productLarge ⊢; omega
obtain ⟨a, hfrom, haFinite, haDecode, haRound⟩ :=
Binary64FromU64Exact product hproductSmall
have hfromField :
F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64.from_u64
product = ok a := by
exact hfrom
rw [hfromField] at hout
simp at hout
obtain ⟨j, hcast22, hjVal, hjUpper⟩ :=
Binary64FastPathIndexCasts.2.1 22#i64 (by norm_num) (by norm_num)
rw [hcast22] at hout
simp at hout
obtain ⟨p, hpow, hpBound, hpDecode⟩ :=
Binary64Pow10FastPathExact j hjUpper
rw [hpow] at hout
simp at hout
have hjValNat : j.val = 22 := by
norm_num at hjVal
exact_mod_cast hjVal
by_cases productZero : product.val = 0
· have haZero : a.val = 0 := by
have peq : product = 0#u64 := UScalar.eq_of_val_eq productZero
have hzero : ModelF64FromU64 0#u64 =
ok (⟨BitVec.ofNat 64 0⟩ : F64) := by
set_option exponentiation.threshold 2048 in
norm_num [ModelF64FromU64, Binary64ModelDefault, zpow_neg]
rw [peq, hzero] at hfrom
cases hfrom
rfl
have hpPositive : (0 : Rat) < (10 : Rat) ^ j.val := by positivity
obtain ⟨hmulFloat, hmagBound, hmagRound⟩ :=
Binary64ZeroMulRounds a p ((10 : Rat) ^ j.val)
haZero hpBound hpDecode hpPositive
have hmulField :
F64.Insts.CoreOpsArithMulF64F64.mul a p = ok a := by
change ModelF64Mul a p = ok a
exact hmulFloat
rw [hmulField] at hout
simp at hout
obtain ⟨f, hsign, hsigned⟩ :=
Binary64ApplySign d.negative a hmagBound
have hsignField :
(if d.negative then
do let t ← F64.Insts.CoreOpsArithNegF64.neg a; ok (some t)
else ok (some a)) = ok (some f) := by
change (if d.negative then
do let t ← ModelF64Neg a; ok (some t)
else ok (some a)) = ok (some f)
exact hsign
rw [hsignField] at hout
have houtEq : out = some f := by cases hout; rfl
have hfactorPositive : 0 < factor.val := by
rw [hfactorVal]
positivity
have mantissaZero : d.mantissa.val = 0 := by
have hprodNat : d.mantissa.val * factor.val = 0 := by
rw [← hproductEq, productZero]
exact (Nat.mul_eq_zero.mp hprodNat).resolve_right
(Nat.ne_of_gt hfactorPositive)
right
refine ⟨f, a, houtEq, hmanyeq, ?_, hsigned⟩
simpa [DecimalGoalVocabularyDefault, mantissaZero] using hmagRound
· have hproductPositive : (0 : Rat) < (product.val : Rat) := by
exact_mod_cast (Nat.zero_lt_of_ne_zero productZero)
have hpPositive : (0 : Rat) < (10 : Rat) ^ j.val := by positivity
have hprodLower : (2 : Rat) ^ (-1022 : Int) ≤
(product.val : Rat) * (10 : Rat) ^ j.val := by
have hbase : (2 : Rat) ^ (-1022 : Int) ≤ 1 := by
rw [zpow_neg]
exact (inv_le_one₀ (pow_pos (by norm_num : (0 : Rat) < 2) _)).2
(one_le_pow₀ (by norm_num))
have hproductOne : (1 : Rat) ≤ product.val := by
exact_mod_cast (Nat.one_le_iff_ne_zero.mpr productZero)
have hpOne : (1 : Rat) ≤ (10 : Rat) ^ j.val :=
one_le_pow₀ (by norm_num)
calc
(2 : Rat) ^ (-1022 : Int) ≤ 1 := hbase
_ = 1 * 1 := by ring
_ ≤ (product.val : Rat) * (10 : Rat) ^ j.val :=
mul_le_mul hproductOne hpOne (by norm_num) (by norm_num)
have hprodUpper : (product.val : Rat) * (10 : Rat) ^ j.val <
(2 : Rat) ^ (128 : Nat) := by
have hproductLe : (product.val : Rat) ≤ (2 : Rat) ^ (53 : Nat) := by
exact_mod_cast hproductSmall
have hpLe : (10 : Rat) ^ j.val ≤ (10 : Rat) ^ (22 : Nat) :=
pow_le_pow_right₀ (by norm_num) hjUpper
calc
(product.val : Rat) * (10 : Rat) ^ j.val ≤
(2 : Rat) ^ (53 : Nat) * (10 : Rat) ^ (22 : Nat) :=
mul_le_mul hproductLe hpLe (by positivity) (by positivity)
_ < (2 : Rat) ^ (128 : Nat) := by norm_num
obtain ⟨magnitude, hmulFloat, hmagBound, hmagRound⟩ :=
Binary64ExactPositiveMulRounds a p (product.val : Rat)
((10 : Rat) ^ j.val) haFinite hpBound haDecode hpDecode
hprodLower hprodUpper
have hmulField :
F64.Insts.CoreOpsArithMulF64F64.mul a p = ok magnitude := by
change ModelF64Mul a p = ok magnitude
exact hmulFloat
rw [hmulField] at hout
simp at hout
obtain ⟨f, hsign, hsigned⟩ :=
Binary64ApplySign d.negative magnitude hmagBound
have hsignField :
(if d.negative then
do let t ← F64.Insts.CoreOpsArithNegF64.neg magnitude; ok (some t)
else ok (some magnitude)) = ok (some f) := by
change (if d.negative then
do let t ← ModelF64Neg magnitude; ok (some t)
else ok (some magnitude)) = ok (some f)
exact hsign
rw [hsignField] at hout
have houtEq : out = some f := by cases hout; rfl
have hproductReal : (product.val : Real) =
(d.mantissa.val : Real) * (10 : Real) ^ i.val := by
rw [hproductEq, hfactorVal]
push_cast
rfl
have hvalue : DecimalGoalVocabularyDefault.decimalMagnitude d =
(((product.val : Rat) * (10 : Rat) ^ j.val : Rat) : Real) := by
dsimp [DecimalGoalVocabularyDefault]
push_cast
have heq : d.exponent.val = (i.val : Int) + (j.val : Int) := by
omega
rw [heq, zpow_add₀ (by norm_num : (10 : Real) ≠ 0),
zpow_natCast, zpow_natCast, hproductReal]
ring
right
refine ⟨f, magnitude, houtEq, hmanyeq, ?_, hsigned⟩
rw [hvalue]
exact hmagRound
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Uses
- Binary64ApplySign
- Binary64ExactPositiveDivRounds
- Binary64ExactPositiveMulRounds
- Binary64FastPathGuard
- Binary64FastPathIndexCasts
- Binary64FromU64Exact
All 45 entries
- Binary64ApplySign
- Binary64ExactPositiveDivRounds
- Binary64ExactPositiveMulRounds
- Binary64FastPathGuard
- Binary64FastPathIndexCasts
- Binary64FromU64Exact
- Binary64IntPow10Index
- Binary64ModelDefault
- Binary64NativeCallDomain
- Binary64Pow10FastPathExact
- Binary64ZeroDivRounds
- Binary64ZeroMulRounds
- DecimalGoalVocabularyDefault
- F64 Insts CoreOpsArithDivF64F64
- F64 Insts CoreOpsArithMulF64F64
- F64 Insts CoreOpsArithNegF64
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64 MAX EXPONENT DISGUISED FAST PATH
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64 MAX EXPONENT FAST PATH
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64 pow10 fast path
- F64 Insts Dec2flt modelNumImpTraitsFloatExtU64
- F64 Insts Dec2flt modelNumImpTraitsFloatU64
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 SIG TOTAL BITS
- ModelF64Div
- ModelF64FromBits
- ModelF64FromU64
- ModelF64MantissaDigits
- ModelF64Mul
- ModelF64Neg
- ModelOptionBranch
- ModelOptionFromResidual
- ModelU64Shl
- num imp dec2flt Lemire MAX MANTISSA FAST PATH default
- num imp dec2flt Lemire MIN EXPONENT FAST PATH default
- num imp dec2flt biased fp to float
- num imp dec2flt dec2flt
- num imp dec2flt dec2flt with trace
- num imp dec2flt decimal Decimal can use fast path
- num imp dec2flt decimal Decimal try fast path
- num imp dec2flt decimal INT POW10
- num imp dec2flt fpu fpu precision set precision
- 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
Inspect related source (201)
- Dec2flt_modelNumImpDec2fltLemireU64 · dec2flt/mod.rs:217 Program Rust
- MAX_EXPONENT_DISGUISED_FAST_PATH · dec2flt/mod.rs:220 Program Rust
- MAX_EXPONENT_FAST_PATH · dec2flt/mod.rs:219 Program Rust
More program dependencies (159)
- from_u64 · dec2flt/mod.rs:263 Program Rust
- pow10_fast_path · dec2flt/mod.rs:222 Program Rust
- Dec2flt_modelNumImpTraitsFloatExtU64 · traits.rs:339 Program Rust
- Dec2flt_modelNumImpTraitsFloatU64 · traits.rs:309 Program Rust
- SIG_TOTAL_BITS · traits.rs:320 Program Rust
- default · dec2flt/mod.rs:128 Program Rust
- default · dec2flt/mod.rs:121 Program Rust
- biased_fp_to_float · dec2flt/mod.rs:282 Program Rust
- dec2flt · dec2flt/mod.rs:508 Program Rust
- dec2flt_with_trace · dec2flt/mod.rs:355 Program Rust
- can_use_fast_path · dec2flt/decimal.rs:42 Program Rust
- try_fast_path · dec2flt/decimal.rs:59 Program Rust
- INT_POW10 · dec2flt/decimal.rs:8 Program Rust
- set_precision · dec2flt/fpu.rs:99 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
- from_u64_bits · traits.rs:341 Program Rust
- integer_decode · traits.rs:348 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
- SMALLEST_POWER_OF_TEN · traits.rs:328 Program Rust
- classify · traits.rs:334 Program Rust
- to_bits · traits.rs:330 Program Rust
- read_u64 · dec2flt/common.rs:18 Program Rust
- Dec2flt_modelNumImpTraitsInt · traits.rs:51 Program Rust
- ParseFloatError · num/mod.rs:13 Program Rust
- Dec2FltTrace · dec2flt/mod.rs:295 Program Rust
- Lemire · dec2flt/mod.rs:115 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
- 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
- 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
- default · traits.rs:116 Program Rust
- default · traits.rs:104 Program Rust
- default · traits.rs:119 Program Rust
- default · traits.rs:110 Program Rust
- default · traits.rs:113 Program Rust
- default · traits.rs:101 Program Rust
- FloatExt · traits.rs:170 Program Rust
- offset_from · dec2flt/common.rs:30 Program Rust
- write_u64 · dec2flt/common.rs:25 Program Rust
- Dec2flt_modelNumImpTraitsCastIntoI16 · traits.rs:45 Program Rust
- ONE · traits.rs:53 Program Rust
- ZERO · traits.rs:52 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
- Int · traits.rs:27 Program Rust
- cast · traits.rs:46 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
- 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)
- 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
- shl · core/src/ops/bit.rs:489 Rust library
- MANTISSA_DIGITS · core/src/num/f64.rs:412 Rust library
- from_bits · core/src/num/f64.rs:1269 Rust library
- from_residual · core/src/option.rs:2793 Rust library
- branch · core/src/option.rs:2779 Rust library
- clone · core/src/clone.rs:698 Rust library
- bitand · core/src/ops/bit.rs:178 Rust library
- bitor · core/src/ops/bit.rs:282 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_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
- to_bits · core/src/num/f64.rs:1223 Rust library
- is_ascii_digit · core/src/num/mod.rs:958 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
- CoreMarkerCopy · core/src/marker.rs:57 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
- 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
- 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
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.configured_x86_64_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
- Binary64AdjacentNormalValues
- Binary64ApplySign
- Binary64EncoderCarryArithmetic
- Binary64ExactPositiveDivRounds
- Binary64ExactPositiveMulRounds
- Binary64FastPathGuard
All 107 entries
- Binary64AdjacentNormalValues
- Binary64ApplySign
- Binary64EncoderCarryArithmetic
- Binary64ExactPositiveDivRounds
- Binary64ExactPositiveMulRounds
- Binary64FastPathGuard
- Binary64FastPathIndexCasts
- Binary64FiniteMagnitudeStrictMono
- Binary64FromU64Exact
- Binary64IntPow10Index
- Binary64Model
- Binary64ModelDefault
- Binary64NativeCallDomain
- Binary64NormalEncoderRounds
- Binary64Pow10FastPathExact
- Binary64ZeroDivRounds
- Binary64ZeroMulRounds
- DecimalGoalVocabulary
- DecimalGoalVocabularyDefault
- DecimalLexeme
- F64
- F64 Insts CoreCloneClone
- F64 Insts CoreMarkerCopy
- F64 Insts CoreOpsArithDivF64F64
- F64 Insts CoreOpsArithMulF64F64
- F64 Insts CoreOpsArithNegF64
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64 MAX EXPONENT DISGUISED FAST PATH
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64 MAX EXPONENT FAST PATH
- F64 Insts Dec2flt modelNumImpDec2fltLemireU64 pow10 fast path
- F64 Insts Dec2flt modelNumImpTraitsFloatExtU64
- F64 Insts Dec2flt modelNumImpTraitsFloatExtU64 from u64 bits
- F64 Insts Dec2flt modelNumImpTraitsFloatExtU64 integer decode
- F64 Insts Dec2flt modelNumImpTraitsFloatU64
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 BITS
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 EXP MASK
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 INFINITY
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 LARGEST POWER OF TEN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 MAX EXPONENT ROUND TO EVEN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 MIN EXPONENT ROUND TO EVEN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 NAN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 NEG INFINITY
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 NEG NAN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 SIG MASK
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 SIG TOTAL BITS
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 SMALLEST POWER OF TEN
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 classify
- F64 Insts Dec2flt modelNumImpTraitsFloatU64 to bits
- ModelF64Classify
- ModelF64Clone
- ModelF64Div
- ModelF64ExponentMask
- ModelF64FromBits
- ModelF64FromU64
- ModelF64Infinity
- ModelF64MantissaDigits
- ModelF64MantissaMask
- ModelF64Mul
- ModelF64Nan
- ModelF64Neg
- ModelF64NegInfinity
- ModelF64ToBits
- ModelOptionBranch
- ModelOptionFromResidual
- ModelSliceFirst
- ModelSliceSplitFirst
- ModelStrAsBytes
- ModelU64BitAnd
- ModelU64BitOr
- ModelU64Shl
- ModelU64Shr
- ModelU8IsAsciiDigit
- NativeCorrectOrDefer
- Preamble
- U64 Insts CoreOpsBitBitAndU64U64
- U64 Insts CoreOpsBitBitOrU64U64
- U64 Insts CoreOpsBitShlU32U64
- U64 Insts CoreOpsBitShrU32U64
- U64 Insts Dec2flt modelNumImpTraitsCastIntoI16
- U64 Insts Dec2flt modelNumImpTraitsCastIntoI16 cast
- U64 Insts Dec2flt modelNumImpTraitsInt
- U64 Insts Dec2flt modelNumImpTraitsInt ONE
- U64 Insts Dec2flt modelNumImpTraitsInt ZERO
- core num FpCategory
- core ops arith Div
- core ops arith Mul
- core ops arith Neg
- core ops bit BitOr
- core ops bit Shl
- core ops bit Shr
- num imp dec2flt Lemire
- num imp dec2flt Lemire MAX MANTISSA FAST PATH default
- num imp dec2flt common BiasedFp
- num imp dec2flt decimal Decimal
- num imp dec2flt decimal Decimal can use fast path
- num imp dec2flt decimal Decimal try fast path
- num imp dec2flt decimal INT POW10
- num imp dec2flt fpu fpu precision set precision
- num imp traits CastInto
- num imp traits Float
- num imp traits FloatExt
- num imp traits Float EXP BIAS default
- num imp traits Float EXP BITS default
- num imp traits Float EXP MIN default
- num imp traits Float EXP SAT default
- num imp traits Float SIG BITS default
- num imp traits Int
Technical checking records
Local closure summary
{
"node": "NativeCorrectOrDefer",
"closure_version": "patch_c_v1",
"active_decl_hash": "03a8d3899e7ea22ddac4339884157a24d6af163775d2f4f6231a78fa012842e9",
"active_statement_hash": "3e732c08404fda52201c3376df141e4640c4336550d79da6ec8bd71f0c66af50",
"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-131",
"boundary_theorems": {},
"strict_theorem_deps": {
"Binary64ApplySign": "d55a8c73d5261f86",
"Binary64ExactPositiveDivRounds": "976564ebe4044467",
"Binary64ExactPositiveMulRounds": "a05b820da3503675",
"Binary64FastPathGuard": "c1391b605f3cfebb",
"Binary64FastPathIndexCasts": "417e901cdb7e8e95",
"Binary64FromU64Exact": "f1dc380dae903c52",
"Binary64IntPow10Index": "335765edc9734a2e",
"Binary64ModelDefault": "c722a2c00805b545",
"Binary64Pow10FastPathExact": "93bbdd6f862814f8",
"Binary64ZeroDivRounds": "dbd86a5562b82095",
"Binary64ZeroMulRounds": "c57caade6d34c32a",
"DecimalGoalVocabularyDefault": "94cb4c406f8efb78",
"F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_FAST_PATH": "6bf5ea9f18f5e8dc",
"num_imp_dec2flt_Lemire_MAX_MANTISSA_FAST_PATH_default": "32d9110750ebf062",
"num_imp_dec2flt_decimal_Decimal_try_fast_path": "ba81300a2601d639"
},
"strict_definition_deps": {
"Binary64Model": "c98c2c511cf0ced6",
"Binary64ModelDefault": "dc548d1e27696ba4",
"DecimalGoalVocabulary": "c43614ff2149ecf2",
"DecimalGoalVocabularyDefault": "512f8d0aea894250",
"DecimalLexeme": "8127b3eaeae00dd2",
"F64": "ec4e25fbaf4e11d4",
"F64_Insts_CoreOpsArithDivF64F64": "dc44e13a99fc6bed",
"F64_Insts_CoreOpsArithMulF64F64": "1ae1a9021a654abd",
"F64_Insts_CoreOpsArithNegF64": "2d9be310c546ea2e",
"F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64": "30963b4ef656cc79",
"F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_DISGUISED_FAST_PATH": "238680a0d0ed48da",
"F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_MAX_EXPONENT_FAST_PATH": "c8b07a02533b83c6",
"F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64_pow10_fast_path": "c0ce6fdd5caeca22",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64": "60afe26c6a80cf0f",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS": "887b52d84a3fc9c4",
"ModelF64Div": "f8da2e585a4f4183",
"ModelF64FromU64": "97a26f5bc593ff7a",
"ModelF64Mul": "ba97971db93c2ae2",
"ModelF64Neg": "78a021de99eb373b",
"ModelOptionBranch": "2b227898dbe15e59",
"ModelOptionFromResidual": "6d48ecfbc617744f",
"Preamble": "4adf4172ae751d7d",
"core_num_FpCategory": "f500de642a5d5148",
"core_ops_arith_Div": "2704fb3c3065e0f5",
"core_ops_arith_Mul": "91e8d5ef661a3d2a",
"core_ops_arith_Neg": "0ff07135a60bcbf9",
"num_imp_dec2flt_Lemire": "94ab5f784cdf5db8",
"num_imp_dec2flt_common_BiasedFp": "c43614ff2149ecf2",
"num_imp_dec2flt_decimal_Decimal": "fe99f3f976739f2d",
"num_imp_dec2flt_decimal_Decimal_can_use_fast_path": "11145d187f88b02e",
"num_imp_dec2flt_decimal_Decimal_try_fast_path": "063a63057ba134c8",
"num_imp_dec2flt_decimal_INT_POW10": "48c78c3dca210847",
"num_imp_dec2flt_fpu_fpu_precision_set_precision": "73042c31057f9ab9",
"num_imp_traits_Float": "22e97e73b1292e80",
"num_imp_traits_FloatExt": "f996e5400649797d"
}
}Prose assessment
{
"label": "Recorded Sound: VerifierPass",
"assessment_status": "VerifierPass",
"fingerprint_relation": "matches current fingerprint",
"assessment_fingerprint": "sound-v2:238da8f44bc18410018d89d9afbe87afc27300a5caea097ba3c20ca803dcd422",
"current_fingerprint": "sound-v2:238da8f44bc18410018d89d9afbe87afc27300a5caea097ba3c20ca803dcd422",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"sound_status": "Pass",
"substantiveness_status": "Pass"
}