Exact rounding
Disproveddec2fltExact rounding. On acceptance of any numeric literal, the returned float
is its exact value rounded to binary64.
Later revision · decision
ParserExactRounding__Refutation proves an accepted one instead of infinity on the 65545-byte literal 0., 65535 zeroes, and 1e655360. This practical defect is repaired by the larger common accumulator, not excluded. The explicit B condition excludes only the exabyte-scale cancellation that a fixed cutoff still cannot resolve exactly. This is the human-authorized efficiency compromise; neither accumulated-value rounding nor a regression pass is substituted for the mathematical exact target within B.
Definitions quoted from revised requirements
Conditional abstract composition
dec2fltConditional 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.
Conditional component compliance
dec2fltConditional 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.
Supporting proofs
Inspect related source (201)
- Dec2flt_modelNumImpDec2fltLemireU64 · dec2flt/mod.rs:217 Program Rust
- MAX_EXPONENT_DISGUISED_FAST_PATH · dec2flt/mod.rs:220 Program Rust
- MAX_EXPONENT_FAST_PATH · dec2flt/mod.rs:219 Program Rust
More program dependencies (159)
- from_u64 · dec2flt/mod.rs:263 Program Rust
- pow10_fast_path · dec2flt/mod.rs:222 Program Rust
- Dec2flt_modelNumImpTraitsFloatExtU64 · traits.rs:339 Program Rust
- Dec2flt_modelNumImpTraitsFloatU64 · traits.rs:309 Program Rust
- SIG_TOTAL_BITS · traits.rs:320 Program Rust
- offset_from · dec2flt/common.rs:30 Program Rust
- read_u64 · dec2flt/common.rs:18 Program Rust
- default · dec2flt/mod.rs:128 Program Rust
- default · dec2flt/mod.rs:121 Program Rust
- is_8digits · dec2flt/common.rs:40 Program Rust
- dec2flt · dec2flt/mod.rs:508 Program Rust
- dec2flt_with_trace · dec2flt/mod.rs:355 Program Rust
- Decimal · dec2flt/decimal.rs:32 Program Rust
- can_use_fast_path · dec2flt/decimal.rs:42 Program Rust
- try_fast_path · dec2flt/decimal.rs:59 Program Rust
- INT_POW10 · dec2flt/decimal.rs:8 Program Rust
- set_precision · dec2flt/fpu.rs:99 Program Rust
- adjust_many_digit_count · dec2flt/parse.rs:86 Program Rust
- adjust_many_digit_count_loop · dec2flt/parse.rs:89 Program Rust
- body · dec2flt/parse.rs:89 Program Rust
- parse_8digits · dec2flt/parse.rs:18 Program Rust
- MASK · dec2flt/parse.rs:19 Program Rust
- MUL1 · dec2flt/parse.rs:20 Program Rust
- MUL2 · dec2flt/parse.rs:21 Program Rust
- parse_number · dec2flt/parse.rs:231 Program Rust
- parse_partial_number · dec2flt/parse.rs:161 Program Rust
- parse_scientific · dec2flt/parse.rs:121 Program Rust
- parse_scientific_loop · dec2flt/parse.rs:142 Program Rust
- body · dec2flt/parse.rs:142 Program Rust
- try_parse_digits · dec2flt/parse.rs:30 Program Rust
- try_parse_digits_loop0 · dec2flt/parse.rs:33 Program Rust
- body · dec2flt/parse.rs:33 Program Rust
- try_parse_digits_loop1 · dec2flt/parse.rs:50 Program Rust
- body · dec2flt/parse.rs:50 Program Rust
- from_u64_bits · traits.rs:341 Program Rust
- integer_decode · traits.rs:348 Program Rust
- BITS · traits.rs:319 Program Rust
- EXP_MASK · traits.rs:321 Program Rust
- INFINITY · traits.rs:312 Program Rust
- LARGEST_POWER_OF_TEN · traits.rs:327 Program Rust
- MAX_EXPONENT_ROUND_TO_EVEN · traits.rs:325 Program Rust
- MIN_EXPONENT_ROUND_TO_EVEN · traits.rs:324 Program Rust
- NAN · traits.rs:314 Program Rust
- NEG_INFINITY · traits.rs:313 Program Rust
- NEG_NAN · traits.rs:317 Program Rust
- SIG_MASK · traits.rs:322 Program Rust
- SMALLEST_POWER_OF_TEN · traits.rs:328 Program Rust
- classify · traits.rs:334 Program Rust
- to_bits · traits.rs:330 Program Rust
- Dec2flt_modelNumImpTraitsInt · traits.rs:51 Program Rust
- ParseFloatError · num/mod.rs:13 Program Rust
- Dec2FltTrace · dec2flt/mod.rs:295 Program Rust
- Lemire · dec2flt/mod.rs:115 Program Rust
- biased_fp_to_float · dec2flt/mod.rs:282 Program Rust
- eq · dec2flt/common.rs:51 Program Rust
- compute_float · dec2flt/lemire.rs:26 Program Rust
- parse_inf_nan · dec2flt/parse.rs:241 Program Rust
- parse_many_digits · dec2flt/parse.rs:104 Program Rust
- pfe_empty · dec2flt/mod.rs:270 Program Rust
- pfe_invalid · dec2flt/mod.rs:277 Program Rust
- parse_long_mantissa · dec2flt/slow.rs:27 Program Rust
- parse_long_mantissa_loop0 · dec2flt/slow.rs:51 Program Rust
- body · dec2flt/slow.rs:51 Program Rust
- parse_long_mantissa_loop1 · dec2flt/slow.rs:69 Program Rust
- body · dec2flt/slow.rs:69 Program Rust
- parse_long_mantissa_loop2 · dec2flt/slow.rs:94 Program Rust
- body · dec2flt/slow.rs:94 Program Rust
- Float · traits.rs:74 Program Rust
- default · traits.rs:116 Program Rust
- default · traits.rs:104 Program Rust
- default · traits.rs:119 Program Rust
- default · traits.rs:110 Program Rust
- default · traits.rs:113 Program Rust
- default · traits.rs:101 Program Rust
- FloatExt · traits.rs:170 Program Rust
- Dec2flt_modelNumImpTraitsCastIntoI16 · traits.rs:45 Program Rust
- ONE · traits.rs:53 Program Rust
- ZERO · traits.rs:52 Program Rust
- FloatErrorKind · num/mod.rs:18 Program Rust
- Dec2FltAssemblyTrace · dec2flt/mod.rs:329 Program Rust
- BiasedFp · dec2flt/common.rs:52 Program Rust
- zero_pow2 · dec2flt/common.rs:62 Program Rust
- ByteSlice · dec2flt/common.rs:4 Program Rust
- DecimalSeq · dec2flt/decimal_seq.rs:21 Program Rust
- DECIMAL_POINT_RANGE · dec2flt/decimal_seq.rs:67 Program Rust
- left_shift · dec2flt/decimal_seq.rs:129 Program Rust
- left_shift_loop0 · dec2flt/decimal_seq.rs:138 Program Rust
- body · dec2flt/decimal_seq.rs:138 Program Rust
- left_shift_loop1 · dec2flt/decimal_seq.rs:152 Program Rust
- body · dec2flt/decimal_seq.rs:152 Program Rust
- right_shift · dec2flt/decimal_seq.rs:175 Program Rust
- right_shift_loop0 · dec2flt/decimal_seq.rs:180 Program Rust
- body · dec2flt/decimal_seq.rs:180 Program Rust
- right_shift_loop0_loop0 · dec2flt/decimal_seq.rs:190 Program Rust
- body · dec2flt/decimal_seq.rs:190 Program Rust
- right_shift_loop1 · dec2flt/decimal_seq.rs:209 Program Rust
- body · dec2flt/decimal_seq.rs:209 Program Rust
- right_shift_loop2 · dec2flt/decimal_seq.rs:216 Program Rust
- body · dec2flt/decimal_seq.rs:216 Program Rust
- round · dec2flt/decimal_seq.rs:96 Program Rust
- round_loop · dec2flt/decimal_seq.rs:106 Program Rust
- body · dec2flt/decimal_seq.rs:106 Program Rust
- parse_decimal_seq · dec2flt/decimal_seq.rs:283 Program Rust
- parse_decimal_seq_loop0 · dec2flt/decimal_seq.rs:290 Program Rust
- body · dec2flt/decimal_seq.rs:290 Program Rust
- parse_decimal_seq_loop1 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- parse_decimal_seq_loop2 · dec2flt/decimal_seq.rs:303 Program Rust
- body · dec2flt/decimal_seq.rs:303 Program Rust
- parse_decimal_seq_loop3 · dec2flt/decimal_seq.rs:307 Program Rust
- body · dec2flt/decimal_seq.rs:307 Program Rust
- parse_decimal_seq_loop4 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- parse_decimal_seq_loop5 · dec2flt/decimal_seq.rs:307 Program Rust
- body · dec2flt/decimal_seq.rs:307 Program Rust
- parse_decimal_seq_loop6 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- parse_decimal_seq_loop7 · dec2flt/decimal_seq.rs:361 Program Rust
- body · dec2flt/decimal_seq.rs:361 Program Rust
- compute_product_approx · dec2flt/lemire.rs:134 Program Rust
- power · dec2flt/lemire.rs:121 Program Rust
- MIN_19DIGIT_INT · dec2flt/parse.rs:8 Program Rust
- try_parse_19digits · dec2flt/parse.rs:61 Program Rust
- try_parse_19digits_loop · dec2flt/parse.rs:64 Program Rust
- body · dec2flt/parse.rs:64 Program Rust
- MAX_SHIFT · dec2flt/slow.rs:28 Program Rust
- call · dec2flt/slow.rs:33 Program Rust
- CastInto · traits.rs:18 Program Rust
- Int · traits.rs:27 Program Rust
- write_u64 · dec2flt/common.rs:25 Program Rust
- cast · traits.rs:46 Program Rust
- default · dec2flt/decimal_seq.rs:33 Program Rust
- MAX_DIGITS · dec2flt/decimal_seq.rs:63 Program Rust
- MAX_DIGITS_WITHOUT_OVERFLOW · dec2flt/decimal_seq.rs:66 Program Rust
- trim · dec2flt/decimal_seq.rs:82 Program Rust
- trim_loop · dec2flt/decimal_seq.rs:91 Program Rust
- body · dec2flt/decimal_seq.rs:91 Program Rust
- count_trailing_zeros · dec2flt/decimal_seq.rs:235 Program Rust
- count_trailing_zeros_loop · dec2flt/decimal_seq.rs:239 Program Rust
- body · dec2flt/decimal_seq.rs:239 Program Rust
- number_of_digits_decimal_left_shift · dec2flt/decimal_seq.rs:368 Program Rust
- number_of_digits_decimal_left_shift_loop · dec2flt/decimal_seq.rs:434 Program Rust
- body · dec2flt/decimal_seq.rs:434 Program Rust
- parse_decimal_exponent · dec2flt/decimal_seq.rs:269 Program Rust
- parse_decimal_exponent_loop · dec2flt/decimal_seq.rs:272 Program Rust
- body · dec2flt/decimal_seq.rs:272 Program Rust
- parse_digits_into_seq · dec2flt/decimal_seq.rs:256 Program Rust
- parse_digits_into_seq_loop · dec2flt/decimal_seq.rs:258 Program Rust
- body · dec2flt/decimal_seq.rs:258 Program Rust
- full_multiplication · dec2flt/lemire.rs:126 Program Rust
- NUM_POWERS · dec2flt/slow.rs:29 Program Rust
- POWERS · dec2flt/slow.rs:30 Program Rust
- closure · dec2flt/slow.rs:33 Program Rust
- LARGEST_POWER_OF_FIVE · dec2flt/table.rs:10 Program Rust
- POWER_OF_FIVE_128 · dec2flt/table.rs:19 Program Rust
- SMALLEST_POWER_OF_FIVE · dec2flt/table.rs:9 Program Rust
- try_add_digit · dec2flt/decimal_seq.rs:73 Program Rust
- TABLE · dec2flt/decimal_seq.rs:370 Program Rust
- TABLE_POW5 · dec2flt/decimal_seq.rs:379 Program Rust
Standard-library dependencies (39)
- mul · core/src/ops/arith.rs:350 Rust library
- bitand · core/src/ops/bit.rs:178 Rust library
- bitor · core/src/ops/bit.rs:282 Rust library
- shl · core/src/ops/bit.rs:489 Rust library
- MANTISSA_DIGITS · core/src/num/f64.rs:412 Rust library
- from_bits · core/src/num/f64.rs:1269 Rust library
- is_ascii_digit · core/src/num/mod.rs:958 Rust library
- branch · core/src/option.rs:2779 Rust library
- first · core/src/slice/mod.rs:155 Rust library
- split_first · core/src/slice/mod.rs:198 Rust library
- as_bytes · core/src/str/mod.rs:498 Rust library
- clone · core/src/clone.rs:698 Rust library
- div · core/src/ops/arith.rs:515 Rust library
- neg · core/src/ops/arith.rs:719 Rust library
- shr · core/src/ops/bit.rs:612 Rust library
- EXPONENT_MASK · core/src/num/f64.rs:615 Rust library
- INFINITY · core/src/num/f64.rs:512 Rust library
- MANTISSA_MASK · core/src/num/f64.rs:637 Rust library
- NAN · core/src/num/f64.rs:509 Rust library
- NEG_INFINITY · core/src/num/f64.rs:515 Rust library
- classify · core/src/num/f64.rs:782 Rust library
- to_bits · core/src/num/f64.rs:1223 Rust library
- from_residual · core/src/option.rs:2793 Rust library
- CoreOpsArithDivF64F64 · core/src/ops/arith.rs:511 Rust library
- CoreOpsArithMulF64F64 · core/src/ops/arith.rs:344 Rust library
- CoreOpsArithNegF64 · core/src/ops/arith.rs:713 Rust library
- CoreOpsBitBitAndU64U64 · core/src/ops/bit.rs:174 Rust library
- CoreOpsBitBitOrU64U64 · core/src/ops/bit.rs:278 Rust library
- CoreOpsBitShlU32U64 · core/src/ops/bit.rs:483 Rust library
- CoreMarkerCopy · core/src/marker.rs:57 Rust library
- Div · core/src/ops/arith.rs:460 Rust library
- Mul · core/src/ops/arith.rs:322 Rust library
- Neg · core/src/ops/arith.rs:690 Rust library
- BitOr · core/src/ops/bit.rs:254 Rust library
- Shl · core/src/ops/bit.rs:461 Rust library
- CoreCloneClone · core/src/clone.rs:696 Rust library
- CoreOpsBitShrU32U64 · core/src/ops/bit.rs:606 Rust library
- FpCategory · core/src/num/mod.rs:1522 Rust library
- Shr · core/src/ops/bit.rs:584 Rust library
Related source and models come from the extraction records and declared dependencies.
Lean statement and supporting proof
Proposition checked for this verdict
theorem ParserExactRounding__Refutation : ¬ (∀ (s : Str) (x : DecimalLexeme) (f : F64), DecimalGoalVocabularyDefault.sourceString s ->
DecimalGoalVocabularyDefault.validNumeric x -> DecimalGoalVocabularyDefault.bytes s = DecimalGoalVocabularyDefault.renderNumeric x ->
num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s = ok (core.result.Result.Ok f) ->
∃ magnitude : F64, DecimalGoalVocabularyDefault.roundsMagnitude (DecimalGoalVocabularyDefault.exactMagnitude x) magnitude ∧
DecimalGoalVocabularyDefault.signedMagnitude (DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f) := byThe negation is proved, disproving the requirement.
Alternate registered target · outside this verdict
theorem ParserExactRounding :
∀ (s : Str) (x : DecimalLexeme) (f : F64), DecimalGoalVocabularyDefault.sourceString s ->
DecimalGoalVocabularyDefault.validNumeric x -> DecimalGoalVocabularyDefault.bytes s = DecimalGoalVocabularyDefault.renderNumeric x ->
num.imp.dec2flt.dec2flt F64.Insts.Dec2flt_modelNumImpDec2fltLemireU64
F64.Insts.CoreOpsArithDivF64F64 F64.Insts.CoreOpsArithMulF64F64
F64.Insts.CoreOpsArithNegF64 s = ok (core.result.Result.Ok f) ->
∃ magnitude : F64, DecimalGoalVocabularyDefault.roundsMagnitude (DecimalGoalVocabularyDefault.exactMagnitude x) magnitude ∧
DecimalGoalVocabularyDefault.signedMagnitude (DecimalGoalVocabularyDefault.lexicalNegative x) magnitude f := byStatement registration
| Live polarity | disprove |
|---|---|
| Authority | recorded audit polarity |
| Registered target | authored:ParserExactRounding__refutation |
| Closure nodes |
|
Counterexample argument as recorded · ParserExactRounding__Refutation
Theorem
The following result is false:
For every accepted source-valid numeric literal, the returned word is its lexical sign applied to the IEEE 754 binary64 round-to-nearest, ties-to-even magnitude target of its exact mathematical decimal value, including subnormals and overflow to infinity.
Proof
Assume, for contradiction, the displayed universal claim. Define the input
s to have bytes
[\texttt{0},\texttt{.}]\mathbin{++}
\operatorname{replicate}(65535,\texttt{0})\mathbin{++}
[\texttt{1},\texttt{e},\texttt{6},\texttt{5},\texttt{5},
\texttt{3},\texttt{6},\texttt{0}].
Thus its ordinary spelling is
0. 0^{65535}1e655360. Let x be the unsigned numeric
lexeme with integer digits [0], fractional digits
\operatorname{replicate}(65535,0)\mathbin{++}[1], and unsigned lower-case
exponent digits [6,5,5,3,6,0]. Let f be the binary64 word
\texttt{0x3ff0000000000000}=4607182418800017408, namely 1.0.The input is source-valid in the precise sense of
DecimalGoalVocabularyDefault. Its length is
2+65535+8=65545<2^{63}-1. For the UTF-8 conjunct, take the Lean string made
from the corresponding character list. The standard encoding of each listed
ASCII character is its single displayed byte. More explicitly, induction on
the replicated list gives that encoding the 65535 zero characters yields
exactly 65535 copies of byte 48. The list conversion used by
String.toUTF8 satisfies the invariant that, at byte-array index i
with reverse accumulator r, the loop result is
r^{\mathrm{rev}} followed by the backing array after index i; induction on
the byte-array loop therefore identifies its output list with the backing
data in order. Applying this to the displayed character list proves that its
UTF-8 bytes are exactly the bytes of s, without relying on evaluation of the
long string.The same definition shows that x is valid and renders to the bytes of s.
Every digit is between 0 and 9, the integer and exponent digit lists are
nonempty, and the fraction consists only of zeros followed by one. Rendering
places byte 46 before that fraction and bytes 101,54,53,53,51,54,48 after
it, which is exactly the displayed byte list.
We next calculate the extracted parser execution directly from
num imp dec2flt parse try parse digits,
SliceU8 Insts Dec2flt modelNumImpDec2fltCommonByteSlice read u64,
num imp dec2flt common is 8digits, and
num imp dec2flt parse parse 8digits. The bit conjunction and
disjunctions in these definitions are the full-word operations supplied by
U64 Insts CoreOpsBitBitAndU64U64,
U64 Insts CoreOpsBitBitOrU64U64,
ModelU64BitAnd, and ModelU64BitOr; they always return
normally. The three constants are, by
num imp dec2flt parse parse 8digits MASK,
num imp dec2flt parse parse 8digits MUL1, and
num imp dec2flt parse parse 8digits MUL2, respectively
M=1095216660735,\qquad M_1=4294967296000100,\qquad
M_2=42949672960001.
For every call to
read_u64 below, the current slice has length at
least eight. Its definition creates an eight-byte zero array, obtains its
mutable slice without failure, and takes the checked prefix
self[..8]; the inequality 8\leq|\texttt{self}| discharges that
slice bound. Both source and destination then have length eight, so
copy_from_slice succeeds, and from_le_bytes returns the
little-endian word. Thus none of these monadic steps can be fail.On the full input, the first eight bytes are
[48,46,48,48,48,48,48,48], so
read_u64 returns
v_0=3472328296227679792=\mathtt{0x3030303030302e30}.
The exact is_8digits arithmetic is
\begin{array}{rcl}
v_0+_{64}5063812098665367110&=&8536140394893046902,\\
v_0-_{64}3472328296227680304&=&18446744073709551104,\\
\text{their bitwise OR}&=&18446744073709551222,\\
18446744073709551222\mathbin{\&}9259542123273814144
&=&9259542123273814016\ne0.
\end{array}
The additions and subtraction here are explicitly wrapping operations and
hence return normally. The predicate is therefore false. The bulk loop
returns the original state. In the scalar loop, count 0<65545, indexed
byte 48 is in bounds, and wrapping subtraction gives 48-_{8}48=0<10.
The repeated digit subtraction is zero, its cast to u64 is in range,
the wrapping product 0\cdot10 and sum 0+0 are zero, and checked
0+1=1 is within usize. At count one the in-bounds byte is 46;
46-_{8}48=254\not<10, so the scalar loop stops. Dropping the checked
one-byte prefix is allowed because 1\leq65545. The first call therefore
returns the suffix beginning at the point and mantissa zero.The actual head-tail operation in
num imp dec2flt parse parse partial number is supplied by
ModelSliceSplitFirst; on this nonempty suffix it succeeds with byte
46 and precisely the remaining tail. That tail has length 65543 and
begins with 65535 zero bytes followed by byte 49.
We now certify the two possible digit blocks. Eight zero bytes give
z=3472328296227680304=\mathtt{0x3030303030303030}.
For is_8digits, the wrapping sum is
8536140394893047414, the wrapping difference z-z is zero, their OR is
8536140394893047414, and conjunction with
9259542123273814144 is zero. Thus the block is accepted. In
parse_8digits, the checked subtraction z-z=0, checked
multiplication 0\cdot10=0, signed-count shift 0\mathbin{\texttt{>>>}}8=0,
and checked addition 0+0=0 all succeed. Conjunction with M is zero;
wrapping multiplication by M_1 is zero. The signed-count shift by 16 is
zero, its conjunction with M is zero, wrapping multiplication by M_2 is
zero, and the wrapping sum is zero. The signed-count shift by 32 is zero.
Each shift count is nonnegative and below 64, so each checked shift succeeds.
Finally 0\leq2^{32}-1, so the u64-to-u32 cast succeeds,
and the widening cast returns u64 zero. Every monadic line of this
call has thus been discharged and the result is zero.Seven zero bytes followed by byte 49 give
q=3544385890265608240=\mathtt{0x3130303030303030}.
The digit test has wrapping sum 8608197988930975350, wrapping difference
72057594037927936, OR 8608197988930975350, and high-bit conjunction zero,
so it too is accepted. The complete parse_8digits reduction is
\begin{array}{rcl}
q-z&=&72057594037927936,\\
(q-z)\cdot10&=&720575940379279360,\\
(q-z)\mathbin{\texttt{>>>}}8&=&281474976710656,\\
v_2=720575940379279360+281474976710656
&=&720857415355990016,\\
v_2\mathbin{\&}M&=&0,\\
0\cdot_{64}M_1&=&0,\\
v_2\mathbin{\texttt{>>>}}16&=&10999411245056,\\
10999411245056\mathbin{\&}M&=&4294967296,\\
4294967296\cdot_{64}M_2&=&4294967296,\\
0+_{64}4294967296&=&4294967296,\\
4294967296\mathbin{\texttt{>>>}}32&=&1.
\end{array}
The first subtraction, multiplication, and addition are checked, and their
displayed results lie in [0,2^{64}-1]. The signed shift counts 8,16,32
again lie in [0,63]. The products and last sum marked with subscript 64
are wrapping and therefore total. Since 1\leq2^{32}-1, the narrowing cast
to u32 succeeds, and widening it gives u64 one. Thus this
call also has no failing bind and returns one.These calculations drive the bulk-loop induction. For 0\leq k\leq8191,
after k zero blocks the accumulator is zero and exactly 8k fractional
bytes have been dropped. The base case is the initial state. If k<8191,
at least eight zero bytes remain; the preceding read, test, and parse
certificate applies, the total wrapping update is
0\cdot_{64}100000000+_{64}0=0, and the range slice beginning at eight is
in bounds. The loop equation therefore proves the next state. At
k=8191, since 8\cdot8191=65528, the next block is q. Its certified
parse value one changes the accumulator by
0\cdot_{64}100000000+_{64}1=1, and its checked eight-byte drop is again in
bounds. Only the seven-byte suffix
e655360 remains. Its length is
less than eight, so the bulk loop stops without reading a word. The scalar
loop performs an in-bounds read of byte 101 at count zero and obtains
101-_{8}48=53\not<10; it stops, and the final drop by count zero is in
bounds. Hence the fractional scan consumes exactly 65536 digits, returns
mantissa one, and leaves e655360.The offset operation is exactly
SliceU8 Insts Dec2flt modelNumImpDec2fltCommonByteSlice offset from:
it casts the two lengths to
isize and subtracts the remaining length
from the original. All lengths here are at most 65545<2^{63}-1, so both
casts succeed. Initially it computes 65545-65544=1; after the point it
computes 65543-7=65536. Checked negation gives -65536, in range for
isize, and its cast to i64 succeeds. Thus the decimal-point
contribution to the record exponent is -65536, and checked addition of the
two digit counts gives 1+65536=65537.After ModelSliceSplitFirst removes byte 101,
num imp dec2flt parse parse scientific receives the six exponent
digits. Its first split sees byte 54, neither sign byte, so the digit slice
is unchanged. The nonempty test succeeds; the index-zero read is in bounds;
and ModelU8IsAsciiDigit recognizes it as a digit. In the loop, the
six wrapping byte subtractions produce 6,5,5,3,6,0, each below ten. For the
first five iterations the checked
i64 products and sums are
10\cdot0+6=6,\quad10\cdot6+5=65,\quad
10\cdot65+5=655,\quad10\cdot655+3=6553,\quad
10\cdot6553+6=65536.
Every displayed value is in i64; the byte-to-i64 casts are
of values at most six. At the sixth digit, the old accumulator is 65536,
so the strict guard is false and no product or sum is attempted. For counts
0 through 5, the premise count < length justifies each indexed
read and checked increment; the increments end at 6, still in
usize. The range slice dropping six bytes has bound 6\leq6 and
therefore returns the empty suffix. The helper returns
Some 65536. The option branch supplied by
ModelOptionBranch is consequently its nonfailing Continue arm, and
the checked exponent addition is -65536+65536=0.Since 65537>19, num imp dec2flt parse parse partial number
performs the checked subtraction 65537-19=65518 and invokes
num imp dec2flt parse adjust many digit count. Its exact invariant,
after the initial zero and point and then k fractional zeros
(0\leq k\leq65535), is: index 2+k, scanning true, and count 65517-k.
For the initial byte 48, the checked byte subtraction 48-1=47 succeeds,
saturating subtraction gives 48\mathbin{\mathrm{sat}-}47=1, its
isize cast succeeds, checked count subtraction gives 65517, and
checked index increment gives one. At the point byte 46, the same checked
48-1=47 is followed by 46\mathbin{\mathrm{sat}-}47=0; subtracting zero
leaves 65517, and the checked increment gives index two. This proves the
base. At each fractional zero the indexed read is justified by
2+k<65545, the same computations yield one, and
(65517-k)-1=65517-(k+1) remains between -18 and 65517; the index
increment remains at most 65537. This proves the induction step without an
overflow or a failing cast. At k=65535 the state is count -18 and index
65537. The in-bounds byte there is 49, neither point nor zero, so that
iteration only changes scanning to false. The next loop equation takes the
non-scanning done arm and returns -18.Because -18\not>0, the many-digit parser is not called. The empty exponent
suffix has offset 65545-0=65545 from the original slice; both
isize length casts, the checked subtraction, and the subsequent
usize cast succeed because 65545<2^{63}-1. Hence the partial
parser returns the num imp dec2flt decimal Decimal record
(\mathit{exponent}=0,\ \mathit{mantissa}=1,\
\mathit{negative}=\mathrm{false},\
\mathit{many\_digits}=\mathrm{false})
together with length 65545. By
num imp dec2flt parse parse number, this equals the original slice
length, so parse_number returns precisely this record in
Some.It remains to reduce the dispatcher and native path. Under
ModelStrAsBytes, the witness string supplies exactly the byte slice
already calculated. The first-byte operation in
num imp dec2flt dec2flt with trace is
ModelSliceFirst, so it returns byte 48 and the dispatcher neither
strips nor records a minus sign. It then receives the preceding
Some record.The concrete trait package
F64 Insts Dec2flt modelNumImpDec2fltLemireU64 contains the float
package F64 Insts Dec2flt modelNumImpTraitsFloatExtU64, whose float
record is F64 Insts Dec2flt modelNumImpTraitsFloatU64. First,
num imp dec2flt fpu fpu precision set precision returns unit, so the
opening bind of num imp dec2flt decimal Decimal try fast path cannot
fail. For num imp dec2flt decimal Decimal can use fast path,
F64 Insts Dec2flt modelNumImpDec2fltLemireU64 MAX EXPONENT FAST PATH
gives 22, and
num imp dec2flt Lemire MIN EXPONENT FAST PATH default performs the
checked negation -22. Also
F64 Insts Dec2flt modelNumImpDec2fltLemireU64 MAX EXPONENT DISGUISED FAST PATH
gives 37. Finally,
F64 Insts Dec2flt modelNumImpTraitsFloatU64 SIG TOTAL BITS calls the
mantissa-digits operation ModelF64MantissaDigits, which returns
53; num imp dec2flt Lemire MAX MANTISSA FAST PATH default shifts
the
u64 word one using U64 Insts CoreOpsBitShlU32U64
and ModelU64Shl. Since 53<64, that modeled shift succeeds and
returns
2^{53}=9007199254740992. Thus the guards evaluate, in their actual order,
to
-22\leq0,\qquad0\leq37,\qquad1\leq2^{53},\qquad
\neg\mathrm{false},
and can_use_fast_path returns true without failure.The next bound is again 0\leq22, so the ordinary, not disguised, arm is
taken. Accordingly the table
num imp dec2flt decimal INT POW10 is not indexed at all. The
concrete
from_u64 field is ModelF64FromU64. Its guard
1\leq2^{53} holds. In the exact conversion semantics of
Binary64ModelDefault, one is below the overflow threshold and is
not subnormal because 2^{-1022}\leq1. The normal-exponent scan tests
2^{e-1023}\leq1: it succeeds through exponent field e=1023 and fails
from e=1024 onward, so its retained field is exactly 1023. Scaling the
significand gives
1\cdot2^{1075-1023}=2^{52}; its quotient/remainder rounding has remainder
zero and returns 2^{52}, not the carry value 2^{53}. The encoder therefore
returns the raw word
1023\cdot2^{52}+(2^{52}-2^{52})=4607182418800017408.
Because exponent zero is nonnegative, its checked cast to
usize
returns zero. In
F64 Insts Dec2flt modelNumImpDec2fltLemireU64 pow10 fast path, the
mask calculation is 0\mathbin{\&}31=0, so the zero table arm calls the
from-bits operation ModelF64FromBits on
4607182418800017408; that operation preserves the word exactly. The
supplied multiplication record
F64 Insts CoreOpsArithMulF64F64 has operation
ModelF64Mul; by Binary64ModelDefault, its exact finite
decoder maps each operand's exponent-1023, fraction-zero magnitude to one,
and their signs agree. Its rational product is therefore 1\cdot1=1; the
same exponent-scan and zero-remainder calculation just displayed re-encodes
that product as raw word 4607182418800017408. The supplied division and negation records
F64 Insts CoreOpsArithDivF64F64 and
F64 Insts CoreOpsArithNegF64 are not invoked: the exponent is not
negative and the record's negative flag is false. Therefore
try_fast_path returns this word in Some.The definition num imp dec2flt dec2flt with trace consequently takes
its fast-path match arm and returns
Result.Ok of the word together
with a fast-path trace. Finally, num imp dec2flt dec2flt projects
the first component and returns
ok (Result.Ok 4607182418800017408). This establishes every premise
of the assumed universal claim for (s,x,f).It remains to show that its conclusion is impossible. Under
DecimalGoalVocabularyDefault, the significand digits of x fold to
one: all 65535 zero fractional digits leave the accumulator zero and the
final digit makes it one. The fraction length is 65536, while the
mathematical, unguarded exponent digits have value 655360. Therefore
\operatorname{exactMagnitude}(x)=10^{655360-65536}=10^{589824}.
Every binary64 magnitude target for this value must be positive infinity.
Indeed,
2^{1024}-2^{970}\leq2^{1024}\leq10^{1024}
\leq10^{589824}.
The first inequality uses 2^{970}\geq0, the second is monotonicity of a
natural power from 2\leq10, and the last follows by factoring
10^{589824}=10^{1024}10^{588800} with the second factor at least one.
The finite branch of roundsMagnitude requires the strict reverse
inequality, so it is impossible; its infinity branch forces raw word
2047\cdot2^{52}=9218868437227405312.The lexeme is unsigned. Hence
signedMagnitude requires the returned
word to equal that magnitude word without adding the sign bit. But the
concrete execution returned 4607182418800017408, and
4607182418800017408\ne9218868437227405312. This contradiction proves the
exact negation in the statement.Recorded replacement requirements
parser_exact_rounding
dec2fltConditional exact rounding. On acceptance of any numeric literal whose complete Rust string has byte length at most ≈ 512 PiB, 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.