1 / 147

Discrete Structures

In The Name of Allah. Discrete Structures. Instructor: Dr. Ali Movaghar. Sharif University of Technology. Fall 1389. Relations : In these slides: Relations and their properties n- ary relations and their applications Representing relations Closures of relations

malo
Télécharger la présentation

Discrete Structures

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. In The Name of Allah Discrete Structures Instructor: Dr. Ali Movaghar Sharif University of Technology Fall 1389

  2. Relations: • In these slides: • Relations and their properties • n-aryrelations and their applications • Representing relations • Closures of relations • Equivalence relations • Partial ordering Discrete Structures Fall 1389

  3. Overview • Relationships between elements of sets occur in many contexts. Every day we deal with relations`hipssuch as those between a business and its telephone number, an employee and his or her salary, a person and a relative, and so on. In mathematics we study relationships such as those between a positive integer and one that it divides, an integer and one that it is congruent to modulo 5, a real number and one that is larger than it, a real number x and the value .f(x) where .f is a function, and so on. Relationships such as that between a program and a variable it uses and that between a computer language and a valid statement in this language often arise in computer science.

  4. Overview • Relationships between elements of sets are represented using the structure called a relation, which is just a subset of the Cartesian product of the sets. Relations can be used to solve problems such as determining which pairs of cities are linked by airline flights in a network, finding a viable order for the different phases of a complicated project, or producing a useful way to store information in computer databases.

  5. Overview • In some computer languages, only the first 31 characters of the name of a variable matter. The relation consisting of ordered pairs of strings where the first string has the same initial 3 1 characters as the second string is an example of a special type of relation, known as an equivalence relation. Equivalence relations arise throughout mathematics and computer science. We will study equivalence relations, and other special types of relations, in this chapter.

  6. Relations and their properties Discrete Structures Fall 1389

  7. Binary Relations • Let A, B be any sets. A binary relationR from A to B, (i.e., with signature R:A×B) can be identified with a subset of A×B. • E.g.,< can be seen as{(n,m)| n < m} Discrete Structures Fall 1389

  8. Binary Relations • Let A, B be any sets. A binary relationR from A to B, (i.e., with signature R:A×B) can be identified with a subset of A×B. • E.g.,< can be seen as{(n,m)| n < m} • (a,b)R means thata is related to b (by R) Discrete Structures Fall 1389

  9. Binary Relations • Let A, B be any sets. A binary relationR from A to B, (i.e., with signature R:A×B) can be identified with a subset of A×B. • E.g.,< can be seen as{(n,m)| n < m} • (a,b)R means thata is related to b (by R) • Also written asaRb; alsoR(a,b) • E.g.,a<b and< (a,b) bothmean(a,b) < Discrete Structures Fall 1389

  10. Binary Relations • Let A, B be any sets. A binary relationR from A to B, (i.e., with signature R:A×B) can be identified with a subset of A×B. • E.g.,< can be seen as{(n,m)| n < m} • (a,b)R means thata is related to b (by R) • Also written asaRb; alsoR(a,b) • E.g.,a<b and< (a,b) bothmean(a,b) < • A binary relation R corresponds to a characteristic function PR:A×B→{T,F} Discrete Structures Fall 1389

  11. Complementary Relations • Let R:A,B be any binary relation. • Then, R:A×B, the complement of R, is the binary relation defined byR:≡{(a,b)A×B | (a,b)R}=(A×B) − R • Note this is just R if the universe of discourse is U = A×B; thus the name complement. • Note the complement of R is R. Discrete Structures Fall 1389

  12. Complementary Relations • Let R:A,B be any binary relation. • Then, R:A×B, the complement of R, is the binary relation defined byR:≡{(a,b)A×B | (a,b)R}=(A×B) − R • Note this is just R if the universe of discourse is U = A×B; thus the name complement. • Note the complement of R is R. Discrete Structures Fall 1389 Example:< = {(a,b) | (a,b)<} = {(a,b) | ¬a<b} = ≥

  13. Inverse Relations • Any binary relation R:A×B has an inverse relation R−1:B×A, defined byR−1 :≡ {(b,a) | (a,b)R}. E.g., <−1 = {(b,a) | a<b} = {(b,a) | b>a} = >. • E.g., if R:People x Foods is defined by a R b  aeatsb, then: bR−1a  a eats b(Compare: bis eaten bya, passive voice.) Discrete Structures Fall 1389

  14. Relations on a Set • A (binary) relation from a set A to itself is called a relation onA. Discrete Structures Fall 1389

  15. Relations on a Set • A (binary) relation from a set A to itself is called a relation onA. • E.g., the “<” relation from earlier was defined as a relation onN. Discrete Structures Fall 1389

  16. Relations on a Set Discrete Structures Fall 1389

  17. Reflexivity and relatives • A relation R on A is reflexiveiffaA(aRa). • E.g., the relation ≥ :≡ {(a,b) | a≥b} is reflexive. • R is irreflexiveiffaA(aRa) • Note “irreflexive” does NOT mean “notreflexive”, which is just aA(aRa). • E.g., if Adore={(j,m),(b,m),(m,b)(j,j)} then this relation is neither reflexive nor irreflexive Discrete Structures Fall 1389

  18. Reflexivity and relatives • Theorem: A relation R is irreflexiveiff its complementary relation R’ is reflexive. • Proof: trivial • Example: < is irreflexive; ≥ is reflexive. Discrete Structures Fall 1389

  19. Can you think of • Reflexive relations • Irreflexive relations Involving numbers, propositions or sets? Discrete Structures Fall 1389

  20. Some examples • Reflexive: =, ‘have same cardinality’,  <=, >=, , , etc. • Irreflexive: <, >, `have different cardinality’, , ‘is logically stronger than’ Discrete Structures Fall 1389

  21. Symmetry & relatives • A binary relation R on A is symmetriciffa,b((a,b)R ↔ (b,a)R). • E.g., = (equality) is symmetric. < is not. • “is married to” is symmetric, “likes” is not. • A binary relation R is asymmetric if a,b((a,b)R → (b,a)R). • Examples: < is asymmetric, “Adores” is not. • Let R={(j,m),(b,m),(j,j)}. Is R (a)symmetric? Discrete Structures Fall 1389

  22. Symmetry & relatives(cont’d) • Let R={(j,m),(b,m),(j,j)}. R is not symmetric (because it does not contain (m,b) and because it does not contain (m,j)). R is not asymmetric, due to (j,j) Discrete Structures Fall 1389

  23. Some direct consequences Theorems: • R is symmetric iffR = R−1, • R is asymmetric iffRR−1 is empty. Discrete Structures Fall 1389

  24. Symmetry & its relatives 1. R is symmetric iffR = R−1 • Suppose R is symmetric. Then (x,y)  R (y,x)  R  (x,y)  R−1  Suppose R = R−1 Then (x,y)  R  (x,y)  R−1 (y,x)  R Discrete Structures Fall 1389

  25. Symmetry & relatives 2. R is asymmetric iffRR−1 is empty.(Straightforward application of the definitions of asymmetry and R−1) Discrete Structures Fall 1389

  26. Question • Can you construct a model in which the relation “son of” is symmetric? • More precisely: find domain A and relation R on A such that R is symmetric and R(x,y) can reasonably be read as ‘x is a son of y’ Discrete Structures Fall 1389

  27. Question(cont’d) • Can you construct a model in which the relation “son_of” is symmetric? • Solution: any model in which there are no x,y such that son_of(x,y) is true • E.g., A = {John, Mary, Sarah}, AxA  R= {} Discrete Structures Fall 1389

  28. Antisymmetry • Consider the relation xy • Is it symmetrical? • Is it asymmetrical? • Is it reflexive? • Is it irreflexive? Discrete Structures Fall 1389

  29. Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? • Is it reflexive? • Is it irreflexive? Discrete Structures Fall 1389

  30. Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? No • Is it reflexive? • Is it irreflexive? Discrete Structures Fall 1389

  31. Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? No • Is it reflexive? Yes • Is it irreflexive? Discrete Structures Fall 1389

  32. Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? No • Is it reflexive? Yes • Is it irreflexive? No Discrete Structures Fall 1389

  33. Antisymmetry • Consider the relation xy • It is not symmetric. (For instance, 56 but not 65) • It is not asymmetric. (For instance, 5 5) • The pattern: the only times when (a,b) and (b,a)  are when a=b • This is called antisymmetryCan you say this in predicate logic? Discrete Structures Fall 1389

  34. Antisymmetry • A binary relation R on A is antisymmetriciffa,b((a,b)R  (b,a)R) a=b). • Examples: , ,  • Another example: the earlier-defined relation Adore={(j,m),(b,m),(j,j)} • How would you define transitivity of a relation? What are its ‘relatives’? Discrete Structures Fall 1389

  35. Transitivity & relatives • A relation R is transitiveiff (for all a,b,c) ((a,b)R  (b,c)R) → (a,c)R. • A relation is nontransitiveiff it is not transitive. • A relation R is intransitiveiff (for all a,b,c)((a,b)R  (b,c)R) → (a,c)R. Discrete Structures Fall 1389

  36. Transitivity & relatives • What about these examples: • “x is an ancestor of y” • “x likes y” • “x is located within 1 mile of y” • “x +1 =y” • “x beat y in the tournament” Discrete Structures Fall 1389

  37. Transitivity & relatives • What about these examples: • “is an ancestor of” is transitive. • “likes” is neither trans nor intrans. • “is located within 1 mile of” is neither trans nor intrans • “x +1 =y”is intransitive • “x beat y in the tournament” is neither trans nor intrans Discrete Structures Fall 1389

  38. Exploring the difference between relations and functions Totality: • A relation R:A×B is total if for every aA, there is at least one bB such that (a,b)R. • N.B., it does not follow that R−1 is total • It does not follow that R is functional (see over). Discrete Structures Fall 1389

  39. Functionality Functionality: • A relation R: A×B is functionaliff, for every aA, there is at most one bB such that (a,b)R. • A functional relation R: A×B does not have to be total (there may be aAsuch that ¬bB (aRb)). • Say that “R is functional”, using predicate logic Discrete Structures Fall 1389

  40. Functionality • R: A×B is functionaliff, for every aA, there is at most one bB such that (a,b)R. aA: ¬ b1,b2 B (b1≠b2  aRb1  aRb2). • If R is a functional and total relation, then R can be seen as a function R: A→B Hence one can write R(a)=b as well as aRb, R(a,b), and (a,b) R. Each of these mean the same. Discrete Structures Fall 1389

  41. Functionality • Definition: R is antifunctionaliff its inverse relation R−1 is functional. (Exercise: Show that iffR is functional and antifunctional, and both it and its inverse are total, then it is a bijective function.) Discrete Structures Fall 1389

  42. Combining what you’ve learned about functions and relations Consider the relation R:NN defined as R = {(x,y) | xN  yN  y=x+1}. Questions: • Is R total? Why (not)? • Is R functional? Why (not)? • Is R an injection? Why (not)? • Is R a surjection? Why (not)? Discrete Structures Fall 1389

  43. Composite Relations • Let R:A×B, and S:B×C. Then the compositeSR of R and S is defined as: SR = {(a,c) | b:aRb bSc} Discrete Structures Fall 1389

  44. Composite Relations • Let R:A×B, and S:B×C. Then the compositeSR of R and S is defined as: SR = {(a,c) | b:aRb bSc} • Does this remind you of something? Discrete Structures Fall 1389

  45. Composite Relations • Let R:A×B, and S:B×C. Then the compositeSR of R and S is defined as: SR = {(a,c) | b:aRb bSc} • Does this remind you of something? • Function composition ... • ... except that SR accommodates the fact that S and R may not be functional Discrete Structures Fall 1389

  46. Composite Relations • Function composition is a special case of relation composition: • Suppose S and R are functional. Then we have (using the definition above, then switching to function notation) SR(a,c)iffb:aRb bSciff R(a)=b and S(b)=c iff S(R(a))=c Discrete Structures Fall 1389

  47. Suppose • Adore={(a,b),(b,c),(c,c)} • Detest={(b,d),(c,a),(c,b)} • AdoreDetest= • DetestAdore= Discrete Structures Fall 1389

  48. Suppose • Adore={(a,b),(b,c),(c,c)} • Detest={(b,d),(c,a),(c,b)} • AdoreDetest= {(c,b),(c,c)} • DetestAdore= Discrete Structures Fall 1389

  49. Suppose • Adore={(a,b),(b,c),(c,c)} • Detest={(b,d),(c,a),(c,b)} • AdoreDetest= {(c,b),(c,c)} • DetestAdore= {(a,d),(b,a),(b,b),(c,a),(c,b)} Discrete Structures Fall 1389

  50. n-aryRelations Discrete Structures Fall 1389

More Related