SlideShare a Scribd company logo
1 of 27
Theory of Computation
CSE 2233
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Chomsky Hierarchy
2
▪ Chomsky hierarchy represents the class of languages that
are accepted by the different machine.
▪ The category of language in Chomsky’s Hierarchy is given
below:
1) Type 0 – Unrestricted Grammar
2) Type 1 – Context Sensitive Grammar
3) Type 2 – Context Free Grammar
4) Type 3 – Regular Grammar
▪ Two major models of automata:
• Generators
– with output and without input
– tell us how to generate all strings in a Language L
• Acceptors
– with input and without output
– tell us if a specific string is in Language L
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Schematic of a Finite Automaton
3
Finite control
a ba a c input
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Finite Automaton
▸ The control represents the states and transition function.
▸ The tape contains the input string.
▸ The arrow represents the input head, pointing at the next input symbol to be read.
FA can remember a finite amount of information
Schematic of a Pushdown Automaton
4
z
Finite control
b cc a a
x
y
stack
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Based on the characteristics of CFG containing recursive rules,
how can we apply a finite state machine to CFG?
▸ The idea to reach the goal is to add a memory device to a
FSM.
Push Down Automaton
▸ Input string
▹ Same as FSM
▹ Cannot back up
▸ Stack operations on each transition
▹ READ + POP or, IGNORE
▹ PUSH or, IGNORE
PDA can remember an infinite amount of information
PDA >> Informal Description & Non-determinism
5
▸ A Pushdown Automata (PDA) can write an unbounded number of Stack Symbols on the stack and read these symbols
later.
▸ Writing a symbol onto the stack is called pushing and it pushes all symbols on the stack one stack cell down.
▸ Removing a symbol off the stack is called popping and every symbol on the stack moves one stack cell up.
Note: A PDA can access only the stack’s topmost symbol (LIFO).
▸ A Nondeterministic PDA allows nondeterministic transitions.
▸ Nondeterministic PDA-s are strictly stronger than deterministic PDA-s.
- In this respect, the situation is not similar to the situation of DFA-s and NFA-s.
- Nondeterministic PDA- are equivalent in power to CFG-s.
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Formal Definition
6
A pushdown automaton is a 6-tuple (Q, 𝛴, 𝛤, 𝛿, q0 , F) where:
▸ Q is a finite set called the states
▸ 𝛴 is the input alphabet
▸ 𝛤 is the stack alphabet
▸ 𝛿: Q X 𝛴 𝜀 X 𝛤 𝜀 → P(Q, 𝛤 𝜀) is the transition function
▸ q0 𝜖 Q is the start state and
▸ F ⊆ Q is the set of accepting states.
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practices 1
7
Create a PDA that recognizes the context free language: L = { 0n 1n | n >=0 }
Solution:
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practices 1 - Formal Definition
8
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practices 2 – How PDA works!!!
9
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Example: PDA that recognizes all the balanced parenthesis strings only.
PDA >> Practices 2 – How PDA works!!!
10
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Instantaneous Description for the string “( ( ) ) ( ) )”
PDA >> Practice 3
11
Create a PDA that recognizes the following context free language:
L = { w ϵ {0, 1}* | w contains at least three 1’s }
Solution:
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practice 4
12
Create a PDA that recognizes the following context free language:
L = { w ϵ {0, 1}* | w = wR and the length of w is odd}
Solution:
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practice 5
13
Create a PDA that recognizes the following context free language:
L = { w ϵ {0, 1}* | w = wR }
Solution:
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practices 6
14
Create a PDA that recognizes the following context free language:
L = { ai bj ck | i, j, k >=0 and i=j }
Solution:
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practices 7
15
Create a PDA that recognizes the following context free language:
L = { ai bj ck | i, j, k >=0 and j=k }
Solution:
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practice 8
16
Create a PDA that recognizes the following context free language:
L = { ai bj ck | i, j, k >=0 and i=j or j=k }
Solution:
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practice 9
17
Create a PDA that recognizes the following context free language:
L = { ai bj ck | i, j, k >=0 and i+j = k }
Solution:
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practice 10
18
Create a PDA that recognizes the following context free language:
L = { a2n b3n | n>=0 }
Solution:
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practice set 1
19
Design a Push-Down Automaton for each one of the following languages:
1. L = { an bn | n >= 0 }
2. L = {an b2n | n >= 0 }
3. L = { a2n bn | n >= 0 }
4. L = { an+1 bn | n > 0 }
5. L = { a2n+1 bn | n > 0 }
6. L = { an+m bm+t at bn | n,t >0 and m>=0 }
7. L = { an+m bm+t at bn | n, t, m > 0 }
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practices 11
20
Create a PDA that recognizes the following context free language:
L = { wwR | w ϵ { 0, 1 }* }
Solution:
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practices 12
21
Create a PDA that recognizes the following context free language:
L = { a* w ck | w ϵ {a, b}* and k = |w|a (k=number of a’s in w) }
Solution:
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practices 13
22
Consider the following PDA:
▸ Now show that the PDA accepts the word ‘aaadbabacc’
▸ Describe the language
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practices 14
23
▸ Design a Push Down Automata(PDA) for the given language –
L = { ai bj ck dm | i + j = k and I, j, k, m > 0 }
a) Now write the components of your designed PDA.
b) Write Instantaneous Description(ID) for the string ‘aaabccccd’ for this PDA.
▸ Consider the following language –
L = { am bi cm dk | m, I, k >=1 }
a) Design a pushdown automaton(PDA)
b) Write the seven components to represent the above PDA.
c) Show instantaneous descriptions for the above PDA when the input is ‘aabccdd’ .
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practices 15
24
▸ Consider the following language –
L = { 12m 05m 2n | m, n >= 1 }
a) Design a pushdown automaton (PDA) for the given language.
b) Write all seven components to represent the above PDA.
c) Show the instantaneous descriptions for the above PDA when the input is ‘11000002’
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> Practice Set 2
25
▸ L = { 0n 1m 2m 3n | n>=1, m>=1 }
▸ L = { 0n 1m 2m 3n | n, m >=0 }
▸ L = { 0n 1m 2n+m | m,n >=0 }
▸ L = { 0m 1n+m 2n | m,n >=0 }
▸ L = { 0n+m 1m 2n | m,n >=0 }
▸ L = { 0n 1m | n>=1, m>=1, m>n+2 }
▸ L = { a2m c4n dn bm | m,n >=0 }
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
PDA >> CFG to PDA
26
▸ Place the marker symbol $ and the start variable on
the stack.
▸ Repeat the following steps forever.
- If the top of stack is a variable symbol A, non-
deterministically select one of the rules for A
and substitute A by the string on the right-hand
side of the rule.
- If the top of stack is a terminal symbol a, read
the next symbol from the input and compare it
to a. If they match, repeat. If they do not match,
reject on this branch of the nondeterminism.
- If the top of stack is the symbol $, enter the
accept state. Doing so accepts the input if it
has all been read.
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
For the CFG,
S → aTb | b
T → Ta | 𝜖
27
References:
Chapter 2(section 2.2), Introduction to the Theory of Computation, 3rd Edition by Michael Sipser
THANKS!
Any questions?
You can find me at imam@cse.uiu.ac.bd

More Related Content

What's hot

Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)Naman Joshi
 
TOC 1 | Introduction to Theory of Computation
TOC 1 | Introduction to Theory of ComputationTOC 1 | Introduction to Theory of Computation
TOC 1 | Introduction to Theory of ComputationMohammad Imam Hossain
 
Pumping lemma Theory Of Automata
Pumping lemma Theory Of AutomataPumping lemma Theory Of Automata
Pumping lemma Theory Of Automatahafizhamza0322
 
Automata theory
Automata theoryAutomata theory
Automata theorycolleges
 
Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Abhimanyu Mishra
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languagesparmeet834
 
Context free grammars
Context free grammarsContext free grammars
Context free grammarsRonak Thakkar
 
Theory of Computation Grammar Concepts and Problems
Theory of Computation Grammar Concepts and ProblemsTheory of Computation Grammar Concepts and Problems
Theory of Computation Grammar Concepts and ProblemsRushabh2428
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihmSajid Marwat
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1Amrinder Arora
 
Types of grammer - TOC
Types of grammer - TOCTypes of grammer - TOC
Types of grammer - TOCAbhayDhupar
 

What's hot (20)

Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
TOC 3 | Different Operations on DFA
TOC 3 | Different Operations on DFATOC 3 | Different Operations on DFA
TOC 3 | Different Operations on DFA
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
TOC 1 | Introduction to Theory of Computation
TOC 1 | Introduction to Theory of ComputationTOC 1 | Introduction to Theory of Computation
TOC 1 | Introduction to Theory of Computation
 
