Presentation is loading. Please wait.

Presentation is loading. Please wait.

Discrete Mathematics Lecture 7 Alexander Bukharovich New York University.

Similar presentations


Presentation on theme: "Discrete Mathematics Lecture 7 Alexander Bukharovich New York University."— Presentation transcript:

1 Discrete Mathematics Lecture 7 Alexander Bukharovich New York University

2 Generic Functions A function f: X  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 X is called domain of f, 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) Sample functions: –f : R  R, f(x) = x 2 –f : Z  Z, f(x) = x + 1 –f : Q  Z, f(x) = 2

3 Generic Functions Arrow diagrams for functions Non-functions Equality of functions: –f(x) = |x| and g(x) = sqrt(x 2 ) Identity function Sequences as functions Functions with a domain of some language Logarithmic function

4 Generic Functions Encoding and decoding of characters Hamming distance function: number of differences between two encodings Boolean functions: f : {0, 1} n  {0, 1} Well-defined functions Euler function:  (n) is the number of positive integers less than n, which are mutually prime with n

5 Exercises Show that if p is a prime number, then  (p n ) = p n – p n-1 Prove that there infinitely many integers for which Euler’s function is a perfect square Show that  (pq) =  (p-1)  (q-1) if p and q are distinct primes Determine which of the following is true: –if A  B, then f(A)  f(B) –f(A  B) = f(A)  f(B) –f(A  B) = f(A)  f(B) –f(A - B) = f(A) - f(B)

6 Finite-State Automata (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

7 FSA by Transition Diagram s0s1 s2 1 1 1 0 0 0

8 FSA by Next-State Table abc UZYY XVVV YZVY ZZZZ

9 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) 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.

10 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 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

11 One-to-One Functions 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 Determine whether the following functions are one-to-one: –f : R  R, f(x) = 4x – 1 –g : Z  Z, g(n) = n 2 Hash functions

12 Onto Functions 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 Determine whether the following functions are onto: –f : R  R, f(x) = 4x – 1 –f : Z  Z, g(n) = 4n – 1 Bijection is one-to-one and onto Reversing strings function is bijective

13 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

14 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 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?

15 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 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?

16 Pigeonhole Principle There is no FSA that accepts the following language: L = {s = a k b k, for positive k} 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.

17 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 disjoint 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

18 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) = n2. 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

19 Cardinality Cardinality refers to the size of the set Finite and infinite sets Two sets have the same cardinality when there is bijective function associating them Cardinality is is reflexive, symmetric and transitive Countable sets: set of all integers, set of even numbers Set of real numbers Computability of functions

20 Exercises Show that the set of irrational numbers is dense Show that a power set has always a greater cardinality than the original set


Download ppt "Discrete Mathematics Lecture 7 Alexander Bukharovich New York University."

Similar presentations


Ads by Google