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

Info icon This 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
Image of page 1

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

View Full Document Right 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
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
Image of page 3

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

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

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern