Discrete Mathematics Relations - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Discrete Mathematics Relations

Description:

Recall: A function takes EACH element from a set and maps it to a UNIQUE element ... (Nil fer, Bursa) (Tepebasi, Eskisehir) etc... – PowerPoint PPT presentation

Number of Views:1626
Avg rating:3.0/5.0
Slides: 23
Provided by: cengAna
Category:

less

Transcript and Presenter's Notes

Title: Discrete Mathematics Relations


1
Discrete MathematicsRelations
2
What is a relation
  • Relation generalizes the notion of functions.
  • Recall A function takes EACH element from a set
    and maps it to a UNIQUE element in another set
  • f X ? Y
  • ? x ? X, ? y such that f(x) y
  • Let A and B be sets.
  • A binary relation R from A to B is a subset of A
    ? B
  • Recall A x B (a, b) a ? A, b ? B
  • aRb (a, b) ? R.
  • Application
  • Relational database model is based on the concept
    of relation.

3
What is a relation
  • Example
  • Let A be the students in a the CS major
  • A Ayse, Baris, Canan, Davut
  • Let B be the courses the department offers
  • B BIM111, BIM122, BIM124
  • We specify relation R ? A ? B as the set that
    lists all students a ? A enrolled in class b ? B
  • R (Ayse, BIM111), (Baris, BIM122), (Baris,
    BIM124), (Davut, BIM122), (Davut, BIM124)

4
More relation examples
  • Another relation example
  • Let A be the cities in Turkey
  • Let B be the districts in Turkey
  • We define R to mean a is a district in city b
  • Thus, the following are in our relation
  • (Bakirköy, Istanbul)
  • (Keçiören, Ankara)
  • (Nilüfer, Bursa)
  • (Tepebasi, Eskisehir)
  • etc
  • Most relations we will see deal with ordered
    pairs of integers

5
Representing relations
We can represent relations graphically
We can represent relations in a table
6
Relations vs. functions
  • If R ? X ? Y is a relation, then is R a function?
  • If f X ? Y is a function, then is f a relation?

7
Relations on a set
  • A relation on the set A is a relation from A to A
  • In other words, the domain and co-domain are the
    same set
  • We will generally be studying relations of this
    type

8
Relations on a set
  • Let A be the set 1, 2, 3, 4
  • Which ordered pairs are in the relation
  • R (a,b) a divides b
  • R (1,1), (1,2), (1,3), (1,4), (2,2), (2,4),
    (3,3), (4,4)

9
More examples
  • Consider some relations on the set Z
  • Are the following ordered pairs in the relation?
  • (1,1) (1,2) (2,1) (1,-1) (2,2)
  • R1 (a,b) ab
  • R2 (a,b) agtb
  • R3 (a,b) ab
  • R4 (a,b) ab
  • R5 (a,b) ab1
  • R6 (a,b) ab3

X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
10
Relation properties
  • Six properties of relations we will study
  • Reflexive
  • Irreflexive
  • Symmetric
  • Asymmetric
  • Antisymmetric
  • Transitive

11
Reflexivity vs. Irreflexivity
  • Reflexivity
  • Definition A relation is reflexive if
  • (a,a) ? R for all a ? A
  • Irreflexivity
  • Definition A relation is irreflexive if
  • (a,a) ? R for all a ? A
  • Examples
  • Is the divides relation on Z reflexive?
  • Is the ? (not ?) relation on a P(A) irreflexive?

?
?
gt
lt

o
o
x
x
o
reflexive
irreflexive
x
x
o
o
x
12
Reflexivity vs. Irreflexivity
  • A relation can be neither reflexive nor
    irreflexive
  • Example?
  • A 1, 2, R (1, 1)
  • It is not reflexive, since (2, 2) ? R,
  • It is not irreflexive, since (1, 1) ? R.

13
Symmetry, Asymmetry, Antisymmetry
  • A relation is symmetric if
  • for all a, b ? A, (a,b) ? R? (b,a) ? R
  • A relation is asymmetric if
  • for all a, b ? A, (a,b) ? R ? (b,a) ? R
  • A relation is antisymmetric if
  • for all a, b ? A, ((a,b) ? R ? (b,a) ? R) ? ab
  • (Second definition) for all a, b ? A, ((a,b) ? R
    ? a ? b) ? (b,a) ? R)

isTwinOf
?
?

gt
lt
o
x
x
o
x
x
symmetric
x
x
x
x
o
o
asymmetric
x
o
o
o
o
o
antisymmetric
14
Notes on symmetric relations
  • A relation can be neither symmetric or asymmetric
  • R (a,b) ab
  • This is not symmetric
  • -4 is not related to itself
  • This is not asymmetric
  • 4 is related to itself
  • Note that it is antisymmetric

15
Transitivity
  • A relation is transitive if
  • for all a, b, c ? A, ((a,b)?R ? (b,c)?R) ?
    (a,c)?R
  • If a lt b and b lt c, then a lt c
  • Thus, lt is transitive
  • If a b and b c, then a c
  • Thus, is transitive

16
Transitivity examples
  • Consider isAncestorOf()
  • Let Ayse be Bariss ancestor, and Baris be
    Canans ancestor
  • Thus, Ayse is an ancestor of Baris, and Baris is
    an ancestor of Canan
  • Thus, Ayse is an ancestor of Canan
  • Thus, isAncestorOf() is a transitive relation
  • Consider isParentOf()
  • Let Ayse be Bariss parent, and Baris be Canans
    parent
  • Thus, Ayse is a parent of Baris, and Baris is a
    parent of Canan
  • However, Ayse is not a parent of Canan
  • Thus, isParentOf() is not a transitive relation

17
Summary of properties of relations
() Alternative definition
18
Combining relations
  • There are two ways to combine relations R1 and R2
  • Via Set operators
  • Via relation composition

19
Combining relations via Set operators
  • Consider two relations R and R
  • R U R all numbers OR
  • Thats all the numbers
  • R n R all numbers AND
  • Thats all numbers equal to
  • R ? R all numbers or , but not both
  • Thats all numbers not equal to
  • R - R all numbers that are not also
  • Thats all numbers strictly greater than
  • R - R all numbers that are not also
  • Thats all numbers strictly less than
  • Note that its possible the result is the empty
    set

20
Combining via relational composition
  • Similar to function composition
  • Let R be a relation from A to B, and S be a
    relation from B to C
  • Let a ? A, b ? B, and c ? C
  • Let (a,b) ? R, and (b,c) ? S
  • Then the composite of R and S consists of the
    ordered pairs (a,c)
  • We denote the relation by S ? R
  • Note that S comes first when writing the
    composition!
  • (a, c) ? S ? R if ? b such that (a, b) ? R, and
    (b,c) ? S

21
Combining via relational composition
  • Let M be the relation is mother of
  • Let F be the relation is father of
  • What is M ? F?
  • If (a,b) ? F, then a is the father of b
  • If (b,c) ? M, then b is the mother of c
  • Thus, M ? F denotes the relation maternal
    grandfather
  • What is F ? M?
  • If (a,b) ? M, then a is the mother of b
  • If (b,c) ? F, then b is the father of c
  • Thus, F ? M denotes the relation paternal
    grandmother
  • What is M ? M?
  • If (a,b) ? M, then a is the mother of b
  • If (b,c) ? M, then b is the mother of c
  • Thus, M ? M denotes the relation maternal
    grandmother

22
Combining via relational composition
  • Given relation R
  • R ? R can be denoted by R2
  • R2 ? R (R ? R) ? R R3
  • Example M3 is your mothers mothers mother
Write a Comment
User Comments (0)
About PowerShow.com