ClassificationSignificandDigit

Lean checked

Statement

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

Theorem

Every finite byte string classified as a numeric literal has at least one digit in the significand, before or after its optional decimal point.

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: ClassificationSignificandDigit]
theorem ClassificationSignificandDigit :
    ∀ (bs : List Nat) x, (∀ b ∈ bs, b < 256) ->
      DecimalGoalVocabularyDefault.classifies bs (some (Sum.inl x)) ->
      x.integerDigits ≠ [] ∨ ∃ ds, x.fractionDigits = some ds ∧ ds ≠ [] := 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 byte list bs and a numeric lexeme x satisfying the two hypotheses. By the definition of classification in DecimalGoalVocabularyDefault, numeric classification unfolds to the conjunction of validNumeric for x and the equality saying that the rendering of x is bs. From the first component of this conjunction, take the third conjunct in the definition of validNumeric. It states
x.\mathit{integerDigits}\ne []\quad\text{or}\quad \begin{cases} \mathsf{False},&x.\mathit{fractionDigits}=\mathsf{none},\\ ds\ne [],&x.\mathit{fractionDigits}=\mathsf{some}(ds). \end{cases}
Now split on x.\mathit{fractionDigits}. If it is none, the second alternative above reduces to false. Hence x.\mathit{integerDigits}\ne [], which is the first alternative of the conclusion. If it is some ds, that same conjunct gives either x.\mathit{integerDigits}\ne [] or ds\ne []. The former again gives the first alternative of the conclusion. In the latter case, the list ds, together with the case equality x.\mathit{fractionDigits}=\mathsf{some}(ds) and the fact ds\ne [], is the witness required by the second alternative.
The byte-bound hypothesis is not needed: validity already contains the desired nonemptiness condition. Likewise, after validity is extracted from numeric classification, the rendering equality is unused.

Lean proof


  intro bs x _ h
  simp only [DecimalGoalVocabularyDefault] at h
  rcases h with ⟨⟨_, _, hdigit, _⟩, _⟩
  cases hfrac : x.fractionDigits with
  | none =>
      simp [hfrac] at hdigit
      exact Or.inl hdigit
  | some ds =>
      simp [hfrac] at hdigit
      rcases hdigit with hInteger | hFraction
      · exact Or.inl hInteger
      · exact Or.inr ⟨ds, rfl, hFraction⟩

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: ClassificationSignificandDigit]
theorem ClassificationSignificandDigit :
    ∀ (bs : List Nat) x, (∀ b ∈ bs, b < 256) ->
      DecimalGoalVocabularyDefault.classifies bs (some (Sum.inl x)) ->
      x.integerDigits ≠ [] ∨ ∃ ds, x.fractionDigits = some ds ∧ ds ≠ [] := by
-- BODY
  intro bs x _ h
  simp only [DecimalGoalVocabularyDefault] at h
  rcases h with ⟨⟨_, _, hdigit, _⟩, _⟩
  cases hfrac : x.fractionDigits with
  | none =>
      simp [hfrac] at hdigit
      exact Or.inl hdigit
  | some ds =>
      simp [hfrac] at hdigit
      rcases hdigit with hInteger | hFraction
      · exact Or.inl hInteger
      · exact Or.inr ⟨ds, rfl, hFraction⟩

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 7 entries
Technical checking records
Local closure summary
{
  "node": "ClassificationSignificandDigit",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "7486955dc7a34b88d1cd739f0a9a74b0b51151c740283e1371710e2c933d3d51",
  "active_statement_hash": "3eaa01e799851903a678afe39b8939121c7ea680eaa8a2881049aab5d58a658f",
  "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-181",
  "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": "Lean proof closed; predictive prose review no longer required",
  "assessment_status": null,
  "fingerprint_relation": "unknown",
  "assessment_fingerprint": null,
  "current_fingerprint": "sound-v2:01300fe7cd9ac788670b39747982680acf8c26d17cfa810d9fc3c741e54fddff",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}