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

Size: px
Start display at page:

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

Transcription

1 Context-Free Grammars 2IT70 Finite Automata and Process Theory Technische Universiteit Eindhoven May 18, 2016

2 Generating strings language L 1 = {a n b n n > 0} ab L 1 if w L 1 then awb L 1 production rules ab and ab 2 IT70 (2016) Context-Free Grammars 2/ 41

3 Generating strings language L 1 = {a n b n n > 0} language L 2 = (01) ab L 1 if w L 1 then awb L 1 ε L 2 if w L 2 then 01w L 2 production rules ab and ab production rules ε and 01 2 IT70 (2016) Context-Free Grammars 2/ 41

4 Variables, terminals, production rules, start symbol palindromes over {a, b} ε a b aa bb binary integer expressions E I E N I a I I0 E E +E E E E E (E) I I1 N 1 N N0 N N1 2 IT70 (2016) Context-Free Grammars 3/ 41

5 Variables, terminals, production rules, start symbol palindromes over {a, b} ε a b aa bb alternative notation ε a b aa bb binary integer expressions E I E N I a I I0 E E +E E E E E (E) I I1 N 1 N N0 N N1 alternative notation E I N E +E E E (E) I a I0 I1 N 1 N0 N1 2 IT70 (2016) Context-Free Grammars 3/ 41

6 Clicker questions L81 Consider again the grammar given by E I N E +E E E (E) I a I0 I1 N 1 N0 N1 How many of the strings aa1, a01, 011, 11a, a01+a01, (a11 a10), +101, (110) cannot be generated by the grammar, you expect? A. Two strings B. Three strings C. Four strings D. ix strings E. Can t tell 2 IT70 (2016) Context-Free Grammars 4/ 41

7 Language of a CFG context-free grammar G = (V, T, R, ) V variables and T terminals R V (V T) production rules A α V start symbol productions G (V T) (V T) γ G γ if γ = β 1 Aβ 2, A α rule of G, γ = β 1 αβ 2 production sequences γ 0 G γ 1 G G γ n 2 IT70 (2016) Context-Free Grammars 5/ 41

8 Language of a CFG context-free grammar G = (V, T, R, ) V variables and T terminals R V (V T) production rules A α V start symbol productions G (V T) (V T) γ G γ if γ = β 1 Aβ 2, A α rule of G, γ = β 1 αβ 2 production sequences γ 0 G γ 1 G G γ n language of a variable L G (A) = {w T A G w } language of the grammar L(G) = L G () = {w T G w } 2 IT70 (2016) Context-Free Grammars 5/ 41

9 More examples expression ::= term expression + term term ::= factor term factor factor ::= identifier ( expression ) identifier ::= a b c... 2 IT70 (2016) Context-Free Grammars 6/ 41

10 More examples expression ::= term expression + term term ::= factor term factor factor ::= identifier ( expression ) identifier ::= a b c... char ::= a... z A... Z... text ::= ε char text doc ::= ε element doc element ::= text <EM> doc </EM> <P> doc <OL> list </OL> listitem ::= <LI> doc list ::= ε listitem doc 2 IT70 (2016) Context-Free Grammars 6/ 41

11 Combining and splitting productions lemma CFG G = (V, T, R, ) if X 1 n 1 G γ 1,...,X k n k G γ k then X 1 X k n G γ 1 γ k where n = n 1 + +n k if X 1 X k n G γ then X 1 n 1 G γ 1,...,X k n k G γ k where n = n 1 + +n k and γ = γ 1...γ k X 1,...,X k (V T), γ 1,...,γ k (V T) 2 IT70 (2016) Context-Free Grammars 7/ 41

12 The parentheses language L () CFG ε () several production sequences for string ()(()) G G () G (()) G (()) G ()(()) G ()(()) G G () G () G ()() G ()(()) G ()(()) G G () G ()() G ()() G ()(()) G ()(()) leftmost, rightmost, mixed production sequence 2 IT70 (2016) Context-Free Grammars 8/ 41

