\begin{lemma}[Exact scientific-exponent scan]
Let $D$ be a nonempty list of ASCII digit bytes, and let $s$ consist of
$D$, optionally preceded by byte 43 or byte 45 according as a supplied sign
is positive or negative.  Define
\[
  G(a,b)=\begin{cases}10a+(b-48),&a<65536,\\a,&a\ge65536,
  \end{cases}
  \qquad E=\operatorname{foldl}(G,0,D).
\]
Then the extracted \texttt{parse\_scientific} consumes all of $s$ and
returns exponent $E$ for no sign or a positive sign, and exponent $-E$ for
a negative sign.
\end{lemma}
\begin{proof}
First unfold the scientific loop in
\noderef{num_imp_dec2flt_parse_parse_scientific}.  For its state $(a,k)$,
maintain $k\le |D|$ and
\[
 a=\operatorname{foldl}(G,0,D.\operatorname{take}(k)).
\]
If $k<|D|$, the extracted indexed read is in bounds.  The byte there lies in
$[48,57]$ by the digit hypothesis.  Consequently wrapping subtraction by 48
is ordinary subtraction, the result is below 10, and the loop takes its
digit branch.  Its second subtraction has the same exact value, and the cast
from eight to signed 64 bits preserves that value.

If $a<65536$, multiplication by 10 is at most 655350 and adding the digit is
at most 655359, so both checked signed operations succeed and compute
$10a+(b-48)=G(a,b)$.  If $a\ge65536$, the extracted guard retains $a$, again
equal to $G(a,b)$.  The checked index increment succeeds because
$k+1\le |D|\le2^{64}-1$.  The standard fold-over-append identity then gives
the invariant at $k+1$, and $|D|-k$ strictly decreases.  If the length guard
is false, $k=|D|$ and taking the whole list turns the invariant into the
claimed exact value $E$.  Thus the loop returns $(E,|D|)$.

Now unfold the outer extracted parser.  The split operation is characterized
by \noderef{ModelSliceSplitFirst}, and the digit test by
\noderef{ModelU8IsAsciiDigit}.  With no explicit sign, the first digit is
neither byte 43 nor byte 45, so the parser retains the whole list.  With an
explicit sign, it drops exactly that first byte.  In all three cases the
remaining slice is precisely $D$, is nonempty, and its first byte passes the
digit test.  Applying the loop result makes the final slice drop start at
$|D|$, hence it returns the empty suffix.  The unsigned and plus-sign
branches return $E$ directly.  In the minus-sign branch, $E$ is a natural
number represented in a signed word and is therefore nonnegative, so it is
not the minimum signed value; checked negation succeeds and has integer value
$-E$.  This proves the return equation and exact exponent in every sign case.
\end{proof}
