Midterm #2 — Review problems

Slides:



Advertisements
Similar presentations
CSCI 3130: Formal languages and automata theory Tutorial 5
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.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
Applied Computer Science II Chapter 2 : Context-free languages Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany.
CS 302: Discrete Math II A Review. An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x.
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 11, 2006.
Chap 2 Context-Free Languages. Context-free Grammars is not regular Context-free grammar : eg. G 1 : A  0A1substitution rules A  Bproduction rules B.
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 9, 2006.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
Today Chapter 2: (Pushdown automata) Non-CF languages CFL pumping lemma Closure properties of CFL.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Lecture 16 Oct 18 Context-Free Languages (CFL) - basic definitions Examples.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Design contex-free grammars that generate: L 1 = { u v : u ∈ {a,b}*, v ∈ {a, c}*, and |u| ≤ |v| ≤ 3 |u| }. L 2 = { a p b q c p a r b 2r : p, q, r ≥ 0 }
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.
Lecture # 5 Pumping Lemma & Grammar
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
CS 44 – Jan. 29 Expression grammars –Associativity √ –Precedence CFG for entire language (handout) CYK algorithm –General technique for testing for acceptance.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
Cs3102: Theory of Computation Class 8: Non-Context-Free Languages Spring 2010 University of Virginia David Evans.
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.
Review for final pm. 2 Review for Midterm Induction – On integer: HW1, Ex 2.2.9b p54 – On length of string: Ex p53, HW2, HW3.
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.
Pumping Lemma for CFLs. Theorem 7.17: Let G be a CFG in CNF and w a string in L(G). Suppose we have a parse tree for w. If the length of the longest path.
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
January 20, 2016CS21 Lecture 71 CS21 Decidability and Tractability Lecture 7 January 20, 2016.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Limitations.
Lecture # 31 Theory Of Automata By Dr. MM Alam 1.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
Transparency No. 1 Formal Language and Automata Theory Homework 5.
CS 154 Formal Languages and Computability March 15 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
Context Free Grammars & Parsing CPSC 388 Fall 2001 Ellen Walker Hiram College.
Closed book, closed notes
G. Pullaiah College of Engineering and Technology
7. Properties of Context-Free Languages
Theorem 29 Given any PDA, there is another PDA that accepts exactly the same language with the additional property that whenever a path leads to ACCEPT,
NPDAs Accept Context-Free Languages
Context free grammar.
CSE 105 theory of computation
Non-Context-Free Languages Sections: 2.3 page 123 October 17, 2008
PARSE TREES.
Context Free Languages
Context-Free Grammars Pushdown Store Automata Properties of the CFLs
Syntax Analysis Sections :.
Jaya Krishna, M.Tech, Assistant Professor
Context-free Languages
Definition: Let G = (V, T, P, S) be a CFL
7. Properties of Context-Free Languages
Context-Free Languages
فصل دوم Context-Free Languages
Properties of Context-Free Languages
Pumping Lemma September 29, 2006
Objectives The student will be able to:
Bell Ringer 10/27/10 What is the GCF? 18x³y² and 24x² ab and a³b².
CS21 Decidability and Tractability
Chapter 2 Context-Free Language - 02
CS21 Decidability and Tractability
LR(1) grammars The Chinese University of Hong Kong Fall 2011
Recap lecture 42 Row language, nonterminals defined from summary table, productions defined by rows, rules for defining productions, all possible productions.
CSE 105 theory of computation
Factoring using the greatest common factor (GCF).
Objectives The student will be able to:
Pumping Theorem for CFLs
CSE 105 theory of computation
Presentation transcript:

Midterm #2 — Review problems CS 350 — Fall 2018 gilray.org/classes/fall2018/cs350/

Midterm #2 The second midterm is Tuesday, Nov 13th, during class. What will not be covered: Pumping lemma for CFLs; non-context-free languages. What may be covered: anything else. Anything from midterm #1. Nonregular languages & the first pumping lemma. CFLs, CFGs, top-down parsing, derivations, parse trees, ambiguity/refactoring, regular grammars, CNF, PDAs, etc.

Exercise Problem: Which two grammars denote the same L? 𝑆→x𝑈x|𝑈 𝑇→𝑇xx|xx 𝑈→𝑈x|xx𝑈 𝑆→𝑉xx 𝑆→𝐴xx 𝑉→𝑉x|x 𝐴→x 𝑆→𝑆xx|x𝐴x 𝑆→x𝑆x|𝐴 𝐴→x 𝐴→x

