ParserSlowLoop0

Lean checked

Statement

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

Lemma · Slow normalization loop zero with fixed endpoints

Let the nonempty parsed record d have decimal cells, positive leading digit, point -324\leq p<310, and canonical initial cell
A=V(d)+\eta,\quad0\leq\eta<10^{p-768},\quad d.\mathit{truncated}\iff0<\eta,
and fix its upper endpoint B=V(d)+10^{p-768}. The first extracted slow loop terminates after at most 21 right shifts, returns no early result, and returns a nonreset record d_0 with -324\leq p_0\leq0 and exponent e_0 satisfying 0\leq e_0\leq60\,\mathit{steps}. Its selector is the literal table stated in Lean. The output has decimal cells and positive-leading shape, 10^{-325}\leq A, and witnesses
A/2^{e_0}=V(d_0)+\eta_0,\qquad B/2^{e_0}=V(d_0)+u_0,\qquad 0\leq\eta_0<u_0,\qquad d_0.\mathit{truncated}\iff0<\eta_0.
The exact loop-call equation and all these facts form the Lean existential.

Lean statement

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

import Tablet.DecimalSeqRightShiftCanonical
import Tablet.P804_T1_DecimalValueBounds
import Tablet.P804_T1_RightLoopStep
import Tablet.DecimalRightShiftLoop0Execution
import Tablet.ParserSlowEarlyExits
import Tablet.SlowShiftSelectorCertificate
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_MAX_SHIFT
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_NUM_POWERS
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_POWERS
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: ParserSlowLoop0]
theorem ParserSlowLoop0 :
    forall (A B : Real) (d : num.imp.dec2flt.decimal_seq.DecimalSeq),
      d.num_digits.val != 0 ->
      -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)) ->
      exists (d0 : num.imp.dec2flt.decimal_seq.DecimalSeq)
        (exp0 : Std.I32) (steps : Nat),
        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) /\
        steps <= 21 /\ 0 <= exp0.val /\ exp0.val <= (60 : Int) * steps /\
        (10 : Real) ^ (-(325 : Int)) <= A /\
        -324 <= d0.decimal_point.val /\ d0.decimal_point.val <= 0 /\
        let selector : Nat -> Nat := fun n => match n with
          | 0 => 0 | 1 => 3 | 2 => 6 | 3 => 9 | 4 => 13 | 5 => 16
          | 6 => 19 | 7 => 23 | 8 => 26 | 9 => 29 | 10 => 33
          | 11 => 36 | 12 => 39 | 13 => 43 | 14 => 46 | 15 => 49
          | 16 => 53 | 17 => 56 | 18 => 59 | _ => 60
        (forall n, selector n <= 60) /\
        let digits0 :=
          (d0.digits.val.take d0.num_digits.val).map (fun z => z.val)
        let integer0 : Nat := digits0.foldl (fun n digit => 10 * n + digit) 0
        let value0 : Real := integer0 * (10 : Real) ^
          (d0.decimal_point.val - (d0.num_digits.val : Int))
        d0.num_digits.val <= 768 /\
        (forall z, z ∈ d0.digits.val.take d0.num_digits.val -> z.val < 10) /\
        (exists z zs, digits0 = z :: zs /\ 1 <= z /\ z < 10 /\
          digits0.length = d0.num_digits.val) /\
        exists eta0 u0 : Real,
          A / (2 : Real) ^ exp0.val = value0 + eta0 /\
          B / (2 : Real) ^ exp0.val = value0 + u0 /\
          0 <= eta0 /\ eta0 < u0 /\
          (d0.truncated = true <-> 0 < eta0) := 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

Use the extracted loop definition in num imp dec2flt slow parse long mantissa. For a state after s right shifts, with record q, point r, and exponent e, maintain the following simultaneous invariant:
\begin{gathered} -324\le r<310,\qquad 0\le e\le60s,\\ q\text{ has at most 768 decimal cells and a positive leading cell},\\ A/2^e=V(q)+\eta_s,\quad B/2^e=V(q)+u_s,quad 0\le\eta_s<u_s,quad q.\mathit{truncated}\iff0<\eta_s. \end{gathered} \tag{1}
The quantitative part of the invariant is
\begin{array}{ll} r\ge19&\Longrightarrow 18s+r\le309,\\ 2\le r\le18&\Longrightarrow s\le17,\\ r=1\text{ and the leading cell is }1&\Longrightarrow s\le19,\\ r=1\text{ and the leading cell is not }1&\Longrightarrow s\le18,\\ r\le0&\Longrightarrow s\le20. \end{array} \tag{2}
At the initial state take s=e=0. The hypothesis r<310 is integral, so r\le309, which proves the first clause of (2); all other clauses with a true antecedent have zero on their right-hand side. The supplied \eta is strictly below the positive cutoff. Taking u=10^{p-768} and using the given equation for B proves the two endpoint clauses of (1).
If r\le0, the guard in the cited extracted definition returns this state unchanged. Suppose therefore that r>0. The alternatives in (2) imply s\le20: in the large regime the first clause even gives s\le16, in the middle regime the second gives s\le17, and at point one the two leading-cell clauses give s\le19. Consequently the pre-update exponent satisfies 0\le e\le1200. Apply RightLoopStep with endpoints A/2^e and B/2^e. It proves the exact body call, a selected k\le60, the successful right shift, the nonreset continuation, and
e'=e+k. \tag{3}
Thus the I32 addition is justified at the instant it is executed: 0\le e+k\le1260<2^{31}. The helper also transports the digit shape, sticky equivalence, and endpoint errors. Since (A/2^e)/2^k=A/2^{e+k}, and similarly for B, (3) converts its transported endpoints precisely into (1) for the successor. Moreover e'le60s+60=60(s+1).
We check (2) for s+1 from the quantitative alternatives in the same helper. If r\ge19, then r'=r-18 or r'=r-19. When r'\ge19,
18(s+1)+r'\le18s+r\le309.
If that step instead enters any smaller regime, 18s+r\le309 and r\ge19 give s\le16, so s+1\le17, stronger than every required new bound. If 2\le r\le18, then r' is zero or one and s\le17, hence s+1\le18; this proves the non-leading-one point-one clause and the terminal clause, and is also stronger than the leading-one clause. Finally let r=1. If its leading cell is one, the no-stall clause of RightLoopStep forces r'=0, and the old s\le19 gives s+1\le20. If its leading cell is not one, the old bound is s\le18. A return to point one has leading cell exactly one by the helper's stall clause, so its new bound is s+1\le19; a return to point zero instead has s+1\le19\le20. These cases prove every clause of (2), including the correlation that prevents two point-one stalls.
For termination use the natural-valued rank
R(q)=\begin{cases} 2r+0,&r>0\text{ and the leading cell is }1,\\ 2r+1,&r>0\text{ and the leading cell is not }1,\\ 0,&r\le0. \end{cases}
The large-point alternatives decrease r by at least eighteen. From 2\le r\le18, the successor point is at most one, so the new rank is at most three whereas the old rank is at least four. At r=1, a leading-one input exits, while a non-leading-one stall changes rank from three to two. Hence every continuation strictly decreases R, and the extracted loop rule applies with (1)--(2).
At exit the last clause of (2) gives s\le20, hence the claimed weaker s\le21. Invariant (1) supplies 0\le e\le60s, the output point bounds, shape, exact call, and endpoint witnesses. Each literal selector entry is at most sixty (the entries are 0,3,6,9,13,16,19,23,26,29,33,36,39,43,46,49,53,56,59, followed by the fallback 60), proving the displayed selector conjunct.
It remains only to prove the stated lower bound on A. Apply DecimalValueBounds to the initial retained word. With leading cell z\ge1 it gives V(d)\ge z10^{p-1}\ge10^{p-1}. Since p\ge-324, 10^{p-1}\ge10^{-325}; since A=V(d)+\eta and \eta\ge0, this yields 10^{-325}\le A. All conjuncts of the existential now follow.

