DecimalLexeme

Lean checked

Definition and explanation

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

Definition

A decimal lexeme records an optional lexical sign (true means minus and false means plus); a list of digits before the decimal point; an optional list of digits after a present decimal point; and an optional exponent. An exponent records whether its marker is uppercase, an optional sign (true means minus and false means plus), and its digit list. The lists contain digit values rather than ASCII codes. This representation deliberately permits invalid records; validity is imposed by the concrete goal vocabulary.

Lean definition

Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.

import Aeneas
import Tablet.Preamble

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: DecimalLexeme]
structure DecimalLexeme where
-- BODY
  leadingSign : Option Bool
  integerDigits : List Nat
  fractionDigits : Option (List Nat)
  exponent : Option (Bool × Option Bool × List Nat)

end dec2flt_model
Preservation and explanation

Natural-language argument

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.

Preservation argument

Claim

For each syntactic decomposition of a numeric literal in the reference grammar, there is a componentwise encoding as a decimal lexeme. An absent, plus, or minus leading sign is encoded respectively as none, some false, or some true. Each ASCII digit byte is encoded uniquely by its value in 0,\ldots,9. Absence of a decimal point is encoded by fractionDigits = none; a present point is encoded by fractionDigits = some ds, including when the following digit list ds is empty. Absence of an exponent is encoded by exponent = none. A present exponent is encoded by a triple that records lowercase e as false and uppercase E as true, records its absent, plus, or minus sign as none, some false, or some true, and contains its entire digit list. Projecting such an encoding recovers every one of these components, and two decimal-lexeme records are equal exactly when their four fields are componentwise equal.

Proof

The retained grammar specifies the optional leading sign, ASCII decimal significand, optional point, and optional e/E exponent with its optional sign and digit list (reference/model-evidence/goal-vocabulary.txt). The three sign cases go to distinct constructors or Boolean values. ASCII digit bytes are exactly 48,\ldots,57, so subtracting 48 maps them bijectively and in order to 0,\ldots,9; adding 48 is the inverse on this domain. Mapping a list applies these mutually inverse operations at every position and therefore loses no digit or order.
For the point, the outer option separates no point from a present point, while the list inside some retains all following digits and may be empty. For the exponent, the outer option separates absence from presence; in the present triple the first Boolean separates the two marker cases, the inner option and Boolean separate all three sign cases, and the list retains every exponent digit. Reading the four record fields and applying the inverse sign, marker, and digit tables therefore recovers the original decomposition. Finally, equality of structure values is equivalent to equality of each named field, and equality of the option, product, Boolean, and list components is componentwise; hence record equality has exactly the stated characterization.
This is only a lossless carrier construction. The carrier deliberately also contains invalid tuples. It supplies neither a validity predicate nor rendering, whole-input membership, grammar complement, classification, numeric or accumulated values, source Decimal records, or source execution behavior.

Requirement: parser totality

This carrier has no source-call or control-flow content and therefore contributes no termination, normal-return, result, error, or panic claim.

Requirement: parser numeric acceptance

A supplied numeric-grammar witness, including every lexical component, can be represented without loss. Validity, whole-input rendering, acceptance, and the returned result remain with their respective owners.

Requirement: parser invalid rejection

This permissive carrier has no validity predicate, whole-input membership test, or grammar complement. It contributes no claim that an invalid string is rejected or returns Err.

Requirement: parser nan acceptance

The carrier describes only possible numeric content and has no special-literal, NaN-word, or source-return observation, so it is noninterfering.

Requirement: parser infinity

The carrier has no special-literal, infinity-word, or source-return observation and therefore contributes no infinity-acceptance claim.

Requirement: parser non nan results

The carrier records possible numeric content only; it asserts neither numeric/special disjointness nor anything about NaN words or successful source results.

Requirement: parser numeric sign

For a supplied numeric-grammar witness, the leading-sign field retains absence, plus, or minus without loss. Interpreting that sign on a returned word, including zero or infinity, remains outside this carrier.

Requirement: parser signed zero

For a supplied numeric-grammar witness, the carrier retains its leading sign and every significand and exponent digit. It asserts neither that the literal denotes zero nor any returned-word relation.

Requirement: parser exact rounding

For a supplied numeric-grammar witness, the carrier retains the sign, all significand digits, point presence, and all exponent components used by later exact-value interpretation. It supplies no value, rounding, acceptance, or return claim.

Requirement: parser selected exponent

The carrier contains no dispatcher trace or raw-pair field and is noninterfering with selection and biased-exponent bounds.

Requirement: parser selected magnitude sign

The carrier contains no dispatcher trace, raw pair, assembly operation, or word observation and contributes no selected-word sign claim.

Requirement: dispatch abstract composition

A lexical contract may use this carrier to hold a supplied numeric-grammar witness without losing any lexical component. The carrier asserts no contract implementation, dispatcher behavior, conversion-tier state, or normal result.

Requirement: dispatch component compliance

Only a supplied numeric-grammar witness receives a lossless lexeme representation. Invalid lexical inputs need not have such a witness, and conversion-tier Decimal arguments have already discarded lexical distinctions; this carrier asserts no component compliance, call-site precondition, or result.

