compute the partitions of a set
setpartition(S, m, returnsets)
set or list of objects
(optional) integer indicating the size of the partitions returned
(optional) to return the partitions as sets even if S is a list
The setpartition command returns all the partitions of S. A partition of a set S is a set of subsets of S such that every element s in S is in one and only one of these subsets of the partition, and the union of these subsets is equal to S. A set of n elements has combinat[bell](n) partitions (the nth Bell number).
If S is a list of objects, then each partition in the output is represented as a list of sublists instead of a set of subsets. By passing the optional argument returnsets = true, each partition in the output will be a set of subsets even if S is a list. Likewise, when passing returnsets = false, each partition will be a list of sublists even if S is a set.
Note: If S is a list of n elements, with some of them being repeated, the total number of partitions will be smaller than combinat[bell](n) and some elements s of S will appear in more than one sublist of a single partition. For example, when computing all the partitions of 1,1,2 via setpartition([1, 1, 2]), the partition 1,1,2 appears only once in the result and it contains the element 1 in two sublists.
When the optional argument m is given, each subset is of size m where m must divide the cardinality of the set.
S ≔ 1,2,3,4
S ≔ 1,1,3,4
The combinat[setpartition] command was updated in Maple 18.
The returnsets option was introduced in Maple 18.
For more information on Maple 18 changes, see Updates in Maple 18.
Download Help Document
What kind of issue would you like to report? (Optional)
Thank you for submitting feedback on this help document. Your feedback will be used
to improve Maple's help in the future.