ModelSliceSplitFirst

Lean checked

Definition and explanation

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

Definition

\mathsf{ModelSliceSplitFirst}(s) successfully returns the first element and remaining suffix of s when present and \mathsf{none} when s is empty.

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

For every Aeneas Slice Std.U8 value satisfying SourceValidByteSlice and representing a Rust &[u8] in the complete configured source domain, this binding returns Ok None for the empty slice and otherwise returns Ok (Some (x, xs)), where x is the same first byte returned by the source's shared reference and xs is the same ordered tail returned by its shared subslice.

Proof

By SourceValidByteSlice and the configured-domain evidence in reference/model-evidence/source-valid-byte-slice.txt, the stated predicate covers every configured Rust &[u8] and adds no restriction on its byte values. The pinned Aeneas definition represents a slice by its complete ordered list. If that list is empty, both the binding and the pinned Rust split_first body return None. If it is x :: xs, the binding returns the head x and precisely the ordered suffix xs; the Rust body returns shared references to that same head and tail. These bodies are pinned in reference/model-evidence/binary64-boundary.txt; the Aeneas commit, slice representation, shared-borrow translation rule, extracted signature, and complete call-site inventory are pinned in reference/model-evidence/aeneas-slice-observations.txt.
The Lean constructor's internal slice obligation follows because |\mathit{xs}|\leq 1+|\mathit{xs}|=|\mathit{x::xs}|\leq \mathtt{Usize.max}. More importantly for the source domain, the original SourceValidByteSlice hypothesis gives |\mathit{x::xs}|\leq\mathtt{isize::MAX}, hence |\mathit{xs}|\leq|\mathit{x::xs}|\leq\mathtt{isize::MAX}; the returned tail is therefore source-valid too. Every frozen call infers T = Std.U8. Aeneas represents the returned &u8 by the same copied U8 value and the shared tail by that ordered byte suffix. All call sites only read these results, so neither mutation nor reference identity is observable; erasing lifetimes and aliasing is harmless.

Requirement: assembly correspondence

The direct biased_fp_to_float subject has no split-first call, so this binding is noninterfering.

Requirement: classification determinism

This mathematical classification statement executes no source slice operation, so the binding does not alter its finite-byte-string domain.

Requirement: classification significand digit

This mathematical grammar statement executes no source slice operation, so the binding does not alter its digit conclusion.

Requirement: classification totality

This mathematical classification statement executes no source slice operation, so the binding does not restrict its finite-byte-string domain.

Requirement: dispatch abstract composition

Numeric component calls receive the same source-valid byte body, and each split returns the same byte and suffix; the abstract dispatcher therefore observes the same component behavior.

Requirement: dispatch component compliance

The proved preservation of SourceValidByteSlice for every returned tail keeps all actual numeric-parser calls within the complete Rust slice domain while preserving their bytes.

Requirement: exponent value agreement

This mathematical comparison of two decimal-value interpretations has no split-first call, so the binding is noninterfering.

Requirement: integer correct or defer

The direct compute_float subject accepts integer values and has no split-first call, so the binding is noninterfering.

Requirement: native correct or defer

The direct try_fast_path subject accepts a Decimal and has no split-first call, so the binding is noninterfering.

Requirement: number helper acceptance

For every source-valid unsigned numeric slice, each numeric-parser split sees the same head and passes the same source-valid ordered tail, preserving Some acceptance.

Requirement: number helper accumulated value

Preserving every consumed byte and exact remaining suffix preserves the returned record from which this goal computes its accumulated value.

Requirement: number helper record bounds

The full domain is exactly SourceValidByteSlice; the tail derivation keeps recursive parser states in that domain and the exact split results leave every returned record unchanged.

Requirement: number helper rejection

For every source-valid invalid slice, the same sequence of empty/head-tail observations reaches the same None result.

Requirement: parser accumulated rounding

The public parser's numeric component consumes the same bytes and suffixes, so its accepted record and accumulated-rounding observation are unchanged.

Requirement: parser equal target rounding

Exact preservation of all numeric head-tail observations leaves the accepted record and the equal-target bridge's parser result unchanged.

Requirement: parser exact rounding

On the full SourceValidByteSlice helper domain, the same ordered byte suffixes preserve the parser execution whose returned rounding is observed.

Requirement: parser infinity

The special helper has no split-first call; numeric parsing still returns the same None before the unchanged special path is selected.

Requirement: parser invalid rejection

The numeric parser consumes the same head bytes and tails and therefore makes the same Some/None decision before invalid rejection.

Requirement: parser nan acceptance

The numeric parser's exact split behavior preserves the None branch that passes the unchanged body to the NaN helper.

Requirement: parser non nan results

Preserving all numeric parsing splits preserves both numeric-versus-special branch selection and the resulting float observation.

Requirement: parser numeric acceptance

Each split of a source-valid numeric body returns the same byte and source-valid suffix, so the public parser receives the same successful numeric record.

Requirement: parser numeric sign

Split-first is used only after the dispatcher has recorded the lexical sign; preserving numeric bytes and tails leaves the result magnitude and that sign unchanged.

Requirement: parser selected exponent

The same sequence of numeric bytes and remaining suffixes yields the same parsed record and hence the same selected raw-pair exponent.

Requirement: parser selected magnitude sign

The same sequence of numeric bytes and tails yields the same selected raw pair and its unchanged unsigned assembled word.

Requirement: parser signed zero

Preserving the numeric parser's bytes, tails, and returned record leaves acceptance of zero and the later lexical-sign application unchanged.

Requirement: parser totality

Every numeric parser split returns normally in both list cases, and every returned tail again satisfies SourceValidByteSlice; this binding introduces no panic on any configured string.

Requirement: rounding determinism

This mathematical real-number rounding statement has no split-first call, so the binding is noninterfering.

Requirement: rounding totality

This mathematical real-number rounding statement has no split-first call, so the binding is noninterfering.

Requirement: slow accumulated rounding

The direct parse_long_mantissa subject and its extracted callees contain no split-first call, so its full source-valid domain and result are unchanged.

Requirement: special helper infinity

The direct parse_inf_nan subject has no split-first call, so its byte-slice and separate-sign observations are unchanged.

Requirement: special helper nan

The direct parse_inf_nan subject has no split-first call, so its byte-slice and NaN observations are unchanged.

Requirement: special helper rejection

The direct parse_inf_nan subject has no split-first call, so its rejection observation on every source-valid byte slice is unchanged.

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 (1)

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": "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-10",
  "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:26b49c7c49d49814e1a51411bf568f7da00bae4f8bf32f6ec912937a0dfec17c",
  "current_fingerprint": "preservation-v1:26b49c7c49d49814e1a51411bf568f7da00bae4f8bf32f6ec912937a0dfec17c",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "sound_status": "Pass",
  "substantiveness_status": "Pass"
}