\begin{lemma}[Finite encoding arithmetic and both saturation tests]
Let $-1022\le e\le1260$, $m,m_4$ be natural numbers, and
$t=X/2^{e-52}$ satisfy $0<t<T=2^{53}$.
Assume $e>-1022$ implies $U=2^{52}\le t$.
Suppose $m$ satisfies both nearest half-step inequalities for $t$ and
is even at either tie. If $m\ge T$, suppose $m_4$ independently satisfies
both nearest half-step inequalities for $t/2$ and is even at either tie.
Define the raw arithmetic result, in source test order, by
\[
 r=\begin{cases}
 2047U,&e\ge1024,\\
 2047U,&e<1024,\ m\ge T,\ e\ge1023,\\
 (e+1024-\mathbf1_{m_4<U})U+(m_4\bmod U),
     &e<1023,\ m\ge T,\\
 (e+1023-\mathbf1_{m<U})U+(m\bmod U),
     &e<1024,\ m<T .
 \end{cases}
\]
Integer coefficients in the last two rows are converted to naturals;
the proof establishes their nonnegativity. Then $X\ge0$ and
at least one of these raw-word alternatives holds, with
$U=2^{52}$, $T=2^{53}$, $J=2047U$ and $H=2^{1024}-2^{970}$:
\begin{enumerate}
\item $r=J$ and $H\le X$;
\item for some natural $j\le T$, $r=j$, $X\le T2^{-1074}$,
$X\le j2^{-1074}+2^{-1075}$,
$j2^{-1074}\le X+2^{-1075}$, and
$(X=(j+1/2)2^{-1074}\ \lor\ X=(j-1/2)2^{-1074})
\Longrightarrow j\bmod2=0$;
\item for some natural $p,j$ with $2\le p\le2046$, $U\le j\le T$,
and $p<2046$ or $j<T$, put $\Delta=2^{p-1075}$.
Then $r=pU+(j-U)$, $U\Delta\le X\le T\Delta$, $X<H$,
$X\le j\Delta+\Delta/2$, $j\Delta\le X+\Delta/2$, and
$(X=(j+1/2)\Delta\ \lor\ X=(j-1/2)\Delta)
\Longrightarrow j\bmod2=0$.
\end{enumerate}
\end{lemma}
\begin{proof}
All scales are positive, so $t>0$ gives $X>0$.
Nearest inequalities and $t<T$ give $m<T+1/2$, hence $m\le T$.
If $m\ge T$, then $m=T$ and $T-1/2\le t<T$.
Dividing by two gives $U-1/4\le t/2<U$.
The separate inequalities for $m_4$ imply
$U-3/4\le m_4<U+1/2$. Since $m_4$ is integral, $m_4=U$.

If the first saturation test succeeds, $e\ge1024>-1022$ gives
$t\ge U$ and
$X=t2^{e-52}\ge U2^{e-52}=2^e\ge2^{1024}>H$.
The raw result is $J$, so the infinity alternative holds.

Assume now $e\le1023$. If carry occurs and the second test succeeds,
$e=1023$ and $m=T$. The first nearest lower bound gives
\[
 X\ge(T-1/2)2^{971}=2^{1024}-2^{970}=H,
\]
so again the infinity alternative holds.
If carry occurs but the second test is false, $e\le1022$ and
$m_4=U$, so the decrement indicator is zero, the remainder is zero,
and $r=(e+1024)U$.
When $e=-1022$, take the low-grid witness $j=T$.
When $e>-1022$, take $p=e+1023$, $j=T$.
Then $2\le p\le2045$ and
$r=(p+1)U=pU+(T-U)$.
For either witness the first-round nearest inequalities scaled by
$2^{e-52}$ give the stated distance bounds; $j=T$ is even.
The magnitude interval follows from $U\le t<T$ in the normal case,
or $t<T$ in the low-grid case.

In the noncarry case $m<T$, set $j=m$.
For $e=-1022$, the coefficient is one before conditional decrement.
If $m<U$, decrement gives zero and the remainder is $m$.
If $U\le m<T=2U$, no decrement occurs and the remainder is $m-U$.
Both cases give $r=m=j$, so the low-grid alternative follows by scaling
the first-round inequalities and tie implication by $2^{-1074}$.
Also $X=t2^{-1074}<T2^{-1074}$.

For $e>-1022$, $t\ge U$ and $m\ge t-1/2\ge U-1/2$ force
$m\ge U$ by integrality. Thus no decrement occurs, and
$r=(e+1023)U+(m-U)$.
Take $p=e+1023$, $j=m$; then $2\le p\le2046$ and $U\le j<T$.
The scale $2^{e-52}$ is exactly $\Delta=2^{p-1075}$.
The assumed $U\le t<T$ gives the binade bounds and scaling gives
the nearest inequalities and the exact even-tie implication.

Finally verify the finite threshold clause, including the top endpoint.
For every finite case with $e\le1022$,
$X<T2^{e-52}=2^{e+1}
\le2^{1023}<H$.
If $e=1023$ and the result is finite, carry cannot occur, so
$m\le T-1$. The nearest upper bound gives $t\le T-1/2$.
Equality forces $m=T-1$ and $t=m+1/2$,
contradicting the even-tie implication because $T-1$ is odd.
Hence $t<T-1/2$ and $X<(T-1/2)2^{971}=H$.
All raw coefficients are nonnegative: the first bias is at least one
and its conditional decrement at most one; the carry bias is at least
two and its decrement is zero. This proves every alternative and covers
zero/subnormal, finite carry and exact top-overflow ties.
\end{proof}
