Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Annoucement n Skills you need: (1) (In Thinking) You think and move by Logic Definitions Mathematical properties (Basic algebra etc.) (2) (In Exploration)

Similar presentations


Presentation on theme: "1 Annoucement n Skills you need: (1) (In Thinking) You think and move by Logic Definitions Mathematical properties (Basic algebra etc.) (2) (In Exploration)"— Presentation transcript:

1 1 Annoucement n Skills you need: (1) (In Thinking) You think and move by Logic Definitions Mathematical properties (Basic algebra etc.) (2) (In Exploration) You understand by: Trying examples Drawing diagrams –For relations, 3 visualization tools have been given to you. Be flexible in using your alternatives. (3) Using (1) and (2) to understand new things.

2 2 Lecture 3 (part 1) Functions Reading: Epp Chp 7.1, 7.3, 7.5

3 3 Overview n Functions –Definition –Visualization Tool –Examples –Notation –Identity Function n Definitions –Domain, codomain, range –Image, inverse image –Let f:A  B and let S  A and T  B. S  InvImg f (Img f (S)) Img f (InvImg f (T))  T n Operations on Functions –Set related ( , ,  ): 1.If f  g is a function, then f = g 2.If f  g is a function, then f = g 3.If f  g is a function, then f  g=  –Inverse –Composition –Theorems 1.G o f is a function. 2.F o id A  id B o f  f 3.(h o g) o f = h o (g o f) 4.(g o f) -1 = f -1 o g -1 n Special Kinds of Functions –Injective, Surjective, Bijective –Theorems Preservation under ‘o’. On inverses n Multi-argument functions

4 4 1. Definition: Function n Given a relation R from a set A to a set B, R is a function iff 1.  x  A,  y  B, x R y 2.  x  A,  y 1,y 2  B, x R y 1  x R y 2  y 1 = y 2.

5 5 1. Definition: Function n Given a relation R from a set A to a set B, R is a function iff 1.  x  A,  y  B, x R y 2.  x  A,  y 1,y 2  B, x R y 1  x R y 2  y 1 = y 2. A function is a relation. It’s just a special kind of relation – a relation with 2 restrictions.

6 6 1. Definition: Function n Given a relation R from a set A to a set B, R is a function iff 1.  x  A,  y  B, x R y 2.  x  A,  y 1,y 2  B, x R y 1  x R y 2  y 1 = y 2. 1.Every element in A must be associated with AT LEAST one element in B. Extract the meaning from the logical expression. AB R

7 7 1. Definition: Function n Given a relation R from a set A to a set B, R is a function iff 1.  x  A,  y  B, x R y 2.  x  A,  y 1,y 2  B, x R y 1  x R y 2  y 1 = y 2. 2. An element in A can only be associated with AT MOST one element in B. Extract the meaning from the logical expression. AB R

8 8 1. Definition: Function n Given a relation R from a set A to a set B, R is a function iff 1.  x  A,  y  B, x R y 2.  x  A,  y 1,y 2  B, x R y 1  x R y 2  y 1 = y 2. 1 and 2 taken together: Every element in A can only be associated with EXACTLY ONE element in B. Extract the meaning from the logical expression. AB R

9 9 2. Visualisation Tool: Arrow Diagram n Given a relation R from a set A to a set B, R is a function iff 1.  x  A,  y  B, x R y 2.  x  A,  y 1,y 2  B, x R y 1  x R y 2  y 1 = y 2. ABf Not a function

10 10 2. Visualisation Tool: Arrow Diagram n Given a relation R from a set A to a set B, R is a function iff 1.  x  A,  y  B, x R y 2.  x  A,  y 1,y 2  B, x R y 1  x R y 2  y 1 = y 2. Yes, it’s a function. ABf

11 11 2. Visualisation Tool: Arrow Diagram n Given a relation R from a set A to a set B, R is a function iff 1.  x  A,  y  B, x R y 2.  x  A,  y 1,y 2  B, x R y 1  x R y 2  y 1 = y 2. Not a function ABf

12 12 3. Examples n Given a relation R from a set A to a set B, R is a function iff 1.  x  A,  y  B, x R y 2.  x  A,  y 1,y 2  B, x R y 1  x R y 2  y 1 = y 2. Example 1: Is R a function? No. (Cond 1) No. (Cond 2) Yes. R = {(1,2)} R  A x B A {1,2,3} B R = {(1,2),(2,3),(1,3)} {1,2,3} R = {(1,1),(2,1),(3,1)} {1,2,3} {1,2,3,4} {1,2,3} R = {(1,1),(2,2),(3,3)} No. (Cond 1) {1,2,3} {1,2,3,4} R = {(1,1),(2,2),(3,3)} Yes.

