Complexity Theory Turing Machines Joseph Spring Department of Computer Science 3COM0074 - Quantum Computing / QIP QC - Lecture 2 1
Areas for Discussion Algorithms Complexity Theory and Computing Models Turing Machines Random Access Machines Circuits / Logic Gates 1 Asymptotic Notation Complexity Classes Tractable v Intractable Problems QC - Lecture 2 2
Models We commence with the following models: The Turing Machine Model fundamental model of computation The Circuit Model most useful in the study of quantum computation and then consider the: energy resources required to perform computations QC - Lecture 2 3
Turing Machines Basic elements a program like an ordinary computer a finite state control acts like a stripped-down microprocessor, coordinating the other operations of the machine a tape acts like a computer memory a read-write tape-head points to the position on the tape currently readable/writable QC - Lecture 2 4
Turing Machines - Finite State Control acts like a stripped-down microprocessor, co-ordinates the other operations of the machine consists of two internal states q s, and q h a starting and halting states a finite set of internal states q 1, q n, n may vary for n sufficiently large the power of the machine is unaffected in any essential way w.l.o.g. n may be considered as a fixed constant provides temporary storage off-tape central place where all processing for machine is carried out QC - Lecture 2 5
Turing Machines - Tape One dimensional object Infinitely long Infinite number of tape squares, numbered 0,1,2,3, The squares each contain a symbol drawn from an alphabet, Γ, containing a finite number of different symbols. For example: Γ= { 0, 1, b, } where b denotes 'a blank square' and denotes the left hand edge of the tape QC - Lecture 2 6
Turing Machines - Tape Initially Tape commences with the diamond symbol, a finite number of 0 s and 1 s, and an infinite number of blanks Read-write head accesses one square at a time Machine starts At square number 0, containing the symbol With finite state control in state q s Computation Proceeds one step at a time according to a program If current state is q h then the computation halted and output is the current (non blank) contents of the tape QC - Lecture 2 7
Turing Machines - Program Program for a Turing Machine A finite ordered list of program lines of the form: < q, x, q, x, s > where: q, q are states from the set of internal states x, x are symbols from the alphabet s takes the value: +1 tape head move the right - 1 tape head moves to the left 0 tape head stands still QC - Lecture 2 8
Turing Machines - Procedure On each machine cycle: Turing machine looks through program lines in order, searching for a line: < q, x,.,.,. > such that the internal state of the machine is q and symbol being read from the tape is x If there does not exist such a line, then internal state is changed to q h and the machine halts there exists such a line, then the line is executed QC - Lecture 2 9
Turing Machines - Procedure Execution of a program line < q, x, q, x, s > Internal state of machine is changed from q to q The symbol x is overwritten with the symbol x Tape head moves left (s = -1), right (s = +1) or doesn t move (s = 0) according to the value that symbol s takes QC - Lecture 2 10
Turing Machines - Example 1. < q s,, q 1,, +1 > 2. < q 1, 0, q 1, b, +1 > 3. < q 1, 1, q 1, b, +1 > 4. < q 1, b, q 2, b, -1 > 5. < q 2, b, q 2, b, -1 > 6. < q 2,, q 3,, +1 > 7. < q 3, b, q h, 1, 0 > QC - Lecture 2 11
Turing Machines - Example The above example computes the constant function f(x) = 1 whatever value is given to the machine as input the output from the machine is 1 Turing machines: (can be thought of as) machines that compute functions from the non negative integers to the non negative integers f : N N by x 1, x N QC - Lecture 2 12
Turing Machines - Example Input represented by the initial state of the tape Output represented by the final state of the tape QC - Lecture 2 13
Turing Machines Questions Is it possible to build up more complicated functions using Turing machines? Example Can we construct a TM to add two numbers together? What class of functions is it possible to compute using a Turing Machine? What of multiple tape TM s and the Universal TM? QC - Lecture 2 14
Turing Machines Response It turns out that single tape TM s can be used to: Carry out all basic arithmetic operations search through text represented as a string of bits on the tape simulate all the operations performed on a modern computer (see Church-Turing Thesis) Simulate multiple tape TM s There exists a Universal TM that can simulate any other TM QC - Lecture 2 15
Turing Machines As you read around the literature you find various definitions for Turing Machines See for example: Gennady Berman et al; Introduction to Quantum Computers, World Scientific, 1998 (ISBN 981-02-3490-2) P Linz; An Introduction to Formal Languages and Automata, Jones & Bartlett, 1997 (ISBN 0-7637-0296-X) QC - Lecture 2 16
Berman et al; Turing Machine Example given in lecture QC - Lecture 2 17
Turing Machine Formal Definition More formally we can define a Turing Machine M by M = ( Q, Σ, Γ, δ, q,, F ), 0 where Q is the set of internal states, Σ is the input alphabet, Γ is a finite set of symbols called the tape alphabet, δ is the transition function, is a special symbol called blank, q0 Q is the initial state F Q is the set of final states Peter Linz p231 QC - Lecture 2 18
Turing Machine - Definition It is assumed that the input alphabet is a subset of the tape alphabet excluding the blank And that the transition function is defined as Current state of control unit Σ Γ \ { } δ : Q Γ Q Γ { L, R} Current tape symbol being read New state of control unit New tape symbol Move symbol, L or R QC - Lecture 2 19
Linz - Turing Machine Examples given in lecture QC - Lecture 2 20
Church-Turing Hypothesis The class of functions computable by a Turing machine corresponds exactly to the class of functions which we would naturally regard as being computable by an algorithm Nielson and Chuang p125 QC - Lecture 2 21
Church-Turing Hypothesis Asserts Equivalence between a rigorous mathematical concept a function computable by a Turing Machine an intuitive concept what it means to be computable by an algorithm That the TM model of computation provides a good foundation for computer science captures the intuitive notion of an algorithm in a rigorous definition QC - Lecture 2 22
Church-Turing Hypothesis Note This is a hypothesis, an assumption It has not been proven Plays same role in computer science as do the basic laws of physics and chemistry Empirical by nature Repeated failure to invalidate the hypothesis strengthens our confidence in its truth QC - Lecture 2 23
Turing Machines - Questions 1. Present algorithms to Convert a number from fahrenheit to centigrade Display the larger of two numbers Sort ten numbers according to size 2. Complete the table outlining the sequence of positions and instructions for addition using the Berman TM? 3. What would be the appropriate table for the addition of 2 and 3 using the Berman TM? 4. Reformulate the addition program given for the Berman TM in terms of the first TM. Appropriate modifications may be employed QC - Lecture 2 24
Universal Turing Machine 5. Consider the following argument: A Turing machine is a special purpose computer. Once the transition function is defined, the machine is restricted to carrying out one particular type of computation. Digital computers are general purpose machines that can be programmed to different jobs at different times. Consequently Turing Machines cannot be considered equivalent to general purpose digital machines This objection can be overcome by designing a reprogrammable Turing Machine called a Universal Turing Machine. How? QC - Lecture 2 25
Summary Algorithms Complexity Theory and Computing Models Turing Machines Random Access Machines Circuits / Logic Gates 1 Asymptotic Notation Complexity Classes Tractable v Intractable Problems QC - Lecture 2 26
References Nielson and Chuang, Quantum Computation and Quantum Information, Cambridge University Press, 2002 (ISBN 0-521-63503-9) Gennady Berman et al; Introduction to Quantum Computers, World Scientific, 1998 (ISBN 981-02-3490-2) Jozef Gruska, Quantum Computing, McGraw-Hill, 1999 (ISBN 0-07709- 503-0) Mika Hirvensalo, Quantum Computing, Springer, 2001 (ISBN 3-540- 66783-0) Dirk Bouwmeester, Artur Ekert, Anton Zeilinger (Eds.), The Physics of Quantum Information, Springer, 2000 (ISBN 3-540-66778-4) Byron and Fuller, Mathematics of Classical and Quantum Physics, Dover, 1992 (ISBN 0-486-67164-X) Roger Penrose, Shadows of the Mind, Vintage, 1995 (ISBN 0-09-958211-2) Julian Brown, Minds, Machines and the Multiverse The Quest for the Quantum Computer, Simon & Schuster, 2000 (ISBN 0-684-81481-1) QC - Lecture 2 27