P9_T1_NormalComponentRefinement

Lean checked

Definition and explanation

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

Definition

Normal-observation refinement of a total abstract package C by ActualDispatchOperations requires equality of actual normal numeric results with C on every nonempty source-valid slice, of native results on every Decimal, of integer results on every I64/U64 pair, and of slow results on every source-valid unsigned numeric slice, without a length restriction. These four clauses are on-normal implications and do not assert that those operations always return normally. Separately, numeric parsing returns normally with the corresponding abstract value on every nonempty source-valid slice through A=3458764513820540928 bytes. Special parsing returns normally with the abstract value on every source-valid slice and either separate sign. Assembly on every unrestricted BiasedFp and negation on every word also return normally with the abstract value. This relation does not include the compatible correctness laws or A-bounded reached-call realization.

Lean definition

Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.

import Tablet.P9_T1_ActualDispatchOperations
import Tablet.P9_T1_AbstractComponents
import Tablet.DecimalGoalVocabularyDefault
import Tablet.SourceValidByteSlice
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: P9_T1_NormalComponentRefinement]
structure P9_T1_NormalComponentRefinement (C : P9_T1_AbstractComponents) : Prop where
-- BODY
  number_normal : forall (body : Slice Std.U8) out,
    SourceValidByteSlice body -> body.val ≠ [] ->
    P9_T1_ActualDispatchOperations.parseNumber body = ok out -> out = C.parseNumber body
  number_bounded : forall body : Slice Std.U8,
    SourceValidByteSlice body -> body.val ≠ [] ->
    body.val.length <= 3458764513820540928 ->
    P9_T1_ActualDispatchOperations.parseNumber body = ok (C.parseNumber body)
  special_all : forall (body : Slice Std.U8) negative,
    SourceValidByteSlice body ->
    P9_T1_ActualDispatchOperations.parseSpecial body negative = ok (C.parseSpecial body negative)
  native_normal : forall d out,
    P9_T1_ActualDispatchOperations.native d = ok out -> out = C.native d
  integer_normal : forall q w out,
    P9_T1_ActualDispatchOperations.integer q w = ok out -> out = C.integer q w
  slow_normal : forall (body : Slice Std.U8) (x : DecimalLexeme) out,
    SourceValidByteSlice body -> x.leadingSign = none ->
    DecimalGoalVocabularyDefault.validNumeric x ->
    DecimalGoalVocabularyDefault.renderNumeric x = DecimalGoalVocabularyDefault.bytes body ->
    P9_T1_ActualDispatchOperations.slow body = ok out -> out = C.slow body
  assembly_all : forall fp,
    P9_T1_ActualDispatchOperations.assemble fp = ok (C.assemble fp)
  negate_all : forall f, P9_T1_ActualDispatchOperations.negate f = ok (C.negate f)
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

The relation separates full-domain conditional equality of normal values from bounded numeric and unrestricted special/assembly/negation normal-return equations. The latter are conditions to be established in the compliance theorem, not assumptions of preservation or of the corresponding acceptance, rejection and totality goals. It asserts no unrestricted native, integer or slow liveness.

Proof

The fields number_normal, native_normal, integer_normal and slow_normal each have an actual equation to ok out as a hypothesis, followed by equality of out with the abstract value. They apply respectively to every nonempty source-valid slice, every Decimal, every I64/U64 pair, and every source-valid unsigned numeric slice with no A/B restriction. Failure or divergence supplies no such hypothesis. These fields alone prove no return.
By contrast, number_bounded requires actual numeric parsing to equal ok of the abstract value on every nonempty source-valid slice through A=3458764513820540928. special_all requires the analogous equation on every source-valid slice and either independent sign. assembly_all requires it on every unrestricted BiasedFp and negate_all on every word. None has a normal-return premise. Proving that the actual components refine a compatible package must establish all these equations; declaring the relation or choosing total abstract functions does not establish them. The compatible value laws, package inhabitability and normal realization at every A-bounded reached call remain separate theorem obligations.
The relation changes no actual helper or frame. Accordingly ActualDispatchFrameEquality preserves actual observations unconditionally, without assuming this relation. On-normal equality can transport a value only after a normal return has been supplied at a legitimate conditional goal or proved at a call; it cannot justify a required return by circularly assuming it. The current source/extraction evidence and domain vocabulary are recorded in reference/model-evidence/dispatch-contracts.txt.

