\begin{lemma}[Exact common decimal-sequence finalization]
Let \texttt{start} and \texttt{rest} be modeled byte slices, let
\texttt{scan} and \texttt{out} be decimal-sequence records, let $S,R,X,Y,T$
be finite lists of natural numbers, let $q$ be natural, let $P,E$ be integers,
and let $f$ map I32 values to modeled results.  Assume all of the following:
\begin{itemize}
\item the natural values in \texttt{start} are $X\mathbin{++}Y\mathbin{++}T$
  and those in \texttt{rest} are $T$;
\item $X$ is empty or has the form $X_0\mathbin{++}[b]$ with
  $b\ne48$ and $b\ne46$, every member of $Y$ is 48 or 46, and
  $Y.\operatorname{count}(48)=q$;
\item $\texttt{scan.num\_digits.val}=|S|$ and, for some integer $k$,
  \[
  \texttt{scan.decimal\_point.val}+q+|R|=P+k2^{32};
  \]
\item $\texttt{scan.truncated}=\mathsf{false}$ and
  $S=R\mathbin{++}[0]^q$;
\item after taking the first $\min(|S|,768)$ cells of
  \texttt{scan.digits} and replacing each modeled byte by its natural value,
  the resulting list is $S.\operatorname{take}(\min(|S|,768))$;
\item for every I32 values \texttt{base} and \texttt{result},
  $f(\texttt{base})=\operatorname{ok}(\texttt{result})$ implies
  $\texttt{result.val}=\texttt{base.val}+E$; and
\item the following checked monadic computation returns
  $\operatorname{ok}(\texttt{out})$: subtract the two slice lengths; count
  trailing zeroes in \texttt{start} up to that difference; cast that count to
  I32 and add it to \texttt{scan.decimal\_point}; subtract the count from
  \texttt{scan.num\_digits}; cast the retained count to I32 and add it to the
  intermediate point; cap the count at 768 and set the flag to true exactly
  in the branch where the retained count is greater than 768, otherwise keep
  the count and \texttt{scan.truncated}; apply $f$ to the point; run extracted
  fill loop~1 on \texttt{scan.digits} from the selected count to
  \texttt{MAX\_DIGITS\_WITHOUT\_OVERFLOW}; and construct \texttt{out} from
  the selected count, final point, selected flag, and returned array.
\end{itemize}
Then
\[
 \texttt{out.num\_digits.val}=\min(|R|,768),
\]
the natural values of its first \texttt{out.num\_digits.val} cells equal
$R.\operatorname{take}(\texttt{out.num\_digits.val})$,
$\texttt{out.truncated}=\mathsf{true}$ if and only if $768<|R|$, and there
is an integer $k$ such that
\[
 \texttt{out.decimal\_point.val}=P+E+k2^{32}.
\]
\end{lemma}
\begin{proof}
The two supplied slice decompositions identify the consumed prefix as
$X\mathbin{++}Y$.  Apply \noderef{DecimalSeqTrailingZeroValues} to these
decompositions and to the stated conditions on $X$ and $Y$.  It returns the
number of 48 entries in $Y$, which is $q$ by hypothesis.  The logical-count
equation and $S=R\mathbin{++}[0]^q$ make the successful checked subtraction
return $|R|$.

Apply \noderef{DecimalSeqI32HCastCongruence} to both the zero count and the
retained count.  Inverting the two successful checked additions and using the
supplied congruence for \texttt{scan.decimal\_point} shows that the point passed
to $f$ is congruent to $P$ modulo $2^{32}$.  The supplied equation for every
successful result of $f$ then adds $E$.  The cap branch returns 768 and true
exactly when $768<|R|$; otherwise it returns $|R|$ and preserves the supplied
false scan flag.  Since $S=R\mathbin{++}[0]^q$, taking no more than $|R|$
entries from the stored prefix of $S$ gives the corresponding prefix of $R$.
Finally \noderef{DecimalSeqFillPrefixPreserved} shows that fill loop~1 does not
change that prefix.  These facts give all four conclusions.
\end{proof}
