0% found this document useful (0 votes)
16 views24 pages

FAFL Final Lecture 26.2 CMH

Uploaded by

shruthi g
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views24 pages

FAFL Final Lecture 26.2 CMH

Uploaded by

shruthi g
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Established as per the Section 2(f) of the UGC Act, 1956

Approved by AICTE, COA and BCI, New Delhi

Lecture 26.2
Simplification of CFG : Removal of ԑ production

S c h o o l o f C o m p u t i n g a n d I n f o r m a t i o n Te c h n o l o g y

Chaithra M H

AY:2020-2021
OUTLINE

Recap of Previous Lecture

Topic of the Lecture

Objective and Outcome of Lecture

Lecture Discussion
• Definition of ԑ production
• Eliminating ԑ-productions examples
• Definition of unit production
• Eliminating of unit-productions examples
• Summary
Simplification of CFG : Removal of ԑ
production
Recap of Previous Lecture
• Substitution with
examples
• Definition of Left
recursion with
ԑ production
examples CFG : Removal of
Simplification of
• Definition of Useless
Course Description
productions with
examples
• Summary
• Quiz RECAP OF PREVIOUS LECTURE
Simplification of CFG : Removal of ԑ
production
To p i c o f t h e L e c t u r e
• Definition of ԑ
production
• Eliminating ԑ-
productions examples ԑ production
CFG : Removal of
• Definition of unit Simplification of
production
• Eliminating of unit-
productions examples
• Summary
TOPIC OF THE LECTURE
Simplification of CFG : Removal of ԑ production
Introduction of ԑ-production
INTRODUCTION OF ԑ [EPSILON]

A production of the A Ԑ is undesirable in a CGF, unless an empty string is derived


from the start symbol.

The language generated from a grammar G does not derive any empty string and
grammar consists of Ԑ - productions. Such Ԑ - productions can be removed.

An Ԑ - production definition is seen in next slide


Simplification of CFG : Removal of ԑ
production
Definition of ԑ-production
DEFINITION OF Ԑ - PRODUCTION

Let G = ( V, T, P, S ) be a CFG. A production in P of the form A  Ԑ is called


Ԑ-production or NULL production. After applying the production the
variable A is erased.

For each A in V, if there is a derivation of the form A ⇒*Ԑ then A is a null


variable.
Simplification of CFG : Removal of ԑ
production
Problems on eliminating ԑ-production
PROBLEMS ON ELIMINATING Ԑ-PRODUCTIONS
Example-1
Eliminate all Ԑ- productions from the grammar:
SABCa|bD
ABC|b
Bb|Ԑ
Cc|Ԑ
Dd

Solution Old variable [ O V ] New variable [ N V ] Productions


Ф B,C Bԑ
Cԑ
Step-1
B,C B,C,A ABC
B,C,A B,C,A --

V = { B, C, A } are all nullable variables


PROBLEMS ON Ԑ-PRODUCTIONS
Example-1 contd…
Constructions of productions P‘ . Add a non ԑ-production in P to P‘. Take all combinations
Step-2
of nullable variables in a production, delete subset of nullable variables one by one and
add the resulting productions to P‘.
Productions Resulting productions [P‘] The grammar G’ = (V’ , T’ , P’ , S) where

S A B C a S A B C a | B C a | A C a | A B a | C a V’ = { S, A, B, C, D}
T’ = { a, b, c, d }
|Aa|Ba|a
P’ = {
SABCa|BCa|ACa|ABa|
SbD SbD
Ca|Aa|Ba|a|bD
ABC|b ABC|B|C|b ABC|B|C|b
Bb
Bb|ԑ Bb Cc
Dd
Cc|ԑ Cc }
S = start symbol
Dd|ԑ Dd
PROBLEMS ON Ԑ-PRODUCTIONS
Example-2
Eliminate all Ԑ- productions from the grammar:
SBAAB
A0A2|2A0|Ԑ
BAB|1B|Ԑ

Solution Old variable [ O V ] New variable [ N V ] Productions

Step-1 Ф A, B Aԑ
Bԑ
A, B A, B , S SBAAB
A, B , S A, B , S --

V = { S, A, B } are all nullable variables


Step-2 Constructions of productions P‘ . Add a non ԑ-production in P to P‘. Take all combinations
of nullable variables in a production, delete subset of nullable variables one by one and
add the resulting productions to P‘.
Productions Resulting productions [P‘] The grammar G’ = (V’ , T’ , P’ , S) where

SBAAB SBAAB|AAB|BAB|BAA|AB V’ = { S, A, B }
|BB|BA|AA|A|B T’ = { 0, 1, 2 }
P’ = {
A0A2 A0A2|02 SBAAB|AAB|BAB|BA
A|AB|BB|BA|AA|A|B
A2A0 A2A0|20 A0A2|02|2A0|20
BAB|B|A|1B|1
BAB BAB|B|A }
S = start symbol
B1B B1B|1
Eliminating ԑ- Definition of ԑ-
productions examples production
SUMMARY OF THE LECTURE
DISCUSSION
5 MINUTES
//
RESOURCES AND TASK
• https:
als/
Optional and non-optional reading resources of the Lecture
tutori
mata-
Optional Resources auto
n-
Web
utatio
comp
resources y-of-
theor
g/
Non-Optional Resources eks.or
forge
John E Hopcroft, Rajeev Motwani, Jeffrey D. Ullman, Introduction to
geeks
Automata Theory, Languages and Computation, 3rd Edition, Pearson
www.
Education, 2009. //
• https:
Peter Linz, An Introduction to formal Languages and Automata, 4/ E, Jones
htm
and Bartlett Publishers, 2006. index.
res/
Lectu
www.tu
• https://
SUMMARY OF THE LECTURE s/
Reading resources for the next lecture
tutorial
a-
automat
ation-
comput
Web of-
resources theory-
/
eeks.org
eksforg
John E Hopcroft, Rajeev Motwani, Jeffrey D. Ullman, Introduction to
www.ge
Automata Theory, Languages and Computation, 3rd Edition, Pearson
• https://
Education, 2009. m
index.ht
s/
Peter Linz, An Introduction to formal Languages and Automata, 4/ E, Jones
Lecture
and Bartlett Publishers, 2006. /
CptS317
h/
~anant
QUIZ TIME
10 MINUTES

“All of you have to give quiz where there


will be 8 questions covering part1 and
part 2 of lecture. It is compulsory as it is
used for assessment and attendance”
QUIZ
Questions from Lecture 26.1 & 26.2

1. Which of the following grammar rules violate the requirements of an operator


grammar ? P, Q, R are nonterminals, and r, s, t are terminals.
A) P → Q R B) P → Q s R

C) P → ε D) P → Q t R r

2. Suppose A->xBz and B->y, then the simplified grammar would


be:
A) A->xyz B) A->xBz|xyz

C) A->xBz|B|y D) none of the mentioned


QUIZ
Questions from Lecture 26.1 & 26.2

3. Given Grammar: S->A, A->aA, A->e, B->bA


Which among the following productions are Useless productions?

A) S->A B) A->e

C) A->aA D) B->bA

4. The variable which produces an epsilon is called:

A) empty variable B) nullable

C) terminal D) None of the Mentioned


QUIZ
Questions from Lecture 26.1 & 26.2
5. Statement:
For A-> e ,A can be erased. So whenever it appears on the left side of a production,
replace with another production without the A.
State true or false:
A) true B) false

6. Given:
S->…->xAy->…->w
if ____________, then A is useful, else useless symbol.

A) A is a non terminal B) A is a terminal

C) w Î L D) w Ë L
Thank you

You might also like