FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY 15-453.

Slides:



Advertisements
Similar presentations
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Advertisements

Closure Properties of CFL's
CFGs and PDAs Sipser 2 (pages ). Long long ago…
101 The Cocke-Kasami-Younger Algorithm An example of bottom-up parsing, for CFG in Chomsky normal form G :S  AB | BB A  CC | AB | a B  BB | CA | b C.
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.
About Grammars CS 130 Theory of Computation HMU Textbook: Sec 7.1, 6.3, 5.4.
Prof. Busch - LSU1 Simplifications of Context-Free Grammars.
Dept. of Computer Science & IT, FUUAST Automata Theory 2 Automata Theory VII.
Western Michigan University CS6800 Advanced Theory of Computation Spring 2014 By Abduljaleel Alhasnawi & Rihab Almalki.
The CYK Algorithm David Rodriguez-Velazquez CS – 6800 Summer I
Chapter 4 Normal Forms for CFGs Chomsky Normal Form n Defn A CFG G = (V, , P, S) is in chomsky normal form if each rule in G has one of.
CFGs and PDAs Sipser 2 (pages ). Last time…
CS5371 Theory of Computation
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 11, 2006.
Lecture Note of 12/22 jinnjy. Outline Chomsky Normal Form and CYK Algorithm Pumping Lemma for Context-Free Languages Closure Properties of CFL.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.1: Context-Free Grammars) David Martin With some.
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
1 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)
Normal forms for Context-Free Grammars
1 Module 32 Chomsky Normal Form (CNF) –4 step process.
Cs466(Prasad)L8Norm1 Normal Forms Chomsky Normal Form Griebach Normal Form.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Chapter 12: Context-Free Languages and Pushdown Automata
Lecture 21: Languages and Grammars. Natural Language vs. Formal Language.
Lecture 16 Oct 18 Context-Free Languages (CFL) - basic definitions Examples.
نظریه زبان ها و ماشین ها فصل دوم Context-Free Languages دانشگاه صنعتی شریف بهار 88.
CONVERTING TO CHOMSKY NORMAL FORM
Pushdown Automata (PDA) Intro
Context-Free Grammars Normal Forms Chapter 11. Normal Forms A normal form F for a set C of data objects is a form, i.e., a set of syntactically valid.
CSCI 2670 Introduction to Theory of Computing September 20, 2005.
Normal Forms for Context-Free Grammars Definition: A symbol X in V  T is useless in a CFG G=(V, T, P, S) if there does not exist a derivation of the form.
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.
Context-Free Grammars – Chomsky Normal Form Lecture 16 Section 2.1 Wed, Sep 26, 2007.
CSCI 2670 Introduction to Theory of Computing September 21, 2004.
CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Ambiguity.
Context-free Languages
The CYK Algorithm Presented by Aalapee Patel Tyler Ondracek CS6800 Spring 2014.
Midterm 1 Breakdown >79 3 >29 7 >69 5 >19 5 >59 7 >49 9 >39 7.
Section 12.4 Context-Free Language Topics
Lecture 11 Theory of AUTOMATA
Chapter 6 Simplification of Context-free Grammars and Normal Forms These class notes are based on material from our textbook, An Introduction to Formal.
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.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
1 Chapter 6 Simplification of CFGs and Normal Forms.
Grammars A grammar is a 4-tuple G = (V, T, P, S) where 1)V is a set of nonterminal symbols (also called variables or syntactic categories) 2)T is a finite.
Introduction Finite Automata accept all regular languages and only regular languages Even very simple languages are non regular (  = {a,b}): - {a n b.
Lecture 16: Modeling Computation Languages and Grammars Finite-State Machines with Output Finite-State Machines with No Output.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Normal forms.
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.
Exercises on Chomsky Normal Form and CYK parsing
Chomsky Normal Form.
About Grammars Hopcroft, Motawi, Ullman, Chap 7.1, 6.3, 5.4.
Computability Joke. Context-free grammars Parsing. Chomsky
Normal Forms for CFG’s Eliminating Useless Variables Removing Epsilon
Context-Free Grammars: an overview
Chomsky Normal Form CYK Algorithm
Complexity and Computability Theory I
CSC312 Automata Theory Grammatical Format Chapter # 13 by Cohen
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Jaya Krishna, M.Tech, Assistant Professor
CHAPTER 2 Context-Free Languages
The Cocke-Kasami-Younger Algorithm
Normal forms and parsing
Presentation transcript:

FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY

CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form: A → BC A → a S → ε B and C aren’t start variables a is a terminal S is the start variable Any variable A that is not the start variable can only generate strings of length > 0

CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form: A → BC A → a S → ε B and C aren’t start variables a is a terminal S is the start variable S → 0S1 S → TT T → ε S → TU | TV T → 0 U → SV S 0 → TU | TV | ε V → 1

Theorem: If G is in CNF, w  L(G) and |w| > 0, then any derivation of w in G has length 2|w| - 1 Proof (by induction on |w|): Base Case: If |w| = 1, then any derivation of w must have length 1 (S → a) Inductive Step: Assume true for any string of length at most k ≥ 1, and let |w| = k+1 Since |w| > 1, derivation starts with S → AB So w = xy where A  * x, |x| > 0 and B  * y, |y| > 0 By the inductive hypothesis, the length of any derivation of w must be 1 + (2|x| - 1) + (2|y| - 1) = 2(|x| + |y|) - 1

Theorem: Any context-free language can be generated by a context-free grammar in Chomsky normal form “Can transform any CFG into Chomsky normal form”

Theorem: Any context-free language can be generated by a context-free grammar in Chomsky normal form Proof Idea: 1. Add a new start variable 2. Eliminate all A  ε rules. Repair grammar 3. Eliminate all A  B rules. Repair 4. Convert A  u 1 u 2... u k to A  u 1 A 1, A 1  u 2 A 2,... If u i is a terminal, replace u i with U i and add U i  u i

1.Add a new start variable S 0 and add the rule S 0 → S S → 0S1 S → T#T T → ε S 0 → S 2. Remove all A → ε rules (where A is not S 0 ) For each occurrence of A on right hand side of a rule, add a new rule with the occurrence deleted If we have the rule B → A, add B → ε, unless we have previously removed B → ε S → T 3. Remove unit rules A → B Whenever B → w appears, add the rule A → w unless this was a unit rule previously removed S → T# S → #T S → # S → ε S → 01 S 0 → ε S 0 → 0S1

S → 0S1 S → T#T S → T# S → #T S → # S → 01 S 0 → ε S 0 → 0S1 S 0 → T#T S 0 → T# S 0 → #T S 0 → # S 0 → Convert all remaining rules into the proper form: S 0 → 0S1 S 0 → A 1 A 2 A 1 → 0 A 2 → SA 3 A 3 → 1 S 0 → 01 S 0 → A 1 A 3 S → 01 S → A 1 A 3

Convert the following into Chomsky normal form: A → BAB | B | ε B → 00 | ε A → BAB | B | ε B → 00 | ε S 0 → A A → BAB | B | BB | AB | BA B → 00 S 0 → A | ε A → BAB | 00 | BB | AB | BA B → 00 S 0 → BAB | 00 | BB | AB | BA | ε S 0 → BC | DD | BB | AB | BA | ε, C → AB, A → BC | DD | BB | AB | BA, B → DD, D → 0