13 13 3. Examples n Given a relation R from a set A to a set B, R is a function iff 1.  x  A,  y  B, x R y 2.  x  A,  y 1,y 2  B, x R y 1  x R y 2  y 1 = y 2. Example 2: Let R  Q x Z such that… (i)x R y iff x = y. Q: Is R a function? A: No (1 st Condition: ½ maps to nothing) QZ ½? (ii)(a/b) R c iff a.b = c. Q: Is R a function? A: Yes

14 14 3. Examples n Given a relation R from a set A to a set B, R is a function iff 1.  x  A,  y  B, x R y 2.  x  A,  y 1,y 2  B, x R y 1  x R y 2  y 1 = y 2. Example 3: Let R  Z x Z such that… (i)x R y iff y = x 2. Q: Is R a function? A: Yes. (ii)x R y iff x = y 2. Q: Is R a function? A: No. (1 st and 2 nd Condition violated) ZZ 3? 1 1

15 15 3. Examples n Functions in real life: 1.Hamming distance function (p351). 2.Encoding/decoding functions (p351). 3.Boolean functions (p352). 4.A program is a function.

16 16 Eg. 3: F  Z x {0,1}, a F b iff (a is even  b=1)  (a is odd  b=0) 4. Notation n We usually use “f,g,h,F,G,H” to denote functions. If the relation f  A x B is a function, we write it as: f : A  B If there is a way to compute y  B from any given x  A, we usually write ‘f(x)’ in place of ‘y’. We will write it as: Eg. 1: F  Z x Z, x F y iff y = x 2. ‘F’ is a function. F : Z  Z, F(x) = x 2 We will write it as: Eg. 2: F  Z x Z, x F y iff y = x 2 + 2x + 1 F : Z  Z, F(x) = x 2 + 2x + 1 F : Z  {0,1}, F(x) = 1,if x is even 0,otherwise

17 17 4. Notation n We usually use “f,g,h,F,G,H” to denote functions. If the relation f  A x B is a function, we write it as: f : A  B If there is a way to compute y  B from any given x  A, we usually write ‘f(x)’ in place of ‘y’. Therefore, the definitions instead of… 1.  x  A,  y  B, x R y 2.  x  A,  y 1,y 2  B, x R y 1  x R y 2  y 1 =y 2. 1.  x  A,  y  B, y = f(x) 2.  x  A,  y 1,y 2  B, y 1 =f(x)  y 2 =f(x)  y 1 =y 2. … can be also expressed as…

18 18 5. The identity function. n The identity function on any given set, is a function that maps every element to itself. id A : A  A,  x  A, id A (x) = x

19 19 Overview n Functions –Definition –Visualization Tool –Examples –Notation –Identity Function n Definitions –Domain, codomain, range –Image, inverse image –Let f:A  B and let S  A and T  B. S  InvImg f (Img f (S)) Img f (InvImg f (T))  T n Operations on Functions –Set related ( , ,  ): 1.If f  g is a function, then f = g 2.If f  g is a function, then f = g 3.If f  g is a function, then f  g=  –Inverse –Composition –Theorems 1.g 1 f is a function. 2.f 1 id A  id B 1 f  f 3.(h 1 g) 1 f = h 1 (g 1 f) 4.(g 1 f) -1 = f -1 1 g -1 n Special Kinds of Functions –Injective, Surjective, Bijective –Theorems Preservation under ‘1’. On inverses n Multi-argument functions

20 20 6. Definition: domain, codomain, range Given a function: f : A  B, –The set A is known as the domain of f. –The set B is known as the codomain of f. –The set { y  B |  x  A, y=f(x)} is known as the range of f. ABf

21 21 6. Definition: domain, codomain, range Given a function: f : A  B, –The set A is known as the domain of f. –The set B is known as the codomain of f. –The set { y  B |  x  A, y=f(x)} is known as the range of f. ABf Domain(f)

22 22 6. Definition: domain, codomain, range Given a function: f : A  B, –The set A is known as the domain of f. –The set B is known as the codomain of f. –The set { y  B |  x  A, y=f(x)} is known as the range of f. ABf Codomain(f)

23 23 6. Definition: domain, codomain, range Given a function: f : A  B, –The set A is known as the domain of f. –The set B is known as the codomain of f. –The set { y  B |  x  A, y=f(x)} is known as the range of f. ABf Range(f) NOTE: range(f)  codomain(f)

