\begin{theorem}
For every source-valid Rust string that is not a NaN literal, every normally returned successful \texttt{f64} parse result is not a binary64 NaN.
\end{theorem}
\begin{proof}
Fix a modeled string $s$ and result $f$ satisfying the three hypotheses.  Put
$U=2^{52}$, $S=2^{63}$, and $I=2047U$.  Unfolding
\noderef{DecimalGoalVocabularyDefault}, the conclusion says that it is
impossible to have simultaneously
\[
       (f.\mathit{val}\bmod S)/U=2047
       \quad\hbox{and}\quad f.\mathit{val}\bmod U\ne0.       \tag{1}
\]

\paragraph{The public call and the sign-stripped body.}
Unfold \noderef{num_imp_dec2flt_dec2flt}.  It first binds the result of
\texttt{dec2flt_with_trace} and then returns the first projection unchanged.
The assumed successful public result therefore supplies a trace $T$ with
\[
 \texttt{dec2flt_with_trace}(s)=\texttt{ok }(\texttt{Ok }f,T), \tag{2}
\]
where throughout the proof the four concrete instance arguments are
\noderef{F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64},
\noderef{F64_Insts_CoreOpsArithDivF64F64},
\noderef{F64_Insts_CoreOpsArithMulF64F64}, and
\noderef{F64_Insts_CoreOpsArithNegF64}.  This follows by case analysis on the
bound result: failure would propagate, and an \texttt{ok} pair whose first
projection differed from \texttt{Ok }$f$ could not yield the assumed final
\texttt{ok (Ok }$f$\texttt{)}.

We shall use the exact body and sign selected in (2).  By
\noderef{ModelStrAsBytes}, the first bind of
\noderef{num_imp_dec2flt_dec2flt_with_trace} returns the byte slice underlying
$s$ without changing its elements or order.  By \noderef{ModelSliceFirst},
the next bind returns \texttt{none} exactly when that list is empty and
otherwise returns its head $c$.  The \texttt{none} branch returns
\texttt{Err} with the \texttt{EmptyInput} trace, so it is incompatible with
(2).  Thus $c$ exists.  The extracted sign branch sets
\[
 (B,n,\sigma)=
 \begin{cases}
   (\operatorname{tail}(\operatorname{bytes}(s)),\mathsf{true},
      \texttt{some true}),&c=45,\\
   (\operatorname{tail}(\operatorname{bytes}(s)),\mathsf{false},
      \texttt{some false}),&c=43,\\
   (\operatorname{bytes}(s),\mathsf{false},\texttt{none}),&
      c\notin\{45,43\},
 \end{cases}                                                     \tag{3}
\]
where $B$ is the list of values in the selected slice \texttt{body1}, $n$ is
the Boolean argument later passed to the special parser, and $\sigma$ is the
corresponding optional lexical sign.  In the first two cases the range starts
at one; the existence of $c$ proves that this range is in bounds.  The next
emptiness branch returns \texttt{Err} with a \texttt{SignOnly} trace, so (2)
also proves that \texttt{body1} is nonempty.

The first conjunct of the source-string hypothesis is
$|\operatorname{bytes}(s)|\le 2^{63}-1$.  Formula (3) gives
$|B|=|\operatorname{bytes}(s)|$ or $|B|=|\operatorname{bytes}(s)|-1$.
Consequently \texttt{body1} satisfies \noderef{SourceValidByteSlice}.  Also,
unfolding the sign-prefix and \texttt{specialLiteral} fields of
\noderef{DecimalGoalVocabularyDefault}, (3) gives, for each Boolean $k$,
\[
 \texttt{specialLiteral}(B,\texttt{none},k)
 \Longrightarrow
 \texttt{specialLiteral}(\operatorname{bytes}(s),\sigma,k).      \tag{4}
\]
Indeed, prepend byte 45, prepend byte 43, or prepend nothing in the three
cases of (3), retaining the same case-insensitive body witness.  The theorem's
second hypothesis and (4) therefore imply
\[
       \neg\texttt{specialLiteral}(B,\texttt{none},\mathsf{true}). \tag{5}
\]

