Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week 7 - Friday.  What did we talk about last time?  Set disproofs  Russell’s paradox  Function basics.

Similar presentations


Presentation on theme: "Week 7 - Friday.  What did we talk about last time?  Set disproofs  Russell’s paradox  Function basics."— Presentation transcript:

1 Week 7 - Friday

2  What did we talk about last time?  Set disproofs  Russell’s paradox  Function basics

3

4  A man has two 10 gallon jars  The first contains 6 gallons of wine and the second contains 6 gallons of water  He poured 3 gallons of wine into the water jar and stirred  Then he poured 3 gallons of the mixture in the water jar into the wine jar and stirred  Then he poured 3 gallons of the mixture in the wine jar into the water jar and stirred  He continued the process until both jars had the same concentration of wine  How many pouring operations did he do?

5

6  A function f from set X to set Y is a relation between elements of X (inputs) and elements of Y (outputs) such that each input is related to exactly one output  We write f: X  Y to indicate this  X is called the domain of f  Y is called the co-domain of f  The range of f is { y  Y | y = f(x), for some x  X}  The inverse image of y is { x  X | f(x) = y }

7  Using standard assumptions, consider f(x) = x 2  What is the domain?  What is the co-domain?  What is the range?  What is f(3.2)?  What is the inverse image of 4?  Assume that the set of positive integers is the domain and co-domain  What is the range?  What is f(3.2)?  What is the inverse image of 4?

8  With finite domains and co-domains, we can define a function using an arrow diagram  What is the domain?  What is the co-domain?  What are f(a), f(b), and f(c)?  What is the range?  What are the inverse images of 1, 2, 3, and 4?  Represent f as a set of ordered pairs abcabc abcabc 12341234 12341234 XYf

9  Which of the following are functions from X to Y? abcabc abcabc 12341234 12341234 XYf abcabc abcabc 12341234 12341234 XYg abcabc abcabc 12341234 12341234 XYh

10  Given two functions f and g from X to Y,  f equals g, written f = g, iff:  f(x) = g(x) for all x  X  Let f(x) = |x| and g(x) =  Does f = g?  Let f(x) = x and g(x) = 1/(1/x)  Does f = g?

11  Functions can be defined from any well- defined set to any other  There is an identity function from any set to itself  We can represent a sequence as a function from a range of integers to the values of the sequence  We can create a function mapping from sets to integers, for example, giving the cardinality of certain sets

12  You should know this already  But, this is the official place where it should be covered formally  There is a function called the logarithm with base b of x defined from R + - {1} to R as follows:  log b x = y  b y = x

13  For a function of multiple values, we can define its domain to be the Cartesian product of sets  Let S n be strings of 1's and 0's of length n  An important CS concept is Hamming distance  Hamming distance takes two binary strings of length n and gives the number of places where they differ  Let Hamming distance be H: S n x S n  Z nonneg  What is H(00101, 01110)?  What is H(10001, 01111)?

14  There are two ways in which a function can be poorly defined  It does not provide a mapping for every value in the domain  Example: f: R  R such that f(x) = 1/x  It provides more than one mapping for some value in the domain  Example: f: Q  Z such that f(m/n) = m, where m and n are the integers representing the rational number

15  Let F be a function from X to Y  F is one-to-one (or injective) if and only if:  If F(x 1 ) = F(x 2 ) then x 1 = x 2  Is f(x) = x 2 from Z to Z one-to-one?  Is f(x) = x 2 from Z + to Z one-to-one?  Is h(x) one-to-one? abcabc abcabc 12341234 12341234 XYh

16  To prove that f from X to Y is one-to-one, prove that  x 1, x 2  X, f(x 1 ) = f(x 2 )  x 1 = x 2  To disprove, just find a counter example  Prove that f: R  R defined by f(x) = 4x – 1 is one-to-one  Prove that g: Z  Z defined by g(n) = n 2 is not one-to-one

17  Let F be a function from X to Y  F is onto (or surjective) if and only if:   y  Y,  x  X such that F(x) = y  Is f(x) = x 2 from Z to Z onto?  Is f(x) = x 2 from R + to R + onto?  Is h(x) onto? abcabc abcabc 123123 123123 XYh