24 24 6. Definition: domain, codomain, range Given a function: f : A  B, –The set A is known as the domain of f. –The set B is known as the codomain of f. –The set { y  B |  x  A, y=f(x)} is known as the range of f. Example 1:f : Z  Z +, f(x) = |2x| a. domain(f) = Z b. codomain(f) = Z + c. range(f) = positive even numbers: {2x | x  Z + }

25 25 6. Definition: domain, codomain, range Given a function: f : A  B, –The set A is known as the domain of f. –The set B is known as the codomain of f. –The set { y  B |  x  A, y=f(x)} is known as the range of f. Example 2: Let f : Z  Z, f(x) = 2x + 1; g : Z  Z, g(x) = 2x - 1 Then range(f) = range(g). Range(f) = 2x+1 = 2(x+1) – 1 = Range(g)  x  Z, f(x) = g(x+1)

26 26 7. Definition: Image, Inverse Image. Given a function: f : A  B, and S  A –The image of S is defined as: Img f (S) = { y  B |  x  S, y=f(x)} AB f

27 27 7. Definition: Image, Inverse Image. Given a function: f : A  B, and S  A –The image of S is defined as: Img f (S) = { y  B |  x  S, y=f(x)} S Image of S NOTE: Img f (S)  range(f)  codomain(f) AB f

28 28 7. Definition: Image, Inverse Image. Given a function: f : A  B, and S  A –The image of S is defined as: Img f (S) = { y  B |  x  S, y=f(x)} Given a function: f : A  B, and T  B –The inverse image of T is defined as: InvImg f (T) = { x  A |  y  T, y=f(x)} Inverse image of T T AB f

29 29 7. Definition: Image, Inverse Image. Given a function: f : A  B, and S  A –The image of S is defined as: Img f (S) = { y  B |  x  S, y=f(x)} Given a function: f : A  B, and T  B –The inverse image of T is defined as: InvImg f (T) = { x  A |  y  T, y=f(x)} Example:f : Z  Z +, f(x) = |x| a. Img f ({10,-20}) = {10,20} b. InvImg f ({10,20}) = {10, 20, -10, -20}

30 30 7. Definition: Image, Inverse Image. Given a function: f : A  B, and S  A –The image of S is defined as: Img f (S) = { y  B |  x  S, y=f(x)} or y  Img f (S) iff  x  S and y=f(x) Given a function: f : A  B, and T  B –The inverse image of T is defined as: InvImg f (T) = { x  A |  y  T, y=f(x)} or x  InvImg f (T) iff  y  T and y=f(x) Axiomatic definition

31 31 7.1 Theorem: Image, Inverse Image. Given any function: f : A  B, S  A, T  B 1. S  InvImg f (Img f (S)) 2. Img f (InvImg f (T))  T ABf Proof of (1): ( Use diagrams to help visualise! )

32 32 7.1 Theorem: Image, Inverse Image. ABf S Proof of (1): ( Use diagrams to help visualize! ) Given any function: f : A  B, S  A, T  B 1. S  InvImg f (Img f (S)) 2. Img f (InvImg f (T))  T

33 33 7.1 Theorem: Image, Inverse Image. ABf S Proof of (1): Given any function: f : A  B, S  A, T  B 1. S  InvImg f (Img f (S)) 2. Img f (InvImg f (T))  T Assume x  S Therefore x  InvImg f (Img f (S)) Then  y  B such that y = f(x) (Since f is a function) Therefore y  Img f (S) (Defn: y  Img f (S) iff  x  S and y=f(x)) x y Therefore y  Img f (S) and y = f(x) Img f (S)

34 34 7.1 Theorem: Image, Inverse Image. ABf Img f (S) Proof of (1): Given any function: f : A  B, S  A, T  B 1. S  InvImg f (Img f (S)) 2. Img f (InvImg f (T))  T Assume x  S Therefore x  InvImg f (Img f (S)) Then  y  B such that y = f(x) (Since f is a function) Therefore y  Img f (S) (Defn: y  Img f (S) iff  x  S and y=f(x)) Therefore y  Img f (S) and y = f(x) (Defn:x  InvImg f (T) iff  y  T and y=f(x) ) x y

35 35 7.1 Theorem: Image, Inverse Image. …Proof of (2) left as an exercise… (Again, the skill that you must pick up is that you must use diagrams wherever possible, to help visualize the problem and use it to help you reason about proofs) Given any function: f : A  B, S  A, T  B 1. S  InvImg f (Img f (S)) 2. Img f (InvImg f (T))  T