13 Clicker question L82 Given the CFG () (). How many production sequences are there for the string (())((()))? A. (())((())) has 5 possible production sequences B. (())((())) has 6 possible production sequences C. (())((())) has 10 possible production sequences D. (())((())) has 12 possible production sequences E. Can t tell 2 IT70 (2016) Context-Free Grammars 9/ 41

14 Proving a grammar correct CFG G with production rules ab and ab for L = {a n b n n 1} it holds that L(G) = L proof induction on n: if n G w then w L, thus L(G) L induction on n: if w = a n b n then w L(G), thus L L(G) 2 IT70 (2016) Context-Free Grammars 10/ 41

15 Avoiding the inductive proofs lemma CFGs G 1 = (V 1, T 1, R 1, 1 ) and G 2 = (V 2, T 2, R 2, 2 ) moreover V 1 and V 2 disjoint define CFG G = ({} V 1 V 2, T 1 T 2, R, ) if R = { 1 2 } R 1 R 2 then L(G) = L(G 1 ) L(G 2 ) if R = { 1 2 } R 1 R 2 then L(G) = L(G 1 ) L(G 2 ) if R = { ε 1 } R 1 then L(G) = L(G 1 ) 2 IT70 (2016) Context-Free Grammars 11/ 41

16 Avoiding the inductive proofs (cont.) CFG G with production rules ab B ε bb 2 ba A ε aa then L(G) = {ab n, ba m n,m 0} proof use the lemma L G (A) = {a m m 0} and L G (B) = {b n n 0} L G ( 1 ) = {a} {b n n 0} and L G ( 2 ) = {b} {a m m 0} L(G) = {ab n n 0} {ba m m 0} 2 IT70 (2016) Context-Free Grammars 12/ 41

17 Context-free languages language L is context-free if L = L(G) for CFG G {a n b n n 0} and {ww R w {0,1} } are context-free 2 IT70 (2016) Context-Free Grammars 13/ 41

18 Context-free languages language L is context-free if L = L(G) for CFG G {a n b n n 0} and {ww R w {0,1} } are context-free theorem if L is regular then L is context-free proof for DFA D = (Q, Σ, δ, q 0, F ) put G = (Q, Σ, R, q 0 ) where R = {q aq δ(q,a) = q } {q ε q F } then L = L(G) 2 IT70 (2016) Context-Free Grammars 13/ 41

19 Chomsky Normal Form 2IT70 Finite Automata and Process Theory Technische Universiteit Eindhoven May 18, 2016

20 Useless symbols CFG G = (V,T,R,) symbol X V T generating if X G w T symbol X V T reachable if α,β: G αxβ symbol X V T is useful if both generating and reachable 2IT70 (2016) Chomsky Normal Form 15/41

21 Clicker question L83 Consider the grammar AB c A a C c 2IT70 (2016) Chomsky Normal Form 16/41

22 Clicker question L83 Consider the grammar AB c A a C c Which of the following statements about variables holds true? A. 2 variables generating, 2 reachable, 1 useful B. 2 variables generating, 2 reachable, 2 useful C. 3 variables generating, 3 reachable, 2 useful D. 3 variables generating, 3 reachable, 3 useful E. Can t tell 2IT70 (2016) Chomsky Normal Form 16/41

23 Finding of generating variables CFG G = (V,T,R,) with L(G) symbol X V T is generating if X G w T and Gen(G) = {X X generating} lemma put Gen 0 = T Gen i+1 = Gen i {A A G α, α Gen i } Gen = i=0 Gen i then Gen(G) = Gen theorem CFG G = (V,T,R,) with V = V Gen(G) and R = {A α R A Gen, α Gen } then L(G) = L(G ) and all symbols of G generating 2IT70 (2016) Chomsky Normal Form 17/41

