Computational Models: Class 5
|
|
- Britton Norton
- 5 years ago
- Views:
Transcription
1 Computational Models: Class 5 Benny Chor School of Computer Science Tel Aviv University March 27, 2019 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay Mansour. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
2 Class 5: Outline Push Down Automata Closure Properties of CFLs Non determinism adds power to PDAs (not in book) Algorithmic Aspects of PDAs and CFLs Equivalence of PDAs and CFLs Chomsky normal form construction (high level only) Sipser s book, 2.2 & 2.3 Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
3 Part I Push Down Automata Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
4 A Finite Automaton (reminder) Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
5 A PushDown Automaton (PDA) (reminder) We add a memory device with restricted access: A stack (last in, first out; push/pop). (ignore the $ sign). Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
6 The language accepted by a PDA A pushdown automaton M accepts a string w, if there is a computation of M on w that leads to an accepting state when all of the input is read. The language accepted by M, denoted L(M), is the set of all strings w Σ accepted by M. A (non-deterministic) PDA may have many computations on a single string. To accept, it suffices that one of them leads to acceptance. To reject, none of them should lead to acceptance. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
7 PDA: Variants Instead of pushing in one move a single letter (or nothing) to the stack, push a string from Γ. Instead of acceptance by being in an accept state after reading all the input, define acceptance as having an empty stack after reading all the input. Instead of acceptance by being in an accept state after reading all the input, define acceptance as having an empty stack and being in an accept state after reading all the input. These variants give rise to PDAs with the same computing power as our PDAs (not hard to show). For different languages, we may choose a variant that is easier to use. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
8 The Transition Function Denote input alphabet by Σ and stack alphabet by Γ. the domain of the transition function δ is current state: Q next input, if any: Σ ε (=Σ {ε}) stack symbol popped, if any: Γ ε (=Γ {ε}) and its range is new state: Q stack symbol pushed, if any: Γ ε non-determinism: P(of two components above) δ : Q Σ ε Γ ε P(Q Γ ε ) Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
9 PDA: Formal Definitions (reminder) A pushdown automaton (PDA) is a 6-tuple (Q, Σ, Γ, δ, q 0, F), where Q is a finite set called the states, Σ is a finite set called the input alphabet, Γ is a finite set called the stack alphabet, δ : Q Σ ε,$ Γ ε P(Q Γ ε ) is the transition function, q 0 Q is the start state, and F Q is the set of accept states. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
10 Model of Computation The following corresponds to M = (Q, Σ, Γ, δ, q 0, F). Definition 1 (δ ) For w Σ let δ(q, w, s) be all pairs (q, s ) Q Γ for which exist w 1,..., w m Σ ε, states r 1,..., r m Q and strings s 0, s 1,... s m Γ s.t.: 1 w = w 1,..., w m, r 0 = q, r m = q, s 0 = s and s m = s 2 For every i {0,..., m 1} exist a, b Γ ε and t Γ s.t.: 1 (r i+1, b) δ(r i, w i+1, a) 2 s i = at and s i+1 = bt Namely, (q, s ) δ(q 0, w, ε) if after reading w (possibly with in-between ε moves), M can find itself in state q and stack value s. M accepts w Σ if q F such that (q, t) δ(q 0, w, ε) for some t. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
11 Diagram Notation When drawing the automata diagram, we use the following notation Transition a, b c from state q to q means (q, c) δ(q, a, b), and informally means the automata read a from input pop b from stack push c onto stack Meaning of ε transitions (informally): a = ε : don t read an input symbol b = ε: don t pop any symbol c = ε: don t push any symbol Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
12 Conventions It will be convenient to be able to know when the stack is empty, but there is no built-in mechanism to do that. Solution: Start by pushing $ onto stack. When you see it again, stack is empty. Question: When is input string exhausted? Answer: When $ is read. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
13 A PDA for L 1 = {0 n 1 n : n 0} Example L(P). Formally, for 0011, the PDA goes through following sequence of symbols, w i, stack contents, s i, and states, q i. w 1 = ε w 2 = 0 w 3 = 0 w 4 = 1 w 5 = 1 w 6 = ε s 0 = ε s 1 = $ s 2 = 0$ s 3 = 00$ s 4 = 0$ s 5 = $ s 6 = ε r 0 = q 1 r 1 = q 2 r 2 = q 2 r 3 = q 2 r 4 = q 3 r 5 = q 3 r 6 = q 4 Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
14 A PDA for L 1 = {0 n 1 n : n 0} We want to show that L(P) = L 1 = {0 n 1 n : n 0} After understanding the intuition, we formally prove this in the following manner: Claim 3 δ(q 1, ε, ε) = {(q 1, ε), (q 2, $)}. δ(q 1, 0 k, ε) = {(q 2, 0 k $)}, for k 1. δ(q 1, 0 k 1 i, ε) = {(q 3, 0 k i $)}, for k > i 1. δ(q 1, 0 k 1 k, ε) = {(q 3, $), (q 4, ε)}, for k 1. δ(q 1, w, ε) =, for w {0 k 1 i k i 0}. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
15 A Second Example A PDA that accepts {a i b j c k i, j, k > 0 and i = j or i = k} Informally: read and push a s either pop and match with b s or else ignore b s. Pop and match with c s a non-deterministic choice! Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
16 A PDA for L 2 = {a i b j c k : i = j i = k} Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
17 A PDA for L 2 = {a i b j c k : i = j i = k}, cont. Non-determinism is essential here! Unlike finite automata, non-determinism does add power. But how do we prove that non-determinism adds power?. Does not seem trivial or immediate. Another example: L = {x n y n : n 0} {x n y 2n : n 0} is accepted by a non-deterministic PDA, but not by a deterministic one. We will prove this claim In a few slides. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
18 Example 3 Palindrome A palindrome is a string w satisfying w = w R. Madam I m Adam Dennis and Edna sinned Red rum, sir, is murder Able was I ere I saw Elba In girum imus nocte et consumimur igni (Latin: "we go into the circle by night, we are consumed by fire.) νιψoν ανoµηµατ α µη µoναν oψιν Palindromes also appear in nature. For example as DNA restriction sites short genomic strings over {A, C, T, G}, being cut by (naturally occurring) restriction enzymes. What is the difference from {ww R }? Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
19 A PDA for Palindromes Algorithm 4 Input: x Σ 1 Start pushing x into stack. 2 At some point, guess that the mid point of x was reached. 3 Pops and compares to input, letter by letter. 4 Reject if mismatch found. 5 Accept If stack is empty together with end of input. This PDA accepts palindromes of even length over the alphabet. Taking care of odd and even lengths is an easy modification. Again, non-determinism (at which point to make the switch) seems necessary. Q.: Which CFG generates palindromes? Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
20 PDA Languages The Push-Down Automata Languages, L PDA, is the set of all languages that can be described by some PDA: L PDA = {L : PDA M such that L[M] = L} We already know L DFA L PDA, since every DFA can be viewed as a PDA that ignores the stack. Likewise, we define L CFL = {L : CFG G such that L[G] = L} Questions: L CFG L PDA? L PDA L CFG? Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
21 Equivalence Theorem Theorem 5 A language is context free if and only if some pushdown automaton accepts it. This time, both the if part and the only if part are non-trivial. We will present a high level view of the proof (not all details) later today. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
22 Part II (Non) Closure Properties of Context Free Languages Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
23 CFL Closure Properties We saw that Context-Free Languages are closed under union, concatenation, and star. It is time we resolve closure with respect to complementation and intersection. Let us start with closure under intersection. Possible approach: Can we intersect two context free languages to get the non CFL {0 n 1 n 2 n }? Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
24 CFL Closure Properties So, are the context free languages closed under intersection? S 1 A 1 B 1 S 2 A 2 B 2 A 1 0A A 2 0A 2 ε B 1 2B 1 ε B 2 1B L 1 = 0 n 1 n 2 L 2 = 0 1 n 2 n L 1 L 2 = 0 n 1 n 2 n L 1 is a context free language, L 2 is a context free language, but L 1 L 2 is not a context free language. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
25 CFL Closure Properties The fact that CFLs are not closed under intersection but are closed under union implies they are not closed under complementation, as L 1 L 2 = L 1 L 2. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
26 CFL Closure Properties Can we give a simple, specific example, where L is not CFL but L is? Take L = {ww w {0, 1} }. In homework assignment 3, you will be asked to describe a context free grammar for L. We sketch a PDA for L (and recall the CFG-PDA equivalence): For any y L, either y s length is odd. y s length is even, 2l, and there is an i 1 such that y i y l+i. PDA non-deterministically tries to verify one of the options. For the second, harder, option, PDA employs stack for matching locations. Accepts only on a successful branch (we recommend you fill in the PDA details!). Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
27 CFL Closure Properties Are the context free languages context free languages closed under intersection with a regular language? That is, if L 1 is context free languages, and L 2 is regular, must L 1 L 2 be context free languages? Yes! Run PDA L 1 and DFA L 2 in parallel (much like the intersection of two regular languages). Formal details omitted (but you should be able to figure them out). Why does intersection work here but does not work for two PDAs? Because the DFA does not try to access the stack, while the two PDAs may impose conflicting actions on the stack! Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
28 CFL Closure Properties: Another Example Let L = {w {0, 1, 2} : # 0 (w) = # 1 (w) = # 2 (w)}. Is this a context free language? L = {0 n 1 n 2 n : n 0} is not context free is regular. Context free languages intersected with a regular languages are context free. So L is not a context free language This could also be established using the pumping lemma, but proof above is more elegant. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
29 Part III Non Determinism Adds Power to PDAs Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
30 Non-Determinism Adds Power Theorem: There are context free languages that are accepted only by non-deterministic push down automata. Comment: Recall that all regular languages are accepted by deterministic finite automata. For finite automata, non-determinism does not add power, even though it may make life more convenient. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
31 Non-Determinism Adds Power: Proof Theorem: Let M be a PDA that accepts Then M is non-deterministic. L = {x n y n n 0} {x n y 2n n 0}. Proof : Suppose, by way of contradiction, that M is deterministic. Create two copies of this PDA, denoted by M 1 and M 2, respectively. Two states in M 1 and M 2 are called cousins if they are copies of the same state in the original PDA. modified from jpower/courses/parsing/node38.html, but this URL is now (Nov. 2014) broken. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
32 Non-Determinism Adds Power (cont.) We now modify these PDA copies to make them into one PDA, M 0, over the alphabet {x, y, z}. The stack alphabet is not changed. States of the new M 0 are those of M 1 union M 2. Start state of the new M 0 is the start state of M 1. The accepting states of the new M 0 are the accepting states of M 2. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
33 Non-Determinism Adds Power (cont.) Modifications: Erase all x transitions of M 2 (formally, on input letter x and any stack option, M 2 moves to a new dead end state). Replace every existing y transition of M 2 by a new z transition (how is this implemented formally?). At this point M 2 got only z transition (so while in M 2, the letters x and y lead immediately to rejection). Erase all x transitions out of accepting states of M 1. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
34 Non-Determinism Adds Power (cont.) The surgery is almost done, but if we don t connect the two halves of its brain, the patient will not function coherently. Replace every existing y transition leading out of an accepting state of M 1 to some state q, by a new z transition, and redirect it to the cousin of q in M 2. Surgery over. Patient (a deterministic PDA) still alive. Let us now diagnose what, if anything, it can do. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
35 Non-Determinism Adds Power (cont.) What language does M 0 recognizes? If M 0 accepts a string, it must be of the form (x y) z. Surely not all strings of that form are accepted by M 0. For example, the prefix in (x y) must be accepted by the original M. Otherwise there will be no switch to M 2, and no acceptance by M 0. So the prefix of an accepted string is either of the form x n y n or x n y 2n. And the whole string is of the form x n y n z i or x n y 2n z j. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
36 Non-Determinism Adds Power (cont.) What can we say about the z i part? First, i must be greater than 0 for a transition to take place. By construction, M 2 on z i imitates the actions of M on y i from the same starting point. This means that if M 0 accepts x n y n z i then M accepts x n y n+i. Which is only possible if i = n, so M 0 accepts x n y n z n, n > 0. Notice that M 0 cannot accepts x n y 2n z j, because M does not accepts any string of the form x n y 2n+j, j > 0. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
37 Conclusion of Proof We just showed that the PDA M 0 accepts the language {x n y n z n n 1}. By the equivalence theorem, the language that a PDA accepts is a context free language. By the so called uvxyz pumping lemma, {x n y n z n n 1} is not a CFL. Contradiction. This means that our initial supposition that the language {x n y n } {x n y 2n } is accepted by a deterministic PDA, does not hold. While thinking about the proof, where would it fail if the original M were non-deterministic? Specifically, why is it true that for deterministic M, L(M 0 ), but for non deterministic M, L(M 0 ) = is possible? Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
38 Part IV Algorithmic Questions for CFG/CFL/PDA Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
39 Algorithmic Questions Regarding CFGs Given a CFG, G, and a string w, does G generate w? Initial Idea: Design an algorithm that tries all derivations. Problem: If G does not generate w, we ll never stop. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
40 Algorithmic Questions for CFGs (2) Lemma 6 If G is in Chomsky normal form, w = n, and w is generated by G, then w has a derivation of length 2n 1 or less. The proof of the lemma relies on the fact that a long derivation which produces a string of terminals must produce long string (try proving it at home!). Algorithm s idea for "does G generate w": First, convert G to Chomsky normal form (see last slides in presentation for details). Now need only consider a bounded number of derivations those of length 2n 1 or less. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
41 Algorithmic Questions for CFGs (3) Theorem 7 There is an algorithm (that halts on every inputs) A, that on inputs G and w, decides if G generates w. On input G, w, where G is a grammar and w a string, 1. Convert G to Chomsky normal form. 2. List all derivations with 2n 1 steps, were n = w. 3. If any generates w, accept, otherwise reject. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
42 Algorithmic Questions for CFGs (4) Theorem 8 There is an algorithm (that halts on every inputs) A, that on inputs G and w, decides if G generates w. Remarks: Related to problem of compiling prog. languages. Would you want to use this algorithm at work? There is a more efficient algorithm, which employs dynamic programming. You will see it in the recitation. Every theorem about CFLs is also about PDAs. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
43 Emptiness of CFGs Question 9 Given a CFG, G, is L(G) =? In other words, is there a string generated by G? Theorem 10 There is an algorithm that solves this problem (and always halts). Possible approaches for a proof: Bad Idea: We know how to test whether w L(G) for any string w, so just try it for each w... Better Idea: Can the start variable generate a string of terminals? Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
44 Removing redundant variables and terminals of a CFG 1 Mark all terminal symbols in G. 2 Repeat until no new variable become marked: Mark any A where A U 1 U 2... U k and all U i have already been marked. 3 Remove all unmarked variables, and any rule they appear in. 4 If S is removed, then L(G) =. A simple example on board. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
45 Checking Emptiness Algorithm 11 Input a CFG G 1 Remove redundant variables and terminals to get G. 2 Return TRUE (i.e., L(G ) = ) iff S is removed Correctness? Two directions: S not removed implies L(G ). S removed implies L(G ) =. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
46 CFGs Fullness Question 12 Given a CFG G, is L(G) = Σ? Fact 13 We just saw an algorithm to determine, given a CFG G, whether L(G) = L(G) = Σ iff L(G) =. Why not modify the algorithm so it determines emptiness of the complement? Unfortunately, CFGs are not closed under complement. There is no algorithm to solve CFG fullness. We are not prepared to prove this remarkable fact (yet). Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
47 Finiteness of CFGs Question 14 Given a CFG G, is L(G) finite? 1 Remove redundant variables and terminals. 2 Turn into a CNF form 3 Create a graph C whose nodes are variables and its directed edges are derivations. 4 Return TRUE iff C has a no cycles. Correctness? Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
48 CFGs Inherent Ambiguity Question 15 Given a CFG G, is L(G) inherently ambiguous? This means that for any CFG that generates L(G), there is a word in the language with two different parse trees. Fact 16 There is no algorithm to solve CFG inherent ambiguity. We will not prove this fact, yet we want you to know it, to put things in context. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
49 When Are Two CFGs equivalent? Question 17 Given two CFG G 1 and G 2, test if L(G 1 ) = L(G 2 ). Is there an algorithm to solve this problem? Fact 18 There is no algorithm to solve Two CFG equivalence. We will prove this result. But only in the computability part of the course (in approx. 5 weeks). Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
50 Part V CFG PDA Equivalence Theorem Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
51 The CFG PDA Equivalence Theorem Theorem 19 L PDA = L CFG : A language is context free if and only if some pushdown automata accepts it. This time (unlike the regular expression vs. regular languages theorem), both the proof if part and of the only if part are non trivial. Proof sketch follows. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
52 PDA = CFL Lemma 20 L PDA L CFG : If a PDA accepts a language then it is context free. We prove the lemma by constructing a CFG G for a language L accepted by a PDA P Let P = (Q, Σ, Γ, δ, q 0, F). We assume wlg. that: A single accepting state qa F. P empties the stack before accepting Each transition either pops or pushes How can we justify the above? Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
53 Defining G = (V, Σ, R, S) V = {A pq : p, q Q} Idea: The variable A pq will generate all strings that take P from p with an empty stack, to q with an empty stack S = A q0,q a Initially the set of rules R is assigned. We then add rules, as following: 1 Add {A pq A p,r A r,q : p, q, r Q} to R 2 Add {A qq ε: q Q} to R 3 For all p, r, s, q Q, a, b Σ ε and t Γ such that 1 (r, t) δ(p, a, ε) and 2 (q, ε) δ(s, b, t) add A pq aa r,s b to R Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
54 Example PDA to CFG A q1,q 4 A q2,q 3 A q2,q 3 0A q2,q 3 1 A q2,q 3 0A q2,q 2 1. A q2,q 2 ε. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
55 PDA Computation corresponding to A pq A p,r A r,q Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
56 PDA Computation corresponding to A pq aa r,s b Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
57 Claim: L(G) = L(P) Claim 21 A pq w Σ iff (q, ε) δ(p, w, ε) Proof by induction on the number of derivation rules/ transitions Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
58 CFL = PDA Lemma 22 L CFG L PDA : If a language is context free, then some PDA accepts it. Let L be a context-free language, and let G = (V, Σ, R, S) be context-free grammar for L We build a PDA P = (Q, Σ, Γ, δ, q 0, F), such that on input w it figures out" if there is a derivation of w using G. Question 23 How does P figure out which substitution to make? Answer: It guesses. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
59 Simplifying Assumptions 1 In a single move, a PDA can push a whole word (from some fixed set) into the stack (first letter at the top) Can we justify it? 2 When deriving a word form a CFL, we always substitute the left most variable 3 Does this change the derived language? Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
60 Informal Description of P Algorithm 24 (P) 1 Push S$ on stack 2 While top of the stack t is not $: 3 If t is variable A, (non-deterministically) select rule A α and substitute. 4 If t is a terminal a, read next input and compare; Reject if different. 5 Accept if end of input and stack is empty Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
61 State Diagram for P Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
62 Example consider the CFG: S 0S1 ε. The related PDA: Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
63 Claim: L(P) = L(G) Claim 25 S α iff α = α 1 α 2 such that (q loop, α 2 $) δ(q loop, α 1, ε). Recall S α. Next, we will see a proof of this claim. The claim implies that L(P) = L(G) (why?) Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
64 S α = α = α 1 α 2 such that (q loop, α 2 $) δ(q loop, α 1, $) Proof by induction on the number of derivations steps used to yield α from S. 0 derivation steps: hence α = S. Since (q loop, S$) δ(q loop, ε, $), the proof follows for α 1 = ε and α 2 = S. Assume S α in k > 0 derivation steps, and let α be the string derived by the first (k 1) steps. By induction hypothesis, α = α 1 α 2 such that (q loop, α 2 $) δ(q loop, α 1, $) Write α 2 = w 1Aw 2 where A is the left most variable in α 2. The k th derivation step replaces this occurrence of A with a string t (why?) It is easy to see that (q loop, tw 2 $) δ(q loop, α 1 w 1, $). To complete the proof take α 1 = α 1 w 1 and α 2 = tw 2. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
65 α = α 1 α 2 such that (q loop, α 2 $) δ(q loop, α 1, $) = S α Proof by induction on the number of steps used by P to process α 1. A single step: α 1 = ε and α 2 = S$, and the proof follows since S S. Assume α 1 was processed in k > 1 steps, and let α 1 and α 2 be the input string read and the stack value before the last step Note that (q loop, α 2 $) δ(q loop, α 1, $). By i.h S α = α 1 α 2. In case the k th move of P is reading an input character, then α 1 α 2 = α 1 α 2, and therefore S α 1 α 2 Otherwise, α 1 = α 1, α 2 = Aw and α 2 = tw for some rule A t R Hence S α 1 α 2 This completes the proof that CFL = PDA. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
66 Part VI Chomsky Normal Form (CNF) Linguist and political commentator Noam Chomsky (born Dec. 1928). Photo taken on May Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
67 Chomsky Normal Form A simplified, canonical form of context free grammars. Elegant by itself, useful (but not crucial) in proving equivalence theorem. Can also be used to slightly simplify proof of pumping lemma. Every rule has the form A BC A a S ε where S is the start symbol, A, B and C are any variable, except B and C not the start symbol, and A can be the start symbol. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
68 Theorem: Any context-free language is generated by a context-free grammar in Chomsky normal form. Proof (basic idea): Add new start symbol S 0. Eliminate all ε rules of the form A ε. Eliminate all unit rules of the form A B. At each step, patch up rules so that grammar generates the same language. Convert remaining long rules to proper form. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
69 Proof Add new start symbol S 0 and rule S 0 S. Guarantees that new start symbol does not appear on right-hand-side of a rule. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
70 Proof Eliminating ε rules. Repeat: remove some A ε. for each R uav, add rule R uv. and so on: for R uavaw add R uvaw, R uavw, and R uvw. for R A add R ε, except if R ε has already been removed. until all ε-rules not involving the original start variable have been removed. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
71 Proof Eliminate unit rules. Repeat: remove some A B. for each B u, add rule A u, unless this is previously removed unit rule. (u is a string of variables and terminals.) until all unit rules have been removed. Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
72 Proof Finally, convert long rules. To replace each A u 1 u 2... u k (for k 3), introduce new non-terminals N 1, N 2,..., N k 1 and rules A u 1 N 1 N 1 u 2 N 2. N k 3 u k 2 N k 2 N k 2 u k 1 u k Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
73 Conversion Example Initial Grammar: S ASA ab A B S B b ε (1) Add new start state: S 0 S S ASA ab A B S B b ε Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
74 Conversion Example (2) S 0 S S ASA ab A B S B b ε (2) Remove ε-rule B ε: S 0 S S ASA ab a A B S ε B b ε Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
75 Conversion Example (3) S 0 S S ASA ab a A B S ε B b (3) Remove ε-rule A ε: S 0 S S ASA ab a AS SA S A B S ε B b Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
76 Conversion Example (4) S 0 S S ASA ab a AS SA S A B S B b (4) Remove unit rule S S S 0 S S ASA ab a AS SA S A B S B b Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
77 Conversion Example (5) S 0 S S ASA ab a AS SA A B S B b (5) Remove unit rule S 0 S: S 0 S ASA ab a AS SA S ASA ab a AS SA A B S B b Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
78 Conversion Example (6) S 0 ASA ab a AS SA S ASA ab a AS SA A B S B b (6) Remove unit rule A B: S 0 ASA ab a AS SA S ASA ab a AS SA A B S b B b Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
79 Conversion Example (7) S 0 ASA ab a AS SA S ASA ab a AS SA A S b B b Remove unit rule A S: S 0 ASA ab a AS SA S ASA ab a AS SA A S b ASA ab a AS SA B b Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
80 Conversion Example (8) S 0 ASA ab a AS SA S ASA ab a AS SA A b ASA ab a AS SA B b (8) Final simplification treat long rules: S 0 AA 1 UB a SA AS S AA 1 UB a SA AS A b AA 1 UB a SA AS A 1 SA U a B b Benny Chor (Tel Aviv University) Computational Models Class 5: Plan March 27, / 80
Computational Models Lecture 5
Computational Models Lecture 5 One More PDAs Example Equivalence of PDAs and CFLs Nondeterminism adds power to PDAs (not in book) Closure Properties of CFLs Algorithmic Aspects of PDAs and CFLs DFAs and
More informationComputational Models - Lecture 5 1
Computational Models - Lecture 5 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. April 10/22, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice
More informationComputational Models - Lecture 4
Computational Models - Lecture 4 Regular languages: The Myhill-Nerode Theorem Context-free Grammars Chomsky Normal Form Pumping Lemma for context free languages Non context-free languages: Examples Push
More informationComputational Models - Lecture 4 1
Computational Models - Lecture 4 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. April 3/8, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice
More informationComputational Models - Lecture 5 1
Computational Models - Lecture 5 1 Handout Mode Iftach Haitner. Tel Aviv University. November 28, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.
More informationComputational Models - Lecture 3
Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Computational Models - Lecture 3 Equivalence of regular expressions and regular languages (lukewarm leftover
More informationCS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF)
CS5371 Theory of Computation Lecture 7: Automata Theory V (CFG, CFL, CNF) Announcement Homework 2 will be given soon (before Tue) Due date: Oct 31 (Tue), before class Midterm: Nov 3, (Fri), first hour
More informationFORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY REVIEW for MIDTERM 1 THURSDAY Feb 6 Midterm 1 will cover everything we have seen so far The PROBLEMS will be from Sipser, Chapters 1, 2, 3 It will be
More informationComputational Models: Class 3
Computational Models: Class 3 Benny Chor School of Computer Science Tel Aviv University November 2, 2015 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay
More informationIntroduction to Theory of Computing
CSCI 2670, Fall 2012 Introduction to Theory of Computing Department of Computer Science University of Georgia Athens, GA 30602 Instructor: Liming Cai www.cs.uga.edu/ cai 0 Lecture Note 3 Context-Free Languages
More informationComputational Models - Lecture 4 1
Computational Models - Lecture 4 1 Handout Mode Iftach Haitner. Tel Aviv University. November 21, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.
More informationCISC4090: Theory of Computation
CISC4090: Theory of Computation Chapter 2 Context-Free Languages Courtesy of Prof. Arthur G. Werschulz Fordham University Department of Computer and Information Sciences Spring, 2014 Overview In Chapter
More informationThe View Over The Horizon
The View Over The Horizon enumerable decidable context free regular Context-Free Grammars An example of a context free grammar, G 1 : A 0A1 A B B # Terminology: Each line is a substitution rule or production.
More informationComputational Models - Lecture 1 1
Computational Models - Lecture 1 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. February 29/ March 02, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames
More informationComputational Models Lecture 2 1
Computational Models Lecture 2 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. March 16/18, 2015 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice
More informationOctober 6, Equivalence of Pushdown Automata with Context-Free Gramm
Equivalence of Pushdown Automata with Context-Free Grammar October 6, 2013 Motivation Motivation CFG and PDA are equivalent in power: a CFG generates a context-free language and a PDA recognizes a context-free
More informationTheory of Computation (IV) Yijia Chen Fudan University
Theory of Computation (IV) Yijia Chen Fudan University Review language regular context-free machine DFA/ NFA PDA syntax regular expression context-free grammar Pushdown automata Definition A pushdown automaton
More informationLecture 17: Language Recognition
Lecture 17: Language Recognition Finite State Automata Deterministic and Non-Deterministic Finite Automata Regular Expressions Push-Down Automata Turing Machines Modeling Computation When attempting to
More informationComputational Models Lecture 8 1
Computational Models Lecture 8 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. May 11/13, 2015 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice
More informationComputational Models Lecture 8 1
Computational Models Lecture 8 1 Handout Mode Nachum Dershowitz & Yishay Mansour. Tel Aviv University. May 17 22, 2017 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice
More informationComputational Models - Lecture 3 1
Computational Models - Lecture 3 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. March 13/18, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice
More informationComputational Models: Class 1
Computational Models: Class 1 Benny Chor School of Computer Science Tel Aviv University October 19, 2015 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay
More informationCPSC 421: Tutorial #1
CPSC 421: Tutorial #1 October 14, 2016 Set Theory. 1. Let A be an arbitrary set, and let B = {x A : x / x}. That is, B contains all sets in A that do not contain themselves: For all y, ( ) y B if and only
More informationComputational Models Lecture 2 1
Computational Models Lecture 2 1 Handout Mode Iftach Haitner. Tel Aviv University. October 30, 2017 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.
More informationPUSHDOWN AUTOMATA (PDA)
PUSHDOWN AUTOMATA (PDA) FINITE STATE CONTROL INPUT STACK (Last in, first out) input pop push ε,ε $ 0,ε 0 1,0 ε ε,$ ε 1,0 ε PDA that recognizes L = { 0 n 1 n n 0 } Definition: A (non-deterministic) PDA
More informationWhat we have done so far
What we have done so far DFAs and regular languages NFAs and their equivalence to DFAs Regular expressions. Regular expressions capture exactly regular languages: Construct a NFA from a regular expression.
More informationPart 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX
Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu Part 4 out of 5 ETH Zürich (D-ITET) October, 12 2017 Last week, we showed the equivalence of DFA, NFA and REX
More informationPushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen
Pushdown automata Twan van Laarhoven Institute for Computing and Information Sciences Intelligent Systems Version: fall 2014 T. van Laarhoven Version: fall 2014 Formal Languages, Grammars and Automata
More informationPushdown Automata. Chapter 12
Pushdown Automata Chapter 12 Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely what it needs is a stack, which gives it an unlimited
More information(pp ) PDAs and CFGs (Sec. 2.2)
(pp. 117-124) PDAs and CFGs (Sec. 2.2) A language is context free iff all strings in L can be generated by some context free grammar Theorem 2.20: L is Context Free iff a PDA accepts it I.e. if L is context
More informationCS311 Computational Structures More about PDAs & Context-Free Languages. Lecture 9. Andrew P. Black Andrew Tolmach
CS311 Computational Structures More about PDAs & Context-Free Languages Lecture 9 Andrew P. Black Andrew Tolmach 1 Three important results 1. Any CFG can be simulated by a PDA 2. Any PDA can be simulated
More informationHarvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs
Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs Harry Lewis October 8, 2013 Reading: Sipser, pp. 119-128. Pushdown Automata (review) Pushdown Automata = Finite automaton
More informationTHEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET
THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET Regular Languages and FA A language is a set of strings over a finite alphabet Σ. All languages are finite or countably infinite. The set of all languages
More informationComputational Models Lecture 8 1
Computational Models Lecture 8 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. April 18/ May 2, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice
More informationFoundations of Informatics: a Bridging Course
Foundations of Informatics: a Bridging Course Week 3: Formal Languages and Semantics Thomas Noll Lehrstuhl für Informatik 2 RWTH Aachen University noll@cs.rwth-aachen.de http://www.b-it-center.de/wob/en/view/class211_id948.html
More informationMA/CSSE 474 Theory of Computation
MA/CSSE 474 Theory of Computation CFL Hierarchy CFL Decision Problems Your Questions? Previous class days' material Reading Assignments HW 12 or 13 problems Anything else I have included some slides online
More informationFinal exam study sheet for CS3719 Turing machines and decidability.
Final exam study sheet for CS3719 Turing machines and decidability. A Turing machine is a finite automaton with an infinite memory (tape). Formally, a Turing machine is a 6-tuple M = (Q, Σ, Γ, δ, q 0,
More informationLanguages, regular languages, finite automata
Notes on Computer Theory Last updated: January, 2018 Languages, regular languages, finite automata Content largely taken from Richards [1] and Sipser [2] 1 Languages An alphabet is a finite set of characters,
More informationCISC 4090 Theory of Computation
CISC 4090 Theory of Computation Context-Free Languages and Push Down Automata Professor Daniel Leeds dleeds@fordham.edu JMH 332 Languages: Regular and Beyond Regular: a b c b d e a Not-regular: c n bd
More informationPushdown Automata. Notes on Automata and Theory of Computation. Chia-Ping Chen
Pushdown Automata Notes on Automata and Theory of Computation Chia-Ping Chen Department of Computer Science and Engineering National Sun Yat-Sen University Kaohsiung, Taiwan ROC Pushdown Automata p. 1
More informationUNIT-VI PUSHDOWN AUTOMATA
Syllabus R09 Regulation UNIT-VI PUSHDOWN AUTOMATA The context free languages have a type of automaton that defined them. This automaton, called a pushdown automaton, is an extension of the nondeterministic
More informationCISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata
CISC 4090: Theory of Computation Chapter Regular Languages Xiaolan Zhang, adapted from slides by Prof. Werschulz Section.: Finite Automata Fordham University Department of Computer and Information Sciences
More informationCS 154. Finite Automata, Nondeterminism, Regular Expressions
CS 54 Finite Automata, Nondeterminism, Regular Expressions Read string left to right The DFA accepts a string if the process ends in a double circle A DFA is a 5-tuple M = (Q, Σ, δ, q, F) Q is the set
More informationPushdown Automata (2015/11/23)
Chapter 6 Pushdown Automata (2015/11/23) Sagrada Familia, Barcelona, Spain Outline 6.0 Introduction 6.1 Definition of PDA 6.2 The Language of a PDA 6.3 Euivalence of PDA s and CFG s 6.4 Deterministic PDA
More informationCSE 355 Test 2, Fall 2016
CSE 355 Test 2, Fall 2016 28 October 2016, 8:35-9:25 a.m., LSA 191 Last Name SAMPLE ASU ID 1357924680 First Name(s) Ima Regrading of Midterms If you believe that your grade has not been added up correctly,
More informationECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam
ECS 120: Theory of Computation Handout MT UC Davis Phillip Rogaway February 16, 2012 Midterm Exam Instructions: The exam has six pages, including this cover page, printed out two-sided (no more wasted
More informationCS500 Homework #2 Solutions
CS500 Homework #2 Solutions 1. Consider the two languages Show that L 1 is context-free but L 2 is not. L 1 = {a i b j c k d l i = j k = l} L 2 = {a i b j c k d l i = k j = l} Answer. L 1 is the concatenation
More informationNPDA, CFG equivalence
NPDA, CFG equivalence Theorem A language L is recognized by a NPDA iff L is described by a CFG. Must prove two directions: ( ) L is recognized by a NPDA implies L is described by a CFG. ( ) L is described
More informationPushdown Automata. We have seen examples of context-free languages that are not regular, and hence can not be recognized by finite automata.
Pushdown Automata We have seen examples of context-free languages that are not regular, and hence can not be recognized by finite automata. Next we consider a more powerful computation model, called a
More informationThe Pumping Lemma for Context Free Grammars
The Pumping Lemma for Context Free Grammars Chomsky Normal Form Chomsky Normal Form (CNF) is a simple and useful form of a CFG Every rule of a CNF grammar is in the form A BC A a Where a is any terminal
More informationFORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
5-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY NON-DETERMINISM and REGULAR OPERATIONS THURSDAY JAN 6 UNION THEOREM The union of two regular languages is also a regular language Regular Languages Are
More informationTheory of Computation (VI) Yijia Chen Fudan University
Theory of Computation (VI) Yijia Chen Fudan University Review Forced handles Definition A handle h of a valid string v = xhy is a forced handle if h is the unique handle in every valid string xhŷ where
More informationBefore We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?
Before We Start The Pumping Lemma Any questions? The Lemma & Decision/ Languages Future Exam Question What is a language? What is a class of languages? Context Free Languages Context Free Languages(CFL)
More informationCS481F01 Prelim 2 Solutions
CS481F01 Prelim 2 Solutions A. Demers 7 Nov 2001 1 (30 pts = 4 pts each part + 2 free points). For this question we use the following notation: x y means x is a prefix of y m k n means m n k For each of
More informationProperties of Context-Free Languages. Closure Properties Decision Properties
Properties of Context-Free Languages Closure Properties Decision Properties 1 Closure Properties of CFL s CFL s are closed under union, concatenation, and Kleene closure. Also, under reversal, homomorphisms
More informationFinite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018
Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Lecture 14 Ana Bove May 14th 2018 Recap: Context-free Grammars Simplification of grammars: Elimination of ǫ-productions; Elimination of
More informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 2 Define push down automata Trace the computation of a push down automaton Design
More informationCS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018
CS 301 Lecture 18 Decidable languages Stephen Checkoway April 2, 2018 1 / 26 Decidable language Recall, a language A is decidable if there is some TM M that 1 recognizes A (i.e., L(M) = A), and 2 halts
More information2.1 Solution. E T F a. E E + T T + T F + T a + T a + F a + a
. Solution E T F a E E + T T + T F + T a + T a + F a + a E E + T E + T + T T + T + T F + T + T a + T + T a + F + T a + a + T a + a + F a + a + a E T F ( E) ( T ) ( F) (( E)) (( T )) (( F)) (( a)) . Solution
More informationCS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,
CS 54, Lecture 2: Finite Automata, Closure Properties Nondeterminism, Why so Many Models? Streaming Algorithms 0 42 Deterministic Finite Automata Anatomy of Deterministic Finite Automata transition: for
More information(pp ) PDAs and CFGs (Sec. 2.2)
(pp. 117-124) PDAs and CFGs (Sec. 2.2) A language is context free iff all strings in L can be generated by some context free grammar Theorem 2.20: L is Context Free iff a PDA accepts it I.e. if L is context
More informationCpSc 421 Final Exam December 15, 2006
CpSc 421 Final Exam December 15, 2006 Do problem zero and six of problems 1 through 9. If you write down solutions for more that six problems, clearly indicate those that you want graded. Note that problems
More informationRecitation 2 - Non Deterministic Finite Automata (NFA) and Regular OctoberExpressions
Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular Expressions Orit Moskovich Gal Rotem Tel Aviv University October 28, 2015 Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular
More informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 3.3, 4.1 State and use the Church-Turing thesis. Give examples of decidable problems.
More informationCPS 220 Theory of Computation
CPS 22 Theory of Computation Review - Regular Languages RL - a simple class of languages that can be represented in two ways: 1 Machine description: Finite Automata are machines with a finite number of
More informationTheory Bridge Exam Example Questions
Theory Bridge Exam Example Questions Annotated version with some (sometimes rather sketchy) answers and notes. This is a collection of sample theory bridge exam questions. This is just to get some idea
More informationClosure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism
Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties Recall a closure property is a statement
More informationFundamentele Informatica II
Fundamentele Informatica II Answer to selected exercises 5 John C Martin: Introduction to Languages and the Theory of Computation M.M. Bonsangue (and J. Kleijn) Fall 2011 5.1.a (q 0, ab, Z 0 ) (q 1, b,
More informationComputational Models #1
Computational Models #1 Handout Mode Nachum Dershowitz & Yishay Mansour March 13-15, 2017 Nachum Dershowitz & Yishay Mansour Computational Models #1 March 13-15, 2017 1 / 41 Lecture Outline I Motivation
More informationNon-Deterministic Finite Automata
Slides modified Yishay Mansour on modification by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 8 Non-Deterministic Finite Automata 0,1 0,1 0 0,ε q q 1 q 2 3 1 q 4 an NFA
More informationDecidability (What, stuff is unsolvable?)
University of Georgia Fall 2014 Outline Decidability Decidable Problems for Regular Languages Decidable Problems for Context Free Languages The Halting Problem Countable and Uncountable Sets Diagonalization
More informationClosure Properties of Context-Free Languages. Foundations of Computer Science Theory
Closure Properties of Context-Free Languages Foundations of Computer Science Theory Closure Properties of CFLs CFLs are closed under: Union Concatenation Kleene closure Reversal CFLs are not closed under
More informationComputational Models - Lecture 3 1
Computational Models - Lecture 3 1 Handout Mode Iftach Haitner. Tel Aviv University. November 14, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.
More informationHarvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata
Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata Salil Vadhan October 4, 2012 Reading: Sipser, 2.2. Another example of a CFG (with proof) L = {x {a, b} : x has the same # of a s and
More informationMiscellaneous. Closure Properties Decision Properties
Miscellaneous Closure Properties Decision Properties 1 Closure Properties of CFL s CFL s are closed under union, concatenation, and Kleene closure. Also, under reversal, homomorphisms and inverse homomorphisms.
More informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION Spring 2017 http://cseweb.ucsd.edu/classes/sp17/cse105-ab/ Review of CFG, CFL, ambiguity What is the language generated by the CFG below: G 1 = ({S,T 1,T 2 }, {0,1,2}, { S
More informationV Honors Theory of Computation
V22.0453-001 Honors Theory of Computation Problem Set 3 Solutions Problem 1 Solution: The class of languages recognized by these machines is the exactly the class of regular languages, thus this TM variant
More informationCS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA)
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA) Objectives Introduce the Pumping Lemma for CFL Show that some languages are non- CFL Discuss the DPDA, which
More informationAccept or reject. Stack
Pushdown Automata CS351 Just as a DFA was equivalent to a regular expression, we have a similar analogy for the context-free grammar. A pushdown automata (PDA) is equivalent in power to contextfree grammars.
More informationContext-Free and Noncontext-Free Languages
Examples: Context-Free and Noncontext-Free Languages a*b* is regular. A n B n = {a n b n : n 0} is context-free but not regular. A n B n C n = {a n b n c n : n 0} is not context-free The Regular and the
More informationPS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010
University of Virginia - cs3102: Theory of Computation Spring 2010 PS2 - Comments Average: 77.4 (full credit for each question is 100 points) Distribution (of 54 submissions): 90, 12; 80 89, 11; 70-79,
More informationAutomata and Computability. Solutions to Exercises
Automata and Computability Solutions to Exercises Fall 28 Alexis Maciel Department of Computer Science Clarkson University Copyright c 28 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata
More information60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor
60-354, Theory of Computation Fall 2013 Asish Mukhopadhyay School of Computer Science University of Windsor Pushdown Automata (PDA) PDA = ε-nfa + stack Acceptance ε-nfa enters a final state or Stack is
More informationPushdown Automata: Introduction (2)
Pushdown Automata: Introduction Pushdown automaton (PDA) M = (K, Σ, Γ,, s, A) where K is a set of states Σ is an input alphabet Γ is a set of stack symbols s K is the start state A K is a set of accepting
More informationCOMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 10 : Context-Free Grammars
COMP-330 Theory of Computation Fall 2017 -- Prof. Claude Crépeau Lec. 10 : Context-Free Grammars COMP 330 Fall 2017: Lectures Schedule 1-2. Introduction 1.5. Some basic mathematics 2-3. Deterministic finite
More informationAutomata and Computability. Solutions to Exercises
Automata and Computability Solutions to Exercises Spring 27 Alexis Maciel Department of Computer Science Clarkson University Copyright c 27 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata
More informationCS 154 Introduction to Automata and Complexity Theory
CS 154 Introduction to Automata and Complexity Theory cs154.stanford.edu 1 INSTRUCTORS & TAs Ryan Williams Cody Murray Lera Nikolaenko Sunny Rajan 2 Textbook 3 Homework / Problem Sets Homework will be
More informationIntro to Theory of Computation
Intro to Theory of Computation 1/19/2016 LECTURE 3 Last time: DFAs and NFAs Operations on languages Today: Nondeterminism Equivalence of NFAs and DFAs Closure properties of regular languages Sofya Raskhodnikova
More informationSCHEME FOR INTERNAL ASSESSMENT TEST 3
SCHEME FOR INTERNAL ASSESSMENT TEST 3 Max Marks: 40 Subject& Code: Automata Theory & Computability (15CS54) Sem: V ISE (A & B) Note: Answer any FIVE full questions, choosing one full question from each
More informationContext Free Languages and Grammars
Algorithms & Models of Computation CS/ECE 374, Fall 2017 Context Free Languages and Grammars Lecture 7 Tuesday, September 19, 2017 Sariel Har-Peled (UIUC) CS374 1 Fall 2017 1 / 36 What stack got to do
More informationDM17. Beregnelighed. Jacob Aae Mikkelsen
DM17 Beregnelighed Jacob Aae Mikkelsen January 12, 2007 CONTENTS Contents 1 Introduction 2 1.1 Operations with languages...................... 2 2 Finite Automata 3 2.1 Regular expressions/languages....................
More informationAutomata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS
Automata Theory Lecture on Discussion Course of CS2 This Lecture is about Mathematical Models of Computation. Why Should I Care? - Ways of thinking. - Theory can drive practice. - Don t be an Instrumentalist.
More informationPushdown Automata (Pre Lecture)
Pushdown Automata (Pre Lecture) Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2017 Dantam (Mines CSCI-561) Pushdown Automata (Pre Lecture) Fall 2017 1 / 41 Outline Pushdown Automata Pushdown
More informationCFGs and PDAs are Equivalent. We provide algorithms to convert a CFG to a PDA and vice versa.
CFGs and PDAs are Equivalent We provide algorithms to convert a CFG to a PDA and vice versa. CFGs and PDAs are Equivalent We now prove that a language is generated by some CFG if and only if it is accepted
More informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 2 Design a PDA and a CFG for a given language Give informal description for a PDA,
More informationTheory of Computation (II) Yijia Chen Fudan University
Theory of Computation (II) Yijia Chen Fudan University Review A language L is a subset of strings over an alphabet Σ. Our goal is to identify those languages that can be recognized by one of the simplest
More informationCS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL) Objectives Introduce Pumping Lemma for CFL Apply Pumping Lemma to show that some languages are non-cfl Pumping Lemma
More informationINF Introduction and Regular Languages. Daniel Lupp. 18th January University of Oslo. Department of Informatics. Universitetet i Oslo
INF28 1. Introduction and Regular Languages Daniel Lupp Universitetet i Oslo 18th January 218 Department of Informatics University of Oslo INF28 Lecture :: 18th January 1 / 33 Details on the Course consists
More informationCritical CS Questions
Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Critical CS Questions What is a computer? And What is a Computation? real computers too complex for any
More informationCSE 211. Pushdown Automata. CSE 211 (Theory of Computation) Atif Hasan Rahman
CSE 211 Pushdown Automata CSE 211 (Theory of Computation) Atif Hasan Rahman Lecturer Department of Computer Science and Engineering Bangladesh University of Engineering & Technology Adapted from slides
More information