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
FA >> Schematic Diagram
3
Finite control
a ba a b 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
PDA >> Schematic Diagram
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 but the memory is usable in LIFO manner
TM – Turing Machine
5
Turing Machine
▸Similar to finite automata but with an unlimited and unrestricted memory.
▸TM model uses an infinite tape as its unlimited memory. Initially the tape contains only the input string and is blank
everywhere else.
▸The tape head can read and write symbols and move around on the tape. If the machine needs to store information, it
may write this information on the tape. To read the information that it has written, the machine can move its head back
over it.
▸The outputs accept and reject are obtained by entering designated accepting and rejecting states, if it doesn’t enter an
accepting or a rejecting state it will go on forever, never halting.
▸TM can do everything that a real computer can do. The problems that a TM can’t solve are beyond the theoretical limits
of computation.
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> Schematic Diagram
6
▸ A Turing Machine can both write on the tape and read from it.
▸ The read-write head can move both to the left and to the right.
▸ The tape is infinite.
▸ The special states for rejecting and accepting take effect immediately.
▸ The ˽ symbol represents blank cell.
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
control
a ab b ˽ input˽
TM >> Formal Definition
7
A Turing Machine is a 7-tuple, (Q, 𝛴, 𝛤, 𝛿, q0, qaccept, qreject), where Q, 𝛴, 𝛤 are all finite sets and
▸ Q is the set of states
▸ 𝛴 is the input alphabet not containing the blank symbol ˽
▸ 𝛤 is the tape alphabet, where ˽ 𝜖 𝛤 and 𝛴 ⊆ 𝛤
▸ 𝛿 : Q x 𝛤 → Q x 𝛤 x { L, R } is the transition function
▸ q0 𝜖 Q is the start state
▸ qaccept 𝜖 Q is the accept state and
▸ qreject 𝜖 Q is the reject state, where qreject ≠ qaccept
Outcomes: accept, reject, or loop
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> Transition Function
8
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
q
a b a b ˽ ˽
𝛿(q, a) = (r, b, L)
r
a b b b ˽ ˽
L = left
Transition Function,
𝛿(q, a) = (r, b, L)
Mechanism :
When the machine is in a certain state q and
the head is over a tape square containing a symbol a,
The machine writes the symbol b replacing the a,
and goes to state r.
The third component is either L or R and indicates whether the
head moves to the left or right after writing.
TM >> Languages
9
Turing-recognizable Language / Recursively Enumerable Language
▸ A language is Turing-recognizable if some Turing machine recognizes it.
▸ TM can fail to accept an input by entering the qreject state and rejecting, or by looping.
This causes a problem to decide whether the machine is in looping state or taking long time to compute.
Turing-decidable Language / Recursive Language
▸ Turing machines that halt on all inputs are called deciders because they always make a decision to accept or reject and
such machines never loop.
▸ A language is Turing-decidable or simply decidable if some TM decides it.
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> L = { 0n 1n | n >= 1 }
10
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
Formal Definition
Q = { q0, q1, q2, q3, q4 }
Σ = { 0, 1 }
𝛤 = { 0, 1, X, Y, ˽ }
𝛿 is described the following transition table:
Start state = q0
qaccept = q4
qreject = { }
0 1 X Y ˽
q0
(q1, X, R) - - (q3, Y, R) -
q1
(q1, 0, R) (q2, Y, L) - (q1, Y, R) -
q2
(q2, 0, L) - (q0, X, R) (q2, Y, L) -
q3
- - - (q3, Y, R) (q4, B, R)
q4
- - - - -
TM >> Configuration
11
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
q
a b a b ˽ ˽
𝛿(q, a) = (r, b, L)
r
a b b b ˽ ˽
L = left
Configuration: abqab
Configuration: arbbb
Start configuration: q0 w
Accepting configuration: the state of the accepting
configuration is qaccept
Rejecting configuration: the state of the rejecting
configuration is qreject
Accepting and Rejecting configurations are halting
configurations and do not yield further configuration.
– The configuration C1 yields configuration C2 if the
TM can legally go from C1 to C2 in a single step.
For example,
ua qi bv yields u qj acv ; if 𝛿(qi, b) = (qj, c, L)
and
ua qi bv yields uac qj v ; if 𝛿(qi, b) = (qj, c, R)
TM >> Machine 1 – L = {w # w | w ∈ {0,1}* }
12
Check acceptability for the following strings:
▸ 1011#1011
▸ 001#100
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> Machine 1 – L = {w # w | w ∈ {0,1}* }
13
How this machine computes … … …
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> Machine 1 – L = {w # w | w ∈ {0,1}* }
14
Acceptability checking: 011#011
Sequence of configurations:
q1 011#011˽
x q2 11#011˽
x1 q2 1#011˽
x11 q2 #011˽
x11# q4 011˽
x11 q6 #x11˽
x1 q7 1#x11˽
x q7 11#x11˽
q7 x11#x11˽
x q111#x11˽
xx q31#x11˽
xx1 q3 #x11˽
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
xx1# q5 x11˽
xx1#x q5 11˽
xx1# q6 xx1˽
xx1 q6 #xx1˽
xx q7 1#xx1˽
x q7 x1#xx1˽
xx q11#xx1˽
xxx q3 #xx1˽
xxx# q5 xx1˽
xxx#x q5 x1˽
xxx#xx q5 1˽
xxx#x q6 xx˽
xxx# q6 xxx˽
xxx q6 #xxx˽
xx q7 x#xxx˽
xxx q1 #xxx˽
xxx# q8 xxx˽
xxx#x q8 xx˽
xxx#xx q8 x˽
xxx#xxx q8 ˽
xxx#xxx˽ qaccept
TM >> Machine 1 – L = {w # w | w ∈ {0,1}* }
15
Acceptability checking: 001#100
Sequence of configurations:
q1 001#100˽
x q2 01#100˽
x0 q2 1#100˽
x01 q2 #100˽
x01# q4 100˽
Rejected, no transition exists.
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> Machine 2 – TM for Addition
16
TM for computing sum:
Each number is represented as a sequence
of 0’s i.e. 2 = 00, 3 = 000
Input: 0 0 0 0 c 0 0 0 // 4 + 3
Output: 0 0 0 0 0 0 0 // 7
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> Machine 3 – TM for Subtraction
17
TM for computing difference from bigger
integer to smaller one:
Each number is represented as a sequence
of 0’s i.e. 2 = 00, 3 = 000
Input: 0 0 0 0 0 c 0 0 0 // 5 - 3
Output: 0 0 // 2
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> Machine 4 – TM for Comparator (A<B)
18
TM for comparing two numbers:
Each number is represented as a sequence of 0’s
i.e. 2 = 00, 3 = 000
Input: 11 0 1111 // 2 < 4
Output: 0 X X 1 1 // 1’s remain in the right
side, so second argument is greater.
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> Machine 5 – TM for Comparator (A=B)
19
TM for comparing two numbers:
Each number is represented as a sequence of 0’s
i.e. 2 = 00, 3 = 000
Input: 111 0 111 // 3 = 3
Output: XXX0XXX // no 1’s remain in both
sides, so A=B
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> Machine 6 – L = {0n 1n 2n | n >=1 }
20
Check acceptability for the following strings:
▸ 001122
▸ 0001112222
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> Machine 7 – L = { an bm an+m | n,m >=1 }
21
Check acceptability for the following strings:
▸ aabbbaaaaa
▸ aabaaaa
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> Machine 8 – L = {wwr | w ∈ {0,1}* }
22
Check acceptability for the following strings:
▸ 00111100
▸ 10100101
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> Machine 9 – L = {ww | w ∈ {0,1}* }
23
Check acceptability for the following strings:
▸ 101101
▸ 101110
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> Machine 10 – L = {ai dj ck | i>j>k and k>=1}
24
Check acceptability for the following strings:
▸ aaabbc
▸ aabbccc
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> Machine 11 – L = {ai dj ck | i<j<k and i>=1}
25
Check acceptability for the following strings:
▸ aaabbc
▸ abbccc
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
TM >> Machine 12 – L = { 02 𝑛
| n >=0 }
26
Check acceptability for the following strings:
▸ 0000
▸ 00000
Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
27
References:
- Chapter 3(section 3.1), Introduction to the Theory of Computation, 3rd Edition by Michael Sipser
- Reference website: https://www.geeksforgeeks.org/turing-machine-in-toc/
THANKS!
Any questions?
You can find me at imam@cse.uiu.ac.bd

More Related Content

What's hot

TOC 4 | Non-deterministic Finite Automata
TOC 4 | Non-deterministic Finite AutomataTOC 4 | Non-deterministic Finite Automata
TOC 4 | Non-deterministic Finite AutomataMohammad Imam Hossain
 
Knapsack problem using greedy approach
Knapsack problem using greedy approachKnapsack problem using greedy approach
Knapsack problem using greedy approachpadmeshagrekar
 
Pumping lemma for regular set h1
Pumping lemma for regular set h1Pumping lemma for regular set h1
Pumping lemma for regular set h1Rajendran
 
SINGLE SOURCE SHORTEST PATH.ppt
SINGLE SOURCE SHORTEST PATH.pptSINGLE SOURCE SHORTEST PATH.ppt
SINGLE SOURCE SHORTEST PATH.pptshanthishyam
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite AutomataRatnakar Mikkili
 
Ch3 4 regular expression and grammar
Ch3 4 regular expression and grammarCh3 4 regular expression and grammar
Ch3 4 regular expression and grammarmeresie tesfay
 
implementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity pptimplementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity pptAntaraBhattacharya12
 
Properties of Regular Expressions
Properties of Regular ExpressionsProperties of Regular Expressions
Properties of Regular ExpressionsShiraz316
 
Fractional Knapsack Problem
Fractional Knapsack ProblemFractional Knapsack Problem
Fractional Knapsack Problemharsh kothari
 
closure properties of regular language.pptx
closure properties of regular language.pptxclosure properties of regular language.pptx
closure properties of regular language.pptxThirumoorthy64
 
Types of grammer - TOC
Types of grammer - TOCTypes of grammer - TOC
Types of grammer - TOCAbhayDhupar
 
Travelling SalesMan Problem(TSP)
Travelling SalesMan Problem(TSP)Travelling SalesMan Problem(TSP)
Travelling SalesMan Problem(TSP)Akshay Kamble
 

What's hot (20)

TOC 4 | Non-deterministic Finite Automata
TOC 4 | Non-deterministic Finite AutomataTOC 4 | Non-deterministic Finite Automata
TOC 4 | Non-deterministic Finite Automata
 
Knapsack problem using greedy approach
Knapsack problem using greedy approachKnapsack problem using greedy approach
Knapsack problem using greedy approach
 
Pumping lemma
Pumping lemmaPumping lemma
Pumping lemma
 
Pumping lemma for regular set h1
Pumping lemma for regular set h1Pumping lemma for regular set h1
Pumping lemma for regular set h1
 
SINGLE SOURCE SHORTEST PATH.ppt
SINGLE SOURCE SHORTEST PATH.pptSINGLE SOURCE SHORTEST PATH.ppt
SINGLE SOURCE SHORTEST PATH.ppt
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
String matching, naive,
String matching, naive,String matching, naive,
String matching, naive,
 
Ch3 4 regular expression and grammar
Ch3 4 regular expression and grammarCh3 4 regular expression and grammar
Ch3 4 regular expression and grammar
 
implementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity pptimplementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity ppt
 
Automata Theory - Turing machine
Automata Theory - Turing machineAutomata Theory - Turing machine
Automata Theory - Turing machine
 
Properties of Regular Expressions
Properties of Regular ExpressionsProperties of Regular Expressions
Properties of Regular Expressions
 
Fractional Knapsack Problem
Fractional Knapsack ProblemFractional Knapsack Problem
Fractional Knapsack Problem
 
frames.pptx
frames.pptxframes.pptx
frames.pptx
 
Np hard
Np hardNp hard
Np hard
 
closure properties of regular language.pptx
closure properties of regular language.pptxclosure properties of regular language.pptx
closure properties of regular language.pptx
 
Pda
PdaPda
Pda
 
Types of grammer - TOC
Types of grammer - TOCTypes of grammer - TOC
Types of grammer - TOC
 
Chomsky Hierarchy.ppt
Chomsky Hierarchy.pptChomsky Hierarchy.ppt
Chomsky Hierarchy.ppt
 
Travelling SalesMan Problem(TSP)
Travelling SalesMan Problem(TSP)Travelling SalesMan Problem(TSP)
Travelling SalesMan Problem(TSP)
 
TOC 3 | Different Operations on DFA
TOC 3 | Different Operations on DFATOC 3 | Different Operations on DFA
TOC 3 | Different Operations on DFA
 

Similar to TOC 10 | Turing Machine

state_machines1.pdf
state_machines1.pdfstate_machines1.pdf
state_machines1.pdfrdjo
 
IE 425 Homework 10Submit on Tuesday, 12101.(20 pts) C.docx
IE 425 Homework 10Submit on Tuesday, 12101.(20 pts) C.docxIE 425 Homework 10Submit on Tuesday, 12101.(20 pts) C.docx
IE 425 Homework 10Submit on Tuesday, 12101.(20 pts) C.docxsheronlewthwaite
 
The Effect of Imbalance on the Performance of Unpaced Production Line – A Mat...
The Effect of Imbalance on the Performance of Unpaced Production Line – A Mat...The Effect of Imbalance on the Performance of Unpaced Production Line – A Mat...
The Effect of Imbalance on the Performance of Unpaced Production Line – A Mat...IOSR Journals
 
Time series analysis use E-views programer
Time series analysis use E-views programerTime series analysis use E-views programer
Time series analysis use E-views programerAl-Qadisiya University
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemMohammad Imam Hossain
 
Modeling examples
Modeling examplesModeling examples
Modeling examplesanand hd
 
Cost minimization model
Cost minimization modelCost minimization model
Cost minimization modelrowell balala
 
Python for Machine Learning
Python for Machine LearningPython for Machine Learning
Python for Machine LearningStudent
 
Cs1123 5 selection_if
Cs1123 5 selection_ifCs1123 5 selection_if
Cs1123 5 selection_ifTAlha MAlik
 
Control structures.ppt
Control structures.pptControl structures.ppt
Control structures.pptRahul Borate
 
MOC2.PPT[1].pptx introduction to mealy machine and moore machine with eample ...
MOC2.PPT[1].pptx introduction to mealy machine and moore machine with eample ...MOC2.PPT[1].pptx introduction to mealy machine and moore machine with eample ...
MOC2.PPT[1].pptx introduction to mealy machine and moore machine with eample ...PranavHendre1
 
Finite state automaton
Finite state automatonFinite state automaton
Finite state automatonAmmAr mobark
 
Lecture-2-01-02-2022.pdf
Lecture-2-01-02-2022.pdfLecture-2-01-02-2022.pdf
Lecture-2-01-02-2022.pdfZakria Bilal
 
Finite State Machines with Output
Finite State Machines with OutputFinite State Machines with Output
Finite State Machines with OutputMustafa Saeed
 
Chapter 3 Control structures.ppt
Chapter 3 Control structures.pptChapter 3 Control structures.ppt
Chapter 3 Control structures.pptRahulBorate10
 

Similar to TOC 10 | Turing Machine (20)

state_machines1.pdf
state_machines1.pdfstate_machines1.pdf
state_machines1.pdf
 
IE 425 Homework 10Submit on Tuesday, 12101.(20 pts) C.docx
IE 425 Homework 10Submit on Tuesday, 12101.(20 pts) C.docxIE 425 Homework 10Submit on Tuesday, 12101.(20 pts) C.docx
IE 425 Homework 10Submit on Tuesday, 12101.(20 pts) C.docx
 
The Effect of Imbalance on the Performance of Unpaced Production Line – A Mat...
The Effect of Imbalance on the Performance of Unpaced Production Line – A Mat...The Effect of Imbalance on the Performance of Unpaced Production Line – A Mat...
The Effect of Imbalance on the Performance of Unpaced Production Line – A Mat...
 
C012111419
C012111419C012111419
C012111419
 
Time series analysis use E-views programer
Time series analysis use E-views programerTime series analysis use E-views programer
Time series analysis use E-views programer
 
AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
 
Modeling examples
Modeling examplesModeling examples
Modeling examples
 
Cost minimization model
Cost minimization modelCost minimization model
Cost minimization model
 
Python for Machine Learning
Python for Machine LearningPython for Machine Learning
Python for Machine Learning
 
Cs1123 5 selection_if
Cs1123 5 selection_ifCs1123 5 selection_if
Cs1123 5 selection_if
 
Control structures.ppt
Control structures.pptControl structures.ppt
Control structures.ppt
 
MOC2.PPT[1].pptx introduction to mealy machine and moore machine with eample ...
MOC2.PPT[1].pptx introduction to mealy machine and moore machine with eample ...MOC2.PPT[1].pptx introduction to mealy machine and moore machine with eample ...
MOC2.PPT[1].pptx introduction to mealy machine and moore machine with eample ...
 
Finite state automaton
Finite state automatonFinite state automaton
Finite state automaton
 
C++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdfC++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdf
 
Lecture-2-01-02-2022.pdf
Lecture-2-01-02-2022.pdfLecture-2-01-02-2022.pdf
Lecture-2-01-02-2022.pdf
 
Finite State Machines with Output
Finite State Machines with OutputFinite State Machines with Output
Finite State Machines with Output
 
Chapter 3 Control structures.ppt
Chapter 3 Control structures.pptChapter 3 Control structures.ppt
Chapter 3 Control structures.ppt
 
Icra 17
Icra 17Icra 17
Icra 17
 
Control system unit(1)
Control system unit(1)Control system unit(1)
Control system unit(1)
 
Kalman_filtering
Kalman_filteringKalman_filtering
Kalman_filtering
 

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 2 | Entity Relationship Model
DBMS 2 | Entity Relationship ModelDBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship Model
 
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
 
TOC 7 | CFG in Chomsky Normal Form
TOC 7 | CFG in Chomsky Normal FormTOC 7 | CFG in Chomsky Normal Form
TOC 7 | CFG in Chomsky Normal Form
 
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
 

Recently uploaded

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
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
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
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
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
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
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
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
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
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Recently uploaded (20)

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 🔝✔️✔️
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
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
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
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
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
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
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
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
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 

TOC 10 | Turing Machine

  • 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. FA >> Schematic Diagram 3 Finite control a ba a b 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. PDA >> Schematic Diagram 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 but the memory is usable in LIFO manner
  • 5. TM – Turing Machine 5 Turing Machine ▸Similar to finite automata but with an unlimited and unrestricted memory. ▸TM model uses an infinite tape as its unlimited memory. Initially the tape contains only the input string and is blank everywhere else. ▸The tape head can read and write symbols and move around on the tape. If the machine needs to store information, it may write this information on the tape. To read the information that it has written, the machine can move its head back over it. ▸The outputs accept and reject are obtained by entering designated accepting and rejecting states, if it doesn’t enter an accepting or a rejecting state it will go on forever, never halting. ▸TM can do everything that a real computer can do. The problems that a TM can’t solve are beyond the theoretical limits of computation. Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 6. TM >> Schematic Diagram 6 ▸ A Turing Machine can both write on the tape and read from it. ▸ The read-write head can move both to the left and to the right. ▸ The tape is infinite. ▸ The special states for rejecting and accepting take effect immediately. ▸ The ˽ symbol represents blank cell. Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU control a ab b ˽ input˽
  • 7. TM >> Formal Definition 7 A Turing Machine is a 7-tuple, (Q, 𝛴, 𝛤, 𝛿, q0, qaccept, qreject), where Q, 𝛴, 𝛤 are all finite sets and ▸ Q is the set of states ▸ 𝛴 is the input alphabet not containing the blank symbol ˽ ▸ 𝛤 is the tape alphabet, where ˽ 𝜖 𝛤 and 𝛴 ⊆ 𝛤 ▸ 𝛿 : Q x 𝛤 → Q x 𝛤 x { L, R } is the transition function ▸ q0 𝜖 Q is the start state ▸ qaccept 𝜖 Q is the accept state and ▸ qreject 𝜖 Q is the reject state, where qreject ≠ qaccept Outcomes: accept, reject, or loop Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 8. TM >> Transition Function 8 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU q a b a b ˽ ˽ 𝛿(q, a) = (r, b, L) r a b b b ˽ ˽ L = left Transition Function, 𝛿(q, a) = (r, b, L) Mechanism : When the machine is in a certain state q and the head is over a tape square containing a symbol a, The machine writes the symbol b replacing the a, and goes to state r. The third component is either L or R and indicates whether the head moves to the left or right after writing.
  • 9. TM >> Languages 9 Turing-recognizable Language / Recursively Enumerable Language ▸ A language is Turing-recognizable if some Turing machine recognizes it. ▸ TM can fail to accept an input by entering the qreject state and rejecting, or by looping. This causes a problem to decide whether the machine is in looping state or taking long time to compute. Turing-decidable Language / Recursive Language ▸ Turing machines that halt on all inputs are called deciders because they always make a decision to accept or reject and such machines never loop. ▸ A language is Turing-decidable or simply decidable if some TM decides it. Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 10. TM >> L = { 0n 1n | n >= 1 } 10 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU Formal Definition Q = { q0, q1, q2, q3, q4 } Σ = { 0, 1 } 𝛤 = { 0, 1, X, Y, ˽ } 𝛿 is described the following transition table: Start state = q0 qaccept = q4 qreject = { } 0 1 X Y ˽ q0 (q1, X, R) - - (q3, Y, R) - q1 (q1, 0, R) (q2, Y, L) - (q1, Y, R) - q2 (q2, 0, L) - (q0, X, R) (q2, Y, L) - q3 - - - (q3, Y, R) (q4, B, R) q4 - - - - -
  • 11. TM >> Configuration 11 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU q a b a b ˽ ˽ 𝛿(q, a) = (r, b, L) r a b b b ˽ ˽ L = left Configuration: abqab Configuration: arbbb Start configuration: q0 w Accepting configuration: the state of the accepting configuration is qaccept Rejecting configuration: the state of the rejecting configuration is qreject Accepting and Rejecting configurations are halting configurations and do not yield further configuration. – The configuration C1 yields configuration C2 if the TM can legally go from C1 to C2 in a single step. For example, ua qi bv yields u qj acv ; if 𝛿(qi, b) = (qj, c, L) and ua qi bv yields uac qj v ; if 𝛿(qi, b) = (qj, c, R)
  • 12. TM >> Machine 1 – L = {w # w | w ∈ {0,1}* } 12 Check acceptability for the following strings: ▸ 1011#1011 ▸ 001#100 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 13. TM >> Machine 1 – L = {w # w | w ∈ {0,1}* } 13 How this machine computes … … … Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 14. TM >> Machine 1 – L = {w # w | w ∈ {0,1}* } 14 Acceptability checking: 011#011 Sequence of configurations: q1 011#011˽ x q2 11#011˽ x1 q2 1#011˽ x11 q2 #011˽ x11# q4 011˽ x11 q6 #x11˽ x1 q7 1#x11˽ x q7 11#x11˽ q7 x11#x11˽ x q111#x11˽ xx q31#x11˽ xx1 q3 #x11˽ Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU xx1# q5 x11˽ xx1#x q5 11˽ xx1# q6 xx1˽ xx1 q6 #xx1˽ xx q7 1#xx1˽ x q7 x1#xx1˽ xx q11#xx1˽ xxx q3 #xx1˽ xxx# q5 xx1˽ xxx#x q5 x1˽ xxx#xx q5 1˽ xxx#x q6 xx˽ xxx# q6 xxx˽ xxx q6 #xxx˽ xx q7 x#xxx˽ xxx q1 #xxx˽ xxx# q8 xxx˽ xxx#x q8 xx˽ xxx#xx q8 x˽ xxx#xxx q8 ˽ xxx#xxx˽ qaccept
  • 15. TM >> Machine 1 – L = {w # w | w ∈ {0,1}* } 15 Acceptability checking: 001#100 Sequence of configurations: q1 001#100˽ x q2 01#100˽ x0 q2 1#100˽ x01 q2 #100˽ x01# q4 100˽ Rejected, no transition exists. Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 16. TM >> Machine 2 – TM for Addition 16 TM for computing sum: Each number is represented as a sequence of 0’s i.e. 2 = 00, 3 = 000 Input: 0 0 0 0 c 0 0 0 // 4 + 3 Output: 0 0 0 0 0 0 0 // 7 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 17. TM >> Machine 3 – TM for Subtraction 17 TM for computing difference from bigger integer to smaller one: Each number is represented as a sequence of 0’s i.e. 2 = 00, 3 = 000 Input: 0 0 0 0 0 c 0 0 0 // 5 - 3 Output: 0 0 // 2 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 18. TM >> Machine 4 – TM for Comparator (A<B) 18 TM for comparing two numbers: Each number is represented as a sequence of 0’s i.e. 2 = 00, 3 = 000 Input: 11 0 1111 // 2 < 4 Output: 0 X X 1 1 // 1’s remain in the right side, so second argument is greater. Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 19. TM >> Machine 5 – TM for Comparator (A=B) 19 TM for comparing two numbers: Each number is represented as a sequence of 0’s i.e. 2 = 00, 3 = 000 Input: 111 0 111 // 3 = 3 Output: XXX0XXX // no 1’s remain in both sides, so A=B Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 20. TM >> Machine 6 – L = {0n 1n 2n | n >=1 } 20 Check acceptability for the following strings: ▸ 001122 ▸ 0001112222 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 21. TM >> Machine 7 – L = { an bm an+m | n,m >=1 } 21 Check acceptability for the following strings: ▸ aabbbaaaaa ▸ aabaaaa Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 22. TM >> Machine 8 – L = {wwr | w ∈ {0,1}* } 22 Check acceptability for the following strings: ▸ 00111100 ▸ 10100101 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 23. TM >> Machine 9 – L = {ww | w ∈ {0,1}* } 23 Check acceptability for the following strings: ▸ 101101 ▸ 101110 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 24. TM >> Machine 10 – L = {ai dj ck | i>j>k and k>=1} 24 Check acceptability for the following strings: ▸ aaabbc ▸ aabbccc Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 25. TM >> Machine 11 – L = {ai dj ck | i<j<k and i>=1} 25 Check acceptability for the following strings: ▸ aaabbc ▸ abbccc Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 26. TM >> Machine 12 – L = { 02 𝑛 | n >=0 } 26 Check acceptability for the following strings: ▸ 0000 ▸ 00000 Mohammad Imam Hossain | Lecturer, Dept. of CSE | UIU
  • 27. 27 References: - Chapter 3(section 3.1), Introduction to the Theory of Computation, 3rd Edition by Michael Sipser - Reference website: https://www.geeksforgeeks.org/turing-machine-in-toc/ THANKS! Any questions? You can find me at imam@cse.uiu.ac.bd