Requirement: parser nan acceptance

Every complete source-valid Rust string spelling a NaN literal must yield outer normal return containing Rust Ok of a NaN; success is a conclusion, not a premise, and no A/B restriction is added. The actual-frame equality and public projection preserve this return-existence assertion and the NaN word predicate on the same bytes. Abstract values and reached events do not discharge that assertion. Neither number_normal nor a declared refinement relation supplies acceptance; the necessary actual normal equations and special value laws must be proved.

Requirement: parser infinity

Every complete source-valid Rust infinity literal must return normally with Rust Ok of infinity bearing its leading lexical sign, without an A/B bound or a prior-success premise. The actual-frame equality preserves the whole input, sign stripping, separate special sign and returned word, so the required existence and signed-infinity predicate are unchanged. Neither abstract totality nor a reached special event proves this return. In particular special_all is a normal-return condition to establish, not an assumed successful special call.

Requirement: parser non nan results

Here normal Rust Ok really is a hypothesis. On the same complete source-valid Rust input, exclusion of all signed NaN spellings and the returned word's non-NaN predicate are unchanged. Actual-frame equality transports that successful result without imposing an A/B bound or requiring a selected pair on native or special direct returns.

Requirement: parser numeric sign

This is conditional on a normally successful numeric parse on any complete source-valid Rust string, with no A/B bound. The preserved leading sign, sign-overwritten native input, pre-sign assembly word and final word express exactly the original lexical-sign conclusion, including zero and infinity. An exponent's sign is not the leading sign. Observation preservation does not assume or prove that conclusion. The compatible sign laws are separate. In particular negate_all requires a normal actual equation, but neither declaring it nor conditional value equality proves the sign law.

Requirement: parser signed zero

Normal acceptance remains the hypothesis for a numeric literal of exact value zero on any source-valid Rust string, without an A/B bound. Whole-input numeric content, zero magnitude and the leading lexical sign are unchanged. Actual-frame equality preserves the complete returned word, hence distinguishes positive and negative zero instead of identifying their magnitudes or adding an acceptance obligation.

Requirement: parser selected exponent

Normal numeric success remains the hypothesis, without an A/B bound. Actual-frame equality preserves each genuinely selected raw pair and its biased-exponent field. The conclusion is still that these fields lie in 0,\ldots,2047, not an assumed bound on every component pair. Native direct returns supply no artificial pair; checked increment, comparison and slow replacement retain exactly which pair is selected.

Requirement: parser selected magnitude sign

For a normally successful numeric parse, without an A/B bound, the observation is the cast/shift/OR word of the actual selected pair before lexical signing. The same trace and word are retained by actual-frame equality, so the clear-sign-bit conclusion remains unchanged. It is not a hypothesis on all BiasedFp inputs, nor a claim that the final negatively signed public word has a clear sign bit.

Requirement: number helper record bounds

The domain is every nonempty source-valid byte slice with arbitrary contents, no UTF-8, unsigned-grammar or A/B restriction. An actual normal Some record is the legitimate premise; its unchanged fields must have negative false and mantissa below 10^{19}. The direct call and complete record are retained, so the representation does not turn this conditional field law into universal helper termination or restrict it to dispatcher-reached inputs. The number_normal equality may transport the record once its normal Some return is supplied; it supplies no acceptance premise.

Requirement: special helper infinity

For every source-valid byte slice spelling an unsigned infinity keyword and either independent sign argument, the actual helper must return normally with Some infinity of that sign. Both normal return and Some are conclusions. The unchanged slice, case-insensitive keyword and Boolean argument retain this requirement without UTF-8, reachability or A/B restrictions; no current-call success is assumed. The special_all equation requires normal return for this slice and sign, with no success premise; it is an obligation of actual compliance.

Requirement: special helper nan

For every source-valid byte slice spelling an unsigned NaN keyword and either independent sign argument, the actual helper must return normally with Some of a NaN. No normal-return or Some premise is introduced. The unchanged byte list, keyword predicate, separate sign and NaN word observation preserve this requirement on its full domain, independently of dispatcher reachability and without UTF-8 or A/B restrictions. The special_all equation requires the actual normal return; the compatible NaN value law is also still to be established.

Requirement: special helper rejection

On every source-valid arbitrary-byte slice not spelling an unsigned inf, infinity or nan keyword, and for either independent sign argument, the actual helper must return normally with None. This includes empty and otherwise invalid slices, with no UTF-8 or A/B restriction. The retained ok none conclusion is not outer failure or divergence; the direct obligation is not conditioned on a reached or successful call. The special_all equation requires normal return also on nonkeywords; it does not merely compare values after successful calls.

Requirement: native correct or defer

The input remains every Decimal, including both ordinary and disguised native paths. An actual outer normal return is the original hypothesis: None defers, while Some must round exact mantissa times 10^{\mathrm{exponent}} with the record's sign and implies many_digits false. The same optional value and fields are retained, without a length, record-bounds or reachability premise and without asserting unrestricted native termination. The refinement native_normal clause compares only supplied normal optional results; no unrestricted native liveness condition is inserted.

Requirement: integer correct or defer

The domain remains every I64 exponent and U64 mantissa. Conditional on the actual call's normal pair, negative biased exponent is deferral; otherwise its unrestricted assembled word must be the clear-sign binary64 rounding of exact w10^q. No biased-exponent upper bound, dispatcher reachability or termination premise is added. Retaining both operands and all pair fields preserves exactly this on-normal alternative. The refinement integer_normal clause is conditional equality of a supplied actual normal pair, not a normal-return assertion for every scalar input.

Requirement: slow accumulated rounding

For every source-valid unsigned numeric slice, without an A or B limit, an actual normal slow pair must assemble to the nonnegative binary64 rounding of the full-significand accumulated-exponent value. The unchanged body retains every significand and exponent digit and the independent exponent sign. No dispatcher-reachability, truncated-record or exact-value premise replaces this domain, and unrestricted actual termination is not asserted. The refinement slow_normal clause compares supplied actual normal results on this unrestricted source-valid domain; it is not A/B-bounded realization or unrestricted slow liveness.

Requirement: assembly correspondence

For every unrestricted BiasedFp, actual assembly must return normally with bits equal to mantissa OR the Rust I32-to-U64 cast of biased exponent shifted left by 52, using bounded 64-bit word operations. Normal return is a conclusion, not a premise. Retaining both complete fields and the same assembly call preserves this assertion without well-formedness, exponent-range, clear-sign, selection or reachability assumptions. The refinement assembly_all equation has no normal-return hypothesis. Actual compliance must establish that equation on every pair as well as the compatible assembly word law.

Requirement: classification totality

Every finite byte string retains the same whole-input numeric, special and invalid classification relation. This mathematical relation executes no dispatcher component; the present definition adds neither Rust source-validity, UTF-8, an A/B bound nor a compatible-package premise. Thus the existence of a classification remains the original unrestricted mathematical conclusion.

Requirement: classification determinism

The unchanged whole-input grammar still determines the classification and complete numeric lexeme whose uniqueness is asserted for every finite byte string. No dispatcher result or event identifies different digit lists, signs, decimal-point positions or exponent contents. This definition supplies no computation or hypothesis to that mathematical uniqueness claim and adds no Rust-domain or A/B restriction.

Requirement: classification significand digit

Validity still requires at least one digit in the combined integer and fractional significand, irrespective of the separately recorded exponent digits. The mathematical claim refers to that unchanged grammar, not to successful parsing, a reached numeric event or an abstract component law. Its unrestricted numeric-literal domain therefore gains no source, UTF-8 or A/B condition.

Requirement: rounding totality

The target relation remains nearest-even binary64 magnitude rounding for every nonnegative real, including subnormals, zero and overflow to infinity. It has no source execution or input-length domain. This dispatcher definition cannot supply a target by abstract function totality or add a compatible-package assumption; the original mathematical target-existence claim and relation are unchanged.

Requirement: rounding determinism

Both candidate targets are still measured by the same unchanged nearest-even magnitude relation on each nonnegative real. Neither dispatcher selection nor a chosen abstract conversion function defines this relation or fixes its answer. Consequently the mathematical uniqueness claim keeps its unrestricted real domain and acquires no component, successful-return or length premise.

Requirement: exponent value agreement

For every valid numeric lexeme, equality of the accumulated and mathematical explicit exponents remains the hypothesis. All significand digits, fractional length and the exponent sign are retained in the two value interpretations, with the same rounding relation. This mathematical bridge uses no source call or dispatcher success and has no A/B restriction; neither value is replaced by a truncated record.

