Closed book, closed notes

Slides:



Advertisements
Similar presentations
The Pumping Lemma for CFL’s
Advertisements

Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
Closure Properties of CFL's
About Grammars CS 130 Theory of Computation HMU Textbook: Sec 7.1, 6.3, 5.4.
1 Midterm I review Reading: Chapters Test Details In class, Wednesday, Feb. 25, :10pm-4pm Comprehensive Closed book, closed notes.
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.
Lecture Note of 12/22 jinnjy. Outline Chomsky Normal Form and CYK Algorithm Pumping Lemma for Context-Free Languages Closure Properties of CFL.
104 Closure Properties of Regular Languages Regular languages are closed under many set operations. Let L 1 and L 2 be regular languages. (1) L 1  L 2.
Normal forms for Context-Free Grammars
Properties of Context-Free Languages
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
1 Properties of Context-free Languages Reading: Chapter 7.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
1 Final Course Review Reading: Chapters Objectives Introduce concepts in automata theory and theory of computation Identify different formal language.
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.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
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.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
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.
C SC 473 Automata, Grammars & Languages Automata, Grammars and Languages Discourse 04 Context-Free Grammars and Pushdown Automata.
CFL Big Picture. Context Free Languages Conclusion We have studied the class of context free languages (CFL) We saw two different ways to express a CFL.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
CS 154 Formal Languages and Computability March 15 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
About Grammars Hopcroft, Motawi, Ullman, Chap 7.1, 6.3, 5.4.
Theory of Languages and Automata By: Mojtaba Khezrian.
1 Context-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5.
Context-Free Languages & Grammars (CFLs & CFGs) (part 2)
Context-Free Languages & Grammars (CFLs & CFGs)
Context-Free Languages & Grammars (CFLs & CFGs)
Context-Free Grammars: an overview
G. Pullaiah College of Engineering and Technology
CS510 Compiler Lecture 4.
Properties of Context-Free Languages
7. Properties of Context-Free Languages
Lecture 22 Pumping Lemma for Context Free Languages
Simplifications of Context-Free Grammars
CSE 105 theory of computation
Pushdown Automata (PDA). Part 2
PDAs Accept Context-Free Languages
Pushdown Automata (PDA). Part 1
Pushdown Automata (PDA)
FORMAL LANGUAGES AND AUTOMATA THEORY
Lecture 14 Grammars – Parse Trees– Normal Forms
Jaya Krishna, M.Tech, Assistant Professor
Context-Free Languages
Cpt S 317: Spring 2009 Reading: Chapters 1-9
Properties of Context-free Languages
Cpt S 317: Spring 2009 Reading: Chapters 1-4
4. Properties of Regular Languages
Definition: Let G = (V, T, P, S) be a CFL
7. Properties of Context-Free Languages
CHAPTER 2 Context-Free Languages
فصل دوم Context-Free Languages
Deterministic PDAs - DPDAs
Properties of Context-Free Languages
Department of Computer Science & Engineering
The Pumping Lemma for CFL’s
Context-Free Languages
Chapter 2 Context-Free Language - 01
CS21 Decidability and Tractability
CSE 105 theory of computation
Cpt S 317: Spring 2009 Reading: Chapters 1-4
Context-Free Languages
CFL Big Picture.
CSE 105 theory of computation
Presentation transcript:

Closed book, closed notes Cpt S 317: Spring 2009 Midterm II review Date: 4/17/2017 Time: 10:10-11am Location: In class Closed book, closed notes School of EECS, WSU

Main Topics Background on Regular Languages CFGs PDAs Cpt S 317: Spring 2009 Main Topics Background on Regular Languages Reg. lang. closure properties + DFA minimization CFGs PDAs CFLs & pumping lemma CFG simplification & normal forms School of EECS, WSU

Regular Languages (Background) Building DFA, NFA, -NFA Building regular expressions Closure property results of regular languages Which languages cannot be regular and why? Property Pumping lemma You need to know all material covered prior to Midterm I

CFGs G=(V,T,P,S) Derivation, recursive inference, parse trees Their equivalence Leftmost & rightmost derivation Generate from parse tree Regular languages vs. CFLs Right-linear & left-linear grammars

CFGs Designing CFGs (tips & techniques): Making your own start symbol for combining grammars Eg., Snew => S1 | S2 (or) Snew => S1 S2 Matching symbols & nested structures: (e.g., S => a S b | … ) Replicating nested structures side by side: (e.g., S => a S b S ) Use variables for specific purposes (similar to states) To go to an “acceptance” from a variable ==> end the recursive substitution by making it generate terminals directly A => w Conversely, to not go to acceptance from a variable, have recursion (loop back to same variable either directly or indirectly)

