1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 7 Functions Instructor: Hayk Melikyan Today we will review sections 7.1 and 7.2.

Slides:



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

COUNTING AND PROBABILITY
Week 7 - Wednesday.  What did we talk about last time?  Set proofs and disproofs  Russell’s paradox.
Functions; Sequences, Sums, Countability
Functions, Pigeonhole Principle Lecture 14: Nov 4 A B f( ) =
Great Theoretical Ideas in Computer Science.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
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.
Functions f( ) = A B Lecture 15: Nov 4.
CHAPTER 4 Decidability Contents Decidable Languages
Pigeonhole.
Copyright © Cengage Learning. All rights reserved.
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,
Discrete Mathematics Lecture 7 Harper Langston New York University.
CS 2210 (22C:019) Discrete Structures Sets and Functions Spring 2015 Sukumar Ghosh.
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.
Cardinality of Sets Section 2.5.
Functions Definition & purpose Notation Functions on binary / returning binary values Finite automaton model We haven’t completely left the world of counting.
Foundations of Discrete Mathematics Chapter 3 By Dr. Dalia M. Gil, Ph.D.
Week 15 - Wednesday.  What did we talk about last time?  Review first third of course.
ICS 253: Discrete Structures I
1 Lecture 3 (part 3) Functions – Cardinality Reading: Epp Chp 7.6.
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.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
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.
Copyright © Cengage Learning. All rights reserved. CHAPTER 7 FUNCTIONS.
1 Annoucement n Skills you need: (1) (In Thinking) You think and move by Logic Definitions Mathematical properties (Basic algebra etc.) (2) (In Exploration)
Functions Reading: Chapter 6 (94 – 107) from the text book 1.
Basic Structures: Sets, Functions, Sequences, and Sums CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Functions Section 2.3. Section Summary Definition of a Function. – Domain, Cdomain – Image, Preimage Injection, Surjection, Bijection Inverse Function.
MATH 224 – Discrete Mathematics
COMPSCI 102 Introduction to Discrete Mathematics.
Mathematical Preliminaries
Basic Structures: Sets, Functions, Sequences, and Sums.
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.
Great Theoretical Ideas in Computer Science.
CompSci 102 Discrete Math for Computer Science February 7, 2012 Prof. Rodger Slides modified from Rosen.
1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 7 Functions Instructor: Hayk Melikyan Today we will review sections 7.3, 7.4 and 7.5.
Section 3.2: Sequences and Summations. Def: A sequence is a function from a subset of the set of integers (usually the set of natural numbers) to a set.
CS 285- Discrete Mathematics
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.
Functions CSRU1400 Spring 2008Ellen Zhang 1 CISC1400, Fall 2010 Ellen Zhang.
Pigeonhole Principle. If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons A function from one finite.
Week 7 - Wednesday.  What did we talk about last time?  Proving the subset relationship  Proving set equality  Set counterexamples  Laws of set algebra.
Section 2.5. Cardinality Definition: A set that is either finite or has the same cardinality as the set of positive integers (Z + ) is called countable.
FUNCTIONS.
Sequences Lecture 11. L62 Sequences Sequences are a way of ordering lists of objects. Java arrays are a type of sequence of finite size. Usually, mathematical.
Russell’s Paradox Is W in W? In words, W is the set that contains all the sets that don’t contain themselves. If W is in W, then W contains itself. But.
1-1 Copyright © 2013, 2005, 2001 Pearson Education, Inc. Section 2.4, Slide 1 Chapter 2 Sets and Functions.
Discrete Mathematics Lecture 6
Discrete Mathematics Lecture 3 (and 4)
The Acceptance Problem for TMs
Discrete Mathematics CS 2610
Functions 1.
CS 2210:0001 Discrete Structures Sets and Functions
Discrete Mathematics Lecture 7
2.4 Sequences and Summations
Cardinality of Sets Section 2.5.
Lecture 7 Functions.
Lesson 5 Relations, mappings, countable and uncountable sets
Lesson 5 Relations, mappings, countable and uncountable sets
SE-561 Math Foundations of Software Engineering VIII. Functions
Functions Rosen 2.3, 2.5 f( ) = A B Lecture 5: Oct 1, 2.
Cardinality Definition: The cardinality of a set A is equal to the cardinality of a set B, denoted |A| = |B|, if and only if there is a one-to-one correspondence.
Presentation transcript:

1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 7 Functions Instructor: Hayk Melikyan Today we will review sections 7.1 and 7.2

2 Melikyan/DM/Fall09 Generic Functions Definition: A function f from set X to a set Y is a relationship between elements of X to elements of Y, when each element from X is related to a unique element from Y. The notation f: X  Y means that f is a function from X to Y. X is called domain of f, and Y is called co-domain of f The range of f is a subset of Y so that for each element y of this subset there exists an element x from X such that y = f (x). range of f = { y  Y| y = f(x) for some x  X }(I like notation for range Im(f )) Sample functions: f : R  R, f(x) = x 2 f : Z  Z, f(x) = 2x + 1 f : Q  Z, f(x) = - 5

3 Melikyan/DM/Fall09 Generic Functions Arrow diagrams for functions is one of possible ways to define a function if the domain and co-domain of a such function is finite sets

4 Melikyan/DM/Fall09 Functions and Non-functions Identify: Which of the following arrow diagrams define a function from X = {a, b, c} to Y = {1, 2, 3, 4 }

5 Melikyan/DM/Fall09 Equality of functions: Definition: Two functions f and g from X to Y are said to be equal ( we write f = g) if f(x) = g (x) for all x  X Example : f(x) = |x| and g(x) = sqrt(x 2 ) Identity function For any set X we define a function i X : X  X as follows i X (x) =x for all x in X

6 Melikyan/DM/Fall09 More Examples of Functions 1. Sequences as functions 2. Functions with a domain of some language 3. Encoding and decoding of characters 4. Hamming distance function: number of differences between two encodings

7 Melikyan/DM/Fall09 Boolean Functions: Definition: An ( n-place) Boolean function f is any function from {0, 1} n to {0, 1} where {0, 1} n is the Cartesian product of n copies of the set {0, 1}. Thus f : {0, 1} n  {0, 1}

8 Melikyan/DM/Fall09 Example of Boolean function Consider 3-place Boolean function define as f (x 1, x 2, x 3 ) = (x 1 +x 2 +x 3 ) mod 2. Here is the input/output table for function f

9 Melikyan/DM/Fall09 Examples_1

10 Melikyan/DM/Fall09 Finite-State Automata (FSA) Two kind of circuits: combinatorial and sequential Boolean functions— combinatorial Finite state automation-- sequential Davit Hilbert-- Alan Turing

11 Melikyan/DM/Fall09 Definition of FSA Finite-state automata A is defined by 5 objects: –Set I of the input alphabet –Set S of automaton states –Designated initial state s 0 from S –Designated set of accepted states from S – Next-state function N: S  I  S that associates next state to the pair {current state, input symbol} Descriptions of finite-state automaton: –State-transition diagram –Next-state table

12 Melikyan/DM/Fall09 FSA by Transition Diagram s0s1 s

13 Melikyan/DM/Fall09 FSA by Next-State Table abc UZYY VVVV YZVY ZZZZ

14 Melikyan/DM/Fall09 FSA and Languages Let A be an FSA with an input alphabet I. The set of all strings w from I* such that A goes to accepting state on w is called a language accepted by A : L(A) (What is the language accepted by an automation 12)12 Eventual state-function N* : S  I*  S is a function that maps a pair {state, input string} to the state to which FSA would lead from the original state given the symbols in the input string as an input.

15 Melikyan/DM/Fall09 Designing FSA Design an FSA that accepts all strings of 0’s and 1’s such that the number of 1’s is divisible by 3 01 s0s0 s0s0 s1s1 s1s1 s1s1 s2s2 s2s2 s2s2 s0s0

16 Melikyan/DM/Fall09 Designing FSA_2 Design an FSA that accepts the set of strings that contain exactly one 1 Design an FSA with alphabet {a, b} which accepts strings that end on the same two characters Simulating an FSA using software

17 Melikyan/DM/Fall09 One-to-One Functions Definition : Function f : X  Y is called one-to-one (injective) when for all elements x 1 and x 2 from X if f(x 1 ) = f(x 2 ), then x 1 = x 2 A B

18 Melikyan/DM/Fall09 Not One_to_One