The constructors listed by \noderef{num_imp_dec2flt_Dec2FltTrace} are
disjoint and exhaustive.  In the exact dispatcher body, empty input,
sign-only input, and failure of both parsers produce \texttt{Err} with traces
\texttt{EmptyInput}, \texttt{SignOnly}, and \texttt{Invalid}; none can equal
(2).  The only remaining traces are \texttt{Special}, \texttt{FastPath}, and
\texttt{Assembled}.  We treat them in turn.

\paragraph{Special result.}
Suppose $T$ is \texttt{Special}.  Constructor injectivity applied to (2) and
the record-free \texttt{Special} return in
\noderef{num_imp_dec2flt_dec2flt_with_trace} gives the exact helper equation
\[
 \texttt{parse_inf_nan}(\texttt{body1},n)=\texttt{ok (some }f\texttt{)}.
                                                                  \tag{6}
\]
Assume temporarily that $B$ is not an unsigned infinity spelling.  Together
with the source-valid bound and (5), the theorem
\noderef{SpecialHelperRejection} would make the left side of (6)
\texttt{ok none}, a contradiction.  Hence $B$ is an unsigned
\texttt{inf}/\texttt{infinity} spelling.  Apply
\noderef{SpecialHelperInfinity} with the same slice and Boolean $n$.  It gives
some $g$ for which the same deterministic helper call is
\texttt{ok (some }g\texttt{)} and
\texttt{isInfinity} $n\ g$.  Comparing with (6), injectivity of
\texttt{ok} and \texttt{some} gives $g=f$.

Thus \texttt{isInfinity} $n\ f$.  By its definition in
\noderef{DecimalGoalVocabularyDefault}, $f.\mathit{val}$ is either $I$ or
$I+S$.  In either case reduction modulo $S$ is $I$, while reduction modulo
$U$ is zero.  Therefore the second conjunct of (1) is false, and $f$ is not a
NaN in the Special case.  Notice that (5), rather than an assumption that the
special parser itself prefers infinity, is what excluded its NaN match.

\paragraph{Native fast path.}
Suppose $T$ is \texttt{FastPath}.  The exact constructor fields in
\noderef{num_imp_dec2flt_Dec2FltTrace} and the corresponding return in
\noderef{num_imp_dec2flt_dec2flt_with_trace} supply a parsed Decimal $r$ and
the overwritten-sign record
\[
 d=\{r\text{ with }\mathit{negative}:=n\}
\quad\hbox{such that}\quad
 \texttt{try_fast_path}(d)=\texttt{ok (some }f\texttt{)}.          \tag{7}
\]
Apply \noderef{NativeCorrectOrDefer} to (7).  Its \texttt{out = none}
alternative contradicts \texttt{out = some }$f$.  In its other alternative,
injectivity of \texttt{some} identifies its returned value with $f$, and we
obtain a magnitude word $v$ satisfying
\[
 \texttt{roundsMagnitude}(\texttt{decimalMagnitude}(d),v),
 \qquad \texttt{signedMagnitude}(n,v,f).                           \tag{8}
\]
The first relation, unfolded from \noderef{DecimalGoalVocabularyDefault},
contains the bound $v.\mathit{val}\le I$.  The second contains
$v.\mathit{val}<S$ and
$f.\mathit{val}=v.\mathit{val}$ or $v.\mathit{val}+S$ according as $n$ is
false or true.  Hence in both cases
\[
 f.\mathit{val}\bmod S=v.\mathit{val},\qquad
 f.\mathit{val}\bmod U=v.\mathit{val}\bmod U.                    \tag{9}
\]
If the first conjunct of (1) held, (9) would give
$v.\mathit{val}/U=2047$.  Euclidean division then gives
$v.\mathit{val}\ge2047U=I$; combined with the bound in (8), this forces
$v.\mathit{val}=I$.  Its remainder modulo $U$ is zero, contradicting the
second conjunct of (1) through (9).  Thus the FastPath result is not NaN.

