SlideShare a Scribd company logo
1 of 46
UNIT - IV
Prepared By:
K Lakshmi Sravani
Assistant Professor
Syllabus
● Normal Forms for Context- Free Grammars: Eliminating
useless symbols, Eliminating €-Productions. Chomsky Normal
form Griebech Normal form.
● Pumping Lemma for Context-Free Languages: Statement of
pumping lemma, Applications
● Closure Properties of Context-Free Languages: Closure
properties of CFL’s, Decision Properties of CFL's
● Turing Machines: Introduction to Turing Machine, Formal
Description, Instantaneous description, The language of a
Turing machine
Normal Forms for Context- Free
Grammars:
● The goal is to show that every CFL (without ε) is generated by a
CFG in which all productions are of the form A ! BC or A
! a, where A, B, C are variables, and a is a terminal.
● A number of simplifications is inevitable:
i. The elimination of useless symbols.
ii. The elimination of ε or null productions.
iii. The elimination of unit productions
The elimination of useless symbols
● The elimination of useless symbols, “variables & terminals
that do not appear in any derivation of a terminal string from
the start symbol”.
● Condition of Useless Symbol :

i)We will entitle any variable useful only when it is deriving
any terminal.

Ii) If a symbol is deriving a terminal but not reachable from
Start state.
● Example:
● Notice that a and b generate themselves “terminals”, S
generates a, and A generates b. B is not generating.
● After eliminating B:
● Notice that only S and a are reachable after eliminating the
non-generating B.
● A is not reachable; so it should be eliminated.
● The result :
The elimination of ε-productions
● The elimination of ε-productions, those of the form A ! ε
for some variable A.
● Example:
The elimination of unit productions
● The elimination of unit productions, those of the form A ! B
for variables A and B.
● We will apply below steps to remove Unit production:
● Write production without Unit production
● Check what we are missing because of Step 1

Example:
1:
S -> Aa/B/c
B -> A/bb
A -> a/bc/B
Sol:
S -> Aa/c/bb/a/bc
A -> a/bc/bb
2:
S -> AC
A -> a
C -> B/d
B -> D
D -> E
E -> b
Sol:
S -> AC
A -> a
C -> d/b
Simply grammars
Example Solution
1:
S->AB A->a B->b B->C E->c/^
S->AB A->a B->b
2:
S->ABC|BaB A->aA|BaC|aaa B-
>bbb|a|D C->CA|AC d->epsilon
S->BaB A->aA|aaa B->bbb|a
3:
S->AaA|CA|BaB A->aaBa|CDA|aa|Dc B-
>bB|aAB|bb|as C->Ca|bC|D
D->bD|epsilon
S->AaA|BaB A->aaBa|aa B->bB|aAB|bb|
as
CNF for CFG
● We have to check following form on a Context free
grammar.

All the productions should be of the form mentioned below:
● A -> BC or A -> a
NON Terminal--> NT. NT
or
NT--> T




Advantage of CNF
● Length of each production is restricted
● Derivation tree or parse tree obtained from CNF is
always binary tree
● Number of steps required to derive string of length |
w| = (2|w| -1)
● It is easy to apply CYK algorithm


Convert given grammar into CNF
Example Solution
S -> bA/aB
A -> bAA/aS/a
B->aBB/bS/b
S->ASB|epsilon
A->aAS|a
B->SbS|A|bb
Greibach Normal Form
A CFG is in Greibach Normal Form if the Productions are in
the following forms −
A → b
A → bD1…Dn
S → ε
● 

EXAMPLES
Sno prroblems
1 S->AA|0 A->SS|1
2 S->AB A->BS|b B-
>SA|a
3 S->CA A->a C->aB|
b
4 S->SS S->0S1|01
Solution 1
PUMPING LEMMA
● Pumping Lemma, here also, is used as a tool to prove that
a language is not CFL.
● f L is a CFL, there exists an integer n, such that for all x ∈ L
with |x| ≥ n, there exists u, v, w, x, y ∈ Σ∗, such that x =
uvwxy, and
I. |vx| ≥ 1
II. |vwx| ≤ n
III. for all i ≥ 0: uvi
wxi
y ∈ L
Problem or application: Find out whether the language L
= {xnynzn | n ≥ 1} is context free or not.
Example
Part-2
Properties
Closure Properties
● Union 
● Concatenation 
● Kleene Closure
● Intersection and
● Complementation
Union
● Union : If L1 and If L2 are two context free languages, their
union L1 ∪ L2 will also be context free. For example,

