SpecialLiteral

Lean checked

Definition and explanation

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

Definition

A special literal witness records a finite byte string, an optional leading sign, its lexical negativity, whether the keyword is NaN, and whether an infinity keyword uses the long spelling. After ASCII case folding, its bytes are exactly the sign followed by nan, inf, or infinity; the long-spelling flag is false for NaN. The lexical sign is negative exactly when the optional sign is a minus.

Lean definition

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

import Tablet.Preamble

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: SpecialLiteral]
structure SpecialLiteral where
-- BODY
  bytes : List Std.U8
  sign : Option Bool
  negative : Bool
  isNan : Bool
  longInfinity : Bool
  negative_eq : negative = sign.getD false
  nan_not_long : isNan = true → longInfinity = false
  bytes_eq :
    bytes.map (fun b =>
      let n := b.val
      if 65 ≤ n ∧ n ≤ 90 then n + 32 else n) =
      (match sign with
       | none => []
       | some true => [45]
       | some false => [43]) ++
      (if isNan then [110, 97, 110]
       else if longInfinity then [105, 110, 102, 105, 110, 105, 116, 121]
       else [105, 110, 102])

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

The witness describes exactly the three ASCII-case-insensitive special keywords, with precisely the optional leading sign specified in the reference.

Proof

The defining byte equation performs ASCII uppercase-to-lowercase conversion and then permits only the three listed byte sequences. Its sign equation treats a minus as negative and an absent or plus sign as nonnegative. This is exactly the grammar and the length-three/length-eight source matching recorded in reference/model-evidence/decimal-specification.txt.

Requirement: parser totality

The witness only classifies inputs and imposes no execution assumption.

Requirement: parser numeric acceptance

Special witnesses do not alter the numeric domain.

Requirement: parser invalid rejection

Together with numeric-witness nonexistence, its nonexistence is exactly invalid syntax.

Requirement: parser nan acceptance

The NaN flag and byte equation give precisely all signed and unsigned NaN literals.

Requirement: parser infinity

The non-NaN cases give both infinity spellings and retain lexical sign.

Requirement: parser non nan results

The NaN flag states exactly the excluded input class.

Requirement: parser numeric sign

Special syntax does not enlarge the numeric domain.

Requirement: parser signed zero

Special syntax contains no numeric zero.

Requirement: parser exact rounding

Special syntax contains no numeric value requiring rounding.

Requirement: parser selected exponent

Special parses select no raw assembly pair.

Requirement: parser selected magnitude sign

Special parses select no raw assembly pair.

Requirement: dispatch abstract composition

Lexical contracts can distinguish both special classes and their signs.

Requirement: dispatch component compliance

The actual special helper can be compared against the exact keyword domain.

Requirement: parser accumulated rounding

Special syntax is outside the accumulated-value claim.

Requirement: parser equal target rounding

Special syntax is outside the equal-target bridge.

Requirement: number helper acceptance

Special keywords are not unsigned numeric literals.

Requirement: number helper rejection

Special keywords fall in the numeric helper's rejection complement.

Requirement: number helper record bounds

The special witness does not affect numeric records.

Requirement: number helper accumulated value

The special witness has no decimal-record value.

Requirement: special helper infinity

Removing the sign and requiring the non-NaN flag gives exactly either unsigned infinity keyword.

Requirement: special helper nan

Removing the sign and requiring the NaN flag gives exactly the unsigned NaN keyword.

Requirement: special helper rejection

Absence of an unsigned witness gives exactly all non-keyword slices.

Requirement: native correct or defer

The native helper consumes decimal records, so special syntax is noninterfering.

Requirement: integer correct or defer

The integer helper consumes numeric integers, so special syntax is noninterfering.

Requirement: slow accumulated rounding

The slow helper's numeric input excludes special syntax.

Requirement: assembly correspondence

Raw-pair assembly is independent of special syntax.

Requirement: classification totality

Witness existence is the special arm of the exhaustive classification.

Requirement: classification determinism

The exact keyword equation permits the numeric and special arms to be proved disjoint.

Requirement: classification significand digit

The property concerns only numeric witnesses.

Requirement: rounding totality

Special syntax is independent of magnitude-target existence.

Requirement: rounding determinism

Special syntax is independent of magnitude-target uniqueness.

Requirement: exponent value agreement

Special syntax has no explicit decimal exponent.

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 (21)
More program dependencies (10)
Standard-library dependencies (8)

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": "SpecialLiteral",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "b425e7a6a2008ef4272d7730db155d700a3882e207d77e2f3c3dceaf1c1ec90a",
  "active_statement_hash": "7510e9fa38e871d92dc9ccdd889ac511d7cd222935af6108f235481019bddec5",
  "kernel_axioms": [
    "propext"
  ],
  "toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
  "lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
  "checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
  "approved_axioms_hash": "b3d2e5a7a57ad9d2abdfb1c60bd76050a5cafa6a2be969c219d3ae71b2a8ade5",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-3",
  "boundary_theorems": {},
  "strict_theorem_deps": {},
  "strict_definition_deps": {}
}
Prose assessment
{
  "label": "Prose review has no verdict in this snapshot",
  "assessment_status": null,
  "fingerprint_relation": "unknown",
  "assessment_fingerprint": null,
  "current_fingerprint": "preservation-v1:fd156852bb6b8d461a8f04d19fb745e75920a4f60b95aa5fcb57511648536077",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}