Relations Relations Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations 5 1 Chapter 5 Re[.]
Trang 1Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Chapter 5
Relations
Discrete Structures for Computing on September 20, 2017
Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Faculty of Computer Science and Engineering
Trang 2Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 3Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Course outcomes
Course learning outcomes
L.O.1.1 – Describe definition of propositional and predicate logic
L.O.1.2 – Define basic discrete structures: set, mapping, graphs
L.O.2.1 – Logically describe some problems arising in Computing
L.O.2.2 – Use proving methods: direct, contrapositive, induction
L.O.3.1 – Define basic probability theory
L.O.3.2 – Explain discrete random variables
L.O.4.1 – Operate (compute/ optimize) on discrete structures
L.O.4.2 – Compute probabilities of various events, conditional
ones, Bayes theorem
Trang 4Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of RelationsIntroduction
Function?
Trang 5Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of RelationsIntroduction
Function?
Trang 6Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 7Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 8Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 9Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 10Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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, d} 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 11Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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, d} 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 12Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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, d} 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 13Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 14Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 15Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 16Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 17Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 18Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 19Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 20Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 21Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 22Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 23Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 24Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of RelationsProperties of Relations
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 25Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Properties of Relations
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 26Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Transitive (xRy∧yRz) →xRz, ∀x, y, z ∈ A(bắc cầu)
Trang 27Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 28Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 29Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 30Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 31Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 32Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 33Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 34Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 35Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 36Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 37Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 38Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 39Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 40Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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
Trang 41Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of RelationsComposition of Relations
DefinitionLet R berelationsfrom A to B and S be from B to C Then thecomposite (hợp thành) of S and R is
Trang 42Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 43Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 44Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 45Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of Relations
Trang 46Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
Contents Properties of Relations Combining Relations Representing Relations Closures of Relations Types of RelationsPower of Relations
DefinitionLet R be a relation on the set A Thepowers(lũy thừa)
Rn, n = 1, 2, 3, are defined recursively by
Trang 47Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 48Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 49Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 50Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 51Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 52Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 53Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 54Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 55Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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 56Nguyen An Khuong, Tran Tuan Anh, Le Hong Trang
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
Example
Given a relation on A = {1, 2, 3, 4},
R = {(1, 1), (1, 3), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (4, 1)}Draw corresponding digraph