chapter 3. relations definitions relations binary relations domain range vertex direct edge loops...
TRANSCRIPT
RelationsChapter 3
Relations
DefinitionsRelations
Binary relationsDomainRangeVertexDirect edgeLoopsReflective RelationsSympatric RelationsAnti Symmetric Relations
Metrics of RelationsReflective RelationsSymmetric RelationsMatrix multiplications
RelationsA set of ordered pairs.The existence or the presence of the order
pair (a, b) indicates that there is a relationship from a to b.The relational Dbase among records in a data
base is based on the Relations concept.
A relation from one set to another can be thought of as which element of the first set is related to which element in the second set
Student Course
Bill Computer Science
Mary Math
Bill Art
Beth Beth
HistoryComputer Science
Dave Math
Student col is the Domain, Course Col is the Range
Binary Relation R A binary relation R from a set X to a set Y is subset of the Cartesian product X*
Y If (x, y) ∈ R, we write x R y and we say x related to y. If x = y we say R is Binary relation on X. A function is a special type of Relation, a function f from X to Y is a Relation
from X to Y with the properties: The Domain f equals X For each x ∈ X, there is exactly y ∈ Y such that (x,y) ∈ f
If X = { Bill, Mary, Beth, Dave} and Y = {Computer Science, Math, Art, History}Then Our Relation from the previous table R = { (Bill, Computer Science), (Mary, Math),(Bill, Art) (Beth, History,) , (Beth, Computer Science ),(Dave. Math)}.
Since the order pair (Beth, History) ∈ R, we can write Beth R History
This shows that a Relation can b given by specifying which ordered pair belongs to the Relation
Defining a Relation by giving a Rule for membership in the Relation
X = {2, 3, 4} an Y = {3, 4, 5, 6, 7}If we define a relation R from X to Y by (x, y) ∈ R if x
divides by y.We obtain
R ={(2,4), (2,6), (3,3), (3,6), (4,4)And if we Write R as a table we obtain
X Y
2 4
2 6
3 3
3 6
4 4
The Domain of R is the set {2,3,4}
The Range of the set R is{3, 4, 6}
GraphsLet R be the Relation on X = {1,2,3,4}
defined by
the order pair (x, y) ∈ R if x ≤ y and x, y ∈ XThe Relation R can be written as R = {(1,1),(1,2,),(1,3), (1,4), (2,2),(2,3),(2,4), (3,3),(3,4),(4,4)}
The Relation R can be drawn as a graph, we call it a digraph (direct graph and will be covered in Chapter 8 1
3 4
2 1, 2, 3, 4 are called verticesThe Arrows are called edgesIf there is a relation between vertices we draw an arrow to represent the relation
Element(vertices) with the form off (x, x) are called lops
Digraph of RelationThe Relation R on X = {a, b, c, d} given by
the DigraphR = {(a,b),(a,d),(d,c), (c,d), (b,b)}
a b
cd
Reflective relation RA Relation R on the set X is called reflective if
(x, x) ∈ R for every x ∈ XThe relation R on the set X ={1,2,3,4}is reflective for each x ∈ X, (x, x) ∈ RSpecifically: {(1,1,), (2,2), (3,3),(4,4)} are each in R
The Digraph of reflective Relation has a loop on every vertex
THE GRAPH ON SLIDE 8 IS REFLEXSIVE
Not a reflective The Relation R R = {(a,b),(a,d),(d,c), (c,d),
)} on X = {a, b, c, d} given by the Digraph
a b
cd
Is not a reflective relation because none of the Vertices have a loop, there is no (b,b), (c,c).. (b,b) and (c,c) ∈ R
Not a reflective The Relation R on X = {a, b, c, d} given by
the DigraphR = {(a,a),(b,c),(c,b), (d,d), )} Is not a reflective relation is b ∈ X, c ∈ X
But there is no loop on (b,b), (c,c) Vertices have a loop a d
cb
No LoopNo
Loop
symmetricA relation R on set X is called Symmetric if for all x, y ∈ X , if (x, y) ∈ R then (y, x) ∈ R The Relation R = {(a,a), (b,c),(c,b), (d,d) } on X = {a, b, c, d} Is symmetric because for all x, y if (x,y) ∈ R then (y, x) ∈ R
example ((b,c) is in R and (c,b) is in also in R The diagraph of a symmetric relation has the property that
whenever there is a direct edge from v to w there is also a direct edge from w to v
b c
a d
NOT Symmetric exampleThe Relation R on X = {1,2,3,4} defined by
(x, y) ∈ R if x ≤ y , x,y ∈ X R = {(1,1),(1,2,),(1,3), (1,4), (2,2),(2,3),(2,4), (3,3),(3,4),(4,4)}
is Not Symmetric.(2,3) ∈ R but (3,2) ∈ R.The digraph of this relation has a direct edge from 2 to 3 but no direct edge between 3 and 21
3
2
4
AntiSymmetric
The relation R on X is antisymmetric if for all x,y ∈ X, if (x,y) ∈ R and (y, x) ∈ R then x =y
Example:The relation R on X = {1,2,3,4} defined by (x ,y)
∈ R if x ≤ y, x,y ∈ X is antisymmetric because for all X,Y , IF (x,y) ∈ R and (y, x) ∈ R
x = yWe also can say if (x, y) ∈ R and (y, x) ∈ R then x = y.
AntisymmetricIf a relation R has no members of the form (x,
y), x ≠ yThe relation is called Anti Symmetric for all x, y ∈ X , if x ≠ y then (x, y) ∈ R or (y, x) ∈ R
Example R ={(a, a),(b, b),(c, c) on X = {a, b, c} is an antisymmetric
a d
c
Also we can say, the digraph of antisymmetic relation has at most one directed edge between any two distinct vertices
This gra
ph is
also sy
mmetric
and Reflexiv
e
Metrics of RelationsA matrix is a convent way to represent a relation.R from X to Y, such a representation can be used
by computers to a analyze a relation.Row elements of X are labeled in some order and
the column elements of Y are labeled .
Entries in Row X and Column Y are set to 1 if
there is R from X to Y otherwise it is set to 0This type of matrix is called Matrix of relations
from X to Y
Example.
The matrix of the Relation R whenR ={(1, b),(1, d), (2, c), (3, c),(3, b),(4, a)}From X={1, 2,3,4} to Y ={a, b, c, d} IS:
a b c d 1 0 1 0 1 2 0 0 1 0 3 0 1 1 0 4 1 0 0 0The matrix is dependent on the ordering of x, y.How would the Matrix for the Relation R look like if:X= {4, 3,2, 1} and Y = {d, c, b, a} … next slide
R ={(1, b),(1, d), (2, c), (3, c),(3, b),(4, a)}From X={4,3,2,1} to Y ={d, c, b, a} IS:
d c b a 4 0 0 0 1 3 0 1 1 0 2 0 1 0 0 1 1 0 1 0
Example 2
The matrix of the Relation R fromX ={2,3,4} to Y={5,6,7,8}is defined by X R Y if x divides y Note: no remainder
5 6 7 8 2 0 1 0 1 3 0 1 0 0 4 0 0 0 1
Reflective RelationsThe matrix of the RelationR = {(a,a), (b, b), (c, c), (d, d),(b, c), (c, b) } on {a, b, c, d} relative to the ordering {a, b, c, d}
a b c d a 1 0 0 0 b 0 1 1 0 c 0 1 1 0 d 1 0 1 1
Matrix diagonal
• The Relation R is Reflective if and ONLY if A has only ones on the main diagonal .
• The main diagonal is the line from the upper left corner to the lower right corner.
• In other words the Relation R is Reflective if and only if
• (x, x) ∈ R for every x ∈ R.
Symmetric RelationIf the Entry of R,C = the entry of C,R then the
relation is symmetric, otherwise it is anti-symmetric.
We can quickly determine if the relation is symmetric by checking the main diagonalLook at all entries for all R,C or (i, j)Look at all entries for all C,R or (j,i)
If they are all 1’s then it is Symmetric
Based on the above: for the previous example the Relation R is Symmetric
How Matrix Multiplication Relate to the composition of Relations and how can we test for Transitivity by using Matrix Relations?
What is TransitivityTransitivity: Transitive means whenever a
none Zero entry in A ( entry (i, j) ≠ 0) there
is also a none Zero in A2 ( entry (i, j) ≠ 0)
Example Let R be the Relation from X to YX ={1, 2,3} to Y ={a, b} defined by R1 ={(1,a),(2,b), (3,a), (3,b) and R2= the Relation from Y to Z where Z ={x, y, z} And the Relation is defined R2 ={(a,x), (a,y), (b,y), (b,z)}
The matrix for R1 Relative to the ordering of 1,2,3 and a,b
a b 1 1 0 2 0 1 3 1 1
x y z a 1 1 0 b1 1 1
The Matrix of R2 relative to the ordering of (a,b) on (x, y, z)
A1 =
A2 =
1 1 0 A1.A2 = 0 1 1
1 2 1
TransitivityIF A is the matrix of R (relative to some
ordering)
We compute A2
Then we compare A and A2
The relation R is Transitive if and only if whenever an entry i,j in A is a
non zero, an entry i,j in A^2 is also a none zero.
Determine if the Relation R is transitiveThe matrix of Relation: R = {(a,a),(b,b),(c,c),(d,d), (b,c),(c.b)}On. (a,b,c,d) relative to the order a, b, c, d a b c d a b c d 0 0 0 1 1 0 0 0 0 1 1 0 0 2 2 0 0 1 1 0 0 2 2 0 0 0 0 1 0 0 0 1
abcd
abcd
A= A^2 =
Every none Zero i,j in A is matched with a none zero entry in i,j in A^2 Transitive Relation R
R2 O R1To obtain the Matrix of the Relation R2 O R1 Compute the Matrix product A1*A2 Change all none zero entries to 1
Adjacency MatrixWill be covered in chapter 11