P798_T1_RightBoundaryTransport

Lean checked

Statement

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

Lemma · Nonreset right-shift transport of a grid boundary

For a decimal sequence e, let V(e) be the base-ten fold of its stored prefix scaled by 10^{e.\mathit{decimal\_point}-e.\mathit{num\_digits}}. Suppose a decimal sequence d has V(d)>0 and decimal stored cells, and a successful extracted right shift by k\le60 returns d'. Assume that d' is not the reset record with zero count, zero point, and false truncation, and that d'.\mathit{num\_digits}\le768. For every b\in\mathbb N, if
b10^{d'.\mathit{decimal\_point}-768}\le V(d)/2^k,
then
b10^{d'.\mathit{decimal\_point}-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.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: P798_T1_RightBoundaryTransport]
theorem P798_T1_RightBoundaryTransport :
    let value := fun d : num.imp.dec2flt.decimal_seq.DecimalSeq =>
      let digits :=
        (d.digits.val.take d.num_digits.val).map (fun z => z.val)
      let integer : Nat := digits.foldl (fun a z => 10 * a + z) 0
      (integer : Real) * (10 : Real) ^
        (d.decimal_point.val - (d.num_digits.val : Int))
    forall (d d' : num.imp.dec2flt.decimal_seq.DecimalSeq)
      (shift : Std.Usize) (b : Nat),
      shift.val <= 60 ->
      0 < value d ->
      (forall z, z ∈ d.digits.val.take d.num_digits.val -> z.val < 10) ->
      num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift d shift = ok d' ->
      ¬ (d'.num_digits.val = 0 /\ d'.decimal_point.val = 0 /\
        d'.truncated = false) ->
      d'.num_digits.val <= 768 ->
      (b : Real) * (10 : Real) ^ (d'.decimal_point.val - 768) <=
        value d / (2 : Real) ^ shift.val ->
      (b : Real) * (10 : Real) ^ (d'.decimal_point.val - 768) <=
        value 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. Its reset alternative contradicts the explicit nonreset hypothesis. Hence its other alternative holds. With
q=10^{d'.\mathit{decimal\_point}-768}>0,
that alternative supplies a real \rho such that
0\le\rho<q,\qquad V(d')=V(d)/2^k-\rho. \tag{1}
By GridAlignment, the returned count bound supplies an a\in\mathbb N with V(d')=aq. Replacing V(d)/2^k in the assumed boundary inequality by V(d')+\rho=aq+\rho from (1) gives
bq\le aq+\rho.
The hypotheses of GridBoundaryRetained are now satisfied, and it yields bq\le aq=V(d'). This transports the boundary through this one nonreset shift without asserting any bound on cumulative loss.

Lean proof


  dsimp only
  intro d d' shift b hshift hvalue hdigit hcall hnonreset hcount hboundary
  rcases DecimalSeqRightShiftRecordSemantics d d' shift hshift hvalue hdigit
      hcall with hreset | ⟨rho, _, hrhoCell, hrecord, _⟩
  · exact False.elim (hnonreset hreset)
  · obtain ⟨a, halign⟩ := P798_T1_GridAlignment d' hcount
    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]
      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.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: P798_T1_RightBoundaryTransport]
theorem P798_T1_RightBoundaryTransport :
    let value := fun d : num.imp.dec2flt.decimal_seq.DecimalSeq =>
      let digits :=
        (d.digits.val.take d.num_digits.val).map (fun z => z.val)
      let integer : Nat := digits.foldl (fun a z => 10 * a + z) 0
      (integer : Real) * (10 : Real) ^
        (d.decimal_point.val - (d.num_digits.val : Int))
    forall (d d' : num.imp.dec2flt.decimal_seq.DecimalSeq)
      (shift : Std.Usize) (b : Nat),
      shift.val <= 60 ->
      0 < value d ->
      (forall z, z ∈ d.digits.val.take d.num_digits.val -> z.val < 10) ->
      num.imp.dec2flt.decimal_seq.DecimalSeq.right_shift d shift = ok d' ->
      ¬ (d'.num_digits.val = 0 /\ d'.decimal_point.val = 0 /\
        d'.truncated = false) ->
      d'.num_digits.val <= 768 ->
      (b : Real) * (10 : Real) ^ (d'.decimal_point.val - 768) <=
        value d / (2 : Real) ^ shift.val ->
      (b : Real) * (10 : Real) ^ (d'.decimal_point.val - 768) <=
        value d' := by
-- BODY
  dsimp only
  intro d d' shift b hshift hvalue hdigit hcall hnonreset hcount hboundary
  rcases DecimalSeqRightShiftRecordSemantics d d' shift hshift hvalue hdigit
      hcall with hreset | ⟨rho, _, hrhoCell, hrecord, _⟩
  · exact False.elim (hnonreset hreset)
  · obtain ⟨a, halign⟩ := P798_T1_GridAlignment d' hcount
    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]
      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 (116)
More program dependencies (83)
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": "P798_T1_RightBoundaryTransport",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "daed3e1507b2e088def49480b9e6b653d8beecb1ca670814965c71d5591098f3",
  "active_statement_hash": "5f625584eb3307b1327289a3961caee8f18d56290680bc38f7ab57a9eb582890",
  "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-188",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "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:a4582bfef807c39487d36153eb1dcbfe22aec08c3dbda1691d62ce0e019fe91e",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}