\begin{lemma}[Branchwise parser factorization]
For every byte slice $s$, the extracted call
$\texttt{parse\_decimal\_seq}(s)$ equals the following Result computation,
including its failure and divergence outcomes.
First execute the scan computation $Q(s)$ below and obtain $(u,a,f)$;
then execute the finishing computation $R(s,u,a,f)$ below.

The computation $Q(s)$ first calls DecimalSeq's default constructor, obtaining
$d$, calls $\texttt{parse\_decimal\_seq\_loop0}(s)$, obtaining $s_1$, and
calls $\texttt{parse\_digits\_into\_seq}(s_1,d)$, obtaining $(s_2,d_1)$.
It calls $\texttt{is\_empty}(s_2)$. If true, it returns
$(s_2,d_1,0\texttt{\#usize})$. Otherwise it reads index zero of $s_2$.
If that byte is not $46\texttt{\#u8}$, it returns the same triple.
If it is $46\texttt{\#u8}$, it obtains $s_3$ by the extracted
RangeFrom-Usize slice index with start one. When $d_1.\mathit{num\_digits}=0$,
it calls loop 2 on $s_3$, then loop 3 on the returned slice with
$d_1.\mathit{num\_digits}$ and $d_1.\mathit{digits}$. Otherwise it calls
loop 5 directly on $s_3$ with those same operands. Each loop 3 or 5 returns
a triple $(v,n,A)$. In either case it calls
$\texttt{parse\_digits\_into\_seq}(v,
\{d_1\text{ with count }n\text{ and digits }A\})$, obtaining $(u,a)$;
it computes the checked difference $f=\texttt{len}(s_3)-\texttt{len}(u)$
and returns $(u,a,f)$.

Let $E(u)$ call $\texttt{is\_empty}(u)$ and return I64 zero when true.
Otherwise it reads index zero. For byte 101 or 69 it obtains the
RangeFrom-Usize suffix with start one, calls $\texttt{parse\_scientific}$,
and returns its optional exponent unwrapped with I64-zero default;
for every other byte it returns I64 zero. The 101 test precedes the 69 test.

The computation $R(s,u,a,f)$ first selects $(r,b)$ as follows.
If $a.\mathit{num\_digits}\ne0$, compute the checked difference
$c=\texttt{len}(s)-\texttt{len}(u)$, call
$\texttt{count\_trailing\_zeros}(s,c)$ to obtain $z$, and compute the
checked difference $k=a.\mathit{num\_digits}-z$.
If $k>\texttt{MAX\_DIGITS}$, select $(\texttt{MAX\_DIGITS},\texttt{true})$;
otherwise select $(k,a.\mathit{truncated})$.
When the scan count is zero, select
$(a.\mathit{num\_digits},a.\mathit{truncated})$ without either difference
or the reverse scan. Next call $E(u)$, obtaining $e$; call
$\texttt{final\_decimal\_point}(a.\mathit{num\_digits},f,e)$, obtaining $p$;
call loop 1 with range $[r,\texttt{MAX\_DIGITS\_WITHOUT\_OVERFLOW})$
and array $a.\mathit{digits}$, obtaining $B$; and return
$\{\mathit{num\_digits}=r,\mathit{decimal\_point}=p,
\mathit{truncated}=b,\mathit{digits}=B\}$.
All computations above use sequential Result binds, aborting on failure
or divergence. In particular the saved operand of the final point call
is the untrimmed count of $a$, not $r$.
\end{lemma}
\begin{proof}
Unfold \noderef{num_imp_dec2flt_decimal_seq_parse_decimal_seq}.
Associate Result binds to the right. This identity holds for all Results:
for $\texttt{ok}\ v$ both sides substitute $v$ into the first continuation,
for $\texttt{fail}\ t$ both sides return that same failure, and for
$\texttt{div}$ both sides diverge. A bind of an explicitly returned tuple
substitutes its components into its continuation. These identities let us
compare the continuations after the common default, loop 0, and integer
digit-scan calls without assuming those calls terminate normally. If any
fails or diverges, both whole computations already have that identical result.
The shared Aeneas slice primitives are also explicit: the empty test returns
$\texttt{ok}(|u.\mathit{val}|=0)$, and index-Usize matches the optional
list entry, returning its value when present and array-out-of-bounds failure
when absent. Thus the empty and head observations below require no parser
correctness lemma or additional input premise.

Fix an arbitrary returned pair $(s_2,d_1)$. There are two possible list
shapes for $s_2.\mathit{val}$. If it is empty, the primitive empty test
normally returns true. The source's first arm selects the trim/cap pair
for $(s,s_2,d_1)$ and its explicit-exponent conditional immediately
returns I64 zero. The scan computation returns $(s_2,d_1,0)$.
In $R$, the repeated empty test on exactly $s_2$ also normally returns
true and $E(s_2)$ returns that same zero. Substituting these values
leaves exactly the source's point call, loop 1, and record construction,
with identical operands and sequencing.

If $s_2.\mathit{val}=h::t$, the primitive empty test normally returns
false and primitive index zero normally returns $h$. These are direct
consequences of the slice primitives' list meanings, with index bound
$0<|h::t|$. Split on $h=46\texttt{\#u8}$.
If false, $Q$ returns $(s_2,d_1,0)$. The source's last arm selects exactly
the trim/cap pair in $R$, then tests the already read $h$ for 101 and 69.
The fresh empty and index calls of $E(s_2)$ normally return false and
the same $h$. After those substitutions its marker tests, suffix indexing,
scientific call, and unwrap are identical to the source's exponent
computation, including every possible abnormal result of those calls.
The loop 7 equality in \noderef{DecimalSeqDuplicateLoops} replaces
the source fill by loop 1 on the identical range and array. The point
operands and resulting record therefore agree.

If $h=46\texttt{\#u8}$, both sides next execute exactly the same
RangeFrom-Usize index call yielding $s_3$. Again bind congruence handles
abnormal results without a normality assumption. For a normal result,
split on $d_1.\mathit{num\_digits}=0$.
In the zero case both sides execute loop 2, loop 3, and the scalar
digit scan with the same updated record. Associate binds past these
calls and substitute the components of their returned triples and pairs.
Both sides then compute the same full fractional difference
$\texttt{len}(s_3)-\texttt{len}(u)$, followed by the same trim/cap
selection and the same fresh empty test and exponent computation on $u$.
The loop 4 equality in \noderef{DecimalSeqDuplicateLoops} identifies
the fill with loop 1. All other operands and the record agree literally.
In the nonzero case both sides instead execute loop 5 and the scalar
digit scan, followed by that same difference and finishing sequence.
The loop 6 equality in \noderef{DecimalSeqDuplicateLoops} identifies
the remaining fill. Tuple substitution and bind associativity give the
same record here as well.

No call has been moved across another possibly abnormal call: in each
arm trim/cap still precedes exponent parsing, which precedes the saved-count
point call and fill. Only repeated primitive observations with the proved
normal values were eliminated. The equalities in
\noderef{DecimalSeqDuplicateLoops} also hold for every Result, not just
normal arrays. Thus the four branch comparisons prove the claimed
unconditional Result equality, including failure and divergence.
\end{proof}
