\begin{lemma}[Exact many-digit adjustment]
Let $s$ be a modeled source byte slice, let $n$ be a modeled \texttt{isize},
and let $P,T$ be byte lists such that
$s.\mathsf{val}=P\mathbin{\texttt{++}}T$.  Suppose every byte in $P$ is either
48 or 46, and suppose either $T=[]$ or
$T=b::R$ for some byte $b$ and byte list $R$ with $b\ne48$ and $b\ne46$.
Assume
\[
 |s.\mathsf{val}|\le 9223372036854775807,\qquad
 0\le n.\mathsf{val}\le |s.\mathsf{val}|,
\]
and
\[
 \mathsf{isize}_{\min}\le
 n.\mathsf{val}-\mathsf{count}(P,48).
\]
Then there exists a modeled \texttt{isize} $a$ such that
\[
 \texttt{adjust\_many\_digit\_count}(s,n)=\texttt{ok}(a)
 \quad\text{and}\quad
 a.\mathsf{val}=n.\mathsf{val}-\mathsf{count}(P,48).
\]
\end{lemma}
\begin{proof}
Unfold \noderef{num_imp_dec2flt_parse_adjust_many_digit_count}.  In its loop,
maintain a decomposition $P=QR$, an index equal to $|Q|$, and a count equal
to $n$ minus the number of zero bytes in $Q$.  While scanning is true and
$R$ starts with byte 48, the extracted subtraction by one, saturated
subtraction from 47, and cast compute the signed value one; the checked count
subtraction therefore changes the count by exactly one.  When $R$ starts
with byte 46, the same operations compute zero, so the count is unchanged.
In both cases the checked index increment succeeds because the indexed byte
is present and $|s|\le2^{63}-1<2^{64}$, and the remaining source length
strictly decreases.

All intermediate count subtractions are in range.  Their final lower bound
is the assumed lower bound on
$n.\mathsf{val}-\mathsf{count}(P,48)$; before the final zero byte, the count
is larger by the number of zero bytes still in $R$.  Their upper bound follows
from $n.\mathsf{val}\le |s.\mathsf{val}|\le2^{63}-1$.  Thus every checked
signed operation succeeds.

When $R$ is empty, the maintained prefix is all of $P$.  If $T$ is empty,
the length guard returns immediately.  Otherwise its first byte is neither
48 nor 46, so that byte changes the scanning flag to false without changing
the index or count; the next iteration returns.  In either case the returned
count has value $n.\mathsf{val}-\mathsf{count}(P,48)$.  This also proves
termination, since consuming a prefix byte strictly decreases twice the
remaining length, and clearing the scanning flag decreases the Boolean
component of the loop measure.
\end{proof}
