relations (1) rosen 6 th ed., ch. 8. binary relations let a, b be any two sets. a binary relation r...
TRANSCRIPT
![Page 1: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/1.jpg)
Relations (1)Relations (1)
Rosen 6th ed., ch. 8
![Page 2: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/2.jpg)
Binary RelationsBinary Relations
• Let A, B be any two sets.• A binary relation R from A to B, written (with signature)
R:A↔B, is a subset of A×B. – E.g., let < : N↔N :≡ {(n,m) | n < m}
• The notation a R b or aRb means (a,b)R.– E.g., a < b means (a,b) <
• If aRb we may say “a is related to b (by relation R)”, or “a relates to b (under relation R)”.
• A binary relation R corresponds to a predicate function PR:A×B→{T,F} defined over the 2 sets A,B; e.g., “eats” :≡ {(a,b)| organism a eats food b}
![Page 3: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/3.jpg)
Complementary RelationsComplementary 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)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.Example: < = {(a,b) | (a,b)<<} = {(} = {(aa,,bb) | ) | ¬¬aa<<bb} = } = ≥≥
![Page 4: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/4.jpg)
Inverse RelationsInverse Relations
• Any binary relation R:A↔B has an inverse relation R−1:B↔A, defined by
R−1 :≡ {(b,a) | (a,b)R}.E.g., <−1 = {(b,a) | a<b} = {(b,a) | b>a} = >.
• E.g., if R:People→Foods is defined by aRb a eats b, then: b R−1
a b is eaten by a. (Passive voice.)
![Page 5: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/5.jpg)
Relations on a SetRelations on a Set
• A relation on the set A is a relation from A to A.• In other words, a relation on a set A is a subset
of A х A.• Example 4. Let A be the set {1, 2, 3, 4}. Which
ordered pairs are in the relation R = {(a, b) | a divides b}?
Solution: R = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}
![Page 6: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/6.jpg)
ReflexivityReflexivity
• A relation R on A is reflexive if aA, aRa.– E.g., the relation ≥ :≡ {(a,b) | a≥b} is reflexive.
• A relation is irreflexive iff its complementary relation is reflexive. (for every aA, (a, a) R)– Note “irreflexive” ≠ “not reflexive”!– Example: < is irreflexive.– Note: “likes” between people is not reflexive, but not
irreflexive either. (Not everyone likes themselves, but not everyone dislikes themselves either.)
![Page 7: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/7.jpg)
Symmetry & AntisymmetrySymmetry & Antisymmetry
• A binary relation R on A is symmetric iff R = R−1, that is, if (a,b)R ↔ (b,a)R.
i.e, ab((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 antisymmetric if ab(((a, b) R (b, a) R) → (a = b))– < is antisymmetric, “likes” is not.
![Page 8: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/8.jpg)
AsymmetryAsymmetry
• A relation R is called asymmetric if (a,b)R implies that (b,a) R.– ‘=’ is antisymmetric, but not asymmetric.– < is antisymmetric and asymmetric.– “likes” is not antisymmetric and asymmetric.
![Page 9: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/9.jpg)
TransitivityTransitivity
• A relation R is transitive iff (for all a,b,c)(a,b)R (b,c)R → (a,c)R.
• A relation is intransitive if it is not transitive.• Examples: “is an ancestor of” is transitive.• “likes” is intransitive.• “is within 1 mile of” is… ?
![Page 10: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/10.jpg)
Examples of Properties of RelationsExamples of Properties of Relations
• Example 7. Relations on {1, 2, 3, 4}– R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)},
R2 = {(1, 1), (1, 2), (2, 1)},
R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1),
(4, 4)}, R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)},
R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4),
(3, 3), (3, 4), (4, 4)}, R6 = {(3, 4)}.
![Page 11: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/11.jpg)
Examples Cont.Examples Cont.
• Solution – Reflective : X, X, O, X, O, X– Irreflective : X, X, X, O, X, O– Symmetric : X, O, O, X, X, X– Antisymmetric : X, X, X, O, O, O– Asymmetric : X, X, X, O, X, O– Transitive : X, X, X, O, O, O
![Page 12: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/12.jpg)
Examples Cont.Examples Cont.
• Example 5. Relations on the set of integers– R1 = {(a, b) | a ≤ b},
R2 = {(a, b) | a > b},
R3 = {(a, b) | a = b or a = -b},
R4 = {(a, b) | a = b},
R5 = {(a, b) | a = b + 1},
R6 = {(a, b) | a + b ≤ 3},
![Page 13: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/13.jpg)
Examples Cont.Examples Cont.
• Solution – Reflective : O, X, O, O, X, X– Irreflective : X, O, X, X, O, X– Symmetric : X, X, O, O, X, O– Antisymmetric : O, O, X, O, O, X– Asymmetric : X, O, X, X, O, X– Transitive : O, O, O, O, X, X
![Page 14: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/14.jpg)
Composition of RelationsComposition of Relations
• DEFINITION: Let R be a relation from a set A to a set B and S a relation from B to a set C. The composite of R and S is the relation consisting of ordered pairs (a, c), where a A, c C, and for which there exists an element b B such that (a, b) R and (b, c) S. We denote the composite of R and S by S◦R.
![Page 15: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/15.jpg)
Composition of Relations Cont.Composition of Relations Cont.
• R : relation between A and B• S : relation between B and C
• S°R : composition of relations R and S– A relation between A and C– {(x,z)| x A, z C, and there exists y B such that xRy and ySz }
z
wx
y
u
R SAB C
x
Az
w
CS°R
![Page 16: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/16.jpg)
ExampleExample
1
2
3
1
2
3
4
1
2
3
4
1
2
R S
S°R
1
2
3
1
2
![Page 17: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/17.jpg)
Example Cont.Example Cont.
• What is the composite of the relations R and S, where R is the relation from {1, 2, 3} to {1, 2, 3, 4} with R = {(1, 1), (1, 4), (2, 3), (3, 1), (3, 4)} and S is the relation from {1, 2, 3, 4} to {0, 1, 2} with S = {(1, 0), (2, 0), (3, 1), (3, 2), (4, 1)}.
Solution: S◦R = {(1, 0), (1, 1), (2, 1), (2, 2), (3, 0), (3, 1)}
![Page 18: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/18.jpg)
Power of RelationsPower of Relations
• DEFINITION: Let R be a relation on the set A. The powers Rn, n = 1, 2, 3, …, are defined recursively by R1 = R and Rn+1 = Rn◦R.
• EXAMPLE: Let R = {(1, 1), (2, 1), (3, 2), (4, 3)}. Find the powers Rn, n = 2, 3, 4, ….
• Solution: R2 = R◦R = {(1, 1), (2, 1), (3, 1), (4, 2)}, R3 = R2◦R = {(1, 1), (2, 1), (3, 1), (4, 1)}, R4 = R2◦R = {(1, 1), (2, 1), (3, 1), (4, 1)} => Rn = R3
![Page 19: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/19.jpg)
Power of Relations Cont.Power of Relations Cont.
• THEOREM: The relation R on a set A is transitive if and only if Rn R for n = 1, 2, 3, ….
• EXAMPLE: Let R = {(1, 1), (2, 1), (3, 2), (4, 3)}. Is R transitive? => No (see the previous page).
• EXAMPLE: Let R = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}. Is R transitive?
• Solution: R2 = ?, R3 = ?, R4 = ? => maybe a tedious task^^
![Page 20: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/20.jpg)
Representing RelationsRepresenting Relations
• Some special ways to represent binary relations:– With a zero-one matrix.– With a directed graph.
![Page 21: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/21.jpg)
Using Zero-One MatricesUsing Zero-One Matrices
• To represent a relation R by a matrix MR = [mij], let mij = 1 if (ai,bj)R, else 0.
• E.g., Joe likes Susan and Mary, Fred likes Mary, and Mark likes Sally.
• The 0-1 matrix representationof that “Likes”relation:
1 00
010
0 1 1
Mark
Fred
JoeSallyMarySusan
![Page 22: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/22.jpg)
Zero-One Reflexive, SymmetricZero-One Reflexive, Symmetric
• Terms: Reflexive, non-Reflexive, irreflexive,symmetric, asymmetric, and antisymmetric.– These relation characteristics are very easy to
recognize by inspection of the zero-one matrix.
0
0
101
0
0
01
1
0
0
0
0
1
1
1
1
Reflexive:all 1’s on diagonal
Irreflexive:all 0’s on diagonal
Symmetric:all identical
across diagonal
Antisymmetric:all 1’s are across
from 0’s
any-thing
any-thing
any-thing
any-thing anything
anything
![Page 23: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/23.jpg)
Finding Composite MatrixFinding Composite Matrix
• Let the zero-one matrices for S◦R, R, S be M S◦R, MR, MS. Then we can find the matrix representing the relation S◦R by:
• M S◦R = MR M⊙ S
• EXAMPLE: MR MS M S◦R
⊙ =
101
010
101
010
010
010
010
010
010
![Page 24: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/24.jpg)
Examples of matrix representationExamples of matrix representation
• List the ordered pairs in the relation on {1, 2, 3} corresponding to these matrices (where the rows and columns correspond to the integers listed in increasing order).
101
010
101
010
010
010
111
101
111
![Page 25: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/25.jpg)
Examples Cont.Examples Cont.
• Determine properties of these relations on {1, 2, 3, 4}.
R1 R2 R3
1101
1110
0101
1011
1001
1100
0010
0111
0101
1010
0101
1010
![Page 26: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/26.jpg)
Examples Cont.Examples Cont.
• Solution – Reflective : X, O, X – Irreflective : O, X, O– Symmetric : O, X, O– Antisymmetric : X, X, X– Asymmetric : X, X, X
![Page 27: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/27.jpg)
Examples Cont.Examples Cont.
– Transitive :
– R12 = = ⊙
– Not Transitive – Notice: (1, 4) and (4, 3) are in R1 but not (1, 3)
1101
1110
0101
1011
1101
1110
0101
1011
1111
1111
1111
1111
![Page 28: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/28.jpg)
Examples Cont.Examples Cont.
– R22 = = ⊙
– R23 = = ⊙
1111
1101
0010
1111
1001
1100
0010
0111
1001
1100
0010
0111
1111
1101
0010
1111
1001
1100
0010
0111
1111
1111
0010
1111
![Page 29: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/29.jpg)
Examples Cont.Examples Cont.
– R24 = = ⊙
– Not transitive – Notice: (1, 3) and (3, 4) are in R1 but not (1, 4)
1111
1111
0010
1111
1001
1100
0010
0111
1111
1111
0010
1111
![Page 30: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/30.jpg)
Examples Cont.Examples Cont.• EXAMPLE: Let R = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)}. Is R
transitive?• Solution: transitive (see below)
– R2 = ⊙
– R3 = ⊙
– R33 = = ⊙
0111
0011
0001
0000
0111
0011
0001
0000
0011
0001
0000
0000
0111
0011
0001
0000
0001
0000
0000
0000
0011
0001
0000
0000
![Page 31: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/31.jpg)
Using Directed GraphsUsing Directed Graphs
• A directed graph or digraph G=(VG,EG) is a set VG of vertices (nodes) with a set EGVG×VG of edges (arcs,links). Visually represented using dots for nodes, and arrows for edges. Notice that a relation R:A↔B can be represented as a graph GR=(VG=AB, EG=R).
1 00
010
0 1 1
Mark
Fred
JoeSallyMarySusan
MR
GRJoe
Fred
Mark
Susan
Mary
Sally
Node set VG(black dots)
Edge set EG(blue arrows)
![Page 32: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/32.jpg)
Digraph Reflexive, SymmetricDigraph Reflexive, Symmetric
It is extremely easy to recognize the reflexive/irreflexive/ symmetric/antisymmetric properties by graph inspection.
Reflexive:Every node
has a self-loop
Irreflexive:No node
links to itself
Symmetric:Every link isbidirectional
Antisymmetric:
No link isbidirectional
Asymmetric, non-antisymmetric Non-reflexive, non-irreflexive
![Page 33: Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a](https://reader035.vdocuments.us/reader035/viewer/2022062407/56649e9e5503460f94b9f73e/html5/thumbnails/33.jpg)
ExampleExample
• Determine which are reflexive, irreflexive, symmetric, antisymmetric, and transitive.
a b
c
a b
ca b
c
transitive ReflexiveSymmetricNot transitive
Reflexiveantisymmetric