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 s satisfying \mathsf{DecimalGoalVocabularyDefault.sourceString}(s), the configured Rust str it represents has exactly those complete ordered UTF-8 bytes. Source str::as_bytes returns normally with an immutable shared slice of precisely those bytes, and ModelStrAsBytes returns ok of the identical ordered Aeneas Slice U8 s. No lexical-validity, A/B, acceptance, rounding, or termination premise is used.

Proof

The historical Aeneas string definition and Rust as_bytes body are retained, explicitly as predecessor evidence, in reference/model-evidence/aeneas-string-bytes.txt; the historical slice and shared-borrow representation is in reference/model-evidence/aeneas-slice-observations.txt. Their current applicability, unchanged executable/library/core-source identities, exact raw signatures and Rust symbols, declaration digests and support bindings, and complete current call inventory are independently checked in reference/model-evidence/P89_T1_PrimitiveApplicability.txt. The current sole generated as_bytes call is generated.lean:4567, at the beginning of dec2flt_with_trace, corresponding to crate/dec2flt/mod.rs:364. The fixed dispatcher frame of DispatchFrame retains the same conversion, including when its helper components are abstract.
Aeneas defines Str := Slice U8, so its type alone overapproximates Rust strings: it permits arbitrary bytes up to Usize.max. The definition DecimalGoalVocabularyDefault restricts sourceString to length at most 9223372036854775807=\mathtt{isize::MAX} and a witness Lean string whose UTF-8 encoding is the entire byte list. These are the configured Rust str representation conditions in reference/model-evidence/source-valid-byte-slice.txt. Consequently the claim covers every configured source string and no invalid UTF-8 model string. A general source-valid Rust &[u8] needs only the length bound of SourceValidByteSlice, not this UTF-8 witness.
For a string in the claim's domain, the pinned core body is an infallible same-layout transmutation to a shared byte slice. It has no branch that changes bytes, reorders them, removes a sign, or fails. Aeneas represents the resulting immutable slice by precisely that ordered list. The implementation ModelStrAsBytes is literally ok s; its result retains the same list, length and subtype bound. In particular the output is source-valid because the input already has the stricter \mathtt{isize::MAX} bound. No pointer identity or mutation through the returned borrow is observed at any subsequent dispatcher use.
Holding the rest of the audited computation fixed, the conversion and its replacement thus feed identical inputs to the next continuation. Every later finite execution prefix and branch is identical; any normal Rust result and trace, outer failure or divergence is unchanged. As the Result.bind cases recorded in the current evidence show, a later failure/divergence is not turned into normal helper None or Rust Err. Primitive infallibility is not complete-parser totality, lexical acceptance, rounding correctness, or component inhabitability. The claim makes no source preservation assertion for model Str values outside sourceString, and imposes no UTF-8 premise on direct helper GOALs that take byte slices rather than strings. For the applications below the original constants are A=3458764513820540928 and B=576460752303421440 bytes; public bounds refer to the complete string before any sign stripping.

Requirement: assembly correspondence

The direct assembly subject starts with every unrestricted BiasedFp, not a string, and has no transitive string conversion. This binding is noninterfering with its required normal return and cast/shift/OR word equation.

Requirement: classification determinism

This mathematical relation is on arbitrary finite byte strings, not Rust string executions. No conversion occurs, so neither UTF-8 nor a source length bound is added and uniqueness is not presumed.

Requirement: classification significand digit

This mathematical grammar statement executes no string conversion. It keeps all finite bytes and does not acquire its digit conclusion from the binding.

Requirement: classification totality

Every finite byte string remains in the mathematical domain, even invalid UTF-8 or lengths beyond Rust's slice limit. No as_bytes call or total-classification assumption is introduced.

Requirement: dispatch abstract composition

For every source-valid complete string through A, the fixed frame performs this same infallible conversion even with abstract helper components. It obtains the complete ordered bytes, then strips at most one leading sign, so a lexical body is no longer than the complete string. Lexical A and exact-transport B component bounds retain their stated slice domains, while the slow law retains every source-valid unsigned literal without an A/B restriction. Conversion supplies neither inhabited-contract existence nor abstract normal output existence, and assumes none of the classification, rounding or sign conclusions.

Requirement: dispatch component compliance

On complete source-valid strings through A, the concrete conversion passes the same bytes before any component call or sign removal. For public exact transport, a complete numeric string through B supplies a body through B; the body bound alone is not a substitute for the complete-string premise. The same primitive inputs and all subsequent outcomes are preserved at reached calls, not just completed traces. Required normal component realization, bounded lexical/exact laws, unrestricted on-normal slow refinement and genuinely inhabited compatible packages remain principal obligations, not preservation premises.

Requirement: exponent value agreement

This mathematical comparison of exact and accumulated values executes no string operation. Its lexical domain and conditional target agreement are unchanged, with no sourceString or UTF-8 restriction added.

Requirement: integer correct or defer

The direct integer tier takes all i64/u64 operands, not a string, and has no conversion callee. Its on-normal deferral/rounding alternatives are unaffected.

Requirement: native correct or defer

