\begin{lemma}
Let $-342\le q\le308$ and let $W$ be a 64-bit word with
$2^{63}\le W<2^{64}$.  Suppose the extracted product approximation at
precision $55$ returns limbs $(lo,hi)$, and suppose either $lo\ne2^{64}-1$
or $-27\le q\le55$.  Let $(a_q,b_q)$ be the accessed table entry and use
$e_q,D_q,T_q$ from \noderef{IntegerPowerTableCertificate}.  Put
\[
 R=WT_q/2^{64},\quad Y=hi\,2^{64}+lo,\quad
 u=\lfloor hi/2^{63}\rfloor,\quad s=73+u,
 \quad G=\lfloor hi/2^{9+u}\rfloor.
\]
Then $u\le1$, and $Y$ is either $Wa_q$ or
$Wa_q+\lfloor Wb_q/2^{64}\rfloor$.  Moreover
\[
 G2^s\le R<(G+1)2^s,                                    \tag{1}
\]
and the exact lower-even midpoint test is
\[
 R=G2^s\ \land\ G\bmod4=1
 \quad\Longleftrightarrow\quad
 \begin{array}{l}
 -4\le q\le23,\quad G\bmod4=1,\quad lo\le1,\\
 G2^{9+u}=hi.
 \end{array}                                             \tag{2}
\]
The table index, cast, and access in this description all return normally.
\end{lemma}
\begin{proof}
By \noderef{num_imp_dec2flt_table_SMALLEST_POWER_OF_FIVE} and
\noderef{num_imp_dec2flt_table_LARGEST_POWER_OF_FIVE}, the extracted signed
32-bit endpoint constants have the defining values $-342$ and $308$,
respectively.  Unfold
\noderef{num_imp_dec2flt_lemire_compute_product_approx}.  Casting these two
values to signed 64 bits succeeds with values $-342$ and $308$, so the first
two extracted assertions are exactly $-342\le q$ and $q\le308$ and follow
from the hypotheses.  The routine then casts the smallest endpoint a second
time, again obtaining the signed 64-bit value $-342$, so its checked
subtraction is exactly $q-(-342)$.  By
\noderef{IntegerPowerTableCertificate}, that subtraction returns the
certificate's $\mathit{delta}$, its following checked cast to a 64-bit
\texttt{usize} returns the certificate's index, and access to the same
extracted table at that index returns the certificate's pair $(a_q,b_q)$.
Thus the routine uses exactly the index and pair supplied by the certificate.

Set $B=2^{64}$.  The same certificate gives $D_q=a_qB+b_q$, together with
all of its normalization, negative-index, exactness, and directed-error
clauses.  Since $55<64$, the precision assertion succeeds and the mask is
$(B-1)\mathbin{\mathtt{>>>}}55=511$.

Unfold \noderef{num_imp_dec2flt_lemire_full_multiplication}.  Widening two
64-bit words to 128 bits is exact and their product is below $2^{128}$;
narrowing returns its remainder modulo $B$, and shifting right by $64$
returns its quotient by $B$.  Thus the first call returns the two limbs of
$Wa_q$.  The mask comparison, whose bitwise operation is total and has its
ordinary bit meaning by \noderef{ModelU64BitAnd}, tests whether the low nine
bits of the first high limb are all one.  If not, the routine returns those
limbs and
\[
                              Y=Wa_q.                      \tag{4}
\]
If so, the high limb of the second multiplication is
\[
                         c=\left\lfloor\frac{Wb_q}{B}\right\rfloor.
\]
The wrapping addition returns the low limb of $Wa_q+c$, and comparison with
$c$ detects exactly whether that addition carried.  The first high limb is
strictly below $a_q<B$, so its carried increment cannot overflow.  Therefore
the refining branch returns
\[
 Y=Wa_q+c
   =Wa_q+\left\lfloor\frac{Wb_q}{B}\right\rfloor
   =\left\lfloor\frac{WD_q}{B}\right\rfloor.              \tag{5}
\]
This proves the asserted two alternatives for $Y$ directly from the extracted
control flow.

Because $hi<B$, one has
$u=\lfloor hi/2^{63}\rfloor\le1$.  Put $d=9+u$ and
$K=B2^d=2^{73+u}=2^s$.  Euclidean division of
$Y=hiB+lo$ by $K$ gives
\[
                  \left\lfloor Y/K\right\rfloor
                  =\left\lfloor hi/2^d\right\rfloor=G.    \tag{6}
\]
The certificate's $2^{127}\le T_q<2^{128}$ and
$2^{63}\le W<B$ imply
\[
                           2^{126}\le R<2^{128}.           \tag{7}
\]
We next prove that $R$ and $Y$ lie in the same $K$-cell.