L1 = { anbncm | m >= 0 and n >= 0 } and L2 = { anbmcm | n
>= 0 and m >= 0 }

L3 = L1 ∪ L2 = { anbncm ∪ anbmcm | n >= 0, m >= 0 } is also
context free.

L1 says number of a’s should be equal to number of b’s and
L2 says number of b’s should be equal to number of c’s.
Their union says either of two conditions to be true. So it is
also context free language.
● Note: So CFL are closed under Union.
Concatenation 
● Concatenation : If L1 and If L2 are two context free languages,
their concatenation L1.L2 will also be context free. For
example,

L1 = { anbn | n >= 0 } and L2 = { cmdm | m >= 0 }

L3 = L1.L2 = { anbncmdm | m >= 0 and n >= 0} is also context
free.

L1 says number of a’s should be equal to number of b’s and L2
says number of c’s should be equal to number of d’s. Their
concatenation says first number of a’s should be equal to
number of b’s, then number of c’s should be equal to number of
d’s. So, we can create a PDA which will first push for a’s, pop
for b’s, push for c’s then pop for d’s. So it can be accepted by
pushdown automata, hence context free.
● Note: So CFL are closed under Concatenation.
Kleene Closure
● Kleene Closure : If L1 is context free, its Kleene
closure L1* will also be context free. For example,

L1 = { anbn | n >= 0 }

L1* = { anbn | n >= 0 }* is also context free.
● Note :So CFL are closed under Kleen Closure.
Intersection 
● Intersection  : If L1 and If L2 are two context free
languages, their intersection L1 ∩ L2 need not be context
free. For example,

L1 = { anbncm | n >= 0 and m >= 0 } and L2 = (ambncn | n >=
0 and m >= 0 }

L3 = L1 ∩ L2 = { anbncn | n >= 0 } need not be context free.

L1 says number of a’s should be equal to number of b’s and
L2 says number of b’s should be equal to number of c’s.
Their intersection says both conditions need to be true, but
push down automata can compare only two. So it cannot be
accepted by pushdown automata, hence not context free.
● Note : So CFL are not closed under Intersection 
Complementation 
● Complementation : Similarly, complementation of
context free language L1 which is ∑* – L1, need not
be context free.
● Note :So CFL are not closed under Complementation
 
Decision Properties
● Emptiness
➢ Remove useless symbols and productions
➢ If S is useless, then L(G) is empty.
● Membership
➢ Unlike FAs, we can’t just run the string through the machine and see where
it goes since PDAs are non-deterministic.
➢ Must consider all possible paths
● Finiteness
➢ Just as with RLs, a language is infinite if there is a string x with length
between n and 2n
➢ With RLs n = number of states in an FA
➢ With CFLs n = 2p+1 where p is the number of variables in the CFG
➢ Systematically generate all strings with lengths between n and 2n
➢ Run through membership algorithm
➢ If one passes, L is infinite, if all fail, L is finite s
Part-3
Turing Machine
Turing Machine
● A Turing Machine is an accepting device which accepts the
languages (recursively enumerable set) generated by type 0
grammars. It was invented in 1936 by Alan Turing.
● Comparison with the previous automaton
Machine Stack Data
Structure
Deterministic?
Finite Automaton N.A Yes
Pushdown
Automaton
Last In First
Out(LIFO)
No
Turing Machine Infinite tape Yes
Definition
● A Turing Machine (TM) is a mathematical model which consists of an infinite
length tape divided into cells on which input is given. It consists of a head
which reads the input tape. A state register stores the state of the Turing
machine. After reading an input symbol, it is replaced with another symbol,
its internal state is changed, and it moves from one cell to the right or left. If
the TM reaches the final state, the input string is accepted, otherwise rejected.
● A TM can be formally described as a 7-tuple (Q, X, ∑, δ, q0, B, F) where −
● Q is a finite set of states
● X is the tape alphabet
● ∑ is the input alphabet
● δ is a transition function; δ : Q × X → Q × X × {Left shift, Right shift}.
● q0 is the initial state
● B / is the blank symbol
● F is the set of final states
Structure
Acceptance
● A Turing machine is somewhat similar to a finite
automaton, but there are important differences
1. A Turing machine can both write on the tape and read
from it.
2. The read-write head can move both to the left and to
the right.
3. The tape is infinite.
4. The special states for rejecting and accepting take
immediate effect.
Example
Turing machine M = (Q, X, ∑, δ, q0, B, F) with
Q = {q0, q1, q2, qf}
X = {a, b}
∑ = {1}
q0 = {q0}
B = blank symbol
F = {qf }
δ is given by − table
● Here the transition 1Rq1 implies that the write symbol is 1, the tape moves
right, and the next state is q1. Similarly, the transition 1Lq2 implies that the
write symbol is 1, the tape moves left, and the next state is q2.
Tape
alphabet
symbol
Present State
‘q0’
Present State
‘q1’
Present State
‘q2’
a 1Rq1 1Lq0 1Lqf
b 1Lq2 1Rq1 1Rqf
Types of TM
● Turing machines with two-dimensional tapes – They have one read-write
head, one finite control and one two-dimensional tape.
● Turing machines with multiple tapes – They have one finite control and
over one tape with a read-write head for each tape.
● Turing machines with multiple heads – They have one finite control, one
tape, and over one read-write head.
● Turing machines with infinite tape – They have one finite control and one
tape extending in both directions infinitely.
● Nondeterministic Turing machines – They have the ability to perform any
action from a given set of actions rather than performing a definite
predetermined action.