\paragraph{A local invariant for the assembled path.}
It remains to handle $T=\texttt{Assembled }A$.  The statements of the
assembly support theorems do not by themselves say that an exponent-2047
pair has zero fraction, so we prove the required converter invariant directly.
First evaluate the concrete constants.  Through the Lemire and FloatExt
records \noderef{F64_Insts_Dec2flt_modelNumImpDec2fltLemireU64} and
\noderef{F64_Insts_Dec2flt_modelNumImpTraitsFloatExtU64}, the selected Float
record is \noderef{F64_Insts_Dec2flt_modelNumImpTraitsFloatU64}.  Its bit
width is 64 by
\noderef{F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_BITS}; its
\texttt{SIG_TOTAL_BITS} method
\noderef{F64_Insts_Dec2flt_modelNumImpTraitsFloatU64_SIG_TOTAL_BITS} invokes
\noderef{ModelF64MantissaDigits} and returns 53.  The checked subtraction in
\noderef{num_imp_traits_Float_SIG_BITS_default} is therefore $53-1=52$.
The checked subtractions in \noderef{num_imp_traits_Float_EXP_BITS_default}
give $64-52-1=11$; the legal shift and subtraction in
\noderef{num_imp_traits_Float_EXP_SAT_default} give
$2^{11}-1=2047$; and
\noderef{num_imp_traits_Float_INFINITE_POWER_default} casts this in-range
value exactly to signed 2047.  All these monadic constant computations
succeed.

We claim that every successful integer conversion
\[
 \texttt{compute_float}(q,w)=\texttt{ok }b                       \tag{10}
\]
at this concrete Float record satisfies
\[
 b.m\le U,\qquad b.m=U\Longrightarrow b.p_{\rm biased}=1,
 \qquad b.p_{\rm biased}=2047\Longrightarrow b.m=0.              \tag{11}
\]
Unfold \noderef{num_imp_dec2flt_lemire_compute_float}.  Its eager zero,
infinity, and error sentinels are made by
\noderef{num_imp_dec2flt_common_BiasedFp_zero_pow2}, hence are respectively
$(0,0)$, $(0,2047)$, and $(0,-1)$.  Every early return of one of these pairs
satisfies (11).

On either nonsentinel product branch, the successful call to
\noderef{num_imp_dec2flt_lemire_compute_product_approx} supplies 64-bit words
$(lo,hi)$.  The shifts in this function have signed \texttt{I32} counts, so
we use their actual Aeneas semantics rather than the unsigned-count shift
binding.  Unfolding \texttt{UScalar.shiftRight\_IScalar}, a shift by a signed
count $c$ first tests $0\le c$; when that test succeeds it calls
\texttt{UScalar.shiftRight} with $c.\texttt{toNat}$, which separately tests
$c.\texttt{toNat}<64$ and then returns the zero-filling
\texttt{BitVec.ushiftRight}.  Thus there are two possible failure guards to
discharge for each such shift.

For $hi\mathbin{\mathtt{>>>}}63\#\texttt{i32}$, the signed value 63 is
nonnegative, its \texttt{toNat} is the same natural number 63, and $63<64$.
Thus the nonnegative and below-width success tests both hold, excluding both
failure alternatives, and the returned U64 value is the logical natural right
shift $hi\mathbin{\mathtt{>>}}63$.  Since $0\le hi<2^{64}$,
this value is either zero or one.  The exact widening cast makes that same
integer the \texttt{I32} value \texttt{upperbit}.  Consequently the checked
calculation $64+\texttt{upperbit}-52-3$ succeeds with \texttt{I32} value 9
or 10; call this count $c$.  In particular $0\le c<64$ and
$c.\texttt{toNat}$ is respectively the natural number 9 or 10.  Unfolding
the same two Aeneas definitions for
$hi\mathbin{\mathtt{>>>}}c$ discharges first the nonnegativity guard and then
the width guard, and identifies the returned \texttt{mantissa} with the
logical unsigned shift by that same natural count.  If \texttt{upperbit} is
zero, $hi\mathbin{\mathtt{>>}}63=0$ implies $hi<2^{63}$, so
$hi\mathbin{\mathtt{>>}}9<2^{54}$; if it is one, the U64 carrier bound
$hi<2^{64}$ gives $hi\mathbin{\mathtt{>>}}10<2^{54}$.  Thus the local
pre-rounding mantissa is always below $2^{54}$.  All casts and checked
operations which calculate the accompanying \texttt{power2} precede every
remaining result monadically; on the assumed successful execution they have
succeeded.  The two blocks below the two outcomes of the $lo$ test are
textually the same, so the following argument covers both.

