ParserSlowFirstRoundSeparation

Lean checked

Statement

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

Lemma · Reachable first-round midpoint separation

Let A<B arise from the original regular parsed record d and its adjacent 768-cell endpoint, exactly as stated in Lean. Retain the exact loop-0, loop-1, checked-decrement, and loop-2 histories and the transported endpoint state of d_2 at exponent e_2+1. Then the extracted 53-bit left shift succeeds, producing a terminally trimmed decimal record d_3 for
Z=A/2^{e_2-52},\qquad B_3=B/2^{e_2-52}.
It has the record, point, and U64-range bounds in Lean and witnesses Z=V(d_3)+\eta_3, B_3=V(d_3)+u_3 with 0\leq\eta_3<u_3 and exact sticky equivalence. Moreover, for every natural n,
n+\tfrac12\leq V(d_3)\quad\hbox{or}\quad B_3\leq n+\tfrac12. \tag{1}

Lean statement

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

import Tablet.DecimalSeqLeftShiftCanonical
import Tablet.ParserSlowLoop0
import Tablet.ParserSlowLoop1
import Tablet.ParserSlowLoop2
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.P856_T1_SeparationPackage

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: ParserSlowFirstRoundSeparation]
theorem ParserSlowFirstRoundSeparation :
    forall (A B : Real)
      (d d0 d1 d2 : num.imp.dec2flt.decimal_seq.DecimalSeq)
      (exp0 exp1 expStart exp2 : 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))
      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) /\
      B = value + cutoff /\
      (exists eta : Real,
        A = value + eta /\ 0 <= eta /\ eta < cutoff /\
        (d.truncated = true <-> 0 < eta)) ->
      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) ->
      exp1 - 1#i32 = ok expStart ->
      num.imp.dec2flt.slow.parse_long_mantissa_loop2
        F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 d1 expStart =
          ok (d2, exp2) ->
      let digits2 :=
        (d2.digits.val.take d2.num_digits.val).map (fun z => z.val)
      let integer2 : Nat := digits2.foldl (fun n digit => 10 * n + digit) 0
      let value2 : Real := integer2 * (10 : Real) ^
        (d2.decimal_point.val - (d2.num_digits.val : Int))
      d2.num_digits.val <= 768 /\
      (forall z, z ∈ d2.digits.val.take d2.num_digits.val -> z.val < 10) /\
      (exists z zs, digits2 = z :: zs /\ 1 <= z /\ z < 10 /\
        digits2.length = d2.num_digits.val) /\
      (exists eta2 u2 : Real,
        A / (2 : Real) ^ (exp2.val + 1) = value2 + eta2 /\
        B / (2 : Real) ^ (exp2.val + 1) = value2 + u2 /\
        0 <= eta2 /\ eta2 < u2 /\
        (d2.truncated = true <-> 0 < eta2)) ->
      exists d3 : num.imp.dec2flt.decimal_seq.DecimalSeq,
        num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift d2 53#usize = ok d3 /\
        let digits3 :=
          (d3.digits.val.take d3.num_digits.val).map (fun z => z.val)
        let integer3 : Nat := digits3.foldl (fun n digit => 10 * n + digit) 0
        let value3 : Real := integer3 * (10 : Real) ^
          (d3.decimal_point.val - (d3.num_digits.val : Int))
        d3.num_digits.val <= 768 /\
        (forall z, z ∈ d3.digits.val.take d3.num_digits.val -> z.val < 10) /\
        (exists z zs, digits3 = z :: zs /\ 1 <= z /\ z < 10 /\
          digits3.length = d3.num_digits.val /\ digits3.getLast? != some 0) /\
        (exists eta3 u3 : Real,
          A / (2 : Real) ^ (exp2.val - 52) = value3 + eta3 /\
          B / (2 : Real) ^ (exp2.val - 52) = value3 + u3 /\
          0 <= eta3 /\ eta3 < u3 /\
          (d3.truncated = true <-> 0 < eta3)) /\
        d3.decimal_point.val < 19 /\
        0 <= A / (2 : Real) ^ (exp2.val - 52) /\
        A / (2 : Real) ^ (exp2.val - 52) <
          (2 : Real) ^ (64 : Nat) - (1 / 2 : Real) /\
        forall n : Nat,
          (n : Real) + (1 / 2 : Real) <= value3 \/
            B / (2 : Real) ^ (exp2.val - 52) <=
              (n : Real) + (1 / 2 : Real) := 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

