Module32 - Module 32 • Chomsky Normal Form(CNF – Assume...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Module 32 Chomsky Normal Form (CNF) Assume we have eliminated unreachable variables and variables that cannot derive terminal strings 4 step process
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Chomsky Normal Form A CFG is in Chomsky normal form (CNF) if every production is one of these two types: A → BC A → a Key ideas Eliminating λ-productions (e.g. S → λ) Eliminating unit productions (e.g. A → B) Running Example S → AACD| ED A → aAb | λ C → aC | a D → aDa | bDb | λ E → ADD
Background image of page 2
3 Nullable Variables A variable A in a CFG G = (V, Σ, S, P) is defined as nullable if: Base case: P contains the production A → λ Recursive case: P contains the production A → B 1 B 2 … B n and B 1 through B n are nullable No other variables are nullable Which variables are nullable in the example? S → AACD|ED A → aAb | λ C → aC | a D → aDa | bDb | λ E → ADD
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Finding Nullable Variables * • Initialize N 0 to be the set of nullable variables by the base case definition i = 0; do i = i+1; – N i = N i-1 union {A | P contains A → α where α is a string in N i-1 * } • while N i ≠ N i-1; • The final N i is the set of nullable variables
Background image of page 4
5 Eliminating λ-productions * Given CFG G = (V, Σ, S, P), construct a CFG G 1 = (V, Σ, S, P 1 ) as follows. Initialize P
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/25/2008 for the course CSE 460 taught by Professor Torng during the Fall '07 term at Michigan State University.

Page1 / 15

Module32 - Module 32 • Chomsky Normal Form(CNF – Assume...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online