6 Relations Let R be a relation on a set A, i.e., a subset of AxA. Notation: xRy iff (x, y) ∈ R ⊆ AxA. Recall: A relation need not be a function. Example: The relation R1 = {(x, y) ∈ RxR | x2 + y 2 = 1} is not a function. Some definitions 1. R is reflexive if xRx ∀x ∈ A. 2. R is symmetric if xRy ⇒ yRx ∀x, y ∈ A. 3. R is antisymmetric if xRy ∧ yRx ⇒ x = y ∀x, y ∈ A. 4. R is transitive if xRy ∧ yRz ⇒ xRz ∀x, y, z ∈ A. We now give a number of examples. 1. R = “ < “ on Z. R, S, A, T. 2. R = “ ≤ “ on Z. R, S, A, T. 3. R = “ = “ on Z. R, S, A, T. 75 4. R, S, A, T . 5. R, S, A, T . 6. R, S, A, T . 7. R, S, A, T . 8. R, S, A, T . 9. R, S, A, T . 10. R, S, A, T . 76 Note: 1. In a reflexive relation there is a loop at each vertex. 2. In a symmetric relation, there are either 2 arcs or no arcs between any two distinct nodes. 3. In an antisymmetric relation there is either 1 arc or no arcs between any two distinct nodes. Definition: If R is a relation from X to Y , then the inverse of R is R−1 = {(y, x) | (x, y) ∈ R}. Examples: R: R−1: R: R−1: R: R−1: Theorem 6.1 R is symmetric iff R = R−1 . Theorem 6.2 The reflexive, symmetric, antisymmetric and transitive properties of relations are preserved by the inverse, i.e., if R has such a property then so does R−1. 77 Equivalence Relations Definition: A relation R ⊆ AxA is an equivalence relation if it is reflexive, symmetric and transitive. Examples: 1. 00 =00 on Z. 2. The universal relation UA = AxA, i.e., the relation consisting of all elements of AxA. 3. Let A be the set of all triangles in the plane. Then T1 RT2 iff T1 and T2 are similar triangles. 4. Let A be the set of all points in the plane. Then p1 Rp2 iff the distance from p1 to the origin equals the distance from p2 to the origin. 5. A = Z, m > 0. aRm b iff m | a − b, i.e., ∃c ∈ Z such that m · c = a − b. (a) Rm is reflexive since m | a − a. (b) Rm is symmetric since m | a − b ⇒ m | b − a. (c) Rm is transitive since if m | a − b and m | b − c, then m | (a − b) + (b − c) or m | a − c. Notation: If m | a − b we say a is congruent to b mod m, or a ≡ b (mod m). 78 6. Let f : A → B. Then Rf given by a1Rf a2 iff f (a1) = f (a2) is an equivalence relation. 7. Definition: Let R be an equivalence relation on A and b ∈ A. Then [b] = {x ∈ A | xRb} is the equivalence class generated by b. Example: Let A = Z and consider aR3 b. Thus a and b are related iff 3 | a − b. Then [0] = {. . . − 6, −3, 0, 3, 6, . . .} [1] = {. . . − 5, −2, 1, 4, 7, . . .} [2] = {. . . − 4, −1, 2, 5, 8, . . .} Example: In (7) above, [1] = [2] = {1, 2} and [3] = [4] = {3, 4}. Definition: Let A = ∪α∈ΛAα, where each Aα 6= φ and the Aα’s are pairwise disjoint. Then {Aα | α ∈ Λ} is a partition of A. Example: A1, A2, . . . , A7 is a partition of A. 79 Note: A partition of a set defines an equivalence relation in a very natural way. Definition: Let P be a partition of a set A. Then the equivalence relation R(P) associated with P is given by: aR(P )b iff a and b are in the same set in P . Note: R(P ) is clearly an equivalence relation. Example: The sets A1, A2, A3 partition Z. A1 = {. . . − 6, −3, 0, 3, 6, . . .} A2 = {. . . − 5, −2, 1, 4, 7, . . .} A3 = {. . . − 4, −1, 2, 5, 8, . . .} Thus 1R(P)7 and -4R(P)8. We now wish to show that each equivalence relation on a set A defines a partition in a natural way. 80 Theorem 6.3 Let R be an equivalence relation on a set A. Then 1. b ∈ [b] ∀b ∈ A. 2. ∀a, b ∈ A, [a] = [b] ⇔ aRb. 3. ∀a, b ∈ A, either [a] = [b] or [a] ∩ [b] = φ. Proof: First recall that [b] = {x ∈ A | xRb}. 1. Since R is reflexive, bRb. Hence b ∈ [b]. 2. (⇒) Suppose [a] = [b]. Since a ∈ [a], a ∈ [b]. Hence aRb. (⇐) Suppose x ∈ [b]. Then xRb. Also, since aRb and R is symmetric, bRa. Since R is also transitive, xRa, i.e., x ∈ [a]. Hence [b] ⊆ [a]. Similarly [a] ⊆ [b]. 3. Suppose x ∈ [a] ∩ [b]. Then xRa and xRb. Since R is symmetric, aRx. Now since R is transitive, aRb. Hence by (2), [a] = [b]. 2 Let P (R) = {[a] | a ∈ A}. If R∗ is an equivalence relation on a set A, the distinct sets P (R∗) partition A. Thus we have a 1-1 correspondence between the partitions of a set A and the equivalence relations on A. Note: P (R(P )) = P and R(P (R∗ )) = R∗. 81 Posets Let R be a relation on a set A. Then R is a partial ordering on A if R is 1. reflexive 2. antisymmetric 3. transitive Examples: 1. R : “ ≤ “ on Z. 2. R : “ ⊆ “ on P(A), the power set of A. 3. R : “divides” on Z +. (a) a | a. (b) a | b and b | a ⇒ a = b. (c) a | b and b | c ⇒ a | c. Definition: If R is a partial ordering on A we call (A, R) a partially ordered set or poset. Note: A subset of a partially ordered set is a partially ordered set (with the same ordering). Notation: When the relation is a partial ordering, we often use a ≤ b instead of aRb. 82 Definition: Suppose (A, R) is a poset. Elements a and b of A are said to be comparable if, and only if, either aRb or bRa. Otherwise they are noncomparable. Definition: Let R be a partial order relation on a set A. If any two elements a and b in A are comparable, then R is a total order relation on A. Examples: 1. R : “ ≤ “ on Z is a total order. 2. R : “ ⊆ “ on P (A) is not a total order if A has more than 1 element. 3. R : “divides” is not a total order on Z +, e.g., 3 does not divide 5 and 5 does not divide 3. Definition: Let (A, R) be a poset. A subset B of A is called a chain if, and only if, each pair of elements in B is comparable. The length of a chain is the number of elements in the chain. Note: The book has a different definition of length. Example: The set P ({a, b, c}) is partially ordered with respect to subset inclusion. The set S = {φ, {a}, {a, b}, {a, b, c}} is a chain of length 4 in P ({a, b, c}). 83 Hasse Diagrams Let A = {0, 1} and consider the poset (P (A), ⊆). Hasse diagram Properties of Hasse Diagrams • arrows are omitted - edges are directed upward • self loops are omitted • edges implied by transitivity are omitted More examples: 84 Definition: A subset of a poset (A, R) is an antichain if no two distinct elements of the subset are related. Example: {c, f, e} Definition: Let (A, ≤) be a poset. An element a ∈ A is a maximal element if there does not exist b ∈ A such that b 6= a and a ≤ b. Note: minimal element is defined similarly. In the examples above • a is a maximal element • g is a minimal element • 1, 2, 7 are maximal elements • 8, 9, 10 are minimal elements Note: Any finite, nonempty partially ordered set has a minimal (and maximal) element. Theorem 6.4 Let (A, ≤) be a poset. If n is the length of a longest chain in (A, ≤), then A can be partitioned into n disjoint antichains. Proof: Later, by induction. 85 Well Orderings Let (A, ≤) be a poset and B ⊆ A. An element b ∈ B is a 0 0 greatest element of B if b ≤ b ∀ b ∈ B. It is a least 0 0 element of B if b ≤ b ∀ b ∈ B. Example: Consider (N, ≤) and B = {3, 7, 12, 15}. Then 3 is a least element of B and 15 is a greatest element of B. Theorem 6.5 Let (A, R) be a poset and B ⊆ A. If x and y are greatest elements of B, then x = y. Proof: If x and y are greatest elements of B, then x ≤ y and y ≤ x. Since R is antisymmetric, x = y. 2 Note: Least elements are also unique. Definition: A relation R on A is a well ordering if R is a total ordering and every nonempty subset of A has a least element. Examples: • Any finite total ordering is a well ordering. • (R+ ∪ {0}) is NOT a well ordering since R+ ⊆ R+ ∪ {0} does not have a least element. • (Z, ≤) is NOT a well ordering since Z has no least element. • (N, ≤) is a well ordering - this is actually taken as an axiom. 86 Theorem 6.6 Every set can be well ordered. Note: It is not always easy to find the ordering. Example: The integers can be well ordered as follows: Let f : Z → N be defined by f (k) = 2k if k ≥ 0 -2k - 1 if k < 0. Note: f (0) = 0, f (−1) = 1, f (1) = 2, f (−2) = 3, etc. Note: Now a“ ≤ “b iff f (a) ≤ f (b) is a well ordering. 87 Closure Operations on Relations Example: Suppose we define a relation R on a set A of cities as follows: aRb iff there is a direct communication link from city a to city b for transmission of messages. Problem: Find a relation that describes how messages can be transmitted from one city to another, either through a direct communication link, or through any number of intermediate cities. Definition: Let R be a relation on a set A. The transitive closure of R is a relation Rt such that 1. Rt is transitive 2. R ⊆ Rt 3. If R1 is transitive and R ⊆ R1 , then Rt ⊆ R1 . Note: The transitive closure is unique. Note: The reflexive and symmetric closures are defined in an analogous way. Example: Rt : R: 88 Theorem 6.7 Let {Sα | α ∈ Λ} be the set of all transitive relations containing a relation R. Then Rt = ∩α∈Λ Sα. Thus the transitive closure of a relation R is the “smallest” transitive relation containing R. It is obtained by adding the least number of ordered pairs to ensure transitivity. Note: A similar theorem holds for reflexive and symmetric closures. 89 Composition of Relations Definition: Let R1 be a relation from A to B and R2 be a relation from B to C. The composition of R1 and R2 is a relation from A to C given by R1 R2 = {(a, c) | a ∈ A, c ∈ C ∧ ∃b ∈ B such that [(a, b) ∈ R1 ∧ (b, c) ∈ R2 ]}. Example: Note: In general, R1 R2 6= R2 R1 . In fact, if R1 is a relation from A to B and R2 is a relation from B to C, then R2 R1 is not defined. Example: Let A = {0, 1, 2, 3} and consider R1 and R2 on A. 90 Theorem 6.8 Let R1 ⊆ AxB, R2 ⊆ BxC and R3 ⊆ CxD. Then (R1 R2 )R3 = R1(R2 R3 ), i.e., the composition of relations is associative. Proof: (⊆) Let (a, d) ∈ (R1 R2 )R3 . Then ∃c ∈ C such that (a, c) ∈ R1 R2 and (c, d) ∈ R3 . Since (a, c) ∈ R1 R2 ∃b ∈ B such that (a, b) ∈ R1 and (b, c) ∈ R2 . Now (b, c) ∈ R2 and (c, d) ∈ R3 ⇒ (b, d) ∈ R2 R3 . But now (a, b) ∈ R1 ⇒ (a, d) ∈ R1 (R2 R3 ). (⊇) Similar. 2 Definition: Let R be a binary relation on a set A. Then Rn is defined as follows: 1. R0 = {(x, x) | x ∈ A}. 2. Rn+1 = RnR. 91 Example: • R0 : • R1 = R: • R2 = R1R: • R3 = R2R: • R4 = R3R: Note: In this example, R4 = R2. 92 Theorem 6.9 Let |A| = n and R ⊆ AxA. Then ∃s, t, 2 0 ≤ s < t ≤ 2n , such that Rs = Rt . Proof: First note that AxA has n2 elements. Hence there 2 are 2n distinct relations on A. By the pigeonhole principle, at least two of them are equal. 2 93