Apply SeparationPackage to the initial adjacent-cell package, the exact loop-0 and loop-1 histories, the successful checked decrement, the exact loop-2 history, and the stated endpoint package for d_2. Its statement supplies a record d_3 returned by the exact 53-bit left shift and asserts all of the following for that same record: the 768-digit bound, decimal-digit bound, positive leading digit, recorded length, nonzero final digit, endpoint equations at reference exponent e_2-52, ordered errors and sticky equivalence, point bound, nonnegative lower endpoint, U64-range upper bound, and midpoint separation (1).
These are exactly the conjuncts required here, in the same order and with the same definitions of the retained digit list, its base-ten fold, and V(d_3). Project the listed conjuncts from the package; its additional odd-integer separation conjunct is not needed for this theorem.

Lean proof


  dsimp only
  intro A B d d0 d1 d2 exp0 exp1 expStart exp2 hpLo hpHi hinitial
    hloop0 hloop1 hsub hloop2 hstate2
  have hpackage := P856_T1_SeparationPackage A B d d0 d1 d2
    exp0 exp1 expStart exp2 hpLo hpHi hinitial hloop0 hloop1 hsub hloop2
    hstate2
  rcases hpackage with ⟨d3, hleft, hrest⟩
  refine ⟨d3, hleft, ?_⟩
  dsimp only at hrest ⊢
  rcases hrest with
    ⟨hcap3, hdigit3, hpositive3, hend3, hpoint3, hnonneg, hupper,
      hhalf, hodd⟩
  exact ⟨hcap3, hdigit3, hpositive3, hend3, hpoint3, hnonneg, hupper,
    hhalf⟩

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.DecimalSeqLeftShiftCanonical
import Tablet.ParserSlowLoop0
import Tablet.ParserSlowLoop1
import Tablet.ParserSlowLoop2
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.P856_T1_SeparationPackage

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: ParserSlowFirstRoundSeparation]
theorem ParserSlowFirstRoundSeparation :
    forall (A B : Real)
      (d d0 d1 d2 : num.imp.dec2flt.decimal_seq.DecimalSeq)
      (exp0 exp1 expStart exp2 : 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))
      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) /\
      B = value + cutoff /\
      (exists eta : Real,
        A = value + eta /\ 0 <= eta /\ eta < cutoff /\
        (d.truncated = true <-> 0 < eta)) ->
      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) ->
      exp1 - 1#i32 = ok expStart ->
      num.imp.dec2flt.slow.parse_long_mantissa_loop2
        F64.Insts.Dec2flt_modelNumImpTraitsFloatU64 d1 expStart =
          ok (d2, exp2) ->
      let digits2 :=
        (d2.digits.val.take d2.num_digits.val).map (fun z => z.val)
      let integer2 : Nat := digits2.foldl (fun n digit => 10 * n + digit) 0
      let value2 : Real := integer2 * (10 : Real) ^
        (d2.decimal_point.val - (d2.num_digits.val : Int))
      d2.num_digits.val <= 768 /\
      (forall z, z ∈ d2.digits.val.take d2.num_digits.val -> z.val < 10) /\
      (exists z zs, digits2 = z :: zs /\ 1 <= z /\ z < 10 /\
        digits2.length = d2.num_digits.val) /\
      (exists eta2 u2 : Real,
        A / (2 : Real) ^ (exp2.val + 1) = value2 + eta2 /\
        B / (2 : Real) ^ (exp2.val + 1) = value2 + u2 /\
        0 <= eta2 /\ eta2 < u2 /\
        (d2.truncated = true <-> 0 < eta2)) ->
      exists d3 : num.imp.dec2flt.decimal_seq.DecimalSeq,
        num.imp.dec2flt.decimal_seq.DecimalSeq.left_shift d2 53#usize = ok d3 /\
        let digits3 :=
          (d3.digits.val.take d3.num_digits.val).map (fun z => z.val)
        let integer3 : Nat := digits3.foldl (fun n digit => 10 * n + digit) 0
        let value3 : Real := integer3 * (10 : Real) ^
          (d3.decimal_point.val - (d3.num_digits.val : Int))
        d3.num_digits.val <= 768 /\
        (forall z, z ∈ d3.digits.val.take d3.num_digits.val -> z.val < 10) /\
        (exists z zs, digits3 = z :: zs /\ 1 <= z /\ z < 10 /\
          digits3.length = d3.num_digits.val /\ digits3.getLast? != some 0) /\
        (exists eta3 u3 : Real,
          A / (2 : Real) ^ (exp2.val - 52) = value3 + eta3 /\
          B / (2 : Real) ^ (exp2.val - 52) = value3 + u3 /\
          0 <= eta3 /\ eta3 < u3 /\
          (d3.truncated = true <-> 0 < eta3)) /\
        d3.decimal_point.val < 19 /\
        0 <= A / (2 : Real) ^ (exp2.val - 52) /\
        A / (2 : Real) ^ (exp2.val - 52) <
          (2 : Real) ^ (64 : Nat) - (1 / 2 : Real) /\
        forall n : Nat,
          (n : Real) + (1 / 2 : Real) <= value3 \/
            B / (2 : Real) ^ (exp2.val - 52) <=
              (n : Real) + (1 / 2 : Real) := by