Lean proof


  dsimp only
  intro A B d hdne hpLower hpUpper hB hcanonical
  classical
  let State := Std.Usize × Std.I32 × Bool × Array Std.U8 768#usize ×
    Std.I32 × Option num.imp.dec2flt.common.BiasedFp
  let recordOf : State -> num.imp.dec2flt.decimal_seq.DecimalSeq := fun x =>
    { num_digits := x.1, decimal_point := x.2.1, truncated := x.2.2.1,
      digits := x.2.2.2.1 }
  let exponentOf : State -> Std.I32 := fun x => x.2.2.2.2.1
  let resultOf : State -> Option num.imp.dec2flt.common.BiasedFp := fun x =>
    x.2.2.2.2.2
  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))
  let Shape := fun q : num.imp.dec2flt.decimal_seq.DecimalSeq =>
    q.num_digits.val <= 768 /\
    (forall z, z ∈ q.digits.val.take q.num_digits.val -> z.val < 10) /\
    (exists z zs, Digits q = z :: zs /\ 1 <= z /\ z < 10 /\
      (Digits q).length = q.num_digits.val)
  let Endpoints := fun (q : num.imp.dec2flt.decimal_seq.DecimalSeq)
      (e : Std.I32) =>
    exists eta u : Real,
      A / (2 : Real) ^ e.val = Value q + eta /\
      B / (2 : Real) ^ e.val = Value q + u /\
      0 <= eta /\ eta < u /\
      (q.truncated = true <-> 0 < eta)
  let HeadOne := fun q : num.imp.dec2flt.decimal_seq.DecimalSeq =>
    exists tail, Digits q = 1 :: tail
  let Budget := fun (q : num.imp.dec2flt.decimal_seq.DecimalSeq) (s : Nat) =>
    (19 <= q.decimal_point.val ->
      (18 : Int) * s + q.decimal_point.val <= 309) /\
    (2 <= q.decimal_point.val -> q.decimal_point.val <= 18 -> s <= 17) /\
    (q.decimal_point.val = 1 -> HeadOne q -> s <= 19) /\
    (q.decimal_point.val = 1 -> Not (HeadOne q) -> s <= 18) /\
    (q.decimal_point.val <= 0 -> s <= 20)
  let Inv := fun x : State =>
    resultOf x = none /\
    -324 <= (recordOf x).decimal_point.val /\
    (recordOf x).decimal_point.val < 310 /\
    0 <= (exponentOf x).val /\
    exists s : Nat,
      (exponentOf x).val <= (60 : Int) * s /\
      Budget (recordOf x) s /\
      Shape (recordOf x) /\ Endpoints (recordOf x) (exponentOf x)
  let Post := fun x : State => Inv x /\ (recordOf x).decimal_point.val <= 0
  let Measure := fun x : State =>
    if 0 < (recordOf x).decimal_point.val then
      2 * (recordOf x).decimal_point.val.toNat +
        (if HeadOne (recordOf x) then 0 else 1)
    else 0
  let Body := fun x : State =>
    num.imp.dec2flt.slow.parse_long_mantissa_loop0.body
      F64.Insts.Dec2flt_modelNumImpTraitsFloatU64
      { m := 0#u64, p_biased := 0#i32 }
      x.1 x.2.1 x.2.2.1 x.2.2.2.1 x.2.2.2.2.1 x.2.2.2.2.2
  have hinitShape : Shape d := by
    exact ⟨hcanonical.1, hcanonical.2.1, hcanonical.2.2.1⟩
  have hinitEndpoints : Endpoints d 0#i32 := by
    rcases hcanonical.2.2.2 with
      ⟨eta, hA, heta0, hetaCut, hsticky⟩
    refine ⟨eta, (10 : Real) ^ (d.decimal_point.val - 768), ?_, ?_,
      heta0, hetaCut, hsticky⟩
    · simpa [Endpoints, Value, Digits] using hA
    · simpa [Endpoints, Value, Digits] using hB
  have hinitBudget : Budget d 0 := by
    simp only [Budget]
    constructor
    · intro _
      omega
    constructor <;> omega
  have hinit : Inv
      (d.num_digits, d.decimal_point, d.truncated, d.digits, 0#i32, none) := by
    simp only [Inv, recordOf, exponentOf, resultOf]
    refine ⟨by simp, hpLower, hpUpper, by norm_num, 0, by norm_num,
      hinitBudget, hinitShape, hinitEndpoints⟩
  have hspec :
      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
        ⦃ Post ⦄ := by
    unfold num.imp.dec2flt.slow.parse_long_mantissa_loop0
    apply Aeneas.Std.loop.spec_decr_nat Measure Inv Post Body
      (d.num_digits, d.decimal_point, d.truncated, d.digits, 0#i32, none)
    · intro x hx
      rcases x with ⟨i, p, t, a, e, lr⟩
      simp only [Inv, recordOf, exponentOf, resultOf] at hx
      rcases hx with ⟨hlr, hpLo, hpHi, heLo, s, heHi, hbudget,
        hshape, hend⟩
      simp only [Budget] at hbudget
      simp only [Shape, Digits] at hshape
      simp only [Endpoints, Value, Digits] at hend
      simp only [Body, Prod.fst, Prod.snd]
      rw [hlr]
      by_cases hp : 0 < p.val
      · have hstep := P804_T1_RightLoopStep
          (A / (2 : Real) ^ e.val) (B / (2 : Real) ^ e.val)
          { num_digits := i, decimal_point := p, truncated := t, digits := a }
          e hp (by omega) heLo (by
            have hs20 : s <= 20 := by
              by_cases hp19 : 19 <= p.val
              · have h := hbudget.1 hp19
                omega
              · by_cases hp2 : 2 <= p.val
                · exact (hbudget.2.1 hp2 (by omega)).trans (by omega)
                · have hp1 : p.val = 1 := by omega
                  by_cases hh : HeadOne
                      { num_digits := i, decimal_point := p,
                        truncated := t, digits := a }
                  · exact (hbudget.2.2.1 hp1 hh).trans (by omega)
                  · exact (hbudget.2.2.2.1 hp1 hh).trans (by omega)
            omega) hshape hend
        rcases hstep with ⟨d', shift, e', read, acc, hbody, hright,
          hk, he', hlarge, hsmall, hshapeEnd, hstall, hnoStall⟩
        change (19 <= p.val -> d'.decimal_point.val = p.val - 18 \/
          d'.decimal_point.val = p.val - 19) at hlarge
        change (p.val <= 18 -> d'.decimal_point.val = 0 \/
          d'.decimal_point.val = 1) at hsmall
        rcases hshapeEnd with ⟨hcap', hdigit', hpositive', hend'⟩
        have hshape' : Shape d' := by
          exact ⟨hcap', hdigit', hpositive'⟩
        have he'Lo : 0 <= e'.val := by omega
        have he'Hi : e'.val <= (60 : Int) * (s + 1) := by
          rw [he']
          norm_num only [Nat.cast_add, Nat.cast_one]
          nlinarith
        have hscaleA :
            (A / (2 : Real) ^ e.val) / (2 : Real) ^ shift.val =
              A / (2 : Real) ^ e'.val := by
          rw [he', zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
          norm_num only [zpow_natCast]
          rw [div_div]
        have hscaleB :
            (B / (2 : Real) ^ e.val) / (2 : Real) ^ shift.val =
              B / (2 : Real) ^ e'.val := by
          rw [he', zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
          norm_num only [zpow_natCast]
          rw [div_div]
        have hendNext : Endpoints d' e' := by
          rcases hend' with ⟨eta, u, hA, hB', heta, hetau, hsticky⟩
          refine ⟨eta, u, ?_, ?_, heta, hetau, hsticky⟩
          · rw [← hscaleA]
            exact hA
          · rw [← hscaleB]
            exact hB'
        have hp'Lo : -324 <= d'.decimal_point.val := by
          by_cases hp19 : 19 <= p.val
          · rcases hlarge hp19 with h | h <;> omega
          · rcases hsmall (by omega) with h | h <;> omega
        have hp'Hi : d'.decimal_point.val < 310 := by
          by_cases hp19 : 19 <= p.val
          · rcases hlarge hp19 with h | h <;> omega
          · rcases hsmall (by omega) with h | h <;> omega
        have hbudgetNext : Budget d' (s + 1) := by
          have hheadStall : p.val = 1 -> d'.decimal_point.val = 1 ->
              HeadOne d' := by
            intro hp1 hp1'
            exact hstall hp1 hp1'
          have hnostall : p.val = 1 -> HeadOne
              { num_digits := i, decimal_point := p,
                truncated := t, digits := a } ->
              d'.decimal_point.val = 0 := by
            exact hnoStall
          constructor
          · intro hp'19
            have hp19 : 19 <= p.val := by
              by_contra h
              rcases hsmall (by omega) with h | h <;> omega
            have hold := hbudget.1 hp19
            rcases hlarge hp19 with h | h <;> omega
          constructor
          · intro hp'2 hp'18
            by_cases hp19 : 19 <= p.val
            · have hold := hbudget.1 hp19
              rcases hlarge hp19 with h | h <;> omega
            · by_cases hp2 : 2 <= p.val
              · have hold := hbudget.2.1 hp2 (by omega)
                rcases hsmall (by omega) with h | h <;> omega
              · have hp1 : p.val = 1 := by omega
                rcases hsmall (by omega) with h | h <;> omega
          constructor
          · intro hp'1 hh'
            by_cases hp19 : 19 <= p.val
            · have hold := hbudget.1 hp19
              rcases hlarge hp19 with h | h <;> omega
            · by_cases hp2 : 2 <= p.val
              · have hold := hbudget.2.1 hp2 (by omega)
                omega
              · have hp1 : p.val = 1 := by omega
                by_cases hh : HeadOne
                    { num_digits := i, decimal_point := p,
                      truncated := t, digits := a }
                · have hold := hbudget.2.2.1 hp1 hh
                  have hz := hnostall hp1 hh
                  omega
                · have hold := hbudget.2.2.2.1 hp1 hh
                  omega
          constructor
          · intro hp'1 hh'
            by_cases hp19 : 19 <= p.val
            · have hold := hbudget.1 hp19
              rcases hlarge hp19 with h | h <;> omega
            · by_cases hp2 : 2 <= p.val
              · have hold := hbudget.2.1 hp2 (by omega)
                omega
              · have hp1 : p.val = 1 := by omega
                have hs := hheadStall hp1 hp'1
                exact False.elim (hh' hs)
          · intro hp'0
            by_cases hp19 : 19 <= p.val
            · have hold := hbudget.1 hp19
              rcases hlarge hp19 with h | h <;> omega
            · by_cases hp2 : 2 <= p.val
              · have hold := hbudget.2.1 hp2 (by omega)
                omega
              · have hp1 : p.val = 1 := by omega
                by_cases hh : HeadOne
                    { num_digits := i, decimal_point := p,
                      truncated := t, digits := a }
                · have hold := hbudget.2.2.1 hp1 hh
                  omega
                · have hold := hbudget.2.2.2.1 hp1 hh
                  omega
        rw [hbody]
        simp only [WP.spec_ok]
        constructor
        · simp only [Inv, recordOf, exponentOf, resultOf]
          exact ⟨by simp, hp'Lo, hp'Hi, he'Lo, s + 1, he'Hi,
            hbudgetNext, hshape', hendNext⟩
        · simp only [Measure, recordOf]
          have hd'eta :
              ({ num_digits := d'.num_digits,
                 decimal_point := d'.decimal_point,
                 truncated := d'.truncated,
                 digits := d'.digits } :
                num.imp.dec2flt.decimal_seq.DecimalSeq) = d' := by
            cases d'
            rfl
          suffices (if 0 < d'.decimal_point.val then
                2 * d'.decimal_point.val.toNat +
                  (if HeadOne d' then 0 else 1) else 0) <
              (if 0 < p.val then 2 * p.val.toNat +
                (if HeadOne
                  { num_digits := i, decimal_point := p,
                    truncated := t, digits := a } then 0 else 1) else 0) by
            simpa only [hd'eta] using this
          by_cases hp' : 0 < d'.decimal_point.val
          · simp only [hp, hp', if_true]
            have hpNat : (p.val.toNat : Int) = p.val :=
              Int.toNat_of_nonneg (by omega)
            have hp'Nat : (d'.decimal_point.val.toNat : Int) =
                d'.decimal_point.val := Int.toNat_of_nonneg (by omega)
            have hflagOld : (if HeadOne
                { num_digits := i, decimal_point := p,
                  truncated := t, digits := a } then 0 else 1) <= 1 := by
              split <;> omega
            have hflagNew : (if HeadOne d' then 0 else 1) <= 1 := by
              split <;> omega
            by_cases hp19 : 19 <= p.val
            · rcases hlarge hp19 with h | h <;> omega
            · by_cases hp2 : 2 <= p.val
              · rcases hsmall (by omega) with h | h <;> omega
              · have hp1 : p.val = 1 := by omega
                by_cases hh : HeadOne
                    { num_digits := i, decimal_point := p,
                      truncated := t, digits := a }
                · have hz := hnoStall hp1 hh
                  omega
                · rcases hsmall (by omega) with hz | hz
                  · omega
                  · have hh' : HeadOne d' := hstall hp1 hz
                    simp only [hh, hh', if_false, if_true]
                    omega
          · simp only [hp, hp', if_true, if_false]
            omega
      · have hpnot : ¬ p > 0#i32 := by
          change ¬ p.val > 0
          omega
        unfold num.imp.dec2flt.slow.parse_long_mantissa_loop0.body
        simp [hpnot]
        simp only [Post, Inv, recordOf, exponentOf, resultOf]
        exact ⟨⟨by simp, hpLo, hpHi, heLo, s, heHi, hbudget, hshape,
          hend⟩, by omega⟩
    · exact hinit
  obtain ⟨out, hcall, hout⟩ := Aeneas.Std.WP.spec_imp_exists hspec
  rcases out with ⟨i0, p0, t0, a0, e0, lr0⟩
  simp only [Post, Inv, recordOf, exponentOf, resultOf] at hout
  rcases hout with
    ⟨⟨hlr0, hp0Lo, hp0Hi, he0Lo, steps, he0Hi, hbudget0,
      hshape0, hend0⟩, hp0Upper⟩
  have hsteps : steps <= 21 := (hbudget0.2.2.2.2 hp0Upper).trans (by omega)
  let d0 : num.imp.dec2flt.decimal_seq.DecimalSeq :=
    { num_digits := i0, decimal_point := p0, truncated := t0, digits := a0 }
  have hAmin : (10 : Real) ^ (-(325 : Int)) <= A := by
    rcases hcanonical with ⟨hcap, hdigit, hshapePack, hcanonicalA⟩
    rcases hshapePack with ⟨z, zs, hshape, hzLo, hzHi, hlen⟩
    rcases hcanonicalA with ⟨eta, hA, heta0, hetaCut, hsticky⟩
    have hv := P804_T1_DecimalValueBounds
      ((d.digits.val.take d.num_digits.val).map (fun q => q.val))
      z zs hshape hzLo (by
        intro q hq
        simp only [List.mem_map] at hq
        rcases hq with ⟨u, hu, rfl⟩
        exact hdigit u hu) d.decimal_point.val
    dsimp only at hv
    rw [hlen] at hv
    have hpw : (10 : Real) ^ (-(325 : Int)) <=
        (10 : Real) ^ (d.decimal_point.val - 1) :=
      zpow_le_zpow_right₀ (by norm_num) (by omega)
    have hzreal : (1 : Real) <= z := by exact_mod_cast hzLo
    have htenpos : 0 <= (10 : Real) ^ (d.decimal_point.val - 1) :=
      le_of_lt (zpow_pos (by norm_num) _)
    have hlead : (10 : Real) ^ (d.decimal_point.val - 1) <=
        (z : Real) * (10 : Real) ^ (d.decimal_point.val - 1) := by
      nlinarith
    rw [hA]
    exact le_trans hpw (le_trans hlead (le_trans hv.1 (by linarith)))
  refine ⟨d0, e0, steps, ?_, hsteps, he0Lo, he0Hi, hAmin,
    hp0Lo, hp0Upper, ?_⟩
  · simpa [d0, hlr0] using hcall
  · constructor
    · intro n
      rcases lt_or_ge n 19 with hn | hn
      · interval_cases n <;> simp
      · simp [show n ≠ 0 by omega, show n ≠ 1 by omega,
          show n ≠ 2 by omega, show n ≠ 3 by omega,
          show n ≠ 4 by omega, show n ≠ 5 by omega,
          show n ≠ 6 by omega, show n ≠ 7 by omega,
          show n ≠ 8 by omega, show n ≠ 9 by omega,
          show n ≠ 10 by omega, show n ≠ 11 by omega,
          show n ≠ 12 by omega, show n ≠ 13 by omega,
          show n ≠ 14 by omega, show n ≠ 15 by omega,
          show n ≠ 16 by omega, show n ≠ 17 by omega,
          show n ≠ 18 by omega]
    · rcases hshape0 with ⟨hcap0, hdigit0, hpositive0⟩
      refine ⟨?_, ?_, ?_, ?_⟩
      · simpa [d0] using hcap0
      · simpa [d0] using hdigit0
      · simpa [Digits, d0] using hpositive0
      · simpa [Endpoints, Value, Digits, d0] using hend0

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.DecimalSeqRightShiftCanonical
import Tablet.P804_T1_DecimalValueBounds
import Tablet.P804_T1_RightLoopStep
import Tablet.DecimalRightShiftLoop0Execution
import Tablet.ParserSlowEarlyExits
import Tablet.SlowShiftSelectorCertificate
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_MAX_SHIFT
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_NUM_POWERS
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_POWERS
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: ParserSlowLoop0]
theorem ParserSlowLoop0 :
    forall (A B : Real) (d : num.imp.dec2flt.decimal_seq.DecimalSeq),
      d.num_digits.val != 0 ->
      -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)) ->
      exists (d0 : num.imp.dec2flt.decimal_seq.DecimalSeq)
        (exp0 : Std.I32) (steps : Nat),
        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) /\
        steps <= 21 /\ 0 <= exp0.val /\ exp0.val <= (60 : Int) * steps /\
        (10 : Real) ^ (-(325 : Int)) <= A /\
        -324 <= d0.decimal_point.val /\ d0.decimal_point.val <= 0 /\
        let selector : Nat -> Nat := fun n => match n with
          | 0 => 0 | 1 => 3 | 2 => 6 | 3 => 9 | 4 => 13 | 5 => 16
          | 6 => 19 | 7 => 23 | 8 => 26 | 9 => 29 | 10 => 33
          | 11 => 36 | 12 => 39 | 13 => 43 | 14 => 46 | 15 => 49
          | 16 => 53 | 17 => 56 | 18 => 59 | _ => 60
        (forall n, selector n <= 60) /\
        let digits0 :=
          (d0.digits.val.take d0.num_digits.val).map (fun z => z.val)
        let integer0 : Nat := digits0.foldl (fun n digit => 10 * n + digit) 0
        let value0 : Real := integer0 * (10 : Real) ^
          (d0.decimal_point.val - (d0.num_digits.val : Int))
        d0.num_digits.val <= 768 /\
        (forall z, z ∈ d0.digits.val.take d0.num_digits.val -> z.val < 10) /\
        (exists z zs, digits0 = z :: zs /\ 1 <= z /\ z < 10 /\
          digits0.length = d0.num_digits.val) /\
        exists eta0 u0 : Real,
          A / (2 : Real) ^ exp0.val = value0 + eta0 /\
          B / (2 : Real) ^ exp0.val = value0 + u0 /\
          0 <= eta0 /\ eta0 < u0 /\
          (d0.truncated = true <-> 0 < eta0) := by
-- BODY
  dsimp only
  intro A B d hdne hpLower hpUpper hB hcanonical
  classical
  let State := Std.Usize × Std.I32 × Bool × Array Std.U8 768#usize ×
    Std.I32 × Option num.imp.dec2flt.common.BiasedFp
  let recordOf : State -> num.imp.dec2flt.decimal_seq.DecimalSeq := fun x =>
    { num_digits := x.1, decimal_point := x.2.1, truncated := x.2.2.1,
      digits := x.2.2.2.1 }
  let exponentOf : State -> Std.I32 := fun x => x.2.2.2.2.1
  let resultOf : State -> Option num.imp.dec2flt.common.BiasedFp := fun x =>
    x.2.2.2.2.2
  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))
  let Shape := fun q : num.imp.dec2flt.decimal_seq.DecimalSeq =>
    q.num_digits.val <= 768 /\
    (forall z, z ∈ q.digits.val.take q.num_digits.val -> z.val < 10) /\
    (exists z zs, Digits q = z :: zs /\ 1 <= z /\ z < 10 /\
      (Digits q).length = q.num_digits.val)
  let Endpoints := fun (q : num.imp.dec2flt.decimal_seq.DecimalSeq)
      (e : Std.I32) =>
    exists eta u : Real,
      A / (2 : Real) ^ e.val = Value q + eta /\
      B / (2 : Real) ^ e.val = Value q + u /\
      0 <= eta /\ eta < u /\
      (q.truncated = true <-> 0 < eta)
  let HeadOne := fun q : num.imp.dec2flt.decimal_seq.DecimalSeq =>
    exists tail, Digits q = 1 :: tail
  let Budget := fun (q : num.imp.dec2flt.decimal_seq.DecimalSeq) (s : Nat) =>
    (19 <= q.decimal_point.val ->
      (18 : Int) * s + q.decimal_point.val <= 309) /\
    (2 <= q.decimal_point.val -> q.decimal_point.val <= 18 -> s <= 17) /\
    (q.decimal_point.val = 1 -> HeadOne q -> s <= 19) /\
    (q.decimal_point.val = 1 -> Not (HeadOne q) -> s <= 18) /\
    (q.decimal_point.val <= 0 -> s <= 20)
  let Inv := fun x : State =>
    resultOf x = none /\
    -324 <= (recordOf x).decimal_point.val /\
    (recordOf x).decimal_point.val < 310 /\
    0 <= (exponentOf x).val /\
    exists s : Nat,
      (exponentOf x).val <= (60 : Int) * s /\
      Budget (recordOf x) s /\
      Shape (recordOf x) /\ Endpoints (recordOf x) (exponentOf x)
  let Post := fun x : State => Inv x /\ (recordOf x).decimal_point.val <= 0
  let Measure := fun x : State =>
    if 0 < (recordOf x).decimal_point.val then
      2 * (recordOf x).decimal_point.val.toNat +
        (if HeadOne (recordOf x) then 0 else 1)
    else 0
  let Body := fun x : State =>
    num.imp.dec2flt.slow.parse_long_mantissa_loop0.body
      F64.Insts.Dec2flt_modelNumImpTraitsFloatU64
      { m := 0#u64, p_biased := 0#i32 }
      x.1 x.2.1 x.2.2.1 x.2.2.2.1 x.2.2.2.2.1 x.2.2.2.2.2
  have hinitShape : Shape d := by
    exact ⟨hcanonical.1, hcanonical.2.1, hcanonical.2.2.1⟩
  have hinitEndpoints : Endpoints d 0#i32 := by
    rcases hcanonical.2.2.2 with
      ⟨eta, hA, heta0, hetaCut, hsticky⟩
    refine ⟨eta, (10 : Real) ^ (d.decimal_point.val - 768), ?_, ?_,
      heta0, hetaCut, hsticky⟩
    · simpa [Endpoints, Value, Digits] using hA
    · simpa [Endpoints, Value, Digits] using hB
  have hinitBudget : Budget d 0 := by
    simp only [Budget]
    constructor
    · intro _
      omega
    constructor <;> omega
  have hinit : Inv
      (d.num_digits, d.decimal_point, d.truncated, d.digits, 0#i32, none) := by
    simp only [Inv, recordOf, exponentOf, resultOf]
    refine ⟨by simp, hpLower, hpUpper, by norm_num, 0, by norm_num,
      hinitBudget, hinitShape, hinitEndpoints⟩
  have hspec :
      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
        ⦃ Post ⦄ := by
    unfold num.imp.dec2flt.slow.parse_long_mantissa_loop0
    apply Aeneas.Std.loop.spec_decr_nat Measure Inv Post Body
      (d.num_digits, d.decimal_point, d.truncated, d.digits, 0#i32, none)
    · intro x hx
      rcases x with ⟨i, p, t, a, e, lr⟩
      simp only [Inv, recordOf, exponentOf, resultOf] at hx
      rcases hx with ⟨hlr, hpLo, hpHi, heLo, s, heHi, hbudget,
        hshape, hend⟩
      simp only [Budget] at hbudget
      simp only [Shape, Digits] at hshape
      simp only [Endpoints, Value, Digits] at hend
      simp only [Body, Prod.fst, Prod.snd]
      rw [hlr]
      by_cases hp : 0 < p.val
      · have hstep := P804_T1_RightLoopStep
          (A / (2 : Real) ^ e.val) (B / (2 : Real) ^ e.val)
          { num_digits := i, decimal_point := p, truncated := t, digits := a }
          e hp (by omega) heLo (by
            have hs20 : s <= 20 := by
              by_cases hp19 : 19 <= p.val
              · have h := hbudget.1 hp19
                omega
              · by_cases hp2 : 2 <= p.val
                · exact (hbudget.2.1 hp2 (by omega)).trans (by omega)
                · have hp1 : p.val = 1 := by omega
                  by_cases hh : HeadOne
                      { num_digits := i, decimal_point := p,
                        truncated := t, digits := a }
                  · exact (hbudget.2.2.1 hp1 hh).trans (by omega)
                  · exact (hbudget.2.2.2.1 hp1 hh).trans (by omega)
            omega) hshape hend
        rcases hstep with ⟨d', shift, e', read, acc, hbody, hright,
          hk, he', hlarge, hsmall, hshapeEnd, hstall, hnoStall⟩
        change (19 <= p.val -> d'.decimal_point.val = p.val - 18 \/
          d'.decimal_point.val = p.val - 19) at hlarge
        change (p.val <= 18 -> d'.decimal_point.val = 0 \/
          d'.decimal_point.val = 1) at hsmall
        rcases hshapeEnd with ⟨hcap', hdigit', hpositive', hend'⟩
        have hshape' : Shape d' := by
          exact ⟨hcap', hdigit', hpositive'⟩
        have he'Lo : 0 <= e'.val := by omega
        have he'Hi : e'.val <= (60 : Int) * (s + 1) := by
          rw [he']
          norm_num only [Nat.cast_add, Nat.cast_one]
          nlinarith
        have hscaleA :
            (A / (2 : Real) ^ e.val) / (2 : Real) ^ shift.val =
              A / (2 : Real) ^ e'.val := by
          rw [he', zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
          norm_num only [zpow_natCast]
          rw [div_div]
        have hscaleB :
            (B / (2 : Real) ^ e.val) / (2 : Real) ^ shift.val =
              B / (2 : Real) ^ e'.val := by
          rw [he', zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
          norm_num only [zpow_natCast]
          rw [div_div]
        have hendNext : Endpoints d' e' := by
          rcases hend' with ⟨eta, u, hA, hB', heta, hetau, hsticky⟩
          refine ⟨eta, u, ?_, ?_, heta, hetau, hsticky⟩
          · rw [← hscaleA]
            exact hA
          · rw [← hscaleB]
            exact hB'
        have hp'Lo : -324 <= d'.decimal_point.val := by
          by_cases hp19 : 19 <= p.val
          · rcases hlarge hp19 with h | h <;> omega
          · rcases hsmall (by omega) with h | h <;> omega
        have hp'Hi : d'.decimal_point.val < 310 := by
          by_cases hp19 : 19 <= p.val
          · rcases hlarge hp19 with h | h <;> omega
          · rcases hsmall (by omega) with h | h <;> omega
        have hbudgetNext : Budget d' (s + 1) := by
          have hheadStall : p.val = 1 -> d'.decimal_point.val = 1 ->
              HeadOne d' := by
            intro hp1 hp1'
            exact hstall hp1 hp1'
          have hnostall : p.val = 1 -> HeadOne
              { num_digits := i, decimal_point := p,
                truncated := t, digits := a } ->
              d'.decimal_point.val = 0 := by
            exact hnoStall
          constructor
          · intro hp'19
            have hp19 : 19 <= p.val := by
              by_contra h
              rcases hsmall (by omega) with h | h <;> omega
            have hold := hbudget.1 hp19
            rcases hlarge hp19 with h | h <;> omega
          constructor
          · intro hp'2 hp'18
            by_cases hp19 : 19 <= p.val
            · have hold := hbudget.1 hp19
              rcases hlarge hp19 with h | h <;> omega
            · by_cases hp2 : 2 <= p.val
              · have hold := hbudget.2.1 hp2 (by omega)
                rcases hsmall (by omega) with h | h <;> omega
              · have hp1 : p.val = 1 := by omega
                rcases hsmall (by omega) with h | h <;> omega
          constructor
          · intro hp'1 hh'
            by_cases hp19 : 19 <= p.val
            · have hold := hbudget.1 hp19
              rcases hlarge hp19 with h | h <;> omega
            · by_cases hp2 : 2 <= p.val
              · have hold := hbudget.2.1 hp2 (by omega)
                omega
              · have hp1 : p.val = 1 := by omega
                by_cases hh : HeadOne
                    { num_digits := i, decimal_point := p,
                      truncated := t, digits := a }
                · have hold := hbudget.2.2.1 hp1 hh
                  have hz := hnostall hp1 hh
                  omega
                · have hold := hbudget.2.2.2.1 hp1 hh
                  omega
          constructor
          · intro hp'1 hh'
            by_cases hp19 : 19 <= p.val
            · have hold := hbudget.1 hp19
              rcases hlarge hp19 with h | h <;> omega
            · by_cases hp2 : 2 <= p.val
              · have hold := hbudget.2.1 hp2 (by omega)
                omega
              · have hp1 : p.val = 1 := by omega
                have hs := hheadStall hp1 hp'1
                exact False.elim (hh' hs)
          · intro hp'0
            by_cases hp19 : 19 <= p.val
            · have hold := hbudget.1 hp19
              rcases hlarge hp19 with h | h <;> omega
            · by_cases hp2 : 2 <= p.val
              · have hold := hbudget.2.1 hp2 (by omega)
                omega
              · have hp1 : p.val = 1 := by omega
                by_cases hh : HeadOne
                    { num_digits := i, decimal_point := p,
                      truncated := t, digits := a }
                · have hold := hbudget.2.2.1 hp1 hh
                  omega
                · have hold := hbudget.2.2.2.1 hp1 hh
                  omega
        rw [hbody]
        simp only [WP.spec_ok]
        constructor
        · simp only [Inv, recordOf, exponentOf, resultOf]
          exact ⟨by simp, hp'Lo, hp'Hi, he'Lo, s + 1, he'Hi,
            hbudgetNext, hshape', hendNext⟩
        · simp only [Measure, recordOf]
          have hd'eta :
              ({ num_digits := d'.num_digits,
                 decimal_point := d'.decimal_point,
                 truncated := d'.truncated,
                 digits := d'.digits } :
                num.imp.dec2flt.decimal_seq.DecimalSeq) = d' := by
            cases d'
            rfl
          suffices (if 0 < d'.decimal_point.val then
                2 * d'.decimal_point.val.toNat +
                  (if HeadOne d' then 0 else 1) else 0) <
              (if 0 < p.val then 2 * p.val.toNat +
                (if HeadOne
                  { num_digits := i, decimal_point := p,
                    truncated := t, digits := a } then 0 else 1) else 0) by
            simpa only [hd'eta] using this
          by_cases hp' : 0 < d'.decimal_point.val
          · simp only [hp, hp', if_true]
            have hpNat : (p.val.toNat : Int) = p.val :=
              Int.toNat_of_nonneg (by omega)
            have hp'Nat : (d'.decimal_point.val.toNat : Int) =
                d'.decimal_point.val := Int.toNat_of_nonneg (by omega)
            have hflagOld : (if HeadOne
                { num_digits := i, decimal_point := p,
                  truncated := t, digits := a } then 0 else 1) <= 1 := by
              split <;> omega
            have hflagNew : (if HeadOne d' then 0 else 1) <= 1 := by
              split <;> omega
            by_cases hp19 : 19 <= p.val
            · rcases hlarge hp19 with h | h <;> omega
            · by_cases hp2 : 2 <= p.val
              · rcases hsmall (by omega) with h | h <;> omega
              · have hp1 : p.val = 1 := by omega
                by_cases hh : HeadOne
                    { num_digits := i, decimal_point := p,
                      truncated := t, digits := a }
                · have hz := hnoStall hp1 hh
                  omega
                · rcases hsmall (by omega) with hz | hz
                  · omega
                  · have hh' : HeadOne d' := hstall hp1 hz
                    simp only [hh, hh', if_false, if_true]
                    omega
          · simp only [hp, hp', if_true, if_false]
            omega
      · have hpnot : ¬ p > 0#i32 := by
          change ¬ p.val > 0
          omega
        unfold num.imp.dec2flt.slow.parse_long_mantissa_loop0.body
        simp [hpnot]
        simp only [Post, Inv, recordOf, exponentOf, resultOf]
        exact ⟨⟨by simp, hpLo, hpHi, heLo, s, heHi, hbudget, hshape,
          hend⟩, by omega⟩
    · exact hinit
  obtain ⟨out, hcall, hout⟩ := Aeneas.Std.WP.spec_imp_exists hspec
  rcases out with ⟨i0, p0, t0, a0, e0, lr0⟩
  simp only [Post, Inv, recordOf, exponentOf, resultOf] at hout
  rcases hout with
    ⟨⟨hlr0, hp0Lo, hp0Hi, he0Lo, steps, he0Hi, hbudget0,
      hshape0, hend0⟩, hp0Upper⟩
  have hsteps : steps <= 21 := (hbudget0.2.2.2.2 hp0Upper).trans (by omega)
  let d0 : num.imp.dec2flt.decimal_seq.DecimalSeq :=
    { num_digits := i0, decimal_point := p0, truncated := t0, digits := a0 }
  have hAmin : (10 : Real) ^ (-(325 : Int)) <= A := by
    rcases hcanonical with ⟨hcap, hdigit, hshapePack, hcanonicalA⟩
    rcases hshapePack with ⟨z, zs, hshape, hzLo, hzHi, hlen⟩
    rcases hcanonicalA with ⟨eta, hA, heta0, hetaCut, hsticky⟩
    have hv := P804_T1_DecimalValueBounds
      ((d.digits.val.take d.num_digits.val).map (fun q => q.val))
      z zs hshape hzLo (by
        intro q hq
        simp only [List.mem_map] at hq
        rcases hq with ⟨u, hu, rfl⟩
        exact hdigit u hu) d.decimal_point.val
    dsimp only at hv
    rw [hlen] at hv
    have hpw : (10 : Real) ^ (-(325 : Int)) <=
        (10 : Real) ^ (d.decimal_point.val - 1) :=
      zpow_le_zpow_right₀ (by norm_num) (by omega)
    have hzreal : (1 : Real) <= z := by exact_mod_cast hzLo
    have htenpos : 0 <= (10 : Real) ^ (d.decimal_point.val - 1) :=
      le_of_lt (zpow_pos (by norm_num) _)
    have hlead : (10 : Real) ^ (d.decimal_point.val - 1) <=
        (z : Real) * (10 : Real) ^ (d.decimal_point.val - 1) := by
      nlinarith
    rw [hA]
    exact le_trans hpw (le_trans hlead (le_trans hv.1 (by linarith)))
  refine ⟨d0, e0, steps, ?_, hsteps, he0Lo, he0Hi, hAmin,
    hp0Lo, hp0Upper, ?_⟩
  · simpa [d0, hlr0] using hcall
  · constructor
    · intro n
      rcases lt_or_ge n 19 with hn | hn
      · interval_cases n <;> simp
      · simp [show n ≠ 0 by omega, show n ≠ 1 by omega,
          show n ≠ 2 by omega, show n ≠ 3 by omega,
          show n ≠ 4 by omega, show n ≠ 5 by omega,
          show n ≠ 6 by omega, show n ≠ 7 by omega,
          show n ≠ 8 by omega, show n ≠ 9 by omega,
          show n ≠ 10 by omega, show n ≠ 11 by omega,
          show n ≠ 12 by omega, show n ≠ 13 by omega,
          show n ≠ 14 by omega, show n ≠ 15 by omega,
          show n ≠ 16 by omega, show n ≠ 17 by omega,
          show n ≠ 18 by omega]
    · rcases hshape0 with ⟨hcap0, hdigit0, hpositive0⟩
      refine ⟨?_, ?_, ?_, ?_⟩
      · simpa [d0] using hcap0
      · simpa [d0] using hdigit0
      · simpa [Digits, d0] using hpositive0
      · simpa [Endpoints, Value, Digits, d0] using hend0

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 124 entries
Technical checking records
Local closure summary
{
  "node": "ParserSlowLoop0",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "7e0460583ba0e702d40649410d6347642f1a9e70950112810b752f2676c3615c",
  "active_statement_hash": "0afa768f1a4a573d4d2b8ebe3a32221f8cac9f477fd80422e4483d311422e249",
  "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-192",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "P804_T1_DecimalValueBounds": "4b5c924b5d52bc9d",
    "P804_T1_RightLoopStep": "10bf9572ca2b2ae4",
    "num_imp_dec2flt_slow_parse_long_mantissa": "d2b4145772dccc04"
  },
  "strict_definition_deps": {
    "F64": "ec4e25fbaf4e11d4",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64": "94095c9bf79da164",
    "num_imp_dec2flt_common_BiasedFp": "63baac539d218a81",
    "num_imp_dec2flt_decimal_seq_DecimalSeq": "92d5f91a5a106668",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_DECIMAL_POINT_RANGE": "0cc5155758bc976a",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift": "1aaf1bb11c0b6a49",
    "num_imp_dec2flt_slow_parse_long_mantissa": "0ce7bdcf55d68c29",
    "num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call": "7df8a2c8e3717790"
  }
}
Prose assessment
{
  "label": "Sound flag superseded by recorded Lean closure",
  "assessment_status": "VerifierFail",
  "fingerprint_relation": "differs from current fingerprint",
  "assessment_fingerprint": "sound-v2:d8cfae5092d99d7d1dca580982ddf65036c5d789323d8247982b7bc235e4a7f0",
  "current_fingerprint": "sound-v2:93f38d17db2f2d08c23ee6a5dafcec908d10119e3cee71354905f9edd6f74dc5",
  "superseded_for_theorem_closure": true
}
Review verdicts
{
  "corr_status": "Pass",
  "sound_status": "Fail",
  "substantiveness_status": "Pass"
}