FInite Automata
FInite AutomataFInite Automata
FInite Automata
 
Pumping lemma Theory Of Automata
Pumping lemma Theory Of AutomataPumping lemma Theory Of Automata
Pumping lemma Theory Of Automata
 
Prim's algorithm
Prim's algorithmPrim's algorithm
Prim's algorithm
 
Automata theory
Automata theoryAutomata theory
Automata theory
 
Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1
 
DBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship ModelDBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship Model
 
UNIT III.docx
UNIT III.docxUNIT III.docx
UNIT III.docx
 
CFG to CNF
CFG to CNFCFG to CNF
CFG to CNF
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
Theory of Computation Grammar Concepts and Problems
Theory of Computation Grammar Concepts and ProblemsTheory of Computation Grammar Concepts and Problems
Theory of Computation Grammar Concepts and Problems
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihm
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 
Types of grammer - TOC
Types of grammer - TOCTypes of grammer - TOC
Types of grammer - TOC
 
Push down automata
Push down automataPush down automata
Push down automata
 

Similar to TOC 9 | Pushdown Automata

Programming for problem solving ppts unit 1
Programming for problem solving ppts unit 1Programming for problem solving ppts unit 1
Programming for problem solving ppts unit 1lakshmi lingutla
 
program-control-instruction.pdf
program-control-instruction.pdfprogram-control-instruction.pdf
program-control-instruction.pdfBapanKar2
 
nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言鍾誠 陳鍾誠
 
Algorithms and flowcharts ppt (seminar presentation)..
 Algorithms and flowcharts  ppt (seminar presentation).. Algorithms and flowcharts  ppt (seminar presentation)..
Algorithms and flowcharts ppt (seminar presentation)..Nagendra N
 
Lecture#2 Computer languages computer system and Programming EC-105
Lecture#2 Computer languages computer system and Programming EC-105Lecture#2 Computer languages computer system and Programming EC-105
Lecture#2 Computer languages computer system and Programming EC-105NUST Stuff
 
Solved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ ExamsSolved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ ExamsMuhammadTalha436
 
Tricky math puzzle project report
Tricky math puzzle project reportTricky math puzzle project report
Tricky math puzzle project reportSanzid Kawsar
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptReshuReshma8
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2lemonmichelangelo
 
Dynamic Programming - Part 1
Dynamic Programming - Part 1Dynamic Programming - Part 1
Dynamic Programming - Part 1Amrinder Arora
 
2 programming-using-java how to built application
2 programming-using-java how to built application2 programming-using-java how to built application
2 programming-using-java how to built applicationMahmoud Alfarra
 

Similar to TOC 9 | Pushdown Automata (20)

Machine language
Machine languageMachine language
Machine language
 
Lecture 06 assembler
Lecture 06 assemblerLecture 06 assembler
Lecture 06 assembler
 
The Knowledge of QBasic
The Knowledge of QBasicThe Knowledge of QBasic
The Knowledge of QBasic
 