36 36 Overview n Functions –Definition –Visualization Tool –Examples –Notation –Identity Function n Definitions –Domain, codomain, range –Image, inverse image –Let f:A  B and let S  A and T  B. S  InvImg f (Img f (S)) Img f (InvImg f (T))  T n Operations on Functions –Set related ( , ,  ): 1.If f  g is a function, then f = g 2.If f  g is a function, then f = g 3.If f  g is a function, then f  g=  –Inverse –Composition –Theorems 1.g 1 f is a function. 2.f 1 id A  id B 1 f  f 3.(h 1 g) 1 f = h 1 (g 1 f) 4.(g 1 f) -1 = f -1 1 g -1 n Special Kinds of Functions –Injective, Surjective, Bijective –Theorems Preservation under ‘1’. On inverses n Multi-argument functions

37 37 8. Operations on Functions. n A function is a (special) relation. n A relation is a set (of ordered pairs). n Therefore, all definitions and operations on sets and relations are extended over to functions.

38 38 8.1 Equality of Functions Given 2 functions, f : A  B, g : A  B, f = g iff f  g and g  f n Or, in cases where y can be computed directly from x: f = g iff  x  A, y 1 =f(x)  y 2 =g(x)  y 1 =y 2 n Which is equivalent to: f = g iff  x  A, f(x) = g(x)

39 39 8.2 Union, Intersection, Difference Given 2 functions, f : A  B, g : A  B, f  g, f  g, f  g are defined as accordingly in set theory (since functions are sets). …Or, in cases where y can be computed directly from x: –(f  g)(x) = y iff y = f(x) or y  g(x) –(f  g)(x) = y iff y = f(x) and y  g(x) –(f  g)(x) = y iff y = f(x) and y  g(x) NOTE: f  g, f  g, f  g need not necessarily be functions. At most, one can only conclude that f  g, f  g, f  g are relations. In order to assert that they are functions, one must prove that the 2 conditions necessary for functions are true.

40 40 8.2 Union, Intersection, Difference Theorem: Given 2 functions f and g from A to B, 1. If f  g is a function, then f = g 2. If f  g is a function, then f = g 3. If f  g is a function, then f  g =  Proof of (1): (Direct proof: f = g iff  x  A, f(x) = g(x) AB f x AB g x AB f  g x y1y1 y2y2 y2y2 y1y1 But f  g is a function! Defn:y 1 = (f  g)(x) and y 2 = (f  g)(x) then y 1 =y 2.

41 41 8.2 Union, Intersection, Difference Theorem: Given 2 functions f and g from A to B, 1. If f  g is a function, then f = g 2. If f  g is a function, then f = g 3. If f  g is a function, then f  g =  Proof of (1): (Direct proof: f = g iff  x  A, f(x) = g(x) Let x  A. Since f is a function, then  y 1  B, y 1 = f(x), (x,y 1 )  f Since g is a function, then  y 2  B, y 2 = g(x), (x,y 2 )  g Therefore (x,y 1 )  f  g and (x,y 2 )  f  g. i.e. y 1  f  g)(x) and y 2  f  g)(x) But since f  g is a function, then y 1 =y 2. Therefore f(x) = g(x) (By definition of function equality)

42 42 8.2 Union, Intersection, Difference Theorem: Given 2 functions f and g from A to B, 1. If f  g is a function, then f = g 2. If f  g is a function, then f = g 3. If f  g is a function, then f  g =  Proof of (3): (By contradiction) AB f  g xy AB f xy AB g xy AB f-g x

43 43 8.2 Union, Intersection, Difference Theorem: Given 2 functions f and g from A to B, 1. If f  g is a function, then f = g 2. If f  g is a function, then f = g 3. If f  g is a function, then f  g =  Proof of (3): (By contradiction) Assume that f  g   Then by definition,  (x,y)  f  g That means that (x,y)  f and (x,y)  g That means that (x,y)  (f – g). But f – g is a function!  x  A,  y  B, y = (f – g)(x). So there must be a (x,y)  (f – g) => Contradiction! Therefore f  g  .

44 44 8.2 Union, Intersection, Difference Theorem: Given 2 functions f and g from A to B, 1. If f  g is a function, then f = g 2. If f  g is a function, then f = g 3. If f  g is a function, then f  g =  Proof of (2) left as an exercise Similar to Proof of (1).