Example 1
Example 2
References
● https://www.slideshare.net/lavishka_anuj/turing-machines-12176328?
qid=57247262-25ef-43ac-b037-53c98692cd02&v=&b=&from_search=1

More Related Content

What's hot

Introduction to fa and dfa
Introduction to fa  and dfaIntroduction to fa  and dfa
Introduction to fa and dfadeepinderbedi
 
Theory of Computation - Lectures 4 and 5
Theory of Computation - Lectures 4 and 5Theory of Computation - Lectures 4 and 5
Theory of Computation - Lectures 4 and 5Dr. Maamoun Ahmed
 
Thoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's ClassificationThoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's ClassificationPrafullMisra
 
FINITE STATE MACHINE AND CHOMSKY HIERARCHY
FINITE STATE MACHINE AND CHOMSKY HIERARCHYFINITE STATE MACHINE AND CHOMSKY HIERARCHY
FINITE STATE MACHINE AND CHOMSKY HIERARCHYnishimanglani
 
1.3.2 non deterministic finite automaton
1.3.2 non deterministic finite automaton1.3.2 non deterministic finite automaton
1.3.2 non deterministic finite automatonSampath Kumar S
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)Naman Joshi
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysisDattatray Gandhmal
 
Nondeterministic Finite Automat
Nondeterministic Finite AutomatNondeterministic Finite Automat
Nondeterministic Finite AutomatAdel Al-Ofairi
 
Formal language & automata theory
Formal language & automata theoryFormal language & automata theory
Formal language & automata theoryNYversity
 
Nondeterministic Finite Automata
Nondeterministic Finite AutomataNondeterministic Finite Automata
Nondeterministic Finite AutomataAdel Al-Ofairi
 
Finite Automata in compiler design
Finite Automata in compiler designFinite Automata in compiler design
Finite Automata in compiler designRiazul Islam
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automatadeepinderbedi
 
AUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESAUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESsuthi
 

What's hot (20)

Introduction to fa and dfa
Introduction to fa  and dfaIntroduction to fa  and dfa
Introduction to fa and dfa
 
Theory of Computation - Lectures 4 and 5
Theory of Computation - Lectures 4 and 5Theory of Computation - Lectures 4 and 5
Theory of Computation - Lectures 4 and 5
 
Lecture: Automata
Lecture: AutomataLecture: Automata
Lecture: Automata
 
Thoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's ClassificationThoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's Classification
 
FINITE STATE MACHINE AND CHOMSKY HIERARCHY
FINITE STATE MACHINE AND CHOMSKY HIERARCHYFINITE STATE MACHINE AND CHOMSKY HIERARCHY
FINITE STATE MACHINE AND CHOMSKY HIERARCHY
 
Finite automata
Finite automataFinite automata
Finite automata
 
1.3.2 non deterministic finite automaton
1.3.2 non deterministic finite automaton1.3.2 non deterministic finite automaton
1.3.2 non deterministic finite automaton
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
 
