0% found this document useful (0 votes)
143 views

Unit-3 TOC

The document describes the Turing machine, which was invented in 1936 by Alan Turing. A Turing machine is an abstract computing device that can simulate any computer algorithm, accepting inputs and producing outputs. It consists of a tape divided into cells, a head that reads and writes symbols on the tape, a finite set of internal states, and a set of transition rules determining the machine's behavior. The transition rules define how the machine's state and tape contents change based on the current state and symbol read by the head. Examples are given of Turing machines that accept specific formal languages.

Uploaded by

sageranimesh20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
143 views

Unit-3 TOC

The document describes the Turing machine, which was invented in 1936 by Alan Turing. A Turing machine is an abstract computing device that can simulate any computer algorithm, accepting inputs and producing outputs. It consists of a tape divided into cells, a head that reads and writes symbols on the tape, a finite set of internal states, and a set of transition rules determining the machine's behavior. The transition rules define how the machine's state and tape contents change based on the current state and symbol read by the head. Examples are given of Turing machines that accept specific formal languages.

Uploaded by

sageranimesh20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Turing Machine

Turing machine was invented in 1936 by Alan Turing. It is an accepting device which
accepts Recursive Enumerable Language generated by type 0 grammar.

There are various features of the Turing machine:

1. It has an external memory which remembers arbitrary long sequence of input.


2. It has unlimited memory capability.
3. The model has a facility by which the input at left or right on the tape can be read
easily.
4. The machine can produce a certain output based on its input. Sometimes it may
be required that the same input has to be used to generate the output. So in this
machine, the distinction between input and output has been removed. Thus a
common set of alphabets can be used for the Turing machine.

Formal definition of Turing machine


A Turing machine can be defined as a collection of 7 components:

Q: the finite set of states


∑: the finite set of input symbols
T: the tape symbol
q0: the initial state
F: a set of final states
B: a blank symbol used as a end marker for input
δ: a transition or mapping function.

The mapping function shows the mapping from states of finite automata and input
symbol on the tape to the next states, external symbols and the direction for moving the
tape head. This is known as a triple or a program for turing machine.

1. (q0, a) → (q1, A, R)

That means in q0 state, if we read symbol 'a' then it will go to state q1, replaced a by X
and move ahead right(R stands for right).

Example:
Construct TM for the language L ={0n1n} where n>=1.

Solution:

We have already solved this problem by PDA. In PDA, we have a stack to remember the
previous symbol. The main advantage of the Turing machine is we have a tape head which
can be moved forward or backward, and the input tape can be scanned.

The simple logic which we will apply is read out each '0' mark it by A and then move ahead
along with the input tape and find out 1 convert it to B. Now, repeat this process for all
a's and b's.

Now we will see how this turing machine work for 0011.

The simulation for 0011 can be shown as below:

Now, we will see how this turing machine will works for 0011. Initially, state is q0 and
head points to 0 as:

The move will be δ(q0, 0) = δ(q1, A, R) which means it will go to state q1, replaced 0 by
A and head will move to the right as:

The move will be δ(q1, 0) = δ(q1, 0, R) which means it will not change any symbol,
remain in the same state and move to the right as:

The move will be δ(q1, 1) = δ(q2, B, L) which means it will go to state q2, replaced 1 by B
and head will move to left as:
Now move will be δ(q2, 0) = δ(q2, 0, L) which means it will not change any symbol,
remain in the same state and move to left as:

The move will be δ(q2, A) = δ(q0, A, R), it means will go to state q0, replaced A by A and
head will move to the right as:

The move will be δ(q0, 0) = δ(q1, A, R) which means it will go to state q1, replaced 0 by
A, and head will move to right as:

The move will be δ(q1, B) = δ(q1, B, R) which means it will not change any symbol,
remain in the same state and move to right as:

The move will be δ(q1, 1) = δ(q2, B, L) which means it will go to state q2, replaced 1 by B
and head will move to left as:

The move δ(q2, B) = (q2, B, L) which means it will not change any symbol, remain in the
same state and move to left as:
Now immediately before B is A that means all the 0?s are market by A. So we will move
right to ensure that no 1 is present. The move will be δ(q2, A) = (q0, A, R) which means it
will go to state q0, will not change any symbol, and move to right as:

The move δ(q0, B) = (q3, B, R) which means it will go to state q3, will not change any
symbol, and move to right as:

The move δ(q3, B) = (q3, B, R) which means it will not change any symbol, remain in the
same state and move to right as:

The move δ(q3, Δ) = (q4, Δ, R) which means it will go to state q4 which is the HALT state
and HALT state is always an accept state for any TM.