Requirement: dispatch abstract composition

The compatible-package existence claim remains separate from the conditional claims for every package satisfying the laws. On every complete source-valid Rust string through A=3458764513820540928, a normal abstract output must be established, and its classification, accumulated rounding and lexical sign must satisfy the reference; a Rust Err counts as normal, outer failure/divergence do not. Numeric complete strings through B=576460752303421440 additionally require the exact target.
The component laws keep nonempty arbitrary-byte numeric lexical slices through A, returned-record bounds on the unrestricted nonempty source domain, representation through A, and exact transport through B. Special, native, integer and unrestricted assembly retain their full domains, as does the source-valid unsigned numeric slow diagnostic with no A/B bound. The fixed frame retains native shortcut, integer operands, guarded checked increment, exact comparison, forced deferral, fallback, selected pair and signing. Total functions and their ok embedding alone prove neither compatible-package existence nor normal whole-frame output.

Requirement: dispatch component compliance

The actual-source obligation still requires an inhabited compatible package, its value laws, normal refinement and realization at every reached call on every complete source-valid Rust string through A=3458764513820540928. A reached event uses successful prior calls, not current-call or whole-dispatch success. Thus current-call normal agreement, helper preconditions, successful checked increment and exact comparison are conclusions still to be proved.
Numeric lexical acceptance/rejection and representation keep nonempty source-valid slices through A; returned-record bounds retain their unrestricted domain. Exact-target transport remains through B=576460752303421440, also measured on complete public strings. Special and unrestricted assembly require normal returns on their full domains; native/integer correctness remains on normal return, and slow correctness remains on normal return for every source-valid unsigned numeric slice without an A/B bound. Original operands, guards, forced deferral, fallback body, selected pair and sign observations are unchanged by actual-frame equality, independently of these correctness and liveness conclusions. Specifically number_normal, native_normal, integer_normal and slow_normal compare supplied normal results, whereas number_bounded, special_all, assembly_all and negate_all require normal equations. All are conditions of the existentially required refinement, not preservation assumptions.

Requirement: number helper acceptance

Every nonempty source-valid arbitrary-byte slice through A=3458764513820540928 matching the whole unsigned numeric grammar must yield an actual normal Some record, including checked-arithmetic executions. Normal return and Some are conclusions. The slice has no leading sign, but its exponent may have either sign and any digit count or mathematical value within A. No UTF-8, reachability or prior-success condition is introduced. Here number_bounded, unlike number_normal, requires the actual normal equation. Establishing it and the compatible acceptance law remains theorem work.

Requirement: number helper rejection

Every nonempty source-valid arbitrary-byte slice through A=3458764513820540928 outside the whole unsigned numeric grammar must yield actual normal None, including checked-arithmetic executions. The same full slice is tested, including malformed exponent digits and characters after exponent accumulation stops. No UTF-8 or successful-call premise is added; ok none, outer checked failure and divergence remain distinct outcomes. Here number_bounded requires normal agreement on invalid as well as valid slices; number_normal alone cannot supply None or normal return.

Requirement: parser exact rounding

Normal numeric acceptance remains the hypothesis, with B=576460752303421440 bounding the complete source-valid Rust string, including its optional leading sign. The target uses every significand digit and the ordinary mathematical explicit exponent, not its bounded accumulation. Actual-frame equality preserves the returned word and lexical sign, including subnormal results, signed zero and signed infinity, without adding an exponent-digit or value restriction.

Requirement: parser invalid rejection

Every complete source-valid Rust string through A=3458764513820540928 outside both whole-input grammars must yield outer normal return containing Rust Err, without panic, including checked executions. This is not conditional on dispatcher success. The same bytes include empty/sign-only cases and suffixes after exponent saturation. Actual-frame equality preserves the required return equation, not a replacement by outer failure, helper None or divergence. The number_bounded and special_all equations require normal actual results. They cannot be justified by assuming the Err whose existence is being required.

Requirement: parser numeric acceptance

Every complete source-valid Rust numeric string through A=3458764513820540928, including its optional leading sign, must yield outer normal return containing Rust Ok without panic in checked executions. No current-call or whole-dispatch success is a premise. The unchanged whole-input grammar permits all exponent digit counts and mathematical values within A; observation equality retains the acceptance assertion without deriving it from abstract component totality. Normal realization of reached native, integer and slow calls through A remains an additional compliance obligation; their on-normal refinement clauses alone supply no acceptance.

