Fundamentals of Informatics Lecture 3 Turing Machines Bas Luttik.

Slides:



Advertisements
Similar presentations
Introduction to Computability Theory
Advertisements

CS 345: Chapter 9 Algorithmic Universality and Its Robustness
THE CHURCH-TURING T H E S I S “ TURING MACHINES” Pages COMPUTABILITY THEORY.
Turing Machines (At last!). Designing Universal Computational Devices Was Not The Only Contribution from Alan Turing… Enter the year 1940: The world is.
1 Introduction to Computability Theory Lecture11: Variants of Turing Machines Prof. Amos Israeli.
Prof. Busch - LSU1 Decidable Languages. Prof. Busch - LSU2 Recall that: A language is Turing-Acceptable if there is a Turing machine that accepts Also.
Fall 2004COMP 3351 Turing Machines. Fall 2004COMP 3352 The Language Hierarchy Regular Languages Context-Free Languages ? ?
CS5371 Theory of Computation Lecture 10: Computability Theory I (Turing Machine)
Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Costas Busch - LSU1 Non-Deterministic Finite Automata.
Prof. Busch - LSU1 Turing Machines. Prof. Busch - LSU2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Chapter 9 Turing Machine (TMs).
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Lecture 03: Theory of Automata:08 Finite Automata.
CSCI 2670 Introduction to Theory of Computing September 28, 2005.
 Computability Theory Turing Machines Professor MSc. Ivan A. Escobar
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
Introduction to CS Theory Lecture 15 –Turing Machines Piotr Faliszewski
Lecture 1 Computation and Languages CS311 Fall 2012.
Lecture 05: Theory of Automata:08 Kleene’s Theorem and NFA.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Models of Computation - Turing Machines Dale Roberts, Lecturer.
Turing Machines Chapter 17. Languages and Machines SD D Context-Free Languages Regular Languages reg exps FSMs cfgs PDAs unrestricted grammars Turing.
Turing Machines. Intro to Turing Machines A Turing Machine (TM) has finite-state control (like PDA), and an infinite read-write tape. The tape serves.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
THE CHURCH-TURING T H E S I S “ TURING MACHINES” Part 1 – Pages COMPUTABILITY THEORY.
Computer Science 101 Theory of Computing. Computer Science is... The study of algorithms, with respect to –their formal properties –their linguistic realizations.
The Church-Turing Thesis Chapter 3 Giorgi Japaridze Theory of Computability.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Fundamentals of Informatics
 2005 SDU Lecture13 Reducibility — A methodology for proving un- decidability.
TM Design Macro Language D and SD MA/CSSE 474 Theory of Computation.
Fundamentals of Informatics Lecture 13 Reduction Bas Luttik.
Fundamentals of Informatics Lecture 4 From Turing Machines to Algorithms Bas Luttik.
Lecture 9  2010 SDU Lecture9: Turing Machine.  2010 SDU 2 Historical Note Proposed by Alan Turing in 1936 in: On Computable Numbers, with an application.
Fundamentals of Informatics Lecture 12 The Halting Problem Bas Luttik.
1 Section 13.1 Turing Machines A Turing machine (TM) is a simple computer that has an infinite amount of storage in the form of cells on an infinite tape.
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
Overview of Previous Lesson(s) Over View  A token is a pair consisting of a token name and an optional attribute value.  A pattern is a description.
1 Turing Machines - Chap 8 Turing Machines Recursive and Recursively Enumerable Languages.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 3 The Church-Turing Thesis Contents Turing Machines definitions, examples,
1 Introduction to Turing Machines
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007.
 2004 SDU Lecture4 Regular Expressions.  2004 SDU 2 Regular expressions A third way to view regular languages. Say that R is a regular expression if.
Lecture 09: Theory of Automata:2014 Asif NawazUIIT, PMAS-Arid Agriclture University Rawalpindi. Kleene’s Theorem and NFA.
Chapter 9 Turing Machines What would happen if we change the stack in Pushdown Automata into some other storage device? Truing Machines, which maintains.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Theory of Computation Automata Theory Dr. Ayman Srour.
Universal Turing Machine
Lecture 14: Theory of Automata:2014 Finite Automata with Output.
Theory of Computation Automata Theory Dr. Ayman Srour.
CSE202: Introduction to Formal Languages and Automata Theory
Kleene’s Theorem and NFA
CIS Automata and Formal Languages – Pei Wang
Busch Complexity Lectures: Turing Machines
CS21 Decidability and Tractability
Pushdown Automata.
Pushdown Automata.
Turing Machines 2nd 2017 Lecture 9.
Turing Machines Acceptors; Enumerators
Turing Machines (At last!).
Chapter 2 FINITE AUTOMATA.
Non-Deterministic Finite Automata
Theory of Computation Turing Machines.
CS21 Decidability and Tractability
Decidability and Tractability
Theory of Computation Lecture 23: Turing Machines III
Presentation transcript:

Fundamentals of Informatics Lecture 3 Turing Machines Bas Luttik

Example regular expressions Give regular expressions for the language consisting of 1. all sequences over a, b containing the pattern aa: (a+b)*(aa)(a+b)* 2. all sequences over a, b with an even number of b’s: a*(ba*ba*)* 3. all sequences over a, b with an odd number of b’s: a*ba*(ba*ba*)* 4. all sequences over a, b, with an even number of b’s that contain the pattern aa: a*(ba*ba*)*(aa)a*(ba*ba*)* + a*ba*(ba*ba*)*(aa)a*ba*(ba*ba*)*

Kleene’s theorem (1956) every language accepted by a finite automaton is described by a regular expression every language described by a regular expression is accepted by some finite automaton There is a direct correspondence between the languages described by a regular expression, and those accepted by a finite automaton: and, moreover, Stephen Kleene ( ) Disclaimer: for this result it is necessary to add symbols ε and Ø denoting the empty language and the language containing the empty string to the language of regular expressions; we left them out for simplicity.

Regular languages Languages accepted by a finite automaton (or, equivalently: described by a regular expression) are called regular. Fundamental question: Is every language regular? Consider, e.g., the language of marked palindromes consisting of all sequences of the shape sms -1 in which s is a sequence of symbols, m is a special marker symbol and s -1 is the reverse of s. There is no finite automaton that accepts the language of marked palindromes. So, the answer to the above fundamental questions is: NO!

Computer (mathematical model) Can we model a computer as a finite automaton? Any particular computer has a finite amount of memory and therefore has finitely many states. But there is no intrinsic bound on the number of states. Therefore, finite automata are unsatisfactory as mathematical model if our goal is to predict which type of problems can be solved with a computer. Let’s analyze what it means to compute! (as Alan Turing did back in 1936)

7 1 The essence of computation x Alan Turing ( ) = x7 7 = 4231 x7 7 = = x7 7 = A person carrying out a computation operates under the following constraints: at each stage only a small number of symbols receive attention; action at each stage depends on symbols receiving attention, and current state of mind of person 7 (remember 2)

Computation (down to bare minimum) Turing’s conclusion in 1936, after careful analysis:  computation is carried out by writing symbols in squares on a tape;  at each step the person performing the computation pays attention to the symbol written in exactly one of these squares;  her next action depends only on this symbol and her state of mind;  this next action consists of writing a new symbol on the square and shifting attention to square immediately to the left or right. How large should the alphabet of symbols be? finitely many How many symbols should be observed simultaneously in a computation? one is enough! How many states of mind? finitely many

Turing machine (conceptual) A Turing machine is an automaton consisting of: a finite control; a finite alphabet of tape symbols a two-way infinite tape subdivided into squares each square contains a symbol or is blank (in diagrams we use the symbol to denote a blank square) a read/write head that scans the contents of one square at a time and can move left or right.

Turing machine (definition) A Turing machine consists of 1. A finite collection of states  exactly one of these states is marked to be the initial state  some states are so-called halting states 2. A finite alphabet of tape symbols including a special symbol 3. A transition table determining for every combination of a non- halting current state and scanned tape symbol:  a new tape symbol (to be written on the position of the scanned tape symbol),  a direction of movement of the tape head (L or R), and  a next current state.

Example current state symbol scanned symbol written motion next state q01Rq q10Rq qLh 1.states: q, h  initial state: q  halting states: h 2.tape symbols: 0, 1, 3.transition table: L q h 1 0 R 0 1 R We prefer to present a Turing machine as a state-transition diagram: Transitions in a state-transition diagram for a Turing machine are labeled with ‘triples’ consisting of For clarity, we may depict halting states with a double circle (but we sometimes forget!)

Turing machine: computation A computation of a Turing machine starts in the initial state, with some input sequence of symbols on the tape and the tape head on the left- most symbol of the sequence (if it is non-empty). The machine then repeatedly performs the following operation, until it enters a halting state: on the basis of the current state and the scanned tape symbol it looks up the corresponding row in the table, carries out the appropriate actions (write new symbol, move the tape head), and enters the next state. The sequence that is found on the tape after the computation has halted is its output sequence. We assume that the input sequence is either the empty sequence, or a non-empty sequence of non-blank symbols written consecutively on the tape.

Exercise L q h 1 0 R 0 1 R Consider the following Turing machine: Determine the result of the computation of this Turing machine: input sequenceoutput sequence εε This Turing machine inverts binary sequences.

