Proofs for affine selective scan #
The Mamba/S4 scan theorem is an algebra theorem about affine maps. A sequential recurrent update and a parallel prefix scan are equivalent because affine transition composition is associative:
$$ (a_2,b_2)\circ(a_1,b_1)=(a_2a_1,a_2b_1+b_2). $$
Over a semiring, prefix summaries denote the same state as the left-to-right recurrence. This does not assert equality between differently ordered floating-point computations or verify a native implementation. The stateful scan and prefix-causality results preserve the sequential step order and do not require semiring laws.
Composing scalar affine transitions agrees with function composition.
The identity transition is a left identity for composition.
The identity transition is a right identity for composition.
Scalar affine transition composition is associative.
Applying a diagonal transition is exactly the scalar affine update in each channel.
Composing diagonal transitions agrees channelwise with composing the corresponding scalar affine maps. This is the exact algebraic invariant used by the variable-coefficient selective-scan kernel: each flattened state lane is an independent affine scan.
Seeding a scan with existing output preserves its state evolution and prepends that output.
The output buffer carried by a scan does not affect its final state.
The state component of scanArray is the ordinary state-only left fold.
A scan over appended inputs is the prefix scan followed by the state-dependent suffix scan.
Appending future inputs cannot change outputs already emitted by a stateful scan.
Running appended scalar transitions factors through the state reached after the prefix.
Running one scalar transition is the same as applying it.
The affine summary denotes the same state as the sequential recurrence.
Prefix summaries compose across array append in execution order.
Scanning appended scalar transitions is the prefix scan followed by the suffix scan.
Running appended diagonal transitions factors through the state after the prefix.
The diagonal scan of an append is the prefix scan followed by the state-dependent suffix scan.
A homogeneous affine transition over $\mathbb{R}$ is Lipschitz with factor $\rho$ whenever $|a|\leq\rho$.
This is the one-channel stability lemma used to lift diagonal SSMs into contraction proofs.