45 45 8.3 Definition: Inverse of a function Given a function, f : A  B, the inverse of a function is defined in the same way as that of a relation: f -1 = { (y,x) | (x,y)  f } n NOTE: f -1 need not necessarily be a function. It is first and foremost, a relation. In order to assert that they are functions, one must prove that the 2 conditions necessary for functions are true. So f -1  B x A If f -1 is a function, then we write: f -1 : B  A … and then say that: f(x) = y iff f -1 (y) = x

46 46 8.3 Definition: Inverse of a function n Find the inverse of the function f(x) = (1+x)/(1-x). n Ans: –Let y = (1+x)/(1-x). Express x in terms of y. –Therefore: y – yx = 1 + x –Therefore: y – 1 = yx + x –Therefore: x(y+1) = y–1 –Therefore: x = (y–1)/(y+1) –Therefore: f -1 (y) = (y–1)/(y+1) –i.e. f -1 (x) = (x–1)/(x+1)

47 47 8.4 Definition: Composition of functions Given 2 functions, f : A  B, g : B  C, then the composition of function ‘g o f’ is defined (in the same way as relation composition) as: g o f = { (x,z) |  y  B, (x,y)  f  (y,z)  g} Or, z = (g o f)(x) iff  y  B, y = f(x)  z = g(y) n And since f and g are functions, y if it exists, must be unique. So: (g o f)(x) = g(f(x))

48 48 8.5 Properties of function composition Given any functions, f : A  B, g : B  C, h : C  D, 1. g o f is a function. (o preserves function property) 2. f o id A  id B o f  f 3. (h o g) o f = h o (g o f)(From relations: o is associative) 4. (g o f) -1 = f -1 o g -1 (From relations) n Since a function is a relation, there’s no need to prove (3) and (4) since the properties of (3) and (4) are proven in the lecture on relations.

49 49 8.5 Properties of function composition Given any functions, f : A  B, g : B  C, h : C  D, 1. g o f is a function. ( o preserves function property) 2. f o id A  id B o f  f 3. (h o g) o f = h o (g o f)(From relations: o is associative) 4. (g o f) -1 = f -1 o g -1 (From relations) Proof of (1): Let f : A  B, g : B  C. Is g o f a function? Proof of condition 1:  x  A,  z  C, z = (g o f)(x)  Let x  A.  Then  y  B, y = f(x)(Since f is a function)  Also,  z  C, z = g(y)(Since g is a function)  Therefore  z  C, z = g(f(x))  Therefore  z  C, z = (g o f)(x)

50 50 8.5 Properties of function composition Given any functions, f : A  B, g : B  C, h : C  D, 1. g o f is a function. (o preserves function property) 2. f o id A  id B o f  f 3. (h o g) o f = h o (g o f)(From relations: o is associative) 4. (g o f) -1 = f -1 o g -1 (From relations) Proof of (1): Let f : A  B, g : B  C. Is g o f a function? n Proof of condition 2:  x  A, z 1 =(g o f)(x)  z 2 =(g o f)(x)  z 1 =z 2.  Let z 1 =(g o f)(x)  z 2 =(g o f)(x)  z 1 =g(f(x))  z 2 =g(f(x))(Defn of composition)  z 1 =g(y)  z 2 =g(y)(Since f is a function)  z 1 =z 2.(Since g is a function) Y es, g o f Is a function.

51 51 8.5 Properties of function composition Given any functions, f : A  B, g : B  C, h : C  D, 1. g o f is a function. (o preserves function property) 2. f o id A  id B o f  f 3. (h o g) o f = h o (g o f)(From relations: o is associative) 4. (g o f) -1 = f -1 o g -1 (From relations) Proof of (2): (f o id A )(x)= f (id A (x)) (since  a  A, id A (a) = a) = f(x) (id B o f )(x)= id B (f(x))(since  b  B, id B (b) = b) = f(x) Therefore f o id A  id B o f  f.

52 52 Overview n Functions –Definition –Visualization Tool –Examples –Notation –Identity Function n Definitions –Domain, codomain, range –Image, inverse image –Let f:A  B and let S  A and T  B. S  InvImg f (Img f (S)) Img f (InvImg f (T))  T n Operations on Functions –Set related ( , ,  ): 1.If f  g is a function, then f = g 2.If f  g is a function, then f = g 3.If f  g is a function, then f  g=  –Inverse –Composition –Theorems 1.G o f is a function. 2.F o id A  id B o f  f 3.(h o g) o f = h o (g o f) 4.(g o f) -1 = f -1 o g -1 n Special Kinds of Functions –Injective, Surjective, Bijective –Theorems Preservation under ‘o’. On inverses n Multi-argument functions

