P13_T1_ParserTotality

Lean checked

Statement

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

Theorem

For every source-valid Rust string of complete byte length at most A=3458764513820540928, the actual specialized dec2flt terminates normally with a Rust float result or parsing error, without panicking. This includes checked-arithmetic executions and numeric, special, invalid, empty and sign-only inputs. The bound is on the complete string, including any leading sign; the Rust-string domain is DecimalGoalVocabularyDefault. A normal outer result containing either Rust Ok or Rust Err is required; outer failure and divergence do not count. 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.ClassificationTotality
import Tablet.P13_T1_ParserNumericAcceptance
import Tablet.P13_T1_ParserInfinity
import Tablet.P13_T1_ParserNanAcceptance
import Tablet.P13_T1_ParserInvalidRejection

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P13_T1_ParserTotality]
theorem P13_T1_ParserTotality :
    forall s : Str,
      DecimalGoalVocabularyDefault.sourceString s ->
      s.val.length <= 3458764513820540928 ->
      exists r : core.result.Result F64 num.float_parse.ParseFloatError,
        num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
          F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
          F64.Insts.CoreOpsArithNegF64 s = ok r := 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 proof: SKETCH. The explanatory prose is preserved as it stood when captured.

Proof

SKETCH: Establish normal realization of every reached source call on the stated complete-string domain, covering all branches and checked arithmetic rather than assuming that an execution already returns normally.

Lean proof


  intro s hsource hlen
  have hbytes : ∀ b ∈ DecimalGoalVocabularyDefault.bytes s, b < 256 := by
    intro b hb
    dsimp [DecimalGoalVocabularyDefault] at hb ⊢
    rcases List.mem_map.mp hb with ⟨u, hu, rfl⟩
    exact u.bv.isLt
  obtain ⟨c, hc⟩ := ClassificationTotality
    (DecimalGoalVocabularyDefault.bytes s) hbytes
  cases c with
  | none =>
      change (¬ ∃ x, DecimalGoalVocabularyDefault.validNumeric x ∧
          DecimalGoalVocabularyDefault.renderNumeric x =
            DecimalGoalVocabularyDefault.bytes s) ∧
        (¬ ∃ sign nan, DecimalGoalVocabularyDefault.specialLiteral
          (DecimalGoalVocabularyDefault.bytes s) sign nan) at hc
      obtain ⟨error, herr⟩ := P13_T1_ParserInvalidRejection s hsource hlen hc
      exact ⟨core.result.Result.Err error, herr⟩
  | some result =>
      cases result with
      | inl x =>
          change DecimalGoalVocabularyDefault.validNumeric x ∧
            DecimalGoalVocabularyDefault.renderNumeric x =
              DecimalGoalVocabularyDefault.bytes s at hc
          obtain ⟨valid, rendered⟩ := hc
          obtain ⟨f, hf⟩ := P13_T1_ParserNumericAcceptance s x
            hsource hlen valid rendered
          exact ⟨core.result.Result.Ok f, hf⟩
      | inr special =>
          rcases special with ⟨sign, nan⟩
          change DecimalGoalVocabularyDefault.specialLiteral
            (DecimalGoalVocabularyDefault.bytes s) sign nan at hc
          cases nan with
          | false =>
              obtain ⟨f, hf, _⟩ := P13_T1_ParserInfinity s sign hsource hc
              exact ⟨core.result.Result.Ok f, hf⟩
          | true =>
              obtain ⟨f, hf, _⟩ := P13_T1_ParserNanAcceptance s sign hsource hc
              exact ⟨core.result.Result.Ok f, hf⟩

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.ClassificationTotality
import Tablet.P13_T1_ParserNumericAcceptance
import Tablet.P13_T1_ParserInfinity
import Tablet.P13_T1_ParserNanAcceptance
import Tablet.P13_T1_ParserInvalidRejection

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P13_T1_ParserTotality]
theorem P13_T1_ParserTotality :
    forall s : Str,
      DecimalGoalVocabularyDefault.sourceString s ->
      s.val.length <= 3458764513820540928 ->
      exists r : core.result.Result F64 num.float_parse.ParseFloatError,
        num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
          F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
          F64.Insts.CoreOpsArithNegF64 s = ok r := by
