P13_T1_ParserExactRounding

Lean checked

Statement

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

Theorem

On acceptance of any numeric literal whose complete source-valid Rust string has byte length at most B=576460752303421440, the actual specialized dec2flt returns its ordinary mathematical exact decimal value rounded to IEEE 754 binary64 nearest, ties to even, with the literal's lexical sign. The bound includes any leading sign. The exact magnitude retains every significand digit and gives the explicit exponent its unbounded mathematical meaning, with no additional exponent-digit or value restriction. This includes subnormal results, lexical signed zero and overflow to lexical signed infinity. Grammar, values, rounding and sign application are DecimalGoalVocabularyDefault; acceptance is normal Rust Ok of the source specialization in 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.P13_T1_ParserAccumulatedRounding
import Tablet.P9_T1_DispatchComponentCompliance

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P13_T1_ParserExactRounding]
theorem P13_T1_ParserExactRounding :
    forall (s : Str) (x : DecimalLexeme) (f : F64),
      DecimalGoalVocabularyDefault.sourceString s ->
      s.val.length <= 576460752303421440 ->
      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.exactMagnitude 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 proof: SKETCH. The explanatory prose is preserved as it stood when captured.

Proof

SKETCH: Establish correctness of successful numeric dispatch and the B-bounded transport from the full-significand accumulated rounding target to the ordinary mathematical exact target, retaining lexical sign.

Lean proof


  intro s x f hsource hlen hvalid hrender hpublic
  obtain ⟨magnitude, hroundAccum, hsigned⟩ :=
    P13_T1_ParserAccumulatedRounding s x f hsource (by omega) hvalid hrender hpublic
  obtain ⟨_C, _hcontracts, _hrefine, _hreached, hexact⟩ :=
    P9_T1_DispatchComponentCompliance
  have hclassifies : DecimalGoalVocabularyDefault.classifies
      (DecimalGoalVocabularyDefault.bytes s) (some (Sum.inl x)) := by
    change DecimalGoalVocabularyDefault.validNumeric x ∧
      DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes s
    exact ⟨hvalid, hrender⟩
  have htransport := (hexact s x hsource hlen hclassifies magnitude).mp hroundAccum
  refine ⟨magnitude, htransport, hsigned⟩

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.P13_T1_ParserAccumulatedRounding
import Tablet.P9_T1_DispatchComponentCompliance

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P13_T1_ParserExactRounding]
theorem P13_T1_ParserExactRounding :
    forall (s : Str) (x : DecimalLexeme) (f : F64),
      DecimalGoalVocabularyDefault.sourceString s ->
      s.val.length <= 576460752303421440 ->
      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.exactMagnitude x) magnitude ∧
        DecimalGoalVocabularyDefault.signedMagnitude
          (DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f := by
-- BODY
  intro s x f hsource hlen hvalid hrender hpublic
  obtain ⟨magnitude, hroundAccum, hsigned⟩ :=
    P13_T1_ParserAccumulatedRounding s x f hsource (by omega) hvalid hrender hpublic
  obtain ⟨_C, _hcontracts, _hrefine, _hreached, hexact⟩ :=
    P9_T1_DispatchComponentCompliance
  have hclassifies : DecimalGoalVocabularyDefault.classifies
      (DecimalGoalVocabularyDefault.bytes s) (some (Sum.inl x)) := by
    change DecimalGoalVocabularyDefault.validNumeric x ∧
      DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes s
    exact ⟨hvalid, hrender⟩
  have htransport := (hexact s x hsource hlen hclassifies magnitude).mp hroundAccum
  refine ⟨magnitude, htransport, hsigned⟩

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 361 entries
Technical checking records
Local closure summary
{
  "node": "P13_T1_ParserExactRounding",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "53a2963e67fa423a8f980e15ac67ecebf2f25cec65ab5439f5079a7e95cce41b",
  "active_statement_hash": "080e0e1f20b0a292190cafa6634be2bb867f5925d1224ccbb6a4a801242e7f40",
  "kernel_axioms": [
    "Classical.choice",
    "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": {
    "P13_T1_ParserAccumulatedRounding": "69d1b6f306eb4da9",
    "P9_T1_DispatchComponentCompliance": "37a2c2611f2ea35d"
  },
  "strict_definition_deps": {
    "DecimalGoalVocabulary": "4da7f295a9b85b50",
    "DecimalGoalVocabularyDefault": "71a18a6c119a3cdc",
    "DecimalLexeme": "8ad754cf2c272e73",
    "DispatchContracts": "008abfbd503545bf",
    "F64": "ec4e25fbaf4e11d4",
    "F64_Insts_CoreOpsArithDivF64F64": "dc44e13a99fc6bed",
    "F64_Insts_CoreOpsArithMulF64F64": "1ae1a9021a654abd",
    "F64_Insts_CoreOpsArithNegF64": "2d9be310c546ea2e",
    "F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64": "30963b4ef656cc79",
    "P9_T1_AbstractComponents": "d6e54fa2100fd398",
    "P9_T1_ActualDispatchOperations": "d8bf51ebbbf153ac",
    "P9_T1_DispatchCall": "c43614ff2149ecf2",
    "P9_T1_DispatchComponentCompliance": "397d926a710930c4",
    "P9_T1_DispatchOperations": "064b44803eb69a33",
    "P9_T1_NormalComponentRefinement": "008abfbd503545bf",
    "P9_T1_ReachedDispatchCall": "d7916c72b79f840d",
    "SourceValidByteSlice": "3dc42716a6378d26",
    "num_float_parse_ParseFloatError": "c43614ff2149ecf2",
    "num_imp_dec2flt_common_BiasedFp": "5c88d5d7976c5e8f",
    "num_imp_dec2flt_common_BiasedFp_Insts_CoreCmpPartialEqBiasedFp_eq": "fbbf553e3c502a05",
    "num_imp_dec2flt_dec2flt": "f9f7d93449a25efa",
    "num_imp_dec2flt_decimal_Decimal": "b702e549017701b8"
  }
}
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:0db576d9e9ff5306fea5fa78b188a48447b1c5535122af6b5df0cd3ceca327f4",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}