Constructing Turing machines Example Construct a Turing machine that multiplies a binary number by 2: 0 L 1 1 R 0 0 R qh

Example TM: (unary) multiplication 1R *R R L 1L1L L xxL 11L11L L * * R L R L L xLxL *L*L L 1L1L R L 11R Example The following Turing machine performs multiplication of unary numbers (e.g., on the input sequence 111x11 it yields the output sequence ). An L (or an R) in a state means: go left (or right) after writing the scanned symbol and stay in the same state, unless there is an outgoing arrow with the scanned symbol.

Want to see more? There are many Turing machine simulators available online, for instance, at

Computations may not terminate… Exercise Design a Turing machine that, when started with a non-empty sequence of 0s and 1s on the tape, has a terminating computation only if the binary input sequence on the tape represents an even number: L 1 1 R 0 0 R 1 1 R 0 0 R R 1 1 R R

Turing machines as language acceptors The language of a Turing machine is the collection of all input sequences on which it halts.

R aRaR a a R L q0q0 q1q1 h l L Exercise Question: Which language does it accept? Answer: It accepts the language (aa)*.

Turing machines as language acceptors The language of a Turing machine is the collection of all input sequences on which it halts. It is straightforward to convert a finite automaton into a Turing machine that accepts precisely the same language:  for every input symbol a, replace every transition with label “a” of the finite automaton by a transition with label “a a R”;  add from every accepting state of the finite automaton a transition with label “R” to a new halting state;  add from every non-accepting state of the finite automaton a transition with label “R” to a new state; this new state has, moreover, transitions with labels “a a R” for every input symbol and a transition with label “R” How about the converse? Is every language of a Turing machine accepted by some finite automaton?

Marked palindromes 0L0L RL 1L1L m m R L L R R 1 1 R 0 0 R m m R 0 0 R R R m m R 1 1 R R 0R0R 1R1R R L Exercise Design a Turing machine that accepts the language of marked palindromes (sms -1 with s a sequence of 0s and 1s, and s -1 its reverse).

Marked palindromes Exercise Design a Turing machine that accepts the language of marked palindromes (sms -1 with s a sequence of 0s and 1s, and s -1 its reverse). 0L0L RL 1L1L m m R L L R R 1 1 R 0 0 R m m R 0 0 R R R m m R 1 1 R R 0R0R 1R1R R L

Robustness (example 1) We could modify the definition of Turing machines by adding a third type of motion for the tape head: S for stay at the current position Question: Are Turing machines with an additional S motion for the tape head more powerful than Turing machines with only the motions L and R? Answer: No. We can always transform a Turing machine with S motions to one without S motions, by replacing x y Sx y R? ? L by We mean to express that there is a transition for every symbol in the alphabet of the Turing machine that writes the same symbol back and causes the tape head to move left. The resulting Turing machine computes/accepts the same.

Robustness (example 2) We could (further) modify the definition of Turing machines by having two (or more) tapes. An entry in the transition table would then look like: current state symbol scanned (tape 1) symbol written (tape 1) motion (tape 1) symbol scanned (tape 2) symbol written (tape 2) motion (tape 2) next state … ……………… … q0q0 acLdLq1q1 … ……………… … Question: Are Turing machines with two tapes more powerful than Turing machines with one tape? Answer: No. We can always transform a Turing machine with two tapes to one with one tape computing/accepting the same (see Ch.31 of NTO).

Robustness Turing machines do not get fundamentally more (or less) powerful if we:  allow multiple tapes  allow multi-dimensional tapes  allow tapes that are bounded on one side  allow non-determinism  restrict the alphabet of tape symbols Moreover, every other (realistic) mathematical model of computation conceived so far can be ‘simulated’ with a Turing machine, and hence is not more powerful.

Turing power As computational devices, Turing machines have clearly delineated the fundamental limits of computation: everything that can be computed (now and in the future), can be computed by some Turing machine Disclaimer: This is not to say that a Turing machine can do everything a computer can do. For instance, computers can interact with their environment, which (conventional) Turing machines can’t. As language acceptors Turing machines are (far) more powerful than finite automata (e.g., there exists a Turing machine that accepts the language of marked palindromes, for which there is no finite automaton)

Material Reading material for this lecture: Chapter 31: Turing Machines (see reader) (Slides and practice material can be found in OASE.) Deviations from text in reader: Chapter 31 specifies a Turing machine as a collection of quintuples, instead of with a transition table; the difference is only cosmetic. Chapter 31 uses the symbol b for blank; we prefer. Chapter 31 mentions, besides L and R, also an S-motion for the tape head. It is not needed (as we have seen), we shall not use it, and therefore we left it out from our definition.