
11/30/11 Relations CS202 Fall 2011 Lecture (lost count) – 12/1 Recall the definition of the Cartesian (Cross) Product: The Cartesian Product of sets A and B, A x B, is the set Relations A x B = {(a,b) : a∈A and b∈B}. Prof. Tanya Berger-Wolf aRb or (a,b) ∈ R means “a is related to b” A relation is just any subset of the Cartesian Product: R ⊆ AxB Ex1: A = {0,1,2}, B = {2,3} => AxB = {(0,2), (0,3), (1,2), (1,3), (2,2), (2,3)} R = {(a,b) | a < b}. So R = {(0,2), (0,3), (1,2), (1,3), (2,3)} = AxB-{(2,2)} Ex2: A = students at UIC; B = courses at UIC. R = {(a,b) | student a is enrolled in class b} Ex3: A = {3 letter strings}, B = {all English words} R = {(a,b) | a is a prefix of b} 1 Relations and Functions Properties of Relations Recall the definition of a function: f = {(a,b) : b = f(a) , a∈A and b∈B} Is every function a relation? Yes, a function is Reflexivity: a special kind of A relation R on AxA is reflexive if for all a∈A, (a,a) ∈R. relation. Symmetry: Draw Venn diagram of cross products, relations, Cross product A relation R on AxA is symmetric if functions (a,b) ∈ R implies (b,a) ∈ R . 1 11/30/11 Properties of Relations Properties of Relations - techniques… How can we check for transitivity? Draw a picture of the relation (called a “graph”) [Epp p. 580]. Transitivity: " ! Vertex for every element of A A relation on AxA is transitive if " ! Edge for every element of R (a,b) ∈ R and (b,c) ∈ R imply (a,c) ∈ R. R={(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),(3,3),(3,4),(4,4)} Anti-symmetry [Epp p.632]: A relation on AxA is anti-symmetric if (a,b) ∈ R implies (b,a) ∉ R. 1 A “short cut” 2 must be present for EVERY path of length 2. 3 4 Properties of Relations - techniques… Properties of Relations - techniques… How can we check for the reflexive property? How can we check for the symmetric property? Draw a picture of the relation (called a “graph”). Draw a picture of the relation (called a “graph”). " ! Vertex for every element of A " ! Vertex for every element of A " ! Edge for every element of R " ! Edge for every element of R R={(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),(3,3),(3,4),(4,4)} R={(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),(3,3),(3,4),(4,4)} 1 Loops must exist 1 EVERY edge 2 on EVERY vertex. 2 must have a return edge. 3 3 4 4 2 11/30/11 Properties of Relations - techniques… Properties of Relations - techniques… How can we check for the anti-symmetric property? Let R be a relation on People, Draw a picture of the relation (called a “graph”). R={(x,y): x and y have lived in the same country} " ! Vertex for every element of A " ! Edge for every element of R ? 1 2 R={(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),(3,3),(3,4),(4,4)} ? ? 3 Is R transitive? Is it symmetric? 1 NO edge can No Yes 2 have a return edge. Is it reflexive? Yes Is it anti-symmetric? No 3 4 Properties of Relations - techniques… Properties of Relations - techniques… Let R be a relation on positive integers, Let R be a relation on positive integers, R={(x,y): 3|(x-y)} R={(x,y): 3|(x-y)} Suppose (x,y) and (y,z) are in R. Is (x,x) in R, for all x? Definition of Definition of Then we can write 3j = (x-y) and 3k = (y-z) Does 3k = (x-x) for some k? “divides” “divides” Can we say 3m = (x-z)? Is (x,z) in R? Yes, for k=0. Add prev eqn to get: 3j + 3k = (x-y) + (y-z) 3(j + k) = (x-z) Is R transitive?! Yes Is R transitive? Yes Is it reflexive? Yes 3 11/30/11 Properties of Relations - techniques… Properties of Relations - techniques… Let R be a relation on positive integers, Let R be a relation on positive integers, R={(x,y): 3|(x-y)} R={(x,y): 3|(x-y)} Suppose (x,y) is in R. Suppose (x,y) is in R. Definition of Definition of Then 3j = (x-y) for some j. “divides” Then 3j = (x-y) for some j. “divides” Does 3k = (y-x) for some k? Does 3k = (y-x) for some k? Yes, for k=-j. Yes, for k=-j. Is R transitive?! Yes Is it symmetric?! Yes Is R transitive?! Yes Is it symmetric?! Yes Is it reflexive?! Yes Is it reflexive?! Yes Is it anti-symmetric?! No More than one relation More than one relation Let R be a relation from A to B (R ⊆ AxB), and let S be a relation from B to C (S ⊆ BxC). The composition of R and S is the relation from A to C (S°R ⊆ AxC): Suppose we have 2 relations, R1 and R2, and recall that relations are just sets! So we can take unions, intersections, complements, S°R = {(a,c): ∃ b∈B, (a,b) ∈ R, (b,c) ∈ S} symmetric differences, etc. There are other things we can do as well… A B C R S 1 x s 2 y t 3 z u 4 v S°R = {(1,u),(1,v),(2,t),(3,t),(4,u)} 4 11/30/11 More than one relation More than one relation Let R be a relation on A. Inductively define Let R be a relation on A. Inductively define R1 = R R1 = R Rn = Rn-1 ° R Rn = Rn-1 ° R A A A A A A R R1 R R2 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 4 … = R4 = R5 R3 = R2°R = {(1,1),(1,2),(1,3),(2,3),(3,3),(4,1),(4,2),(4,3)} R2 = R1°R = {(1,1),(1,2),(1,3),(2,3),(3,3),(4,1), (4,2)} = R6… Relations - A Theorem: Relations - A Theorem: If R is a transitive relation, then Rn ⊆ R, ∀n. Proof by induction on n. If R is a transitive relation, then Rn ⊆ R, ∀n. Base case (n=1): R1 ⊆ R because by definition, R1 = R. Inductive Step: IH: if R is transitive, then Rn-1 ⊆ R. Prove: if R is transitive, then Rn ⊆ R.! Aside: notice that this theorem allows us to conclude that Typical the previous relation was NOT transitive. We are trying to prove that Rn ⊆ R. To do this, we select an way of Recall: “if p then q” ≡ “if not q then not p.” element of Rn and show that it is also an element of R. proving subset. We saw that Rn was not a subset of R (it was growing on Let (a,b) be an element of Rn. Since Rn = Rn-1 ° R, we know every iteration). there is an x so that (a,x) ∈ R and (x,b) ∈ Rn-1. Therefore, R is not transitive. By IH, since Rn-1 ⊆ R, (x,b) ∈ R. But wait, if (a,x) ∈ R, and (x,b) ∈ R, and R is transitive, then (a,b) ∈ R. 5 11/30/11 Relations - more techniques… Relations - more techniques… Suppose we have our old relation R on AxB, where A={1,2,3,4}, and B={u,v,w}, R={(1,u),(1,v),(2,w),(3,w),(4,u)}. Some things to think about. Then we can represent R as: Let R be a relation on a set A, and let MR be the matrix representation of R. u v w The labels on Then R is reflexive if, ______________. the outside are 1 1 1 0 for clarity. It’s really the ! 2 0 0 1 matrix in the u v w A. All entries in MR are 1. middle that’s 3 0 0 1 B.! The \ diagonal of MR contains important. u 1 1 0 only 1s. 4 1 0 0 v 0 1 1 C.! The first column of MR contains no 0s. This is a |A| x |B| matrix whose entries indicate membership w 0 0 1 D.! None of the above. in R. Relations - more techniques… Relations - more techniques… Suppose we have R1 and R2 defined on A: R1 u v w R2 u v w Some things to think about. u 1 0 1 u 1 1 0 Let R be a relation on a set A, and let MR be the matrix representation of R. Then R is symmetric if, ______________. v 0 0 1 v 0 1 1 w 1 1 0 w 0 0 1 1 1 1 A.! All entries above the \ are 1. Then R ∪ R is the bitwise “or” of the entries:! 0 1 1 u v w 1 2 B.! The first and last columns of 1 1 1 MR1∪R2 = MR1 v MR2 u 1 0 1 MR contain an equal # of 0s. C.! MR is visually symmetric about Then R ∩ R is the bitwise “and” of the entries: 1 0 0 v 0 0 1 the \ diagonal. 1 2 M = M ∧ M 0 0 1 D.! None of the above.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages17 Page
-
File Size-