P856_T1_ReachableCapacity

Lean checked

Statement

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

Lemma · Reachable 715-cell capacity

Let A<B be represented by the original canonical record d and its adjacent 768-cell upper endpoint, with -324\leq d.\mathit{point}<310. Follow the exact extracted loop-0 and loop-1 calls to (d_0,e_0) and (d_1,e_1), the successful checked decrement e_s=e_1-1, and the exact loop-2 call to (d_2,e_2). Then
0\leq e_2-e_0+715-d_0.\mathit{point}.

Lean statement

Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.

import Tablet.ParserSlowLoop0
import Tablet.ParserSlowLoop1
import Tablet.ParserSlowLoop2
import Tablet.ParserSlowReachableNormalizationBounds
import Tablet.P804_T1_DecimalValueBounds
import Tablet.P856_T1_Loop0NegativeExit
import Tablet.P856_T1_DecimalBinaryExponentBound
import Mathlib.Tactic.FieldSimp

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P856_T1_ReachableCapacity]
theorem P856_T1_ReachableCapacity
    (A B : Real)
    (d d0 d1 d2 : num.imp.dec2flt.decimal_seq.DecimalSeq)
    (exp0 exp1 expStart exp2 : Std.I32)
    (hpLo : -324 <= d.decimal_point.val)
    (hpHi : d.decimal_point.val < 310)
    (hB :
      let digits :=
        (d.digits.val.take d.num_digits.val).map (fun z => z.val)
      let integer : Nat := digits.foldl (fun n digit => 10 * n + digit) 0
      let value : Real := integer * (10 : Real) ^
        (d.decimal_point.val - (d.num_digits.val : Int))
      let cutoff : Real := (10 : Real) ^ (d.decimal_point.val - (768 : Int))
      B = value + cutoff)
    (hcanonical :
      let digits :=
        (d.digits.val.take d.num_digits.val).map (fun z => z.val)
      let integer : Nat := digits.foldl (fun n digit => 10 * n + digit) 0
      let value : Real := integer * (10 : Real) ^
        (d.decimal_point.val - (d.num_digits.val : Int))
      let cutoff : Real := (10 : Real) ^ (d.decimal_point.val - (768 : Int))
      d.num_digits.val <= 768 /\
      (forall z, z ∈ d.digits.val.take d.num_digits.val -> z.val < 10) /\
      (exists z zs, digits = z :: zs /\ 1 <= z /\ z < 10 /\
        digits.length = d.num_digits.val) /\
      (exists eta : Real,
        A = value + eta /\ 0 <= eta /\ eta < cutoff /\
        (d.truncated = true <-> 0 < eta)))
    (hloop0 :
      num.imp.dec2flt.slow.parse_long_mantissa_loop0
        F64.Insts.Dec2flt_modelNumImpTraitsFloatU64
        { m := 0#u64, p_biased := 0#i32 }
        d.num_digits d.decimal_point d.truncated d.digits 0#i32 none =
          ok (d0.num_digits, d0.decimal_point, d0.truncated, d0.digits,
            exp0, none))
    (hloop1 :
      num.imp.dec2flt.slow.parse_long_mantissa_loop1
        F64.Insts.Dec2flt_modelNumImpTraitsFloatU64
        { m := 0#u64, p_biased := 2047#i32 }
        d0.num_digits d0.decimal_point d0.truncated d0.digits exp0 none =
          ok (d1.num_digits, d1.decimal_point, d1.truncated, d1.digits,
            exp1, none))
    (hsub : exp1 - 1#i32 = ok expStart)
    (hloop2 :
      num.imp.dec2flt.slow.parse_long_mantissa_loop2
        F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 d1 expStart =
          ok (d2, exp2)) :
    0 <= exp2.val - exp0.val + 715 - d0.decimal_point.val := 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

Apply ParserSlowLoop0 to the original adjacent-cell package and identify its output with the supplied successful call. This gives -324\leq p_0:=d_0.\mathit{point}\leq0, e_0\geq0, the canonical shape and endpoint equations for d_0, and the lower bound on A. Apply ParserSlowLoop1 and identify its exact output, obtaining the point-zero normalized record d_1, its leading digit at least five, and its endpoint equations. Then ParserSlowReachableNormalizationBounds gives
B/2^{e_1}\leq1,qquad e_1\geq-1079.
Finally ParserSlowLoop2, with the supplied decrement and call identified by injectivity, gives
e_2=\max(e_1-1,-1022).
In particular e_2\geq-1022 and e_2\geq e_1-1.
Split at p_0=-307. If p_0\leq-307, then p_0<0, so Loop0NegativeExit applied to the same exact loop-0 history gives e_0=0. Therefore
e_2-e_0+715-p_0\geq-1022+715+307=0.
Suppose instead that -306\leq p_0\leq0. Write V_0 for the retained value of d_0. Its nonzero leading digit and decimal-digit bounds give, by DecimalValueBounds,
10^{p_0-1}\leq V_0.
The loop-0 endpoint equation has A/2^{e_0}=V_0+\eta_0 with \eta_0\geq0, hence V_0\leq A/2^{e_0}. The original adjacent-cell equations have a positive cutoff and an error strictly below it, so A<B. Also B/2^{e_1}\leq1 and positivity of powers of two imply B\leq2^{e_1}. Dividing these strict and weak inequalities by the positive 2^{e_0} gives
10^{p_0-1}\leq V_0\leq A/2^{e_0} <B/2^{e_0}\leq2^{e_1-e_0}.
Consequently DecimalBinaryExponentBound yields p_0\leq e_1-e_0+714. Combining this with e_1-1\leq e_2 gives p_0\leq e_2-e_0+715, which is the required inequality.

Lean proof


  dsimp only at hB hcanonical
  let Digits := fun q : num.imp.dec2flt.decimal_seq.DecimalSeq =>
    (q.digits.val.take q.num_digits.val).map (fun z => z.val)
  let Value := fun q : num.imp.dec2flt.decimal_seq.DecimalSeq =>
    ((Digits q).foldl (fun n digit => 10 * n + digit) 0 : Nat) *
      (10 : Real) ^ (q.decimal_point.val - (q.num_digits.val : Int))
  rcases hcanonical with ⟨hcap, hdigit, hpositive, hcanonicalA⟩
  rcases hpositive with ⟨z, zs, hzshape, hzLo, hzHi, hzlen⟩
  have hdne : d.num_digits.val != 0 := by
    have hpos : 0 < d.num_digits.val := by
      rw [← hzlen, hzshape]
      simp
    simpa [bne_iff_ne] using hpos.ne'
  have hcanonicalPack :
      d.num_digits.val <= 768 /\
      (forall q, q ∈ d.digits.val.take d.num_digits.val -> q.val < 10) /\
      (exists z zs, Digits d = z :: zs /\ 1 <= z /\ z < 10 /\
        (Digits d).length = d.num_digits.val) /\
      (exists eta : Real,
        A = Value d + eta /\ 0 <= eta /\
        eta < (10 : Real) ^ (d.decimal_point.val - (768 : Int)) /\
        (d.truncated = true <-> 0 < eta)) :=
    ⟨hcap, hdigit, ⟨z, zs, hzshape, hzLo, hzHi, hzlen⟩, hcanonicalA⟩
  have hspec0 := ParserSlowLoop0 A B d hdne hpLo hpHi hB
    (by simpa [Digits, Value] using hcanonicalPack)
  dsimp only at hspec0
  rcases hspec0 with ⟨q0, e0, steps0, hcall0, hsteps0, he0Lo,
    he0Hi, hALower, hp0Lo, hp0Hi, hselector0, hshape0⟩
  have htuple0 := Result.ok.inj (hcall0.symm.trans hloop0)
  have hq0 : q0 = d0 := by
    cases q0
    cases d0
    simp only [Prod.mk.injEq] at htuple0
    simp only [num.imp.dec2flt.decimal_seq.DecimalSeq.mk.injEq]
    tauto
  have he0 : e0 = exp0 := congrArg
    (fun x : Std.Usize × Std.I32 × Bool × Array Std.U8 768#usize ×
      Std.I32 × Option num.imp.dec2flt.common.BiasedFp => x.2.2.2.2.1)
    htuple0
  subst q0
  subst e0
  rcases hshape0 with ⟨hcap0, hdigit0, hpositive0, hend0⟩
  have hshape0Pack :
      d0.num_digits.val <= 768 /\
      (forall q, q ∈ d0.digits.val.take d0.num_digits.val -> q.val < 10) /\
      (exists z zs, Digits d0 = z :: zs /\ 1 <= z /\ z < 10 /\
        (Digits d0).length = d0.num_digits.val) :=
    ⟨hcap0, hdigit0, by simpa [Digits] using hpositive0⟩
  have hend0Pack :
      exists eta u : Real,
        A / (2 : Real) ^ exp0.val = Value d0 + eta /\
        B / (2 : Real) ^ exp0.val = Value d0 + u /\
        0 <= eta /\ eta < u /\ (d0.truncated = true <-> 0 < eta) := by
    simpa [Value, Digits] using hend0
  have hspec1 := ParserSlowLoop1 A B d0 exp0 hp0Lo hp0Hi he0Lo
    ⟨hcap0, hdigit0, hpositive0, hend0⟩
  dsimp only at hspec1
  rcases hspec1 with ⟨q1, e1, steps1, hcall1, hsteps1, he1Hi,
    hp1, hnum1, hlead1, hlead1Hi, hshape1⟩
  have htuple1 := Result.ok.inj (hcall1.symm.trans hloop1)
  have hq1 : q1 = d1 := by
    cases q1
    cases d1
    simp only [Prod.mk.injEq] at htuple1
    simp only [num.imp.dec2flt.decimal_seq.DecimalSeq.mk.injEq]
    tauto
  have he1 : e1 = exp1 := congrArg
    (fun x : Std.Usize × Std.I32 × Bool × Array Std.U8 768#usize ×
      Std.I32 × Option num.imp.dec2flt.common.BiasedFp => x.2.2.2.2.1)
    htuple1
  subst q1
  subst e1
  rcases hshape1 with ⟨hcap1, hdigit1, hpositive1, hend1⟩
  have hnorm := ParserSlowReachableNormalizationBounds A B d d0 d1 exp0 exp1
    hpLo hpHi hB (by simpa [Digits, Value] using hcanonicalPack) hALower
    hloop0 hloop1 hp1 hnum1 hlead1 (by simpa [Digits, Value] using hend1)
  have hspec2 := ParserSlowLoop2 A B d1 exp1 hnorm.2 hp1 hnum1 hlead1
    ⟨hcap1, hdigit1, hend1⟩
  dsimp only at hspec2
  rcases hspec2 with ⟨es, q2, e2, total, hsubS, hloop2S, htotal,
    hes, he2, htotalEq, hpoint2Lo, hnum2, hshape2⟩
  have hesEq : es = expStart := Result.ok.inj (hsubS.symm.trans hsub)
  subst es
  have hout2 := Result.ok.inj (hloop2S.symm.trans hloop2)
  have he2Eq : e2 = exp2 := congrArg Prod.snd hout2
  subst e2
  have hexp2Floor : -1022 <= exp2.val := by
    rw [he2]
    exact le_max_right _ _
  have hexp2Norm : exp1.val - 1 <= exp2.val := by
    rw [he2, hes]
    exact le_max_left _ _
  by_cases hlow : d0.decimal_point.val <= -307
  · have he0zero := P856_T1_Loop0NegativeExit A B d d0 0#i32 exp0
      hpLo hpHi (by exact ⟨hcap, hdigit,
        ⟨z, zs, hzshape, hzLo, hzHi, hzlen⟩⟩)
      (by
        rcases hcanonicalA with ⟨eta, hAeq, heta0, hetaCut, hsticky⟩
        refine ⟨eta, (10 : Real) ^ (d.decimal_point.val - 768), ?_, ?_,
          heta0, hetaCut, hsticky⟩
        · simpa [Value, Digits] using hAeq
        · simpa [Value, Digits] using hB)
      hloop0 (by omega)
    have he0val : exp0.val = 0 := by rw [he0zero]; norm_num
    omega
  · have hp0Ord : -306 <= d0.decimal_point.val := by omega
    rcases hpositive0 with ⟨z0, zs0, hzshape0, hz0Lo, hz0Hi, hzlen0⟩
    have hv0 := P804_T1_DecimalValueBounds (Digits d0) z0 zs0
      (by simpa [Digits] using hzshape0) hz0Lo (by
        intro w hw
        simp only [Digits, List.mem_map] at hw
        rcases hw with ⟨w8, hw8, rfl⟩
        exact hdigit0 w8 hw8) d0.decimal_point.val
    dsimp only at hv0
    rw [hzlen0] at hv0
    rcases hend0 with ⟨eta0, u0, hA0, hB0, heta0, heta0u0, hsticky0⟩
    have hAB : A < B := by
      rcases hcanonicalA with ⟨eta, hAeq, hetaLo, hetaHi, hsticky⟩
      have hcutPos : 0 < (10 : Real) ^ (d.decimal_point.val - 768) :=
        zpow_pos (by norm_num) _
      rw [hAeq, hB]
      linarith
    have hpow0Pos : 0 < (2 : Real) ^ exp0.val := zpow_pos (by norm_num) _
    have hpow1Pos : 0 < (2 : Real) ^ exp1.val := zpow_pos (by norm_num) _
    have hBpow : B <= (2 : Real) ^ exp1.val := by
      have hm := (div_le_iff₀ hpow1Pos).mp hnorm.1
      simpa using hm
    have hv0A : Value d0 <= A / (2 : Real) ^ exp0.val := by
      rw [hA0]
      linarith
    have hAdivB : A / (2 : Real) ^ exp0.val <
        B / (2 : Real) ^ exp0.val := by
      exact (div_lt_div_iff_of_pos_right hpow0Pos).2 hAB
    have hBdivPow : B / (2 : Real) ^ exp0.val <=
        (2 : Real) ^ (exp1.val - exp0.val) := by
      calc
        B / (2 : Real) ^ exp0.val <=
            (2 : Real) ^ exp1.val / (2 : Real) ^ exp0.val :=
          div_le_div_of_nonneg_right hBpow hpow0Pos.le
        _ = (2 : Real) ^ (exp1.val - exp0.val) := by
          rw [zpow_sub₀ (by norm_num : (2 : Real) ≠ 0)]
    have hdecimalBinary : (10 : Real) ^ (d0.decimal_point.val - 1) <
        (2 : Real) ^ (exp1.val - exp0.val) := by
      have hzReal : (1 : Real) <= z0 := by exact_mod_cast hz0Lo
      have hpow10Pos : 0 < (10 : Real) ^ (d0.decimal_point.val - 1) :=
        zpow_pos (by norm_num) _
      have hleadLower : (10 : Real) ^ (d0.decimal_point.val - 1) <=
          (z0 : Real) * (10 : Real) ^ (d0.decimal_point.val - 1) := by
        nlinarith
      have hv0Lower :
          (z0 : Real) * (10 : Real) ^ (d0.decimal_point.val - 1) <=
            Value d0 := by
        simpa [Value, Digits] using hv0.1
      exact lt_of_le_of_lt (hleadLower.trans (hv0Lower.trans hv0A))
        (hAdivB.trans_le hBdivPow)
    have hpBound := P856_T1_DecimalBinaryExponentBound
      d0.decimal_point.val (exp1.val - exp0.val) hp0Ord hp0Hi hdecimalBinary
    omega

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.ParserSlowLoop0
import Tablet.ParserSlowLoop1
import Tablet.ParserSlowLoop2
import Tablet.ParserSlowReachableNormalizationBounds
import Tablet.P804_T1_DecimalValueBounds
import Tablet.P856_T1_Loop0NegativeExit
import Tablet.P856_T1_DecimalBinaryExponentBound
import Mathlib.Tactic.FieldSimp

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P856_T1_ReachableCapacity]
theorem P856_T1_ReachableCapacity
    (A B : Real)
    (d d0 d1 d2 : num.imp.dec2flt.decimal_seq.DecimalSeq)
    (exp0 exp1 expStart exp2 : Std.I32)
    (hpLo : -324 <= d.decimal_point.val)
    (hpHi : d.decimal_point.val < 310)
    (hB :
      let digits :=
        (d.digits.val.take d.num_digits.val).map (fun z => z.val)
      let integer : Nat := digits.foldl (fun n digit => 10 * n + digit) 0
      let value : Real := integer * (10 : Real) ^
        (d.decimal_point.val - (d.num_digits.val : Int))
      let cutoff : Real := (10 : Real) ^ (d.decimal_point.val - (768 : Int))
      B = value + cutoff)
    (hcanonical :
      let digits :=
        (d.digits.val.take d.num_digits.val).map (fun z => z.val)
      let integer : Nat := digits.foldl (fun n digit => 10 * n + digit) 0
      let value : Real := integer * (10 : Real) ^
        (d.decimal_point.val - (d.num_digits.val : Int))
      let cutoff : Real := (10 : Real) ^ (d.decimal_point.val - (768 : Int))
      d.num_digits.val <= 768 /\
      (forall z, z ∈ d.digits.val.take d.num_digits.val -> z.val < 10) /\
      (exists z zs, digits = z :: zs /\ 1 <= z /\ z < 10 /\
        digits.length = d.num_digits.val) /\
      (exists eta : Real,
        A = value + eta /\ 0 <= eta /\ eta < cutoff /\
        (d.truncated = true <-> 0 < eta)))
    (hloop0 :
      num.imp.dec2flt.slow.parse_long_mantissa_loop0
        F64.Insts.Dec2flt_modelNumImpTraitsFloatU64
        { m := 0#u64, p_biased := 0#i32 }
        d.num_digits d.decimal_point d.truncated d.digits 0#i32 none =
          ok (d0.num_digits, d0.decimal_point, d0.truncated, d0.digits,
            exp0, none))
    (hloop1 :
      num.imp.dec2flt.slow.parse_long_mantissa_loop1
        F64.Insts.Dec2flt_modelNumImpTraitsFloatU64
        { m := 0#u64, p_biased := 2047#i32 }
        d0.num_digits d0.decimal_point d0.truncated d0.digits exp0 none =
          ok (d1.num_digits, d1.decimal_point, d1.truncated, d1.digits,
            exp1, none))
    (hsub : exp1 - 1#i32 = ok expStart)
    (hloop2 :
      num.imp.dec2flt.slow.parse_long_mantissa_loop2
        F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 d1 expStart =
          ok (d2, exp2)) :
    0 <= exp2.val - exp0.val + 715 - d0.decimal_point.val := by
-- BODY
  dsimp only at hB hcanonical
  let Digits := fun q : num.imp.dec2flt.decimal_seq.DecimalSeq =>
    (q.digits.val.take q.num_digits.val).map (fun z => z.val)
  let Value := fun q : num.imp.dec2flt.decimal_seq.DecimalSeq =>
    ((Digits q).foldl (fun n digit => 10 * n + digit) 0 : Nat) *
      (10 : Real) ^ (q.decimal_point.val - (q.num_digits.val : Int))
  rcases hcanonical with ⟨hcap, hdigit, hpositive, hcanonicalA⟩
  rcases hpositive with ⟨z, zs, hzshape, hzLo, hzHi, hzlen⟩
  have hdne : d.num_digits.val != 0 := by
    have hpos : 0 < d.num_digits.val := by
      rw [← hzlen, hzshape]
      simp
    simpa [bne_iff_ne] using hpos.ne'
  have hcanonicalPack :
      d.num_digits.val <= 768 /\
      (forall q, q ∈ d.digits.val.take d.num_digits.val -> q.val < 10) /\
      (exists z zs, Digits d = z :: zs /\ 1 <= z /\ z < 10 /\
        (Digits d).length = d.num_digits.val) /\
      (exists eta : Real,
        A = Value d + eta /\ 0 <= eta /\
        eta < (10 : Real) ^ (d.decimal_point.val - (768 : Int)) /\
        (d.truncated = true <-> 0 < eta)) :=
    ⟨hcap, hdigit, ⟨z, zs, hzshape, hzLo, hzHi, hzlen⟩, hcanonicalA⟩
  have hspec0 := ParserSlowLoop0 A B d hdne hpLo hpHi hB
    (by simpa [Digits, Value] using hcanonicalPack)
  dsimp only at hspec0
  rcases hspec0 with ⟨q0, e0, steps0, hcall0, hsteps0, he0Lo,
    he0Hi, hALower, hp0Lo, hp0Hi, hselector0, hshape0⟩
  have htuple0 := Result.ok.inj (hcall0.symm.trans hloop0)
  have hq0 : q0 = d0 := by
    cases q0
    cases d0
    simp only [Prod.mk.injEq] at htuple0
    simp only [num.imp.dec2flt.decimal_seq.DecimalSeq.mk.injEq]
    tauto
  have he0 : e0 = exp0 := congrArg
    (fun x : Std.Usize × Std.I32 × Bool × Array Std.U8 768#usize ×
      Std.I32 × Option num.imp.dec2flt.common.BiasedFp => x.2.2.2.2.1)
    htuple0
  subst q0
  subst e0
  rcases hshape0 with ⟨hcap0, hdigit0, hpositive0, hend0⟩
  have hshape0Pack :
      d0.num_digits.val <= 768 /\
      (forall q, q ∈ d0.digits.val.take d0.num_digits.val -> q.val < 10) /\
      (exists z zs, Digits d0 = z :: zs /\ 1 <= z /\ z < 10 /\
        (Digits d0).length = d0.num_digits.val) :=
    ⟨hcap0, hdigit0, by simpa [Digits] using hpositive0⟩
  have hend0Pack :
      exists eta u : Real,
        A / (2 : Real) ^ exp0.val = Value d0 + eta /\
        B / (2 : Real) ^ exp0.val = Value d0 + u /\
        0 <= eta /\ eta < u /\ (d0.truncated = true <-> 0 < eta) := by
    simpa [Value, Digits] using hend0
  have hspec1 := ParserSlowLoop1 A B d0 exp0 hp0Lo hp0Hi he0Lo
    ⟨hcap0, hdigit0, hpositive0, hend0⟩
  dsimp only at hspec1
  rcases hspec1 with ⟨q1, e1, steps1, hcall1, hsteps1, he1Hi,
    hp1, hnum1, hlead1, hlead1Hi, hshape1⟩
  have htuple1 := Result.ok.inj (hcall1.symm.trans hloop1)
  have hq1 : q1 = d1 := by
    cases q1
    cases d1
    simp only [Prod.mk.injEq] at htuple1
    simp only [num.imp.dec2flt.decimal_seq.DecimalSeq.mk.injEq]
    tauto
  have he1 : e1 = exp1 := congrArg
    (fun x : Std.Usize × Std.I32 × Bool × Array Std.U8 768#usize ×
      Std.I32 × Option num.imp.dec2flt.common.BiasedFp => x.2.2.2.2.1)
    htuple1
  subst q1
  subst e1
  rcases hshape1 with ⟨hcap1, hdigit1, hpositive1, hend1⟩
  have hnorm := ParserSlowReachableNormalizationBounds A B d d0 d1 exp0 exp1
    hpLo hpHi hB (by simpa [Digits, Value] using hcanonicalPack) hALower
    hloop0 hloop1 hp1 hnum1 hlead1 (by simpa [Digits, Value] using hend1)
  have hspec2 := ParserSlowLoop2 A B d1 exp1 hnorm.2 hp1 hnum1 hlead1
    ⟨hcap1, hdigit1, hend1⟩
  dsimp only at hspec2
  rcases hspec2 with ⟨es, q2, e2, total, hsubS, hloop2S, htotal,
    hes, he2, htotalEq, hpoint2Lo, hnum2, hshape2⟩
  have hesEq : es = expStart := Result.ok.inj (hsubS.symm.trans hsub)
  subst es
  have hout2 := Result.ok.inj (hloop2S.symm.trans hloop2)
  have he2Eq : e2 = exp2 := congrArg Prod.snd hout2
  subst e2
  have hexp2Floor : -1022 <= exp2.val := by
    rw [he2]
    exact le_max_right _ _
  have hexp2Norm : exp1.val - 1 <= exp2.val := by
    rw [he2, hes]
    exact le_max_left _ _
  by_cases hlow : d0.decimal_point.val <= -307
  · have he0zero := P856_T1_Loop0NegativeExit A B d d0 0#i32 exp0
      hpLo hpHi (by exact ⟨hcap, hdigit,
        ⟨z, zs, hzshape, hzLo, hzHi, hzlen⟩⟩)
      (by
        rcases hcanonicalA with ⟨eta, hAeq, heta0, hetaCut, hsticky⟩
        refine ⟨eta, (10 : Real) ^ (d.decimal_point.val - 768), ?_, ?_,
          heta0, hetaCut, hsticky⟩
        · simpa [Value, Digits] using hAeq
        · simpa [Value, Digits] using hB)
      hloop0 (by omega)
    have he0val : exp0.val = 0 := by rw [he0zero]; norm_num
    omega
  · have hp0Ord : -306 <= d0.decimal_point.val := by omega
    rcases hpositive0 with ⟨z0, zs0, hzshape0, hz0Lo, hz0Hi, hzlen0⟩
    have hv0 := P804_T1_DecimalValueBounds (Digits d0) z0 zs0
      (by simpa [Digits] using hzshape0) hz0Lo (by
        intro w hw
        simp only [Digits, List.mem_map] at hw
        rcases hw with ⟨w8, hw8, rfl⟩
        exact hdigit0 w8 hw8) d0.decimal_point.val
    dsimp only at hv0
    rw [hzlen0] at hv0
    rcases hend0 with ⟨eta0, u0, hA0, hB0, heta0, heta0u0, hsticky0⟩
    have hAB : A < B := by
      rcases hcanonicalA with ⟨eta, hAeq, hetaLo, hetaHi, hsticky⟩
      have hcutPos : 0 < (10 : Real) ^ (d.decimal_point.val - 768) :=
        zpow_pos (by norm_num) _
      rw [hAeq, hB]
      linarith
    have hpow0Pos : 0 < (2 : Real) ^ exp0.val := zpow_pos (by norm_num) _
    have hpow1Pos : 0 < (2 : Real) ^ exp1.val := zpow_pos (by norm_num) _
    have hBpow : B <= (2 : Real) ^ exp1.val := by
      have hm := (div_le_iff₀ hpow1Pos).mp hnorm.1
      simpa using hm
    have hv0A : Value d0 <= A / (2 : Real) ^ exp0.val := by
      rw [hA0]
      linarith
    have hAdivB : A / (2 : Real) ^ exp0.val <
        B / (2 : Real) ^ exp0.val := by
      exact (div_lt_div_iff_of_pos_right hpow0Pos).2 hAB
    have hBdivPow : B / (2 : Real) ^ exp0.val <=
        (2 : Real) ^ (exp1.val - exp0.val) := by
      calc
        B / (2 : Real) ^ exp0.val <=
            (2 : Real) ^ exp1.val / (2 : Real) ^ exp0.val :=
          div_le_div_of_nonneg_right hBpow hpow0Pos.le
        _ = (2 : Real) ^ (exp1.val - exp0.val) := by
          rw [zpow_sub₀ (by norm_num : (2 : Real) ≠ 0)]
    have hdecimalBinary : (10 : Real) ^ (d0.decimal_point.val - 1) <
        (2 : Real) ^ (exp1.val - exp0.val) := by
      have hzReal : (1 : Real) <= z0 := by exact_mod_cast hz0Lo
      have hpow10Pos : 0 < (10 : Real) ^ (d0.decimal_point.val - 1) :=
        zpow_pos (by norm_num) _
      have hleadLower : (10 : Real) ^ (d0.decimal_point.val - 1) <=
          (z0 : Real) * (10 : Real) ^ (d0.decimal_point.val - 1) := by
        nlinarith
      have hv0Lower :
          (z0 : Real) * (10 : Real) ^ (d0.decimal_point.val - 1) <=
            Value d0 := by
        simpa [Value, Digits] using hv0.1
      exact lt_of_le_of_lt (hleadLower.trans (hv0Lower.trans hv0A))
        (hAdivB.trans_le hBdivPow)
    have hpBound := P856_T1_DecimalBinaryExponentBound
      d0.decimal_point.val (exp1.val - exp0.val) hp0Ord hp0Hi hdecimalBinary
    omega

end dec2flt_model

Proof structure

Follow the declared dependencies to read the supporting statements and proofs.

Explore this dependency tree

Inspect related source (201)
More program dependencies (159)
Standard-library dependencies (39)

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
All 157 entries
Technical checking records
Local closure summary
{
  "node": "P856_T1_ReachableCapacity",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "d15f9ec5f5d22cbb2f1e27110e95599dba1f51e46c0a00ebb8d628a74191325f",
  "active_statement_hash": "789c13a66c02998ab4324a64b1721f4a5949f8efe58643842667cb42bb3a7f8f",
  "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": "revalidate-cycle-199",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "P804_T1_DecimalValueBounds": "4b5c924b5d52bc9d",
    "P856_T1_DecimalBinaryExponentBound": "c090950acf612415",
    "P856_T1_Loop0NegativeExit": "32c8aed039df3ef2",
    "ParserSlowLoop0": "33531ee210efb042",
    "ParserSlowLoop1": "f2b7099d6b2b429c",
    "ParserSlowLoop2": "988df2b319919687",
    "ParserSlowReachableNormalizationBounds": "3d4872e8ccb1d877",
    "num_imp_dec2flt_decimal_seq_DecimalSeq": "3c283430b9003d37"
  },
  "strict_definition_deps": {
    "F64": "ec4e25fbaf4e11d4",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64": "94095c9bf79da164",
    "ParserSlowLoop0": "7ebc2b39d69850c4",
    "num_imp_dec2flt_common_BiasedFp": "63baac539d218a81",
    "num_imp_dec2flt_decimal_seq_DecimalSeq": "59bf1ff9fe88fa8d",
    "num_imp_dec2flt_slow_parse_long_mantissa": "71d9bebe88212f80"
  }
}
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:8262d610f0547a0e1f797acd7a53fa0568fabca61402939463cb4f996ac41146",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}