Programming for problem solving ppts unit 1
Programming for problem solving ppts unit 1Programming for problem solving ppts unit 1
Programming for problem solving ppts unit 1
 
program-control-instruction.pdf
program-control-instruction.pdfprogram-control-instruction.pdf
program-control-instruction.pdf
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Penyelesaian masalah
Penyelesaian masalahPenyelesaian masalah
Penyelesaian masalah
 
Algorithms and flowcharts ppt (seminar presentation)..
 Algorithms and flowcharts  ppt (seminar presentation).. Algorithms and flowcharts  ppt (seminar presentation)..
Algorithms and flowcharts ppt (seminar presentation)..
 
C programming
C programmingC programming
C programming
 
Lecture#2 Computer languages computer system and Programming EC-105
Lecture#2 Computer languages computer system and Programming EC-105Lecture#2 Computer languages computer system and Programming EC-105
Lecture#2 Computer languages computer system and Programming EC-105
 
Solved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ ExamsSolved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ Exams
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Tricky math puzzle project report
Tricky math puzzle project reportTricky math puzzle project report
Tricky math puzzle project report
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2
 
Dynamic Programming - Part 1
Dynamic Programming - Part 1Dynamic Programming - Part 1
Dynamic Programming - Part 1
 
2 programming-using-java how to built application
2 programming-using-java how to built application2 programming-using-java how to built application
2 programming-using-java how to built application
 

More from Mohammad Imam Hossain

DS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path SearchDS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path SearchMohammad Imam Hossain
 
DS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL IntroductionDS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL IntroductionMohammad Imam Hossain
 
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaDBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaMohammad Imam Hossain
 
DBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR SchemaDBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR SchemaMohammad Imam Hossain
 
DBMS 6 | MySQL Practice List - Rank Related Queries
DBMS 6 | MySQL Practice List - Rank Related QueriesDBMS 6 | MySQL Practice List - Rank Related Queries
DBMS 6 | MySQL Practice List - Rank Related QueriesMohammad Imam Hossain
 

More from Mohammad Imam Hossain (20)

DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6
 
DS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic ProgrammingDS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic Programming
 
DS & Algo 5 - Disjoint Set and MST
DS & Algo 5 - Disjoint Set and MSTDS & Algo 5 - Disjoint Set and MST
DS & Algo 5 - Disjoint Set and MST
 
DS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path SearchDS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path Search
 
DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3
 
DS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and ConquerDS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and Conquer
 
DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2
 
DS & Algo 2 - Recursion
DS & Algo 2 - RecursionDS & Algo 2 - Recursion
DS & Algo 2 - Recursion
 
DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1
 
DS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL IntroductionDS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL Introduction
 
DBMS 1 | Introduction to DBMS
DBMS 1 | Introduction to DBMSDBMS 1 | Introduction to DBMS
DBMS 1 | Introduction to DBMS
 
DBMS 10 | Database Transactions
DBMS 10 | Database TransactionsDBMS 10 | Database Transactions
DBMS 10 | Database Transactions
 
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaDBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational Schema
 
DBMS 7 | Relational Query Language
DBMS 7 | Relational Query LanguageDBMS 7 | Relational Query Language
DBMS 7 | Relational Query Language
 
DBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML CommandsDBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML Commands
 
DBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR SchemaDBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR Schema
 
DBMS 6 | MySQL Practice List - Rank Related Queries
DBMS 6 | MySQL Practice List - Rank Related QueriesDBMS 6 | MySQL Practice List - Rank Related Queries
DBMS 6 | MySQL Practice List - Rank Related Queries
 
DBMS 9 | Extendible Hashing
DBMS 9 | Extendible HashingDBMS 9 | Extendible Hashing
DBMS 9 | Extendible Hashing
 
Web 6 | JavaScript DOM
Web 6 | JavaScript DOMWeb 6 | JavaScript DOM
Web 6 | JavaScript DOM
 
