280 likes | 416 Views
CO1301 - Games Development 2 Week 21 Turing Machines & Computability. Gareth Bellaby. Foundations of Mathematics. David Hilbert Is Maths: Complete? Consistent? Decidable? The Entscheidungsproblem (the "decision problem")
E N D
CO1301 - Games Development 2Week 21Turing Machines & Computability • Gareth Bellaby
Foundations of Mathematics • David Hilbert • Is Maths: • Complete? • Consistent? • Decidable? • The Entscheidungsproblem (the "decision problem") • Is there an algorithm which will be able to decide whether a given statement is provable from its axioms? • Gödel's incompleteness theorem: all consistent axiomatic formulations of number theory include undecidable propositions (propositions which can't be either proved or disproved).
Alan Turing • Attempting to clarify the foundations of mathematics. • 1936: "On Computable Numbers, with an Application to the Entscheidungsproblem" . • Can find it in a number of places on the internet, just put the whole title into a search engine. • Wanted to make precise what is meant by a calculation (or an effectively computable function).
Turing's Approach • Turning defined a class of abstract machines now called Turing Machines. • Consider computation as performed by a human and, by dismissing the extraneous and superfluous elements, to arrive at a description of the fundamental steps of computation. • Break maths down to its most basic operations.
Approach • Imagine a man in a room. He has: • Pencil • A rubber. • A notepad which he can record a number. There's a number written on it at the beginning of the proceedings. • There is a single window onto the room. • Another person hands a sheet of paper over to him • On it is written a single symbol
Approach • He has a book of instructions. • He looks up the symbol in the book and matches it the number written in the notepad. The instructions tell him what precisely to do. He will find a instruction. The instruction will tell him to rub out the symbol on the sheet of paper and to write a new symbol on the sheet (it could actually be the same as the original one). The instructions will also tell him if he needs to change the number in the notepad. The instructions will also say whether to go back or go forward.
Approach • The instructions will also say when to stop. • Hands back the sheet of paper. Depending on the instructions he will tell the person to get the previous sheet in sequence, or to get the next sheet in sequence. • Note the man knows nothing about maths. He just reads symbols, acts on the instructions and writes symbols. The symbols may be meaningless to him.
Turing Machine • Recasts this idea as a machine which he supposes can perform all of the functions that the man does. • Turning defined a class of abstract machines now called Turing Machines.
Turing Machine • A finite alphabet of input and output symbols. • A tape divided into a linear sequence of boxes. Each box contains one symbol. Tape can move in both directions. • A tape head that can read from, and then write to, one box at a time. • A control or processing unit. The unit can assume one a finite number of states (finite state machine) • A program: rules or instructions which define the action of the machine when in a particular state reading a particular character. The permitted actions are to change state (or stay in the same state), write a particular symbol (could be the same the original symbol).
1 1 1 1 1 Turing Machine Tape Tape Head Processor
Turing Machine • Imagine a TM with the following program: • in state a, reading 1, write B (blank), move Right, go to state a • in state a, reading B, write B, STOP, go to state b • This is a program to erase the tape. • Examples of TMs are easy to find, e.g. • http://en.wikipedia.org/wiki/Turing_machine_examples
Write 'B', move R B B B B 1 B B B 1 B B 1 B 1 1 1 B B B B Turing Machine Write 'B', move R Write 'B', move R Write 'B', STOP
Capabilities • It can be demonstrated that a TM can simulate another TM. • A Universal Turing Machine is one that can simulate any TM. • It can also be demonstrated that a binary TM can simulate any TM.
Capabilities • The Universal TM can: • do recursion • add • do functions • It is suggested that this comprises the whole of maths. All mathematical operations can be created using these actions. This is not a formal proof, but it appears to work. You can create any mathematical operation we know about using these basic operations.
Universal TM • A TM computes one particular function. • Universal TM is one which can simulate any other machine. • It takes as input a description of a particular machine in addition to a copy of the input tape. • A Universal TM is a universal algorithm device. • A Universal TM can do any computation. • Any calculation defined recursively by algorithm can be performed by TM. • Any set defined by a recursive definition can be defined by a TM.
Turing's Thesis • The definition of computation is "something which can be done by a TM" • Turing's Thesis: The class of effectively computable functions can be identified with the class of Turing machine computable functions. • A binary alphabet is sufficient to construct a machine to compute any function. • Universal TM can perform all of the basic functions of computation (or calculation).
Alonzo Church • Church and Turing worked independently. • Church published first. Church described the Lambda calculus. Expresses maths in terms of functions. Even numbers are expressed as functions. • Note: a subset of the LISP programming language can be used to write Lambda calculus functions. • Demonstrated that any computation can be done using the Lambda calculus. • Later a formal proof that anything written using Lambda calculus can be done using a Universal TM, and vice versa.
The Halting Problem • The halting problem: the determination of whether a TM will come to a halt given a particular input program. • The halting problem is just a particular expression of the Entscheidungsproblem (the "decision problem") but now expressed in terms of a TM. • Disproof by showing a contraction. It posits the existence of a program to solve the Halting Problem and then demonstrates that it would lead to a contradiction.
Proof • Imagine a program called Halt(P, I) • P is a string. You can think of P as being a program. • I is a string. Again you can think of as being a program. • Halt solves the halting problem. It returns true if program P halts when it given string I.
Proof • Imagine a program called Test • Test takes an input string X. You can think of X as being a program. Test( X ) { if( Halt( X , X ) ) infinite loop else halt }
Proof • What happens if the program Test is run with itself as the input? • Test halts on input of Halt. • But this means that the test condition is true. Hence the program goes into an infinite loop. This is in contradiction with the statement in the condition that Halt is true (and so would halt, rather than going into an infinite loop). • Test doesn't halt on input of Halt. • But this means that the test condition is false. Hence the program halts. This is in contradiction with the statement in the condition that Halt is false (and would not halt).
Proof • In other words we've shown that the halting problem cannot, in general, be solved. The reason that it cannot be solved is that it gives rise to an inherent contradiction.
Proof • The conclusion is that you cannot answer the question "does a program halt?" • You can answer it for a specific algorithm. • However, each algorithm requires its own proof. • There is no general all encompassing way to answer the question. • To rephrase: there is no way to prove that an algorithm is complete except by doing it. • It proves that maths is not a complete system. • There are problems which are known to have known algorithmic solution.
Humans • A Universal TM can compute anything which is computable. • It has been argued (for example by Turing himself) that a Universal TM should, in principle, be capable of intelligence. • Human minds might be Universal TMs. • There has been a lot of discussion based on this: John Searle, Daniel Dennett
Cellular Automata • Elementary cellular automata: one dimensional CA. • Rule 110 CA has been proven to Turing complete. • In theory it is possible for the Rule 110 1D to calculate anything a Universal TM can.
Real computers • Universal TM is comparable to a real computer. • Anything a real computer can compute can be computed by a TM. • Note that one implication is that there are things computers cannot compute, however everything that can be computed can be computed by a computer (given enough time and storage). • Ironically it can be a lot easier to describe certain algorithms using a TM than a real computer. Similar to the use of recursive proofs or predicate logic.
Real computers • A universal TM is unbounded: the tape can be infinite, the number of instructions unlimited, and no time is imposed on its computations. • A real computer is bounded: both time and space are limited. The number of configurations a real computer can take are limited. They are finite (hence FSM). • A TM expresses algorithms in general terms. A real program needs to consider things such as precision (floating point imprecision) and error conditions.
Real computers • The TM uses a sequential tape. A real computer uses registers and random-access storage. It can use registers to store other registers and access data across a spectrum. • TMs do not model concurrency easily.