ParserSlowReachableNormalizationBounds

Lean checked

Statement

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

Lemma · Reachable slow-normalization exponent bound

Fix the original regular parsed record d with point -324\leq p<310 and adjacent decimal-cell endpoints
A=V(d)+\eta,\quad B=V(d)+10^{p-768},\quad 0\leq\eta<10^{p-768}.
Assume its retained count is at most 768, every retained digit is below 10, and its retained digits have the form z::zs, of length equal to the retained count, with 1\leq z<10. Also assume d.\mathit{truncated}=\mathit{true} if and only if 0<\eta. Assume 10^{-325}\leq A, the exact extracted loop-0 and loop-1 histories in the Lean statement, and the transported fixed-endpoint state at their point-zero exit d_1, whose leading digit is at least five. Then
B/2^{e_1}\leq1\qquad\hbox{and}\qquad e_1\geq-1079.
This claim is reachability-specific: it retains the initial parse cell and both exact loop histories rather than quantifying over an arbitrary endpoint.

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.P798_T1_GridAlignment
import Tablet.P826_T1_PowerGridAlignment
import Tablet.P826_T1_LeftHistoryBoundary
import Tablet.P826_T1_RightHistoryBoundary
import Tablet.P826_T1_ExponentLowerBound
import Tablet.P804_T1_DecimalValueBounds
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: ParserSlowReachableNormalizationBounds]
theorem ParserSlowReachableNormalizationBounds :
    forall (A B : Real)
      (d d0 d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
      (exp0 exp1 : Std.I32),
      -324 <= d.decimal_point.val -> d.decimal_point.val < 310 ->
      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 ->
      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)) ->
      (10 : Real) ^ (-(325 : Int)) <= A ->
      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) ->
      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) ->
      d1.decimal_point.val = 0 -> d1.num_digits.val != 0 ->
      5 <= d1.digits.val[0].val ->
      let digits1 :=
        (d1.digits.val.take d1.num_digits.val).map (fun z => z.val)
      let integer1 : Nat := digits1.foldl (fun n digit => 10 * n + digit) 0
      let value1 : Real := integer1 * (10 : Real) ^
        (d1.decimal_point.val - (d1.num_digits.val : Int))
      (exists eta1 u1 : Real,
        A / (2 : Real) ^ exp1.val = value1 + eta1 /\
        B / (2 : Real) ^ exp1.val = value1 + u1 /\
        0 <= eta1 /\ eta1 < u1 /\
        (d1.truncated = true <-> 0 < eta1)) ->
      B / (2 : Real) ^ exp1.val <= 1 /\ -1079 <= exp1.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.

Earlier prose review

An earlier review questioned the prose argument. Lean subsequently checked the formal proof. Review of the statement’s intended meaning is a separate judgment.

Proof

