COMP232 - Mathematics for Computer Science

COMP232 - Mathematics for Computer Science Tutorial 11 Ali Moallemi moa [email protected] Iraj Hedayati h [email protected] Concordia Univ...
2 downloads 0 Views 176KB Size
COMP232 - Mathematics for Computer Science Tutorial 11

Ali Moallemi moa [email protected]

Iraj Hedayati h [email protected]

Concordia University, Winter 2016

Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

1 / 25

Table of Contents

1

9.1 Relations and Their Properties Exercise 3 Exercise 5 Exercise 6 Exercise 31 Exercise 36 Exercise 44 Exercise 46 Exercise 52

Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

2 / 25

Exercise 3 For each of these relations on the set {1, 2, 3, 4}, decide whether it is reflexive, whether it is symmetric, whether it is antisymmetric, and whether it is transitive. a) {(2, 2), (2, 3), (2, 4), (3, 2), (3, 3), (3, 4)} Answer: Reflexive: NO (1, 1) 6∈ R Symmetric: NO (2, 4) ∈ R but (4, 2) 6∈ R Antisymmetric: NO (2, 3) ∈ R and (3, 2) ∈ R where 2 6= 3 Transitive: YES b) {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (4, 4)} Answer: Reflexive: YES Symmetric: YES Antisymmetric: NO (1, 2) ∈ R and (2, 1) ∈ R where 1 6= 2 Transitive: YES Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

3 / 25

Exercise 3 - Cont... For each of these relations on the set {1, 2, 3, 4}, decide whether it is reflexive, whether it is symmetric, whether it is antisymmetric, and whether it is transitive. c) {(2, 4), (4, 2)} Answer: Reflexive: NO (2, 2) 6∈ R Symmetric: YES Antisymmetric: NO (2, 4) ∈ R and (4, 2) ∈ R where 2 6= 4 Transitive: NO (2, 4), (4, 2) ∈ R but (2, 2) 6∈ R d) {(1, 2), (2, 3), (3, 4)} Answer: Reflexive: NO (1, 1) 6∈ R Symmetric: NO (2, 3) ∈ R but (3, 2) 6∈ R Antisymmetric: YES Transitive: NO (2, 3), (3, 4) ∈ R but (2, 4) 6∈ R Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

4 / 25

Exercise 3 - Cont... For each of these relations on the set {1, 2, 3, 4}, decide whether it is reflexive, whether it is symmetric, whether it is antisymmetric, and whether it is transitive. e) {(1, 1), (2, 2), (3, 3), (4, 4)} Answer: Reflexive: YES Symmetric: YES Antisymmetric: YES Transitive: YES f) {(1, 3), (1, 4), (2, 3), (2, 4), (3, 1), (3, 4)} Answer: Reflexive: NO (1, 1) 6∈ R Symmetric: NO (1, 4) ∈ R but (4, 1) 6∈ R Antisymmetric: NO (1, 3), (3, 1) ∈ R but 1 6= 3 Transitive: NO (2, 3), (3, 1) ∈ R but (2, 1) 6∈ R Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

5 / 25

Exercise 5 Determine whether the relation R on the set of all Web pages is reflexive, symmetric, antisymmetric, and/or transitive, where (a, b) ∈ R if and only if a) everyone who has visited Web page a has also visited Web page b Answer: Reflexive: YES Symmetric: NO Antisymmetric: NO Transitive: YES b) there are no common links found on both Web page a and Web page b. Answer: Reflexive: NO Symmetric: YES Antisymmetric: NO Transitive: NO Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

6 / 25

Exercise 5 - Cont... Determine whether the relation R on the set of all Web pages is reflexive, symmetric, antisymmetric, and/or transitive, where (a, b) ∈ R if and only if c) there is at least one common link on Web page a and Web page b. Answer: Reflexive: NO Symmetric: YES Antisymmetric: NO Transitive: NO d) there is a Web page that includes links to both Web page a and Web page b. Answer: Reflexive: NO Symmetric: YES Antisymmetric: NO Transitive: NO Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

7 / 25

Exercise 6 Determine whether the relation R on the set of all real numbers is reflexive, symmetric, antisymmetric, and/or transitive, where (x, y) ∈ R if and only if a) x + y = 0 Answer: Reflexive: NO 1 + 1 = 2 Symmetric: YES x + y = 0 → y + x = 0 Antisymmetric: NO x + y = 0 → y + x = 0 → x = −y → x 6= y Transitive: NO (x, y), (y, z) ∈ R and y 6= 0, then x + y = 0 and y + z = 0 implies x + 2y + z = 0. Hence x + z can not be 0.

Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

8 / 25

Exercise 6 - Cont... Determine whether the relation R on the set of all real numbers is reflexive, symmetric, antisymmetric, and/or transitive, where (x, y) ∈ R if and only if b) x = ±y Answer: Reflexive: NO x 6= −x Symmetric: YES x = ±y → y = ±x Antisymmetric: NO x = ±y and y = ±x, x 6= y because x 6= −x Transitive: YES

Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

9 / 25

Exercise 6 - Cont... Determine whether the relation R on the set of all real numbers is reflexive, symmetric, antisymmetric, and/or transitive, where (x, y) ∈ R if and only if c) x − y is a rational number Answer: Reflexive: YES x − x = 0 ∈ Q Symmetric: YES x − y ∈ Q → y − x = −(x − y) ∈ Q Antisymmetric: NO 2 − 1 = 1 → 1 − 2 = −1 but 2 6= 1 Transitive: YES Let a = x − y and b = y − z. Then c = a + b = x − y + y − z = x − z. As a, b ∈ Q, then c ∈ Q and (x, z) ∈ R

Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

10 / 25

Exercise 6 - Cont... Determine whether the relation R on the set of all real numbers is reflexive, symmetric, antisymmetric, and/or transitive, where (x, y) ∈ R if and only if d) x = 2y Answer: Reflexive: NO x 6= 2x Symmetric: NO x = 2y → y = x2 6= 2x Antisymmetric: YES x = 2y and y = 2x → x = 4x → x = 0 ⇒ x = 2x = 0 Transitive: NO x = 2y and y = 2z then x = 4z

Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

11 / 25

Exercise 6 - Cont... Determine whether the relation R on the set of all real numbers is reflexive, symmetric, antisymmetric, and/or transitive, where (x, y) ∈ R if and only if e) xy ≥ 0 Answer: Reflexive: YES x · x = x2 ≥ 0 Symmetric: YES xy ≥ 0 → yx ≥ 0 Antisymmetric: NO x = 1 and y = 2. (x, y), (y, x) ∈ R but x 6= y Transitive: NO x = 1, y = 0, z = −1 then (x, y) ∈ R and (y, z) ∈ R but (x, z) 6∈ R

Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

12 / 25

Exercise 6 - Cont... Determine whether the relation R on the set of all real numbers is reflexive, symmetric, antisymmetric, and/or transitive, where (x, y) ∈ R if and only if f) xy = 0 Answer: Reflexive: NO x = 1 Symmetric: YES xy = 0 → yx = 0 Antisymmetric: NO x = 1 and y = 0. (x, y), (y, x) ∈ R but x 6= y Transitive: NO x = 1, y = 0 and z = 2. Then (x, y) ∈ R and (y, z) ∈ R but (x, z) 6∈ R

Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

13 / 25

Exercise 6 - Cont... Determine whether the relation R on the set of all real numbers is reflexive, symmetric, antisymmetric, and/or transitive, where (x, y) ∈ R if and only if g) x = 1 Answer: Reflexive: NO x = 2 → (2, 2) 6∈ R Symmetric: NO x = 1 → ∀y ∈ R (x, y) ∈ R but ∀y ∈ R − {1} (y, x) 6∈ R. For example y = 2: (1, 2) ∈ R and (2, 1) 6∈ R Antisymmetric: YES (x, y) ∈ R → x = 1 and also (y, x) ∈ R → y = 1. Hence x = y = 1 Transitive: YES (x, y) ∈ R → x = 1 and also (y, z) ∈ R → y = 1. Hence (x, z) ∈ R

Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

