ModelStrAsBytes

Lean checked

Definition and explanation

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

Definition

For every modeled Aeneas Str byte slice s, \mathsf{ModelStrAsBytes}(s) successfully returns s itself.

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: ModelStrAsBytes]
def ModelStrAsBytes (s : Str) : Result (Slice Std.U8) :=
-- BODY
  ok s
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 Str value s satisfying \mathsf{DecimalGoalVocabularyDefault.sourceString}(s), the configured Rust str represented by s has exactly the same complete ordered UTF-8 bytes, source str::as_bytes returns normally with a shared slice of exactly those bytes, and \mathsf{ModelStrAsBytes}(s) returns ok of the identical ordered Aeneas Slice U8 s.

Proof

Aeneas defines Str to be Slice U8; its exact definition, the frozen external declaration, its sole generated call, the support binding, and the configured Rust as_bytes body are pinned in reference/model-evidence/aeneas-string-bytes.txt. By itself this Aeneas type overapproximates Rust str: it permits arbitrary byte values up to Aeneas's Usize.max slice bound, rather than requiring UTF-8 and the stricter configured isize::MAX byte bound. The paired definition DecimalGoalVocabularyDefault supplies exactly the missing restriction: its sourceString predicate requires length at most 9223372036854775807 and a witness Lean string whose UTF-8 encoding is the entire byte list of s. Those are precisely the configured Rust str representation conditions established by reference/model-evidence/source-valid-byte-slice.txt.
For such an s, the witness therefore identifies a source-valid Rust str with the same complete ordered bytes. The frozen Rust body is an infallible same-layout transmutation from that str to a shared [u8] slice, so it neither changes the byte sequence nor introduces a panic or error. Aeneas represents the slice as the complete ordered list subtype and erases this immutable shared borrow to its value observation, as pinned in reference/model-evidence/aeneas-slice-observations.txt. Finally, the bound implementation is literally ok s. Hence, on exactly the sourceString subset and without making a claim about other Aeneas Str values, the source call and its replacement both continue normally with the identical complete ordered U8 slice.

Requirement: assembly correspondence

The source subject biased_fp_to_float begins from a BiasedFp and contains no string-to-bytes conversion; the unique frozen as_bytes call is instead in dec2flt_with_trace, as shown by reference/model-evidence/aeneas-string-bytes.txt. This binding is therefore noninterfering with every execution and raw-word observation of the assembly goal.

Requirement: classification determinism

This is a mathematical claim about the classification relation on arbitrary finite byte strings, not an execution of a Rust string operation. It therefore contains no as_bytes call, so this binding neither restricts its byte domain nor supplies its uniqueness conclusion.

Requirement: classification significand digit

This mathematical goal inspects the significand of a classified finite byte string and performs no source call. Consequently string conversion is absent and this binding is noninterfering; in particular, it does not assume that a numeric classification contains a digit.

Requirement: classification totality

The goal quantifies over every finite byte string without a source-string or UTF-8 restriction and is stated entirely in the mathematical classification relation. It never executes as_bytes; this source-valid-string claim therefore adds no restriction and does not assert total classification.

Requirement: dispatch abstract composition

For the theorem's source-valid-string input, the claim identifies exactly the complete ordered byte slice passed to its abstract flow. Thus the string input and abstract byte-domain input are connected without changing bytes or adding a failure at conversion. The abstract flow itself does not execute the frozen source call; this application asserts neither contract inhabitation nor any classification, rounding, sign, or normal-return conclusion.

Requirement: dispatch component compliance

The unique frozen as_bytes call is the first operation of the concrete dec2flt_with_trace execution, as pinned in reference/model-evidence/aeneas-string-bytes.txt. On the goal's source-valid strings, the replacement succeeds exactly when the infallible source call does and feeds the identical ordered bytes to every subsequent branch, helper call, trace field, and result; later panic-versus-normal behavior is therefore unchanged. This establishes only preservation of the concrete execution and of later comparisons with contracts, not existence of a compliant contract instance or the component-compliance conclusion.

Requirement: exponent value agreement

