\begin{definition}[Decimal-sequence fractional finalization]
\label{def:DecimalSeqFractionalFinish}
For arbitrary modeled slices $s$ and \texttt{rest} and an arbitrary modeled
decimal-sequence record $d$, \texttt{DecimalSeqFractionalFinish} is the
following checked monadic computation.  It subtracts
$|\texttt{rest}|$ from $|s|$ and passes the resulting \texttt{consumed} count
to the extracted trailing-zero counter on $s$.  It casts the returned
\texttt{trailing} count to I32 and adds it to
$d.\texttt{decimal\_point}$; subtracts \texttt{trailing} from
$d.\texttt{num\_digits}$ to obtain \texttt{kept}; casts \texttt{kept} to I32
and adds it to the intermediate point; and then selects
\[
 (\texttt{nDigits},\texttt{flag})=
 \begin{cases}(768,\mathsf{true}),&\texttt{kept}>768,\\
 (\texttt{kept},d.\texttt{truncated}),&\texttt{kept}\le768.
 \end{cases}
\]
It applies \noderef{DecimalSeqExponentEval} to \texttt{rest} and the resulting
point.  Finally it runs the extracted parser loop~1 on $d.\texttt{digits}$
over the half-open array-index interval $[\texttt{nDigits},19)$, setting
exactly those cells to zero and leaving every other cell unchanged, and
returns the record made from \texttt{nDigits}, the exponent-adjusted point,
\texttt{flag}, and that array.  Each failed or divergent checked operation is
propagated by its monadic bind.
\end{definition}
\begin{preservation}
\begin{claim}
Consider an actual execution of
\texttt{crate/dec2flt/decimal_seq.rs:320--363} after the integral and optional
fractional scans.  Let $s_0$ be the exact original source slice stored as
\texttt{start}, let $r$ be the exact current residual suffix stored as
\texttt{s}, and let $d$ be the exact post-scan \texttt{DecimalSeq}.  On the
branch $d.\texttt{num_digits}\ne0$, the remainder of that source execution is
exactly \texttt{DecimalSeqFractionalFinish}$(s_0,r,d)$: it has the same final
record on normal return and fails at the same modeled checked operation on an
abnormal return.  No claim is made that the source invokes this finalization
from an arbitrary state with zero digit count.
\end{claim}
\begin{proof}
Fix an execution and $s_0,r,d$ satisfying the claim.  The branch hypothesis is
the source guard at line 320, so the assignments at lines 322--333 execute;
it is not an invented premise on the public parser.  Compare those assignments
and the subsequent exponent and fill code with the corresponding branches of
the pinned \texttt{parse_decimal_seq} declaration
\noderef{num_imp_dec2flt_decimal_seq_parse_decimal_seq}.

First, the source sets \texttt{consumed_len} to
$|s_0|-|r|$.  The definition binds the same Usize subtraction
\texttt{Slice.len} $s_0-$ \texttt{Slice.len} $r$.  Since $r$ is the exact
residual suffix of this execution, $|r|\le |s_0|$ on every source-reachable
state.  At the model level the two fragments still use the same checked
subtraction, so an underflow, if presented outside that source invariant,
would be the same first propagated failure rather than a different result.

Next both call the pinned reverse scanner
\noderef{num_imp_dec2flt_decimal_seq_count_trailing_zeros} on $s_0$ and that
same consumed length.  The adaptation record
\evidenceref{reference/model-evidence/source-adaptation-delta.txt} establishes
that this indexed helper visits positions
\texttt{consumed_len-1}, \ldots, $0$ in the same order as the original
\texttt{iter().rev()} loop, increments exactly on ASCII zero, passes over a
decimal point, and stops at the first byte that is neither zero nor point.
Thus its Usize result is exactly the source value
\texttt{n_trailing_zeros}; a helper failure is bound and returned before any
record update on both model fragments.

