Ranked Subset Convolution: Enforce Disjointness with One Extra Dimension
Many hard bitmask problems ask you to split a set into disjoint roles. A subset zeta transform efficiently handles unions, but a union is not necessarily a partition. Ranked subset convolution adds exactly the information needed to tell them apart.
Assume basic subset enumeration and zeta transforms. Our target is
Computing this independently for every costs . The fast method costs over a ring with subtraction.
Why the tempting transform fails
Define and similarly for . Multiplying the transformed values enumerates pairs . After Mobius inversion, it selects pairs with , but it does not exclude .
For , the pair survives that union condition. It is invalid for our partition because was used twice. The missing invariant is the total number of used elements.
Rank the inputs
Create layers when , and zero otherwise. Zeta-transform each layer:
At each mask, multiply these short polynomials in rank:
Now Mobius-invert every rank layer over subsets. Its value counts pairs with union exactly and . Finally select .
Why does that last equality enforce disjointness? Because
If the union already equals , choosing rank forces the intersection to be empty. We used a scalar measurement to recover a structural constraint.
Explore weighted partitions
Let the universe have three elements. Give a set weight and . The lab lists every ordered partition of a chosen mask. The two sides have separate roles, so exchanging them generally changes the contribution.
This tiny enumeration is the independent specification against which the fast transform should be tested. It is intentionally different from the internal rank representation.
Implementation shape
put f[S] in layer popcount(S)put g[S] in layer popcount(S)zeta-transform every layerfor each S: multiply the rank polynomials at S, keeping ranks 0..nMobius-invert every output layeranswer[S] = output[popcount(S)][S]The C++ companion implements this as subset_convolution. It accepts equal power-of-two arrays, including a length-one universe with no elements. Modular subtraction must be normalized; unsigned underflow is not a substitute for subtraction in the intended field.
Memory often becomes the real constraint
Each of the three layer tables uses coefficients. For and four-byte coefficients, that is about 84 MiB per table before vector overhead. Three simultaneous tables can exceed a 256 MiB limit. Reusing layers, streaming selected outputs, or exploiting a problem-specific sparse support can matter more than a small constant optimization in the transform loops.
Do not replace arithmetic addition with min and expect the same algorithm: Mobius inversion needs additive inverses. Min-plus subset convolution is a different problem, with different assumptions and bounds.
Exercise. Let count valid nonempty connected groups. Explain how repeated subset convolution can count ordered decompositions into groups. Then determine what extra argument is needed to turn ordered groups into unordered groups; dividing by requires a field where this factorial is invertible and a symmetry argument that actually applies.
Support & Share
If this article helped you, please share or support!





























































Conversation
Comments powered by Waline