The direct native tier takes every Decimal and has no string conversion, including on the disguised path. Its on-normal None/ Some, sign and many_digits observations are unchanged.

Requirement: number helper acceptance

The helper takes byte slices directly and has no transitive string conversion. Its nonempty source-valid unsigned slices through A need no UTF-8 hypothesis and no added exponent-sign or digit-count restriction. Required normal Some, including with overflow checks, is not assumed.

Requirement: number helper accumulated value

Direct helper slices through A are unchanged and gain no UTF-8 condition. The full-significand accumulated value, independently signed exponent and returned-record premise retain their meanings; no equality or interval result is supplied by this unused string binding.

Requirement: number helper record bounds

Every nonempty source-valid arbitrary-byte slice remains allowed, without A/B or UTF-8 restrictions. The direct helper has no string conversion, so any returned record and the separate field-bound obligations are unchanged.

Requirement: number helper rejection

The helper directly takes every nonempty source-valid arbitrary-byte slice through A outside the whole unsigned grammar. It has no string conversion, so neither UTF-8 nor prior normal return is imposed; malformed exponent tails and required normal None retain their original meaning.

Requirement: parser accumulated rounding

For accepted numeric source strings of complete length through A, conversion preserves all sign, significand and exponent bytes. Thus all subsequent outcomes and any returned word remain unchanged, without assuming the full-significand accumulated-rounding conclusion.

Requirement: parser equal target rounding

For accepted numeric complete strings through A, identical converted bytes preserve both value interpretations and the common-target premise. Any returned word is unchanged; the equal-target bridge is not used.

Requirement: parser exact rounding

The original bound is B on the complete source-valid Rust string, including its optional leading sign. Conversion keeps exactly those bytes before sign stripping and preserves any accepted word, without assuming ordinary mathematical exact rounding or adding an exponent restriction.

Requirement: parser infinity

For every source-valid infinity spelling, with no A/B bound, source and model expose identical complete sign and keyword bytes. Later outcomes are unchanged, without assuming the required normal signed-infinity result.

Requirement: parser invalid rejection

For every invalid source string of complete length through A, conversion preserves all bytes, including any tail after numerical exponent updates stop. All later branches and outcomes are unchanged; required normal Rust Err without panic is not presumed.

Requirement: parser nan acceptance

For every source-valid NaN spelling, with no A/B restriction, conversion preserves the complete sign and case-sensitive byte sequence on which unchanged case-insensitive matching operates. Normal NaN acceptance is not a preservation premise.

Requirement: parser non nan results

For every source-valid non-NaN input, conversion preserves all downstream outcomes and any successful word. Whether that word is non-NaN remains the separate conclusion.

Requirement: parser numeric acceptance

For every numeric complete source string through A, the same bytes are passed before optional leading-sign removal, with independently signed and arbitrarily long exponent digits allowed within A. All subsequent outcomes are unchanged; normal Rust Ok without panic remains required, not assumed.

Requirement: parser numeric sign

For successful numeric parses, conversion preserves both the leading lexical sign and all independent exponent-sign bytes. Later sign handling and the returned word stay unchanged; the lexical-sign property is not assumed.

Requirement: parser selected exponent

For successful numeric parses, identical converted bytes preserve every selected pair and trace. No selected-exponent range is used to justify the string primitive.

Requirement: parser selected magnitude sign

For successful numeric parses, conversion preserves each selected raw pair and assembled word. A clear sign bit is not a preservation premise.

Requirement: parser signed zero

For accepted numeric zero literals, the complete sign and digit/exponent bytes are unchanged. All subsequent execution, including a slow scientific call before zero detection if reached, and any returned word are preserved; the signed-zero conclusion is not assumed.

Requirement: parser totality

For every Rust string of complete length through A, including empty, sign-only, numeric, special and invalid cases, conversion is infallible on the exact sourceString domain and returns identical bytes. Any later failure, divergence or normal Rust output remains unchanged. This does not prove or assume the required whole-parser normal termination.

Requirement: rounding determinism

This mathematical real-number statement executes no string conversion and gains no uniqueness premise from it.

Requirement: rounding totality

This mathematical existence statement executes no string conversion and retains every nonnegative real.

Requirement: slow accumulated rounding

The direct slow helper and its decimal/scientific callees take byte slices, not strings, and have no string conversion. Its domain remains every source-valid unsigned numeric literal without A/B or public reachability restrictions. The independently signed exponent, full significand, outer outcomes and any normal raw pair are unaffected; neither slow termination nor on-normal accumulated-value rounding is assumed.

Requirement: special helper infinity

The direct helper starts from arbitrary source-valid byte slices and either separate sign, with no UTF-8 or A/B restriction. It has no string conversion; the required normal signed-infinity option is unchanged.

Requirement: special helper nan

The direct helper has no string conversion. Every source-valid arbitrary-byte slice and either separate sign remain allowed, without assuming normal NaN acceptance or imposing UTF-8.

Requirement: special helper rejection

The direct helper takes every source-valid arbitrary-byte slice and either separate sign, not a string. Conversion is absent, so whole-keyword rejection and required normal None retain their meanings with no UTF-8 premise.

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