P529_T1_FinalShiftCertificate

Lean checked

Statement

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

Lemma · Constructed final 53-bit shift

Let d_2 have -18\le p_2\le0, positive exact-length decimal shape and count at most 768. Suppose
X/2^{e_2+1}=V(d_2)+\eta_2,\quad Y/2^{e_2+1}=V(d_2)+u_2,\quad 0\le\eta_2<u_2,\quad d_2.\mathit{truncated}\iff\eta_2>0, \quad Y/2^{e_2+1}\le1 .
The actual left shift by 53 returns normally to d_3 with -18\le p_3\le16, positive exact-length decimal shape, count at most 768 and nonzero last retained cell. For X_3=X/2^{e_2-52} and Y_3=Y/2^{e_2-52},
0<X_3<2^{53},\quad X_3=V(d_3)+\eta_3,\quad Y_3=V(d_3)+u_3,\quad 0\le\eta_3<u_3,\quad d_3.\mathit{truncated}\iff\eta_3>0 .

Lean statement

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

import Tablet.P529_T1_LeftShiftCertificate
import Tablet.P472_T1_DecimalValueBounds
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model

-- [TABLET NODE: P529_T1_FinalShiftCertificate]
theorem P529_T1_FinalShiftCertificate (X Y : Real)
    (d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (exp2 : Std.I32)
    (hpointLo : -18 <= d2.decimal_point.val)
    (hpointHi : d2.decimal_point.val <= 0)
    (hinput : d2.num_digits.val <= 768 /\
      (forall b, b ∈ d2.digits.val.take d2.num_digits.val -> b.val < 10) /\
      (exists h tail,
        (d2.digits.val.take d2.num_digits.val).map (fun b => b.val) = h :: tail /\
        1 <= h /\ h < 10 /\ (h :: tail).length = d2.num_digits.val))
    (hupper : Y / (2 : Real) ^ (exp2.val + 1) <= 1) :
    let V := fun a : num.imp.dec2flt.decimal_seq.DecimalSeq =>
      ((((a.digits.val.take a.num_digits.val).map (fun b => b.val)).foldl
        (fun n z => 10 * n + z) 0 : Nat) : Real) *
        (10 : Real) ^ (a.decimal_point.val - (a.num_digits.val : Int))
    (exists eta2 u2 : Real,
      X / (2 : Real) ^ (exp2.val + 1) = V d2 + eta2 /\
      Y / (2 : Real) ^ (exp2.val + 1) = V d2 + 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 /\
      -18 <= d3.decimal_point.val /\ d3.decimal_point.val <= 16 /\
      d3.num_digits.val <= 768 /\
      (forall b, b ∈ d3.digits.val.take d3.num_digits.val -> b.val < 10) /\
      (exists h tail,
        (d3.digits.val.take d3.num_digits.val).map (fun b => b.val) = h :: tail /\
        1 <= h /\ h < 10 /\ (h :: tail).length = d3.num_digits.val) /\
      d3.digits.val[d3.num_digits.val - 1]? ≠ some 0#u8 /\
      0 < X / (2 : Real) ^ (exp2.val - 52) /\
      X / (2 : Real) ^ (exp2.val - 52) < (2 : Real) ^ (53 : Nat) /\
      (exists eta3 u3 : Real,
        X / (2 : Real) ^ (exp2.val - 52) = V d3 + eta3 /\
        Y / (2 : Real) ^ (exp2.val - 52) = V d3 + u3 /\
        0 <= eta3 /\ eta3 < u3 /\ (d3.truncated = true <-> 0 < eta3)) := 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

The input point interval is contained in [-324,0], and 53\le60. Apply LeftShiftCertificate to X/2^{e_2+1},Y/2^{e_2+1} and these hypotheses. It constructs the normal shift, positive decimal shape, terminal trimming and ordered endpoint errors. The integer-power law identifies 2^{53}(X/2^{e_2+1})=X/2^{e_2-52}, and likewise for Y. Its point update adds a nonnegative growth, so p_3\ge p_2\ge-18.
The positive input head gives V(d_2)>0 by DecimalValueBounds. Thus 0<X/2^{e_2+1}<Y/2^{e_2+1}\le1. Multiplication by the positive 2^{53} gives 0<X_3<2^{53}. The output endpoint equation with \eta_3\ge0 gives V(d_3)\le X_3. Apply DecimalValueBounds to the output positive exact-length word to obtain 10^{p_3-1}\le V(d_3). Since 2^{53}=9007199254740992<10^{16}, p_3\ge17 would give 10^{16}\le V(d_3)<10^{16}. Hence p_3\le16, and in particular p_3<19. All remaining conclusions are the certificate's output clauses. The shift itself establishes terminal trimming even when the input was an initially capped prefix with a terminal zero.

Lean proof


  intro Vfun hinterval
  rcases hinput with ⟨hcount, hdigits, hshape⟩
  rcases hshape with ⟨head, tail, hword, hheadLo, hheadHi, hlen⟩
  let V := fun a : num.imp.dec2flt.decimal_seq.DecimalSeq =>
    ((((a.digits.val.take a.num_digits.val).map (fun b => b.val)).foldl
      (fun n z => 10 * n + z) 0 : Nat) : Real) *
      (10 : Real) ^ (a.decimal_point.val - (a.num_digits.val : Int))
  let xs := (d2.digits.val.take d2.num_digits.val).map (fun b => b.val)
  have hxs : xs = head :: tail := hword
  have hlenxs : xs.length = d2.num_digits.val := by rw [hxs]; exact hlen
  have hxsDigits : ∀ q, q ∈ xs → q < 10 := by
    intro q hq
    rcases List.mem_map.mp hq with ⟨b, hb, hq⟩
    have hb' := hdigits b hb
    rw [← hq]
    exact hb'
  have hVbounds := P472_T1_DecimalValueBounds xs head tail hxs
    hheadLo hxsDigits d2.decimal_point.val
  have hVpos : 0 < V d2 := by
    have hheadpos : (0 : Real) < (head : Nat) := by exact_mod_cast (by omega : 0 < head)
    have hval := hVbounds.1
    rw [hlenxs] at hval
    have hpowpos : 0 < (10 : Real) ^ (d2.decimal_point.val - 1) :=
      zpow_pos (by norm_num) _
    have hmul : 0 < (head : Real) *
        (10 : Real) ^ (d2.decimal_point.val - 1) := mul_pos hheadpos hpowpos
    have : 0 < ((xs.foldl (fun n z => 10 * n + z) 0 : Nat) : Real) *
        (10 : Real) ^ (d2.decimal_point.val - (d2.num_digits.val : Int)) :=
      lt_of_lt_of_le hmul hval
    simpa [V, xs] using this
  rcases hinterval with ⟨eta2, u2, hXeq, hYeq, hetaLo, hetaLt, htrunc⟩
  have hXpos0 : 0 < X / (2 : Real) ^ (exp2.val + 1) := by
    rw [hXeq]
    linarith
  have hXYlt0 : X / (2 : Real) ^ (exp2.val + 1) <
      Y / (2 : Real) ^ (exp2.val + 1) := by
    rw [hXeq, hYeq]
    linarith
  have hshift := P529_T1_LeftShiftCertificate
    (X / (2 : Real) ^ (exp2.val + 1))
    (Y / (2 : Real) ^ (exp2.val + 1)) d2 53#usize
    (by norm_num) (by omega) (by omega)
    ⟨hcount, hdigits, ⟨head, tail, hword, hheadLo, hheadHi, hlen⟩⟩
    ⟨eta2, u2, hXeq, hYeq, hetaLo, hetaLt, htrunc⟩
  rcases hshift with ⟨d3, growth, hleft, hgrowth, hgrowthHi, hpointEq,
    hpointLo3, hpointHi3, hcount3, hdigits3, hshape3, hlast3,
    eta3, u3, hXscale, hYscale, heta3Lo, heta3Lt, htrunc3⟩
  have hpointLoFinal : -18 <= d3.decimal_point.val := by
    rw [hpointEq]
    have hgrowthLo : (0 : Int) <= growth.val := Int.natCast_nonneg _
    omega
  have hscaleX : (2 : Real) ^ (53 : Nat) *
      (X / (2 : Real) ^ (exp2.val + 1)) = X / (2 : Real) ^ (exp2.val - 52) := by
    rw [div_eq_mul_inv, div_eq_mul_inv]
    rw [← zpow_neg, ← zpow_neg]
    calc
      (2 : Real) ^ (53 : Nat) * (X * (2 : Real) ^ (-(exp2.val + 1))) =
          ((2 : Real) ^ (53 : Nat) * (2 : Real) ^ (-(exp2.val + 1))) * X := by ring
      _ = (2 : Real) ^ (-(exp2.val - 52)) * X := by
        rw [← zpow_natCast (2 : Real) 53]
        rw [← zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
        rw [show (↑(53 : Nat) : Int) + -(exp2.val + 1) =
          -(exp2.val - 52) by norm_num; omega]
      _ = X * (2 : Real) ^ (-(exp2.val - 52)) := by ring
  have hscaleY : (2 : Real) ^ (53 : Nat) *
      (Y / (2 : Real) ^ (exp2.val + 1)) = Y / (2 : Real) ^ (exp2.val - 52) := by
    rw [div_eq_mul_inv, div_eq_mul_inv]
    rw [← zpow_neg, ← zpow_neg]
    calc
      (2 : Real) ^ (53 : Nat) * (Y * (2 : Real) ^ (-(exp2.val + 1))) =
          ((2 : Real) ^ (53 : Nat) * (2 : Real) ^ (-(exp2.val + 1))) * Y := by ring
      _ = (2 : Real) ^ (-(exp2.val - 52)) * Y := by
        rw [← zpow_natCast (2 : Real) 53]
        rw [← zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
        rw [show (↑(53 : Nat) : Int) + -(exp2.val + 1) =
          -(exp2.val - 52) by norm_num; omega]
      _ = Y * (2 : Real) ^ (-(exp2.val - 52)) := by ring
  have hXeq3 : X / (2 : Real) ^ (exp2.val - 52) = V d3 + eta3 := by
    calc
      X / (2 : Real) ^ (exp2.val - 52) =
          (2 : Real) ^ (53 : Nat) *
            (X / (2 : Real) ^ (exp2.val + 1)) := hscaleX.symm
      _ = V d3 + eta3 := hXscale
  have hYeq3 : Y / (2 : Real) ^ (exp2.val - 52) = V d3 + u3 := by
    calc
      Y / (2 : Real) ^ (exp2.val - 52) =
          (2 : Real) ^ (53 : Nat) *
            (Y / (2 : Real) ^ (exp2.val + 1)) := hscaleY.symm
      _ = V d3 + u3 := hYscale
  have hXltY0 : X / (2 : Real) ^ (exp2.val + 1) < 1 := lt_of_lt_of_le hXYlt0 hupper
  have hXlt1 : X / (2 : Real) ^ (exp2.val + 1) < 1 := hXltY0
  have hpow53pos : (0 : Real) < (2 : Real) ^ (53 : Nat) := by positivity
  have hXpos3 : 0 < X / (2 : Real) ^ (exp2.val - 52) := by
    rw [← hscaleX]
    exact mul_pos hpow53pos hXpos0
  have hXlt3 : X / (2 : Real) ^ (exp2.val - 52) < (2 : Real) ^ (53 : Nat) := by
    rw [← hscaleX]
    nlinarith
  have hV3le : V d3 <= X / (2 : Real) ^ (exp2.val - 52) := by
    rw [hXeq3]
    linarith
  rcases hshape3 with ⟨head3, tail3, hword3, hhead3Lo, hhead3Hi, hlen3⟩
  let xs3 := (d3.digits.val.take d3.num_digits.val).map (fun b => b.val)
  have hxs3 : xs3 = head3 :: tail3 := hword3
  have hxs3Digits : ∀ q, q ∈ xs3 → q < 10 := by
    intro q hq
    rcases List.mem_map.mp hq with ⟨b, hb, hq⟩
    have hb' := hdigits3 b hb
    rw [← hq]
    exact hb'
  have hlenxs3 : xs3.length = d3.num_digits.val := by rw [hxs3]; exact hlen3
  have hV3bounds := P472_T1_DecimalValueBounds xs3 head3 tail3 hxs3
    hhead3Lo hxs3Digits d3.decimal_point.val
  have hpointHiFinal : d3.decimal_point.val <= 16 := by
    by_contra hnot
    have hgt : 16 < d3.decimal_point.val := by omega
    have hptle : d3.decimal_point.val <= 19 := hpointHi3
    have hhead3pos : (1 : Real) ≤ (head3 : Nat) := by exact_mod_cast hhead3Lo
    have hpowbound : (2 : Real) ^ (53 : Nat) < (10 : Real) ^ (16 : Nat) := by norm_num
    have hp : d3.decimal_point.val = 17 ∨ d3.decimal_point.val = 18 ∨
        d3.decimal_point.val = 19 := by omega
    have hVlarge : (10 : Real) ^ (16 : Nat) <= V d3 := by
      rcases hp with hp | hp | hp
      · have hpowlower := hV3bounds.1
        rw [hp, hlenxs3] at hpowlower
        have hleft : (10 : Real) ^ (16 : Nat) <=
            (head3 : Real) * (10 : Real) ^ (16 : Nat) := by nlinarith
        calc
          (10 : Real) ^ (16 : Nat) <= (head3 : Real) * (10 : Real) ^ (16 : Nat) := hleft
          _ <= V d3 := by simpa [V, xs3, hlenxs3, hp] using hpowlower
      · have hpowlower := hV3bounds.1
        rw [hp, hlenxs3] at hpowlower
        have hleft : (10 : Real) ^ (16 : Nat) <=
            (head3 : Real) * (10 : Real) ^ (17 : Nat) := by nlinarith
        calc
          (10 : Real) ^ (16 : Nat) <= (head3 : Real) * (10 : Real) ^ (17 : Nat) := hleft
          _ <= V d3 := by simpa [V, xs3, hlenxs3, hp] using hpowlower
      · have hpowlower := hV3bounds.1
        rw [hp, hlenxs3] at hpowlower
        have hleft : (10 : Real) ^ (16 : Nat) <=
            (head3 : Real) * (10 : Real) ^ (18 : Nat) := by nlinarith
        calc
          (10 : Real) ^ (16 : Nat) <= (head3 : Real) * (10 : Real) ^ (18 : Nat) := hleft
          _ <= V d3 := by simpa [V, xs3, hlenxs3, hp] using hpowlower
    linarith
  refine ⟨d3, hleft, hpointLoFinal, hpointHiFinal, hcount3, hdigits3,
    ⟨head3, tail3, hword3, hhead3Lo, hhead3Hi, hlen3⟩, hlast3, hXpos3, hXlt3, ?_⟩
  exact ⟨eta3, u3, hXeq3, hYeq3, heta3Lo, heta3Lt, htrunc3⟩

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.P529_T1_LeftShiftCertificate
import Tablet.P472_T1_DecimalValueBounds
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model

-- [TABLET NODE: P529_T1_FinalShiftCertificate]
theorem P529_T1_FinalShiftCertificate (X Y : Real)
    (d2 : num.imp.dec2flt.decimal_seq.DecimalSeq) (exp2 : Std.I32)
    (hpointLo : -18 <= d2.decimal_point.val)
    (hpointHi : d2.decimal_point.val <= 0)
    (hinput : d2.num_digits.val <= 768 /\
      (forall b, b ∈ d2.digits.val.take d2.num_digits.val -> b.val < 10) /\
      (exists h tail,
        (d2.digits.val.take d2.num_digits.val).map (fun b => b.val) = h :: tail /\
        1 <= h /\ h < 10 /\ (h :: tail).length = d2.num_digits.val))
    (hupper : Y / (2 : Real) ^ (exp2.val + 1) <= 1) :
    let V := fun a : num.imp.dec2flt.decimal_seq.DecimalSeq =>
      ((((a.digits.val.take a.num_digits.val).map (fun b => b.val)).foldl
        (fun n z => 10 * n + z) 0 : Nat) : Real) *
        (10 : Real) ^ (a.decimal_point.val - (a.num_digits.val : Int))
    (exists eta2 u2 : Real,
      X / (2 : Real) ^ (exp2.val + 1) = V d2 + eta2 /\
      Y / (2 : Real) ^ (exp2.val + 1) = V d2 + 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 /\
      -18 <= d3.decimal_point.val /\ d3.decimal_point.val <= 16 /\
      d3.num_digits.val <= 768 /\
      (forall b, b ∈ d3.digits.val.take d3.num_digits.val -> b.val < 10) /\
      (exists h tail,
        (d3.digits.val.take d3.num_digits.val).map (fun b => b.val) = h :: tail /\
        1 <= h /\ h < 10 /\ (h :: tail).length = d3.num_digits.val) /\
      d3.digits.val[d3.num_digits.val - 1]? ≠ some 0#u8 /\
      0 < X / (2 : Real) ^ (exp2.val - 52) /\
      X / (2 : Real) ^ (exp2.val - 52) < (2 : Real) ^ (53 : Nat) /\
      (exists eta3 u3 : Real,
        X / (2 : Real) ^ (exp2.val - 52) = V d3 + eta3 /\
        Y / (2 : Real) ^ (exp2.val - 52) = V d3 + u3 /\
        0 <= eta3 /\ eta3 < u3 /\ (d3.truncated = true <-> 0 < eta3)) := by
-- BODY
  intro Vfun hinterval
  rcases hinput with ⟨hcount, hdigits, hshape⟩
  rcases hshape with ⟨head, tail, hword, hheadLo, hheadHi, hlen⟩
  let V := fun a : num.imp.dec2flt.decimal_seq.DecimalSeq =>
    ((((a.digits.val.take a.num_digits.val).map (fun b => b.val)).foldl
      (fun n z => 10 * n + z) 0 : Nat) : Real) *
      (10 : Real) ^ (a.decimal_point.val - (a.num_digits.val : Int))
  let xs := (d2.digits.val.take d2.num_digits.val).map (fun b => b.val)
  have hxs : xs = head :: tail := hword
  have hlenxs : xs.length = d2.num_digits.val := by rw [hxs]; exact hlen
  have hxsDigits : ∀ q, q ∈ xs → q < 10 := by
    intro q hq
    rcases List.mem_map.mp hq with ⟨b, hb, hq⟩
    have hb' := hdigits b hb
    rw [← hq]
    exact hb'
  have hVbounds := P472_T1_DecimalValueBounds xs head tail hxs
    hheadLo hxsDigits d2.decimal_point.val
  have hVpos : 0 < V d2 := by
    have hheadpos : (0 : Real) < (head : Nat) := by exact_mod_cast (by omega : 0 < head)
    have hval := hVbounds.1
    rw [hlenxs] at hval
    have hpowpos : 0 < (10 : Real) ^ (d2.decimal_point.val - 1) :=
      zpow_pos (by norm_num) _
    have hmul : 0 < (head : Real) *
        (10 : Real) ^ (d2.decimal_point.val - 1) := mul_pos hheadpos hpowpos
    have : 0 < ((xs.foldl (fun n z => 10 * n + z) 0 : Nat) : Real) *
        (10 : Real) ^ (d2.decimal_point.val - (d2.num_digits.val : Int)) :=
      lt_of_lt_of_le hmul hval
    simpa [V, xs] using this
  rcases hinterval with ⟨eta2, u2, hXeq, hYeq, hetaLo, hetaLt, htrunc⟩
  have hXpos0 : 0 < X / (2 : Real) ^ (exp2.val + 1) := by
    rw [hXeq]
    linarith
  have hXYlt0 : X / (2 : Real) ^ (exp2.val + 1) <
      Y / (2 : Real) ^ (exp2.val + 1) := by
    rw [hXeq, hYeq]
    linarith
  have hshift := P529_T1_LeftShiftCertificate
    (X / (2 : Real) ^ (exp2.val + 1))
    (Y / (2 : Real) ^ (exp2.val + 1)) d2 53#usize
    (by norm_num) (by omega) (by omega)
    ⟨hcount, hdigits, ⟨head, tail, hword, hheadLo, hheadHi, hlen⟩⟩
    ⟨eta2, u2, hXeq, hYeq, hetaLo, hetaLt, htrunc⟩
  rcases hshift with ⟨d3, growth, hleft, hgrowth, hgrowthHi, hpointEq,
    hpointLo3, hpointHi3, hcount3, hdigits3, hshape3, hlast3,
    eta3, u3, hXscale, hYscale, heta3Lo, heta3Lt, htrunc3⟩
  have hpointLoFinal : -18 <= d3.decimal_point.val := by
    rw [hpointEq]
    have hgrowthLo : (0 : Int) <= growth.val := Int.natCast_nonneg _
    omega
  have hscaleX : (2 : Real) ^ (53 : Nat) *
      (X / (2 : Real) ^ (exp2.val + 1)) = X / (2 : Real) ^ (exp2.val - 52) := by
    rw [div_eq_mul_inv, div_eq_mul_inv]
    rw [← zpow_neg, ← zpow_neg]
    calc
      (2 : Real) ^ (53 : Nat) * (X * (2 : Real) ^ (-(exp2.val + 1))) =
          ((2 : Real) ^ (53 : Nat) * (2 : Real) ^ (-(exp2.val + 1))) * X := by ring
      _ = (2 : Real) ^ (-(exp2.val - 52)) * X := by
        rw [← zpow_natCast (2 : Real) 53]
        rw [← zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
        rw [show (↑(53 : Nat) : Int) + -(exp2.val + 1) =
          -(exp2.val - 52) by norm_num; omega]
      _ = X * (2 : Real) ^ (-(exp2.val - 52)) := by ring
  have hscaleY : (2 : Real) ^ (53 : Nat) *
      (Y / (2 : Real) ^ (exp2.val + 1)) = Y / (2 : Real) ^ (exp2.val - 52) := by
    rw [div_eq_mul_inv, div_eq_mul_inv]
    rw [← zpow_neg, ← zpow_neg]
    calc
      (2 : Real) ^ (53 : Nat) * (Y * (2 : Real) ^ (-(exp2.val + 1))) =
          ((2 : Real) ^ (53 : Nat) * (2 : Real) ^ (-(exp2.val + 1))) * Y := by ring
      _ = (2 : Real) ^ (-(exp2.val - 52)) * Y := by
        rw [← zpow_natCast (2 : Real) 53]
        rw [← zpow_add₀ (by norm_num : (2 : Real) ≠ 0)]
        rw [show (↑(53 : Nat) : Int) + -(exp2.val + 1) =
          -(exp2.val - 52) by norm_num; omega]
      _ = Y * (2 : Real) ^ (-(exp2.val - 52)) := by ring
  have hXeq3 : X / (2 : Real) ^ (exp2.val - 52) = V d3 + eta3 := by
    calc
      X / (2 : Real) ^ (exp2.val - 52) =
          (2 : Real) ^ (53 : Nat) *
            (X / (2 : Real) ^ (exp2.val + 1)) := hscaleX.symm
      _ = V d3 + eta3 := hXscale
  have hYeq3 : Y / (2 : Real) ^ (exp2.val - 52) = V d3 + u3 := by
    calc
      Y / (2 : Real) ^ (exp2.val - 52) =
          (2 : Real) ^ (53 : Nat) *
            (Y / (2 : Real) ^ (exp2.val + 1)) := hscaleY.symm
      _ = V d3 + u3 := hYscale
  have hXltY0 : X / (2 : Real) ^ (exp2.val + 1) < 1 := lt_of_lt_of_le hXYlt0 hupper
  have hXlt1 : X / (2 : Real) ^ (exp2.val + 1) < 1 := hXltY0
  have hpow53pos : (0 : Real) < (2 : Real) ^ (53 : Nat) := by positivity
  have hXpos3 : 0 < X / (2 : Real) ^ (exp2.val - 52) := by
    rw [← hscaleX]
    exact mul_pos hpow53pos hXpos0
  have hXlt3 : X / (2 : Real) ^ (exp2.val - 52) < (2 : Real) ^ (53 : Nat) := by
    rw [← hscaleX]
    nlinarith
  have hV3le : V d3 <= X / (2 : Real) ^ (exp2.val - 52) := by
    rw [hXeq3]
    linarith
  rcases hshape3 with ⟨head3, tail3, hword3, hhead3Lo, hhead3Hi, hlen3⟩
  let xs3 := (d3.digits.val.take d3.num_digits.val).map (fun b => b.val)
  have hxs3 : xs3 = head3 :: tail3 := hword3
  have hxs3Digits : ∀ q, q ∈ xs3 → q < 10 := by
    intro q hq
    rcases List.mem_map.mp hq with ⟨b, hb, hq⟩
    have hb' := hdigits3 b hb
    rw [← hq]
    exact hb'
  have hlenxs3 : xs3.length = d3.num_digits.val := by rw [hxs3]; exact hlen3
  have hV3bounds := P472_T1_DecimalValueBounds xs3 head3 tail3 hxs3
    hhead3Lo hxs3Digits d3.decimal_point.val
  have hpointHiFinal : d3.decimal_point.val <= 16 := by
    by_contra hnot
    have hgt : 16 < d3.decimal_point.val := by omega
    have hptle : d3.decimal_point.val <= 19 := hpointHi3
    have hhead3pos : (1 : Real) ≤ (head3 : Nat) := by exact_mod_cast hhead3Lo
    have hpowbound : (2 : Real) ^ (53 : Nat) < (10 : Real) ^ (16 : Nat) := by norm_num
    have hp : d3.decimal_point.val = 17 ∨ d3.decimal_point.val = 18 ∨
        d3.decimal_point.val = 19 := by omega
    have hVlarge : (10 : Real) ^ (16 : Nat) <= V d3 := by
      rcases hp with hp | hp | hp
      · have hpowlower := hV3bounds.1
        rw [hp, hlenxs3] at hpowlower
        have hleft : (10 : Real) ^ (16 : Nat) <=
            (head3 : Real) * (10 : Real) ^ (16 : Nat) := by nlinarith
        calc
          (10 : Real) ^ (16 : Nat) <= (head3 : Real) * (10 : Real) ^ (16 : Nat) := hleft
          _ <= V d3 := by simpa [V, xs3, hlenxs3, hp] using hpowlower
      · have hpowlower := hV3bounds.1
        rw [hp, hlenxs3] at hpowlower
        have hleft : (10 : Real) ^ (16 : Nat) <=
            (head3 : Real) * (10 : Real) ^ (17 : Nat) := by nlinarith
        calc
          (10 : Real) ^ (16 : Nat) <= (head3 : Real) * (10 : Real) ^ (17 : Nat) := hleft
          _ <= V d3 := by simpa [V, xs3, hlenxs3, hp] using hpowlower
      · have hpowlower := hV3bounds.1
        rw [hp, hlenxs3] at hpowlower
        have hleft : (10 : Real) ^ (16 : Nat) <=
            (head3 : Real) * (10 : Real) ^ (18 : Nat) := by nlinarith
        calc
          (10 : Real) ^ (16 : Nat) <= (head3 : Real) * (10 : Real) ^ (18 : Nat) := hleft
          _ <= V d3 := by simpa [V, xs3, hlenxs3, hp] using hpowlower
    linarith
  refine ⟨d3, hleft, hpointLoFinal, hpointHiFinal, hcount3, hdigits3,
    ⟨head3, tail3, hword3, hhead3Lo, hhead3Hi, hlen3⟩, hlast3, hXpos3, hXlt3, ?_⟩
  exact ⟨eta3, u3, hXeq3, hYeq3, heta3Lo, heta3Lt, htrunc3⟩

end dec2flt_model

Proof structure

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

Explore this dependency tree

Inspect related source (117)
More program dependencies (84)
Standard-library dependencies (30)

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 31 entries
Technical checking records
Local closure summary
{
  "node": "P529_T1_FinalShiftCertificate",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "e102052f939fbcabc5b64117d0774aa27107d5b7461a3f0b6701d1a8ffbfb8e7",
  "active_statement_hash": "88062fda152f07ed8b566e5eeb083eaa8255ab57824cbf1520e36fd98d256aa9",
  "kernel_axioms": [
    "Classical.choice",
    "Quot.sound",
    "propext"
  ],
  "toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
  "lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
  "checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
  "approved_axioms_hash": "576e6bf9480cfd32f53c309c7ac8fb115c1ba6e413f299ed5ff9fa7c647e6769",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-181",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "P472_T1_DecimalValueBounds": "4b5c924b5d52bc9d",
    "P529_T1_LeftShiftCertificate": "abbc26ccb53b0399"
  },
  "strict_definition_deps": {
    "num_imp_dec2flt_decimal_seq_DecimalSeq": "b0286c42454b158d",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift": "fd298e37d5ae4f86",
    "num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift": "b3efbd0e6b3fe061"
  }
}
Prose assessment
{
  "label": "Recorded Sound: VerifierPass",
  "assessment_status": "VerifierPass",
  "fingerprint_relation": "matches current fingerprint",
  "assessment_fingerprint": "sound-v2:ce99cb98e139be4d070f124c3323d8bc29687683f73060fb409efd44046349a0",
  "current_fingerprint": "sound-v2:ce99cb98e139be4d070f124c3323d8bc29687683f73060fb409efd44046349a0",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "sound_status": "Pass",
  "substantiveness_status": "Pass"
}