Pre-Amble
I would like to rephrase the question
PREVIOUS INSTANCE OF THIS QUESTION ( Was closed due to an alleged duplicity ).
Considering sets of four elements we can consider sets of the following type:
- ABCD,
- AACD,
- AADD,
- AAAD,
- AAAA.
The number of types is (of course) equal to p(4)=5, where p(n) is the PartitionsP (MMa) function.
The number of set partitions for these type of sets is:
- ABCD: 15 = BellB[4] (MMa), where BellB is the Bell Number Function
- AACD: 11
- AADD: 9
- AAAD: 7
- AAAA: 5.
The 7 set partitions of AAAD are
- AAAD (1)
- AA, AD (2)
- AAD, A (2)
- AAA, D (2)
- AA, A, D (3)
- AD, A, A (3)
- A, A, A, D (4).
I would like to know the number of set partitions of an arbitrary set, for example: ABCDEF (although, for this particular case, BellB[6] works), AAAFFF, or AAAAAA, expressed in a formula, or a (programmable) algorithm.
( The Function SetPartitions in the Combinatorica Package in Mathematica can calculate the actual partitions but is rather memory-consuming, even for moderate set sizes. )