- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Construct a Turing Machine for L = {a^n b^n | n>=1}
The Turing machine (TM) is more powerful than both finite automata (FA) and pushdown automata (PDA). They are as powerful as any computer we have ever built.
Formal Definition of Turing Machine
A Turing machine can be formally described as seven tuples
(Q,X, Σ, δ,q0,B,F)
Where,
Q is a finite set of states
X is the tape alphabet
Σ is the input alphabet
δ is a transition function: δ:QxX→QxXx{left shift, right shift}
q0 is the initial state
B is the blank symbol
F is the final state.
A Turing Machine (TM) is a mathematical model which consists of an infinite length tape divided into cells on which input is given. It consists of a head which reads the input tape. A state register stores the state of the Turing machine.
After reading an input symbol, it is replaced with another symbol, its internal state is changed, and it moves from one cell to the right or left. If the TM reaches the final state, the input string is accepted, otherwise rejected.
The Turing machine has a read/write head. So we can write on the tape.
Now, let us construct a Turing machine which accepts equal number of a’s and b’s,
The language it is generated is L ={ anbn | n>=1}, the strings that are accepted by the given language is −
L= {ab, aabb, aaabbb, aaaabbbb,………}
Example
Consider n=3 so, a3b3 , the tape looks like −
B= blank
We need to convert every ‘a’ as X and every ‘b’ as Y. If the Turing machine contains an equal number of X and Y then it reaches the final state.
Step 1 − Consider the initial state as q0. This state replace ‘a’ as X and move to right, now state changes for q0 toq1, so the transition function is −
δ(q0, a) = (q1,X,R)
Step 2 − Move right until you see the blank symbol.
δ(q1, a) = (q1,a,R) δ(q1, b) = (q1,b,R)
After reaching the blank symbol B, move left and change the state to q2, because we need to change the last ‘b’ to Y.
δ(q1, B) = (q2,B,L) //1st iteration δ(q1, Y) = (q2,Y,L) // remaining iterations
Step 3 − When we see the symbol ‘b’, replace it as Y and change the state to q3 and move left.
δ(q2, B) = (q3,Y,L)
Step 4 − Move to left until reach the symbol X.
δ(q3, a) = (q3,a,L) δ(q3, b) = (q3,b,L)
When we reach X move right and change the state as q0, and the next iteration is started.
After replacing every ‘a’ and ‘b’ as X and Y by changing the states to q0 to q4, we get the following −
δ(q0, Y) = (q4,Y,N)
N represents No movement.
X | X | X | Y | Y | Y | B | B | ....................... |
q4 is the final state and q0 is the initial state of the Turing Machine, the intermediate states are q1, q2, q3.
Transition diagram
The transition diagram for Turing Machine is as follows −
- Related Articles
- Construct a Turing Machine for language L = {0n1n2n | n≥1}
- Construct Turing machine for L = {an bm a(n+m) - n,m≥1} in C++
- Construct a Turing Machine for language L = {wwr | w ∈ {0, 1}}
- Construct PDA for L = {0n1m2(n+m) | m,n >=1}
- Construct Deterministic PDA for a^n b^n where n>=1
- Construct a Turing machine for L = {aibjck | i< j< k; i ≥ 1}
- Construct a Turing machine for L = {aibjck | i>j>k; k ≥ 1}
- Construct a Turing Machine for language L = {ww | w ∈ {0,1}}
- Construct PDA for accepting L = {anb(2n) | n>=1} U {anbn | n>=1}
- Construct a Turing machine for L = {aibjck | i*j = k; i, j, k ≥ 1}
- Construct a PDA for language L = {0n 1m2m3n | n>=1, m>=1}
- If \( a=x^{m+n} y^{l}, b=x^{n+l} y^{m} \) and \( c=x^{l+m} y^{n} \), prove that \( a^{m-n} b^{n-1} c^{l-m}=1 . \)
- Construct Turing machine for addition
- Construct Turing machine for subtraction
- Construct DPDA for a(n+m)bmcn n,m≥1 in TOC
