Download presentation
Presentation is loading. Please wait.
1
Context Free Grammar: Simplification
Erwin Yudi Hidayat
2
CFG Simplification Purpose: to limit or minimize complexity in parsing a tree due to unnecessary production rule Example: production rule in CFG is defined as follow: SAB a Aa ???
3
CFG Simplification Purpose: to limit or minimize complexity in parsing a tree due to unnecessary production rule Example: production rule in CFG is defined as follow: SAB a Aa B has no derivation...
4
D A : causes complexity (redundant)
CFG Simplification What about this one? SA AB BC CD Da A Lengthy path D A : causes complexity (redundant)
5
CFG Simplification Context Free Grammar can be simplified by:
Useless production elimination Unit production elimination production elimination
6
Useless Production Elimination
Useless production is defined as: Any production contains variable which has no derivation to produce terminals. This production is useless as endless derivation (variable symbol still remains) Any production that never can be reached using any derivation from start symbol, therefore this production is redundant.
7
Useless Production Elimination
Example: production rule in CFG is as follow: SaSa Abd Bde AAda BBBB a Variable A has no derivation to reach terminal As consequence, S Abd has no derivation Simplified CFG: SaSa Bde
8
Useless Production Elimination
Example: production rule in CFG is as follow: S Aa B Aab D Bb E Cbb EaEa Variable E has no derivation to reach terminal Variable D has no derivation to reach terminal Variable C never be used Simplified CFG: SAa B Aab Bb
9
Unit Production Elimination
Unit production is defined as any production that consist only one single variable symbol, e.g. A B, C D Example: production rule in CFG is as follow: SSb SC CD Cef Ddd
10
Unit Production Elimination
Unit production is defined as any production that consist only one single variable symbol, e.g. A B, C D Example: production rule in CFG is as follow: SSb SC CD Cef Ddd
11
Unit Production Elimination
Unit production is defined as any production that consist only one single variable symbol, e.g. A B, C D Example: production rule in CFG is as follow: SSb SC Cdd Cef Ddd
12
Unit Production Elimination
Unit production is defined as any production that consist only one single variable symbol, e.g. A B, C D Example: production rule in CFG is as follow: SSb SC Cdd Cef Ddd
13
Unit Production Elimination
Unit production is defined as any production that consist only one single variable symbol, e.g. A B, C D Example: production rule in CFG is as follow: SSb Sdd | ef Cdd Cef Ddd
14
Unit Production Elimination
Unit production is defined as any production that consist only one single variable symbol, e.g. A B, C D Example: production rule after simplification: SSb Sdd | ef Cdd Cef Ddd
15
Unit Production Elimination
Ctd...
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.