53 53 9. Special Kinds of functions n Three types of functions: –Injective (1-1) –Surjective (onto) –Bijective (1-1 correspondence)

54 54 9.1 Injective (1-1) Functions Definition: Let f : A  B. f is injective (or one-to-one) iff  x 1,x 2  A, f(x 1 ) = f(x 2 )  x 1 = x 2 A B f x1x1 x2x2

55 55 9.1 Injective (1-1) Functions Definition: Let f : A  B. f is injective (or one-to-one) iff  x 1,x 2  A, f(x 1 ) = f(x 2 )  x 1 = x 2 A B f x1x1 x2x2 An element in B can only receive from at most one element in A.

56 56 9.1 Injective (1-1) Functions Definition: Let f : A  B. f is injective (or one-to-one) iff  x 1,x 2  A, f(x 1 ) = f(x 2 )  x 1 = x 2 n NOTE: This is different from saying:  x 1,x 2  A, x 1 = x 2  f(x 1 ) = f(x 2 ) A B f x1x1 x2x2

57 57 9.1 Injective (1-1) Functions Definition: Let f : A  B. f is injective (or one-to-one) iff  x 1,x 2  A, f(x 1 ) = f(x 2 )  x 1 = x 2 n NOTE: This is different from saying:  x 1,x 2  A, x 1 = x 2  f(x 1 ) = f(x 2 ) A B f x1x1 x2x2 An element in A can only send to at most one element in B. (2 nd cond of function)

58 58 9.1 Injective (1-1) Functions Definition: Let f : A  B. f is injective (or one-to-one) iff  x 1,x 2  A, f(x 1 ) = f(x 2 )  x 1 = x 2 Q: Is f an injection? A: No. B A x1x1 x2x2 f Examples:

59 59 9.1 Injective (1-1) Functions Definition: Let f : A  B. f is injective (or one-to-one) iff  x 1,x 2  A, f(x 1 ) = f(x 2 )  x 1 = x 2 Q: Is f an injection? A: Yes. A x1x1 x2x2 B f Examples:

60 60 9.1 Injective (1-1) Functions Definition: Let f : A  B. f is injective (or one-to-one) iff  x 1,x 2  A, f(x 1 ) = f(x 2 )  x 1 = x 2 Examples: f : Z  Z, f(x) = x 2 Q: Is f an injection? A: No. A 1 B f 1 F(1) = F(-1) but 1  -1

61 61 9.1 Injective (1-1) Functions Definition: Let f : A  B. f is injective (or one-to-one) iff  x 1,x 2  A, f(x 1 ) = f(x 2 )  x 1 = x 2 Examples: Q: Is f an injection? A: No. f : Z  Z, f(x) = x – 1if x >= 0 x if x<0 A -2 B f 0 0 1 2 1 F(0) = F(-1) but 0  1

62 62 9.1 Injective (1-1) Functions Definition: Let f : A  B. f is injective (or one-to-one) iff  x 1,x 2  A, f(x 1 ) = f(x 2 )  x 1 = x 2 Examples: f : Z  Z, f(x) = 3x+2 Q: Is f an injection? A: Yes. Proof: Assume f(a) = f(b) 3a+2 = 3b+2 a=b A B f 0 1 2 2 5 8

63 63 9.2 Surjective (onto) Functions Definition: Let f : A  B. f is surjective (or onto) iff  y  B,  x  A, f(x) = y AB f n Again, note that this is different from saying:  x  A,  y  B, f(x) = y (This is 1 st condition of a function) (“Every girl is loved by some boy”) (“Every boy loves some girl”) (Boys)(Girls)

64 64 9.2 Surjective (onto) Functions Definition: Let f : A  B. f is surjective (or onto) iff  y  B,  x  A, f(x) = y n Or, Codomain(f) = Range(f) Q: Is f a surjection? A: No. Examples: A a b B f

65 65 9.2 Surjective (onto) Functions Definition: Let f : A  B. f is surjective (or onto) iff  y  B,  x  A, f(x) = y n Or, Codomain(f) = Range(f) Q: Is f a surjection? A: Yes. A a b B f Examples:

66 66 9.2 Surjective (onto) Functions Definition: Let f : A  B. f is surjective (or onto) iff  y  B,  x  A, f(x) = y n Or, Codomain(f) = Range(f) Examples: f : Z  Z, f(x) = x 2 Q: Is f a surjection? A: No.  y  B,  x  A, f(x)  y. Take y = -1. ?

