COMP232 - Mathematics for Computer Science - Tutorial 12moa_ali/Comp232Tutorial... ·...

Preview:

Citation preview

COMP232 - Mathematics for Computer ScienceTutorial 12

Ali Moallemimoa ali@encs.concordia.ca

Iraj Hedayatih iraj@encs.concordia.ca

Concordia University, Fall 2015

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 1 / 29

Table of Contents

1 9.5 Equivalence RelationsExercise 1Exercise 3Exercise 7Exercise 10Exercise 15Exercise 16Exercise 21Exercise 22Exercise 23Exercise 24Exercise 42Exercise 43Exercise 45Exercise 56Exercise 61

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 2 / 29

Exercise 1

Which of these relations on {0, 1, 2, 3} are equivalence relations?Determine the properties of an equivalence relation that the others lack.

Equivalence Relation

Reflexive

Symmetric

Transitive

a) {(0, 0), (1, 1), (2, 2), (3, 3)}Answer:Reflexive: YESSymmetric: YESTransitive: YESYes, it is an Equivalence Relation

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 3 / 29

Exercise 1 - Cont...

Which of these relations on {0, 1, 2, 3} are equivalence relations?Determine the properties of an equivalence relation that the others lack.

Equivalence Relation

Reflexive

Symmetric

Transitive

b) {(0, 0), (0, 2), (2, 0), (2, 2), (2, 3), (3, 2), (3, 3)}Answer:Reflexive: NO (1, 1) is not in this relationSymmetric: YESTransitive: NO (0, 2) and (2, 3) are in the relation but (0, 3) is not.No, it is not an Equivalence Relation

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 4 / 29

Exercise 1 - Cont...

Which of these relations on {0, 1, 2, 3} are equivalence relations?Determine the properties of an equivalence relation that the others lack.

Equivalence Relation

Reflexive

Symmetric

Transitive

c) {(0, 0), (1, 1), (1, 2), (2, 1), (2, 2), (3, 3)}Answer:Reflexive: YESSymmetric: YESTransitive: YESYes, it is an Equivalence Relation

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 5 / 29

Exercise 1 - Cont...

Which of these relations on {0, 1, 2, 3} are equivalence relations?Determine the properties of an equivalence relation that the others lack.

Equivalence Relation

Reflexive

Symmetric

Transitive

d) {(0, 0), (1, 1), (1, 3), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)}Answer:Reflexive: YESSymmetric: YESTransitive: NO (1, 3) and (3, 2) are in the relation but (1, 2) is not.No, it is not an Equivalence Relation

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 6 / 29

Exercise 1 - Cont...

Which of these relations on {0, 1, 2, 3} are equivalence relations?Determine the properties of an equivalence relation that the others lack.

Equivalence Relation

Reflexive

Symmetric

Transitive

e) {(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 2), (3, 3)}Answer:Reflexive: YESSymmetric: NO (1, 2) is in this relation but (2, 1) is notTransitive: NO (2, 0) and (0, 1) are in the relation but (2, 1) is not.No, it is not an Equivalence Relation

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 7 / 29

Exercise 3

Which of these relations on the set of all functions from Z to Z areequivalence relations? Determine the properties of an equivalence relationthat the others lack.

a) {(f , g)|f (1) = g(1)}Answer:Reflexive: YES For every function f , f (1) = f (1)Symmetric: YES For every functions f and gf (1) = g(1)→ g(1) = f (1)Transitive: YES For every functions f , g and hf (1) = g(1), g(1) = h(1)→ f (1) = h(1)Yes, it is an Equivalence Relation

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 8 / 29

Exercise 3 - Cont...

Which of these relations on the set of all functions from Z to Z areequivalence relations? Determine the properties of an equivalence relationthat the others lack.

b) {(f , g)|f (0) = g(0) or f (1) = g(1)}Answer:Reflexive: YESSymmetric: YESTransitive: NO Example: f (0) = g(0) then (f , g) is in relation.g(1) = h(1) means (f , h) is in relation. But it can not guarantee thatf (0) = h(0) or f (1) = h(1)No, it is not an Equivalence Relation

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 9 / 29

Exercise 3 - Cont...

Which of these relations on the set of all functions from Z to Z areequivalence relations? Determine the properties of an equivalence relationthat the others lack.

c) {(f , g)|f (x)− g(x) = 1 ∀x ∈ Z}Answer:Reflexive: NO f (x)− f (x) = 0 6= 1. Hence (f , f ) is not in relation.Symmetric: NO (f , g) is in relation meansf (x)− g(x) = 1→ g(x)− f (x) = −1 6= 1. Thus (g , f ) is not inrelationTransitive: NO (f , g) and (g , h) are in relation meansf (x)− g(x) = 1 and g(x)− h(x) = 1 and f (x)− h(x) = 2 6= 1 hence(f , h) is not in relationNo, it is not an Equivalence Relation

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 10 / 29

Exercise 3 - Cont...

Which of these relations on the set of all functions from Z to Z areequivalence relations? Determine the properties of an equivalence relationthat the others lack.

d) {(f , g)| for some C ∈ Z,∀x ∈ Z, f (x)− g(x) = C}Answer:Reflexive: YES Let C = 0, then f (x)− f (x) = 0 means (f (x), f (x))is in relationSymmetric: YES if (f , g) is in relation, f (x)− g(x) = C .Theng(x)− f (x) = −C and −C ∈ Z and (g(x), f (x)) is also in thisrelationTransitive: YES if (f , g) is in relation, f (x)− g(x) = C . if (g , h) is inrelation, g(x)− h(x) = C ′. Then f (x)− h(x) = C + C ′ andC + C ′ ∈ Z and (f (x), h(x)) is also in this relationYes, it is an Equivalence Relation

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 11 / 29

Exercise 3 - Cont...

Which of these relations on the set of all functions from Z to Z areequivalence relations? Determine the properties of an equivalence relationthat the others lack.

e) {(f , g)|f (0) = g(1) and f (1) = g(0)}Answer:Reflexive: NO f (0) 6= f (1)Symmetric: YESTransitive: NO if (f , g) is in relation, f (0) = g(1) and f (1) = g(0). if(g , h) is in relation, g(0) = h(1) and g(1) = h(0). Thenf (0) = g(1) = h(0) and f (1) = g(0) = h(1). Hence (f (x), h(x)) isnot in this relationNo, it is not an Equivalence Relation

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 12 / 29

Exercise 7

Show that the relation of logical equivalence on the set of all compoundpropositions is an equivalence relation. What are the equivalence classes ofF and T?Answer:The statement ”p is equivalent to q” means that p and q have the sameentries in their truth tables.

R is reflexive, because p has the same truth table as p.

R is symmetric, because if p and q have the same truth table, then qand p have the same truth table.

If p and q have the same entries in their truth tables and q and rhave the same entries in their truth tables, then p and r also do, so Ris transitive.

1 The equivalence class of T is the set of all tautologies

2 The equivalence class of F is the set of all contradictions.

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 13 / 29

Exercise 10

Suppose that A is a nonempty set and R is an equivalence relation on A.Show that there is a function f with A as its domain such that (x , y) ∈ Rif and only if f (x) = f (y).Answer:We define f as f (x) = [x ]R

R is reflexive, thus (x , x) ∈ R ↔ f (x) = f (x)

R is symmetric, thus (x , y) ∈ R → (y , x) ∈ R.(x , y) ∈ R ↔ f (x) = f (y)↔ f (y) = f (x)↔ (y , x) ∈ R

R is transitive, thus (x , y), (y , z) ∈ R → (x , z) ∈ R[1] (x , y) ∈ R ↔ f (x) = f (y)[2] (y , z) ∈ R ↔ f (y) = f (z)[1], [2]→ f (x) = f (z)↔ (x , z) ∈ R

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 14 / 29

Exercise 15

Let R be the relation on the set of ordered pairs of positive integers suchthat ((a, b), (c , d)) ∈ R if and only if a + d = b + c . Show that R is anequivalence relation.Answer:

Reflexivea + b = a + b → ((a, b), (a, b)) ∈ R

Symmetric((a, b), (c , d)) ∈ R → a + b = c + d ↔ c + d = a + b →((c , d), (a, b)) ∈ R

Transitive[1] ((a, b), (c , d)) ∈ R → a + d = b + c[2] ((c , d), (e, f )) ∈ R → c + f = d + e[1], [2]→ a + b = e + f → ((a, b), (e, f )) ∈ R

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 15 / 29

Exercise 16

Let R be the relation on the set of ordered pairs of positive integers suchthat ((a, b), (c , d)) ∈ R if and only if ad = bc. Show that R is anequivalence relationAnswer:

Reflexiveab = ab → ((a, b), (a, b)) ∈ R

Symmetric((a, b), (c , d)) ∈ R → ad = bc ↔ cd = ab → ((c , d), (a, b)) ∈ R

Transitive[1] ((a, b), (c , d)) ∈ R → ad = bc[2] ((c , d), (e, f )) ∈ R → cf = de[1], [2]→ af = be → ((a, b), (e, f )) ∈ R

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 16 / 29

Exercise 21

Determine whether the relation with the directed graph shown is anequivalence relation.

a b

c d

Answer: NO

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 17 / 29

Exercise 22

Determine whether the relation with the directed graph shown is anequivalence relation.

a b

d c

Answer: YES

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 18 / 29

Exercise 23

Determine whether the relation with the directed graph shown is anequivalence relation.

a b

d c

Answer: NO

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 19 / 29

Exercise 24

Determine whether the relations represented by these zero one matricesare equivalence relations.

a) 1 1 10 1 11 1 1

Answer:

I Reflexive YES(1, 1) = 1, (2, 2) = 1, (3, 3) = 1

I Symmetric NO(1, 2) = 1 but (2, 1) = 0

