P13_T1_ParserNanAcceptance

Lean checked

Statement

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

Theorem

Every source-valid Rust string spelling a complete NaN literal returns normally with Rust Ok of a float satisfying is_nan() from the actual specialized dec2flt. The optionally signed, ASCII-case-insensitive NaN grammar, source-string domain and raw-word NaN predicate are DecimalGoalVocabularyDefault. No A or B bound is imposed, and outer checked failure or divergence is not Rust Ok. The source specialization is the one used by 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.P347_T1_SpecialDispatch
import Tablet.SpecialHelperNan

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P13_T1_ParserNanAcceptance]
theorem P13_T1_ParserNanAcceptance :
    forall (s : Str) (sign : Option Bool),
      DecimalGoalVocabularyDefault.sourceString s ->
      DecimalGoalVocabularyDefault.specialLiteral
        (DecimalGoalVocabularyDefault.bytes s) sign true ->
      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) ∧
        DecimalGoalVocabularyDefault.isNan 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 a source-valid string s and its optional lexical sign \sigma. Its literal hypothesis is DecimalGoalVocabularyDefault's complete special-literal predicate with kind true. Apply SpecialDispatch with that kind and sign. The resulting body slice u satisfies the unsigned NaN-literal predicate, and the resulting implication transfers any normal Some f return of the specialized parse_inf_nan on that body to a normal Rust Ok f return of the actual public parser on s. Its negative argument is \nu=\operatorname{decide}(\sigma=\texttt{some true}).
Apply the current SpecialHelperNan to u, \nu, and its unsigned-literal predicate. For either Boolean sign, its statement supplies a binary64 word f with the required helper equation ok (Some f) and DecimalGoalVocabularyDefault's sign-insensitive \mathit{isNan}(f) property. It requires no additional length, numeric-rejection, or platform-width premise. The dispatch implication applied to that exact helper equation establishes the requested dec2flt equation ok (Rust Ok f), at the specialization of ActualDispatchOperations. Take f as the witness and retain its NaN property; no particular NaN payload or sign is required. These are normal outer returns, so neither checked failure nor divergence is being substituted for Rust Ok. The retained source-validity hypothesis imposes no further work because the shared dispatch statement holds for every model string satisfying this short grammar, without A or B restrictions.

Lean proof


  intro s sign _ hspecial
  obtain ⟨body, hbody, hdispatch⟩ := P347_T1_SpecialDispatch s sign true hspecial
  obtain ⟨f, hf, hnan⟩ := SpecialHelperNan body (decide (sign = some true)) hbody
  exact ⟨f, hdispatch f hf, hnan⟩

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.P347_T1_SpecialDispatch
import Tablet.SpecialHelperNan

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: P13_T1_ParserNanAcceptance]
theorem P13_T1_ParserNanAcceptance :
    forall (s : Str) (sign : Option Bool),
      DecimalGoalVocabularyDefault.sourceString s ->
      DecimalGoalVocabularyDefault.specialLiteral
        (DecimalGoalVocabularyDefault.bytes s) sign true ->
      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) ∧
        DecimalGoalVocabularyDefault.isNan f := by
-- BODY
  intro s sign _ hspecial
  obtain ⟨body, hbody, hdispatch⟩ := P347_T1_SpecialDispatch s sign true hspecial
  obtain ⟨f, hf, hnan⟩ := SpecialHelperNan body (decide (sign = some true)) hbody
  exact ⟨f, hdispatch f hf, hnan⟩

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 160 entries
Technical checking records
Local closure summary
{
  "node": "P13_T1_ParserNanAcceptance",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "1477a99480d6c603453691222e79624437ec9f4e258e2314292ebac1a47c9863",
  "active_statement_hash": "812cab8da25b841fa74899eac90dab7557cce53404b1f0d84b46edf0385ec921",
  "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-181",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "P347_T1_SpecialDispatch": "a80643c9dc7b88ce",
    "SpecialHelperNan": "1abf1a568c158d53"
  },
  "strict_definition_deps": {
    "DecimalGoalVocabulary": "65227461bf3cac06",
    "DecimalGoalVocabularyDefault": "71a18a6c119a3cdc",
    "F64": "ec4e25fbaf4e11d4",
    "F64_Insts_CoreOpsArithDivF64F64": "dc44e13a99fc6bed",
    "F64_Insts_CoreOpsArithMulF64F64": "1ae1a9021a654abd",
    "F64_Insts_CoreOpsArithNegF64": "2d9be310c546ea2e",
    "F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64": "30963b4ef656cc79",
    "F64_Insts_Dec2flt_modelNumImpTraitsFloatU64": "94095c9bf79da164",
    "num_float_parse_ParseFloatError": "c43614ff2149ecf2",
    "num_imp_dec2flt_dec2flt": "f9f7d93449a25efa",
    "num_imp_dec2flt_parse_parse_inf_nan": "85655c19a8791b54"
  }
}
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:3b14598b801dd1c6e73e920353a20455bfb7028037ed7e9d4cec37bf7bbe0536",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}