Determine the number of equivalence relations on the set {1, 2, 3, 4}
This sort of counting argument can be quite tricky, or at least inelegant, especially for large sets. Here's one approach:
There's a bijection between equivalence relations on $S$ and the number of partitions on that set. Since $\{1,2,3,4\}$ has 4 elements, we just need to know how many partitions there are of 4.
There are five integer partitions of 4:
- $4$,
- $3+1$,
- $2+2$,
- $2+1+1$,
- $1+1+1+1$
So we just need to calculate the number of ways of placing the four elements of our set into these sized bins.
4
There is just one way to put four elements into a bin of size 4. This represents the situation where there is just one equivalence class (containing everything), so that the equivalence relation is the total relationship: everything is related to everything.
3+1
There are four ways to assign the four elements into one bin of size 3 and one of size 1. The corresponding equivalence relationships are those where one element is related only to itself, and the others are all related to each other. There are clearly 4 ways to choose that distinguished element.
2+2
There are $\pmatrix{4\\2}/2=6/2=3$ ways. The equivalence relations we are looking at here are those where two of the elements are related to each other, and the other two are related to themselves. So, start by picking an element, say 1. Then there are three things that 1 could be related to. Once that element has been chosen, the equivalence relation is completely determined.
2+1+1
There are $\pmatrix{4\\2}=6$ ways.
1+1+1+1
Just one way. This is the identity equivalence relationship.
Thus, there are, in total 1+4+3+6+1=15 partitions on $\{1,2,3,4\}$, and thus 15 equivalence relations.
Total number of equivalence relations on $\{1,2,3,4\}$=Number of partitions of the set $\{1,2,3,4\}$ into equivalence classes(nonempty subsets)
Number of possible partitions of a set $A$=Bell's number, $B(m)$=$\sum_{n=1}^m S(m,n)$,
where $S(m,n)=\frac{1}{n!}\sum_{k=0}^n(-1)^k.{^n}C_{k}(n-k)^m$ are the Stirling numbers of the second kind.
$$ S(4,1)=\frac{1}{1!}\sum_{k=0}^1(-1)^k.{^1}C_{k}(1-k)^4={^1}C_{0}.1^4-{^1}C_{1}.0=1\\S(4,2)=\frac{1}{2!}\sum_{k=0}^2(-1)^k.{^2}C_{k}(2-k)^4=\frac{{^2}C_{0}.2^4-{^2}C_{1}.1^4+{^2}C_{2}.0}{2}=\frac{14}{2}=7\\ S(4,3)=\frac{1}{3!}\sum_{k=0}^{3}(-1)^k.{^3}C_k(3-k)^4=\frac{{^3}C_0.3^4-{^3}C_1.2^4+{^3}C_2.1^4-{^3}C_3.0}{6}=\frac{81-3(16)+3}{6}=\frac{36}{6}=6\\ S(4,4)=1 $$
Number of possible partitions of the set $\{1,2,3,4\}$,i.e., number of equivalence relations of the set, $$ B(4)=\sum_{n=1}^4S(4,n)=S(4,1)+S(4,2)+S(4,3)+S(4,4)=1+7+6+1=15 $$
Here's another method: Count the equivalent relations by number of equivalence classes and recurse through the set size (we start with set size 1 and ignore the empty set equivalence relation).
Let's denote with $a_{n,k}$ the number of equivalence classes of an $n$-element set which have $k$ equivalence classes. To avoid special cases in the formulas, let's assume $a_{0,k}=a_{n,0}=0$.
A set of one element obviously has only one equivalence relation, with one equivalence class. That is, $a_{1,1}=1$.
The equivalence relations with $k$ equivalence classes of a set with $n$ elements is obtained by combining the following two disjoint sets:
All equivalence relations obtained by adding the $n$-th element as separate equivalence class to the relations with $k-1$ equivalence classes in the remaining $n-1$ elements. For example, from $\{\{1,2\},\{3\}$ you get $\{\{1,2\},\{3\},\{4\}\}$. Obviously we get one $(n,k)$-relation from each $(n-1,k-1)$ relation.
All equivalence relations by adjoining the $n$-th element to one of the equivalence classes of a relation with $k$ equivalence classes in the remaining $n-1$ elements. For example, from $\{\{1\},\{2,\},\{3\}\}$ you get $\{\{1,4\},\{2\},\{3\}\}$, $\{\{1\},\{2,4\},\{3\}\}$ and $\{\{1\},\{2\},\{3,4\}\}$. Obviously we get $k$ $(n,k)$ relations from each $/n-1,k)$-relation
Thus $a_{n,k} = a_{n-1,k-1} + k a_{n-1,k}$.
So let's do the recursion:
$n=2$:
$a_{2,1} = a_{1,0} + 1 a_{1,1} = 1$. Indeed, we can easily see that $a_{n,1}$ is always $1$ for all $n$. Therefore from now on this calculation will be omitted.
$a_{2,2} = a_{1,1} + 2 a_{1,2} = 1$. Again, we can easily see that $a_{n,n}$ is always $1$. Therefore from now on this calculation will be omitted, too.
So there are $1+1=2$ equivalence relations for $n=2$.
$n=3$:
- $a_{3,2} = a_{2,1} + 2 a_{1,2} = 3$
So there are $1+3+1=5$ equivalence relations for $n=3$.
$n=4$:
$a_{4,2} = a_{3,1} + 2 a_{3,2} = 7$
$a_{4,3} = a_{3,2} + 3 a_{3,3} = 6$
So there are $1+7+6+1=15$ equivalence relations for $n=4$.
This can be put into a nice schema which has some resemblance of Pascal's triangle:
n\k 1 2 3 4 5 6
1 1 -> 1
2 1 1 -> 2
3 1 3 1 -> 5
4 1 7 6 1 -> 15
5 1 15 25 10 1 -> 52
6 1 31 90 65 15 1 -> 203
Each number is the column number times the number above it plus the number left from that.