Download presentation

Presentation is loading. Please wait.

1
CS 302: Discrete Math II A Review

2
An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x a string, |x| isthe length of x The unique string of length 0 will be denoted by ε and will be called the empty or null string NOTATION A language over Σ is a set of strings over Σ

3
Q = {q 0, q 1, q 2, q 3 } are states Σ = {0,1} is the alphabet : Q Σ → Q transition function * q 0 Q is start state F = {q 1, q 2 } Q accept states M = (Q, Σ, , q 0, F) where 01 q0q0 q0q0 q1q1 q1q1 q2q2 q2q2 q2q2 q3q3 q2q2 q3q3 q0q0 q2q2 * q2q2 0 0,1 0 0 1 1 1 q0q0 q1q1 q3q3 M NFAs have “choices” -- : Q Σ P (Q), and accept on input w if there is a path from q 0 to a q a in F.

4
DFA NFA Regular Language Regular Expression DEF

5
THE REGULAR PUMPING LEMMA Let L be a regular language Then there exists P such that For every w L with |w| ≥ P 1. |y| > 0 there exist xyz=w, where: 3. xy i z L for any i ≥ 0 2. |xy| ≤ P { ww : w 2 Σ* } is not regular!

6
SOME LANGUAGES ARE NOT REGULAR! B = {0 n 1 n | n ≥ 0} is NOT regular! Suppose B is regular and let P be the pumping length. The string 0 P 1 P B and has length at least P. So by the pumping lemma, there should be xyz = 0 P 1 P so that |xy| ≤ P, |y| > 0, and xyyz B. But y must be only 0s (otherwise |xy| > P), so xyyz has at least P+1 “0”s (because |y| > 0) but only P “1”s. So xyyz B, contradicting the pumping lemma. Therefore B is not regular.

7
ε,ε → $ 0,ε → 0 1,0 → ε ε,$ → ε stringpoppush A PDA accepts the string x if there is a path on input x and empty stack from q 0 to some q a 2 F. Following transition “a,b c” reads “a” from the input, pops “b” off the stack, and pushes “c” onto it.

8
A → 0A1 A → B B → # CONTEXT-FREE GRAMMARS A 0A1 00A11 00B11 00#11 A derives 00#11 in 4 steps. uVw yields uvw if (V → v) in G. variables terminals production rules start variable

9
THE CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form: A → BC A → a S → ε B and C are not start variable a is a terminal S is the start variable Any variable A that is not the start variable can only generate strings of length > 0 Theorem: All grammars can be converted to CNF

10
THE CONTEXT-FREE PUMPING LEMMA Let L be a context-free language Then there exists P such that For every w L with |w| ≥ P 1. |vy| > 0 there exist uvxyz=w, where: 3. uv i xy i z L for any i ≥ 0 2. |vxy| ≤ P { ww : w in Σ* } is not context-free!

11
0 → 0, R readwritemove → , R q accept q reject 0 → 0, R → , R 0 → 0, R → , L TURING MACHINES UNBOUNDED TAPE 0 q0q0 q0q0 q1q1 q2q2 q1q1 qaqa 0

12
Definition: A Turing Machine is a 7-tuple T = (Q, Σ, Γ, , q 0, q accept, q reject ), where: Q is a finite set of states; q 0 is the start state Σ is the input alphabet, Γ is the tape alphabet : Q Γ → Q Γ {L,R} is the transition function q accept q reject are the accept and reject states We can encode a TM as a string of 0s and 1s:

13
Terminology Every TM recognizes a language. The language of M is the set L(M) = { w | M(w) eventually accepts } A TM decides L if it accepts all strings in L and rejects all strings not in L A language is decidable if some TM decides it A language is recursively enumerable if some TM recognizes it. THE CHURCH-TURING THESIS: There is a program for L iff there is a TM for L

