1.5k likes | 1.8k Vues
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
E N D
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-aryrelations and their applications • Representing relations • Closures of relations • Equivalence relations • Partial ordering Discrete Structures Fall 1389
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.
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.
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.
Relations and their properties Discrete Structures Fall 1389
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
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
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
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
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
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} = ≥
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
Relations on a Set • A (binary) relation from a set A to itself is called a relation onA. Discrete Structures Fall 1389
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
Relations on a Set Discrete Structures Fall 1389
Reflexivity and relatives • A relation R on A is reflexiveiffaA(aRa). • E.g., the relation ≥ :≡ {(a,b) | a≥b} is reflexive. • R is irreflexiveiffaA(aRa) • Note “irreflexive” does NOT mean “notreflexive”, which is just aA(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
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
Can you think of • Reflexive relations • Irreflexive relations Involving numbers, propositions or sets? Discrete Structures Fall 1389
Some examples • Reflexive: =, ‘have same cardinality’, <=, >=, , , etc. • Irreflexive: <, >, `have different cardinality’, , ‘is logically stronger than’ Discrete Structures Fall 1389
Symmetry & relatives • A binary relation R on A is symmetriciffa,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
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
Some direct consequences Theorems: • R is symmetric iffR = R−1, • R is asymmetric iffRR−1 is empty. Discrete Structures Fall 1389
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
Symmetry & relatives 2. R is asymmetric iffRR−1 is empty.(Straightforward application of the definitions of asymmetry and R−1) Discrete Structures Fall 1389
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
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
Antisymmetry • Consider the relation xy • Is it symmetrical? • Is it asymmetrical? • Is it reflexive? • Is it irreflexive? Discrete Structures Fall 1389
Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? • Is it reflexive? • Is it irreflexive? Discrete Structures Fall 1389
Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? No • Is it reflexive? • Is it irreflexive? Discrete Structures Fall 1389
Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? No • Is it reflexive? Yes • Is it irreflexive? Discrete Structures Fall 1389
Antisymmetry • Consider the relation xy • Is it symmetrical? No • Is it asymmetrical? No • Is it reflexive? Yes • Is it irreflexive? No Discrete Structures Fall 1389
Antisymmetry • Consider the relation xy • It is not symmetric. (For instance, 56 but not 65) • 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
Antisymmetry • A binary relation R on A is antisymmetriciffa,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
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
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
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
Exploring the difference between relations and functions Totality: • A relation R:A×B is total if for every aA, there is at least one bB 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
Functionality Functionality: • A relation R: A×B is functionaliff, for every aA, there is at most one bB such that (a,b)R. • A functional relation R: A×B does not have to be total (there may be aAsuch that ¬bB (aRb)). • Say that “R is functional”, using predicate logic Discrete Structures Fall 1389
Functionality • R: A×B is functionaliff, for every aA, there is at most one bB such that (a,b)R. aA: ¬ 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
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
Combining what you’ve learned about functions and relations Consider the relation R:NN defined as R = {(x,y) | xN yN 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
Composite Relations • Let R:A×B, and S:B×C. Then the compositeSR of R and S is defined as: SR = {(a,c) | b:aRb bSc} Discrete Structures Fall 1389
Composite Relations • Let R:A×B, and S:B×C. Then the compositeSR of R and S is defined as: SR = {(a,c) | b:aRb bSc} • Does this remind you of something? Discrete Structures Fall 1389
Composite Relations • Let R:A×B, and S:B×C. Then the compositeSR of R and S is defined as: SR = {(a,c) | b:aRb bSc} • Does this remind you of something? • Function composition ... • ... except that SR accommodates the fact that S and R may not be functional Discrete Structures Fall 1389
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) SR(a,c)iffb:aRb bSciff R(a)=b and S(b)=c iff S(R(a))=c Discrete Structures Fall 1389
Suppose • Adore={(a,b),(b,c),(c,c)} • Detest={(b,d),(c,a),(c,b)} • AdoreDetest= • DetestAdore= Discrete Structures Fall 1389
Suppose • Adore={(a,b),(b,c),(c,c)} • Detest={(b,d),(c,a),(c,b)} • AdoreDetest= {(c,b),(c,c)} • DetestAdore= Discrete Structures Fall 1389
Suppose • Adore={(a,b),(b,c),(c,c)} • Detest={(b,d),(c,a),(c,b)} • AdoreDetest= {(c,b),(c,c)} • DetestAdore= {(a,d),(b,a),(b,b),(c,a),(c,b)} Discrete Structures Fall 1389
n-aryRelations Discrete Structures Fall 1389