- reading: MCS [10.10][mcs1010]
- define equivalence relations, equivalence classes
- quotient rule

We can draw a binary relation \(A\) on \(R\) as a graph, with a vertex for each element of \(A\) and an arrow for each pair in \(R\).

For example, the following diagram represents the relation \(\{(a,b), (b,e), (b,f), (c,d), (g,h), (h,g), (g,g)\}\):

Using these diagrams, we can describe the three equivalence relation properties visually:

**reflexive**(\(∀ x, x R x\)): every node should have a self-loop. The above relation is not reflexive, because (for example) there is no edge from \(a\) to \(a\).**symmetric**(\(∀ x, y\) if \(xRy\) then \(yRx\)): every edge should have a reverse edge as well. The above relation is not symmetric, because (for example) there is an edge from \(b\) to \(f\) but not from \(f\) to \(b\).**transitive**(\(∀ x,y,z\), if \(xRy\) and \(yRz\) then \(xRz\)): if there is a path from \(x\) to \(z\) then there should be an edge directly from \(x\) to \(z\). The above relation is not transitive, because (for example) there is an path from \(a\) to \(f\) but no edge from \(a\) to \(f\).

If we have a relation that we know is an equivalence relation, we can leave out the directions of the arrows (since we know it is symmetric, all the arrows go both directions), and the self loops (since we know it is reflexive, so there is a self loop on every vertex).

If we have a relation \(R\) that doesn't satisfy a property \(P\) (such as reflexivity or symmetry), we can add edges until it does. This is called the \(P\) closure of \(R\). Formally:

**Definition**: the if \(P\) is a property of relations, **\(P\) closure** of \(R\) is the smallest relation containing \(R\) that satisfies property \(P\).

For example, to take the reflexive closure of the above relation, we need to add self loops to every vertex (this makes it reflexive) and nothing else (this makes it the smallest reflexive relation). Here is a picture of the reflexive closure:

Similarly for the transitive and symmetric closures:

We can take the reflexive symmetric transitive closure of \(R\) to turn \(R\) into an equivalence relation:

**Definition:** If \(R\) is an equivalence relation on \(A\) and \(x \in A\), then the **equivalence class of \(x\)**, denoted \([x]_R\), is the set of all elements of \(A\) that are related to \(x\), i.e. \([x]_R = \{y \in A \mid x R y\}\). If \(R\) is clear from context, we leave it out.

In the example above, \([a] = [b] = [e] = [f] = \{a,b,e,f\}\), while \([c] = [d] = \{c,d\}\) and \([g] = [h] = \{g,h\}\). The equivalence classes are easy to see in the diagram:

Equivalence classes let us think of groups of related objects as objects in themselves. For example

if \(A\) is the set of people, and \(R\) is the "is a relative of" relation, then equivalence classes are families

if \(A\) is the set of permutations of \(\{C,H,E_1,E_2,S,E_3\}\), and \(R\) is the "is the same if you ignore subscripts" relation, then the equivalence classes are rearrangements of the string "CHEESE".

The concept of equivalence classes allows us to be more concrete about certain counting problems.

Suppose we don't care about some of the structure of the elements of \(X\). For example, suppose we want to count the rearrangements of the string \(FOO\). We could start by counting all of the rearrangements of \(FO_1O_2\), but we would be overcounting: we want to consider \(FO_1O_2\) to be the same as \(FO_2O_1\).

What we really want to count is not strings, but equivalence classes of strings. We have an equivalence relation on strings: \(x \sim y\) if we can rearrange the O's of \(x\) to form \(y\). Under this relation, \(FO_1O_2 \sim FO_2O_1\); and we want to count this equivalence class as a single element.

Each equivalence class has 2 strings in it, because we can swap the two O's. Thus we have 6 strings total, divided up into groups of "equivalent" strings; each class has two elements, so the total number of groups is 6/2.

**Example:** Suppose we want to count the number of ways to rearrange the string \(MISSISSIPPI\) (one M, 2 P's, 4 I's, and 4 S's). We can start by finding the number of ways of rearranging the string \(MI_1S_1S_2I_2S_3S_4I_3P_1P_2I_4\). We can then consider two of these strings equal if we can rearrange the subscripts.

There are 11 characters total, so there are 11! ways to rearrange the string. We then want to mod out by the relation given by \(x \sim y\) if we can rearrange the O's, the I's, the P's, and the S's

How many elements are in each equivalence class? This is the same as asking, if I give you a string, how many other strings are equivalent to it? We can use the product rule to count them: to find an equivalent string, first choose one of the 4! permutations of the I's. Then, choose one of the 4! permutations of the S's. Then, chose one of the 2! permutations of the P's. If you want, you can choose one of the 1! permutations of the M's. Applying these permutations to your string yields an equivalent string. Thus, there are \(4!4!2!1!\) elements of each equivalence class.

Thus, the total number of equivalence classes is \(\frac{11!}{4!4!2!1!}\); this is the total number of ways to rearrange the string MISSISSIPPI.