Functions and Inverses
Total Page:16
File Type:pdf, Size:1020Kb
Functions and Inverses CS 2800: Discrete Structures, Spring 2015 Sid Chaudhuri Recap: Relations and Functions ● A relation between sets A !the domain) and B !the codomain" is a set of ordered pairs (a, b) such that a ∈ A, b ∈ B !i.e. it is a subset o# A × B" Cartesian product – The relation maps each a to the corresponding b ● Neither all possible a%s, nor all possible b%s, need be covered – Can be one-one, one&'an(, man(&one, man(&man( Alice CS 2800 Bob A Carol CS 2110 B David CS 3110 Recap: Relations and Functions ● ) function is a relation that maps each element of A to a single element of B – Can be one-one or man(&one – )ll elements o# A must be covered, though not necessaril( all elements o# B – Subset o# B covered b( the #unction is its range/image Alice Balch Bob A Carol Jameson B David Mews Recap: Relations and Functions ● Instead of writing the #unction f as a set of pairs, e usually speci#y its domain and codomain as: f : A → B * and the mapping via a rule such as: f (Heads) = 0.5, f (Tails) = 0.5 or f : x ↦ x2 +he function f maps x to x2 Recap: Relations and Functions ● Instead of writing the #unction f as a set of pairs, e usually speci#y its domain and codomain as: f : A → B * and the mapping via a rule such as: f (Heads) = 0.5, f (Tails) = 0.5 2 or f : x ↦ x f(x) ● Note: the function is f, not f(x), – f(x) is the value assigned b( f the #unction f to input x x Recap: Injectivity ● ) function is injective (one-to-one) if every element in the domain has a unique i'age in the codomain – +hat is, f(x) = f(y) implies x = y Albany NY New York A MA Sacramento B CA Boston ... ... Recap: Surjectivity ● ) function if surjective (onto) if every element of the codomain has a prei'age in the domain – +hat is, for every b ∈ B there is some a ∈ A such that f(a) = b – +hat is, the codomain is equal to the range/image August September October November Autumn December January Winter A February B March Spring April Summer May June July Recap: Surjectivity ● ) function if surjective (onto) if every element of the codomain has a prei'age in the domain – +hat is, for every b ∈ B there is some a ∈ A such that f(a) = b – +hat is, the codomain is equal to the range/image August September (Ithaca etc) October November Almost Winter December January Winter A February B March Still Winter April Road Construction May June July Recap: 0ijectivity ● ) function is bijective if it is both surjective and injective January 1 February 2 March 3 April 4 May 5 June 6 A July 7 B August 8 September 9 October 10 November 11 December 12 Composition o# Functions ● +he composition o# t o #unctions f : B → C g : A → B is the function f ○ g : A → C de1ned as f ○ g : x ↦ f ( g (x) ) g x 1 f Even y 2 Odd z 3 A B C Composition o# Functions ● +he composition o# t o #unctions f : B → C g ○ f is not possible g : A → B unless A = C ! is the function f ○ g : A → C de1ned as f ○ g : x ↦ f ( g (x) ) x f ○ g Even y Odd z A C Factoid o# the Day 21 Composition is associative (f ○ g) ○ h = f ○ (g ○ h) (two functions are equal if for every input, they give the same output) Prove it! h x 1 g Even f True y 2 False z 3 Odd A B C D 3e#t Inverse o# a Function ● g : B → A is a left inverse of f : A → B i# g ( f (a) ) = a for all a ∈ A – If you follo the function from the domain to the codomain, the left inverse tells you ho to go back to here you started f a f(a) A B 3e#t Inverse o# a Function ● g : B → A is a left inverse of f : A → B i# g ( f (a) ) = a for all a ∈ A – If you follo the function from the domain to the codomain, the left inverse tells you ho to go back to here you started f a f(a) A 5 B 3e#t Inverse o# a Function ● g : B → A is a left inverse of f : A → B i# g ( f (a) ) = a for all a ∈ A – If you follo the function from the domain to the codomain, the left inverse tells you ho to go back to here you started f a f(a) g A B Right Inverse o# a Function ● h : B → A is a right inverse of f : A → B i# f ( h (b) ) = b for all b ∈ B – If you're trying to get to a destination in the codomain, the right inverse tells you a possible place to start b A B Right Inverse o# a Function ● h : B → A is a right inverse of f : A → B i# f ( h (b) ) = b for all b ∈ B – If you're trying to get to a destination in the codomain, the right inverse tells you a possible place to start f 5 b A B Right Inverse o# a Function ● h : B → A is a right inverse of f : A → B i# f ( h (b) ) = b for all b ∈ B – If you're trying to get to a destination in the codomain, the right inverse tells you a possible place to start h(b) b h A B Right Inverse o# a Function ● h : B → A is a right inverse of f : A → B i# f ( h (b) ) = b for all b ∈ B – If you're trying to get to a destination in the codomain, the right inverse tells you a possible place to start f h(b) b h A B 6ote the subtle difference, ● +he left inverse tells (ou ho to exactly retrace (our steps, if (ou 'anaged to get to a destination – “Some places might be unreachable, but I can al a(s put (ou on the return 8ight” ● +he right inverse tells (ou here (ou might have come from, #or any possible destination – :)ll places are reachable, but I can%t put (ou on the return 8ight because I don%t 4no e;actl( here (ou came #ro'9 Factoid o# the Day 22 3eft and right inverses need not e;ist, and need not be uni.ue Can you come up with some examples? 3e#t inverse ⇔ Injective ● Theorem: ) function is injective !one-to-one) i7 it has a left inverse ● Proof (⇐): )ssume f : A → B has left inverse g – If f(x) = f(y) ... – … then g(f(x)) = g(f(y)) !any fn maps equals to equals" – … i.e. x = y !since g is a left inverse" – <ence f is injective 3e#t inverse ⇔ Injective ● Theorem: ) function is injective !one-to-one) i7 it has a left inverse ● Proof (⇒): )ssume f : A → B is injective – =ick any a0 in A, and defineg as a if f(a) = b g(b) = a0 otherwise – +his is a well-defined function: since f is injective, there can be at most a single a such that f(a) = b – )lso, if f(a) = b then g(f(a)) = a, by construction – <ence g is a left inverse of f Right inverse ⇔ Surjective ● Theorem: ) function is surjective !onto) i7 it has a right inverse ● Proof (⇐): )ssume f : A → B has right inverse h – For any b ∈ B, we can apply h to it to get h(b) – Since h is a right inverse, f(h(b)) = b – +herefore every element of B has a preimage in A – <ence f is sur-ective Right inverse ⇔ Surjective ● Theorem: ) function is surjective !onto) i7 it has a right inverse ● Proof (⇒): )ssume f : A → B is surjective – For every b ∈ B, there is a non-empty set Ab ⊆ A such that for every a ∈ Ab, f(a) = b !since f is surjective) – Define h : b ↦ an arbitrary element of Ab – )gain, this is a well-defined function since Ab is non‑empty (and assuming the “axiom of choice”," – )lso, f(h(b)) = b for all b ∈ B, by construction – <ence h is a right inverse of f Recap: 3e#t and Right Inverses ● ) function is injective !one-to-one) i7 it has a left inverse ● ) function is surjective (onto) i7 it has a right inverse Factoid #or the Day 2? If a function has both a left inverse and a right inverse, then the t o inverses are identical, and this com'on inverse is unique (Prove!) +his is called the two-sided inverse, or usually just the inverse f –1 of the function f http:// .cs.cornell.edu/courses/cs2800/2015sp/handouts/-onpa4@function_notes.pdf 0ijection and two-sided inverse ● ) function f is bijective i7 it has a t o-sided inverse ● Proof (⇒): If it is bijective, it has a left inverse !since injective) and a right inverse (since surjective), which must be one and the sa'e by the previous factoid ● Proof (⇐): If it has a t o-sided inverse, it is both injective (since there is a left inverse) and surjective (since there is a right inverse). <ence it is bijective..