Question? Leave a message!




Turing completeness

Turing completeness
Dr.SethPatton Profile Pic
Dr.SethPatton,United Kingdom,Teacher
Published Date:22-07-2017
Website URL
Comment
ECE 250 Algorithms and Data Structures Turing Douglas Wilhelm Harder, M.Math. LEL completeness Department of Electrical and Computer Engineering University of Waterloo Waterloo, Ontario, Canada ece.uwaterloo.ca dwharderalumni.uwaterloo.ca © 2006-2013 by Douglas Wilhelm Harder. Some rights reserved.Turing completeness 2 Outline In this topic, we will: – Ask what is computable – Describe a Turing machine – Define Turing completenessTuring completeness 3 Computability How do we define what is and what is not computable? – Is it possible to write a C++ function which cannot be written using Pascal, Java, or C, or vice versa? – For example, do pointers (not available in Java) make C++ more powerful than Java? – Is BASIC really that bad?Turing completeness 4 Computability Consider INTERCAL – 16-bit integers .1 … .65535 – 32-bit integers ,1 … ,65535 – Arrays of 16-bit integers :1 … :65535 – Arrays of 32-bit integers ;1 … ;65535 – Each variable has its own stack • You can push the current value onto the stack, or pop back a previous value – There are five operations: interleave, select, and, or, xor Can you do everything you do in C in INTERCAL and vice versa?Turing completeness 5 Computability Does computability depend on the processor? – The VAX had a machine instruction POLY for polynomial evaluation using Horner’s rule – Is the instruction set of the Intel Core 2 processor significantly different from the Motorola MC6800?Turing completeness 6 Computability To study computability, Alan Turing developed a simple and basic but surprisingly powerful symbol-manipulating device: – He called it the a-machine (for automatic) – It has since been christened the Turing machine – First described in 1936 • Five years before the first computer (the Z3)Turing completeness 7 Computability The Turing machine has four components: – An arbitrary-length tape • Divided into linearly-ordered entries • Each entry is from a finite alphabet G which usually includes a blank B • In this example, G = B, 0, 1Turing completeness 8 Computability The Turing machine has four components: – An arbitrary-length tape – A head that can • Read a symbol off the tape, • Write a symbol to the tape, and/or • Move to the next entry to the left or the rightTuring completeness 9 Computability The Turing machine has four components: – An arbitrary-length tape – A head – A state • The state is one of a finite set of symbols Q • In this example, Q = b, c, e, f • The initial state of the machine is denoted q∈ Q 0 • Certain states may halt the computationTuring completeness 10 Computability The Turing machine has four components: – An arbitrary-length tape – A head – A state Current New Symbol Symbol – A transition table State State Direction read to write • Q ×G → Q ×G × L, R, N b B c 0 R • L moves one entry to the left c B e B R • R moves one entry to the right e B f 1 R • N indicates no shift f B b B R There is at most one entry in this table for each pair of current settingsTuring completeness 11 Computability Currently, the state is e and the symbol under the head is B Current Next Symbol Symbol State State Direction read to write b B c 0 R c B e B R e B f 1 R f B b B RTuring completeness 12 Computability The transition table dictates that the machine must: – The state is set to f – Print symbol 1 onto the tape – Move one entry to the right Current Next Symbol Symbol State State Direction read to write b B c 0 R c B e B R e B f 1 R f B b B RTuring completeness 13 Computability The state and symbol under the head have been updated Current Next Symbol Symbol State State Direction read to write b B c 0 R c B e B R e B f 1 R f B b B RTuring completeness 14 Computability The state is f and the symbol under the head is the blank B:t – The state is set to b – A blank is printed to the tape – Move one entry to the right Current Next Symbol Symbol State State Direction read to write b B c 0 R c B e B R e B f 1 R f B b B RTuring completeness 15 Computability Again, the state is b, the symbol a blank, and therefore: – Set the state to c – Print the symbol 0 to the tape – Move one entry to the right Current Next Symbol Symbol State State Direction read to write b B c 0 R c B e B R e B f 1 R f B b B RTuring completeness 16 Computability The result is the state c and a blank symbol is under the head: – Set the state to e – Write a blank to the tape – Move one entry to the right Current Next Symbol Symbol State State Direction read to write b B c 0 R c B e B R e B f 1 R f B b B RTuring completeness 17 Computability The result is the state e and a blank symbol B under the head – This is the state we were in four steps ago – This machine never halts... Current Next Symbol Symbol State State Direction read to write b B c 0 R c B e B R e B f 1 R f B b B RTuring completeness 18 Computability This was Turing’s first example in his 1937 paper On Computable Numbers, with an Application to the Enscheidungsproblem – It demonstrates a machine which can compute the sequence 0 1 0 1 0 1 0 ···Turing completeness 19 Computability This Turing machine adds two numbers: – Tape symbols:G = B, 1 – States: Q = a, b, c, d, e, H – Initial state: q = a 0 Current Next – Halting state: H Symbol Symbol State State Direction read to write a B a B R Note there is exactly one entry a 1 b 1 R for each pair in Q \ H ×G b B c 1 R – It may not be necessary to have b 1 b 1 R one for each, but you cannot have c B d B L more than one transition for a given state and symbol c 1 b 1 R d B d B L d 1 e B L e B H B R e 1 e 1 LTuring completeness 20 Computability After 22 steps, a group of five ones and a group of six ones are merged into a single group of eleven ones – This represents 5 + 6 = 11