67 67 9.2 Surjective (onto) Functions Definition: Let f : A  B. f is surjective (or onto) iff  y  B,  x  A, f(x) = y n Or, Codomain(f) = Range(f) Examples: f : Z  Z nonneg, f(x) = x 2 Q: Is f a surjection? A: No.  y  B,  x  A, f(x)  y. Take y = 3. 3? 1 2 4 1

68 68 9.2 Surjective (onto) Functions Definition: Let f : A  B. f is surjective (or onto) iff  y  B,  x  A, f(x) = y n Or, Codomain(f) = Range(f) Examples: Q: Is f a surjection? A: No.  y  B,  x  A, f(x)  y. Take y = 0. 0? 0 1 f : Z  Z, f(x) = x+1if x>=0 xotherwise

69 69 9.2 Surjective (onto) Functions Definition: Let f : A  B. f is surjective (or onto) iff  y  B,  x  A, f(x) = y n Or, Codomain(f) = Range(f) Examples: f : R  R, f(x) = 4x-1 Take any y, where y = 4x + 1. There exist an x, where x = (y-1)/4 (which is in R) Q: Is f a surjection? A: Yes.

70 70 9.2 Surjective (onto) Functions Definition: Let f : A  B. f is surjective (or onto) iff  y  B,  x  A, f(x) = y n Or, Codomain(f) = Range(f) Examples: f : Z  Z, f(x) = 4x-1 0? 0 3 -5  y  B,  x  A, f(x)  y. Take y = 0. Q: Is f a surjection? A: No.

71 71 9.2 Surjective (onto) Functions n Application –Pigeon-Hole Principle (Later) –Hashing Static Hashing Dynamic Hashing –Linear Hashing –Extendible Hashing (Database Management Systems Course)

72 72 9.3 Bijective Functions Definition: Let f : A  B. f is bijective (or 1-1 correspondence) iff –f is injective (1-1); and –f is surjective (onto) Not injective, Not surjective Injective, but not surjective Not injective, but surjective Injective AND surjective = bijective

73 73 9.3 Bijective Functions n Application: –Cardinality (Next lecture)

74 74 9.4.1 Theorem (preservation under composition) Theorem (preservation under composition): Given f : A  B and g : B  C, 1. If f and g are injective, then (g o f) is injective. 2. If f and g are surjective, then (g o f) is surjective. 3. If f and g are bijective, then (g o f) is bijective. 4. The converse of the above 3 statements is not true Proof of (1):  x 1,x 2  A, (g o f)(x 1 ) = (g o f)(x 2 )  x 1 = x 2 (g o f)(x 1 ) = (g o f)(x 2 ) g(f(x 1 ))= g(f(x 2 ))(By defn of composition) f(x 1 ) = f(x 2 )(Since g is injective) x 1 = x 2 (Since f is injective)

75 75 9.4.1 Theorem (preservation under composition) Theorem (preservation under composition): Given f : A  B and g : B  C, 1. If f and g are injective, then (g o f) is injective. 2. If f and g are surjective, then (g o f) is surjective. 3. If f and g are bijective, then (g o f) is bijective. 4. The converse of the above 3 statements is not true fg g o f Converse of (1) is not true. g o f is injective. But g is not injective.

76 76 9.4.1 Theorem (preservation under composition) Theorem (preservation under composition): Given f : A  B and g : B  C, 1. If f and g are injective, then (g o f) is injective. 2. If f and g are surjective, then (g o f) is surjective. 3. If f and g are bijective, then (g o f) is bijective. 4. The converse of the above 3 statements is not true Proof of (2): (  c  C,  a  A, (g o f)(a) = c) Let c  C Since g is surjective, then  b  B, g(b) = c Since f is surjective, then  a  A, f(a) = b Therefore  a  A,  b  B, f(a) = b and g(b) = c Therefore  a  A, g(f(a)) = c Therefore  a  A, (g o f)(a) = c

77 77 9.4.1 Theorem (preservation under composition) Theorem (preservation under composition): Given f : A  B and g : B  C, 1. If f and g are injective, then (g o f) is injective. 2. If f and g are surjective, then (g o f) is surjective. 3. If f and g are bijective, then (g o f) is bijective. 4. The converse of the above 3 statements is not true fg g o f Converse of (2) is not true. g o f is surjective But f is not surjective.

78 78 9.4.1 Theorem (preservation under composition) Theorem (preservation under composition): Given f : A  B and g : B  C, 1. If f and g are injective, then (g o f) is injective. 2. If f and g are surjective, then (g o f) is surjective. 3. If f and g are bijective, then (g o f) is bijective. 4. The converse of the above 3 statements is not true Proof of (3): Since f and g are both bijective, then by definition, f and g are both injective and surjective. By previous two theorems, g o f is injective.and also g o f is surjective Therefore, g o f is bijective. (The converse is not true. It follows from the previous 2 counter-examples.)

