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

5 Unit Theory

Uploaded by

galampriya9743
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

5 Unit Theory

Uploaded by

galampriya9743
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

1) 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 a nbncn 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= {a b c |n>=0}
n n n

L2= {d e f |m>=0}
m m m
L3= L1.L2
= {a b c d e f |m>=0 and n>=0} is also recursive.
n n n m m m

 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= {a b c |n>=0} n n n

L1*= { a b c ||n>=0}* is also recursive.


n n n

 Intersection and complement: If L1 and If L2 are two recursive languages, their intersection L1 ?
L2 will also be recursive. For Example:
L1= {a b c dm|n>=0 and m>=0}
n n n

L2= {a b c d |n>=0 and m>=0}


n n n n

L3=L1 ? L2
= { a b c d |n>=0} will be recursive.
n n n n

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.

2) Instantaneous Description Turing Machine


The instantaneous description is one such representation to show the acceptance and rejection of the input
string.

The below diagram shows the Turing machine for the language strings containing palindromes.
Example: Take the input string 1001.

given below is the instantaneous description for the input string 1001.

q0 1001

We start from state q0. We take the input string in our instantaneous description.

On state q0 with input symbol one, we move to state q4.

We convert the input symbol 1 to ‘y’ and move right.

We show the above transition as Yq4 001

We convert the first one to ‘y’, and the state is mentioned after ‘y’.

In the instantaneous description, We do not mention the blank symbols.

Whenever we move beyond input symbols, we assume them as blank symbols.


The below description shows the next transition

On q4, the input symbol is 0. We move right.

We show the instantaneous description as Y0q4 01.

Similarly, the next transitions are.

Y00q4 1

Y001 q4

Now we have blank as input on state q4.

Y00q5 1

Y0q3 0Y

Yq3 00Y

q3 Y00Y

Yq0 00Y

YXq1 0Y

Similarly, you try to write the remaining descriptions.

We accept the input if the instantaneous description finally had a q10 state. Otherwise, We reject the string.

3) 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.
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.”
Or in simple words we can say that “Every computation that can be carried out in the real world can be
effectively performed by a Turing Machine.”
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.

4) 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 machine can contain input symbols and blanks. It has a
head pointer that can move in any direction, it points to the cell where the input is being read.
Universal Turing Machine simulates a Turing Machine. Universal Turing Machine can be considered as
a subset of all the Turing machines, it can match or surpass other Turing machines including itself.
Universal Turing Machine is like a single Turing Machine that has a solution to all problems that is
computable. It contains a Turing Machine description as input along with an input string, runs the Turing
Machine on the input and returns a result.
The difference between Turing Machine and Universal Turing Machine are as follows:

Turing Machine Universal Turing Machine

It is a mathematical model of
Universal Turing Machine is like a single
computation it manipulates symbols
1. Turing Machine that has a solution to all
on the tape according to the rules
problem that is computable
defined

A program can be compared to a Programmable Turing Machine is called


2.
Turing Machine Universal Turing Machine

Turing machine’s temporary storage is Universal Turing Machine contains Turing


tape. The infinite cells of the Turing Machine description as input along with an
3.
machine can contain input symbols input string, runs the Turing Machine on the
and blanks. input and returns the result.

Turing machines help us understand Although developed for theoretical reasons, it


4. the fundamental limitations of helped in the development of stored program
mechanical computation power computers

A Turing machine is a formal model Universal Turing Machine provides a solution


5.
of a computer with a fixed program to problems that are computable

It does not minimize the space


6. It minimizes space complexity
complexity
Transition function which Turing
The transition function is Q × T → Q × T ×
Machine performs is defined as: δ X T
7, {L, R}, where Q is a finite set of states, T is
-> Q X T X {L,R}, where δ is the
the tape of the alphabet
transition function

In the set theory point of view, all


Turing machines form a set of the all Universal Turing Machine is a subset of all the
8.
the device that accepts type 0 Turing Machines
grammar

5) Decidability and Undecidability in TOC


Identifying languages (or problems*) as decidable, undecidable or partially decidable is a very common
question in GATE. With correct knowledge and ample experience, this question becomes very easy to
solve. Lets start with some definitions:-
Decidable language -A decision problem P is said to be decidable (i.e., have an algorithm) if the
language L of all yes instances to P is decidable. Example-
(I) (Acceptance problem for DFA) Given a DFA does it accept a given word?
(II) (Emptiness problem for DFA) Given a DFA does it accept any word?
(III) (Equivalence problem for DFA) Given two DFAs, do they accept the same language?
Undecidable language -– A decision problem P is said to be undecidable if the language L of all yes
instances to P is not decidable or a language is undecidable if it is not decidable. An undecidable language
maybe a partially decidable language or something else but not decidable. If a language is not even
partially decidable , then there exists no Turing machine for that language.
Partially decidable or Semi-Decidable Language -– A decision problem P is said to be semi-decidable
(i.e., have a semi-algorithm) if the language L of all yes instances to P is RE. A language ‘L’ is partially
decidable if ‘L’ is a RE but not REC language.
Recursive language(REC) – A language ‘L’ is said to be recursive if there exists a Turing machine
which will accept all the strings in ‘L’ and reject all the strings not in ‘L’. The Turing machine will halt
every time and give an answer(accepted or rejected) for each and every string input. A language ‘L’ is
decidable if it is a recursive language. All decidable languages are recursive languages and vice-versa.
Recursively enumerable language(RE) – A language ‘L’ is said to be a recursively enumerable
language if there exists a Turing machine which will accept (and therefore halt) for all the input strings
which are in ‘L’ but may or may not halt for all input strings which are not in ‘L’. By definition , all
REC languages are also RE languages but not all RE languages are REC languages.
Now lets solve some examples – One way to solve decidability problems is by trying to reduce an
already known undecidable problem to the given problem. By reducing a problem P1 to P2, we mean
that we are trying to solve P1 by using the algorithm used to solve P2. If we can reduce an already
known undecidable problem P1 to a given problem P2 , then we can surely say that P2 is also
undecidable. If P2 was decidable, then P1 would also be decidable but that becomes a contradiction
because P1 is known to be undecidable.