The same TM can be represented by Transition Diagram:

Basic Model of Turing machine


The turning machine can be modelled with the help of the following representation.
1. The input tape is having an infinite number of cells, each cell containing one input
symbol and thus the input string can be placed on tape. The empty tape is filled by blank
characters.

2. The finite control and the tape head which is responsible for reading the current input symbol.
The tape head can move to left to right.

3. A finite set of states through which machine has to undergo.

4. Finite set of symbols called external symbols which are used in building the logic of
turing machine.

Language accepted by Turing machine


The turing machine accepts all the language even though they are recursively enumerable.
Recursive means repeating the same set of rules for any number of times and enumerable
means a list of elements. The TM also accepts the computable functions, such as addition,
multiplication, subtraction, division, power function, and many more.

Example:
Construct a turing machine which accepts the language of aba over ∑ = {a, b}.

Solution:

We will assume that on input tape the string 'aba' is placed like this:
The tape head will read out the sequence up to the Δ characters. If the tape head is
readout 'aba' string then TM will halt after reading Δ.

Now, we will see how this turing machine will work for aba. Initially, state is q0 and head
points to a as:

The move will be δ(q0, a) = δ(q1, A, R) which means it will go to state q1, replaced a by A and
head will move to right as:

The move will be δ(q1, b) = δ(q2, B, R) which means it will go to state q2, replaced b by B and
head will move to right as:

The move will be δ(q2, a) = δ(q3, A, R) which means it will go to state q3, replaced a by A and
head will move to right as:

The move δ(q3, Δ) = (q4, Δ, S) which means it will go to state q4 which is the HALT state and
HALT state is always an accept state for any TM.

The same TM can be represented by Transition Table:


States A b Δ

q0 (q1, A, R) – –

q1 – (q2, B, R) –

q2 (q3, A, R) – –

q3 – – (q4, Δ, S)

q4 – – –

The same TM can be represented by Transition Diagram:

Examples of TM
Example 1:
Construct a TM for the language L = {0n1n2n} where n≥1

Solution:

L = {0n1n2n | n≥1} represents language where we use only 3 character, i.e., 0, 1 and 2. In
this, some number of 0's followed by an equal number of 1's and then followed by an
equal number of 2's. Any type of string which falls in this category will be accepted by this
language.
The simulation for 001122 can be shown as below:Skip Ad

Now, we will see how this Turing machine will work for 001122. Initially, state is q0 and
head points to 0 as:

The move will be δ(q0, 0) = δ(q1, A, R) which means it will go to state q1, replaced 0 by A and
head will move to the right as:

The move will be δ(q1, 0) = δ(q1, 0, R) which means it will not change any symbol, remain in the
same state and move to the right as:

The move will be δ(q1, 1) = δ(q2, B, R) which means it will go to state q2, replaced 1 by B
and head will move to right as:

The move will be δ(q2, 1) = δ(q2, 1, R) which means it will not change any symbol, remain
in the same state and move to right as:
The move will be δ(q2, 2) = δ(q3, C, R) which means it will go to state q3, replaced 2 by C
and head will move to right as:

Now move δ(q3, 2) = δ(q3, 2, L) and δ(q3, C) = δ(q3, C, L) and δ(q3, 1) = δ(q3, 1, L) and δ(q3, B)
= δ(q3, B, L) and δ(q3, 0) = δ(q3, 0, L), and then move δ(q3, A) = δ(q0, A, R), it means will go to
state q0, replaced A by A and head will move to right as:

The move will be δ(q0, 0) = δ(q1, A, R) which means it will go to state q1, replaced 0 by
A, and head will move to right as:

The move will be δ(q1, B) = δ(q1, B, R) which means it will not change any symbol, remain
in the same state and move to right as:

The move will be δ(q1, 1) = δ(q2, B, R) which means it will go to state q2, replaced 1 by B
and head will move to right as:
The move will be δ(q2, C) = δ(q2, C, R) which means it will not change any symbol, remain in the
same state and move to right as:

The move will be δ(q2, 2) = δ(q3, C, L) which means it will go to state q3, replaced 2 by C and
head will move to left until we reached A as:

immediately before B is A that means all the 0's are market by A. So we will move right to
ensure that no 1 or 2 is present. The move will be δ(q2, B) = (q4, B, R) which means it will
go to state q4, will not change any symbol, and move to right as:

The move will be (q4, B) = δ(q4, B, R) and (q4, C) = δ(q4, C, R) which means it will not
change any symbol, remain in the same state and move to right as:

The move δ(q4, X) = (q5, X, R) which means it will go to state q5 which is the HALT state
and HALT state is always an accept state for any TM.
The same TM can be represented by Transition Diagram:

Example 2:
Construct a TM machine for checking the palindrome of the string of even length.

Solution:

Firstly we read the first symbol from the left and then we compare it with the first symbol
from right to check whether it is the same.

Again we compare the second symbol from left with the second symbol from right. We
repeat this process for all the symbols. If we found any symbol not matching, we cannot
lead the machine to HALT state.

Suppose the string is ababbabaΔ. The simulation for ababbabaΔ can be shown as follows:
Now, we will see how this Turing machine will work for ababbabaΔ. Initially, state is q0
and head points to a as:

We will mark it by * and move to right end in search of a as:

We will move right up to Δ as:

We will move left and check if it is a:

It is 'a' so replace it by Δ and move left as:


Now move to left up to * as:

Move right and read it

Now convert b by * and move right as:

Move right up to Δ in search of b as:

Move left, if the symbol is b then convert it into Δ as:

Now move left until * as:


Replace a by * and move right up to Δ as:

We will move left and check if it is a, then replace it by Δ as:

It is 'a' so replace it by Δ as:

Now move left until *

Now move right as:


Replace b by * and move right up to Δ as:

Move left, if the left symbol is b, replace it by Δ as:

Move left till *

Move right and check whether it is Δ

Go to HALT state

The same TM can be represented by Transition Diagram:


Example 3:
Construct a TM machine for checking the palindrome of the string of odd length.

Solution:

Firstly we read the first symbol from left and then we compare it with the first symbol
from right to check whether it is the same.

Again we compare the second symbol from left with the second symbol from right. We
repeat this process for all the symbols. If we found any symbol not matching, we lead the
machine to HALT state.

Suppose the string is 00100Δ. The simulation for 00100Δ can be shown as follows:

Now, we will see how this Turing machine will work for 00100Δ. Initially, state is q0 and
head points to 0 as:
Now replace 0 by * and move right as:

Move right up to Δ as:

Move left and replace 0 by Δ and move left:

Now move left up to * as:

Move right, convert 0 by * and then move right as:

Moved right up to Δ
Move left and replace 0 by Δ as:

Move left till * as:

Move right and convert 1 to * as:

Move left

Since it is *, goto HALT state.

The same TM can be represented by Transition Diagram:


Example 4:
Construct TM for the addition function for the unary number system.

Solution:

The unary number is made up of only one character, i.e. The number 5 can be written in
unary number system as 11111. In this TM, we are going to perform the addition of two
unary numbers.

For example

2 + 3
i.e. 11 + 111 = 11111

If you observe this process of addition, you will find the resemblance with string
concatenation function.

In this case, we simply replace + by 1 and move ahead right for searching end of the string
we will convert last 1 to Δ.

Input: 3+2

The simulation for 111+11Δ can be shown as below:


Move right up to + sign as:

Convert + to 1 and move right as:

Now, move right

Again move right

Now Δ has encountered, so just move left as:


Convert 1 to Δ

Thus the tape now consists of the addition of two unary numbers.

The TM will look like as follows:

Here, we are implementing the function of f(a + b) = c. We assume a and b both are non
zero elements.

Example 5:
Construct a TM for subtraction of two unary numbers f(a-b) = c where a is always greater
than b.

Solution: Here we have certain assumptions as the first number is greater than the second
one. Let us assume that a = 3, b = 2, so the input tape will be:
We will move right to - symbol as perform reduction of a number of 1's from the first
number. Let us look at the simulation for understanding the logic:

Move right up to - as:

Move right and convert 1 to * as:

Now move left

Again move left

Convert 1 to * and move right-hand


Now move right till 1

Convert 1 to * and move left

Convert 1 to * and move

Move right till Δ as:

Now we are in the HALT state.


Thus we get 1 on the input tape as the answer for f(3-2).

The Turing machine will look like this:

Introduction to Undecidability
In the theory of computation, we often come across such problems that are answered
either 'yes' or 'no'. The class of problems which can be answered as 'yes' are called solvable
or decidable. Otherwise, the class of problems is said to be unsolvable or undecidable.

Undecidability of Universal Languages:


The universal language Lu is a recursively enumerable language and we have
to prove that it is undecidable (non-recursive).

Theorem: Lu is RE but not recursive.

Proof:Consider that language Lu is recursively enumerable language. We will assume that