Let $z$ be that Usize result, and write $\operatorname{cast32}(u)$ for the
signed I32 representative of the low 32 bits of a Usize value $u$.  Rust's
narrowing \texttt{u as i32} and Aeneas's pure
\texttt{UScalar.hcast .I32 u} both compute exactly
$\operatorname{cast32}(u)$; this operation truncates and cannot fail (the
\texttt{lift} surrounding it in the pinned parser merely places that pure
value in the \texttt{Result} computation).  Thus both fragments first perform
the same checked I32 addition
$d.\texttt{decimal_point}+\operatorname{cast32}(z)$, which either fails on
both sides or produces the same intermediate point.  They next perform the
same checked Usize subtraction $d.\texttt{num_digits}-z$; if it succeeds, call
its Usize result $k$.  Both then compute the identical pure value
$\operatorname{cast32}(k)$ and perform the same checked I32 addition to the
intermediate point.  Consequently, whenever both additions and the
subtraction succeed, the uncapped point on each side is the I32 value
$d.\texttt{decimal_point}+\operatorname{cast32}(z)
 +\operatorname{cast32}(k)$; subtraction and addition failures coincide, and
neither narrowing cast contributes a failure.

The next test is the same strict comparison
$k>\texttt{DecimalSeq::MAX_DIGITS}$, whose pinned value is 768 by
\noderef{num_imp_dec2flt_decimal_seq_DecimalSeq_MAX_DIGITS}.  In the true
branch both retain 768 digits and set \texttt{truncated} to true.  In the false
branch both retain $k$ and preserve $d.\texttt{truncated}$.  This establishes
the same pair $(n,f)$ of stored digit count and flag, including the equality
case $k=768$.

It remains to justify the residual observation made before the optional
exponent computation.  The cited pinned parser has four source-reachable
copies of this nonzero finalization.  When the residual $s_2$ is empty, the
outer \texttt{Slice.is_empty} result is saved across finalization.  After a
decimal point, the two copies (according as the pre-fractional digit count is
zero or nonzero) use the post-scan residual $s_6$ or $s_5$ and test it after
finalization.  In the remaining nonempty, non-decimal-point copy, the parser
saves both the false emptiness result and the byte $s_2[0]$ across
finalization.  In every copy, the intervening consumed-length computation,
trailing-zero scan, casts, arithmetic, cap test, and flag update only read the
residual slice; none changes that slice.  Thus the argument $r$ passed to the
factoring is respectively that same $s_2$, $s_6$, $s_5$, or $s_2$.

By the Aeneas slice semantics, \texttt{Slice.is_empty} is total and returns
the deterministic test of whether the slice length is zero.  Recomputing it
on the unchanged $r$ therefore returns the parser's saved Boolean in the
first and fourth copies, and is the identical test already made by the parser
in the two post-decimal copies.  In the empty case both computations take the
empty branch and neither indexes $r$.  In every nonempty case, index zero is
in bounds; \texttt{Slice.index_usize} therefore succeeds deterministically
and returns the same byte, including the byte saved by the outer parser in
the fourth copy.  Hence the factoring's extra emptiness and index observations
cannot fail or diverge, and both sides select the same nonmarker,
lowercase-\texttt{e}, or uppercase-\texttt{E} branch.

Only after that observation equality is established, apply the optional
exponent computation \noderef{DecimalSeqExponentEval} to the identical
residual $r$ and the identical cast-correct I32 base
$d.\texttt{decimal_point}+\operatorname{cast32}(z)
 +\operatorname{cast32}(k)$.  Its empty/marker, optional-sign,
decimal-exponent-parser, checked-multiplication, and checked-addition analysis
then gives the same final point $p$ or the same first arithmetic or parser
failure.  Separately, the source/adaptation evidence cited above identifies
the guarded nonempty/index tests with the original source's split-first tests;
it is used for that source-preservation comparison, not for the
saved-versus-recomputed observation equality just proved.

