P856_T1_OddIntegerSeparation

Lean checked

Statement

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

Lemma · Reachable odd-integer separation before the carry shift

Under the complete initial adjacent-cell package and exact loop-0, loop-1, checked-decrement, and loop-2 histories displayed in Lean, let the exact 53-bit left shift of d_2 return the displayed record d_3. Write V_3 for the retained decimal value of d_3. Then, for every n\in\mathbb N,
2n+1\leq V_3\quad\hbox{or}\quad B/2^{e_2-52}\leq2n+1.
Thus no odd integer lies strictly between the retained lower endpoint and the transported upper endpoint at the reference exponent e_2-52.

Lean statement

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

import Tablet.P856_T1_SeparationPackage

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P856_T1_OddIntegerSeparation]
theorem P856_T1_OddIntegerSeparation :
    forall (A B : Real)
      (d d0 d1 d2 d3 : 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)) ->
      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))
      forall n : Nat,
        ((2 * n + 1 : Nat) : Real) <= value3 \/
          B / (2 : Real) ^ (exp2.val - 52) <=
            ((2 * n + 1 : Nat) : 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.

Proof

Apply SeparationPackage to the stated initial package and the four exact operational histories. It supplies a record d_3' returned by the exact same call
d_2.\mathit{left\_shift}(53)=\mathsf{ok}(d_3')
and proves, at reference exponent e_2-52, the odd-integer separation
2n+1\leq V(d_3')\quad\hbox{or}\quad B/2^{e_2-52}\leq2n+1
for every natural n. The hypothesis says the identical deterministic call returns \mathsf{ok}(d_3). Injectivity of the successful result constructor therefore gives d_3'=d_3. Substitution in the displayed separation is exactly the conclusion, including the retained-value formula specified in the Lean statement.

Lean proof


  dsimp only
  intro A B d d0 d1 d2 d3 exp0 exp1 expStart exp2 hpLo hpHi hinitial
    hloop0 hloop1 hsub hloop2 hstate2 hleft
  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⟩
  have hd3 : d3' = d3 := Result.ok.inj (hleft'.symm.trans hleft)
  subst d3'
  dsimp only at hrest
  rcases hrest with
    ⟨hcap3, hdigit3, hpositive3, hend3, hpoint3, hnonneg, hupper,
      hhalf, hodd⟩
  exact hodd

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.P856_T1_SeparationPackage

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P856_T1_OddIntegerSeparation]
theorem P856_T1_OddIntegerSeparation :
    forall (A B : Real)
      (d d0 d1 d2 d3 : 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)) ->
      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))
      forall n : Nat,
        ((2 * n + 1 : Nat) : Real) <= value3 \/
          B / (2 : Real) ^ (exp2.val - 52) <=
            ((2 * n + 1 : Nat) : Real) := by
-- BODY
  dsimp only
  intro A B d d0 d1 d2 d3 exp0 exp1 expStart exp2 hpLo hpHi hinitial
    hloop0 hloop1 hsub hloop2 hstate2 hleft
  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⟩
  have hd3 : d3' = d3 := Result.ok.inj (hleft'.symm.trans hleft)
  subst d3'
  dsimp only at hrest
  rcases hrest with
    ⟨hcap3, hdigit3, hpositive3, hend3, hpoint3, hnonneg, hupper,
      hhalf, hodd⟩
  exact hodd

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": "P856_T1_OddIntegerSeparation",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "0ec4d0933019dee9822e5f336629f81886fcef0be7a887a338373cfc2a029886",
  "active_statement_hash": "caa9a5ed0b5cad696499331211c7f80ca96db4810dece774bc9187a66b4a4e9c",
  "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": "Lean proof closed; predictive prose review no longer required",
  "assessment_status": null,
  "fingerprint_relation": "unknown",
  "assessment_fingerprint": null,
  "current_fingerprint": "sound-v2:15499c48a2fbdd3070765008e7268bf2e92864c4f0e96614c8bdd909d559dac8",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}