P798_T1_GridAlignment

Lean checked

Statement

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

Lemma · Canonical 768-cell grid alignment

Let d be a decimal sequence with n=d.\mathit{num\_digits}\le768, let p=d.\mathit{decimal\_point}, and let I be the base-ten fold of the first n stored cells. Its represented value
V(d)=I10^{p-n}
is an integer multiple of the 768-cell grid unit 10^{p-768}: there exists a\in\mathbb N such that
V(d)=a10^{p-768}.

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

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P798_T1_GridAlignment]
theorem P798_T1_GridAlignment
    (d : num.imp.dec2flt.decimal_seq.DecimalSeq)
    (hcount : d.num_digits.val <= 768) :
    let value :=
      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))
    exists a : Nat,
      value = (a : Real) *
        (10 : Real) ^ (d.decimal_point.val - 768) := 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

Set a=I10^{768-n}. This is a natural number because n\le768. The integer exponent identity
p-n=(p-768)+(768-n)
and the multiplication law for powers of the nonzero real number 10 give
I10^{p-n}=I10^{768-n}10^{p-768}=a10^{p-768}.
This proves the claimed grid alignment, including the cases I=0 and n=768.

Lean proof


  dsimp only
  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
  refine ⟨integer * 10 ^ (768 - d.num_digits.val), ?_⟩
  have hexp :
      d.decimal_point.val - (d.num_digits.val : Int) =
        (d.decimal_point.val - 768) +
          ((768 - d.num_digits.val : Nat) : Int) := by
    rw [Nat.cast_sub hcount]
    omega
  rw [hexp, zpow_add₀ (by norm_num : (10 : Real) ≠ 0)]
  norm_num only [zpow_natCast]
  push_cast
  ring

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.DecimalSeqLeftShiftRecordSemantics

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P798_T1_GridAlignment]
theorem P798_T1_GridAlignment
    (d : num.imp.dec2flt.decimal_seq.DecimalSeq)
    (hcount : d.num_digits.val <= 768) :
    let value :=
      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))
    exists a : Nat,
      value = (a : Real) *
        (10 : Real) ^ (d.decimal_point.val - 768) := by
-- BODY
  dsimp only
  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
  refine ⟨integer * 10 ^ (768 - d.num_digits.val), ?_⟩
  have hexp :
      d.decimal_point.val - (d.num_digits.val : Int) =
        (d.decimal_point.val - 768) +
          ((768 - d.num_digits.val : Nat) : Int) := by
    rw [Nat.cast_sub hcount]
    omega
  rw [hexp, zpow_add₀ (by norm_num : (10 : Real) ≠ 0)]
  norm_num only [zpow_natCast]
  push_cast
  ring

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
Technical checking records
Local closure summary
{
  "node": "P798_T1_GridAlignment",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "e30730bfaabc133664db01353f338b73ae213726489bab8e586b659280a01468",
  "active_statement_hash": "621b1f39c8632d9cb149f51d355bc5ee79531d049cf49ba04ee729ec9c06ccb8",
  "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": {},
  "strict_definition_deps": {
    "num_imp_dec2flt_decimal_seq_DecimalSeq": "59bf1ff9fe88fa8d"
  }
}
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:f2e5c748276ed25541b312250b34943399a86e8dae7bbb374f751c8f32366019",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}