I Transitive NO(2, 3) = 1, (3, 1) = 1 but (2, 1) = 0

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 20 / 29

Exercise 24 - Cont...

Determine whether the relations represented by these zero one matricesare equivalence relations.

b) 1 0 1 00 1 0 11 0 1 00 1 0 1

Answer:

I Reflexive YES(1, 1) = 1, (2, 2) = 1, (3, 3) = 1, (4, 4) = 1

I Symmetric YESMR = (Mr )

t

I Transitive YES

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 21 / 29

Exercise 24 - Cont...

Determine whether the relations represented by these zero one matricesare equivalence relations.

c) 1 1 1 01 1 1 01 1 1 00 0 0 1

Answer:

I Reflexive YES(1, 1) = 1, (2, 2) = 1, (3, 3) = 1, (4, 4) = 1

I Symmetric YESMR = (Mr )

t

I Transitive YES

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 22 / 29

Exercise 42

Which of these collections of subsets are partitions of{−3,−2,−1, 0, 1, 2, 3}

a) {−3,−1, 1, 3}, {−2, 0, 2}Answer: YES

b) {−3,−2,−1, 0}, {0, 1, 2, 3}Answer: NO

c) {−3, 3},{−2, 2}, {−1, 1}, {0}Answer: YES

d) {−3,−2, 2, 3}, {−1, 1}Answer: NO

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 23 / 29

Exercise 43

Which of these collections of subsets are partitions of the set of bit stringsof length 8?

a) the set of bit strings that begin with 1, the set of bit strings thatbegin with 00, and the set of bit strings that begin with 01Answer: YES

b) the set of bit strings that contain the string 00, the set of bit stringsthat contain the string 01, the set of bit strings that contain thestring 10, and the set of bit strings that contain the string 11Answer: NO

c) strings that end with 01, the set of bit strings that end with 10, andthe set of bit strings that end with 11Answer: NO

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 24 / 29

Exercise 43 Cont...

Which of these collections of subsets are partitions of the set of bit stringsof length 8?

d) the set of bit strings that end with 111, the set of bit strings that endwith 011, and the set of bit strings that end with 00Answer: NO

e) the set of bit strings that contain 3k ones for some nonnegativeinteger k ; the set of bit strings that contain 3k + 1 ones for somenonnegative integer k ; and the set of bit strings that contain 3k + 2ones for some nonnegative integer k .Answer: YES

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 25 / 29

Exercise 45

Which of these are partitions of the set Z × Z of ordered pairs of integers?

a) the set of pairs (x , y), where x or y is odd; the set of pairs (x , y),where x is even; and the set of pairs (x , y), where y is evenAnswer: NO

b) the set of pairs (x , y), where both x and y are odd; the set of pairs(x , y), where exactly one of x and y is odd; and the set of pairs(x , y), where both x and y are evenAnswer: YES

c) the set of pairs (x , y), where x is positive; the set of pairs (x , y),where y is positive; and the set of pairs (x , y), where both x and yare negativeAnswer: NO

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 26 / 29

Exercise 45 Cont...

Which of these are partitions of the set Z × Z of ordered pairs of integers?

d) the set of pairs (x , y), where 3|x and 3|y ; the set of pairs (x , y),where 3|x and 3 6 |y ; the set of pairs (x , y), where 3 6 |x and 3|y ; andthe set of pairs (x , y), where 3 6 |x and 3 6 |yAnswer: YES

e) the set of pairs (x , y), where x > 0 and y > 0; the set of pairs (x , y),where x > 0 and y ≤ 0; the set of pairs (x , y), where x ≤ 0 andy > 0; and the set of pairs (x , y), where x ≤ 0 and y ≤ 0Answer: YES

f) the set of pairs (x , y), where x 6= 0 and y 6= 0; the set of pairs (x , y),where x = 0 and y 6= 0; and the set of pairs (x , y), where x 6= 0 andy = 0Answer: NO

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 27 / 29

Exercise 56

Suppose that R1 and R2 are equivalence relations on the set S . Determinewhether each of these combinations of R1 and R2 must be an equivalencerelation.

a) R1 ∪ R2

Answer: NOR1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3)},R2 = {(1, 1), (2, 2), (2, 3), (3, 2), (3, 3)},R1 ∪ R2 = {(1, 1), (1, 2), (2, 1), (2, 2), (2, 3), (3, 2), (3, 3)}

b) R1 ∩ R2

Answer: YES

c) R1 ⊕ R2

Answer: NOR1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3)},R2 = {(1, 1), (2, 2), (2, 3), (3, 2), (3, 3)},R1 ⊕ R2 = {(1, 2), (2, 1), (2, 3), (3, 2)}

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 28 / 29

Exercise 61

Determine the number of different equivalence relations on a set withthree elements by listing them.Answer:R1 = {1}, {2}, {3}R2 = {1}, {2, 3}R3 = {1, 2}, {3}R4 = {1, 3}, {2}R5 = {1, 2, 3}

Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 29 / 29