14
UNDECIDABILITY A language is a set of strings. It is a mathematical way of expressing a problem: given an input, is it in the set L? If a language is decidable, there is a computer program (TM) that can always solve the problem correctly – it terminates and has the right answer. If a language is undecidable, then no matter how smart you are, and no matter how long you give it, you cannot program a computer to always solve the problem correctly.

15
Let S be any set and P(S) be the power set of S Theorem: There is no onto map from S to P(S) Proof: Assume, for a contradiction, that there is an onto map f : S P(S) Let D f = { d S | d f(d) } If D f = f(y) then y D f if and only if y D f Turing Machines Strings of 0s and 1s Sets of strings of 0s and 1s Languages over {0,1} S P(S)

16
UNDECIDABLE PROBLEMS D TM = { (M) : M is a TM that does not accept (M) } Theorem. D TM is undecidable. Proof. Suppose machine N decides D TM. Then N accepts → D TM → N does not accept A TM = { (M,w) : M is a TM that accepts on input w } Theorem. If A TM is decidable, so is D TM. Proof. If ¬A TM is decided by the program nAccept we can decide if D TM by calling nAccept(M,M). Here we have reduced deciding D TM to deciding A TM. Since we know D TM is undecidable, A TM must also be undecidable.

17
MAPPING REDUCTIONS f : Σ* Σ* is a computable function if there is a TM that on input w, halts with f(w) on its tape A m B if there is a computable f, such that w A f(w) B f is called a reduction from A to B

18
RICE’S THEOREM Let P be a set of Turing machines. If P satisfies the following two properties: For any TMs M 1 and M 2, where L(M 1 ) = L(M 2 ), M 1 P if and only if M 2 P There exist TMs M IN P and M OUT P Then P is undecidable EXTREMELY POWERFUL (i.e. P is a “nontrivial property of the r.e. languages.”)

19
CONTEXT-FREE LANGUAGES 100 200 300 REGULAR LANGUAGES 100 200 300 NON-REGULAR NON-CFL 100 200 300 JEOPARDY

20
A DFA for the language (ab + ba)*

21
A regular expression for the set of strings accepted by the NFA: 0,1 1

22
A proof that the language { w Σ*: w ≠ w R } is not regular.

23
The language accepted by the following PDA: ε,ε → $ 0,ε → 0 1,0 → ε ε, $ → ε

24
A CFG for the language { w # b n : |w| = n }.

25
Regular operations that the Context-Free Languages are closed under. DAILY DOUBLE

26
A string in the language L = { 1 n #1 n : n ≥ 0} that contradicts the regular pumping lemma.

27
A string in the language {a n #a n #a n : n ≥ 0 } that contradicts the context-free pumping lemma.

28
A proof that the language { a n #b m : m = n 2, n ≥ 0 } is not context-free.

29
Do there exist non-regular languages that satisfy the Regular Pumping Lemma?

30
UNDECIDABLE LANGUAGES 100 200 300 DECIDABLE LANGUAGES 100 200 300 NP-COMPLETE REDUCTIONS 100 200 300 DOUBLE JEOPARDY

31
Show that if L 1 and L 2 are decidable, then so is L 1 – L 2.

32
A proof that the set {0,1,2}* is countable.

33
A proof that ODD ≤ m EVEN, where Σ = {0,1} ODD = { 1 i : i is odd} EVEN = { 1 i : i is even}

34
A proof, using Rice’s Theorem, that P 3 = { (M) : M accepts all strings of length 3 } is undecidable.

35
What operations are recursively enumerable languages closed under?

36
A proof that A TM ≤ m A JAVA, where A JAVA = { (J,w) : J is a Java program with method “public boolean test(string w)” that returns true on string w. }

37
What’s the definition of NP? NP-Complete? NP-hard?

38
Is Addition an NP-Complete problem? Why or why not?

39
Show that 4-SAT is NP-Complete by reducing it to 3-SAT.

Similar presentations

© 2020 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google