combinat
setpartition
compute the partitions of a set
Calling Sequence
Parameters
Description
Examples
Compatibility
setpartition(S, m, returnsets)
S
-
set or list of objects
m
(optional) integer indicating the size of the partitions returned
returnsets
(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.
with⁡combinat,setpartition
S≔1,2,3,4
setpartition⁡S
1,2,3,4,1,2,3,4,2,1,3,4,3,1,2,4,4,1,2,3,1,2,3,4,1,3,2,4,1,4,2,3,1,2,3,4,1,3,2,4,1,4,2,3,2,3,1,4,2,4,1,3,3,4,1,2,1,2,3,4
nops⁡=combinat:-bell⁡4
15=15
nops⁡setpartition⁡1,2,3,4,5,6,7=combinat:-bell⁡7
877=877
setpartition⁡S,2
1,2,3,4,1,3,2,4,1,4,2,3
S≔1,1,3,4
1,1,3,4,1,3,1,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.
See Also
combinat[bell]
combinat[choose]
combinat[partition]
list
set
Download Help Document