\begin{lemma}[Exact decimal-sequence exponent loop]
Let $s$ be a source-valid byte slice whose byte-value list renders a list
$D$ of decimal digits, every member of $D$ being below ten.  Define
\[
 G(a,r)=\begin{cases}10a+r,&a<65536,\\a,&a\ge65536.\end{cases}
\]
Then \texttt{parse\_decimal\_exponent($s$)} returns normally with an I32
value whose mathematical value is \(\operatorname{foldl}(G,0,D)\).
\end{lemma}
\begin{proof}
Map equality and the digit bound imply that the $j$th byte of $s$, for every
$j<|D|$, is exactly $48+D[j]$ and lies in $48,\ldots,57$.  We prove by
induction on $j$ the invariant for the loop in
\noderef{num_imp_dec2flt_decimal_seq_parse_decimal_exponent}: before its
$j$th test, the cursor is the Usize value $j$ and the I32 accumulator has
value the fold of $G$ over \texttt{take $j$ $D$}.

The invariant holds initially because both cursor and accumulator are zero.
If $j<|D|$, source-validity
\noderef{SourceValidByteSlice} gives
$j<|D|\le2^{63}-1<2^{64}$, so the slice read at $j$ is in bounds and the
checked cursor increment $j+1$ cannot overflow Usize.  The byte is an ASCII
digit, hence the digit test is true, wrapping subtraction by 48 is ordinary
subtraction, and the U8-to-I32 cast returns exactly $D[j]\in[0,9]$.

If the old accumulator is at least 65536 the extracted branch retains it,
which is $G(a,D[j])$ by definition.  Otherwise $0\le a\le65535$; therefore
\[
 0\le 10a+D[j]\le10\cdot65535+9=655359<2^{31}.
\]
Thus the checked I32 multiplication by ten and addition of the digit both
return normally and yield exactly $G(a,D[j])$.  This proves the invariant
after the continuation.  If $j=|D|$, the bounds test is false and the loop
returns the accumulator.  Induction therefore reaches the normal return at
$j=|D|$, and the invariant there is the full fold asserted in the statement.
The reducible wrapper merely invokes that loop with the two zero initial
values, so choosing its returned I32 value proves the existential equation.
\end{proof}