Lu is recursive. Then the complement of Lu that is L`u is also recursive. However, if we have
a TM M to accept L`u then we can construct a TM Ld. But Ld the diagonalization language
is not RE. Thus our assumption that Lu is recursive is wrong (not RE means not recursive).
Hence we can say that Lu is RE but not recursive. The construction of M for Ld is as shown
in the following diagram:
Undecidable Problem about Turing Machine
In this section, we will discuss all the undecidable problems regarding turing machine. The
reduction is used to prove whether given language is desirable or not. In this section, we
will understand the concept of reduction first and then we will see an important theorem
in this regard.

Reduction
Reduction is a technique in which if a problem P1 is reduced to a problem P2 then any
solution of P2 solves P1. In general, if we have an algorithm to convert an instance of a
problem P1 to an instance of a problem P2 that have the same answer then it is called as
P1 reduced P2. Hence if P1 is not recursive then P2 is also not recursive. Similarly, if P1 is
not recursively enumerable then P2 also is not recursively enumerable.

Theorem: if P1 is reduced to P2 then

1. If P1 is undecidable, then P2 is also undecidable.


2. If P1 is non-RE, then P2 is also non-RE.

Proof:OOPs Concepts in Java

1. Consider an instance w of P1. Then construct an algorithm such that the algorithm
takes instance w as input and converts it into another instance x of P2. Then apply
that algorithm to check whether x is in P2. If the algorithm answer 'yes' then that
means x is in P2, similarly we can also say that w is in P1. Since we have obtained
P2 after reduction of P1. Similarly if algorithm answer 'no' then x is not in P2, that
also means w is not in P1. This proves that if P1 is undecidable, then P1 is also
undecidable.
2. We assume that P1 is non-RE but P2 is RE. Now construct an algorithm to reduce
P1 to P2, but by this algorithm, P2 will be recognized. That means there will be a
Turing machine that says 'yes' if the input is P2 but may or may not halt for the
input which is not in P2. As we know that one can convert an instance of w in P1
to an instance x in P2. Then apply a TM to check whether x is in P2. If x is accepted
that also means w is accepted. This procedure describes a TM whose language is
P1 if w is in P1 then x is also in P2 and if w is not in P1 then x is also not in P2. This
proves that if P1 is non-RE then P2 is also non-RE.

Empty and non empty languages:


There are two types of languages empty and non empty language. L et Le denotes an
empty language, and Lne denotes non empty language. Let w be a binary string, and Mi
be a TM. If L(Mj) = Ф then Mi does not accept input then w is in Le. Similarly, if L(Mj) is not
the empty language, then w is in Lne. Thus we can say that

Le = {M | L(M) = Ф}
Lne = {M | L(M) ≠ Ф}

Both Le and Lne are the complement of one another.

What are the Turing machine variations in TOC?


Turing machines (TM) can also be deterministic or non-deterministic, but this does not
make them any more or less powerful.
However, if the tape is restricted so that you can only see use of the part of the tape with
the input, the TM becomes less powerful (linear bounded automata) and can only
recognise context sensitive languages.
Many other TM variations are equivalent to the original TM. This includes the following −

• Multi-track

• Multi-tape

• Multi-head

• Multi-dimensional tape
• The off-line Turing machine
Multi-tape Turing Machine
A Turing machine with several tapes we call it a multi tape Turing machine.
Every tape’s have their own Read/Write head
For N-tape Turing Machine
M={( Q,X, ∑,δ,q0,B,F)}
We define
δ=QxXN ->Q x XN x {L,R}N
Example
If n=2 with current configuration δ(q0,a,e)=(q1,X,Y,L,R)

δ=QxXN ->Q x XN x {L,R}N


Non Deterministic Turing Machine
It is similar to DTM except that for any input and current state it has a number of choices.
A string is accepted by a NDTM if there is a sequence of moves that leads to a final state
The Transition function −
=Q x X ->2QxXx(L,R)
A NDTM is allowed to have more than one transition for a given tape symbol.
Multi-head Turing machine
It has a number of heads instead of one.
Each head independently reads/ writes symbols and moves left/right or keeps stationery.
Off-line Turing Machine
An offline Turing machine has two tapes, which are as follows −

• One tape is read-only and contains the input.

• The other is read-write and is initially blank.


