Lecture 16 Cocke-Younger-Kasimi Parsing Topics: Closure Properties of Context Free Languages Cocke-Younger-Kasimi Parsing Algorithm June 23, 2015 CSCE.

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
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
Simplifying CFGs There are several ways in which context-free grammars can be simplified. One natural way is to eliminate useless symbols those that cannot.
The CYK Algorithm David Rodriguez-Velazquez CS – 6800 Summer I
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Introduction to Computability Theory
CS5371 Theory of Computation
Lecture Note of 12/22 jinnjy. Outline Chomsky Normal Form and CYK Algorithm Pumping Lemma for Context-Free Languages Closure Properties of CFL.
1 CSC 3130: Automata theory and formal languages Tutorial 4 KN Hung Office: SHB 1026 Department of Computer Science & Engineering.
Decidable and undecidable problems deciding regular languages and CFL’s Undecidable problems.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
Foundations of (Theoretical) Computer Science Chapter 4 Lecture Notes (Section 4.1: Decidable Languages) David Martin With modifications.
Normal forms for Context-Free Grammars
1 Module 32 Chomsky Normal Form (CNF) –4 step process.
January 23, 2015CS21 Lecture 81 CS21 Decidability and Tractability Lecture 8 January 23, 2015.
1 Applications of Regular Closure. 2 The intersection of a context-free language and a regular language is a context-free language context free regular.
Properties of Context-Free Languages
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
نظریه زبان ها و ماشین ها فصل دوم Context-Free Languages دانشگاه صنعتی شریف بهار 88.
CONVERTING TO CHOMSKY NORMAL FORM
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.
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.
 2005 SDU Lecture13 Reducibility — A methodology for proving un- decidability.
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.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
Lecture 17 Undecidability Topics:  TM variations  Undecidability June 25, 2015 CSCE 355 Foundations of Computation.
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
Lecture 16b Turing Machines Topics: Closure Properties of Context Free Languages Cocke-Younger-Kasimi Parsing Algorithm June 23, 2015 CSCE 355 Foundations.
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
Exercises on Chomsky Normal Form and CYK parsing
Lecture 15 Ambiguous Grammars Topics: Context Free Grammars Language generated by a grammar Proofs with L(G) Ambiguous grammars October 20, 2008 CSCE 355.
About Grammars Hopcroft, Motawi, Ullman, Chap 7.1, 6.3, 5.4.
 2005 SDU Lecture11 Decidability.  2005 SDU 2 Topics Discuss the power of algorithms to solve problems. Demonstrate that some problems can be solved.
Complexity and Computability Theory I Lecture #12 Instructor: Rina Zviel-Girshin Lea Epstein.
Closed book, closed notes
Normal Forms for CFG’s Eliminating Useless Variables Removing Epsilon
David Rodriguez-Velazquez CS – 6800 Summer I
Properties of Context-Free Languages
CSE 105 theory of computation
CSCE 355 Foundations of Computation
7. Properties of Context-Free Languages
Lecture 22 Pumping Lemma for Context Free Languages
PDAs Accept Context-Free Languages
CSCI 2670 Introduction to Theory of Computing
Lecture 14 Grammars – Parse Trees– Normal Forms
Jaya Krishna, M.Tech, Assistant Professor
Context-Free Languages
4. Properties of Regular Languages
7. Properties of Context-Free Languages
Deterministic PDAs - DPDAs
Closure Properties of Context-Free languages
Properties of Context-Free Languages
CSCE 531 Compiler Construction
Decidable Problems of Regular Languages
The Pumping Lemma for CFL’s
CSE 105 theory of computation
Decidability continued….
Applications of Regular Closure
Automata, Grammars and Languages
MA/CSSE 474 Theory of Computation
CSE 105 theory of computation
Normal Forms for Context-free Grammars
CSE 105 theory of computation
Presentation transcript:

Lecture 16 Cocke-Younger-Kasimi Parsing Topics: Closure Properties of Context Free Languages Cocke-Younger-Kasimi Parsing Algorithm June 23, 2015 CSCE 355 Foundations of Computation

– 2 – CSCE 355 Summer 2015 ialc slides Ullman Stanford Summary of Decision Properties  As usual, when we talk about “a CFL” we really mean “a representation for the CFL, e.g., a CFG or a PDA accepting by final state or empty stack.  There are algorithms to decide if: 1. String w is in CFL L. 2. CFL L is empty. 3. CFL L is infinite.

– 3 – CSCE 355 Summer 2015 ialc slides Ullman Stanford Non-Decision Properties  Many questions that can be decided for regular sets cannot be decided for CFL’s.  Example: Are two CFL’s the same?  Example: Are two CFL’s disjoint? How would you do that for regular languages?  Need theory of Turing machines and decidability to prove no algorithm exists.

