\begin{helper}[Exact semantics of the final decimal right-shift output loop]
Let $a$ be a 768-cell U8 array, let $0\le k\le60$, put $B=2^k$, and
let an initial write cursor $w\le768$ and a U64 accumulator $c<10B$ be
given.  Suppose the modeled U64 operations successfully compute
\[
 p=1\mathbin{\mathtt{<<}}k,\qquad m=p-1.
\]
If the extracted \texttt{right\_shift\_loop2}, started with Boolean $b$,
array $a$, shift $k$, cursor $w$, accumulator $c$, and mask $m$, returns
Boolean $b'$, array $a'$, and cursor $w'$, then there is a finite list $Z$
of natural decimal digits.  Writing
$F(L)=\operatorname{fold}_{10}(L)$, it satisfies
\[
 (\forall z\in Z,\ z<10),\qquad
 c10^{|Z|}=B\bigl(10F(Z)\bigr),\qquad
 w'=\min(w+|Z|,768).                                      \tag{1}
\]
For every $j<|Z|$ whose destination $w+j$ is below 768, cell $w+j$ of
$a'$ has natural value $Z_j$.  Every cell below the initial cursor $w$ is
unchanged, and every cell at or above the final cursor $w'$ is unchanged.
Finally,
\[
 b'=\mathrm{true}\quad\Longleftrightarrow\quad
 b=\mathrm{true}\ \text{or}\
 \exists j<|Z|,\ 768\le w+j\ \text{and}\ Z_j\ne0.          \tag{2}
\]
\end{helper}
\begin{proof}
By \noderef{Assumptions}, the current Usize carrier has 64 bits; thus
the cursor bounds of 828 or 769 used below fit far below its maximum.
The scalar bounds used below are for this approved width binding.
Unfold the final loop and its body from
\noderef{num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift}, and apply
\noderef{ResultLoopPartial}.  Keep $a,b,w,c$ fixed.  For a current state
$(b_t,a_t,w_t,c_t)$, use an emitted list $Z_t$ and maintain
\[
 c_t<10B,\qquad
 c10^{|Z_t|}=B\bigl(10F(Z_t)\bigr)+c_t,\qquad
 w_t=\min(w+|Z_t|,768).                                   \tag{3}
\]
Maintain also the three array clauses in the statement with $Z_t,a_t,w_t$
in place of $Z,a',w'$, and
\[
 b_t=\mathrm{true}\quad\Longleftrightarrow\quad
 b=\mathrm{true}\ \text{or}\
 \exists j<|Z_t|,\ 768\le w+j\ \text{and}\ (Z_t)_j\ne0.  \tag{4}
\]
Initially $Z_t$ is empty.  Equation (3), the cursor equation, both
unchanged-region claims, and (4) are then immediate from $w\le768$.

Consider a continuation, so the body test gives $c_t>0$.  Apply
\noderef{DecimalRightShiftU64DyadicBridge} to the successful power, mask,
right-shift, and bit-and operations.  If $q$ is the quotient and $e$ the
masked remainder, the bridge gives
\[
 q=c_t/B,\quad e=c_t\bmod B,\quad c_t=qB+e,\quad e<B,
 \quad 10e<2^{64}.                                        \tag{5}
\]
Since $B>0$ and $c_t<10B$, one has $q<10$.  Thus the U64-to-U8 cast is
exact.  The last bound in (5), supplied by the bridge with appended digit
zero, validates the checked multiplication, and the next accumulator is
$c_{t+1}=10e<10B$.

Append $q$ to $Z_t$.  The fold recurrence
$F(Z_t{+\!+}[q])=10F(Z_t)+q$, (3), and (5) give
\[
\begin{aligned}
 c10^{|Z_t|+1}
 &=10\left(B(10F(Z_t))+c_t\right)\\
 &=B\left(10(10F(Z_t)+q)\right)+10e,
\end{aligned}
\]
which is (3) for the continuation.

By
\noderef{num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS}, the symbolic
cap tested by the body is exactly 768.  If $w_t<768$, (3) for the cursor
implies $w_t=w+|Z_t|$.  The body writes the exact U8 digit $q$ there and
successfully increments the cursor.  Hence
$w_{t+1}=w_t+1=\min(w+|Z_t|+1,768)$; the update establishes the new final
stored digit and changes neither cells below $w$ nor cells at or above the
new cursor.  The new destination is retained, so it contributes nothing to
the omitted-digit disjunct in (4).

If $w_t\not<768$, the cursor equation and $w\le768$ give $w_t=768$ and
$768\le w+|Z_t|$.  The body leaves the array and cursor fixed, and changes
the Boolean to true exactly when $q>0$.  Thus the new last digit is outside
the array precisely at a destination at least 768, and the two Boolean
branches give exactly (4) for $Z_t{+\!+}[q]$.  All array clauses are
unchanged in this case.  This proves preservation for every normal
continuation, including every cast, multiplication, update, and cursor
side condition.

At a normal finish the body test gives $c_t=0$.  Equation (3) therefore
becomes the terminal identity in (1), and all other invariant clauses are
already the claimed conclusions.  The supplied successful loop result is
a finite execution; equivalently, its quotient/remainder recurrence also
has an explicit arithmetic bound: after one step the residual is $10e$,
and after at most $k$ further appended zeroes its residual is
$(e10^k)\bmod 2^k=0$, since $2^k\mid10^k$.  Thus no infinite residual case
is hidden in the successful call.  The conclusion follows from
\noderef{ResultLoopPartial}.
\end{proof}
