Context Free Languages
|
|
- Damian Anderson
- 7 years ago
- Views:
Transcription
1 Computer Science Department Fall 2014
2 Outline Context Free Grammars (CFGs) Ambiguity Chomsky Normal Form Pushdown Automata (PDAs) Equivalence between CFGs and PDAs The Pumping Lemma
3 Formal Grammars We ve seen that regular languages can be recognized by finite automata. Other types of automata recognize other classes of languages. Formal languages can also be described by formal grammars. Intuitively a grammar is a set of variables and terminal symbols, and a set of rules which state when a variable can be replaced with another string. Example A 0A1 A B B # A, B are variables (A is the start ), and 0, 1, # terminals. The grammar generates the language {0 n #1 n n 1}. Starting with A, there is a sequence of rule applications in which variables on the left side are replaced with strings on the right. The language above is not regular. It is context free, however.
4 Formal Grammar Definition A formal grammar G = (V, Σ, R, S) is a 4-tuple consisting of 1. a finite set V of nonterminal symbols or variables; 2. a finite set Σ of terminal symbols; 3. a finite set R of substitution (production) rules u v, where u and v are both strings from (V Σ), and u contains a variable; 4. a designated start symbol S V ; Sets V, Σ, and R are disjoint. Placing restrictions on the form of rules determines whether the language of the grammar falls into a particular class (e.g., regular).
5 Context Free Grammars and Languages Definition A formal grammar G = (V, Σ, R, S) is context free if and only if for each rule u v in R, u is a single variable. If u, v and w are strings from (V Σ) + and A w a rule of R, then uav yields uwv, written uav uwv. u derives v, written u v, if and only if u v or there is a sequence u u 1 u k v, with k 0. L(G) = {w S w} is the language of the grammar. Example A 0A1 A B B # A 0A1 00A11 000A B #111 L(G) = {0 n #1 n n 1}
6 Formal Grammars Multiple rules for the same variable are often written using. Other types of automata recognize other classes of languages. Example A 0A1 A B B # is equivalent to A 0A1 B B #
7 Example Here, variables are indicated with ( and ). Example (SENTENCE) (NOUN-PHRASE) (VERB-PHRASE) (NOUN-PHRASE) (CMPLX-NOUN) (CMPLX-NOUN)(PREP-PHRASE) (VERB-PHRASE) (CMPLX-VERB) (CMPLX-VERB)(PREP-PHRASE) (PREP-PHRASE) (PREP) (CMPLX-NOUN) (CMPLX-NOUN) (ARTICLE) (NOUN) (CMPLX-VERB) (VERB) (VERB)(NOUN-PHRASE) (ARTICLE) a the (NOUN) boy girl flower (VERB) touches likes sees (PREP) with The above grammar generates strings such as. a girl with a flower likes the boy
8 Combining Grammars Grammars can be combined to form new grammars. This fact can be used to design grammars for particular languages. Example Let G 1 be S 1 0S 1 1 ε. L(G 1 ) = {0 n 1 n n 0}. Let G 2 be S 2 1S 2 0 ε. L(G 2 ) = {1 n 0 n n 0}. Let G be S S 1 S 2 S 1 0S 1 1 ε S 2 1S 2 0 ε L(G) = {1 n 0 n n 0} {0 n 1 n n 0}.
9 CFGs for Regular Languages Context free grammars can be easily constructed for regular languages. Let D = (Q, Σ, δ, q 0, F ) be a DFA. Construct a CFG G = (V, Σ, R, S) as follows: 1. V = {R i q i Q} (make a variable for each state of Q). 2. S = R 0 (S corresponds to the start state q 0). 3. For each transition δ(q i, a) = q j, add rule R i ar j to R. 4. For each q i F, add rule R i ε to R. In general, a grammar is regular if all rules are of the form: A ab A a A ε where A, B V and a Σ. A language is regular if some regular grammar generates it.
10 In-class Questions L(M) = CSCI {w 2670 w ends Context in FreeaLanguages 1}. Give the regular grammar for the language which can be accepted by the following DFA M. The above DFA M can be formally defined as follows: Q = {q 1, q 2}. Σ = {0, 1}. δ is given by the table: δ 0 1 q 1 q 1 q 2 q 2 q 1 q 2 q 0 = q 1. F = {q 2}
11 In-class Questions Give the regular grammar for the language which can be accepted by the following DFA M. The regular grammar G can be formally defined as follows: V = {R 1, R 2}. Σ = {0, 1}. the set of rules R: S = R 1. R 1 0R 1 1R 2 R 2 0R 1 1R 2 ε
12 Parse Trees The derivation of a string using a grammar can also be represented using a parse tree.
13 Ambiguity In a given CFG, it s possible for there to be multiple parse trees for the same string w. Such a grammar is said to be ambiguous. Definition A derivation of a string w in a grammar is a leftmost derivation if, at each step of the derivation, it is the leftmost variable of the string that is replaced. A string w is derived ambiguously in CFG G if it has two or more leftmost derivations. A CFG G is ambiguous if it generates some string ambiguously. Some languages are inherently ambiguous. They can only be generated by ambiguous grammars.
14 Ambiguity Example This grammar is ambiguous (but the language generated by it is not inherently ambiguous). < EXPR > < EXPR > + < EXPR > < EXPR > < EXPR > (< EXPR >) a
15 Chomsky Normal Form Definition A CFG G is in Chomsky Normal Form (CNF) if and only if every rule of the grammar is of the form: A BC A a S ε where S is the start variable, A is any variable, B and C are variables other than S, and a is any terminal. Theorem For each CFL L, there exists a grammar G in CNF such that L(G) = L.
16 Chomsky Normal Form Theorem For each CFL L, there exists a grammar G in CNF such that L(G) = L. Proof. 1. Add a new start symbol and rule S 0 S, where S is the old start. 2. For each A ε (A S 0), delete it and for each B w, where A appears in w, add rules B w, where w is w with one or more As removed. If w = ε and B ε was deleted, don t re-add it. Repeat until all ε rules are deleted. 3. Remove each rule A B: If rule B u exists, add rule A u unless it was previously removed. 4. For each rule of the form A u 1u 2... u n, where each u i V Σ and n 3, replace the rule with rules A u 1A 1, A 1 u 2A 2,... A n 2 u n 1u n, where each A i is a new variable. 5. Replace each rule of the form A ub, u Σ, with A UB and U u.
17 Chomsky Normal Form Convert the following to CNF: S ASA ab A B S B b ε Step 1: Add a new start symbol and rule. Step 2: Process ε rules. S 0 S S ASA ab A B S B b ε S 0 S S ASA ab a A B S ε B b ε
18 Chomsky Normal Form Step 2: Process ε rules. S 0 S S ASA ab a AS SA S A B S ε B b Step 3: Process unit rules (S S). Here, no new rules need to be added. S 0 S S ASA ab a AS SA S A B S B b
19 Chomsky Normal Form Step 3: Process unit rules (S 0 S). S 0 S ASA ab a AS SA S ASA ab a AS SA A B S B b Step 3: Process unit rules (A S). S 0 ASA ab a AS SA S ASA ab a AS SA A B S ASA ab a AS SA B b
20 Chomsky Normal Form Step 3: Process unit rules (A B). S 0 ASA ab a AS SA S ASA ab a AS SA A B b ASA ab a AS SA B b Step 4: Process remaining rules. S 0 AA 1 ab a AS SA S AA 1 ab a AS SA A b AA 1 ab a AS SA B b A 1 SA
21 Chomsky Normal Form Step 4: Process remaining rules. S 0 AA 1 UB a AS SA S AA 1 UB a AS SA A b AA 1 UB a AS SA B b A 1 SA U a At this point, the grammar is in Chomsky Normal Form.
22 Stack
23 Conceptual View of a Stack
24 Stack: Push Operation
25 Stack: Pop Operation
26 Pushdown Automata Context free languages are recognized by pushdown automata (PDAs). A PDA has a memory in the form of a stack. At each step of computation, the PDA occupies some state q, a symbol a can be read from the input string (optionally, nothing need be read), and a symbol b can be popped from the top of the stack (optionally, nothing need be popped). Based on the state, input symbol, and stack symbol, the PDA optionally pushes a symbol onto the stack, and changes state. A PDA accepts a string w if it occupies an accept state after reading the last symbol of the input. Note that PDAs can be nondeterministic. Nondeterministic PDAs are more powerful than deterministic PDAs.
27 Pushdown Automata Definition A pushdown automaton P is a 6-tuple (Q, Σ, Γ, δ, q o, F ), where 1. Q is a finite set of states, 2. Σ is a finite input alphabet, 3. Γ is a finite stack alphabet, 4. δ : (Q Σ ε Γ ε ) P(Q Γ ε ) is the transition function, 5. q 0 is the start state, 6. F Q is a set of accept states. δ maps triples (q, a, b) where q is a state, a an input symbol, and b a stack symbol to sets of pairs (q, b ), where q is a state and b a stack symbol. a,b, b can also be ε. δ is nondeterministic. The PDA needn t read an input or stack symbol, and it needn t write a stack symbol. In general, there might be multiple transitions for a given state, input symbol, and stack symbol.
28 Transition Tables for PDAs Example Let M 1 = (Q, Σ, Γ, δ, q 1, F ), where 1. Q = {q 1, q 2, q 3, q 4 }, 2. Σ = {0, 1}, 3. Γ = {0, $}, 4. F = {q 1, q 4 }, and 5. δ is given by the below table. Input 0 1 ε Stack 0 $ ε 0 $ ε 0 $ ε q 1 {(q 2, $)} q 2 {(q 2, 0)} {(q 3, ε)} q 3 {(q 3, ε)} {(q 4, ε)} q 4 The symbol $ is, by convention, used to mark an empty stack. As shown in the table, when started, the PDA immediately pushes it onto the stack.
29 State Diagrams for PDAs Example The PDA M 1 recognizes the language {0 n 1 n n 0}. The PDA may be represented using the following state diagram. A label a, b c means that a is read from the input, b is popped from the stack, and c is pushed onto the stack.
30 Acceptance for PDAs Definition Let P = (Q, Σ, Γ, δ, q o, F ) be a PDA and w = w 1 w 2... w m a string such that each w i Σ ɛ. P accepts w if and only if there exists a sequence r 0, r 1,..., r m of states of Q, and a sequence of strings s 0, s 1,..., s m, each s i Γ (these represent the stack contents at a given step), such that 1. r 0 = q 0 and s 0 = ε (initially, the stack is empty), 2. for each 0 i < m, (r i+1, b) δ(r i, w i, a), where s i = at and s i+1 = bt for some a, b Γ ε and t Γ, and 3. r m F.
31 Example PDAs Example The below PDA M 2 recognizes the language {a i b j c k i, j, k 0 and i = j or i = k}.
32 Example PDAs Example The below PDA M 3 recognizes the language {ww R w {0, 1} }.
33 Pushdown Automata Example Given an informal description for a PDA recognizing the below language. 1. {a i b j c k i = j or j = k where i, j, k 0}
34 Equivalence between CFGs and PDAs Theorem A language is context free if and only if it is recognized by some pushdown automaton. This can be broken down into two lemmas (which will be proven). Lemma If a language is context free, then it is recognized by a pushdown automaton. Lemma If a language is recognized by a pushdown automaton, then it is context free.
35 Equivalence between CFGs and PDAs Lemma If a language is context free, then it is recognized by a pushdown automaton. We construct a PDA to recognize context free language L. We modify the definition of the PDA slightly to allow whole strings to be pushed onto the stack in a single step (this causes no harm). The machine only has three states: q start, q loop, and q accept. The input alphabet of the PDA is Σ, the alphabet of the grammar. The stack alphabet is {$} V Σ. The transition functions for the PDA are as follows: δ(q start, ε, ε) = {(q loop, S$), where S is the start state of the grammar. If A w is a rule of G, then (q loop, w) δ(q loop, ε, A). If a Σ, then (q loop, ε) δ(q loop, a, a). (q accept, ε) δ(q loop, ε, $).
36 Equivalence between CFGs and PDAs The conversion produces a PDA of the form below. It accepts w if it enters q accept (and there is no more input). (Undefined transitions go to a trap state).
37 Equivalence between CFGs and PDAs Implementing pushing a compound string onto the stack.
38 Equivalence between CFGs and PDAs Construct a PDA for the following grammar. S atb b T Ta ε
39 Equivalence between CFGs and PDAs
40 Equivalence between CFGs and PDAs Construct a PDA for the following grammar. Try processing (()()). S SS (S) ()
41 Equivalence between CFGs and PDAs Lemma If a language is recognized by a pushdown automaton, then it is context free. For this direction, we construct a grammar to generate the language recognized by the PDA P. P must have a certain form. It has a single accept state, q accept. An existing PDA can be modified by adding a new accept state and connecting old states to it via ε-edges. It can only accept a string if its stack is empty. This can be accomplished by adding loops ε, a ε to the accept state for each a Γ. Each step pops or pushes a stack symbol but never both. This can be accomplished by adding new states and modifying transitions: 1. If a transition pops and pushes, split the transition into separate pop and push transitions going through a new state. 2. If a transition neither pops nor pushes, add transitions to push and then pop an arbitrary symbol, going through a new state.
42 Equivalence between CFGs and PDAs Given PDA P = (Q, Σ, Γ, δ, q 0, {q accept}), we construct the grammar G = (V, Σ, R, S) as follows: V = {A pq p Q and q Q} (we add a variable for each pair of states). S = A q0 q accept. R is defined as follows: For each p Q, add A pp ε. For each p, q, r Q, add rule A pq A pr A rq. For each p, q, r, s Q, t Γ, and a, b Σ ε, if (r, t) δ(p, a, ε) and (q, ε) δ(s, b, t), then add A pq aa rsb to R. In the grammar, if one starts in state A pq and applies the rules, all of the strings that take the PDA P from state p (and an empty stack) to state q (with an empty stack) will be generated. A q0 q accept generates all strings that take P from q 0 to q accept (beginning and ending with an empty stack). I.e., A q0 q accept generates L(P). The starting and ending with the empty stack implies that it is possible to begin and end with the same stack contents, regardless of what that is.
43 Equivalence between CFGs and PDAs Proposition If A pq generates x, then x can bring P from p with empty stack to q with empty stack. The proof is by induction on the length of the derivation of x from variable A pq. Basis: If the derivation takes only one step then the rule used must be A pp ε. All other rules contain variables on the RHS. And so x = ε and q = p. It is clearly possible to go from p to p reading ε (by staying put).
44 Equivalence between CFGs and PDAs Induction: Suppose the claim holds for derivations of length k or less, k 1, and suppose the derivation of x from A pq takes k + 1 steps. Since the derivation is of length greater than 1, it must be that the rule used has either the form A pq aa rsb or A pr A rq. We consider each in turn. If the rule has the form A pq aa rsb, then x = awb and A rs w. By the construction of G, (r, t) δ(p, a, ε) and (q, ε) δ(s, b, t), for some a, b Σ ε and t Γ. That is, one may go from p to r reading input a and pushing t onto the stack. By the inductive hypothesis, w can bring P from state r to state s, leaving the stack in the same state as when it started (here, with t as the top symbol). Given that (q, ε) δ(s, b, t), x thus can bring p with empty stack to q with empty stack. If the rule has the form A pq A pr A rq, then x can be split into halves y and z such that A pr y and A rq z. By the inductive hypothesis, y can bring P from p with empty stack to r with empty stack, and z can bring P from r with empty stack to q with empty stack. And so x = yz can bring P from p with empty stack to q with empty stack. One of these cases must hold, and so the claim holds.
45 Equivalence between CFGs and PDAs Proposition If x can bring P from p with empty stack to q with empty stack, then A pq generates x. The proof is by induction on the number of steps in the computation brings P from p with empty stack to q with empty stack on input x. Basis: Suppose the computation has 0 steps. Then p = q and x must be ε. Since A pp ε is rule of G, A pq generates x.
46 Equivalence between CFGs and PDAs Induction: Suppose the claim holds for all computations taking k or fewer steps, k 0, and suppose a computation of P on input x takes k + 1 steps. Suppose the stack is empty only at the beginning and end of the computation. Then an input symbol a is read and a symbol t is pushed onto the stack on the first move, and P enters state r. t must be popped from the stack in the last move. Let b be the symbol read in the last move and s the state of P before the last move. Then (r, t) δ(p, a, ε) and (q, ε) δ(s, b, t). As such, rule A pq aa rsb exists as a rule of G. Let x = ayb. y can bring P from state r to state s never popping t from the stack, and so y can bring P from r with empty stack to s with empty stack. By the ind. hyp., A rs generates y. From this, A pq generates x. If the stack is empty at some intermediary step with corresponding state r, then the computations from p to r and from r to q both have length less than k + 1. Let y be the input read going from state p to r in the first computation, and let z be the input read during the second computation. By the ind. hyp., A pr generates y and A rq generates z. As rule A pq A pr A qr is a rule of G, it follows that A pq generates x.
47 Every regular language is context free It has been proved that pushdown automata recognize the class of context-free languages. Every regular language is recognized by a finite automaton. Every finite automaton is automatically a pushdown automaton that simply ignores its stack. Hence, every regular language is a context-free language. { regular languages } { context free languages }
48 A Pumping Lemma for CFLs Like regular languages, CFLs have strings that can be pumped. For large strings s, the parse tree for s has a branch with a repeated variable R. A later occurrence of R can be replaced with the subtree under an earlier occurrence. Similarly, an earlier occurrence can be replaced with the subtree under the last occurrence. As seen below, s = uvxyz, and v and y can be pumped.
49 A Pumping Lemma for CFLs Theorem If A is a context free language, then there exists an integer p such for all s A with s p, s may be divided into five pieces s = uvxyz such that 1. uv i xy i z A for each i 0, 2. vy > 0, and 3. vxy p. Observe that v or y can be empty, but not both. (Without this, the theorem would be trivial).
50 A Pumping Lemma for CFLs Let G be a CFG and let b be the maximum number of symbols on the RHS of any rule in G. It is clear that the branching factor of any parse tree generated by G will be at most b, and so if a parse tree for a string s has height h, then s has at most b h symbols. Similarly, if s b h + 1, it must be that any parse tree for s has height at least h + 1. (Proof of the Pumping Lemma) Let A be a CFL with grammar G, and let p = b V +1, where b is the maximum number of symbols on the RHS of any rule of G. Let s be a string generated by G such that s p. Let τ be a minimal parse tree for s (minimal in the sense that no other parse tree for s has fewer nodes than τ). Assume the root of τ is T. It follows that τ has height V + 1, and so there exists a branch B of length (in edges) V + 1. Since that is so, some variable R must appear at least twice on the branch.
51 A Pumping Lemma for CFLs (Proof of the Pumping Lemma) We may chose any branch with length V + 1, and so we assume B to be the longest branch of τ. We also assume R is a variable on B in which multiple occurrence occur on the last V + 1 variables on the path, and we let R 1 and R 2 be the last two occurrences of R on the branch. It is clear that s can be divided into uvxyz, where vxy consists of the leaves of the tree rooted at R 1, x consists of the leaves of the tree rooted at R 2, and uvxyz consists of the leaves of the tree rooted at T. Since R 1 and R 2 are occurrences of R, it is possible to replace the subtree rooted at R 2 with the one rooted at R 1, yielding a larger tree. This process can be repeated infinitely, giving parse trees for uv i xy i z for each i > 1. And so the resulting strings are all in A. Similarly, is possible to replace the subtree rooted at R 1 with the one rooted at R 2, yielding the tree τ and corresponding string uv 0 xy 0 z. If both v and y are empty, then uxz would equal uvxyz. Since τ has fewer nodes than τ, this would mean that τ is not a minimal tree for s. But we have assumed τ to be minimal, and so one of v or y must be nonempty.
52 A Pumping Lemma for CFLs (Proof of the Pumping Lemma) Since R 1 and R 2 appear among the last V + 1 variables on B, it must be that the subtree rooted at R 1 has height at most V + 1. But a tree of that height can generate strings of length at most b V +1, where b is the maximum number of symbols on the RHS of any rule of G. And so vxy b V +1. However, p = b V +1, and so vxy p.
53 A Pumping Lemma for CFLs Example B = {a n b n c n n 0} is not context free. Proof. Suppose that B is context free, and let s = a p b p c p, where p is the pumping length of B. By the pumping lemma, s = uvxyz such that vy > 0 and vxy p. Given that vxy p, v and y can consist of at most two types of symbols (e.g., a and b). Neither will contain the third (e.g., c). Thus, pumping up v and y will ruin the symmetry of s, which implies that uv 2 xy 2 z / B, contradicting the pumping lemma.
54 A Pumping Lemma for CFLs Example B = {a i b j c k 0 i j k} is not context free. Proof. Suppose that B is context free, and let s = a p b p c p, where p is the pumping length of B. By the pumping lemma, s = uvxyz such that vy > 0 and vxy p. Given that vxy p, v and y can consist of at most two types of symbols (e.g., a and b). Neither will contain the third (e.g., c). We consider the possibilities. If neither contain c, then v and y can be pumped so that the number of a s and/or b s outnumber the c s. If neither contain b, then v and y must be all a s (or empty) or else all c s. In the former case, the a s can be pumped up to outnumber the b s. In the latter, v and y can be pumped down so so that the number of b s outnumber the c s. If neither contain a s, we can again pump down so that the a s outnumber the b s, or the b s outnumber the c s.
55 A Pumping Lemma for CFLs Example 1. The language A 1 = {0 n 1 n 0 n 1 n n 0} 2. The language A 2 = {w#w w {0, 1} } 3. The language A 3 = {0 n #0 2n #0 3n n 0} 4. The language A 4 = {w#t w is a substring of t, where w, t {a, b} } Proof.???
Automata and Computability. Solutions to Exercises
Automata and Computability Solutions to Exercises Fall 25 Alexis Maciel Department of Computer Science Clarkson University Copyright c 25 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata
More informationPushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, 2014. School of Informatics University of Edinburgh als@inf.ed.ac.
Pushdown automata Informatics 2A: Lecture 9 Alex Simpson School of Informatics University of Edinburgh als@inf.ed.ac.uk 3 October, 2014 1 / 17 Recap of lecture 8 Context-free languages are defined by context-free
More informationThe Halting Problem is Undecidable
185 Corollary G = { M, w w L(M) } is not Turing-recognizable. Proof. = ERR, where ERR is the easy to decide language: ERR = { x { 0, 1 }* x does not have a prefix that is a valid code for a Turing machine
More informationFormal Languages and Automata Theory - Regular Expressions and Finite Automata -
Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Samarjit Chakraborty Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology (ETH) Zürich March
More informationFundamentele Informatica II
Fundamentele Informatica II Answer to selected exercises 1 John C Martin: Introduction to Languages and the Theory of Computation M.M. Bonsangue (and J. Kleijn) Fall 2011 Let L be a language. It is clear
More informationIntroduction to Automata Theory. Reading: Chapter 1
Introduction to Automata Theory Reading: Chapter 1 1 What is Automata Theory? Study of abstract computing devices, or machines Automaton = an abstract computing device Note: A device need not even be a
More informationÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK. 15 april 2003. Master Edition
ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK 5 april 23 Master Edition CONTEXT FREE LANGUAGES & PUSH-DOWN AUTOMATA CONTEXT-FREE GRAMMARS, CFG Problems Sudkamp Problem. (3.2.) Which language generates the grammar
More informationAutomata and Formal Languages
Automata and Formal Languages Winter 2009-2010 Yacov Hel-Or 1 What this course is all about This course is about mathematical models of computation We ll study different machine models (finite automata,
More information6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch
6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010 Class 4 Nancy Lynch Today Two more models of computation: Nondeterministic Finite Automata (NFAs)
More informationHonors Class (Foundations of) Informatics. Tom Verhoeff. Department of Mathematics & Computer Science Software Engineering & Technology
Honors Class (Foundations of) Informatics Tom Verhoeff Department of Mathematics & Computer Science Software Engineering & Technology www.win.tue.nl/~wstomv/edu/hci c 2011, T. Verhoeff @ TUE.NL 1/20 Information
More informationIncreasing Interaction and Support in the Formal Languages and Automata Theory Course
Increasing Interaction and Support in the Formal Languages and Automata Theory Course [Extended Abstract] Susan H. Rodger rodger@cs.duke.edu Jinghui Lim Stephen Reading ABSTRACT The introduction of educational
More informationRegular Languages and Finite State Machines
Regular Languages and Finite State Machines Plan for the Day: Mathematical preliminaries - some review One application formal definition of finite automata Examples 1 Sets A set is an unordered collection
More informationFinite Automata. Reading: Chapter 2
Finite Automata Reading: Chapter 2 1 Finite Automaton (FA) Informally, a state diagram that comprehensively captures all possible states and transitions that a machine can take while responding to a stream
More information3515ICT Theory of Computation Turing Machines
Griffith University 3515ICT Theory of Computation Turing Machines (Based loosely on slides by Harald Søndergaard of The University of Melbourne) 9-0 Overview Turing machines: a general model of computation
More informationPushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile
Pushdown Automata In the last section we found that restricting the computational power of computing devices produced solvable decision problems for the class of sets accepted by finite automata. But along
More informationModel 2.4 Faculty member + student
Model 2.4 Faculty member + student Course syllabus for Formal languages and Automata Theory. Faculty member information: Name of faculty member responsible for the course Office Hours Office Number Email
More informationTuring Machines: An Introduction
CIT 596 Theory of Computation 1 We have seen several abstract models of computing devices: Deterministic Finite Automata, Nondeterministic Finite Automata, Nondeterministic Finite Automata with ɛ-transitions,
More informationSRM UNIVERSITY FACULTY OF ENGINEERING & TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF SOFTWARE ENGINEERING COURSE PLAN
Course Code : CS0355 SRM UNIVERSITY FACULTY OF ENGINEERING & TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF SOFTWARE ENGINEERING COURSE PLAN Course Title : THEORY OF COMPUTATION Semester : VI Course : June
More informationCS5236 Advanced Automata Theory
CS5236 Advanced Automata Theory Frank Stephan Semester I, Academic Year 2012-2013 Advanced Automata Theory is a lecture which will first review the basics of formal languages and automata theory and then
More informationC H A P T E R Regular Expressions regular expression
7 CHAPTER Regular Expressions Most programmers and other power-users of computer systems have used tools that match text patterns. You may have used a Web search engine with a pattern like travel cancun
More informationFull and Complete Binary Trees
Full and Complete Binary Trees Binary Tree Theorems 1 Here are two important types of binary trees. Note that the definitions, while similar, are logically independent. Definition: a binary tree T is full
More informationChapter 7 Uncomputability
Chapter 7 Uncomputability 190 7.1 Introduction Undecidability of concrete problems. First undecidable problem obtained by diagonalisation. Other undecidable problems obtained by means of the reduction
More informationFast nondeterministic recognition of context-free languages using two queues
Fast nondeterministic recognition of context-free languages using two queues Burton Rosenberg University of Miami Abstract We show how to accept a context-free language nondeterministically in O( n log
More informationDeterministic Finite Automata
1 Deterministic Finite Automata Definition: A deterministic finite automaton (DFA) consists of 1. a finite set of states (often denoted Q) 2. a finite set Σ of symbols (alphabet) 3. a transition function
More information(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.
3130CIT: Theory of Computation Turing machines and undecidability (IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems. An undecidable problem
More informationAutomata on Infinite Words and Trees
Automata on Infinite Words and Trees Course notes for the course Automata on Infinite Words and Trees given by Dr. Meghyn Bienvenu at Universität Bremen in the 2009-2010 winter semester Last modified:
More informationCS 103X: Discrete Structures Homework Assignment 3 Solutions
CS 103X: Discrete Structures Homework Assignment 3 s Exercise 1 (20 points). On well-ordering and induction: (a) Prove the induction principle from the well-ordering principle. (b) Prove the well-ordering
More information6.3 Conditional Probability and Independence
222 CHAPTER 6. PROBABILITY 6.3 Conditional Probability and Independence Conditional Probability Two cubical dice each have a triangle painted on one side, a circle painted on two sides and a square painted
More informationCPS 140 - Mathematical Foundations of CS Dr. S. Rodger Section: Properties of Context-Free Languages èhandoutè Section 3.5 Which of the following languages are CFL? æ L=fa n b n c j j 0 énçjg æ L=fa n
More informationReading 13 : Finite State Automata and Regular Expressions
CS/Math 24: Introduction to Discrete Mathematics Fall 25 Reading 3 : Finite State Automata and Regular Expressions Instructors: Beck Hasti, Gautam Prakriya In this reading we study a mathematical model
More informationRegular Expressions and Automata using Haskell
Regular Expressions and Automata using Haskell Simon Thompson Computing Laboratory University of Kent at Canterbury January 2000 Contents 1 Introduction 2 2 Regular Expressions 2 3 Matching regular expressions
More informationCompiler Construction
Compiler Construction Regular expressions Scanning Görel Hedin Reviderad 2013 01 23.a 2013 Compiler Construction 2013 F02-1 Compiler overview source code lexical analysis tokens intermediate code generation
More informationFinite Automata. Reading: Chapter 2
Finite Automata Reading: Chapter 2 1 Finite Automata Informally, a state machine that comprehensively captures all possible states and transitions that a machine can take while responding to a stream (or
More informationOverview of E0222: Automata and Computability
Overview of E0222: Automata and Computability Deepak D Souza Department of Computer Science and Automation Indian Institute of Science, Bangalore. August 3, 2011 What this course is about What we study
More information6.080/6.089 GITCS Feb 12, 2008. Lecture 3
6.8/6.89 GITCS Feb 2, 28 Lecturer: Scott Aaronson Lecture 3 Scribe: Adam Rogal Administrivia. Scribe notes The purpose of scribe notes is to transcribe our lectures. Although I have formal notes of my
More informationPush-down Automata and Context-free Grammars
14 Push-down Automata and Context-free Grammars This chapter details the design of push-down automata (PDA) for various languages, the conversion of CFGs to PDAs, and vice versa. In particular, after formally
More informationThe Optimum One-Pass Strategy for Juliet
Master s Thesis One-Pass Strategies for Context-Free Games Christian Cöster August 2015 Examiners: Prof. Dr. Thomas Schwentick Prof. Dr. Christoph Buchheim Technische Universität Dortmund Fakultät für
More informationMathematical Induction
Mathematical Induction (Handout March 8, 01) The Principle of Mathematical Induction provides a means to prove infinitely many statements all at once The principle is logical rather than strictly mathematical,
More informationLearning Analysis by Reduction from Positive Data
Learning Analysis by Reduction from Positive Data František Mráz 1, Friedrich Otto 1, and Martin Plátek 2 1 Fachbereich Mathematik/Informatik, Universität Kassel 34109 Kassel, Germany {mraz,otto}@theory.informatik.uni-kassel.de
More informationSOLUTION Trial Test Grammar & Parsing Deficiency Course for the Master in Software Technology Programme Utrecht University
SOLUTION Trial Test Grammar & Parsing Deficiency Course for the Master in Software Technology Programme Utrecht University Year 2004/2005 1. (a) LM is a language that consists of sentences of L continued
More informationLecture summary for Theory of Computation
Lecture summary for Theory of Computation Sandeep Sen 1 January 8, 2015 1 Department of Computer Science and Engineering, IIT Delhi, New Delhi 110016, India. E- mail:ssen@cse.iitd.ernet.in Contents 1 The
More informationA First Investigation of Sturmian Trees
A First Investigation of Sturmian Trees Jean Berstel 2, Luc Boasson 1 Olivier Carton 1, Isabelle Fagnot 2 1 LIAFA, CNRS Université Paris 7 2 IGM, CNRS Université de Marne-la-Vallée Atelier de Combinatoire,
More informationCS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.
CS54 Turing Machines Turing Machine q 0 AI N P U T IN TAPE read write move read write move Language = {0} q This Turing machine recognizes the language {0} Turing Machines versus DFAs TM can both write
More informationTuring Machines, Part I
Turing Machines, Part I Languages The $64,000 Question What is a language? What is a class of languages? Computer Science Theory 2 1 Now our picture looks like Context Free Languages Deterministic Context
More informationGenetic programming with regular expressions
Genetic programming with regular expressions Børge Svingen Chief Technology Officer, Open AdExchange bsvingen@openadex.com 2009-03-23 Pattern discovery Pattern discovery: Recognizing patterns that characterize
More informationMathematical Induction. Lecture 10-11
Mathematical Induction Lecture 10-11 Menu Mathematical Induction Strong Induction Recursive Definitions Structural Induction Climbing an Infinite Ladder Suppose we have an infinite ladder: 1. We can reach
More informationω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear:
ω-automata ω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear: in verification, as encodings of non-terminating executions of a program. in arithmetic,
More informationFormal Grammars and Languages
Formal Grammars and Languages Tao Jiang Department of Computer Science McMaster University Hamilton, Ontario L8S 4K1, Canada Bala Ravikumar Department of Computer Science University of Rhode Island Kingston,
More informationRegular Languages and Finite Automata
Regular Languages and Finite Automata A C Norman, Lent Term 1996 Part IA 1 Introduction This course is short, but it is present in Part 1A because of the way it introduces links between many different
More information136 CHAPTER 4. INDUCTION, GRAPHS AND TREES
136 TER 4. INDUCTION, GRHS ND TREES 4.3 Graphs In this chapter we introduce a fundamental structural idea of discrete mathematics, that of a graph. Many situations in the applications of discrete mathematics
More informationCSE 135: Introduction to Theory of Computation Decidability and Recognizability
CSE 135: Introduction to Theory of Computation Decidability and Recognizability Sungjin Im University of California, Merced 04-28, 30-2014 High-Level Descriptions of Computation Instead of giving a Turing
More informationTesting LTL Formula Translation into Büchi Automata
Testing LTL Formula Translation into Büchi Automata Heikki Tauriainen and Keijo Heljanko Helsinki University of Technology, Laboratory for Theoretical Computer Science, P. O. Box 5400, FIN-02015 HUT, Finland
More informationScanner. tokens scanner parser IR. source code. errors
Scanner source code tokens scanner parser IR errors maps characters into tokens the basic unit of syntax x = x + y; becomes = + ; character string value for a token is a lexeme
More informationHow To Compare A Markov Algorithm To A Turing Machine
Markov Algorithm CHEN Yuanmi December 18, 2007 1 Abstract Markov Algorithm can be understood as a priority string rewriting system. In this short paper we give the definition of Markov algorithm and also
More informationMathematical Induction
Mathematical Induction In logic, we often want to prove that every member of an infinite set has some feature. E.g., we would like to show: N 1 : is a number 1 : has the feature Φ ( x)(n 1 x! 1 x) How
More informationPhiladelphia University Faculty of Information Technology Department of Computer Science First Semester, 2007/2008.
Philadelphia University Faculty of Information Technology Department of Computer Science First Semester, 2007/2008 Course Syllabus Course Title: Theory of Computation Course Level: 3 Lecture Time: Course
More information1. Prove that the empty set is a subset of every set.
1. Prove that the empty set is a subset of every set. Basic Topology Written by Men-Gen Tsai email: b89902089@ntu.edu.tw Proof: For any element x of the empty set, x is also an element of every set since
More informationLecture I FINITE AUTOMATA
1. Regular Sets and DFA Lecture I Page 1 Lecture I FINITE AUTOMATA Lecture 1: Honors Theory, Spring 02, Yap We introduce finite automata (deterministic and nondeterministic) and regular languages. Some
More informationRegular Languages and Finite Automata
Regular Languages and Finite Automata 1 Introduction Hing Leung Department of Computer Science New Mexico State University Sep 16, 2010 In 1943, McCulloch and Pitts [4] published a pioneering work on a
More informationCONTINUED FRACTIONS AND PELL S EQUATION. Contents 1. Continued Fractions 1 2. Solution to Pell s Equation 9 References 12
CONTINUED FRACTIONS AND PELL S EQUATION SEUNG HYUN YANG Abstract. In this REU paper, I will use some important characteristics of continued fractions to give the complete set of solutions to Pell s equation.
More informationCS 598CSC: Combinatorial Optimization Lecture date: 2/4/2010
CS 598CSC: Combinatorial Optimization Lecture date: /4/010 Instructor: Chandra Chekuri Scribe: David Morrison Gomory-Hu Trees (The work in this section closely follows [3]) Let G = (V, E) be an undirected
More informationImplementation of Recursively Enumerable Languages using Universal Turing Machine in JFLAP
International Journal of Information and Computation Technology. ISSN 0974-2239 Volume 4, Number 1 (2014), pp. 79-84 International Research Publications House http://www. irphouse.com /ijict.htm Implementation
More informationTheory of Computation Class Notes 1
Theory of Computation Class Notes 1 1 based on the books by Sudkamp and by Hopcroft, Motwani and Ullman ii Contents 1 Introduction 1 1.1 Sets.............................................. 1 1.2 Functions
More informationOn line construction of suffix trees 1
(To appear in ALGORITHMICA) On line construction of suffix trees 1 Esko Ukkonen Department of Computer Science, University of Helsinki, P. O. Box 26 (Teollisuuskatu 23), FIN 00014 University of Helsinki,
More informationOn Winning Conditions of High Borel Complexity in Pushdown Games
Fundamenta Informaticae (2005) 1 22 1 IOS Press On Winning Conditions of High Borel Complexity in Pushdown Games Olivier Finkel Equipe de Logique Mathématique U.F.R. de Mathématiques, Université Paris
More information1 Definition of a Turing machine
Introduction to Algorithms Notes on Turing Machines CS 4820, Spring 2012 April 2-16, 2012 1 Definition of a Turing machine Turing machines are an abstract model of computation. They provide a precise,
More informationConnectivity and cuts
Math 104, Graph Theory February 19, 2013 Measure of connectivity How connected are each of these graphs? > increasing connectivity > I G 1 is a tree, so it is a connected graph w/minimum # of edges. Every
More informationINCIDENCE-BETWEENNESS GEOMETRY
INCIDENCE-BETWEENNESS GEOMETRY MATH 410, CSUSM. SPRING 2008. PROFESSOR AITKEN This document covers the geometry that can be developed with just the axioms related to incidence and betweenness. The full
More informationRegular Expressions with Nested Levels of Back Referencing Form a Hierarchy
Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy Kim S. Larsen Odense University Abstract For many years, regular expressions with back referencing have been used in a variety
More informationMATH10040 Chapter 2: Prime and relatively prime numbers
MATH10040 Chapter 2: Prime and relatively prime numbers Recall the basic definition: 1. Prime numbers Definition 1.1. Recall that a positive integer is said to be prime if it has precisely two positive
More informationPushdown Automata. International PhD School in Formal Languages and Applications Rovira i Virgili University Tarragona, Spain
Pushdown Automata transparencies made for a course at the International PhD School in Formal Languages and Applications Rovira i Virgili University Tarragona, Spain Hendrik Jan Hoogeboom, Leiden http://www.liacs.nl/
More informationChapter 3. Cartesian Products and Relations. 3.1 Cartesian Products
Chapter 3 Cartesian Products and Relations The material in this chapter is the first real encounter with abstraction. Relations are very general thing they are a special type of subset. After introducing
More informationMathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson
Mathematics for Computer Science/Software Engineering Notes for the course MSM1F3 Dr. R. A. Wilson October 1996 Chapter 1 Logic Lecture no. 1. We introduce the concept of a proposition, which is a statement
More informationTwo Way F finite Automata and Three Ways to Solve Them
An Exponential Gap between LasVegas and Deterministic Sweeping Finite Automata Christos Kapoutsis, Richard Královič, and Tobias Mömke Department of Computer Science, ETH Zürich Abstract. A two-way finite
More informationSo let us begin our quest to find the holy grail of real analysis.
1 Section 5.2 The Complete Ordered Field: Purpose of Section We present an axiomatic description of the real numbers as a complete ordered field. The axioms which describe the arithmetic of the real numbers
More informationAutomata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi
Automata Theory Automata theory is the study of abstract computing devices. A. M. Turing studied an abstract machine that had all the capabilities of today s computers. Turing s goal was to describe the
More informationER E P M A S S I CONSTRUCTING A BINARY TREE EFFICIENTLYFROM ITS TRAVERSALS DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF TAMPERE REPORT A-1998-5
S I N S UN I ER E P S I T VER M A TA S CONSTRUCTING A BINARY TREE EFFICIENTLYFROM ITS TRAVERSALS DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF TAMPERE REPORT A-1998-5 UNIVERSITY OF TAMPERE DEPARTMENT OF
More informationAlgorithms and Data Structures
Algorithms and Data Structures Part 2: Data Structures PD Dr. rer. nat. habil. Ralf-Peter Mundani Computation in Engineering (CiE) Summer Term 2016 Overview general linked lists stacks queues trees 2 2
More informationGraph Theory Problems and Solutions
raph Theory Problems and Solutions Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles November, 005 Problems. Prove that the sum of the degrees of the vertices of any finite graph is
More informationOBTAINING PRACTICAL VARIANTS OF LL (k) AND LR (k) FOR k >1. A Thesis. Submitted to the Faculty. Purdue University.
OBTAINING PRACTICAL VARIANTS OF LL (k) AND LR (k) FOR k >1 BY SPLITTING THE ATOMIC k-tuple A Thesis Submitted to the Faculty of Purdue University by Terence John Parr In Partial Fulfillment of the Requirements
More informationCHAPTER 7 GENERAL PROOF SYSTEMS
CHAPTER 7 GENERAL PROOF SYSTEMS 1 Introduction Proof systems are built to prove statements. They can be thought as an inference machine with special statements, called provable statements, or sometimes
More informationGRAPH THEORY LECTURE 4: TREES
GRAPH THEORY LECTURE 4: TREES Abstract. 3.1 presents some standard characterizations and properties of trees. 3.2 presents several different types of trees. 3.7 develops a counting method based on a bijection
More informationElementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.
Elementary Number Theory and Methods of Proof CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.edu/~cse215 1 Number theory Properties: 2 Properties of integers (whole
More informationGrammars with Regulated Rewriting
Grammars with Regulated Rewriting Jürgen Dassow Otto-von-Guericke-Universität Magdeburg Fakultät für Informatik Lecture in the 5 th PhD Program Formal Languages and Applications PhD Program Formal Languages
More informationQuestions and Answers in Computer Science. By Yonas Tesfazghi Weldeselassie http://www.ictp.trieste.it/ weldesel
Questions and Answers in Computer Science By Yonas Tesfazghi Weldeselassie http://www.ictp.trieste.it/ weldesel The Questions in this material are collected from Computer Science Subject Graduate Record
More informationHow To Understand The Theory Of Computer Science
Theory of Computation Lecture Notes Abhijat Vichare August 2005 Contents 1 Introduction 2 What is Computation? 3 The λ Calculus 3.1 Conversions: 3.2 The calculus in use 3.3 Few Important Theorems 3.4 Worked
More informationBottom-Up Parsing. An Introductory Example
Bottom-Up Parsing Bottom-up parsing is more general than top-down parsing Just as efficient Builds on ideas in top-down parsing Bottom-up is the preferred method in practice Reading: Section 4.5 An Introductory
More informationINTRODUCTORY SET THEORY
M.Sc. program in mathematics INTRODUCTORY SET THEORY Katalin Károlyi Department of Applied Analysis, Eötvös Loránd University H-1088 Budapest, Múzeum krt. 6-8. CONTENTS 1. SETS Set, equal sets, subset,
More information3. Mathematical Induction
3. MATHEMATICAL INDUCTION 83 3. Mathematical Induction 3.1. First Principle of Mathematical Induction. Let P (n) be a predicate with domain of discourse (over) the natural numbers N = {0, 1,,...}. If (1)
More informationComputability Theory
CSC 438F/2404F Notes (S. Cook and T. Pitassi) Fall, 2014 Computability Theory This section is partly inspired by the material in A Course in Mathematical Logic by Bell and Machover, Chap 6, sections 1-10.
More informationModels of Sequential Computation
Models of Sequential Computation 13 C H A P T E R Programming is often considered as an art, but it raises mostly practical questions like which language should I choose, which algorithm is adequate, and
More informationPage 331, 38.4 Suppose a is a positive integer and p is a prime. Prove that p a if and only if the prime factorization of a contains p.
Page 331, 38.2 Assignment #11 Solutions Factor the following positive integers into primes. a. 25 = 5 2. b. 4200 = 2 3 3 5 2 7. c. 10 10 = 2 10 5 10. d. 19 = 19. e. 1 = 1. Page 331, 38.4 Suppose a is a
More informationInformatique Fondamentale IMA S8
Informatique Fondamentale IMA S8 Cours 1 - Intro + schedule + finite state machines Laure Gonnord http://laure.gonnord.org/pro/teaching/ Laure.Gonnord@polytech-lille.fr Université Lille 1 - Polytech Lille
More informationSample Induction Proofs
Math 3 Worksheet: Induction Proofs III, Sample Proofs A.J. Hildebrand Sample Induction Proofs Below are model solutions to some of the practice problems on the induction worksheets. The solutions given
More informationMATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1.
MATH10212 Linear Algebra Textbook: D. Poole, Linear Algebra: A Modern Introduction. Thompson, 2006. ISBN 0-534-40596-7. Systems of Linear Equations Definition. An n-dimensional vector is a row or a column
More informationGraphs without proper subgraphs of minimum degree 3 and short cycles
Graphs without proper subgraphs of minimum degree 3 and short cycles Lothar Narins, Alexey Pokrovskiy, Tibor Szabó Department of Mathematics, Freie Universität, Berlin, Germany. August 22, 2014 Abstract
More informationI. GROUPS: BASIC DEFINITIONS AND EXAMPLES
I GROUPS: BASIC DEFINITIONS AND EXAMPLES Definition 1: An operation on a set G is a function : G G G Definition 2: A group is a set G which is equipped with an operation and a special element e G, called
More informationCSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions
CSC45 AUTOMATA 2. Finite Automata: Examples and Definitions Finite Automata: Examples and Definitions A finite automaton is a simple type of computer. Itsoutputislimitedto yes to or no. It has very primitive
More informationT-79.186 Reactive Systems: Introduction and Finite State Automata
T-79.186 Reactive Systems: Introduction and Finite State Automata Timo Latvala 14.1.2004 Reactive Systems: Introduction and Finite State Automata 1-1 Reactive Systems Reactive systems are a class of software
More informationComputer Architecture Syllabus of Qualifying Examination
Computer Architecture Syllabus of Qualifying Examination PhD in Engineering with a focus in Computer Science Reference course: CS 5200 Computer Architecture, College of EAS, UCCS Created by Prof. Xiaobo
More information