Types of Complexity Classes | P, NP, CoNP, NP
hard and NP complete
In computer science, there exist some problems whose solutions are not yet found,
the problems are divided into classes known as Complexity Classes. In complexity
theory, a Complexity Class is a set of problems with related complexity. These
classes help scientists to groups problems based on how much time and space they
require to solve problems and verify the solutions. It is the branch of the theory of
computation that deals with the resources required to solve a problem.
The common resources are time and space, meaning how much time the algorithm
takes to solve a problem and the corresponding memory usage.
The time complexity of an algorithm is used to describe the number of steps
required to solve a problem, but it can also be used to describe how long it takes to
verify the answer.
The space complexity of an algorithm describes how much memory is required for
the algorithm to operate.
Complexity classes are useful in organizing similar types of problems.
Types of Complexity Classes
This article discusses the following complexity classes:
1. P Class
2. NP Class
3. CoNP Class
4. NP hard
5. NP complete
P Class
The P in the P class stands for Polynomial Time. It is the collection of decision
problems(problems with a “yes” or “no” answer) that can be solved by a
deterministic machine in polynomial time.
Features:
1. The solution to P problems is easy to find.
2. P is often a class of computational problems that are solvable and
tractable. Tractable means that the problems can be solved in theory as
well as in practice. But the problems that can be solved in theory but not in
practice are known as intractable.
This class contains many natural problems like:
1. Calculating the greatest common divisor.
2. Finding a maximum matching.
3. Decision versions of linear programming.
NP Class
The NP in NP class stands for Non-deterministic Polynomial Time. It is the
collection of decision problems that can be solved by a non-deterministic machine in
polynomial time.
Features:
1. The solutions of the NP class are hard to find since they are being solved
by a non-deterministic machine but the solutions are easy to verify.
2. Problems of NP can be verified by a Turing machine in polynomial time.
Example:
Let us consider an example to better understand the NP class. Suppose there is a
company having a total of 1000 employees having unique employee IDs. Assume
that there are 200 rooms available for them. A selection of 200 employees must be
paired together, but the CEO of the company has the data of some employees who
can’t work in the same room due to some personal reasons.
This is an example of an NP problem. Since it is easy to check if the given choice of
200 employees proposed by a coworker is satisfactory or not i.e. no pair taken from
the coworker list appears on the list given by the CEO. But generating such a list
from scratch seems to be so hard as to be completely impractical.
It indicates that if someone can provide us with the solution to the problem, we can
find the correct and incorrect pair in polynomial time. Thus for the NP class
problem, the answer is possible, which can be calculated in polynomial time.
This class contains many problems that one would like to be able to solve
effectively:
1. Boolean Satisfiability Problem (SAT).
2. Hamiltonian Path Problem.
3. Graph coloring.
Co-NP Class
Co-NP stands for the complement of NP Class. It means if the answer to a problem in
Co-NP is No, then there is proof that can be checked in polynomial time.
Features:
1. If a problem X is in NP, then its complement X’ is also is in CoNP.
2. For an NP and CoNP problem, there is no need to verify all the answers at
once in polynomial time, there is a need to verify only one particular
answer “yes” or “no” in polynomial time for a problem to be in NP or
CoNP.
Some example problems for C0-NP are:
1. To check prime number.
2. Integer Factorization.
NP-hard class
An NP-hard problem is at least as hard as the hardest problem in NP and it is the
class of the problems such that every problem in NP reduces to NP-hard.
Features:
1. All NP-hard problems are not in NP.
2. It takes a long time to check them. This means if a solution for an NP-hard
problem is given then it takes a long time to check whether it is right or
not.
3. A problem A is in NP-hard if, for every problem L in NP, there exists a
polynomial-time reduction from L to A.
Some of the examples of problems in Np-hard are:
1. Halting problem.
2. Qualified Boolean formulas.
3. No Hamiltonian cycle.
NP-complete class
A problem is NP-complete if it is both NP and NP-hard. NP-complete problems are
the hardest problems in NP.
Features:
1. NP-complete problems are special as any problem in NP class can be
transformed or reduced into NP-complete problems in polynomial time.
2. If one could solve an NP-complete problem in polynomial time, then one
could also solve any NP problem in polynomial time.
Some example problems include:
1. 0/1 Knapsack.
2. Hamiltonian Cycle.
3. Satisfiability.
4. Vertex cover.
Complexity
Class Characteristic feature

P Easily solvable in polynomial time.

NP Yes, answers can be checked in polynomial time.

Co-NP No, answers can be checked in polynomial time.

All NP-hard problems are not in NP and it takes a long time to check
NP-hard them.

NP- A problem that is NP and NP-hard is NP-complete.