24 Finding of reachable variables CFG G = (V,T,R,) with L(G) symbol X V T is reachable if G Reach(G) = {X X reachable} αxβ and lemma put Reach 0 = {} Reach i+1 = Reach i {X A G γ, A Reach i, γαxβ } Reach = i=0 Reach i then Reach(G) = Reach theorem CFG G = (V,T,R,) with V = V Reach(G) and R = {A α R A Reach } then L(G) = L(G ) and all variables of G reachable 2IT70 (2016) Chomsky Normal Form 18/41

25 Parse Trees 2IT70 Finite Automata and Process Theory Technische Universiteit Eindhoven May 18, 2016

26 Identifying production sequences parentheses grammar ε () several production sequences for string ()(()) G G () G () G ()() G ()(()) G ()(()) G G () G ()() G ()() G ()(()) G ()(()) 2IT70 (2016) Parse Trees 20/41

27 Identifying production sequences parentheses grammar ε () several production sequences for string ()(()) G G () G () G ()() G ()(()) G ()(()) G G () G ()() G ()() G ()(()) G ()(()) swapping independent productions 2IT70 (2016) Parse Trees 20/41

28 Identifying production sequences (cont.) 2IT70 (2016) Parse Trees 21/41

29 Identifying production sequences (cont.) 2IT70 (2016) Parse Trees 21/41

30 Identifying production sequences (cont.) ( ) 2IT70 (2016) Parse Trees 21/41

31 Identifying production sequences (cont.) ( ) ε 2IT70 (2016) Parse Trees 21/41

32 Identifying production sequences (cont.) ( ) ( ) ε 2IT70 (2016) Parse Trees 21/41

33 Identifying production sequences (cont.) ( ) ( ) ε ( ) 2IT70 (2016) Parse Trees 21/41

34 Identifying production sequences (cont.) ( ) ( ) ε ( ) ε 2IT70 (2016) Parse Trees 21/41

35 Identifying production sequences (once more) 2IT70 (2016) Parse Trees 22/41

36 Identifying production sequences (once more) 2IT70 (2016) Parse Trees 22/41

37 Identifying production sequences (once more) ( ) 2IT70 (2016) Parse Trees 22/41

38 Identifying production sequences (once more) ( ) ( ) 2IT70 (2016) Parse Trees 22/41

39 Identifying production sequences (once more) ( ) ( ) ε 2IT70 (2016) Parse Trees 22/41

40 Identifying production sequences (once more) ( ) ( ) ε ( ) 2IT70 (2016) Parse Trees 22/41

41 Identifying production sequences (once more) ( ) ( ) ε ( ) ε 2IT70 (2016) Parse Trees 22/41

42 Yield of a parse tree CFG G = (V, T, R, ) set PT G of all parse trees of G [X] single node tree, X V T [A ε] two node tree, root A, leaf ε for rule A ε R [A PT 1,PT 2,...,PT k ] rule A X 1 X k R parse trees PT i with root X i 2IT70 (2016) Parse Trees 23/41

43 Yield of a parse tree CFG G = (V, T, R, ) set PT G of all parse trees of G [X] single node tree, X V T [A ε] two node tree, root A, leaf ε for rule A ε R [A PT 1,PT 2,...,PT k ] rule A X 1 X k R parse trees PT i with root X i yield function yield : PT G (V T) yield([x]) = X yield([a ε]) = ε yield([a PT 1,...,PT k ]) = yield(pt 1 )... yield(pt k ) parse tree PT is complete if yield(pt) T 2IT70 (2016) Parse Trees 23/41

44 A parse tree with yield ()(()) ( ) ( ) ε ( ) ε 2IT70 (2016) Parse Trees 24/41

45 A parse tree with yield ()(()) ( ) ( ) ε ( ) ε 2IT70 (2016) Parse Trees 24/41

46 Another parse tree CFG AB A ε aaa B ε Bb A B a a A B b ε ε parse tree with yield aab 2IT70 (2016) Parse Trees 25/41

47 Another parse tree CFG AB A ε aaa B ε Bb A B a a A B b ε ε parse tree with yield aab 2IT70 (2016) Parse Trees 25/41

