ClassificationTotality

Lean checked

Statement

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

Theorem

Every finite byte string, with no source-string or UTF-8 restriction, has a numeric classification with complete parsed content, a signed special classification, or the invalid classification.

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.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64
import Tablet.F64_Insts_CoreOpsArithDivF64F64
import Tablet.F64_Insts_CoreOpsArithMulF64F64
import Tablet.F64_Insts_CoreOpsArithNegF64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.num_imp_dec2flt_dec2flt
import Tablet.num_imp_dec2flt_dec2flt_with_trace
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_parse_parse_inf_nan
import Tablet.num_imp_dec2flt_decimal_Decimal_try_fast_path
import Tablet.num_imp_dec2flt_lemire_compute_float
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_dec2flt_biased_fp_to_float

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: ClassificationTotality]
theorem ClassificationTotality :
    ∀ bs : List Nat, (∀ b ∈ bs, b < 256) -> ∃ c, DecimalGoalVocabularyDefault.classifies bs c := 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.

Earlier prose review

An earlier review questioned the prose argument. Lean subsequently checked the formal proof. Review of the statement’s intended meaning is a separate judgment.

Proof

Fix a finite list b_s satisfying the stated byte-value bound. We use classical excluded middle on the two possible successful-witness families. First ask whether there is a lexeme x for which b_s is classified as \operatorname{some}(\operatorname{inl}(x)). If so, choose this option as c; its witnessing classification is exactly the required conclusion.
Suppose instead that there is no such numeric-classification witness. Ask whether there are a sign s and kind Boolean n for which b_s is classified as \operatorname{some}(\operatorname{inr}(s,n)). If so, choose that option as c, again using the witness just obtained.
It remains to consider the case in which neither witness family exists. By the definition of the classifies field in DecimalGoalVocabularyDefault, a left value is related exactly when its numeric-literal witness holds, a right value is related exactly when its special-literal sign/kind witness holds, and none is related exactly when neither of those two witness families exists. The two negative case assumptions therefore establish both conjuncts required for classifies b_s none. Choosing c=\texttt{none} proves the conclusion in this final case. These cases are exhaustive by the two applications of excluded middle.
The byte-value hypothesis is unused: this mathematical classification relation is total on every finite List Nat, including lists that do not encode Rust bytes.

Lean proof


  intro bs _
  classical
  by_cases hnum : ∃ x, DecimalGoalVocabularyDefault.classifies bs (some (Sum.inl x))
  · obtain ⟨x, hx⟩ := hnum
    exact ⟨some (Sum.inl x), hx⟩
  · by_cases hspecial :
        ∃ sign nan, DecimalGoalVocabularyDefault.classifies bs (some (Sum.inr (sign, nan)))
    · obtain ⟨sign, nan, hsn⟩ := hspecial
      exact ⟨some (Sum.inr (sign, nan)), hsn⟩
    · refine ⟨none, ?_⟩
      simp only [DecimalGoalVocabularyDefault] at hnum hspecial ⊢
      exact ⟨hnum, hspecial⟩

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.DecimalGoalVocabularyDefault
import Tablet.F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64
import Tablet.F64_Insts_CoreOpsArithDivF64F64
import Tablet.F64_Insts_CoreOpsArithMulF64F64
import Tablet.F64_Insts_CoreOpsArithNegF64
import Tablet.F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64
import Tablet.num_imp_dec2flt_dec2flt
import Tablet.num_imp_dec2flt_dec2flt_with_trace
import Tablet.num_imp_dec2flt_parse_parse_number
import Tablet.num_imp_dec2flt_parse_parse_inf_nan
import Tablet.num_imp_dec2flt_decimal_Decimal_try_fast_path
import Tablet.num_imp_dec2flt_lemire_compute_float
import Tablet.num_imp_dec2flt_slow_parse_long_mantissa
import Tablet.num_imp_dec2flt_biased_fp_to_float

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: ClassificationTotality]
theorem ClassificationTotality :
    ∀ bs : List Nat, (∀ b ∈ bs, b < 256) -> ∃ c, DecimalGoalVocabularyDefault.classifies bs c := by
-- BODY
  intro bs _
  classical
  by_cases hnum : ∃ x, DecimalGoalVocabularyDefault.classifies bs (some (Sum.inl x))
  · obtain ⟨x, hx⟩ := hnum
    exact ⟨some (Sum.inl x), hx⟩
  · by_cases hspecial :
        ∃ sign nan, DecimalGoalVocabularyDefault.classifies bs (some (Sum.inr (sign, nan)))
    · obtain ⟨sign, nan, hsn⟩ := hspecial
      exact ⟨some (Sum.inr (sign, nan)), hsn⟩
    · refine ⟨none, ?_⟩
      simp only [DecimalGoalVocabularyDefault] at hnum hspecial ⊢
      exact ⟨hnum, hspecial⟩

end dec2flt_model

Proof structure

Follow the declared dependencies to read the supporting statements and proofs.

Explore this dependency tree

Inspect related source (201)
More program dependencies (159)
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 7 entries
Technical checking records
Local closure summary
{
  "node": "ClassificationTotality",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "e63bbd99fde2dce9f298b740e783eb6d36dd7105c5fcd2b4a79b03dba671560c",
  "active_statement_hash": "6cb5e7c254e840370e84b7857ceb36d37c06a47cc5404c188f1ff32f413af831",
  "kernel_axioms": [
    "Classical.choice",
    "Quot.sound",
    "propext"
  ],
  "toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
  "lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
  "checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
  "approved_axioms_hash": "ab64d13f256386ee0e494a5abcc6a5db49512cf3d90bbdfcabd6327793a31f95",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-89",
  "boundary_theorems": {},
  "strict_theorem_deps": {
    "DecimalGoalVocabularyDefault": "94cb4c406f8efb78"
  },
  "strict_definition_deps": {
    "DecimalGoalVocabulary": "c43614ff2149ecf2",
    "DecimalGoalVocabularyDefault": "55eb6bce0e8a4131",
    "DecimalLexeme": "8127b3eaeae00dd2",
    "F64": "ec4e25fbaf4e11d4",
    "num_imp_dec2flt_common_BiasedFp": "c43614ff2149ecf2",
    "num_imp_dec2flt_decimal_Decimal": "4c41a56bf44cb31e"
  }
}
Prose assessment
{
  "label": "Sound flag superseded by recorded Lean closure",
  "assessment_status": "ReviewerPinnedFail",
  "fingerprint_relation": "differs from current fingerprint",
  "assessment_fingerprint": "sound-v2:1a8b5f5ccfc62e5e08b3313af1ffa823ce3a626170db8e8e4824d4621e919775",
  "current_fingerprint": "sound-v2:16677fb2b2a9f7dd1acfdd03113e4d6fd57ab7e6a9f588af7d2198d66d00b17e",
  "superseded_for_theorem_closure": true
}
Review verdicts
{
  "corr_status": "Pass",
  "sound_status": "Fail",
  "substantiveness_status": "Pass"
}