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

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

1 Module 32 Chomsky Normal Form (CNF) Assume we have eliminated unreachable variables and variables that cannot derive terminal strings 4 step process

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

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

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

View Full Document
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
5 Eliminating λ-productions * Given CFG G = (V, Σ, S, P), construct a CFG G 1 = (V, Σ, S, P 1 ) as follows.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern