Loading in 5 sec....

Simplifications of Context-Free GrammarsPowerPoint Presentation

Simplifications of Context-Free Grammars

- 83 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about ' Simplifications of Context-Free Grammars' - tyrone-santiago

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

### Simplifications of Context-Free Grammars

### Normal FormsforContext-free Grammars

### The CYK Parser

COMP 335

COMP 335

COMP 335

COMP 335

COMP 335

terminals

In general:

if

then variable is useful

otherwise, variable is useless

COMP 335

useless

Variables

useless

useless

useless

useless

useless

useless

A production is useless

if any of its variables is useless

COMP 335

that produce terminal symbols:

(the rest variables are useless)

Remove useless productions

COMP 335

reachable from S

(the rest variables are useless)

Final Grammar

Remove useless productions

COMP 335

Removing All

- Step 1: Remove -productions
- Step 2: Remove Unit-productions
- Step 3: Remove Useless productions

COMP 335

COMP 335

Introduce variables for terminals:

COMP 335

Introduce intermediate variable:

COMP 335

Introduce intermediate variable:

COMP 335

From any context-free grammar

(which doesn’t produce )

not in Chomsky Normal Form

we can obtain:

An equivalent grammar

in Chomsky Normal Form

COMP 335

For any context-free grammar

(which doesn’t produce )

there is an equivalent grammar

in Chomsky Normal Form

COMP 335

- Chomsky normal forms are good
- for parsing and proving theorems

- It is very easy to find the Chomsky normal
- form for any context-free grammar

COMP 335

For any context-free grammar

(which doesn’t produce )

there is an equivalent grammar

in Greibach Normal Form

COMP 335

- Greibach normal forms are very good
- for parsing

- It is hard to find the Greibach normal
- form of any context-free grammar

COMP 335

COMP 335

Time Complexity:

Observation:

The CYK algorithm can be

easily converted to a parser

(bottom up parser)

COMP 335

Download Presentation

Connecting to Server..