If \texttt{power2}$\le0$, its successful checked negation produces
\texttt{i20} with value $-\texttt{power2}\ge0$, and its checked addition of
one produces \texttt{i21} with value
$k=-\texttt{power2}+1\ge1$.  The branch $k\ge64$ returns the zero sentinel.
On its false branch, therefore, $1\le k<64$.  The code repeats the very same
checked addition to form \texttt{i22}; determinism of that operation gives
$\texttt{i22.val}=k$.  Hence this signed count is nonnegative, its
\texttt{toNat} is the same natural $k$, and that natural is below 64.
For the operation
$\texttt{mantissa}\mathbin{\mathtt{>>>}}\texttt{i22}$, unfolding
\texttt{UScalar.shiftRight\_IScalar} and then
\texttt{UScalar.shiftRight} discharges respectively the sign and width
guards and identifies \texttt{mantissa1} with the logical shift by $k$.
If $k\le54$, the pre-rounding bound gives
$\texttt{mantissa1}<2^{54-k}\le2^{53}$; if $k>54$, then
$\texttt{mantissa}<2^{54}<2^k$, so \texttt{mantissa1} is zero.  Thus in all
cases $x=\texttt{mantissa1}<2^{53}$.  By
\noderef{ModelU64BitAnd}, $e=x\mathbin{\mathtt{\&}}1$ is its low bit, so
$x+e\le2^{53}$; the checked addition producing \texttt{mantissa2} therefore
cannot overflow.

The next operation has the signed count $1\#\texttt{i32}$.  Its value is
nonnegative, its \texttt{toNat} is the natural number one, and $1<64$; the
outer and inner success tests therefore hold, excluding both failure
alternatives.  The same unfolding identifies \texttt{mantissa3} with the logical halving
$\lfloor\texttt{mantissa2}/2\rfloor$, which is at most $2^{52}=U$.  The legal
shift $1\mathbin{\mathtt{<<}}52=U$ is governed by
\noderef{ModelU64Shl}, and the returned exponent is exactly the Boolean
value of $m\ge U$.  Hence $m=U$ implies exponent one, while exponent 2047 is
impossible on this ordinary return.

If \texttt{power2}>0$, the optional tie adjustment only clears the low bit by
\noderef{ModelU64BitAnd}.  Thus \texttt{mantissa1}$<2^{54}$, and adding its
low bit produces \texttt{mantissa2}$\le2^{54}$ without overflow.  Its next
shift again has signed count $1\#\texttt{i32}$: $0\le1$, its
$\texttt{toNat}=1<64$, so the two success tests in
\texttt{UScalar.shiftRight\_IScalar} and \texttt{UScalar.shiftRight} are
true and neither failure alternative is reachable.  The result is the
logical halving
$\texttt{mantissa3}=\lfloor\texttt{mantissa2}/2\rfloor\le2^{53}$.  The legal thresholds
$2\mathbin{\mathtt{<<}}52=2^{53}$ and
$1\mathbin{\mathtt{<<}}52=U$ either replace a carrying value by $U$ or leave
it below $2^{53}$.  The final conjunction with the complement of $U$ clears
bit 52, and no higher bit is set, so the ordinary record has mantissa
strictly below $U$.  Its final exponent test returns the zero-mantissa
infinity sentinel whenever the computed exponent is at least 2047; otherwise
the ordinary record has exponent below 2047.  This proves all three clauses
of (11), including both duplicated product blocks and every underflow,
ordinary, and infinity exit.  Any failed product, cast, checked arithmetic,
or shift would propagate and cannot be confused with the successful premise
(10).