14 / 25

Exercise 6 - Cont... Determine whether the relation R on the set of all real numbers is reflexive, symmetric, antisymmetric, and/or transitive, where (x, y) ∈ R if and only if h) x = 1 or y = 1 Answer: Reflexive: NO x = 2 → (2, 2) 6∈ R Symmetric: YES (x, y) ∈ R → x = 1 and also (y, x) ∈ R Antisymmetric: NO x = 1 and y = 2. Then (x, y), (y, x) ∈ R but x 6= y Transitive: NO x = 2, y = 1 and z = 3. Then (x, y) ∈ R and (y, z) ∈ R but (x, z) 6∈ R

Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

15 / 25

Exercise 31 Let A be the set of students at your school and B the set of books in the school library. Let R1 and R2 be the relations consisting of all ordered pairs (a, b), where student a is required to read book b in a course, and where student a has read book b, respectively. Describe the ordered pairs in each of these relations. a) R1 ∪ R2 ? Answer: {(a, b)|a is required to read or has read b} b) R1 ∩ R2 Answer: {(a, b)|a is required to read and has read b} c) R1 ⊕ R2 Answer: {(a, b)| either a is required to read b but has not read it or a has read b but is not required to} Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

16 / 25

Exercise 31 Let A be the set of students at your school and B the set of books in the school library. Let R1 and R2 be the relations consisting of all ordered pairs (a, b), where student a is required to read book b in a course, and where student a has read book b, respectively. Describe the ordered pairs in each of these relations. d) R1 − R2 Answer: {(a, b)|a is required to read b but has not read it} e) R2 − R1 ? Answer: {(a, b)|a has read b but is not required to}

Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

17 / 25

Exercise 36 Relations 1

R1 = {(a, b) ∈ R2 |a > b}

2

R2 = {(a, b) ∈ R2 |a ≥ b}

3

R3 = {(a, b) ∈ R2 |a < b}

4

R4 = {(a, b) ∈ R2 |a ≤ b}

5

R5 = {(a, b) ∈ R2 |a = b}

6

R6 = {(a, b) ∈ R2 |a 6= b}

a) R1 ◦ R1 Answer: R1 ∀a∀c∃b(a > b ∧ b > c) b) R1 ◦ R2 ? Answer: R1 ∀a∀c∃b (a ≥ b ∧ b > c) ⇒ ∀a∀c∃b (a > c) Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

18 / 25

Exercise 36-Cont... Relations 1

R1 = {(a, b) ∈ R2 |a > b}

2

R2 = {(a, b) ∈ R2 |a ≥ b}

3

R3 = {(a, b) ∈ R2 |a < b}

4

R4 = {(a, b) ∈ R2 |a ≤ b}

5

R5 = {(a, b) ∈ R2 |a = b}

6

R6 = {(a, b) ∈ R2 |a 6= b}

c) R1 ◦ R3 Answer: R2 ∀a∀c∃b(a < b ∧ b > c) d) R1 ◦ R4 ? Answer: R2 ∀a∀c∃b(a ≤ b ∧ b > c) Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

19 / 25

Exercise 36-Cont... Relations 1

R1 = {(a, b) ∈ R2 |a > b}

2

R2 = {(a, b) ∈ R2 |a ≥ b}

3

R3 = {(a, b) ∈ R2 |a < b}

4

R4 = {(a, b) ∈ R2 |a ≤ b}

5

R5 = {(a, b) ∈ R2 |a = b}

6

R6 = {(a, b) ∈ R2 |a 6= b}

e) R1 ◦ R5 Answer: R1 ∀a∀c∃b (a = b ∧ b > c) ⇒ ∀a∀c∃b (a > c) f) R1 ◦ R6 ? Answer: R2 ∀a∀c∃b (a 6= b ∧ b > c) Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

20 / 25

Exercise 36-Cont... Relations 1

R1 = {(a, b) ∈ R2 |a > b}

2

R2 = {(a, b) ∈ R2 |a ≥ b}

