Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Lemma
compute_float call returns a biased pair fp with nonnegative
biased exponent, then some binary64 carrier word is the unrestricted assembly
of fp and is the nonnegative nearest-even rounding of the exact real number
w10^q.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.P861_T1_IntegerSubnormalRounds
import Tablet.P873_T1_IntegerNormalRounds
import Tablet.Binary64AdjacentNormalValues
import Tablet.Binary64EncoderCarryArithmetic
import Tablet.Binary64FiniteMagnitudeStrictMono
import Tablet.Binary64NormalEncoderRounds
import Tablet.F64
import Tablet.IntegerPowerTableCertificate
import Tablet.IntegerProductApproximation
import Tablet.ModelU64BitAnd
import Tablet.ModelU64BitOr
import Tablet.ModelU64Shl
import Tablet.ParserExponentConstants
import Tablet.num_imp_dec2flt_lemire_compute_float
import Mathlib.Tactic.FieldSimp
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 1500000
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: IntegerCoreRounding]
theorem IntegerCoreRounding :
∀ (q : Std.I64) (w : Std.U64)
(fp : num.imp.dec2flt.common.BiasedFp),
0 < w.val → -342 ≤ q.val → q.val ≤ 308 →
0 ≤ fp.p_biased.val →
num.imp.dec2flt.lemire.compute_float
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 q w = ok fp →
∃ target : F64,
DecimalGoalVocabularyDefault.assembledWord fp target ∧
DecimalGoalVocabularyDefault.roundsMagnitude
((w.val : Real) * (10 : Real) ^ q.val) 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
usize and the
checked addition by three give precision 55.power2.assembledWord and roundsMagnitude for the exact value
w10^q, as required.Lean proof
set_option maxRecDepth 1000000 in
intro q w fp hw hqlo hqhi hfp hrun
have bind_ok_inv : ∀ {α β : Type} (r : Result α) (f : α → Result β) y,
Bind.bind r f = ok y → ∃ x, r = ok x ∧ f x = ok y := by as_aux_lemma =>
intro α β r f y hr
cases r <;> simp_all [Bind.bind, Aeneas.Std.bind]
rcases ParserExponentConstants with
⟨hbits, htotal, hsig, hexpbits, hexpsat, hinf, hbias, hmin,
hsmall, hlarge, hroundmin, hroundmax⟩
have hzero : num.imp.dec2flt.common.BiasedFp.zero_pow2 0#i32 =
ok { m := 0#u64, p_biased := 0#i32 } := by rfl
have hinfFp : num.imp.dec2flt.common.BiasedFp.zero_pow2 2047#i32 =
ok { m := 0#u64, p_biased := 2047#i32 } := by rfl
have herr : num.imp.dec2flt.common.BiasedFp.zero_pow2 (-1)#i32 =
ok { m := 0#u64, p_biased := (-1)#i32 } := by rfl
have hcastSmall : lift (IScalar.cast .I64 (-342)#i32) =
ok (-342)#i64 := by rfl
have hcastLarge : lift (IScalar.cast .I64 308#i32) =
ok 308#i64 := by rfl
have hsigop : (53#u32 - 1#u32) = ok 52#u32 := by rfl
unfold num.imp.dec2flt.lemire.compute_float at hrun
rw [hzero, hinf] at hrun
simp only [bind_tc_ok] at hrun
rw [hinfFp, herr] at hrun
simp only [bind_tc_ok] at hrun
have hwne : w ≠ 0#u64 := by as_aux_lemma =>
intro h
have : w.val = 0 := UScalar.val_eq_of_eq h
omega
simp only [hwne, if_false] at hrun
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SMALLEST_POWER_OF_TEN.eq_def,
hcastSmall] at hrun
simp only [bind_tc_ok] at hrun
have hnsmall : ¬ q < (-342)#i64 := by as_aux_lemma =>
simpa only [IScalar.lt_equiv] using (show ¬ q.val < -342 by omega)
simp only [hnsmall, if_false] at hrun
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.LARGEST_POWER_OF_TEN.eq_def,
hcastLarge] at hrun
simp only [bind_tc_ok] at hrun
have hnlarge : ¬ q > 308#i64 := by as_aux_lemma =>
simpa only [IScalar.lt_equiv] using (show ¬ 308 < q.val by omega)
simp only [hnlarge, if_false] at hrun
simp only [lift, bind_tc_ok] at hrun
let l : Std.U32 := core.num.U64.leading_zeros w
cases hW : (w <<< l) with
| fail e => simp only [l, hW, bind_tc_fail] at hrun; contradiction
| div => simp only [l, hW, bind_tc_div] at hrun; contradiction
| ok W =>
simp only [l, hW, bind_tc_ok] at hrun
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def] at hrun
simp only [core.f64.F64.MANTISSA_DIGITS, ModelF64MantissaDigits,
Binary64ModelDefault] at hrun
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def] at hrun
simp only [bind_tc_ok] at hrun
rw [hsigop] at hrun
simp only [bind_tc_ok] at hrun
obtain ⟨precision, hprecision, hrun⟩ := bind_ok_inv _ _ _ hrun
have hprecisionEq : precision = 55#usize := by
have hs := UScalar.add_equiv (UScalar.cast .Usize 52#u32) 3#usize
rw [hprecision] at hs
apply UScalar.eq_of_val_eq
norm_num at hs ⊢
exact hs.2.1
subst precision
obtain ⟨pair, hproduct, hrun⟩ := bind_ok_inv _ _ _ hrun
rcases pair with ⟨lo, hi⟩
simp only [Aeneas.Std.uncurry_apply_pair] at hrun
have hwneVal : w.val ≠ 0 := by omega
have hwbv : w.bv ≠ 0 := by
intro h
apply hwneVal
change w.bv.toNat = 0
rw [h]
rfl
have hwlt : w.val < 2 ^ 64 := w.bv.isLt
have hloglt : Nat.log 2 w.val < 64 :=
Nat.log_lt_of_lt_pow hwneVal hwlt
have hlval : l.val = 63 - Nat.log 2 w.val := by
simp only [l, core.num.U64.leading_zeros, BitVec.leadingZeros, if_neg hwbv,
UScalar.val]
change (BitVec.ofNat 32 (64 - Nat.log 2 w.bv.toNat - 1)).toNat =
63 - Nat.log 2 w.bv.toNat
rw [BitVec.toNat_ofNat, Nat.mod_eq_of_lt (by omega)]
omega
have hl : l.val ≤ 63 := by omega
have hpowlo : 2 ^ Nat.log 2 w.val ≤ w.val :=
Nat.pow_log_le_self 2 hwneVal
have hpowhi : w.val < 2 ^ (Nat.log 2 w.val + 1) :=
Nat.lt_pow_succ_log_self (by omega) w.val
have hmul_lt : w.val * 2 ^ l.val < 2 ^ 64 := by
rw [hlval]
have heq : Nat.log 2 w.val + 1 + (63 - Nat.log 2 w.val) = 64 := by
omega
calc
w.val * 2 ^ (63 - Nat.log 2 w.val) <
2 ^ (Nat.log 2 w.val + 1) * 2 ^ (63 - Nat.log 2 w.val) :=
Nat.mul_lt_mul_of_pos_right hpowhi (by positivity)
_ = 2 ^ 64 := by rw [← pow_add, heq]
have hshiftSpec := UScalar.ShiftLeft_spec w l (2 ^ 64) (by
change l.val < 64
omega) (by norm_num [U64.size_eq])
rw [hW] at hshiftSpec
have hWval : W.val = w.val * 2 ^ l.val := by as_aux_lemma =>
have hmul_lt' : w.val * 2 ^ l.val < 18446744073709551616 := by
norm_num at hmul_lt ⊢
exact hmul_lt
simpa [WP.spec_ok, Nat.shiftLeft_eq, Nat.mod_eq_of_lt hmul_lt'] using
hshiftSpec.1
have hWlower : 2 ^ 63 ≤ W.val := by as_aux_lemma =>
rw [hWval, hlval]
calc
2 ^ 63 = 2 ^ Nat.log 2 w.val * 2 ^ (63 - Nat.log 2 w.val) := by
rw [← pow_add]
congr 1
omega
_ ≤ w.val * 2 ^ (63 - Nat.log 2 w.val) :=
Nat.mul_le_mul_right _ hpowlo
let coreRun : Result num.imp.dec2flt.common.BiasedFp := do
let i8 ← hi >>> 63#i32
let upperbit := UScalar.hcast .I32 i8
let i9 ← upperbit + 64#i32
let sigbits := UScalar.hcast .I32 52#u32
let i11 ← i9 - sigbits
let i12 ← i11 - 3#i32
let mantissa ← hi >>> i12
let i14 ← num.imp.dec2flt.lemire.power (IScalar.cast .I32 q)
let i15 ← i14 + upperbit
let i17 ← i15 - UScalar.hcast .I32 (core.num.U64.leading_zeros w)
let i18 ← do
let i ← do
let i ← do
let i ← do
let i2 ← 64#u32 - 52#u32
i2 - 1#u32
let i1 ← 1#u32 <<< i
i1 - 1#u32
i >>> 1#i32
let i2 ← UScalar.hcast .I32 i - 1#i32
-. i2
let i19 ← i17 - i18
let power2 ← i19 + 1#i32
if power2 ≤ 0#i32 then do
let i20 ← -. power2
let i21 ← i20 + 1#i32
if i21 ≥ 64#i32 then ok { m := 0#u64, p_biased := 0#i32 }
else do
let i22 ← i20 + 1#i32
let mantissa1 ← mantissa >>> i22
let mantissa2 ← mantissa1 + (mantissa1 &&& 1#u64)
let mantissa3 ← mantissa2 >>> 1#i32
let i24 ← 1#u64 <<< 52#u32
ok { m := mantissa3, p_biased :=
IScalar.cast_fromBool .I32 (decide (mantissa3 ≥ i24)) }
else do
let mantissa1 ←
if lo ≤ 1#u64 then
if q ≥ IScalar.cast .I64
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.MIN_EXPONENT_ROUND_TO_EVEN then
if q ≤ IScalar.cast .I64
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.MAX_EXPONENT_ROUND_TO_EVEN then
if mantissa &&& 3#u64 = 1#u64 then do
let i26 ← i9 - sigbits
let i27 ← i26 - 3#i32
let i28 ← mantissa <<< i27
if i28 = hi then ok (mantissa &&& ~~~1#u64) else ok mantissa
else ok mantissa
else ok mantissa
else ok mantissa
else ok mantissa
let mantissa2 ← mantissa1 + (mantissa1 &&& 1#u64)
let mantissa3 ← mantissa2 >>> 1#i32
let i21 ← 2#u64 <<< 52#u32
let (mantissa4, power21) ←
if mantissa3 ≥ i21 then do
let mantissa5 ← 1#u64 <<< 52#u32
let power22 ← power2 + 1#i32
ok (mantissa5, power22)
else ok (mantissa3, power2)
let i22 ← 1#u64 <<< 52#u32
if power21 ≥ 2047#i32 then
ok { m := 0#u64, p_biased := 2047#i32 }
else ok { m := mantissa4 &&& ~~~i22, p_biased := power21 }
have hsent : lo.val ≠ 2 ^ 64 - 1 ∨
(-27 ≤ q.val ∧ q.val ≤ 55) := by as_aux_lemma =>
by_cases hlo : lo = 18446744073709551615#u64
· right
have hqneg : q ≥ (-27)#i64 := by
by_contra hn
simp only [hlo, if_true, hn, bind_tc_ok, if_false] at hrun
cases hrun
norm_num at hfp
have hq55 : q ≤ 55#i64 := by
by_contra hn
have hbfalse : decide (q ≤ 55#i64) = false := by simpa using hn
simp only [hlo, if_true, hqneg, bind_tc_ok, hbfalse] at hrun
cases hrun
norm_num at hfp
simpa only [IScalar.le_equiv] using And.intro hqneg hq55
· left
intro hv
apply hlo
apply UScalar.eq_of_val_eq
norm_num at hv ⊢
exact hv
have hrunTail : coreRun = ok fp := by as_aux_lemma =>
by_cases hlo : lo = 18446744073709551615#u64
· have hs := hsent.resolve_left (by
intro hv
apply hv
rw [hlo]
norm_num)
have hqneg : q ≥ (-27)#i64 := by
simpa only [IScalar.le_equiv] using hs.1
have hq55 : q ≤ 55#i64 := by
simpa only [IScalar.le_equiv] using hs.2
have hbtrue : decide (q ≤ 55#i64) = true := by simpa using hq55
simp only [hlo, if_true, hqneg, bind_tc_ok, hbtrue] at hrun
simpa only [coreRun, hlo] using hrun
· simp only [hlo, if_false] at hrun
simpa only [coreRun] using hrun
clear hrun
have hrun := hrunTail
clear hrunTail
dsimp only [coreRun] at hrun
rcases IntegerProductApproximation q W lo hi hqlo hqhi hWlower hproduct hsent with
⟨delta, index, a, b, hdelta, hindex, htable, happrox⟩
rcases IntegerPowerTableCertificate q hqlo hqhi with
⟨q32, power, delta', index', a', b', hq32, hpower, hpowerVal,
hdelta', hindex', htable', htableFacts⟩
simp only [lift] at hq32
have hq32' : IScalar.cast .I32 q = q32 := Result.ok.inj hq32
let expMinRun : Result Std.I32 := do
let i ← do
let i ← do
let i ← do
let i2 ← 64#u32 - 52#u32
i2 - 1#u32
let i1 ← 1#u32 <<< i
i1 - 1#u32
i >>> 1#i32
let i2 ← UScalar.hcast .I32 i - 1#i32
-. i2
let tailRun (G64 : Std.U64) (i9 i12 p : Std.I32) :
Result num.imp.dec2flt.common.BiasedFp :=
if p ≤ 0#i32 then do
let i20 ← -. p
let i21 ← i20 + 1#i32
if i21 ≥ 64#i32 then ok { m := 0#u64, p_biased := 0#i32 }
else do
let i22 ← i20 + 1#i32
let mantissa1 ← G64 >>> i22
let mantissa2 ← mantissa1 + (mantissa1 &&& 1#u64)
let mantissa3 ← mantissa2 >>> 1#i32
let i24 ← 1#u64 <<< 52#u32
ok { m := mantissa3, p_biased :=
IScalar.cast_fromBool .I32 (decide (mantissa3 ≥ i24)) }
else do
let mantissa1 ←
if lo ≤ 1#u64 then
if q ≥ IScalar.cast .I64
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.MIN_EXPONENT_ROUND_TO_EVEN then
if q ≤ IScalar.cast .I64
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.MAX_EXPONENT_ROUND_TO_EVEN then
if G64 &&& 3#u64 = 1#u64 then do
let i26 ← i9 - UScalar.hcast .I32 52#u32
let i27 ← i26 - 3#i32
let i28 ← G64 <<< i27
if i28 = hi then ok (G64 &&& ~~~1#u64) else ok G64
else ok G64
else ok G64
else ok G64
else ok G64
let mantissa2 ← mantissa1 + (mantissa1 &&& 1#u64)
let mantissa3 ← mantissa2 >>> 1#i32
let i21 ← 2#u64 <<< 52#u32
let (mantissa4, power21) ←
if mantissa3 ≥ i21 then do
let mantissa5 ← 1#u64 <<< 52#u32
let power22 ← p + 1#i32
ok (mantissa5, power22)
else ok (mantissa3, p)
let i22 ← 1#u64 <<< 52#u32
if power21 ≥ 2047#i32 then
ok { m := 0#u64, p_biased := 2047#i32 }
else ok { m := mantissa4 &&& ~~~i22, p_biased := power21 }
have hcoreInv : ∃ (i8 : Std.U64) (i9 i11 i12 : Std.I32)
(G64 : Std.U64) (i15 i17 i18 i19 p : Std.I32),
hi >>> 63#i32 = ok i8 ∧
UScalar.hcast .I32 i8 + 64#i32 = ok i9 ∧
i9 - UScalar.hcast .I32 52#u32 = ok i11 ∧
i11 - 3#i32 = ok i12 ∧
hi >>> i12 = ok G64 ∧
power + UScalar.hcast .I32 i8 = ok i15 ∧
i15 - UScalar.hcast .I32 (core.num.U64.leading_zeros w) = ok i17 ∧
expMinRun = ok i18 ∧ i17 - i18 = ok i19 ∧
i19 + 1#i32 = ok p ∧ tailRun G64 i9 i12 p = ok fp := by as_aux_lemma =>
have hr := hrun
rw [hq32', hpower] at hr
simp only [bind_tc_ok] at hr
change (do
let i8 ← hi >>> 63#i32
let i9 ← UScalar.hcast .I32 i8 + 64#i32
let i11 ← i9 - UScalar.hcast .I32 52#u32
let i12 ← i11 - 3#i32
let G64 ← hi >>> i12
let i15 ← power + UScalar.hcast .I32 i8
let i17 ← i15 - UScalar.hcast .I32 (core.num.U64.leading_zeros w)
let i18 ← expMinRun
let i19 ← i17 - i18
let p ← i19 + 1#i32
tailRun G64 i9 i12 p) = ok fp at hr
obtain ⟨i8, hi8, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨i9, hi9, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨i11, hi11, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨i12, hi12, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨G64, hG64, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨i15, hi15, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨i17, hi17, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨i18, hi18, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨i19, hi19, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨p, hp, hr⟩ := bind_ok_inv _ _ _ hr
exact ⟨i8, i9, i11, i12, G64, i15, i17, i18, i19, p,
hi8, hi9, hi11, hi12, hG64, hi15, hi17, hi18, hi19, hp, hr⟩
rcases hcoreInv with ⟨i8, i9, i11, i12, G64, i15, i17, i18, i19, p,
hi8, hi9, hi11, hi12, hG64, hi15, hi17, hi18, hi19, hp, hrun⟩
dsimp only [tailRun] at hrun
dsimp only at happrox
let e : Int := 217706 * q.val / 65536 - q.val
let T : Real := (2 : Real) ^ (127 - e) * (5 : Real) ^ q.val
let R : Real := (W.val : Real) * T / (2 : Real) ^ (64 : Nat)
let u : Nat := hi.val / 2 ^ 63
let G : Nat := hi.val / 2 ^ (9 + u)
have hu : u ≤ 1 := by simpa only [u] using happrox.1
have hi8Spec := UScalar.ShiftRight_IScalar_spec hi (63#i32)
(by norm_num) (by norm_num)
rw [hi8] at hi8Spec
have hi8val : i8.val = u := by as_aux_lemma =>
simpa [WP.spec_ok, Nat.shiftRight_eq_div_pow, u] using hi8Spec.1
have hi8bound : i8.val ≤ IScalar.max .I32 := by as_aux_lemma =>
rw [hi8val]
rw [IScalar.max_I32_eq]
omega
have huCast : (UScalar.hcast .I32 i8).val = (u : Int) := by as_aux_lemma =>
have hs := UScalar.hcast_inBounds_spec .I32 i8 hi8bound
simp only [lift, WP.spec_ok] at hs
rw [hs, hi8val]
have hi9val : i9.val = (u : Int) + 64 := by as_aux_lemma =>
have hs := IScalar.add_equiv (UScalar.hcast .I32 i8) 64#i32
rw [hi9] at hs
norm_num at hs
omega
have hi11val : i11.val = (u : Int) + 12 := by as_aux_lemma =>
have hs := IScalar.sub_equiv i9 (UScalar.hcast .I32 52#u32)
rw [hi11] at hs
have h52 : (UScalar.hcast .I32 52#u32).val = 52 := by rfl
rw [h52] at hs
omega
have hi12val : i12.val = (u : Int) + 9 := by as_aux_lemma =>
have hs := IScalar.sub_equiv i11 3#i32
rw [hi12] at hs
norm_num at hs
omega
have hi12nat : i12.toNat = 9 + u := by as_aux_lemma =>
apply Nat.cast_injective (R := Int)
rw [Int.toNat_of_nonneg (by rw [hi12val]; omega), hi12val]
norm_num
omega
have hGSpec := UScalar.ShiftRight_IScalar_spec hi i12
(by change 0 ≤ i12.val; rw [hi12val]; omega) (by
change i12.val < 64
rw [hi12val]
omega)
rw [hG64] at hGSpec
have hGval : G64.val = G := by as_aux_lemma =>
simpa [WP.spec_ok, Nat.shiftRight_eq_div_pow, hi12nat, G] using hGSpec.1
have hi15val : i15.val = power.val + (u : Int) := by as_aux_lemma =>
have hs := IScalar.add_equiv power (UScalar.hcast .I32 i8)
rw [hi15] at hs
omega
have hlCast : (UScalar.hcast .I32 l).val = (l.val : Int) := by as_aux_lemma =>
have hs := UScalar.hcast_inBounds_spec .I32 l (by
rw [IScalar.max_I32_eq]
omega)
simp only [lift, WP.spec_ok] at hs
exact hs
have hi17val : i17.val = power.val + (u : Int) - l.val := by as_aux_lemma =>
have hs := IScalar.sub_equiv i15 (UScalar.hcast .I32 l)
rw [hi17] at hs
omega
have hi18eq : i18 = (-1022)#i32 := by as_aux_lemma =>
have hc := hmin
have htotal' := htotal
dsimp only [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64] at hc
dsimp only [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64] at htotal'
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def,
htotal'] at hc
simp only [bind_tc_ok, lift] at hc
have hh := hc.symm.trans hi18
exact (Result.ok.inj hh).symm
have hi19val : i19.val = power.val + (u : Int) - l.val + 1022 := by as_aux_lemma =>
have hs := IScalar.sub_equiv i17 i18
rw [hi19, hi18eq] at hs
norm_num at hs
omega
have hpval : p.val = power.val + (u : Int) - l.val + 1023 := by as_aux_lemma =>
have hs := IScalar.add_equiv i19 1#i32
rw [hp] at hs
norm_num at hs
omega
have hpformula : p.val = q.val + e + (u : Int) - l.val + 1086 := by as_aux_lemma =>
dsimp only [e]
rw [hpval, hpowerVal]
omega
let x : Real := (w.val : Real) * (10 : Real) ^ q.val
let k : Int := q.val + e - (l.val : Int) - 63
have hx : x = R * (2 : Real) ^ k := by as_aux_lemma =>
dsimp only [x, R, T, k]
rw [hWval]
push_cast
rw [show (10 : Real) = 2 * 5 by norm_num, mul_zpow]
rw [show (2 : Real) ^ (l.val : Nat) =
(2 : Real) ^ (l.val : Int) by rw [zpow_natCast]]
rw [show (2 : Real) ^ (64 : Nat) =
(2 : Real) ^ (64 : Int) by rfl]
rw [div_eq_mul_inv, ← zpow_neg]
have hpow : (2 : Real) ^ (l.val : Int) * (2 : Real) ^ (127 - e) *
(2 : Real) ^ (-64 : Int) * (2 : Real) ^
(q.val + e - (l.val : Int) - 63) = (2 : Real) ^ q.val := by
rw [← zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
rw [← zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
rw [← zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
congr 1
ring
rw [← hpow]
ring
have hk : (73 : Int) + (u : Int) + k = p.val - 1076 := by as_aux_lemma =>
dsimp only [k]
rw [hpformula]
omega
dsimp only at htableFacts
have hTlo : (2 : Real) ^ (127 : Nat) ≤ T := htableFacts.1.1
have hThi : T < (2 : Real) ^ (128 : Nat) := htableFacts.1.2
have hWlowerR : (2 : Real) ^ (63 : Nat) ≤ (W.val : Real) := by
exact_mod_cast hWlower
have hWupperR : (W.val : Real) < (2 : Real) ^ (64 : Nat) := by
exact_mod_cast W.bv.isLt
have hRlower : (2 : Real) ^ (126 : Nat) ≤ R := by as_aux_lemma =>
have hm : (2 : Real) ^ (63 : Nat) * (2 : Real) ^ (127 : Nat) ≤
(W.val : Real) * T :=
mul_le_mul hWlowerR hTlo (by positivity) (by positivity)
dsimp only [R]
calc
(2 : Real) ^ (126 : Nat) =
((2 : Real) ^ (63 : Nat) * (2 : Real) ^ (127 : Nat)) /
(2 : Real) ^ (64 : Nat) := by
rw [show 126 = 63 + 63 by omega, show 127 = 63 + 64 by omega,
pow_add, pow_add]
field_simp
_ ≤ (W.val : Real) * T / (2 : Real) ^ (64 : Nat) :=
(div_le_div_iff_of_pos_right (by positivity)).2 hm
have hRupper : R < (2 : Real) ^ (128 : Nat) := by as_aux_lemma =>
have hm : (W.val : Real) * T <
(2 : Real) ^ (64 : Nat) * (2 : Real) ^ (128 : Nat) :=
mul_lt_mul hWupperR hThi.le (by positivity) (by positivity)
dsimp only [R]
calc
(W.val : Real) * T / (2 : Real) ^ (64 : Nat) <
((2 : Real) ^ (64 : Nat) * (2 : Real) ^ (128 : Nat)) /
(2 : Real) ^ (64 : Nat) :=
(div_lt_div_iff_of_pos_right (by positivity)).2 hm
_ = (2 : Real) ^ (128 : Nat) := by field_simp
have hcellLo : (G : Real) * (2 : Real) ^ (73 + u) ≤ R :=
happrox.2.2.1
have hcellHi : R < ((G + 1 : Nat) : Real) * (2 : Real) ^ (73 + u) :=
happrox.2.2.2.1
have hscalePos : 0 < (2 : Real) ^ k := zpow_pos (by norm_num) _
have hscaleEq : (2 : Real) ^ (73 + u : Nat) * (2 : Real) ^ k =
(2 : Real) ^ (p.val - 1076) := by as_aux_lemma =>
rw [← zpow_natCast, ← zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
congr 1
have hxcellLo : (G : Real) * (2 : Real) ^ (p.val - 1076) ≤ x := by as_aux_lemma =>
calc
(G : Real) * (2 : Real) ^ (p.val - 1076) =
((G : Real) * (2 : Real) ^ (73 + u : Nat)) *
(2 : Real) ^ k := by rw [← hscaleEq]; ring
_ ≤ R * (2 : Real) ^ k := mul_le_mul_of_nonneg_right hcellLo hscalePos.le
_ = x := hx.symm
have hxcellHi : x < ((G + 1 : Nat) : Real) *
(2 : Real) ^ (p.val - 1076) := by as_aux_lemma =>
calc
x = R * (2 : Real) ^ k := hx
_ < (((G + 1 : Nat) : Real) * (2 : Real) ^ (73 + u : Nat)) *
(2 : Real) ^ k := mul_lt_mul_of_pos_right hcellHi hscalePos
_ = ((G + 1 : Nat) : Real) * (2 : Real) ^ (p.val - 1076) := by
rw [← hscaleEq]
ring
have hxLowerEq :
x = (G : Real) * (2 : Real) ^ (p.val - 1076) ↔
R = (G : Real) * (2 : Real) ^ (73 + u : Nat) := by as_aux_lemma =>
rw [hx, ← hscaleEq]
constructor
· intro heq
apply mul_right_cancel₀ hscalePos.ne'
simpa only [mul_assoc] using heq
· intro heq
rw [heq]
ring
have htie :
(x = (G : Real) * (2 : Real) ^ (p.val - 1076) ∧ G % 4 = 1) ↔
(-4 ≤ q.val ∧ q.val ≤ 23 ∧ G % 4 = 1 ∧
lo.val ≤ 1 ∧ G * 2 ^ (9 + u) = hi.val) := by as_aux_lemma =>
rw [hxLowerEq]
exact happrox.2.2.2.2
have hpLower : -114 ≤ p.val := by
dsimp only [e] at hpformula
omega
have hpUpper : p.val ≤ 2110 := by
dsimp only [e] at hpformula
omega
have hGLower : 2 ^ 53 ≤ G := by as_aux_lemma =>
rcases (Nat.le_one_iff_eq_zero_or_eq_one.mp hu) with hu0 | hu1
· have hstrict : (2 : Real) ^ (126 : Nat) <
((G + 1 : Nat) : Real) * (2 : Real) ^ (73 : Nat) := by
exact hRlower.trans_lt (by simpa only [hu0, Nat.add_zero] using hcellHi)
have hpEq : (2 : Real) ^ (126 : Nat) =
(2 : Real) ^ (53 : Nat) * (2 : Real) ^ (73 : Nat) := by
rw [← pow_add]
rw [hpEq, Nat.cast_add, Nat.cast_one] at hstrict
have hc : (2 : Real) ^ (53 : Nat) < (G : Real) + 1 := by
nlinarith [show 0 < (2 : Real) ^ (73 : Nat) by positivity]
have hn : 2 ^ 53 < G + 1 := by exact_mod_cast hc
omega
· have hu1' : 1 ≤ hi.val / 2 ^ 63 := by simpa only [u] using hu1.ge
have hhi : 2 ^ 63 ≤ hi.val := by
have := (Nat.le_div_iff_mul_le (by positivity : 0 < 2 ^ 63)).mp hu1'
simpa only [one_mul] using this
dsimp only [G]
rw [hu1]
apply (Nat.le_div_iff_mul_le (by positivity : 0 < 2 ^ (9 + 1))).2
norm_num at hhi ⊢
exact hhi
have hGUpper : G < 2 ^ 54 := by as_aux_lemma =>
rcases (Nat.le_one_iff_eq_zero_or_eq_one.mp hu) with hu0 | hu1
· have hhi : hi.val < 2 ^ 63 := by
apply Nat.lt_of_div_eq_zero (by positivity : 0 < 2 ^ 63)
simpa only [u] using hu0
dsimp only [G]
rw [hu0]
apply (Nat.div_lt_iff_lt_mul (by positivity : 0 < 2 ^ (9 + 0))).2
norm_num at hhi ⊢
exact hhi
· have hhi : hi.val < 2 ^ 64 := hi.bv.isLt
dsimp only [G]
rw [hu1]
apply (Nat.div_lt_iff_lt_mul (by positivity : 0 < 2 ^ (9 + 1))).2
norm_num at hhi ⊢
exact hhi
have andOne (z : Std.U64) : (z &&& 1#u64).val = z.val % 2 := by as_aux_lemma =>
change (z.bv &&& 1#64).toNat = z.bv.toNat % 2
rw [show (1#64) = 2#64 ^ 1 - 1#64 by decide,
BitVec.and_two_pow_sub_one_eq_mod]
simp
have andThree (z : Std.U64) : (z &&& 3#u64).val = z.val % 4 := by as_aux_lemma =>
change (z.bv &&& 3#64).toNat = z.bv.toNat % 4
rw [show (3#64) = 2#64 ^ 2 - 1#64 by decide,
BitVec.and_two_pow_sub_one_eq_mod]
simp
have clearLow (z : Std.U64) (hz : z.val % 2 = 1) :
(z &&& ~~~1#u64).val = z.val - 1 := by as_aux_lemma =>
have clearNat (n : Nat) (hn : n < 2 ^ 64) :
n &&& (2 ^ 64 - 2) = n - n % 2 := by
have hn2 : n / 2 < 2 ^ 63 := by
apply (Nat.div_lt_iff_lt_mul (by omega)).2
norm_num at hn ⊢
exact hn
conv_lhs =>
rw [← Nat.bit_bodd_div2 n]
rw [show 2 ^ 64 - 2 = Nat.bit false (2 ^ 63 - 1) by simp [Nat.bit]]
rw [Nat.land_bit]
simp only [Bool.and_false, Nat.bit_false]
rw [Nat.and_two_pow_sub_one_eq_mod, Nat.div2_val,
Nat.mod_eq_of_lt hn2]
have hd := Nat.div_add_mod n 2
omega
change (z.bv &&& ~~~(1#64)).toNat = z.bv.toNat - 1
rw [BitVec.toNat_and, BitVec.toNat_not, BitVec.toNat_ofNat]
norm_num
have hc := clearNat z.bv.toNat z.bv.isLt
norm_num at hc
rw [hc]
omega
let unit : Nat := 2 ^ 52
let expBits : Nat :=
((fp.p_biased.val.emod (2 ^ 64)).toNat * (2 ^ 52)) % (2 ^ 64)
let target : F64 := ⟨fp.m.bv ||| BitVec.ofNat 64 expBits⟩
have htargetAssembly :
DecimalGoalVocabularyDefault.assembledWord fp target := by
dsimp only [DecimalGoalVocabularyDefault, target, expBits]
change (fp.m.bv ||| BitVec.ofNat 64
((fp.p_biased.val.emod (2 ^ 64)).toNat * 2 ^ 52 % 2 ^ 64)).toNat = _
rw [BitVec.toNat_or, BitVec.toNat_ofNat]
simp only [Nat.mod_mod]
rfl
refine ⟨target, htargetAssembly, ?_⟩
by_cases hp0 : p ≤ 0#i32
· simp only [hp0, if_true] at hrun
exact P861_T1_IntegerSubnormalRounds q w G64 p G fp target
hw hqlo hpLower hp0 hGval hGUpper hxcellLo hxcellHi
htargetAssembly hrun
· as_aux_lemma =>
let adjustRun : Result Std.U64 :=
if lo ≤ 1#u64 then
if q ≥ IScalar.cast .I64 (-4)#i32 then
if q ≤ IScalar.cast .I64 23#i32 then
if G64 &&& 3#u64 = 1#u64 then do
let i26 ← i9 - UScalar.hcast .I32 52#u32
let i27 ← i26 - 3#i32
let i28 ← G64 <<< i27
if i28 = hi then ok (G64 &&& ~~~1#u64) else ok G64
else ok G64
else ok G64
else ok G64
else ok G64
let carryRun (S64 twoU : Std.U64) : Result (Std.U64 × Std.I32) :=
if S64 ≥ twoU then do
let mantissa5 ← 1#u64 <<< 52#u32
let power22 ← p + 1#i32
ok (mantissa5, power22)
else ok (S64, p)
have hposInv : ∃ (Gc Ga S64 twoU Sf : Std.U64) (pf : Std.I32)
(oneU : Std.U64),
adjustRun = ok Gc ∧ Gc + (Gc &&& 1#u64) = ok Ga ∧
Ga >>> 1#i32 = ok S64 ∧ 2#u64 <<< 52#u32 = ok twoU ∧
carryRun S64 twoU = ok (Sf, pf) ∧
1#u64 <<< 52#u32 = ok oneU ∧
(if pf ≥ 2047#i32 then
ok { m := 0#u64, p_biased := 2047#i32 }
else ok { m := Sf &&& ~~~oneU, p_biased := pf }) = ok fp := by
as_aux_lemma =>
have hr := hrun
simp only [hp0, if_false] at hr
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.MIN_EXPONENT_ROUND_TO_EVEN.eq_def,
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.MAX_EXPONENT_ROUND_TO_EVEN.eq_def] at hr
change (do
let Gc ← adjustRun
let Ga ← Gc + (Gc &&& 1#u64)
let S64 ← Ga >>> 1#i32
let twoU ← 2#u64 <<< 52#u32
let pair ← carryRun S64 twoU
let (Sf, pf) := pair
let oneU ← 1#u64 <<< 52#u32
if pf ≥ 2047#i32 then
ok { m := 0#u64, p_biased := 2047#i32 }
else ok { m := Sf &&& ~~~oneU, p_biased := pf }) = ok fp at hr
obtain ⟨Gc, hGc, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨Ga, hGa, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨S64, hS64, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨twoU, htwoU, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨pair, hcarry, hr⟩ := bind_ok_inv _ _ _ hr
rcases pair with ⟨Sf, pf⟩
simp only [Aeneas.Std.uncurry_apply_pair] at hr
obtain ⟨oneU, honeU, hr⟩ := bind_ok_inv _ _ _ hr
exact ⟨Gc, Ga, S64, twoU, Sf, pf, oneU, hGc, hGa, hS64,
htwoU, hcarry, honeU, hr⟩
rcases hposInv with ⟨Gc, Ga, S64, twoU, Sf, pf, oneU, hGc, hGa,
hS64, htwoU, hcarry, honeU, hfinal⟩
dsimp only [adjustRun] at hGc
dsimp only [carryRun] at hcarry
have hcastNeg4 : IScalar.cast .I64 (-4)#i32 = (-4)#i64 := rfl
have hcast23 : IScalar.cast .I64 23#i32 = 23#i64 := rfl
have hshiftWP := UScalar.ShiftLeft_IScalar_spec G64 i12 (2 ^ 64)
(by change 0 ≤ i12.val; rw [hi12val]; omega) (by
change i12.val < 64
rw [hi12val]
omega)
(by norm_num [U64.size_eq])
obtain ⟨H, hH, hHspec⟩ := Aeneas.Std.WP.spec_imp_exists hshiftWP
have hGshiftBound : G * 2 ^ (9 + u) < 2 ^ 64 := by
interval_cases u <;> norm_num at hGUpper ⊢ <;> omega
have hHval : H.val = G * 2 ^ (9 + u) := by
have hb : G * 2 ^ (9 + u) < 18446744073709551616 := by
norm_num at hGshiftBound ⊢
exact hGshiftBound
have hv : H.val = (G * 2 ^ (9 + u)) % 18446744073709551616 := by
simpa only [hGval, hi12nat, Nat.shiftLeft_eq] using hHspec.1
rw [Nat.mod_eq_of_lt hb] at hv
exact hv
have hshiftIff : H = hi ↔ G * 2 ^ (9 + u) = hi.val := by as_aux_lemma =>
constructor
· intro heq
rw [← hHval, heq]
· intro heq
apply UScalar.eq_of_val_eq
omega
have hmodIff : G64 &&& 3#u64 = 1#u64 ↔ G % 4 = 1 := by as_aux_lemma =>
constructor
· intro heq
have := congrArg UScalar.val heq
rw [andThree, hGval] at this
norm_num at this
exact this
· intro heq
apply UScalar.eq_of_val_eq
rw [andThree, hGval]
norm_num
exact heq
let tieLow : Prop :=
x = (G : Real) * (2 : Real) ^ (p.val - 1076) ∧ G % 4 = 1
let codeTie : Prop :=
lo ≤ 1#u64 ∧ q ≥ (-4)#i64 ∧ q ≤ 23#i64 ∧
G64 &&& 3#u64 = 1#u64 ∧ H = hi
have hcodeTie : codeTie ↔ tieLow := by as_aux_lemma =>
dsimp only [codeTie, tieLow]
constructor
· intro hc
apply htie.mpr
refine ⟨?_, ?_, hmodIff.mp hc.2.2.2.1, ?_, hshiftIff.mp hc.2.2.2.2⟩
· simpa only [IScalar.le_equiv] using hc.2.1
· simpa only [IScalar.le_equiv] using hc.2.2.1
· simpa only [UScalar.le_equiv] using hc.1
· intro ht
have hc := htie.mp ht
refine ⟨?_, ?_, ?_, hmodIff.mpr hc.2.2.1, hshiftIff.mpr hc.2.2.2.2⟩
· simpa only [UScalar.le_equiv] using hc.2.2.2.1
· simpa only [IScalar.le_equiv] using hc.1
· simpa only [IScalar.le_equiv] using hc.2.1
rw [hcastNeg4, hcast23, hi11] at hGc
simp only [bind_tc_ok] at hGc
rw [hi12] at hGc
simp only [bind_tc_ok] at hGc
rw [hH] at hGc
simp only [bind_tc_ok] at hGc
have hGcEq : Gc = if codeTie then G64 &&& ~~~1#u64 else G64 := by as_aux_lemma =>
dsimp only [codeTie]
by_cases c1 : lo ≤ 1#u64 <;>
by_cases c2 : q ≥ (-4)#i64 <;>
by_cases c3 : q ≤ 23#i64 <;>
by_cases c4 : G64 &&& 3#u64 = 1#u64 <;>
by_cases c5 : H = hi <;>
simp only [c1, c2, c3, c4, c5, if_true, if_false,
and_true, and_false] at hGc ⊢ <;>
exact (Result.ok.inj hGc).symm
have hGcval : Gc.val = if tieLow then G - 1 else G := by as_aux_lemma =>
by_cases ht : tieLow
· have hc := hcodeTie.mpr ht
rw [if_pos ht, hGcEq, if_pos hc]
rw [clearLow, hGval]
· dsimp only [tieLow] at ht
omega
· have hc : ¬ codeTie := fun h => ht (hcodeTie.mp h)
rw [if_neg ht, hGcEq, if_neg hc, hGval]
have hGaVal : Ga.val = Gc.val + Gc.val % 2 := by
have hs := UScalar.add_equiv Gc (Gc &&& 1#u64)
rw [hGa] at hs
rw [andOne] at hs
exact hs.2.1
have hSspec := UScalar.ShiftRight_IScalar_spec Ga (1#i32)
(by norm_num) (by norm_num)
rw [hS64] at hSspec
have hSval : S64.val = (Gc.val + Gc.val % 2) / 2 := by
have hv := hSspec.1
rw [hGaVal] at hv
simpa [Nat.shiftRight_eq_div_pow] using hv
let lowSig : Nat := G / 2
let chooseHigh : Prop := G % 2 = 1 ∧ ¬ tieLow
have hSchoice : S64.val = if chooseHigh then lowSig + 1 else lowSig := by as_aux_lemma =>
dsimp only [chooseHigh, lowSig]
by_cases ht : tieLow
· rw [if_pos ht] at hGcval
have htmod : G % 4 = 1 := by simpa only [tieLow] using ht.2
have hmod2 : G % 2 = 1 := by omega
rw [if_neg (by simp [ht])]
rw [hSval, hGcval]
omega
· rw [if_neg ht] at hGcval
by_cases hodd : G % 2 = 1
· rw [if_pos (by exact ⟨hodd, ht⟩)]
rw [hSval, hGcval]
omega
· rw [if_neg (by simp [hodd])]
rw [hSval, hGcval]
have hm := Nat.mod_lt G (by omega : 0 < 2)
omega
have hLowSigLower : 2 ^ 52 ≤ lowSig := by
dsimp only [lowSig]
apply (Nat.le_div_iff_mul_le (by omega : 0 < 2)).2
norm_num at hGLower ⊢
exact hGLower
have hLowSigUpper : lowSig < 2 ^ 53 := by
dsimp only [lowSig]
apply (Nat.div_lt_iff_lt_mul (by omega : 0 < 2)).2
norm_num at hGUpper ⊢
exact hGUpper
have hSBounds : 2 ^ 52 ≤ S64.val ∧ S64.val ≤ 2 ^ 53 := by
rw [hSchoice]
split <;> omega
have htwoUSpec := UScalar.ShiftLeft_spec (2#u64) (52#u32) (2 ^ 64)
(by norm_num) (by norm_num [U64.size_eq])
rw [htwoU] at htwoUSpec
have htwoUval : twoU.val = 2 ^ 53 := by
norm_num [WP.spec_ok, Nat.shiftLeft_eq] at htwoUSpec ⊢
exact htwoUSpec.1
have honeUSpec := UScalar.ShiftLeft_spec (1#u64) (52#u32) (2 ^ 64)
(by norm_num) (by norm_num [U64.size_eq])
rw [honeU] at honeUSpec
have honeUval : oneU.val = 2 ^ 52 := by
norm_num [WP.spec_ok, Nat.shiftLeft_eq] at honeUSpec ⊢
exact honeUSpec.1
have hcarryIff : S64 ≥ twoU ↔ S64.val = 2 ^ 53 := by
change twoU.val ≤ S64.val ↔ S64.val = 2 ^ 53
rw [htwoUval]
omega
have hSfPf :
(S64.val = 2 ^ 53 ∧ Sf = oneU ∧ pf.val = p.val + 1) ∨
(S64.val < 2 ^ 53 ∧ Sf = S64 ∧ pf = p) := by as_aux_lemma =>
by_cases hc : S64 ≥ twoU
· have hceq := hcarryIff.mp hc
simp only [hc, if_true, honeU, bind_tc_ok] at hcarry
obtain ⟨pnext, hpnext, hpair⟩ := bind_ok_inv _ _ _ hcarry
have hpnextVal : pnext.val = p.val + 1 := by
have hs := IScalar.add_equiv p 1#i32
rw [hpnext] at hs
exact hs.2.1
have heq := Result.ok.inj hpair
cases heq
exact Or.inl ⟨hceq, rfl, hpnextVal⟩
· simp only [hc, if_false] at hcarry
have heq := Result.ok.inj hcarry
have hclt : S64.val < 2 ^ 53 := by
have hc' : ¬ twoU.val ≤ S64.val := by
simpa only [UScalar.le_equiv] using hc
rw [htwoUval] at hc'
omega
exact Or.inr ⟨hclt, (congrArg Prod.fst heq).symm,
(congrArg Prod.snd heq).symm⟩
have hpPos : 0 < p.val := by
have hn : ¬ p.val ≤ 0 := by simpa only [IScalar.le_equiv] using hp0
omega
let pNat : Nat := p.val.toNat
have hpNatCast : (pNat : Int) = p.val := by
dsimp only [pNat]
exact Int.toNat_of_nonneg hpPos.le
let deltaR : Real := (2 : Real) ^ (p.val - 1076)
let ulpR : Real := (2 : Real) ^ (p.val - 1075)
have hdeltaPos : 0 < deltaR := by
dsimp only [deltaR]
exact zpow_pos (by norm_num) _
have hulpEq : ulpR = 2 * deltaR := by
dsimp only [ulpR, deltaR]
rw [show p.val - 1075 = (p.val - 1076) + 1 by omega,
zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
norm_num
ring
have hGdecomp : G = 2 * lowSig + G % 2 := by
dsimp only [lowSig]
have hd := Nat.mod_add_div G 2
omega
have hrem2 : G % 2 ≤ 1 := Nat.le_pred_of_lt (Nat.mod_lt _ (by omega))
have hxcellLo' : (G : Real) * deltaR ≤ x := by
simpa only [deltaR] using hxcellLo
have hxcellHi' : x < ((G + 1 : Nat) : Real) * deltaR := by
simpa only [deltaR] using hxcellHi
have hLowX : (lowSig : Real) * ulpR ≤ x := by
have hc : ((2 * lowSig : Nat) : Real) * deltaR ≤
(G : Real) * deltaR := by
apply mul_le_mul_of_nonneg_right _ hdeltaPos.le
exact_mod_cast (by omega : 2 * lowSig ≤ G)
rw [hulpEq]
push_cast at hc ⊢
linarith only [hc, hxcellLo']
have hXHigh : x ≤ ((lowSig + 1 : Nat) : Real) * ulpR := by
have hc : ((G + 1 : Nat) : Real) * deltaR ≤
((2 * (lowSig + 1) : Nat) : Real) * deltaR := by
apply mul_le_mul_of_nonneg_right _ hdeltaPos.le
exact_mod_cast (by omega : G + 1 ≤ 2 * (lowSig + 1))
calc
x ≤ ((G + 1 : Nat) : Real) * deltaR := hxcellHi'.le
_ ≤ ((2 * (lowSig + 1) : Nat) : Real) * deltaR := hc
_ = ((lowSig + 1 : Nat) : Real) * ulpR := by
rw [hulpEq]
push_cast
ring
have hLowNear (hc : ¬ chooseHigh) :
abs (x - (lowSig : Real) * ulpR) ≤
abs (x - ((lowSig + 1 : Nat) : Real) * ulpR) := by as_aux_lemma =>
rw [abs_of_nonneg (sub_nonneg.mpr hLowX),
abs_of_nonpos (sub_nonpos.mpr hXHigh)]
dsimp only [chooseHigh] at hc
by_cases ht : tieLow
· have hteq := ht.1
dsimp only [tieLow] at ht
rw [hteq]
rw [hulpEq]
push_cast
have hg : (G : Real) = 2 * (lowSig : Real) + 1 := by
exact_mod_cast (show G = 2 * lowSig + 1 by omega)
nlinarith only [hdeltaPos, hg]
· have heven : G % 2 = 0 := by
have hnotOdd : G % 2 ≠ 1 := by
intro hodd
exact hc ⟨hodd, ht⟩
have hm : G % 2 < 2 := Nat.mod_lt G (by omega)
have hmle : G % 2 ≤ 1 := Nat.lt_succ_iff.mp hm
apply Nat.eq_zero_of_not_pos
intro hpos
exact hnotOdd (Nat.le_antisymm hmle hpos)
have hmid : x < ((2 * lowSig + 1 : Nat) : Real) * deltaR := by
have hnext : G + 1 = 2 * lowSig + 1 := by omega
simpa only [hnext] using hxcellHi'
rw [hulpEq]
push_cast at hmid ⊢
nlinarith only [hmid, hdeltaPos]
have hHighNear (hc : chooseHigh) :
abs (x - ((lowSig + 1 : Nat) : Real) * ulpR) ≤
abs (x - (lowSig : Real) * ulpR) := by as_aux_lemma =>
rw [abs_of_nonpos (sub_nonpos.mpr hXHigh),
abs_of_nonneg (sub_nonneg.mpr hLowX)]
have hodd : G % 2 = 1 := hc.1
have hmid : ((2 * lowSig + 1 : Nat) : Real) * deltaR ≤ x := by
have hg : G = 2 * lowSig + 1 := by omega
simpa only [hg] using hxcellLo'
rw [hulpEq]
push_cast at hmid ⊢
nlinarith only [hmid, hdeltaPos]
let lowBits : Nat := pNat * unit + (lowSig - unit)
let selectedBits : Nat := if chooseHigh then lowBits + 1 else lowBits
have hlowParity : lowBits % 2 = lowSig % 2 := by
dsimp only [lowBits, unit]
omega
have hTieLowEven (hc : ¬ chooseHigh)
(heq : abs (x - (lowSig : Real) * ulpR) =
abs (x - ((lowSig + 1 : Nat) : Real) * ulpR)) :
lowBits % 2 = 0 := by as_aux_lemma =>
rw [abs_of_nonneg (sub_nonneg.mpr hLowX),
abs_of_nonpos (sub_nonpos.mpr hXHigh)] at heq
have hmid : x = ((2 * lowSig + 1 : Nat) : Real) * deltaR := by
rw [hulpEq] at heq
push_cast at heq ⊢
nlinarith only [heq, hdeltaPos]
have hgOdd : G % 2 = 1 := by
by_contra hn
have hm := Nat.mod_lt G (by omega : 0 < 2)
have hge : G + 1 = 2 * lowSig + 1 := by omega
have := hxcellHi'
rw [hge, hmid] at this
exact (lt_irrefl _ this)
have ht : tieLow := by
dsimp only [tieLow]
have hG : G = 2 * lowSig + 1 := by omega
refine ⟨?_, ?_⟩
· simpa only [hG] using hmid
· dsimp only [chooseHigh] at hc
have hnot : ¬ (G % 2 = 1 ∧ ¬tieLow) := hc
by_contra hm4
have hm4lt := Nat.mod_lt G (by omega : 0 < 4)
have hnTie : ¬ tieLow := by
intro hyes
exact hm4 hyes.2
exact hnot ⟨hgOdd, hnTie⟩
have hm4 := ht.2
rw [hlowParity]
omega
have hTieHighEven (hc : chooseHigh)
(heq : abs (x - ((lowSig + 1 : Nat) : Real) * ulpR) =
abs (x - (lowSig : Real) * ulpR)) :
(lowBits + 1) % 2 = 0 := by as_aux_lemma =>
rw [abs_of_nonpos (sub_nonpos.mpr hXHigh),
abs_of_nonneg (sub_nonneg.mpr hLowX)] at heq
have hmid : x = ((2 * lowSig + 1 : Nat) : Real) * deltaR := by
rw [hulpEq] at heq
push_cast at heq ⊢
nlinarith only [heq, hdeltaPos]
have hodd := hc.1
have hG : G = 2 * lowSig + 1 := by omega
have hnotTie := hc.2
have hnotMod : G % 4 ≠ 1 := by
intro hm
apply hnotTie
dsimp only [tieLow]
exact ⟨by simpa only [hG] using hmid, hm⟩
have hm4lt := Nat.mod_lt G (by omega : 0 < 4)
rw [Nat.add_mod, hlowParity]
omega
have hxpos : 0 < x := by
dsimp only [x]
exact mul_pos (by exact_mod_cast hw) (zpow_pos (by norm_num) _)
exact P873_T1_IntegerNormalRounds x G p S64 Sf oneU pf fp target
hxpos hpPos hGLower hGUpper honeUval hSfPf htargetAssembly hfinal
hSchoice hxcellLo' hxcellHi' hLowX hXHigh hLowNear hHighNear
hTieLowEven hTieHighEven
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.DecimalGoalVocabularyDefault
import Tablet.P861_T1_IntegerSubnormalRounds
import Tablet.P873_T1_IntegerNormalRounds
import Tablet.Binary64AdjacentNormalValues
import Tablet.Binary64EncoderCarryArithmetic
import Tablet.Binary64FiniteMagnitudeStrictMono
import Tablet.Binary64NormalEncoderRounds
import Tablet.F64
import Tablet.IntegerPowerTableCertificate
import Tablet.IntegerProductApproximation
import Tablet.ModelU64BitAnd
import Tablet.ModelU64BitOr
import Tablet.ModelU64Shl
import Tablet.ParserExponentConstants
import Tablet.num_imp_dec2flt_lemire_compute_float
import Mathlib.Tactic.FieldSimp
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 1500000
set_option maxRecDepth 1000000
namespace dec2flt_model
-- [TABLET NODE: IntegerCoreRounding]
theorem IntegerCoreRounding :
∀ (q : Std.I64) (w : Std.U64)
(fp : num.imp.dec2flt.common.BiasedFp),
0 < w.val → -342 ≤ q.val → q.val ≤ 308 →
0 ≤ fp.p_biased.val →
num.imp.dec2flt.lemire.compute_float
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 q w = ok fp →
∃ target : F64,
DecimalGoalVocabularyDefault.assembledWord fp target ∧
DecimalGoalVocabularyDefault.roundsMagnitude
((w.val : Real) * (10 : Real) ^ q.val) target := by
-- BODY
set_option maxRecDepth 1000000 in
intro q w fp hw hqlo hqhi hfp hrun
have bind_ok_inv : ∀ {α β : Type} (r : Result α) (f : α → Result β) y,
Bind.bind r f = ok y → ∃ x, r = ok x ∧ f x = ok y := by as_aux_lemma =>
intro α β r f y hr
cases r <;> simp_all [Bind.bind, Aeneas.Std.bind]
rcases ParserExponentConstants with
⟨hbits, htotal, hsig, hexpbits, hexpsat, hinf, hbias, hmin,
hsmall, hlarge, hroundmin, hroundmax⟩
have hzero : num.imp.dec2flt.common.BiasedFp.zero_pow2 0#i32 =
ok { m := 0#u64, p_biased := 0#i32 } := by rfl
have hinfFp : num.imp.dec2flt.common.BiasedFp.zero_pow2 2047#i32 =
ok { m := 0#u64, p_biased := 2047#i32 } := by rfl
have herr : num.imp.dec2flt.common.BiasedFp.zero_pow2 (-1)#i32 =
ok { m := 0#u64, p_biased := (-1)#i32 } := by rfl
have hcastSmall : lift (IScalar.cast .I64 (-342)#i32) =
ok (-342)#i64 := by rfl
have hcastLarge : lift (IScalar.cast .I64 308#i32) =
ok 308#i64 := by rfl
have hsigop : (53#u32 - 1#u32) = ok 52#u32 := by rfl
unfold num.imp.dec2flt.lemire.compute_float at hrun
rw [hzero, hinf] at hrun
simp only [bind_tc_ok] at hrun
rw [hinfFp, herr] at hrun
simp only [bind_tc_ok] at hrun
have hwne : w ≠ 0#u64 := by as_aux_lemma =>
intro h
have : w.val = 0 := UScalar.val_eq_of_eq h
omega
simp only [hwne, if_false] at hrun
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SMALLEST_POWER_OF_TEN.eq_def,
hcastSmall] at hrun
simp only [bind_tc_ok] at hrun
have hnsmall : ¬ q < (-342)#i64 := by as_aux_lemma =>
simpa only [IScalar.lt_equiv] using (show ¬ q.val < -342 by omega)
simp only [hnsmall, if_false] at hrun
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.LARGEST_POWER_OF_TEN.eq_def,
hcastLarge] at hrun
simp only [bind_tc_ok] at hrun
have hnlarge : ¬ q > 308#i64 := by as_aux_lemma =>
simpa only [IScalar.lt_equiv] using (show ¬ 308 < q.val by omega)
simp only [hnlarge, if_false] at hrun
simp only [lift, bind_tc_ok] at hrun
let l : Std.U32 := core.num.U64.leading_zeros w
cases hW : (w <<< l) with
| fail e => simp only [l, hW, bind_tc_fail] at hrun; contradiction
| div => simp only [l, hW, bind_tc_div] at hrun; contradiction
| ok W =>
simp only [l, hW, bind_tc_ok] at hrun
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.SIG_TOTAL_BITS.eq_def] at hrun
simp only [core.f64.F64.MANTISSA_DIGITS, ModelF64MantissaDigits,
Binary64ModelDefault] at hrun
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def] at hrun
simp only [bind_tc_ok] at hrun
rw [hsigop] at hrun
simp only [bind_tc_ok] at hrun
obtain ⟨precision, hprecision, hrun⟩ := bind_ok_inv _ _ _ hrun
have hprecisionEq : precision = 55#usize := by
have hs := UScalar.add_equiv (UScalar.cast .Usize 52#u32) 3#usize
rw [hprecision] at hs
apply UScalar.eq_of_val_eq
norm_num at hs ⊢
exact hs.2.1
subst precision
obtain ⟨pair, hproduct, hrun⟩ := bind_ok_inv _ _ _ hrun
rcases pair with ⟨lo, hi⟩
simp only [Aeneas.Std.uncurry_apply_pair] at hrun
have hwneVal : w.val ≠ 0 := by omega
have hwbv : w.bv ≠ 0 := by
intro h
apply hwneVal
change w.bv.toNat = 0
rw [h]
rfl
have hwlt : w.val < 2 ^ 64 := w.bv.isLt
have hloglt : Nat.log 2 w.val < 64 :=
Nat.log_lt_of_lt_pow hwneVal hwlt
have hlval : l.val = 63 - Nat.log 2 w.val := by
simp only [l, core.num.U64.leading_zeros, BitVec.leadingZeros, if_neg hwbv,
UScalar.val]
change (BitVec.ofNat 32 (64 - Nat.log 2 w.bv.toNat - 1)).toNat =
63 - Nat.log 2 w.bv.toNat
rw [BitVec.toNat_ofNat, Nat.mod_eq_of_lt (by omega)]
omega
have hl : l.val ≤ 63 := by omega
have hpowlo : 2 ^ Nat.log 2 w.val ≤ w.val :=
Nat.pow_log_le_self 2 hwneVal
have hpowhi : w.val < 2 ^ (Nat.log 2 w.val + 1) :=
Nat.lt_pow_succ_log_self (by omega) w.val
have hmul_lt : w.val * 2 ^ l.val < 2 ^ 64 := by
rw [hlval]
have heq : Nat.log 2 w.val + 1 + (63 - Nat.log 2 w.val) = 64 := by
omega
calc
w.val * 2 ^ (63 - Nat.log 2 w.val) <
2 ^ (Nat.log 2 w.val + 1) * 2 ^ (63 - Nat.log 2 w.val) :=
Nat.mul_lt_mul_of_pos_right hpowhi (by positivity)
_ = 2 ^ 64 := by rw [← pow_add, heq]
have hshiftSpec := UScalar.ShiftLeft_spec w l (2 ^ 64) (by
change l.val < 64
omega) (by norm_num [U64.size_eq])
rw [hW] at hshiftSpec
have hWval : W.val = w.val * 2 ^ l.val := by as_aux_lemma =>
have hmul_lt' : w.val * 2 ^ l.val < 18446744073709551616 := by
norm_num at hmul_lt ⊢
exact hmul_lt
simpa [WP.spec_ok, Nat.shiftLeft_eq, Nat.mod_eq_of_lt hmul_lt'] using
hshiftSpec.1
have hWlower : 2 ^ 63 ≤ W.val := by as_aux_lemma =>
rw [hWval, hlval]
calc
2 ^ 63 = 2 ^ Nat.log 2 w.val * 2 ^ (63 - Nat.log 2 w.val) := by
rw [← pow_add]
congr 1
omega
_ ≤ w.val * 2 ^ (63 - Nat.log 2 w.val) :=
Nat.mul_le_mul_right _ hpowlo
let coreRun : Result num.imp.dec2flt.common.BiasedFp := do
let i8 ← hi >>> 63#i32
let upperbit := UScalar.hcast .I32 i8
let i9 ← upperbit + 64#i32
let sigbits := UScalar.hcast .I32 52#u32
let i11 ← i9 - sigbits
let i12 ← i11 - 3#i32
let mantissa ← hi >>> i12
let i14 ← num.imp.dec2flt.lemire.power (IScalar.cast .I32 q)
let i15 ← i14 + upperbit
let i17 ← i15 - UScalar.hcast .I32 (core.num.U64.leading_zeros w)
let i18 ← do
let i ← do
let i ← do
let i ← do
let i2 ← 64#u32 - 52#u32
i2 - 1#u32
let i1 ← 1#u32 <<< i
i1 - 1#u32
i >>> 1#i32
let i2 ← UScalar.hcast .I32 i - 1#i32
-. i2
let i19 ← i17 - i18
let power2 ← i19 + 1#i32
if power2 ≤ 0#i32 then do
let i20 ← -. power2
let i21 ← i20 + 1#i32
if i21 ≥ 64#i32 then ok { m := 0#u64, p_biased := 0#i32 }
else do
let i22 ← i20 + 1#i32
let mantissa1 ← mantissa >>> i22
let mantissa2 ← mantissa1 + (mantissa1 &&& 1#u64)
let mantissa3 ← mantissa2 >>> 1#i32
let i24 ← 1#u64 <<< 52#u32
ok { m := mantissa3, p_biased :=
IScalar.cast_fromBool .I32 (decide (mantissa3 ≥ i24)) }
else do
let mantissa1 ←
if lo ≤ 1#u64 then
if q ≥ IScalar.cast .I64
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.MIN_EXPONENT_ROUND_TO_EVEN then
if q ≤ IScalar.cast .I64
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.MAX_EXPONENT_ROUND_TO_EVEN then
if mantissa &&& 3#u64 = 1#u64 then do
let i26 ← i9 - sigbits
let i27 ← i26 - 3#i32
let i28 ← mantissa <<< i27
if i28 = hi then ok (mantissa &&& ~~~1#u64) else ok mantissa
else ok mantissa
else ok mantissa
else ok mantissa
else ok mantissa
let mantissa2 ← mantissa1 + (mantissa1 &&& 1#u64)
let mantissa3 ← mantissa2 >>> 1#i32
let i21 ← 2#u64 <<< 52#u32
let (mantissa4, power21) ←
if mantissa3 ≥ i21 then do
let mantissa5 ← 1#u64 <<< 52#u32
let power22 ← power2 + 1#i32
ok (mantissa5, power22)
else ok (mantissa3, power2)
let i22 ← 1#u64 <<< 52#u32
if power21 ≥ 2047#i32 then
ok { m := 0#u64, p_biased := 2047#i32 }
else ok { m := mantissa4 &&& ~~~i22, p_biased := power21 }
have hsent : lo.val ≠ 2 ^ 64 - 1 ∨
(-27 ≤ q.val ∧ q.val ≤ 55) := by as_aux_lemma =>
by_cases hlo : lo = 18446744073709551615#u64
· right
have hqneg : q ≥ (-27)#i64 := by
by_contra hn
simp only [hlo, if_true, hn, bind_tc_ok, if_false] at hrun
cases hrun
norm_num at hfp
have hq55 : q ≤ 55#i64 := by
by_contra hn
have hbfalse : decide (q ≤ 55#i64) = false := by simpa using hn
simp only [hlo, if_true, hqneg, bind_tc_ok, hbfalse] at hrun
cases hrun
norm_num at hfp
simpa only [IScalar.le_equiv] using And.intro hqneg hq55
· left
intro hv
apply hlo
apply UScalar.eq_of_val_eq
norm_num at hv ⊢
exact hv
have hrunTail : coreRun = ok fp := by as_aux_lemma =>
by_cases hlo : lo = 18446744073709551615#u64
· have hs := hsent.resolve_left (by
intro hv
apply hv
rw [hlo]
norm_num)
have hqneg : q ≥ (-27)#i64 := by
simpa only [IScalar.le_equiv] using hs.1
have hq55 : q ≤ 55#i64 := by
simpa only [IScalar.le_equiv] using hs.2
have hbtrue : decide (q ≤ 55#i64) = true := by simpa using hq55
simp only [hlo, if_true, hqneg, bind_tc_ok, hbtrue] at hrun
simpa only [coreRun, hlo] using hrun
· simp only [hlo, if_false] at hrun
simpa only [coreRun] using hrun
clear hrun
have hrun := hrunTail
clear hrunTail
dsimp only [coreRun] at hrun
rcases IntegerProductApproximation q W lo hi hqlo hqhi hWlower hproduct hsent with
⟨delta, index, a, b, hdelta, hindex, htable, happrox⟩
rcases IntegerPowerTableCertificate q hqlo hqhi with
⟨q32, power, delta', index', a', b', hq32, hpower, hpowerVal,
hdelta', hindex', htable', htableFacts⟩
simp only [lift] at hq32
have hq32' : IScalar.cast .I32 q = q32 := Result.ok.inj hq32
let expMinRun : Result Std.I32 := do
let i ← do
let i ← do
let i ← do
let i2 ← 64#u32 - 52#u32
i2 - 1#u32
let i1 ← 1#u32 <<< i
i1 - 1#u32
i >>> 1#i32
let i2 ← UScalar.hcast .I32 i - 1#i32
-. i2
let tailRun (G64 : Std.U64) (i9 i12 p : Std.I32) :
Result num.imp.dec2flt.common.BiasedFp :=
if p ≤ 0#i32 then do
let i20 ← -. p
let i21 ← i20 + 1#i32
if i21 ≥ 64#i32 then ok { m := 0#u64, p_biased := 0#i32 }
else do
let i22 ← i20 + 1#i32
let mantissa1 ← G64 >>> i22
let mantissa2 ← mantissa1 + (mantissa1 &&& 1#u64)
let mantissa3 ← mantissa2 >>> 1#i32
let i24 ← 1#u64 <<< 52#u32
ok { m := mantissa3, p_biased :=
IScalar.cast_fromBool .I32 (decide (mantissa3 ≥ i24)) }
else do
let mantissa1 ←
if lo ≤ 1#u64 then
if q ≥ IScalar.cast .I64
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.MIN_EXPONENT_ROUND_TO_EVEN then
if q ≤ IScalar.cast .I64
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.MAX_EXPONENT_ROUND_TO_EVEN then
if G64 &&& 3#u64 = 1#u64 then do
let i26 ← i9 - UScalar.hcast .I32 52#u32
let i27 ← i26 - 3#i32
let i28 ← G64 <<< i27
if i28 = hi then ok (G64 &&& ~~~1#u64) else ok G64
else ok G64
else ok G64
else ok G64
else ok G64
let mantissa2 ← mantissa1 + (mantissa1 &&& 1#u64)
let mantissa3 ← mantissa2 >>> 1#i32
let i21 ← 2#u64 <<< 52#u32
let (mantissa4, power21) ←
if mantissa3 ≥ i21 then do
let mantissa5 ← 1#u64 <<< 52#u32
let power22 ← p + 1#i32
ok (mantissa5, power22)
else ok (mantissa3, p)
let i22 ← 1#u64 <<< 52#u32
if power21 ≥ 2047#i32 then
ok { m := 0#u64, p_biased := 2047#i32 }
else ok { m := mantissa4 &&& ~~~i22, p_biased := power21 }
have hcoreInv : ∃ (i8 : Std.U64) (i9 i11 i12 : Std.I32)
(G64 : Std.U64) (i15 i17 i18 i19 p : Std.I32),
hi >>> 63#i32 = ok i8 ∧
UScalar.hcast .I32 i8 + 64#i32 = ok i9 ∧
i9 - UScalar.hcast .I32 52#u32 = ok i11 ∧
i11 - 3#i32 = ok i12 ∧
hi >>> i12 = ok G64 ∧
power + UScalar.hcast .I32 i8 = ok i15 ∧
i15 - UScalar.hcast .I32 (core.num.U64.leading_zeros w) = ok i17 ∧
expMinRun = ok i18 ∧ i17 - i18 = ok i19 ∧
i19 + 1#i32 = ok p ∧ tailRun G64 i9 i12 p = ok fp := by as_aux_lemma =>
have hr := hrun
rw [hq32', hpower] at hr
simp only [bind_tc_ok] at hr
change (do
let i8 ← hi >>> 63#i32
let i9 ← UScalar.hcast .I32 i8 + 64#i32
let i11 ← i9 - UScalar.hcast .I32 52#u32
let i12 ← i11 - 3#i32
let G64 ← hi >>> i12
let i15 ← power + UScalar.hcast .I32 i8
let i17 ← i15 - UScalar.hcast .I32 (core.num.U64.leading_zeros w)
let i18 ← expMinRun
let i19 ← i17 - i18
let p ← i19 + 1#i32
tailRun G64 i9 i12 p) = ok fp at hr
obtain ⟨i8, hi8, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨i9, hi9, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨i11, hi11, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨i12, hi12, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨G64, hG64, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨i15, hi15, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨i17, hi17, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨i18, hi18, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨i19, hi19, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨p, hp, hr⟩ := bind_ok_inv _ _ _ hr
exact ⟨i8, i9, i11, i12, G64, i15, i17, i18, i19, p,
hi8, hi9, hi11, hi12, hG64, hi15, hi17, hi18, hi19, hp, hr⟩
rcases hcoreInv with ⟨i8, i9, i11, i12, G64, i15, i17, i18, i19, p,
hi8, hi9, hi11, hi12, hG64, hi15, hi17, hi18, hi19, hp, hrun⟩
dsimp only [tailRun] at hrun
dsimp only at happrox
let e : Int := 217706 * q.val / 65536 - q.val
let T : Real := (2 : Real) ^ (127 - e) * (5 : Real) ^ q.val
let R : Real := (W.val : Real) * T / (2 : Real) ^ (64 : Nat)
let u : Nat := hi.val / 2 ^ 63
let G : Nat := hi.val / 2 ^ (9 + u)
have hu : u ≤ 1 := by simpa only [u] using happrox.1
have hi8Spec := UScalar.ShiftRight_IScalar_spec hi (63#i32)
(by norm_num) (by norm_num)
rw [hi8] at hi8Spec
have hi8val : i8.val = u := by as_aux_lemma =>
simpa [WP.spec_ok, Nat.shiftRight_eq_div_pow, u] using hi8Spec.1
have hi8bound : i8.val ≤ IScalar.max .I32 := by as_aux_lemma =>
rw [hi8val]
rw [IScalar.max_I32_eq]
omega
have huCast : (UScalar.hcast .I32 i8).val = (u : Int) := by as_aux_lemma =>
have hs := UScalar.hcast_inBounds_spec .I32 i8 hi8bound
simp only [lift, WP.spec_ok] at hs
rw [hs, hi8val]
have hi9val : i9.val = (u : Int) + 64 := by as_aux_lemma =>
have hs := IScalar.add_equiv (UScalar.hcast .I32 i8) 64#i32
rw [hi9] at hs
norm_num at hs
omega
have hi11val : i11.val = (u : Int) + 12 := by as_aux_lemma =>
have hs := IScalar.sub_equiv i9 (UScalar.hcast .I32 52#u32)
rw [hi11] at hs
have h52 : (UScalar.hcast .I32 52#u32).val = 52 := by rfl
rw [h52] at hs
omega
have hi12val : i12.val = (u : Int) + 9 := by as_aux_lemma =>
have hs := IScalar.sub_equiv i11 3#i32
rw [hi12] at hs
norm_num at hs
omega
have hi12nat : i12.toNat = 9 + u := by as_aux_lemma =>
apply Nat.cast_injective (R := Int)
rw [Int.toNat_of_nonneg (by rw [hi12val]; omega), hi12val]
norm_num
omega
have hGSpec := UScalar.ShiftRight_IScalar_spec hi i12
(by change 0 ≤ i12.val; rw [hi12val]; omega) (by
change i12.val < 64
rw [hi12val]
omega)
rw [hG64] at hGSpec
have hGval : G64.val = G := by as_aux_lemma =>
simpa [WP.spec_ok, Nat.shiftRight_eq_div_pow, hi12nat, G] using hGSpec.1
have hi15val : i15.val = power.val + (u : Int) := by as_aux_lemma =>
have hs := IScalar.add_equiv power (UScalar.hcast .I32 i8)
rw [hi15] at hs
omega
have hlCast : (UScalar.hcast .I32 l).val = (l.val : Int) := by as_aux_lemma =>
have hs := UScalar.hcast_inBounds_spec .I32 l (by
rw [IScalar.max_I32_eq]
omega)
simp only [lift, WP.spec_ok] at hs
exact hs
have hi17val : i17.val = power.val + (u : Int) - l.val := by as_aux_lemma =>
have hs := IScalar.sub_equiv i15 (UScalar.hcast .I32 l)
rw [hi17] at hs
omega
have hi18eq : i18 = (-1022)#i32 := by as_aux_lemma =>
have hc := hmin
have htotal' := htotal
dsimp only [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64] at hc
dsimp only [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64] at htotal'
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.BITS.eq_def,
htotal'] at hc
simp only [bind_tc_ok, lift] at hc
have hh := hc.symm.trans hi18
exact (Result.ok.inj hh).symm
have hi19val : i19.val = power.val + (u : Int) - l.val + 1022 := by as_aux_lemma =>
have hs := IScalar.sub_equiv i17 i18
rw [hi19, hi18eq] at hs
norm_num at hs
omega
have hpval : p.val = power.val + (u : Int) - l.val + 1023 := by as_aux_lemma =>
have hs := IScalar.add_equiv i19 1#i32
rw [hp] at hs
norm_num at hs
omega
have hpformula : p.val = q.val + e + (u : Int) - l.val + 1086 := by as_aux_lemma =>
dsimp only [e]
rw [hpval, hpowerVal]
omega
let x : Real := (w.val : Real) * (10 : Real) ^ q.val
let k : Int := q.val + e - (l.val : Int) - 63
have hx : x = R * (2 : Real) ^ k := by as_aux_lemma =>
dsimp only [x, R, T, k]
rw [hWval]
push_cast
rw [show (10 : Real) = 2 * 5 by norm_num, mul_zpow]
rw [show (2 : Real) ^ (l.val : Nat) =
(2 : Real) ^ (l.val : Int) by rw [zpow_natCast]]
rw [show (2 : Real) ^ (64 : Nat) =
(2 : Real) ^ (64 : Int) by rfl]
rw [div_eq_mul_inv, ← zpow_neg]
have hpow : (2 : Real) ^ (l.val : Int) * (2 : Real) ^ (127 - e) *
(2 : Real) ^ (-64 : Int) * (2 : Real) ^
(q.val + e - (l.val : Int) - 63) = (2 : Real) ^ q.val := by
rw [← zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
rw [← zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
rw [← zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
congr 1
ring
rw [← hpow]
ring
have hk : (73 : Int) + (u : Int) + k = p.val - 1076 := by as_aux_lemma =>
dsimp only [k]
rw [hpformula]
omega
dsimp only at htableFacts
have hTlo : (2 : Real) ^ (127 : Nat) ≤ T := htableFacts.1.1
have hThi : T < (2 : Real) ^ (128 : Nat) := htableFacts.1.2
have hWlowerR : (2 : Real) ^ (63 : Nat) ≤ (W.val : Real) := by
exact_mod_cast hWlower
have hWupperR : (W.val : Real) < (2 : Real) ^ (64 : Nat) := by
exact_mod_cast W.bv.isLt
have hRlower : (2 : Real) ^ (126 : Nat) ≤ R := by as_aux_lemma =>
have hm : (2 : Real) ^ (63 : Nat) * (2 : Real) ^ (127 : Nat) ≤
(W.val : Real) * T :=
mul_le_mul hWlowerR hTlo (by positivity) (by positivity)
dsimp only [R]
calc
(2 : Real) ^ (126 : Nat) =
((2 : Real) ^ (63 : Nat) * (2 : Real) ^ (127 : Nat)) /
(2 : Real) ^ (64 : Nat) := by
rw [show 126 = 63 + 63 by omega, show 127 = 63 + 64 by omega,
pow_add, pow_add]
field_simp
_ ≤ (W.val : Real) * T / (2 : Real) ^ (64 : Nat) :=
(div_le_div_iff_of_pos_right (by positivity)).2 hm
have hRupper : R < (2 : Real) ^ (128 : Nat) := by as_aux_lemma =>
have hm : (W.val : Real) * T <
(2 : Real) ^ (64 : Nat) * (2 : Real) ^ (128 : Nat) :=
mul_lt_mul hWupperR hThi.le (by positivity) (by positivity)
dsimp only [R]
calc
(W.val : Real) * T / (2 : Real) ^ (64 : Nat) <
((2 : Real) ^ (64 : Nat) * (2 : Real) ^ (128 : Nat)) /
(2 : Real) ^ (64 : Nat) :=
(div_lt_div_iff_of_pos_right (by positivity)).2 hm
_ = (2 : Real) ^ (128 : Nat) := by field_simp
have hcellLo : (G : Real) * (2 : Real) ^ (73 + u) ≤ R :=
happrox.2.2.1
have hcellHi : R < ((G + 1 : Nat) : Real) * (2 : Real) ^ (73 + u) :=
happrox.2.2.2.1
have hscalePos : 0 < (2 : Real) ^ k := zpow_pos (by norm_num) _
have hscaleEq : (2 : Real) ^ (73 + u : Nat) * (2 : Real) ^ k =
(2 : Real) ^ (p.val - 1076) := by as_aux_lemma =>
rw [← zpow_natCast, ← zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
congr 1
have hxcellLo : (G : Real) * (2 : Real) ^ (p.val - 1076) ≤ x := by as_aux_lemma =>
calc
(G : Real) * (2 : Real) ^ (p.val - 1076) =
((G : Real) * (2 : Real) ^ (73 + u : Nat)) *
(2 : Real) ^ k := by rw [← hscaleEq]; ring
_ ≤ R * (2 : Real) ^ k := mul_le_mul_of_nonneg_right hcellLo hscalePos.le
_ = x := hx.symm
have hxcellHi : x < ((G + 1 : Nat) : Real) *
(2 : Real) ^ (p.val - 1076) := by as_aux_lemma =>
calc
x = R * (2 : Real) ^ k := hx
_ < (((G + 1 : Nat) : Real) * (2 : Real) ^ (73 + u : Nat)) *
(2 : Real) ^ k := mul_lt_mul_of_pos_right hcellHi hscalePos
_ = ((G + 1 : Nat) : Real) * (2 : Real) ^ (p.val - 1076) := by
rw [← hscaleEq]
ring
have hxLowerEq :
x = (G : Real) * (2 : Real) ^ (p.val - 1076) ↔
R = (G : Real) * (2 : Real) ^ (73 + u : Nat) := by as_aux_lemma =>
rw [hx, ← hscaleEq]
constructor
· intro heq
apply mul_right_cancel₀ hscalePos.ne'
simpa only [mul_assoc] using heq
· intro heq
rw [heq]
ring
have htie :
(x = (G : Real) * (2 : Real) ^ (p.val - 1076) ∧ G % 4 = 1) ↔
(-4 ≤ q.val ∧ q.val ≤ 23 ∧ G % 4 = 1 ∧
lo.val ≤ 1 ∧ G * 2 ^ (9 + u) = hi.val) := by as_aux_lemma =>
rw [hxLowerEq]
exact happrox.2.2.2.2
have hpLower : -114 ≤ p.val := by
dsimp only [e] at hpformula
omega
have hpUpper : p.val ≤ 2110 := by
dsimp only [e] at hpformula
omega
have hGLower : 2 ^ 53 ≤ G := by as_aux_lemma =>
rcases (Nat.le_one_iff_eq_zero_or_eq_one.mp hu) with hu0 | hu1
· have hstrict : (2 : Real) ^ (126 : Nat) <
((G + 1 : Nat) : Real) * (2 : Real) ^ (73 : Nat) := by
exact hRlower.trans_lt (by simpa only [hu0, Nat.add_zero] using hcellHi)
have hpEq : (2 : Real) ^ (126 : Nat) =
(2 : Real) ^ (53 : Nat) * (2 : Real) ^ (73 : Nat) := by
rw [← pow_add]
rw [hpEq, Nat.cast_add, Nat.cast_one] at hstrict
have hc : (2 : Real) ^ (53 : Nat) < (G : Real) + 1 := by
nlinarith [show 0 < (2 : Real) ^ (73 : Nat) by positivity]
have hn : 2 ^ 53 < G + 1 := by exact_mod_cast hc
omega
· have hu1' : 1 ≤ hi.val / 2 ^ 63 := by simpa only [u] using hu1.ge
have hhi : 2 ^ 63 ≤ hi.val := by
have := (Nat.le_div_iff_mul_le (by positivity : 0 < 2 ^ 63)).mp hu1'
simpa only [one_mul] using this
dsimp only [G]
rw [hu1]
apply (Nat.le_div_iff_mul_le (by positivity : 0 < 2 ^ (9 + 1))).2
norm_num at hhi ⊢
exact hhi
have hGUpper : G < 2 ^ 54 := by as_aux_lemma =>
rcases (Nat.le_one_iff_eq_zero_or_eq_one.mp hu) with hu0 | hu1
· have hhi : hi.val < 2 ^ 63 := by
apply Nat.lt_of_div_eq_zero (by positivity : 0 < 2 ^ 63)
simpa only [u] using hu0
dsimp only [G]
rw [hu0]
apply (Nat.div_lt_iff_lt_mul (by positivity : 0 < 2 ^ (9 + 0))).2
norm_num at hhi ⊢
exact hhi
· have hhi : hi.val < 2 ^ 64 := hi.bv.isLt
dsimp only [G]
rw [hu1]
apply (Nat.div_lt_iff_lt_mul (by positivity : 0 < 2 ^ (9 + 1))).2
norm_num at hhi ⊢
exact hhi
have andOne (z : Std.U64) : (z &&& 1#u64).val = z.val % 2 := by as_aux_lemma =>
change (z.bv &&& 1#64).toNat = z.bv.toNat % 2
rw [show (1#64) = 2#64 ^ 1 - 1#64 by decide,
BitVec.and_two_pow_sub_one_eq_mod]
simp
have andThree (z : Std.U64) : (z &&& 3#u64).val = z.val % 4 := by as_aux_lemma =>
change (z.bv &&& 3#64).toNat = z.bv.toNat % 4
rw [show (3#64) = 2#64 ^ 2 - 1#64 by decide,
BitVec.and_two_pow_sub_one_eq_mod]
simp
have clearLow (z : Std.U64) (hz : z.val % 2 = 1) :
(z &&& ~~~1#u64).val = z.val - 1 := by as_aux_lemma =>
have clearNat (n : Nat) (hn : n < 2 ^ 64) :
n &&& (2 ^ 64 - 2) = n - n % 2 := by
have hn2 : n / 2 < 2 ^ 63 := by
apply (Nat.div_lt_iff_lt_mul (by omega)).2
norm_num at hn ⊢
exact hn
conv_lhs =>
rw [← Nat.bit_bodd_div2 n]
rw [show 2 ^ 64 - 2 = Nat.bit false (2 ^ 63 - 1) by simp [Nat.bit]]
rw [Nat.land_bit]
simp only [Bool.and_false, Nat.bit_false]
rw [Nat.and_two_pow_sub_one_eq_mod, Nat.div2_val,
Nat.mod_eq_of_lt hn2]
have hd := Nat.div_add_mod n 2
omega
change (z.bv &&& ~~~(1#64)).toNat = z.bv.toNat - 1
rw [BitVec.toNat_and, BitVec.toNat_not, BitVec.toNat_ofNat]
norm_num
have hc := clearNat z.bv.toNat z.bv.isLt
norm_num at hc
rw [hc]
omega
let unit : Nat := 2 ^ 52
let expBits : Nat :=
((fp.p_biased.val.emod (2 ^ 64)).toNat * (2 ^ 52)) % (2 ^ 64)
let target : F64 := ⟨fp.m.bv ||| BitVec.ofNat 64 expBits⟩
have htargetAssembly :
DecimalGoalVocabularyDefault.assembledWord fp target := by
dsimp only [DecimalGoalVocabularyDefault, target, expBits]
change (fp.m.bv ||| BitVec.ofNat 64
((fp.p_biased.val.emod (2 ^ 64)).toNat * 2 ^ 52 % 2 ^ 64)).toNat = _
rw [BitVec.toNat_or, BitVec.toNat_ofNat]
simp only [Nat.mod_mod]
rfl
refine ⟨target, htargetAssembly, ?_⟩
by_cases hp0 : p ≤ 0#i32
· simp only [hp0, if_true] at hrun
exact P861_T1_IntegerSubnormalRounds q w G64 p G fp target
hw hqlo hpLower hp0 hGval hGUpper hxcellLo hxcellHi
htargetAssembly hrun
· as_aux_lemma =>
let adjustRun : Result Std.U64 :=
if lo ≤ 1#u64 then
if q ≥ IScalar.cast .I64 (-4)#i32 then
if q ≤ IScalar.cast .I64 23#i32 then
if G64 &&& 3#u64 = 1#u64 then do
let i26 ← i9 - UScalar.hcast .I32 52#u32
let i27 ← i26 - 3#i32
let i28 ← G64 <<< i27
if i28 = hi then ok (G64 &&& ~~~1#u64) else ok G64
else ok G64
else ok G64
else ok G64
else ok G64
let carryRun (S64 twoU : Std.U64) : Result (Std.U64 × Std.I32) :=
if S64 ≥ twoU then do
let mantissa5 ← 1#u64 <<< 52#u32
let power22 ← p + 1#i32
ok (mantissa5, power22)
else ok (S64, p)
have hposInv : ∃ (Gc Ga S64 twoU Sf : Std.U64) (pf : Std.I32)
(oneU : Std.U64),
adjustRun = ok Gc ∧ Gc + (Gc &&& 1#u64) = ok Ga ∧
Ga >>> 1#i32 = ok S64 ∧ 2#u64 <<< 52#u32 = ok twoU ∧
carryRun S64 twoU = ok (Sf, pf) ∧
1#u64 <<< 52#u32 = ok oneU ∧
(if pf ≥ 2047#i32 then
ok { m := 0#u64, p_biased := 2047#i32 }
else ok { m := Sf &&& ~~~oneU, p_biased := pf }) = ok fp := by
as_aux_lemma =>
have hr := hrun
simp only [hp0, if_false] at hr
rw [F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.MIN_EXPONENT_ROUND_TO_EVEN.eq_def,
F64.Insts.Dec2flt_modelNumImpTraitsFloatU64.MAX_EXPONENT_ROUND_TO_EVEN.eq_def] at hr
change (do
let Gc ← adjustRun
let Ga ← Gc + (Gc &&& 1#u64)
let S64 ← Ga >>> 1#i32
let twoU ← 2#u64 <<< 52#u32
let pair ← carryRun S64 twoU
let (Sf, pf) := pair
let oneU ← 1#u64 <<< 52#u32
if pf ≥ 2047#i32 then
ok { m := 0#u64, p_biased := 2047#i32 }
else ok { m := Sf &&& ~~~oneU, p_biased := pf }) = ok fp at hr
obtain ⟨Gc, hGc, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨Ga, hGa, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨S64, hS64, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨twoU, htwoU, hr⟩ := bind_ok_inv _ _ _ hr
obtain ⟨pair, hcarry, hr⟩ := bind_ok_inv _ _ _ hr
rcases pair with ⟨Sf, pf⟩
simp only [Aeneas.Std.uncurry_apply_pair] at hr
obtain ⟨oneU, honeU, hr⟩ := bind_ok_inv _ _ _ hr
exact ⟨Gc, Ga, S64, twoU, Sf, pf, oneU, hGc, hGa, hS64,
htwoU, hcarry, honeU, hr⟩
rcases hposInv with ⟨Gc, Ga, S64, twoU, Sf, pf, oneU, hGc, hGa,
hS64, htwoU, hcarry, honeU, hfinal⟩
dsimp only [adjustRun] at hGc
dsimp only [carryRun] at hcarry
have hcastNeg4 : IScalar.cast .I64 (-4)#i32 = (-4)#i64 := rfl
have hcast23 : IScalar.cast .I64 23#i32 = 23#i64 := rfl
have hshiftWP := UScalar.ShiftLeft_IScalar_spec G64 i12 (2 ^ 64)
(by change 0 ≤ i12.val; rw [hi12val]; omega) (by
change i12.val < 64
rw [hi12val]
omega)
(by norm_num [U64.size_eq])
obtain ⟨H, hH, hHspec⟩ := Aeneas.Std.WP.spec_imp_exists hshiftWP
have hGshiftBound : G * 2 ^ (9 + u) < 2 ^ 64 := by
interval_cases u <;> norm_num at hGUpper ⊢ <;> omega
have hHval : H.val = G * 2 ^ (9 + u) := by
have hb : G * 2 ^ (9 + u) < 18446744073709551616 := by
norm_num at hGshiftBound ⊢
exact hGshiftBound
have hv : H.val = (G * 2 ^ (9 + u)) % 18446744073709551616 := by
simpa only [hGval, hi12nat, Nat.shiftLeft_eq] using hHspec.1
rw [Nat.mod_eq_of_lt hb] at hv
exact hv
have hshiftIff : H = hi ↔ G * 2 ^ (9 + u) = hi.val := by as_aux_lemma =>
constructor
· intro heq
rw [← hHval, heq]
· intro heq
apply UScalar.eq_of_val_eq
omega
have hmodIff : G64 &&& 3#u64 = 1#u64 ↔ G % 4 = 1 := by as_aux_lemma =>
constructor
· intro heq
have := congrArg UScalar.val heq
rw [andThree, hGval] at this
norm_num at this
exact this
· intro heq
apply UScalar.eq_of_val_eq
rw [andThree, hGval]
norm_num
exact heq
let tieLow : Prop :=
x = (G : Real) * (2 : Real) ^ (p.val - 1076) ∧ G % 4 = 1
let codeTie : Prop :=
lo ≤ 1#u64 ∧ q ≥ (-4)#i64 ∧ q ≤ 23#i64 ∧
G64 &&& 3#u64 = 1#u64 ∧ H = hi
have hcodeTie : codeTie ↔ tieLow := by as_aux_lemma =>
dsimp only [codeTie, tieLow]
constructor
· intro hc
apply htie.mpr
refine ⟨?_, ?_, hmodIff.mp hc.2.2.2.1, ?_, hshiftIff.mp hc.2.2.2.2⟩
· simpa only [IScalar.le_equiv] using hc.2.1
· simpa only [IScalar.le_equiv] using hc.2.2.1
· simpa only [UScalar.le_equiv] using hc.1
· intro ht
have hc := htie.mp ht
refine ⟨?_, ?_, ?_, hmodIff.mpr hc.2.2.1, hshiftIff.mpr hc.2.2.2.2⟩
· simpa only [UScalar.le_equiv] using hc.2.2.2.1
· simpa only [IScalar.le_equiv] using hc.1
· simpa only [IScalar.le_equiv] using hc.2.1
rw [hcastNeg4, hcast23, hi11] at hGc
simp only [bind_tc_ok] at hGc
rw [hi12] at hGc
simp only [bind_tc_ok] at hGc
rw [hH] at hGc
simp only [bind_tc_ok] at hGc
have hGcEq : Gc = if codeTie then G64 &&& ~~~1#u64 else G64 := by as_aux_lemma =>
dsimp only [codeTie]
by_cases c1 : lo ≤ 1#u64 <;>
by_cases c2 : q ≥ (-4)#i64 <;>
by_cases c3 : q ≤ 23#i64 <;>
by_cases c4 : G64 &&& 3#u64 = 1#u64 <;>
by_cases c5 : H = hi <;>
simp only [c1, c2, c3, c4, c5, if_true, if_false,
and_true, and_false] at hGc ⊢ <;>
exact (Result.ok.inj hGc).symm
have hGcval : Gc.val = if tieLow then G - 1 else G := by as_aux_lemma =>
by_cases ht : tieLow
· have hc := hcodeTie.mpr ht
rw [if_pos ht, hGcEq, if_pos hc]
rw [clearLow, hGval]
· dsimp only [tieLow] at ht
omega
· have hc : ¬ codeTie := fun h => ht (hcodeTie.mp h)
rw [if_neg ht, hGcEq, if_neg hc, hGval]
have hGaVal : Ga.val = Gc.val + Gc.val % 2 := by
have hs := UScalar.add_equiv Gc (Gc &&& 1#u64)
rw [hGa] at hs
rw [andOne] at hs
exact hs.2.1
have hSspec := UScalar.ShiftRight_IScalar_spec Ga (1#i32)
(by norm_num) (by norm_num)
rw [hS64] at hSspec
have hSval : S64.val = (Gc.val + Gc.val % 2) / 2 := by
have hv := hSspec.1
rw [hGaVal] at hv
simpa [Nat.shiftRight_eq_div_pow] using hv
let lowSig : Nat := G / 2
let chooseHigh : Prop := G % 2 = 1 ∧ ¬ tieLow
have hSchoice : S64.val = if chooseHigh then lowSig + 1 else lowSig := by as_aux_lemma =>
dsimp only [chooseHigh, lowSig]
by_cases ht : tieLow
· rw [if_pos ht] at hGcval
have htmod : G % 4 = 1 := by simpa only [tieLow] using ht.2
have hmod2 : G % 2 = 1 := by omega
rw [if_neg (by simp [ht])]
rw [hSval, hGcval]
omega
· rw [if_neg ht] at hGcval
by_cases hodd : G % 2 = 1
· rw [if_pos (by exact ⟨hodd, ht⟩)]
rw [hSval, hGcval]
omega
· rw [if_neg (by simp [hodd])]
rw [hSval, hGcval]
have hm := Nat.mod_lt G (by omega : 0 < 2)
omega
have hLowSigLower : 2 ^ 52 ≤ lowSig := by
dsimp only [lowSig]
apply (Nat.le_div_iff_mul_le (by omega : 0 < 2)).2
norm_num at hGLower ⊢
exact hGLower
have hLowSigUpper : lowSig < 2 ^ 53 := by
dsimp only [lowSig]
apply (Nat.div_lt_iff_lt_mul (by omega : 0 < 2)).2
norm_num at hGUpper ⊢
exact hGUpper
have hSBounds : 2 ^ 52 ≤ S64.val ∧ S64.val ≤ 2 ^ 53 := by
rw [hSchoice]
split <;> omega
have htwoUSpec := UScalar.ShiftLeft_spec (2#u64) (52#u32) (2 ^ 64)
(by norm_num) (by norm_num [U64.size_eq])
rw [htwoU] at htwoUSpec
have htwoUval : twoU.val = 2 ^ 53 := by
norm_num [WP.spec_ok, Nat.shiftLeft_eq] at htwoUSpec ⊢
exact htwoUSpec.1
have honeUSpec := UScalar.ShiftLeft_spec (1#u64) (52#u32) (2 ^ 64)
(by norm_num) (by norm_num [U64.size_eq])
rw [honeU] at honeUSpec
have honeUval : oneU.val = 2 ^ 52 := by
norm_num [WP.spec_ok, Nat.shiftLeft_eq] at honeUSpec ⊢
exact honeUSpec.1
have hcarryIff : S64 ≥ twoU ↔ S64.val = 2 ^ 53 := by
change twoU.val ≤ S64.val ↔ S64.val = 2 ^ 53
rw [htwoUval]
omega
have hSfPf :
(S64.val = 2 ^ 53 ∧ Sf = oneU ∧ pf.val = p.val + 1) ∨
(S64.val < 2 ^ 53 ∧ Sf = S64 ∧ pf = p) := by as_aux_lemma =>
by_cases hc : S64 ≥ twoU
· have hceq := hcarryIff.mp hc
simp only [hc, if_true, honeU, bind_tc_ok] at hcarry
obtain ⟨pnext, hpnext, hpair⟩ := bind_ok_inv _ _ _ hcarry
have hpnextVal : pnext.val = p.val + 1 := by
have hs := IScalar.add_equiv p 1#i32
rw [hpnext] at hs
exact hs.2.1
have heq := Result.ok.inj hpair
cases heq
exact Or.inl ⟨hceq, rfl, hpnextVal⟩
· simp only [hc, if_false] at hcarry
have heq := Result.ok.inj hcarry
have hclt : S64.val < 2 ^ 53 := by
have hc' : ¬ twoU.val ≤ S64.val := by
simpa only [UScalar.le_equiv] using hc
rw [htwoUval] at hc'
omega
exact Or.inr ⟨hclt, (congrArg Prod.fst heq).symm,
(congrArg Prod.snd heq).symm⟩
have hpPos : 0 < p.val := by
have hn : ¬ p.val ≤ 0 := by simpa only [IScalar.le_equiv] using hp0
omega
let pNat : Nat := p.val.toNat
have hpNatCast : (pNat : Int) = p.val := by
dsimp only [pNat]
exact Int.toNat_of_nonneg hpPos.le
let deltaR : Real := (2 : Real) ^ (p.val - 1076)
let ulpR : Real := (2 : Real) ^ (p.val - 1075)
have hdeltaPos : 0 < deltaR := by
dsimp only [deltaR]
exact zpow_pos (by norm_num) _
have hulpEq : ulpR = 2 * deltaR := by
dsimp only [ulpR, deltaR]
rw [show p.val - 1075 = (p.val - 1076) + 1 by omega,
zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
norm_num
ring
have hGdecomp : G = 2 * lowSig + G % 2 := by
dsimp only [lowSig]
have hd := Nat.mod_add_div G 2
omega
have hrem2 : G % 2 ≤ 1 := Nat.le_pred_of_lt (Nat.mod_lt _ (by omega))
have hxcellLo' : (G : Real) * deltaR ≤ x := by
simpa only [deltaR] using hxcellLo
have hxcellHi' : x < ((G + 1 : Nat) : Real) * deltaR := by
simpa only [deltaR] using hxcellHi
have hLowX : (lowSig : Real) * ulpR ≤ x := by
have hc : ((2 * lowSig : Nat) : Real) * deltaR ≤
(G : Real) * deltaR := by
apply mul_le_mul_of_nonneg_right _ hdeltaPos.le
exact_mod_cast (by omega : 2 * lowSig ≤ G)
rw [hulpEq]
push_cast at hc ⊢
linarith only [hc, hxcellLo']
have hXHigh : x ≤ ((lowSig + 1 : Nat) : Real) * ulpR := by
have hc : ((G + 1 : Nat) : Real) * deltaR ≤
((2 * (lowSig + 1) : Nat) : Real) * deltaR := by
apply mul_le_mul_of_nonneg_right _ hdeltaPos.le
exact_mod_cast (by omega : G + 1 ≤ 2 * (lowSig + 1))
calc
x ≤ ((G + 1 : Nat) : Real) * deltaR := hxcellHi'.le
_ ≤ ((2 * (lowSig + 1) : Nat) : Real) * deltaR := hc
_ = ((lowSig + 1 : Nat) : Real) * ulpR := by
rw [hulpEq]
push_cast
ring
have hLowNear (hc : ¬ chooseHigh) :
abs (x - (lowSig : Real) * ulpR) ≤
abs (x - ((lowSig + 1 : Nat) : Real) * ulpR) := by as_aux_lemma =>
rw [abs_of_nonneg (sub_nonneg.mpr hLowX),
abs_of_nonpos (sub_nonpos.mpr hXHigh)]
dsimp only [chooseHigh] at hc
by_cases ht : tieLow
· have hteq := ht.1
dsimp only [tieLow] at ht
rw [hteq]
rw [hulpEq]
push_cast
have hg : (G : Real) = 2 * (lowSig : Real) + 1 := by
exact_mod_cast (show G = 2 * lowSig + 1 by omega)
nlinarith only [hdeltaPos, hg]
· have heven : G % 2 = 0 := by
have hnotOdd : G % 2 ≠ 1 := by
intro hodd
exact hc ⟨hodd, ht⟩
have hm : G % 2 < 2 := Nat.mod_lt G (by omega)
have hmle : G % 2 ≤ 1 := Nat.lt_succ_iff.mp hm
apply Nat.eq_zero_of_not_pos
intro hpos
exact hnotOdd (Nat.le_antisymm hmle hpos)
have hmid : x < ((2 * lowSig + 1 : Nat) : Real) * deltaR := by
have hnext : G + 1 = 2 * lowSig + 1 := by omega
simpa only [hnext] using hxcellHi'
rw [hulpEq]
push_cast at hmid ⊢
nlinarith only [hmid, hdeltaPos]
have hHighNear (hc : chooseHigh) :
abs (x - ((lowSig + 1 : Nat) : Real) * ulpR) ≤
abs (x - (lowSig : Real) * ulpR) := by as_aux_lemma =>
rw [abs_of_nonpos (sub_nonpos.mpr hXHigh),
abs_of_nonneg (sub_nonneg.mpr hLowX)]
have hodd : G % 2 = 1 := hc.1
have hmid : ((2 * lowSig + 1 : Nat) : Real) * deltaR ≤ x := by
have hg : G = 2 * lowSig + 1 := by omega
simpa only [hg] using hxcellLo'
rw [hulpEq]
push_cast at hmid ⊢
nlinarith only [hmid, hdeltaPos]
let lowBits : Nat := pNat * unit + (lowSig - unit)
let selectedBits : Nat := if chooseHigh then lowBits + 1 else lowBits
have hlowParity : lowBits % 2 = lowSig % 2 := by
dsimp only [lowBits, unit]
omega
have hTieLowEven (hc : ¬ chooseHigh)
(heq : abs (x - (lowSig : Real) * ulpR) =
abs (x - ((lowSig + 1 : Nat) : Real) * ulpR)) :
lowBits % 2 = 0 := by as_aux_lemma =>
rw [abs_of_nonneg (sub_nonneg.mpr hLowX),
abs_of_nonpos (sub_nonpos.mpr hXHigh)] at heq
have hmid : x = ((2 * lowSig + 1 : Nat) : Real) * deltaR := by
rw [hulpEq] at heq
push_cast at heq ⊢
nlinarith only [heq, hdeltaPos]
have hgOdd : G % 2 = 1 := by
by_contra hn
have hm := Nat.mod_lt G (by omega : 0 < 2)
have hge : G + 1 = 2 * lowSig + 1 := by omega
have := hxcellHi'
rw [hge, hmid] at this
exact (lt_irrefl _ this)
have ht : tieLow := by
dsimp only [tieLow]
have hG : G = 2 * lowSig + 1 := by omega
refine ⟨?_, ?_⟩
· simpa only [hG] using hmid
· dsimp only [chooseHigh] at hc
have hnot : ¬ (G % 2 = 1 ∧ ¬tieLow) := hc
by_contra hm4
have hm4lt := Nat.mod_lt G (by omega : 0 < 4)
have hnTie : ¬ tieLow := by
intro hyes
exact hm4 hyes.2
exact hnot ⟨hgOdd, hnTie⟩
have hm4 := ht.2
rw [hlowParity]
omega
have hTieHighEven (hc : chooseHigh)
(heq : abs (x - ((lowSig + 1 : Nat) : Real) * ulpR) =
abs (x - (lowSig : Real) * ulpR)) :
(lowBits + 1) % 2 = 0 := by as_aux_lemma =>
rw [abs_of_nonpos (sub_nonpos.mpr hXHigh),
abs_of_nonneg (sub_nonneg.mpr hLowX)] at heq
have hmid : x = ((2 * lowSig + 1 : Nat) : Real) * deltaR := by
rw [hulpEq] at heq
push_cast at heq ⊢
nlinarith only [heq, hdeltaPos]
have hodd := hc.1
have hG : G = 2 * lowSig + 1 := by omega
have hnotTie := hc.2
have hnotMod : G % 4 ≠ 1 := by
intro hm
apply hnotTie
dsimp only [tieLow]
exact ⟨by simpa only [hG] using hmid, hm⟩
have hm4lt := Nat.mod_lt G (by omega : 0 < 4)
rw [Nat.add_mod, hlowParity]
omega
have hxpos : 0 < x := by
dsimp only [x]
exact mul_pos (by exact_mod_cast hw) (zpow_pos (by norm_num) _)
exact P873_T1_IntegerNormalRounds x G p S64 Sf oneU pf fp target
hxpos hpPos hGLower hGUpper honeUval hSfPf htargetAssembly hfinal
hSchoice hxcellLo' hxcellHi' hLowX hXHigh hLowNear hHighNear
hTieLowEven hTieHighEven
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Uses
- Binary64AdjacentNormalValues
- Binary64EncoderCarryArithmetic
- Binary64FiniteMagnitudeStrictMono
- Binary64NormalEncoderRounds
- DecimalGoalVocabularyDefault
- F64
All 15 entries
- Binary64AdjacentNormalValues
- Binary64EncoderCarryArithmetic
- Binary64FiniteMagnitudeStrictMono
- Binary64NormalEncoderRounds
- DecimalGoalVocabularyDefault
- F64
- IntegerPowerTableCertificate
- IntegerProductApproximation
- ModelU64BitAnd
- ModelU64BitOr
- ModelU64Shl
- IntegerSubnormalRounds
- IntegerNormalRounds
- ParserExponentConstants
- num imp dec2flt lemire compute float
Used by
Inspect related source (87)
- compute_float · dec2flt/lemire.rs:26 Program Rust
- Dec2flt_modelNumImpTraitsFloatU64 · traits.rs:309 Program Rust
- BITS · traits.rs:319 Program Rust
More program dependencies (45)
- 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
- SIG_TOTAL_BITS · traits.rs:320 Program Rust
- SMALLEST_POWER_OF_TEN · traits.rs:328 Program Rust
- BiasedFp · dec2flt/common.rs:56 Program Rust
- zero_pow2 · dec2flt/common.rs:66 Program Rust
- compute_product_approx · dec2flt/lemire.rs:134 Program Rust
- full_multiplication · dec2flt/lemire.rs:126 Program Rust
- power · dec2flt/lemire.rs:121 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
- 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
- from_u64 · dec2flt/mod.rs:263 Program Rust
- EXP_MASK · traits.rs:321 Program Rust
- INFINITY · traits.rs:312 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
- classify · traits.rs:334 Program Rust
- to_bits · traits.rs:330 Program Rust
- Dec2flt_modelNumImpTraitsInt · traits.rs:51 Program Rust
- FloatErrorKind · num/mod.rs:18 Program Rust
- ParseFloatError · num/mod.rs:13 Program Rust
- Dec2FltAssemblyTrace · dec2flt/mod.rs:329 Program Rust
- Dec2FltTrace · dec2flt/mod.rs:295 Program Rust
- Lemire · dec2flt/mod.rs:115 Program Rust
- ByteSlice · dec2flt/common.rs:4 Program Rust
- Decimal · dec2flt/decimal.rs:32 Program Rust
- DecimalSeq · dec2flt/decimal_seq.rs:22 Program Rust
- CastInto · traits.rs:18 Program Rust
- FloatExt · traits.rs:170 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
- cast · traits.rs:46 Program Rust
Standard-library dependencies (39)
- 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
- MANTISSA_DIGITS · core/src/num/f64.rs:412 Rust library
- clone · core/src/clone.rs:698 Rust library
- div · core/src/ops/arith.rs:515 Rust library
- mul · core/src/ops/arith.rs:350 Rust library
- neg · core/src/ops/arith.rs:719 Rust library
- 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
- 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
- CoreMarkerCopy · core/src/marker.rs:57 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
- FpCategory · core/src/num/mod.rs:1522 Rust library
- Div · core/src/ops/arith.rs:460 Rust library
- Mul · core/src/ops/arith.rs:322 Rust library
- Neg · core/src/ops/arith.rs:690 Rust library
- BitOr · core/src/ops/bit.rs:254 Rust library
- Shl · core/src/ops/bit.rs:461 Rust library
- Shr · core/src/ops/bit.rs:584 Rust library
- 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
- Binary64AdjacentNormalValues
- Binary64FiniteMagnitudeStrictMono
- Binary64Model
- Binary64ModelDefault
- DecimalGoalVocabulary
- DecimalGoalVocabularyDefault
All 95 entries
- Binary64AdjacentNormalValues
- Binary64FiniteMagnitudeStrictMono
- Binary64Model
- Binary64ModelDefault
- DecimalGoalVocabulary
- DecimalGoalVocabularyDefault
- DecimalLexeme
- F64
- F64 Insts CoreCloneClone
- F64 Insts CoreMarkerCopy
- F64 Insts CoreOpsArithDivF64F64
- F64 Insts CoreOpsArithMulF64F64
- F64 Insts CoreOpsArithNegF64
- 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
- IntegerCoreRounding
- IntegerPowerFiniteCertificate
- IntegerPowerRealBridge
- IntegerPowerTableCertificate
- IntegerProductApproximation
- ModelF64Classify
- ModelF64Clone
- ModelF64Div
- ModelF64ExponentMask
- ModelF64FromBits
- ModelF64FromU64
- ModelF64Infinity
- ModelF64MantissaDigits
- ModelF64MantissaMask
- ModelF64Mul
- ModelF64Nan
- ModelF64Neg
- ModelF64NegInfinity
- ModelF64ToBits
- ModelOptionBranch
- ModelOptionFromResidual
- ModelSliceFirst
- ModelSliceSplitFirst
- ModelStrAsBytes
- ModelU64BitAnd
- ModelU64BitOr
- ModelU64Shl
- ModelU64Shr
- ModelU8IsAsciiDigit
- IntegerSubnormalRounds
- IntegerNormalRounds
- ParserExponentConstants
- 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 common BiasedFp
- num imp dec2flt common BiasedFp zero pow2
- num imp dec2flt decimal Decimal
- num imp dec2flt lemire compute float
- num imp dec2flt lemire compute product approx
- num imp dec2flt lemire full multiplication
- num imp dec2flt lemire power
- num imp dec2flt table LARGEST POWER OF FIVE
- num imp dec2flt table POWER OF FIVE 128
- num imp dec2flt table SMALLEST POWER OF FIVE
- num imp traits CastInto
- num imp traits Float
- 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": "IntegerCoreRounding",
"closure_version": "patch_c_v1",
"active_decl_hash": "363059395a81d94d22bc6b2891978b3de191d17665ad844765ad819ae4b35ef3",
"active_statement_hash": "5511328d628dcc58c470e1c6366a75e76588e748f032f86469c7af1d2bf07e8a",
"kernel_axioms": [
"Classical.choice",
"Quot.sound",
"propext"
],
"toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
"lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
"checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
"approved_axioms_hash": "576e6bf9480cfd32f53c309c7ac8fb115c1ba6e413f299ed5ff9fa7c647e6769",
"axcheck_status": "Agreed",
"accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-202",
"boundary_theorems": {},
"strict_theorem_deps": {
"Binary64ModelDefault": "c722a2c00805b545",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS": "cfedcf26d6dae341",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_LARGEST_POWER_OF_TEN": "2532cbe447dc07c7",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MAX_EXPONENT_ROUND_TO_EVEN": "00627f5fdfb01b16",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MIN_EXPONENT_ROUND_TO_EVEN": "4b74105a95f2b02f",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SMALLEST_POWER_OF_TEN": "8a9e3dfa7e9aa5ec",
"IntegerPowerTableCertificate": "c4b148e6d8bda215",
"IntegerProductApproximation": "b8e44e7cccbfad60",
"P861_T1_IntegerSubnormalRounds": "0eba22dc03105b0a",
"P873_T1_IntegerNormalRounds": "4b983d7044a57313",
"ParserExponentConstants": "ef5e21eed09ecd9a",
"num_imp_dec2flt_lemire_compute_float": "7539bc2a998f5c1c",
"num_imp_traits_Float_EXP_BIAS_default": "39417be39e20ce5d",
"num_imp_traits_Float_EXP_BITS_default": "9ab622d85ef04d94",
"num_imp_traits_Float_EXP_MIN_default": "39417be39e20ce5d",
"num_imp_traits_Float_EXP_SAT_default": "9ab622d85ef04d94",
"num_imp_traits_Float_SIG_BITS_default": "9ab622d85ef04d94"
},
"strict_definition_deps": {
"Binary64Model": "c98c2c511cf0ced6",
"Binary64ModelDefault": "dc548d1e27696ba4",
"DecimalGoalVocabulary": "f76c8174a4d58eb5",
"DecimalGoalVocabularyDefault": "71a18a6c119a3cdc",
"F64": "ec4e25fbaf4e11d4",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64": "94095c9bf79da164",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS": "d9fd91641cb78c5e",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_LARGEST_POWER_OF_TEN": "e23324c94fa5d1b5",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MAX_EXPONENT_ROUND_TO_EVEN": "3dbd3f15a918cb2c",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_MIN_EXPONENT_ROUND_TO_EVEN": "e508b987ade7bf71",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS": "887b52d84a3fc9c4",
"F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SMALLEST_POWER_OF_TEN": "0c461c0c4f5aa880",
"Preamble": "1f712bede6a5dae6",
"core_num_FpCategory": "f500de642a5d5148",
"num_imp_dec2flt_common_BiasedFp": "5c88d5d7976c5e8f",
"num_imp_dec2flt_common_BiasedFp_zero_pow2": "0f99ae12c6707137",
"num_imp_dec2flt_lemire_compute_float": "39d89e3f0a8a9d4c",
"num_imp_dec2flt_lemire_compute_product_approx": "af91b9cbef7779f3",
"num_imp_dec2flt_lemire_power": "56b7c3bd69ca3c6a",
"num_imp_dec2flt_table_POWER_OF_FIVE_128": "bdd28e83b60fa362",
"num_imp_traits_Float": "4442e69083aa891d"
}
}Prose assessment
{
"label": "Recorded Sound: Pass",
"assessment_status": "Pass",
"fingerprint_relation": "unknown",
"assessment_fingerprint": null,
"current_fingerprint": "sound-v2:8f7acb7ef074f83e333cea081c8c91fd952150be75a64f00073a3bdcae6f40b5",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"sound_status": "Pass",
"substantiveness_status": "Pass"
}