Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 2.3: Set Theory, and Functions

Similar presentations


Presentation on theme: "Lecture 2.3: Set Theory, and Functions"— Presentation transcript:

1 Lecture 2.3: Set Theory, and Functions
CS 250, Discrete Structures, Fall 2013 Nitesh Saxena *Adopted from previous lectures by Cinda Heeren

2 Lecture 2.3 -- Set Theory, and Functions
Course Admin HW1 Provided the solution soon We have been grading Mid Term 1: Oct 8 (Tues) Review Oct 3 (Thu) Covers Chapter 1 and Chapter 2 HW2 coming out: early next week Due Oct 15 (Tues) 9/6/2011 Lecture Set Theory, and Functions

3 Lecture 2.3 -- Set Theory, and Functions
Outline Sets: Inclusion/Exclusion Principle Functions 9/6/2011 Lecture Set Theory, and Functions

4 A Proof (direct and indirect)
A  B =  Pv that if (A - B) U (B - A) = (A U B) then Suppose to the contrary, that A  B  , and that x  A  B. A U B =  A = B A  B =  A-B = B-A =  Then x cannot be in A-B and x cannot be in B-A. Then x is not in (A - B) U (B - A). But x is in A U B since (A  B)  (A U B). Thus, A  B = . 9/6/2011 Lecture Set Theory, and Functions

5 Set Theory - Inclusion/Exclusion
Example: How many people are wearing a watch? a How many people are wearing sneakers? b How many people are wearing a watch OR sneakers? a + b Wrong. What’s wrong? A B |A  B| = |A| + |B| - |A  B| 9/6/2011 Lecture Set Theory, and Functions

6 Set Theory - Inclusion/Exclusion
Example: There are 217 cs majors. 157 are taking cs125. 145 are taking cs173. 98 are taking both. How many are taking neither? 125 173 217 - ( ) = 13 9/6/2011 Lecture Set Theory, and Functions

7 Set Theory – Generalized Inclusion/Exclusion
Suppose we have: B A C Now let’s do it for 4 sets! And I want to know |A U B U C| kidding. |A U B U C| = |A| + |B| + |C| - |A  B| - |A  C| - |B  C| + |A  B  C| 9/6/2011 Lecture Set Theory, and Functions

8 Set Theory – Generalized Inclusion/Exclusion
* Image courtesy wikipedia

9 Lecture 2.3 -- Set Theory, and Functions
Suppose we have: -50 -25 And I ask you to describe the yellow function. What’s a function? y = f(x) = -(1/2)x - 25 Notation: f: RR, f(x) = -(1/2)x - 25 co-domain domain 9/6/2011 Lecture Set Theory, and Functions

10 Functions: Definitions
A function f : A B is given by a domain set A, a codomain set B, and a rule which for every element a of A, specifies a unique element f (a) in B f (a) is called the image of a, while a is called the pre-image of f (a) The range (or image) of f is defined by f (A) = {f (a) | a  A }. 9/6/2011 Lecture Set Theory, and Functions

11 Lecture 2.3 -- Set Theory, and Functions
Function or not? A B B A 9/6/2011 Lecture Set Theory, and Functions

12 Lecture 2.3 -- Set Theory, and Functions
Functions: examples Ex: Let f : Z  R be given by f (x ) = x 2 Q1: What are the domain and co-domain? Q2: What’s the image of -3 ? Q3: What are the pre-images of 3, 4? Q4: What is the range f ? 9/6/2011 Lecture Set Theory, and Functions

13 Lecture 2.3 -- Set Theory, and Functions
Functions: examples f : Z  R is given by f (x ) = x 2 A1: domain is Z, co-domain is R A2: image of -3 = f (-3) = 9 A3: pre-images of 3: none as 3 isn’t an integer! pre-images of 4: -2 and 2 A4: range is the set of perfect squares = {0,1,4,9,16,25,…} 9/6/2011 Lecture Set Theory, and Functions

