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

AI 9 | Bayesian Network and Probabilistic Inference
AI 9 | Bayesian Network and Probabilistic InferenceAI 9 | Bayesian Network and Probabilistic Inference
AI 9 | Bayesian Network and Probabilistic InferenceMohammad Imam Hossain
 
AI 2 | Rational Agents and Problem Formulation
AI 2 | Rational Agents and Problem FormulationAI 2 | Rational Agents and Problem Formulation
AI 2 | Rational Agents and Problem FormulationMohammad Imam Hossain
 
DBMS 12 | Design theory 2 [Normalization 2]
DBMS 12 | Design theory 2 [Normalization 2]DBMS 12 | Design theory 2 [Normalization 2]
DBMS 12 | Design theory 2 [Normalization 2]Mohammad Imam Hossain
 
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
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Animesh Chaturvedi
 
1.7. eqivalence of nfa and dfa
1.7. eqivalence of nfa and dfa1.7. eqivalence of nfa and dfa
1.7. eqivalence of nfa and dfaSampath Kumar S
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)Naman Joshi
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languagesparmeet834
 
3.1,2,3 pushdown automata definition, moves &amp; id
3.1,2,3 pushdown automata   definition, moves &amp; id3.1,2,3 pushdown automata   definition, moves &amp; id
3.1,2,3 pushdown automata definition, moves &amp; idSampath Kumar S
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite AutomataRatnakar Mikkili
 
DBMS 8 | Memory Hierarchy and Indexing
DBMS 8 | Memory Hierarchy and IndexingDBMS 8 | Memory Hierarchy and Indexing
DBMS 8 | Memory Hierarchy and IndexingMohammad Imam Hossain
 

What's hot (20)

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
 
Chomsky Normal Form
Chomsky Normal FormChomsky Normal Form
Chomsky Normal Form
 
AI 9 | Bayesian Network and Probabilistic Inference
AI 9 | Bayesian Network and Probabilistic InferenceAI 9 | Bayesian Network and Probabilistic Inference
AI 9 | Bayesian Network and Probabilistic Inference
 
AI 3 | Uninformed Search
AI 3 | Uninformed SearchAI 3 | Uninformed Search
AI 3 | Uninformed Search
 
DBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship ModelDBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship Model
 
AI 2 | Rational Agents and Problem Formulation
AI 2 | Rational Agents and Problem FormulationAI 2 | Rational Agents and Problem Formulation
AI 2 | Rational Agents and Problem Formulation
 
AI 5 | Local Search
AI 5 | Local SearchAI 5 | Local Search
AI 5 | Local Search
 
DBMS 12 | Design theory 2 [Normalization 2]
DBMS 12 | Design theory 2 [Normalization 2]DBMS 12 | Design theory 2 [Normalization 2]
DBMS 12 | Design theory 2 [Normalization 2]
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
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
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
Chomsky Normal Form
Chomsky Normal FormChomsky Normal Form
Chomsky Normal Form
 
1.7. eqivalence of nfa and dfa
1.7. eqivalence of nfa and dfa1.7. eqivalence of nfa and dfa
1.7. eqivalence of nfa and dfa
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
3.1,2,3 pushdown automata definition, moves &amp; id
3.1,2,3 pushdown automata   definition, moves &amp; id3.1,2,3 pushdown automata   definition, moves &amp; id
3.1,2,3 pushdown automata definition, moves &amp; id
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
DBMS 8 | Memory Hierarchy and Indexing
DBMS 8 | Memory Hierarchy and IndexingDBMS 8 | Memory Hierarchy and Indexing
DBMS 8 | Memory Hierarchy and Indexing
 
Cache coherence ppt
Cache coherence pptCache coherence ppt
Cache coherence ppt
 

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
 
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
 
C012111419
C012111419C012111419
C012111419
 
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...
 
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
 
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
 
Penyelesaian masalah
Penyelesaian masalahPenyelesaian masalah
Penyelesaian masalah
 

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

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
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
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
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
 
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
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
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
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
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
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
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
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
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
 
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
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 

Recently uploaded (20)

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
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
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
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
 
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
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
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
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
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
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.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
 
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 🔝✔️✔️
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.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