48 Parsing CFG G with rules ε ab ba aabb L(G)? w {a,b} 2IT70 (2016) Parse Trees 26/41

49 Parsing CFG G with rules ε ab ba aabb L(G)? ε a b b a ε awb bwa w 1 w 2 2IT70 (2016) Parse Trees 26/41

50 Parsing CFG G with rules ε ab ba aabb L(G)? ε a b b a ε awb bwa w 1 w 2 2IT70 (2016) Parse Trees 26/41

51 Parsing CFG G with rules ε ab ba aabb L(G)? a b a b a b a b ε a b b a 2IT70 (2016) Parse Trees 27/41

52 Parsing CFG G with rules ε ab ba aabb L(G)? a b a b a b a b ε a b b a ab aawbb abwab aw 1 w 2 b 2IT70 (2016) Parse Trees 27/41

53 Parsing CFG G with rules ε ab ba aabb L(G)? a b a b a b a b ε a b a b a b a b ε a b b a 2IT70 (2016) Parse Trees 28/41

54 Parsing CFG G with rules ε ab ba aabb L(G)? a b a b a b a b ε a b a b a b a b ε a b b a aabb aaawbbb aabwabb aaw 1 w 2 bb 2IT70 (2016) Parse Trees 28/41

55 Parsing CFG G with rules ε ab ba aabb L(G)? a b a b a b a b ε a b a b a b a b ε a b b a aabb aaawbbb aabwabb aaw 1 w 2 bb Thus aabb L(G) 2IT70 (2016) Parse Trees 28/41

56 Clicker question L91 parsing takes at most 2 w 1 rounds if no summand ε summands have at least one terminal or at least two variables 2IT70 (2016) Parse Trees 29/41

57 Clicker question L91 parsing takes at most 2 w 1 rounds if no summand ε summands have at least one terminal or at least two variables With the parsing procedure and restrictions above, we have that A. Parsing is linear in the length of the string B. Parsing is quadratic in the length of the string C. Parsing is exponential in the length of the string D. Can t tell 2IT70 (2016) Parse Trees 29/41

58 generated strings of terminals vs. yields of parse trees theorem CFG G = (V, T, R, ) A G w implies w = yield(pt) for parse tree PT with root A proof by induction on n: A n G w implies PT PT G(A): w = yield(pt) for all A V and w T 2IT70 (2016) Parse Trees 30/41

59 generated strings of terminals vs. yields of parse trees theorem CFG G = (V, T, R, ) A G w implies w = yield(pt) for parse tree PT with root A proof by induction on n: A n G w implies PT PT G(A): w = yield(pt) for all A V and w T thus L(G)={w T G w } {yield(pt) PT complete parse tree of G, root } 2IT70 (2016) Parse Trees 30/41

60 Clicker question L92 uppose X l G β for a CFG G. 2IT70 (2016) Parse Trees 31/41

61 Clicker question L92 uppose X l G β for a CFG G. Then it holds that A. αxγ l G αβγ for all α T and γ T B. αxγ l G αβγ for all α T and γ (V T) C. αxγ l G αβγ for all α (V T) and γ T D. αxγ l G αβγ for all α (V T) and γ (V T) E. Can t tell 2IT70 (2016) Parse Trees 31/41

62 From parse tree to leftmost production sequence theorem CFG G for parse tree PT, root A and yield w: A l G w proof induction on the height of the parse tree PT thus {yield(pt) PT complete parse tree of G, root } {w T G w }=L(G) 2IT70 (2016) Parse Trees 32/41

63 Different parse trees (harmless) a b a ε b ε aabb ε a b a ε b ε aabb ambiguous grammar ε ab 2IT70 (2016) Parse Trees 33/41

64 Different parse trees (harmful) E I E + E E * E ( E ) I a b c E E E E E + E I E + E E E E a I I I I c b c a b a*b+c a*b+c ambigious grammar 2IT70 (2016) Parse Trees 34/41

65 Different parse trees (harmful, cont.) E I E + E E * E ( E ) I a b c a c b c a b 2*3+4? wrong 2*3+4? right ambigious grammar 2IT70 (2016) Parse Trees 35/41

66 Disambiguation E T E + T T F T * F F I ( E ) I a b c syntactic categories: expression, term, factor, identifier 2IT70 (2016) Parse Trees 36/41

67 Disambiguation E E + T E T E + T T F T * F F I ( E ) I a b c T F T F I F I c I b a a*b+c syntactic categories: expression, term, factor, identifier 2IT70 (2016) Parse Trees 36/41

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 Quartile2, 2014-2015 Generating strings language L 1 èa n b n Ë n 0 í ab L 1 if w L 1 then awb L 1 2 IT70

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

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

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

Context-Free Grammars and Languages

Context-Free Grammars and Languages Context-Free Grammars and 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

Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x where

Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x where Recitation 11 Notes Context Free Grammars Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x A V, and x (V T)*. Examples Problem 1. Given the

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

Lecture 11 Context-Free Languages

Lecture 11 Context-Free Languages Lecture 11 Context-Free Languages COT 4420 Theory of Computation Chapter 5 Context-Free Languages n { a b : n n { ww } 0} R Regular Languages a *b* ( a + b) * Example 1 G = ({S}, {a, b}, S, P) Derivations:

More information

Automata Theory CS F-08 Context-Free Grammars

Automata Theory CS F-08 Context-Free Grammars Automata Theory CS411-2015F-08 Context-Free Grammars David Galles Department of Computer Science University of San Francisco 08-0: Context-Free Grammars Set of Terminals (Σ) Set of Non-Terminals Set of

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

5/10/16. Grammar. Automata and Languages. Today s Topics. Grammars Definition A grammar G is defined as G = (V, T, P, S) where:

5/10/16. Grammar. Automata and Languages. Today s Topics. Grammars Definition A grammar G is defined as G = (V, T, P, S) where: Grammar Automata and Languages Grammar Prof. Mohamed Hamada oftware Engineering Lab. The University of Aizu Japan Regular Grammar Context-free Grammar Context-sensitive Grammar Left-linear Grammar right-linear

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

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

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

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

Einführung in die Computerlinguistik

Einführung in die Computerlinguistik Einführung in die Computerlinguistik Context-Free Grammars (CFG) Laura Kallmeyer Heinrich-Heine-Universität Düsseldorf Summer 2016 1 / 22 CFG (1) Example: Grammar G telescope : Productions: S NP VP NP

More 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

Push-Down Automata and Context-Free Languages

Push-Down Automata and Context-Free Languages Chapter 3 Push-Down Automata and Context-Free Languages In the previous chapter, we studied finite automata, modeling computers without memory. In the next chapter, we study a general model of computers

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

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

Grammars and Context Free Languages

Grammars and Context Free Languages Grammars and Context Free Languages H. Geuvers and A. Kissinger Institute for Computing and Information Sciences Version: fall 2015 H. Geuvers & A. Kissinger Version: fall 2015 Talen en Automaten 1 / 23

More information

Context-free Grammars and Languages

Context-free Grammars and Languages Context-free Grammars and Languages COMP 455 002, Spring 2019 Jim Anderson (modified by Nathan Otterness) 1 Context-free Grammars Context-free grammars provide another way to specify languages. Example:

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

Computational Models - Lecture 4 1

Computational Models - Lecture 4 1 Computational Models - Lecture 4 1 Handout Mode Iftach Haitner. Tel Aviv University. November 21, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.

More information

5 Context-Free Languages

5 Context-Free Languages CA320: COMPUTABILITY AND COMPLEXITY 1 5 Context-Free Languages 5.1 Context-Free Grammars Context-Free Grammars Context-free languages are specified with a context-free grammar (CFG). Formally, a CFG G

More information

Formal Languages, Grammars and Automata Lecture 5

Formal Languages, Grammars and Automata Lecture 5 Formal Languages, Grammars and Automata Lecture 5 Helle Hvid Hansen helle@cs.ru.nl http://www.cs.ru.nl/~helle/ Foundations Group Intelligent Systems Section Institute for Computing and Information Sciences