This is a mathematical relation among a valid numeric lexeme, its two exponent interpretations, and their rounding targets. It contains no source operation, so the string binding is noninterfering and does not assume that the targets agree.

Requirement: integer correct or defer

The source subject compute_float starts directly from an i64 exponent and u64 mantissa and has no string conversion. The sole as_bytes call belongs to the outer traced dispatcher, so this binding does not affect the integer tier's return, deferral, or assembled-word behavior.

Requirement: native correct or defer

The source subject try_fast_path starts directly from a Decimal record and contains no str::as_bytes call. Hence the binding is noninterfering with its panic/normal, None/Some, and float-result observations and does not assert native correctness.

Requirement: number helper acceptance

The source subject parse_number receives a Rust byte slice directly; it does not convert a Rust string. The sole frozen as_bytes call is in the outer traced dispatcher, so this binding neither restricts helper slices nor asserts that this helper accepts numeric input.

Requirement: number helper accumulated value

This helper goal starts with the byte slice passed directly to parse_number. Since that source function contains no string conversion, this binding changes neither its returned record nor the values compared with that record, and supplies none of the interval conclusion.

Requirement: number helper record bounds

The quantified source-valid object here is already a Rust byte slice in the sense of SourceValidByteSlice, not a Rust str. The helper therefore does not call as_bytes; this binding is noninterfering with normal return and the record-field bounds.

Requirement: number helper rejection

The source subject parse_number takes its arbitrary nonempty byte slice directly and performs no string conversion. Thus this binding adds no UTF-8 premise, changes no helper execution, and does not presume the asserted None result.

Requirement: parser accumulated rounding

The sole frozen as_bytes call is the first operation of the public parser path through dec2flt_with_trace, as pinned in reference/model-evidence/aeneas-string-bytes.txt. On each source-valid input the source call and replacement both continue with identical ordered bytes, so every later branch, panic/normal outcome, returned word, and trace observation is unchanged. This does not assume accumulated-value rounding.

Requirement: parser equal target rounding

At the unique frozen public-parser as_bytes call recorded in reference/model-evidence/aeneas-string-bytes.txt, the sourceString premise places the input exactly in the claim's domain. Both sides continue infallibly with the same ordered bytes, preserving all downstream branches, panic/normal behavior, words, and traces without assuming the equal-target bridge.

Requirement: parser exact rounding

The unique frozen string conversion on the public parser path is pinned in reference/model-evidence/aeneas-string-bytes.txt. For every source-valid numeric input it is replaced by ok of precisely the same ordered bytes, with no new failure; hence all subsequent control flow, panic-versus-normal behavior, and result words are preserved. No exact-rounding conclusion is used here.

Requirement: parser infinity

For a source-valid infinity literal, the unique public-parser as_bytes call pinned in reference/model-evidence/aeneas-string-bytes.txt and its model both continue normally with the literal's identical ordered bytes. All subsequent matching, sign handling, panic/normal behavior, and returned word are therefore unchanged; this does not assert acceptance or the infinity result.

Requirement: parser invalid rejection

For every source-valid string in this goal, the unique conversion at the start of dec2flt_with_trace, pinned in reference/model-evidence/aeneas-string-bytes.txt, is infallible and is replaced by ok of the exact same bytes. Downstream classification, panic/normal behavior, and Ok/Err observations are preserved without assuming that invalid inputs are rejected.

Requirement: parser nan acceptance

The source-valid NaN spelling reaches the sole frozen public-parser as_bytes call recorded in reference/model-evidence/aeneas-string-bytes.txt. That call and the replacement both continue with exactly the same ordered bytes, preserving later case matching, sign handling, panic/normal behavior, and result bits; no NaN acceptance claim is assumed.

Requirement: parser non nan results

The unique public-parser as_bytes call is pinned in reference/model-evidence/aeneas-string-bytes.txt. On every source-valid non-NaN input it and the replacement succeed with identical bytes, so later branches, panic/normal outcomes, and the returned word are unchanged. Whether that word is non-NaN remains the separate GOAL obligation.

Requirement: parser numeric acceptance

