- Reading: MCS 10.10-10.11
\(A / R\), properties of equivalence classes, defining functions

**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:

**Definition:** The set of all equivalence classes of \(A\) is denoted **\(A / R\)** (pronounced "\(A\) modulo \(R\)" or "\(A\) mod \(R\)"). Notationally, \(A/R = \{[x] \mid x \in A\}\).

In the example above, \(A/R = \{[a], [c], [g]\}\).

**Definition:** If \(c \in A/R\) and \(x \in c\), then \(x\) is called a **representative** of \(c\).

In the example above, \(a\) is a representative of \([b]\), and \(d\) is a representative of \(\{c,d\}\).

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 \(A/R\) is the set of families

if \(A\) is the set of hash tables, and \(R\) is the "has the same entries as" relation, then \(A/R\) is the set of functions with a finite domain.

We'll see equivalence classes in several places in the remainder of the course:

(cardinality) if \(A\) is the set of all sets (this is actually problematic, but we'll pretend it makes sense), and \(R\) is the "has a same cardinality as" relation, then \(A/R\) is the set of cardinal numbers; which is how you would define \(|X|\).

(combinatorics) we'll see later that if \(A\) is the set of sequences of length \(n\), and \(R\) is the "can be rearranged to" relation, then \(A/R\) is the set of subsets of size \(n\).

(automata) we'll take \(A\) to be the set of states of a machine, and \(R\) to be the "behaves the same as" relation, and then \(A/R\) will be the states of an optimized machine.

(number theory) if \(A\) is the set of integers, and \(R\) is the "has the same remainder when divided by \(n\) as" relation, then \(A/R\) will be the modular numbers.

(graphs) if \(A\) is the set of vertices, and \(R\) is the "is reachable from" relation, then \(A/R\) is the set of connected components of the graph.

**Claim:** if \(R\) is an equivalence relation on \(A\), then the equivalence classes of \(R\) form a partition of \(A\). That is, every element of \(x\) is in some equivalence class, and no two different equivalence classes overlap.

**Proof sketch:** (you could fill in the details as an exercise)

first part: every \(x\) is in \([x]\) because \(R\) is reflexive.

second part: if \([a]\) and \([b]\) overlap, then there is some \(c\) in the intersection. Then we can use symmetry and transitivity to show that every element of \([a]\) is related to \(d\), and thus to \(b\), and is thus in \([b]\); likewise, every element of \([b]\) is in \([a]\), so \([a]\) and \([b]\) are the same.

We ended lecture with the following question. Let \(A\) be a set of people, and let \(R\) be the "is related to" relation (where everyone is assumed to be related to themselves).

Suppose I wrote down the following rule:

Let \(f : A/R → A\) be defined by letting \(f([a])\) be \(a\)'s oldest living relative

Is \(f\) a function?

To see why it might or might not be, compare it with the following rule:

Let \(g : A/R → \mathbb{N}\) be defined by letting \(g([a])\) be \(a\)'s age.

One of these *is* a function, and the other is *not*. \(f\) is a function, but not obviously so. \(g\) is not a function. To see why, suppose that \(a\)'s age is 13 and \(b\)'s age is 25. Then \(g([a]) = 13\) and \(g([b]) = 25\). But \([a] = [b]\), so we have a single input giving multiple outputs, depending on how we write it down.

\(f\) is a function, because if \([a] = [b]\) and if \(a\)'s oldest living relative is \(c\), then \(b\)'s oldest living relative must also by \(c\). So choosing different representatives of the input leads to the same value; the function is well-defined.