Maxima Function
set_partitions (a)
set_partitions(a,n)
Returns the set of all partitions of a, or a subset of that set.
set_partitions(a, n)
returns a set of all
decompositions of a into n nonempty disjoint subsets.
set_partitions(a)
returns the set of all partitions.
stirling2
returns the cardinality of the set of partitions of a set.
A set of sets P is a partition of a set S when
each member of P is a nonempty set,
distinct members of P are disjoint,
the union of the members of P equals S.
Examples:
The empty set is a partition of itself, the conditions 1 and 2 being vacuously true.
(%i1) set_partitions ({}); (%o1) {{}}
The cardinality of the set of partitions of a set can be found using stirling2
.
(%i1) s: {0, 1, 2, 3, 4, 5}$ (%i2) p: set_partitions (s, 3)$ (%o3) 90 = 90 (%i4) cardinality(p) = stirling2 (6, 3);
Each member of p
should have n = 3 members; let's check.
(%i1) s: {0, 1, 2, 3, 4, 5}$ (%i2) p: set_partitions (s, 3)$ (%o3) {3} (%i4) map (cardinality, p);
Finally, for each member of p
, the union of its members should
equal s
; again let's check.
(%i1) s: {0, 1, 2, 3, 4, 5}$ (%i2) p: set_partitions (s, 3)$ (%o3) {{0, 1, 2, 3, 4, 5}} (%i4) map (lambda ([x], apply (union, listify (x))), p);