The unique conversion at the start of the public parser's traced execution is pinned in reference/model-evidence/aeneas-string-bytes.txt. The source-valid numeric input satisfies the claim premise, so source and model continue infallibly with identical ordered bytes; all later control flow, panic/normal behavior, and Ok/Err results are preserved without asserting acceptance.

Requirement: parser numeric sign

At the sole frozen public-parser as_bytes call pinned in reference/model-evidence/aeneas-string-bytes.txt, each source-valid numeric input and its model expose the same first sign byte and remaining ordered bytes. Thus all downstream branches, panic/normal behavior, assembly, and returned words are unchanged, without assuming the claimed lexical sign.

Requirement: parser selected exponent

The unique frozen as_bytes call on the public traced-parser path is pinned in reference/model-evidence/aeneas-string-bytes.txt. On source-valid inputs the model supplies its exact bytes with the same infallible boundary behavior, preserving every later branch, panic/normal outcome, and recorded selected pair. It does not assume that the selected exponent is in range.

Requirement: parser selected magnitude sign

At the sole public-parser string conversion recorded in reference/model-evidence/aeneas-string-bytes.txt, source and model continue normally with identical ordered bytes for every source-valid input. Therefore downstream control, panic/normal behavior, selected-pair and assembled word observations are unchanged; the clear-sign-bit conclusion is not assumed.

Requirement: parser signed zero

For a source-valid numeric zero literal, the unique frozen public-parser as_bytes call pinned in reference/model-evidence/aeneas-string-bytes.txt and the replacement both continue infallibly with the identical sign and digit bytes. This preserves later branches, panic/normal behavior, and the returned word but does not assert the signed-zero conclusion.

Requirement: parser totality

The unique string conversion at the beginning of the public parser's traced execution is pinned in reference/model-evidence/aeneas-string-bytes.txt. Every input satisfying sourceString lies in the claim's exact domain, and source and model both pass the same ordered bytes without failure at this boundary. Thus all later execution, including any panic, normal return, or divergence, is unchanged; this application does not assume totality.

Requirement: rounding determinism

This mathematical goal quantifies over nonnegative reals and binary64 rounding targets and contains no source execution. It never calls as_bytes, so the binding is noninterfering and supplies no uniqueness premise or conclusion.

Requirement: rounding totality

This mathematical existence statement concerns every nonnegative real and the binary64 rounding relation, not a Rust parser call. String conversion is absent, so the binding neither changes its domain nor assumes a rounding target exists.

Requirement: slow accumulated rounding

The source subject parse_long_mantissa begins directly from a Rust byte slice and does not call str::as_bytes; the sole frozen call is in the outer traced dispatcher. This binding therefore changes neither helper execution nor its raw pair and does not assert the rounding conclusion.

Requirement: special helper infinity

The specialized parse_inf_nan source subject receives its keyword as a Rust byte slice directly, so it performs no string conversion. This binding adds no UTF-8 condition and is noninterfering with its return and sign observations, without assuming infinity acceptance.

Requirement: special helper nan

This helper starts directly from a Rust byte slice and a separate sign argument; it contains no as_bytes call. The string binding therefore changes no branch, panic/normal outcome, or returned word and does not assume NaN acceptance.

Requirement: special helper rejection

The source subject parse_inf_nan receives an arbitrary Rust byte slice directly and never converts a Rust string. Consequently this binding is noninterfering, imposes no UTF-8 restriction, and supplies none of the claimed None result.

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": "ModelStrAsBytes",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "8021e96ef85ff3c69be4b89e2bcdd08beb0207aed3c1c3c141e633c44ade6981",
  "active_statement_hash": "f2c07a8479b86f8e65e17874a1a1ac6d3d23b6e603a676dd49d6a90c93970974",
  "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-12",
  "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:71a95de8883b0a988e9389c8489ef382ae05dfb9eafc47a61a198d21de57d498",
  "current_fingerprint": "preservation-v1:71a95de8883b0a988e9389c8489ef382ae05dfb9eafc47a61a198d21de57d498",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "sound_status": "Pass",
  "substantiveness_status": "Pass"
}