Requirement: parser accumulated rounding

For a supplied numeric-grammar witness, all significand digits and the explicit exponent sign and digit list remain available to a later bounded-accumulation interpretation. No accumulated value, rounding target, acceptance, or return relation is asserted.

Requirement: parser equal target rounding

For a supplied numeric-grammar witness, the same retained sign, significand, point, and exponent components are available to later exact and accumulated interpretations. The carrier supplies neither interpretation, their target equality, acceptance, nor the returned result.

Requirement: number helper acceptance

A supplied unsigned numeric-grammar witness can be represented without loss by using leadingSign = none; its exponent sign is still retained independently. Unsigned validity, rendering, byte-domain coverage, acceptance, and Some remain outside this carrier.

Requirement: number helper rejection

The carrier has no unsigned-validity predicate, rendering, whole-input membership, or complement, and therefore contributes no rejection or None claim.

Requirement: number helper record bounds

The carrier has no source Decimal record, mantissa, many_digits, returned option, or execution observation, so record bounds and negativity are noninterfering.

Requirement: number helper accumulated value

For a supplied unsigned numeric-grammar witness, the carrier retains every significand digit and the explicit exponent sign and digits needed by a later accumulated-value interpretation. It asserts no such value and no returned-record or interval relation.

Requirement: special helper infinity

The carrier has no special-keyword, separate sign-argument, infinity-word, option-return, or execution content and is noninterfering.

Requirement: special helper nan

The carrier has no special-keyword, separate sign-argument, NaN-word, option-return, or execution content and is noninterfering.

Requirement: special helper rejection

The carrier has no special-keyword grammar, grammar complement, separate sign argument, option-return, or execution content and is noninterfering.

Requirement: native correct or defer

This goal ranges over unrestricted source Decimal records, whereas this carrier supplies no source record or conversion value. It is noninterfering and provides no lexeme witness, deferral, many_digits, rounding, or return claim.

Requirement: integer correct or defer

The unrestricted integer exponent and mantissa arguments, raw result pair, deferral, assembly, rounding, and normal return are independent of this lexical carrier.

Requirement: slow accumulated rounding

For a supplied unsigned numeric-grammar witness, the carrier retains the complete significand and explicit exponent components for later interpretation. It asserts no accumulated value, source result pair, assembly, rounding, or normal return.

Requirement: assembly correspondence

The carrier has no BiasedFp, bit operation, assembled word, float, or source-call field and is noninterfering with unrestricted assembly.

Requirement: classification totality

The carrier provides a place for the complete numeric content of a classification when such a witness is supplied. It has no classification relation and proves neither existence of a classification nor existence of a numeric witness for an arbitrary finite byte string.

Requirement: classification determinism

The carrier's componentwise equality precisely compares two supplied numeric-content records. It has no classification relation and proves neither uniqueness of classifications nor uniqueness of a numeric witness for an input.

Requirement: classification significand digit

The carrier exposes both significand digit lists, but deliberately permits both to be empty. Numeric validity and the required nonemptiness consequence remain outside this definition.

Requirement: rounding totality

The carrier supplies no real-value or binary64-rounding relation and is noninterfering with existence of a rounding target.

Requirement: rounding determinism

The carrier supplies no real-value or binary64-rounding relation and is noninterfering with uniqueness of a rounding target.

Requirement: exponent value agreement

For a supplied numeric-grammar witness, the single retained exponent marker, sign, and entire digit list are available to both later exponent interpretations. This carrier supplies neither interpretation, exact or accumulated values, rounding targets, nor their agreement.

Download Lean source · Download TeX source

Proof structure

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

Explore this dependency tree

Inspect related source (44)
More program dependencies (11)
Standard-library dependencies (30)

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
Technical checking records
Local closure summary
{
  "node": "DecimalLexeme",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "647f6faf0b0b16232d26033aeacffcf3ef0d6f68f7151c52f4afef31f5bd1b0f",
  "active_statement_hash": "2227a26a68ede6cea6a61e5db647c12f28eb09e24db63973c2039eca507f2ee6",
  "kernel_axioms": [
    "propext"
  ],
  "toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
  "lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
  "checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
  "approved_axioms_hash": "d5c04ffa333d9b33b238a527f5beaa2be82e021d3e9c0bbe01b1310280f7f55a",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-13",
  "boundary_theorems": {},
  "strict_theorem_deps": {},
  "strict_definition_deps": {}
}
Prose assessment
{
  "label": "Recorded Sound: VerifierPass",
  "assessment_status": "VerifierPass",
  "fingerprint_relation": "matches current fingerprint",
  "assessment_fingerprint": "preservation-v1:6e0662b43d58b11899df5abc12b068d22507d1ac93928a9e58ea8f922dffe6fa",
  "current_fingerprint": "preservation-v1:6e0662b43d58b11899df5abc12b068d22507d1ac93928a9e58ea8f922dffe6fa",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "sound_status": "Pass",
  "substantiveness_status": "Pass"
}