Write V(q) for the retained decimal value of a record q. The nonempty initial digit list makes the recorded count nonzero. Hence ParserSlowLoop0 applies to the supplied loop-0 equality. Injectivity of the successful result identifies the record and exponent it produces with the displayed d_0,e_0; in particular it supplies the decimal shape and the scaled endpoint equations at that state. Applying ParserSlowLoop1 in the same way identifies its output with the displayed d_1,e_1 and supplies the final decimal shape. Thus the exact histories in the hypotheses have precisely the interfaces required below; no state other than one on those histories is introduced.
For orientation, at a reachable record q with point p and exponent e put
T(q,e)=2^{e_1-e},\qquad C(q,e)=e_1-e+768-p.
Whenever p\leq768 and C\geq0, PowerGridAlignment gives a natural number b with
T(q,e)=b10^{p-768}. \tag{1}
This is an integer boundary of the 768-cell grid; on the same grid GridAlignment writes V(q)=a10^{p-768} for a natural number a.
We record why the two reachable-history certificates preserve both capacity and order. Their backward induction is the rule ResultLoopBackward. On loop 1, a continuing body has its actual selector shift k, shifted record, and update e'=e-k recovered by LeftBodySelector and packaged, together with all decimal shape and endpoint equations, by LeftStepCertificate. The one-step capacity inequality in LeftCapacityStep combines those exact selector cases with the point and leading-digit progress. Its terminal bonuses make the capacity inequality an equality at a successful exit, whose unchanged record, point zero, and leading digit at least five are given by LeftDoneCertificate. Consequently LeftHistoryBoundary proves
0\leq e_1-e_0+768-d_0.p \tag{2}
and
2^{e_1-e_0}\leq V(d_0)\quad\Longrightarrow\quad 1\leq V(d_1). \tag{3}
The order step used in that induction is exact rather than an accumulated error estimate. Since e'=e-k, the successor threshold is 2^{e_1-e'}=2^kT(q,e). Equation (1) aligns it to the successor grid. The exact left-shift equation and LeftBoundaryTransport then retain that boundary below the successor value. The latter transport rests on the strict fresh-loss criterion GridBoundaryRetained; hence even a capped shift cannot cross an aligned integer boundary. The induction hypothesis may therefore be applied at the successor without summing truncation errors.
Loop 0 is analogous. The actual selector and update e'=e+k are recovered by RightBodySelector and the full transition is packaged by RightStepCertificate. The exact table arithmetic in RightCapacityStep gives p-p'\leq k, so
C(q,e)=C(q',e')+k-(p-p')\geq0
whenever successor capacity is nonnegative. A done body is unchanged and has nonpositive point by RightDoneCertificate. For order, e'=e+k makes the successor threshold 2^{e_1-e'}=T(q,e)/2^k; (1) aligns it to the successor grid, and RightBoundaryTransport retains it below V(q'). Again GridBoundaryRetained supplies the strict-loss step, so no per-step error is accumulated. Backward induction, summarized by RightHistoryBoundary, starts from (2)--(3) and yields
0\leq e_1+768-d.p,qquad 2^{e_1}\leq V(d)\Longrightarrow1\leq V(d_1). \tag{4}
Here the input exponent is exactly zero, as in the supplied loop-0 call.
Suppose, for contradiction, that 1<B/2^{e_1}. Positivity of every integer power of two gives 2^{e_1}<B. The capacity part of (4) and PowerGridAlignment write 2^{e_1}=bq, where q=10^{d.p-768}>0 and b is natural. Meanwhile GridAlignment writes V(d)=aq, and the hypothesis on the right cell endpoint says B=V(d)+q=(a+1)q. Cancelling the positive q from
bq< (a+1)q
gives b<a+1. Discreteness of natural numbers gives b\leq a, whence 2^{e_1}\leq V(d). The order part of (4) now gives 1\leq V(d_1).
On the other hand, the final digit list is nonempty, begins with a digit at least five, and every retained digit is below ten. The upper fold estimate in DecimalValueBounds, together with final point zero and the recorded list length, gives V(d_1)<10^0=1. This contradicts the preceding lower bound. Therefore B/2^{e_1}\leq1.
Finally, A=V(d)+\eta with \eta<10^{d.p-768}, whereas B=V(d)+10^{d.p-768}, so A<B. We have therefore proved
10^{-325}\leq A<B\leq2^{e_1}. \tag{5}
The exact natural-number comparison 10^{325}<2^{1080}, checked by kernel reduction, reverses on taking positive inverses and gives 2^{-1080}<10^{-325}. If e_1\leq-1080, monotonicity of integer powers of the base 2>1 would give 2^{e_1}\leq2^{-1080}<10^{-325}, contradicting (5). This argument is packaged by ExponentLowerBound, which yields -1079\leq e_1 and completes both conclusions.

Lean proof


  dsimp only
  intro A B d d0 d1 exp0 exp1 hpLo hpHi hB hcanonical hA hloop0 hloop1
    hp1 hnum1 hlead1 hfinal
  classical
  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)) := by
    exact ⟨hcap, hdigit, ⟨z, zs, hzshape, hzLo, hzHi, hzlen⟩,
      hcanonicalA⟩
  have hloop0Spec := ParserSlowLoop0 A B d hdne hpLo hpHi hB
    (by simpa [Digits, Value] using hcanonicalPack)
  dsimp only at hloop0Spec
  rcases hloop0Spec with ⟨q0, e0, steps0, hcall0, hsteps0, he0Lo,
    he0Hi, hA0, 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 := by
    exact 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) := by
    exact ⟨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 hloop1Spec := ParserSlowLoop1 A B d0 exp0 hp0Lo hp0Hi he0Lo
    (by exact ⟨hcap0, hdigit0, hpositive0, hend0⟩)
  dsimp only at hloop1Spec
  rcases hloop1Spec with ⟨q1, e1, steps1, hcall1, hsteps1, he1Hi,
    hp1Spec, hnum1Spec, hlead1Spec, 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 := by
    exact 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 hleft := P826_T1_LeftHistoryBoundary A B d0 d1 exp0 exp1
    hp0Lo hp0Hi hshape0Pack hend0Pack hloop1
  have hendInit :
      exists eta u : Real,
        A / (2 : Real) ^ (0#i32 : Std.I32).val = Value d + eta /\
        B / (2 : Real) ^ (0#i32 : Std.I32).val = Value d + u /\
        0 <= eta /\ eta < u /\ (d.truncated = true <-> 0 < eta) := 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
  have hright := P826_T1_RightHistoryBoundary A B d d0 d1 0#i32
    exp0 exp1 hpLo hpHi
    (by exact ⟨hcap, hdigit, z, zs, hzshape, hzLo, hzHi, hzlen⟩)
    hendInit hloop0 hleft
  have hcapInit : 0 <= exp1.val + 768 - d.decimal_point.val := by
    have := hright.1
    norm_num at this ⊢
    exact this
  have hAB : A < B := by
    rcases hcanonicalA with ⟨eta, hAeq, heta0, hetaCut, hsticky⟩
    rw [hAeq, hB]
    linarith
  have hBUpper : B / (2 : Real) ^ exp1.val <= 1 := by
    by_contra hnot
    have hgt : 1 < B / (2 : Real) ^ exp1.val := lt_of_not_ge hnot
    have hpowPos : 0 < (2 : Real) ^ exp1.val := zpow_pos (by norm_num) _
    have hpowB : (2 : Real) ^ exp1.val < B := by
      simpa using (lt_div_iff₀ hpowPos).mp hgt
    obtain ⟨b, hb⟩ := P826_T1_PowerGridAlignment exp1.val
      d.decimal_point.val (by omega) hcapInit
    obtain ⟨a, ha⟩ := P798_T1_GridAlignment d hcap
    let q : Real := (10 : Real) ^ (d.decimal_point.val - 768)
    have hq : 0 < q := by
      dsimp only [q]
      exact zpow_pos (by norm_num) _
    have hmult : (b : Real) * q < ((a : Real) + 1) * q := by
      calc
        (b : Real) * q = (2 : Real) ^ exp1.val := by
          simpa [q] using hb.symm
        _ < B := hpowB
        _ = (a : Real) * q + q := by
          rw [hB]
          simpa [q] using congrArg (fun r : Real => r + q) ha
        _ = ((a : Real) + 1) * q := by ring
    have hbaR : (b : Real) < (a : Real) + 1 :=
      lt_of_mul_lt_mul_right hmult (le_of_lt hq)
    have hba : b <= a := by
      have : b < a + 1 := by exact_mod_cast hbaR
      omega
    have ha' : Value d = (a : Real) * q := by
      simpa [Value, Digits, q, List.map_take] using ha
    have hthreshold : (2 : Real) ^ exp1.val <= Value d := by
      rw [hb, ha']
      exact mul_le_mul_of_nonneg_right (by exact_mod_cast hba)
        (le_of_lt hq)
    have hfinalLower : 1 <= Value d1 := by
      apply hright.2
      norm_num
      simpa [Value, Digits, List.map_take] using hthreshold
    rcases hpositive1 with ⟨z1, zs1, hzshape1, hz1Lo, hz1Hi, hzlen1⟩
    have hv1 := P804_T1_DecimalValueBounds (Digits d1) z1 zs1
      (by simpa [Digits] using hzshape1) (by omega) (by
        intro w hw
        simp only [Digits, List.mem_map] at hw
        rcases hw with ⟨w8, hw8, rfl⟩
        exact hdigit1 w8 hw8) d1.decimal_point.val
    have hfinalUpper : Value d1 < 1 := by
      dsimp only at hv1
      rw [hzlen1] at hv1
      have hu := hv1.2
      rw [hp1] at hu
      norm_num at hu
      simpa [Value, Digits, List.map_take, hp1, zpow_neg] using hu
    linarith
  exact ⟨hBUpper,
    P826_T1_ExponentLowerBound A B exp1.val hA hAB hBUpper⟩

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.ParserSlowLoop0
import Tablet.ParserSlowLoop1
import Tablet.P798_T1_GridAlignment
import Tablet.P826_T1_PowerGridAlignment
import Tablet.P826_T1_LeftHistoryBoundary
import Tablet.P826_T1_RightHistoryBoundary
import Tablet.P826_T1_ExponentLowerBound
import Tablet.P804_T1_DecimalValueBounds
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: ParserSlowReachableNormalizationBounds]
theorem ParserSlowReachableNormalizationBounds :
    forall (A B : Real)
      (d d0 d1 : num.imp.dec2flt.decimal_seq.DecimalSeq)
      (exp0 exp1 : Std.I32),
      -324 <= d.decimal_point.val -> d.decimal_point.val < 310 ->
      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 ->
      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)) ->
      (10 : Real) ^ (-(325 : Int)) <= A ->
      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) ->
      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) ->
      d1.decimal_point.val = 0 -> d1.num_digits.val != 0 ->
      5 <= d1.digits.val[0].val ->
      let digits1 :=
        (d1.digits.val.take d1.num_digits.val).map (fun z => z.val)
      let integer1 : Nat := digits1.foldl (fun n digit => 10 * n + digit) 0
      let value1 : Real := integer1 * (10 : Real) ^
        (d1.decimal_point.val - (d1.num_digits.val : Int))
      (exists eta1 u1 : Real,
        A / (2 : Real) ^ exp1.val = value1 + eta1 /\
        B / (2 : Real) ^ exp1.val = value1 + u1 /\
        0 <= eta1 /\ eta1 < u1 /\
        (d1.truncated = true <-> 0 < eta1)) ->
      B / (2 : Real) ^ exp1.val <= 1 /\ -1079 <= exp1.val := by
