ModelSliceFirst

Lean checked

Definition and explanation

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

Definition

\mathsf{ModelSliceFirst}(s) successfully returns the first element 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: ModelSliceFirst]
def ModelSliceFirst {T : Type} (s : Slice T) : Result (Option T) :=
-- BODY
  ok s.val.head?
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), where x is the same first byte that the source returns by shared reference.

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 first body return None. If it is x :: xs, the binding returns Some x, while the Rust body returns a shared reference to that same head. 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. Every frozen call infers T = Std.U8. Aeneas therefore represents the returned &u8 by the same copied U8 value. All such call sites only read that byte, so neither mutable state nor reference identity is observable; erasing its lifetime and aliasing information is harmless. The input ordered list is unchanged in both cases.

Requirement: assembly correspondence

The direct biased_fp_to_float subject has no slice-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

The dispatcher uses this binding only to observe the first byte of the source-valid Std.U8 body. The proved empty/head correspondence preserves exactly the branch input used by abstract composition.

Requirement: dispatch component compliance

The configured Rust string supplies a byte slice satisfying SourceValidByteSlice; the binding preserves the dispatcher's empty test and copied sign byte before any component call.

Requirement: exponent value agreement

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

Requirement: integer correct or defer

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

Requirement: native correct or defer

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

Requirement: number helper acceptance

The direct parse_number subject has no first call; its slice observations are therefore unchanged by this binding.

Requirement: number helper accumulated value

The direct parse_number subject has no first call; its returned record and accumulated value are therefore unchanged by this binding.

Requirement: number helper record bounds

The direct parse_number subject has no first call, so this binding neither narrows its SourceValidByteSlice domain nor changes a returned record.

Requirement: number helper rejection

The direct parse_number subject has no first call; its None observations are therefore unchanged by this binding.

Requirement: parser accumulated rounding

Every configured parser input yields a source-valid byte body; preserving its empty/head observation keeps the same execution and hence the same accumulated-rounding result.

Requirement: parser equal target rounding

On the full SourceValidByteSlice body domain, the same first byte selects the same parser path, leaving the stated equal-target bridge unchanged.

Requirement: parser exact rounding

On the full source-valid byte-body domain, the exact empty/head result preserves the parser execution whose returned rounding this goal observes.

Requirement: parser infinity

The copied first byte is exactly the byte used for lexical sign removal, so infinity spelling and its lexical sign are preserved.

Requirement: parser invalid rejection

The empty/head cases and first byte are unchanged for every source-valid string, so the parser reaches the same invalid-input decision.

Requirement: parser nan acceptance

The empty/head cases and copied sign byte are unchanged, so the parser passes the same unsigned body to the NaN helper and preserves its result.

Requirement: parser non nan results

The exact first-byte observation preserves sign stripping and subsequent branch selection, so no successful-result or NaN-classification observation changes.

Requirement: parser numeric acceptance

The binding preserves the initial nonempty test and optional sign byte on every configured Rust string, so the same numeric body is accepted.

Requirement: parser numeric sign

Returning the same copied first byte preserves whether the dispatcher strips + or - and records the negative flag.

Requirement: parser selected exponent

The same initial byte selects the same sign-stripped body and subsequent execution, so every selected raw pair and exponent observation is unchanged.

Requirement: parser selected magnitude sign

The same initial byte preserves lexical sign stripping and the selected unsigned raw-pair assembly observed by this goal.

Requirement: parser signed zero

The copied head byte preserves the lexical sign that the source later applies to an accepted zero.

Requirement: parser totality

For every configured Rust string, its bytes satisfy SourceValidByteSlice; both empty and nonempty first-byte observations return normally exactly as the source does.

Requirement: rounding determinism

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

Requirement: rounding totality

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

Requirement: slow accumulated rounding

The direct parse_long_mantissa subject has no slice-first call, so its full source-valid slice domain and result are unchanged.

Requirement: special helper infinity

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

Requirement: special helper nan

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

Requirement: special helper rejection

The direct parse_inf_nan subject has no slice-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": "ModelSliceFirst",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "f38dbcad0a84ab884eec3f16d86eb111712b828a19dccf0bf5974d6d1e02bd18",
  "active_statement_hash": "335139a4afbfb70e58bb0bcb1244b046933cf859037e19598e254e40a3e50024",
  "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-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:613b2edd8feaccbb058727b693d4737fa58dfa7db6665e3ee2272038e963e6c7",
  "current_fingerprint": "preservation-v1:613b2edd8feaccbb058727b693d4737fa58dfa7db6665e3ee2272038e963e6c7",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "sound_status": "Pass",
  "substantiveness_status": "Pass"
}