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

Slides:



Advertisements
Similar presentations
Functions Reading: Epp Chp 7.1, 7.2, 7.4
Advertisements

1.6 Functions. Chapter 1, section 6 Functions notation: f: A B x in A, y in B, f(x) = y. concepts: –domain of f, –codomain of f, –range of f, –f maps.
Functions Section 2.3 of Rosen Fall 2008
Terminology Domain: set which holds the values to which we apply the function Co-domain: set which holds the possible values (results) of the function.
Discrete Mathematics Lecture 7 Alexander Bukharovich New York University.
Discrete Structures Chapter 5 Relations and Functions
Terminology Domain: set which holds the values to which we apply the function Co-domain: set which holds the possible values (results) of the function.
Functions f( ) = A B Lecture 15: Nov 4.
Functions Goals Introduce the concept of function Introduce injective, surjective, & bijective functions.
1 Section 1.8 Functions. 2 Loose Definition Mapping of each element of one set onto some element of another set –each element of 1st set must map to something,
Functions.
Chapter 7 Functions Dr. Curry Guinn. Outline of Today Section 7.1: Functions Defined on General Sets Section 7.2: One-to-One and Onto Section 7.3: The.
1 CMSC 250 Chapter 7, Functions. 2 CMSC 250 Function terminology l A relationship between elements of two sets such that no element of the first set is.
Section 1.8: Functions A function is a mapping from one set to another that satisfies certain properties. We will first introduce the notion of a mapping.
Functions A B f( ) =. This Lecture We will define a function formally, and then in the next lecture we will use this concept in counting. We will also.
Sets Set Operations Functions. 1. Sets 1.1 Introduction and Notation 1.2 Cardinality 1.3 Power Set 1.4 Cartesian Products.
2.1 Sets 2.2 Set Operations 2.3 Functions ‒Functions ‒ Injections, Surjections and Bijections ‒ Inverse Functions ‒Composition 2.4 Sequences and Summations.
FUNCTION Discrete Mathematics Asst. Prof. Dr. Choopan Rattanapoka.
Relations and Functions Another Foundational Concept Copyright © 2014 – Curt Hill.
Mathematics. Session Set, Relation & Function Session - 3.
A Brief Summary for Exam 1 Subject Topics Propositional Logic (sections 1.1, 1.2) –Propositions Statement, Truth value, Proposition, Propositional symbol,
February 12, 2015Applied Discrete Mathematics Week 2: Functions and Sequences 1Exercises Question 1: Given a set A = {x, y, z} and a set B = {1, 2, 3,
Functions. Copyright © Peter Cappello2 Definition Let D and C be nonempty sets. A function f from D to C, for each element d  D, assigns exactly 1 element.
Week 7 - Friday.  What did we talk about last time?  Set disproofs  Russell’s paradox  Function basics.
An ordered n-tuple is a set of n objects with an order associated with them. If n objects are represented by x 1, x 2,..., x n, then we write the ordered.
Part B Set Theory What is a set? A set is a collection of objects. Can you give me some examples?
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
Fall 2002CMSC Discrete Structures1 … and the following mathematical appetizer is about… Functions.
10/26/20151 … and the following mathematical appetizer is about… Functions.
FUNCTIONS.
Discrete Mathematics CS 2610 September 12, Agenda Last class Functions  Vertical line rule  Ordered pairs  Graphical representation  Predicates.
Functions Section 2.3 of Rosen Spring 2012 CSCE 235 Introduction to Discrete Structures Course web-page: cse.unl.edu/~cse235 Questions: Use Piazza.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
Functions1 Elementary Discrete Mathematics Jim Skon.
Example Prove that: “IF 3n + 2 is odd, then n is odd” Proof by Contradiction: -p = 3n + 2 is odd, q = n is odd. -Assume that ~(p  q) is true OR -(p 
Functions Reading: Chapter 6 (94 – 107) from the text book 1.
Basic Structures: Functions Muhammad Arief download dari
Sets Define sets in 2 ways  Enumeration  Set comprehension (predicate on membership), e.g., {n | n  N   k  k  N  n = 10  k  0  n  50} the set.
Agenda Week 10 Lecture coverage: –Functions –Types of Function –Composite function –Inverse of a function.
What is a set? A set is a collection of objects.
Discrete Mathematics R. Johnsonbaugh
Discrete Mathematics Relation.
Sets. Definitions (I) Collection of elements such that: There are no duplicates There is no order Special sets Universe (U or E): all elements under consideration.
Basic Structures: Sets, Functions, Sequences, and Sums.
1 Discrete and Combinatorial Mathematics R. P. Grimaldi, 5 th edition, 2004 Chapter 5 Relations and Functions.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
Discrete Mathematics CS 2610 February 10, Agenda Previously Functions And now Finish functions Start Boolean algebras (Sec. 11.1)
FUNCTIONS COSC-1321 Discrete Structures 1. Function. Definition Let X and Y be sets. A function f from X to Y is a relation from X to Y with the property.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Functions CSRU1400 Spring 2008Ellen Zhang 1 CISC1400, Fall 2010 Ellen Zhang.
DEFINITION A function f : A  B is onto B (called a surjection) iff Rng(f) = B. We write f : A  B to indicate that f is a surjection. Look at the illustration.
1 Lecture 5 Functions. 2 Functions in real applications Curve of a bridge can be described by a function Converting Celsius to Fahrenheit.
Section 2.3. Section Summary  Definition of a Function. o Domain, Cdomain o Image, Preimage  One-to-one (Injection), onto (Surjection), Bijection 
Chapter 2 1. Chapter Summary Sets The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions and sequences.
FUNCTIONS.
Discrete Mathematics Lecture # 17 Function. Relations and Functions  A function F from a set X to a set Y is a relation from X to Y that satisfies the.
Functions Goals Introduce the concept of function
Applied Discrete Mathematics Week 2: Functions and Sequences
Chapter 2 Sets and Functions.
Functions Section 2.3.
CS201: Data Structures and Discrete Mathematics I
Lecture 7 Functions.
Functions.
Functions Rosen 2.3, 2.5 f( ) = A B Lecture 5: Oct 1, 2.
Functions.
Lecture # 18 Types of Functions
Functions Section 2.3.
REVISION Relation. REVISION Relation Introduction to Relations and Functions.
Presentation transcript:

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 Lecture 3 (part 1) Functions Reading: Epp Chp 7.1, 7.3, 7.5

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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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  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 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 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 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 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 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 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 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 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 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 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 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 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 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

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! )

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

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)

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

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 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 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.

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)

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.

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.

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)

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

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  .

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).

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

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)

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))

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.

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)

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.

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 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 9. Special Kinds of functions n Three types of functions: –Injective (1-1) –Surjective (onto) –Bijective (1-1 correspondence)

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

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.

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

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)

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:

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:

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

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 F(0) = F(-1) but 0  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

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)

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

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:

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. ?

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?

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

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.

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?  y  B,  x  A, f(x)  y. Take y = 0. Q: Is f a surjection? A: No.

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

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

Bijective Functions n Application: –Cardinality (Next lecture)

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)

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.

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

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.

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.)

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

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

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)

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.

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

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

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.

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

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

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 n End of Lecture