TL;DR
A partition of a set cuts it into smaller sets, called blocks, so that every element lands in exactly one block and no block is empty. It is the exact version of the everyday idea of sorting things into groups with no leftovers and no doubles. Partitions appear wherever each item must belong to exactly one group, from clustering data to dividing voters into districts.
Builds on: Set Operations · Leads to: Mathematical Relation, K-Means Clustering
Where it's used
Hard clustering in machine learning. K-means clustering assigns each data point to exactly one of k clusters. Its output is therefore a partition of the data points: a point cannot sit in two clusters at once, and every point is placed somewhere. Hierarchical clustering produces a nested sequence of partitions, one for each cut of its tree of merges.
Electoral districts. In a country that elects one representative per district, each voter lives in exactly one constituency. The districts, taken together, form a partition of the electorate. A voter in two districts, or in none, would break the rule that every vote counts once.
Splitting numbers into equal halves. The partition problem asks whether a list of numbers can be split into two groups with equal sums. For the list 3, 1, 1, 2, 2, 1 the answer is yes: the groups 3 and 2 sum to 5, and 1, 1, 2, 1 also sum to 5. The problem is a standard hard task in computer science: no fast general method is known for it, and it is one of the problems shown to be NP-complete. Any solution is a partition of the list into two groups.
How it works
Take the set and list every way to split it into groups. Place the elements one at a time, and at each step either join an existing group or start a new one.
- Start with three items. The set is , and every final grouping must use each of the three exactly once. Check: there are three items to place.
- Place item 1. It has nowhere else to go, so it starts a group: . Check: the group is not empty.
- Place item 2. There are two choices. It can join the group holding 1, giving , or start a new group . Check: in both cases 2 sits in exactly one group.
- Place item 3. Each arrangement from step 3 offers the same choice. From , item 3 joins the group to give , or starts a new group to give . From , item 3 joins the group of 1, joins the group of 2, or starts a new group, giving , and . Check: the tree below has five leaves.
- Read off the answer. The five arrangements are all the ways to split three items into nonempty, non-overlapping groups that leave nothing out. Check: no arrangement is repeated, because each one came from a different sequence of choices.
- Name the idea. Each arrangement is a set partition. A three-element set has five of them.
flowchart TD A["Place 1: group [1]"] --> B["Place 2 in [1]: group [1 2]"] A --> C["Place 2 new: groups [1] [2]"] B --> D["Place 3 in [1 2]: [1 2 3]"] B --> E["Place 3 new: [1 2] [3]"] C --> F["Place 3 with 1: [1 3] [2]"] C --> G["Place 3 with 2: [1] [2 3]"] C --> H["Place 3 new: [1] [2] [3]"]
The math
A partition of a set is a collection of sets , called blocks, such that every block is nonempty, the blocks cover , and no element lies in two blocks.
Here is the set being split, and is the block with number . The symbols come from set operations: means union (everything in either set), means intersection (what two sets share), and is the empty set, with nothing in it.
Step 2 in symbols: a block is nonempty
Placing item 1 gives the block . It is a valid block because .
Step 5 in symbols: cover and disjoint
Take the arrangement and . It is a partition of for two reasons.
- Cover: the union is , so every element is in some block.
- Disjoint: the intersection is , so no element is in two blocks.
The arrangement and fails the second test. Its intersection is , which is not empty, so element 2 is in two blocks.
Step 6 in symbols: counting partitions
Write for the number of partitions of a set with elements; these are the Bell numbers. The walkthrough shows .
Worked examples
- Take .
- One block: . The block is nonempty and covers . Valid.
- Two blocks: and . They are nonempty, cover , and do not overlap. Valid.
- No other arrangement works, since any split must use one block or two.
- Check: , matching the two partitions found.
Interpretation: a two-element set has exactly two partitions, one that keeps everything together and one that separates the elements.
Count the partitions of by the sizes of their blocks, using the tools from Counting Principles.
- One block of size 4: . That is 1 partition.
- Blocks of sizes 3 and 1: choose which element stands alone, 4 ways. That is 4 partitions.
- Blocks of sizes 2 and 2: pair element 1 with one of the other three, 3 ways. The remaining two form the other block. That is 3 partitions, for example with .
- Blocks of sizes 2, 1 and 1: choose the pair, ways. That is 6 partitions.
- Four blocks of size 1: . That is 1 partition.
- Add the counts: .
- Check: , the same total.
Interpretation: sorting by the shape of the blocks gives a complete count with no double counting, because each partition has exactly one shape.
A clustering algorithm such as k-means groups six data points, to , into two clusters. Its first output is and .
- Check that every point is covered: are in , and are in . All six appear.
- Check that no point is in both clusters: .
- Check that neither cluster is empty.
- Conclusion: the output is a partition of the six points.
Now a buggy output: and . Point was assigned twice. Its intersection is not empty, so this is not a partition.
Interpretation: a clustering that assigns points to one cluster each is a partition, so a double assignment is a bug that the disjointness test catches.
Try it: is , , a partition of the six points? Answer: No. Point is in no block, so the blocks do not cover the set, even though they are nonempty and do not overlap.
Common mistakes and tradeoffs
It is tempting to think a partition is any collection of subsets. In fact the blocks must be nonempty, must cover the whole set, and must not overlap. The collection , is not a partition of , because element 2 sits in two blocks.
It is tempting to think the order of the blocks matters. In fact a partition is an unordered collection. The listings and describe the same partition.
It is tempting to think a partition is just a kind of subset. In fact subsets may overlap or leave elements out, while a partition may do neither. A four-element set has 16 subsets, including the empty one, but only 15 partitions. The Power Set is the family of all subsets; partitions are a stricter family.
| Structure | Overlap allowed? | Leftovers allowed? | Empty group allowed? |
|---|---|---|---|
| Partition | no | no | no |
| Cover | yes | no | no |
| Any subset collection | yes | yes | yes |
When to use a partition: when each item must belong to exactly one group, as in hard clustering or district maps. When not to use it: when items may belong to several groups, as with topic tags, where a cover or a soft assignment fits better. Alternatives: a cover allows overlap. A labelling is a Function from items to group names, and the items sharing a name form a block; requiring every name to be used is the same as requiring the labelling to be surjective, which is the nonempty-block condition.
History
Set theory, which gives partitions their notation, was developed by Georg Cantor in the 1870s and 1880s. Counting partitions came later: the Bell numbers are named after Eric Temple Bell, who studied them in the 1930s. In 1972 Richard Karp showed that the partition problem is NP-complete, which made it a standard example of a hard problem in computer science.
Recap
- A partition splits a set into nonempty blocks that do not overlap and leave nothing out.
- Build the partitions of a set by placing its elements one at a time, either joining an existing block or starting a new one.
- The number of partitions of a three-element set is 5, and of a four-element set is 15.
- Overlap, leftovers, or an empty block each rule a collection out as a partition.
- Read next: Mathematical Relation, where an equivalence relation is a relation whose groups form a partition, and Counting Principles for the counting tools used above.