1 / 22

Lecture 4.1: Relations Basics

Lecture 4.1: Relations Basics. CS 250, Discrete Structures, Fall 2011 Nitesh Saxena * Adopted from previous lectures by Cinda Heeren. Course Admin. Mid-Term 2 Exam How was it? Solution will be posted soon Should have the results by the coming weekend HW3 Was due yesterday

ailish
Download Presentation

Lecture 4.1: Relations Basics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 4.1: Relations Basics CS 250, Discrete Structures, Fall 2011 NiteshSaxena *Adopted from previous lectures by CindaHeeren

  2. Course Admin • Mid-Term 2 Exam • How was it? • Solution will be posted soon • Should have the results by the coming weekend • HW3 • Was due yesterday • Bonus problem? • Solution will be posted soon • Results should be ready by the coming weekend Lecture 4.1: Relations Basics

  3. Roadmap • Done with about 60% of the course • We are left with two more homeworks • We are left with one final exam • Cumulative – will cover everything • Focus more on material covered after the two mid-terms • Please try to do your best in the remainder of the time; I know you have been working hard • Please submit your homeworks on time • Do you need periodic reminders? • Still a lot of scope of improvement • Done with travel for this semester – I will be fully at your disposal for the rest of the semester  Lecture 4.1: Relations Basics

  4. Outline • Relation Definition and Examples • Types of Relations • Operations on Relations Lecture 4.1: Relations Basics

  5. Relations • Recall the definition of the Cartesian (Cross) Product: The Cartesian Product of sets A and B, A x B, is the set A x B = {<x,y> : xA and yB}. • A relation is just any subset of the CP!! R  AxB • Ex: A = students; B = courses. R = {(a,b) | student a is enrolled in class b} We often say: aRb if (a,b) belongs to R Lecture 4.1: Relations Basics

  6. Yes, a function is a special kind of relation. Relations vs. Functions • Recall the definition of a function: f = {<a,b> : b = f(a) , aA and bB} • Is every function a relation? • Draw venn diagram of cross products, relations, functions Lecture 4.1: Relations Basics

  7. Properties of Relations • Reflexivity: A relation R on AxA is reflexive if for all aA, (a,a) R. • Symmetry: A relation R on AxA is symmetric if (a,b)  R implies (b,a)  R . Lecture 4.1: Relations Basics

  8. Properties of Relations • Transitivity: A relation on AxA is transitive if (a,b)  R and (b,c)  R imply (a,c)  R. • Anti-symmetry: A relation on AxA is anti-symmetric if (a,b)  R implies (b,a)  R. Lecture 4.1: Relations Basics

  9. 1 2 3 Loops must exist on EVERY vertex. 4 Properties of Relations - Techniques How can we check for the reflexive property? Draw a picture of the relation (called a “graph”). • Vertex for every element of A • Edge for every element of R Now, what’s R? {(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),(3,3),(3,4),(4,4)} Lecture 4.1: Relations Basics

  10. 1 2 3 EVERY edge must have a return edge. 4 Properties of Relations - Techniques How can we check for the symmetric property? Draw a picture of the relation (called a “graph”). • Vertex for every element of A • Edge for every element of R Now, what’s R? {(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),(3,3),(3,4),(4,4)} Lecture 4.1: Relations Basics

  11. 1 2 3 A “short cut” must be present for EVERY path of length 2. 4 Properties of Relations - Techniques How can we check for transitivity? Draw a picture of the relation (called a “graph”). • Vertex for every element of A • Edge for every element of R Now, what’s R? {(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),(3,3),(3,4),(4,4)} Lecture 4.1: Relations Basics

  12. 1 2 3 No edge can have a return edge. 4 Properties of Relations - Techniques How can we check for the anti-symmetric property? Draw a picture of the relation (called a “graph”). • Vertex for every element of A • Edge for every element of R Now, what’s R? {(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),(3,3),(3,4),(4,4)} Lecture 4.1: Relations Basics

  13. ? 2 1 2 1 1 ? ? 3 Yes Yes No No Properties of Relations - Examples Let R be a relation on People, R={(x,y): x and y have lived in the same country} Is R transitive? Is it symmetric? Is it reflexive? Is it anti-symmetric? Lecture 4.1: Relations Basics

  14. Yes Definition of “divides” Is (x,z) in R? Properties of Relations - Examples Let R be a relation on positive integers, R={(x,y): 3|(x-y)} Suppose (x,y) and (y,z) are in R. Then we can write 3j = (x-y) and 3k = (y-z) Can we say 3m = (x-z)? Add prev eqn to get: 3j + 3k = (x-y) + (y-z) 3(j + k) = (x-z) Is R transitive? Lecture 4.1: Relations Basics

  15. Yes Yes Definition of “divides” Yes, for k=0. Properties of Relations - Techniques Let R be a relation on positive integers, R={(x,y): 3|(x-y)} Is (x,x) in R, for all x? Does 3k = (x-x) for some k? Is R transitive? Is it reflexive? Lecture 4.1: Relations Basics

  16. Yes Yes Yes Definition of “divides” Yes, for k=-j. Properties of Relations - Techniques Let R be a relation on positive integers, R={(x,y): 3|(x-y)} Suppose (x,y) is in R. Then 3j = (x-y) for some j. Does 3k = (y-x) for some k? Is R transitive? Is it symmetric? Is it reflexive? Lecture 4.1: Relations Basics

  17. Yes Yes Yes No Definition of “divides” Yes, for k=-j. Properties of Relations - Techniques Let R be a relation on positive integers, R={(x,y): 3|(x-y)} Suppose (x,y) is in R. Then 3j = (x-y) for some j. Does 3k = (y-x) for some k? Is R transitive? Is it symmetric? Is it reflexive? Is it anti-symmetric? Lecture 4.1: Relations Basics

  18. More than one relation Suppose we have 2 relations, R1 and R2, and recall that relations are just sets! So we can take unions, intersections, complements, symmetric differences, etc. There are other things we can do as well… Lecture 4.1: Relations Basics

  19. B C A R S 1 x s 2 y t 3 z u 4 v 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): SR = {(a,c):  bB, (a,b)  R, (b,c)  S} SR = {(1,u),(1,v),(2,t),(3,t),(4,u)} Lecture 4.1: Relations Basics

  20. More than one relation Let R be a relation on A. Inductively define R1 = R Rn+1 = Rn R A A A R R1 1 1 1 2 2 2 3 3 3 4 4 4 R2 = R1R = {(1,1),(1,2),(1,3),(2,3),(3,3),(4,1), (4,2)} Lecture 4.1: Relations Basics

  21. … = R4 = R5 = R6… More than one relation Let R be a relation on A. Inductively define R1 = R Rn+1 = Rn R A A A R R2 1 1 1 2 2 2 3 3 3 4 4 4 R3 = R2R = {(1,1),(1,2),(1,3),(2,3),(3,3),(4,1),(4,2),(4,3)} Lecture 4.1: Relations Basics

  22. Today’s Reading • Rosen 9.1 Lecture 4.1: Relations Basics

More Related