Properties of context-free Languages

Size: px
Start display at page:

Download "Properties of context-free Languages"

Transcription

1 Properties of context-free Languages We simplify CFL s. Greibach Normal Form Chomsky Normal Form We prove pumping lemma for CFL s. We study closure properties and decision properties. Some of them remain, some not. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

2 Greibach Normal Form It would be nice to know which rule to select expecially dificult is the left recursion A Aα Definition Greibach Normal Form or a CFG We say a grammar G is in Greibach Normal Form iff all rules are in the form A aβ, where a T, β V (a string of variables). the terminal in the body of the rule helps to select appropriate rule expecially if we have a unique rule with this terminal. Theorem (Greibach Normal Form) For each CFL language L there exists a CFG grammar G in Greibach Normal Form such that L(G) = L {λ}. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

3 Join the rules Lemma (Joining the rules) Let us have a rule A αbβ in grammar G and B ω 1,..., B ω k are all rules for B. If we replace the rule A αbβ by rules A αω 1 β,..., A αω k β we get an equivalent grammar. Proof: A αbβ α Bβ α ω i β A αω i β α ω i β in the original grammar in the new grammar Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

4 Left Recursion Lemma (Left Recursion) Let A Aω 1,..., A Aω k be all productions with left recursion in the grammar G for A and A α 1,..., A α m be all other rules for A, Z is a new variable. Then, by replaceing these rules by the rules: 1. A α i, A α i Z, Z ω j, Z ω j Z, nebo 2. A α i Z, Z ω j Z, Z λ we get an equivalent grammar. Proof: A Aω in... Aω i1... ω in α j ω i1... ω in (G) A α j Z α j ω i1 Z... α j ω i1... ω in 1 Z α j ω i1... ω in (1) A α j Z α j ω i1 Z... α j ω i1... ω in Z α j ω i1... ω in (2) Theorem (Greibach Normal Form) For each CFL language L there exists a CFG grammar G in Greibach Normal Form such that L(G) = L {λ}. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

5 Proof: Greibach Normal Form join rules and remove left recursion we enumerate all variables {A 1,..., A n } we allow recursion only in the form A i A j ω, where i < j we iterate i from 1 to n A i A j ω for j < i removed by joining the rules for j = i remove left recursion we get rules in the form A i A j ω (i < j), A i aω (a T ), Z i ω rules with A i (original variables) only in the form A i aω iteratively join the rules for i from n to 1 (for n already holds) rules with Z i (new variables) only in the form Z i aω In none rule for Z i the body begins with Z j either it is in required form or we join it with the rule A j aω we remove terminals inside rules. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

