P13_T1_ParserAccumulatedRounding

Lean checked

Statement

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

Theorem

Every accepted numeric literal whose complete source-valid Rust string has byte length at most A=3458764513820540928 is rounded by the actual specialized dec2flt to its full-significand accumulated-exponent value, with its lexical sign, including signed zero and infinity. The bound includes any leading sign. In DecimalGoalVocabularyDefault, every significand digit contributes, and the explicit exponent is the signed fold updating a to 10a+d while the previous a<2^{59}, allowing overshoot and scanning all remaining digits after updates stop. This diagnostic target is distinct from the ordinary mathematical exact-value target. Rounding is binary64 nearest, ties to even, including subnormals; acceptance is normal Rust Ok. The specialization is ActualDispatchOperations.

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.P9_T1_ActualDispatchOperations
import Tablet.num_imp_dec2flt_dec2flt
import Tablet.P687_T1_ActualEmbeddedFrameEquality
import Tablet.P616_T1_CompatibleCompletion
import Tablet.P616_T1_FrameNormality
import Tablet.P616_T1_FrameCorrectness
import Tablet.P9_T1_ActualDispatchFrameEquality

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P13_T1_ParserAccumulatedRounding]
theorem P13_T1_ParserAccumulatedRounding :
    forall (s : Str) (x : DecimalLexeme) (f : F64),
      DecimalGoalVocabularyDefault.sourceString s ->
      s.val.length <= 3458764513820540928 ->
      DecimalGoalVocabularyDefault.validNumeric x ->
      DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes s ->
      num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
        F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
        F64.Insts.CoreOpsArithNegF64 s = ok (core.result.Result.Ok f) ->
      exists magnitude : F64,
        DecimalGoalVocabularyDefault.roundsMagnitude
          (DecimalGoalVocabularyDefault.accumulatedMagnitude x) magnitude ∧
        DecimalGoalVocabularyDefault.signedMagnitude
          (DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f := 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

Fix the stated s,x,f and hypotheses. Choose one C with its DispatchContracts and NormalComponentRefinement using CompatibleCompletion; keep this C throughout. FrameNormality, at the original complete-string A-bound, constructs r,\tau with the embedded frame returning \mathrm{ok}(r,\tau). The validity and rendering hypotheses give exactly the numeric classification by x in DecimalGoalVocabularyDefault. The numeric clause of FrameCorrectness, on this same normal frame equation, supplies f',m such that
r=\mathrm{Rust\ Ok}(f'),\qquad \mathrm{roundsMagnitude}(\mathrm{accumulatedMagnitude}(x),m),\qquad \mathrm{signedMagnitude}(\mathrm{lexicalNegative}(x),m,f').
These predicates use every significand digit and the source's bounded exponent fold, not the separate ordinary exact-value interpretation.
Apply ActualEmbeddedFrameEquality to this same C and s, then ActualDispatchFrameEquality, to transfer the normal embedded Result to the specialized extracted traced dispatcher. The first-projection definition num imp dec2flt dec2flt and normal bind reduction give a public return \mathrm{ok}(\mathrm{Rust\ Ok}(f')). Equate this constructed return with the hypothesis \mathrm{ok}(\mathrm{Rust\ Ok}(f)) of this theorem. Injectivity of outer normal return and then of Rust Ok gives f'=f. Substitute in the displayed signedMagnitude predicate and retain its roundsMagnitude witness m to obtain both required conjuncts. There is no extra public-success premise in the simulation or normality steps, no restriction on the exponent digits, and no replacement of the complete-string A-bound by a shorter-body bound.

Lean proof


  intro s x f hs hA hv hb hsuccess
  obtain ⟨C, hc, hr⟩ := P616_T1_CompatibleCompletion
  obtain ⟨r, trace, hembed⟩ := P616_T1_FrameNormality C hc s hs hA
  have hclass : DecimalGoalVocabularyDefault.classifies
      (DecimalGoalVocabularyDefault.bytes s) (some (Sum.inl x)) := ⟨hv, hb⟩
  obtain ⟨f', magnitude, hresult, hround, hsign⟩ :=
    (P616_T1_FrameCorrectness C hc s r trace hs hA hembed).2.2 x hclass
  have hactual := (P9_T1_ActualDispatchFrameEquality s).symm.trans
    ((P687_T1_ActualEmbeddedFrameEquality C hc hr s hs hA).trans hembed)
  have hpublic : num.imp.dec2flt.dec2flt
      F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
      F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
      F64.Insts.CoreOpsArithNegF64 s = ok (core.result.Result.Ok f') := by
    simp only [num.imp.dec2flt.dec2flt, hactual, bind_tc_ok, hresult]
    rfl
  have hsame : f' = f := by
    simpa only [Result.ok.injEq, core.result.Result.Ok.injEq] using
      hpublic.symm.trans hsuccess
  exact ⟨magnitude, hround, hsame ▸ hsign⟩

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.DecimalGoalVocabularyDefault
import Tablet.P9_T1_ActualDispatchOperations
import Tablet.num_imp_dec2flt_dec2flt
import Tablet.P687_T1_ActualEmbeddedFrameEquality
import Tablet.P616_T1_CompatibleCompletion
import Tablet.P616_T1_FrameNormality
import Tablet.P616_T1_FrameCorrectness
import Tablet.P9_T1_ActualDispatchFrameEquality

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P13_T1_ParserAccumulatedRounding]
theorem P13_T1_ParserAccumulatedRounding :
    forall (s : Str) (x : DecimalLexeme) (f : F64),
      DecimalGoalVocabularyDefault.sourceString s ->
      s.val.length <= 3458764513820540928 ->
      DecimalGoalVocabularyDefault.validNumeric x ->
      DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes s ->
      num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
        F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
        F64.Insts.CoreOpsArithNegF64 s = ok (core.result.Result.Ok f) ->
      exists magnitude : F64,
        DecimalGoalVocabularyDefault.roundsMagnitude
          (DecimalGoalVocabularyDefault.accumulatedMagnitude x) magnitude ∧
        DecimalGoalVocabularyDefault.signedMagnitude
          (DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f := by
-- BODY
  intro s x f hs hA hv hb hsuccess
  obtain ⟨C, hc, hr⟩ := P616_T1_CompatibleCompletion
  obtain ⟨r, trace, hembed⟩ := P616_T1_FrameNormality C hc s hs hA
  have hclass : DecimalGoalVocabularyDefault.classifies
      (DecimalGoalVocabularyDefault.bytes s) (some (Sum.inl x)) := ⟨hv, hb⟩
  obtain ⟨f', magnitude, hresult, hround, hsign⟩ :=
    (P616_T1_FrameCorrectness C hc s r trace hs hA hembed).2.2 x hclass
  have hactual := (P9_T1_ActualDispatchFrameEquality s).symm.trans
    ((P687_T1_ActualEmbeddedFrameEquality C hc hr s hs hA).trans hembed)
  have hpublic : num.imp.dec2flt.dec2flt
      F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
      F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
      F64.Insts.CoreOpsArithNegF64 s = ok (core.result.Result.Ok f') := by
    simp only [num.imp.dec2flt.dec2flt, hactual, bind_tc_ok, hresult]
    rfl
  have hsame : f' = f := by
    simpa only [Result.ok.injEq, core.result.Result.Ok.injEq] using
      hpublic.symm.trans hsuccess
  exact ⟨magnitude, hround, hsame ▸ hsign⟩

end dec2flt_model

Proof structure

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

Explore this dependency tree

Inspect related source (199)
More program dependencies (157)
Standard-library dependencies (39)

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 359 entries
Technical checking records
Local closure summary
{
  "node": "P13_T1_ParserAccumulatedRounding",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "9ce45ea5fb78216a9f2afb5049517caef7cbc0c94136d73fb8c3c50a02d3a5fe",
  "active_statement_hash": "7a0a2ce93243d3c5239b82bc8a77a3eeabcaa252fbe44091d8bdcdb390df4208",
  "kernel_axioms": [
    "propext"
  ],
  "toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
  "lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
  "checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
  "approved_axioms_hash": "576e6bf9480cfd32f53c309c7ac8fb115c1ba6e413f299ed5ff9fa7c647e6769",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-202",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "P616_T1_CompatibleCompletion": "aa31d8fe34fb8053",
    "P616_T1_FrameCorrectness": "a90f9fab4a7d01e5",
    "P616_T1_FrameNormality": "29abc091a2722bc0",
    "P687_T1_ActualEmbeddedFrameEquality": "36a7e7b39c17d946",
    "P9_T1_ActualDispatchFrameEquality": "92c71f92e809e8b3"
  },
  "strict_definition_deps": {
    "DecimalGoalVocabulary": "c08dd4b4aea4abb4",
    "DecimalGoalVocabularyDefault": "28ca0a8ac503ee01",
    "DecimalLexeme": "250be645520aec86",
    "DispatchContracts": "008abfbd503545bf",
    "F64": "ec4e25fbaf4e11d4",
    "F64_Insts_CoreOpsArithDivF64F64": "dc44e13a99fc6bed",
    "F64_Insts_CoreOpsArithMulF64F64": "1ae1a9021a654abd",
    "F64_Insts_CoreOpsArithNegF64": "2d9be310c546ea2e",
    "F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64": "30963b4ef656cc79",
    "P9_T1_AbstractComponents": "c43614ff2149ecf2",
    "P9_T1_ActualDispatchOperations": "d8bf51ebbbf153ac",
    "P9_T1_DispatchFrame": "3d36c6a218e86be3",
    "P9_T1_EmbedComponents": "c6037220641c6c08",
    "P9_T1_NormalComponentRefinement": "008abfbd503545bf",
    "core_ops_arith_Div": "6e5df64b87169aa0",
    "core_ops_arith_Mul": "6e5df64b87169aa0",
    "core_ops_arith_Neg": "94ab5f784cdf5db8",
    "num_float_parse_ParseFloatError": "c43614ff2149ecf2",
    "num_imp_dec2flt_Dec2FltTrace": "644abe66cec8ac98",
    "num_imp_dec2flt_Lemire": "94ab5f784cdf5db8",
    "num_imp_dec2flt_dec2flt": "f9f7d93449a25efa",
    "num_imp_dec2flt_dec2flt_with_trace": "ebe6a57c6dce0df6"
  }
}
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:52420aea37870ffc2a9200fc5d64fcf8eaa6b20fc692601643dee66043262e1f",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}