79 79 9.4.2 Theorem (On inverses) Theorem: Given f : A  B, If f is a bijection, then f -1 is a function from B to A. Proof: (a) To show 1 st condition: Every element in B must map to some element in A. Assume any y  B, Since f is surjective (due to the fact that f is bijective), then  x  A such that f(x) = y. So  x  A such that x = f -1 (y) AB

80 80 9.4.2 Theorem (On inverses) Theorem: Given f : A  B, If f is a bijection, then f -1 is a function from B to A. Proof: (b) To show 2 nd condition: An element in B must map to at most one element in A. Assume f -1 (y) = x 1 and f -1 (y) = x 2 Then f(x 1 ) = y and f(x 2 ) = y Since f is injective (due to the fact that f is bijective), then x 1 = x 2 AB

81 81 9.4.3 Theorem (On inverses) Theorem: Given f : A  B, 1.If f is a bijection, then f -1 is a bijection. 2.If f is a bijection, then a.f -1 o f = id A b.f o f -1 = id B Proof of (1): (a) To show is f -1 injective (1-1) Assume f -1 (y 1 ) = f -1 (y 2 ) = x Then x = f -1 (y 1 ) and x = f -1 (y 2 ) Therefore f(x) = y 1 and f(x) = y 2 Therefore y 1 = y 2 (Since f is a function)

82 82 9.4.3 Theorem (On inverses) Theorem: Given f : A  B, 1.If f is a bijection, then f -1 is a bijection. 2.If f is a bijection, then a.f -1 o f = id A b.f o f -1 = id B Proof of (1): (b) To show is f -1 surjective (onto) (  a  A,  b  B, f -1 (b) = a) Assume a  A Since f is a function, therefore  b  B, f(a) = b  b  B, f -1 (b) = a.

83 83 9.4.3 Theorem (On inverses) Theorem: Given f : A  B, 1.If f is a bijection, then f -1 is a bijection. 2.If f is a bijection, then a.f -1 o f = id A b.f o f -1 = id B Proof of (2a): (f -1 o f)(x) = f -1 (f(x)) Let x’ = f -1 (f(x)). Thenf(x’) = f(x)(Since f -1 (b) = a iff f(a) = b) Sox’ = x(Since f is a bijection) Therefore x = f -1 (f(x)). Meaning that: (f -1 o f)(x) = x. Sof -1 o f = id A

84 84 9.4.3 Theorem (On inverses) Theorem: Given f : A  B, 1.If f is a bijection, then f -1 is a bijection. 2.If f is a bijection, then a.f -1 o f = id A b.f o f -1 = id B Proof of (2b): (f o f -1 )(x) = f (f -1 (x)) Let y’ = f (f -1 (y)). Thenf -1 (y) = f -1 (y’)(Since f -1 (b) = a iff f(a) = b) Soy = y’(Since f -1 is a bijection) Therefore y = f (f -1 (y)). Meaning that: (f o f -1 )(y) = y. Sof o f -1 = id B

85 85 10. Multi-argument functions n In general, a function can take in more than 1 argument. f : (A x B)  C n Example: f : (Z x Z)  Z, where f(x,y) = 2x + 3y n f is a function: –Condition 1: Every element in (Z x Z) is mapped to some element in Z. –Condition 2: The mapping is a unqiue mapping: if f(x,y) = j and f(x,y) = k, then it must be true that j = k.

86 86 10. Multi-argument functions n Example: f : (Z x Z)  Z, where f(x,y) = 2x + 3y (0,0) (0,1) (1,0) (0,-1) 1 2 3 0 -2

87 87 10. Multi-argument functions n Multi-argument functions can be expressed as functions to functions. n Example: f : Z  (Z  Z), where f x y = 2x + 3y 0 1 2 0 1 0 3 -3 0 1 2 5

88 88 10. Multi-argument functions n Multi-argument functions can be expressed as functions to functions. n Example: f : Z  (Z  Z), where f x y = 2x + 3y The result of a applying a function to an argument is another function!!! Expressing multi-argument functions in this way is known as ‘currying’. Taught in courses on programming language theory

89 89 n End of Lecture


Download ppt "1 Annoucement n Skills you need: (1) (In Thinking) You think and move by Logic Definitions Mathematical properties (Basic algebra etc.) (2) (In Exploration)"

Similar presentations


Ads by Google