Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this document? Why not share!

- Relations by Ali Saleem 292 views
- Relations by Yehuda Garti 558 views
- Discrete-Chapter 04 Logic Part I by Wongyos Keardsri 719 views
- Discrete-Chapter 03 Matrices by Wongyos Keardsri 335 views
- Discrete-Chapter 02 Functions and S... by Wongyos Keardsri 682 views
- Introduction to management by Bilal Amjad 1109 views

No Downloads

Total views

624

On SlideShare

0

From Embeds

0

Number of Embeds

2

Shares

0

Downloads

34

Comments

0

Likes

1

No embeds

No notes for slide

- 1. Relations - 08 CSC1001 Discrete Mathematics 1 CHAPTER ความสัมพันธ์ 8 (Relations) 1 Relations and Their Properties1. Relation Deffinitions The most direct way to express a relationship between elements of two sets is to use ordered pairs madeup of two related elements. Definition 1 Let A and B be sets. A binary relation from A to B is a subset of A × B.Example 1 (2 points) Let A = {0, 1, 2} and B = {a, b}. Then {(0, a), (0, b), (1, a), (2, b)} is a relation from A to B.This means, for instance, that 0 R a, but that 1 not R b. Relations can be represented graphically using arrowsto represent ordered pairs. Another way to represent this relation is to use a table.Example 2 (2 points) Let A be the set of cities in the ASEAN, and let B be the set of countries in the ASEANas follow list;A = { Bangkok, Johor, Manila, Kuala Lumpur, Hanoi, Phuket, Penang, Naypyidaw, Ho Chi Minh, Chiang Mai }B = { Malaysia, Thailand, Philippines, Vietnam, Myanmar }Find the relations from A to B.Example 3 (2 points) Let A = { 0, 1, 4 } is domain of f(x) and B = { -2, -1, 0, 1, 2 } is range of f(x), find therelations from A to B, if given f(x) = x .มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
- 2. 2 CSC1001 Discrete Mathematics 08 - Relations2. Relations on a Set Definition 2 A relation on a 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 (2 points) Let A be the set {1, 2, 3, 4}. Which ordered pairs are in the relation R = {(a, b) | a dividesb} for example 2 divides 4?Example 5 (4 points) From Example 4 draw all relations by using arrows and table to represent ordered pairs?Example 6 (6 points) Consider these 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}.Which of these relations contain each of the pairs (1, 1), (1, 2), (2, 1), (1,-1), and (2, 2)?Example 7 (2 points) How many relations are there on a set with n elements?มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
- 3. Relations - 08 CSC1001 Discrete Mathematics 33. Properties of Relations Definition 3 A relation R on a set A is called reflexive if (a, a) ∈ R for every element a ∈ A.Example 8 (2 points) Consider the following 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)}.Which of these relations are reflexive?Example 9 (2 points) Which of the relations from Example 6 are reflexive? Definition 4 A relation R on a set A is called symmetric if (b, a) ∈ R whenever (a, b) ∈ R, for all a, b ∈ A. A relation R on a set A such that for all a, b ∈ A, if (a, b) ∈ R and (b, a) ∈ R, then a = b is called antisymmetric.Example 10 (2 points) Which of the relations from Example 8 are symmetric and which are antisymmetric?Example 11 (2 points) Which of the relations from Example 6 are symmetric and which are antisymmetric?มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
- 4. 4 CSC1001 Discrete Mathematics 08 - Relations Definition 5 A relation R on a set A is called transitive if whenever (a, b) ∈ R and (b, c) ∈ R, then (a, c) ∈ R, for all a, b, c ∈ A.Example 12 (2 points) Which of the relations from Example 8 are transitive?Example 13 (2 points) Which of the relations from Example 6 are transitive?4. Combining Relations Because relations from A to B are subsets of A × B, two relations from A to B can be combined in any waytwo sets can be combined.Example 13 (8 points) Let A = {1, 2, 3} and B = {1, 2, 3, 4}. The relations R1 = {(1, 1), (2, 2), (3, 3)} and R2 ={(1, 1), (1, 2), (1, 3), (1, 4)} can be combined to obtainR1 ∪ R2 = …………………………………………………………………………………………………………………R1 ∩ R2 = …………………………………………………………………………………………………………………R1 - R2 = …………………………………………………………………………………………………………………R2 - R1 = …………………………………………………………………………………………………………………Example 14 (8 points) Let A = {-1, 0, 1, 2} and B = {1, 3, 5, 7}. The relations R1 = {(-1, 1), (0, 3), (1, 5) , (2, 7)}and R2 = {(1, 1), (0, 3), (1, 3), (1, 5), (2, 5)} can be combined to obtainR1 ∪ R2 = …………………………………………………………………………………………………………………R1 ∩ R2 = …………………………………………………………………………………………………………………R1 - R2 = …………………………………………………………………………………………………………………R2 - R1 = …………………………………………………………………………………………………………………Example 15 (2 points) Let R1 and R2 are the relations from Example 14 and given R3 = {(-1, 1), (0, 3), (0, 5),(1, 5), (2, 7)} find (R1 ∪ R2) ∩ R3(R1 ∪ R2 ) ∩ R3 = ………………………………………………………………………………………………………..มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
- 5. Relations - 08 CSC1001 Discrete Mathematics 5 Definition 6 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 o R.Example 16 (2 points) 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)}?Example 17 (2 points) Let R be the relation {(1, 2), (1, 3), (2, 3), (2, 4), (3, 1)}, and let S be the relation {(2, 1),(3, 1), (3, 2), (4, 2)}. Find S o R? 2 n-ary Relations and Their Applications1. n-ary Relations Definition 1 Let A1,A2, . . . , An be sets. An n-ary relation on these sets is a subset of A1 × A2 × … × An. The sets A1, A2, … An are called the domains of the relation, and n is called its degree.Example 18 (2 points) Let R be the relation on N × N × N consisting of triples (a, b, c), where a, b, and c areintegers with a < b < c. Find the degree and its domains? and Show 5 examples of (a, b, c) ∈ RExample 19 (2 points) Let R be the relation on Z × Z × Z consisting of all triples of integers (a, b, c) in which a,b, and c form an arithmetic progression. That is, (a, b, c) ∈ R if and only if there is an integer k such that b = a+ k and c = a + 2k, or equivalently, such that b - a = k and c - b = k. Find the degree and its domains? andShow 5 examples of (a, b, c) ∈ Rมหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
- 6. 6 CSC1001 Discrete Mathematics 08 - RelationsExample 20 (2 points) Let R be the relation on Z × Z × Z+ consisting of triples (a, b, m), where a, b, and m areintegers with m ≥ 1 and a ≡ b (mod m). Find the degree and its domains? and Show 5 examples of (a, b, c)∈R2. Databases and Relations The relational data model, based on the concept of a relation. A database consists of records, which aren-tuples, made up of fields. The fields are the entries of the n-tuples. Relations used to represent databasesare also called tables. Each column of the table corresponds to an attribute of the database. A domain of ann-ary relation is called a primary key. That is, a domain is a primary key when no two n-tuples in the relationhave the same value from this domain. Combinations of domains can also uniquely identify n-tuples in an relation. When the values of a set ofdomains determine an n-tuple in a relation, the Cartesian product of these domains is called a composite key.Example 21 (2 points) Find a number of records and fields and identify the primary key of the table?Example 22 (2 points) Is the Cartesian product of the domain of major fields of study and the domain of GPAsa composite key for the n-ary relation from Table 1, assuming that no n-tuples are ever added?มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
- 7. Relations - 08 CSC1001 Discrete Mathematics 73. Operations on n-ary Relations Definition 2 Let R be an n-ary relation and C a condition that elements in R may satisfy. Then the selection operator sC maps the n-ary relation R to the n-ary relation of all n-tuples from R that satisfy the condition C.Example 23 (2 points) Find the records of computer science majors in the n-ary relation R shown in Table 1Example 24 (2 points) Find the records where GPA greater than 3.50 in the n-ary relation R shown in Table 1 3 Representing Relations1. Representing Relations Using Matrices Definition 1 A relation between finite sets can be represented using a zero–one matrix. by the matrix MR = [mij ], where ⎧1 if(a i , b i ) ∈ R m ij = ⎨ ⎩0 if(a i , b i ) ∉ RExample 25 (2 points) Suppose that A = {1, 2, 3} and B = {1, 2}. Let R be the relation from A to B containing(a, b) if a ∈ A, b ∈ B, and a > b. What is the matrix representing R if a1 = 1, a2 = 2, and a3 = 3, and b1 = 1and b2 = 2?Example 26 (2 points) Suppose that A = {0, 2, 4, 6} and B = {1, 2, 3, 4}. Let R be the relation from A to Bcontaining (a, b) if a ∈ A, b ∈ B, and a ≤ b. What is the matrix representing R?มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
- 8. 8 CSC1001 Discrete Mathematics 08 - RelationsExample 27 (2 points) Let A = {a1, a2, a3} and B = {b1, b2, b3, b4, b5}. Which ordered pairs are in the relation Rrepresented by the matrix? ⎡0 1 0 0 0 ⎤ M R = ⎢1 0 1 1 0 ⎥ ⎢ ⎥ ⎢1 0 1 0 1 ⎥ ⎣ ⎦Example 28 (2 points) Let A = {0, 4, 8, 12} and B = {1, 3, 5}. Which ordered pairs are in the relation Rrepresented by the matrix? ⎡0 1 1⎤ ⎢1 0 1⎥ MR = ⎢ ⎥ ⎢0 1 1⎥ ⎢ ⎥ ⎣1 0 0⎦ Definition 2 The relation R is symmetric if (a, b) ∈ R implies that (b, a) ∈ R. In terms of the entries of MR, R is symmetric if and only if mji = 1 whenever mij = 1. This also means mji = 0 whenever mij = 0. Consequently, R is symmetric if and only if mij = mji. Recalling the definition of the transpose of a matrix from Chapter 3, we see that R is symmetric if and only if MR = (MR)t Definition 3 The relation R is antisymmetric if and only if (a, b) ∈ R and (b, a) ∈ R imply that a = b. Consequently, the matrix of an antisymmetric relation has the property that if mij = 1 with i ≠ j, then mji = 0. Or, in other words, either mij = 0 or mji = 0 when i ≠ j.มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี
- 9. Relations - 08 CSC1001 Discrete Mathematics 9Example 29 (2 points) Suppose that the relation R on a set is represented by the matrix. Is R reflexive, sym-metric, and/or antisymmetric? ⎡1 1 0⎤ M R = ⎢1 1 1⎥ ⎢ ⎥ ⎢0 1 1 ⎥ ⎣ ⎦Example 30 (2 points) Suppose that the relation R on a set is represented by the matrix. Is R reflexive, sym-metric, and/or antisymmetric? ⎡0 0 0 ⎤ M R = ⎢0 1 0 ⎥ ⎢ ⎥ ⎢0 0 1 ⎥ ⎣ ⎦ Definition 4 The Boolean operations join and meet can be used to find the matrices representing the union and the intersection of two relations. Suppose that R1 and R2 are relations on a set A represented by the matrices MR1 and MR2, respectively. The matrices representing the union and intersection of these relations are M R ∪R = M R ∨ M R and M R ∩R = M R ∧ M R 1 2 1 2 1 2 1 2 Definition 5 Let the zero–one matrices for S o R, R, and S be M SoR = [tij ], MR = [rij ], and MS = [sij ], respectively. The ordered pair (ai, cj ) belongs to S o R if and only if there is an element bk such that (ai, bk) belongs to R and (bk, cj ) belongs to S. It follows that tij = 1 if and only if rik = skj = 1 for some k. From the definition of the Boolean product, this means that M SoR = M R M SExample 31 (2 points) Suppose that the relations S and R on a set A are represented by the matrices? ⎡1 0 0⎤ ⎡1 0 0⎤ ⎢0 1 1⎥ ⎢1 1 1⎥S= ⎢ ⎥ R= ⎢ ⎥ Find M S∪ R , M S∩ R and M So R ? ⎢0 1 1⎥ ⎢1 1 1⎥ ⎢ ⎥ ⎢ ⎥ ⎣0 0 1⎦ ⎣1 0 0⎦มหาวิทยาลัยราชภัฏสวนส ุนันทา (ภาคการศึกษาที่ 2/2555) เรียบเรียงโดย อ.วงศ์ยศ เกิดศรี

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment