Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views55 pages

5 Toc

this notes is for toc unit 5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
6 views55 pages

5 Toc

this notes is for toc unit 5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 55
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, Ithas an external memory which remembers arbitrary long sequence of input. 2. Ithas 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 3: the finite set of input symbols T: the tape symbol : the initial state F: a set of final states B: a blank symbol used as a end marker for input 6: 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. (gO, a) > (q1, A, R) ‘That means in g0 state, if we read symbol ‘a’ then it will go to state ql, replaced a by X and move ahead right(R stands for right). Examp| Construct TM for the language L ={0°1"} 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 Oas: lo The move will be 8(q0, 0) = 6(q1, A, R) which means it will go to state q1, replaced 0 by A and head will move to the right as: be The move will be 8(q1, 0) = 6(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 8(q1, 1) = 6(q2, 8, L) which means it will go to state q2, replaced 1 by B and head will move to left as: po in the same state and move to left as: Now move will be 5(q2, 0) = 6(q2, 0, L) which means it will not change any symbol, remain t+, The move will be 6(q2, A) = 6(q0, A, R), it m head will move to the right as: 1eans will go to state qO, replaced A by A and be The move will be (0, 0) = (41, A, R) whic and head will move to right as: h means it will go to state ql, replaced 0 by A, The move will be 5(q1, B) = 6(q1, B, R) whic! in the same state and move to right as: h means it will not change any symbol, remain The move will be 8(q1, 1) = 6(q2, 8, L) which means it will go to state q2, replaced 1 by B and head will move to left as: be The move 8(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 8(q2, A) = (q0, A, R) which means it will go to state qO, will not change any symbol, and move to right as: ‘The move 8(q0, B) = (93, 8, R) which means it will go to state q3, will not change any symbol, and move to right as: low The move 6(q3, B) = (q3, 8, R) which means it will not change any symbol, remain in the same state and move to right as: bo The move 8(q3, 4) = (q4, 4, 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. bo The same TM can be represented by Transition Diagrai 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 QO: the initial state F: a set of final states B: a blank symbol used as 2 end marker for input 6: a transition or mapping function. (q0, a) > (ql, A.R) [90] Example 1: Construct a TM for the language L = {a" b>} where n21. Solution: L={a"br : n21} represents language where we use only 2 character, i.e., a, and b. In this, some number of a's followed by an equal number of b's Any type of string which falls in this category will be accepted by this language. To solve this we have to follow following steps:- Step 1: Let string w= aaabbb Bla al a{b |b |» [B Step 2:- Now, we will see how this Turing machine will work for aaabbb Initially, state is gO and head points to a as: ID-> BaaabbbB Bla | al af{b |v|p {|B 7 Step 3:- The move will be 8(q0, a) = 8{a1, X, R) which means it will o to state ql, replaced a by X and head will move to the right as: s os a/X,.R 1) aa » “ Cw a ID-> BXaabbbB a Step 4:- The move will be 8(q1, a) = 6(q1, a, R) which means it will not change any symbol, remain in the same state and move to the right as: ID->BXaabbbB ID-> BxaabbbeccB u OS G0} ES) Step 5:- The move will be 5(q1, b) = 8(q2, Y, L) which means it will go to state q2, replaced b by Y and head will move to left ID->BXaaYbbB 2 ‘Automata Theory And Theory of Computation Step 6:- The move will be 6(q2, a) = 6(q2, 2, L) which means it will not change any symbol, remain in the same state and move to Left as: ID->BXaaYbbB a ID->BXaaYbbB e Bi x| a| aly | b|» [B <3 @ Step 7:- Now move 5(q2, X) = 6(g0, X, R), it means will go to state q0, replaced X by X and head will move to right as: ID->BXaaYbbB e ID->BXaaYbbB Step 8:- The move will be 6(q0, a) = 6(q1, X, R) which means it will go to state ql, replaced a by X, and head will move to right as: ID->BXXaYbbB a a Step 9:- And move 8(q1, a) = 8(q1, a, R) .The move will be 8(q1, Y) = 8(q1, Y, R) which means it will not change any symbol, remain in the same state and move to right as: ID->BXXaYbbB a ID->BXXaYbbB Step 10:-Now The move will be 5(q1, b) = 8(q2, Y, L) which means it will go to state q2, replaced b by Y and head will move to Left as: ID->BXXaYYB ‘Automata Theory And Theory of Computation ee a Step 11:- Now move 8(q2, Y) = 6(q2, ¥, L) and 8(q2, a) = 6(q2, a, L) and move 6(q2, X) = 8(q0, X, R), it means will go to state q0, replaced X by X and head will move to right as: ID->BXKaYYbB a ID->BxxayYbB @ 1D->BxxaYYbB % ID->BxKaYYbB 4% ID->BXXKYYZzcB a B| x{x/x]iyl|y¥|»s |B 2 Step 12:- Repeat the same process untill ll as are replaced by X and b’s are replaced by Y ID->BXXXYYbB qu ID->BXXXYYbB qu ID->BXXXYYYB, a ID->BXXXYYYB, a2 ID->BXXXYYYB, a % ‘Automata Theory And Theory of Computation Step 13:-Immediately before X is ¥ that means all the a's are market by X and all b’s are marked by Y. After that there is B blank that means all a’s and b’s are replaced by X and Y respectively therefore move 6(q0, 8) = 8(af, 8, R).The move (q0,8}=(af,8,R) which is the Fi state or HALT state is always an accept state for any TM. ID-> BXXXYYYB oF ‘The TM can be represented by State Transition Table: qo qu a at a b x y b ai/x,r a 2 a af/b,r qiar — a2ly.r - Qiar - a2/al a go/b,r — q2/y,| - Transitions 10,91,q2,4f} YB} Initial state={q0) Finial state={af} B=Blank symbol Example Il: Construct a TM for the language L = {a"b"c"} where n21 Soluti L={a'bc’ : n21} represents language where we use only 3 character, i.e., a, b and c. In this, some number of a's followed by an equal number of b's and then followed by an equal number of c's. Any type of string which falls in this category will be accepted by this language. To solve this we have to follow following steps:- Step 1: Let string w= aaabbbece aLa[o[el[o clele|B Step 2:- Now, we will see how this Turing machine will work for aaabbbccc Initially, state is qO and head points to a as: ID-> Baaabbbece8 qo gl: [al ale [als @ Step 3:- The move will be 8(q0, a) = (43, X, R) which means it will go to state qi, replaced a by X and head will move to the right as: Jie | io | | ID-> BxaabbbeceB Step 4:- The move will be 8(q1, a) = 8(q1, a, R) which means it will not change any symbol, remain in the same state and move to the right as: ID->BXaabbbecc8 ID-> BxaabbbcccB a ‘Automata Theory And Theory of Computation 3 1 Step 5:- The move will be 8(q1, b) = 5(q2, Y, R) which means it will go to state q2, replaced b by Y and head will move to right as: ID->BXaaYbbece8 a2 Bi; X}| aj aly|biob © © B Step 6:- The move will be 6(q2, b) = 6(42, b, R) which means it will not change any symbol, remain in the same state and move to right as: ID->BXaaYbbeceB alt aly] bib ele c | B a Step 7:- The move will be 6(q2, C) = 6(43, Z, R) which means it will go to state q3, replaced c by Z and head will move to left as shown: ID->BXaaYbbZecB a3 3 ‘Step 8:- Now move 6(q3, Z) = 6(q3, Z, L} and 8(q3, b) = 6(q3, b, L) and 8(q3, ¥) = 8(q3, ¥, L) and (a3, a) = 6(a3, a, L), and then move (a3, X) = 6(q0, X, R}, it means will go to state qQ, replaced X by X and head will move to right as: ID->BXaaYbbZccB 3 ID->BXaaYbbZecB a3 ID->BXaaYbbZecB 3B ID->BXaaYbbZecB 3 ID->BXaaYbbZecB co Step 9:- The move will be 8(q0, a) = (41, X, R) which means it will go to state qi, replaced a by X, and head will move to right as: ID->BXXaYbbZccB a ‘Automata Theory And Theory of Computation eek ybbR a Awe emu CORATT = sal xxR_ Step 10:- And move 5(q2, a) = 6{q1, a, R) .The move will be 6(q1, Y) = (a1, Y, R) which ‘means it will not change any symbol, remain in the same state and move to right as: ID->BXXaYbbZccB q1 ID->BXXaYbbZccB qt pak cyber Py ly qd — Step 11:-Now The move will be 6(q1, b) = 6(q2, Y, R) which means it will go to state q2, replaced b by Y and head will move to right as: 1D->BxXaYYbZccB a ID>BxxaYYbZecB a ‘Step 12:- The move will be 6(q2, Z) = 6(@2, Z, R) which means it will not change any symbol, remain in the same state and move to right as:[91] ID->BXXaYYbZecB a YYR _ 22R gre gt a OQ (a) WEB Ae at 7h. — a aia py] =x] xT aly][¥y[»][zJ.Te Ts] s2 Step 13:- The move will be 6(42, c) = 6(q3, Z, L) which means it will go to state q3, replaced c by Zand head will move to left until we reached X as: ID->BXXaYYbZZcB 3 Step 14:- Now move 6(q3, Z) = (q3, Z, L) and 6(q3, b) = 6{q3, b, L) and 6(q3, ¥) = 6(@3, Y, L) and (a3, a) = 8(q3, a, L), and then move 6(q3, X) = 6(g0, X, R}, it means will go to state q0, replaced X by X and head will move to right as: ID->BXXaYYbZZcB ‘Automata Theory And Theory of Computation a3 ID>EXXaYYbZZeB @3 ID>BxxaYYbzzeB @3 ID>BxKaYYbZZcB 43 ID->BXKaY¥bZ2eB 3 SEDGE DoE 3 Step 15 Repeat the same process untill ll a's are replaced by X and b's. are replaced by Y ‘And c's are replaced by Z. we will get ID->BXXXYYbZZcB a ID->BXXXYYbZZcB a ID->BXXXYYYZZcB a ID->BXXXYYYZZcB a ID->BXXXYYYZZZB 3 cr AN", ter Step 16:-Immediately before X is ¥ that means all the a's are market by X. So we will move right ‘to ensure that no a,b and c is present. The move will be 6(q0, Y) = (44, Y, R) which means it will go and (a4, Y) = (a4, ¥, R) to state @4, will not change any symbol, and move to right as: ID->xXXYYYZZZB 3 ID->xXXYYYZZ2B 0 XX ID->xXXYYYZZZB a a Step 17:-The move will be (q4, Z) = 6(q5, Z, R) and (5, Z) = 6(Q5, ¥, R) which means it will not change any symbol, remain in the same state and move to right as: ID->xxXYYYZZZB at ID->XXXYYYZZB 5 ID->XXXYYYZZZB ‘Automata Theory And Theory of Computation 5 22R eee ra M6 oar, Ad bon (8) Lays Wt wal x[xTy¥l¥lTy¥Tazl2zlz[s Step 18:- The move (95,8)=(af,B,R) which is the Finial state or HALT state is always an accept state for any TM. ID->XXXYYYZZZBq5 1D- >XXXYYYZZZB ats Ts Tslvl¥lyIxIx [x Ta B ‘The TM can be represented by Transition Diagram: ‘The TM can be represented by State Transition Table: a2 ob oc x i) y 2b @ qer = = = gaye a ar avr = = Qifar = a - a/b q3/z1 = a2fer 3 93/21 43/b,1 Oh! a3/yl a3/zl— - as : - = ati afer 0s A Blt = abe Assignment ‘L.Construct 2 TM for the language L = {anbmep} where nQxT {Move Directions} Q \times \Gamma \to Q \times \Gamma \times \{ \text {Move Directions} \}QxT+QxI'x {Move Directions} In the case of a 2D MDTM, for example, the move directions might be {Up,Down,Left.Right}\{ \text{Up}, \text{Down}, \text {Left}, Mext (Right) \} (Up.Down,Left,Right}, and in a 3D MDTM, the move directions would include additional up-down, left-right, and forward-backward movements. + q0q_0q0 is the start state. + qhaliq_{\text {halt} }qhalt is the halting state, + qaccepiq_{\text {accept} }qaccept is the accepting state, The transition function d\deltad specifies how the machine moves between states based on the symbol it reads on the tape and which direction it should move Higher. mensional MDTM. Ina 3D MDTM, the tape extends to three dimensions. The head could move in one of the following directions: + Up or Down along the z-axis. + Left or Right along the x- + Forward or Backward along the y-axis. Thus, the transition function would have more possible movements (6 directions in 3D: +x, -x, ty, -y, 42, Computational Power of MDTM. + Computational Power: A multidimensional Turing machine does not increase the computational power ofa Turing machine. Whether the machine has a single tape or a multi- dimensional tape, it still recognizes exactly the same class of languages: recursively enumerable languages (RE) © However, MDTMs are more powerful in terms of ease of simulation or algorithmic expressiveness. Problems that would be difficult to express on a ‘one-dimensional tape (c.g., certain spatial or geometric problems) may be easier to model on a multidimensional tape. + Simulation by Standard Turing Machine: A standard (single-tape) Turing machine can simulate a multidimensional ‘Turing machine. For example, a 2D MDTM can be simulated by a single-tape Turing machine by encoding the 2D grid as a linear sequence. Each pair of coordinates (x,y)(X, y)(X,y) on the 2D tape can be mapped to a unique position in the one-dimensional tape (e.g., using a pairing function such as Cantor's pairing function). Similarly, a 3D MDTM can be simulated by a single-tape Turing machine with more complex encoding ‘Automata Theory And Theory of Computation Halting Problem in Theory of Computation Computation theory is a branch of computer science that studies algorithms, computation, and mathematical models of computing equipment. It investigates the capabilities and limits of computational models to determine what problems can be solved algorithmically, how efficiently ‘they may be addressed, and which issues are intrinsically intractable Infinite loop Yes Input string No. iovaWpoint The following are key principles in computing theor 1. Automata Theory concerns abstract machines and computational models such as finite automata, pushdown automata, and Turing machines. These models aid in the study of fundamental computational concepts. 2. Computability Theory: This discipline, often known as recursion theory, investigates whether problems can be addressed algorithmically. It studies Turing machines and other models to establish what is possible. 3, Intricacy Hypothesis: The resources (time, space, etc.) needed to solve computer problems are the subject of this study. It arranges issues relying upon their trouble and explores issue classes like P (polynomial-time resolvable issues) and NP (polynomial-time checked issues), among others. 4, Calculation: an examination investigates calculation effectiveness concerning reality intricacy. This study helps decide how quickly a calculation runs and how much memory it consumes as the info size increments. Advantages: 1. Understanding Computational Boundaries: It aids in defining which issues algorithms can and cannot tackle. This understanding is critical in defining computation's constraints. 2. Algorithm Design: The theory provides a foundation for creating efficient algorithms by examining their time complexity, space complexity, and overall performance, This information can now solve computational problems more quickly and effectively. 3. Itis the hypothetical supporting of software engineering, filling in as an establishment for various subfields, for example, artificial reasoning, cryptography, programming language plan, and others. 4, Issue Arrangement: It classifies issues into a few intricacy classes (e.g., P, NP, NP-complete, etc.), which helps with perceiving the natural trouble levels of issues and helps in their effective arrangement. 5. Athorough understanding of computational theory is required for many technical advancements like encryption, artificial intelligence, and data processing, Limitations: 1. Abstract Nature: Some topics in computer theory can be exceedingly abstract and may not transfer immediately into practical algorithms or implementations. It might not be easy to translate theoretical principles into real-world solutions. 2. Computational Complexity: While the theory identifies problem classes based on their complexity, it can be difficult to determine whether an issue is in P (solvable in polynomial time) or NP (verifiable in polynomial time). The 3. Real-world Constraints: Because of hardware restrictions, practical constraints, or unforeseen complexity in implementation, theoretical models may not precisely replicate real-world computing systems. imited Scope: Computation theory focuses on theoretical elements of computation and ‘may not address all real computational issues or scenarios faced in many disciplines, 5. Challenges in Application: Applying theoretical insights to real-world situations may include complexity that the theory does not directly address. Bridging the theoretical-practical divide can be difficult Halting Problem in TOC ‘The halting problem is a classic topic in Alan Turing's 1936 theory of computing. It relates to whether computer program can detect whether another arbitrary program will ultimately cease (terminate) or continue running indefinitely for a given input. Formally, the halting problem is as follows: "Given a description of 2 computer program P and its input J, is there an algorithm that can decide whether P will eventually halt (terminate) or run forever on input /2" In simpler terms, it asks if itis feasible to develop a generic algorithm that, given any program and input, can predict with confidence whether that program will eventually end running or continue indefinitely. ‘Alan Turing demonstrated that such an algorithm does not exist. He accomplished this by employing 2 demonstration by contradiction technique in which he assumed the existence of a halting oracle (an algorithm capable of solving the halting issue) and then illustrated a situation in which this hypothetical oracle would result in a contradiction, establishing its impossibility. ‘The proof simply shows that if an algorithm existed to solve the halting issue for all programs, it would result in a logical contradiction, making such an algorithm impossible to develop, This finding has far-reaching ramifications in computer science since it indicates that computers have basic constraints in terms of what they can compute. It demonstrates that there are some issues for which no algorithm can give a definite solution, regardless of its complexity. Types of Halting Problem 1. Language-Specific Stopping Issues: Example: Consider the following problem in a limited language in which programs are only made up of a loop that decrements a counter until it hits zero: Explanation: Within this constrained language, the halting issue would include determining if any given input value 1. def countdown(n): 2. whilen>0: 3 ne ‘The countdown() method would pause or loop forever if n were used. For example, predicting whether countdown(5) will end is doable; however, the issue becomes intractable with more complicated changes or inputs. 2. Probabilistic Halting Problems: Example: Analyzing the likelihood of a random program terminating: 1, import random 2, 3. def random_halt) 4, while random.random() < 0.9: 5, continue Explanation: In this case, the random_halt() method loops depending on a probability criterion. In this case, the halting issue entails determining the chance of this function terminating within a certain number of iterations or given a range of probabilities. 3. Concurrent System Halting Issues: Example: Analyzing termination in concurrent systems with several interacting processes, for example: 1. public class ConcurrentSystem { 2, public static void main(string{] args) { 3 Thread thread: \ew Thread{() > { 10. 1 2 2B. 14, 415. 16. Vv. 18. while (true) { // Process 1 operations Ms ‘Thread thread: new Thread{() > { while (true) { J/ Process 2 operations Ds thread1start(); thread2.start(); } Explanation: This entails deciding if the concurrent processes will come to a halt, deadlock, or run endlessly. Complex interactions between several threads or processes are frequently involved in the analysis of these scenarios. 4, Aland Machine Learning Problems: ‘Assessment of Convergence in Iterative Algorithms: 1 2. 9, def gradient_descent(); # Algorithm for gradient descent t.. # Apply gradient descent algorithm to optimize a mode! model while True: # Perform model optimization using gradient descent gradient_descent() Explanation: In Al or machine learning, the difficulty is identifying whether the iterative optimization process (such as gradient descent) will converge and cease or continue forever during the model training phase. 5. Stopping Issues in Quantum Computation: Analyzing Behaviors in Quantum Algorithms: 1. From qiskit, import QuantumCircuit and execute Aer. 2, 3, def quantum_algorithm(): 4, # Construct a quantum circuit for a specific algorithm 5. circu Quantumcircui(2) 6 # 7. Execute quantum circuit af 9. 410, # Running a quantum algorithm 11, quantum_algorithm() Explanation: Quantum algorithms use qubit operations and superposition. When implemented on a quantum computer, the halting issue entails deciding whether a quantum program will halt or continue forever. Post Correspondence Problem Post Correspondence Problem is a popular undecidable problem that was introduced by Emil Leon Post in 1946. It is simpler than Halting Problem. In this problem we have N number of Dominos (tiles). The aim is to arrange tiles in such order that string made by Numerators is same as string made by Denominators. In simple words, lets assume we have two lists both containing N words, aim is to find out concatenation of these words in some sequence such that both lists yield same result. Let’s try understanding this by taking ‘two lists A and B ‘A=[aa, bb, abb] and B=[aab, ba, b] Now for sequence 1, 2, 1, 3 first list will yield aabbaaabb and second list will yield same string aabbaaabb. So the solution to this PCP becomes 1, 2, 1, 3. Post Correspondence Problems can be represented in two ways: Domino's Form 8B |} _A| |ca}) [asc CA AB A Cc Table Form Numerator Denominator 1 B CA 2 A AB 3 CA A 4 ABC Cc Lets consider following examples. Example-1. a 1 111 2 10111 10 Explanation — Step-1: We will start with tile in which numerator and denominator are starting with same number, so we can start with either 1 or 2. Lets go with second tile, string made by numerator- 10111, string made by denominator is 10. Step-2: We need 1s in denominator to match 1s in numerator so we will go with first tile, string made by numerator is 10111 1, string made by denominator is 10111. Step-3: There is extra 1 in numerator to match this 1 we will add first tile in sequence, string made by numerator is now 10111 1 1, string made by denominator is 10111111, Step-4: Now there is extra 1 in denominator to match it we will add third tile, string made by numerator is 10111 1 1 10, string made by denominator is 10 111 1110. Final Solution -2113 String made by numerators: 101111110 String made by denominators: 101111110 As you can see, strings are same. Example-2: 1 100 1 2 0 100 Explanation — ‘+ Step-1: We will start from tile 1 as it is our only option, string made by numerator is 100, string made by denominator is 1 + Step-2: We have extra 00 in numerator, to balance this only way is to add tile 3 to sequence, string made by numerator is 100 1, string made by denominator is 1 00. + Step-3: There is extra 1 in numerator to balance we can either add tile 1 or tile 2. Lets try adding tile 1 first, string made by numerator is 100 1 100, string made by denominator is 1 00 1. + Step-4: There is extra 100 in numerator, to balance this we can add 1st tile again, string made by numerator is 100 1 100 100, string made by denominator is 1 00 11 1. The 6th digit in numerator string is 0 which is different from 6th digit in string made by denominator which is 1. Introduction to NP-Complete Complexity Classes NP-complete problems are a subset of the larger class of NP (nondeterministic polynomial time) problems. NP problems are a class of computational problems that can be solved in polynomial time by a non-deterministic machine and can be verified in polynomial time by a deterministic Machine. A problem Lin NP is NP-complete if all other problems in NP can be reduced to Lin polynomial time. If any NP-complete problem can be solved in polynomial time, then every problem in NP can be solved in polynomial time. NP-complete problems are the hardest problems in the NP set. Adecision problem L is NP-complete if it follow the below two properties: 1, Lis in NP (Any solution to NP-complete problems can be checked quickly, but no efficient solution is known), 1. Every problem in NP is reducible toLin polynomial time (Reduction is defined below). A problem is NP-Hard if it obeys Property 2 above and need not obey Property 1. Therefore, a problem is NP-complete if it is both NP and NP-hard. 3 NP-COMPLETE Complexity Classes Ser com plone NP-Complete Complexity Classes Decision vs Optimization Problems NP-completeness applies to the realm of decision problems. It was set up this way because it’s easier to compare the difficulty of decision problems than that of optimization problems. In reality, though, being able to solve a decision problem in polynomial time will often permit us to solve the corresponding optimization problem in polynomial time (using a polynomial number of calls to the decision problem). So, discussing the difficulty of decision problems is often really equivalent to discussing the difficulty of optimization problems. For example, consider the vertex cover problem (Given a graph, find out the minimum sized vertex set that covers all edges). It is an optimization problem. The corresponding decision problem is, given undirected graph G and k, is there a vertex cover of size k? What is Reduction? Let L1 and L2 be two decision problems. Suppose algorithm A2 solves L2. That is, ify is an input for L2 then algorithm A2 will answer Yes or No depending upon whether y belongs to L2 or not. The idea is to find a transformation from L1 to L2 so that algorithm A2 can be part of algorithm A1 to solve L1. Algorithm for Lt Yes/No} Yes/No input f Taput for k2 Jota"! og for L1 for L2 on fx) | on x Learning reduction, in general, is very important. For example, if we have library functions to solve certain problems and if we can reduce a new problem to one of the solved problems, we save a lot of time. Consider the example of a problem where we have to find the minimum product path in a given directed graph where the product of the path is the multiplication of weights of edges along the path. If we have code for Dijkstra’s algorithm to find the shortest path, we can take the log of all weights and use Dijkstra’s algorithm to find the minimum product path rather than writing a fresh code for this new problem. How to prove that a given problem is NP-complete? From the definition of NP-complete, it appears impossible to prove that a problem Lis NP- Complete. By definition, it requires us to that show every problem in NP is polynomial time reducible to L. Fortunately, there is an alternate way to prove it. The idea is to take a known NP-Complete problem and reduce it to L. If a polynomial-time reduction is possible, we can prove that L is NP-Complete by transitivity of reduction (If an NP-Complete problem is reducible to L in polynomial time, then all problems are reducible to L in polynomial time). 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: ‘AProblem 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. ‘Alot 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 ¥, 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 itis a part of both NP and NP-Hard Problem. A non-deterministic Turing machine can solve NP-Complete problem in polynomial time. problem is np-complete when itis 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. Difference between NP-Hard and NP-Complete: NP-hard NP-Hard problems(say X) can be solved if and only if there is a NP-Complete problem(say ¥) that can be reducible into X in polynomial time. To solve this problem, it do not have to be in NP Time is unknown in NP-Hard, NP-hard is not a decision problem. Not all NP-hard problems are NP-complete. Do not have to be a Decision problem, Itis optimization problem used. Example: Halting problem, Vertex cover problem, etc. NP-Complete NP-Complete problems can be solved by a non- deterministic Algorithm/Turing Machine in polynomial time. To solve this problem, it must be both NP and NP- hard problems. Time is known as its fixed in NP-Hard. NP-Complete is exclusively a decision problem. All NP-complete problems are NP-hard It is exclusively a Decision problem. Itis Decision problem used. Example: Determine whether a graph has a Hamiltonian cycle, Determine whether a Boolean formula is satisfiable or not, Circuit-satisfiability problem, etc. What is a recu e and recursively enumerable language In the context of Turing machines and formal language theory, the terms "recursive" and “recursively enumerable" (also called Turing-recognizable) refer to different classes of languages based on the computational power of Turing machines. 1. Recursive Language (Decidable Language): ‘A recursive language is a set of strings for which there exists a deciding Turing machine that halts on every input, either accepting or rejecting the string, thus determining whether the string belongs to the language. This means: ‘+ Alanguage LLL is recursive (also called decidable) if there is a Turing machine that can decide whether any given string www is in LLL by always halting + The key characteristic is that the Turing machine always halts (i.e, it will never run indefinitely). Formally, a language LLL is recursive if there exists a Turing machine MMM such that for every string www: + IFwelw \in Lwel, MMM halts and accepts www. + Ifwelw \notin Lwe/L, MMM halts and rejects www. Examples of recursive languages include: + The set of all valid programs in a particular programming language (assuming a precise definition of "valid. + The set of all even-length binary strings. 2. Recursively Enumerable Language (Turing-Recognizable Language): A recursively enumerable (RE) language is a set of strings for which there exists a Turing machine that recognizes whether a string belongs to the language. The key difference from recursive languages is that the Turing machine might not halt on strings that are not in the language. + Alanguage LLL is recursively enumerable (RE) if there exists a Turing machine MMM such that: if welw \in LweL, MMM halts and accepts www. © If wéLw \notin Lwe/L, MMM may not halt (it might run forever without providing an answer). This means that for strings in the language, the Turing machine will always eventually accept them, but for strings outside the language, the machine may loop indefinitely. Examples of recursively enumerable languages include: +The halting problem language (the set of Turing machine descriptions and inputs for which the machine halts). +The set of all valid proofs in a formal system (like Peano arithmetic). Key Differences: + Recursive languages are decidable: a Turing machine always halts and gives an answer (accept or reject). + Recursively enumerable languages are recognizable: a Turing machine can recognize members of the language (accept them), but it may not halt for strings outside the language. Explain decidable languages, undecidable languages in turing machine De lable Languages (Recursive Languages) ‘A decidable language is a language for which there exists Turing machine that can decide whether a given string is in the language in finite time. This means that for any string, the Turing machine will eventually halt and either accept or reject the string, Characteristics: + Decision process: There is a Turing machine MMM that halts on every input, meaning for every string www, it will either accept www if weLw \in LweL or reject www if weLw \notin Lwe/L. + Algorithmic solvability: A decidable language can be solved by an algorithm (a Turing machine) that always gives an answer (accepts or rejects) in finite time. Formal Definition: ‘A language LLL is decidable (also called recursive) if there exists a Turing machine MMM such that for every string www: + If welw \in Lwel, the Turing machine MMM halts and accepts www. + If welw \notin Lwe/L, the Turing machine MMM halts and rejects www. Examples of Decidable Languages: +The set of all valid programs in a specific programming language, assuming a precise definition of "valid", +The set of even-length binary strings: This can be easily checked by a Turing machine that counts the number of symbols in the string, + The set of strings over an alphabet that satisfy a regular grammar: Regular languages (defined by finite automata) are decidable because a Turing machine can simulate a finite automaton to accept or reject a string. 2. Undecidable Languages An undecidable language is a language for which there does not exist a Turing machine that can decide membership in the language for all possible input strings. In other words, no algorithm (Turing machine) can solve the problem for all inputs in finite time. Characteristics: + Non-halting for some inputs: There is no Turing machine that can decide the membership of strings in the language such that it always halts (i.e, gives an answer) for all inputs. + Unsolvability: The problem of determining whether a string belongs to an undecidable language is unsolvable by any algorithm. Formal Definition: A language LLL is undecidable if there does not exist any Turing machine MMM that, for every string www, will halt and correctly decide whether welw \in LweL. This means the Turing machine may either: ‘+ Never halt (run indefinitely), or + May give the wrong answer on some inputs (even if it halts) Examples of Undecidable Languages: 1, The Halting Problem: The classic example of an undecidable problem is the halting problem, which asks: given a Turing machine MMM and an input www, will MMM halt on input www? © There is no Turing machine that can solve this problem for all possible pairs of Turing machines and inputs. Alan Turing proved this in 1936. ‘The halting problem is undecidable because there is no general algorithm that can determine whether an arbitrary Turing machine will halt or run forever on a given input. 2. Post's Correspondence Problem: Given two lists of strings, does there exist a sequence of indices such that the strings from the first list can be concatenated to match the concatenation of the strings from the second list? This problem is undecidable. 3. The Problem of Determining Whether a Turing Machine Accepts a Given String: Even determining whether a Turing machine accepts a given string is undecidable in general. This is because solving it would involve solving the halting problem for all possible inputs. 3, Decidability and Turing Machines: To summarize the distinction between decidable and undecidable languages in the context of Turing machines: Decidable languages are those for which a Turing machine can decide membership. (ie., whether a string is in the language or not) in finite time. This means the Turing, machine always halts and gives a correct answer (either accepts or rejects). Undecidable languages are those for which no Turing machine can decide membership in finite time for all inputs. This could mean the Turing machine might run indefinitely for some inputs, and thus, there is no general algorithm to solve the problem for all strings. 4, Relation Between Decidable and Undecidable Languages: Every decidable language is also recursively enumerable (RE), but not every RE language is decidable. Undecidable languages are often related to problems that are too complex to be solved by a Turing machine in finite time, such as the halting problem 5. Key Theoretical Result - The Halting Problem: The halting problem is one of the most famous results in the theory of computation, and it demonstrates that some languages are undecidable. In formal terms, the halting problem is the language H={(M,w)|M halts on input w}H = \{(M, w) \mid M \text{ halts on input } w \}H={(M,w)[M halts on input w}, where MMM is a Turing machine and www is an input string. Turing proved that there is no general algorithm (no Turing machine) that can decide whether an arbitrary machine MMM halts on a given input www. Conclusion: Decidable languages are those for which a Turing machine can decide membership in finite time, and this includes languages that are solvable by algorithms. Undecidable languages are those for which no Turing machine can decide membership for all inputs, often due to the inherent complexity of the problem. The halting problem is a classic example of an undecidable language, highlighting the limits of what can be computed by Turing machines.

You might also like