Lecture7x

Lecture7x - 15-453 FORMAL LANGUAGES, AUTOMATA AND...

This preview shows pages 1–9. Sign up to view the full content.

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 Lecture7x.ppt

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Chomsky Normal Form and TURING MACHINES
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 (except the start variable) can only generate strings of length > 0

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
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

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
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

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
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
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/29/2012 for the course CS 15-453 taught by Professor Edmundm.clarke during the Spring '09 term at Carnegie Mellon.

Page1 / 33

Lecture7x - 15-453 FORMAL LANGUAGES, AUTOMATA AND...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online