Statement
This explanation was written alongside the formalization to describe the statement and its reasoning.
Helper · Integer-to-real normalization bridge
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
set_option autoImplicit false
set_option maxRecDepth 65536
namespace dec2flt_model
-- [TABLET NODE: IntegerPowerRealBridge]
theorem IntegerPowerRealBridge (q e : Int) (D b : Nat)
(hneg : q < 0 →
let n := (-q).toNat
let z := (-e).toNat
q = -(n : Int) ∧ 1 ≤ n ∧ 1 ≤ z ∧
2 ^ (z - 1) < 5 ^ n ∧ 5 ^ n < 2 ^ z ∧ e = -(z : Int) ∧
(q < -27 → D * 5 ^ n ≤ 2 ^ (z + 127) ∧
2 ^ (z + 127) < (D + 1) * 5 ^ n) ∧
(-27 ≤ q → (D - 1) * 5 ^ n < 2 ^ (z + 127) ∧
2 ^ (z + 127) < D * 5 ^ n))
(hnonneg : 0 ≤ q →
0 ≤ e ∧
2 ^ e.toNat ≤ 5 ^ q.toNat ∧ 5 ^ q.toNat < 2 ^ (e.toNat + 1) ∧
(e ≤ 127 → D = 5 ^ q.toNat * 2 ^ (127 - e).toNat) ∧
(127 < e → D * 2 ^ (e - 127).toNat ≤ 5 ^ q.toNat ∧
5 ^ q.toNat < (D + 1) * 2 ^ (e - 127).toNat) ∧
(q ≤ 55 → D = 5 ^ q.toNat * 2 ^ (127 - e).toNat) ∧
(q ≤ 23 → b = 0))
(hsmallE : q ≤ 55 → e ≤ 127) :
let T : Real := (2 : Real) ^ (127 - e) * (5 : Real) ^ q
(((2 : Real) ^ (127 : Nat) ≤ T ∧ T < (2 : Real) ^ (128 : Nat)) ∧
(q < 0 →
∃ n z : Nat,
q = -(n : Int) ∧ 1 ≤ n ∧ 1 ≤ z ∧
(2 : Nat) ^ (z - 1) < 5 ^ n ∧ 5 ^ n < 2 ^ z ∧
e = -(z : Int) ∧ T = (2 : Real) ^ (z + 127) / (5 : Real) ^ n) ∧
((0 ≤ q ∧ q ≤ 55) → (D : Real) = T) ∧
((0 ≤ q ∧ q ≤ 23) → b = 0) ∧
((q < -27 ∨ 0 ≤ q) → (D : Real) ≤ T ∧ T < (D : Real) + 1) ∧
((-27 ≤ q ∧ q < 0) → (D : Real) - 1 < T ∧ T < D)) := by
Proof
Natural-language proof
The status above describes the Lean proof. Its explanatory prose may remain a sketch after that proof closes.
Explanatory prose status
Prose retained as authored. The explanatory prose is preserved as it stood when captured.
Proof
Lean proof
dsimp only
have hnorm :
(2 : Real) ^ (127 : Nat) ≤
(2 : Real) ^ (127 - e) * (5 : Real) ^ q ∧
(2 : Real) ^ (127 - e) * (5 : Real) ^ q <
(2 : Real) ^ (128 : Nat) := by
by_cases hqneg : q < 0
· obtain ⟨hqn, hnpos, hzpos, h2z, h5z, he, hfar, hnear⟩ := hneg hqneg
let n : Nat := (-q).toNat
let z : Nat := (-e).toNat
have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(2 : Real) ^ (z + 127) / (5 : Real) ^ n := by
have heExp : 127 - e = ((z + 127 : Nat) : Int) := by
dsimp only [z]
omega
rw [heExp, hqn, zpow_natCast, zpow_neg, zpow_natCast]
rfl
rw [hT]
have hden : 0 < (5 : Real) ^ n := by positivity
constructor
· apply (le_div_iff₀ hden).2
rw [show z + 127 = z + 127 by rfl, pow_add]
have h5zR : (5 : Real) ^ n ≤ (2 : Real) ^ z := by
exact_mod_cast (Nat.le_of_lt h5z)
nlinarith [pow_pos (by norm_num : (0 : Real) < 2) 127]
· apply (div_lt_iff₀ hden).2
rw [show z + 127 = (z - 1) + 128 by omega, pow_add]
have h2zR : (2 : Real) ^ (z - 1) < (5 : Real) ^ n := by
exact_mod_cast h2z
nlinarith [pow_pos (by norm_num : (0 : Real) < 2) 128]
· have hqnonneg : 0 ≤ q := by omega
obtain ⟨he0, h2e, h5e, hExact, hFloor, hSmall, hbSmall⟩ := hnonneg hqnonneg
let m : Nat := q.toNat
let k : Nat := e.toNat
have hqm : q = (m : Int) := by
dsimp only [m]
omega
have h2eR : (2 : Real) ^ k ≤ (5 : Real) ^ m := by exact_mod_cast h2e
have h5eR : (5 : Real) ^ m < (2 : Real) ^ (k + 1) := by exact_mod_cast h5e
by_cases he127 : e ≤ 127
· have hk127 : k ≤ 127 := by omega
have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(2 : Real) ^ (127 - k) * (5 : Real) ^ m := by
have heExp : 127 - e = (((127 - k : Nat) : Nat) : Int) := by omega
rw [heExp, hqm, zpow_natCast, zpow_natCast]
rw [hT]
constructor
· calc
(2 : Real) ^ (127 : Nat) =
(2 : Real) ^ (127 - k) * (2 : Real) ^ k := by
rw [← pow_add]
congr 1
omega
_ ≤ (2 : Real) ^ (127 - k) * (5 : Real) ^ m :=
mul_le_mul_of_nonneg_left h2eR (by positivity)
· calc
(2 : Real) ^ (127 - k) * (5 : Real) ^ m <
(2 : Real) ^ (127 - k) * (2 : Real) ^ (k + 1) :=
mul_lt_mul_of_pos_left h5eR (by positivity)
_ = (2 : Real) ^ (128 : Nat) := by
rw [← pow_add]
congr 1
omega
· have hegt : 127 < e := by omega
let s : Nat := (e - 127).toNat
have hks : k = 127 + s := by
dsimp only [k, s]
omega
have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(5 : Real) ^ m / (2 : Real) ^ s := by
have heExp : 127 - e = -(s : Int) := by
dsimp only [s]
omega
rw [heExp, hqm, zpow_neg, zpow_natCast, zpow_natCast]
simp [div_eq_mul_inv, mul_comm]
rw [hT]
have hden : 0 < (2 : Real) ^ s := by positivity
constructor
· apply (le_div_iff₀ hden).2
calc
(2 : Real) ^ (127 : Nat) * (2 : Real) ^ s =
(2 : Real) ^ k := by rw [← pow_add, hks]
_ ≤ (5 : Real) ^ m := h2eR
· apply (div_lt_iff₀ hden).2
calc
(5 : Real) ^ m < (2 : Real) ^ (k + 1) := h5eR
_ = (2 : Real) ^ (128 : Nat) * (2 : Real) ^ s := by
rw [← pow_add, hks]
congr 1
omega
refine ⟨hnorm, ?_, ?_, ?_, ?_, ?_⟩
· intro hqneg
obtain ⟨hqn, hnpos, hzpos, h2z, h5z, he, hfar, hnear⟩ := hneg hqneg
let n : Nat := (-q).toNat
let z : Nat := (-e).toNat
refine ⟨n, z, hqn, hnpos, hzpos, h2z, h5z, he, ?_⟩
have heExp : 127 - e = ((z + 127 : Nat) : Int) := by
dsimp only [z]
omega
rw [heExp, hqn, zpow_natCast, zpow_neg, zpow_natCast]
rfl
· rintro ⟨hqnonneg, hq55⟩
obtain ⟨he0, h2e, h5e, hExact, hFloor, hSmall, hbSmall⟩ := hnonneg hqnonneg
have he127 : e ≤ 127 := hsmallE hq55
let m : Nat := q.toNat
let k : Nat := e.toNat
have hqm : q = (m : Int) := by
dsimp only [m]
omega
have hek : e = (k : Int) := by
dsimp only [k]
omega
have hqToNat : q.toNat = m := rfl
have hsub : (127 - e).toNat = 127 - k := by omega
have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(2 : Real) ^ (127 - k) * (5 : Real) ^ m := by
have heExp : 127 - e = (((127 - k : Nat) : Nat) : Int) := by omega
rw [heExp, hqm, zpow_natCast, zpow_natCast]
rw [hT, hSmall hq55, hqToNat, hsub]
simp only [Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat]
ring
· rintro ⟨hqnonneg, hq23⟩
exact (hnonneg hqnonneg).2.2.2.2.2.2 hq23
· intro hside
rcases hside with hqfar | hqnonneg
· obtain ⟨hqn, hnpos, hzpos, h2z, h5z, he, hfar, hnear⟩ := hneg (by omega)
let n : Nat := (-q).toNat
let z : Nat := (-e).toNat
have hcross := hfar hqfar
have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(2 : Real) ^ (z + 127) / (5 : Real) ^ n := by
have heExp : 127 - e = ((z + 127 : Nat) : Int) := by
dsimp only [z]
omega
rw [heExp, hqn, zpow_natCast, zpow_neg, zpow_natCast]
rfl
rw [hT]
have hden : 0 < (5 : Real) ^ n := by positivity
constructor
· apply (le_div_iff₀ hden).2
exact_mod_cast hcross.1
· apply (div_lt_iff₀ hden).2
exact_mod_cast hcross.2
· obtain ⟨he0, h2e, h5e, hExact, hFloor, hSmall, hbSmall⟩ := hnonneg hqnonneg
let m : Nat := q.toNat
let k : Nat := e.toNat
have hqm : q = (m : Int) := by
dsimp only [m]
omega
have hek : e = (k : Int) := by
dsimp only [k]
omega
by_cases he127 : e ≤ 127
· have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(2 : Real) ^ (127 - k) * (5 : Real) ^ m := by
have heExp : 127 - e = (((127 - k : Nat) : Nat) : Int) := by omega
rw [heExp, hqm, zpow_natCast, zpow_natCast]
have hD := hExact he127
have hqToNat : q.toNat = m := rfl
have hsub : (127 - e).toNat = 127 - k := by omega
have hDR : (D : Real) =
(5 : Real) ^ m * (2 : Real) ^ (127 - k) := by
rw [hD, hqToNat, hsub]
simp only [Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat]
rw [hT, hDR]
constructor
· rw [mul_comm ((5 : Real) ^ m) ((2 : Real) ^ (127 - k))]
· nlinarith
· have hegt : 127 < e := by omega
let s : Nat := (e - 127).toNat
have hcross := hFloor hegt
have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(5 : Real) ^ m / (2 : Real) ^ s := by
have heExp : 127 - e = -(s : Int) := by
dsimp only [s]
omega
rw [heExp, hqm, zpow_neg, zpow_natCast, zpow_natCast]
simp [div_eq_mul_inv, mul_comm]
rw [hT]
have hden : 0 < (2 : Real) ^ s := by positivity
constructor
· apply (le_div_iff₀ hden).2
exact_mod_cast hcross.1
· apply (div_lt_iff₀ hden).2
exact_mod_cast hcross.2
· rintro ⟨hqnear, hqneg⟩
obtain ⟨hqn, hnpos, hzpos, h2z, h5z, he, hfar, hnear⟩ := hneg hqneg
let n : Nat := (-q).toNat
let z : Nat := (-e).toNat
have hcross := hnear hqnear
have hDpos : 1 ≤ D := by
by_contra hnot
have hDzero : D = 0 := by omega
rw [hDzero] at hcross
simp at hcross
have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(2 : Real) ^ (z + 127) / (5 : Real) ^ n := by
have heExp : 127 - e = ((z + 127 : Nat) : Int) := by
dsimp only [z]
omega
rw [heExp, hqn, zpow_natCast, zpow_neg, zpow_natCast]
rfl
rw [hT]
have hden : 0 < (5 : Real) ^ n := by positivity
constructor
· apply (lt_div_iff₀ hden).2
have hlowR : (((D - 1) * 5 ^ n : Nat) : Real) <
((2 ^ (z + 127) : Nat) : Real) :=
(Nat.cast_lt (α := Real)).2 hcross.1
simpa only [Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat,
Nat.cast_one, Nat.cast_sub hDpos] using hlowR
· apply (div_lt_iff₀ hden).2
have huppR : ((2 ^ (z + 127) : Nat) : Real) <
((D * 5 ^ n : Nat) : Real) :=
(Nat.cast_lt (α := Real)).2 hcross.2
simpa only [Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] using huppR
end dec2flt_model
Download Lean source · Download TeX source
Complete Lean module
import Tablet.DecimalGoalVocabularyDefault
set_option autoImplicit false
set_option maxRecDepth 65536
namespace dec2flt_model
-- [TABLET NODE: IntegerPowerRealBridge]
theorem IntegerPowerRealBridge (q e : Int) (D b : Nat)
(hneg : q < 0 →
let n := (-q).toNat
let z := (-e).toNat
q = -(n : Int) ∧ 1 ≤ n ∧ 1 ≤ z ∧
2 ^ (z - 1) < 5 ^ n ∧ 5 ^ n < 2 ^ z ∧ e = -(z : Int) ∧
(q < -27 → D * 5 ^ n ≤ 2 ^ (z + 127) ∧
2 ^ (z + 127) < (D + 1) * 5 ^ n) ∧
(-27 ≤ q → (D - 1) * 5 ^ n < 2 ^ (z + 127) ∧
2 ^ (z + 127) < D * 5 ^ n))
(hnonneg : 0 ≤ q →
0 ≤ e ∧
2 ^ e.toNat ≤ 5 ^ q.toNat ∧ 5 ^ q.toNat < 2 ^ (e.toNat + 1) ∧
(e ≤ 127 → D = 5 ^ q.toNat * 2 ^ (127 - e).toNat) ∧
(127 < e → D * 2 ^ (e - 127).toNat ≤ 5 ^ q.toNat ∧
5 ^ q.toNat < (D + 1) * 2 ^ (e - 127).toNat) ∧
(q ≤ 55 → D = 5 ^ q.toNat * 2 ^ (127 - e).toNat) ∧
(q ≤ 23 → b = 0))
(hsmallE : q ≤ 55 → e ≤ 127) :
let T : Real := (2 : Real) ^ (127 - e) * (5 : Real) ^ q
(((2 : Real) ^ (127 : Nat) ≤ T ∧ T < (2 : Real) ^ (128 : Nat)) ∧
(q < 0 →
∃ n z : Nat,
q = -(n : Int) ∧ 1 ≤ n ∧ 1 ≤ z ∧
(2 : Nat) ^ (z - 1) < 5 ^ n ∧ 5 ^ n < 2 ^ z ∧
e = -(z : Int) ∧ T = (2 : Real) ^ (z + 127) / (5 : Real) ^ n) ∧
((0 ≤ q ∧ q ≤ 55) → (D : Real) = T) ∧
((0 ≤ q ∧ q ≤ 23) → b = 0) ∧
((q < -27 ∨ 0 ≤ q) → (D : Real) ≤ T ∧ T < (D : Real) + 1) ∧
((-27 ≤ q ∧ q < 0) → (D : Real) - 1 < T ∧ T < D)) := by
-- BODY
dsimp only
have hnorm :
(2 : Real) ^ (127 : Nat) ≤
(2 : Real) ^ (127 - e) * (5 : Real) ^ q ∧
(2 : Real) ^ (127 - e) * (5 : Real) ^ q <
(2 : Real) ^ (128 : Nat) := by
by_cases hqneg : q < 0
· obtain ⟨hqn, hnpos, hzpos, h2z, h5z, he, hfar, hnear⟩ := hneg hqneg
let n : Nat := (-q).toNat
let z : Nat := (-e).toNat
have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(2 : Real) ^ (z + 127) / (5 : Real) ^ n := by
have heExp : 127 - e = ((z + 127 : Nat) : Int) := by
dsimp only [z]
omega
rw [heExp, hqn, zpow_natCast, zpow_neg, zpow_natCast]
rfl
rw [hT]
have hden : 0 < (5 : Real) ^ n := by positivity
constructor
· apply (le_div_iff₀ hden).2
rw [show z + 127 = z + 127 by rfl, pow_add]
have h5zR : (5 : Real) ^ n ≤ (2 : Real) ^ z := by
exact_mod_cast (Nat.le_of_lt h5z)
nlinarith [pow_pos (by norm_num : (0 : Real) < 2) 127]
· apply (div_lt_iff₀ hden).2
rw [show z + 127 = (z - 1) + 128 by omega, pow_add]
have h2zR : (2 : Real) ^ (z - 1) < (5 : Real) ^ n := by
exact_mod_cast h2z
nlinarith [pow_pos (by norm_num : (0 : Real) < 2) 128]
· have hqnonneg : 0 ≤ q := by omega
obtain ⟨he0, h2e, h5e, hExact, hFloor, hSmall, hbSmall⟩ := hnonneg hqnonneg
let m : Nat := q.toNat
let k : Nat := e.toNat
have hqm : q = (m : Int) := by
dsimp only [m]
omega
have h2eR : (2 : Real) ^ k ≤ (5 : Real) ^ m := by exact_mod_cast h2e
have h5eR : (5 : Real) ^ m < (2 : Real) ^ (k + 1) := by exact_mod_cast h5e
by_cases he127 : e ≤ 127
· have hk127 : k ≤ 127 := by omega
have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(2 : Real) ^ (127 - k) * (5 : Real) ^ m := by
have heExp : 127 - e = (((127 - k : Nat) : Nat) : Int) := by omega
rw [heExp, hqm, zpow_natCast, zpow_natCast]
rw [hT]
constructor
· calc
(2 : Real) ^ (127 : Nat) =
(2 : Real) ^ (127 - k) * (2 : Real) ^ k := by
rw [← pow_add]
congr 1
omega
_ ≤ (2 : Real) ^ (127 - k) * (5 : Real) ^ m :=
mul_le_mul_of_nonneg_left h2eR (by positivity)
· calc
(2 : Real) ^ (127 - k) * (5 : Real) ^ m <
(2 : Real) ^ (127 - k) * (2 : Real) ^ (k + 1) :=
mul_lt_mul_of_pos_left h5eR (by positivity)
_ = (2 : Real) ^ (128 : Nat) := by
rw [← pow_add]
congr 1
omega
· have hegt : 127 < e := by omega
let s : Nat := (e - 127).toNat
have hks : k = 127 + s := by
dsimp only [k, s]
omega
have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(5 : Real) ^ m / (2 : Real) ^ s := by
have heExp : 127 - e = -(s : Int) := by
dsimp only [s]
omega
rw [heExp, hqm, zpow_neg, zpow_natCast, zpow_natCast]
simp [div_eq_mul_inv, mul_comm]
rw [hT]
have hden : 0 < (2 : Real) ^ s := by positivity
constructor
· apply (le_div_iff₀ hden).2
calc
(2 : Real) ^ (127 : Nat) * (2 : Real) ^ s =
(2 : Real) ^ k := by rw [← pow_add, hks]
_ ≤ (5 : Real) ^ m := h2eR
· apply (div_lt_iff₀ hden).2
calc
(5 : Real) ^ m < (2 : Real) ^ (k + 1) := h5eR
_ = (2 : Real) ^ (128 : Nat) * (2 : Real) ^ s := by
rw [← pow_add, hks]
congr 1
omega
refine ⟨hnorm, ?_, ?_, ?_, ?_, ?_⟩
· intro hqneg
obtain ⟨hqn, hnpos, hzpos, h2z, h5z, he, hfar, hnear⟩ := hneg hqneg
let n : Nat := (-q).toNat
let z : Nat := (-e).toNat
refine ⟨n, z, hqn, hnpos, hzpos, h2z, h5z, he, ?_⟩
have heExp : 127 - e = ((z + 127 : Nat) : Int) := by
dsimp only [z]
omega
rw [heExp, hqn, zpow_natCast, zpow_neg, zpow_natCast]
rfl
· rintro ⟨hqnonneg, hq55⟩
obtain ⟨he0, h2e, h5e, hExact, hFloor, hSmall, hbSmall⟩ := hnonneg hqnonneg
have he127 : e ≤ 127 := hsmallE hq55
let m : Nat := q.toNat
let k : Nat := e.toNat
have hqm : q = (m : Int) := by
dsimp only [m]
omega
have hek : e = (k : Int) := by
dsimp only [k]
omega
have hqToNat : q.toNat = m := rfl
have hsub : (127 - e).toNat = 127 - k := by omega
have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(2 : Real) ^ (127 - k) * (5 : Real) ^ m := by
have heExp : 127 - e = (((127 - k : Nat) : Nat) : Int) := by omega
rw [heExp, hqm, zpow_natCast, zpow_natCast]
rw [hT, hSmall hq55, hqToNat, hsub]
simp only [Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat]
ring
· rintro ⟨hqnonneg, hq23⟩
exact (hnonneg hqnonneg).2.2.2.2.2.2 hq23
· intro hside
rcases hside with hqfar | hqnonneg
· obtain ⟨hqn, hnpos, hzpos, h2z, h5z, he, hfar, hnear⟩ := hneg (by omega)
let n : Nat := (-q).toNat
let z : Nat := (-e).toNat
have hcross := hfar hqfar
have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(2 : Real) ^ (z + 127) / (5 : Real) ^ n := by
have heExp : 127 - e = ((z + 127 : Nat) : Int) := by
dsimp only [z]
omega
rw [heExp, hqn, zpow_natCast, zpow_neg, zpow_natCast]
rfl
rw [hT]
have hden : 0 < (5 : Real) ^ n := by positivity
constructor
· apply (le_div_iff₀ hden).2
exact_mod_cast hcross.1
· apply (div_lt_iff₀ hden).2
exact_mod_cast hcross.2
· obtain ⟨he0, h2e, h5e, hExact, hFloor, hSmall, hbSmall⟩ := hnonneg hqnonneg
let m : Nat := q.toNat
let k : Nat := e.toNat
have hqm : q = (m : Int) := by
dsimp only [m]
omega
have hek : e = (k : Int) := by
dsimp only [k]
omega
by_cases he127 : e ≤ 127
· have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(2 : Real) ^ (127 - k) * (5 : Real) ^ m := by
have heExp : 127 - e = (((127 - k : Nat) : Nat) : Int) := by omega
rw [heExp, hqm, zpow_natCast, zpow_natCast]
have hD := hExact he127
have hqToNat : q.toNat = m := rfl
have hsub : (127 - e).toNat = 127 - k := by omega
have hDR : (D : Real) =
(5 : Real) ^ m * (2 : Real) ^ (127 - k) := by
rw [hD, hqToNat, hsub]
simp only [Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat]
rw [hT, hDR]
constructor
· rw [mul_comm ((5 : Real) ^ m) ((2 : Real) ^ (127 - k))]
· nlinarith
· have hegt : 127 < e := by omega
let s : Nat := (e - 127).toNat
have hcross := hFloor hegt
have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(5 : Real) ^ m / (2 : Real) ^ s := by
have heExp : 127 - e = -(s : Int) := by
dsimp only [s]
omega
rw [heExp, hqm, zpow_neg, zpow_natCast, zpow_natCast]
simp [div_eq_mul_inv, mul_comm]
rw [hT]
have hden : 0 < (2 : Real) ^ s := by positivity
constructor
· apply (le_div_iff₀ hden).2
exact_mod_cast hcross.1
· apply (div_lt_iff₀ hden).2
exact_mod_cast hcross.2
· rintro ⟨hqnear, hqneg⟩
obtain ⟨hqn, hnpos, hzpos, h2z, h5z, he, hfar, hnear⟩ := hneg hqneg
let n : Nat := (-q).toNat
let z : Nat := (-e).toNat
have hcross := hnear hqnear
have hDpos : 1 ≤ D := by
by_contra hnot
have hDzero : D = 0 := by omega
rw [hDzero] at hcross
simp at hcross
have hT : (2 : Real) ^ (127 - e) * (5 : Real) ^ q =
(2 : Real) ^ (z + 127) / (5 : Real) ^ n := by
have heExp : 127 - e = ((z + 127 : Nat) : Int) := by
dsimp only [z]
omega
rw [heExp, hqn, zpow_natCast, zpow_neg, zpow_natCast]
rfl
rw [hT]
have hden : 0 < (5 : Real) ^ n := by positivity
constructor
· apply (lt_div_iff₀ hden).2
have hlowR : (((D - 1) * 5 ^ n : Nat) : Real) <
((2 ^ (z + 127) : Nat) : Real) :=
(Nat.cast_lt (α := Real)).2 hcross.1
simpa only [Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat,
Nat.cast_one, Nat.cast_sub hDpos] using hlowR
· apply (div_lt_iff₀ hden).2
have huppR : ((2 ^ (z + 127) : Nat) : Real) <
((D * 5 ^ n : Nat) : Real) :=
(Nat.cast_lt (α := Real)).2 hcross.2
simpa only [Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] using huppR
end dec2flt_model
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Inspect related source (44)
- BiasedFp · dec2flt/common.rs:56 Program Rust
- Decimal · dec2flt/decimal.rs:32 Program Rust
- from_u64 · dec2flt/mod.rs:263 Program Rust
More program dependencies (11)
- 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
- DecimalSeq · dec2flt/decimal_seq.rs:22 Program Rust
- CastInto · traits.rs:18 Program Rust
- Float · traits.rs:74 Program Rust
- FloatExt · traits.rs:170 Program Rust
- Int · traits.rs:27 Program Rust
Standard-library dependencies (30)
- clone · core/src/clone.rs:698 Rust library
- div · core/src/ops/arith.rs:515 Rust library
- mul · core/src/ops/arith.rs:350 Rust library
- neg · core/src/ops/arith.rs:719 Rust library
- bitand · core/src/ops/bit.rs:178 Rust library
- bitor · core/src/ops/bit.rs:282 Rust library
- shl · core/src/ops/bit.rs:489 Rust library
- shr · core/src/ops/bit.rs:612 Rust library
- EXPONENT_MASK · core/src/num/f64.rs:615 Rust library
- INFINITY · core/src/num/f64.rs:512 Rust library
- MANTISSA_DIGITS · core/src/num/f64.rs:412 Rust library
- MANTISSA_MASK · core/src/num/f64.rs:637 Rust library
- NAN · core/src/num/f64.rs:509 Rust library
- NEG_INFINITY · core/src/num/f64.rs:515 Rust library
- classify · core/src/num/f64.rs:782 Rust library
- from_bits · core/src/num/f64.rs:1269 Rust library
- to_bits · core/src/num/f64.rs:1223 Rust library
- is_ascii_digit · core/src/num/mod.rs:958 Rust library
- from_residual · core/src/option.rs:2793 Rust library
- branch · core/src/option.rs:2779 Rust library
- first · core/src/slice/mod.rs:155 Rust library
- split_first · core/src/slice/mod.rs:198 Rust library
- as_bytes · core/src/str/mod.rs:498 Rust library
- FpCategory · core/src/num/mod.rs:1522 Rust library
- Div · core/src/ops/arith.rs:460 Rust library
- Mul · core/src/ops/arith.rs:322 Rust library
- Neg · core/src/ops/arith.rs:690 Rust library
- BitOr · core/src/ops/bit.rs:254 Rust library
- Shl · core/src/ops/bit.rs:461 Rust library
- Shr · core/src/ops/bit.rs:584 Rust library
Related source and models come from the extraction records and declared dependencies.
Proof assumptions and review
Lean checks the formal proof. Trellis also reviews how the statement corresponds to the intended requirement.
Transitive assumptions
- Classical.choice
- Quot.sound
- propext
This list combines the assumptions recorded for this declaration and its dependencies. It may include assumptions used by auxiliary declarations in those modules.
Helper theorems included
Technical checking records
Local closure summary
{
"node": "IntegerPowerRealBridge",
"closure_version": "patch_c_v1",
"active_decl_hash": "99daa76b3867cd1b4bf93e97d4208ee2e0fc05884bb7d5810ace0217cc6970c7",
"active_statement_hash": "3dad85df05e3613817c56c42af4c517115e6864df44f301384ae0f6449614f69",
"kernel_axioms": [
"Classical.choice",
"Quot.sound",
"propext"
],
"toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
"lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
"checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
"approved_axioms_hash": "d5c04ffa333d9b33b238a527f5beaa2be82e021d3e9c0bbe01b1310280f7f55a",
"axcheck_status": "Agreed",
"accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-68",
"boundary_theorems": {},
"strict_theorem_deps": {},
"strict_definition_deps": {}
}Prose assessment
{
"label": "Lean proof closed; predictive prose review no longer required",
"assessment_status": null,
"fingerprint_relation": "unknown",
"assessment_fingerprint": null,
"current_fingerprint": "sound-v2:2c4ef1e8d2aa7141223a74280c9988f3b8398189f9e4ffa36d20ea16051f4037",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"substantiveness_status": "Pass"
}