complete
What is the Halting Problem in TOC?
Usually, programs consist of loops that are limited or unlimited in length.
The total work done by the program completely depends on the input
given to the program.
The program may consist of several different numbers of loops that may
be in linear or nested manner.
The Halting Problem is the problem of deciding or concluding based on
a given arbitrary computer program and its input, whether that program
will stop executing or run-in an infinite loop for the given input.
The Halting Problem tells that it is not easy to write a computer program
that executes in the limited time that is capable of deciding whether a
program halts for an input.
In addition to that the Halting Problem never says that it is not
practicable to determine whether a given random program is going to
halt (stop).
Generally, it asks the question like “Given a random program and an
input, conclude whether the given random program is going to halt when
that input is given”.

Write a Halting Problem


An example of writing the Halting Problem is as follows −
INPUT − Program P and a string S.
OUTPUT − if P stops on S, it returns 1.
Otherwise, if P enters into an endless loop on S, it returns 0.
Let us consider the Halting Problem called H having the solution.
Now H takes the following two inputs −

• Program P

• Input S.
If P stops on S, then H results in “halt”, otherwise H gives the result
“loop”.
The diagrammatic representation of H is as follows −
Example
ATM = {(M,w) | M is a TM and M halts at input w }.
We can build a universal Turing machine which can simulate any Turing
machine on any input.
Let’s consider TM which recognizing the Altering Turing Machine (ATM)

Recognize-ATM (<M,w>)
Simulate M using UTM till it halts
If M halts and accept then
Accept
Else
Reject
Suppose, if M goes into an infinite loop on input w, then the TM
Recognize-ATM is going to run forever which means TM is only a
recognizer, not a decider.
A decider for this problem would call a halt to simulations that loop
forever.
Now the question is whether an ATM is TM decidable is equivalent to
asking the question whether we can tell if a TM M will halt on input w.
Because of this, both versions of this question are generally called the
halting problem.

Recursive and Recursive


Enumerable Languages in TOC
Recursive Enumerable (RE) or Type -0 Language
RE languages or type-0 languages are generated by type-0
grammars. An RE language can be accepted or recognized by Turing
machine which means it will enter into final state for the strings of
language and may or may not enter into rejecting state for the
strings which are not part of the language. It means TM can loop
forever for the strings which are not a part of the language. RE
languages are also called as Turing recognizable languages.
Recursive Language (REC)
A recursive language (subset of RE) can be decided by Turing
machine which means it will enter into final state for the strings of
language and rejecting state for the strings which are not part of the
language. e.g.; L= {anbncn|n>=1} is recursive because we can construct
a turing machine which will move to final state if the string is of the
form anbncn else move to non-final state. So the TM will always halt in
this case. REC languages are also called as Turing decidable
languages. The relationship between RE and REC languages can be
shown in Figure 1.

Closure Properties of Recursive Languages


• Union: If L1 and If L2 are two recursive languages, their
union L1∪L2 will also be recursive because if TM halts for
L1 and halts for L2, it will also halt for L1∪L2.
• Concatenation: If L1 and If L2 are two recursive
languages, their concatenation L1.L2 will also be
recursive. For Example:
L1= {anbncn|n>=0}
L2= {dmemfm|m>=0}
L3= L1.L2
= {anbncndm emfm|m>=0 and n>=0} is also recursive.
• L1 says n no. of a’s followed by n no. of b’s followed by n
no. of c’s. L2 says m no. of d’s followed by m no. of e’s
followed by m no. of f’s. Their concatenation first matches
no. of a’s, b’s and c’s and then matches no. of d’s, e’s and f’s.
So it can be decided by TM.
• Kleene Closure: If L1is recursive, its kleene closure L1*
will also be recursive. For Example:
L1= {anbncn|n>=0}
L1*= { anbncn||n>=0}* is also recursive.
• Intersection and complement: If L1 and If L2 are two
recursive languages, their intersection L1 ∩ L2 will also be
recursive. For Example:
L1= {anbncndm|n>=0 and m>=0}
L2= {anbncndn|n>=0 and m>=0}
L3=L1 ∩ L2
= { anbncndn |n>=0} will be recursive.

L1 says n no. of a’s followed by n no. of b’s followed by n no. of c’s


and then any no. of d’s. L2 says any no. of a’s followed by n no. of b’s
followed by n no. of c’s followed by n no. of d’s. Their intersection
says n no. of a’s followed by n no. of b’s followed by n no. of c’s
followed by n no. of d’s. So it can be decided by turing machine, hence
recursive.
Similarly, complement of recursive language L1 which is ∑*-L1, will
also be recursive.
Note: As opposed to REC languages, RE languages are not closed under
complementation which means complement of RE language need not
be RE.

Church’s Thesis for Turing


