DecimalLeftShiftTableCertificate

Lean checked

Statement

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

Helper · Decimal left-shift table certificate

For every integer k with 0\le k\le60, let x_k and x_{k+1} be consecutive entries of the extracted left-shift table. Put h_k=\lfloor x_k/2048\rfloor, s_k=x_k\bmod2048, and s_{k+1}=x_{k+1}\bmod2048, and let d_k be the slice [s_k,s_{k+1}) of the extracted power-of-five digit array. Then 0\le s_k\le s_{k+1}\le1308, the slice has length s_{k+1}-s_k, and every member of it is a decimal digit. At k=0, h_k=0 and the slice is empty. For 1\le k\le60, the slice is nonempty with nonzero first digit, its base-ten fold is 5^k, and
|d_k|+h_k=k+1,\qquad 10^{h_k-1}<2^k<10^{h_k}.

Lean statement

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

import Tablet.num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE
import Tablet.num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE_POW5

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 65536

namespace dec2flt_model

-- [TABLET NODE: DecimalLeftShiftTableCertificate]
theorem DecimalLeftShiftTableCertificate :
    forall k : Fin 61,
      let table :=
        num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift.TABLE
      let pow5 :=
        num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift.TABLE_POW5
      let x := table.val.get ⟨k.val, by
        have hk := k.isLt
        have hlen : table.val.length = 65 := by
          simp
        omega⟩
      let y := table.val.get ⟨k.val + 1, by
        have hk := k.isLt
        have hlen : table.val.length = 65 := by
          simp
        omega⟩
      let hi := x.val / 2048
      let lo := x.val % 2048
      let hiNext := y.val % 2048
      let ds := (pow5.val.extract lo hiNext).map (fun d => d.val)
      lo <= hiNext /\ hiNext <= 1308 /\
      ds.length = hiNext - lo /\
      (forall d, d ∈ ds -> d < 10) /\
      (k.val = 0 -> hi = 0 /\ ds = []) /\
      (0 < k.val ->
        0 < ds.length /\ 0 < ds.headD 0 /\
        ds.foldl (fun n d => 10 * n + d) 0 = 5 ^ k.val /\
        hi + ds.length = k.val + 1 /\
        10 ^ (hi - 1) < 2 ^ k.val /\ 2 ^ k.val < 10 ^ hi) := 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

Unfold the literal arrays num imp dec2flt decimal seq number of digits decimal left shift TABLE and num imp dec2flt decimal seq number of digits decimal left shift TABLE POW5. There are exactly 61 values of the finite index. For each one, kernel evaluation reads entries k and k+1, divides and reduces modulo 2048, extracts exactly the indicated list interval, and checks the delimiter bounds, list length, and digit bounds. In the positive cases it folds the extracted digits by v\mapsto10v+d and compares the result with exact natural-number exponentiation 5^k; it also checks the displayed length identity and both exact power inequalities. The zero case is checked separately. Lean's kernel reduces all Boolean decisions for the inhabitants of Fin 61; no native evaluator or unproved arithmetic fact is used.

Lean proof


  simp only [
    num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift.TABLE.eq_def,
    num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift.TABLE_POW5.eq_def]
  decide +kernel

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE
import Tablet.num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE_POW5

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxRecDepth 65536

namespace dec2flt_model

-- [TABLET NODE: DecimalLeftShiftTableCertificate]
theorem DecimalLeftShiftTableCertificate :
    forall k : Fin 61,
      let table :=
        num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift.TABLE
      let pow5 :=
        num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift.TABLE_POW5
      let x := table.val.get ⟨k.val, by
        have hk := k.isLt
        have hlen : table.val.length = 65 := by
          simp
        omega⟩
      let y := table.val.get ⟨k.val + 1, by
        have hk := k.isLt
        have hlen : table.val.length = 65 := by
          simp
        omega⟩
      let hi := x.val / 2048
      let lo := x.val % 2048
      let hiNext := y.val % 2048
      let ds := (pow5.val.extract lo hiNext).map (fun d => d.val)
      lo <= hiNext /\ hiNext <= 1308 /\
      ds.length = hiNext - lo /\
      (forall d, d ∈ ds -> d < 10) /\
      (k.val = 0 -> hi = 0 /\ ds = []) /\
      (0 < k.val ->
        0 < ds.length /\ 0 < ds.headD 0 /\
        ds.foldl (fun n d => 10 * n + d) 0 = 5 ^ k.val /\
        hi + ds.length = k.val + 1 /\
        10 ^ (hi - 1) < 2 ^ k.val /\ 2 ^ k.val < 10 ^ hi) := by
-- BODY
  simp only [
    num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift.TABLE.eq_def,
    num.imp.dec2flt.decimal_seq.number_of_digits_decimal_left_shift.TABLE_POW5.eq_def]
  decide +kernel

end dec2flt_model

Proof structure

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

Explore this dependency tree

Inspect related source (46)
More program dependencies (13)
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": "DecimalLeftShiftTableCertificate",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "0ad9a9347ae5a9abb188640eacdfcde231127bf9f0c63ac0faac6f50217bda93",
  "active_statement_hash": "982547034feec90e035a861626e45bfc6cd7313a3c07cb7cd226c6de47ac1056",
  "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": "worker-result-local-closure-issuance-cycle-152",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE": "f5b2bc783737c939",
    "num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE_POW5": "1aac760f5f63a686"
  },
  "strict_definition_deps": {
    "num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE": "e68bec96fec99700",
    "num_imp_dec2flt_decimal_seq_number_of_digits_decimal_left_shift_TABLE_POW5": "4dda92c1af5f2c9e"
  }
}
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:d0db555c18ed0ab2ce85f1ddda74c9a0d1f1de2d5225633d8d469e488c2ee922",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}