-- BODY
  dsimp only
  intro A B d d0 d1 exp0 exp1 hpLo hpHi hB hcanonical hA hloop0 hloop1
    hp1 hnum1 hlead1 hfinal
  classical
  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)) := by
    exact ⟨hcap, hdigit, ⟨z, zs, hzshape, hzLo, hzHi, hzlen⟩,
      hcanonicalA⟩
  have hloop0Spec := ParserSlowLoop0 A B d hdne hpLo hpHi hB
    (by simpa [Digits, Value] using hcanonicalPack)
  dsimp only at hloop0Spec
  rcases hloop0Spec with ⟨q0, e0, steps0, hcall0, hsteps0, he0Lo,
    he0Hi, hA0, 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 := by
    exact 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) := by
    exact ⟨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 hloop1Spec := ParserSlowLoop1 A B d0 exp0 hp0Lo hp0Hi he0Lo
    (by exact ⟨hcap0, hdigit0, hpositive0, hend0⟩)
  dsimp only at hloop1Spec
  rcases hloop1Spec with ⟨q1, e1, steps1, hcall1, hsteps1, he1Hi,
    hp1Spec, hnum1Spec, hlead1Spec, 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 := by
    exact 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 hleft := P826_T1_LeftHistoryBoundary A B d0 d1 exp0 exp1
    hp0Lo hp0Hi hshape0Pack hend0Pack hloop1
  have hendInit :
      exists eta u : Real,
        A / (2 : Real) ^ (0#i32 : Std.I32).val = Value d + eta /\
        B / (2 : Real) ^ (0#i32 : Std.I32).val = Value d + u /\
        0 <= eta /\ eta < u /\ (d.truncated = true <-> 0 < eta) := 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
  have hright := P826_T1_RightHistoryBoundary A B d d0 d1 0#i32
    exp0 exp1 hpLo hpHi
    (by exact ⟨hcap, hdigit, z, zs, hzshape, hzLo, hzHi, hzlen⟩)
    hendInit hloop0 hleft
  have hcapInit : 0 <= exp1.val + 768 - d.decimal_point.val := by
    have := hright.1
    norm_num at this ⊢
    exact this
  have hAB : A < B := by
    rcases hcanonicalA with ⟨eta, hAeq, heta0, hetaCut, hsticky⟩
    rw [hAeq, hB]
    linarith
  have hBUpper : B / (2 : Real) ^ exp1.val <= 1 := by
    by_contra hnot
    have hgt : 1 < B / (2 : Real) ^ exp1.val := lt_of_not_ge hnot
    have hpowPos : 0 < (2 : Real) ^ exp1.val := zpow_pos (by norm_num) _
    have hpowB : (2 : Real) ^ exp1.val < B := by
      simpa using (lt_div_iff₀ hpowPos).mp hgt
    obtain ⟨b, hb⟩ := P826_T1_PowerGridAlignment exp1.val
      d.decimal_point.val (by omega) hcapInit
    obtain ⟨a, ha⟩ := P798_T1_GridAlignment d hcap
    let q : Real := (10 : Real) ^ (d.decimal_point.val - 768)
    have hq : 0 < q := by
      dsimp only [q]
      exact zpow_pos (by norm_num) _
    have hmult : (b : Real) * q < ((a : Real) + 1) * q := by
      calc
        (b : Real) * q = (2 : Real) ^ exp1.val := by
          simpa [q] using hb.symm
        _ < B := hpowB
        _ = (a : Real) * q + q := by
          rw [hB]
          simpa [q] using congrArg (fun r : Real => r + q) ha
        _ = ((a : Real) + 1) * q := by ring
    have hbaR : (b : Real) < (a : Real) + 1 :=
      lt_of_mul_lt_mul_right hmult (le_of_lt hq)
    have hba : b <= a := by
      have : b < a + 1 := by exact_mod_cast hbaR
      omega
    have ha' : Value d = (a : Real) * q := by
      simpa [Value, Digits, q, List.map_take] using ha
    have hthreshold : (2 : Real) ^ exp1.val <= Value d := by
      rw [hb, ha']
      exact mul_le_mul_of_nonneg_right (by exact_mod_cast hba)
        (le_of_lt hq)
    have hfinalLower : 1 <= Value d1 := by
      apply hright.2
      norm_num
      simpa [Value, Digits, List.map_take] using hthreshold
    rcases hpositive1 with ⟨z1, zs1, hzshape1, hz1Lo, hz1Hi, hzlen1⟩
    have hv1 := P804_T1_DecimalValueBounds (Digits d1) z1 zs1
      (by simpa [Digits] using hzshape1) (by omega) (by
        intro w hw
        simp only [Digits, List.mem_map] at hw
        rcases hw with ⟨w8, hw8, rfl⟩
        exact hdigit1 w8 hw8) d1.decimal_point.val
    have hfinalUpper : Value d1 < 1 := by
      dsimp only at hv1
      rw [hzlen1] at hv1
      have hu := hv1.2
      rw [hp1] at hu
      norm_num at hu
      simpa [Value, Digits, List.map_take, hp1, zpow_neg] using hu
    linarith
  exact ⟨hBUpper,
    P826_T1_ExponentLowerBound A B exp1.val hA hAB hBUpper⟩

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 152 entries
Technical checking records
Local closure summary
{
  "node": "ParserSlowReachableNormalizationBounds",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "54bc4b9832b7ee6c482bcd1f1abed87ea9c3a69398686a86ea9a13603b01d505",
  "active_statement_hash": "b593e9a4c24456a6022cd6b2ad1756e2fbc0a1a724378451c8c5be1b0c1066ff",
  "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-196",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "P798_T1_GridAlignment": "f2e86c75264ff7d3",
    "P804_T1_DecimalValueBounds": "4b5c924b5d52bc9d",
    "P826_T1_ExponentLowerBound": "5a0b94e823acb335",
    "P826_T1_LeftHistoryBoundary": "f02ed9a17369ee2b",
    "P826_T1_PowerGridAlignment": "0cee3aaeb64f7353",
    "P826_T1_RightHistoryBoundary": "d5b161de4edd07da",
    "ParserSlowLoop0": "33531ee210efb042",
    "ParserSlowLoop1": "f2b7099d6b2b429c",
    "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": "13e3cec939d02f51",
    "num_imp_dec2flt_slow_parse_long_mantissa": "a3ed147b34a97b11"
  }
}
Prose assessment
{
  "label": "Sound flag superseded by recorded Lean closure",
  "assessment_status": "VerifierFail",
  "fingerprint_relation": "differs from current fingerprint",
  "assessment_fingerprint": "sound-v2:7c8d6fd119decd0ce2797b00a549c91f531c133c0a9881b9fd2a260d96ac1875",
  "current_fingerprint": "sound-v2:4add3d7c92f57fa4dee822f36581df83c1c5f38a3cfe9470cc252747554b42bf",
  "superseded_for_theorem_closure": true
}
Review verdicts
{
  "corr_status": "Pass",
  "sound_status": "Fail",
  "substantiveness_status": "Pass"
}