Exercise Problem: Which two grammars denote the same L? 𝑆→x𝑈x|𝑈 𝑇→𝑇xx|xx 𝑈→𝑈x|xx𝑈 𝑆→𝑉xx 𝑆→𝐴xx 𝑉→𝑉x|x 𝐴→x 𝑆→𝑆xx|x𝐴x 𝑆→x𝑆x|𝐴 𝐴→x 𝐴→x

Exercise Problem: Which grammars are regular? 𝑆→xx𝑆𝑉|𝑉 𝑆→xyz𝐴 𝑉→𝑉x|x 𝐴→zz|𝑆 𝑆→x𝑇 𝑆→x𝑈x|𝑈 𝑇→𝑇xy𝑇|yx 𝑈→𝑈x|xx𝑈 𝑆→𝑆xx|x𝐴x 𝑆→xy𝑆|yz𝑅 𝐴→x 𝑅→xz𝑅|zz|𝜖

Exercise Problem: Which grammars are regular? 𝑆→xx𝑆𝑉|𝑉 𝑆→xyz𝐴 𝑉→𝑉x|x 𝐴→zz|𝑆 𝑆→x𝑇 𝑆→x𝑈x|𝑈 𝑇→𝑇xy𝑇|yx 𝑈→𝑈x|xx𝑈 𝑆→𝑆xx|x𝐴x 𝑆→xy𝑆|yz𝑅 𝐴→x 𝑅→xz𝑅|zz|𝜖

Exercise Problem: Find a regular grammar for a(b*a)*.

Exercise Problem: Find a regular grammar for a(b*a)*.

Exercise Problem: Explicitly left-factor the following grammar: 𝑆→ab|a𝑆|b

Exercise Problem: Explicitly left-factor the following grammar: 𝑆→ab|a𝑆|b 𝑆→a𝑇|b 𝑇→b|a𝑆

Exercise Problem: Explicitly left-factor the following grammar: 𝑆→ab𝑇|aa𝑉 𝑇→b𝑆|b𝑉|c 𝑉→a|b

Exercise Problem: Explicitly left-factor the following grammar: 𝑆→ab𝑇|aa𝑉 𝑇→b𝑆|b𝑉|c 𝑉→a|b 𝑆→a 𝑆 ′ 𝑆 ′ →b𝑇|a𝑉 𝑇→b 𝑇 ′ |c 𝑇 ′ →a 𝑇 ′′ |b 𝑉→a|b 𝑇 ′′ →b𝑇|a𝑉|𝜖

Exercise Problem: Diagram an empty-stack-accepting PDA, where |Q| = 1, that accepts the language of even-length strings over {a}. q0 ?

a,A/𝜖 a, Z 0 / AZ 0 𝜖, Z 0 /𝜖 ⟨{ 𝑞 0 },{a},{A, Z 0 },𝛿, 𝑞 0 , Z 0 ,Ø⟩ Exercise Problem: Diagram an empty-stack-accepting PDA, where |Q| = 1, that accepts the language of even-length strings over {a}. q0 a,A/𝜖 a, Z 0 / AZ 0 𝜖, Z 0 /𝜖 𝛿={( 𝑞 0 ,a,A,{( 𝑞 0 ,𝜖)}),( 𝑞 0 ,a, Z 0 ,{( 𝑞 0 , AZ 0 )}),( 𝑞 0 ,𝜖, Z 0 ,{( 𝑞 0 ,𝜖)})} ⟨{ 𝑞 0 },{a},{A, Z 0 },𝛿, 𝑞 0 , Z 0 ,Ø⟩

Exercise Problem: Define a grammar, over terminals {[,]}, in regex [*]*, for the language of mismatched braces.

𝑆→𝐿𝑀|𝑀𝑅 𝑀→[𝑀]|𝜖 𝐿→[𝐿|[ 𝑅→]𝑅|] Exercise Problem: Define a grammar, over terminals {[,]}, in regex [*]*, for the language of mismatched braces. 𝑆→𝐿𝑀|𝑀𝑅 𝑀→[𝑀]|𝜖 𝐿→[𝐿|[ 𝑅→]𝑅|]