Multisets
---------

Example:
    A bag of Scrabble tiles contains 100 tiles: 10 A's, 2 B's, 2 C's, 5 D's
    and so on.

    When you start a game, you take 7 letters from the bag, and put them on a
    rack. How many possible hands can you get, if we say that the order of the
    tiles on the rack matters? How about if it doesn't?

A _multiset_ is a "set with multiplicity".

Notation: {2*a,3*b,1*c}

(Think of a "bag" with 2 a's, 3 b's and a c in it.)

We also allow "infinite multiplicity", denoted {\infty*a}.

Multiplicities are also called "repetition numbers".

The _size_ of a multiset is the sum of the multiplicities (may be \infty).

An r-permutation of a multiset is an ordered list of r elements from the
multiset;
e.g. the 2-permutations of {2*a,1*b} are
    aa, ab, ba;
the 3-permutations of {\infty*a,2*b} are
    aaa, aab, aba, baa, abb, bab, bba.

A _permutation_ of a multiset of size n is an n-permutation.

Example: how many permutations are there of the unfortunate scrabble hand
    {4*U,1*J,2*K}?

Theorem:
    Let S be a multiset with k types with finite multiplicities n_1,...,n_k.
    Let n = \Sigma_i n_i be the size of S.
    Then the number of permutations of S is
	n! / n_1!*n_2!*...*n_k!
Proof:
    Label the elements 1,...,n. Each permutation of {1,...,n} yields a
    permutation of S, and two yield the same permutation precisely when we can
    get one from another by permuting the labels on elements of the same type.
    So there are n_1!*n_2!*...*n_k! permutations of {1,...,n} per permutation
    of S. We conclude by the division principle.
    
Example:
    We have 4 black rooks and 4 white rooks. How many ways are there of
    putting them on a chess board such that no two are attacking (/defending)
    each other? e.g.

    .......R  8
    ....r...  5
    ..R.....  3
    ......R.  7
    ...r....  4
    .R......  2
    .....r..  6
    r.......  1
Solution:
    First, just choose the 8 squares for them to occupy.

    By listing off the filled columns row-by-row, a choice corresponds to a
    permutation of the columns, so there are 8!.

    For a given such choice, a choice of colours corresponds to a permutation
    of the multiset {4*r,4*R}.

    So the answer is
	8! * (8! / 4!*4!) = 2822400


An _r-submultiset_, or _r-combination_, of a multiset S is a multiset S' such
that for all x,
    the multiplicity of x in S' is at most the multiplicity of x in S.

e.g. the 2-submultisets of {3*a,b} are
    {2*a}, {1*a,1*b}.

Theorem:
    The number of r-combinations of a multiset with k types each with
    multiplicity at least r is
	C(r+k-1,r) = C(r+k-1,k-1)
Example:
    If we have a bag containing red, green and blue marbles, with many of
    each, and we draw 5 marbles from the bag, how many possible results
    (numbers of each colour drawn) are there?
    Answer: C(5+3-1,5) = C(7,5) = 7! / 2!5! = 21
Proof:
    We can identify an r-submultiset with an arrangement of (k-1) partitions
    interspersed among r identical objects, by counting the numbers of objects
    between the partitions; e.g. with k=6 and r=8,
	oo|ooo||o|oo|
    corresponds to
	{ 2*a_1, 3*a_2, 0*a_3, 1*a_4, 2*a_5, 0*a_6 }.

    These arrangements correspond to choosing r of the (r+k-1) characters to
    be 'o's, so the number of such arrangements is C(r+k-1,r). Counting '|'s, it's
    also C(r+k-1,k-1). So