-- BODY
  intro s hsource hlen
  have hbytes : ∀ b ∈ DecimalGoalVocabularyDefault.bytes s, b < 256 := by
    intro b hb
    dsimp [DecimalGoalVocabularyDefault] at hb ⊢
    rcases List.mem_map.mp hb with ⟨u, hu, rfl⟩
    exact u.bv.isLt
  obtain ⟨c, hc⟩ := ClassificationTotality
    (DecimalGoalVocabularyDefault.bytes s) hbytes
  cases c with
  | none =>
      change (¬ ∃ x, DecimalGoalVocabularyDefault.validNumeric x ∧
          DecimalGoalVocabularyDefault.renderNumeric x =
            DecimalGoalVocabularyDefault.bytes s) ∧
        (¬ ∃ sign nan, DecimalGoalVocabularyDefault.specialLiteral
          (DecimalGoalVocabularyDefault.bytes s) sign nan) at hc
      obtain ⟨error, herr⟩ := P13_T1_ParserInvalidRejection s hsource hlen hc
      exact ⟨core.result.Result.Err error, herr⟩
  | some result =>
      cases result with
      | inl x =>
          change DecimalGoalVocabularyDefault.validNumeric x ∧
            DecimalGoalVocabularyDefault.renderNumeric x =
              DecimalGoalVocabularyDefault.bytes s at hc
          obtain ⟨valid, rendered⟩ := hc
          obtain ⟨f, hf⟩ := P13_T1_ParserNumericAcceptance s x
            hsource hlen valid rendered
          exact ⟨core.result.Result.Ok f, hf⟩
      | inr special =>
          rcases special with ⟨sign, nan⟩
          change DecimalGoalVocabularyDefault.specialLiteral
            (DecimalGoalVocabularyDefault.bytes s) sign nan at hc
          cases nan with
          | false =>
              obtain ⟨f, hf, _⟩ := P13_T1_ParserInfinity s sign hsource hc
              exact ⟨core.result.Result.Ok f, hf⟩
          | true =>
              obtain ⟨f, hf, _⟩ := P13_T1_ParserNanAcceptance s sign hsource hc
              exact ⟨core.result.Result.Ok f, hf⟩

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 369 entries
Technical checking records
Local closure summary
{
  "node": "P13_T1_ParserTotality",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "34f50626d766e187f88fbf811c4a6f67f563936f2f70aa2a7f9a6dba1097af0d",
  "active_statement_hash": "2206565ac2b5fcb16924dce2586397bcfdb68bb09687a26664b6bfcbb43ab72e",
  "kernel_axioms": [
    "Quot.sound",
    "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": {
    "ClassificationTotality": "fee1612033f77123",
    "P13_T1_ParserInfinity": "a0ec9ffb9ebbbefb",
    "P13_T1_ParserInvalidRejection": "6079647b2532590a",
    "P13_T1_ParserNanAcceptance": "1579c8a8860d1b73",
    "P13_T1_ParserNumericAcceptance": "7cb416a8a3c67b7f"
  },
  "strict_definition_deps": {
    "DecimalGoalVocabulary": "daa08120138b32b6",
    "DecimalGoalVocabularyDefault": "71a18a6c119a3cdc",
    "DecimalLexeme": "c43614ff2149ecf2",
    "F64": "ec4e25fbaf4e11d4",
    "F64_Insts_CoreOpsArithDivF64F64": "dc44e13a99fc6bed",
    "F64_Insts_CoreOpsArithMulF64F64": "1ae1a9021a654abd",
    "F64_Insts_CoreOpsArithNegF64": "2d9be310c546ea2e",
    "F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64": "30963b4ef656cc79",
    "num_float_parse_ParseFloatError": "c43614ff2149ecf2",
    "num_imp_dec2flt_dec2flt": "f9f7d93449a25efa"
  }
}
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:fd3333cf60ce9995121476b5c255e56cfce7216b6fcc5283770e32ed0db51b06",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}