\begin{helper}[Exact semantics of the main decimal right-shift output loop]
Let $a$ be a 768-cell U8 array, let $0\le k\le60$, put $B=2^k$, and
let $1\le r\le i$ with $r\le768$.  Suppose every entry in $a[0:i]$ is
below ten, and let a U64 accumulator $c$ satisfy $c<10B$.  Suppose also that the
modeled U64 operations successfully compute
\[
 p=1\mathbin{\mathtt{<<}}k,
 \qquad m=p-1.
\]
If the extracted \texttt{right\_shift\_loop1}, started with limit $i$,
array $a$, shift $k$, read cursor $r$, write cursor zero, accumulator $c$,
and mask $m$, returns array $a'$, write cursor $w'$, and accumulator $c'$,
then there is a list $E$ of natural decimal digits such that
\[
 i\le768,\qquad |E|=i-r=w',\qquad
 (\forall z\in E,\ z<10),\qquad c'<10B.                         \tag{1}
\]
Writing $x$ for the list of natural values of all cells of $a$ and
$F(L)=\operatorname{fold}_{10}(L)$, the exact long-division equation is
\[
 c10^{i-r}+F(x[r:i])=B\bigl(10F(E)\bigr)+c'.                  \tag{2}
\]
For every $j<|E|$, cell $j$ of $a'$ has natural value $E_j$.  Every
physical cell $j\ge w'$ is unchanged from $a$; in particular every cell
$j\ge i$ is unchanged from $a$.
\end{helper}
\begin{proof}
Unfold the main output loop and its body from
\noderef{num_imp_dec2flt_decimal_seq_DecimalSeq_right_shift}, and apply
the result-loop induction principle \noderef{ResultLoopPartial}.  Keep the
initial array $a$, cursor $r$, and accumulator $c$ immutable.  For a current
state $(A,s,w,C)$ use the invariant that
\[
 r\le s\le i,\qquad s\le768,\qquad w=s-r,\qquad C<10B,       \tag{3}
\]
and that there is a decimal-digit list $E_s$ with
\[
 |E_s|=w,
 \qquad
 c10^{s-r}+F(x[r:s])=B\bigl(10F(E_s)\bigr)+C.                \tag{4}
\]
For every $j<|E_s|$, cell $j$ of $A$ has natural value $(E_s)_j$, and
every physical cell $j\ge w$ still equals cell $j$ of the immutable array
$a$.  Initially $s=r$, $w=0$, and $C=c$.  Take $E_r$ empty.  The slice
$x[r:r]$ is empty, so (3)--(4) and both array clauses are immediate.

Suppose $s<i$.  Since $r\ge1$ and $w=s-r$, one has $w<s$.  A normal return
of this body step forces its fixed-array read at $s$ to succeed; if
$s\ge768$, the extracted array-index operation fails and cannot equal the
assumed normal body result.  Hence $s<768$.  The unchanged suffix clause
therefore identifies the current array cell read at $s$ with the immutable
original cell $a[s]$, and the digit hypothesis supplies
\[
                         d=a[s]<10.                           \tag{5}
\]
Apply \noderef{DecimalRightShiftU64DyadicBridge} to the successful right
shift of $C$ and the exact mask operation in this body step.  If their
outputs are $q$ and $e$, respectively, the helper gives
\[
 q=\lfloor C/B\rfloor,\qquad e=C\bmod B,\qquad
 C=qB+e,qquad e<B,                                          \tag{6}
\]
and also $10e+d<2^{64}$.  From $C<10B$ and $B>0$,
$q=C/B<10$.  Consequently the extracted U64-to-U8 cast of $q$ is exact.
The multiplication $10e$ and addition of the U64 cast of $d$ are both
within range by the last bound supplied by the bridge, and the U8-to-U64
cast of $d$ is exact.  Thus the new accumulator is exactly
\[
                         C_1=10e+d.                           \tag{7}
\]
In particular, using $e<B$ and $d<10$,
\[
 C_1\le10(B-1)+9<10B,                                       \tag{8}
\]
so the strict accumulator bound required at the next iteration is
preserved.  The two checked cursor increments are valid because $s<768$
and $w<s$.

Set $E_{s+1}=E_s\mathbin{+\!+}[q]$.  Its length is $w+1$, all its entries
are below ten, and
\[
 F(E_{s+1})=10F(E_s)+q,
 \qquad F(x[r:s+1])=10F(x[r:s])+d.                           \tag{9}
\]
Multiplying (4) by ten, adding $d$, and substituting (6)--(7) gives
\[
\begin{aligned}
 c10^{s+1-r}+F(x[r:s+1])
 &=10\left(B(10F(E_s))+C\right)+d\\
 &=B\left(10(10F(E_s)+q)\right)+(10e+d)\\
 &=B\bigl(10F(E_{s+1})\bigr)+C_1,
\end{aligned}
\]
which is (4) for the next state.

The array write is at $w<s<768$, hence is in range.  It stores the
exact U8 representation of $q$, establishing the new final cell of the
emitted prefix.  Earlier prefix cells have indices below $w$ and are not
changed.  The update changes only cell $w$, so every cell at or above
$w+1$ remains equal to its immutable value in $a$.  Advancing both cursors
also gives $w+1=(s+1)-r$.  This proves every continuation clause of the
invariant, including all read, write, cast, and U64 side conditions.

At a normal finish the body test is false.  Together with $s\le i$, this
gives $s=i$.  The invariant bound $s\le768$ also proves $i\le768$.
Thus (3)--(4) become (1)--(2), and the emitted-prefix and
unchanged-suffix clauses have exactly the asserted form.  Finally,
$w'=i-r\le i$, so every $j\ge i$ is also at or above $w'$ and is unchanged.
The conclusion follows from \noderef{ResultLoopPartial}.
\end{proof}
