Computational Models - Lecture 4
|
|
- Cecil Rogers
- 5 years ago
- Views:
Transcription
1 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 Down Automata (PDA) Hopcroft and Ullman, 3.4 Sipser, 2.1, 2.2 & 2.3 Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1
2 The Equivalence Relation L Let L Σ be a language. Define an equivalence relation L on pairs of strings: Let x,y Σ. We say that x L y if for every string z Σ, xz L if and only if yz L. It is easy to see that L is indeed an equivalence relation (reflexive, symmetric, transitive) on Σ. In addition, if x L y then for every string z Σ, xz L yz as well (this is called right invariance). Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 2
3 The Equivalence Relation L Like every equivalence relation, L partitions Σ to (disjoint) equivalence classes. For every string x, let [x] Σ denote its equivalence class w.r.t. L (if x L y then [x] = [y] equality of sets). Question is, how many equivalence classes does L induce? In particular, is the number of equivalence classes of L finite or infinite? Well, it could be either finite or infinite. This depends on the language L. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 3
4 Example: L = (ab ba) L has the following four equivalence classes: [ǫ] = L [a] = La [b] = Lb [aa] = L(aa bb)σ Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 4
5 Classes of L : More Examples Let L 1 {0, 1} contain all strings where the number of 1s is divisible by 4. Then L1 has finitely many equivalence classes. Let L 2 = L(0 10 ). Then L2 has finitely many equivalence classes. Let L 3 {0, 1} contain all strings of the form 0 n 1 n. Then L3 has infinitely many equivalence classes. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 5
6 Myhill-Nerode Theorem Theorem: Let L Σ be a language. Then L is regular L has finitely many equivalence classes. Three specific consequences: L 1 {0, 1} contains all strings where the number of 1s is divisible by 4. Then L 1 is regular. L 2 = L(0 10 ) is regular. L 3 {0, 1} contains all strings of the form 0 n 1 n. Then L 2 is not regular. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 6
7 Myhill-Nerode Theorem: Proof = Suppose L is regular. Let M = (Q, Σ,δ,q 0,F) be a DFA accepting it. For every x Σ, let δ(q 0,x) Q be the state where the computation of M on input x ends. The relation M on pairs of strings is defined as follows: x M y if δ(q 0,x) = δ(q 0,y). Clearly, M is an equivalence relation. Furthermore, if x M y, then for every z Σ, also xz M yz. Therefore, xz L if and only if yz L. This means that x M y = x L y. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 7
8 Myhill-Nerode Theorem: Proof (cont.) = The equivalence relation M has finitely many equivalence classes (at most the number of states in M). We saw that x M y = x L y. This means that the equivalence classes of M refine those of L. Thus, the number of equivalence classes of M is greater or equal than the number of equivalence classes of L. Therefore, L has finitely many equivalence classes, as desired. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 8
9 Myhill-Nerode Theorem: Proof (cont.) = Suppose L has finitely many equivalence classes. We ll construct a DFA M that accepts L. Let x 1,...,x n Σ be representatives for the finitely many equivalence classes of L. The states of M are the equivalence classes [x 1 ],...,[x n ]. The transition function δ is defined as follows: For all a Σ, δ([x i ],a) = [x i a] (the equivalence class of x i a). Why is δ well-defined? (Hint: right invariance: if x L y, then xz L yz). Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 9
10 Myhill-Nerode Theorem: Proof (conc.) = The initial state is [ε]. The accept states are F = {[x i ] x i L}. Easy: On input x Σ, M ends at state [x] (why?). Therefore M accepts x iff x L (why?). So L is accepted by DFA, hence L is regular. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 10
11 Context Switch Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 11
12 Algorithmic Questions for NFAs Q.: Given an NFA, N, and a string s, is s L(N)? Answer: Construct the DFA equivalent to N and run it on w. Q.: Is L(N) =? Answer: This is a reachability question in graphs: Is there a path in the states graph of N from the start state to some accepting state. There are simple, efficient algorithms for this task. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 12
13 More Algorithmic Questions for NFAs Q.: Is L(N) = Σ? Answer: Check if L(N) =. Q.: Given N 1 and N 2, is L(N 1 ) L(N 2 )? Answer: Check if L(N 2 ) L(N 1 ) =. Q.: Given N 1 and N 2, is L(N 1 ) = L(N 2 )? Answer: Check if L(N 1 ) L(N 2 ) and L(N 2 ) L(N 1 ). In the future, we will see that for stronger models of computations, many of these problems cannot be solved by any algorithm. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 13
14 Another, More Radical Context Switch So far we saw finite automata, regular languages, regular expressions, Myhill-Nerode theorem and pumping lemma for regular languages. We now introduce stronger machines and languages with more expressive power: pushdown automata, context-free languages, context-free grammars, pumping lemma for context-free languages. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 14
15 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. Each rule has the form: symbol string. The left-hand symbol is a variable (usually upper-case). A string consists of variables and terminals. One variable is the start variable. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 15
16 Rules for Generating Strings Write down the start variable (lhs of top rule). Pick a variable written down in current string and a derivation that starts with that variable. Replace that variable with right-hand side of that derivation. Repeat until no variables remain. Return final string (concatenation of terminals). Process is inherently non deterministic. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 16
17 Example Grammar G 1 : A 0A1 A B B # Derivation with G 1 : A 0A1 00A11 000A B #111 Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 17
18 A Parse Tree A A A B # Question: What strings can be generated in this way from the grammar G 1? Answer: Exactly those of the form 0 n #1 n (n 0). Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 18
19 Context-Free Languages The language generated in this way is called the language of the grammar. For example, L(G 1 ) is {0 n #1 n n 0}. Any language generated by a context-free grammar is called a context-free language. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 19
20 A Useful Abbreviation Rules with same variable on left hand side A A 0A1 B are written as: A 0A1 B Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 20
21 English-like Sentences A grammar G 2 to describe a few English sentences: < SENTENCE > < NOUN-PHRASE >< VERB > < NOUN-PHRASE > < ARTICLE >< NOUN > < NOUN > boy girl flower < ARTICLE > a the < VERB > touches likes sees Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 21
22 Deriving English-like Sentences A specific derivation in G 2 : < SENTENCE > < NOUN-PHRASE >< VERB > < ARTICLE >< NOUN >< VERB > a < NOUN >< VERB > a boy < VERB > a boy sees More strings generated by G 2 : a flower sees the girl touches Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 22
23 Derivation and Parse Tree < SENTENCE > < NOUN-PHRASE >< VERB > < ARTICLE >< NOUN >< VERB > a < NOUN >< VERB > a boy < VERB > a boy sees SENTENCE NOUN-PHRASE VERB ARTICLE NOUN a boy sees Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 23
24 Formal Definitions A context-free grammar is a 4-tuple (V, Σ,R,S) where V is a finite set of variables, Σ is a finite set of terminals, R is a finite set of rules: each rule is a variable and a finite string of variables and terminals. S is the start symbol. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 24
25 Formal Definitions If u and v are strings of variables and terminals, and A w is a rule of the grammar, then we say uav yields uwv, written uav uwv. We write u v if u = v or u u 1... u k v. for some sequence u 1,u 2,...,u k. { Definition: The language } of the grammar is w Σ S w. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 25
26 Example Consider G 3 = (V, {(, )},R,S). R (Rules): S (S) SS ε. Some words in the language: (()), (()()). Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 26
27 Arithmetic Example Consider G 4 = (V, Σ,R,E) where V = {E,T,F } Σ = {a, +,, (, )} Rules: E E + T T T T F F F (E) a Strings generated by the grammar: a + a a and (a + a) a. What is the language of this grammar? Hint: arithmetic expressions. E = expression, T = term, F = factor. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 27
28 Parse Tree for a + a a E T F E + T T T F F (E) a E E T T T F F F a + a X a Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 28
29 Parse Tree for (a + a) a E T E T F E + T T T F F (E) a T F E E T T F F F ( a + a ) X a Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 29
30 Designing Context-Free Grammars - 1 If CFG is the union of several CFGs, rename variables (not terminals) so they are disjoint, and add new rule S S 1 S 2... S i. For example, to get a grammar for the language L = {0 n 1 n n 0} {1 n 0 n n 0} we construct the grammars: S 1 0 S 1 1 ǫ and then add the rule: S 2 1 S 2 0 ǫ S S 1 S 2 Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 30
31 Designing Context-Free Grammars - 2 To construct CFG for a regular language, follow a DFA for the language. For initial state q 0, make R 0 the start variable. For state transition δ(q i,a) = q j add rule R i ar j to grammar. For each final state q f, add rule R f ε to grammar. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 31
32 Designing Context-Free Grammars - 3 For languages with linked substrings, a rule of form R urv may be helpful, forcing desired relation between substrings. For L = {0 n 1 n n 0}: For L = {1 n ##0 n n 0}: S 0 S 1 ǫ S 1 S 0 ## Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 32
33 Closure Properties Regular languages are closed under union concatenation star Context-Free Languages are closed under union : S S 1 S 2 concatenation S S 1 S 2 star S ε SS Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 33
34 More Closure Properties Regular languages are also closed under complement (reverse accept/non-accept states of DFA) ) intersection (L 1 L 2 = L 1 L 2. What about complement and intersection of context-free languages? Not clear... Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 34
35 Ambiguity Grammar: E E+E E E (E) a a X a + a E E E E E a X a + a E E E E E Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 35
36 Ambiguity We say that a string w is derived ambiguously from grammar G if w has two or more parse trees that generate it from G. Ambiguity is usually not only a syntactic notion but also a semantic one, implying multiple meanings for the same string. It is sometime possible to eliminate ambiguity by finding a different context free grammar generating the same language. This is true for the grammar above, which can be replaced by unambiguous grammar from slide 50. Some languages (e.g. {1 i 2 j 3 k i = j or j = k} are inherentrly ambigous. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 36
37 Chomsky Normal Form A simplified, canonical form of context free grammars. Every rule has the form A A S BC a ε 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. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 37
38 Theorem Theorem: Any context-free language is generated by a context-free grammar in Chomsky normal form. Basic idea: Add new start symbol S 0. Eliminate all ε rules of the form A ε. Eliminate all unit rules of the form A B. Patch up rules so that grammar generates the same language. Convert remaining long rules to proper form. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 38
39 Proof Idea 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. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 39
40 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. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 40
41 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. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 41
42 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 Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 42
43 Conversion Example Initial Grammar: S A B ASA ab B S b ε (1) Add new start state: S 0 S S ASA ab A B S B b ε Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 43
44 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 ε Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 44
45 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 Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 45
46 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 Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 46
47 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 Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 47
48 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 Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 48
49 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 Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 49
50 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 Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 50
51 Non-Context-Free Languages The pumping lemma for finite automata and Myhill-Nerode theorem are our tools for showing that languages are not regular. We do not have a simple Myhill-Nerode type theorem. However, will now show a similar pumping lemma for context-free languages. It is slightly more complicated... Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 51
52 Pumping Lemma for CFL Also known as the uvxyz Theorem. Theorem: If A is a CFL, there is an l (critical length), such that if s A and s l, then s = uvxyz where for every i 0, uv i xy i z A vy > 0, (non-triviality) vxy l. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 52
53 Basic Intuition Let A be a CFL and G its CFG. Let s be a very long string in A. Then s must have a tall parse tree. And some root-to-leaf path must repeat a symbol. ahmmm,... why is that so? T R R u v x y z Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 53
54 Proof let G be a CFG for CFL A. let b be the max number of symbols in right-hand-side of any rule. no node in parse tree has > b children. at depth d, can have at most b d leaves. let V be the number of variables in G. set l = b V +2. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 54
55 Proof (2) let s be a string where s l let T be parse tree for s with fewest nodes T has height V + 2 some path in T has length V + 2 that path repeats a variable R Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 55
56 Proof (3) Split s = uvxyz T R R u v x y z each occurrence of R produces a string upper produces string vxy lower produces string x Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 56
57 Proof(4) Replacing smaller by larger yields uv i xy i z, for i > 0. T R R u v Rx y z Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 57
58 Proof (5) Replacing larger by smaller yields uxz. T R x u z Together, they establish: for all i 0, uv i xy i z A Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 58
59 Proof (6) Next condition is: vy > 0 (out of uvxyz) T R x If v and y are both ε, then u z is a parse tree for s with fewer nodes than T, contradiction. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 59
60 Proof (7) Final condition is vxy l: T R R V +2 u v x y z b V +2 the upper occurrence of R generates vxy. can choose symbols such that both occurrences of R lie in bottom V + 1 variables on path. subtree where R generates vxy is V + 2 high. strings by subtree at most b V +2 = l long. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 60
61 Non CFL Example Theorem: B = {a n b n c n } is not a CFL. Proof: By contradiction. Let l be the critical length. Consider s = a l b l c l. If s = uvxyz, neither v nor y can contain both a s and b s, or both b s and c s, because otherwise uv 2 xy 2 z would have out-of-order symbols. But if v and y contain only one letter, then uv 2 xy 2 z has an imbalance! Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 61
62 Non CFL Example (2) The language C = { a i b j c k 0 i j k } is not context-free. Let l be the critical length, and s = a l b l c l. Let s = uvxyz Neither v nor y contains two distinct symbols, because uv 2 xy 2 z would then have out-of-order symbols. Then one of the symbols a,b,c does not appear neither in v nor in y. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 62
63 Non CFL Example (2) - cont. The language C = { a i b j c k 0 i j k } is not context-free. Let l be the critical length, and s = a l b l c l. Let s = uvxyz One of the symbols a,b,c does not appear neither in v nor in y: If a s do not appear, then the string uv 0 xy 0 z C, as it has the same number of a s as s, but has fewer b s or fewer c s. If b s do not appear, then either a s or c s must appear in v or y (as they cannot be both empty). If a s appear, then the string uv 2 xy 2 z C, as it contains more a s than b s. If c s appear, the string uv 0 xy 0 z C, as it contains more b s If c s do not appear, then the string uv 2 xy 2 z C, as it contains more a s or more b s than c s. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 63
64 Non CFL Example (3) The language D = { ww w {0, 1} } is not context-free. Let s = 0 l 1 l 0 l 1 l As before, suppose s = uvxyz. Recall that vxy l. if vxy is in the first half of s, uv 2 xy 2 z moves a 1 into the first position in second half. if vxy is in the second half, uv 2 xy 2 z moves a 0 into the last position in first half. if vxy straddles the midpoint, then pumping down to uxz yields 0 l 1 i 0 j 1 l where i and j cannot both be l. Interestingly, we will shortly see that D = { ww R w {0, 1} } is a CFL. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 64
65 String Generators and String Acceptors Regular expressions are string generators they tell us how to generate all strings in a language L Finite Automata (DFA, NFA) are string acceptors they tell us if a specific string w is in L CFGs are string generators Are there string acceptors for Context-Free languages? YES! Push-down automata Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 65
66 A Finite Automaton Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 66
67 A PushDown Automaton Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 67
68 A PushDown Automaton We add a memory device with restricted access: A stack (last in, first out; push/pop). Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 68
69 An Example Recall that the language {0 n 1 n n 0} is not regular. Consider the following PDA: Read input symbols, one by one For each 0, push it on the stack As soon as a 1 is seen, pop a 0 for each 1 read Accept if stack is empty when last symbol read Reject if Stack is non-empty when end of input symbol read Stack is empty but input symbol(s) still exist, 0 is read after 1. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 69
70 PDA Configuration A Configuration of a Push-Down Automata is a triplet (<state>, <remaining input string>, <stack>). A configuration is like a snapshot of PDA progress. A PDA computation is a sequence of successive configurations, starting from start configuration. In the string describing the stack, we put the top of the stack on the left (technical item). Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 70
71 Comparing PDA and Finite Automata Our PDAs have a special end of input symbol, $. This symbol is not part of input alphabet Σ. (This technical point differs from book. It is for convenience, and can be handled differently too.) PDA may be deterministic or non-deterministic. Unlike finite automata, non-determinism adds power: There are some languages accepted only by non-deterministic PDAs. Transition function δ looks different than DFA or NFA cases, reflecting stack functionality. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 71
72 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 Γ ε ) Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 72
73 Formal Definitions 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. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 73
74 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. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 74
75 Semi Formal Definitions A pushdown automaton (PDA) M accepts a string x if there is a computation of M on x (a sequence of state and stack transitions according to M s transition function and corresponding to x) that leads to an accepting state and empty stack. The language accepted by M is the set of all strings x accepted by M. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 75
76 Notation Transition a,b c means if read a from input and pop b from stack then push c onto stack Meaning of ε transitions: if a = ε, don t read inputs if b = ε, don t pop any symbols if c = ε, don t push any symbols Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 76
77 Example The PDA accepts {0 n 1 n n 1}. Does it also accept the empty string? Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 77
78 Another 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! Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 78
79 Another Example (cont.) This PDA accepts { } a i b j c k i,j,k > 0 and i = j or i = k Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 79
80 Another Example (cont.) A PDA that accepts { a i b j c k i,j,k > 0 and i = j or i = k } Note: non-determinism is essential here! Unlike finite automata, non-determinism does add power. Let us try to think how a proof that nondeterminism is indeed essential could go,. and realize it does not seem trivial or immediate. We will later give a proof that the language 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. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 80
81 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 L[M] = L} We already know L PDA L DFA, since every DFA is just a PDA that ignores the stack. L CFG L PDA? L PDA L CFG? Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 81
82 Equivalence Theorem Theorem: 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. Based on slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 82
Computational 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 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 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 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 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 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 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 informationComputational Models: Class 5
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
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 - 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 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 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 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 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 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 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 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 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 informationComputational 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 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 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 informationTheory of Computation
Fall 2002 (YEN) Theory of Computation Midterm Exam. Name:... I.D.#:... 1. (30 pts) True or false (mark O for true ; X for false ). (Score=Max{0, Right- 1 2 Wrong}.) (1) X... If L 1 is regular and L 2 L
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 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 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: Captured by Regular Operations a b
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 informationLecture III CONTEXT FREE LANGUAGES
1. Context Free Languages and Grammar Lecture III Page 1 Lecture III CONTEXT FREE LANGUAGES Lecture 3: Honors Theory, Spring 02. We introduce context free languages (CFL), context free grammar (CFG) and
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 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 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 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 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 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 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 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 information3515ICT: Theory of Computation. Regular languages
3515ICT: Theory of Computation Regular languages Notation and concepts concerning alphabets, strings and languages, and identification of languages with problems (H, 1.5). Regular expressions (H, 3.1,
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 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 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 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 informationPumping Lemma for CFLs
Pumping Lemma for CFLs v y s Here we go again! Intuition: If L is CF, then some CFG G produces strings in L If some string in L is very long, it will have a very tall parse tree If a parse tree is taller
More informationCliff s notes for equivalence of CFLs and L(PDAs) LisaCFL L = L(M) for some PDA M L=L(M)forsomePDAM L = L(G) for some CFG G
What s on our plate today? Cliff s notes for equivalence of CFLs and L(PDAs) LisaCFL L = L(M) for some PDA M L=L(M)forsomePDAM L = L(G) for some CFG G Pumping Lemma (one last time) Statement of Pumping
More informationContext-Free Languages
CS:4330 Theory of Computation Spring 2018 Context-Free Languages Non-Context-Free Languages Haniel Barbosa Readings for this lecture Chapter 2 of [Sipser 1996], 3rd edition. Section 2.3. Proving context-freeness
More informationContext Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer.
Context Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer. Language Generator: Context free grammars are language generators,
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 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 informationOutline. CS21 Decidability and Tractability. Machine view of FA. Machine view of FA. Machine view of FA. Machine view of FA.
Outline CS21 Decidability and Tractability Lecture 5 January 16, 219 and Languages equivalence of NPDAs and CFGs non context-free languages January 16, 219 CS21 Lecture 5 1 January 16, 219 CS21 Lecture
More informationContext-Free Languages (Pre Lecture)
Context-Free Languages (Pre Lecture) Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2017 Dantam (Mines CSCI-561) Context-Free Languages (Pre Lecture) Fall 2017 1 / 34 Outline Pumping Lemma
More informationMA/CSSE 474 Theory of Computation
MA/CSSE 474 Theory of Computation Bottom-up parsing Pumping Theorem for CFLs Recap: Going One Way Lemma: Each context-free language is accepted by some PDA. Proof (by construction): The idea: Let the stack
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 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 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 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 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 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 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 informationEinführung in die Computerlinguistik
Einführung in die Computerlinguistik Context-Free Grammars (CFG) Laura Kallmeyer Heinrich-Heine-Universität Düsseldorf Summer 2016 1 / 22 CFG (1) Example: Grammar G telescope : Productions: S NP VP NP
More informationAutomata Theory. CS F-10 Non-Context-Free Langauges Closure Properties of Context-Free Languages. David Galles
Automata Theory CS411-2015F-10 Non-Context-Free Langauges Closure Properties of Context-Free Languages David Galles Department of Computer Science University of San Francisco 10-0: Fun with CFGs Create
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 informationContext Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages
Context Free Languages Automata Theory and Formal Grammars: Lecture 6 Context Free Languages Last Time Decision procedures for FAs Minimum-state DFAs Today The Myhill-Nerode Theorem The Pumping Lemma Context-free
More informationContext-Free Grammars and Languages. Reading: Chapter 5
Context-Free Grammars and Languages Reading: Chapter 5 1 Context-Free Languages The class of context-free languages generalizes the class of regular languages, i.e., every regular language is a context-free
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 informationFinite Automata and Regular languages
Finite Automata and Regular languages Huan Long Shanghai Jiao Tong University Acknowledgements Part of the slides comes from a similar course in Fudan University given by Prof. Yijia Chen. http://basics.sjtu.edu.cn/
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 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 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 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 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 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 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 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 informationContext-Free Languages
CS:4330 Theory of Computation Spring 2018 Context-Free Languages Pushdown Automata Haniel Barbosa Readings for this lecture Chapter 2 of [Sipser 1996], 3rd edition. Section 2.2. Finite automaton 1 / 13
More information1 More finite deterministic automata
CS 125 Section #6 Finite automata October 18, 2016 1 More finite deterministic automata Exercise. Consider the following game with two players: Repeatedly flip a coin. On heads, player 1 gets a point.
More informationContext Free Grammars
Automata and Formal Languages Context Free Grammars Sipser pages 101-111 Lecture 11 Tim Sheard 1 Formal Languages 1. Context free languages provide a convenient notation for recursive description of languages.
More informationFunctions on languages:
MA/CSSE 474 Final Exam Notation and Formulas page Name (turn this in with your exam) Unless specified otherwise, r,s,t,u,v,w,x,y,z are strings over alphabet Σ; while a, b, c, d are individual alphabet
More information5 Context-Free Languages
CA320: COMPUTABILITY AND COMPLEXITY 1 5 Context-Free Languages 5.1 Context-Free Grammars Context-Free Grammars Context-free languages are specified with a context-free grammar (CFG). Formally, a CFG G
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 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 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 informationSri vidya college of engineering and technology
Unit I FINITE AUTOMATA 1. Define hypothesis. The formal proof can be using deductive proof and inductive proof. The deductive proof consists of sequence of statements given with logical reasoning in order
More informationAC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013
Q.2 a. Prove by mathematical induction n 4 4n 2 is divisible by 3 for n 0. Basic step: For n = 0, n 3 n = 0 which is divisible by 3. Induction hypothesis: Let p(n) = n 3 n is divisible by 3. Induction
More informationContext Free Languages: Decidability of a CFL
Theorem 14.1 Context Free Languages: Decidability of a CFL Statement: Given a CFL L and string w, there is a decision procedure that determines whether w L. Proof: By construction. 1. Proof using a grammar
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 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 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 informationHKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed
HKN CS/ECE 374 Midterm 1 Review Nathan Bleier and Mahir Morshed For the most part, all about strings! String induction (to some extent) Regular languages Regular expressions (regexps) Deterministic finite
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 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 informationFall 1999 Formal Language Theory Dr. R. Boyer. Theorem. For any context free grammar G; if there is a derivation of w 2 from the
Fall 1999 Formal Language Theory Dr. R. Boyer Week Seven: Chomsky Normal Form; Pumping Lemma 1. Universality of Leftmost Derivations. Theorem. For any context free grammar ; if there is a derivation of
More informationDD2371 Automata Theory
KTH CSC VT 2008 DD2371 Automata Theory Dilian Gurov Lecture Outline 1. The lecturer 2. Introduction to automata theory 3. Course syllabus 4. Course objectives 5. Course organization 6. First definitions
More informationProperties of Context-free Languages. Reading: Chapter 7
Properties of Context-free Languages Reading: Chapter 7 1 Topics 1) Simplifying CFGs, Normal forms 2) Pumping lemma for CFLs 3) Closure and decision properties of CFLs 2 How to simplify CFGs? 3 Three ways
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 informationNon-context-Free Languages. CS215, Lecture 5 c
Non-context-Free Languages CS215, Lecture 5 c 2007 1 The Pumping Lemma Theorem. (Pumping Lemma) Let be context-free. There exists a positive integer divided into five pieces, Proof for for each, and..
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 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 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 informationCOMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 5 : DFA minimization
COMP-33 Theory of Computation Fall 27 -- Prof. Claude Crépeau Lec. 5 : DFA minimization COMP 33 Fall 27: Lectures Schedule 4. Context-free languages 5. Pushdown automata 6. Parsing 7. The pumping lemma
More informationPushdown Automata. Reading: Chapter 6
Pushdown Automata Reading: Chapter 6 1 Pushdown Automata (PDA) Informally: A PDA is an NFA-ε with a infinite stack. Transitions are modified to accommodate stack operations. Questions: What is a stack?
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 information