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). $$
The tensor/CUDA implementation is allowed to choose an efficient scan schedule, but the mathematical contract is this file: prefix summaries denote the same state as the left-to-right recurrence.
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.
A stateful scan emits exactly one value for every input.
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.
Prefix summaries composed across append have the expected denotation.
The scalar affine scan has one state per transition.
Scanning appended scalar transitions is the prefix scan followed by the suffix scan.
The diagonal tensor scan has one state per transition.
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.