Lecture 24 summary : Equivalence classes

Equivalence classes

Let A be a set and let R be an equivalence relation.

Siblings example

Consider the set A of all people, and consider the relation R given by xRy if x and y have the same parents (both parents must be the same).

The elements of A / R are the sets of siblings; you could think of A / R as the set of nuclear families (although the parents would not be included in the family under this definition).

Defining functions on A / R

Often we want to define a function with domain A / R by showing how to compute the output given a representative. In the sibling example, we may define the function f: [x]↦x's father.

However, we must be careful when we do so, because the function may be ambiguous. If y is a different representative of [x], then [y] = [x]. In order for f to be unambiguous, it had better be the case that f([y]) = f([x]) (since [y] = [x]). The output of the function shouldn't depend on the way we write down the input; we'd be very unhappy if g(3 + 3) ≠ g(6).

In this case, the function f is well-defined (not ambiguous), because every element of the equivalence class of x has the same parents as x, so they must have the same father as x.

As an example of an ambiguous function, we might try to define age: [x]↦ the age of x. This function is not well-defined, because my age is different from my sister's age. age is a property of the individual, not the family.

Example: BST

We could consider two binary search trees to be equivalent if they contain the same set of values.

Well defined functions are good to expose in an interface, while it's good to hide functions that aren't well defined. This gives the implementer the ability to choose more efficient representatives at any time without affecting the client code.

Example: minimizing DFAs

There are many automata that have the same language. Some of them have more states than others. It is sometimes useful to optimize a DFA by finding an equivalent DFA with the smallest number of states.

We defined the language of a state q (written L(M, q)) to be the set of strings that would be accepted if we started in state q instead of the start state. We considered two states to be equivalent if they had the same language.

We can construct a new automaton by taking the states of the new automaton to be equivalence classes of states of the original automaton. We can define the transition function and final states using representatives; we have to check that these functions are well defined (but they are).

For more details, see here.

Example: integers mod m

In the coming lectures we will consider the integers mod m, defined as follows. Let  ∼  be the relation "equivalence mod m", i.e. a ∼ b if and only if a ≡ b (modm).

Recall that a ≡ b (modm) if m∣(a − b), i.e. a − b = km for some k. Also, we showed previously that a ≡ b (modm) if amodm = bmodm.

The set of integers mod m, written Zm, is Z /  ∼ . It consists of the equivalence classes {[0], [1], [2], …, [m − 1]}. In general, ⋯ = [a − 2m] = [a − m] = [a] = [a + m] = [a + 2m] = ⋯.

In the coming lectures, we will show that operations like addition, multiplication, negation, etc. are well defined on Zm.