The slow converter has the stronger successful-return invariant
\[
 \texttt{parse_long_mantissa}(t)=\texttt{ok }b
 \Longrightarrow b.m<U\ \land\
   (b.p_{\rm biased}=2047\Longrightarrow b.m=0).                  \tag{12}
\]
Unfold \noderef{num_imp_dec2flt_slow_parse_long_mantissa}.  Its eager zero
and infinity sentinels again come from
\noderef{num_imp_dec2flt_common_BiasedFp_zero_pow2} and have mantissa zero.
A failure of \noderef{num_imp_dec2flt_decimal_seq_parse_decimal_seq}
propagates; zero digits and decimal point below $-324$ return zero, while
decimal point at least 310 returns the infinity sentinel.

For the first loop, the invariant is that \texttt{loop_result} is
\texttt{none} or the zero sentinel.  It holds initially, and the only branch
which writes the field does so after the closure call
\noderef{num_imp_dec2flt_slow_parse_long_mantissa_closure_Insts_CoreOpsFunctionFnTupleUsizeUsize_call}
and \noderef{num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift}, writing
exactly that sentinel.  Every other branch preserves the field or terminates.
The second loop analogously keeps \texttt{loop_result} equal to
\texttt{none} or the infinity sentinel; its only writes occur after
\noderef{num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift} and store exactly
that sentinel.  All intervening casts, array accesses, shifts, and checked
exponent operations are monadic, so a failure cannot yield the successful
outer result.  Therefore every \texttt{some} exit from either loop has
mantissa zero.

If both loop-result fields are \texttt{none}, the third loop repeatedly caps
its positive shift by
\noderef{num_imp_dec2flt_slow_parse_long_mantissa_MAX_SHIFT}, whose value is
60, applies
\noderef{num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift}, and continues;
its only final branch is the one where the exponent has reached the concrete
minimum.  Write $E_{\min}$ for the exactly returned \texttt{EXP\_MIN} value.
After the loop, the successful checked subtraction and addition name
\[
             \texttt{i7}=\texttt{exp23}-E_{\min}+1.
\]
The already evaluated infinite-power value \texttt{i} is 2047.  If the first
guard \texttt{i7 >= i} is true, the function returns the zero-mantissa
infinity sentinel.  If it is false, the signed comparison gives the strict
integer inequality
\[
                         \texttt{i7}<2047.                         \tag{12a}
\]
The code then shifts the decimal sequence and calls
\noderef{num_imp_dec2flt_decimal_seq_DecimalSeq_round}.

On the noncarry branch, the later successful checked operations recompute
\texttt{power2}$=\texttt{exp23}-E_{\min}+1$, so
\texttt{power2}$=\texttt{i7}$.  The returned \texttt{power21} is either
\texttt{power2}, or, when the rounded mantissa is below $U$, the successful
checked subtraction \texttt{power2 - 1}.  In the first case (12a) applies
directly; in the second,
$\texttt{power21}=\texttt{power2}-1<\texttt{power2}<2047$.  Thus every
ordinary noncarry return has exponent strictly below 2047.

On the carry branch, the successful checked increment gives
\texttt{exp24}$=\texttt{exp23}+1$, the code shifts right once, rounds again,
and names
\[
             \texttt{i14}=\texttt{exp24}-E_{\min}+1.
\]
If its second saturation guard is true, the function again returns the
zero-mantissa infinity sentinel.  On the false branch,
\texttt{i14}$<2047$.  The immediately following checked subtraction and
addition recompute exactly the same expression, so the local
\texttt{power2} equals \texttt{i14}.  Again \texttt{power21} is either
\texttt{power2} or the successfully computed \texttt{power2 - 1}; hence in
both cases \texttt{power21}$<2047$.  Thus every ordinary carry return also
has exponent strictly below 2047.

On either ordinary return the code forms $U-1$ and conjoins the rounded word
with that mask.  By \noderef{ModelU64BitAnd}, the result is at most $U-1$.
We have now shown more than the second clause of (12): every ordinary
post-loop record has exponent below 2047, whereas every post-loop return with
exponent 2047 is the zero-mantissa infinity sentinel.  Together with the
eager and loop-sentinel cases above, this exhausts the direct, loop-sentinel,
carry, noncarry, and saturation exits and proves (12); all checked-operation
failures instead propagate.