More information

Languages. Languages. An Example Grammar. Grammars. Suppose we have an alphabet V. Then we can write:

Languages. Languages. An Example Grammar. Grammars. Suppose we have an alphabet V. Then we can write: Languages A language is a set (usually infinite) of strings, also known as sentences Each string consists of a sequence of symbols taken from some alphabet An alphabet, V, is a finite set of symbols, e.g.

More information

Grammars and Context Free Languages

Grammars and Context Free Languages Grammars and Context Free Languages H. Geuvers and J. Rot Institute for Computing and Information Sciences Version: fall 2016 H. Geuvers & J. Rot Version: fall 2016 Talen en Automaten 1 / 24 Outline Grammars

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

1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata.

1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata. Code No: R09220504 R09 Set No. 2 II B.Tech II Semester Examinations,December-January, 2011-2012 FORMAL LANGUAGES AND AUTOMATA THEORY Computer Science And Engineering Time: 3 hours Max Marks: 75 Answer

More information

Harvard CS 121 and CSCI E-207 Lecture 9: Regular Languages Wrap-Up, Context-Free Grammars

Harvard CS 121 and CSCI E-207 Lecture 9: Regular Languages Wrap-Up, Context-Free Grammars Harvard CS 121 and CSCI E-207 Lecture 9: Regular Languages Wrap-Up, Context-Free Grammars Salil Vadhan October 2, 2012 Reading: Sipser, 2.1 (except Chomsky Normal Form). Algorithmic questions about regular

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

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

Suppose h maps number and variables to ɛ, and opening parenthesis to 0 and closing parenthesis

Suppose h maps number and variables to ɛ, and opening parenthesis to 0 and closing parenthesis 1 Introduction Parenthesis Matching Problem Describe the set of arithmetic expressions with correctly matched parenthesis. Arithmetic expressions with correctly matched parenthesis cannot be described

More information

Context Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer.

Context Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer. Context Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer. Language Generator: Context free grammars are language generators,

More information

Chapter 5: Context-Free Languages

Chapter 5: Context-Free Languages Chapter 5: Context-Free Languages Peter Cappello Department of Computer Science University of California, Santa Barbara Santa Barbara, CA 93106 cappello@cs.ucsb.edu Please read the corresponding chapter

More information

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen Pushdown automata Twan van Laarhoven Institute for Computing and Information Sciences Intelligent Systems Version: fall 2014 T. van Laarhoven Version: fall 2014 Formal Languages, Grammars and Automata

More information

This lecture covers Chapter 5 of HMU: Context-free Grammars

This lecture covers Chapter 5 of HMU: Context-free Grammars This lecture covers Chapter 5 of HMU: Context-free rammars (Context-free) rammars (Leftmost and Rightmost) Derivations Parse Trees An quivalence between Derivations and Parse Trees Ambiguity in rammars

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

Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata

Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata Salil Vadhan October 4, 2012 Reading: Sipser, 2.2. Another example of a CFG (with proof) L = {x {a, b} : x has the same # of a s and

More information

Introduction and Motivation. Introduction and Motivation. Introduction to Computability. Introduction and Motivation. Theory. Lecture5: Context Free

Introduction and Motivation. Introduction and Motivation. Introduction to Computability. Introduction and Motivation. Theory. Lecture5: Context Free ntroduction to Computability Theory Lecture5: Context Free Languages Prof. Amos sraeli 1 ntroduction and Motivation n our study of RL-s we Covered: 1. Motivation and definition of regular languages. 2.

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

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3}, Code No: 07A50501 R07 Set No. 2 III B.Tech I Semester Examinations,MAY 2011 FORMAL LANGUAGES AND AUTOMATA THEORY Computer Science And Engineering Time: 3 hours Max Marks: 80 Answer any FIVE Questions All

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

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

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

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

FLAC Context-Free Grammars