6 Reduction to GreibachNF Example Original Grammar E E + T T T T F F F (E) a (almost) Greibach Normal Form E (E) a (E)T at (E)E ae (E)T E at E E +T + TE T (E) a (E)T at T F FT F (E) a Left Recursion Removed E T TE E +T + TE T F FT T F FT F (E) a Greibach Normal Form E (EP a (EPT at (EPE ae (EPT E at E E +T + TE T (EP a (EPT at T F FT F (EP a P ) Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

7 Normal Forms for Context-Free Grammars Chomsky Normal Form: all production are of the form A BC or A a, A, B, C where are variables, a is a terminal. Every CFL (without λ) is generated by a CFG in Chomsky Normal Form. To get there, we perform simplifications Eliminate useless symbols eliminate λ-productions A λ for some variable A eliminate unit productions A B for variables A, B. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

8 Eliminating Useless symbols Definition (useful symbol) A symbol X is useful for a grammar G = (V, T, P, S) if there is some derivation of the form S αxβ w where w T, X (V T ). If X is not useful, we say it is useless. X is generating if X w for some terminal string w. Note always w w by zero steps. X is reachable if the is S αxβ for some α, β. We aim eliminate non generating and not reachable symbols. Example Consider the grammar: S AB a A b Eliminate B (nongenerating): S a A b. Eliminate A (not reachable): S a. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

9 Theorem (Eliminating useless symbols) Let G = (V, T, P, S) be a CFG, and assume that L(G). Let G 1 = (V 1, T 1, P 1, S) is obtained: Eliminate nongenerating symbols and all productions involving them. Eliminate all symbols that are not reachable after previous step. Then G 1 has no useless symbols, and L(G 1 ) = L(G). Generating symbols: BASIS: Every a T is generating. INDUCTION: For any production A α and every symbol of α is generating. Then A is generating. (This includes A ). Reachable symbols: BASIS: S is surely reachable. INDUCTION: If A is reachable, for all production with A in the head, all symbols of the bodies are also reachable. Theorem The algorithms above find all and only the generating / reachable symbols. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

10 Eliminating λ-productions Without λ-production, λ / L. We aim to prove: L has a CFG, then L {λ} has a CFG without λ-productions. Definition (nullable variable) A variable A is nullable if A λ. For nullable variables in the body B CAD, we create two versions of the production - with and without this variable. An algorithm to find all nullable symbols of G: If A λ is a production of G, then A is nullable. If B C 1... C k where each C i is nullable, then B is nullable (note terminal C i T is not nullable). Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

11 Construction of a grammar without λ-productions from G = (V, T, P, S). Determine nullable symbols. For each production A X 1... X k P, k 1 suppose m of X i s are nullable. The new grammar G 1 will have 2 m versions of this production with/without each nullable symbol except λ in case m = k. Example Consider the grammar: S AB A aaa λ B bbb λ S AB A B A aaa aa aa a B bbb bb bb b Final grammar: S AB A B A aaa aa a B bbb bb b. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

12 Eliminating Unit Productions Definition (unit production) A unit production is A B P where both A, B are variables. Example I a b Ia Ib I0 I1 F I (E) T F T F E T E + T Expanding T in E T E F T F Expanding E F E I (E) Expanding E I E a b Ia Ib I0 I1 Together: E a b Ia Ib I0 I1 (E) T F E + T. We have to avoid possible cycles. Definition (unit pair) A pair A, B V such that A B using only unit productions is called a unit pair. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

13 Unit pairs identification BASIS: (A, A) for A V is a unit pair. INDUCTION: If (A, B) is a unit pair and B C P, then (A, C) is a unit pair. Example (Unit pairs from previous grammar) (E, E), (T, T ), (F, F ), (I, I), (E, T ), (E, F ), (E, I), (T, F ), (T, I), (F, I). To eliminate unit productions from G = (V, T, P, S): Example Find all unit pairs of G. For each unit pair (A, B) new grammar all productions A α there B α P. I a b Ia Ib I0 I1 F I (E) T F T F E T E + T I a b Ia Ib I0 I1 F (E) a b Ia Ib I0 I1 T T F (E) a B Ia Ib I0 I1 E E + T T F (E) a b Ia Ib I0 I1 Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

14 Normal Form of CFGs Theorem (Normal Form of CFGs) If G is a CFG, L(G) \ {λ}, then there is a CFG G 1 such that L(G 1 ) = L(G) \ {λ} and G 1 has no λ-productions, unit productions, or useless symbols. Proof. Proof outline: Start by eliminating λ-productions. Eliminate unit productions. This does not introduce λ-productions. Eliminate useless symbols. This does not introduce any new production. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

15 Chomsky Normal Form Definition (Chomsky Normal Form) A CFG grammar G = (V, T, P, S) that has no useless symbols and all productions are in on of two forms: A BC, A, B, C V, A a, A V, a T, is said to be in Chomsky Normal Form (CNF). To put a grammar to CNF, we need two additional steps: Bodies of length 2 or more consist only of variables. Break bodies of length 3 or more to bodies of two variables. For every terminal a create a new variable, say A, add one production rule A a, Use A in place of a everywhere a appears in a body of length 2 or more. For a production A B 1... B k introduce k 2 variables C i And productions A B 1 C 1,C 1 B 2 C 2,...,C k 2 B k 1 B k. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

16 CNF Example I a b IA IB IZ IU F LER a b Ia IB IZ IU T TMF LER a b IA IB IZ IU E EPT TMF LER a b IA IB IZ IU A a B b Z 0 U 1 P + M L ( R ) F LC 3 a b Ia IB IZ IU T TC 2 LC 3 a b IA IB IZ IU E EC 1 TC 2 LC 3 a b IA IB IZ IU C 1 PT C 2 MF C 3 ER I, A, B, Z, U, P, M, L, R as before Theorem (CNF) If G is a CFG, L(G) \ {λ}, then there is a grammar G 1 in Chomsky Normal Form such that L(G 1 ) = L(G) \ {λ}. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

17 The Size of the Parse Tree Theorem (The Size of Parse Trees) Suppose we have a parse tree according the a CNF grammar G = (V, T, P, S) that yield a terminal string w. If the length of the longeeset path is n, then w 2 n 1. Proof. By induction on n, BASIS: a = 1 = 2 0, INDUCTION: 2 n n 2 = 2 n 1. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

18 Pumping Lemma for Context Free Languages Theorem (Pumping Lemma for Context Free Languages) Let L be a CFL. Then there exists constants p, q N such that any z L, z p can be written z = uvwxy subject to: vwx q. vx λ. i 0, uv i wx i y L. A 1 T 1 A 2 T 2 u v w x y v w x Proof Idea: take the parse tree for z find the longest path there must be two equal variables these variables define two subtrees the subtrees define partition of z = uvwxy we can move the tree T 1 (i > 1) or replace T 1 by T 2 (i = 0) Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

19 Proof: z > p : z = uvwxy, vwx q, vx λ, i 0uv i wx i y L we take the grammar in Chomsky NF (for L = {λ} and proof separatelly). Let V = k. We set p = 2 k 1, q = 2 k. For z L, z n, the parse tree has a path z of length > k we denote the terminal of the longest path t At least two of the last k variables on the path to t are equal we take the couple A 1, A 2 closest to t (it defines subtrees T 1, T 2 ) the path from A 1 to t is the longest in T 1 and the length is maximally k + 1 the yield of T 1 is no longer than 2 k (so vwx q) there are two paths from A 1 (ChNF), one to T 2 other to the rest of vx ChNF not nullable, so vx λ derivation of the word (A 1 va 2 x, A 2 w) S ua 1 y uva 2 xy uvwxy if we move A 2 to A 1 (i = 0) S ua 2 y uwy if we move A 1 to A 2 (i = 2, 3,...) S ua 1 y uva 1 xy uvva 2 xxy uvvwxxy Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

20 Applications of the Pomping Lemma for CFL s "Adversary game" as for regular languages: Pick a language L that is not CFL. Our adversary gets to pik n, which we do not know. We get to pick z, and we may use n as a parameter. Our adversary gets to berak z into uvwxy, subject vwx n and vx λ. We win the game, if by picking i and showing uv i wx i y is not in L. Lemma (Not CFL) Following languages are not CFL: {0 n 1 n 2 n n 1} {0 i 1 j 2 i 3 j i 1&j 1} {ww w is in {0, 1} } Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

21 Pumping Lemma Ussage Example (non CFL) Following language is not CFL {0 n 1 n 2 n n 1} assume it were CFL we get p, q from the Pumping Lemma select k = max(p, q), then 0 k 1 k 2 k > p the word is not longer then q we pump at most two different symbols the equality of symbols is violated CONTRADICTION. Example (not a CFL) Following language is not CFL {0 i 1 j 2 k 0 i j k} assume it were CFL we get p, q from the Pumping Lemma select n = max(p, q), then 0 n 1 n 2 n > p the word is not longer then q we pump at most two different symbols in the case of a (or b), pump up CONTRADICTION i j (or j k) if c (or b), pump down CONTRADICTION j k (or i j) Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

22 Generalisations of the Pumping Lemma Pumping lemma is only an implication. Example (non CFL, that can be pumped) L = {a i b j c k d l i = 0 j = k = l} is not a CFL but it can be pumped. i = 0 : b j c k d l i > 0 : a i b n c n d n can be pumped in any letter can be pumped in a A solution? generalisations (Ogden lemma and others) pumping marked symbols closure properties. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

23 Closure Properties of CFLs Theorem (CFLs are closed on substitution) If L is a CFL over Σ, and s is a substitution on Σ such that s(a) is a CFL for each a Σ, then s(l) is CFL. Proof. Idea: Replace each a by the start symbol of a CFG for language s(a). First, rename variables to be unique in all G = (V, T, P, S), G a = (V a, T a, P a, S a ), a Σ. We construct a new grammar G = (V, T, P, S) for s(l): V = V a Σ Va T = a Σ Ta P = Pa {p P with all a replaced by Sa}. a Σ G generates the language s(l). Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

24 CFL closed under From Substitution theorem we can prove: Theorem (CFL s closed under union, concatenation, closure, homomorphism.) The CFL s are slosed under union, concatenation, closure ( ), positive closure (+), homomorphism. Theorem (CFL s closed under reversal) If L is a CFL, then so is L R. Proof. Reverse all productions. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

25 CFL s and intersection Example (CFLs are not closed on intersection) The langulage L = {0 n 1 n 2 n n 1} = {0 n 1 n 2 i n 1, i 1} {0 i 1 n 2 n n 1, i 1} is not CFL. Theorem (CFLs are closed on intersection with a regular language) If L is a CFL and F is a regular language, then L R is a CFL. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

26 Theorem (CFLs are not closed on complement) Let L, L 1, L 2 be CFLs, R a regular language. L R is a CFL. L R = L R, R is regular. L is not necessarily a CFL. L 1 L 2 = L 1 L 2. L 1 L 2 is not necessarily a CFL. Σ L not always CFL. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

27 CFLs are closed on inverse homomorphism Theorem (CFLs are closed on inverse homomorphism) Let L be a CFL and h a homomorphism, then h 1 (L) is a CFL. Proof. After a is read, h(a) is placed in a buffer. The symbols of h(a) are one at a time fed to the PDA being simulated. Only when the buffer is empty does the constructed PDA read another of its input symbols. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

28 Closure Properties Language Regular Context-free Dyck union YES YES NO intersection YES NO NO with RL YES YES YES complement YES NO YES homomorphism YES YES NO inverse hom. YES YES YES Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

29 Complexity of Converting among CFG s and PDA s Conversions linear in the size of the input: Theorem CFG to a PDA. PDA by final state to a PDA by empty stack. PDA by empty stack to PDA by final state. There is an O(n 3 ) algorithm that takes a PDA P whose repr3esentation nas length n and produces a DVG of length at most O(n 3 ). Theorem Given a grammar G of length n, we can find an equivalent CNF grammar for G in time O(n 2 ); the resulting grammar has length O(n 2 ). Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

30 Testing Emptiness of CFL s Lemma Test whether the start symbol S of G is generating can be done in O(n) time. Create an indexed list of all variables (left) Add links: variable a chain of all the positions in which that variable appears (full line). production, a count of the number of positions holding variables whose ability to generate a terminal string has not yet been taken into account (dashed and dotted lines) Establishing B is generating follow full links and decrease the count by 1 for each occurrence. If a count reaches 0, then we know the head variable is generating. Keep all generating variables on a stack and procceed them. This algorithm is O(n). Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

31 Cocke-Younger-Kasami algorithm for testing a membership in a CFL Inefficient: exponential in w (check all derivation trees of appropriage depth of CNF grammar for L. Definition (CYG Algorithm, time O(n 3 )) The input is CNF grammar G = (V, T, P, S) for language L and a string w = q 1 a 2... a n T. Produce triangular table (right), horizontal axis is w X ij is the set of variables A such that A a ia i+1... a j. Fill the table upwards. X ij = {A BC; B X ik, C X k+1,j } X 15 X 14 X 25 X 13 X 24 X 35 X 12 X 23 X 34 X 45 X 11 X 22 X 33 X 44 X 55 a 1 a 2 a 3 a 4 a 5 BASIS: X ii = {A; A a i P} Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

32 {S, A, C} - {S, A, C} - {B} {B} {S, A} {B} {S, C} {S, A} {B} {A, C} {A, C} {B} {A, C} b a a b a Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

33 Undecidable CFL Problems (preview) Is a given CFG ambiguous? Is a given CFL inherently ambiguous? Is the intersection of two CFL s empty? Is a given CFL equal to Σ, where Σ is the alphabet of this language? Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

34 Summary of Chapter 7 Eliminating Useless Symbols Eliminating λ and Unit productions Chomsky Normal Form: no useless symbols, evry production body consists of either two variable or one terminal. G CFG; L(G) NFG : L(NFG) = L(G) \ {λ}. The Pumping Lemma n; z L, z n u, v, w, x, y; z = uvwxy such that: vwx n; vx λ; i 0, uv i wx i y L. Testing Empriness of a CFL possible also in O( G ) time. Testing Membership in a CFL: Cocke-Younger-Kasami algorithm O( w 3 ); w Σ for a fixed CFL. Automata and Grammars Normal Forms, Pumping Lemma 8 April 6, / 26

Properties of Context-Free Languages

Properties of Context-Free Languages Properties of Context-Free Languages Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjin@postech.ac.kr

More information

Properties of Context-free Languages. Reading: Chapter 7

Properties 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 information

Chap. 7 Properties of Context-free Languages

Chap. 7 Properties of Context-free Languages Chap. 7 Properties of Context-free Languages 7.1 Normal Forms for Context-free Grammars Context-free grammars A where A N, (N T). 0. Chomsky Normal Form A BC or A a except S where A, B, C N, a T. 1. Eliminating

More information

This lecture covers Chapter 7 of HMU: Properties of CFLs

This lecture covers Chapter 7 of HMU: Properties of CFLs This lecture covers Chapter 7 of HMU: Properties of CFLs Chomsky Normal Form Pumping Lemma for CFs Closure Properties of CFLs Decision Properties of CFLs Additional Reading: Chapter 7 of HMU. Chomsky Normal

More information

Non-context-Free Languages. CS215, Lecture 5 c

Non-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 information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite 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 information

NPDA, CFG equivalence

NPDA, CFG equivalence NPDA, CFG equivalence Theorem A language L is recognized by a NPDA iff L is described by a CFG. Must prove two directions: ( ) L is recognized by a NPDA implies L is described by a CFG. ( ) L is described

More information

Ogden s Lemma for CFLs

Ogden s Lemma for CFLs Ogden s Lemma for CFLs Theorem If L is a context-free language, then there exists an integer l such that for any u L with at least l positions marked, u can be written as u = vwxyz such that 1 x and at

More information

The Pumping Lemma for Context Free Grammars

The 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 information

CS20a: summary (Oct 24, 2002)

CS20a: summary (Oct 24, 2002) CS20a: summary (Oct 24, 2002) Context-free languages Grammars G = (V, T, P, S) Pushdown automata N-PDA = CFG D-PDA < CFG Today What languages are context-free? Pumping lemma (similar to pumping lemma for

More information

Foundations of Informatics: a Bridging Course

Foundations 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 information

Plan for 2 nd half. Just when you thought it was safe. Just when you thought it was safe. Theory Hall of Fame. Chomsky Normal Form

Plan for 2 nd half. Just when you thought it was safe. Just when you thought it was safe. Theory Hall of Fame. Chomsky Normal Form Plan for 2 nd half Pumping Lemma for CFLs The Return of the Pumping Lemma Just when you thought it was safe Return of the Pumping Lemma Recall: With Regular Languages The Pumping Lemma showed that if a

More information

CS 373: Theory of Computation. Fall 2010

CS 373: Theory of Computation. Fall 2010 CS 373: Theory of Computation Gul Agha Mahesh Viswanathan Fall 2010 1 1 Normal Forms for CFG Normal Forms for Grammars It is typically easier to work with a context free language if given a CFG in a normal

More information

Before 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. 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 information

Finite Automata and Formal Languages TMV026/DIT321 LP Useful, Useless, Generating and Reachable Symbols

Finite Automata and Formal Languages TMV026/DIT321 LP Useful, Useless, Generating and Reachable Symbols Finite Automata and Formal Languages TMV026/DIT321 LP4 2012 Lecture 13 Ana Bove May 7th 2012 Overview of today s lecture: Normal Forms for Context-Free Languages Pumping Lemma for Context-Free Languages

More information

Lecture 12 Simplification of Context-Free Grammars and Normal Forms

Lecture 12 Simplification of Context-Free Grammars and Normal Forms Lecture 12 Simplification of Context-Free Grammars and Normal Forms COT 4420 Theory of Computation Chapter 6 Normal Forms for CFGs 1. Chomsky Normal Form CNF Productions of form A BC A, B, C V A a a T

More information

CS375: Logic and Theory of Computing

CS375: Logic and Theory of Computing CS375: Logic and Theory of Computing Fuhua (Frank) Cheng Department of Computer Science University of Kentucky 1 Table of Contents: Week 1: Preliminaries (set algebra, relations, functions) (read Chapters

More information

Context-Free Languages (Pre Lecture)

Context-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 information

Properties of Context-Free Languages. Closure Properties Decision Properties

Properties 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 information

Einführung in die Computerlinguistik

Einführung in die Computerlinguistik Einführung in die Computerlinguistik Context-Free Grammars formal properties Laura Kallmeyer Heinrich-Heine-Universität Düsseldorf Summer 2018 1 / 20 Normal forms (1) Hopcroft and Ullman (1979) A normal

More information

Section 1 (closed-book) Total points 30

Section 1 (closed-book) Total points 30 CS 454 Theory of Computation Fall 2011 Section 1 (closed-book) Total points 30 1. Which of the following are true? (a) a PDA can always be converted to an equivalent PDA that at each step pops or pushes

More information

Context Free Language Properties

Context Free Language Properties Context Free Language Properties Knowing that the context free languages are exactly those sets accepted by nondeterministic pushdown automata provides us a bit of information about them. We know that

More information

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

THEORY 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 information

TAFL 1 (ECS-403) Unit- III. 3.1 Definition of CFG (Context Free Grammar) and problems. 3.2 Derivation. 3.3 Ambiguity in Grammar

TAFL 1 (ECS-403) Unit- III. 3.1 Definition of CFG (Context Free Grammar) and problems. 3.2 Derivation. 3.3 Ambiguity in Grammar TAFL 1 (ECS-403) Unit- III 3.1 Definition of CFG (Context Free Grammar) and problems 3.2 Derivation 3.3 Ambiguity in Grammar 3.3.1 Inherent Ambiguity 3.3.2 Ambiguous to Unambiguous CFG 3.4 Simplification

More information

Simplification of CFG and Normal Forms. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

Simplification of CFG and Normal Forms. Wen-Guey Tzeng Computer Science Department National Chiao Tung University Simplification of CFG and Normal Forms Wen-Guey Tzeng Computer Science Department National Chiao Tung University Normal Forms We want a cfg with either Chomsky or Greibach normal form Chomsky normal form

More information

Simplification of CFG and Normal Forms. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

Simplification of CFG and Normal Forms. Wen-Guey Tzeng Computer Science Department National Chiao Tung University Simplification of CFG and Normal Forms Wen-Guey Tzeng Computer Science Department National Chiao Tung University Normal Forms We want a cfg with either Chomsky or Greibach normal form Chomsky normal form

More information

Notes for Comp 497 (Comp 454) Week 10 4/5/05

Notes for Comp 497 (Comp 454) Week 10 4/5/05 Notes for Comp 497 (Comp 454) Week 10 4/5/05 Today look at the last two chapters in Part II. Cohen presents some results concerning context-free languages (CFL) and regular languages (RL) also some decidability

More information

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES Contents i SYLLABUS UNIT - I CHAPTER - 1 : AUT UTOMA OMATA Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 2 : FINITE AUT UTOMA OMATA An Informal Picture of Finite Automata,

More information

CPS 220 Theory of Computation

CPS 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 information

CS5371 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) 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 information

CSE 355 Test 2, Fall 2016

CSE 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 information

CS311 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 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 information

Context-Free Grammar

Context-Free Grammar Context-Free Grammar CFGs are more powerful than regular expressions. They are more powerful in the sense that whatever can be expressed using regular expressions can be expressed using context-free grammars,

More information

Notes for Comp 497 (454) Week 10

Notes for Comp 497 (454) Week 10 Notes for Comp 497 (454) Week 10 Today we look at the last two chapters in Part II. Cohen presents some results concerning the two categories of language we have seen so far: Regular languages (RL). Context-free

More information

Parsing. Context-Free Grammars (CFG) Laura Kallmeyer. Winter 2017/18. Heinrich-Heine-Universität Düsseldorf 1 / 26

Parsing. Context-Free Grammars (CFG) Laura Kallmeyer. Winter 2017/18. Heinrich-Heine-Universität Düsseldorf 1 / 26 Parsing Context-Free Grammars (CFG) Laura Kallmeyer Heinrich-Heine-Universität Düsseldorf Winter 2017/18 1 / 26 Table of contents 1 Context-Free Grammars 2 Simplifying CFGs Removing useless symbols Eliminating

More information

Computational Models - Lecture 4

Computational Models - Lecture 4 Computational Models - Lecture 4 Regular languages: The Myhill-Nerode Theorem Context-free Grammars Chomsky Normal Form Pumping Lemma for context free languages Non context-free languages: Examples Push

More information

Einführung in die Computerlinguistik Kontextfreie Grammatiken - Formale Eigenschaften

Einführung in die Computerlinguistik Kontextfreie Grammatiken - Formale Eigenschaften Normal forms (1) Einführung in die Computerlinguistik Kontextfreie Grammatiken - Formale Eigenschaften Laura Heinrich-Heine-Universität Düsseldorf Sommersemester 2013 normal form of a grammar formalism

More information

Computational Models - Lecture 5 1

Computational 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 information

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

AC68 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 information

Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules).

Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules). Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules). 1a) G = ({R, S, T}, {0,1}, P, S) where P is: S R0R R R0R1R R1R0R T T 0T ε (S generates the first 0. R generates

More information

Computability and Complexity

Computability and Complexity Computability and Complexity Push-Down Automata CAS 705 Ryszard Janicki Department of Computing and Software McMaster University Hamilton, Ontario, Canada janicki@mcmaster.ca Ryszard Janicki Computability

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL 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 information

The View Over The Horizon

The 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 information

MA/CSSE 474 Theory of Computation

MA/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 information

Theory of Computation 8 Deterministic Membership Testing

Theory of Computation 8 Deterministic Membership Testing Theory of Computation 8 Deterministic Membership Testing Frank Stephan Department of Computer Science Department of Mathematics National University of Singapore fstephan@comp.nus.edu.sg Theory of Computation

More information

Theory of Computation

Theory 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 information

Computational Models - Lecture 5 1

Computational 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 information

Context-Free Grammars: Normal Forms

Context-Free Grammars: Normal Forms Context-Free Grammars: Normal Forms Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjin@postech.ac.kr

More information

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 10 : Context-Free Grammars

COMP-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 information

Solution. S ABc Ab c Bc Ac b A ABa Ba Aa a B Bbc bc.

Solution. S ABc Ab c Bc Ac b A ABa Ba Aa a B Bbc bc. Section 12.4 Context-Free Language Topics Algorithm. Remove Λ-productions from grammars for langauges without Λ. 1. Find nonterminals that derive Λ. 2. For each production A w construct all productions

More information

CS5371 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) 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 information

Computational Models - Lecture 4 1

Computational 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 information

CFG Simplification. (simplify) 1. Eliminate useless symbols 2. Eliminate -productions 3. Eliminate unit productions

CFG Simplification. (simplify) 1. Eliminate useless symbols 2. Eliminate -productions 3. Eliminate unit productions CFG Simplification (simplify) 1. Eliminate useless symbols 2. Eliminate -productions 3. Eliminate unit productions 1 Eliminating useless symbols 1. A symbol X is generating if there exists: X * w, for

More information

St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad-500 014 Subject: FORMAL LANGUAGES AND AUTOMATA THEORY Class : CSE II PART A (SHORT ANSWER QUESTIONS) UNIT- I 1 Explain transition diagram, transition

More information

Context-Free and Noncontext-Free Languages

Context-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 information

6.1 The Pumping Lemma for CFLs 6.2 Intersections and Complements of CFLs

6.1 The Pumping Lemma for CFLs 6.2 Intersections and Complements of CFLs CSC4510/6510 AUTOMATA 6.1 The Pumping Lemma for CFLs 6.2 Intersections and Complements of CFLs The Pumping Lemma for Context Free Languages One way to prove AnBn is not regular is to use the pumping lemma

More information

Fall 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. 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 information

DD2371 Automata Theory

DD2371 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 information

Harvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition

Harvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition Harvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition Salil Vadhan October 11, 2012 Reading: Sipser, Section 2.3 and Section 2.1 (material on Chomsky Normal Form). Pumping Lemma for

More information

Pushdown Automata. Notes on Automata and Theory of Computation. Chia-Ping Chen

Pushdown 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 information

Solution to CS375 Homework Assignment 11 (40 points) Due date: 4/26/2017

Solution to CS375 Homework Assignment 11 (40 points) Due date: 4/26/2017 Solution to CS375 Homework Assignment 11 (40 points) Due date: 4/26/2017 1. Find a Greibach normal form for the following given grammar. (10 points) S bab A BAa a B bb Ʌ Solution: (1) Since S does not

More information

60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor

60-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 information

Concordia University Department of Computer Science & Software Engineering

Concordia University Department of Computer Science & Software Engineering Concordia University Department of Computer Science & Software Engineering COMP 335/4 Theoretical Computer Science Winter 2015 Assignment 3 1. In each case, what language is generated by CFG s below. Justify

More information

CS481F01 Prelim 2 Solutions

CS481F01 Prelim 2 Solutions CS481F01 Prelim 2 Solutions A. Demers 7 Nov 2001 1 (30 pts = 4 pts each part + 2 free points). For this question we use the following notation: x y means x is a prefix of y m k n means m n k For each of

More information

6.8 The Post Correspondence Problem

6.8 The Post Correspondence Problem 6.8. THE POST CORRESPONDENCE PROBLEM 423 6.8 The Post Correspondence Problem The Post correspondence problem (due to Emil Post) is another undecidable problem that turns out to be a very helpful tool for

More information

MTH401A Theory of Computation. Lecture 17

MTH401A Theory of Computation. Lecture 17 MTH401A Theory of Computation Lecture 17 Chomsky Normal Form for CFG s Chomsky Normal Form for CFG s For every context free language, L, the language L {ε} has a grammar in which every production looks

More information

Context Free Languages and Grammars

Context Free Languages and Grammars Algorithms & Models of Computation CS/ECE 374, Fall 2017 Context Free Languages and Grammars Lecture 7 Tuesday, September 19, 2017 Sariel Har-Peled (UIUC) CS374 1 Fall 2017 1 / 36 What stack got to do

More information

Miscellaneous. Closure Properties Decision Properties

Miscellaneous. Closure Properties Decision Properties Miscellaneous Closure Properties Decision Properties 1 Closure Properties of CFL s CFL s are closed under union, concatenation, and Kleene closure. Also, under reversal, homomorphisms and inverse homomorphisms.

More information

SFWR ENG 2FA3. Solution to the Assignment #4

SFWR ENG 2FA3. Solution to the Assignment #4 SFWR ENG 2FA3. Solution to the Assignment #4 Total = 131, 100%= 115 The solutions below are often very detailed on purpose. Such level of details is not required from students solutions. Some questions

More information

CSE 105 Homework 5 Due: Monday November 13, Instructions. should be on each page of the submission.

CSE 105 Homework 5 Due: Monday November 13, Instructions. should be on each page of the submission. CSE 05 Homework 5 Due: Monday November 3, 207 Instructions Upload a single file to Gradescope for each group. should be on each page of the submission. All group members names and PIDs Your assignments

More information

Homework 4. Chapter 7. CS A Term 2009: Foundations of Computer Science. By Li Feng, Shweta Srivastava, and Carolina Ruiz

Homework 4. Chapter 7. CS A Term 2009: Foundations of Computer Science. By Li Feng, Shweta Srivastava, and Carolina Ruiz CS3133 - A Term 2009: Foundations of Computer Science Prof. Carolina Ruiz Homework 4 WPI By Li Feng, Shweta Srivastava, and Carolina Ruiz Chapter 7 Problem: Chap 7.1 part a This PDA accepts the language

More information

Harvard 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 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 information

Final exam study sheet for CS3719 Turing machines and decidability.

Final 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 information

Theory of Computation - Module 3

Theory of Computation - Module 3 Theory of Computation - Module 3 Syllabus Context Free Grammar Simplification of CFG- Normal forms-chomsky Normal form and Greibach Normal formpumping lemma for Context free languages- Applications of

More information

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014 Q.2 a. Show by using Mathematical Induction that n i= 1 i 2 n = ( n + 1) ( 2 n + 1) 6 b. Define language. Let = {0; 1} denote an alphabet. Enumerate five elements of the following languages: (i) Even binary

More information

Theory Of Computation UNIT-II

Theory Of Computation UNIT-II Regular Expressions and Context Free Grammars: Regular expression formalism- equivalence with finite automata-regular sets and closure properties- pumping lemma for regular languages- decision algorithms

More information

2.1 Solution. E T F a. E E + T T + T F + T a + T a + F a + a

2.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 information

CDM Parsing and Decidability

CDM Parsing and Decidability CDM Parsing and Decidability 1 Parsing Klaus Sutner Carnegie Mellon Universality 65-parsing 2017/12/15 23:17 CFGs and Decidability Pushdown Automata The Recognition Problem 3 What Could Go Wrong? 4 Problem:

More information

Introduction to Theory of Computing

Introduction 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 information

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF)

CS5371 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 information

VTU QUESTION BANK. Unit 1. Introduction to Finite Automata. 1. Obtain DFAs to accept strings of a s and b s having exactly one a.

VTU QUESTION BANK. Unit 1. Introduction to Finite Automata. 1. Obtain DFAs to accept strings of a s and b s having exactly one a. VTU QUESTION BANK Unit 1 Introduction to Finite Automata 1. Obtain DFAs to accept strings of a s and b s having exactly one a.(5m )( Dec-2014) 2. Obtain a DFA to accept strings of a s and b s having even

More information

Ogden s Lemma. and Formal Languages. Automata Theory CS 573. The proof is similar but more fussy. than the proof of the PL4CFL.

Ogden s Lemma. and Formal Languages. Automata Theory CS 573. The proof is similar but more fussy. than the proof of the PL4CFL. CS 573 Automata Theory and Formal Languages Professor Leslie Lander Lecture # 24 December 4, 2000 Ogden s Lemma (6.2) Let L be a CFL, then there is a constant n such that if z is a word in L with z > n

More information

Computational Models - Lecture 3

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 information

Testing Emptiness of a CFL. Testing Finiteness of a CFL. Testing Membership in a CFL. CYK Algorithm

Testing Emptiness of a CFL. Testing Finiteness of a CFL. Testing Membership in a CFL. CYK Algorithm Testing Emptiness of a CFL As for regular languages, we really take a representation of some language and ask whether it represents φ Can use either CFG or PDA Our choice, since there are algorithms to

More information

Context Free Languages: Decidability of a CFL

Context 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 information

Context Free Grammars

Context 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 information

Decidability (What, stuff is unsolvable?)

Decidability (What, stuff is unsolvable?) University of Georgia Fall 2014 Outline Decidability Decidable Problems for Regular Languages Decidable Problems for Context Free Languages The Halting Problem Countable and Uncountable Sets Diagonalization

More information

Closure Properties of Context-Free Languages. Foundations of Computer Science Theory

Closure 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 information

DM17. Beregnelighed. Jacob Aae Mikkelsen

DM17. 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 information

Computational Models: Class 5

Computational 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 information

Theory Bridge Exam Example Questions

Theory Bridge Exam Example Questions Theory Bridge Exam Example Questions Annotated version with some (sometimes rather sketchy) answers and notes. This is a collection of sample theory bridge exam questions. This is just to get some idea

More information

Functions on languages:

Functions 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 information

Context-Free Grammars and Languages. Reading: Chapter 5

Context-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 information

Closure 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 of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties Recall a closure property is a statement

More information

MA/CSSE 474 Theory of Computation

MA/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 information

The Post Correspondence Problem

The Post Correspondence Problem The Post Correspondence Problem - Given a set, P of pairs of strings: where t i, b i Σ P = {[ t 1 b 1 ], t 2 b 2 ],, t k b k ]} - Question: Does there exist a sequence i 1, i 2, i n such that: t i1 t i2

More information

Context-Free Grammars. 2IT70 Finite Automata and Process Theory

Context-Free Grammars. 2IT70 Finite Automata and Process Theory Context-Free Grammars 2IT70 Finite Automata and Process Theory Technische Universiteit Eindhoven May 18, 2016 Generating strings language L 1 = {a n b n n > 0} ab L 1 if w L 1 then awb L 1 production rules

More information

Question Bank UNIT I

Question Bank UNIT I Siddhivinayak Technical Campus School of Engineering & Research Technology Department of computer science and Engineering Session 2016-2017 Subject Name- Theory of Computation Subject Code-4KS05 Sr No.

More information

Automata Theory Final Exam Solution 08:10-10:00 am Friday, June 13, 2008

Automata Theory Final Exam Solution 08:10-10:00 am Friday, June 13, 2008 Automata Theory Final Exam Solution 08:10-10:00 am Friday, June 13, 2008 Name: ID #: This is a Close Book examination. Only an A4 cheating sheet belonging to you is acceptable. You can write your answers

More information

Chomsky and Greibach Normal Forms

Chomsky and Greibach Normal Forms Chomsky and Greibach Normal Forms Teodor Rus rus@cs.uiowa.edu The University of Iowa, Department of Computer Science Computation Theory p.1/25 Simplifying a CFG It is often convenient to simplify CFG One

More information