Web 5 | JavaScript Events
Web 5 | JavaScript EventsWeb 5 | JavaScript Events
Web 5 | JavaScript Events
 

Recently uploaded

Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
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
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
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
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 

Recently uploaded (20)

Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
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
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
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
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 

TOC 9 | Pushdown Automata

  • 1. Theory of Computation CSE 2233 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 2. Chomsky Hierarchy 2 ▪ Chomsky hierarchy represents the class of languages that are accepted by the different machine. ▪ The category of language in Chomsky’s Hierarchy is given below: 1) Type 0 – Unrestricted Grammar 2) Type 1 – Context Sensitive Grammar 3) Type 2 – Context Free Grammar 4) Type 3 – Regular Grammar ▪ Two major models of automata: • Generators – with output and without input – tell us how to generate all strings in a Language L • Acceptors – with input and without output – tell us if a specific string is in Language L Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 3. Schematic of a Finite Automaton 3 Finite control a ba a c input Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU Finite Automaton ▸ The control represents the states and transition function. ▸ The tape contains the input string. ▸ The arrow represents the input head, pointing at the next input symbol to be read. FA can remember a finite amount of information
  • 4. Schematic of a Pushdown Automaton 4 z Finite control b cc a a x y stack Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU Based on the characteristics of CFG containing recursive rules, how can we apply a finite state machine to CFG? ▸ The idea to reach the goal is to add a memory device to a FSM. Push Down Automaton ▸ Input string ▹ Same as FSM ▹ Cannot back up ▸ Stack operations on each transition ▹ READ + POP or, IGNORE ▹ PUSH or, IGNORE PDA can remember an infinite amount of information
  • 5. PDA >> Informal Description & Non-determinism 5 ▸ A Pushdown Automata (PDA) can write an unbounded number of Stack Symbols on the stack and read these symbols later. ▸ Writing a symbol onto the stack is called pushing and it pushes all symbols on the stack one stack cell down. ▸ Removing a symbol off the stack is called popping and every symbol on the stack moves one stack cell up. Note: A PDA can access only the stack’s topmost symbol (LIFO). ▸ A Nondeterministic PDA allows nondeterministic transitions. ▸ Nondeterministic PDA-s are strictly stronger than deterministic PDA-s. - In this respect, the situation is not similar to the situation of DFA-s and NFA-s. - Nondeterministic PDA- are equivalent in power to CFG-s. Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 6. PDA >> Formal Definition 6 A pushdown automaton is a 6-tuple (Q, 𝛴, 𝛤, 𝛿, q0 , F) where: ▸ Q is a finite set called the states ▸ 𝛴 is the input alphabet ▸ 𝛤 is the stack alphabet ▸ 𝛿: Q X 𝛴 𝜀 X 𝛤 𝜀 → P(Q, 𝛤 𝜀) is the transition function ▸ q0 𝜖 Q is the start state and ▸ F ⊆ Q is the set of accepting states. Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 7. PDA >> Practices 1 7 Create a PDA that recognizes the context free language: L = { 0n 1n | n >=0 } Solution: Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 8. PDA >> Practices 1 - Formal Definition 8 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 9. PDA >> Practices 2 – How PDA works!!! 9 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU Example: PDA that recognizes all the balanced parenthesis strings only.
  • 10. PDA >> Practices 2 – How PDA works!!! 10 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU Instantaneous Description for the string “( ( ) ) ( ) )”
  • 11. PDA >> Practice 3 11 Create a PDA that recognizes the following context free language: L = { w ϵ {0, 1}* | w contains at least three 1’s } Solution: Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 12. PDA >> Practice 4 12 Create a PDA that recognizes the following context free language: L = { w ϵ {0, 1}* | w = wR and the length of w is odd} Solution: Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 13. PDA >> Practice 5 13 Create a PDA that recognizes the following context free language: L = { w ϵ {0, 1}* | w = wR } Solution: Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 14. PDA >> Practices 6 14 Create a PDA that recognizes the following context free language: L = { ai bj ck | i, j, k >=0 and i=j } Solution: Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 15. PDA >> Practices 7 15 Create a PDA that recognizes the following context free language: L = { ai bj ck | i, j, k >=0 and j=k } Solution: Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 16. PDA >> Practice 8 16 Create a PDA that recognizes the following context free language: L = { ai bj ck | i, j, k >=0 and i=j or j=k } Solution: Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 17. PDA >> Practice 9 17 Create a PDA that recognizes the following context free language: L = { ai bj ck | i, j, k >=0 and i+j = k } Solution: Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 18. PDA >> Practice 10 18 Create a PDA that recognizes the following context free language: L = { a2n b3n | n>=0 } Solution: Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 19. PDA >> Practice set 1 19 Design a Push-Down Automaton for each one of the following languages: 1. L = { an bn | n >= 0 } 2. L = {an b2n | n >= 0 } 3. L = { a2n bn | n >= 0 } 4. L = { an+1 bn | n > 0 } 5. L = { a2n+1 bn | n > 0 } 6. L = { an+m bm+t at bn | n,t >0 and m>=0 } 7. L = { an+m bm+t at bn | n, t, m > 0 } Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 20. PDA >> Practices 11 20 Create a PDA that recognizes the following context free language: L = { wwR | w ϵ { 0, 1 }* } Solution: Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 21. PDA >> Practices 12 21 Create a PDA that recognizes the following context free language: L = { a* w ck | w ϵ {a, b}* and k = |w|a (k=number of a’s in w) } Solution: Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 22. PDA >> Practices 13 22 Consider the following PDA: ▸ Now show that the PDA accepts the word ‘aaadbabacc’ ▸ Describe the language Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 23. PDA >> Practices 14 23 ▸ Design a Push Down Automata(PDA) for the given language – L = { ai bj ck dm | i + j = k and I, j, k, m > 0 } a) Now write the components of your designed PDA. b) Write Instantaneous Description(ID) for the string ‘aaabccccd’ for this PDA. ▸ Consider the following language – L = { am bi cm dk | m, I, k >=1 } a) Design a pushdown automaton(PDA) b) Write the seven components to represent the above PDA. c) Show instantaneous descriptions for the above PDA when the input is ‘aabccdd’ . Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 24. PDA >> Practices 15 24 ▸ Consider the following language – L = { 12m 05m 2n | m, n >= 1 } a) Design a pushdown automaton (PDA) for the given language. b) Write all seven components to represent the above PDA. c) Show the instantaneous descriptions for the above PDA when the input is ‘11000002’ Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 25. PDA >> Practice Set 2 25 ▸ L = { 0n 1m 2m 3n | n>=1, m>=1 } ▸ L = { 0n 1m 2m 3n | n, m >=0 } ▸ L = { 0n 1m 2n+m | m,n >=0 } ▸ L = { 0m 1n+m 2n | m,n >=0 } ▸ L = { 0n+m 1m 2n | m,n >=0 } ▸ L = { 0n 1m | n>=1, m>=1, m>n+2 } ▸ L = { a2m c4n dn bm | m,n >=0 } Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 26. PDA >> CFG to PDA 26 ▸ Place the marker symbol $ and the start variable on the stack. ▸ Repeat the following steps forever. - If the top of stack is a variable symbol A, non- deterministically select one of the rules for A and substitute A by the string on the right-hand side of the rule. - If the top of stack is a terminal symbol a, read the next symbol from the input and compare it to a. If they match, repeat. If they do not match, reject on this branch of the nondeterminism. - If the top of stack is the symbol $, enter the accept state. Doing so accepts the input if it has all been read. Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU For the CFG, S → aTb | b T → Ta | 𝜖
  • 27. 27 References: Chapter 2(section 2.2), Introduction to the Theory of Computation, 3rd Edition by Michael Sipser THANKS! Any questions? You can find me at imam@cse.uiu.ac.bd