Definition and explanation
This explanation was written alongside the formalization to describe the statement and its reasoning.
Definition
e/E marker, optional exponent sign, and
exponent digits. Every recorded digit lies in 0,\ldots,9, the significand
has at least one digit, fractional digits occur only with a point, and exponent
digits are nonempty exactly when an exponent marker occurs. Re-encoding these
fields gives the recorded bytes. Its lexical sign is negative exactly for a
leading minus. Its mathematical exponent is the signed integer represented by
all exponent digits. Its accumulated exponent folds those same digits from
zero, performing a\mapsto10a+d only while the prior accumulator is below
65536, and then applies the exponent sign. The witness's exact and
accumulated values use all significand digits, subtract the fractional digit
count from the corresponding exponent, multiply by the resulting power of ten,
and apply the lexical sign.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
import Mathlib.Data.Real.Basic
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: DecimalLiteral]
structure DecimalLiteral where
-- BODY
bytes : List Std.U8
sign : Option Bool
negative : Bool
integralDigits : List Nat
fractionalDigits : List Nat
decimalPointPresent : Bool
exponentMarker : Option Bool
exponentSign : Option Bool
exponentDigits : List Nat
mathematicalExponent : Int
accumulatedExponent : Int
exactValue : Real
accumulatedValue : Real
negative_eq : negative = sign.getD false
integral_digits : ∀ d ∈ integralDigits, d < 10
fractional_digits : ∀ d ∈ fractionalDigits, d < 10
exponent_digits : ∀ d ∈ exponentDigits, d < 10
significand_nonempty : integralDigits ≠ [] ∨ fractionalDigits ≠ []
fractional_empty_without_point :
decimalPointPresent = false → fractionalDigits = []
exponent_shape :
exponentMarker = none ↔ exponentSign = none ∧ exponentDigits = []
exponent_digits_nonempty :
exponentMarker ≠ none → exponentDigits ≠ []
bytes_eq :
bytes.map (fun b => b.val) =
(match sign with
| none => []
| some true => [45]
| some false => [43]) ++
integralDigits.map (fun d => d + 48) ++
(if decimalPointPresent
then [46] ++ fractionalDigits.map (fun d => d + 48)
else []) ++
(match exponentMarker with
| none => []
| some upper =>
[if upper then 69 else 101] ++
(match exponentSign with
| none => []
| some true => [45]
| some false => [43]) ++
exponentDigits.map (fun d => d + 48))
mathematicalExponent_eq :
mathematicalExponent =
let n : Nat := exponentDigits.foldl (fun a d => 10 * a + d) 0
if exponentSign.getD false then -(n : Int) else (n : Int)
accumulatedExponent_eq :
accumulatedExponent =
let n : Nat := exponentDigits.foldl
(fun a d => if a < 65536 then 10 * a + d else a) 0
if exponentSign.getD false then -(n : Int) else (n : Int)
exactValue_eq :
exactValue =
let n : Nat := (integralDigits ++ fractionalDigits).foldl
(fun a d => 10 * a + d) 0
let magnitude := (n : Real) *
10 ^ (mathematicalExponent - (fractionalDigits.length : Int))
if negative then -magnitude else magnitude
accumulatedValue_eq :
accumulatedValue =
let n : Nat := (integralDigits ++ fractionalDigits).foldl
(fun a d => 10 * a + d) 0
let magnitude := (n : Real) *
10 ^ (accumulatedExponent - (fractionalDigits.length : Int))
if negative then -magnitude else magnitude
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
GOAL.md; it neither accepts extra bytes nor identifies
the unbounded mathematical exponent with the source's bounded accumulator.Proof
parse_scientific; both consume
every digit. The value equations retain every significand digit and adjust for
the decimal point. These facts follow directly from the definition and the
frozen grammar and loop recorded in
reference/model-evidence/decimal-specification.txt.Requirement: parser totality
Requirement: parser numeric acceptance
Requirement: parser invalid rejection
Requirement: parser nan acceptance
Requirement: parser infinity
Requirement: parser non nan results
Requirement: parser numeric sign
Requirement: parser signed zero
Requirement: parser exact rounding
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: number helper acceptance
Requirement: number helper rejection
Requirement: number helper record bounds
Requirement: number helper accumulated value
Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
Requirement: native correct or defer
Requirement: integer correct or defer
i64 and u64, so the witness is noninterfering.Requirement: slow accumulated rounding
Requirement: assembly correspondence
Requirement: classification totality
Requirement: classification determinism
Requirement: classification significand digit
Requirement: rounding totality
Requirement: rounding determinism
Requirement: exponent value agreement
Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Uses
Used by
- ClassificationDeterminism
- ClassificationSignificandDigit
- ClassificationTotality
- DispatchComponentContract
- ExponentValueAgreement
- NumberHelperAcceptance
All 18 entries
- ClassificationDeterminism
- ClassificationSignificandDigit
- ClassificationTotality
- DispatchComponentContract
- ExponentValueAgreement
- NumberHelperAcceptance
- NumberHelperAccumulatedValue
- NumberHelperRejection
- ParserAccumulatedRounding
- ParserEqualTargetRounding
- ParserExactRounding
- ParserInvalidRejection
- ParserNumericAcceptance
- ParserNumericSign
- ParserSelectedExponent
- ParserSelectedMagnitudeSign
- ParserSignedZero
- SlowAccumulatedRounding
Inspect related source (21)
- FloatErrorKind · num/mod.rs:18 Program Rust
- ParseFloatError · num/mod.rs:13 Program Rust
- Dec2FltAssemblyTrace · dec2flt/mod.rs:318 Program Rust
More program dependencies (10)
- Dec2FltTrace · dec2flt/mod.rs:284 Program Rust
- Lemire · dec2flt/mod.rs:115 Program Rust
- BiasedFp · dec2flt/common.rs:52 Program Rust
- ByteSlice · dec2flt/common.rs:4 Program Rust
- Decimal · dec2flt/decimal.rs:32 Program Rust
- DecimalSeq · dec2flt/decimal_seq.rs:21 Program Rust
- CastInto · traits.rs:18 Program Rust
- Float · traits.rs:67 Program Rust
- FloatExt · traits.rs:168 Program Rust
- Int · traits.rs:27 Program Rust
Standard-library dependencies (8)
- FpCategory · core/src/num/mod.rs:1522 Rust library
- Add · core/src/ops/arith.rs:76 Rust library
- Div · core/src/ops/arith.rs:460 Rust library
- Mul · core/src/ops/arith.rs:322 Rust library
- Neg · core/src/ops/arith.rs:690 Rust library
- BitOr · core/src/ops/bit.rs:254 Rust library
- Shl · core/src/ops/bit.rs:461 Rust library
- Shr · core/src/ops/bit.rs:584 Rust library
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
- Classical.choice
- Quot.sound
- propext
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": "DecimalLiteral",
"closure_version": "patch_c_v1",
"active_decl_hash": "c35ed168338e712086834df219578b85d396ccd8a96ff95cc69a582108ebd4e1",
"active_statement_hash": "a808f3f76a9241dc0d5b187edd07df517d3f7aa2a349ef3ede6222f654bb98d5",
"kernel_axioms": [
"Classical.choice",
"Quot.sound",
"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:58022bc102f020fdb12f711e1d0c5ba2dc97e09f53f22bfa3f00d61842efa37b",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"substantiveness_status": "Pass"
}