A function pairs each input with exactly one output, but "divides", "has the same birthday as" and "leaves the same remainder on division by as" pair things far more freely, and they need a language of their own.
The previous lesson closed on the observation that many useful relations are not functions at all. This lesson defines relations, picks out the ones that say two things are "the same for present purposes", and shows that each of them cuts its set into pieces, which is how modular arithmetic and the fractions are built. It assumes sets, the Cartesian product of all ordered pairs with and , the quantifiers, and divisibility: when for some integer .
Relations as sets of pairs
A relation on a set is a subset of . When the pair belongs to it we say is related to and write . A relation is exactly the set of pairs it holds between, so two relations are equal when they contain the same pairs, however differently they were described.
Take and let mean . As a set of pairs this is
eight of the sixteen pairs in . Order matters, since is in the set and is not. A relation on can be any subset of , and a set of elements has ordered pairs, so it carries relations: for , .
A function from to fits the same mould. Its graph, , is a set of pairs in which every appears as a first coordinate exactly once, so functions are the relations with that property. On , when is a function. The relation when is not, and it fails both ways: is related to and to , and is related to nothing. Divisibility above is not one either, since is related to four elements.
Reflexive, symmetric and transitive
Three properties of a relation on matter here, each a universal statement:
A relation with all three is an equivalence relation. Equality is the model, and "has the same birthday as" is another: everyone shares a birthday with themselves, sharing is mutual, and two people who share with a third share with each other.
Being universal, each property is broken by a single counterexample, and three relations on show that any two can hold without the third. The order is reflexive and transitive but not symmetric, since and not . "Close to", meaning , is reflexive and symmetric but not transitive: is close to and to , but is not close to . And when is symmetric and transitive (if and , then and both have the sign of ) but not reflexive, since .
That last example refutes a tempting proof: "if then , so by transitivity". Each step is valid, but the argument needs some with to start from, and for there is none. Reflexivity asks about every , including those related to nothing.
Proving a relation is an equivalence
Such a proof is three short proofs, one per property, each a universal conditional: take arbitrary elements, assume the hypothesis, and reach the conclusion from the definition of the relation.
Example. On , let when . Prove that is an equivalence relation.
Reflexive: let . Then , an integer, so . Symmetric: let , so for some integer . Then , also an integer, so . Transitive: let and , so and for integers and . Adding, , an integer, so . All three hold, so is an equivalence relation.
Here : two reals are related when they have the same fractional part. The three steps used that the integers contain and are closed under negation and addition.
Now you. On the nonzero reals, let when . Prove that is an equivalence relation.
Answer
Reflexive: for , , which is rational, so . Symmetric: let with rational. Since , , so is rational and . Transitive: let and with and rational. Then , which is rational, so . Hence is an equivalence relation.
Equivalence classes partition the set
Given an equivalence relation on and , the equivalence class of is everything related to it:
Under the fractional part relation above, , and : one class, two names. Any element of a class is a representative of it. A partition of is a collection of nonempty subsets of , its blocks, such that every element of lies in exactly one block. Birthdays cut a room into at most 366 blocks, and that always happens.
Theorem. If is an equivalence relation on , its equivalence classes form a partition of .
First, every element is in its own class: by reflexivity, so . Hence every class is nonempty and every element lies in at least one class.
Second, if then , by double inclusion. Let , so ; with , transitivity gives , so . Conversely let , so ; symmetry turns into , and transitivity gives , so .
Third, two classes are equal or disjoint. Suppose and share an element , so and . Symmetry gives , transitivity gives , and the second step gives . So no element lies in two different classes, and each lies in exactly one.
The converse holds too. Given a partition of , let when and lie in the same block. This is reflexive because every element lies in some block, and symmetric because "the same block" ignores order. For transitivity, let and share a block , and and a block . Then lies in both, and since it lies in exactly one block, , so and share a block. The classes of this relation are the blocks, so equivalence relations on and partitions of are one idea described two ways. On there are five partitions (all together, all apart, or a pair beside a singleton, in three ways), so only five of the 512 relations on that set are equivalence relations.
Congruence modulo
Fix a positive integer . Integers and are congruent modulo , written , when . So and . The notation is Carl Friedrich Gauss's, from his Disquisitiones Arithmeticae of 1801, and a clock uses it daily: five hours after nine o'clock is two o'clock because .
Example. Prove that congruence modulo is an equivalence relation on .
Reflexive: for , , so . Symmetric: let , so for some integer . Then , so . Transitive: let and for integers and . Adding, , so . Congruence modulo is therefore an equivalence relation.
Its classes, the congruence classes, number exactly . Division with remainder writes every integer uniquely as with , and then , so : every integer lies in one of . These are different, because if then lies strictly between and , and no multiple of does. For :
So says exactly that and leave the same remainder on division by .
Now you. On , let when . Prove that is an equivalence relation.
Answer
Reflexive: , so . Symmetric: let . Then , so . Transitive: let and . Then , so . In fact , so this is congruence modulo in disguise, with three classes.
The fractions as classes of pairs
A fraction is written as a pair of integers, but different pairs name the same number: , and are one rational number written three ways. An equivalence relation makes this precise, and builds from without assuming the division it is meant to create.
Let , and for pairs in let when , the cross multiplication test stated with multiplication alone. It is reflexive, since , and symmetric, since is the same equation as . Transitivity is the real work.
Claim. If and , then .
We are given and , and must show . Multiplying the first equation by gives , and by the second . Hence , that is, . The pair lies in , so , and a product of integers is zero only when a factor is; so .
The condition is not a formality. Allow and it is related to everything, since . Then and , but is not related to , because and . Transitivity would fail.
A rational number is now defined to be a class , written , and is the set of these classes. So is the set , and the integer reappears as the class of .
Well defined operations
Arithmetic on classes is defined through representatives, and that creates an obligation. A rule that picks a representative of a class and computes with it defines something only if every representative gives the same answer. Such a rule is well defined, and until that is proved it is not yet a function.
Here is one that fails. "Send to " looks like a function from to . But , and the rule sends this one class to through one name and to through the other. A school favourite fails the same way: "add the tops and add the bottoms" gives , yet with for it gives , and because and .
Example. Prove that addition of rationals, , is well defined.
First, because and , so the result is a class of pairs in . Now let and , that is, and . We must show , that is, . Expanding and substituting,
So the sum depends only on the classes, and addition of rationals is well defined.
Congruence classes behave as well. Define modulo . If and , then is a sum of multiples of , so . Clock arithmetic is arithmetic on the twelve classes modulo , whether nine o'clock is represented by , or .
Now you. Prove that multiplication of congruence classes modulo , , is well defined.
Answer
Let and for integers and . Then
so , and the product class does not depend on the representatives. For example, gives for every , which is why a number and the sum of its digits leave the same remainder on division by .
Equivalence relations group things: they say when two objects are the same for present purposes, and cut a set into classes that become objects in their own right. The other great kind of relation ranks things instead. The order on the numbers, on sets and divisibility on the positive integers are reflexive and transitive but far from symmetric, and the next lesson takes up these orders.