Past exam of the mathematics course of the University of Cambridge 2013 ia Paper 4 6E iii Solution Created 2026-09-24 Updated 2026-10-07
For bounded weak compositions, start with the unrestricted stars and bars set and let be its subset where . For an index subset , subtract from each coordinate with . This is a bijection from to nonnegative tuples summing toThuswhere a negative remaining sum gives zero, in accordance with the stipulated convention. Apply the avoidance form of the inclusion-exclusion principle:Expanding by subset size gives the alternating single-index, pair-index and higher-index sums. The empty subset supplies .
Stars and bars (combinatorics) 2026-10-13
Stars and bars counts tuples of nonnegative integers with a prescribed sum. For integers and , its statement isSuch a tuple is a weak composition of an integer. Think of labelled bins: counts identical objects in the first bin, in the second, and so on. Bin names distinguish positions even when counts agree. Stars and bars counts these count tuples; assigning individually distinct objects requires additional information. [ref]
https://math.mit.edu/~fgotti/docs/Courses/C.%20Combinatorial%20Analysis/6.%20Compositions/Compositions.pdf. Felix Gotti, MIT 18.211, Lecture 6: Compositions, Proposition 1 and Example 3
Computed example. With and , the number of weak compositions of an integer is . The string
••|•|•• encodes : two dots before the first bar, one between the bars, and two after the second. For a fixed first-bin count , the second-bin count can be any integer from to and the third is forced. Thus the direct count is .Stars and bars for five identical objects and three labelled bins: ordinary splits, adjacent bars, and bars at either end
. Details. Adjacent bars encode an empty middle bin:
••||••• gives . A bar at the left end encodes an empty first bin, as in |••|••• for ; a bar at the right end encodes an empty third bin, as in ••|•••| for . These are valid weak compositions of an integer. For every count is zero, and for the unique tuple is , consistent with .Proof outline. Replace each count by that many dots and separate successive groups with bars. Reading the group sizes reverses this construction, so it is a bijection between weak compositions of an integer and strings of dots and bars. Choose the bar positions among positions; the binomial coefficient counts the choices. The beauty is that empty bins need no separate cases: end bars and adjacent bars encode them automatically.
If every bin must be nonempty, the tuples are compositions of an integer, and their count is for ; for there are none. Subtract one from every count, setting . This is a bijection to weak compositions of an integer of , so stars and bars gives . For five objects and three bins, this is , with the six positive tuplesFor instance, shifts to , whose sum is . Sorting the six positive tuples collapses them to just two integer partitions, and . Thus named bins and unordered summands answer different questions.
Stars and bars is useful for allocating identical resources or enumerating integer solutions without listing them individually. Prescribed lower bounds can be subtracted just like the nonempty-bin requirement. Upper bounds require removing forbidden tuples; the existing bounded weak compositions article applies the inclusion-exclusion principle to those violations.
