P13_T1_ParserEqualTargetRounding

Lean checked

Statement

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

Theorem

On acceptance of a numeric literal whose complete source-valid Rust string has byte length at most A=3458764513820540928, if its ordinary mathematical exact magnitude and its source-defined accumulated-exponent magnitude have the same binary64 nearest-even magnitude target t, the actual specialized dec2flt returns t with the literal's lexical sign, including signed zero and signed infinity. The common-target premise is retained explicitly; it is not replaced by equality of explicit exponents or an unconditional exact-rounding assertion. The complete-string bound includes any leading sign. Both values retain every significand digit, and the accumulated exponent uses the signed pre-update 2^{59} fold with overshoot and continued scanning. Grammar, the two distinct values, full binary64 rounding and sign application are DecimalGoalVocabularyDefault. Acceptance is normal Rust Ok of the 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.RoundingDeterminism

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P13_T1_ParserEqualTargetRounding]
theorem P13_T1_ParserEqualTargetRounding :
    forall (s : Str) (x : DecimalLexeme) (f target : F64),
      DecimalGoalVocabularyDefault.sourceString s ->
      s.val.length <= 3458764513820540928 ->
      DecimalGoalVocabularyDefault.validNumeric x ->
      DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes s ->
      DecimalGoalVocabularyDefault.roundsMagnitude
        (DecimalGoalVocabularyDefault.exactMagnitude x) target ->
      DecimalGoalVocabularyDefault.roundsMagnitude
        (DecimalGoalVocabularyDefault.accumulatedMagnitude x) target ->
      num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
        F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
        F64.Insts.CoreOpsArithNegF64 s = ok (core.result.Result.Ok f) ->
      DecimalGoalVocabularyDefault.signedMagnitude
        (DecimalGoalVocabularyDefault.lexicalNegative x) target 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: Apply ParserAccumulatedRounding on the same A-bounded complete string, then use RoundingDeterminism to identify the returned magnitude with the stated common target. Do not remove the common-target premise.

Lean proof


  intro s x f target hs hlen hvalid hrender hexact hacc hcall
  obtain ⟨magnitude, hround, hsigned⟩ :=
    P13_T1_ParserAccumulatedRounding s x f hs hlen hvalid hrender hcall
  have hnonneg : 0 ≤ DecimalGoalVocabularyDefault.accumulatedMagnitude x :=
    hround.1
  have htarget : magnitude = target :=
    RoundingDeterminism _ magnitude target hnonneg hround hacc
  rw [htarget] at hsigned
  exact 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.RoundingDeterminism

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P13_T1_ParserEqualTargetRounding]
theorem P13_T1_ParserEqualTargetRounding :
    forall (s : Str) (x : DecimalLexeme) (f target : F64),
      DecimalGoalVocabularyDefault.sourceString s ->
      s.val.length <= 3458764513820540928 ->
      DecimalGoalVocabularyDefault.validNumeric x ->
      DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes s ->
      DecimalGoalVocabularyDefault.roundsMagnitude
        (DecimalGoalVocabularyDefault.exactMagnitude x) target ->
      DecimalGoalVocabularyDefault.roundsMagnitude
        (DecimalGoalVocabularyDefault.accumulatedMagnitude x) target ->
      num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
        F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
        F64.Insts.CoreOpsArithNegF64 s = ok (core.result.Result.Ok f) ->
      DecimalGoalVocabularyDefault.signedMagnitude
        (DecimalGoalVocabularyDefault.lexicalNegative x) target f := by
-- BODY
  intro s x f target hs hlen hvalid hrender hexact hacc hcall
  obtain ⟨magnitude, hround, hsigned⟩ :=
    P13_T1_ParserAccumulatedRounding s x f hs hlen hvalid hrender hcall
  have hnonneg : 0 ≤ DecimalGoalVocabularyDefault.accumulatedMagnitude x :=
    hround.1
  have htarget : magnitude = target :=
    RoundingDeterminism _ magnitude target hnonneg hround hacc
  rw [htarget] at hsigned
  exact 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 360 entries
Technical checking records
Local closure summary
{
  "node": "P13_T1_ParserEqualTargetRounding",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "9e977e4589f44ab7c80f9425c05f48d753a93e73e0a92da849268b0539fef5a0",
  "active_statement_hash": "81a1bc43dee091886bd4f0554d05dfd927bc36379237b83d2f958c504777f73c",
  "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": {
    "DecimalGoalVocabularyDefault": "2bbf2be48b5a4a4b",
    "P13_T1_ParserAccumulatedRounding": "69d1b6f306eb4da9",
    "RoundingDeterminism": "6500074d31847e13"
  },
  "strict_definition_deps": {
    "DecimalGoalVocabulary": "c08dd4b4aea4abb4",
    "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:eed50ad8e839b181136e345c5ab3a1aa16959cfcce3b283df1a3017e3d979313",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}