\begin{helper}[Exact semantics of the first decimal left-shift loop]
Let $a$ be a 768-cell array, let $b$ be a Boolean, and let
$0\le k\le60$.  Put $n=\mathit{read}$ and $w=\mathit{write}$, assume
$n\le768$ and $n\le w$, and suppose every entry in $a[0:n]$ is below ten.
Write
\[
 x=(a[0:n])\quad\hbox{and}\quad I=\operatorname{fold}_{10}(x).
\]
If the extracted \texttt{left\_shift\_loop0}, started with Boolean $b$,
array $a$, shift $k$, read index $n$, write index $w$, and zero carry,
returns $(b',a',q,c)$, then there is a list of natural digits
$e=(e_0,\ldots,e_{n-1})$ such that
\[
 |e|=n,\qquad e_j<10,\qquad q+n=w,\qquad c<2^k,
\]
and, on writing $W=\operatorname{fold}_{10}(e)$,
\[
                         2^k I=c10^n+W.                 \tag{1}
\]
For every $j<n$ with $q+j<768$, cell $q+j$ of $a'$ has value $e_j$.
Every cell $t<768$ outside the half-open interval $[q,w)$ is unchanged
from $a$.  Finally,
\[
 b'=\mathrm{true}\quad\Longleftrightarrow\quad
 b=\mathrm{true}\ \text{or}\
 \exists j<n,\ 768\le q+j\ \text{and}\ e_j\ne0.        \tag{2}
\]
\end{helper}
\begin{proof}
This is an induction over the exact extracted loop in
\noderef{num_imp_dec2flt_decimal_seq_DecimalSeq_left_shift}, using the
result-loop principle \noderef{ResultLoopPartial}.  Put $B=2^k$, and for a
current state $(\beta,A,r,s,C)$ let $u=n-r$ be the number of input cells
already visited.  The invariant supplies a digit list $E$ and asserts
\[
\begin{gathered}
 0\le r\le n,\qquad s+(n-r)=w,\qquad C<B,\qquad |E|=n-r,\qquad
 (\forall z\in E,\ z<10),                               \tag{3}\\
 B\operatorname{fold}_{10}(x[r:n])
       =C10^{|E|}+\operatorname{fold}_{10}(E).           \tag{4}
\end{gathered}
\]
For each $j<|E|$ with $s+j<768$, the value in $A[s+j]$ is $E_j$.
Every physical cell outside $[s,w)$ still equals its value in $a$, and
\[
 \beta=\mathrm{true}\quad\Longleftrightarrow\quad
 b=\mathrm{true}\ \text{or}\
 \exists j<|E|,\ 768\le s+j\ \text{and}\ E_j\ne0.       \tag{5}
\]
At the initial state take $E$ empty.  Then (3) is immediate, (4) is
$0=0$, the array clauses have empty written interval, and (5) is the
identity $b=b$.

Assume $r>0$.  From $n\le w$ and
$s+(n-r)=w$ one gets $r\le s$, so both unsigned decrements succeed and
give $r_1=r-1$ and $s_1=s-1$.  Moreover $r_1<n\le768$, hence the fixed
array read at $r_1$ succeeds.  This index is below the old write cursor
$s$, so the unchanged-cell clause shows that the value read from the
current array is the original digit $d=x_{r_1}<10$.

The body next casts $d$ to U64 and computes its left shift.  The cast is
exact because $d<10$.  Since $k\le60$,
\[
 d2^k\le9\cdot2^{60}<2^{64},
\]
so the modeled U64 shift has natural value $dB$ rather than a wrapped
value.  With $C<B$, the following checked addition is also exact:
\[
 T=C+dB<(B-1)+9B<10\cdot2^{60}<2^{64}.                 \tag{6}
\]
The division by the nonzero word ten therefore returns
$Q=\lfloor T/10\rfloor$.  Its checked multiplication by ten is in range
because $10Q\le T<2^{64}$, and the subsequent checked subtraction returns
\[
 R=T-10Q=T\bmod10,\qquad 0\le R<10.                    \tag{7}
\]
In particular the U8 cast of $R$ is exact.  Also $T<10B$, so $Q<B$;
this is the new carry bound in (3).

Set $E'=R::E$.  The base-ten fold identity
\[
 \operatorname{fold}_{10}(z::L)
   =z10^{|L|}+\operatorname{fold}_{10}(L)               \tag{8}
\]
applied to both the input suffix and $E'$ combines (4) with
$T=10Q+R$ to give
\[
 B\operatorname{fold}_{10}(x[r_1:n])
   =Q10^{|E'|}+\operatorname{fold}_{10}(E').             \tag{9}
\]
Thus (3)--(4) are preserved, and both cursor equations advance by one.

It remains to check the two destination branches.  If $s_1<768$, the
array update succeeds and writes the exact U8 representation of $R$ at
$s_1$.  This establishes the new $j=0$ retained-digit clause.  Each old
retained digit moves from offset $j$ to offset $j+1$, but its physical
index is unchanged because $s_1+(j+1)=s+j$.  The only changed cell is
$s_1$, so every cell outside $[s_1,w)$ remains unchanged.  Since this
new destination is below 768, it contributes nothing to the omitted-digit
disjunction in (5), and the Boolean itself is unchanged.

If instead $s_1\ge768$, the body performs no array update.  The new
retained-digit requirement has no $j=0$ physical case, while all old cases
again use $s_1+(j+1)=s+j$; the unchanged-cell clause follows immediately.
When $R=0$ the Boolean is unchanged and the new omitted digit is zero, so
(5) is unchanged.  When $R>0$ the body sets the Boolean to true, and the
new witness $j=0$ satisfies $768\le s_1$ and $E'_0=R\ne0$.  Conversely,
every omitted nonzero digit of $E'$ is either this new head or, after
subtracting one from its list index, an omitted nonzero digit already
covered by (5).  Hence (5) is preserved in both cap branches.

If $r=0$, the extracted body returns immediately with the current Boolean,
array, write cursor, and carry.  The invariant then has $|E|=n$ and
$s+n=w$; its input suffix is all of $x$, so (4) is exactly (1).  Its array
and Boolean clauses are exactly the two asserted postconditions.  Applying
\noderef{ResultLoopPartial} to the successful loop return proves the
claim.
\end{proof}