Machine
In 1936, A method named as lambda-calculus was created by
Alonzo Church in which the Church numerals are well defined, i.e.
the encoding of natural numbers. Also in 1936, Turing machines
(earlier called theoretical model for machines) was created by Alan
Turing, that is used for manipulating the symbols of string with the
help of tape.
Church Turing Thesis :
Turing machine is defined as an abstract representation of a
computing device such as hardware in computers. Alan Turing
proposed Logical Computing Machines (LCMs), i.e. Turing’s
expressions for Turing Machines. This was done to define
algorithms properly. So, Church made a mechanical method named
as ‘M’ for manipulation of strings by using logic and mathematics.
This method M must pass the following statements:
• Number of instructions in M must be finite.
• Output should be produced after performing finite
number of steps.
• It should not be imaginary, i.e. can be made in real life.
• It should not require any complex understanding.
Using these statements Church proposed a hypothesis
called Church’s Turing thesis that can be stated as: “The
assumption that the intuitive notion of computable functions can
be identified with partial recursive functions.”
In 1930, this statement was first formulated by Alonzo Church and
is usually referred to as Church’s thesis, or the Church-Turing
thesis. However, this hypothesis cannot be proved.
The recursive functions can be computable after taking following
assumptions:
1. Each and every function must be computable.
2. Let ‘F’ be the computable function and after performing
some elementary operations to ‘F’, it will transform a new
function ‘G’ then this function ‘G’ automatically becomes
the computable function.
3. If any functions that follow above two assumptions must
be states as computable function.

Undecidability and Reducibility in TOC


Decidable Problems
A problem is decidable if we can construct a Turing machine which
will halt in finite amount of time for every input and give answer as
‘yes’ or ‘no’. A decidable problem has an algorithm to determine the
answer for a given input.
Examples
• Equivalence of two regular languages: Given two
regular languages, there is an algorithm and Turing
machine to decide whether two regular languages are
equal or not.
• Finiteness of regular language: Given a regular
language, there is an algorithm and Turing machine to
decide whether regular language is finite or not.
• Emptiness of context free language: Given a context
free language, there is an algorithm whether CFL is empty
or not.
Undecidable Problems
A problem is undecidable if there is no Turing machine which will
always halt in finite amount of time to give answer as ‘yes’ or ‘no’.
An undecidable problem has no algorithm to determine the answer
for a given input.
Examples
• Ambiguity of context-free languages: Given a context-
free language, there is no Turing machine which will
always halt in finite amount of time and give answer
whether language is ambiguous or not.
• Equivalence of two context-free languages: Given two
context-free languages, there is no Turing machine which
will always halt in finite amount of time and give answer
whether two context free languages are equal or not.
• Everything or completeness of CFG: Given a CFG and
input alphabet, whether CFG will generate all possible
strings of input alphabet (∑*)is undecidable.
• Regularity of CFL, CSL, REC and REC: Given a CFL, CSL,
REC or REC, determining whether this language is regular
is undecidable.
Note: Two popular undecidable problems are halting problem of TM
and PCP (Post Correspondence Problem). Semi-decidable Problems
A semi-decidable problem is subset of undecidable problems for
which Turing machine will always halt in finite amount of time for
answer as ‘yes’ and may or may not halt for answer as ‘no’.
Relationship between semi-decidable and decidable problem has
been shown in Figure 1 as:
Rice’s Theorem
Every non-trivial (answer is not known) problem on Recursive
Enumerable languages is undecidable.e.g.; If a language is
Recursive Enumerable, its complement will be recursive
enumerable or not is undecidable.
Reducibility and Undecidability
Language A is reducible to language B (represented as A≤B) if there
exists a function f which will convert strings in A to strings in B as:
w ɛ A <=> f(w) ɛ B
Theorem 1: If A≤B and B is decidable then A is also decidable.
Theorem 2: If A≤B and A is undecidable then B is also undecidable.
Question: Which of the following is/are undecidable?
1. G is a CFG. Is L(G)=ɸ?
2. G is a CFG. Is L(G)=∑*?
3. M is a Turing machine. Is L(M) regular?
4. A is a DFA and N is an NFA. Is L(A)=L(N)?
A. 3 only
B. 3 and 4 only
C. 1, 2 and 3 only
D. 2 and 3 only
Explanation:
• Option 1 is whether a CFG is empty or not, this problem is
decidable.
• Option 2 is whether a CFG will generate all possible
strings (everything or completeness of CFG), this problem
is undecidable.
• Option 3 is whether language generated by TM is regular
is undecidable.
• Option 4 is whether language generated by DFA and NFA
are same is decidable. So option D is correct.
Question: Which of the following problems are decidable?
1. Does a given program ever produce an output?
2. If L is context free language then L’ is also context free?
3. If L is regular language then L’ is also regular?
4. If L is recursive language then L’ is also recursive?
A. 1,2,3,4
B. 1,2
C. 2,3,4
D. 3,4
Explanation:
• As regular and recursive languages are closed under
complementation, option 3 and 4 are decidable problems.
• Context free languages are not closed under
complementation, option 2 is undecidable.
• Option 1 is also undecidable as there is no TM to
determine whether a given program will produce an
output. So, option D is correct.
Question: Consider three decision problems P1, P2 and P3. It is
known that P1 is decidable and P2 is undecidable. Which one
of the following is TRUE?
A. P3 is undecidable if P2 is reducible to P3
B. P3 is decidable if P3 is reducible to P2’s complement
C. P3 is undecidable if P3 is reducible to P2
D. P3 is decidable if P1 is reducible to P3
Explanation:
• Option A says P2≤P3. According to theorem 2 discussed,
if P2 is undecidable then P3 is undecidable. It is given that
P2 is undecidable, so P3 will also be undecidable. So
option (A) is correct.
• Option C says P3≤P2. According to theorem 2 discussed, if
P3 is undecidable then P2 is undecidable. But it is not
given in question about undecidability of P3. So
option (C) is not correct.
• Option D says P1≤P3. According to theorem 1 discussed,
if P3 is decidable then P1 is also decidable. But it is not
given in question about decidability of P3. So option (D)
is not correct.
• Option (B) says P3≤P2’. According to theorem 2
discussed, if P3 is undecidable then P2’ is undecidable.
But it is not given in question about undecidability of P3.
So option (B) is not correct.

