01_IntroToComputation
-
Upload
ravindra-joshi -
Category
Documents
-
view
214 -
download
0
Transcript of 01_IntroToComputation
-
7/30/2019 01_IntroToComputation
1/37
A Gentle Introduction to
Theory of Computation:
Ravindra V. Joshi
-
7/30/2019 01_IntroToComputation
2/37
Goals of the session
What is meant by Computation?
A model for Computation ( Turing Machine )
Why Turing Machine is Universal?
Relevance of Church-Turing thesis
Halting theorem and its proof ( informal )
Complexity
P, NP, NP-Hard, NP-Complete
Most Important Problem in Computer Science!!
-
7/30/2019 01_IntroToComputation
3/37
Theory of Computations
What are different types of Computers (Automata ) and what
kind of problems can be solved by them?
FSM RegEx Pattern Matching
PDA CFG -> Language Parsers
TM -> TM-Languages -> All computer languages and Programs
-
7/30/2019 01_IntroToComputation
4/37
Turing Machine (Revised )
-
7/30/2019 01_IntroToComputation
5/37
Universal Turing Machine
-
7/30/2019 01_IntroToComputation
6/37
Universal Turing Machine
In other words, Any UTM with any number of Tapes and
Heads can be simulated by a 3-Tape Head in PolynomialTime
-
7/30/2019 01_IntroToComputation
7/37
How Universalis UTM ?
Church-Turing thesis : Every form of computation can be expressedas a TM with Polynomial overhead
Parallel
Real ( Precision )
Randomness
A Tape with Random Bits
Quantum Computation
Other Exotic Theories ( String Theory!!! )
Natural-BIO_Inspired
ANN, ACO, Swarm_Intelligence, Cellular Automata and otheralgorithms
Apporximate Solutions
for subset of all Inputs
for some Sub Optimal Solution
-
7/30/2019 01_IntroToComputation
8/37
UnComputability
0-Normal Idea = Input Program Output
PROGRAM TO COUNTNO OF SEMICOLONS
PROGRAM TO REVERSERS(REVERSE A STRING)
Get(s);
While( *s )
S.Push(s);
While ( !S.Empty() )
Print S.Pop();
Hello,
Hyderabad;
Hello, Bangalore;Hello, Chennai;
Hello, Mumbai;
Hello
3
olleH
-
7/30/2019 01_IntroToComputation
9/37
UnComputability
1- Idea-Program as Input =
Another Program Program Output
PROGRAM TO COUNT NO
OF SEMICOLONS
Get (S); Count = 0;
Foreach ( char c in S )
If ( c==; )Count++;
Print Count;
3
RS(REVERSE A STRING)
Get(s);
While( *s )
Stack.Push(*s);
While ( !Stack.Empty() )
Print Stack.Pop();
-
7/30/2019 01_IntroToComputation
10/37
UnComputability
Idea 2- Same-Program as Input To Itself =
Program Program Output
PROGRAM TO COUNT NO
OF SEMICOLONS
Get (S); Count = 0;
Foreach ( char c in S )
If ( c==; )Count++;
Print Count;
5
PROGRAM TO COUNT NO
OF SEMICOLONS
Get (S); Count = 0;
Foreach ( char c in S )
If ( c==; )Count++;
Print Count;
-
7/30/2019 01_IntroToComputation
11/37
UnComputabilityHello, World
Consider a program to print Hello, World
Print Hello, World Hello, World
While(true) ;
Print Hello, World;
-
7/30/2019 01_IntroToComputation
12/37
UnComputabilityDependency of
Ouptut on both Program and Input This program will print Hello, world for positive values and 0 but not
for negative values
The point is same program may print Hello, World for some data
and may not, for some other and vice versa
Get(x);
While(x != 0 )
x-- ;
Print Hello, World
Hello, World
-
7/30/2019 01_IntroToComputation
13/37
The UnComputability Problem
Given a Program P and Input I can we say whether it will print
Hello, World or not?
P
I
PRINTS_HW
If P prints HW for input
I return TRUE else
FALSE
TRUE
FALSE
-
7/30/2019 01_IntroToComputation
14/37
UnComputability Problem - Proof
Let us consider the pseudo-code for H The Undecidability
function
H( P, I )
{
If ( P halts over I )
Return Yes
Else
Return No
}
-
7/30/2019 01_IntroToComputation
15/37
UnComputabilityProof ( contd )
Let us construct a function H1 on top of H as follows
H1( P, I)
{
IF (H( P, I) == TRUE )
Print YES;
ELSE
Print Hello, World;
}
-
7/30/2019 01_IntroToComputation
16/37
UnComputability
Let us build a function H2 on top of H1.
H2( P )
{
H1(P,P)
}
Here a program is given as input to the same program.
This eliminates the need for Data.
H2(P) If a Program P ( /* when P itself is given as input to it*/) prints Hello World, it prints YES else it prints Hello, World
Now, the twist comes, what happens when we invoke
following function
H2(H2)?
-
7/30/2019 01_IntroToComputation
17/37
UnComputability( contd )
// IF H2 can print HW, then Yes
// ELSE should Print Hello, World
// CASE-A: H2(H2) will print HW I.e., H(H2,H2)==> YES
H2(H2)
H1(H2,H2)
H(H2,H2) returns TRUEH1 prints YES
Output is YES
Where is "Hello, World?"
-
7/30/2019 01_IntroToComputation
18/37
Uncomputability( Contd. )
//CASE-B: H2(H2) will not print HW i.e.,
//PRINTS(H2,H2)==>FALSE
H2(H2)
H1(H2,H2)
H(H2, H2) returns FALSE
In H1, ELSE part is executed
"Hello, World" is printed
But according to our own starting condition,
H2(H2) should not print "Hello, World"
-
7/30/2019 01_IntroToComputation
19/37
UnComputability Problem Proof
( Final )H2 is a contradiction
H2 can not exist
H1 can not exist
H can not exist
Our assumption was wrong
Hence the theorem
-
7/30/2019 01_IntroToComputation
20/37
Uncomputability Problem
Implemented in LISP
-
7/30/2019 01_IntroToComputation
21/37
UnComputability Problem
Implemented in LISP
-
7/30/2019 01_IntroToComputation
22/37
From Computability To Complexity
Given that a function is Computable by Turing Machine how
many instances of Turing Instructions will be executed?
In other words, how efficient is given function?
Given a definition of Problem, can we tell what is the
minimum number of instructions required to implement it?
-
7/30/2019 01_IntroToComputation
23/37
Some Complexity Classes
Let n be the size of input( like Length of Array ) P-Polynomial - No of steps required can be expressed as a
polynomial of (length of Array ) O(n^2)
Complement of Polynomial
Cannot expressed as Polynomial of n
Exponential of n
NP Problems whose correctness can be verified within Polynomial
number of steps
NP is not same as Complement of P, in fact it is super set of P
NP-Hard, a class of problems which are currently solvable inexponential time only, and satisfy a curious property that if one of
the problems belonging to this class can be solved, all the problems
in that class can be solved
NP-Complete : A problem that is both NP and NP-Hard
-
7/30/2019 01_IntroToComputation
24/37
Examples
P - Sorting Problem
NP Dinner Party Problem
NP Hard Finding the Hamiltonian Circuit in a Graph
NP Complete Mine Sweeper, also Dinner Party
-
7/30/2019 01_IntroToComputation
25/37
Example of NP Problem - Dinner PartyMOTHER OF ALL PARTIES
-
7/30/2019 01_IntroToComputation
26/37
But---Guests should be carefully
invited
-
7/30/2019 01_IntroToComputation
27/37
But---Guests should be carefully
invited
-
7/30/2019 01_IntroToComputation
28/37
But---Guests should be carefully
invited
-
7/30/2019 01_IntroToComputation
29/37
But---Guests should be carefully
invited
-
7/30/2019 01_IntroToComputation
30/37
Complexity Classes, Visualized
P
NP
NP-HARDNP-COMPLETE
-
7/30/2019 01_IntroToComputation
31/37
Most Important Question in
Computer Science Today Is this relation true?
http://www.claymath.org/millennium/P_vs_NP/
http://www.claymath.org/millennium/P_vs_NP/http://www.claymath.org/millennium/P_vs_NP/http://www.claymath.org/millennium/P_vs_NP/http://www.claymath.org/millennium/P_vs_NP/http://www.claymath.org/millennium/P_vs_NP/ -
7/30/2019 01_IntroToComputation
32/37
Some Historical background
http://blog.computationalcomplexity.org/2006/04/kurt-gdel-1906-
1978.html
In a letter written by Godel to Neumann, Godel raises the question
of P=NP
http://blog.computationalcomplexity.org/2006/04/kurt-gdel-1906-1978.htmlhttp://blog.computationalcomplexity.org/2006/04/kurt-gdel-1906-1978.htmlhttp://blog.computationalcomplexity.org/2006/04/kurt-gdel-1906-1978.htmlhttp://blog.computationalcomplexity.org/2006/04/kurt-gdel-1906-1978.htmlhttp://blog.computationalcomplexity.org/2006/04/kurt-gdel-1906-1978.htmlhttp://blog.computationalcomplexity.org/2006/04/kurt-gdel-1906-1978.htmlhttp://blog.computationalcomplexity.org/2006/04/kurt-gdel-1906-1978.htmlhttp://blog.computationalcomplexity.org/2006/04/kurt-gdel-1906-1978.htmlhttp://blog.computationalcomplexity.org/2006/04/kurt-gdel-1906-1978.htmlhttp://blog.computationalcomplexity.org/2006/04/kurt-gdel-1906-1978.html -
7/30/2019 01_IntroToComputation
33/37
QUESTIONS??
THANK YOU
Testing Ourselves Have we really
-
7/30/2019 01_IntroToComputation
34/37
Testing Ourselves
Have we really
understood Uncomputability
theorem1. Do we need to do all this twisting and turning? Cant be there asimpler proof?2. We reverse the functionalities of h in h1. Is this fair? Can't we
negate existence of any logic by this kind of approach? Justconsider following series functions
MoreThan100 ( P )
{
If P contains more than 100 Lines
Return TRUE
Else
Return FALSE
}
-
7/30/2019 01_IntroToComputation
35/37
Testing Ourselves
h1( P )
{
If MoreThan100( P )
Print NoElse
Print Yes
}
h2( P )
{
h1( P )
}
-
7/30/2019 01_IntroToComputation
36/37
Testing Ourselves
3. Answer following questions on programs above.
a. Is h2 necessary?
b. What will be the output when A program contains 50 lines?
150 lines?
c. hat will be output of h2(h2)? Will it not give wrong results ?Does this mean there cannot be a program to count the no. of
lines( We all know that there indeed exists a program. Then,
where did we go wrong?
4. When we map h2(p) ==> h1( p, p). Is it merely, an approach
to reduce two parameters to one? Could'nt we make h1accept only program and no data h1(p,null)? Or Program P
and Data some f(P). F may be any string transforming
function?
-
7/30/2019 01_IntroToComputation
37/37
Testing Ourselves
3. In Final step, we give H2 only as input to H2. Is this a must? If
so, why? Can't we find a simpler version?
4. Prove the Undecidability of Halting Theorem
5. This is only out-line of the Proof. Formal forms techniques
used here are known as Diagonalization and Reduction.Study them