IntegerPowerRealBridge

Lean checked

Statement

This explanation was written alongside the formalization to describe the statement and its reasoning.

Helper · Integer-to-real normalization bridge

Let q,e\in\mathbb Z and D,b\in\mathbb N. Suppose the following exact integer certificate is available. For q=-n<0, with z=-e, suppose n,z\ge1, 2^{z-1}<5^n<2^z, and the directed cross-product bounds
D5^n\le2^{z+127}<(D+1)5^n\quad(q<-27),
and
(D-1)5^n<2^{z+127}<D5^n\quad(-27\le q<0)
hold. For q\ge0, suppose e\ge0, 2^e\le5^q<2^{e+1}, D=5^q2^{127-e} when e\le127, and the corresponding floor cross-products hold when e>127. Also suppose the exact formula holds for q\le55, that b=0 for q\le23, and that q\le55 implies e\le127.
Then, for T=2^{127-e}5^q, one has 2^{127}\le T<2^{128}, the stated negative representation T=2^{z+127}/5^n, both small-range exactness conclusions, and
D\le T<D+1\quad(q<-27\text{ or }q\ge0),\qquad D-1<T<D\quad(-27\le q<0).

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

For q=-n<0, the equality e=-z rewrites the definition directly as T=2^{z+127}/5^n. Positivity of 5^n permits cross multiplication. The upper consecutive-power inequality 5^n<2^z, multiplied by 2^{127}, gives 2^{127}\le T; the lower inequality 2^{z-1}<5^n, multiplied by 2^{128}, gives T<2^{128}. The two assumed cross-product pairs similarly divide by positive 5^n to give the two directed intervals. In the near-negative case the strict upper cross-product forces D\ge1, so the natural subtraction D-1 agrees with subtraction after casting to the reals.
For q\ge0, put k=e. If k\le127, then T=2^{127-k}5^q. Multiplying 2^k\le5^q<2^{k+1} by the positive factor 2^{127-k} gives 2^{127}\le T<2^{128}. The assumed exact formula makes T=D, which also yields D\le T<D+1. If k>127, put s=k-127; then T=5^q/2^s. Dividing the consecutive-power inequalities by 2^s again gives the normalization interval, while the assumed floor cross-products give D\le T<D+1. When 0\le q\le55, the extra hypothesis gives e\le127, so casting the exact natural-number formula proves D=T. The b=0 conclusion is exactly the remaining small-range hypothesis. All divisions used above have strictly positive power denominators, so each cross multiplication preserves the stated strict or weak inequality.

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.

Explore this dependency tree

Inspect related source (44)
More program dependencies (11)
Standard-library dependencies (30)

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

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": "ab64d13f256386ee0e494a5abcc6a5db49512cf3d90bbdfcabd6327793a31f95",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-145",
  "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"
}