– 4 – CSCE 355 Summer 2015 ialc slides Ullman Stanford Testing Emptiness  We already did this.  We learned to eliminate variables that generate no terminal string.  If the start symbol is one of these, then the CFL is empty; otherwise not.

– 5 – CSCE 355 Summer 2015 ialc slides Ullman Stanford Testing Membership  Want to know if string w is in L(G).  Assume G is in CNF. Or convert the given grammar to CNF. w = ε is a special case, solved by testing if the start symbol is nullable.  Algorithm (CYK ) is a good example of dynamic programming and runs in time O(n 3 ), where n = |w|.

– 6 – CSCE 355 Summer 2015 ialc slides Ullman Stanford CYK Algorithm  Let w = a 1 …a n.  We construct an n-by-n triangular array of sets of variables.  X ij = {variables A | A =>* a i …a j }.  Induction on j–i+1. The length of the derived string.  Finally, ask if S is in X 1n.

– 7 – CSCE 355 Summer 2015 ialc slides Ullman Stanford CYK Algorithm – (2)  Basis: X ii = {A | A -> a i is a production}.  Induction: X ij = {A | there is a production A -> BC and an integer k, with i BC and an integer k, with i < k < j, such that B is in X ik and C is in X k+1,j.

– 8 – CSCE 355 Summer 2015 ialc slides Ullman Stanford Example: CYK Algorithm Grammar: S -> AB A -> BC | a B -> AC | b C -> a | b String w = ababa X 11 ={A,C} X 22 ={B,C} X 33 ={A,C} X 44 ={B,C} X 55 ={A,C} X 12 ={B,S}X 23 ={A} X 34 ={B,S} X 45 ={A}

– 9 – CSCE 355 Summer 2015 ialc slides Ullman Stanford Example: CYK Algorithm X 11 ={A,C} X 22 ={B,C} X 33 ={A,C} X 44 ={B,C} X 55 ={A,C} X 12 ={B,S}X 23 ={A} X 34 ={B,S} X 45 ={A} X 13 ={} Yields nothing Grammar: S -> AB A -> BC | a B -> AC | b C -> a | b String w = ababa

– 10 – CSCE 355 Summer 2015 ialc slides Ullman Stanford Example: CYK Algorithm X 11 ={A,C} X 22 ={B,C} X 33 ={A,C} X 44 ={B,C} X 55 ={A,C} X 12 ={B,S}X 23 ={A} X 34 ={B,S} X 45 ={A} X 13 ={A}X 24 ={B,S} X 35 ={A} Grammar: S -> AB A -> BC | a B -> AC | b C -> a | b String w = ababa

– 11 – CSCE 355 Summer 2015 ialc slides Ullman Stanford Example: CYK Algorithm Grammar: S -> AB, A -> BC | a, B -> AC | b, C -> a | b String w = ababa X 11 ={A,C} X 22 ={B,C} X 33 ={A,C} X 44 ={B,C} X 55 ={A,C} X 12 ={B,S}X 23 ={A} X 34 ={B,S} X 45 ={A} X 13 ={A}X 24 ={B,S} X 35 ={A} X 14 ={B,S} Grammar: S -> AB A -> BC | a B -> AC | b C -> a | b String w = ababa

– 12 – CSCE 355 Summer 2015 ialc slides Ullman Stanford Example: CYK Algorithm X 11 ={A,C} X 22 ={B,C} X 33 ={A,C} X 44 ={B,C} X 55 ={A,C} X 12 ={B,S}X 23 ={A} X 34 ={B,S} X 45 ={A} X 13 ={A}X 24 ={B,S} X 35 ={A} X 14 ={B,S}X 25 ={A} X 15 ={A} Grammar: S -> AB A -> BC | a B -> AC | b C -> a | b String w = ababa

– 13 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 2010

– 14 – CSCE 355 Summer 2015 ialc slides Ullman Stanford  Minimize  First distinguishes F = {C,F,I} and Q-F = {A,B,D,E,G,H} 01 AABE BCF *CDH DEH EFI *FGB GHB HIC *IAE

– 15 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 2010  On 0 does the partition refine Π 1 = {C, F, I}, {A, B, D, E, G, H} On 0 these map to D G A B C E F H I so  Π 2 = {C, F, I}, {A, D} {E, B, H} 01 AABE BCF *CDH DEH EFI *FGB GHB HIC *IAE

– 16 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 2010

– 17 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 2010

– 18 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 2010

– 19 – CSCE 355 Summer 2015 ialc slides Ullman Stanford 2010