Theory of Computation Lecture #8 Sarmad Abbasi Virtual University Sarmad Abbasi (Virtual University) Theory of Computation 1 / 33 Lecture 8: Overview The Halting Problem Universal Turing Machine Undecidability of the Halting Problem Diagonalization Galilean Paradox Hilbert Hotel Countable Sets Cantor Diagonalization Sarmad Abbasi (Virtual University) Theory of Computation 2 / 33 Acceptance Problem for TMs Let us define A TM = {〈 M , w 〉 : M is a TM that accepts w } This is called the acceptance problem for TMs or the halting problem. Sarmad Abbasi (Virtual University) Theory of Computation 3 / 33 Acceptance Problem for TMs Theorem A TM is Turing Recognizable. Sarmad Abbasi (Virtual University) Theory of Computation 4 / 33 Acceptance Problem for TMs On Input < M , w > Simulate M on w If M accepts w accept. This machine lets call it U is a recognizer for A TM Sarmad Abbasi (Virtual University) Theory of Computation 5 / 33 Acceptance Problem for TMs Why is this not a decider. If M loops on w then U will also loop on 〈 M , w 〉 Sarmad Abbasi (Virtual University) Theory of Computation 6 / 33 Universal Turning Machine U is called a universal Turing Machine. Suppose we have made the Universal TM U . Then we do not need to make any other machines. We only need to describe them. Sarmad Abbasi (Virtual University) Theory of Computation 7 / 33 Universal Turning Machine U is a general purpose computer. M is the program and w are the data. That is what happens in a typical computer system. We make one kind of machine and run different programs on various data on it. Sarmad Abbasi (Virtual University) Theory of Computation 8 / 33 Universal Turning Machine The fact that Universal TM may look simple to us now but it is extremely important. Notice there are no: 1 Universal DFAs 2 Universal PDAs 3 Universal CFGs However, there is a Universal TM . Turing machines are powerful enough to simulate DFAs, PDAs and other Turing machines as well. Sarmad Abbasi (Virtual University) Theory of Computation 9 / 33 Universal Turning Machine What happens to U if the input is a machine M and data w such that M does not halt on w Then U does not halt on 〈 M , w 〉 Sarmad Abbasi (Virtual University) Theory of Computation 10 / 33 Universal Turning Machine We can ask the question is A TM decidable. So, we are asking if there is a decider H such that 1 H will accept 〈 M , w 〉 if M accepts w 2 H will reject 〈 M , w 〉 if M does not accept w Note that H has to halt on all inputs. So H has to halt even if M does not halt on w. Sarmad Abbasi (Virtual University) Theory of Computation 11 / 33 Universal Turning Machine Our goal is today to prove the following theorem: A TM is undecidable. Which means no such H exists. Sarmad Abbasi (Virtual University) Theory of Computation 12 / 33 Cantor Diagonalization The technique used to prove this theorem is called diagonalization. It was first introduced by the great mathematician Cantor. Sarmad Abbasi (Virtual University) Theory of Computation 13 / 33 Galilean Paradox N = { 1 , 2 , 3 , 4 5 , 6 , 7 , · · · , } S = { 1 4 , 9 , 25 , · · · , } It is clear that: S ⊂ N Another view: N = { 1 , 2 , 3 , 4 5 , 6 , 7 , · · · , } S = { 1 2 2 , 3 2 , 4 2 , 5 2 , 6 2 , 7 2 , · · · , } Sarmad Abbasi (Virtual University) Theory of Computation 14 / 33 Galilean Paradox It seems that the larger circle has more points than the smaller circle. Sarmad Abbasi (Virtual University) Theory of Computation 15 / 33 Galilean Paradox There is a one to one correspondence between the two sets. It seems now that both the sets have same size! Sarmad Abbasi (Virtual University) Theory of Computation 16 / 33 Galalian Paradox A = { a , b , c , } | A | = 3 B = { x , y , z } | B | = 3 | A | = | B | Sarmad Abbasi (Virtual University) Theory of Computation 17 / 33 Galalian Paradox A = { a , b , c , d , } | A | = 4 B = { p , q , r , s , t , u , v } | B | = 7 | A | < | B | Sarmad Abbasi (Virtual University) Theory of Computation 18 / 33 Cantor’s approach To show that two sets are of the same size we can have two approaches. Let us say we want to prove that the number of passengers standing at a bus stop is equal to the number of seats in the bus. There are two ways to do this: 1 Count the passengers and the seats and see if they are equal. 2 Seat all the passengers in the bus and see if all passengers are seated and all the seats are occupied. Sarmad Abbasi (Virtual University) Theory of Computation 19 / 33 One to one and onto functions A function f : A → B is called one to one if each element of A is assigned a unique element B (that is, f is a function) and f ( a ) 6 = f ( b ) whenever a 6 = b A function f : A → B if for every b in B there is an a such that f ( a ) = b A correspondence (or a one-to-one correspondence) is a function that is both one to one and onto. Sarmad Abbasi (Virtual University) Theory of Computation 20 / 33