An equivalence relation is Reflexive, Symmetric and Transitive. Before counting the number of possible equivalence relations on a set |A|=n, let us see an example of a equivalence relation and identify **Equivalence Classes** in it.

Let A = {1, 2, 3, 4} be a set and R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (3, 4), (4, 3), (4, 4)} be an equivalence relation on A. we see here that the total relation T = {(1, 1), (1, 2), (1, 3), (1, 4)} over the set C1 = {1, 2} which is the subset of A is present in R, i.e subset of R. And also there is no such total relation T’>=T over set C1’>=C1 which is present in R i.e subset of R. Hence we found an equivalence class E1 = {1, 2} over relation R.

Similarly there is another equivalence class E2 = {3, 4} over R. And no more such equivalence classes are present in R. Notice here that E1 and E2 are disjoint sets and this is always true because {E1, E2} i.e {{1, 2}, {3, 4}} is one of the possible partition of the set A.

Hence above equivalence relation R corresponds to the partition {{1, 2}, {3, 4}} of the set A. Similarly each and every equivalence relation on A corresponds to one of the partition of A. In fact this mapping is Bijective.

Now we come to our question of finding number of possible equivalence relations on a finite set which is equal to the number of partitions of A. The Bell Numbers count the same. Starting with B0 = B1 = 1, the first few Bell numbers are:

1, 1, 2, 5, 15, 52, 203, 877, 4140, 21147, 115975, 678570, 4213597, 27644437, 190899322, 1382958545, 10480142147, 82864869804, 682076806159, 5832742205057, … etc.

Here are the first five rows of the triangle constructed:

1 1 2 2 3 5 5 7 10 15 15 20 27 37 52

The Bell numbers appear on both the left and right sides of the triangle.

**Example –** 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 (42)/2=6/2=3(42)/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 (42)=6(42)=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}{1, 2, 3, 4}, and thus 15 equivalence relations.

**Note –** This sort of counting argument can be quite tricky, or at least inelegant, especially for large sets. There is no direct formula to do so.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the **CS Theory Course** at a student-friendly price and become industry ready.