Captured revision records
Detailed evidence retained for inspection; the result views summarize the decision and its supporting checks.
generation-0001/predecessor-receipt.json
Exact captured recorddisposition
{
"action": "reopen",
"reason": "Approve the F64-only preparation reopening, with the second critic's corrections incorporated. The request-25 candidate is the smallest convincing tested boundary: its source diff leaves every parser, helper, overflow/debug check, native-path decision, and trace body intact, while fresh Cargo, Charon, Aeneas, and inspect-native evidence reduces the unresolved inventory from 72 to 24 declarations (14 F64, four U64 bit operations, and six byte/Option/slice/string operations). Removing the irrelevant F16/F32 implementations, U16/U32 instances, and unused F64 Add/equality/order/default/Clone supertraits matches GOAL.md's exclusively binary64 scope. Keeping the frozen boundary would avoid revalidation but impose 48 demonstrated irrelevant bindings and three-format preservation work; fuller monomorphization would rewrite goal-facing generic bodies and traces for a smaller marginal saving. Because trait records, declaration hashes, and the extraction basis change, this is a preparation reopening rather than an in-place native-model change.\n\nThe raw-U64 F64 carrier and safe exact rational/dyadic round-to-nearest-ties-to-even computation are adequate and kernel-checkable. Bit conversions and clone are exact, negation is XOR of bit 63 on every word including NaNs, and from_u64 must reproduce the enabled debug assertion outside v <= 2^53 while the two relevant call sites discharge that guard. Multiplication and division need exact word preservation on their actual native-path calls, whose operands must be proved finite and non-NaN and whose divisors must be proved nonzero. A preferred NaN may totalize unreachable arithmetic cases only under Rust's permitted-NaN relation; it is not a global bit-equality claim. Since accepted observations include returned F64 bits and negative nan reaches negation, the exact f64::NAN word must be pinned to the reopened target/toolchain by primary evidence and negative NaN must retain the exact sign-bit flip. Runtime Float, unsafe floating-point computation, native evaluation, and new axioms remain inadmissible.\n\nThe source-domain correction must cover more than UTF-8. Define a source-valid byte-slice predicate that expresses the configured 64-bit Rust reference/slice value invariant, including the isize::MAX byte-size bound, and define source-valid Rust strings by that invariant plus UTF-8 validity. Premise every source byte-slice or str theorem, contract law, and dispatch quantifier with the appropriate predicate, without adding any smaller convenience bound. This is a faithful restriction of Aeneas's Slice/Str overapproximation, not a GOAL reduction. The checked-arithmetic audit must cover every length-derived offset, cast, addition, subtraction, and counter, especially both exponent additions in parse_partial_number/parse_many_digits and the i32 casts/additions in parse_decimal_seq. If a source-valid large input makes a positive totality, acceptance, or rejection statement false, retain its current mathematical meaning and route it to disproof; do not narrow the domain. ParserAccumulatedRounding must additionally state the lexical sign conclusion. DispatchComponentContract.dispatch_total and every branch law, DispatchAbstractComposition, and the compliance instantiation receive the valid-string premise, while numeric_target_preservation remains unchanged.\n\nAll 32 GOALs remain pursued. Four false statements are already sufficiently identified for disproof polarity after Modeling: ParserExactRounding, DispatchAbstractComposition, and DispatchComponentCompliance use the valid ASCII 65,535-zero witness whose exact target is infinity while the source returns 1.0; SlowAccumulatedRounding uses the valid 2^31-ASCII-'1' witness whose usize-to-i32 cast yields i32::MIN and normal slow result zero although the accumulated target is infinity. Their statements must not be weakened. The first parser disproof and the slow-helper disproof require symbolic, kernel-checked extracted-execution lemmas rather than infeasible direct reduction; the dispatch disproofs use the unchanged uninhabited target-preservation law. The length audit is a required truth-classification gate for ParserTotality, ParserNumericAcceptance, ParserInvalidRejection, NumberHelperAcceptance, and NumberHelperRejection in particular, because the source-valid isize bound alone does not obviously protect the checked i64 exponent sums. No further positive polarity may be assumed until that audit is complete.",
"request_id": 27,
"cycle": 4
}audit_assessment
"Do not weaken numeric_target_preservation, narrow the literal domain, or drop either GOAL merely to make the positive claims provable. The audit should check the shared 65,536-fractional-digit/exponent-overflow witness against DecimalLiteral, the extracted bounded exponent behavior, and Binary64MagnitudeTarget. If the refutation is valid, plan a shared exact-negation route for dispatch_abstract_composition and dispatch_component_compliance while retaining the current source-faithful contract and both GOALs; if it is invalid, identify the precise failed step before returning either node to ordinary verification."generation-0002/predecessor-receipt.json
Exact captured recorddisposition
{
"action": "reopen",
"reason": "Confirmed frozen preparation defect: crate/dec2flt/mod.rs:255-258 and modeling-input/SETUP.md:40-41 falsely claim that opacity is confined to the u64-as-f64 cast and leaves the assertion visible; reference/model-evidence/binary64-boundary.txt:297-303 repeats that claim, while generated.lean:3700-3704 shows the whole from_u64 method is external. Reopen narrowly to correct those preservation-support claims, retain the whole asserted conversion as the boundary modeled by ModelF64FromU64, and re-run all preparation and composition validation. The smaller adequate route changes no computation or GOAL and retains all 32 obligations; continuing to rely on the cast-only account is unsound.",
"request_id": 145,
"cycle": 27
}audit_assessment
"Approve the requested narrow preparation reopening. The current preparation approval cannot remain authoritative: crate/dec2flt/mod.rs:255-258 and modeling-input/SETUP.md:40-41 state that opacity is confined to the cast and that the assertion remains visible, but #[charon::opaque] is attached to the entire function and generated.lean:3700-3704 exposes the whole from_u64 method as one external declaration. reference/model-evidence/binary64-boundary.txt:297-303 reproduces the false account, and the adaptation audit reason in modeling-input/manifest.json likewise relies on narrow cast opacity. These are preservation-support defects and therefore block completion despite passing mechanical provenance reports.\n\nThe proposed repair is adequate. The adapted computation and extraction configuration need not be changed: the frozen Rust body is the source debug assertion followed by the u64-to-f64 conversion, and the existing authored boundary already gives the correct whole-method behavior. Tablet/ModelF64FromU64.lean delegates to Binary64ModelDefault.fromU64, which succeeds with the exact binary64 conversion for v <= 2^53 and returns assertionFailure otherwise; generated callers and their guards remain transparent. Reopening must replace the false source comment, SETUP account, binary64 evidence excerpt/account, and affected setup/adaptation audit reasoning with this whole-function description, then rerun Cargo, Charon, Aeneas, inventory/provenance checks, and native composition on the resulting source basis. Because even a comment correction changes the frozen source basis, the current preparation basis must be retired and freshly approved, although the same 24-external computational boundary may be re-established.\n\nThis correction changes no computation, domain, observation, or principal statement. The approved route already requires the full asserted conversion semantics, all 32 configured targets remain pursued, and no target is declined or polarity-rewritten. Thus no additional modeling-route review is needed; after fresh preparation approval, the repaired Preamble and evidence must be rematerialized and rechecked against that basis."generation-0002/revision/state.json
Exact captured recordhuman_decisions
[
{
"action": "amend",
"amendment": "Check the effects on performance of all of your proposed code changes in various input regimes and carefully work out a new set of proposals. Your proposals should still be principled *and minimal* changes to the original, but they should not be careless about performance impact.\n\nIt is acceptable to retain conditional goals that exclude failures that arise only with exabyte-scale inputs when this avoids greater code complexity or changes. Keep any such conditions explicit in the proposed goals and explain the tradeoff in the review package.",
"digest": "0d8a16d77a54e28a0cdb8f107010a7983a97a3fc7ddf0051096e3a91adfc362e",
"reason": "The source changes have too much of an effect on efficiency to be accepted without justification"
},
{
"action": "amend",
"amendment": "",
"code_edits": {
"files": [
{
"base_sha256": "fd74e5a6a6ad8c7fe353f56f2ab931ede1e29fd357a194d36714326f56d88bde",
"operation": "modify",
"path": "dec2flt/decimal_seq.rs",
"requested_sha256": "7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d"
},
{
"base_sha256": "1c012f0b700c949ed40ffb3e449aaa726ed7e2a958123f41866a9e63931a7c00",
"operation": "modify",
"path": "dec2flt/parse.rs",
"requested_sha256": "51bb06e40b57642ba848720dfe73c1ff6db8fdacfa9e51213c4d0c2341b1f595"
}
],
"package_digest": "16080f5b7a317839c61ad8597e6690daeabb3669936cb207c61b45dbce6bbfe3",
"path": "human-edits/4182028f7ae49ea4e5bfefa0bed70cc0748746db5efcf6200ab599b5e5e6bcb2.json",
"sha256": "4182028f7ae49ea4e5bfefa0bed70cc0748746db5efcf6200ab599b5e5e6bcb2"
},
"digest": "16080f5b7a317839c61ad8597e6690daeabb3669936cb207c61b45dbce6bbfe3",
"reason": "Code changes are good. I have merely changed the comment text."
},
{
"action": "amend",
"amendment": "Change only the exponent comment to the inclusive bound. Preserve the prior decimal_seq.rs comment edit and all previous performance and scope instructions.",
"code_edits": {
"files": [
{
"base_sha256": "51bb06e40b57642ba848720dfe73c1ff6db8fdacfa9e51213c4d0c2341b1f595",
"operation": "modify",
"path": "dec2flt/parse.rs",
"requested_sha256": "a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3"
}
],
"package_digest": "89611cb1a5fba9eaf4303a3bb9072dc4bd2c9ee85579ecf9d149cba834af13de",
"path": "human-edits/d646573d71a1593fe3d88d8fdc2eb487a79fd86d6b2d334a629cf4f75dc9e244.json",
"sha256": "d646573d71a1593fe3d88d8fdc2eb487a79fd86d6b2d334a629cf4f75dc9e244"
},
"comment_only": true,
"digest": "89611cb1a5fba9eaf4303a3bb9072dc4bd2c9ee85579ecf9d149cba834af13de",
"reason": "User approved the at-most correction and repaired focused comment review in chat."
},
{
"action": "accept",
"amendment": null,
"attached_evidence_digest": "e98f4f3731604154ff0f2a2206af7b06c581c5d95cc98f614775f9df578fc4e6",
"digest": "8b02ca6ad5ba017048bd411240bb02e313e84b14d1aac5367a64902452355cae",
"evidence_ratified": false,
"ratified_candidate_digest": "084530edb695c8b2428c781dc84b7ac6ef53b9e34e3972e2f40a916eb37e5e4c",
"reason": "Approved"
}
]negated_goals
[
"dispatch_abstract_composition",
"dispatch_component_compliance",
"number_helper_acceptance",
"number_helper_rejection",
"parser_exact_rounding",
"parser_invalid_rejection",
"parser_numeric_acceptance",
"parser_totality",
"slow_accumulated_rounding"
]generation-0002/revision/review.zip
Exact captured recordgeneration-0002/revision/candidate.patch
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/0-baseline/stderr
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/0-baseline/stdout
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/0-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/0-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/1-baseline/stderr
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/1-baseline/stdout
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/1-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/1-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/2-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/2-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/3-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/3-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/4-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/4-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/5-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/5-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/6-baseline/stderr
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/6-baseline/stdout
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/6-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/6-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/7-baseline/stderr
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/7-baseline/stdout
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/7-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/7-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-1badd7074511-1791414830911757114/result.json
Exact captured recordgeneration-0002/revision/checks/check-2f209ebdf22a-1791349114568413152/0-baseline/stderr
Exact captured recordgeneration-0002/revision/checks/check-2f209ebdf22a-1791349114568413152/0-baseline/stdout
Exact captured recordgeneration-0002/revision/checks/check-2f209ebdf22a-1791349114568413152/0-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-2f209ebdf22a-1791349114568413152/0-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-2f209ebdf22a-1791349114568413152/1-baseline/stderr
Exact captured recordgeneration-0002/revision/checks/check-2f209ebdf22a-1791349114568413152/1-baseline/stdout
Exact captured recordgeneration-0002/revision/checks/check-2f209ebdf22a-1791349114568413152/1-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-2f209ebdf22a-1791349114568413152/1-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-2f209ebdf22a-1791349114568413152/2-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-2f209ebdf22a-1791349114568413152/2-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-2f209ebdf22a-1791349114568413152/3-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-2f209ebdf22a-1791349114568413152/3-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-2f209ebdf22a-1791349114568413152/4-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-2f209ebdf22a-1791349114568413152/4-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-2f209ebdf22a-1791349114568413152/result.json
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/0-baseline/stderr
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/0-baseline/stdout
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/0-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/0-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/1-baseline/stderr
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/1-baseline/stdout
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/1-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/1-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/2-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/2-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/3-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/3-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/4-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/4-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/5-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/5-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/6-baseline/stderr
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/6-baseline/stdout
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/6-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/6-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/7-baseline/stderr
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/7-baseline/stdout
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/7-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/7-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-b56439873101-1791413836035272440/result.json
Exact captured recordgeneration-0002/revision/checks/check-d4ffeff64578-1791348555097098378/0-baseline/stderr
Exact captured recordgeneration-0002/revision/checks/check-d4ffeff64578-1791348555097098378/0-baseline/stdout
Exact captured recordgeneration-0002/revision/checks/check-d4ffeff64578-1791348555097098378/0-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-d4ffeff64578-1791348555097098378/0-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-d4ffeff64578-1791348555097098378/1-baseline/stderr
Exact captured recordgeneration-0002/revision/checks/check-d4ffeff64578-1791348555097098378/1-baseline/stdout
Exact captured recordgeneration-0002/revision/checks/check-d4ffeff64578-1791348555097098378/1-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-d4ffeff64578-1791348555097098378/1-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-d4ffeff64578-1791348555097098378/2-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-d4ffeff64578-1791348555097098378/2-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-d4ffeff64578-1791348555097098378/3-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-d4ffeff64578-1791348555097098378/3-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-d4ffeff64578-1791348555097098378/4-candidate/stderr
Exact captured recordgeneration-0002/revision/checks/check-d4ffeff64578-1791348555097098378/4-candidate/stdout
Exact captured recordgeneration-0002/revision/checks/check-d4ffeff64578-1791348555097098378/result.json
Exact captured recordgeneration-0002/revision/review.json
Exact captured recordnegated_goals
[
"dispatch_abstract_composition",
"dispatch_component_compliance",
"number_helper_acceptance",
"number_helper_rejection",
"parser_exact_rounding",
"parser_invalid_rejection",
"parser_numeric_acceptance",
"parser_totality",
"slow_accumulated_rounding"
]ratification
{
"original_collection": {
"context": "# Decimal-to-binary64 parsing\n\n## Scope and vocabulary\n\nThe subject is the `f64` specialization of Rust's decimal parser and its\nhelper functions, including executions with integer overflow checks enabled.\nPublic results are the returned floats and errors.\n\nA numeric literal has an optional leading sign, an ASCII decimal significand\nwith at least one digit and at most one decimal point, and an optional `e` or\n`E` exponent with an optional sign and at least one ASCII digit. Special\nliterals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,\nwith an optional leading sign. The whole input must match; whitespace and\nother extra characters are invalid. An unsigned literal omits the leading\nsign, while its exponent may still have a sign.\n\nThe exact value of a numeric literal is its ordinary mathematical decimal\nvalue. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,\nincluding subnormal results, signed zero, and overflow to infinity.\n\nFor auxiliary claims, the **accumulated-exponent value** retains every\nsignificand digit but interprets the explicit exponent using the source's\nbounded exponent-accumulation rule. This is an implementation-level diagnostic\nvalue, distinct from the exact value required by the public contract.",
"goals": [
{
"id": "parser_totality",
"text": "`dec2flt`\n\n**Totality.** For every Rust string, the function terminates normally with a\nresult or parsing error, without panicking."
},
{
"id": "parser_numeric_acceptance",
"text": "`dec2flt`\n\n**Numeric acceptance.** Every numeric literal returns `Ok`."
},
{
"id": "parser_invalid_rejection",
"text": "`dec2flt`\n\n**Invalid rejection.** Every string outside the numeric and special literal\ngrammar returns `Err`."
},
{
"id": "parser_nan_acceptance",
"text": "`dec2flt`\n\n**NaN acceptance.** Every NaN literal returns `Ok` of a float satisfying\n`is_nan()`."
},
{
"id": "parser_infinity",
"text": "`dec2flt`\n\n**Infinity.** Every infinity literal returns `Ok` of the infinity with its\nlexical sign."
},
{
"id": "parser_non_nan_results",
"text": "`dec2flt`\n\n**No spurious NaNs.** Every successful result for an input other than a NaN\nliteral is not NaN."
},
{
"id": "parser_numeric_sign",
"text": "`dec2flt`\n\n**Numeric sign.** Every successful numeric result has the literal's lexical\nsign, including results that underflow to zero or overflow to infinity."
},
{
"id": "parser_signed_zero",
"text": "`dec2flt`\n\n**Signed zero.** On acceptance, a numeric literal denoting zero returns\nzero with its lexical sign."
},
{
"id": "parser_exact_rounding",
"text": "`dec2flt`\n\n**Exact rounding.** On acceptance of any numeric literal, the returned float\nis its exact value rounded to binary64."
},
{
"id": "parser_selected_exponent",
"text": "`dec2flt`\n\n**Selected exponent range.** On a successful numeric parse, each raw pair\nselected by the dispatcher for final float assembly has a biased exponent\nin `0..=2047`."
},
{
"id": "parser_selected_magnitude_sign",
"text": "`dec2flt`\n\n**Selected magnitude sign.** On a successful numeric parse, the assembled\nword of each raw pair selected for final float assembly has a clear sign bit."
},
{
"id": "dispatch_abstract_composition",
"text": "`dec2flt`\n\n**Abstract composition.** The lexical and conversion component contracts admit\nimplementations. For any components satisfying those contracts, the\ndispatcher's normal results satisfy the classification, rounding, and sign\nrequirements. This includes the native shortcut, integer tier, many-digit\ndecision, fallback, sign handling, and final assembly."
},
{
"id": "dispatch_component_compliance",
"text": "`dec2flt`\n\n**Component compliance.** The actual source components satisfy the contracts\nused in abstract composition, including preservation of the input's rounding\ntarget. The dispatcher establishes the helper preconditions at their call\nsites."
},
{
"id": "parser_accumulated_rounding",
"text": "`dec2flt`\n\n**Accumulated-value diagnostic.** Every accepted numeric literal is rounded\nto its accumulated-exponent value."
},
{
"id": "parser_equal_target_rounding",
"text": "`dec2flt`\n\n**Equal-target bridge.** On acceptance of a numeric literal whose exact\nand accumulated-exponent values have the same rounding target, the result\nhas that target and the literal's lexical sign."
},
{
"id": "number_helper_acceptance",
"text": "`parse_number`\n\n**Numeric acceptance.** Every nonempty byte slice forming an unsigned numeric\nliteral returns `Some`."
},
{
"id": "number_helper_rejection",
"text": "`parse_number`\n\n**Invalid rejection.** Every nonempty byte slice that is not an unsigned\nnumeric literal returns `None`."
},
{
"id": "number_helper_record_bounds",
"text": "`parse_number`\n\n**Record bounds.** For every nonempty byte slice, any returned record has\n`negative = false` and `mantissa < 10^19`."
},
{
"id": "number_helper_accumulated_value",
"text": "`parse_number`\n\n**Accumulated-value diagnostic.** For every unsigned numeric literal, a\nreturned record with `many_digits = false` represents its accumulated-exponent\nvalue exactly as `mantissa * 10^exponent`. With `many_digits = true`, that value\nlies in the half-open interval from `mantissa * 10^exponent` to\n`(mantissa + 1) * 10^exponent`."
},
{
"id": "special_helper_infinity",
"text": "`parse_inf_nan`\n\n**Infinity.** For every byte slice and either value of the separate sign\nargument, an unsigned infinity keyword returns `Some` infinity with that sign."
},
{
"id": "special_helper_nan",
"text": "`parse_inf_nan`\n\n**NaN.** For every byte slice and either value of the separate sign argument,\nan unsigned NaN keyword returns `Some` of a NaN."
},
{
"id": "special_helper_rejection",
"text": "`parse_inf_nan`\n\n**Rejection.** For every byte slice and either value of the separate sign\nargument, an input other than an unsigned `inf`, `infinity`, or `nan` keyword\nreturns `None`."
},
{
"id": "native_correct_or_defer",
"text": "`try_fast_path`\n\n**Native correctness or defer.** For every `Decimal` record, on normal return,\nthe result is either `None` or `Some` of the binary64 rounding of the exact\n`mantissa * 10^exponent`, with the record's sign. A `Some` result also implies\n`many_digits = false`. The contract applies to both the ordinary native path\nand the disguised path that transfers powers of ten into the mantissa."
},
{
"id": "integer_correct_or_defer",
"text": "`compute_float`\n\n**Correctness or defer.** For all `i64` exponents `q` and all `u64` mantissas\n`w`, a normal result is either a pair with negative biased exponent (deferral)\nor a pair whose assembled word is the nonnegative binary64 rounding of the\nexact value `w * 10^q`."
},
{
"id": "slow_accumulated_rounding",
"text": "`parse_long_mantissa`\n\n**Full-significand diagnostic.** For every unsigned numeric literal, a normal\nresult is a pair whose assembled word is the nonnegative binary64 rounding\nof its accumulated-exponent value, retaining the full significand's\ncontribution to rounding."
},
{
"id": "assembly_correspondence",
"text": "`biased_fp_to_float`\n\n**Assembly correspondence.** For every `BiasedFp`, the function returns\nnormally with float bits equal to the bitwise OR of its mantissa and its\nbiased exponent cast to `u64` using Rust semantics and shifted left by 52.\nThe word interpretation used in the other obligations agrees with this\noperation for all field values, without a well-formedness precondition."
},
{
"id": "classification_totality",
"text": "Mathematical specification\n\n**Classification totality.** Every finite byte string is classified as\nnumeric, special, or invalid."
},
{
"id": "classification_determinism",
"text": "Mathematical specification\n\n**Classification determinism.** Every finite byte string has at most one\nclassification, and the parsed content of each numeric literal is unique."
},
{
"id": "classification_significand_digit",
"text": "Mathematical specification\n\n**Significand digit.** Every numeric literal contains a significand digit."
},
{
"id": "rounding_totality",
"text": "Mathematical specification\n\n**Rounding totality.** Every nonnegative real has a binary64 magnitude\nrounding target, finite or infinite."
},
{
"id": "rounding_determinism",
"text": "Mathematical specification\n\n**Rounding determinism.** For every nonnegative real, the binary64 magnitude\nrounding target is unique."
},
{
"id": "exponent_value_agreement",
"text": "Mathematical specification\n\n**Exponent agreement.** For every numeric literal whose accumulated explicit\nexponent equals its mathematical explicit exponent, exact and\naccumulated-exponent rounding agree."
}
]
},
"original_manifest": {
"files": [
{
"byte_length": 2409,
"relative_path": "dec2flt/common.rs",
"sha256_of_raw_bytes": "fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace"
},
{
"byte_length": 3197,
"relative_path": "dec2flt/decimal.rs",
"sha256_of_raw_bytes": "3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d"
},
{
"byte_length": 15819,
"relative_path": "dec2flt/decimal_seq.rs",
"sha256_of_raw_bytes": "c0c1c6028e3f57cefc3de7635a94788e9180f5ebcedc7a334ec8dbac786ec788"
},
{
"byte_length": 4472,
"relative_path": "dec2flt/fpu.rs",
"sha256_of_raw_bytes": "16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f"
},
{
"byte_length": 7106,
"relative_path": "dec2flt/lemire.rs",
"sha256_of_raw_bytes": "fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1"
},
{
"byte_length": 10193,
"relative_path": "dec2flt/mod.rs",
"sha256_of_raw_bytes": "7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a"
},
{
"byte_length": 7202,
"relative_path": "dec2flt/parse.rs",
"sha256_of_raw_bytes": "9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1"
},
{
"byte_length": 4044,
"relative_path": "dec2flt/slow.rs",
"sha256_of_raw_bytes": "43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2"
},
{
"byte_length": 36759,
"relative_path": "dec2flt/table.rs",
"sha256_of_raw_bytes": "6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb"
},
{
"byte_length": 9120,
"relative_path": "traits.rs",
"sha256_of_raw_bytes": "66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e"
}
],
"schema": "trellis-source-tree-manifest/v1",
"source_tree_sha256": "3cab8073145562182e1519113544384487c4dbefdd05b05648fd5a8ed9514b3b"
},
"proposed_collection": {
"context": "# Decimal-to-binary64 parsing\n\n## Scope and vocabulary\n\nThe subject is the `f64` specialization of Rust's decimal parser and its\nhelper functions, including executions with integer overflow checks enabled.\nPublic results are the returned floats and errors.\n\nA numeric literal has an optional leading sign, an ASCII decimal significand\nwith at least one digit and at most one decimal point, and an optional `e` or\n`E` exponent with an optional sign and at least one ASCII digit. Special\nliterals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,\nwith an optional leading sign. The whole input must match; whitespace and\nother extra characters are invalid. An unsigned literal omits the leading\nsign, while its exponent may still have a sign.\n\nThe exact value of a numeric literal is its ordinary mathematical decimal\nvalue. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,\nincluding subnormal results, signed zero, and overflow to infinity.\n\nFor auxiliary claims, the **accumulated-exponent value** retains every\nsignificand digit but interprets the explicit exponent using the source's\nbounded exponent-accumulation rule. This is an implementation-level diagnostic\nvalue, distinct from the exact value required by the public contract.",
"goals": [
{
"id": "parser_nan_acceptance",
"text": "`dec2flt`\n\n**NaN acceptance.** Every NaN literal returns `Ok` of a float satisfying\n`is_nan()`."
},
{
"id": "parser_infinity",
"text": "`dec2flt`\n\n**Infinity.** Every infinity literal returns `Ok` of the infinity with its\nlexical sign."
},
{
"id": "parser_non_nan_results",
"text": "`dec2flt`\n\n**No spurious NaNs.** Every successful result for an input other than a NaN\nliteral is not NaN."
},
{
"id": "parser_numeric_sign",
"text": "`dec2flt`\n\n**Numeric sign.** Every successful numeric result has the literal's lexical\nsign, including results that underflow to zero or overflow to infinity."
},
{
"id": "parser_signed_zero",
"text": "`dec2flt`\n\n**Signed zero.** On acceptance, a numeric literal denoting zero returns\nzero with its lexical sign."
},
{
"id": "parser_selected_exponent",
"text": "`dec2flt`\n\n**Selected exponent range.** On a successful numeric parse, each raw pair\nselected by the dispatcher for final float assembly has a biased exponent\nin `0..=2047`."
},
{
"id": "parser_selected_magnitude_sign",
"text": "`dec2flt`\n\n**Selected magnitude sign.** On a successful numeric parse, the assembled\nword of each raw pair selected for final float assembly has a clear sign bit."
},
{
"id": "number_helper_record_bounds",
"text": "`parse_number`\n\n**Record bounds.** For every nonempty byte slice, any returned record has\n`negative = false` and `mantissa < 10^19`."
},
{
"id": "special_helper_infinity",
"text": "`parse_inf_nan`\n\n**Infinity.** For every byte slice and either value of the separate sign\nargument, an unsigned infinity keyword returns `Some` infinity with that sign."
},
{
"id": "special_helper_nan",
"text": "`parse_inf_nan`\n\n**NaN.** For every byte slice and either value of the separate sign argument,\nan unsigned NaN keyword returns `Some` of a NaN."
},
{
"id": "special_helper_rejection",
"text": "`parse_inf_nan`\n\n**Rejection.** For every byte slice and either value of the separate sign\nargument, an input other than an unsigned `inf`, `infinity`, or `nan` keyword\nreturns `None`."
},
{
"id": "native_correct_or_defer",
"text": "`try_fast_path`\n\n**Native correctness or defer.** For every `Decimal` record, on normal return,\nthe result is either `None` or `Some` of the binary64 rounding of the exact\n`mantissa * 10^exponent`, with the record's sign. A `Some` result also implies\n`many_digits = false`. The contract applies to both the ordinary native path\nand the disguised path that transfers powers of ten into the mantissa."
},
{
"id": "integer_correct_or_defer",
"text": "`compute_float`\n\n**Correctness or defer.** For all `i64` exponents `q` and all `u64` mantissas\n`w`, a normal result is either a pair with negative biased exponent (deferral)\nor a pair whose assembled word is the nonnegative binary64 rounding of the\nexact value `w * 10^q`."
},
{
"id": "slow_accumulated_rounding",
"text": "`parse_long_mantissa`\n\n**Full-significand diagnostic.** For every unsigned numeric literal, a normal\nresult is a pair whose assembled word is the nonnegative binary64 rounding\nof its accumulated-exponent value, retaining the full significand's\ncontribution to rounding."
},
{
"id": "assembly_correspondence",
"text": "`biased_fp_to_float`\n\n**Assembly correspondence.** For every `BiasedFp`, the function returns\nnormally with float bits equal to the bitwise OR of its mantissa and its\nbiased exponent cast to `u64` using Rust semantics and shifted left by 52.\nThe word interpretation used in the other obligations agrees with this\noperation for all field values, without a well-formedness precondition."
},
{
"id": "classification_totality",
"text": "Mathematical specification\n\n**Classification totality.** Every finite byte string is classified as\nnumeric, special, or invalid."
},
{
"id": "classification_determinism",
"text": "Mathematical specification\n\n**Classification determinism.** Every finite byte string has at most one\nclassification, and the parsed content of each numeric literal is unique."
},
{
"id": "classification_significand_digit",
"text": "Mathematical specification\n\n**Significand digit.** Every numeric literal contains a significand digit."
},
{
"id": "rounding_totality",
"text": "Mathematical specification\n\n**Rounding totality.** Every nonnegative real has a binary64 magnitude\nrounding target, finite or infinite."
},
{
"id": "rounding_determinism",
"text": "Mathematical specification\n\n**Rounding determinism.** For every nonnegative real, the binary64 magnitude\nrounding target is unique."
},
{
"id": "exponent_value_agreement",
"text": "Mathematical specification\n\n**Exponent agreement.** For every numeric literal whose accumulated explicit\nexponent equals its mathematical explicit exponent, exact and\naccumulated-exponent rounding agree."
},
{
"id": "dispatch_abstract_composition",
"text": "`dec2flt`\n\n**Conditional abstract composition.** Let A = 3458764513820540928 bytes and B = 576460752303421440 bytes. The lexical and conversion component contracts admit implementations, with numeric lexical acceptance, rejection and record representation required for nonempty source-valid byte slices of length at most A, and preservation of the ordinary mathematical exact rounding target required for numeric inputs of length at most B. Special parsing, native correctness-or-defer, integer correctness-or-defer, unrestricted assembly, and the full-significand accumulated-exponent slow diagnostic retain their existing domains; the slow diagnostic applies to every source-valid unsigned numeric literal, without an A or B restriction. For any components satisfying these contracts, the dispatcher's normal results on Rust strings of byte length at most A satisfy classification, accumulated-exponent rounding and lexical sign requirements. On numeric strings of byte length at most B they additionally satisfy ordinary mathematical exact rounding. These conclusions include the native shortcut, integer tier, many-digit endpoint decision, fallback, sign handling and final assembly. Contract inhabitability and the existence of an abstract normal output for every Rust string of byte length at most A must be established, not inferred from an implication over an empty contract package."
},
{
"id": "dispatch_component_compliance",
"text": "`dec2flt`\n\n**Conditional component compliance.** Let A = 3458764513820540928 bytes and B = 576460752303421440 bytes. The actual source components satisfy the contracts used in conditional abstract composition. In particular, the numeric lexical component returns normally and satisfies acceptance, rejection and record representation on every nonempty source-valid byte slice of length at most A; it preserves the input's ordinary mathematical exact rounding target on numeric slices of length at most B. The source components for special parsing, native conversion, integer conversion and unrestricted assembly retain their existing full-domain obligations. The actual slow component satisfies the full-significand accumulated-exponent diagnostic on every source-valid unsigned numeric literal, without a length restriction. For every Rust string of byte length at most A, the concrete dispatcher agrees with the abstract component operations at its calls and establishes their helper preconditions. On numeric strings of byte length at most B, this agreement additionally preserves the exact rounding target throughout dispatch. These obligations include native shortcut, integer tier, many-digit decision, fallback, sign handling and assembly, and require a genuinely inhabited compatible component package."
},
{
"id": "number_helper_acceptance",
"text": "`parse_number`\n\n**Conditional numeric acceptance.** Every nonempty source-valid byte slice of length at most 3458764513820540928 bytes that forms an unsigned numeric literal returns normally with `Some`. This requirement includes executions with integer overflow checks enabled and does not impose a limit on the number or mathematical value of explicit exponent digits within the stated byte-length domain."
},
{
"id": "number_helper_rejection",
"text": "`parse_number`\n\n**Conditional invalid rejection.** Every nonempty source-valid byte slice of length at most 3458764513820540928 bytes that is not an unsigned numeric literal returns normally with `None`, including executions with integer overflow checks enabled. The entire byte slice must be checked against the unsigned numeric grammar, including malformed exponent digits and trailing characters after exponent accumulation has stopped."
},
{
"id": "parser_exact_rounding",
"text": "`dec2flt`\n\n**Conditional exact rounding.** On acceptance of any numeric literal whose complete Rust string has byte length at most 576460752303421440 bytes, the returned float is its ordinary mathematical exact decimal value rounded to binary64 round-to-nearest, ties-to-even. This includes subnormal results, signed zero with the literal's lexical sign, and overflow to infinity with that sign. The explicit exponent has its ordinary mathematical meaning; no restriction on its digit count or value is added beyond the stated complete-string byte-length bound."
},
{
"id": "parser_invalid_rejection",
"text": "`dec2flt`\n\n**Conditional invalid rejection.** Every Rust string of byte length at most 3458764513820540928 bytes that is outside the numeric and special literal grammar returns normally with `Err`, without panicking, including executions with integer overflow checks enabled. Grammar matching covers the whole input, including characters after a numerically saturated exponent."
},
{
"id": "parser_numeric_acceptance",
"text": "`dec2flt`\n\n**Conditional numeric acceptance.** Every numeric literal whose complete Rust string has byte length at most 3458764513820540928 bytes returns normally with `Ok`, without panicking, including executions with integer overflow checks enabled. Optional leading signs and arbitrarily long explicit exponent digit strings are allowed whenever the complete string satisfies the stated byte-length bound."
},
{
"id": "parser_totality",
"text": "`dec2flt`\n\n**Conditional totality.** For every Rust string of byte length at most 3458764513820540928 bytes, the function terminates normally with a float result or parsing error, without panicking. This requirement includes executions with integer overflow checks enabled and applies to numeric, special, invalid, empty and sign-only inputs."
},
{
"id": "parser_accumulated_rounding",
"text": "`dec2flt`\n\n**Conditional accumulated-value diagnostic.** Every accepted numeric literal whose complete Rust string has byte length at most 3458764513820540928 bytes is rounded to its accumulated-exponent value, retaining every significand digit and interpreting the explicit exponent using the actual source's bounded exponent-accumulation rule. The returned binary64 float has the literal's lexical sign, including zero and infinity. This diagnostic is distinct from the ordinary mathematical exact-value requirement."
},
{
"id": "parser_equal_target_rounding",
"text": "`dec2flt`\n\n**Conditional equal-target bridge.** On acceptance of a numeric literal whose complete Rust string has byte length at most 3458764513820540928 bytes and whose ordinary mathematical exact value and source-defined accumulated-exponent value have the same binary64 rounding target, the result has that target and the literal's lexical sign, including signed zero and signed infinity."
},
{
"id": "number_helper_accumulated_value",
"text": "`parse_number`\n\n**Conditional accumulated-value diagnostic.** For every source-valid unsigned numeric byte slice of length at most 3458764513820540928 bytes, any returned record with `many_digits = false` represents its accumulated-exponent value exactly as `mantissa * 10^exponent`. With `many_digits = true`, that value lies in the half-open interval from `mantissa * 10^exponent` to `(mantissa + 1) * 10^exponent`. The accumulated-exponent value retains every significand digit and uses the actual source's bounded explicit-exponent accumulation rule."
}
]
},
"source_manifest": {
"files": [
{
"byte_length": 2409,
"relative_path": "dec2flt/common.rs",
"sha256_of_raw_bytes": "fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace"
},
{
"byte_length": 3197,
"relative_path": "dec2flt/decimal.rs",
"sha256_of_raw_bytes": "3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d"
},
{
"byte_length": 15939,
"relative_path": "dec2flt/decimal_seq.rs",
"sha256_of_raw_bytes": "7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d"
},
{
"byte_length": 4472,
"relative_path": "dec2flt/fpu.rs",
"sha256_of_raw_bytes": "16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f"
},
{
"byte_length": 7106,
"relative_path": "dec2flt/lemire.rs",
"sha256_of_raw_bytes": "fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1"
},
{
"byte_length": 10193,
"relative_path": "dec2flt/mod.rs",
"sha256_of_raw_bytes": "7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a"
},
{
"byte_length": 7228,
"relative_path": "dec2flt/parse.rs",
"sha256_of_raw_bytes": "a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3"
},
{
"byte_length": 4044,
"relative_path": "dec2flt/slow.rs",
"sha256_of_raw_bytes": "43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2"
},
{
"byte_length": 36759,
"relative_path": "dec2flt/table.rs",
"sha256_of_raw_bytes": "6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb"
},
{
"byte_length": 9120,
"relative_path": "traits.rs",
"sha256_of_raw_bytes": "66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e"
}
],
"schema": "trellis-source-tree-manifest/v1",
"source_tree_sha256": "e811e153d0550be4137891901d09c1ce47e61b033de47fcd7cff5ed98259554f"
}
}aggregate_diff
{
"base_source_digest": "3cab8073145562182e1519113544384487c4dbefdd05b05648fd5a8ed9514b3b",
"changes": [
{
"after": {
"byte_length": 15939,
"relative_path": "dec2flt/decimal_seq.rs",
"sha256_of_raw_bytes": "7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d"
},
"before": {
"byte_length": 15819,
"relative_path": "dec2flt/decimal_seq.rs",
"sha256_of_raw_bytes": "c0c1c6028e3f57cefc3de7635a94788e9180f5ebcedc7a334ec8dbac786ec788"
},
"binary": false,
"operation": "modify",
"path": "dec2flt/decimal_seq.rs"
},
{
"after": {
"byte_length": 7228,
"relative_path": "dec2flt/parse.rs",
"sha256_of_raw_bytes": "a9303bac61a5e8e7b610632925bb0d04483374a91f9ec38a7305fd4a1ca0b5f3"
},
"before": {
"byte_length": 7202,
"relative_path": "dec2flt/parse.rs",
"sha256_of_raw_bytes": "9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1"
},
"binary": false,
"operation": "modify",
"path": "dec2flt/parse.rs"
}
],
"patch": "--- a/dec2flt/decimal_seq.rs\n+++ b/dec2flt/decimal_seq.rs\n@@ -10,6 +10,7 @@\n //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.\n \n use dec2flt::common::{ByteSlice, is_8digits};\n+use dec2flt::parse::parse_scientific;\n \n use crate::num::imp::dec2flt;\n \n@@ -218,10 +219,27 @@\n }\n }\n \n+/// Combine counts in i64 and clamp before casting to i32.\n+#[inline]\n+pub(super) fn final_decimal_point(\n+ significant_count: usize,\n+ fractional_count: usize,\n+ explicit: i64,\n+) -> i32 {\n+ if significant_count == 0 {\n+ return 0;\n+ }\n+ let base = significant_count as i64 - fractional_count as i64;\n+ base.saturating_add(explicit)\n+ .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)\n+ as i32\n+}\n+\n /// Parse a big integer representation of the float as a decimal.\n pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {\n let mut d = DecimalSeq::default();\n let start = s;\n+ let mut fractional_count = 0;\n \n while let Some((&b'0', s_next)) = s.split_first() {\n s = s_next;\n@@ -248,9 +266,10 @@\n s = &s[8..];\n }\n s = s.parse_digits(|digit| d.try_add_digit(digit));\n- d.decimal_point = s.len() as i32 - first.len() as i32;\n- }\n-\n+ fractional_count = first.len() - s.len();\n+ }\n+\n+ let significant_count = d.num_digits;\n if d.num_digits != 0 {\n // Ignore the trailing zeros if there are any\n let mut n_trailing_zeros = 0;\n@@ -261,36 +280,21 @@\n break;\n }\n }\n- d.decimal_point += n_trailing_zeros as i32;\n d.num_digits -= n_trailing_zeros;\n- d.decimal_point += d.num_digits as i32;\n if d.num_digits > DecimalSeq::MAX_DIGITS {\n d.truncated = true;\n d.num_digits = DecimalSeq::MAX_DIGITS;\n }\n }\n \n+ let mut explicit = 0;\n if let Some((&ch, s_next)) = s.split_first() {\n if ch == b'e' || ch == b'E' {\n s = s_next;\n- let mut neg_exp = false;\n- if let Some((&ch, s_next)) = s.split_first() {\n- neg_exp = ch == b'-';\n- if ch == b'-' || ch == b'+' {\n- s = s_next;\n- }\n- }\n- let mut exp_num = 0_i32;\n-\n- s.parse_digits(|digit| {\n- if exp_num < 0x10000 {\n- exp_num = 10 * exp_num + digit as i32;\n- }\n- });\n-\n- d.decimal_point += if neg_exp { -exp_num } else { exp_num };\n- }\n- }\n+ explicit = parse_scientific(&mut s).unwrap_or(0);\n+ }\n+ }\n+ d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);\n \n for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {\n d.digits[i] = 0;\n--- a/dec2flt/parse.rs\n+++ b/dec2flt/parse.rs\n@@ -70,7 +70,7 @@\n }\n \n /// Parse the scientific notation component of a float.\n-fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {\n+pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {\n let mut exponent = 0i64;\n let mut negative = false;\n \n@@ -85,8 +85,8 @@\n \n if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {\n *s_ref = s.parse_digits(|digit| {\n- // no overflows here, saturate well before overflow\n- if exponent < 0x10000 {\n+ // The exponent is at most 10 * 2^59 - 1, which fits in i64.\n+ if exponent < (1_i64 << 59) {\n exponent = 10 * exponent + digit as i64;\n }\n });\n",
"result_source_digest": "e811e153d0550be4137891901d09c1ce47e61b033de47fcd7cff5ed98259554f"
}proof_status
"requires_modeling_and_reproof"tests_are_proofs
falseretirement_is_proof
falsegeneration-0002/revision/reviews/16080f5b7a317839c61ad8597e6690daeabb3669936cb207c61b45dbce6bbfe3/review.json
Exact captured recordnegated_goals
[
"dispatch_abstract_composition",
"dispatch_component_compliance",
"number_helper_acceptance",
"number_helper_rejection",
"parser_exact_rounding",
"parser_invalid_rejection",
"parser_numeric_acceptance",
"parser_totality",
"slow_accumulated_rounding"
]ratification
{
"original_collection": {
"context": "# Decimal-to-binary64 parsing\n\n## Scope and vocabulary\n\nThe subject is the `f64` specialization of Rust's decimal parser and its\nhelper functions, including executions with integer overflow checks enabled.\nPublic results are the returned floats and errors.\n\nA numeric literal has an optional leading sign, an ASCII decimal significand\nwith at least one digit and at most one decimal point, and an optional `e` or\n`E` exponent with an optional sign and at least one ASCII digit. Special\nliterals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,\nwith an optional leading sign. The whole input must match; whitespace and\nother extra characters are invalid. An unsigned literal omits the leading\nsign, while its exponent may still have a sign.\n\nThe exact value of a numeric literal is its ordinary mathematical decimal\nvalue. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,\nincluding subnormal results, signed zero, and overflow to infinity.\n\nFor auxiliary claims, the **accumulated-exponent value** retains every\nsignificand digit but interprets the explicit exponent using the source's\nbounded exponent-accumulation rule. This is an implementation-level diagnostic\nvalue, distinct from the exact value required by the public contract.",
"goals": [
{
"id": "parser_totality",
"text": "`dec2flt`\n\n**Totality.** For every Rust string, the function terminates normally with a\nresult or parsing error, without panicking."
},
{
"id": "parser_numeric_acceptance",
"text": "`dec2flt`\n\n**Numeric acceptance.** Every numeric literal returns `Ok`."
},
{
"id": "parser_invalid_rejection",
"text": "`dec2flt`\n\n**Invalid rejection.** Every string outside the numeric and special literal\ngrammar returns `Err`."
},
{
"id": "parser_nan_acceptance",
"text": "`dec2flt`\n\n**NaN acceptance.** Every NaN literal returns `Ok` of a float satisfying\n`is_nan()`."
},
{
"id": "parser_infinity",
"text": "`dec2flt`\n\n**Infinity.** Every infinity literal returns `Ok` of the infinity with its\nlexical sign."
},
{
"id": "parser_non_nan_results",
"text": "`dec2flt`\n\n**No spurious NaNs.** Every successful result for an input other than a NaN\nliteral is not NaN."
},
{
"id": "parser_numeric_sign",
"text": "`dec2flt`\n\n**Numeric sign.** Every successful numeric result has the literal's lexical\nsign, including results that underflow to zero or overflow to infinity."
},
{
"id": "parser_signed_zero",
"text": "`dec2flt`\n\n**Signed zero.** On acceptance, a numeric literal denoting zero returns\nzero with its lexical sign."
},
{
"id": "parser_exact_rounding",
"text": "`dec2flt`\n\n**Exact rounding.** On acceptance of any numeric literal, the returned float\nis its exact value rounded to binary64."
},
{
"id": "parser_selected_exponent",
"text": "`dec2flt`\n\n**Selected exponent range.** On a successful numeric parse, each raw pair\nselected by the dispatcher for final float assembly has a biased exponent\nin `0..=2047`."
},
{
"id": "parser_selected_magnitude_sign",
"text": "`dec2flt`\n\n**Selected magnitude sign.** On a successful numeric parse, the assembled\nword of each raw pair selected for final float assembly has a clear sign bit."
},
{
"id": "dispatch_abstract_composition",
"text": "`dec2flt`\n\n**Abstract composition.** The lexical and conversion component contracts admit\nimplementations. For any components satisfying those contracts, the\ndispatcher's normal results satisfy the classification, rounding, and sign\nrequirements. This includes the native shortcut, integer tier, many-digit\ndecision, fallback, sign handling, and final assembly."
},
{
"id": "dispatch_component_compliance",
"text": "`dec2flt`\n\n**Component compliance.** The actual source components satisfy the contracts\nused in abstract composition, including preservation of the input's rounding\ntarget. The dispatcher establishes the helper preconditions at their call\nsites."
},
{
"id": "parser_accumulated_rounding",
"text": "`dec2flt`\n\n**Accumulated-value diagnostic.** Every accepted numeric literal is rounded\nto its accumulated-exponent value."
},
{
"id": "parser_equal_target_rounding",
"text": "`dec2flt`\n\n**Equal-target bridge.** On acceptance of a numeric literal whose exact\nand accumulated-exponent values have the same rounding target, the result\nhas that target and the literal's lexical sign."
},
{
"id": "number_helper_acceptance",
"text": "`parse_number`\n\n**Numeric acceptance.** Every nonempty byte slice forming an unsigned numeric\nliteral returns `Some`."
},
{
"id": "number_helper_rejection",
"text": "`parse_number`\n\n**Invalid rejection.** Every nonempty byte slice that is not an unsigned\nnumeric literal returns `None`."
},
{
"id": "number_helper_record_bounds",
"text": "`parse_number`\n\n**Record bounds.** For every nonempty byte slice, any returned record has\n`negative = false` and `mantissa < 10^19`."
},
{
"id": "number_helper_accumulated_value",
"text": "`parse_number`\n\n**Accumulated-value diagnostic.** For every unsigned numeric literal, a\nreturned record with `many_digits = false` represents its accumulated-exponent\nvalue exactly as `mantissa * 10^exponent`. With `many_digits = true`, that value\nlies in the half-open interval from `mantissa * 10^exponent` to\n`(mantissa + 1) * 10^exponent`."
},
{
"id": "special_helper_infinity",
"text": "`parse_inf_nan`\n\n**Infinity.** For every byte slice and either value of the separate sign\nargument, an unsigned infinity keyword returns `Some` infinity with that sign."
},
{
"id": "special_helper_nan",
"text": "`parse_inf_nan`\n\n**NaN.** For every byte slice and either value of the separate sign argument,\nan unsigned NaN keyword returns `Some` of a NaN."
},
{
"id": "special_helper_rejection",
"text": "`parse_inf_nan`\n\n**Rejection.** For every byte slice and either value of the separate sign\nargument, an input other than an unsigned `inf`, `infinity`, or `nan` keyword\nreturns `None`."
},
{
"id": "native_correct_or_defer",
"text": "`try_fast_path`\n\n**Native correctness or defer.** For every `Decimal` record, on normal return,\nthe result is either `None` or `Some` of the binary64 rounding of the exact\n`mantissa * 10^exponent`, with the record's sign. A `Some` result also implies\n`many_digits = false`. The contract applies to both the ordinary native path\nand the disguised path that transfers powers of ten into the mantissa."
},
{
"id": "integer_correct_or_defer",
"text": "`compute_float`\n\n**Correctness or defer.** For all `i64` exponents `q` and all `u64` mantissas\n`w`, a normal result is either a pair with negative biased exponent (deferral)\nor a pair whose assembled word is the nonnegative binary64 rounding of the\nexact value `w * 10^q`."
},
{
"id": "slow_accumulated_rounding",
"text": "`parse_long_mantissa`\n\n**Full-significand diagnostic.** For every unsigned numeric literal, a normal\nresult is a pair whose assembled word is the nonnegative binary64 rounding\nof its accumulated-exponent value, retaining the full significand's\ncontribution to rounding."
},
{
"id": "assembly_correspondence",
"text": "`biased_fp_to_float`\n\n**Assembly correspondence.** For every `BiasedFp`, the function returns\nnormally with float bits equal to the bitwise OR of its mantissa and its\nbiased exponent cast to `u64` using Rust semantics and shifted left by 52.\nThe word interpretation used in the other obligations agrees with this\noperation for all field values, without a well-formedness precondition."
},
{
"id": "classification_totality",
"text": "Mathematical specification\n\n**Classification totality.** Every finite byte string is classified as\nnumeric, special, or invalid."
},
{
"id": "classification_determinism",
"text": "Mathematical specification\n\n**Classification determinism.** Every finite byte string has at most one\nclassification, and the parsed content of each numeric literal is unique."
},
{
"id": "classification_significand_digit",
"text": "Mathematical specification\n\n**Significand digit.** Every numeric literal contains a significand digit."
},
{
"id": "rounding_totality",
"text": "Mathematical specification\n\n**Rounding totality.** Every nonnegative real has a binary64 magnitude\nrounding target, finite or infinite."
},
{
"id": "rounding_determinism",
"text": "Mathematical specification\n\n**Rounding determinism.** For every nonnegative real, the binary64 magnitude\nrounding target is unique."
},
{
"id": "exponent_value_agreement",
"text": "Mathematical specification\n\n**Exponent agreement.** For every numeric literal whose accumulated explicit\nexponent equals its mathematical explicit exponent, exact and\naccumulated-exponent rounding agree."
}
]
},
"original_manifest": {
"files": [
{
"byte_length": 2409,
"relative_path": "dec2flt/common.rs",
"sha256_of_raw_bytes": "fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace"
},
{
"byte_length": 3197,
"relative_path": "dec2flt/decimal.rs",
"sha256_of_raw_bytes": "3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d"
},
{
"byte_length": 15819,
"relative_path": "dec2flt/decimal_seq.rs",
"sha256_of_raw_bytes": "c0c1c6028e3f57cefc3de7635a94788e9180f5ebcedc7a334ec8dbac786ec788"
},
{
"byte_length": 4472,
"relative_path": "dec2flt/fpu.rs",
"sha256_of_raw_bytes": "16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f"
},
{
"byte_length": 7106,
"relative_path": "dec2flt/lemire.rs",
"sha256_of_raw_bytes": "fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1"
},
{
"byte_length": 10193,
"relative_path": "dec2flt/mod.rs",
"sha256_of_raw_bytes": "7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a"
},
{
"byte_length": 7202,
"relative_path": "dec2flt/parse.rs",
"sha256_of_raw_bytes": "9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1"
},
{
"byte_length": 4044,
"relative_path": "dec2flt/slow.rs",
"sha256_of_raw_bytes": "43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2"
},
{
"byte_length": 36759,
"relative_path": "dec2flt/table.rs",
"sha256_of_raw_bytes": "6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb"
},
{
"byte_length": 9120,
"relative_path": "traits.rs",
"sha256_of_raw_bytes": "66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e"
}
],
"schema": "trellis-source-tree-manifest/v1",
"source_tree_sha256": "3cab8073145562182e1519113544384487c4dbefdd05b05648fd5a8ed9514b3b"
},
"proposed_collection": {
"context": "# Decimal-to-binary64 parsing\n\n## Scope and vocabulary\n\nThe subject is the `f64` specialization of Rust's decimal parser and its\nhelper functions, including executions with integer overflow checks enabled.\nPublic results are the returned floats and errors.\n\nA numeric literal has an optional leading sign, an ASCII decimal significand\nwith at least one digit and at most one decimal point, and an optional `e` or\n`E` exponent with an optional sign and at least one ASCII digit. Special\nliterals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,\nwith an optional leading sign. The whole input must match; whitespace and\nother extra characters are invalid. An unsigned literal omits the leading\nsign, while its exponent may still have a sign.\n\nThe exact value of a numeric literal is its ordinary mathematical decimal\nvalue. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,\nincluding subnormal results, signed zero, and overflow to infinity.\n\nFor auxiliary claims, the **accumulated-exponent value** retains every\nsignificand digit but interprets the explicit exponent using the source's\nbounded exponent-accumulation rule. This is an implementation-level diagnostic\nvalue, distinct from the exact value required by the public contract.",
"goals": [
{
"id": "parser_nan_acceptance",
"text": "`dec2flt`\n\n**NaN acceptance.** Every NaN literal returns `Ok` of a float satisfying\n`is_nan()`."
},
{
"id": "parser_infinity",
"text": "`dec2flt`\n\n**Infinity.** Every infinity literal returns `Ok` of the infinity with its\nlexical sign."
},
{
"id": "parser_non_nan_results",
"text": "`dec2flt`\n\n**No spurious NaNs.** Every successful result for an input other than a NaN\nliteral is not NaN."
},
{
"id": "parser_numeric_sign",
"text": "`dec2flt`\n\n**Numeric sign.** Every successful numeric result has the literal's lexical\nsign, including results that underflow to zero or overflow to infinity."
},
{
"id": "parser_signed_zero",
"text": "`dec2flt`\n\n**Signed zero.** On acceptance, a numeric literal denoting zero returns\nzero with its lexical sign."
},
{
"id": "parser_selected_exponent",
"text": "`dec2flt`\n\n**Selected exponent range.** On a successful numeric parse, each raw pair\nselected by the dispatcher for final float assembly has a biased exponent\nin `0..=2047`."
},
{
"id": "parser_selected_magnitude_sign",
"text": "`dec2flt`\n\n**Selected magnitude sign.** On a successful numeric parse, the assembled\nword of each raw pair selected for final float assembly has a clear sign bit."
},
{
"id": "number_helper_record_bounds",
"text": "`parse_number`\n\n**Record bounds.** For every nonempty byte slice, any returned record has\n`negative = false` and `mantissa < 10^19`."
},
{
"id": "special_helper_infinity",
"text": "`parse_inf_nan`\n\n**Infinity.** For every byte slice and either value of the separate sign\nargument, an unsigned infinity keyword returns `Some` infinity with that sign."
},
{
"id": "special_helper_nan",
"text": "`parse_inf_nan`\n\n**NaN.** For every byte slice and either value of the separate sign argument,\nan unsigned NaN keyword returns `Some` of a NaN."
},
{
"id": "special_helper_rejection",
"text": "`parse_inf_nan`\n\n**Rejection.** For every byte slice and either value of the separate sign\nargument, an input other than an unsigned `inf`, `infinity`, or `nan` keyword\nreturns `None`."
},
{
"id": "native_correct_or_defer",
"text": "`try_fast_path`\n\n**Native correctness or defer.** For every `Decimal` record, on normal return,\nthe result is either `None` or `Some` of the binary64 rounding of the exact\n`mantissa * 10^exponent`, with the record's sign. A `Some` result also implies\n`many_digits = false`. The contract applies to both the ordinary native path\nand the disguised path that transfers powers of ten into the mantissa."
},
{
"id": "integer_correct_or_defer",
"text": "`compute_float`\n\n**Correctness or defer.** For all `i64` exponents `q` and all `u64` mantissas\n`w`, a normal result is either a pair with negative biased exponent (deferral)\nor a pair whose assembled word is the nonnegative binary64 rounding of the\nexact value `w * 10^q`."
},
{
"id": "slow_accumulated_rounding",
"text": "`parse_long_mantissa`\n\n**Full-significand diagnostic.** For every unsigned numeric literal, a normal\nresult is a pair whose assembled word is the nonnegative binary64 rounding\nof its accumulated-exponent value, retaining the full significand's\ncontribution to rounding."
},
{
"id": "assembly_correspondence",
"text": "`biased_fp_to_float`\n\n**Assembly correspondence.** For every `BiasedFp`, the function returns\nnormally with float bits equal to the bitwise OR of its mantissa and its\nbiased exponent cast to `u64` using Rust semantics and shifted left by 52.\nThe word interpretation used in the other obligations agrees with this\noperation for all field values, without a well-formedness precondition."
},
{
"id": "classification_totality",
"text": "Mathematical specification\n\n**Classification totality.** Every finite byte string is classified as\nnumeric, special, or invalid."
},
{
"id": "classification_determinism",
"text": "Mathematical specification\n\n**Classification determinism.** Every finite byte string has at most one\nclassification, and the parsed content of each numeric literal is unique."
},
{
"id": "classification_significand_digit",
"text": "Mathematical specification\n\n**Significand digit.** Every numeric literal contains a significand digit."
},
{
"id": "rounding_totality",
"text": "Mathematical specification\n\n**Rounding totality.** Every nonnegative real has a binary64 magnitude\nrounding target, finite or infinite."
},
{
"id": "rounding_determinism",
"text": "Mathematical specification\n\n**Rounding determinism.** For every nonnegative real, the binary64 magnitude\nrounding target is unique."
},
{
"id": "exponent_value_agreement",
"text": "Mathematical specification\n\n**Exponent agreement.** For every numeric literal whose accumulated explicit\nexponent equals its mathematical explicit exponent, exact and\naccumulated-exponent rounding agree."
},
{
"id": "dispatch_abstract_composition",
"text": "`dec2flt`\n\n**Conditional abstract composition.** Let A = 3458764513820540928 bytes and B = 576460752303421440 bytes. The lexical and conversion component contracts admit implementations, with numeric lexical acceptance, rejection and record representation required for nonempty source-valid byte slices of length at most A, and preservation of the ordinary mathematical exact rounding target required for numeric inputs of length at most B. Special parsing, native correctness-or-defer, integer correctness-or-defer, unrestricted assembly, and the full-significand accumulated-exponent slow diagnostic retain their existing domains; the slow diagnostic applies to every source-valid unsigned numeric literal, without an A or B restriction. For any components satisfying these contracts, the dispatcher's normal results on Rust strings of byte length at most A satisfy classification, accumulated-exponent rounding and lexical sign requirements. On numeric strings of byte length at most B they additionally satisfy ordinary mathematical exact rounding. These conclusions include the native shortcut, integer tier, many-digit endpoint decision, fallback, sign handling and final assembly. Contract inhabitability and the existence of an abstract normal output for every Rust string of byte length at most A must be established, not inferred from an implication over an empty contract package."
},
{
"id": "dispatch_component_compliance",
"text": "`dec2flt`\n\n**Conditional component compliance.** Let A = 3458764513820540928 bytes and B = 576460752303421440 bytes. The actual source components satisfy the contracts used in conditional abstract composition. In particular, the numeric lexical component returns normally and satisfies acceptance, rejection and record representation on every nonempty source-valid byte slice of length at most A; it preserves the input's ordinary mathematical exact rounding target on numeric slices of length at most B. The source components for special parsing, native conversion, integer conversion and unrestricted assembly retain their existing full-domain obligations. The actual slow component satisfies the full-significand accumulated-exponent diagnostic on every source-valid unsigned numeric literal, without a length restriction. For every Rust string of byte length at most A, the concrete dispatcher agrees with the abstract component operations at its calls and establishes their helper preconditions. On numeric strings of byte length at most B, this agreement additionally preserves the exact rounding target throughout dispatch. These obligations include native shortcut, integer tier, many-digit decision, fallback, sign handling and assembly, and require a genuinely inhabited compatible component package."
},
{
"id": "number_helper_acceptance",
"text": "`parse_number`\n\n**Conditional numeric acceptance.** Every nonempty source-valid byte slice of length at most 3458764513820540928 bytes that forms an unsigned numeric literal returns normally with `Some`. This requirement includes executions with integer overflow checks enabled and does not impose a limit on the number or mathematical value of explicit exponent digits within the stated byte-length domain."
},
{
"id": "number_helper_rejection",
"text": "`parse_number`\n\n**Conditional invalid rejection.** Every nonempty source-valid byte slice of length at most 3458764513820540928 bytes that is not an unsigned numeric literal returns normally with `None`, including executions with integer overflow checks enabled. The entire byte slice must be checked against the unsigned numeric grammar, including malformed exponent digits and trailing characters after exponent accumulation has stopped."
},
{
"id": "parser_exact_rounding",
"text": "`dec2flt`\n\n**Conditional exact rounding.** On acceptance of any numeric literal whose complete Rust string has byte length at most 576460752303421440 bytes, the returned float is its ordinary mathematical exact decimal value rounded to binary64 round-to-nearest, ties-to-even. This includes subnormal results, signed zero with the literal's lexical sign, and overflow to infinity with that sign. The explicit exponent has its ordinary mathematical meaning; no restriction on its digit count or value is added beyond the stated complete-string byte-length bound."
},
{
"id": "parser_invalid_rejection",
"text": "`dec2flt`\n\n**Conditional invalid rejection.** Every Rust string of byte length at most 3458764513820540928 bytes that is outside the numeric and special literal grammar returns normally with `Err`, without panicking, including executions with integer overflow checks enabled. Grammar matching covers the whole input, including characters after a numerically saturated exponent."
},
{
"id": "parser_numeric_acceptance",
"text": "`dec2flt`\n\n**Conditional numeric acceptance.** Every numeric literal whose complete Rust string has byte length at most 3458764513820540928 bytes returns normally with `Ok`, without panicking, including executions with integer overflow checks enabled. Optional leading signs and arbitrarily long explicit exponent digit strings are allowed whenever the complete string satisfies the stated byte-length bound."
},
{
"id": "parser_totality",
"text": "`dec2flt`\n\n**Conditional totality.** For every Rust string of byte length at most 3458764513820540928 bytes, the function terminates normally with a float result or parsing error, without panicking. This requirement includes executions with integer overflow checks enabled and applies to numeric, special, invalid, empty and sign-only inputs."
},
{
"id": "parser_accumulated_rounding",
"text": "`dec2flt`\n\n**Conditional accumulated-value diagnostic.** Every accepted numeric literal whose complete Rust string has byte length at most 3458764513820540928 bytes is rounded to its accumulated-exponent value, retaining every significand digit and interpreting the explicit exponent using the actual source's bounded exponent-accumulation rule. The returned binary64 float has the literal's lexical sign, including zero and infinity. This diagnostic is distinct from the ordinary mathematical exact-value requirement."
},
{
"id": "parser_equal_target_rounding",
"text": "`dec2flt`\n\n**Conditional equal-target bridge.** On acceptance of a numeric literal whose complete Rust string has byte length at most 3458764513820540928 bytes and whose ordinary mathematical exact value and source-defined accumulated-exponent value have the same binary64 rounding target, the result has that target and the literal's lexical sign, including signed zero and signed infinity."
},
{
"id": "number_helper_accumulated_value",
"text": "`parse_number`\n\n**Conditional accumulated-value diagnostic.** For every source-valid unsigned numeric byte slice of length at most 3458764513820540928 bytes, any returned record with `many_digits = false` represents its accumulated-exponent value exactly as `mantissa * 10^exponent`. With `many_digits = true`, that value lies in the half-open interval from `mantissa * 10^exponent` to `(mantissa + 1) * 10^exponent`. The accumulated-exponent value retains every significand digit and uses the actual source's bounded explicit-exponent accumulation rule."
}
]
},
"source_manifest": {
"files": [
{
"byte_length": 2409,
"relative_path": "dec2flt/common.rs",
"sha256_of_raw_bytes": "fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace"
},
{
"byte_length": 3197,
"relative_path": "dec2flt/decimal.rs",
"sha256_of_raw_bytes": "3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d"
},
{
"byte_length": 15966,
"relative_path": "dec2flt/decimal_seq.rs",
"sha256_of_raw_bytes": "fd74e5a6a6ad8c7fe353f56f2ab931ede1e29fd357a194d36714326f56d88bde"
},
{
"byte_length": 4472,
"relative_path": "dec2flt/fpu.rs",
"sha256_of_raw_bytes": "16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f"
},
{
"byte_length": 7106,
"relative_path": "dec2flt/lemire.rs",
"sha256_of_raw_bytes": "fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1"
},
{
"byte_length": 10193,
"relative_path": "dec2flt/mod.rs",
"sha256_of_raw_bytes": "7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a"
},
{
"byte_length": 7241,
"relative_path": "dec2flt/parse.rs",
"sha256_of_raw_bytes": "1c012f0b700c949ed40ffb3e449aaa726ed7e2a958123f41866a9e63931a7c00"
},
{
"byte_length": 4044,
"relative_path": "dec2flt/slow.rs",
"sha256_of_raw_bytes": "43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2"
},
{
"byte_length": 36759,
"relative_path": "dec2flt/table.rs",
"sha256_of_raw_bytes": "6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb"
},
{
"byte_length": 9120,
"relative_path": "traits.rs",
"sha256_of_raw_bytes": "66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e"
}
],
"schema": "trellis-source-tree-manifest/v1",
"source_tree_sha256": "154a15b5d86cbda4cdb4610299109317a4509088cdf9cda0f143b5109955da79"
}
}aggregate_diff
{
"base_source_digest": "3cab8073145562182e1519113544384487c4dbefdd05b05648fd5a8ed9514b3b",
"changes": [
{
"after": {
"byte_length": 15966,
"relative_path": "dec2flt/decimal_seq.rs",
"sha256_of_raw_bytes": "fd74e5a6a6ad8c7fe353f56f2ab931ede1e29fd357a194d36714326f56d88bde"
},
"before": {
"byte_length": 15819,
"relative_path": "dec2flt/decimal_seq.rs",
"sha256_of_raw_bytes": "c0c1c6028e3f57cefc3de7635a94788e9180f5ebcedc7a334ec8dbac786ec788"
},
"binary": false,
"operation": "modify",
"path": "dec2flt/decimal_seq.rs"
},
{
"after": {
"byte_length": 7241,
"relative_path": "dec2flt/parse.rs",
"sha256_of_raw_bytes": "1c012f0b700c949ed40ffb3e449aaa726ed7e2a958123f41866a9e63931a7c00"
},
"before": {
"byte_length": 7202,
"relative_path": "dec2flt/parse.rs",
"sha256_of_raw_bytes": "9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1"
},
"binary": false,
"operation": "modify",
"path": "dec2flt/parse.rs"
}
],
"patch": "--- a/dec2flt/decimal_seq.rs\n+++ b/dec2flt/decimal_seq.rs\n@@ -10,6 +10,7 @@\n //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.\n \n use dec2flt::common::{ByteSlice, is_8digits};\n+use dec2flt::parse::parse_scientific;\n \n use crate::num::imp::dec2flt;\n \n@@ -218,10 +219,27 @@\n }\n }\n \n+/// Combine source-valid counts before encoding an extreme point for the slow guards.\n+#[inline]\n+pub(super) fn final_decimal_point(\n+ significant_count: usize,\n+ fractional_count: usize,\n+ explicit: i64,\n+) -> i32 {\n+ if significant_count == 0 {\n+ return 0;\n+ }\n+ let base = significant_count as i64 - fractional_count as i64;\n+ base.saturating_add(explicit)\n+ .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)\n+ as i32\n+}\n+\n /// Parse a big integer representation of the float as a decimal.\n pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {\n let mut d = DecimalSeq::default();\n let start = s;\n+ let mut fractional_count = 0;\n \n while let Some((&b'0', s_next)) = s.split_first() {\n s = s_next;\n@@ -248,9 +266,10 @@\n s = &s[8..];\n }\n s = s.parse_digits(|digit| d.try_add_digit(digit));\n- d.decimal_point = s.len() as i32 - first.len() as i32;\n- }\n-\n+ fractional_count = first.len() - s.len();\n+ }\n+\n+ let significant_count = d.num_digits;\n if d.num_digits != 0 {\n // Ignore the trailing zeros if there are any\n let mut n_trailing_zeros = 0;\n@@ -261,36 +280,21 @@\n break;\n }\n }\n- d.decimal_point += n_trailing_zeros as i32;\n d.num_digits -= n_trailing_zeros;\n- d.decimal_point += d.num_digits as i32;\n if d.num_digits > DecimalSeq::MAX_DIGITS {\n d.truncated = true;\n d.num_digits = DecimalSeq::MAX_DIGITS;\n }\n }\n \n+ let mut explicit = 0;\n if let Some((&ch, s_next)) = s.split_first() {\n if ch == b'e' || ch == b'E' {\n s = s_next;\n- let mut neg_exp = false;\n- if let Some((&ch, s_next)) = s.split_first() {\n- neg_exp = ch == b'-';\n- if ch == b'-' || ch == b'+' {\n- s = s_next;\n- }\n- }\n- let mut exp_num = 0_i32;\n-\n- s.parse_digits(|digit| {\n- if exp_num < 0x10000 {\n- exp_num = 10 * exp_num + digit as i32;\n- }\n- });\n-\n- d.decimal_point += if neg_exp { -exp_num } else { exp_num };\n- }\n- }\n+ explicit = parse_scientific(&mut s).unwrap_or(0);\n+ }\n+ }\n+ d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);\n \n for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {\n d.digits[i] = 0;\n--- a/dec2flt/parse.rs\n+++ b/dec2flt/parse.rs\n@@ -70,7 +70,7 @@\n }\n \n /// Parse the scientific notation component of a float.\n-fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {\n+pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {\n let mut exponent = 0i64;\n let mut negative = false;\n \n@@ -85,8 +85,8 @@\n \n if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {\n *s_ref = s.parse_digits(|digit| {\n- // no overflows here, saturate well before overflow\n- if exponent < 0x10000 {\n+ // The pre-update cutoff permits one overshoot, bounded by 10 * 2^59 - 1.\n+ if exponent < (1_i64 << 59) {\n exponent = 10 * exponent + digit as i64;\n }\n });\n",
"result_source_digest": "154a15b5d86cbda4cdb4610299109317a4509088cdf9cda0f143b5109955da79"
}proof_status
"requires_modeling_and_reproof"tests_are_proofs
falseretirement_is_proof
falsegeneration-0002/revision/reviews/89611cb1a5fba9eaf4303a3bb9072dc4bd2c9ee85579ecf9d149cba834af13de/review.json
Exact captured recordnegated_goals
[
"dispatch_abstract_composition",
"dispatch_component_compliance",
"number_helper_acceptance",
"number_helper_rejection",
"parser_exact_rounding",
"parser_invalid_rejection",
"parser_numeric_acceptance",
"parser_totality",
"slow_accumulated_rounding"
]ratification
{
"original_collection": {
"context": "# Decimal-to-binary64 parsing\n\n## Scope and vocabulary\n\nThe subject is the `f64` specialization of Rust's decimal parser and its\nhelper functions, including executions with integer overflow checks enabled.\nPublic results are the returned floats and errors.\n\nA numeric literal has an optional leading sign, an ASCII decimal significand\nwith at least one digit and at most one decimal point, and an optional `e` or\n`E` exponent with an optional sign and at least one ASCII digit. Special\nliterals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,\nwith an optional leading sign. The whole input must match; whitespace and\nother extra characters are invalid. An unsigned literal omits the leading\nsign, while its exponent may still have a sign.\n\nThe exact value of a numeric literal is its ordinary mathematical decimal\nvalue. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,\nincluding subnormal results, signed zero, and overflow to infinity.\n\nFor auxiliary claims, the **accumulated-exponent value** retains every\nsignificand digit but interprets the explicit exponent using the source's\nbounded exponent-accumulation rule. This is an implementation-level diagnostic\nvalue, distinct from the exact value required by the public contract.",
"goals": [
{
"id": "parser_totality",
"text": "`dec2flt`\n\n**Totality.** For every Rust string, the function terminates normally with a\nresult or parsing error, without panicking."
},
{
"id": "parser_numeric_acceptance",
"text": "`dec2flt`\n\n**Numeric acceptance.** Every numeric literal returns `Ok`."
},
{
"id": "parser_invalid_rejection",
"text": "`dec2flt`\n\n**Invalid rejection.** Every string outside the numeric and special literal\ngrammar returns `Err`."
},
{
"id": "parser_nan_acceptance",
"text": "`dec2flt`\n\n**NaN acceptance.** Every NaN literal returns `Ok` of a float satisfying\n`is_nan()`."
},
{
"id": "parser_infinity",
"text": "`dec2flt`\n\n**Infinity.** Every infinity literal returns `Ok` of the infinity with its\nlexical sign."
},
{
"id": "parser_non_nan_results",
"text": "`dec2flt`\n\n**No spurious NaNs.** Every successful result for an input other than a NaN\nliteral is not NaN."
},
{
"id": "parser_numeric_sign",
"text": "`dec2flt`\n\n**Numeric sign.** Every successful numeric result has the literal's lexical\nsign, including results that underflow to zero or overflow to infinity."
},
{
"id": "parser_signed_zero",
"text": "`dec2flt`\n\n**Signed zero.** On acceptance, a numeric literal denoting zero returns\nzero with its lexical sign."
},
{
"id": "parser_exact_rounding",
"text": "`dec2flt`\n\n**Exact rounding.** On acceptance of any numeric literal, the returned float\nis its exact value rounded to binary64."
},
{
"id": "parser_selected_exponent",
"text": "`dec2flt`\n\n**Selected exponent range.** On a successful numeric parse, each raw pair\nselected by the dispatcher for final float assembly has a biased exponent\nin `0..=2047`."
},
{
"id": "parser_selected_magnitude_sign",
"text": "`dec2flt`\n\n**Selected magnitude sign.** On a successful numeric parse, the assembled\nword of each raw pair selected for final float assembly has a clear sign bit."
},
{
"id": "dispatch_abstract_composition",
"text": "`dec2flt`\n\n**Abstract composition.** The lexical and conversion component contracts admit\nimplementations. For any components satisfying those contracts, the\ndispatcher's normal results satisfy the classification, rounding, and sign\nrequirements. This includes the native shortcut, integer tier, many-digit\ndecision, fallback, sign handling, and final assembly."
},
{
"id": "dispatch_component_compliance",
"text": "`dec2flt`\n\n**Component compliance.** The actual source components satisfy the contracts\nused in abstract composition, including preservation of the input's rounding\ntarget. The dispatcher establishes the helper preconditions at their call\nsites."
},
{
"id": "parser_accumulated_rounding",
"text": "`dec2flt`\n\n**Accumulated-value diagnostic.** Every accepted numeric literal is rounded\nto its accumulated-exponent value."
},
{
"id": "parser_equal_target_rounding",
"text": "`dec2flt`\n\n**Equal-target bridge.** On acceptance of a numeric literal whose exact\nand accumulated-exponent values have the same rounding target, the result\nhas that target and the literal's lexical sign."
},
{
"id": "number_helper_acceptance",
"text": "`parse_number`\n\n**Numeric acceptance.** Every nonempty byte slice forming an unsigned numeric\nliteral returns `Some`."
},
{
"id": "number_helper_rejection",
"text": "`parse_number`\n\n**Invalid rejection.** Every nonempty byte slice that is not an unsigned\nnumeric literal returns `None`."
},
{
"id": "number_helper_record_bounds",
"text": "`parse_number`\n\n**Record bounds.** For every nonempty byte slice, any returned record has\n`negative = false` and `mantissa < 10^19`."
},
{
"id": "number_helper_accumulated_value",
"text": "`parse_number`\n\n**Accumulated-value diagnostic.** For every unsigned numeric literal, a\nreturned record with `many_digits = false` represents its accumulated-exponent\nvalue exactly as `mantissa * 10^exponent`. With `many_digits = true`, that value\nlies in the half-open interval from `mantissa * 10^exponent` to\n`(mantissa + 1) * 10^exponent`."
},
{
"id": "special_helper_infinity",
"text": "`parse_inf_nan`\n\n**Infinity.** For every byte slice and either value of the separate sign\nargument, an unsigned infinity keyword returns `Some` infinity with that sign."
},
{
"id": "special_helper_nan",
"text": "`parse_inf_nan`\n\n**NaN.** For every byte slice and either value of the separate sign argument,\nan unsigned NaN keyword returns `Some` of a NaN."
},
{
"id": "special_helper_rejection",
"text": "`parse_inf_nan`\n\n**Rejection.** For every byte slice and either value of the separate sign\nargument, an input other than an unsigned `inf`, `infinity`, or `nan` keyword\nreturns `None`."
},
{
"id": "native_correct_or_defer",
"text": "`try_fast_path`\n\n**Native correctness or defer.** For every `Decimal` record, on normal return,\nthe result is either `None` or `Some` of the binary64 rounding of the exact\n`mantissa * 10^exponent`, with the record's sign. A `Some` result also implies\n`many_digits = false`. The contract applies to both the ordinary native path\nand the disguised path that transfers powers of ten into the mantissa."
},
{
"id": "integer_correct_or_defer",
"text": "`compute_float`\n\n**Correctness or defer.** For all `i64` exponents `q` and all `u64` mantissas\n`w`, a normal result is either a pair with negative biased exponent (deferral)\nor a pair whose assembled word is the nonnegative binary64 rounding of the\nexact value `w * 10^q`."
},
{
"id": "slow_accumulated_rounding",
"text": "`parse_long_mantissa`\n\n**Full-significand diagnostic.** For every unsigned numeric literal, a normal\nresult is a pair whose assembled word is the nonnegative binary64 rounding\nof its accumulated-exponent value, retaining the full significand's\ncontribution to rounding."
},
{
"id": "assembly_correspondence",
"text": "`biased_fp_to_float`\n\n**Assembly correspondence.** For every `BiasedFp`, the function returns\nnormally with float bits equal to the bitwise OR of its mantissa and its\nbiased exponent cast to `u64` using Rust semantics and shifted left by 52.\nThe word interpretation used in the other obligations agrees with this\noperation for all field values, without a well-formedness precondition."
},
{
"id": "classification_totality",
"text": "Mathematical specification\n\n**Classification totality.** Every finite byte string is classified as\nnumeric, special, or invalid."
},
{
"id": "classification_determinism",
"text": "Mathematical specification\n\n**Classification determinism.** Every finite byte string has at most one\nclassification, and the parsed content of each numeric literal is unique."
},
{
"id": "classification_significand_digit",
"text": "Mathematical specification\n\n**Significand digit.** Every numeric literal contains a significand digit."
},
{
"id": "rounding_totality",
"text": "Mathematical specification\n\n**Rounding totality.** Every nonnegative real has a binary64 magnitude\nrounding target, finite or infinite."
},
{
"id": "rounding_determinism",
"text": "Mathematical specification\n\n**Rounding determinism.** For every nonnegative real, the binary64 magnitude\nrounding target is unique."
},
{
"id": "exponent_value_agreement",
"text": "Mathematical specification\n\n**Exponent agreement.** For every numeric literal whose accumulated explicit\nexponent equals its mathematical explicit exponent, exact and\naccumulated-exponent rounding agree."
}
]
},
"original_manifest": {
"files": [
{
"byte_length": 2409,
"relative_path": "dec2flt/common.rs",
"sha256_of_raw_bytes": "fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace"
},
{
"byte_length": 3197,
"relative_path": "dec2flt/decimal.rs",
"sha256_of_raw_bytes": "3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d"
},
{
"byte_length": 15819,
"relative_path": "dec2flt/decimal_seq.rs",
"sha256_of_raw_bytes": "c0c1c6028e3f57cefc3de7635a94788e9180f5ebcedc7a334ec8dbac786ec788"
},
{
"byte_length": 4472,
"relative_path": "dec2flt/fpu.rs",
"sha256_of_raw_bytes": "16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f"
},
{
"byte_length": 7106,
"relative_path": "dec2flt/lemire.rs",
"sha256_of_raw_bytes": "fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1"
},
{
"byte_length": 10193,
"relative_path": "dec2flt/mod.rs",
"sha256_of_raw_bytes": "7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a"
},
{
"byte_length": 7202,
"relative_path": "dec2flt/parse.rs",
"sha256_of_raw_bytes": "9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1"
},
{
"byte_length": 4044,
"relative_path": "dec2flt/slow.rs",
"sha256_of_raw_bytes": "43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2"
},
{
"byte_length": 36759,
"relative_path": "dec2flt/table.rs",
"sha256_of_raw_bytes": "6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb"
},
{
"byte_length": 9120,
"relative_path": "traits.rs",
"sha256_of_raw_bytes": "66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e"
}
],
"schema": "trellis-source-tree-manifest/v1",
"source_tree_sha256": "3cab8073145562182e1519113544384487c4dbefdd05b05648fd5a8ed9514b3b"
},
"proposed_collection": {
"context": "# Decimal-to-binary64 parsing\n\n## Scope and vocabulary\n\nThe subject is the `f64` specialization of Rust's decimal parser and its\nhelper functions, including executions with integer overflow checks enabled.\nPublic results are the returned floats and errors.\n\nA numeric literal has an optional leading sign, an ASCII decimal significand\nwith at least one digit and at most one decimal point, and an optional `e` or\n`E` exponent with an optional sign and at least one ASCII digit. Special\nliterals are `inf`, `infinity`, and `nan`, matched ASCII case-insensitively,\nwith an optional leading sign. The whole input must match; whitespace and\nother extra characters are invalid. An unsigned literal omits the leading\nsign, while its exponent may still have a sign.\n\nThe exact value of a numeric literal is its ordinary mathematical decimal\nvalue. Rounding means IEEE 754 binary64 round-to-nearest, ties-to-even,\nincluding subnormal results, signed zero, and overflow to infinity.\n\nFor auxiliary claims, the **accumulated-exponent value** retains every\nsignificand digit but interprets the explicit exponent using the source's\nbounded exponent-accumulation rule. This is an implementation-level diagnostic\nvalue, distinct from the exact value required by the public contract.",
"goals": [
{
"id": "parser_nan_acceptance",
"text": "`dec2flt`\n\n**NaN acceptance.** Every NaN literal returns `Ok` of a float satisfying\n`is_nan()`."
},
{
"id": "parser_infinity",
"text": "`dec2flt`\n\n**Infinity.** Every infinity literal returns `Ok` of the infinity with its\nlexical sign."
},
{
"id": "parser_non_nan_results",
"text": "`dec2flt`\n\n**No spurious NaNs.** Every successful result for an input other than a NaN\nliteral is not NaN."
},
{
"id": "parser_numeric_sign",
"text": "`dec2flt`\n\n**Numeric sign.** Every successful numeric result has the literal's lexical\nsign, including results that underflow to zero or overflow to infinity."
},
{
"id": "parser_signed_zero",
"text": "`dec2flt`\n\n**Signed zero.** On acceptance, a numeric literal denoting zero returns\nzero with its lexical sign."
},
{
"id": "parser_selected_exponent",
"text": "`dec2flt`\n\n**Selected exponent range.** On a successful numeric parse, each raw pair\nselected by the dispatcher for final float assembly has a biased exponent\nin `0..=2047`."
},
{
"id": "parser_selected_magnitude_sign",
"text": "`dec2flt`\n\n**Selected magnitude sign.** On a successful numeric parse, the assembled\nword of each raw pair selected for final float assembly has a clear sign bit."
},
{
"id": "number_helper_record_bounds",
"text": "`parse_number`\n\n**Record bounds.** For every nonempty byte slice, any returned record has\n`negative = false` and `mantissa < 10^19`."
},
{
"id": "special_helper_infinity",
"text": "`parse_inf_nan`\n\n**Infinity.** For every byte slice and either value of the separate sign\nargument, an unsigned infinity keyword returns `Some` infinity with that sign."
},
{
"id": "special_helper_nan",
"text": "`parse_inf_nan`\n\n**NaN.** For every byte slice and either value of the separate sign argument,\nan unsigned NaN keyword returns `Some` of a NaN."
},
{
"id": "special_helper_rejection",
"text": "`parse_inf_nan`\n\n**Rejection.** For every byte slice and either value of the separate sign\nargument, an input other than an unsigned `inf`, `infinity`, or `nan` keyword\nreturns `None`."
},
{
"id": "native_correct_or_defer",
"text": "`try_fast_path`\n\n**Native correctness or defer.** For every `Decimal` record, on normal return,\nthe result is either `None` or `Some` of the binary64 rounding of the exact\n`mantissa * 10^exponent`, with the record's sign. A `Some` result also implies\n`many_digits = false`. The contract applies to both the ordinary native path\nand the disguised path that transfers powers of ten into the mantissa."
},
{
"id": "integer_correct_or_defer",
"text": "`compute_float`\n\n**Correctness or defer.** For all `i64` exponents `q` and all `u64` mantissas\n`w`, a normal result is either a pair with negative biased exponent (deferral)\nor a pair whose assembled word is the nonnegative binary64 rounding of the\nexact value `w * 10^q`."
},
{
"id": "slow_accumulated_rounding",
"text": "`parse_long_mantissa`\n\n**Full-significand diagnostic.** For every unsigned numeric literal, a normal\nresult is a pair whose assembled word is the nonnegative binary64 rounding\nof its accumulated-exponent value, retaining the full significand's\ncontribution to rounding."
},
{
"id": "assembly_correspondence",
"text": "`biased_fp_to_float`\n\n**Assembly correspondence.** For every `BiasedFp`, the function returns\nnormally with float bits equal to the bitwise OR of its mantissa and its\nbiased exponent cast to `u64` using Rust semantics and shifted left by 52.\nThe word interpretation used in the other obligations agrees with this\noperation for all field values, without a well-formedness precondition."
},
{
"id": "classification_totality",
"text": "Mathematical specification\n\n**Classification totality.** Every finite byte string is classified as\nnumeric, special, or invalid."
},
{
"id": "classification_determinism",
"text": "Mathematical specification\n\n**Classification determinism.** Every finite byte string has at most one\nclassification, and the parsed content of each numeric literal is unique."
},
{
"id": "classification_significand_digit",
"text": "Mathematical specification\n\n**Significand digit.** Every numeric literal contains a significand digit."
},
{
"id": "rounding_totality",
"text": "Mathematical specification\n\n**Rounding totality.** Every nonnegative real has a binary64 magnitude\nrounding target, finite or infinite."
},
{
"id": "rounding_determinism",
"text": "Mathematical specification\n\n**Rounding determinism.** For every nonnegative real, the binary64 magnitude\nrounding target is unique."
},
{
"id": "exponent_value_agreement",
"text": "Mathematical specification\n\n**Exponent agreement.** For every numeric literal whose accumulated explicit\nexponent equals its mathematical explicit exponent, exact and\naccumulated-exponent rounding agree."
},
{
"id": "dispatch_abstract_composition",
"text": "`dec2flt`\n\n**Conditional abstract composition.** Let A = 3458764513820540928 bytes and B = 576460752303421440 bytes. The lexical and conversion component contracts admit implementations, with numeric lexical acceptance, rejection and record representation required for nonempty source-valid byte slices of length at most A, and preservation of the ordinary mathematical exact rounding target required for numeric inputs of length at most B. Special parsing, native correctness-or-defer, integer correctness-or-defer, unrestricted assembly, and the full-significand accumulated-exponent slow diagnostic retain their existing domains; the slow diagnostic applies to every source-valid unsigned numeric literal, without an A or B restriction. For any components satisfying these contracts, the dispatcher's normal results on Rust strings of byte length at most A satisfy classification, accumulated-exponent rounding and lexical sign requirements. On numeric strings of byte length at most B they additionally satisfy ordinary mathematical exact rounding. These conclusions include the native shortcut, integer tier, many-digit endpoint decision, fallback, sign handling and final assembly. Contract inhabitability and the existence of an abstract normal output for every Rust string of byte length at most A must be established, not inferred from an implication over an empty contract package."
},
{
"id": "dispatch_component_compliance",
"text": "`dec2flt`\n\n**Conditional component compliance.** Let A = 3458764513820540928 bytes and B = 576460752303421440 bytes. The actual source components satisfy the contracts used in conditional abstract composition. In particular, the numeric lexical component returns normally and satisfies acceptance, rejection and record representation on every nonempty source-valid byte slice of length at most A; it preserves the input's ordinary mathematical exact rounding target on numeric slices of length at most B. The source components for special parsing, native conversion, integer conversion and unrestricted assembly retain their existing full-domain obligations. The actual slow component satisfies the full-significand accumulated-exponent diagnostic on every source-valid unsigned numeric literal, without a length restriction. For every Rust string of byte length at most A, the concrete dispatcher agrees with the abstract component operations at its calls and establishes their helper preconditions. On numeric strings of byte length at most B, this agreement additionally preserves the exact rounding target throughout dispatch. These obligations include native shortcut, integer tier, many-digit decision, fallback, sign handling and assembly, and require a genuinely inhabited compatible component package."
},
{
"id": "number_helper_acceptance",
"text": "`parse_number`\n\n**Conditional numeric acceptance.** Every nonempty source-valid byte slice of length at most 3458764513820540928 bytes that forms an unsigned numeric literal returns normally with `Some`. This requirement includes executions with integer overflow checks enabled and does not impose a limit on the number or mathematical value of explicit exponent digits within the stated byte-length domain."
},
{
"id": "number_helper_rejection",
"text": "`parse_number`\n\n**Conditional invalid rejection.** Every nonempty source-valid byte slice of length at most 3458764513820540928 bytes that is not an unsigned numeric literal returns normally with `None`, including executions with integer overflow checks enabled. The entire byte slice must be checked against the unsigned numeric grammar, including malformed exponent digits and trailing characters after exponent accumulation has stopped."
},
{
"id": "parser_exact_rounding",
"text": "`dec2flt`\n\n**Conditional exact rounding.** On acceptance of any numeric literal whose complete Rust string has byte length at most 576460752303421440 bytes, the returned float is its ordinary mathematical exact decimal value rounded to binary64 round-to-nearest, ties-to-even. This includes subnormal results, signed zero with the literal's lexical sign, and overflow to infinity with that sign. The explicit exponent has its ordinary mathematical meaning; no restriction on its digit count or value is added beyond the stated complete-string byte-length bound."
},
{
"id": "parser_invalid_rejection",
"text": "`dec2flt`\n\n**Conditional invalid rejection.** Every Rust string of byte length at most 3458764513820540928 bytes that is outside the numeric and special literal grammar returns normally with `Err`, without panicking, including executions with integer overflow checks enabled. Grammar matching covers the whole input, including characters after a numerically saturated exponent."
},
{
"id": "parser_numeric_acceptance",
"text": "`dec2flt`\n\n**Conditional numeric acceptance.** Every numeric literal whose complete Rust string has byte length at most 3458764513820540928 bytes returns normally with `Ok`, without panicking, including executions with integer overflow checks enabled. Optional leading signs and arbitrarily long explicit exponent digit strings are allowed whenever the complete string satisfies the stated byte-length bound."
},
{
"id": "parser_totality",
"text": "`dec2flt`\n\n**Conditional totality.** For every Rust string of byte length at most 3458764513820540928 bytes, the function terminates normally with a float result or parsing error, without panicking. This requirement includes executions with integer overflow checks enabled and applies to numeric, special, invalid, empty and sign-only inputs."
},
{
"id": "parser_accumulated_rounding",
"text": "`dec2flt`\n\n**Conditional accumulated-value diagnostic.** Every accepted numeric literal whose complete Rust string has byte length at most 3458764513820540928 bytes is rounded to its accumulated-exponent value, retaining every significand digit and interpreting the explicit exponent using the actual source's bounded exponent-accumulation rule. The returned binary64 float has the literal's lexical sign, including zero and infinity. This diagnostic is distinct from the ordinary mathematical exact-value requirement."
},
{
"id": "parser_equal_target_rounding",
"text": "`dec2flt`\n\n**Conditional equal-target bridge.** On acceptance of a numeric literal whose complete Rust string has byte length at most 3458764513820540928 bytes and whose ordinary mathematical exact value and source-defined accumulated-exponent value have the same binary64 rounding target, the result has that target and the literal's lexical sign, including signed zero and signed infinity."
},
{
"id": "number_helper_accumulated_value",
"text": "`parse_number`\n\n**Conditional accumulated-value diagnostic.** For every source-valid unsigned numeric byte slice of length at most 3458764513820540928 bytes, any returned record with `many_digits = false` represents its accumulated-exponent value exactly as `mantissa * 10^exponent`. With `many_digits = true`, that value lies in the half-open interval from `mantissa * 10^exponent` to `(mantissa + 1) * 10^exponent`. The accumulated-exponent value retains every significand digit and uses the actual source's bounded explicit-exponent accumulation rule."
}
]
},
"source_manifest": {
"files": [
{
"byte_length": 2409,
"relative_path": "dec2flt/common.rs",
"sha256_of_raw_bytes": "fc64094721ff23e08fcba013154d04dec3fe986cae5ffd73a20f86049980aace"
},
{
"byte_length": 3197,
"relative_path": "dec2flt/decimal.rs",
"sha256_of_raw_bytes": "3c164785e1bc3f3b48aa9c212dd6c4ab535fe828523af9fa584df4c7b1e60e0d"
},
{
"byte_length": 15939,
"relative_path": "dec2flt/decimal_seq.rs",
"sha256_of_raw_bytes": "7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d"
},
{
"byte_length": 4472,
"relative_path": "dec2flt/fpu.rs",
"sha256_of_raw_bytes": "16cf9ec154d477ab3d4184a01fb4b9ed7c59f0228cc55589d393c40a61b19d8f"
},
{
"byte_length": 7106,
"relative_path": "dec2flt/lemire.rs",
"sha256_of_raw_bytes": "fee1397d264fe4c5af5fa27efae0af7c5ad453be7cff8389abc24b9b252aead1"
},
{
"byte_length": 10193,
"relative_path": "dec2flt/mod.rs",
"sha256_of_raw_bytes": "7198e238c554b692405537a446b3526ad66805ec2900cd0e299f10c51402a44a"
},
{
"byte_length": 7238,
"relative_path": "dec2flt/parse.rs",
"sha256_of_raw_bytes": "51bb06e40b57642ba848720dfe73c1ff6db8fdacfa9e51213c4d0c2341b1f595"
},
{
"byte_length": 4044,
"relative_path": "dec2flt/slow.rs",
"sha256_of_raw_bytes": "43e7aba32d7431bbf0e1bbcb4c334eaffb23eb66891c7e45abe799c5235cc0d2"
},
{
"byte_length": 36759,
"relative_path": "dec2flt/table.rs",
"sha256_of_raw_bytes": "6eb59023784bd84cb6fb074c70da8a99bef72bc2a2ea179b0da457ca1ee00abb"
},
{
"byte_length": 9120,
"relative_path": "traits.rs",
"sha256_of_raw_bytes": "66a02c44d72dfcc3ddae7e34a290e390dabaf98c5911b283d2d97f2f0075a44e"
}
],
"schema": "trellis-source-tree-manifest/v1",
"source_tree_sha256": "2facae262ddc2236b9f5e41a1f36d42d39e04c515a8fd07169ce0614f714c735"
}
}aggregate_diff
{
"base_source_digest": "3cab8073145562182e1519113544384487c4dbefdd05b05648fd5a8ed9514b3b",
"changes": [
{
"after": {
"byte_length": 15939,
"relative_path": "dec2flt/decimal_seq.rs",
"sha256_of_raw_bytes": "7b1b28b8c439afb4628411af12920b7c0ecd19036fa530dc74c6a356ec6e351d"
},
"before": {
"byte_length": 15819,
"relative_path": "dec2flt/decimal_seq.rs",
"sha256_of_raw_bytes": "c0c1c6028e3f57cefc3de7635a94788e9180f5ebcedc7a334ec8dbac786ec788"
},
"binary": false,
"operation": "modify",
"path": "dec2flt/decimal_seq.rs"
},
{
"after": {
"byte_length": 7238,
"relative_path": "dec2flt/parse.rs",
"sha256_of_raw_bytes": "51bb06e40b57642ba848720dfe73c1ff6db8fdacfa9e51213c4d0c2341b1f595"
},
"before": {
"byte_length": 7202,
"relative_path": "dec2flt/parse.rs",
"sha256_of_raw_bytes": "9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1"
},
"binary": false,
"operation": "modify",
"path": "dec2flt/parse.rs"
}
],
"patch": "--- a/dec2flt/decimal_seq.rs\n+++ b/dec2flt/decimal_seq.rs\n@@ -10,6 +10,7 @@\n //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.\n \n use dec2flt::common::{ByteSlice, is_8digits};\n+use dec2flt::parse::parse_scientific;\n \n use crate::num::imp::dec2flt;\n \n@@ -218,10 +219,27 @@\n }\n }\n \n+/// Combine counts in i64 and clamp before casting to i32.\n+#[inline]\n+pub(super) fn final_decimal_point(\n+ significant_count: usize,\n+ fractional_count: usize,\n+ explicit: i64,\n+) -> i32 {\n+ if significant_count == 0 {\n+ return 0;\n+ }\n+ let base = significant_count as i64 - fractional_count as i64;\n+ base.saturating_add(explicit)\n+ .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)\n+ as i32\n+}\n+\n /// Parse a big integer representation of the float as a decimal.\n pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {\n let mut d = DecimalSeq::default();\n let start = s;\n+ let mut fractional_count = 0;\n \n while let Some((&b'0', s_next)) = s.split_first() {\n s = s_next;\n@@ -248,9 +266,10 @@\n s = &s[8..];\n }\n s = s.parse_digits(|digit| d.try_add_digit(digit));\n- d.decimal_point = s.len() as i32 - first.len() as i32;\n- }\n-\n+ fractional_count = first.len() - s.len();\n+ }\n+\n+ let significant_count = d.num_digits;\n if d.num_digits != 0 {\n // Ignore the trailing zeros if there are any\n let mut n_trailing_zeros = 0;\n@@ -261,36 +280,21 @@\n break;\n }\n }\n- d.decimal_point += n_trailing_zeros as i32;\n d.num_digits -= n_trailing_zeros;\n- d.decimal_point += d.num_digits as i32;\n if d.num_digits > DecimalSeq::MAX_DIGITS {\n d.truncated = true;\n d.num_digits = DecimalSeq::MAX_DIGITS;\n }\n }\n \n+ let mut explicit = 0;\n if let Some((&ch, s_next)) = s.split_first() {\n if ch == b'e' || ch == b'E' {\n s = s_next;\n- let mut neg_exp = false;\n- if let Some((&ch, s_next)) = s.split_first() {\n- neg_exp = ch == b'-';\n- if ch == b'-' || ch == b'+' {\n- s = s_next;\n- }\n- }\n- let mut exp_num = 0_i32;\n-\n- s.parse_digits(|digit| {\n- if exp_num < 0x10000 {\n- exp_num = 10 * exp_num + digit as i32;\n- }\n- });\n-\n- d.decimal_point += if neg_exp { -exp_num } else { exp_num };\n- }\n- }\n+ explicit = parse_scientific(&mut s).unwrap_or(0);\n+ }\n+ }\n+ d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);\n \n for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {\n d.digits[i] = 0;\n--- a/dec2flt/parse.rs\n+++ b/dec2flt/parse.rs\n@@ -70,7 +70,7 @@\n }\n \n /// Parse the scientific notation component of a float.\n-fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {\n+pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {\n let mut exponent = 0i64;\n let mut negative = false;\n \n@@ -85,8 +85,8 @@\n \n if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {\n *s_ref = s.parse_digits(|digit| {\n- // no overflows here, saturate well before overflow\n- if exponent < 0x10000 {\n+ // The largest the exponent can end up below is 10 * 2^59 - 1, so fits\n+ if exponent < (1_i64 << 59) {\n exponent = 10 * exponent + digit as i64;\n }\n });\n",
"result_source_digest": "2facae262ddc2236b9f5e41a1f36d42d39e04c515a8fd07169ce0614f714c735"
}proof_status
"requires_modeling_and_reproof"tests_are_proofs
falseretirement_is_proof
falsegeneration-0002/revision/reviews/998f214618f966d3636b4dccfbab7fed101cfb3a436fb57e502336e4b0c0c224/review.json
Exact captured recordnegated_goals
[
"dispatch_abstract_composition",
"dispatch_component_compliance",
"number_helper_acceptance",
"number_helper_rejection",
"parser_exact_rounding",
"parser_invalid_rejection",
"parser_numeric_acceptance",
"parser_totality",
"slow_accumulated_rounding"
]aggregate_diff
{
"base_source_digest": "3cab8073145562182e1519113544384487c4dbefdd05b05648fd5a8ed9514b3b",
"changes": [
{
"after": {
"byte_length": 15966,
"relative_path": "dec2flt/decimal_seq.rs",
"sha256_of_raw_bytes": "fd74e5a6a6ad8c7fe353f56f2ab931ede1e29fd357a194d36714326f56d88bde"
},
"before": {
"byte_length": 15819,
"relative_path": "dec2flt/decimal_seq.rs",
"sha256_of_raw_bytes": "c0c1c6028e3f57cefc3de7635a94788e9180f5ebcedc7a334ec8dbac786ec788"
},
"binary": false,
"operation": "modify",
"path": "dec2flt/decimal_seq.rs"
},
{
"after": {
"byte_length": 7241,
"relative_path": "dec2flt/parse.rs",
"sha256_of_raw_bytes": "1c012f0b700c949ed40ffb3e449aaa726ed7e2a958123f41866a9e63931a7c00"
},
"before": {
"byte_length": 7202,
"relative_path": "dec2flt/parse.rs",
"sha256_of_raw_bytes": "9daf21ab9445a84552535152f376eef8c30f3d5827296c0645f5952d3b22bbf1"
},
"binary": false,
"operation": "modify",
"path": "dec2flt/parse.rs"
},
{
"after": {
"byte_length": 3443,
"relative_path": "regression/bench.rs",
"sha256_of_raw_bytes": "17e4c8a633baa57d6adf0e9ca395a89ac4234d03a3cc354f53205ea653beeb9d"
},
"before": null,
"binary": false,
"operation": "add",
"path": "regression/bench.rs"
},
{
"after": {
"byte_length": 3397,
"relative_path": "regression/cases.rs",
"sha256_of_raw_bytes": "56f6f7faf18949908e114c52c69ace5d6ae009302fdfb881ea30a78da74d02a8"
},
"before": null,
"binary": false,
"operation": "add",
"path": "regression/cases.rs"
},
{
"after": {
"byte_length": 11477,
"relative_path": "regression/performance.py",
"sha256_of_raw_bytes": "0e06463fcf7ce7ddc4fd2c43ab66990b079bdd1bfb0b074c23c9445b08e76719"
},
"before": null,
"binary": false,
"operation": "add",
"path": "regression/performance.py"
},
{
"after": {
"byte_length": 21948,
"relative_path": "regression/run.py",
"sha256_of_raw_bytes": "62db0a127937ac52f4df3570675d6960afcdec666ccbb631dc4a4681709d2a58"
},
"before": null,
"binary": false,
"operation": "add",
"path": "regression/run.py"
},
{
"after": {
"byte_length": 764,
"relative_path": "regression/shim.rs",
"sha256_of_raw_bytes": "f8452909913cc180709b5d4e210db5ff0731f493cf1ce9dbe6151bbee65f774e"
},
"before": null,
"binary": false,
"operation": "add",
"path": "regression/shim.rs"
}
],
"patch": "--- a/dec2flt/decimal_seq.rs\n+++ b/dec2flt/decimal_seq.rs\n@@ -10,6 +10,7 @@\n //! available online: <https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html>.\n \n use dec2flt::common::{ByteSlice, is_8digits};\n+use dec2flt::parse::parse_scientific;\n \n use crate::num::imp::dec2flt;\n \n@@ -218,10 +219,27 @@\n }\n }\n \n+/// Combine source-valid counts before encoding an extreme point for the slow guards.\n+#[inline]\n+pub(super) fn final_decimal_point(\n+ significant_count: usize,\n+ fractional_count: usize,\n+ explicit: i64,\n+) -> i32 {\n+ if significant_count == 0 {\n+ return 0;\n+ }\n+ let base = significant_count as i64 - fractional_count as i64;\n+ base.saturating_add(explicit)\n+ .clamp(-(DecimalSeq::DECIMAL_POINT_RANGE as i64), DecimalSeq::DECIMAL_POINT_RANGE as i64)\n+ as i32\n+}\n+\n /// Parse a big integer representation of the float as a decimal.\n pub fn parse_decimal_seq(mut s: &[u8]) -> DecimalSeq {\n let mut d = DecimalSeq::default();\n let start = s;\n+ let mut fractional_count = 0;\n \n while let Some((&b'0', s_next)) = s.split_first() {\n s = s_next;\n@@ -248,9 +266,10 @@\n s = &s[8..];\n }\n s = s.parse_digits(|digit| d.try_add_digit(digit));\n- d.decimal_point = s.len() as i32 - first.len() as i32;\n- }\n-\n+ fractional_count = first.len() - s.len();\n+ }\n+\n+ let significant_count = d.num_digits;\n if d.num_digits != 0 {\n // Ignore the trailing zeros if there are any\n let mut n_trailing_zeros = 0;\n@@ -261,36 +280,21 @@\n break;\n }\n }\n- d.decimal_point += n_trailing_zeros as i32;\n d.num_digits -= n_trailing_zeros;\n- d.decimal_point += d.num_digits as i32;\n if d.num_digits > DecimalSeq::MAX_DIGITS {\n d.truncated = true;\n d.num_digits = DecimalSeq::MAX_DIGITS;\n }\n }\n \n+ let mut explicit = 0;\n if let Some((&ch, s_next)) = s.split_first() {\n if ch == b'e' || ch == b'E' {\n s = s_next;\n- let mut neg_exp = false;\n- if let Some((&ch, s_next)) = s.split_first() {\n- neg_exp = ch == b'-';\n- if ch == b'-' || ch == b'+' {\n- s = s_next;\n- }\n- }\n- let mut exp_num = 0_i32;\n-\n- s.parse_digits(|digit| {\n- if exp_num < 0x10000 {\n- exp_num = 10 * exp_num + digit as i32;\n- }\n- });\n-\n- d.decimal_point += if neg_exp { -exp_num } else { exp_num };\n- }\n- }\n+ explicit = parse_scientific(&mut s).unwrap_or(0);\n+ }\n+ }\n+ d.decimal_point = final_decimal_point(significant_count, fractional_count, explicit);\n \n for i in d.num_digits..DecimalSeq::MAX_DIGITS_WITHOUT_OVERFLOW {\n d.digits[i] = 0;\n--- a/dec2flt/parse.rs\n+++ b/dec2flt/parse.rs\n@@ -70,7 +70,7 @@\n }\n \n /// Parse the scientific notation component of a float.\n-fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {\n+pub(super) fn parse_scientific(s_ref: &mut &[u8]) -> Option<i64> {\n let mut exponent = 0i64;\n let mut negative = false;\n \n@@ -85,8 +85,8 @@\n \n if matches!(s.first(), Some(&x) if x.is_ascii_digit()) {\n *s_ref = s.parse_digits(|digit| {\n- // no overflows here, saturate well before overflow\n- if exponent < 0x10000 {\n+ // The pre-update cutoff permits one overshoot, bounded by 10 * 2^59 - 1.\n+ if exponent < (1_i64 << 59) {\n exponent = 10 * exponent + digit as i64;\n }\n });\n--- /dev/null\n+++ b/regression/bench.rs\n@@ -0,0 +1,96 @@\n+//! Offline timing only; construction, formatting and checksums are outside samples.\n+use crate::dec2flt;\n+use std::hint::black_box;\n+use std::io::{self, BufRead};\n+use std::time::Instant;\n+\n+const MIN_NS: u128 = 15_000_000;\n+\n+fn decode(s: &str) -> Vec<u8> {\n+ assert_eq!(s.len() % 2, 0);\n+ (0..s.len()).step_by(2)\n+ .map(|i| u8::from_str_radix(&s[i..i + 2], 16).unwrap()).collect()\n+}\n+\n+fn hash(s: &str) -> u64 {\n+ s.bytes().fold(0xcbf29ce484222325, |h, b| (h ^ b as u64).wrapping_mul(0x100000001b3))\n+}\n+\n+fn elapsed<F, I, R>(f: &F, input: I, iterations: u64) -> u128\n+where F: Fn(I) -> R, I: Copy {\n+ let start = Instant::now();\n+ for _ in 0..iterations {\n+ black_box(f(black_box(input)));\n+ }\n+ start.elapsed().as_nanos()\n+}\n+\n+fn samples<F, I, R>(name: &str, operation: &str, f: F, input: I, result: &str)\n+where F: Fn(I) -> R, I: Copy {\n+ println!(\"R\\t{name}\\t{operation}\\t{result}\");\n+ let checksum = hash(result);\n+ let mut iterations = 1_u64;\n+ // Calibration and warmup are discarded. Every retained sample is >=15ms.\n+ while elapsed(&f, input, iterations) < MIN_NS {\n+ iterations = iterations.checked_mul(2).unwrap();\n+ assert!(iterations < (1_u64 << 50));\n+ }\n+ for sample in 0..5 {\n+ let mut ns = elapsed(&f, input, iterations);\n+ while ns < MIN_NS {\n+ iterations = iterations.checked_mul(2).unwrap();\n+ assert!(iterations < (1_u64 << 50));\n+ ns = elapsed(&f, input, iterations);\n+ }\n+ println!(\"S\\t{name}\\t{operation}\\t{sample}\\t{iterations}\\t{ns}\\t{checksum:016x}\");\n+ }\n+}\n+\n+#[inline(never)]\n+fn public(input: &str) -> Result<f64, crate::num::ParseFloatError> {\n+ dec2flt::dec2flt::<f64>(input)\n+}\n+\n+#[inline(never)]\n+fn number(input: &[u8]) -> Option<dec2flt::decimal::Decimal> {\n+ dec2flt::parse::parse_number(input)\n+}\n+\n+#[inline(never)]\n+fn sequence(input: &[u8]) -> dec2flt::decimal_seq::DecimalSeq {\n+ dec2flt::decimal_seq::parse_decimal_seq(input)\n+}\n+\n+#[inline(never)]\n+fn slow(input: &[u8]) -> dec2flt::common::BiasedFp {\n+ dec2flt::slow::parse_long_mantissa::<f64>(input)\n+}\n+\n+pub fn run() {\n+ let inputs: Vec<_> = io::stdin().lock().lines().map(|line| {\n+ let line = line.unwrap();\n+ let (name, hex) = line.split_once('\\t').unwrap();\n+ (name.to_owned(), decode(hex))\n+ }).collect();\n+ for (name, input) in inputs {\n+ assert!(!input.is_empty());\n+ let text = std::str::from_utf8(&input).unwrap();\n+ let value = match public(text) {\n+ Ok(f) => format!(\"{:016x}\", f.to_bits()),\n+ Err(e) => format!(\"ERR:{:?}\", e.kind),\n+ };\n+ samples(&name, \"public\", public, text, &value);\n+ let value = match number(&input) {\n+ Some(d) => format!(\"{},{},{},{}\", d.mantissa, d.exponent, d.negative, d.many_digits),\n+ None => \"NONE\".into(),\n+ };\n+ samples(&name, \"parse_number\", number, input.as_slice(), &value);\n+ let d = sequence(&input);\n+ let digits: String = d.digits[..d.num_digits].iter().map(|d| char::from(b'0' + d)).collect();\n+ let value = format!(\"{},{},{},{}\", d.num_digits, d.decimal_point, d.truncated, digits);\n+ samples(&name, \"parse_decimal_seq\", sequence, input.as_slice(), &value);\n+ let fp = slow(&input);\n+ let value = format!(\"{:016x},{},{}\", dec2flt::regression_assemble(fp).to_bits(), fp.m, fp.p_biased);\n+ samples(&name, \"slow\", slow, input.as_slice(), &value);\n+ }\n+}\n--- /dev/null\n+++ b/regression/cases.rs\n@@ -0,0 +1,68 @@\n+//! Probe only: expected values and all assertions live in the independent driver.\n+use std::io::{self, BufRead};\n+use crate::dec2flt;\n+\n+fn decode(s: &str) -> Vec<u8> {\n+ assert_eq!(s.len() % 2, 0);\n+ (0..s.len()).step_by(2)\n+ .map(|i| u8::from_str_radix(&s[i..i + 2], 16).unwrap()).collect()\n+}\n+\n+fn bits(v: Option<f64>) -> String {\n+ v.map_or_else(|| \"NONE\".into(), |f| format!(\"{:016x}\", f.to_bits()))\n+}\n+\n+pub fn run() {\n+ for line in io::stdin().lock().lines() {\n+ let line = line.unwrap();\n+ let fields: Vec<_> = line.split('\\t').collect();\n+ match fields[0] {\n+ \"N\" => {\n+ let bytes = decode(fields[1]);\n+ // The numeric helper's specified domain is nonempty slices.\n+ let record = if bytes.is_empty() { None } else {\n+ dec2flt::parse::parse_number(&bytes)\n+ };\n+ let h = record.map_or_else(|| \"NONE\".into(), |d| {\n+ format!(\"{},{},{},{}\", d.mantissa, d.exponent, d.negative, d.many_digits)\n+ });\n+ let public = match std::str::from_utf8(&bytes) {\n+ Ok(s) => match dec2flt::dec2flt::<f64>(s) {\n+ Ok(f) => format!(\"{:016x}\", f.to_bits()),\n+ Err(e) => format!(\"ERR:{:?}\", e.kind),\n+ },\n+ Err(_) => \"UTF8\".into(),\n+ };\n+ let special_pos = bits(dec2flt::parse::parse_inf_nan::<f64>(&bytes, false));\n+ let special_neg = bits(dec2flt::parse::parse_inf_nan::<f64>(&bytes, true));\n+ let (slow, seq, endpoints) = if let Some(d) = record {\n+ let fp = dec2flt::slow::parse_long_mantissa::<f64>(&bytes);\n+ let slow = dec2flt::regression_assemble(fp);\n+ let seq = dec2flt::decimal_seq::parse_decimal_seq(&bytes);\n+ let digits: String = seq.digits[..seq.num_digits].iter()\n+ .map(|d| char::from(b'0' + d)).collect();\n+ let a = dec2flt::lemire::compute_float::<f64>(d.exponent, d.mantissa);\n+ let b = dec2flt::lemire::compute_float::<f64>(d.exponent, d.mantissa + 1);\n+ (format!(\"{:016x}\", slow.to_bits()),\n+ format!(\"{},{},{},{}\", seq.num_digits, seq.decimal_point, seq.truncated, digits),\n+ format!(\"{},{},{},{}\", a.m, a.p_biased, b.m, b.p_biased))\n+ } else { (\"NONE\".into(), \"NONE\".into(), \"NONE\".into()) };\n+ println!(\"N\\t{h}\\t{public}\\t{special_pos}\\t{special_neg}\\t{slow}\\t{seq}\\t{endpoints}\");\n+ }\n+ #[cfg(has_final_point)]\n+ \"C\" => {\n+ let sig: usize = fields[1].parse().unwrap();\n+ let frac: usize = fields[2].parse().unwrap();\n+ let mut suffix = fields[4].as_bytes();\n+ let explicit = if suffix == b\"ABSENT\" { Some(0) } else {\n+ dec2flt::parse::parse_scientific(&mut suffix)\n+ };\n+ if let Some(e) = explicit {\n+ let point = dec2flt::decimal_seq::final_decimal_point(sig, frac, e);\n+ println!(\"C\\t{e}\\t{point}\\t{}\", suffix.len());\n+ } else { println!(\"C\\tNONE\\t{}\", suffix.len()); }\n+ }\n+ _ => panic!(\"unsupported probe operation\"),\n+ }\n+ }\n+}\n--- /dev/null\n+++ b/regression/performance.py\n@@ -0,0 +1,224 @@\n+#!/usr/bin/env python3\n+\"\"\"Dependency-free measured comparisons; no timing tolerance implies acceptance.\"\"\"\n+import argparse\n+import hashlib\n+import json\n+import os\n+from pathlib import Path\n+import re\n+import statistics\n+import subprocess\n+import sys\n+import tempfile\n+import time\n+\n+import run\n+\n+OPERATIONS = (\"public\", \"parse_number\", \"parse_decimal_seq\", \"slow\")\n+\n+\n+def inputs():\n+ midpoint = b\"1.00000000000000011102230246251565404236316680908203125\"\n+ result = [\n+ (\"short_integer\", b\"12345\"), (\"short_fraction\", b\"12.345\"),\n+ (\"short_exponent\", b\"1.2345e12\"), (\"short_leading_zero\", b\"000000000000001.25\"),\n+ (\"ordinary_17_digit\", b\"12345678901234567\"),\n+ (\"many_digit\", b\"1234567890123456789012345678901234567890e-20\"),\n+ (\"subnormal\", b\"2.2250738585072011e-308\"), (\"midpoint_fallback\", midpoint),\n+ (\"special_inf\", b\"infinity\"), (\"special_nan\", b\"-NaN\"),\n+ (\"invalid_short\", b\"1e+x\"), (\"invalid_nonascii\", b\"1\\xc3\\xa9\"),\n+ ]\n+ for n, label in ((65536, \"64KiB\"), (1048576, \"1MiB\")):\n+ result.extend([\n+ (\"leading_zero_\" + label, b\"0\" * n + b\"1.25\"),\n+ (\"leading_zero_cancel_\" + label, b\"0.\" + b\"0\" * n + b\"1e\" + str(n + 1).encode()),\n+ (\"trailing_zero_\" + label, b\"1\" + b\"0\" * n + b\"e-\" + str(n).encode()),\n+ (\"nonzero_integer_\" + label, b\"1\" * n),\n+ (\"nonzero_fraction_\" + label, b\"0.\" + b\"1\" * n),\n+ (\"long_tail_\" + label, midpoint + b\"0\" * n + b\"1\"),\n+ (\"padded_finite_fallback_\" + label, b\"0.\" + b\"0\" * 11 + b\"1000000000000000080\" + b\"0\" * n),\n+ ])\n+ for n in (1024, 65536):\n+ for sign in (b\"\", b\"-\"):\n+ label = str(n) + (\"_negative\" if sign else \"_positive\")\n+ result.append((\"saturated_exponent_\" + label, b\"1e\" + sign + b\"9\" * n))\n+ result.append((\"invalid_saturated_\" + label, b\"1e\" + sign + b\"9\" * n + b\"x\"))\n+ return result\n+\n+\n+def fnv(text):\n+ value = 0xcbf29ce484222325\n+ for byte in text.encode():\n+ value = ((value ^ byte) * 0x100000001b3) & ((1 << 64) - 1)\n+ return f\"{value:016x}\"\n+\n+\n+def source_digest(root):\n+ digest = hashlib.sha256()\n+ for relative in [Path(\"traits.rs\"), *(p.relative_to(root) for p in sorted((root / \"dec2flt\").glob(\"*.rs\")))]:\n+ digest.update(str(relative).encode() + b\"\\0\" + (root / relative).read_bytes())\n+ return digest.hexdigest()\n+\n+\n+def affinity():\n+ available = sorted(os.sched_getaffinity(0)) if hasattr(os, \"sched_getaffinity\") else []\n+ if available:\n+ os.sched_setaffinity(0, {2 if 2 in available else available[0]})\n+ return sorted(os.sched_getaffinity(0)) if available else []\n+\n+\n+def parse_output(output, data):\n+ records = {(name, op): {\"name\": name, \"operation\": op, \"samples\": []}\n+ for name, _ in data for op in OPERATIONS}\n+ for line in output.splitlines():\n+ row = line.split(\"\\t\")\n+ if len(row) < 3 or (row[1], row[2]) not in records:\n+ raise RuntimeError(\"malformed or unexpected benchmark row\")\n+ record = records[row[1], row[2]]\n+ if row[0] == \"R\" and len(row) == 4 and \"result\" not in record:\n+ value, operation = row[3], row[2]\n+ if operation == \"public\":\n+ valid = re.fullmatch(r\"[0-9a-f]{16}|ERR:(Empty|Invalid)\", value)\n+ elif operation == \"parse_number\":\n+ valid = re.fullmatch(r\"NONE|[0-9]+,-?[0-9]+,(true|false),(true|false)\", value)\n+ if valid and value != \"NONE\":\n+ m, q, negative, _ = value.split(\",\")\n+ valid = int(m) < 10 ** 19 and run.MIN <= int(q) <= run.MAX and negative == \"false\"\n+ elif operation == \"parse_decimal_seq\":\n+ valid = re.fullmatch(r\"[0-9]+,-?[0-9]+,(true|false),[0-9]*\", value)\n+ if valid:\n+ n, point, _, digits = value.split(\",\")\n+ valid = int(n) == len(digits) <= 768 and -(1 << 31) <= int(point) < (1 << 31)\n+ else:\n+ valid = re.fullmatch(r\"[0-9a-f]{16},[0-9]+,-?[0-9]+\", value)\n+ if valid:\n+ bits, m, exponent = value.split(\",\")\n+ valid = (0 <= int(m) < (1 << 64) and 0 <= int(exponent) <= 2047\n+ and int(bits, 16) == int(m) | (int(exponent) << 52))\n+ if not valid:\n+ raise RuntimeError(\"malformed benchmark result\")\n+ record[\"result\"] = row[3]\n+ record[\"checksum\"] = fnv(row[3])\n+ elif row[0] == \"S\" and len(row) == 7:\n+ index, iterations, ns = map(int, row[3:6])\n+ if (index != len(record[\"samples\"]) or index >= 5 or iterations <= 0\n+ or ns < 15_000_000 or row[6] != record.get(\"checksum\")):\n+ raise RuntimeError(\"invalid calibrated benchmark sample\")\n+ record[\"samples\"].append({\"iterations\": iterations, \"elapsed_ns\": ns,\n+ \"ns_per_operation\": ns / iterations})\n+ else:\n+ raise RuntimeError(\"malformed or duplicate benchmark row\")\n+ for record in records.values():\n+ if \"result\" not in record or len(record[\"samples\"]) != 5:\n+ raise RuntimeError(\"missing benchmark regime, operation or samples\")\n+ samples = [s[\"ns_per_operation\"] for s in record[\"samples\"]]\n+ record.update(median_ns=statistics.median(samples), min_ns=min(samples), max_ns=max(samples))\n+ return list(records.values())\n+\n+\n+def measure(args, selected=None):\n+ data = inputs()\n+ if selected is not None:\n+ data = [(name, value) for name, value in data if name in selected]\n+ if set(selected) != {name for name, _ in data}:\n+ raise RuntimeError(\"unknown repeat regime\")\n+ cpu = affinity()\n+ version = subprocess.run([str(args.rustc), \"-Vv\"], capture_output=True, text=True,\n+ timeout=30, check=True)\n+ root = args.source.resolve()\n+ evidence = {\"source\": str(root), \"source_digest\": source_digest(root),\n+ \"compiler\": str(args.rustc), \"compiler_version\": version.stdout,\n+ \"compiler_version_stderr\": version.stderr, \"cpu_affinity\": cpu,\n+ \"platform\": dict(zip((\"sysname\", \"nodename\", \"release\", \"version\", \"machine\"), os.uname())),\n+ \"overflow_checks\": args.overflow_checks,\n+ \"opt_level\": 3, \"debug_assertions\": \"on\", \"minimum_sample_ms\": 15,\n+ \"samples_per_operation\": 5, \"utc_epoch\": time.time(),\n+ \"inputs\": [{\"name\": name, \"length\": len(value), \"sha256\": hashlib.sha256(value).hexdigest()}\n+ for name, value in data], \"routes\": []}\n+ payload = \"\\n\".join(name + \"\\t\" + value.hex() for name, value in data) + \"\\n\"\n+ args.scratch.mkdir(parents=True, exist_ok=True)\n+ with tempfile.TemporaryDirectory(prefix=\"performance-\", dir=args.scratch) as temporary:\n+ out = Path(temporary)\n+ run.copy_source(root, out, Path(__file__).resolve().parent)\n+ for route in (\"ordinary\", \"optimize_for_size\"):\n+ executable = out / route\n+ command = [str(args.rustc), \"--edition=2018\", str(out / \"shim.rs\"), \"-o\", str(executable),\n+ \"-C\", \"opt-level=3\", \"-C\", \"debug-assertions=on\",\n+ \"-C\", \"overflow-checks=\" + args.overflow_checks, \"--cfg\", \"performance\"]\n+ if route == \"optimize_for_size\":\n+ command.extend([\"--cfg\", 'feature=\"optimize_for_size\"'])\n+ build = subprocess.run(command, capture_output=True, text=True, timeout=120)\n+ print(f\"PERFORMANCE_COMPILE route={route} exit={build.returncode}\", flush=True)\n+ if build.returncode:\n+ raise RuntimeError(f\"benchmark compilation failed: {build.stdout}\\n{build.stderr}\")\n+ process = subprocess.run([str(executable)], input=payload, capture_output=True,\n+ text=True, timeout=3600)\n+ print(f\"PERFORMANCE_PROCESS route={route} exit={process.returncode}\", flush=True)\n+ if process.returncode or process.stderr:\n+ raise RuntimeError(f\"benchmark execution failed: {process.returncode} {process.stderr}\")\n+ evidence[\"routes\"].append({\"route\": route, \"command\": command,\n+ \"compiler_exit\": build.returncode, \"compiler_stdout\": build.stdout,\n+ \"compiler_stderr\": build.stderr, \"process_exit\": process.returncode,\n+ \"process_stderr\": process.stderr, \"records\": parse_output(process.stdout, data)})\n+ if source_digest(root) != evidence[\"source_digest\"]:\n+ raise RuntimeError(\"source changed during benchmark\")\n+ return evidence\n+\n+\n+def single(args):\n+ evidence = measure(args)\n+ print(\"PERFORMANCE_JSON \" + json.dumps(evidence, separators=(\",\", \":\")), flush=True)\n+ return 0\n+\n+\n+def paired(args):\n+ all_runs, pairs = [], []\n+ for round_index in range(args.rounds):\n+ pair = {}\n+ for label in ((\"baseline\", \"candidate\") if round_index % 2 == 0 else (\"candidate\", \"baseline\")):\n+ args.source = args.baseline if label == \"baseline\" else args.candidate\n+ evidence = measure(args, args.regimes)\n+ evidence.update(label=label, paired_round=round_index)\n+ all_runs.append(evidence)\n+ pair[label] = {(route[\"route\"], r[\"name\"], r[\"operation\"]): r\n+ for route in evidence[\"routes\"] for r in route[\"records\"]}\n+ if pair[\"baseline\"].keys() != pair[\"candidate\"].keys():\n+ raise RuntimeError(\"unpaired benchmark keys\")\n+ pairs.append([{ \"route\": key[0], \"name\": key[1], \"operation\": key[2],\n+ \"baseline_ns\": pair[\"baseline\"][key][\"median_ns\"],\n+ \"candidate_ns\": pair[\"candidate\"][key][\"median_ns\"],\n+ \"ratio\": pair[\"candidate\"][key][\"median_ns\"] / pair[\"baseline\"][key][\"median_ns\"]}\n+ for key in pair[\"baseline\"]])\n+ comparisons = []\n+ for rows in zip(*pairs, strict=True):\n+ comparisons.append({\"route\": rows[0][\"route\"], \"name\": rows[0][\"name\"],\n+ \"operation\": rows[0][\"operation\"], \"pairs\": list(rows),\n+ \"median_ratio\": statistics.median(r[\"ratio\"] for r in rows),\n+ \"ratio_min\": min(r[\"ratio\"] for r in rows),\n+ \"ratio_max\": max(r[\"ratio\"] for r in rows)})\n+ print(\"PAIRED_PERFORMANCE_JSON \" + json.dumps({\"runs\": all_runs, \"comparisons\": comparisons},\n+ separators=(\",\", \":\")), flush=True)\n+ return 0\n+\n+\n+def main():\n+ parser = argparse.ArgumentParser()\n+ parser.add_argument(\"--baseline\", type=Path, required=True)\n+ parser.add_argument(\"--candidate\", type=Path, required=True)\n+ parser.add_argument(\"--scratch\", type=Path, required=True)\n+ parser.add_argument(\"--rustc\", type=Path, required=True)\n+ parser.add_argument(\"--overflow-checks\", choices=(\"on\", \"off\"), required=True)\n+ parser.add_argument(\"--rounds\", type=int, default=2)\n+ parser.add_argument(\"--regimes\", nargs=\"+\")\n+ args = parser.parse_args()\n+ if args.rounds < 2:\n+ raise RuntimeError(\"paired measurements require both alternating orders\")\n+ return paired(args)\n+\n+\n+if __name__ == \"__main__\":\n+ try:\n+ sys.exit(main())\n+ except (OSError, subprocess.SubprocessError, RuntimeError, ValueError, AssertionError) as error:\n+ print(f\"PERFORMANCE_FAILURE {type(error).__name__}: {error}\", file=sys.stderr)\n+ sys.exit(6)\n--- /dev/null\n+++ b/regression/run.py\n@@ -0,0 +1,438 @@\n+#!/usr/bin/env python3\n+\"\"\"Offline source-copy shim, independent grammar and exact-integer test oracles.\"\"\"\n+import argparse\n+import hashlib\n+import itertools\n+from pathlib import Path\n+import random\n+import re\n+import subprocess\n+import sys\n+import tempfile\n+\n+MIN, MAX = -(1 << 63), (1 << 63) - 1\n+T = 1 << 59\n+A, B = 6 * T, T - 2048\n+INF, SIGN = 0x7FF0000000000000, 1 << 63\n+NUMERIC = re.compile(rb\"(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?\")\n+SPECIAL = re.compile(rb\"(?:inf|infinity|nan)\", re.I)\n+\n+\n+def numeric(body):\n+ return NUMERIC.fullmatch(body) is not None\n+\n+\n+def parts(body):\n+ mantissa, *exponent = re.split(rb\"[eE]\", body)\n+ explicit = int(exponent[0]) if exponent else 0\n+ integer, *fraction = mantissa.split(b\".\")\n+ frac = fraction[0] if fraction else b\"\"\n+ significant = (integer + frac).lstrip(b\"0\")\n+ return significant, len(frac), explicit\n+\n+\n+def accumulated_exponent(suffix):\n+ \"\"\"Independent unbounded-integer reference for the source pre-update fold.\"\"\"\n+ negative = suffix.startswith(b\"-\")\n+ if suffix[:1] in (b\"+\", b\"-\"):\n+ suffix = suffix[1:]\n+ match = re.match(rb\"[0-9]+\", suffix)\n+ if match is None:\n+ return None, len(suffix)\n+ magnitude = 0\n+ for digit in match[0]:\n+ if magnitude < T:\n+ magnitude = 10 * magnitude + digit - 48\n+ return -magnitude if negative else magnitude, len(suffix) - len(match[0])\n+\n+\n+def round_ratio(n, d):\n+ \"\"\"Binary64 nearest-even magnitude, using only integer comparisons/division.\"\"\"\n+ if n == 0:\n+ return 0\n+ e = n.bit_length() - d.bit_length()\n+ below = n < (d << e) if e >= 0 else (n << -e) < d\n+ if below:\n+ e -= 1\n+ if e >= 1024:\n+ return INF\n+ shift = 1074 if e < -1022 else 52 - e\n+ a, b = (n << shift, d) if shift >= 0 else (n, d << -shift)\n+ q, r = divmod(a, b)\n+ q += (2 * r > b) or (2 * r == b and q % 2 != 0)\n+ if e < -1022:\n+ return q\n+ if q == 1 << 53:\n+ q >>= 1\n+ e += 1\n+ return INF if e == 1024 else ((e + 1023) << 52) | (q - (1 << 52))\n+\n+\n+def exact_bits(body, diagnostic=False):\n+ significant, frac, explicit = parts(body)\n+ if diagnostic and re.search(rb\"[eE]\", body):\n+ explicit, _ = accumulated_exponent(re.split(rb\"[eE]\", body)[1])\n+ if not significant:\n+ return 0\n+ point = len(significant) - frac + explicit\n+ if point >= 310:\n+ return INF\n+ if point < -324:\n+ return 0\n+ trimmed = significant.rstrip(b\"0\")\n+ exponent = explicit - frac + len(significant) - len(trimmed)\n+ coefficient = int(trimmed)\n+ n, d = (coefficient * 10 ** exponent, 1) if exponent >= 0 else (coefficient, 10 ** -exponent)\n+ return round_ratio(n, d)\n+\n+\n+def numeric_cases():\n+ alphabet = [b\"0\", b\"1\", b\".\", b\"e\", b\"E\", b\"+\", b\"-\", b\"x\", b\"\\xff\"]\n+ cases = [b\"\"]\n+ for length in range(1, 5):\n+ cases.extend(b\"\".join(c) for c in itertools.product(alphabet, repeat=length))\n+ for word in (\"inf\", \"infinity\", \"nan\"):\n+ for letters in itertools.product(*[(c.lower(), c.upper()) for c in word]):\n+ for sign in (\"\", \"+\", \"-\"):\n+ cases.append((sign + \"\".join(letters)).encode())\n+ for text in (\"\\u00e9\", \"1\\u00e9\", \"\\u0661\", \"\\uff11\", \"1\\u00a0\", \"\\u22121\", \"\\u00001\", \" 1\", \"1\\n\"):\n+ cases.append(text.encode())\n+ rng = random.Random(0xDEC2F64)\n+ for _ in range(1000):\n+ cases.append(bytes(rng.choice(b\"0123456789.eE+-x \\x00\\xff\") for _ in range(rng.randrange(1, 50))))\n+ integer = bytes(rng.choice(b\"0123456789\") for _ in range(rng.randrange(1, 80)))\n+ frac = bytes(rng.choice(b\"0123456789\") for _ in range(rng.randrange(0, 90)))\n+ body = integer + b\".\" + frac + b\"e\" + str(rng.randrange(-400, 401)).encode()\n+ cases.extend([body, b\"+\" + body, b\"-\" + body])\n+ cases.extend(x.encode() for x in (\n+ \"9007199254740993\", \"9007199254740995\", \"1.7976931348623157e308\",\n+ \"1.7976931348623159e308\", \"2.2250738585072014e-308\", \"2.2250738585072011e-308\",\n+ \"5e-324\", \"2e-324\", \"3e-324\", \"1e309\", \"1e-400\", \"12345678901234567890.00001\",\n+ ))\n+ # Exact dyadic midpoints and their two decimal neighbors. Powers of five\n+ # turn dyadic rationals into decimal literals without a floating oracle.\n+ for n, k in ((1, 1075), (3, 1075), (5, 1075), ((1 << 53) - 1, 1075),\n+ ((1 << 53) + 1, 53), ((1 << 53) + 3, 53)):\n+ decimal_coefficient = n * 5 ** k\n+ for delta in (-1, 0, 1):\n+ body = str(decimal_coefficient + delta).encode() + b\"e-\" + str(k).encode()\n+ cases.extend([body, b\"-\" + body])\n+ overflow_midpoint = (1 << 1024) - (1 << 970)\n+ for delta in (-1, 0, 1):\n+ cases.append(str(overflow_midpoint + delta).encode())\n+ midpoint = b\"1.00000000000000011102230246251565404236316680908203125\"\n+ cases.extend([midpoint, midpoint + b\"0\" * 1200 + b\"1\",\n+ b\"1.\" + b\"0\" * 1200 + b\"1\", b\"1.\" + b\"0\" * 1200])\n+ for padding in (0, 769, 10000, 65536):\n+ body = b\"0.\" + b\"0\" * 11 + b\"1000000000000000080\" + b\"0\" * padding\n+ cases.extend([body, b\"-\" + body])\n+ for prefix in (b\"1e\", b\"1.e+\", b\".1E-\", b\"0e\", b\"-0e\"):\n+ cases.extend([prefix + b\"9\" * 256, prefix + b\"9\" * 256 + b\"x\",\n+ prefix + b\"9\" * 256 + b\".0\", prefix + b\"9\" * 256 + b\"\\xff\"])\n+ for e in (MIN - 1, MIN, MIN + 1, MAX - 1, MAX, MAX + 1):\n+ for base in (b\"1\", b\"0.0001\", b\"100000000000000000000\", b\"0\", b\"-0\"):\n+ cases.append(base + b\"e\" + str(e).encode())\n+ return cases\n+\n+\n+def cutoff_cases():\n+ witness = b\"0.\" + b\"0\" * 65535 + b\"1e655360\"\n+ assert len(witness) == 65545\n+ cases = [(\"formal_wrong_one\", witness, INF),\n+ (\"signed_formal_wrong_one\", b\"-\" + witness, INF | SIGN),\n+ (\"cutoff_control_one\", b\"0.\" + b\"0\" * 65535 + b\"1e65536\", 0x3FF0000000000000),\n+ (\"negative_exponent_cancellation\", b\"1\" + b\"0\" * 655360 + b\"e-655360\", 0x3FF0000000000000)]\n+ for e in (65535, 65536, 65537, 655359, 655360, 655361,\n+ T - 1, T, T + 1, 10 * T - 1, 10 * T, MAX, MAX + 1, MIN):\n+ body = b\"0.\" + b\"0\" * 65535 + b\"1e\" + str(e).encode()\n+ # Derived decimal order: 10^(E-65536).\n+ expected = INF if e - 65536 >= 310 else exact_bits(body)\n+ cases.append((f\"transition_{e}\", body, expected))\n+ negbody = b\"1e-\" + str(abs(e)).encode()\n+ cases.append((f\"negative_transition_{e}\", negbody, exact_bits(negbody)))\n+ for sign in (b\"\", b\"-\"):\n+ for e in (b\"9\" * 256, b\"-\" + b\"9\" * 256):\n+ cases.append((f\"zero_{sign!r}_{e[:2]!r}\", sign + b\"0.000e\" + e, SIGN if sign else 0))\n+ cases.append((f\"huge_{sign!r}_{e[:2]!r}\", sign + b\"1e\" + e,\n+ (0 if e.startswith(b\"-\") else INF) | (SIGN if sign else 0)))\n+ for junk in (b\"x\", b\".0\", b\"+\", b\"\\xff\", b\"\\xc3\\xa9\"):\n+ body = b\"1e\" + b\"9\" * 1024 + junk\n+ cases.append((f\"saturated_junk_{junk!r}\", body,\n+ \"ERR:Invalid\" if junk != b\"\\xff\" else \"UTF8\"))\n+ return cases\n+\n+\n+def count_cases():\n+ cases = []\n+ boundaries = [(1 << 31) - 1, 1 << 31, (1 << 31) + 1,\n+ (1 << 32) - 1, 1 << 32, (1 << 32) + 1, MAX - 128]\n+ for n in boundaries:\n+ cases.extend([(f\"ones_{n}\", n, 0, 0, \"ABSENT\"),\n+ (f\"fractional_cancel_{n}\", n - 11, n, n - 30, \"ABSENT\"),\n+ (f\"terminal_zero_{n}\", n - 11, n, n - 29, \"ABSENT\"),\n+ (f\"negative_cancel_{n}\", n, 0, 0, str(19 - n)),\n+ (f\"leading_zero_cancel_{n}\", 1, n, 0, str(n)),\n+ (f\"trailing_zero_cancel_{n}\", n, n, n - 1, str(n - 1))])\n+ # The historical i64 witness lies outside A. Do not execute or allocate it.\n+ cases.append((\"source_max_ones\", MAX, 0, 0, \"ABSENT\"))\n+ for sig, frac, trail in ((1, 0, 0), (19, 19, 0), (MAX - 128, 0, MAX - 129),\n+ (1, MAX - 128, 0), (MAX - 150, MAX - 128, MAX - 170)):\n+ base = sig - frac\n+ for e in (-base, -base - 325, -base + 309,\n+ T - 1, T, T + 1, 10 * T - 1, 10 * T, 10 ** 100, -(10 ** 100)):\n+ cases.append((f\"bounds_{sig}_{frac}_{e}\", sig, frac, trail, str(e)))\n+ for point in (-(1 << 31) - 1, -(1 << 31), -(1 << 31) + 1, (1 << 31) - 1, 1 << 31,\n+ -2048, -2047, -2046, 2046, 2047, 2048):\n+ cases.append((f\"point_narrow_{point}\", 1, 0, 0, str(point - 1)))\n+ cases.extend([(\"zero_huge\", 0, MAX - 128, 0, \"9\" * 100),\n+ (\"saturated_suffix\", 1, 0, 0, \"9\" * 100 + \"x\"),\n+ (\"malformed_empty\", 1, 0, 0, \"\"),\n+ (\"malformed_sign\", 1, 0, 0, \"-\"),\n+ (\"malformed_double_sign\", 1, 0, 0, \"--1\"),\n+ (\"zero_max\", 0, MAX - 128, 0, \"ABSENT\")])\n+ for magnitude in (T - 1, T, T + 1, 10 * T - 1, 10 * T, 10 ** 100):\n+ for sign in (\"\", \"+\", \"-\"):\n+ for tail in (\"\", \"9\", \"999x\", \"999.0\", \"999+\", \"999\\u00e9\"):\n+ cases.append((f\"fold_{sign}{magnitude}_{tail}\", 1, 0, 0,\n+ sign + str(magnitude) + tail))\n+ for point in (-325, -11, 0, 19, 309):\n+ for sign in (-1, 1):\n+ exponent = sign * (T - 1)\n+ sig, frac = (T - 1 + point, 0) if sign < 0 else (1, T - point)\n+ cases.append((f\"large_finite_cancellation_{point}_{sign}\", sig, frac, 0, str(exponent)))\n+ for name, sig, frac, trail, e in cases:\n+ assert 0 <= trail <= sig\n+ assert max(sig, frac) + (1 if frac else 0) + (0 if e == \"ABSENT\" else len(e) + 1) <= MAX, name\n+ return cases\n+\n+\n+def check_counts(cases, rows):\n+ assert A + (10 * T - 1) == MAX\n+ assert T - B == 2048 and T - B >= 310 and B - T < -324\n+ print(f\"DOMAIN_ARITHMETIC A={A} B={B} T={T} overshoot_bound={10*T-1} margin=2048\")\n+ print(\"HISTORICAL_I64_WITNESS fractional_count=9223372036854120450 outside_A=true native_execution=false repaired=false\")\n+ for (name, sig, frac, trail, suffix), row in zip(cases, rows, strict=True):\n+ if suffix == \"ABSENT\":\n+ explicit, remaining = 0, len(suffix)\n+ else:\n+ explicit, remaining = accumulated_exponent(suffix.encode())\n+ if explicit is None:\n+ assert row == [\"C\", \"NONE\", str(remaining)], (name, row)\n+ continue\n+ point = sig - frac + explicit if sig else 0\n+ point = min(2047, max(-2047, point))\n+ expected = [\"C\", str(explicit), str(point), str(remaining)]\n+ assert row == expected, (name, row, expected)\n+ if name == \"fractional_cancel_2147483648\":\n+ assert point == -11\n+ if name == \"ones_2147483648\":\n+ assert point >= 310, (\"infinity guard\", name, row)\n+ if name in (\"fractional_cancel_2147483648\", \"ones_2147483648\"):\n+ print(f\"COUNT_WITNESS case={name} bounded_E={explicit} point={point}\")\n+ print(f\"COUNT_BOUNDARIES_OK cases={len(cases)} arbitrary_precision_reference=true\")\n+\n+\n+def count_scan_cases():\n+ cases = [b\"0.000e\" + b\"9\" * 256, b\"000001.25000\", b\"0.00000001\",\n+ b\"1.\" + b\"1\" * 767, b\"1.\" + b\"1\" * 768,\n+ b\"1.\" + b\"0\" * 1200, b\"1.\" + b\"0\" * 1200 + b\"1\"]\n+ for padding in (769, 10000, 65536):\n+ cases.append(b\"0.\" + b\"0\" * 11 + b\"1000000000000000080\" + b\"0\" * padding)\n+ return cases\n+\n+\n+def check_preservation(cases, rows):\n+ fallback_padding = 0\n+ for data, row in zip(cases, rows, strict=True):\n+ assert row[0] == \"N\" and len(row) == 8, row\n+ label = repr(data[:100]) + f\" length={len(data)}\"\n+ unsigned = numeric(data)\n+ assert (row[1] != \"NONE\") == unsigned, (\"helper grammar\", label, row)\n+ body = data[1:] if data[:1] in (b\"+\", b\"-\") else data\n+ negative = data[:1] == b\"-\"\n+ valid_numeric = numeric(body)\n+ special = SPECIAL.fullmatch(body) is not None\n+ try:\n+ data.decode(\"utf-8\")\n+ except UnicodeDecodeError:\n+ assert row[2] == \"UTF8\", (label, row)\n+ else:\n+ if valid_numeric:\n+ expected = exact_bits(body) | (SIGN if negative else 0)\n+ assert row[2] == f\"{expected:016x}\", (\"public rounding\", label, row[2], hex(expected))\n+ assert int(row[2], 16) & SIGN == (SIGN if negative else 0)\n+ assert int(row[2], 16) & ~SIGN <= INF\n+ elif special:\n+ actual = int(row[2], 16)\n+ if body.lower() == b\"nan\":\n+ assert actual & ~SIGN > INF, (\"NaN\", label, row)\n+ else:\n+ assert actual == INF | (SIGN if negative else 0), (\"infinity\", label, row)\n+ else:\n+ assert row[2] == (\"ERR:Empty\" if not data else \"ERR:Invalid\"), (\"public grammar\", label, row)\n+ for sign, cell in ((False, row[3]), (True, row[4])):\n+ if SPECIAL.fullmatch(data):\n+ actual = int(cell, 16)\n+ assert (actual & ~SIGN > INF) if data.lower() == b\"nan\" else (actual == INF | (SIGN if sign else 0)), (label, cell)\n+ else:\n+ assert cell == \"NONE\", (\"special rejection\", label, cell)\n+ if not unsigned:\n+ continue\n+ sig, frac, e = parts(data)\n+ r = max(len(sig) - 19, 0) - frac\n+ bounded = accumulated_exponent(re.split(rb\"[eE]\", data)[1])[0] if re.search(rb\"[eE]\", data) else 0\n+ expected_q = r + bounded\n+ m, q, neg, many = row[1].split(\",\")\n+ m, q = int(m), int(q)\n+ assert neg == \"false\" and m < 10 ** 19, (\"record bounds\", label, row)\n+ assert q == expected_q and (many == \"true\") == (len(sig) > 19), (\"record scale\", label, row)\n+ full = int(sig or b\"0\")\n+ unit = 10 ** max(len(sig) - 19, 0)\n+ assert (m * unit <= full < (m + 1) * unit) if many == \"true\" else (m == full), (\"diagnostic interval\", label, row)\n+ expected = exact_bits(data, diagnostic=True)\n+ assert row[5] == f\"{expected:016x}\", (\"direct slow rounding\", label, row[5], hex(expected))\n+ trimmed = sig.rstrip(b\"0\")\n+ n, point, sticky, retained = row[6].split(\",\")\n+ expected_point = len(sig) - frac + bounded if sig else 0\n+ expected_point = min(2047, max(-2047, expected_point))\n+ assert (int(n), int(point), sticky, retained) == (\n+ min(len(trimmed), 768), expected_point, str(len(trimmed) > 768).lower(), trimmed[:768].decode()), (\"decimal state\", label, row)\n+ if data.startswith(b\"0.\" + b\"0\" * 11 + b\"1000000000000000080\") and len(data) > 768:\n+ a, ap, b, bp = row[7].split(\",\")\n+ assert many == \"true\" and int(ap) >= 0 and (a, ap) != (b, bp), (\"forced fallback\", label, row)\n+ fallback_padding += 1\n+ assert fallback_padding >= 3, (\"padded fallback coverage\", fallback_padding)\n+ print(f\"PRESERVATION_OK cases={len(cases)} forced_fallback_padding={fallback_padding} exact_rational_oracle=true\")\n+\n+\n+def copy_source(root, out, harness):\n+ \"\"\"Only internal stability attributes and test visibility change in copies.\"\"\"\n+ digest = hashlib.sha256()\n+ files = [Path(\"traits.rs\"), *(p.relative_to(root) for p in sorted((root / \"dec2flt\").glob(\"*.rs\")))]\n+ for relative in files:\n+ raw = (root / relative).read_bytes()\n+ digest.update(str(relative).encode() + b\"\\0\" + raw)\n+ source = raw.decode()\n+ source = re.sub(r'#!\\[unstable\\(.*?\\)\\]\\s*', '', source, flags=re.S)\n+ if relative in (Path(\"dec2flt/parse.rs\"), Path(\"dec2flt/decimal_seq.rs\")):\n+ source = source.replace(\"pub(super) fn\", \"pub(crate) fn\")\n+ if relative == Path(\"dec2flt/mod.rs\"):\n+ source = source.replace(\"mod common;\", \"pub(crate) mod common;\")\n+ source = source.replace(\"mod slow;\", \"pub(crate) mod slow;\")\n+ source += \"\\npub(crate) fn regression_assemble(x: common::BiasedFp) -> f64 { biased_fp_to_float::<f64>(x) }\\n\"\n+ path = out / relative\n+ path.parent.mkdir(parents=True, exist_ok=True)\n+ path.write_text(source)\n+ for name in (\"shim.rs\", \"cases.rs\", \"bench.rs\"):\n+ if not (harness / name).exists():\n+ continue\n+ (out / name).write_bytes((harness / name).read_bytes())\n+ print(f\"SOURCE_ROOT={root} SOURCE_DIGEST={digest.hexdigest()}\")\n+\n+\n+def main():\n+ parser = argparse.ArgumentParser()\n+ parser.add_argument(\"--source\", type=Path, required=True)\n+ parser.add_argument(\"--scratch\", type=Path, required=True)\n+ parser.add_argument(\"--rustc\", type=Path, required=True)\n+ parser.add_argument(\"--suite\", choices=(\"cutoff\", \"count-boundaries\", \"preservation\", \"performance\"), required=True)\n+ parser.add_argument(\"--overflow-checks\", choices=(\"on\", \"off\"), required=True)\n+ parser.add_argument(\"--fast-path\", choices=(\"both\",), required=True)\n+ args = parser.parse_args()\n+ if hasattr(sys, \"set_int_max_str_digits\"):\n+ sys.set_int_max_str_digits(0)\n+ args.source = args.source.resolve()\n+ args.scratch.mkdir(parents=True, exist_ok=True)\n+ harness = Path(__file__).resolve().parent\n+ if args.suite == \"performance\":\n+ import performance\n+ return performance.single(args)\n+ if args.suite == \"cutoff\":\n+ cases = cutoff_cases()\n+ requests = [\"N\\t\" + data.hex() for _, data, _ in cases]\n+ elif args.suite == \"count-boundaries\":\n+ cases = count_cases()\n+ scans = count_scan_cases()\n+ for index, data in enumerate(scans):\n+ sig, frac, _ = parts(data)\n+ suffix = re.split(rb\"[eE]\", data)[1].decode() if re.search(rb\"[eE]\", data) else \"ABSENT\"\n+ cases.append((f\"ordinary_scan_link_{index}\", len(sig), frac,\n+ len(sig) - len(sig.rstrip(b\"0\")), suffix))\n+ requests = [f\"C\\t{sig}\\t{frac}\\t{trail}\\t{e}\" for _, sig, frac, trail, e in cases]\n+ requests.extend(\"N\\t\" + data.hex() for data in scans)\n+ else:\n+ cases = numeric_cases()\n+ requests = [\"N\\t\" + data.hex() for data in cases]\n+ results = []\n+ with tempfile.TemporaryDirectory(prefix=\"dec2flt-\", dir=args.scratch) as temporary:\n+ out = Path(temporary)\n+ copy_source(args.source, out, harness)\n+ for route in (\"ordinary\", \"optimize_for_size\"):\n+ exe = out / route\n+ command = [str(args.rustc), \"--edition=2018\", str(out / \"shim.rs\"), \"-o\", str(exe),\n+ \"-C\", \"opt-level=1\", \"-C\", \"debug-assertions=on\",\n+ \"-C\", \"overflow-checks=\" + args.overflow_checks]\n+ if \"fn final_decimal_point(\" in (args.source / \"dec2flt/decimal_seq.rs\").read_text():\n+ command.extend([\"--cfg\", \"has_final_point\"])\n+ if route == \"optimize_for_size\":\n+ command.extend([\"--cfg\", 'feature=\"optimize_for_size\"'])\n+ print(\"COMPILE\", \" \".join(command), flush=True)\n+ build = subprocess.run(command, capture_output=True, text=True, timeout=120)\n+ print(f\"COMPILER_EXIT={build.returncode} route={route}\")\n+ if build.stdout:\n+ print(build.stdout, end=\"\")\n+ if build.stderr:\n+ print(build.stderr, end=\"\", file=sys.stderr)\n+ if build.returncode:\n+ return 3\n+ process = subprocess.run([str(exe)], input=\"\\n\".join(requests) + \"\\n\",\n+ capture_output=True, text=True, timeout=180)\n+ print(f\"PROCESS_EXIT={process.returncode} route={route} STDERR={process.stderr!r}\")\n+ if process.returncode:\n+ completed = process.stdout.splitlines()\n+ request = requests[len(completed)] if len(completed) < len(requests) else \"AFTER_FINAL_CASE\"\n+ print(f\"FAILED_CASE_INDEX={len(completed)} REQUEST_PREFIX={request[:180]!r}\")\n+ print(\"LAST_PROBE_ROWS\", completed[-3:])\n+ return 4\n+ rows = [line.split(\"\\t\") for line in process.stdout.splitlines()]\n+ if len(rows) != len(requests):\n+ raise RuntimeError(\"probe output row count mismatch\")\n+ results.append((route, rows))\n+ mismatch = False\n+ for route, rows in results:\n+ print(f\"CHECK route={route} suite={args.suite} overflow_checks={args.overflow_checks}\")\n+ if args.suite == \"cutoff\":\n+ for (name, data, expected), row in zip(cases, rows, strict=True):\n+ if isinstance(expected, str):\n+ assert row[2] == expected, (name, row, expected)\n+ assert row[1] == \"NONE\", (name, row)\n+ print(f\"CUTOFF_INVALID case={name} actual={row[2]}\")\n+ continue\n+ if len(row) != 8 or row[0] != \"N\" or not re.fullmatch(r\"[0-9a-f]{16}\", row[2]):\n+ raise RuntimeError(f\"invalid cutoff probe output: {row}\")\n+ print(f\"CUTOFF case={name} bytes={len(data)} actual={row[2]} expected={expected:016x} slow={row[5]}\")\n+ if row[2] != f\"{expected:016x}\":\n+ print(f\"EXP_CUTOFF_MISMATCH case={name} route={route} actual={row[2]} expected={expected:016x}\")\n+ mismatch = True\n+ if numeric(data) and row[5] != f\"{expected:016x}\":\n+ if not re.fullmatch(r\"[0-9a-f]{16}\", row[5]):\n+ raise RuntimeError(\"invalid slow probe output\")\n+ print(f\"EXP_CUTOFF_MISMATCH case={name} route={route} direct_slow_actual={row[5]} expected={expected:016x}\")\n+ mismatch = True\n+ elif args.suite == \"count-boundaries\":\n+ check_counts(cases, rows[:len(cases)])\n+ check_preservation(scans, rows[len(cases):])\n+ print(f\"COUNT_SCAN_LINKS_OK cases={len(scans)} trimming_and_sticky=true\")\n+ else:\n+ check_preservation(cases, rows)\n+ return 42 if mismatch else 0\n+\n+\n+if __name__ == \"__main__\":\n+ try:\n+ if not __debug__:\n+ raise RuntimeError(\"regression assertions require Python without -O\")\n+ sys.exit(main())\n+ except (OSError, subprocess.SubprocessError, RuntimeError, ValueError, AssertionError) as error:\n+ print(f\"HARNESS_FAILURE {type(error).__name__}: {error}\", file=sys.stderr)\n+ sys.exit(5)\n--- /dev/null\n+++ b/regression/shim.rs\n@@ -0,0 +1,28 @@\n+#![feature(float_masks, cfg_target_has_reliable_f16_f128, f16)]\n+#![allow(dead_code, unused_imports, unexpected_cfgs)]\n+\n+pub use std::{f32, f64, fmt, ops};\n+pub mod traits;\n+pub mod dec2flt;\n+pub mod num {\n+ pub use std::num::FpCategory;\n+ pub use float_parse::ParseFloatError;\n+ pub mod float_parse {\n+ #[derive(Debug, PartialEq, Eq)]\n+ pub enum FloatErrorKind { Empty, Invalid }\n+ #[derive(Debug, PartialEq, Eq)]\n+ pub struct ParseFloatError { pub kind: FloatErrorKind }\n+ }\n+ pub mod imp {\n+ pub use crate::traits::*;\n+ pub use crate::dec2flt;\n+ }\n+}\n+#[cfg(not(performance))]\n+mod cases;\n+#[cfg(performance)]\n+mod bench;\n+#[cfg(not(performance))]\n+fn main() { cases::run(); }\n+#[cfg(performance)]\n+fn main() { bench::run(); }\n",
"result_source_digest": "f874abb28913ac76b94d8c67f41d8ce934530dbfd2594f68fb40aa3589885ea9"
}proof_status
"requires_modeling_and_reproof"tests_are_proofs
falseretirement_is_proof
false