Turing machines istory: 1900 David ilert asked: Given an axiomatization of an area of mathematics (e.g. ilert s axiomatization of Geometry, or Frege s axiomatization of natural numers), is there a procedure that will determine the truth of any conjecture? ilert did not mathematically define the concept of a procedure. 1930 Gödel showed that every true sentence in firstorder predicate logic can e proved. It remained to develop a procedure of determining whether the a sentence in first order predicate logic is true or false. 1936 Alan Turing proposed the Turing machine to define the concept of a procedure. is conclusion: There is no procedure that can classify sentences of March 20, 2018 1
A Turing machine represents an idealized human computer: Performs one kind of computation. Never makes a mistake. Never runs out of paper, pencils, erasers, or time. Finite rain power. Syntax of a Turing Machine A Turing Machine is a tuple(s,q,q start,q halt,t) S is a finite alphaet set including the lank symol / Qis a finite state set q start Q is the start state q halt / Q is the halt pseudostate. T is a set of transitions (see elow) Each transition is a tuple(q,a,r,,d) whereq Q, a, S,r Q {q halt },andd {L,}. We require that the Turing machine e deterministic in the sense that for each(q,a) pair, there is exactly one transition (q,a,,r): q Q a S 1= {(r,,d) (q,a,r,,d) T} March 20, 2018 2
Operation of a Turing Machine: The input and output of a Turing Machine is represented y a tape, which is a two way infinite sequence of symols. Although the tape is considered to e infinite, we will restrict it to contain only a finite amount of information y insisting that all ut a finite numer of cells on the tape e lank. We imagine there is a read/write head over the tape. In each step of execution, one symol is read and that cell of the tape is then overwritten with a symol. The the head moves either left or right. A configuration of a Turing machine consists of a stateq, a value of the tapet, and a position of the headk. Letw e the input string. vart:z tot S:=[..., /, /, /,...] fori {0,.. w } dot(i):=w(i) vark:=0 varq:=q start while true do ( letr,,d (q,t(k),r,,d) T t(k):=; ifr=q halt reak ifd=l thenk:=k 1elsek:=k+1; q:=r) outputt[k,...] March 20, 2018 3
An example: Another parenthesis checker. In the pictures states are marked with or L. All transitions into a state marked haved=. All transitions into a state marked L state haved=l. The halt pseudostate is. start ) X L no X ( yes L ( no Convention: Arrows that leave state alone and don't change the tape are omitted from the diagram. E.g. ( start omitted ( X X Notice that it overwrites its input with X s two matching parentheses at a time. March 20, 2018 4
A Turing machine to convert inary to unary Convert Binary to Unary. start A 0 in input: Doule the output. 1 X X A 1 L 1 0 X 1 0 L X X 1 1 in input: Change to 0 and add 1 to output Initial Config start...110x... Final config...111111... March 20, 2018 5
alting Note a Turing machine may not halt on some inputs. Thus a Turing machine does not define a function from strings to strings, ut rather a partial function i.e. a function except that for some memers of the domain there is no result. Prolem 0 (The halting prolem): Given a Turing machine and an input tape, determine whether the TM will halt. Prolem 1: Given a Turing machine determine, if it will halt for all initial configurations. Prolem 2: (Busy Beaver): Given a numer N, find the maximum numer of 1 s that can e output y a TM with N states, and an alphaet of{1, } when started on an all lank tape. (NB the TM must halt for this input tape.) Equivalent formalisms. Idealized Programming languages Suppose C s or Java s new command never failed to find new memory. Suppose that in askell, LISP, or ML we can construct aritrarily long lists. Idealized computers. a computer in which a memory of finite words is indexed y the natural numers (rather than a finite suset thereof) a computer with a finite numer of words (at least 2), ut where every memory word contains an integer (rather than a 32-it integer). (egister Machine) March 20, 2018 6
Infinite numer of integers (andom Access Machine) a PC with an endless supply of rewritale disks and an operator to change them on request. Lamda Calculus (Church 1936). A simple Functional Programming Language. Partial recursive functions (Kleene 1936): Functions formed from addition, sutraction and a minimum operator: minf(x)=the minimum naturalxsuch thatf(x)=0. x Grammars in which more than one symol may appear on Left-hand-side L B B 0ABC2 ɛ AC 1 A1 1A 2PDAs Like PDA s ut with 2 stacks. The human computer. Any limitation that applies to an idealized programming language or a idealized computer will also apply to real programming languages and real computers. Effective computaility Defn: An effectively computale function is a function which can e evaluated y an algorithm. N.B. This is not a mathematical definition as algorithm is not a well defined concept. March 20, 2018 7
The Church-Turing Thesis: Any effectively computale function can e computed y some (always halting) Turing machine. Note: This is not a mathematical theorem. It is a generally held elief. Note: The converse is oviously true. Any function computed y a TM is effectively computale. Corollary: Any effectively computale function can e computed y any of the aove equivalent formalisms. Why Turing Machines make good models Why would we e interested in Turing Machines and similar models if all real devices have a finite amount of memory? We can not investigate time and space complexity unless we can consider inputs of unounded size. Limitations on finite memory models can e overcome y enlarging the memory. Limitations on infinite memory models are fundamental. unning out of space in software is unpredictale. The model of memory used y (good) software developers is that of an unknown amount of memory. If an algorithm won t work on a machine with unlimited memory, it certainly won t work given an unknown amount of memory. Limits on the power of Turing machines Are there well-defined mathematical prolems that no computer can solve? March 20, 2018 8
We will show that the alting Prolem can not e solved y any algorithmic method Claim: For any TM, there exists an equivalent TM with an alphaet of{0, 1, }. We can encode the original alphaet with a inary code. We can encode any such TM as a sequence of symols from a small alphaet. E.g. use inary encoding of the states. Define enc(t)= the encoding oft Theorem the halting prolem can not e solved y any Turing Machine. Proof (By contradiction) Assume to the contrary that we have a TM that solves the halting prolem. Specifically: If we start in a configuration... encoding of a T X I... then if T halts for input I, halts in a configuration:... Yes... and if T does not halt for input I, halts in a configuration... No... March 20, 2018 9
Thus computes a function (enc(t),i)= if T halts on I then output yes and halt else output no and halt We can uild another TM D using as a suroutine as follows D(I)=if(I,I)then loopelse halt I.e. D loops forever if returns yes. start Turing machine yes no start D Duplicate the input Turing machine yes Note machine will move right forever from this state. (ememer omitted arrows) no March 20, 2018 10
Consider running D with an input of enc(d). This computation must halt or not. Furthermore can tell us which. Suppose D(enc(D)) halts. D(enc(D)) = if(enc(d), enc(d))then loopelse halt = Supposition if yesthen loopelse halt = loop ThusD(enc(D)) does not halt. Contradiction. Suppose now thatd(enc(d)) does not halt D(enc D) = if(enc(d), enc(d))then loopelse halt = Supposition if nothen loopelse halt = halt ThusD(enc(D)) does halt. Contradiction Either way there is a contradiction. The culprit must e out assumption that exists. QED Note: For many TMs and specific inputs, we can determine if they halt. Corollary: Assuming the C-T thesis, there are prolems no computer (and no human) can solve. Other unsolvale prolems. Given an aritrary mathematical conjecture, does it have March 20, 2018 11
a proof? Given an aritrary polynomial such as a 3 2 c 4 +a 2 3 =0 Do there exists integer solutions? That is unsolvale was proved in 1970: 70 years after ilert asked for a solution. (Proof y showing that such equations can encode Turing Machines.) The first says there is no universal theorem proving method. The second shows there are implications for everyday mathematics. A universal TM (Optional) Claim: There exists a TM (called U) with the following properties: Suppose we have a TMT (with alphaet{0,1, }) that only uses the left half of the tape. Suppose we have an input sequencei fort We will start it in a configuration... encoding of a T X input I... IfT halts on inputi with outputothenu halts in a configuration... encoding of a T X output O... IfT does not halt on inputi thenu does not halt. Minsky (1967) descries a U with 23 states. March 20, 2018 12
U is a stored-program computer: It is capale of executing any algorithm.t is the software representing the algorithm. We only need one TM: U We only need one kind of computing machine. The rest we can do with software. March 20, 2018 13
The Chomsky ierarchy (+ Others) Type 3: (Finite space) egular languages: ecognized y Deterministic Finite ecognizers (DFs) Nondeterministic Finite ecognizers (NDFs) egular expressions & EFs Type?: (Stack memory) L(k) Deterministic Push-Down Automata Type 2: (Stack memory) Context Free Languages Nondeteriministic Push-Down Automata Context-Free Grammars Type 1 (Linear space) Context Sensitive Languages Turing Machines with memoryo(n) of input sizen. Type? (Infinite space) ecursive Languages Turing Machines (etc) that halt Type 0 (Infinite space.) ecursively Enumerale Languages Turing Machines, Unrestricted grammars, Idealized Computers and Languages, Lamda Calculus, General ecursive Functions March 20, 2018 14