Transparency No. 1 Formal Language and Automata Theory Homework 5.

Slides:



Advertisements
Similar presentations
1 Lecture 32 Closure Properties for CFL’s –Kleene Closure construction examples proof of correctness –Others covered less thoroughly in lecture union,
Advertisements

Lecture # 8 Chapter # 4: Syntax Analysis. Practice Context Free Grammars a) CFG generating alternating sequence of 0’s and 1’s b) CFG in which no consecutive.
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
CFGs and PDAs Sipser 2 (pages ). Long long ago…
About Grammars CS 130 Theory of Computation HMU Textbook: Sec 7.1, 6.3, 5.4.
Dept. of Computer Science & IT, FUUAST Automata Theory 2 Automata Theory VII.
CSCI 2670 Introduction to Theory of Computing September 15, 2004.
CFGs and PDAs Sipser 2 (pages ). Last time…
1 Introduction to Computability Theory Lecture5: Context Free Languages Prof. Amos Israeli.
CS5371 Theory of Computation
Applied Computer Science II Chapter 2 : Context-free languages Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany.
Transparency No. P2C4-1 Formal Language and Automata Theory Part II Chapter 4 Parse Trees and Parsing.
1 CSC 3130: Automata theory and formal languages Tutorial 4 KN Hung Office: SHB 1026 Department of Computer Science & Engineering.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)
1 Module 31 Closure Properties for CFL’s –Kleene Closure construction examples proof of correctness –Others covered less thoroughly in lecture union, concatenation.
1 CSCI 3130: Formal Languages and Automata Theory Tutorial 4 Hung Chun Ho Office: SHB 1026 Department of Computer Science & Engineering.
Normal forms for Context-Free Grammars
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
CS 3240 – Chapter 8.  Is a n b n c n context-free? CS Properties of Context-Free Languages2.
Lecture 9UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 9.
Context-Free Grammars Chapter 3. 2 Context-Free Grammars and Languages n Defn A context-free grammar is a quadruple (V, , P, S), where  V is.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Context-Free Grammars
Formal Grammars Denning, Sections 3.3 to 3.6. Formal Grammar, Defined A formal grammar G is a four-tuple G = (N,T,P,  ), where N is a finite nonempty.
Lecture 16 Oct 18 Context-Free Languages (CFL) - basic definitions Examples.
نظریه زبان ها و ماشین ها فصل دوم Context-Free Languages دانشگاه صنعتی شریف بهار 88.
CONVERTING TO CHOMSKY NORMAL FORM
Context-free Grammars Example : S   Shortened notation : S  aSaS   | aSa | bSb S  bSb Which strings can be generated from S ? [Section 6.1]
CSCI 2670 Introduction to Theory of Computing September 21, 2004.
1 Context-Free Languages Not all languages are regular. L 1 = {a n b n | n  0} is not regular. L 2 = {(), (()), ((())),...} is not regular.  some properties.
Context Free Grammars CIS 361. Introduction Finite Automata accept all regular languages and only regular languages Many simple languages are non regular:
Chapter 5 Context-Free Grammars
Grammars CPSC 5135.
Context-free Languages
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
Lecture # 9 Chap 4: Ambiguous Grammar. 2 Chomsky Hierarchy: Language Classification A grammar G is said to be – Regular if it is right linear where each.
Context Free Grammar. Introduction Why do we want to learn about Context Free Grammars?  Used in many parsers in compilers  Yet another compiler-compiler,
CS 3240: Languages and Computation Context-Free Languages.
The CYK Algorithm Presented by Aalapee Patel Tyler Ondracek CS6800 Spring 2014.
Membership problem CYK Algorithm Project presentation CS 5800 Spring 2013 Professor : Dr. Elise de Doncker Presented by : Savitha parur venkitachalam.
Grammar G = (V N, V T, P, S) –V N : Nonterminal symbols –V T : Terminal symbols V N  V T = , V N ∪ V T = V – P : a finite set of production rules α 
Midterm 1 Breakdown >79 3 >29 7 >69 5 >19 5 >59 7 >49 9 >39 7.
Context Free Grammars.
CSCI 3130: Formal languages and automata theory Tutorial 4 Chin.
1 Simplification of Context-Free Grammars Some useful substitution rules. Removing useless productions. Removing -productions. Removing unit-productions.
Closure Properties Lemma: Let A 1 and A 2 be two CF languages, then the union A 1  A 2 is context free as well. Proof: Assume that the two grammars are.
Re-enter Chomsky More about grammars. 2 Parse trees S  A B A  aA | a B  bB | b Consider L = { a m b n | m, n > 0 } (one/more a ’s followed by one/more.
Grammars CS 130: Theory of Computation HMU textbook, Chap 5.
Non-CF Languages The language L = { a n b n c n | n  0 } does not appear to be context-free. Informal: A PDA can compare #a’s with #b’s. But by the time.
1 Chapter 6 Simplification of CFGs and Normal Forms.
Homework 4 due 11/25.
Introduction Finite Automata accept all regular languages and only regular languages Even very simple languages are non regular (  = {a,b}): - {a n b.
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
CSCI 2670 Introduction to Theory of Computing September 14, 2005.
Lecture # 31 Theory Of Automata By Dr. MM Alam 1.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Dept. of Computer Science & IT, FUUAST Theory of Computation 2 Regular Expressions Regular Expression.
Lecture 6: Context-Free Languages
Theory of Languages and Automata By: Mojtaba Khezrian.
CSCI 2670 Introduction to Theory of Computing September 16, 2004.
Context Free Grammars & Parsing CPSC 388 Fall 2001 Ellen Walker Hiram College.
Lecture 17: Theory of Automata:2014 Context Free Grammars.
Formal Language & Automata Theory
PARSE TREES.
Context-free Languages
فصل دوم Context-Free Languages
Department of Computer Science & Engineering
Midterm #2 — Review problems
Theory of Computation Lecture #
Presentation transcript:

Transparency No. 1 Formal Language and Automata Theory Homework 5

Homework Transparency No CFG design 1. Give context-free grammars that generate the following languages. 1.1 A1 = {0,1}* 1.2 A2 = {w  {a,b}* | w ends with ‘aba’.} 1.3 A3 = {w | w matches the regular expression (ab*+ba*)* } 1.4 A4 = {w  {0,1}* | w contains more 0s than 1s,i.e.,#0(w) > #1(w).} 1.5 A5 = {0,1}* - { ww | w  {0,1}* }. Notes. 1. A1, A2 and A3 are regular. 2. Hint for 1.4: Two grammars for the language A4’ = {w | w contains as many 0s as 1s, i.e., #0(w) = #1(w). } can be given as follows: G 1 : S   | 0S1 | 1S0 | SS or G 2 : T   | 0A | 1BA  1 | 0AA | 1T B  0 | 1BB | 0T (For G 2 : we have: for all x  L(T), y  L(A) and z  L(B), #0(x)=#1(x), #1(y) = #0(y) + 1, #0(z) = #1(z) + 1. )

Homework Transparency No Regular grammar 2. Let B = { x  {a,b}* | k  0, #b(x) = 4k+1 or 4k+2 } 2.1 Find a strongly right linear grammar G1 such that L(G1) = B. 2.2 Find a strongly left linear grammar G2 such that L(G2) = B. //note: #b(x) is the number of b’s occurring in x. 3. Given the following Grammar G3: S  A | T | AS T   | bA | aB A  a | bAA | aT B  b | aBB | bT 3.1 Find a grammar G4 containing no  -rule such that L(G4) = L(G3) – {  }. 3.2 Find a grammar G5 containing no unit rule such that L(G5) = L(G4) 3.3 Find a Gramamr G6 in Chomsky normal form such that L(G6) = L(G5).

Homework Transparency No. 4 3 Pumping lemma for CFL 3.1 Show that the language A = { a k b s c t  {a,b,c}* | 0< k < s < t } is not context free. 3.2 Show that the language B = { xy  {0,1}* | x  {0,1}* and y is the 1's complement of x.} is not context free. Instances of B include 0110, etc, but do not include 0101, 010 and 0111.

Homework Transparency No Context free grammar composition Given two grammar : G7: S  bS | Ab A  a | BA | SB B  bA | bB G8: T  Tb | aTC C  aC | bT 4.1 Find a CFG G9 such that L(G9) = L(G7)  L(G8). 4.2 Find a CFG G10 such that L(G10) = (L(G7)  L(G8) )*. Notes 1.you can reuse production rules and symbols in G7 and G8. 2.You need not study the specific details of G7 and G8, since, as studied in the lecture, there is a systematic method to compose both grammars directly from the general definition of two input CFGs.

Homework Transparency No CYK algorithm 5.1. Given the grammar G in Chomsky normal form S  AB A  BB | a B  AB | b | AA 1 Apply the CYK algorithm on the input string aabba to determine if it is in L(G) by completing the following table. 2 Is aabba a member of L(G) ? why ? 3 Is this grammar ambiguous ? why ? 4 a 3 b 2 b 1 a 0 a

Homework Transparency No CYK algorithm 5.2 Given the grammar G in Chomsky normal form S  CB | DA A  a | CS | EA B  b | DS | FB C  aD  b E  DA F  CB 1 Apply the CYK algorithm on the input string aabbab to determine if it is in L(G) by completing the following table. 2 Is aabbab a member of L(G) ? 3 Is this grammar ambiguous ? 5 b 4 a 3 b 2 b 1 a 0 a

Homework Transparency No Parse trees and derivations 6.Given the following grammar : S   | aB | bA A  aS | bAA B  bS | aBB 6.1 Find a left-most derivation for the string aabbba 6.2 Find a right-most derivation for the string babbaa. 6.3 Find a parse tree for aababb.