SlideShare a Scribd company logo
1
Abhishek Shivhare
Deptt.Of CSE
ITSEC, Gr. Noida
2
Recall that DFAs accept regular
languages(for e.g. an)
We want to design more powerful
machines similar to DFAs that will accept
context-free languages(for e.g. anbn ).
Final
state
a
 An illusion : anbn is accepted by:
 It doesn’t guarantee equal nos. of a’s and b’s:
 It can accept any no. of a’s and any no. of
b’s(a’s = b’s OR a’s ≠ b’s )
4
Initial
State
Final
state
a b
b
To handle a language like {anbn | n  0},
the machine needs to “remember” the
number of a’s.
To do this, we use a stack.
A push-down automaton (PDA) is
essentially an NFA with a stack.
5
A push-down automaton (PDA) is a six-
tuple (K, Σ, Γ, Δ, s, F) where
• K is a finite set of states.
• Σ is a finite alphabet of tape symbols.
• Γ is a finite alphabet of stack symbols.
• s  K is the start state.
• F  K is the set of final states.
• Δ is the transition relation, i.e., Δ is a finite subset
of
(K  (Σ  {e})  Γ*)  (K  Γ*).
…a1a2
Control
Input
Stack
Let ((p, a, β), (q, γ))  Δ be a transition.
It means that we
• Move from state p.
• Read a from the tape,
• Pop the string β off the stack,
• Move to state q,
• Push string γ onto the stack.
The first three (p, a, β), are “input.”
The last two (q, γ) are “output.”
A configuration fully describes the current
“state” of the PDA.
• The current state p.
• The remaining input w.
• The current stack contents .
Thus, a configuration is a triple
(p, w, )  (K, *, *).
∆(q0, a, $)= (q1, a$)
∆(q0, b, $)= (q1, b$)
PUSH starting symbol onto stack (a/b) and
change state
10
Input:
a a b b c b b a a
$
∆(q1, a, a)= (q1, aa)
∆(q1, b, b)= (q1, bb)
∆(q1, a, b)= (q1, ab)
∆(q1, b, a)= (q1, ba)
PUSH moves continue till occurrence of ‘c’
11
Input:
a a b b c b b a
a$
∆(q1, c, b)= (q2, b)
∆(q1, c, a)= (q2, a)
No movement in stack but state changed
12
Input:
a a b b c
b b a a $
∆(q2, b, b)= (q2, €)
∆(q2, a, a )= (q2, €)
POP moves start as c is passed
13
Input:
a a b b
b b a a $
∆(q2, a, a)= (q2, €)
∆(q2, b, b)= (q2, €)
POP moves continue until a mismatch
14
Input:
a a
a a $
∆(q2, €, $)= (qf, $)
Final state comes into picture as input
exhausts and stack becomes empty!
Hence our string is accepted as valid
15
Input:
€
$
 ∆(q0, a, $)= (q1, a$)
 ∆(q0, b, $)= (q1, b$)
 ∆(q1, a, a)= (q1, aa)
 ∆(q1, b, b)= (q1, bb)
 ∆(q1, a, b)= (q1, ab)
 ∆(q1, b, a)= (q1, ba)
 ∆(q1, a, c)= (q2, a)
 ∆(q1, b, c)= (q2, b)
 ∆(q2, a, a)= (q2, €)
 ∆(q2, b, b)=(q2, €)
 ∆(q2, €, $)= (qf, $)
16
Initial (PUSH)
move
PUSH Move
No Stack
Operation
POP Move
Acceptance
All a’s are pushed into stack
On finding b on input, popping off a’s may
be achieved
At last if all input is exhausted and stack
becomes empty result achieved.
17
Stack uses LIFO, works best for strings
like:
 ambncndm | m  0, n  0,
 ambmcndn | m  0, n  0,
 ambncpdq | m + n = p + q and
 ambnck | m = n or n = k
18
But has a disadvantage, cannot work for
followings:
 anb2ncn | m  0, n  0,
 ambm+ncn | m  0, n  0 and
 anbncn | n  0 (Turing machines are
efficient for this type of language)
19
A: Use a three phase process:
1. Push mode: Before reading “#”, push
everything on the stack.
2. Reading “#” switches modes.
3. Pop mode: Read remaining symbols making
sure that each new read symbol is identical to
symbol popped from stack.
Accept if able to empty stack completely.
Otherwise reject, and reject if could not pop
somewhere.
20
21
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
22
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
Input:
aaab#baa
23
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
a
Input:
aaab#baa
24
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
a a
Input:
aaab#baa
25
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
a a a
Input:
aaab#baa
26
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
b a a a
Input:
aaab#baa
27
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
b a a a
Input:
aaab#baa
28
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
a a a
Input:
aaab#baa
29
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
a a
Input:
aaab#baa
30
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
a
Input:
aaab#baa
REJECT (nonempty stack)
31
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
a a
Input:
aaab#baaa
32
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
a
Input:
aaab#baaa
33
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
Input:
aaab#baaa
Pause input
34
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
Input:
aaab#baaa
ACCEPT
35
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
a a
Input:
aaab#baaaa
36
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
a
Input:
aaab#baaaa
37
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
Input:
aaab#baaaa
Pause input
38
(1)
PUSH
(3)
POP
read a or b ?
Push it
ACCEPT
(2)
read # ?
(ignore stack)
read == peek ?
Pop
Else: CRASH!
empty
stack?
Input:
aaab#baaaa
CRASH
39
e , e$
a , ea
b , eb
#, ee e , $e
a , ae
b , be
Input:
aaab#baaa
ACCEPT!
PUSH DOWN AUTOMATA VS TURING MACHINE
•Automata accepts regular languages only
For example, {anbn : n = 0, 1, …} is not regular
•Pushdown Automata accepts context-free languages only
For example, {anbncn : w  *} is not context-free
Turing decomposed operations in the device as follows:
•Computational steps erase a symbol
observed by the pencil and write a new one
in its place
•The decision about which symbol should be
written and which will be observed next
depend on:
•A pencil will be “observing” symbols from a paper
1. The current symbol being observed
2. The “state of mind” of the device
This device is called a Turing Machine
•The pencil can move left and right
•TMs can simulate any data structure
•TMs can simulate major components of imperative
languages: sequence, branching and loop
•TMs can control branching and loops
…a1 a2
Control
Tape
cell
head
The head:
•Reads the symbol from the cell it is
pointing to, and
•Either:
•Writes a new symbol in the cell,
or
•Moves one cell to the left or
•New cells can be added to the right of the tape as
needed (similar to RAM memory)
•These new cells contain the blank symbol, #
•The tape is bounded to the left
• denotes the alphabet of characters in language as
usual.
• denotes the set of symbols that can be written on tape
•It contains # and all symbols in 
• Transitions can be described by (Case I):
((s,a),(bRq)) If the machine is in state s and the
current cell has an a then jump to
state q and write b in the current cell
and moves head to right
• Transitions can be described by (Case II):
((s,a),(bLq)) If the machine is in state s and the
current cell has an a then jump to
state q and write b in the current cell
and moves head to left
Definition. A Turing machine is a 7-tuple (Q, , , , q0, qaccept, q
where:
•Q is a set of states
• is a set of symbols (the alphabet)
• is a set of symbols that can be written in tape, #   and
  
•q0  Q is the initial state
• qaccept is the accepting state
• qreject is the rejecting state, qreject  qaccept
•  is a collection of transitions defined by the
function:
: (Q  {qaccept, qreject })    Q    {L , R}
 Lets take a case of a3b3c3
 Moves are :
 aaabbbccc
 #aabbbccc
 #aa#bbccc
 #aa#bb#cc
 ##a#bb#cc
 ##a##b#cc
 ##a##b##c
 #####b##c
 ########c
 #########
50
a b c #
q1 #Rq2
q2
q3
q4
q5
q6
q7
51q7
a b c #
q1 #Rq2
q2 aRq2
q3
q4
q5
q6
q7
52q7
a b c #
q1 #Rq2
q2 aRq2
q3
q4
q5
q6
q7
53q7
a b c #
q1 #Rq2
q2 aRq2 #Rq3
q3
q4
q5
q6
q7
54q7
a b c #
q1 #Rq2
q2 aRq2 #Rq3
q3 bRq3
q4
q5
q6
q7
55q7
a b c #
q1 #Rq2
q2 aRq2 #Rq3
q3 bRq3
q4
q5
q6
q7
56q7
a b c #
q1 #Rq2
q2 aRq2 #Rq3
q3 bRq3 #Rq4
q4
q5
q6
q7
57q7
a b c #
q1 #Rq2
q2 aRq2 #Rq3
q3 bRq3 #Rq4
q4 cLq5
q5
q6
q7
58q7
a b c #
q1 #Rq2
q2 aRq2 #Rq3
q3 bRq3 #Rq4
q4 cLq5
q5 #Lq5
q6
q7
59q7
a b c #
q1 #Rq2
q2 aRq2 #Rq3
q3 bRq3 #Rq4
q4 cLq5
q5 bLq5 #Lq5
q6
q7
60q7
a b c #
q1 #Rq2
q2 aRq2 #Rq3
q3 bRq3 #Rq4
q4 cLq5
q5 bLq5 #Lq5
q6
q7
61q7
a b c #
q1 #Rq2
q2 aRq2 #Rq3
q3 bRq3 #Rq4
q4 cLq5
q5 bLq5 #Lq5
q6
q7
62q7
a b c #
q1 #Rq2
q2 aRq2 #Rq3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#Rq2
q3 bRq3 #Rq4 #Rq3
q4 cLq5
q5 aLq6 bLq5 #Lq5
q6 aLq6 #Rq1
q7
84q7
a b c #
q1 #Rq2
q2 aRq2 #Rq3 #Rq2
q3 bRq3 #Rq4 #Rq3
q4 cLq5
q5 aLq6 bLq5 #Lq5
q6 aLq6 #Rq1
q7
85q7
a b c #
q1 #Rq2
q2 aRq2 #Rq3 #Rq2
q3 bRq3 #Rq4 #Rq3
q4 cLq5
q5 aLq6 bLq5 #Lq5
q6 aLq6 #Rq1
q7
86q7
a b c #
q1 #Rq2
q2 aRq2 #Rq3 #Rq2
q3 bRq3 #Rq4 #Rq3
q4 cLq5
q5 aLq6 bLq5 #Lq5
q6 aLq6 #Rq1
q7
87q7
a b c #
q1 #Rq2
q2 aRq2 #Rq3 #Rq2
q3 bRq3 #Rq4 #Rq3
q4 cLq5 #Lq7
q5 aLq6 bLq5 #Lq5
q6 aLq6 #Rq1
q7
88q7
a b c #
q1 #Rq2 #Rq1
q2 aRq2 #Rq3 #Rq2
q3 bRq3 #Rq4 #Rq3
q4 cLq5 #Lq7
q5 aLq6 bLq5 #Lq5
q6 aLq6 #Rq1
q7
89q7
90
Device
Separate
Input?
Read/Write Data
Structure
Deterministic
by default?
FA
PDA
TM
91
Device
Separate
Input?
Read/Write Data
Structure
Deterministic
by default?
FA Yes None Yes
PDA
TM
92
Device
Separate
Input?
Read/Write Data
Structure
Deterministic
by default?
FA Yes None Yes
PDA Yes LIFO Stack No
TM
93
Device
Separate
Input?
Read/Write Data
Structure
Deterministic
by default?
FA Yes None Yes
PDA Yes LIFO Stack No
TM No
1-way infinite
tape. 1 cell
access per step.
Yes
(but will also
allow crashes)
94
Device Type of
Grammar
String/
Language
Finite
Automata
Regular
(Type 3)
an
95
Device Type of
Grammar
String/
Language
Finite
Automata
Regular
(Type 3)
an
Push Down
Automata
Context Free
(Type 2)
anbn
96
Device Type of
Grammar
String/
Language
Finite
Automata
Regular
(Type 3)
an
Push Down
Automata
Context Free
(Type 2)
anbn
Linear
Bounded
Automata
Context Sensitive
(Type 1) N.A.
97
Device Type of
Grammar
String/
Language
Finite
Automata
Regular
(Type 3)
an
Push Down
Automata
Context Free
(Type 2)
anbn
Linear
Bounded
Automata
Context Sensitive
(Type 1) N.A.
Turing
Machine
Unrestricted
(Type 0)
anbncn
98
99

More Related Content

PPTX
Restoring & Non-Restoring Division Algorithm By Sania Nisar
PPTX
Introduction TO Finite Automata
PPTX
Turing machine
PPTX
NFA & DFA
PDF
NFA to DFA
PDF
Deterministic Finite Automata (DFA)
PPTX
Context free grammar
PPTX
Shortest path algorithm
Restoring & Non-Restoring Division Algorithm By Sania Nisar
Introduction TO Finite Automata
Turing machine
NFA & DFA
NFA to DFA
Deterministic Finite Automata (DFA)
Context free grammar
Shortest path algorithm

What's hot (20)

PPTX
Specification-of-tokens
PDF
Turing machines
PPTX
Automata Theory - Turing machine
PPT
pushdown automata
PPTX
Chomsky classification of Language
PPTX
Principle source of optimazation
PPTX
Hamming code system
PPTX
Types of grammer - TOC
PPT
Gsm radio-interface
PPT
Compiler Design
PDF
Working principle of Turing machine
PPT
Turing Machine
PPTX
Finite Automata in compiler design
PPT
Finite automata
PDF
I. AO* SEARCH ALGORITHM
PPTX
Time delay programs and assembler directives 8086
PPTX
Instruction pipeline: Computer Architecture
PPTX
Address resolution protocol (ARP)
PPTX
Addressing modes
Specification-of-tokens
Turing machines
Automata Theory - Turing machine
pushdown automata
Chomsky classification of Language
Principle source of optimazation
Hamming code system
Types of grammer - TOC
Gsm radio-interface
Compiler Design
Working principle of Turing machine
Turing Machine
Finite Automata in compiler design
Finite automata
I. AO* SEARCH ALGORITHM
Time delay programs and assembler directives 8086
Instruction pipeline: Computer Architecture
Address resolution protocol (ARP)
Addressing modes
Ad

Viewers also liked (20)

PPT
Pushdown automata
PPTX
Push down automata
PPTX
Turing machine by_deep
PDF
Undecidable Problem
PDF
Push Down Automata (PDA)
PPTX
Pushdown autometa
PPTX
Theory of automata and formal languages Unit 4
PPTX
Quanttech(About Us)
PPTX
Юлия Киселева (ДонНТУ). "2012 - год Алана Тьюринга"
PPTX
Theory of computation Lec7 pda
PPT
Regular expressions and languages pdf
PPTX
Backus Naur and Chomsky Normal Forms
PPTX
Two-way Deterministic Finite Automata
PPTX
Pushdown Automata - Materi 8 - TBO
PPT
Bakus naur form
PPTX
Edited alan turing-presentation
PDF
Automata languages and computation
PPTX
Theory of automata and formal language
PDF
Automata
Pushdown automata
Push down automata
Turing machine by_deep
Undecidable Problem
Push Down Automata (PDA)
Pushdown autometa
Theory of automata and formal languages Unit 4
Quanttech(About Us)
Юлия Киселева (ДонНТУ). "2012 - год Алана Тьюринга"
Theory of computation Lec7 pda
Regular expressions and languages pdf
Backus Naur and Chomsky Normal Forms
Two-way Deterministic Finite Automata
Pushdown Automata - Materi 8 - TBO
Bakus naur form
Edited alan turing-presentation
Automata languages and computation
Theory of automata and formal language
Automata
Ad

Similar to PUSH DOWN AUTOMATA VS TURING MACHINE (20)

PPTX
Unit 2 Pumping lemma Unit 2 Pumping lemma
PPT
PushdownAutomata and Turing machines ppt
PPT
Turing Machine
PPT
PushdownAutomata.ppt
PPT
Pushdown automata
PPT
Pushdown automata
PPT
Unit-3_TOC theory of computation subj.ppt
PPT
FiniteAutomata-DFA and NFA from Theory of Computation.ppt
PPT
FiniteAutomata (1).ppt
PPT
FiniteAutomata.ppt
PPT
TuringMachines.ppt
PPT
Turing Machine push down automata-examples
PDF
Lec14_TuringMachines 2PDA (1).pdf thooooo
PPT
TuringMachines and its introduction for computer science studetns
PDF
Pushdown Automota
PDF
Turingmachines
PPTX
Theory of automata
PPTX
PDA (pushdown automaton)
PPT
Turing Machine
Unit 2 Pumping lemma Unit 2 Pumping lemma
PushdownAutomata and Turing machines ppt
Turing Machine
PushdownAutomata.ppt
Pushdown automata
Pushdown automata
Unit-3_TOC theory of computation subj.ppt
FiniteAutomata-DFA and NFA from Theory of Computation.ppt
FiniteAutomata (1).ppt
FiniteAutomata.ppt
TuringMachines.ppt
Turing Machine push down automata-examples
Lec14_TuringMachines 2PDA (1).pdf thooooo
TuringMachines and its introduction for computer science studetns
Pushdown Automota
Turingmachines
Theory of automata
PDA (pushdown automaton)
Turing Machine

Recently uploaded (20)

PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
Well-logging-methods_new................
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
PPT on Performance Review to get promotions
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
Digital Logic Computer Design lecture notes
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
additive manufacturing of ss316l using mig welding
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
web development for engineering and engineering
PDF
composite construction of structures.pdf
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPT
Mechanical Engineering MATERIALS Selection
Automation-in-Manufacturing-Chapter-Introduction.pdf
Well-logging-methods_new................
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
R24 SURVEYING LAB MANUAL for civil enggi
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Operating System & Kernel Study Guide-1 - converted.pdf
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPT on Performance Review to get promotions
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Digital Logic Computer Design lecture notes
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
additive manufacturing of ss316l using mig welding
OOP with Java - Java Introduction (Basics)
web development for engineering and engineering
composite construction of structures.pdf
Foundation to blockchain - A guide to Blockchain Tech
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Mechanical Engineering MATERIALS Selection

PUSH DOWN AUTOMATA VS TURING MACHINE

  • 1. 1
  • 3. Recall that DFAs accept regular languages(for e.g. an) We want to design more powerful machines similar to DFAs that will accept context-free languages(for e.g. anbn ). Final state a
  • 4.  An illusion : anbn is accepted by:  It doesn’t guarantee equal nos. of a’s and b’s:  It can accept any no. of a’s and any no. of b’s(a’s = b’s OR a’s ≠ b’s ) 4 Initial State Final state a b b
  • 5. To handle a language like {anbn | n  0}, the machine needs to “remember” the number of a’s. To do this, we use a stack. A push-down automaton (PDA) is essentially an NFA with a stack. 5
  • 6. A push-down automaton (PDA) is a six- tuple (K, Σ, Γ, Δ, s, F) where • K is a finite set of states. • Σ is a finite alphabet of tape symbols. • Γ is a finite alphabet of stack symbols. • s  K is the start state. • F  K is the set of final states. • Δ is the transition relation, i.e., Δ is a finite subset of (K  (Σ  {e})  Γ*)  (K  Γ*).
  • 8. Let ((p, a, β), (q, γ))  Δ be a transition. It means that we • Move from state p. • Read a from the tape, • Pop the string β off the stack, • Move to state q, • Push string γ onto the stack. The first three (p, a, β), are “input.” The last two (q, γ) are “output.”
  • 9. A configuration fully describes the current “state” of the PDA. • The current state p. • The remaining input w. • The current stack contents . Thus, a configuration is a triple (p, w, )  (K, *, *).
  • 10. ∆(q0, a, $)= (q1, a$) ∆(q0, b, $)= (q1, b$) PUSH starting symbol onto stack (a/b) and change state 10 Input: a a b b c b b a a $
  • 11. ∆(q1, a, a)= (q1, aa) ∆(q1, b, b)= (q1, bb) ∆(q1, a, b)= (q1, ab) ∆(q1, b, a)= (q1, ba) PUSH moves continue till occurrence of ‘c’ 11 Input: a a b b c b b a a$
  • 12. ∆(q1, c, b)= (q2, b) ∆(q1, c, a)= (q2, a) No movement in stack but state changed 12 Input: a a b b c b b a a $
  • 13. ∆(q2, b, b)= (q2, €) ∆(q2, a, a )= (q2, €) POP moves start as c is passed 13 Input: a a b b b b a a $
  • 14. ∆(q2, a, a)= (q2, €) ∆(q2, b, b)= (q2, €) POP moves continue until a mismatch 14 Input: a a a a $
  • 15. ∆(q2, €, $)= (qf, $) Final state comes into picture as input exhausts and stack becomes empty! Hence our string is accepted as valid 15 Input: € $
  • 16.  ∆(q0, a, $)= (q1, a$)  ∆(q0, b, $)= (q1, b$)  ∆(q1, a, a)= (q1, aa)  ∆(q1, b, b)= (q1, bb)  ∆(q1, a, b)= (q1, ab)  ∆(q1, b, a)= (q1, ba)  ∆(q1, a, c)= (q2, a)  ∆(q1, b, c)= (q2, b)  ∆(q2, a, a)= (q2, €)  ∆(q2, b, b)=(q2, €)  ∆(q2, €, $)= (qf, $) 16 Initial (PUSH) move PUSH Move No Stack Operation POP Move Acceptance
  • 17. All a’s are pushed into stack On finding b on input, popping off a’s may be achieved At last if all input is exhausted and stack becomes empty result achieved. 17
  • 18. Stack uses LIFO, works best for strings like:  ambncndm | m  0, n  0,  ambmcndn | m  0, n  0,  ambncpdq | m + n = p + q and  ambnck | m = n or n = k 18
  • 19. But has a disadvantage, cannot work for followings:  anb2ncn | m  0, n  0,  ambm+ncn | m  0, n  0 and  anbncn | n  0 (Turing machines are efficient for this type of language) 19
  • 20. A: Use a three phase process: 1. Push mode: Before reading “#”, push everything on the stack. 2. Reading “#” switches modes. 3. Pop mode: Read remaining symbols making sure that each new read symbol is identical to symbol popped from stack. Accept if able to empty stack completely. Otherwise reject, and reject if could not pop somewhere. 20
  • 21. 21 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack?
  • 22. 22 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? Input: aaab#baa
  • 23. 23 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? a Input: aaab#baa
  • 24. 24 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? a a Input: aaab#baa
  • 25. 25 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? a a a Input: aaab#baa
  • 26. 26 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? b a a a Input: aaab#baa
  • 27. 27 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? b a a a Input: aaab#baa
  • 28. 28 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? a a a Input: aaab#baa
  • 29. 29 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? a a Input: aaab#baa
  • 30. 30 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? a Input: aaab#baa REJECT (nonempty stack)
  • 31. 31 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? a a Input: aaab#baaa
  • 32. 32 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? a Input: aaab#baaa
  • 33. 33 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? Input: aaab#baaa Pause input
  • 34. 34 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? Input: aaab#baaa ACCEPT
  • 35. 35 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? a a Input: aaab#baaaa
  • 36. 36 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? a Input: aaab#baaaa
  • 37. 37 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? Input: aaab#baaaa Pause input
  • 38. 38 (1) PUSH (3) POP read a or b ? Push it ACCEPT (2) read # ? (ignore stack) read == peek ? Pop Else: CRASH! empty stack? Input: aaab#baaaa CRASH
  • 39. 39 e , e$ a , ea b , eb #, ee e , $e a , ae b , be Input: aaab#baaa ACCEPT!
  • 41. •Automata accepts regular languages only For example, {anbn : n = 0, 1, …} is not regular •Pushdown Automata accepts context-free languages only For example, {anbncn : w  *} is not context-free
  • 42. Turing decomposed operations in the device as follows: •Computational steps erase a symbol observed by the pencil and write a new one in its place •The decision about which symbol should be written and which will be observed next depend on: •A pencil will be “observing” symbols from a paper 1. The current symbol being observed 2. The “state of mind” of the device This device is called a Turing Machine •The pencil can move left and right
  • 43. •TMs can simulate any data structure •TMs can simulate major components of imperative languages: sequence, branching and loop •TMs can control branching and loops
  • 44. …a1 a2 Control Tape cell head The head: •Reads the symbol from the cell it is pointing to, and •Either: •Writes a new symbol in the cell, or •Moves one cell to the left or
  • 45. •New cells can be added to the right of the tape as needed (similar to RAM memory) •These new cells contain the blank symbol, # •The tape is bounded to the left
  • 46. • denotes the alphabet of characters in language as usual. • denotes the set of symbols that can be written on tape •It contains # and all symbols in  • Transitions can be described by (Case I): ((s,a),(bRq)) If the machine is in state s and the current cell has an a then jump to state q and write b in the current cell and moves head to right
  • 47. • Transitions can be described by (Case II): ((s,a),(bLq)) If the machine is in state s and the current cell has an a then jump to state q and write b in the current cell and moves head to left
  • 48. Definition. A Turing machine is a 7-tuple (Q, , , , q0, qaccept, q where: •Q is a set of states • is a set of symbols (the alphabet) • is a set of symbols that can be written in tape, #   and    •q0  Q is the initial state • qaccept is the accepting state • qreject is the rejecting state, qreject  qaccept
  • 49. •  is a collection of transitions defined by the function: : (Q  {qaccept, qreject })    Q    {L , R}
  • 50.  Lets take a case of a3b3c3  Moves are :  aaabbbccc  #aabbbccc  #aa#bbccc  #aa#bb#cc  ##a#bb#cc  ##a##b#cc  ##a##b##c  #####b##c  ########c  ######### 50
  • 51. a b c # q1 #Rq2 q2 q3 q4 q5 q6 q7 51q7
  • 52. a b c # q1 #Rq2 q2 aRq2 q3 q4 q5 q6 q7 52q7
  • 53. a b c # q1 #Rq2 q2 aRq2 q3 q4 q5 q6 q7 53q7
  • 54. a b c # q1 #Rq2 q2 aRq2 #Rq3 q3 q4 q5 q6 q7 54q7
  • 55. a b c # q1 #Rq2 q2 aRq2 #Rq3 q3 bRq3 q4 q5 q6 q7 55q7
  • 56. a b c # q1 #Rq2 q2 aRq2 #Rq3 q3 bRq3 q4 q5 q6 q7 56q7
  • 57. a b c # q1 #Rq2 q2 aRq2 #Rq3 q3 bRq3 #Rq4 q4 q5 q6 q7 57q7
  • 58. a b c # q1 #Rq2 q2 aRq2 #Rq3 q3 bRq3 #Rq4 q4 cLq5 q5 q6 q7 58q7
  • 59. a b c # q1 #Rq2 q2 aRq2 #Rq3 q3 bRq3 #Rq4 q4 cLq5 q5 #Lq5 q6 q7 59q7
  • 60. a b c # q1 #Rq2 q2 aRq2 #Rq3 q3 bRq3 #Rq4 q4 cLq5 q5 bLq5 #Lq5 q6 q7 60q7
  • 61. a b c # q1 #Rq2 q2 aRq2 #Rq3 q3 bRq3 #Rq4 q4 cLq5 q5 bLq5 #Lq5 q6 q7 61q7
  • 62. a b c # q1 #Rq2 q2 aRq2 #Rq3 q3 bRq3 #Rq4 q4 cLq5 q5 bLq5 #Lq5 q6 q7 62q7
  • 63. a b c # q1 #Rq2 q2 aRq2 #Rq3 q3 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q4 cLq5 q5 aLq6 bLq5 #Lq5 q6 aLq6 #Rq1 q7 83q7
  • 84. a b c # q1 #Rq2 q2 aRq2 #Rq3 #Rq2 q3 bRq3 #Rq4 #Rq3 q4 cLq5 q5 aLq6 bLq5 #Lq5 q6 aLq6 #Rq1 q7 84q7
  • 85. a b c # q1 #Rq2 q2 aRq2 #Rq3 #Rq2 q3 bRq3 #Rq4 #Rq3 q4 cLq5 q5 aLq6 bLq5 #Lq5 q6 aLq6 #Rq1 q7 85q7
  • 86. a b c # q1 #Rq2 q2 aRq2 #Rq3 #Rq2 q3 bRq3 #Rq4 #Rq3 q4 cLq5 q5 aLq6 bLq5 #Lq5 q6 aLq6 #Rq1 q7 86q7
  • 87. a b c # q1 #Rq2 q2 aRq2 #Rq3 #Rq2 q3 bRq3 #Rq4 #Rq3 q4 cLq5 q5 aLq6 bLq5 #Lq5 q6 aLq6 #Rq1 q7 87q7
  • 88. a b c # q1 #Rq2 q2 aRq2 #Rq3 #Rq2 q3 bRq3 #Rq4 #Rq3 q4 cLq5 #Lq7 q5 aLq6 bLq5 #Lq5 q6 aLq6 #Rq1 q7 88q7
  • 89. a b c # q1 #Rq2 #Rq1 q2 aRq2 #Rq3 #Rq2 q3 bRq3 #Rq4 #Rq3 q4 cLq5 #Lq7 q5 aLq6 bLq5 #Lq5 q6 aLq6 #Rq1 q7 89q7
  • 93. 93 Device Separate Input? Read/Write Data Structure Deterministic by default? FA Yes None Yes PDA Yes LIFO Stack No TM No 1-way infinite tape. 1 cell access per step. Yes (but will also allow crashes)
  • 95. 95 Device Type of Grammar String/ Language Finite Automata Regular (Type 3) an Push Down Automata Context Free (Type 2) anbn
  • 96. 96 Device Type of Grammar String/ Language Finite Automata Regular (Type 3) an Push Down Automata Context Free (Type 2) anbn Linear Bounded Automata Context Sensitive (Type 1) N.A.
  • 97. 97 Device Type of Grammar String/ Language Finite Automata Regular (Type 3) an Push Down Automata Context Free (Type 2) anbn Linear Bounded Automata Context Sensitive (Type 1) N.A. Turing Machine Unrestricted (Type 0) anbncn
  • 98. 98
  • 99. 99