Finally the source loop at lines 361--363 ranges from $n$ to
\texttt{MAX_DIGITS_WITHOUT_OVERFLOW} and writes zero to each selected digit
cell.  Aeneas duplicated this one source loop across control-flow branches as
\texttt{parse_decimal_seq_loop1}, \texttt{loop4}, \texttt{loop6}, and
\texttt{loop7} in the pinned node; their range iterator, array update, state,
and exit bodies are identical.  The factoring calls \texttt{loop1} with the
same range and original $d.\texttt{digits}$, and hence produces exactly the
same filled array $a$, or propagates the same range/array failure at the same
iteration.  When all binds succeed, both computations construct
\texttt{DecimalSeq.mk} with fields
\texttt{num_digits}$=n$, \texttt{decimal_point}$=p$,
\texttt{truncated}$=f$, and \texttt{digits}$=a$.  Monadic short-circuiting
also shows that any earlier failure prevents this construction on both sides.
This proves equality of normal and failure behavior precisely on the source's
nonzero-digit post-scan branch, while making no assertion about source use at
zero count.
\end{proof}
\begin{goalproof}{parser_totality}On every actual nonzero post-scan branch this definition is the pinned parser's own checked finalization, including its first failure; the zero-count branch is left untouched.  Factoring therefore adds no public-input premise and changes no termination or panic observation.\end{goalproof}
\begin{goalproof}{parser_numeric_acceptance}Every numeric execution reaching this nonzero branch retains the exact residual, point, digit count, truncation flag, exponent update, and zero-filled array of \texttt{parse_decimal_seq}.  The definition adds no grammar condition and assumes no acceptance result.\end{goalproof}
\begin{goalproof}{parser_invalid_rejection}The same residual byte controls the optional-exponent branch, and nonmarker and failure cases are preserved without extra consumption.  Thus finalization cannot change a later invalidity decision or impose a new premise.\end{goalproof}
\begin{goalproof}{parser_nan_acceptance}NaN literals are accepted by the special helper and do not enter the numeric decimal-sequence finalization.  Restricting this claim to the actual nonzero numeric branch leaves NaN recognition and construction unchanged.\end{goalproof}
\begin{goalproof}{parser_infinity}Infinity literals also bypass \texttt{parse_decimal_seq}.  This factoring changes neither their keyword path nor their lexical sign.\end{goalproof}
\begin{goalproof}{parser_non_nan_results}For numeric slow executions, the factored record and every failure coincide with the pinned parser; for special executions it is unused.  It therefore neither creates a NaN nor assumes the no-spurious-NaN conclusion.\end{goalproof}
\begin{goalproof}{parser_numeric_sign}The public lexical sign is stored and assembled outside this unsigned decimal-sequence record.  Preserving the exact post-scan record leaves the eventual sign application unchanged.\end{goalproof}
\begin{goalproof}{parser_signed_zero}Trailing-zero removal changes only the canonical record exactly as in the pinned parser, while the public sign remains outside it.  The zero magnitude and later signed assembly paths are therefore unchanged and unrestricted.\end{goalproof}
\begin{goalproof}{parser_exact_rounding}The slow converter receives the same capped digits, decimal point, sticky/truncation flag, and zero-filled tail as before.  This source-branch factoring adds no hypothesis about exact value or rounding and preserves the parser observation used by the goal.\end{goalproof}
\begin{goalproof}{parser_selected_exponent}All downstream raw-pair computations see the identical \texttt{DecimalSeq} or the identical prior failure.  No biased-exponent range fact is inserted as a premise.\end{goalproof}
\begin{goalproof}{parser_selected_magnitude_sign}The definition neither applies the public sign nor assembles a raw pair; it preserves the magnitude record supplied to the slow converter.  Hence selected magnitude words are unchanged.\end{goalproof}
\begin{goalproof}{dispatch_abstract_composition}This definition extensionally factors the actual nonzero finalization inside the slow numeric component while preserving the source's zero-count alternative.  It adds no component precondition and does not assume the disputed abstract-composition conclusion.\end{goalproof}
\begin{goalproof}{dispatch_component_compliance}At a real slow-component call, $s_0$, $r$, and $d$ are exactly the parser-produced source slice, residual, and state required by the claim; that is a control-flow fact, not a strengthened caller contract.  The component's normal and failure behavior remains exact.\end{goalproof}
\begin{goalproof}{parser_accumulated_rounding}Trailing-zero normalization, retained digits, sticky flag, and signed explicit-exponent update determine the same accumulated decimal record as the pinned parser.  Factoring adds no premise and does not assume the record is ultimately rounded correctly.\end{goalproof}
\begin{goalproof}{parser_equal_target_rounding}Both the parser result and the decimal-sequence input to slow rounding are unchanged on the branch, while exact/accumulated target equality remains the GOAL's own condition.  No new equality condition is introduced.\end{goalproof}
\begin{goalproof}{number_helper_acceptance}\texttt{parse_number} returns a \texttt{Decimal} before the optional slow decimal-sequence conversion and never calls this finalizer.  Its nonempty-slice domain and \texttt{Some} cases are unaffected.\end{goalproof}
\begin{goalproof}{number_helper_rejection}The number helper's \texttt{None} decision precedes and is independent of \texttt{parse_decimal_seq}.  A definition over \texttt{DecimalSeq} states no new condition on that decision.\end{goalproof}
\begin{goalproof}{number_helper_record_bounds}The helper-bound fields belong to \texttt{Decimal}, whereas this definition consumes and constructs \texttt{DecimalSeq}.  It cannot change the returned mantissa, negative flag, or $10^{19}$ bound.\end{goalproof}
\begin{goalproof}{number_helper_accumulated_value}The mantissa/exponent interval in this goal describes the earlier \texttt{parse_number} record.  Post-scan trailing-zero and array finalization occurs only later on the slow path and leaves that record untouched.\end{goalproof}
\begin{goalproof}{special_helper_infinity}\texttt{parse_inf_nan} neither produces nor consumes a \texttt{DecimalSeq}.  Its keyword bytes, separate sign argument, and infinity result are noninterfering.\end{goalproof}
\begin{goalproof}{special_helper_nan}The special NaN helper is disjoint from this numeric slow-path finalization.  No NaN payload, classification, or sign argument is changed.\end{goalproof}
\begin{goalproof}{special_helper_rejection}Inputs rejected by the special helper are decided by its keyword comparisons, not by decimal-sequence state.  Its \texttt{None} cases remain identical.\end{goalproof}
\begin{goalproof}{native_correct_or_defer}\texttt{try_fast_path} operates directly on the \texttt{Decimal} record and runs before slow decimal-sequence parsing.  This finalizer changes neither a native-path \texttt{Some} value nor a deferral.\end{goalproof}
\begin{goalproof}{integer_correct_or_defer}\texttt{compute_float} accepts scalar exponent and mantissa arguments and does not observe any \texttt{DecimalSeq} array.  Its returned or deferred \texttt{BiasedFp} is unaffected.\end{goalproof}
\begin{goalproof}{slow_accumulated_rounding}This is the relevant consumer: \texttt{parse_long_mantissa} calls \texttt{parse_decimal_seq} and receives precisely the final record factored here on the actual nonzero branch, with the zero branch preserved separately.  No premise is added to unsigned numeric inputs, and no rounding result is assumed.\end{goalproof}
\begin{goalproof}{assembly_correspondence}\texttt{biased_fp_to_float} consumes only a completed raw pair, not a source slice, residual, or decimal digit array.  This finalizer cannot alter the assembly formula quantified over all field values.\end{goalproof}
\begin{goalproof}{classification_totality}The mathematical classification relation ranges over finite byte strings and is defined before any decimal-sequence execution.  Its coverage by numeric, special, or invalid is unchanged.\end{goalproof}
\begin{goalproof}{classification_determinism}No grammar rule or parsed lexical content is changed by factoring a later source branch.  Classification uniqueness and uniqueness of numeric content are therefore noninterfering.\end{goalproof}
\begin{goalproof}{classification_significand_digit}The existence of a significand digit is a property of numeric syntax; the finalizer is entered only after scanning such bytes and does not redefine the grammar.  The goal is unchanged.\end{goalproof}
\begin{goalproof}{rounding_totality}Abstract rounding totality quantifies over nonnegative real numbers, with no parser state or byte slice.  The source-branch factoring has no effect on its candidates or domain.\end{goalproof}
\begin{goalproof}{rounding_determinism}Abstract target uniqueness is likewise independent of the construction of a \texttt{DecimalSeq}.  Its real input and binary64 comparison relation remain unchanged.\end{goalproof}
\begin{goalproof}{exponent_value_agreement}The mathematical exact and accumulated exponent values are defined from lexical content, not from this finalizer's implementation.  The definition preserves the implementation but neither changes those values nor assumes their stated equality, so the agreement goal is noninterfering.\end{goalproof}
\end{preservation}
