SlowAccumulatedRoundingLexical

Lean checked

Statement

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

Lemma · Source-valid all-one literal

There are an Aeneas byte slice s and decimal lexeme x such that
\begin{aligned} s.\mathit{val}&=\operatorname{replicate}(2147483648,49\#\mathrm{u8}),\\ x&=(\mathrm{none},\operatorname{replicate}(2147483648,1), \mathrm{none},\mathrm{none}), \end{aligned}
and s is source-valid, x has no leading sign, x is a valid numeric lexeme, and the observed bytes of s equal the rendering of x.

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
import Tablet.SourceValidByteSlice

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000

namespace dec2flt_model

-- [TABLET NODE: SlowAccumulatedRoundingLexical]
theorem SlowAccumulatedRoundingLexical :
    exists (s : Slice Std.U8) (x : DecimalLexeme),
      s.val = List.replicate 2147483648 49#u8 /\
      x = {
        leadingSign := none
        integerDigits := List.replicate 2147483648 1
        fractionDigits := none
        exponent := none } /\
      SourceValidByteSlice s /\
      x.leadingSign = none /\
      DecimalGoalVocabularyDefault.validNumeric x /\
      DecimalGoalVocabularyDefault.bytes s =
        DecimalGoalVocabularyDefault.renderNumeric x := 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

Take the displayed replicate list as the slice contents and the displayed record as x. Its length is N=2147483648. The concrete usize constructor for the slice supplies its own machine bound, and N\leq9223372036854775807, so SourceValidByteSlice holds.
Under the definitions in DecimalGoalVocabularyDefault, every integer digit is 1<10; the integer list is nonempty because its length is N>0; and absent fraction and exponent fields impose no further conditions. Thus the lexeme is valid, and its sign field is definitionally none. Mapping the digit renderer d\mapsto48+d over N copies of 1 yields N copies of 49. The absent sign, fraction, and exponent render as empty lists, while observing the slice maps each byte 49\#\mathrm{u8} to the natural number 49. The replicate-map and empty-append equations prove byte-for-byte equality without expanding the list.

Lean proof


  let bytes : List Std.U8 := List.replicate 2147483648 49#u8
  have hbytesLen : bytes.length = 2147483648 := by
    exact List.length_replicate
  let s : Slice Std.U8 := ⟨bytes, by
    rw [hbytesLen]
    rcases Usize.bounds_eq with q | q <;>
      norm_num [q, U32.max_eq, U64.max_eq]⟩
  let x : DecimalLexeme := {
    leadingSign := none
    integerDigits := List.replicate 2147483648 1
    fractionDigits := none
    exponent := none }
  have hs : s.val = List.replicate 2147483648 49#u8 := by rfl
  have hx : x = {
      leadingSign := none
      integerDigits := List.replicate 2147483648 1
      fractionDigits := none
      exponent := none } := by rfl
  have hsource : SourceValidByteSlice s := by
    unfold SourceValidByteSlice
    rw [hs, List.length_replicate]
    norm_num
  have hsign : x.leadingSign = none := by rfl
  have hvalid : DecimalGoalVocabularyDefault.validNumeric x := by
    dsimp only [DecimalGoalVocabularyDefault, x]
    refine ⟨?_, True.intro, ?_, True.intro⟩
    · intro d hd
      have hdEq := List.eq_of_mem_replicate hd
      subst d
      norm_num
    · left
      intro hnil
      have hlen := congrArg List.length hnil
      simp only [List.length_replicate, List.length_nil] at hlen
      omega
  have hrender : DecimalGoalVocabularyDefault.bytes s =
      DecimalGoalVocabularyDefault.renderNumeric x := by
    dsimp only [DecimalGoalVocabularyDefault, x]
    rw [hs]
    simp only [List.map_replicate, List.nil_append, List.append_nil]
    rfl
  exact ⟨s, x, hs, hx, hsource, hsign, hvalid, hrender⟩

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.DecimalGoalVocabularyDefault
import Tablet.SourceValidByteSlice

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
set_option maxHeartbeats 2000000

namespace dec2flt_model

-- [TABLET NODE: SlowAccumulatedRoundingLexical]
theorem SlowAccumulatedRoundingLexical :
    exists (s : Slice Std.U8) (x : DecimalLexeme),
      s.val = List.replicate 2147483648 49#u8 /\
      x = {
        leadingSign := none
        integerDigits := List.replicate 2147483648 1
        fractionDigits := none
        exponent := none } /\
      SourceValidByteSlice s /\
      x.leadingSign = none /\
      DecimalGoalVocabularyDefault.validNumeric x /\
      DecimalGoalVocabularyDefault.bytes s =
        DecimalGoalVocabularyDefault.renderNumeric x := by
-- BODY
  let bytes : List Std.U8 := List.replicate 2147483648 49#u8
  have hbytesLen : bytes.length = 2147483648 := by
    exact List.length_replicate
  let s : Slice Std.U8 := ⟨bytes, by
    rw [hbytesLen]
    rcases Usize.bounds_eq with q | q <;>
      norm_num [q, U32.max_eq, U64.max_eq]⟩
  let x : DecimalLexeme := {
    leadingSign := none
    integerDigits := List.replicate 2147483648 1
    fractionDigits := none
    exponent := none }
  have hs : s.val = List.replicate 2147483648 49#u8 := by rfl
  have hx : x = {
      leadingSign := none
      integerDigits := List.replicate 2147483648 1
      fractionDigits := none
      exponent := none } := by rfl
  have hsource : SourceValidByteSlice s := by
    unfold SourceValidByteSlice
    rw [hs, List.length_replicate]
    norm_num
  have hsign : x.leadingSign = none := by rfl
  have hvalid : DecimalGoalVocabularyDefault.validNumeric x := by
    dsimp only [DecimalGoalVocabularyDefault, x]
    refine ⟨?_, True.intro, ?_, True.intro⟩
    · intro d hd
      have hdEq := List.eq_of_mem_replicate hd
      subst d
      norm_num
    · left
      intro hnil
      have hlen := congrArg List.length hnil
      simp only [List.length_replicate, List.length_nil] at hlen
      omega
  have hrender : DecimalGoalVocabularyDefault.bytes s =
      DecimalGoalVocabularyDefault.renderNumeric x := by
    dsimp only [DecimalGoalVocabularyDefault, x]
    rw [hs]
    simp only [List.map_replicate, List.nil_append, List.append_nil]
    rfl
  exact ⟨s, x, hs, hx, hsource, hsign, hvalid, hrender⟩

end dec2flt_model

Proof structure

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

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
All 8 entries
Technical checking records
Local closure summary
{
  "node": "SlowAccumulatedRoundingLexical",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "597d67140a9979551eb655384aab9bd707d485003a50556c32055255592429bf",
  "active_statement_hash": "f04aefd00785b6627ff402d3cf06046fd908f6a56d0a33e3ffcf18502f037b91",
  "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-129",
  "boundary_theorems": {},
  "strict_theorem_deps": {},
  "strict_definition_deps": {
    "DecimalGoalVocabulary": "65227461bf3cac06",
    "DecimalGoalVocabularyDefault": "512f8d0aea894250",
    "DecimalLexeme": "c43614ff2149ecf2",
    "SourceValidByteSlice": "3dc42716a6378d26"
  }
}
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:f96072a27f0a77719d71d070bc21ef9034979f4de12a444694d873770aea74a3",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}