P9_T1_ExponentFoldBounds

Lean checked

Statement

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

Lemma

Let D be any finite list of digits in 0,\ldots,9, and let 0\leq a\leq E=5764607523034234879. Folding D from a with n\mapsto10n+d when n<T=576460752303423488=2^{59}, and with n unchanged otherwise, gives a natural number at most E.

Lean statement

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

import Tablet.DecimalGoalVocabularyDefault

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model

-- [TABLET NODE: P9_T1_ExponentFoldBounds]
theorem P9_T1_ExponentFoldBounds (digits : List Nat)
    (hdigits : forall d, d ∈ digits -> d < 10) :
    forall a : Nat, a <= 5764607523034234879 ->
      digits.foldl
        (fun n d => if n < 576460752303423488 then 10 * n + d else n) a
        <= 5764607523034234879 := 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

Induct on the list, allowing every initial accumulator in [0,E]. The empty fold is the initial accumulator. For a first digit d, if a<T, integrality gives a\leq T-1, so 10a+d\leq10(T-1)+9=E. Otherwise the update retains a\leq E. The remaining list still consists only of digits, and the induction hypothesis applies to the updated accumulator. Nonnegativity holds because the fold is over natural numbers. No digit-length bound is used.

Lean proof


  induction digits with
  | nil => simp
  | cons d ds ih =>
    intro a ha
    simp only [List.foldl_cons]
    apply ih
    · intro b hb
      exact hdigits b (List.mem_cons_of_mem d hb)
    · have hd := hdigits d List.mem_cons_self
      split <;> omega
end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.DecimalGoalVocabularyDefault

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model

-- [TABLET NODE: P9_T1_ExponentFoldBounds]
theorem P9_T1_ExponentFoldBounds (digits : List Nat)
    (hdigits : forall d, d ∈ digits -> d < 10) :
    forall a : Nat, a <= 5764607523034234879 ->
      digits.foldl
        (fun n d => if n < 576460752303423488 then 10 * n + d else n) a
        <= 5764607523034234879 := by
-- BODY
  induction digits with
  | nil => simp
  | cons d ds ih =>
    intro a ha
    simp only [List.foldl_cons]
    apply ih
    · intro b hb
      exact hdigits b (List.mem_cons_of_mem d hb)
    · have hd := hdigits d List.mem_cons_self
      split <;> omega
end dec2flt_model

Proof structure

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

Used by

No other declaration in this version lists this one as a dependency.

Explore this dependency tree

Inspect related source (44)
More program dependencies (11)
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": "P9_T1_ExponentFoldBounds",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "f4dba30fc187ea4f943bd459e1268088dd03ee76ebc1db27e706c532f4c40f6d",
  "active_statement_hash": "8ee6d8d4d60f9b8982ac9fdb6191169fcbd728250dee5354068795c62698f430",
  "kernel_axioms": [
    "Quot.sound",
    "propext"
  ],
  "toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
  "lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
  "checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
  "approved_axioms_hash": "d5c04ffa333d9b33b238a527f5beaa2be82e021d3e9c0bbe01b1310280f7f55a",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-68",
  "boundary_theorems": {},
  "strict_theorem_deps": {},
  "strict_definition_deps": {}
}
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:2a0a140f352f46bfe5493f32a3b85c868e04c617fe2c3726e9930c1f25bc7765",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}