Ch2 finite automaton
Ch2 finite automatonCh2 finite automaton
Ch2 finite automaton
 
Unit v
Unit vUnit v
Unit v
 
Unit ii
Unit iiUnit ii
Unit ii
 
Nondeterministic Finite Automat
Nondeterministic Finite AutomatNondeterministic Finite Automat
Nondeterministic Finite Automat
 
Formal language & automata theory
Formal language & automata theoryFormal language & automata theory
Formal language & automata theory
 
Nondeterministic Finite Automata
Nondeterministic Finite AutomataNondeterministic Finite Automata
Nondeterministic Finite Automata
 
Theory of computation and automata
Theory of computation and automataTheory of computation and automata
Theory of computation and automata
 
Finite Automata in compiler design
Finite Automata in compiler designFinite Automata in compiler design
Finite Automata in compiler design
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
 
Finite automata
Finite automataFinite automata
Finite automata
 
AUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTESAUTOMATA THEORY - SHORT NOTES
AUTOMATA THEORY - SHORT NOTES
 

Similar to Formal Languages and Automata Theory unit 4

Presentation (5).pdf
Presentation (5).pdfPresentation (5).pdf
Presentation (5).pdfGaurav447273
 
Pushdown AutomataChapter 12Recognizing Context-F.docx
Pushdown AutomataChapter 12Recognizing Context-F.docxPushdown AutomataChapter 12Recognizing Context-F.docx
Pushdown AutomataChapter 12Recognizing Context-F.docxwoodruffeloisa
 
Closure properties of context free grammar
Closure properties of context free grammarClosure properties of context free grammar
Closure properties of context free grammarAfshanKhan51
 
Automata
AutomataAutomata
AutomataGaditek
 
Automata
AutomataAutomata
AutomataGaditek
 
01. Theory of Computing
01. Theory of Computing01. Theory of Computing
01. Theory of Computingrabiul souvon
 
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdfFariyaTasneem1
 
Automata theory - CFG and normal forms
Automata theory - CFG and normal formsAutomata theory - CFG and normal forms
Automata theory - CFG and normal formsAkila Krishnamoorthy
 
03-FiniteAutomata.pptx
03-FiniteAutomata.pptx03-FiniteAutomata.pptx
03-FiniteAutomata.pptxssuser47f7f2
 
1LECTURE 9TuringMachines.ppt
1LECTURE 9TuringMachines.ppt1LECTURE 9TuringMachines.ppt
1LECTURE 9TuringMachines.pptMarvin886766
 
Lecture1.pptxjendfkdmdmmdmmedhf bf fbbd ed
Lecture1.pptxjendfkdmdmmdmmedhf bf fbbd edLecture1.pptxjendfkdmdmmdmmedhf bf fbbd ed
Lecture1.pptxjendfkdmdmmdmmedhf bf fbbd edzoobiarana76
 
souraj Toc.pptx
souraj Toc.pptxsouraj Toc.pptx
souraj Toc.pptxLifo4
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMRajendran
 
Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Editor IJARCET
 
Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Editor IJARCET
 

Similar to Formal Languages and Automata Theory unit 4 (20)

Presentation (5).pdf
Presentation (5).pdfPresentation (5).pdf
Presentation (5).pdf
 
Pushdown AutomataChapter 12Recognizing Context-F.docx
Pushdown AutomataChapter 12Recognizing Context-F.docxPushdown AutomataChapter 12Recognizing Context-F.docx
Pushdown AutomataChapter 12Recognizing Context-F.docx
 
Closure properties of context free grammar
Closure properties of context free grammarClosure properties of context free grammar
Closure properties of context free grammar
 
Automata Theory - Turing machine
Automata Theory - Turing machineAutomata Theory - Turing machine
Automata Theory - Turing machine
 
TOC Introduction
TOC Introduction TOC Introduction
TOC Introduction
 
Theory of computation and automata
Theory of computation and automataTheory of computation and automata
Theory of computation and automata
 
Automata
AutomataAutomata
Automata
 
Automata
AutomataAutomata
Automata
 
CS 5th.pptx
CS 5th.pptxCS 5th.pptx
CS 5th.pptx
 
01. Theory of Computing
01. Theory of Computing01. Theory of Computing
01. Theory of Computing
 
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
 
Automata theory - CFG and normal forms
Automata theory - CFG and normal formsAutomata theory - CFG and normal forms
Automata theory - CFG and normal forms
 
