Huynh Tuong Nguyen, Vinh Tan Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of RelationsPower of Relations Definition Let R be a
Trang 1Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Chapter 5
Relations
Discrete Structures for Computing on 22 March 2012
Huynh Tuong Nguyen, Tran Huong Lan, Tran Vinh Tan
Faculty of Computer Science and Engineering
University of Technology - VNUHCM
Trang 2Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 3Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of RelationsIntroduction
Function?
Trang 4Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of RelationsIntroduction
Function?
Trang 5Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Relation
Definition
Let A and B be sets Abinary relation(quan hệ hai ngôi ) from a
set A to a set B is a set
R ⊆ A × B
• Notations:
(a, b) ∈ R ←→ aRb
• n-ary relations?
Trang 6Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Relation
Definition
Let A and B be sets Abinary relation(quan hệ hai ngôi ) from a
set A to a set B is a set
R ⊆ A × B
• Notations:
(a, b) ∈ R ←→ aRb
• n-ary relations?
Trang 7Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Relation
Definition
Let A and B be sets Abinary relation(quan hệ hai ngôi ) from a
set A to a set B is a set
R ⊆ A × B
• Notations:
(a, b) ∈ R ←→ aRb
• n-ary relations?
Trang 8Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Relation
Definition
Let A and B be sets Abinary relation(quan hệ hai ngôi ) from a
set A to a set B is a set
R ⊆ A × B
• Notations:
(a, b) ∈ R ←→ aRb
• n-ary relations?
Trang 9Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Example
Example
Let A = {a, b, c} be the set of students, B = {l, c, s, g} be the set
of the available optional courses We can have relation R that
consists of pairs (a, b), where a is a student enrolled in course b
R = {(a, l), (a, s), (a, g), (b, c),
Trang 10Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Example
Example
Let A = {a, b, c} be the set of students, B = {l, c, s, g} be the set
of the available optional courses We can have relation R that
consists of pairs (a, b), where a is a student enrolled in course b
R = {(a, l), (a, s), (a, g), (b, c),
Trang 11Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Example
Example
Let A = {a, b, c} be the set of students, B = {l, c, s, g} be the set
of the available optional courses We can have relation R that
consists of pairs (a, b), where a is a student enrolled in course b
R = {(a, l), (a, s), (a, g), (b, c),
Trang 12Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 13Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 14Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 15Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 16Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 17Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 18Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 19Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 20Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 21Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Relations on a Set
Definition
Arelation on the set A is a relation from A to A
Example
Let A be the set {1, 2, 3, 4} Which ordered pairs are in the
relation R = {(a, b) | a divides b} (a là ước số của b)?
Trang 22Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Relations on a Set
Definition
Arelation on the set A is a relation from A to A
Example
Let A be the set {1, 2, 3, 4} Which ordered pairs are in the
relation R = {(a, b) | a divides b} (a là ước số của b)?
Trang 23Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
———————————————————–
Trang 24Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of RelationsRelations can have special properties
Reflexive xRx, ∀x ∈ A(phản xạ)
Symmetric xRy →yRx, ∀x, y ∈ A(đối xứng )
Antisymmetric (xRy∧yRx) →x=y, ∀x, y ∈ A(phản đối xứng )
Transitive (xRy∧yRz) →xRz, ∀x, y, z ∈ A(bắc cầu)
Trang 25Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Relations can have special properties
Reflexive xRx, ∀x ∈ A
(phản xạ)
Symmetric xRy →yRx, ∀x, y ∈ A(đối xứng )
Antisymmetric (xRy∧yRx) →x=y, ∀x, y ∈ A(phản đối xứng )
Transitive (xRy∧yRz) →xRz, ∀x, y, z ∈ A(bắc cầu)
Trang 26Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Relations can have special properties
Transitive (xRy∧yRz) →xRz, ∀x, y, z ∈ A(bắc cầu)
Trang 27Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Relations can have special properties
Trang 28Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Relations can have special properties
Trang 29Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 30Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 31Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 32Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 33Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 34Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 35Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 36Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 37Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 38Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 39Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 40Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
———————————————————–
Trang 41Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Combining Relations
Because relations from A to B are subsetsof A × B, two
relations from A to B can be combined in any way two sets can
Trang 42Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Combining Relations
Because relations from A to B are subsetsof A × B, two
relations from A to B can be combined in any way two sets can
Trang 43Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Combining Relations
Because relations from A to B are subsetsof A × B, two
relations from A to B can be combined in any way two sets can
Trang 44Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Combining Relations
Because relations from A to B are subsetsof A × B, two
relations from A to B can be combined in any way two sets can
Let A and B be the set of all students and the set of all courses at
school, respectively SupposeR1= {(a, b) | a has taken the course
b}andR2= {(a, b) | a requires course b to graduate} What are
the relations R1∪ R2, R1∩ R2, R1− R2, R2− R1?
Trang 45Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of RelationsComposition of Relations
Trang 46Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 47Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 48Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 49Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 50Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of RelationsPower of Relations
Definition
Let R be a relation on the set A Thepowers(lũy thừa)
Rn, n = 1, 2, 3, are defined recursively by
Trang 51Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Power of Relations
Definition
Let R be a relation on the set A Thepowers(lũy thừa)
Rn, n = 1, 2, 3, are defined recursively by
Trang 52Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Power of Relations
Definition
Let R be a relation on the set A Thepowers(lũy thừa)
Rn, n = 1, 2, 3, are defined recursively by
Trang 53Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Power of Relations
Definition
Let R be a relation on the set A Thepowers(lũy thừa)
Rn, n = 1, 2, 3, are defined recursively by
Trang 54Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Power of Relations
Definition
Let R be a relation on the set A Thepowers(lũy thừa)
Rn, n = 1, 2, 3, are defined recursively by
Trang 55Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Power of Relations
Definition
Let R be a relation on the set A Thepowers(lũy thừa)
Rn, n = 1, 2, 3, are defined recursively by
Trang 56Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Power of Relations
Definition
Let R be a relation on the set A Thepowers(lũy thừa)
Rn, n = 1, 2, 3, are defined recursively by
Trang 57Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 58
Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Representing Relations Using Matrices
Definition
Suppose R is a relation from A = {a1, a2, , am} to
B = {b1, b2, , bn}, R can be represented by thematrix
R is relation from A = {1, 2, 3} to B = {1, 2} Let
R = {(2, 1), (3, 1), (3, 2)}, the matrix for R is
Trang 59Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Representing Relations Using Matrices
Definition
Suppose R is a relation from A = {a1, a2, , am} to
B = {b1, b2, , bn}, R can be represented by thematrix
R is relation from A = {1, 2, 3} to B = {1, 2} Let
R = {(2, 1), (3, 1), (3, 2)}, the matrix for R is
Trang 60Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Representing Relations Using Matrices
Definition
Suppose R is a relation on A = {a1, a2, , am}, R can be
represented by thematrix MR= [mij], where
Trang 61Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Representing Relations Using Matrices
Definition
Suppose R is a relation on A = {a1, a2, , am}, R can be
represented by thematrix MR= [mij], where
Trang 62Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Representing Relations Using Matrices
Definition
Suppose R is a relation on A = {a1, a2, , am}, R can be
represented by thematrix MR= [mij], where
Can we determine whether the relation has certain properties
(reflexive, symmetric, antisymmetric, ) by investigating its
Trang 63Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Representing Relations Using Matrices
Examples
Determine if the relations represented by the following matrices
have special properties?
Trang 64Huynh Tuong Nguyen, Vinh Tan
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Representing Relations Using Digraphs
Definition
Suppose R is a relation in A = {a1, a2, , am}, R can be
represented by thedigraph(đồ thị có hướng ) G = (V, E), where
V = A(ai, aj) ∈ E if (ai, aj) ∈ R