Proving CFGs are correct You will use induction either on Input string length Derivation length To show: “IF a string is of a particular form (e.g., balanced paranthesis), THEN it will be generated by G Use induction on string length To show: “IF a string is generated by L(G), THEN it is of a particular form (e.g., balanced paranthesis)” Use induction on derivation length

CFGs & ambiguity Ambiguity of CFGs To show that a CFG is ambiguous, given one input string in the language which has more than one parse tree (or equivalenty, >1 leftmost/rightmost derivation) Finding one example is sufficient A CFL is inherently ambiguous if all grammars for that language are going to be ambiguous Converting ambiguous CFGs to non-ambiguous CFGs Not possible for inherently ambiguous CFLs For unambiguous CFLs, use ambiguity resolving techniques (e.g., precedence)

PDAs PDA ==> -NFA + “a stack” P = ( Q,∑,, δ,q0,Z0,F ) δ(q,a,X) = {(p,Y), …} ID : (q, aw, XB ) |--- (p,w,AB) State diagram way to show the design of PDAs Next input symbol Current Stack top Stack Top Replacement (w/ string Y) Current state Next state a, X / Y qi qj

PDA - common mistakes Transition notation Goal: push symbol 0 on top of the current stack top symbol 1 a, 1 / 0 qi qj X Why? a / 1 0 qi qj X Why? a, 1 / 10 qi qj X Why? a, 1 / 01 qi qj

PDA - common mistakes… Transition notation Goal: pop stack top if stack top is 0 a, 0 / 0 qi qj X Why? a / 0 qi qj X Why? Remember: you can push multiple symbols in one step, but can pop only one symbol at a time a, 00 / 0 qi qj X Why? a, 0 /  qi qj

Design tips for PDAs Take advantage of the two types of PDAs Acceptance by empty stack If no more input and stack becomes empty Acceptance by final state If no more input and end in final state Convert one form to another Assign state for specific purposes Push to “remember” and Pop to “tally” Introducing your own stack symbols may help Take advantage of non-determinism

PDA design restrictions Feel free to design an empty stack PDA or final state PDA unless otherwise explicitly specified This is meant for design convenience But if I ask you design a specific type of PDA in the question, then show a direct construction i.e., do not convert one to another Same applies for PDA vs. CFG i.e., If I ask you to design a PDA, then give a direct construction (do not convert from CFG) Same for CFG

Conversion procedures Be familiar with: CFG => PDA conversion PDA empty stack => PDA final state PDA final state => PDA empty stack

CFG Simplification Eliminate -productions: A =>  Follow the algorithms described in class. if you come up with an ad hoc way that works for that example but not necessarily for others, then that could lead to reduction of points CFG Simplification Eliminate -productions: A =>  ==> substitute for A (with & without) Find nullable symbols first and substitute next Eliminate unit productions: A=> B ==> substitute for B directly in A Find unit pairs and then go production by production Eliminate useless symbols Retain only reachable and generating symbols Order: first generating test, and then reachability test Order is important : steps (1) => (2) => (3)

Chomsky Normal Form All productions of the form: A => BC or A=> a Grammar does not contain: Useless symbols, unit and -productions Converting CFG (without S=>*) into CNF Introduce new variables that collectively represent a sequence of other variables & terminals New variables for each terminal CNF ==> Parse tree size If the length of the longest path in the parse tree is n, then |w| ≤ 2n-1.

Pumping Lemma for CFLs Then there exists a constant n, s.t., if z is any string in L s.t. |z|≥n, then we can write z=uvwxy, subject to the following conditions: |vwx| ≤ n vx≠ For all k≥0, uvkwxky is in L

Using Pumping Lemmas for CFLs Steps: Let n be the P/L constant Pick a word z in the language s.t. |z|≥n (choice critical - any arbitrary choice may not work) z=uvwxy First, argue that because of conditions (1) & (2), the portions covered by vwx on the main string z will have to satisfy some properties Next, argue that by pumping up or down you will get a new string from z that is not in L Refer to the exercises done in class as examples

Closure Properties for CFL CFLs are closed under: Union Concatenation Kleene closure operator Substitution Homomorphism, inverse homomorphism CFLs are not closed under: Intersection Difference Complementation

Good luck !!