03-FiniteAutomata.pptx
03-FiniteAutomata.pptx03-FiniteAutomata.pptx
03-FiniteAutomata.pptx
 
Turing machines
Turing machinesTuring machines
Turing machines
 
1LECTURE 9TuringMachines.ppt
1LECTURE 9TuringMachines.ppt1LECTURE 9TuringMachines.ppt
1LECTURE 9TuringMachines.ppt
 
Lecture1.pptxjendfkdmdmmdmmedhf bf fbbd ed
Lecture1.pptxjendfkdmdmmdmmedhf bf fbbd edLecture1.pptxjendfkdmdmmdmmedhf bf fbbd ed
Lecture1.pptxjendfkdmdmmdmmedhf bf fbbd ed
 
souraj Toc.pptx
souraj Toc.pptxsouraj Toc.pptx
souraj Toc.pptx
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEM
 
Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207
 
Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207
 

More from Srimatre K

ML_ Unit 2_Part_B
ML_ Unit 2_Part_BML_ Unit 2_Part_B
ML_ Unit 2_Part_BSrimatre K
 
ML_Unit_2_Part_A
ML_Unit_2_Part_AML_Unit_2_Part_A
ML_Unit_2_Part_ASrimatre K
 
ML_Unit_1_Part_C
ML_Unit_1_Part_CML_Unit_1_Part_C
ML_Unit_1_Part_CSrimatre K
 
ML_Unit_1_Part_B
ML_Unit_1_Part_BML_Unit_1_Part_B
ML_Unit_1_Part_BSrimatre K
 
Internet of things unit-1
Internet of things unit-1Internet of things unit-1
Internet of things unit-1Srimatre K
 
ML_ Unit_1_PART_A
ML_ Unit_1_PART_AML_ Unit_1_PART_A
ML_ Unit_1_PART_ASrimatre K
 
Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3Srimatre K
 
Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2Srimatre K
 

More from Srimatre K (8)

ML_ Unit 2_Part_B
ML_ Unit 2_Part_BML_ Unit 2_Part_B
ML_ Unit 2_Part_B
 
ML_Unit_2_Part_A
ML_Unit_2_Part_AML_Unit_2_Part_A
ML_Unit_2_Part_A
 
ML_Unit_1_Part_C
ML_Unit_1_Part_CML_Unit_1_Part_C
ML_Unit_1_Part_C
 
ML_Unit_1_Part_B
ML_Unit_1_Part_BML_Unit_1_Part_B
ML_Unit_1_Part_B
 
Internet of things unit-1
Internet of things unit-1Internet of things unit-1
Internet of things unit-1
 
ML_ Unit_1_PART_A
ML_ Unit_1_PART_AML_ Unit_1_PART_A
ML_ Unit_1_PART_A
 
Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3
 
Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2
 

Recently uploaded

Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 

Recently uploaded (20)

Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 