First suppose the routine does not refine, so (4) holds.  On a floor entry,
write $T_q=D_q+\epsilon$ with $0\le\epsilon<1$.  Then
\[
              R-Y=\frac{W(b_q+\epsilon)}B,\qquad
              0\le R-Y<B.                                \tag{8}
\]
On a ceiling entry, the certificate supplies $q=-n$, positive $z_n$, and
$P=5^n$, $N=2^{z_n+127}$ with $T_q=N/P$.  Dividing
$N=kP+r$ gives $0<r<P$: $P$ is odd and greater than one, so it cannot divide
the power of two $N$.  The strict interval $D_q-1<T_q<D_q$ therefore gives
\[
 D_q=k+1=\frac{N+\delta}{P},\qquad \delta=P-r,qquad
 0<\delta<P.                                               \tag{9}
\]
Here $1\le n\le27$, so
$P\le5^{27}<2^{63}<B$.  Also $z_n\ge3$, since
$5\le P<2^{z_n}$, and hence $B\mid N$.  If $b_q=0$, then
$B\mid D_q$ and (9) would make $B$ divide
$D_qP-N=\delta$, contrary to $0<\delta<P<B$.  Thus $b_q\ge1$, and
\[
              R-Y=\frac{W(b_q-\delta/P)}B,\qquad
              0<R-Y<B.                                   \tag{10}
\]
The failed mask test says $hi\bmod512\ne511$.  Since $d$ is $9$ or $10$,
this implies $hi\bmod2^d\le2^d-2$, and consequently
\[
 Y\bmod K\le(2^d-2)B+(B-1)<K-B.                          \tag{11}
\]
The positive correction of size less than $B$ in (8) or (10) cannot cross
the next $K$-boundary.  Thus $R$ and $Y$ have the same quotient by $K$ in
the nonrefining branch.

Now suppose the routine refines, so (5) holds.  For a floor entry, $R$ is at
least $Y$ and less than $Y+2$.  If it crossed the next integral
$K$-boundary, that boundary would have to be $Y+1$, forcing
$Y\bmod B=B-1$, hence $lo=B-1$.  The continuing-sentinel hypothesis then
forces $-27\le q\le55$.  A floor entry in that interval has
$0\le q\le55$, and the certificate says $D_q=T_q$ there.  In that exact
case $R=WD_q/B<Y+1$, so no boundary is crossed after all.

For a ceiling entry, use (9).  Write $WD_q=YB+\rho$ with
$0\le\rho<B$.  Then
\[
 BP(R-Y)=WN-YBP=\rho P-W\delta.                           \tag{12}
\]
Since $0<W\delta<BP$ and $0\le\rho P<BP$, the absolute value of the
integer on the right is below $BP$.  Also
$Y-1<R<Y+1$, so a downward $K$-boundary could be crossed only when
$K\mid Y$.  In that case $WN$ is divisible by $2^{z_n+127}$, with
$z_n+127\ge130$, while $YBP$ is divisible by
$2^{s+64}$, with $s+64\ge137$.  Their difference in (12) is thus divisible
by $2^{130}$.  But $P<2^{63}$ makes its absolute value less than
$BP<2^{127}$, so the difference is zero.  Hence $R=Y$ at the only possible
downward boundary.  This proves that $R$ and $Y$ share a $K$-cell in every
branch.  Together with (6), this is exactly (1).

It remains to prove (2).  Write $W=2^vh$ with $h$ odd and
$0\le v\le63$.  Assume first that $R=G2^s$ and $G\bmod4=1$, so $G$ is odd.
If $q=-n<0$, the certificate's negative-index formula gives
$R=W2^{z_n+63}/5^n$.  Clearing the odd denominator in $R=G2^s$ and comparing
the power-of-two and odd parts gives
\[
 v+z_n+63=s,\qquad h=G5^n.                               \tag{13}
\]
As $v\ge0$ and $s\le74$, this forces $z_n\le11$.  Since
$2^{11}<5^5$, the certificate's inequality $5^n<2^{z_n}$ then forces
$n\le4$.  If $q\ge0$, the definition of $T_q$ gives
\[
 v+63-e_q=s,\qquad h5^q=G.                               \tag{14}
\]
The odd factors $h5^q$ and $G$ force first the displayed equality of 2-adic
exponents and then the equality of odd parts.  Here $v\le63$ and $s\ge73$,
so $e_q\le53$.  The normalization clause of
the certificate is equivalent in this case to
$2^{e_q}\le5^q<2^{e_q+1}$; hence $5^q<2^{54}$, while
$5^{24}>2^{55}$.  Thus $q\le23$.  Every odd midpoint therefore has
$-4\le q\le23$.

We now finish the forward implication, including the product calculation at
the four negative indices.  If $0\le q\le23$, the certificate says both
$D_q=T_q$ and $b_q=0$.  Thus $D_q=a_qB$, $R=Wa_q$, and the correction
$c$ is zero.  Whether or not the mask requests the second multiplication,
the returned integer is $Y=R=G2^s$.  Hence $lo=0$ and
$hi=R/B=G2^{9+u}$.

