Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 7 Functions Instructor: Hayk Melikyan Today we will review sections 7.1 and 7.2."— Presentation transcript:

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

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 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 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 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 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 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 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 9 Melikyan/DM/Fall09 Examples_1

10 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 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 12 Melikyan/DM/Fall09 FSA by Transition Diagram s0s1 s2 1 1 1 0 0 0

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

14 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 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 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 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 18 Melikyan/DM/Fall09 Not One_to_One

19 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 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 21 Melikyan/DM/Fall09 Surjections (Onto) A B is a surjection iff every element of B is f of something f( ) =

22 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 23 Melikyan/DM/Fall09 Not Onto: Co-domain of function and range of function are not equal

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

25 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 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 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 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 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 30 Melikyan/DM/Fall09 Example

31 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 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 33 Melikyan/DM/Fall09 If more pigeons than pigeonholes, Pigeonhole Principle

34 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 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 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 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 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 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 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 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 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 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 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 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. {1,3,5,7, } has cardinality 5 so is therefore countable 4. Z : This one is more interesting. Continue on next page:

46 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 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 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 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 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 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 52 Melikyan/DM/Fall09 L652 Cantor's Diagonalization Argument r 1 0.1234567 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 53 Melikyan/DM/Fall09 L653 Cantor's Diagonalization Argument r 1 0.1234567 r 2 0.1111111 r 3 0. r 4 0. r 5 0. r 6 0. r 7 0. : r evil 0.  Decimal expansions of r i 

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

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

56 56 Melikyan/DM/Fall09 L656 Cantor's Diagonalization Argument r 1 0.1234567 r 2 0.1511111 r 3 0.2542090 r 4 0.7890623 r 5 0.0110101 r 6 0. r 7 0. : r evil 0.  Decimal expansions of r i 

57 57 Melikyan/DM/Fall09 L657 Cantor's Diagonalization Argument r 1 0.1234567 r 2 0.1511111 r 3 0.2542090 r 4 0.7890623 r 5 0.0110101 r 6 0.5555555 r 7 0. : r evil 0.  Decimal expansions of r i 

58 58 Melikyan/DM/Fall09 58 Cantor's Diagonalization Argument r 1 0.1234567 r 2 0.1511111 r 3 0.2542090 r 4 0.7890623 r 5 0.0110101 r 6 0.5555555 r 7 0.7679544 : r evil 0.  Decimal expansions of r i 

59 59 Melikyan/DM/Fall09 L659 Cantor's Diagonalization Argument r 1 0.1234567 r 2 0.1511111 r 3 0.2542090 r 4 0.7890623 r 5 0.0110101 r 6 0.5555555 r 7 0.7679544 : r evil 0.5455545  Decimal expansions of r i 

60 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 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: 1. 0.11111111… 2. 0.12345678901234567890… 3. 0.10110111011110….

62 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!


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

Similar presentations


Ads by Google