Low Lying Island

(math) Weak compositions as products of compositions and weak compositions

Let us start by recalling the definitions of compositions and weak compositions. A composition of n of length k is a list of k positive integers that sum to n. A weak composition is the same idea but we are allowed to use zeros. Denote the former set by Ck(n) and the set of weak compositions of n of length k by Wk(n). The list (1,2,1,3)∈C4(7) and (0,1,4,0,2)∈W5(7).

I am going to prove the following result for n≥1,
Wk(n)=⨆j=1kCj(n)×Wj+1(k−j) but before I do that, I wanna tell you how I ended here in the first place. A project of mine looks at the behavior of the s^r statistic on weak compositions. The details of this function don't matter at the moment. If I want to understand this function for an input composition β, I first need to compute it on a subset of weak compositions and sum all the outputs. What is this particular subset? These are all the weak compositions of length r which yield β when I remove all the zeros and preserve the order of entries. So, for a composition (1,2,1) and r=5, the subset would include the weak compositions (0,1,0,2,1), (1,0,0,2,1) and so on. One method to generate this subset is to start with the composition, and insert zeros between the entries. For a composition of length j, there are j+1 spots to insert the zeros, and I can choose how to insert them.

Okay, it's now time for the proof! I will use exponential notation ab which means that a appears b times consecutively. If b=0, then ab is the empty string.

Proof. First pick w∈Wk(n). Define βw to be the composition obtained by removing all the zeros in w while preserving the order of the entries. Suppose βw has j entries, then let vw=(v0,v1,…,vj) be a weak composition where v0 is the number of zeros in the beginning of w, vi for i=1,2,…,j−1 is the number of zeros to the right of βi and to the left of βi+1, and vj is the number of zeros at the end of w. This gives us the map from w to the pair (βw,vw)∈⨆j=1kCj(n)×Wj+1(k−j).
On the other hand, if we start with (β,v)∈Cj(n)×Wj+1(k−j), then we can define w(β,v)=(0v0,β1,0v1,β2,0v2,…,0vj−1,βj,0vj), which is an element of Wk(n). ◻

Bonus: the way to generate weak compositions in SageMath is by using IntegerVectors.