COMP232 - Mathematics for Computer Science Tutorial 8 Ali Moallemi moa ali@encs.concordia.ca Iraj Hedayati h iraj@encs.concordia.ca Concordia University, Winter 2016 Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 1 / 12 Table of Contents 1 2.3 Functions Exercise 53 Exercise 70 Exercise 71 Exercise 72 Exercise 73 Exercise 77 Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 2 / 12 Exercise 53 Prove that if n is an integer, then bn/2c = n/2 if n is even and (n − 1)/2 if n is odd. Answer: Let n be even, then there exists an integer k such that, n = 2k. As a result we have, bn/2c = b2k/2c = bkc = k = n/2. Now let n be odd, then there exists an integer k such that, n = 2k + 1. As a result we have, bn/2c = b(2k + 1)/2c = bk + 1/2c = k = (n − 1)/2. Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 3 / 12 Exercise 70 Suppose that f is an invertible function from Y to Z and g is an invertible function from X to Y . Show that the inverse of the composition f ◦ g is given by (f ◦ g)−1 = g −1 ◦ f −1 Answer: ∀x ∈ X x ∈ (f ◦ g)−1 (Z) ↔ ∃z ∈ Z; f ◦ g(x) = z ⇔ ∀x ∈ X x ∈ (f ◦ g)−1 (Z) ↔ ∃z ∈ Z, ∃y ∈ Y ; f (y) = z ∧ g(x) = y ⇔ ∀x ∈ X x ∈ (f ◦ g)−1 (Z) ↔ ∃z ∈ Z, ∃y ∈ Y ; f −1 (z) = y ∧ g −1 (y) = x ⇔ ∀x ∈ X x ∈ (f ◦ g)−1 (Z) ↔ ∃z ∈ Z; g −1 ◦ f −1 (z) = x Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 4 / 12 Exercise 71 Let S be a subset of a universal set U . The characteristic function fS of S is the function from U to the set {0, 1} such that fS (x) = 1 if x belongs to S and fS (x) = 0 if x does not belong to S. Let A and B be sets. Show that for all x ∈ U , a) fA∩B (x) = fA (x) · fB (x) Answer: fA∩B (x) = 1 ↔ x ∈ A ∩ B ↔ x ∈ A ∧ x ∈ B ↔ fA (x) = 1 ∧ fB (x) = 1 ↔ fA (x) · fB (x) = 1 b) fA∪B (x) = fA (x) + fB (x) − fA (x) · fB (x) Answer: fA∪B (x) = 1 ↔ x ∈ A ∪ B ↔ x ∈ A ∨ x ∈ B ↔ fA (x) = 1 ∨ fB (x) = 1 ↔ fA (x) + fB (x) − fA (x) · fB (x) = 1 Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 5 / 12 Exercise 71 Cont... Let S be a subset of a universal set U . The characteristic function fS of S is the function from U to the set {0, 1} such that fS (x) = 1 if x belongs to S and fS (x) = 0 if x does not belong to S. Let A and B be sets. Show that for all x ∈ U , c) fA (x) = 1 − fA (x) Answer: fA (x) = 1 ↔ x ∈ A ↔ x ∈ U − A ↔ fA (x) = fU (x) − fA (x) = 1 − fA (x) d) fA⊕B (x) = fA (x) + fB (x) − 2fA (x) · fB (x) Answer: fA⊕B (x) = 1 ↔ x ∈ A ⊕ B ↔ x ∈ (A ∪ B) − (A ∩ B) ↔ fA⊕B (x) = fA∪B (x) − fA∩B (x) = From (a) and (b) fA (x) + fB (x) − fA (x) · fB (x) − fA (x) · fB (x) = fA (x) + fB (x) − 2fA (x) · fB (x) Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 6 / 12 Exercise 72 Suppose that f is a function from A to B, where A and B are finite sets with |A| = |B|. Show that f is one-to-one if and only if it is onto Answer: Let f be one-to-one, then |f (A)| = |A|. since |B| = |A| and |f (A)| = |A|, then |f (A)| = |B|, and we know f (A) ⊆ B, consequently, f (A) = B, which means f is onto. Now let f be onto, as a result f (A) = B and |f (A)| = |B|, which implies |f (A)| = |A|. So, we can imply that f is one-to-one. Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 7 / 12 Exercise 73 Prove or disprove each of these statements about the floor and ceiling functions. a) dbxce = bxc for all real numbers x. Answer: Since, bxc is an integer, so, dbxce = bxc holds. b) b2xc = 2bxc whenever x is a real number. Answer: If x = 0.6 then b2xc = b1.2c = 1, however 2bxc = 2b0.6c = 2 · 0 = 0 c) dxe + dye − dx + ye = 0 or 1 whenever x and y are real numbers. Answer: If x or y is integer, by property 4.b in table1, dxe + dye − dx + ye = 0. Now if neither is integer, so we there are m, n ∈ Z and α, β ∈ R; 0 < α, β < 1, where x = m + α, y = n + β. which means, m + n < x + y < m + n + 2. So, dx + ye = m + n + 1 or dx + ye = m + n + 2. Finally we have either, dxe + dye − dx + ye = m + 1 + n + 1 − (m + n + 1) or dxe + dye − dx + ye = m + 1 + n + 1 − (m + n + 2) which is equal to 0 or 1. Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 8 / 12 Exercise 73 Prove or disprove each of these statements about the floor and ceiling functions. d) dxye = dxedye for real numbers x and y. Answer: Let x = 2 and y = 0.1, Then we have, dxye = d2 × 0.1e = 1, however, dxedye = d2ed0.1e = 2 e) d x2 e = b x+1 2 c for all real numbers x. Answer: Let x = 0.5 then, d x2 e = 1, however, b x+1 2 c=0 Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 9 / 12 Exercise 77 For each of these partial functions, determine its domain, codomain, domain of definition, and the set of values for which it is undefined. Also, determine whether it is a total function. a) f : Z → R, f (n) = 1/n Answer: Domain: Z. Codomain: R. Domain of definition: Set of nonzero integers. Set of undefined values:{0}. Total function: No. b) f : Z → Z, f (n) = dn/2e Answer: Domain: Z. Codomain: Z. Domain of definition: Z. Set of undefined values:∅ Total function: Yes. Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 10 / 12 Exercise 77 Cont... For each of these partial functions, determine its domain, codomain, domain of definition, and the set of values for which it is undefined. Also, determine whether it is a total function. c) f : Z × Z → Q, f (m, n) = m/n Answer: Domain: Z × Z. Codomain: Q. Domain of definition: Z × (Z − {0}). Set of undefined values: Z × {0} Total function: No. d) f : Z × Z → Z, f (m, n) = mn Answer: Domain: Z × Z. Codomain: Z. Domain of definition: Z × Z. Set of undefined values: ∅. Total function: Yes Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 11 / 12 Exercise 77 Cont... For each of these partial functions, determine its domain, codomain, domain of definition, and the set of values for which it is undefined. Also, determine whether it is a total function. e) f : Z × Z → Z, f (m, n) = m − n if m > n. Answer: Domain: Z × Z. Codomain: Z. Domain of definition: {(m, n) ∈ Z × Z | m > n} Set of undefined values: {(m, n) ∈ Z × Z | m ≤ n} Total function: No. Ali Moallemi, Iraj Hedayati COMP232 - Mathematics for Computer Science 12 / 12