6) Halting Problem
Introduction
Halting means that the system will either accept or halt(reject) a certain input to avoid entering an infinite loop.
The decision of whether or not a specific Turning machine should halt is known as the Halting Problem of
Turning Machines.
The halting problem is one of the most well-known problems proven to be undecidable. In this article, we will
learn about the Halting Problem in the Theory of Computation.

What is the Halting Problem?


The Halting Problem is determining whether a computer program will eventually stop or run forever. Creating
a general algorithm that can accurately predict this for all programs is impossible. Alan Turing's proof showed
no way to solve the Halting Problem for all cases.
Before moving on to the proof, let's first understand some terms.
1. Turing Machine
A Turing machine is a computational mathematical model. It is a type of CPU that controls all data
manipulation performed by a computer. Turing machines can be either halting or non-halting, depending on
the algorithm and the input associated with the algorithm.
2. Decision Problems
A decision problem has only two possible outcomes (yes or no) on any input. In computability and
computational complexity theories, a decision problem for a given program can be expressed as a yes/no
question of the input values.
3. Computability theory
An undecidable problem is a sort of computational problem requiring a yes/no answer but where no computer
program can give the proper answer all of the time; that is, any possible algorithm or program would
sometimes give the wrong answer or run forever without providing any answer.

Proof by Contradiction
Step 1: Assume we can create a machine called HM(P, I), where HM is the Halting machine, P is the program,
and I is the input. After receiving both inputs, the machine HM will output whether or not the program P
terminates.

Step 2: Now, create an inverted halting machine IM that takes a program P as input and,
 Loops forever If HM returns YES.
 Halts if HM returns NO.
Step 3:Now, take a situation where the program IM is passed to the IM function as an input. Here, we got a
contradiction. Let's understand how.

It is impossible for the outer function to halt if its inner function is in a loop(RHS), and it is likewise
impossible for the outer function to halt even if its inner function is halting(LHS). So both conditions are non-
halting for the IM machine, despite our above assumptions.
Hence, the halting problem is undecidable.

7) P, NP, CoNP, NP hard and NP complete | Complexity Classes


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 group 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 organising similar types of problems.
fs

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:
 The solution to P problems is easy to find.
 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 problems:
1. Calculating the greatest common divisor.
2. Finding a maximum matching.
3. Merge Sort

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:
 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.
 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 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:
 If a problem X is in NP, then its complement X’ is also in CoNP.
 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 CoNP 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 a class of problems such
that every problem in NP reduces to NP-hard.
Features:
 All NP-hard problems are not in NP.
 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.
 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 hard problems
in NP.
Features:
 NP-complete problems are special as any problem in NP class can be transformed or reduced into
NP-complete problems in polynomial time.
 If one could solve an NP-complete problem in polynomial time, then one could also solve any NP
problem in polynomial time.

Complexity Characteristic feature


Class

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-complete A problem that is NP and NP-hard is NP-complete.

8) Difference between NP hard and NP complete problem

NP Problem:
The NP problems set of problems whose solutions are hard to find but easy to verify and are solved
by Non-Deterministic Machine in polynomial time.
NP-Hard Problem:
A Problem X is NP-Hard if there is an NP-Complete problem Y, such that Y is reducible to X in
polynomial time. NP-Hard problems are as hard as NP-Complete problems. NP-Hard Problem need not
be in NP class.
If every problem of NP can be polynomial time reduced to it called as NP Hard.

A lot of times takes the particular problem solve and reducing different problems.

example :
1. Hamiltonian cycle .
2. optimization problem .
3. Shortest path
NP-Complete Problem:
A problem X is NP-Complete if there is an NP problem Y, such that Y is reducible to X in polynomial
time. NP-Complete problems are as hard as NP problems. A problem is NP-Complete if it is a part of
both NP and NP-Hard Problem. A non-deterministic Turing machine can solve NP-Complete problem
in polynomial time.

A problem is np-complete when it is both np and np hard combines together.

this means np complete problems can be verified in polynomial time.

Example:
1. Decision problems.
2. Regular graphs.

9)Difference between NP-Hard and NP-Complete :


NP-hard NP-Complete

NP-Hard problems(say X) can be solved if


NP-Complete problems can be solved by a non-
and only if there is a NP-Complete
deterministic Algorithm/Turing Machine in
problem(say Y) that can be reducible into X
polynomial time.
in polynomial time.

To solve this problem, it do not have to be To solve this problem, it must be both NP and NP-
in NP . hard problems.

Time is unknown in NP-Hard. Time is known as it is fixed in NP-Hard.

NP-hard is not a decision problem. NP-Complete is exclusively a decision problem.

Not all NP-hard problems are NP-complete. All NP-complete problems are NP-hard

Do not have to be a Decision problem. It is exclusively a Decision problem.

It is optimization problem used. It is Decision problem used.

Example: Determine whether a graph has a


Example: Halting problem, Vertex cover Hamiltonian cycle, Determine whether a Boolean
problem, etc. formula is satisfiable or not, Circuit-satisfiability
problem, etc.

You might also like