250 likes | 334 Views
Lecture 2.3: Set Theory, and Functions. CS 250, Discrete Structures, Fall 2013 Nitesh Saxena * Adopted from previous lectures by Cinda Heeren. 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
E N D
Lecture 2.3: Set Theory, and Functions CS 250, Discrete Structures, Fall 2013 Nitesh Saxena *Adopted from previous lectures by Cinda Heeren
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) Lecture 2.3 -- Set Theory, and Functions
Outline • Sets: Inclusion/Exclusion Principle • Functions Lecture 2.3 -- Set Theory, and Functions
A U B = • A = B • A B = • A-B = B-A = 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. 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 = . Lecture 2.3 -- Set Theory, and Functions
B A Wrong. 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 What’s wrong? |A B| = |A| + |B| - |A B| Lecture 2.3 -- Set Theory, and Functions
125 173 217 - (157 + 145 - 98) = 13 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? Lecture 2.3 -- Set Theory, and Functions
Now let’s do it for 4 sets! kidding. Set Theory – Generalized Inclusion/Exclusion Suppose we have: B A C And I want to know |A U B U C| |A U B U C| = |A| + |B| + |C| - |A B| - |A C| - |B C| + |A B C| Lecture 2.3 -- Set Theory, and Functions
Set Theory – Generalized Inclusion/Exclusion * Image courtesy wikipedia
y = f(x) = -(1/2)x - 25 domain co-domain Functions Suppose we have: -50 -25 And I ask you to describe the yellow function. What’s a function? Notation: f: RR, f(x) = -(1/2)x - 25 Lecture 2.3 -- Set Theory, and Functions
Functions: Definitions A function f : A Bis 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}. Lecture 2.3 -- Set Theory, and Functions
B A Function or not? B A 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 ? 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,…} Lecture 2.3 -- Set Theory, and Functions
Michael Tito Janet Cindy Bobby Katherine Scruse Carol Brady Mother Teresa 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). Lecture 2.3 -- Set Theory, and Functions
Michael Tito Janet Cindy Bobby Katherine Scruse Carol Brady Mother Teresa image(A) is also called range image(S) = f(S) Functions - image set For any set S A, image(S) = {f(a) : a S} So, image({Michael, Tito}) = {Katherine Scruse} image(A) = B - {Mother Teresa} Lecture 2.3 -- Set Theory, and Functions
Michael Tito Janet Cindy Bobby Katherine Scruse Carol Brady Mother Teresa preimage(S) = f-1(S) Functions – preimage set For any S B, preimage(S) = {a A: f(a) S} So, preimage({Carol Brady}) = {Cindy, Bobby} preimage(B) = A Lecture 2.3 -- Set Theory, and Functions
Michael Tito Janet Cindy Bobby Katherine Scruse Carol Brady Mother Teresa Not one-to-one 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 Lecture 2.3 -- Set Theory, and Functions
Michael Tito Janet Cindy Bobby Katherine Scruse Carol Brady Mother Teresa Not onto 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 Lecture 2.3 -- Set Theory, and Functions
Isaak Bri Lynette Aidan Evan Alice Bob Tom Charles Eve Cinda Dee Deb Katrina Dawn A B C D A- Every b B has exactly 1 preimage. An important implication of this characteristic: The preimage (f-1) is a function! Functions - bijection A function f: A B is bijective if it is one-to-one and onto. Lecture 2.3 -- Set Theory, and Functions
yes yes yes Functions - examples Suppose f: R+ R+, f(x) = x2. Is f one-to-one? Is f onto? Is f bijective? Lecture 2.3 -- Set Theory, and Functions
no yes no Functions - examples Suppose f: R R+, f(x) = x2. Is f one-to-one? Is f onto? Is f bijective? Lecture 2.3 -- Set Theory, and Functions
no no no Functions - examples Suppose f: R R, f(x) = x2. Is f one-to-one? Is f onto? Is f bijective? 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. 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 Lecture 2.3 -- Set Theory, and Functions
Today’s Reading • Rosen 2.3 and 2.4 Lecture 2.3 -- Set Theory, and Functions