sequalignore SciMax Toolbox set_plot_option

SciMax Toolbox >> set_partitions

set_partitions

Maxima Function

Calling Sequence

set_partitions (a)
set_partitions(a,n)

Description

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

  1. each member of P is a nonempty set,

  2. distinct members of P are disjoint,

  3. 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);
sequalignore SciMax Toolbox set_plot_option