FLAC Context-Free Grammars FLAC Context-Free Grammars Klaus Sutner Carnegie Mellon Universality Fall 2017 1 Generating Languages Properties of CFLs Generation vs. Recognition 3 Turing machines can be used to check membership in

More information

CPSC 313 Introduction to Computability

CPSC 313 Introduction to Computability CPSC 313 Introduction to Computability Grammars in Chomsky Normal Form (Cont d) (Sipser, pages 109-111 (3 rd ed) and 107-109 (2 nd ed)) Renate Scheidler Fall 2018 Chomsky Normal Form A context-free grammar

More information

Solutions to Problem Set 3

Solutions to Problem Set 3 V22.0453-001 Theory of Computation October 8, 2003 TA: Nelly Fazio Solutions to Problem Set 3 Problem 1 We have seen that a grammar where all productions are of the form: A ab, A c (where A, B non-terminals,

More information

PUSHDOWN AUTOMATA (PDA)

PUSHDOWN AUTOMATA (PDA) PUSHDOWN AUTOMATA (PDA) FINITE STATE CONTROL INPUT STACK (Last in, first out) input pop push ε,ε $ 0,ε 0 1,0 ε ε,$ ε 1,0 ε PDA that recognizes L = { 0 n 1 n n 0 } Definition: A (non-deterministic) PDA

More 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

Context-Free Grammars and Languages. We have seen that many languages cannot be regular. Thus we need to consider larger classes of langs.

Context-Free Grammars and Languages. We have seen that many languages cannot be regular. Thus we need to consider larger classes of langs. Context-Free Grammars and Languages We have seen that many languages cannot be regular. Thus we need to consider larger classes of langs. Contex-Free Languages (CFL s) played a central role natural languages

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

Pushdown Automata. Reading: Chapter 6

Pushdown Automata. Reading: Chapter 6 Pushdown Automata Reading: Chapter 6 1 Pushdown Automata (PDA) Informally: A PDA is an NFA-ε with a infinite stack. Transitions are modified to accommodate stack operations. Questions: What is a stack?

More 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

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

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

Properties of context-free Languages

Properties of context-free Languages 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,

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

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

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

Problem Session 5 (CFGs) Talk about the building blocks of CFGs: S 0S 1S ε - everything. S 0S0 1S1 A - waw R. S 0S0 0S1 1S0 1S1 A - xay, where x = y.

Problem Session 5 (CFGs) Talk about the building blocks of CFGs: S 0S 1S ε - everything. S 0S0 1S1 A - waw R. S 0S0 0S1 1S0 1S1 A - xay, where x = y. CSE2001, Fall 2006 1 Problem Session 5 (CFGs) Talk about the building blocks of CFGs: S 0S 1S ε - everything. S 0S0 1S1 A - waw R. S 0S0 0S1 1S0 1S1 A - xay, where x = y. S 00S1 A - xay, where x = 2 y.

More information

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

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

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

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

CPSC 421: Tutorial #1

CPSC 421: Tutorial #1 CPSC 421: Tutorial #1 October 14, 2016 Set Theory. 1. Let A be an arbitrary set, and let B = {x A : x / x}. That is, B contains all sets in A that do not contain themselves: For all y, ( ) y B if and only

More information

Intro to Theory of Computation

Intro to Theory of Computation Intro to Theory of Computation LECTURE 7 Last time: Proving a language is not regular Pushdown automata (PDAs) Today: Context-free grammars (CFG) Equivalence of CFGs and PDAs Sofya Raskhodnikova 1/31/2016

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

Theory of Computer Science

Theory of Computer Science Theory of Computer Science C1. Formal Languages and Grammars Malte Helmert University of Basel March 14, 2016 Introduction Example: Propositional Formulas from the logic part: Definition (Syntax of Propositional

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

Homework 4 Solutions. 2. Find context-free grammars for the language L = {a n b m c k : k n + m}. (with n 0,

Homework 4 Solutions. 2. Find context-free grammars for the language L = {a n b m c k : k n + m}. (with n 0, Introduction to Formal Language, Fall 2016 Due: 21-Apr-2016 (Thursday) Instructor: Prof. Wen-Guey Tzeng Homework 4 Solutions Scribe: Yi-Ruei Chen 1. Find context-free grammars for the language L = {a n

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

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages Context Free Languages Automata Theory and Formal Grammars: Lecture 6 Context Free Languages Last Time Decision procedures for FAs Minimum-state DFAs Today The Myhill-Nerode Theorem The Pumping Lemma Context-free

More information

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu Part 4 out of 5 ETH Zürich (D-ITET) October, 12 2017 Last week, we showed the equivalence of DFA, NFA and REX

More 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

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

CISC4090: Theory of Computation

CISC4090: Theory of Computation CISC4090: Theory of Computation Chapter 2 Context-Free Languages Courtesy of Prof. Arthur G. Werschulz Fordham University Department of Computer and Information Sciences Spring, 2014 Overview In Chapter

More information

Chapter 16: Non-Context-Free Languages

Chapter 16: Non-Context-Free Languages Chapter 16: Non-Context-Free Languages Peter Cappello Department of Computer Science University of California, Santa Barbara Santa Barbara, CA 93106 cappello@cs.ucsb.edu Please read the corresponding chapter

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

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

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

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

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

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

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

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

INSTITUTE OF AERONAUTICAL ENGINEERING

INSTITUTE OF AERONAUTICAL ENGINEERING INSTITUTE OF AERONAUTICAL ENGINEERING DUNDIGAL 500 043, HYDERABAD COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name : FORMAL LANGUAGES AND AUTOMATA THEORY Course Code : A40509 Class :

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

Sheet 1-8 Dr. Mostafa Aref Format By : Mostafa Sayed

Sheet 1-8 Dr. Mostafa Aref Format By : Mostafa Sayed Sheet -8 Dr. Mostafa Aref Format By : Mostafa Sayed 09 Introduction Assignment. For = {a, } a) Write 0 strings of the following languages i) All strings with no more than one a,,, a, a, a, a, a, a, a ii)

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

Finite Automata Theory and Formal Languages TMV026/TMV027/DIT321 Responsible: Ana Bove

Finite Automata Theory and Formal Languages TMV026/TMV027/DIT321 Responsible: Ana Bove Finite Automata Theory and Formal Languages TMV026/TMV027/DIT321 Responsible: Ana Bove Tuesday 28 of May 2013 Total: 60 points TMV027/DIT321 registration VT13 TMV026/DIT321 registration before VT13 Exam

More information

Theory of Computation (Classroom Practice Booklet Solutions)

Theory of Computation (Classroom Practice Booklet Solutions) Theory of Computation (Classroom Practice Booklet Solutions) 1. Finite Automata & Regular Sets 01. Ans: (a) & (c) Sol: (a) The reversal of a regular set is regular as the reversal of a regular expression

More information

CA320 - Computability & Complexity

CA320 - Computability & Complexity CA320 - Computability & Complexity Dav Sinclair Context-Free Grammars A context-free grammar (CFG) is a 4-tuple G = (N,Σ,S,P) where N is a set of nonterminal symbols, or variables, Σ is a set of terminal

More information

Chapter 4: Context-Free Grammars

Chapter 4: Context-Free Grammars Chapter 4: Context-Free Grammars 4.1 Basics of Context-Free Grammars Definition A context-free grammars, or CFG, G is specified by a quadruple (N, Σ, P, S), where N is the nonterminal or variable alphabet;

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

CSC 4181Compiler Construction. Context-Free Grammars Using grammars in parsers. Parsing Process. Context-Free Grammar

CSC 4181Compiler Construction. Context-Free Grammars Using grammars in parsers. Parsing Process. Context-Free Grammar CSC 4181Compiler Construction Context-ree Grammars Using grammars in parsers CG 1 Parsing Process Call the scanner to get tokens Build a parse tree from the stream of tokens A parse tree shows the syntactic

More information