19 Melikyan/DM/Fall09 Examples : Determine whether the following functions are one-to-one ( on infinite set ) –f : R  R, f(x) = 4x – 1 –g : Z  Z, g(n) = n2 Hash functions (Applications)

20 Melikyan/DM/Fall09 Onto Functions Definition: Function f : X  Y is called onto (surjective) when given any element y from Y, there exists x in X so that f(x) = y Symbolically: f: X  Y is onto  (  y  Y,  x  X such that f(x) = y

21 Melikyan/DM/Fall09 Surjections (Onto) A B is a surjection iff every element of B is f of something f( ) =

22 Melikyan/DM/Fall09 Example: Determine whether the following functions are on_to –f : R  R, f(x) = 4x – 1 –f : Z  Z, g(n) = 4n – 1

23 Melikyan/DM/Fall09 Not Onto: Co-domain of function and range of function are not equal

24 Melikyan/DM/Fall09 Bijections A B is a bijection iff it is surjection and injection. f( ) = exactly one arrow in

25 Melikyan/DM/Fall09 FunctionDomainCodomainInjective?Subjective?Bijective? f(x)=sin(x)Real f(x)=2 x RealPositive real f(x)=x 2 RealPositive real Reverse string Bit strings of length n In-Class Exercises

26 Melikyan/DM/Fall09 Inverse Functions If f : X  Y is a bijective function, then it is possible to define an inverse function f -1 : Y  X so that f -1 (y) = x whenever f(x) = y Find an inverse for the following functions: –String-reverse function –f : R  R, f(x) = 4x – 1 Inverse function of a bijective function is a bijective function itself

27 Melikyan/DM/Fall09 Inverse Function Theorem Theorem: If f:X  Y is one-to=one and onto, then inverse function f-1 Y  X exists and is also one-to- one and onto. Let F: Z  Z  Z and G: Z  Z  Z, F(n, m) = 3 n 6 m and G(n, m) = 3 n 5 m. Is F one-to-one? Is G one-to-one?

28 Melikyan/DM/Fall09 Exercises Let c m,n be the number of onto functions from a set of m elements to a set of n elements. Find a relationship between c m,n, c m-1,n and c m-1,n-1

29 Melikyan/DM/Fall09 Composition of Functions Two functions f:X->Y’, g:Y->Z so that Y’ is a subset of Y, then the composition of f and g is the function g 。 f: X->Z, where g 。 f(x) = g(f(x)). X Y Z Y’

30 Melikyan/DM/Fall09 Example

31 Melikyan/DM/Fall09 Composition of Functions Let f : X  Y and g : Y  Z, let range of f be a subset of the domain of g. The we can define a composition of g o f : X  Z Let f, g : Z  Z, f(n) = n + 1, g(n) = n 2. Find f o g and g o f. Composition with identity function Composition with an inverse function Composition of two one-to-one functions is one-to-one Composition of two onto functions is onto

32 Melikyan/DM/Fall09 Pigeonhole Principle If n pigeons fly into m pigeonholes and n > m, then at least one hole must contain two or more pigeons

33 Melikyan/DM/Fall09 If more pigeons than pigeonholes, Pigeonhole Principle

34 Melikyan/DM/Fall09 Pigeonhole Principle then some hole must have at least two pigeons! Pigeonhole principle A function from a larger set to a smaller set cannot be one- to-one injective. (There must be at least two elements in the domain that havethe same image in the codomain.)

35 Melikyan/DM/Fall09 Examples: A function from one finite set to a smaller finite set cannot be one-to-one In a group of 13 people must there be at least two who have birthday in the same month? A drawer contains 10 black and 10 white socks. How many socks need to be picked to ensure that a pair is found? Let A = {1, 2, 3, 4, 5, 6, 7, 8}. If 5 integers are selected must at least one pair have sum of 9? There is no FSA that accepts the following language: L = {s = a k b k, for positive k}

36 Melikyan/DM/Fall09 Pigeonhole Principle Generalized Pigeonhole Principle : For any function f : X  Y acting on finite sets, if n(X) > k * n(Y), then there exists some y from Y so that there are at least k + 1 distinct x’s so that f(x) = y There are 42 students who are to share 12 computers. Each student uses exactly 1 computer and no computer is used by more than 6 students. Show that at least 5 computers are used by 3 or more students. Generalized Pigeonhole Principle( contrapositive form): For any function f : X  Y acting on finite sets and any positive integer k, if for each y  Y, f -1 (y) has at most k elements, then X has at most k * n(Y) elements

37 Melikyan/DM/Fall09 ♠ ♥ ♣ ♦ If n pigeons and h holes, then some hole has at least Cannot have < 3 cards in every hole. Generalized Pigeonhole Principle

38 Melikyan/DM/Fall09 Exercises Let f : X  Y and n(X) = n(Y), then f is bijective iff f is surjective Let A be a set of 6 integers less than 13. Show that there must be two distinct subsets of A whose sum of elements adds up to the same number Given 52 distinct integers, show that there must be two whose sum or difference is divisible by 100 Show that if 101 integers are chosen from 1 to 200 inclusive, there must be two with the property that one is divisible by the other Suppose a 1, a 2, …, a n is a sequence of n integers none of which is divisible by n. Show that at least one difference a i – a j is divisible by n

39 Melikyan/DM/Fall09 39 Cardinality and Countability Up to now cardinality has been the number of elements in a finite sets. Really, cardinality is a much deeper concept. Cardinality allows us to generalize the notion of number to infinite collections and it turns out that many type of infinities exist. EG: –{,  } –{, } –{Ø, {Ø,{Ø,{Ø}}} } These all share “2-ness”.

40 Melikyan/DM/Fall09 L640 Cardinality and Countability For finite sets, can just count the elements to get cardinality. Infinite sets are harder. First Idea: Can tell which set is bigger by seeing if one contains the other. –{1, 2, 4}  N –{0, 2, 4, 6, 8, 10, 12, …}  N So set of even numbers ought to be smaller than the set of natural number because of strict containment. Q: Any problems with this?

41 Melikyan/DM/Fall09 L641 Cardinality and Countability Set of even numbers is obtained from N by multiplication by 2. I.e. {even numbers} = 2 N For finite sets, since multiplication by 2 is a one-to-one function, the size doesn’t change. EG: {1,7,11} –  2  {2,14,22} Another problem: set of even numbers is disjoint from set of odd numbers. Which one is bigger?

42 Melikyan/DM/Fall09 L642 Cardinality and Countability – Finite Sets Definition: Two sets A and B have the same cardinality if there’s a bijection f : A  B For finite sets this is the same as the old definition: {,  } {, }

43 Melikyan/DM/Fall09 43 Cardinality and Countability – Infinite Sets Notation, the Hebrew letter Aleph is often used to denote infinite cardinalities. Countable sets are said to have cardinality. Intuitively, countable sets can be counted in the sense that if you allocate 1 second to count each member, eventually any particular member will be counted after a finite time period. Paradoxically, you won’t be able to count the whole set in a finite time period! Definition: If S is finite or has the same cardinality as N, S is called countable

44 Melikyan/DM/Fall09 L644 Countability – Examples Q: Why are the following sets countable? 1. {0,2,4,6,8,…} 2. {1,3,5,7,9,…} 1. {1,3,5,7, } 2. Z

45 Melikyan/DM/Fall09 L645 Countability – Examples 1. {0,2,4,6,8,…}: Just set up the bijection f ( n ) = 2 n 2. {1,3,5,7,9,…} : Because of the bijection f ( n ) = 2 n {1,3,5,7, } has cardinality 5 so is therefore countable 4. Z : This one is more interesting. Continue on next page:

46 Melikyan/DM/Fall09 46 Countability of the Integers Let’s try to set up a bijection between N and Z. One way is to just write a sequence down whose pattern shows that every element is hit (onto) and none is hit twice (one-to-one). The most common way is to alternate back and forth between the positives and negatives. I.e.: 0,1,-1,2,-2,3,-3,… It’s possible to write an explicit formula down for this sequence which makes it easier to check for bijectivity:

47 Melikyan/DM/Fall09 47 Demonstrating Countability. Useful Facts Because is the smallest kind of infinity, it turns out that to show that a set is countable one can either demonstrate an injection into N or a surjection from N. Theorem: Suppose A is a set. If there is an one-to-one function f : A  N, or there is an onto function g : N  A then A is countable. The proof requires the principle of mathematical induction.

48 Melikyan/DM/Fall09 48 Uncountability of R A: This is not a trivial matter. Here are some typical reasoning: 1. R strictly contains N so has bigger cardinality. What’s wrong with this argument 1. R contains infinitely many numbers between any two numbers. Surprisingly, this is not a valid argument. Q has the same property, yet is countable. 1. Many numbers in R are infinitely complex in that they have infinite decimal expansions. An infinite set with infinitely complex numbers should be bigger than N.

49 Melikyan/DM/Fall09 49 Uncountability of R Last argument is the closest. Here’s the real reason: Suppose that R were countable. In particular, any subset of R, being smaller, would be countable also. So the interval [0,1] would be countable. Thus it would be possible to find a bijection from Z + to [0,1] and hence list all the elements of [0,1] in a sequence. What would this list look like? r 1, r 2, r 3, r 4, r 5, r 6, r 7, …

50 Melikyan/DM/Fall09 L50 Uncountability of R Cantor’s Diabolical Diagonal So we have this list r 1, r 2, r 3, r 4, r 5, r 6, r 7, … supposedly containing every real number between 0 and 1. Cantor’s diabolical diagonalization argument will take this supposed list, and create a number between 0 and 1 which is not on the list. This will contradict the countability assumption hence proving that R is not countable.

51 Melikyan/DM/Fall09 51 Cantor's Diagonalization Argument r 1 0. r 2 0. r 3 0. r 4 0. r 5 0. r 6 0. r 7 0. : r evil 0.  Decimal expansions of r i 

52 Melikyan/DM/Fall09 L652 Cantor's Diagonalization Argument r r 2 0. r 3 0. r 4 0. r 5 0. r 6 0. r 7 0. : r evil 0.  Decimal expansions of r i 

53 Melikyan/DM/Fall09 L653 Cantor's Diagonalization Argument r r r 3 0. r 4 0. r 5 0. r 6 0. r 7 0. : r evil 0.  Decimal expansions of r i 

54 Melikyan/DM/Fall09 54 Cantor's Diagonalization Argument r r r r 4 0. r 5 0. r 6 0. r 7 0. : r evil 0.  Decimal expansions of r i 

55 Melikyan/DM/Fall09 55 Cantor's Diagonalization Argument r r r r r 5 0. r 6 0. r 7 0. : r evil 0.  Decimal expansions of r i 

56 Melikyan/DM/Fall09 L656 Cantor's Diagonalization Argument r r r r r r 6 0. r 7 0. : r evil 0.  Decimal expansions of r i 

57 Melikyan/DM/Fall09 L657 Cantor's Diagonalization Argument r r r r r r r 7 0. : r evil 0.  Decimal expansions of r i 

58 Melikyan/DM/Fall09 58 Cantor's Diagonalization Argument r r r r r r r : r evil 0.  Decimal expansions of r i 

59 Melikyan/DM/Fall09 L659 Cantor's Diagonalization Argument r r r r r r r : r evil  Decimal expansions of r i 

60 Melikyan/DM/Fall09 60 Uncountability of R Cantor’s Diabolical Diagonal GENERALIZE: To construct a number not on the list “ r evil ”, let r i,j be the j ’th decimal digit in the fractional part of r i. Define the digits of r evil by the following rule: The j ’th digit of r evil is 5 if r i,j  5. Otherwise the j ’ ’th digit is set to be 4. his guarantees that r evil is an anti-diagonal. I.e., it does not share any elements on the diagonal. But every number on the list contains a diagonal element. This proves that it cannot be on the list and contradicts our assumption that R was countable so the list must contain r evil. //QED

61 Melikyan/DM/Fall09 61 Impossible Computations Notice that the set of all bit strings is countable. Here’s how the list looks: 0,1,00,01,10,11,000,001,010,011,100,101,110,111,0000,… DEF: A decimal number 0. d 1 d 2 d 3 d 4 d 5 d 6 d 7 … Is said to be computable if there is a computer program that outputs a particular digit upon request. EG: … … ….

62 Melikyan/DM/Fall09 62 Impossible Computations Claim: There are numbers which cannot be computed by any computer. Proof : It is well known that every computer program may be represented by a bit-string (after all, this is how it’s stored inside). Thus a computer program can be thought of as a bit string. As there are bit-strings yet R is uncountable, there can be no onto function from computer programs to decimal numbers. In particular, most numbers do not correspond to any computer program so are incomputable!