If $q=-n$ with $1\le n\le4$, retain $P,N,\delta$ from (9).  At the assumed
midpoint, $R=WN/(BP)=G2^s$ is an integer, while
\[
 \frac{WD_q}{B}=\frac{WN}{BP}+\frac{W\delta}{BP}
                =R+\frac{W\delta}{BP}.
\]
The bounds $W<B$ and $0<\delta<P$ give
$0<W\delta/(BP)<1$, so independently of which product branch is taken,
\[
 \left\lfloor\frac{WD_q}{B}\right\rfloor=R,\qquad
 Wa_q+c=R,\quad c=\left\lfloor\frac{Wb_q}{B}\right\rfloor. \tag{15}
\]
If $c=0$, the first product is already $Wa_q=R$, and a possible refinement
adds zero.  If $c>0$, then $0<c<B$ because $W,b_q<B$, and (15) gives
$Wa_q=R-c$.  Since $R/B=G2^{9+u}$ is integral, the first product has high
limb $R/B-1$ and low limb $B-c$.  The low nine bits of that high limb are
all one, because $R/B$ is divisible by $2^9$.  The mask therefore forces
the refining branch, whose correction is exactly $c$ and whose carry returns
exactly $R$.  In both subcases the final limbs are
$lo=0$ and $hi=G2^{9+u}$.  This proves the forward implication of (2).

Conversely, assume the right side of (2), put $j=lo\in\{0,1\}$, and let
$L=G2^s$.  The reconstruction hypothesis gives
\[
                              Y=L+j.                       \tag{16}
\]
For $0\le q\le23$, the certificate again gives $D_q=T_q$ and $b_q=0$, so
both product paths give $Y=R=Wa_q$.  Moreover
$5^q\le5^{23}<2^{54}$ and normalization give $e_q\le53$, while
$D_q=T_q=5^q2^{127-e_q}=a_qB$ gives
$a_q=5^q2^{63-e_q}$.  Hence $2^{10}\mid a_q$ and $2^{10}\mid Y$.
Since $2^{10}\mid L$ and $j\in\{0,1\}$, (16) forces $j=0$, so $R=L$.

It remains only $q=-n$ for $1\le n\le4$.  The four inequalities defining
$z_n$, followed by division of $N=2^{z_n+127}$ by $P=5^n$, are
\[
\begin{array}{c|r|r|r|r|r|r|r}
n&P&z_n&r&\delta&a_q&b_q&\nu_2(a_q)\\ \hline
1&5&3&4&1&14757395258967641292&14757395258967641293&2\\
2&25&5&21&4&11805916207174113034&4427218577690292388&1\\
3&125&7&59&66&9444732965739290427&7231123676894144234&0\\
4&625&10&472&153&15111572745182864683&15259146697772541097&0.
\end{array}                                                \tag{17}
\]
Indeed, the certificate states $T_q=N/P$, $D_q-1<T_q<D_q$, and
$D_q=a_qB+b_q$; hence $D_q=\lfloor N/P\rfloor+1$, so every entry of (17)
is ordinary Euclidean division from statement-level facts.

If the extracted routine refined, (5), (9), and (16) show
$Y=\lfloor WD_q/B\rfloor=L+j$ and $Y-1<R<Y+1$; hence
$|R-L|<2$.  The integer $WN-LBP=BP(R-L)$ is divisible by $2^{130}$:
$N$ has at least that power of two by (17), and $L$ contributes at least
$2^{73}$ before multiplication by $B$.  Its absolute value is below
$2BP<2^{75}$.  It is therefore zero, and $R=L$.

If the routine did not refine, (4) and (16) give $Wa_q=L+j$.  When $j=0$,
(17) gives
$\nu_2(Wa_q)\le63+2<73\le s=\nu_2(L)$, a contradiction.  When $j=1$,
$Wa_q=L+1$ is odd, so (17) leaves only $n=3,4$.  Because
$G\bmod4=1$, reduction modulo $2^{s+2}$ gives
$Wa_q\equiv2^s+1\pmod {2^{s+2}}$.  Inverting the displayed odd values of
$a_q$ gives the following least nonnegative residues for $W$:
\[
\begin{array}{c|c|r}
n&u&W\bmod 2^{s+2}\\ \hline
3&0&36501965416058737238515\\
3&1&27057232450319446811123\\
4&0&35111753888106220892547\\
4&1&63445952785324092174723.
\end{array}                                                \tag{18}
\]
Each number in (18) exceeds $B$, whereas $0\le W<B$ and
$B<2^{s+2}$, a contradiction.  Thus the nonrefining case cannot occur, and
the refining case already gave $R=L$.  Combining this equality with the
common assumption $G\bmod4=1$ proves the reverse implication and completes
(2).
\end{proof}
