slicecompose v0.2.0 — k-ary composition
k-ary composition
compose(*slices) now decides whole chains of any length exactly — sound and complete, like the binary case: it returns a slice equivalent to arr[s1][s2]...[sk] for every sequence length, or None exactly when no such slice exists.
This is strictly stronger than iterated pairwise composition: there are chains where no adjacent pair (and no sub-chain) is expressible, yet the whole chain is — e.g. [2::-1], [:2], [:-1] equals [2:0:-2] for every length, while both pairs are inexpressible. compose now finds these directly.
Minimal chain reduction
SliceChainreduces to a minimal-length equivalent chain via interval decisions with the k-arycompose— merge order plays no role, and reductions invisible to pairwise merging are found. Tiered implementation: fold-like chains reduce at plain greedy-stack speed; the full interval DP runs only for genuinely tangled chains.SlicePlankeeps its raw gathered history alongside the reduced cache, so plans branched after an early collapse never lose reduction opportunities.
Validation
- Exhaustive binary grids (147,456 and 1,000,000 pairs) re-verified through the generalized engine.
- All 36,898 pairwise-stuck small-grid triples audited against a brute-force oracle: exactly the 1,272 with expressible totals merge.
- All 499,864 "4-stuck" chains (no pair and no interior triple expressible) audited: 6,784 expressible totals, zero soundness or completeness failures.
- 60,000 random triples audited in both directions; 15,000 random 4–6-chains checked sound at field magnitudes up to 1e15.
See EXPLANATION.md §§7–8 for the theory (staircase composition, sawtooth cancellation, wrap-coincidence classes).