We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byAlbert Henry
Modified about 1 year ago
Fall 2004COMP 3351 Simplifications of Context-Free Grammars
Fall 2004COMP 3352 A Substitution Rule Substitute Equivalent grammar
Fall 2004COMP 3353 A Substitution Rule Equivalent grammar Substitute
Fall 2004COMP 3354 In general: Substitute equivalent grammar
Fall 2004COMP 3355 Nullable Variables Nullable Variable:
Fall 2004COMP 3356 Removing Nullable Variables Example Grammar: Nullable variable
Fall 2004COMP 3357 Substitute Final Grammar
Fall 2004COMP 3358 Unit-Productions Unit Production: (a single variable in both sides)
Fall 2004COMP 3359 Removing Unit Productions Observation: Is removed immediately
Fall 2004COMP Example Grammar:
Fall 2004COMP Substitute
Fall 2004COMP Remove
Fall 2004COMP Substitute
Fall 2004COMP Remove repeated productions Final grammar
Fall 2004COMP Useless Productions Some derivations never terminate... Useless Production
Fall 2004COMP Another grammar: Not reachable from S Useless Production
Fall 2004COMP In general: if then variable is useful otherwise, variable is useless contains only terminals
Fall 2004COMP A production is useless if any of its variables is useless Productions useless Variables useless
Fall 2004COMP Removing Useless Productions Example Grammar:
Fall 2004COMP First: find all variables that can produce strings with only terminals Round 1: Round 2:
Fall 2004COMP Keep only the variables that produce terminal symbols: (the rest variables are useless) Remove useless productions
Fall 2004COMP Second: Find all variables reachable from Use a Dependency Graph not reachable
Fall 2004COMP Keep only the variables reachable from S Final Grammar (the rest variables are useless) Remove useless productions
Fall 2004COMP Removing All Step 1: Remove -productions Step 2: Remove Unit-productions Step 3: Remove Useless productions
Fall 2004COMP Normal Forms for Context-free Grammars
Fall 2004COMP Chomsky Normal Form Each productions has form: variable or terminal
Fall 2004COMP Examples: Not Chomsky Normal Form Chomsky Normal Form
Fall 2004COMP Conversion to Chomsky Normal Form Example: Not Chomsky Normal Form
Fall 2004COMP Introduce variables for terminals:
Fall 2004COMP Introduce intermediate variable:
Fall 2004COMP Introduce intermediate variable:
Fall 2004COMP Final grammar in Chomsky Normal Form: Initial grammar
Fall 2004COMP From any context-free grammar (which doesn’t produce ) not in Chomsky Normal Form we can obtain: An equivalent grammar in Chomsky Normal Form In general:
Fall 2004COMP The Procedure First remove: Nullable variables Unit productions
Fall 2004COMP Then, for every symbol : In productions: replace with Add production New variable:
Fall 2004COMP Replace any production with New intermediate variables:
Fall 2004COMP Theorem: For any context-free grammar (which doesn’t produce ) there is an equivalent grammar in Chomsky Normal Form
Fall 2004COMP Observations Chomsky normal forms are good for parsing and proving theorems It is very easy to find the Chomsky normal form for any context-free grammar
Fall 2004COMP Greibach Normal Form All productions have form: symbolvariables
Fall 2004COMP Examples: Greibach Normal Form Not Greibach Normal Form
Fall 2004COMP Conversion to Greibach Normal Form: Greibach Normal Form
Fall 2004COMP Theorem: For any context-free grammar (which doesn’t produce ) there is an equivalent grammar in Greibach Normal Form
Fall 2004COMP Observations Greibach normal forms are very good for parsing It is hard to find the Greibach normal form of any context-free grammar
Fall 2004COMP The CYK Parser
Fall 2004COMP The CYK Membership Algorithm Input: Grammar in Chomsky Normal Form String Output: find if
Fall 2004COMP The Algorithm Grammar : String : Input example:
Fall 2004COMP 33547
Fall 2004COMP 33548
Fall 2004COMP 33549
Fall 2004COMP 33550
Fall 2004COMP Therefore: Time Complexity: The CYK algorithm can be easily converted to a parser (bottom up parser) Observation:
1 Simplifications of Context-Free Grammars. 2 A Substitution Rule Substitute Equivalent grammar.
Fall 2006Costas Buch - RPI1 Simplifications of Context-Free Grammars.
REMOVING LEFT RECURSION AND INDIRECT LEFT RECURSION.
Hector Miguel Chavez Western Michigan University.
1 PDAs Accept Context-Free Languages. 2 Context-Free Languages (Grammars) Languages Accepted by PDAs Theorem:
Compiler Construction A Compulsory Module for Students in Computer Science Department Faculty of IT / Al – Al Bayt University Second Semester 2010/2011.
8.2 Systems of Linear Equations: Two Equations Containing Two Variables
Parsing 4 Dr William Harrison Fall 2008 CS4430 – Compilers I.
How to convert a left linear grammar to a right linear grammar Roger L. Costello May 28, 2014.
Grammar types There are 4 types of grammars according to the types of rules: – General grammars – Context Sensitive grammars – Context Free grammars –
Tangent Lines Section 2.1. Secant Line A secant line is a line that connects two points on a graph. Notice the slopes of secant lines are different depending.
Context-Free and Noncontext-Free Languages Chapter 13.
Parsing II : Top-down Parsing Lecture 7 CS 4318/5531 Spring 2010 Apan Qasem Texas State University *some slides adopted from Cooper and Torczon.
2.3 Continuity When you plot function values generated in a laboratory or collected in a field, you can connect the plotted points with an unbroken curve.
Measuring Time Complexity Sipser 7.1 (pages )
CS416 Compilr Design1 Syntax Analyzer Syntax Analyzer creates the syntactic structure of the given source program. This syntactic structure is mostly a.
CSCI 3130: Formal Languages and Automata Theory Tutorial 5 Hung Chun Ho Office: SHB 1026 Department of Computer Science & Engineering 1.
1.4 Linear Equations in Two Variables. Definition of Slope The slope of the line through the distinct points (x 1, y 1 ) and (x 2, y 2 ) is where x 2.
Planes in three dimensions 1.Normal equation 2.Cartesian equation of plane 3.Angle between a line and a plane or between two planes 4.Determine whether.
How To Multiply Fractions Introducing: factor product reciprocal inverse identity inverse.
Parsing V: Bottom-up Parsing Lecture 10 CS 4318/5531 Spring 2009 Apan Qasem Texas State University *some slides adopted from Cooper and Torczon.
Completeness and Expressiveness. Consistency: a syntactic definition, related to the proof system. A set of formulas is consistent if there is no formula.
The Rational Zero Theorem. The Rational Zero Theorem gives a list of possible rational zeros of a polynomial function. Equivalently, the theorem gives.
Artificial Intelligence 8. The Resolution Method Course V231 Department of Computing Imperial College, London Jeremy Gow.
Solving Systems of Equations using Substitution * Best method when one variable is already solved for or if a variable has a coefficient of 1.
Automated Theorem Proving Lecture 2 Propositional Satisfiability.
Introduction to Proofs A proof is a valid argument that establishes the truth of a statement. Previous section discussed formal proofs Informal proofs.
Iterative Rounding and Iterative Relaxation Some of the slides prepared by Lap Chi Lau.
CS 336 March 19, 2012 Tandy Warnow. Basic Graph Terminology Nodes, vertices, edges, degrees, paths, cycles, connected components, adjacency, isolated.
3.6 Solving Systems of Linear Equations in Three Variables.
© 2016 SlidePlayer.com Inc. All rights reserved.