Formal Languages and Automata Theory unit 4

  • 1. UNIT - IV Prepared By: K Lakshmi Sravani Assistant Professor
  • 2. Syllabus ● Normal Forms for Context- Free Grammars: Eliminating useless symbols, Eliminating €-Productions. Chomsky Normal form Griebech Normal form. ● Pumping Lemma for Context-Free Languages: Statement of pumping lemma, Applications ● Closure Properties of Context-Free Languages: Closure properties of CFL’s, Decision Properties of CFL's ● Turing Machines: Introduction to Turing Machine, Formal Description, Instantaneous description, The language of a Turing machine
  • 3. Normal Forms for Context- Free Grammars: ● The goal is to show that every CFL (without ε) is generated by a CFG in which all productions are of the form A ! BC or A ! a, where A, B, C are variables, and a is a terminal. ● A number of simplifications is inevitable: i. The elimination of useless symbols. ii. The elimination of ε or null productions. iii. The elimination of unit productions
  • 4.
  • 5. The elimination of useless symbols ● The elimination of useless symbols, “variables & terminals that do not appear in any derivation of a terminal string from the start symbol”. ● Condition of Useless Symbol :
 i)We will entitle any variable useful only when it is deriving any terminal.
 Ii) If a symbol is deriving a terminal but not reachable from Start state. ● Example:
  • 6. ● Notice that a and b generate themselves “terminals”, S generates a, and A generates b. B is not generating. ● After eliminating B: ● Notice that only S and a are reachable after eliminating the non-generating B. ● A is not reachable; so it should be eliminated. ● The result :
  • 7. The elimination of ε-productions ● The elimination of ε-productions, those of the form A ! ε for some variable A. ● Example:
  • 8.
  • 9. The elimination of unit productions ● The elimination of unit productions, those of the form A ! B for variables A and B. ● We will apply below steps to remove Unit production: ● Write production without Unit production ● Check what we are missing because of Step 1

  • 10. Example: 1: S -> Aa/B/c B -> A/bb A -> a/bc/B Sol: S -> Aa/c/bb/a/bc A -> a/bc/bb 2: S -> AC A -> a C -> B/d B -> D D -> E E -> b Sol: S -> AC A -> a C -> d/b
  • 11. Simply grammars Example Solution 1: S->AB A->a B->b B->C E->c/^ S->AB A->a B->b 2: S->ABC|BaB A->aA|BaC|aaa B- >bbb|a|D C->CA|AC d->epsilon S->BaB A->aA|aaa B->bbb|a 3: S->AaA|CA|BaB A->aaBa|CDA|aa|Dc B- >bB|aAB|bb|as C->Ca|bC|D D->bD|epsilon S->AaA|BaB A->aaBa|aa B->bB|aAB|bb| as
  • 12. CNF for CFG ● We have to check following form on a Context free grammar.
 All the productions should be of the form mentioned below: ● A -> BC or A -> a NON Terminal--> NT. NT or NT--> T
  • 13. 
 
 Advantage of CNF ● Length of each production is restricted ● Derivation tree or parse tree obtained from CNF is always binary tree ● Number of steps required to derive string of length | w| = (2|w| -1) ● It is easy to apply CYK algorithm 

  • 14. Convert given grammar into CNF Example Solution S -> bA/aB A -> bAA/aS/a B->aBB/bS/b S->ASB|epsilon A->aAS|a B->SbS|A|bb
  • 15. Greibach Normal Form A CFG is in Greibach Normal Form if the Productions are in the following forms − A → b A → bD1…Dn S → ε
  • 17. EXAMPLES Sno prroblems 1 S->AA|0 A->SS|1 2 S->AB A->BS|b B- >SA|a 3 S->CA A->a C->aB| b 4 S->SS S->0S1|01
  • 19.
  • 20.
  • 21. PUMPING LEMMA ● Pumping Lemma, here also, is used as a tool to prove that a language is not CFL. ● f L is a CFL, there exists an integer n, such that for all x ∈ L with |x| ≥ n, there exists u, v, w, x, y ∈ Σ∗, such that x = uvwxy, and I. |vx| ≥ 1 II. |vwx| ≤ n III. for all i ≥ 0: uvi wxi y ∈ L Problem or application: Find out whether the language L = {xnynzn | n ≥ 1} is context free or not.
  • 24. Closure Properties ● Union  ● Concatenation  ● Kleene Closure ● Intersection and ● Complementation
  • 25. Union ● Union : If L1 and If L2 are two context free languages, their union L1 ∪ L2 will also be context free. For example,
 L1 = { anbncm | m >= 0 and n >= 0 } and L2 = { anbmcm | n >= 0 and m >= 0 }
 L3 = L1 ∪ L2 = { anbncm ∪ anbmcm | n >= 0, m >= 0 } is also context free.
 L1 says number of a’s should be equal to number of b’s and L2 says number of b’s should be equal to number of c’s. Their union says either of two conditions to be true. So it is also context free language. ● Note: So CFL are closed under Union.
  • 26. Concatenation  ● Concatenation : If L1 and If L2 are two context free languages, their concatenation L1.L2 will also be context free. For example,
 L1 = { anbn | n >= 0 } and L2 = { cmdm | m >= 0 }
 L3 = L1.L2 = { anbncmdm | m >= 0 and n >= 0} is also context free.
 L1 says number of a’s should be equal to number of b’s and L2 says number of c’s should be equal to number of d’s. Their concatenation says first number of a’s should be equal to number of b’s, then number of c’s should be equal to number of d’s. So, we can create a PDA which will first push for a’s, pop for b’s, push for c’s then pop for d’s. So it can be accepted by pushdown automata, hence context free. ● Note: So CFL are closed under Concatenation.
  • 27. Kleene Closure ● Kleene Closure : If L1 is context free, its Kleene closure L1* will also be context free. For example,
 L1 = { anbn | n >= 0 }
 L1* = { anbn | n >= 0 }* is also context free. ● Note :So CFL are closed under Kleen Closure.
  • 28. Intersection  ● Intersection  : If L1 and If L2 are two context free languages, their intersection L1 ∩ L2 need not be context free. For example,
 L1 = { anbncm | n >= 0 and m >= 0 } and L2 = (ambncn | n >= 0 and m >= 0 }
 L3 = L1 ∩ L2 = { anbncn | n >= 0 } need not be context free.
 L1 says number of a’s should be equal to number of b’s and L2 says number of b’s should be equal to number of c’s. Their intersection says both conditions need to be true, but push down automata can compare only two. So it cannot be accepted by pushdown automata, hence not context free. ● Note : So CFL are not closed under Intersection 
  • 29. Complementation  ● Complementation : Similarly, complementation of context free language L1 which is ∑* – L1, need not be context free. ● Note :So CFL are not closed under Complementation  
  • 30. Decision Properties ● Emptiness ➢ Remove useless symbols and productions ➢ If S is useless, then L(G) is empty. ● Membership ➢ Unlike FAs, we can’t just run the string through the machine and see where it goes since PDAs are non-deterministic. ➢ Must consider all possible paths ● Finiteness ➢ Just as with RLs, a language is infinite if there is a string x with length between n and 2n ➢ With RLs n = number of states in an FA ➢ With CFLs n = 2p+1 where p is the number of variables in the CFG ➢ Systematically generate all strings with lengths between n and 2n ➢ Run through membership algorithm ➢ If one passes, L is infinite, if all fail, L is finite s
  • 32. Turing Machine ● A Turing Machine is an accepting device which accepts the languages (recursively enumerable set) generated by type 0 grammars. It was invented in 1936 by Alan Turing. ● Comparison with the previous automaton Machine Stack Data Structure Deterministic? Finite Automaton N.A Yes Pushdown Automaton Last In First Out(LIFO) No Turing Machine Infinite tape Yes
  • 33. Definition ● A Turing Machine (TM) is a mathematical model which consists of an infinite length tape divided into cells on which input is given. It consists of a head which reads the input tape. A state register stores the state of the Turing machine. After reading an input symbol, it is replaced with another symbol, its internal state is changed, and it moves from one cell to the right or left. If the TM reaches the final state, the input string is accepted, otherwise rejected. ● A TM can be formally described as a 7-tuple (Q, X, ∑, δ, q0, B, F) where − ● Q is a finite set of states ● X is the tape alphabet ● ∑ is the input alphabet ● δ is a transition function; δ : Q × X → Q × X × {Left shift, Right shift}. ● q0 is the initial state ● B / is the blank symbol ● F is the set of final states
  • 35.
  • 36.
  • 37.
  • 38.
  • 40. ● A Turing machine is somewhat similar to a finite automaton, but there are important differences 1. A Turing machine can both write on the tape and read from it. 2. The read-write head can move both to the left and to the right. 3. The tape is infinite. 4. The special states for rejecting and accepting take immediate effect.
  • 41. Example Turing machine M = (Q, X, ∑, δ, q0, B, F) with Q = {q0, q1, q2, qf} X = {a, b} ∑ = {1} q0 = {q0} B = blank symbol F = {qf } δ is given by − table ● Here the transition 1Rq1 implies that the write symbol is 1, the tape moves right, and the next state is q1. Similarly, the transition 1Lq2 implies that the write symbol is 1, the tape moves left, and the next state is q2. Tape alphabet symbol Present State ‘q0’ Present State ‘q1’ Present State ‘q2’ a 1Rq1 1Lq0 1Lqf b 1Lq2 1Rq1 1Rqf
  • 42. Types of TM ● Turing machines with two-dimensional tapes – They have one read-write head, one finite control and one two-dimensional tape. ● Turing machines with multiple tapes – They have one finite control and over one tape with a read-write head for each tape. ● Turing machines with multiple heads – They have one finite control, one tape, and over one read-write head. ● Turing machines with infinite tape – They have one finite control and one tape extending in both directions infinitely. ● Nondeterministic Turing machines – They have the ability to perform any action from a given set of actions rather than performing a definite predetermined action. 

  • 44.