P798_T1_LeftBoundaryTransport

Lean checked

Statement

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

Lemma · Left-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 left shift by k\le60 returns d'. Suppose also that d'.\mathit{num\_digits}\le768. For every b\in\mathbb N, if
b10^{d'.\mathit{decimal\_point}-768}\le2^kV(d),
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.DecimalSeqLeftShiftRecordSemantics
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_LeftBoundaryTransport]
theorem P798_T1_LeftBoundaryTransport :
    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.left_shift d shift = ok d' ->
      d'.num_digits.val <= 768 ->
      (b : Real) * (10 : Real) ^ (d'.decimal_point.val - 768) <=
        (2 : Real) ^ shift.val * value d ->
      (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 DecimalSeqLeftShiftRecordSemantics. With
q=10^{d'.\mathit{decimal\_point}-768}>0,
it supplies a real \rho such that
0\le\rho<q,\qquad V(d')=2^kV(d)-\rho. \tag{1}
By GridAlignment, the count bound on d' supplies an a\in\mathbb N with V(d')=aq. Substitute this and (1) into the assumed boundary inequality. It becomes
bq\le aq+\rho.
All hypotheses of GridBoundaryRetained now hold, so that lemma yields bq\le aq=V(d'), which is the desired conclusion. Only the fresh loss \rho of this successful shift is used.

Lean proof


  dsimp only
  intro d d' shift b hshift hvalue hdigit hcall hcount hboundary
  obtain ⟨rho, _, hrhoCell, hrecord, _⟩ :=
    DecimalSeqLeftShiftRecordSemantics d d' shift hshift hvalue hdigit hcall
  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.DecimalSeqLeftShiftRecordSemantics
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_LeftBoundaryTransport]
theorem P798_T1_LeftBoundaryTransport :
    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.left_shift d shift = ok d' ->
      d'.num_digits.val <= 768 ->
      (b : Real) * (10 : Real) ^ (d'.decimal_point.val - 768) <=
        (2 : Real) ^ shift.val * value d ->
      (b : Real) * (10 : Real) ^ (d'.decimal_point.val - 768) <=
        value d' := by
-- BODY
  dsimp only
  intro d d' shift b hshift hvalue hdigit hcall hcount hboundary
  obtain ⟨rho, _, hrhoCell, hrecord, _⟩ :=
    DecimalSeqLeftShiftRecordSemantics d d' shift hshift hvalue hdigit hcall
  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 19 entries
Technical checking records
Local closure summary
{
  "node": "P798_T1_LeftBoundaryTransport",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "ccf38c01e66991ce5e28e3b7189883dfce92ab0da37b8a2b37e890643da509a3",
  "active_statement_hash": "66bc221636a08d258cf98313b6ab990b496bbc59ea5aab09c04473e418be33ca",
  "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": {
    "DecimalSeqLeftShiftRecordSemantics": "abe9f51b6cd0693a",
    "P798_T1_GridAlignment": "f2e86c75264ff7d3",
    "P798_T1_GridBoundaryRetained": "76774c228a980cf9"
  },
  "strict_definition_deps": {
    "num_imp_dec2flt_decimal_seq_DecimalSeq": "b0286c42454b158d",
    "num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift": "fd298e37d5ae4f86"
  }
}
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:c478905870f0cc4073c5cba0bdbc966537fbd5d9e844e2be70033f47b0091052",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}