-- BODY
  dsimp only
  intro A B d d0 d1 d2 exp0 exp1 expStart exp2 hpLo hpHi hinitial
    hloop0 hloop1 hsub hloop2 hstate2
  have hpackage := P856_T1_SeparationPackage A B d d0 d1 d2
    exp0 exp1 expStart exp2 hpLo hpHi hinitial hloop0 hloop1 hsub hloop2
    hstate2
  rcases hpackage with ⟨d3, hleft, hrest⟩
  refine ⟨d3, hleft, ?_⟩
  dsimp only at hrest ⊢
  rcases hrest with
    ⟨hcap3, hdigit3, hpositive3, hend3, hpoint3, hnonneg, hupper,
      hhalf, hodd⟩
  exact ⟨hcap3, hdigit3, hpositive3, hend3, hpoint3, hnonneg, hupper,
    hhalf⟩

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 165 entries
Technical checking records
Local closure summary
{
  "node": "ParserSlowFirstRoundSeparation",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "6e2b88b953c46d5715fa0148d6078d864de691b50d1371ffcb8a50878f0db25c",
  "active_statement_hash": "c0b3d61b0864bbd7b03deb8a451cc6346873fa71203d0119736678a4a48d6bad",
  "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": {
    "P856_T1_SeparationPackage": "a19fe6c55bc79310"
  },
  "strict_definition_deps": {
    "F64": "ec4e25fbaf4e11d4",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64": "94095c9bf79da164",
    "num_imp_dec2flt_common_BiasedFp": "63baac539d218a81",
    "num_imp_dec2flt_decimal_seq_DecimalSeq": "b0286c42454b158d",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift": "fd298e37d5ae4f86",
    "num_imp_dec2flt_slow_parse_long_mantissa": "71d9bebe88212f80"
  }
}
Prose assessment
{
  "label": "Sound flag superseded by recorded Lean closure",
  "assessment_status": "VerifierFail",
  "fingerprint_relation": "differs from current fingerprint",
  "assessment_fingerprint": "sound-v2:372a54771dd8a931d6e20f67f673301958e9ac190d3eb85a68fac923b0415d9f",
  "current_fingerprint": "sound-v2:2a8bc64a09a43f61ce23e7b0412aa9086be6cf6727055dfbda46bf31c27321e4",
  "superseded_for_theorem_closure": true
}
Review verdicts
{
  "corr_status": "Pass",
  "sound_status": "Fail",
  "substantiveness_status": "Pass"
}