14 Lecture 2.3 -- Set Theory, and Functions
Functions: examples A = {Michael, Tito, Janet, Cindy, Bobby} B = {Katherine Scruse, Carol Brady, Mother Teresa} Let f: A  B be defined as f(a) = mother(a). Michael Tito Janet Cindy Bobby Katherine Scruse Carol Brady Mother Teresa 9/6/2011 Lecture Set Theory, and Functions

15 Functions - image set For any set S  A, image(S) = {f(a) : a  S}
image(S) = f(S) For any set S  A, image(S) = {f(a) : a  S} So, image({Michael, Tito}) = {Katherine Scruse} image(A) = B - {Mother Teresa} Michael Tito Janet Cindy Bobby Katherine Scruse Carol Brady Mother Teresa image(A) is also called range 9/6/2011 Lecture Set Theory, and Functions

16 Functions – preimage set
For any S  B, preimage(S) = {a  A: f(a)  S} So, preimage({Carol Brady}) = {Cindy, Bobby} preimage(B) = A preimage(S) = f-1(S) Michael Tito Janet Cindy Bobby Katherine Scruse Carol Brady Mother Teresa 9/6/2011 Lecture Set Theory, and Functions

17 Every b  B has at most 1 preimage.
Functions - injection A function f: A  B is one-to-one (injective, an injection) if a,b,c, (f(a) = b  f(c) = b)  a = c Not one-to-one Michael Tito Janet Cindy Bobby Katherine Scruse Carol Brady Mother Teresa 9/6/2011 Lecture Set Theory, and Functions

18 Functions - surjection
Every b  B has at least 1 preimage. Functions - surjection A function f: A  B is onto (surjective, a surjection) if b  B, a  A, f(a) = b Not onto Michael Tito Janet Cindy Bobby Katherine Scruse Carol Brady Mother Teresa 9/6/2011 Lecture Set Theory, and Functions

19 Functions - bijection A function f: A  B is bijective if it is one-to-one and onto. Every b  B has exactly 1 preimage. A B C D A- Alice Bob Tom Charles Eve Isaak Bri Lynette Aidan Evan Cinda Dee Deb Katrina Dawn An important implication of this characteristic: The preimage (f-1) is a function! 9/6/2011 Lecture Set Theory, and Functions

20 Lecture 2.3 -- Set Theory, and Functions
Functions - examples Suppose f: R+  R+, f(x) = x2. Is f one-to-one? Is f onto? Is f bijective? yes yes yes 9/6/2011 Lecture Set Theory, and Functions

21 Lecture 2.3 -- Set Theory, and Functions
Functions - examples Suppose f: R  R+, f(x) = x2. Is f one-to-one? Is f onto? Is f bijective? no yes no 9/6/2011 Lecture Set Theory, and Functions

22 Lecture 2.3 -- Set Theory, and Functions
Functions - examples Suppose f: R  R, f(x) = x2. Is f one-to-one? Is f onto? Is f bijective? no no no 9/6/2011 Lecture Set Theory, and Functions

23 Lecture 2.3 -- Set Theory, and Functions
Functions - examples Q: Which of the following are 1-to-1, onto, a bijection? If f is invertible, what is its inverse? f : Z  R is given by f (x ) = x 2 f : Z  R is given by f (x ) = 2x f : R  R is given by f (x ) = x 3 f : Z  N is given by f (x ) = |x | f : {people}  {people} is given by f (x ) = the father of x. 9/6/2011 Lecture Set Theory, and Functions

24 Lecture 2.3 -- Set Theory, and Functions
Functions - examples f : Z  R, f (x ) = x 2: none f : Z  Z, f (x ) = 2x : 1-1 f : R  R, f (x ) = x 3: 1-1, onto, bijection, inverse is f (x ) = x (1/3) f : Z  N, f (x ) = |x |: onto f (x ) = the father of x : none 9/6/2011 Lecture Set Theory, and Functions

25 Lecture 2.3 -- Set Theory, and Functions
Today’s Reading Rosen 2.3 and 2.4 9/6/2011 Lecture Set Theory, and Functions


Download ppt "Lecture 2.3: Set Theory, and Functions"

Similar presentations


Ads by Google