18  If a function F: X  Y is both one-to-one and onto (bijective), then there is an inverse function F -1 : Y  X such that:  F -1 (y) = x  F(x) = y, for all x  X and y  Y

19

20  If there are two functions f: A  B and g: Y  Z such that the range of f is a subset of the domain of g, we can define a new function g o f: A  Z such that  (g o f)(x) = g(f(x)), for all x  A

21  As before, we can show these functions for finite sets using arrow diagrams  What's the arrow diagram for (g o f)(x)? 123123 123123 e e xyzxyz xyzxyz abcdabcd abcdabcd f g

22  The identity function (on set X) maps elements from set X to themselves  Thus, the identity function i x : X  X is:  i X (x) = x  For functions f: X  Y and g: Y  X  What is (f o i X )(x)?  What is (i X 0 g)(x)?

23  If functions f: X  Y and g: Y  Z are both one-to-one, then g o f is one-to-one  If functions f: X  Y and g: Y  Z are both onto, then g o f is onto  How would you go about proving these claims?

24  If f: X  Y is one-to-one and onto with inverse function f -1 : Y  X, then  What is f -1 o f?  What is f o f -1 ?

25 Student Lecture

26

27  If n pigeons fly into m pigeonholes, where n > m, then there is at least one pigeonhole with two or more pigeons in it  More formally, if a function has a larger domain than co-domain, it cannot be one-to-one  We cannot say exactly how many pigeons are in any given holes  Some holes may be empty  But, at least one hole will have at least two pigeons

28  A sock drawer has white socks, black socks, and red argyle socks, all mixed together,  What is the smallest number of socks you need to pull out to be guaranteed a matching pair?  Let A = {1, 2, 3, 4, 5, 6, 7, 8}  If you select five distinct elements from A, must it be the case that some pair of integers from the five you selected will sum to 9?

29  If n pigeons fly into m pigeonholes, and for some positive integer k, n > km, then at least one pigeonhole contains k + 1 or more pigeons in it  Example:  In a group of 85 people, at least 4 must have the same last initial

30

31  Cardinality gives the number of things in a set  Cardinality is:  Reflexive: A has the same cardinality as A  Symmetric: If A has the same cardinality as B, B has the same cardinality as A  Transitive: If A has the same cardinality as B, and B has the same cardinality as C, A has the same cardinality as C  For finite sets, we could just count the things to determine if two sets have the same cardinality

32  Because we can't just count the number of things in infinite sets, we need a more general definition  For any sets A and B, A has the same cardinality as B iff there is a bijective mapping A to B  Thus, for any element in A, it corresponds to exactly one element in B, and everything in B has exactly one corresponding element in A

33  Show that the set of positive integers has the same cardinality as the set of all integers  Hint: Create a bijective function from all integers to positive integers  Hint 2: Map the positive integers to even integers and the negative integers to odd integers

34  A set is called countably infinite if it has the same cardinality as Z +  You have just shown that Z is countable  It turns out that (positive) rational numbers are countable too, because we can construct a table of their values and move diagonally across it, numbering values, skipping numbers that have been listed already 1/11/21/31/4 2/12/22/32/4 3/13/23/33/4 4/14/24/34/4

35  We showed that positive rational numbers were countable, but a trick similar to the one for integers can show that all rational numbers are countable  The book gives a classic proof that real numbers are not countable, but we don't have time to go through it  For future reference, the cardinality of positive integers, countable infinity, is named  0 (pronounced aleph null)  The cardinality of real numbers, the first uncountable infinity (because there are infinitely many uncountable infinities), is named  1 (pronounced aleph 1)

36

37  Relations (after Spring Break)  Exam 2 is the Monday after the Monday after Spring Break

38  Work on Homework 5  Due on Monday after Spring Break  Look at Homework 6  Read Chapter 8 for after Spring Break


Download ppt "Week 7 - Friday.  What did we talk about last time?  Set disproofs  Russell’s paradox  Function basics."

Similar presentations


Ads by Google