P13_T1_ParserNumericAcceptance

Lean checked

Statement

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

Theorem

Every numeric literal whose complete source-valid Rust string has byte length at most A=3458764513820540928 returns normally with Rust Ok from the actual specialized dec2flt, without panicking, including checked-arithmetic executions. The bound includes any leading sign. The complete numeric grammar is DecimalGoalVocabularyDefault; optional leading signs and explicit exponents of arbitrary digit count and mathematical value are allowed within this complete-string bound. No normal-return premise replaces the required acceptance conclusion. The source 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_ParserNumericAcceptance]
theorem P13_T1_ParserNumericAcceptance :
    forall (s : Str) (x : DecimalLexeme),
      DecimalGoalVocabularyDefault.sourceString s ->
      s.val.length <= 3458764513820540928 ->
      DecimalGoalVocabularyDefault.validNumeric x ->
      DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes s ->
      exists f : F64,
        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
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 s,x with the stated source-validity, complete-string A-bound, numeric validity and rendering hypotheses. Choose once the package C supplied by CompatibleCompletion, together with its DispatchContracts and NormalComponentRefinement. Apply FrameNormality to this same C and s to obtain r,\tau with
\mathrm{P9\_T1\_DispatchFrame}(\mathrm{P9\_T1\_EmbedComponents}(C),s) =\mathrm{ok}(r,\tau).
By the numeric clause of DecimalGoalVocabularyDefault, the given validity and rendering equations are precisely a complete numeric classification by x. The numeric conclusion of FrameCorrectness, applied to this normal equation and the same contracts, supplies f,m with r=\mathrm{Rust\ Ok}(f) and its rounding and sign witnesses. Only the equality for r is needed here.
ActualEmbeddedFrameEquality, with the same C, its two laws and the original s hypotheses, identifies the entire actual frame Result with that normal embedded frame Result. ActualDispatchFrameEquality then identifies the actual frame with the specialized extracted traced dispatcher. Thus that dispatcher returns \mathrm{ok}(\mathrm{Rust\ Ok}(f),\tau). The extracted definition num imp dec2flt dec2flt binds this traced Result and returns its first projection. Its normal-bind equation therefore gives exactly \mathrm{ok}(\mathrm{Rust\ Ok}(f)), the required witness. Normal output was constructed using FrameNormality, not assumed of either the actual dispatcher or the public parser. All applications retain the bound on the complete string, including its optional sign.

Lean proof


  intro s x hs hA hv hb
  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)
  refine ⟨f, ?_⟩
  simp only [num.imp.dec2flt.dec2flt, hactual, bind_tc_ok, hresult]
  rfl

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_ParserNumericAcceptance]
theorem P13_T1_ParserNumericAcceptance :
    forall (s : Str) (x : DecimalLexeme),
      DecimalGoalVocabularyDefault.sourceString s ->
      s.val.length <= 3458764513820540928 ->
      DecimalGoalVocabularyDefault.validNumeric x ->
      DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes s ->
      exists f : F64,
        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
-- BODY
  intro s x hs hA hv hb
  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)
  refine ⟨f, ?_⟩
  simp only [num.imp.dec2flt.dec2flt, hactual, bind_tc_ok, hresult]
  rfl

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_ParserNumericAcceptance",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "2ea6ec7cd0d3df252d0989fc0316a7a6a6158739b4a7bd01ae41fa16e84c39d8",
  "active_statement_hash": "07660fae195b0d10e191e36d15fa135d72f6fe8ccd61cf7f7077552bea6d7b0c",
  "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:d4c1e804848a0ccf7c7e8bc34483a73e37c73117c7c5d75d9b6bc3c29fb42a8a",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}