3

R3 = {(a, b) ∈ R2 |a < b}

4

R4 = {(a, b) ∈ R2 |a ≤ b}

5

R5 = {(a, b) ∈ R2 |a = b}

6

R6 = {(a, b) ∈ R2 |a 6= b}

g) R2 ◦ R3 Answer: R2 ∀a∀c∃b(a < b ∧ b ≥ c) h) R3 ◦ R3 ? Answer: R3 ∀a∀c∃b(a < b ∧ b < c) Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

21 / 25

Exercise 44 Which of the 16 relations on {0, 1}, which you listed in Exercise 42, are

Relations 1. ∅ 2. {(0, 0)} 3. {(0, 1)} 4. {(1, 0)} 5. {(1, 1)} 6. {(0, 0), (0, 1)} 7. {(0, 0), (1, 0)} 8. {(0, 0), (1, 1)} 9. {(0, 1), (1, 0)} 10. {(0, 1), (1, 1)} 11. {(1, 0), (1, 1)} 12. {(0, 0), (0, 1), (1, 0)} 13. {(0, 0), (0, 1), (1, 1)} 14. {(0, 0), (1, 0), (1, 1)} 15. {(0, 1), (1, 0), (1, 1)} 16. {(0, 0), (0, 1), (1, 0), (1, 1)} a) reflexive? Answer:8,13,14,16 b) irreflexive? Answer:1,3,4,9 c) symmetric? Answer:1, 2, 5, 8, 9, 12, 15, 16 d) antisymmetric? Answer:1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 13, 14 Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

22 / 25

Exercise 44-Cont... Which of the 16 relations on {0, 1}, which you listed in Exercise 42, are

Relations 1. ∅ 2. {(0, 0)} 3. {(0, 1)} 4. {(1, 0)} 5. {(1, 1)} 6. {(0, 0), (0, 1)} 7. {(0, 0), (1, 0)} 8. {(0, 0), (1, 1)} 9. {(0, 1), (1, 0)} 10. {(0, 1), (1, 1)} 11. {(1, 0), (1, 1)} 12. {(0, 0), (0, 1), (1, 0)} 13. {(0, 0), (0, 1), (1, 1)} 14. {(0, 0), (1, 0), (1, 1)} 15. {(0, 1), (1, 0), (1, 1)} 16. {(0, 0), (0, 1), (1, 0), (1, 1)} e) Asymmetric? Answer:1, 3, 4 f) Transitive? Answer:1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 13, 14, 16

Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

23 / 25

Exercise 46 Let S be a set with n elements and let a and b be distinct elements of S. How many relations R are there on S such that a) (a, b) ∈ R? 2 Answer:2n −1 b) (a, b) 6∈ R? 2 Answer:2n −1 c) no ordered pair in R has a as its first element? Answer:2n(n−1) d) at least one ordered pair in R has a as its first element? 2 Answer:2n − 2n(n−1) e) no ordered pair in R has a as its first element or b as its second element? Answer:2(n−1)(n−1) f) at least one ordered pair in R either has a as its first element or has b as its second element? 2 Answer:2n − 2(n−1)(n−1) Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

24 / 25

Exercise 52 Show that the relation R on a set A is antisymmetric if and only if R ∩ R−1 is a subset of the diagonal relation ∆ = {(a, a)|a ∈ A}. Answer:If R is antisymmetric and (x, y) ∈ R ∩ R−1 , then (x, y) ∈ R−1 implies that (y, x) ∈ R. Therefore, (x, y) ∈ R and (y, x) ∈ R, and since R is antisymmetric, then x = y, and (x, y) ∈ ∆. So we have shown that R ∩ R−1 ⊆ ∆. Conversely, suppose that R ∩ R−1 ⊆ ∆. If (x, y) ∈ R and (y, x) ∈ R, then (x, y) ∈ R ∩ R−1 ⊆ ∆, so that x = y, and therefore R is antisymmetric

Ali Moallemi, Iraj Hedayati

COMP232 - Mathematics for Computer Science

25 / 25

Suggest Documents