co1301 - games development 2 week 21 turing machines & computability

28
1 CO1301 - Games Development 2 Week 21 Turing Machines & Computability Gareth Bellaby

Upload: kimball

Post on 23-Jan-2016

43 views

Category:

Documents


0 download

DESCRIPTION

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") - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

1

CO1301 - Games Development 2Week 21

Turing Machines & Computability

CO1301 - Games Development 2Week 21

Turing Machines & Computability

Gareth BellabyGareth Bellaby

Page 2: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

2

Foundations of MathematicsFoundations 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).

Page 3: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

3

Alan TuringAlan 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).

Page 4: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

4

Turing's ApproachTuring'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.

Page 5: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

5

ApproachApproach

• 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

Page 6: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

6

ApproachApproach

• 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.

Page 7: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

7

ApproachApproach

• 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.

Page 8: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

8

Turing MachineTuring 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.

Page 9: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

9

Turing MachineTuring Machine1.A finite alphabet of input and output symbols.2.A tape divided into a linear sequence of boxes.

Each box contains one symbol. Tape can move in both directions.

3.A tape head that can read from, and then write to, one box at a time.

4.A control or processing unit. The unit can assume one a finite number of states (finite state machine)

5.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).

Page 10: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

10

Turing MachineTuring Machine

1 1 1 1 1 Tape

Tape Head

Processor

Page 11: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

11

Turing MachineTuring MachineImagine 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

Page 12: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

12

Turing MachineTuring Machine

B 1 1 1 B Write 'B', move R

B B 1 1 B Write 'B', move R

B B B 1 B Write 'B', move R

B B B B B Write 'B', STOP

Page 13: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

13

CapabilitiesCapabilities

• 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.

Page 14: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

14

CapabilitiesCapabilities

• 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.

Page 15: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

15

Universal TMUniversal 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.

Page 16: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

16

Turing's ThesisTuring'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).

Page 17: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

17

Alonzo ChurchAlonzo 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.

Page 18: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

18

The Halting ProblemThe 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.

Page 19: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

19

ProofProof

• 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.

Page 20: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

20

ProofProof

• 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

}

Page 21: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

21

ProofProof• 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).

Page 22: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

22

ProofProof

• 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.

Page 23: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

23

ProofProof

• 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.

Page 24: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

24

HumansHumans

• 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

Page 25: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

25

Cellular AutomataCellular 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.

Page 26: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

26

Real computersReal 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.

Page 27: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

27

Real computersReal 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.

Page 28: CO1301 - Games Development 2 Week 21 Turing Machines & Computability

28

Real computersReal 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.