1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2011
2 Content Chomsky’s Language Hierarchy Turing Machines Determinism Halting TM Examples Standard TM Computing Functions with TM Combining TMs Turing Thesis
3 The Language Hierarchy Regular Languages Context-Free Languages ? ?
4 Regular Languages Context-free languages Recursively enumerable languages
5 Finite Automata Push-down Automata Turing Machines
6 Who was Alan Turing? Founder of Computability Theory, mathematician, philosopher, codebreaker, visionary man before his time. Jack Copeland and Diane Proudfoot The Alan Turing Home Page Andrew Hodges/
7 Alan Turing 1912 (23 June): Birth, London : Sherborne School 1930: Death of friend Christopher Morcom : Undergraduate at King's College, Cambridge University : Quantum mechanics, probability, logic 1935: Elected fellow of King's College, Cambridge 1936: The Turing machine, computability, universal machine : Princeton University. Ph.D. Logic, algebra, number theory : Return to Cambridge. Introduced to German Enigma cipher machine : The Bombe, machine for Enigma decryption : Breaking of U-boat Enigma, saving battle of the Atlantic
8 Alan Turing : Chief Anglo-American crypto consultant. Electronic work. 1945: National Physical Laboratory, London 1946: Computer and software design leading the world : Programming, neural nets, and artificial intelligence 1948: Manchester University 1949: First serious mathematical use of a computer 1950: The Turing Test for machine intelligence 1951: Elected FRS. Non-linear theory of biological growth 1952: Arrested as a homosexual, loss of security clearance : Unfinished work in biology and physics 1954 (7 June): Death (suicide) by cyanide poisoning, Wilmslow, Cheshire.
9 Hilbert’s Program, 1900 Hilbert’s hope was that mathematics would be reducible to finding proofs (manipulating the strings of symbols) from a fixed system of axioms, axioms that everyone could agree were true. Can all of mathematics be made algorithmic, or will there always be new problems that outstrip any given algorithm, and so require creative acts of mind to solve?
10 Turing Machines and Computability The question Hilbert raised was whether there could be a general method or process by which one could decide whether a mathematical proposition could be proved. But what exactly was meant by a 'method' or 'process'? People had already used the concept of a 'mechanical' process, and Turing had an idea which made this quite precise: computability. Turing wrote in his first sentences: “The "computable" numbers may be described briefly as the real numbers whose expressions as a decimal are calculable by finite means... a number is computable if its decimal can be written down by a machine. “
11 Turing Machines and Computability The Turing machine concept involves specifying a very restricted set of logical operations, but Turing showed how other more complex mathematical procedures could be built out of these atomic components. Turing argued that his formalism was sufficiently general to encompass anything that a human being could do when carrying out a definite method. Turing's famous paper On computable numbers, with an application to the Entscheidungsproblem, which worked out the theory of Turing machines and the definition of computability, is available as a PDF file on-line:
12 Turing Machines
Turing’s "Machines". These machines are humans who calculate. (Wittgenstein) A man provided with paper, pencil, and rubber, and subject to strict discipline, is in effect a universal machine. (Turing) 13
Tape Read-Write head Control Unit Turing Machine
Read-Write head No boundaries -- infinite length The head moves Left or Right The Tape
Read-Write head 1. Reads a symbol 2. Writes a symbol 3. Moves Left or Right The head at each time step:
17 Example Time Time Reads 2. Writes 3. Moves Left
18 Time Time Reads 2. Writes 3. Moves Right
19 Head starts at the leftmost position of the input string Blank symbol head Input string The Input String
20 Read Write Move Left Move Right States & Transitions
21 Example Time 1 current state
Time Time 2
Time Time 2 Example
Time Time 2 Example
25 Determinism Allowed Not Allowed No lambda transitions allowed in TM! Turing Machines are deterministic
26 Determinism Note the difference between state indeterminism when not even possible future states are known in advance and choice indeterminism when possible future states are known, but we do not know which state will be taken.
27 Partial Transition Function Example No transition for input symbol Allowed
28 Halting The machine halts if there are no possible transitions to follow
29 Example No possible transition HALT!
30 Final States Allowed Not Allowed Final states have no outgoing transitions In a final state the machine halts
31 Acceptance Accept Input If machine halts in a final state Reject Input If machine halts in a non-final state or If machine enters an infinite loop
32 Turing Machine Example A TM that accepts the language
33 Time 0
34 Time 1
35 Time 2
36 Time 3
37 Time 4 Halt & Accept
38 Rejection Example Time 0
39 Time 1 No possible Transition Halt & Reject
40 Infinite Loop Example Another TM for language
41 Time 0
42 Time 1
43 Time 2
44 Time 2 Time 3 Time 4 Time 5... infinite loop…
45 Because of the infinite loop: The final state cannot be reached The machine never halts The input is not accepted
46 Another Turing Machine Example Turing machine for the language
47 Time 0
48 Time 1
49 Time 2
50 Time 3
51 Time 4
52 Time 5
53 Time 6
54 Time 7
55 Time 8
56 Time 9
57 Time 10
58 Time 11
59 Time 12
60 Halt & Accept Time 13
61 If we modify the machine for the language we can easily construct a machine for the language Observation
62 Formal Definitions for Turing Machines
63 Transition Function
64 Transition Function
65 Turing Machine Transition function Initial state blank Final states States Input alphabet Tape alphabet
66 Instantaneous description: Configuration
67 Time 4Time 5 A move:
68 Time 4Time 5 Time 6Time 7
69 Equivalent notation:
70 Initial configuration: Input string
71 For any Turing Machine Initial stateFinal state The Accepted Language
72 Standard Turing Machine Deterministic Infinite tape in both directions Tape is the input/output file The machine we described is the standard:
73 Computing Functions with Turing Machines
74 A function has: Domain (domän): Range (värdemängd):
75 A function may have many parameters: Example: Addition function
76 Integer Domain Binary:101 Decimal:5 We prefer unary representation: easier to manipulate Unary:11111
77 Definition A function is computable if there is a Turing Machine such that: Initial configuration Final configuration Domain final state initial state For all
78 Initial Configuration Final Configuration In other words Domain For all A function is computable if there is a Turing Machine such that
79 Example (Addition) The function is computable Turing Machine: Input string: unary Output string: unary are integers
80 Start Finish final state initial state
81 Turing machine for function
82 Execution Example: Time 0 Final Result (2)
83 Time 0
84 Time 1
85 Time 2
86 Time 3
87 Time 4
88 Time 5
89 Time 6
90 Time 7
91 Time 8
92 Time 9
93 Time 10
94 Time 11
95 HALT & accept Time 12
96 Another Example (Multiplication) The functionis computable Turing Machine Input string: unary Output string:unary is integer
97 Start Finish final state initial state
98 Turing Machine Pseudocode for Replace every 1 with $ Repeat: Find rightmost $, replace it with 1 Go to right end, insert 1 Until no more $ remain
99 Turing Machine for
100 Start Finish
101 Time 0
102 Time 1
103 Time 2
104 Time 3
105 Time 4
106 Time 5
107 Time 6
108 Time 7
109 Time 8
110 Time 9
111 Time 10
112 Time 11
113 Time 12
114 Time 13
115 Time 14
116 Another Example The function is computable if Turing Machine for Output: or Input:
117 Turing Machine Pseudocode Match a 1 from with a 1 from Repeat Until all of or are matched If a 1 from is not matched erase tape, write 1 else erase tape, write 0
118 Combining Turing Machines
119 Block Diagram Turing Machine inputoutput
120 Example if Comparer Adder Eraser
121 Turing’s Thesis
122 Do Turing machines have the same power with a digital computer? Intuitive answer: Yes There is no formal answer! Question:
123 Turing’s thesis Any computation carried out by mechanical means can be performed by a Turing Machine (1930) The Origins of the Turing Thesis Myth Goldin & Wegner
124 And, the other way round: A computation is mechanical if and only if it can be performed by a Turing Machine Strong Turing Thesis: There is no known model of computation more powerful than Turing Machines Wrong! Asynchronous parallel computation is more powerful than TM model, and cannot be reduced to TM.
125 Definition of Algorithm An algorithm for function is a Turing Machine which computes
126 When we say There exists an algorithm Algorithms are Turing Machines It means There exists a Turing Machine
127 LanguageGrammarMachine Chomsky Hierarchy Non-computable?? Recursively enumerable (RE) UnrestrictedTuring machines 0 Recursive Turing machines that always halt 0 Context-sensitive Context-sensitive grammar Linear-bounded automata 1 Context-free Context-free grammar Non-deterministic pushdown automata 2 Regular Regular expressions Finite state automata 3 properly inclusive Languages, Grammars, Machines
128 Regular Languages FINITE AUTOMATA Context-free languages PUSH-DOWN AUTOMATA Unrestricted grammar languages TURING MACHINES
Interesting further reading Computational and evolutionary aspects of language Turing’s thesis The Alan Turing World Symposium on Natural/Unconventional Computing AISB/IACAP World Congress 129