P529_T1_RightBoundaryTransport

Lean checked

Statement

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

Lemma · A nonreset right shift retains an aligned boundary

Let V(a) be the retained fold scaled by 10^{a.p-a.n}. Suppose d has decimal retained cells, V(d)>0, and an actual normal right shift by k\le60 returns d' of count at most 768. Assume d' is not the record with zero count, zero point and false sticky. For every natural b,
b10^{d'.p-768}\le V(d)/2^k \quad\Longrightarrow\quad b10^{d'.p-768}\le V(d').

Lean statement

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

import Tablet.P472_T1_DecimalSeqRightShiftRecordSemantics
import Tablet.P798_T1_GridAlignment
import Tablet.P798_T1_GridBoundaryRetained
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model

-- [TABLET NODE: P529_T1_RightBoundaryTransport]
theorem P529_T1_RightBoundaryTransport
    (d d' : num.imp.dec2flt.decimal_seq.DecimalSeq) (shift : Std.Usize)
    (hshift : shift.val <= 60)
    (hdigits : forall b, b ∈ d.digits.val.take d.num_digits.val -> b.val < 10)
    (hcall : num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift d shift = ok d')
    (hnonreset : ¬ (d'.num_digits.val = 0 /\ d'.decimal_point.val = 0 /\ d'.truncated = false))
    (hcap : d'.num_digits.val <= 768) :
    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))
    0 < V d ->
    forall b : Nat,
      (b : Real) * (10 : Real) ^ (d'.decimal_point.val - 768) <= V d / (2 : Real) ^ shift.val ->
      (b : Real) * (10 : Real) ^ (d'.decimal_point.val - 768) <= V d' := 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 DecimalSeqRightShiftRecordSemantics. The explicit nonreset hypothesis excludes its reset alternative. Put q=10^{d'.p-768}>0. Its other alternative supplies 0\le\rho<q and V(d')=V(d)/2^k-\rho. By GridAlignment and the output count bound, there is a natural a with V(d')=aq. The assumed inequality becomes bq\le aq+\rho. Apply GridBoundaryRetained with this q,a,b,\rho. Its positivity and strict-loss premises were just established, so it gives bq\le aq=V(d'). This is a one-shift boundary claim, with no cumulative error or fresh-cutoff assumption.

Lean proof


  dsimp only
  intro hvalue b hboundary
  rcases P472_T1_DecimalSeqRightShiftRecordSemantics
      d d' shift hshift hvalue hdigits hcall with hreset | ⟨rho, hrho0, hrhoCell, hrecord, _⟩
  · exact False.elim (hnonreset hreset)
  · obtain ⟨a, halign⟩ := P798_T1_GridAlignment d' hcap
    dsimp only at hrecord
    let q : Real := (10 : Real) ^ (d'.decimal_point.val - 768)
    have hq : 0 < q := by
      dsimp only [q]
      exact zpow_pos (by norm_num) _
    have hboundary' : (b : Real) * q <= (a : Real) * q + rho := by
      dsimp only [q] at halign hrhoCell hboundary ⊢
      rw [← halign]
      rw [hrecord]
      nlinarith
    have hretained :=
      P798_T1_GridBoundaryRetained a b q rho hq
        (by simpa [q] using hrhoCell) hboundary'
    dsimp only [q] at hretained ⊢
    rw [halign]
    exact hretained

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.P472_T1_DecimalSeqRightShiftRecordSemantics
import Tablet.P798_T1_GridAlignment
import Tablet.P798_T1_GridBoundaryRetained
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model

-- [TABLET NODE: P529_T1_RightBoundaryTransport]
theorem P529_T1_RightBoundaryTransport
    (d d' : num.imp.dec2flt.decimal_seq.DecimalSeq) (shift : Std.Usize)
    (hshift : shift.val <= 60)
    (hdigits : forall b, b ∈ d.digits.val.take d.num_digits.val -> b.val < 10)
    (hcall : num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift d shift = ok d')
    (hnonreset : ¬ (d'.num_digits.val = 0 /\ d'.decimal_point.val = 0 /\ d'.truncated = false))
    (hcap : d'.num_digits.val <= 768) :
    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))
    0 < V d ->
    forall b : Nat,
      (b : Real) * (10 : Real) ^ (d'.decimal_point.val - 768) <= V d / (2 : Real) ^ shift.val ->
      (b : Real) * (10 : Real) ^ (d'.decimal_point.val - 768) <= V d' := by
-- BODY
  dsimp only
  intro hvalue b hboundary
  rcases P472_T1_DecimalSeqRightShiftRecordSemantics
      d d' shift hshift hvalue hdigits hcall with hreset | ⟨rho, hrho0, hrhoCell, hrecord, _⟩
  · exact False.elim (hnonreset hreset)
  · obtain ⟨a, halign⟩ := P798_T1_GridAlignment d' hcap
    dsimp only at hrecord
    let q : Real := (10 : Real) ^ (d'.decimal_point.val - 768)
    have hq : 0 < q := by
      dsimp only [q]
      exact zpow_pos (by norm_num) _
    have hboundary' : (b : Real) * q <= (a : Real) * q + rho := by
      dsimp only [q] at halign hrhoCell hboundary ⊢
      rw [← halign]
      rw [hrecord]
      nlinarith
    have hretained :=
      P798_T1_GridBoundaryRetained a b q rho hq
        (by simpa [q] using hrhoCell) hboundary'
    dsimp only [q] at hretained ⊢
    rw [halign]
    exact hretained

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 15 entries
Technical checking records
Local closure summary
{
  "node": "P529_T1_RightBoundaryTransport",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "115fff1f014a46e8f56bf438a980d46090305de8f8e49f4e2e41edc61c602a09",
  "active_statement_hash": "015cee6bb1178c65f8967d4262287aa59116e9d6b795914167d0898e144ab618",
  "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_DecimalSeqRightShiftRecordSemantics": "81ed2135baca7c94",
    "P798_T1_GridAlignment": "f2e86c75264ff7d3",
    "P798_T1_GridBoundaryRetained": "76774c228a980cf9"
  },
  "strict_definition_deps": {
    "num_imp_dec2flt_decimal_seq_DecimalSeq": "59bf1ff9fe88fa8d",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift": "1aaf1bb11c0b6a49"
  }
}
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:85def31dff8cacc87e66bc6f7552a89a306ebb789e45afbba61fcd0c3ddc5494",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}