A Gentle Introduction To Theory of Computation:: Ravindra V. Joshi
A Gentle Introduction To Theory of Computation:: Ravindra V. Joshi
Ravindra V. Joshi
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
Apporximate Solutions
for subset of all Inputs for some Sub Optimal Solution
UnComputability
0-Normal Idea = Input Program Output
Hello, Hyderabad; Hello, Bangalore; Hello, Chennai; Hello, Mumbai;
Hello
PROGRAM TO REVERSE RS(REVERSE A STRING) Get(s); While( *s ) S.Push(s); While ( !S.Empty() ) Print S.Pop();
olleH
UnComputability
1- Idea-Program as Input = Another Program Program Output
RS(REVERSE A STRING) Get(s); While( *s ) Stack.Push(*s); While ( !Stack.Empty() ) Print Stack.Pop(); PROGRAM TO COUNT NO OF SEMICOLONS Get (S); Count = 0; Foreach ( char c in S ) If ( c==; ) Count++; Print Count;
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; PROGRAM TO COUNT NO OF SEMICOLONS Get (S); Count = 0; Foreach ( char c in S ) If ( c==; ) Count++; Print Count;
Hello, World
Hello, World
TRUE
FALSE
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)?
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 TRUE H1 prints YES Output is YES Where is "Hello, World?"
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"
NP-Hard, a class of problems which are currently solvable in exponential 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
Examples
P - Sorting Problem NP Dinner Party Problem NP Hard Finding the Hamiltonian Circuit in a Graph NP Complete Mine Sweeper, also Dinner Party
NP P NP-COMPLETE NP-HARD
http://www.claymath.org/millennium/P_vs_NP/
QUESTIONS??
THANK YOU
Testing Ourselves Have we really understood Uncomputability theoremto do all this twisting and turning? Cant be there a 1. Do we need
2. simpler proof? We reverse the functionalities of h in h1. Is this fair? Can't we negate existence of any logic by this kind of approach? Just consider following series functions
MoreThan100 ( P ) { If P contains more than 100 Lines Return TRUE Else Return FALSE }
Testing Ourselves
h1( P ) { If MoreThan100( P ) Print No Else Print Yes }
h2( P ) {
h1( P ) }
Testing Ourselves
3. Answer following questions on programs above.
a. b.
c.
Is h2 necessary? What will be the output when A program contains 50 lines? 150 lines? 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 h1 accept only program and no data h1(p,null)? Or Program P and Data some f(P). F may be any string transforming function?
Testing Ourselves
3. 4. 5. 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? Prove the Undecidability of Halting Theorem This is only out-line of the Proof. Formal forms techniques used here are known as Diagonalization and Reduction. Study them