Construct Turing machine for subtraction

A Turing machine is a seven tuples


(Q, Σ,Γ, δ,q0,qacc, qrej)
Where,

• Q is finite number of states


• Σ is the input alphabet does not contain the blank symbol t;
• Γ is the tape alphabet, where t ε Γ and Σ ⊆ Γ;
• δ: (Q × Γ) → (Q × Γ × {L, R}) is the transition function;
• q0 ε Q is the start state;
• qacc ε Q is the accept state;
• qrej ε Q is the reject state, where qrej ≠qacc.
Problem
Construct a Turing machine (TM) for subtraction of two unary integers.

Solution
Subtraction of two unary integers
3-2=1
In Turing Machine 3 represents − 111
2 represents: 11
Let ‘M’ be a symbol used to separate two integers
B 1 1 1 M 1 1 B

Here B= blank
M= Symbol used two separate two integers

Algorithm
Follow the step wise algorithm given below to construct a TM for subtraction −
Step 1 − Let’s take two unary integers as an input. We start from the initial state q0.
Step 2 − If we find the 1 in the string then go to the same state without changing the value
of 1, and go to the right of the string.
Step 3 − If we find the m symbol then ignore this symbol without changing the symbol
and go to the right of the string.
Step 4 − If we find the 1 after the pass the M symbol then change the value of 1 into the
X and go to the left of the string.
Step 5 − Then pass the symbol of M and go to the left and if we find the 1 then change
the value of 1 to X and go to the right.
Step 6 − So, this type after the symbol(M) we change all values of 1's into X and the same
total number of 1's change into the X before the symbol M.
Step 7 − Apply these steps and get the Turing machine subtraction of two unary integers.
While working with subtraction, the Turing machine considers any of the three cases
based on input given by the user.
If ‘a’ and ‘b’ are two integers, we have two consider whether −

• a>b
• a<b
• a=b
By consider all the three conditions, the final Turing machine is as follows−
Explanation of the diagram
Step 1 − Consider an input string as 110111
i.e. a=11 and b=111, according to given input a
Step 2 − Scan string from left to right.
Step 3 − Mark '1' as 'X' and then move to the right.
Step 4 − Reaching to the right of '0' and marking '1' as 'X' and moving left.
Step 5 − Reaching 'X' on left of '0' and moving one step right.
Step 6 − Again mark '1' as 'X' and then move to the right.
Step 7 − Reaching to the right of '0' and passing 'X', mark '1' as 'X' and move left.
Step 8 − Reach 'X' in the left of '0'and move one step right.
Step 9 − If there is a ‘0’ after 'X' that means all '1's are finished before '0'.
Step 10 − Pass '0', 'X' and there is '1' remaining. That is, the second number is greater
than the first one.
Step 11 − And then the final state is "a<b"

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy