Open In App

Construct a Turing Machine for language L = {a^n b^m c^nm where n >=0 and m >= 0}

Last Updated : 24 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Prerequisite – Turing Machine The language L = {anbmcnm | n >= 0 and m>=0} represents a kind of language where we use only 3 symbols, i.e., a, b and c. In the beginning, language has n number of a’s followed by m number of b’s and then n*m number of c’s. Any such string which falls in this category will be accepted by this language. 

Examples:

Input : abbcc
Output : YES

Input : abbbcc
Output : NO

Input : \epsilon or empty stringOutput : YES 

The basic Representation is as follows: 

  

Start of Computation : The tape contains the input string w, the tape head is on the leftmost symbol of w, and the Turing machine is in the start state Q0. 

Basic Idea : The tape head reads the leftmost symbol of w, which is a and at start only we will make it Blank. Then we will traverse to make leftmost b a $ and replace rightmost c by a Blank, we will do this zigzag pattern of replacing b by $ and c by Blank till all b are not replaced by $.After this we will traverse back in left direction till we get leftmost a and replacing all $ by b in the traversal. After this we have reduced our string into form an-1bmcnm-m so we can figure if all a’s are replaced by blankand if the string belongs to Language L then there will be no c’s left hence it will get accepted.

 

Meanings of symbols used: R, L – direction of movement of one unit on either side. B-Blank, a, b, c -symbols whose combination string is to be tested. $-Temporarily symbol to replace b. 

Working Procedure :

  • Step-1: We first replace leftmost a by Blank and then traverse to replace leftmost b by $ and rightmost c by Blank.Repeat this step from state Q1 till there is no more b left.
  • Step-2: After replacing all b by $ we have also replaced m rightmost c’s with Blanks and then we will traverse back to left most a and replace all $ by b’s.After this step if check the string it is now reduced to an-1bmcnm-m form.
  • Now we will repeat from step 1 till all a’s are not made Blank, but after all c’s are made blank, we encounter a Blank (B) at state Q1 which we keep as it is and go to the left most blank 
  • Step-4: So after all a’s are made blank and if the string belonged to Language L then 0 c’s must be left which we check at state Q0 and Q6 as only b’s will be left and after which if Blank is found then all c’s must have been replace by Blank as we where making c’s Blank from rightmost end of the string.
  • Step-5: So if we get a Blank symbol at state Q6 the string is accepted at final state Q7. Also if the string was empty then it will also be accepted as Blank symbol input at state Q0 then it will got to state Q7 and gets accepted.

Similar Reads

Difference between Turing machine and Universal Turing machine
Turing Machine was first described by Alan Turing in the year 1936. It was primarily invented to investigate the computability of a given problem. It accepts type-0 grammar which is Recursively Enumerable language. The Turing machine has a tape of infinite length where we can perform read and write operations. The infinite cells of the Turing machi
3 min read
Turing Machine Construction (Transducers Turing Machine) in Java
Prerequisite - Turing Machine Turing Machines can broadly be classified into two types, the Acceptors and the Transducers. Acceptor Turing Machine is an automaton used to define Turing-acceptable languages. Such a machine can be used to check whether a given string belongs to a language or not. It is defined as a 7-tuple machine. Coming to Transduc
10 min read
Construct a Turing Machine for language L = {0<sup>n</sup>1<sup>n</sup>2<sup>n</sup> | n≥1}
Prerequisite - Turing Machine The language L = {0n1n2n | n≥1} represents a kind of language where we use only 3 character, i.e., 0, 1 and 2. In the beginning language has some number of 0's followed by equal number of 1's and then followed by equal number of 2's. Any such string which falls in this category will be accepted by this language. The be
3 min read
Construct a Turing Machine for language L = {ww | w &isin; {0,1}}
Prerequisite - Turing Machine The language L = {ww | w ∈ {0, 1}} tells that every string of 0's and 1's which is followed by itself falls under this language. The logic for solving this problem can be divided into 2 parts: Finding the mid point of the string After we have found the mid point we match the symbols Example - Lets understand it with th
7 min read
Construct a Turing Machine for a language L = {aibjck | i&lt;j&lt;k or i&gt;j&gt;k} ∩ {aibjck | i&gt;j&gt;k or i&gt;j&gt;k}
Prerequisite – Turing MachineThe language L = {aibjck | i &lt; j &lt; k or i &gt; j &gt; k} ∩ {aibjck | i &gt; j &gt; k or i &gt; j &gt; k} is same as the languages L={aibjck | j &gt; max(i, k)} In this language, every string of ‘a’, ‘b’ and ‘c’ have certain number of a’s, then certain number of b’s and then certain number of c’s. Count of 1st symb
4 min read
Construct a Turing Machine for language L = {0<sup>2n</sup>1<sup>n</sup> | n&gt;=0}
Prerequisite - Turing Machine The language L = {02n1n | n &gt;= 0} represents a kind of language where we use only 2 symbols, i.e., 0 and 1. In the beginning language has some number of 0's followed by exactly half number of 1's . Any such string which falls in this category will be accepted by this language. Examples : Input : 001 Output : YES Inp
2 min read
Construct a Turing Machine for language L = {wwr | w &isin; {0, 1}}
Prerequisite - Turing Machine  The language L = {wwres | w ∈ {0, 1}} reprents a kind of language where you use only 2 character, i.e., 0 and 1. The first part of language can be any string of 0 and 1. The second part is the reverse of the first part. Combining both these parts out string will be formed. Any such string which falls in this category
5 min read
Construct Turing machine for L = {a<sup>n</sup> b<sup>m</sup> a<sup>(n+m)</sup> | n,m≥1}
L = {an bm a(n+m) | n,m≥1} represents a kind of language where we use only 2 character, i.e., a and b. The first part of language can be any number of "a" (at least 1). The second part be any number of "b" (at least 1). The third part of language is a number of "a" whose count is sum of count of a's in first part of string and count of b's in secon
3 min read
Construct a Turing machine for L = {aibjck | i&gt;j&gt;k; k &ge; 1}
Prerequisite – Turing MachineIn given language L = {aibjck | i&gt;j&gt;k; k ≥ 1}, every string of ‘a’, ‘b’ and ‘c’ have certain number of a’s, then certain number of b’s and then certain number of c’s. The condition is that count of 3rd symbols should be atleast 1. ‘a’ and ‘b’ can have thereafter be as many but count of c is less than count of ‘b’
3 min read
Construct a Turing machine for L = {a<sup>i</sup>b<sup>j</sup>c<sup>k</sup> | i&lt; j&lt; k; i &ge; 1}
Prerequisite – Turing Machine In given language L = {aibjck | i&lt; j&lt; k; i&ge; 1}, every string of ‘a’, ‘b’ and ‘c’ have certain number of a’s, then certain number of b’s and then certain number of c’s. The condition is that count of 1st symbols should be atleast 1. ‘b’ and ‘c’ can have thereafter be as many but count of a is less than count of
3 min read