Requirement: parser totality

For every complete source-valid Rust string through A=3458764513820540928, normal termination with a Rust Ok float or Rust Err is the conclusion, including empty, sign-only, numeric, special and invalid inputs and checked executions. There is no normal-return premise. Actual-frame equality and projection preserve this output-existence requirement as well as failures/divergence; neither of the latter, nor normal helper None by itself, counts as the required public result. The on-normal clauses do not prove native, integer or slow calls return. Bounded reached-call realization must establish current-call normal equations; declaring refinement or total abstract functions cannot do so.

Requirement: parser accumulated rounding

Normal numeric acceptance remains the hypothesis, with A=3458764513820540928 bounding the complete source-valid Rust string. The unchanged diagnostic retains every significand digit and the bounded explicit-exponent fold, including its independent sign. Actual-frame equality preserves the word and leading lexical sign required for the accumulated target, including zero and infinity; it neither substitutes the exact value nor supplies an acceptance premise elsewhere.

Requirement: parser equal target rounding

On a normally accepted numeric complete source-valid Rust string through A=3458764513820540928, equality of the ordinary exact and accumulated binary64 targets remains a separate hypothesis. Both full-significand values and the returned word are unchanged, so the common-target and leading-lexical-sign conclusions retain their meanings, including zero and infinity. No B bound or extra exponent restriction is imposed.

Requirement: number helper accumulated value

On every source-valid unsigned numeric slice through A=3458764513820540928, a returned normal Some record is the legitimate premise. With many_digits false it must exactly represent the full-significand accumulated value; otherwise that value must lie in [\mathit{mantissa}10^q,(\mathit{mantissa}+1)10^q). The upper endpoint uses mathematical addition, not an assumed successful machine increment. The complete slice and record fields are retained, with no UTF-8 or dispatcher-reachability premise. The number_normal clause transports the supplied normal record; compatible representation is an additional law to prove, not a consequence of declaring refinement.

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 (198)
More program dependencies (156)
Standard-library dependencies (39)

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
All 145 entries
Technical checking records
Local closure summary
{
  "node": "P9_T1_NormalComponentRefinement",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "e657acba4b413b6ca800f311a2a09762a6d073c5b7908f5c6af0f7852c53ffe9",
  "active_statement_hash": "d41f6ddcbda8237548f6a5615ad0bd846766d6bbe64a2c81e3bd53c690bd2f4d",
  "kernel_axioms": [
    "propext"
  ],
  "toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
  "lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
  "checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
  "approved_axioms_hash": "576e6bf9480cfd32f53c309c7ac8fb115c1ba6e413f299ed5ff9fa7c647e6769",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-181",
  "boundary_theorems": {},
  "strict_theorem_deps": {},
  "strict_definition_deps": {
    "DecimalGoalVocabulary": "c08dd4b4aea4abb4",
    "DecimalGoalVocabularyDefault": "71a18a6c119a3cdc",
    "DecimalLexeme": "8ad754cf2c272e73",
    "F64": "ec4e25fbaf4e11d4",
    "P9_T1_AbstractComponents": "a5e42cc5d69d7da4",
    "P9_T1_ActualDispatchOperations": "d8bf51ebbbf153ac",
    "P9_T1_DispatchOperations": "9a657a317bca572b",
    "SourceValidByteSlice": "3dc42716a6378d26",
    "num_imp_dec2flt_common_BiasedFp": "c43614ff2149ecf2",
    "num_imp_dec2flt_decimal_Decimal": "c43614ff2149ecf2"
  }
}
Prose assessment
{
  "label": "Recorded Sound: VerifierPass",
  "assessment_status": "VerifierPass",
  "fingerprint_relation": "matches current fingerprint",
  "assessment_fingerprint": "preservation-v1:bc3b92fed5ffbadb9d54199a259d019eec06f646e387ebad459127340712c9ef",
  "current_fingerprint": "preservation-v1:bc3b92fed5ffbadb9d54199a259d019eec06f646e387ebad459127340712c9ef",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "sound_status": "Pass",
  "substantiveness_status": "Pass"
}