Now inspect selection in
\noderef{num_imp_dec2flt_dec2flt_with_trace}.  The first integer result obeys
(11).  If \texttt{many_digits} makes the second-computation guard true, the
checked increment and the second call must both succeed, and the second result
also obeys (11).  The comparison
\noderef{num_imp_dec2flt_common_BiasedFp_Insts_CoreCmpPartialEqBiasedFp_eq}
is the exact comparison of both fields.  Equality retains the first pair;
inequality retains its mantissa but replaces its exponent by $-1$.  Thus a
second-call disagreement cannot be assembled: the subsequent negative-
exponent guard forces the slow call.  The same slow replacement occurs for
any other negative post-comparison exponent.  If the guard is false, the
post-comparison pair itself is selected.  Combining (11), (12), and these
first/second/forced-deferral/slow choices gives the exact local invariant for
the selected pair $b$:
\[
 b.m\le U,\qquad b.m=U\Longrightarrow b.p_{\rm biased}=1,
 \qquad b.p_{\rm biased}=2047\Longrightarrow b.m=0.              \tag{13}
\]
The endpoint clause is important: a blanket claim $b.m<U$ would be false for
the integer converter's carry into exponent one, but (13) is precisely what
the assembly argument needs.

\paragraph{Assembly and the final sign.}
Constructor injectivity in (2), using the field schema
\noderef{num_imp_dec2flt_Dec2FltAssemblyTrace}, identifies the local selected
pair $b$ with $A.\texttt{selected_pair}$ and the locally computed OR word
$W$ with $A.\texttt{assembled_word}$.  Apply
\noderef{ParserSelectedExponent} to (2):
\[
             0\le p=b.p_{\rm biased}\le2047.                     \tag{14}
\]
Apply \noderef{ParserSelectedMagnitudeSign} to the same execution: the
recorded $W$ satisfies \texttt{assembledWord} $b\ W$ and $W<S$.

Since $p$ is nonnegative, its signed-to-unsigned cast is exactly $p$.
The shift count 52 is legal by \noderef{ModelU64Shl}, and
\noderef{ModelU64BitOr} identifies the assembly operation with
\[
                     W=\operatorname{lor}(b.m,pU).                \tag{15}
\]
If $b.m=U$, (13) gives $p=1$, and (15) is
\texttt{lor}$(U,U)=U<I$.  If $b.m<U$ and $p\le2046$, the operands occupy
disjoint exponent and fraction fields, so
$W=pU+b.m\le2046U+(U-1)<I$.  Finally, if $p=2047$, (13) gives $b.m=0$ and
$W=I$.  These cases are exhaustive by (13)--(14), and therefore
\[
                         W<I\quad\hbox{or}\quad W=I.              \tag{16}
\]
In the first case $W/U<2047$; in the second $W\bmod U=0$.  Thus a carrier
whose raw word is $W$ cannot satisfy (1).

The exact trace execution also contains
\texttt{biased_fp_to_float}$(b)=\texttt{ok }A.\texttt{assembly_result}$.
Apply \noderef{AssemblyCorrespondence} to $b$.  It supplies a carrier $g$
with the same deterministic call result and with
\texttt{assembledWord} $b\ g$.  Comparing the two result equations gives
$g=A.\texttt{assembly_result}$; unfolding the assembled-word relation and
using (15) identifies its raw word with $W$.  This also agrees with the
recorded assembly fact from \noderef{ParserSelectedMagnitudeSign}; no
proof-internal invariant of either cited theorem is being used.

If the lexical sign is not minus, the extracted false-sign return sets
$f=A.\texttt{assembly_result}$, so (16) proves that $f$ is not NaN.  If it is
minus, the final call uses the concrete negation instance
\noderef{F64_Insts_CoreOpsArithNegF64}.  Its operation
\noderef{ModelF64Neg} succeeds and toggles exactly bit 63.  Because
$W<S$ by \noderef{ParserSelectedMagnitudeSign}, the final raw word is $W+S$.
Reduction modulo $S$ and modulo $U$ therefore gives the same exponent and
fraction fields as $W$, so (16) again excludes (1).  This completes the
Assembled case and, with the three exhaustive successful trace cases, proves
the theorem.
\end{proof}
