Definition and explanation
This explanation was written alongside the formalization to describe the statement and its reasoning.
Definition
Lean definition
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Aeneas
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelSliceSplitFirst]
def ModelSliceSplitFirst {T : Type}
(s : Slice T) : Result (Option (T × Slice T)) :=
-- BODY
match h : s.val with
| [] => ok none
| x :: xs => ok (some (x, ⟨xs, by
have p := s.property
rw [h] at p
have p' : 1 + xs.length ≤ Usize.max := by
simpa [Nat.add_comm] using p
exact Nat.le_trans (Nat.le_add_left xs.length 1) p'⟩))
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
Slice Std.U8 satisfying
SourceValidByteSlice and representing a configured Rust
&[u8], this binding returns normally with ok none exactly
for the empty slice, and otherwise with ok (some (x, xs)).
Here x is the source's first byte and xs its complete ordered
tail, which again satisfies SourceValidByteSlice.
There is no UTF-8, lexical-validity, A/B, or public-reachability premise.
The binding preserves the immutable head/tail observation at every current
bound call, including scientific parsing reached through the slow helper.Proof
None on the empty slice and shared
references to precisely the head and tail on a nonempty slice.
Aeneas represents slices as complete ordered lists with a
\mathtt{Usize.max} length proof and immutable shared borrows as values.
Thus ModelSliceSplitFirst's two list cases give the identical option,
byte and suffix, with normal return and no memory change.x :: xs, the Lean tail constructor is legal because
|\mathit{xs}|\leq 1+|\mathit{xs}|=|\mathit{x::xs}|
\leq\mathtt{Usize.max}.
The source-domain hypothesis also gives
|\mathit{xs}|\leq|\mathit{x::xs}|\leq\mathtt{isize::MAX}, so that tail is
source-valid. Every current bound call infers T = Std.U8.
The calls copy/read the head and use the tail as another immutable slice;
none observes reference identity or mutates either returned borrow.
The four calls are scientific sign inspection at generated.lean:1734,
nineteen-digit scanning at 4094, and point/exponent-marker inspection
at 4347,4369, with source counterparts
crate/dec2flt/parse.rs:127,65,180,197.
Original upstream split observations rewritten to guarded indexing are
identified separately in the current evidence, not counted as bound calls.parse_scientific, the exact head sets negative precisely
when it is -; + or - consumes exactly the returned
tail, while any other head retains the original slice. Empty input retains
the empty slice and a false flag. This is the exponent's independent sign,
not a leading significand sign. The unchanged guarded digit-entry test reads
that same post-sign first byte only when it exists. The original
upstream/dec2flt/parse.rs:86 uses first; the audited
crate/dec2flt/parse.rs:134-137 uses nonemptiness then index zero.
Their empty and nonempty observations agree, but neither is an additional
current bound first call.i64), the source updates E to 10E+d only when the
pre-update E<T. Starting from zero, 0\leq E\leq10T-1 is maintained:
an updating state has E\leq T-1 and 0\leq d\leq9, so
10E+d\leq10T-1=5764607523034234879<\mathtt{i64::MAX}; otherwise E is
unchanged. The product, byte-to-i64 cast and sum fit, and negating
this final nonnegative magnitude fits as well.
One update may overshoot T; there is no clamp to T.
The count is incremented for every exponent digit even after updates
stop. At an increment, \mathit{count}<|s| implies
\mathit{count}+1\leq|s|\leq\mathtt{isize::MAX}<\mathtt{Usize.max}.
Guarded indexing and the final suffix starting at count are therefore in
bounds. The same maximal digit prefix is consumed, and the same first
nondigit and all later bytes remain in the residual. A normally returned
Some has the same signed accumulator and exact residual; a missing
digit, including an empty or sign-only suffix, normally gives None
and the same post-sign residual. No lexical acceptance or rounding result
is used in this argument.parse_long_mantissa:3941 to parse_decimal_seq,
whose eight e/E branches at
2084/2094,2156/2166,2224/2234,2281/2292 call this scientific parser,
and hence split-first at 1734.
Each exponent suffix is an ordered suffix of the original source-valid
slice; the claim applies without any A/B or dispatcher-reachability bound.
The slow caller ignores the residual only after the call and applies
unwrap_or(0) only to the normally returned option:
Some e contributes e, while normal None contributes zero.
As pinned in the current evidence, Result.bind propagates
fail and div; neither becomes zero, a normal None,
or a Rust parsing error. This is unwrap_or, not Option
Try/residual conversion. The later zero-significand test at 3942
cannot bypass the earlier scientific call.parse_number, parse_long_mantissa, or dispatch, and does
not assume an inhabited component package.
The following separate applications use only this extensional replacement.
Where the original GOAL imposes a bound, write
A=3458764513820540928 and B=576460752303421440 bytes;
public bounds concern the complete string before leading-sign removal.Requirement: assembly correspondence
biased_fp_to_float subject takes a raw pair,
not a slice, and has no transitive bound split call in the current inventory.
Its required normal return and cast/shift/OR word equation are unaffected.Requirement: classification determinism
Requirement: classification significand digit
Requirement: classification totality
Requirement: dispatch abstract composition
Requirement: dispatch component compliance
Requirement: exponent value agreement
Requirement: integer correct or defer
i64/u64 input and has no
split callee. Its on-normal deferral/rounding alternative is unchanged.Requirement: native correct or defer
Decimal, not a slice, and has no
split callee. Ordinary and disguised on-normal alternatives are unaffected.Requirement: number helper acceptance
Some is the GOAL's required conclusion, not a
premise of this preservation argument.Requirement: number helper accumulated value
many_digits
flag and represented value are unaltered; the exact/half-open interval laws
for the full significand remain to be established.Requirement: number helper record bounds
Requirement: number helper rejection
None, including with overflow checks, is not presumed.Requirement: parser accumulated rounding
Requirement: parser equal target rounding
Requirement: parser exact rounding
Requirement: parser infinity
None or the required normal signed-infinity result.Requirement: parser invalid rejection
Err without panic remains the conclusion.Requirement: parser nan acceptance
Requirement: parser non nan results
Requirement: parser numeric acceptance
Ok
without panic is still required, not assumed.Requirement: parser numeric sign
Requirement: parser selected exponent
Requirement: parser selected magnitude sign
Requirement: parser signed zero
Requirement: parser totality
Requirement: rounding determinism
Requirement: rounding totality
Requirement: slow accumulated rounding
None-to-zero occur only after the call;
outer failure/divergence propagates, even for a zero significand.
The complete significand and any normally returned raw pair are unchanged.
Only such normal results are the diagnostic's subjects; their accumulated-value
rounding is not assumed by primitive preservation.Requirement: special helper infinity
Requirement: special helper nan
Requirement: special helper rejection
None is not supplied by this binding.Proof structure
Follow the declared dependencies to read the supporting statements and proofs.
Uses
No declared dependencies.
Used by
- NumberHelperScientificClassificationSourceLength
- NumberHelperScientificPrefixSafeLength
- NumberHelperTryParse19SafeLength
- NumberHelperRecordBounds
- NonDigitNumberRejection
- NumberHelperPartialNormalA
All 13 entries
- NumberHelperScientificClassificationSourceLength
- NumberHelperScientificPrefixSafeLength
- NumberHelperTryParse19SafeLength
- NumberHelperRecordBounds
- NonDigitNumberRejection
- NumberHelperPartialNormalA
- UnsignedZeroRecord
- PartialLexicalCertificateA
- SignificandScanA
- PartialNumberBranches
- RenderedExponentContinuation
- SignificandNonwrapping
- Preamble
Inspect related source (1)
- split_first · core/src/slice/mod.rs:198 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": "ModelSliceSplitFirst",
"closure_version": "patch_c_v1",
"active_decl_hash": "f2b66ed1eafca9de7351e962dd2a28ef015b982da6ac255c70d5e9623e05199e",
"active_statement_hash": "763bf8c37d808420d7fa7e74c84fccbd7ad86fb1abe6b4106e147a95d594e02c",
"kernel_axioms": [
"Classical.choice",
"Quot.sound",
"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-68",
"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:f05a5cfad8eb1c5c3f09eb3958815c5bfd33ed8638cf924a1d78649befb3f783",
"current_fingerprint": "preservation-v1:f05a5cfad8eb1c5c3f09eb3958815c5bfd33ed8638cf924a1d78649befb3f783",
"superseded_for_theorem_closure": false
}Review verdicts
{
"corr_status": "Pass",
"sound_status": "Pass",
"substantiveness_status": "Pass"
}