Turing Machines Part II

Similar documents
Turing Machines Part II

Announcements. Problem Set 6 due next Monday, February 25, at 12:50PM. Midterm graded, will be returned at end of lecture.

Turing Machines Part III

Turing Machines Part Two

Decidability and Undecidability

A Note on Turing Machine Design

V Honors Theory of Computation

Complexity Theory Part I

CSE 105 THEORY OF COMPUTATION

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

Turing Machine Variants

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

Turing Machines Part One

Theory of Computation (IX) Yijia Chen Fudan University

CPSC 421: Tutorial #1

Announcements. Final exam review session tomorrow in Gates 104 from 2:15PM 4:15PM Final Friday Four Square of the quarter!

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

Computability Theory. CS215, Lecture 6,

CS20a: Turing Machines (Oct 29, 2002)

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

Busch Complexity Lectures: Turing s Thesis. Costas Busch - LSU 1

More Turing Machines. CS154 Chris Pollett Mar 15, 2006.

CS4026 Formal Models of Computation

CSE 105 THEORY OF COMPUTATION

Announcements. Using a 72-hour extension, due Monday at 11:30AM.

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Computational Models Lecture 8 1

Finite Automata Part Two

CSC 5170: Theory of Computational Complexity Lecture 4 The Chinese University of Hong Kong 1 February 2010

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement:

An example of a decidable language that is not a CFL Implementation-level description of a TM State diagram of TM

Computational Models Lecture 8 1

CSCE 551: Chin-Tser Huang. University of South Carolina

The Turing machine model of computation

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

The Church-Turing Thesis

Harvard CS 121 and CSCI E-121 Lecture 14: Turing Machines and the Church Turing Thesis

Turing Machines A Turing Machine is a 7-tuple, (Q, Σ, Γ, δ, q0, qaccept, qreject), where Q, Σ, Γ are all finite

More About Turing Machines. Programming Tricks Restrictions Extensions Closure Properties

Announcements. Problem Set 7 graded; will be returned at end of lecture. Unclaimed problem sets and midterms moved!

Turing s Thesis. Fall Costas Busch - RPI!1

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CSE 105 THEORY OF COMPUTATION

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

Complexity Theory Part II

Computational Models Lecture 8 1

Decidable and undecidable languages

Further discussion of Turing machines

Fooling Sets and. Lecture 5

Exam Computability and Complexity

Introduction to Languages and Computation

Friday Four Square! Today at 4:15PM, Outside Gates

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Turing Machines, diagonalization, the halting problem, reducibility

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

NP, polynomial-time mapping reductions, and NP-completeness

CS5371 Theory of Computation. Lecture 15: Computability VI (Post s Problem, Reducibility)

UNIT-VIII COMPUTABILITY THEORY

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

Finite Automata. Mahesh Viswanathan

Computability and Complexity

Introduction to Turing Machines. Reading: Chapters 8 & 9

Foundations of

Advanced topic: Space complexity

1 Showing Recognizability

CSCE 551: Chin-Tser Huang. University of South Carolina

Turing Machines Part Three

CSE 105 THEORY OF COMPUTATION

An example of a decidable language that is not a CFL Implementation-level description of a TM State diagram of TM

Most General computer?

Mapping Reducibility. Human-aware Robotics. 2017/11/16 Chapter 5.3 in Sipser Ø Announcement:

Theory of Computation

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages

CS20a: Turing Machines (Oct 29, 2002)

1 Unrestricted Computation

Lecture Notes: The Halting Problem; Reductions

Lecture 23: Rice Theorem and Turing machine behavior properties 21 April 2009

Turing Machines. Our most powerful model of a computer is the Turing Machine. This is an FA with an infinite tape for storage.

Homework Assignment 6 Answers

Decidability (What, stuff is unsolvable?)

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

Turing machines and linear bounded automata

SOLUTION: SOLUTION: SOLUTION:

Variations of the Turing Machine

ACS2: Decidability Decidability

Reducability. Sipser, pages

Time-bounded computations

Intro to Theory of Computation

Problems, and How Computer Scientists Solve Them Manas Thakur

Theory of Computation

Space Complexity. The space complexity of a program is how much memory it uses.

Complexity Theory Part I

Undecidable Problems and Reducibility

2017/08/29 Chapter 1.2 in Sipser Ø Announcement:

Decidable Languages - relationship with other classes.

Variants of Turing Machine (intro)

Turing Machines. 22c:135 Theory of Computation. Tape of a Turing Machine (TM) TM versus FA, PDA

CS21 Decidability and Tractability

Transcription:

Turing Machines Part II Problem Set Set Five Five due due in in the the box box up up front front using using a late late day. day.

Hello Hello Condensed Slide Slide Readers! Readers! This This lecture lecture is is almost almost entirely entirely animations that that show show how how each each Turing Turing machine machine would would be be built built and and how how the the machine machine works. works. I've I've tried tried to to condense condense the the slides slides here, here, but but I think think a lot lot got got lost lost in in the the conversion. I would would recommend reviewing reviewing the the full full slide slide deck deck to to walk walk through through each each animation animation and and see see how how the the overall overall constructions work. work. Hope Hope this this helps! helps! -Keith -Keith

The Turing Machine A Turing machine consists of three parts: A finite-state control that issues commands, an infinite tape for input and scratch space, and a tape head that can read and write a single tape cell. At each step, the Turing machine writes a symbol to the tape cell under the tape head, changes state, and moves the tape head to the left or to the right.

, R 0 0, R 0 0, L 1 1, L Go to start 1, L Clear a 1 start, R, L 1, R q acc rej Check for 0 0, R Go to end 0 0, R 1 1, R, R q acc

Key Idea: Subroutines A subroutine of a Turing machine is a small set of states in the TM such that performs a small computation. Usually, a single entry state and a single exit state. Many very complicated tasks can be performed by TMs by breaking those tasks into smaller subroutines.

Turing Machines and Math Turing machines are capable of performing Addition Subtraction Multiplication Integer division Exponentiation Integer logarithms Plus a whole lot more...

Outline for Today List Processing Turing machines that operate on sequences. Exhaustive Search A fundamentally different approach to designing Turing machines. Nondeterministic Turing Machines What does a Turing machine with Magic Superpowers look like? The Church-Turing Thesis (ITA) Just how powerful are Turing machines?

List Processing Suppose we have a list of strings represented as w 1 : w 2 : : w n : What sorts of transformations can we perform on this list using a Turing machine?

Example: Take Odds Given a list of 2n strings encoded as follows: w 1 : w 2 : : w 2n : filter the list to get back just the odd-numbered entries: w 1 : w 3 : : w 2n 1 : How might we do this with a Turing machine?

start Read Symbol 0, R Go to end 0 0, R 1 1, R : :, R, R 0 0, R 1 1, R : :, R Find open, R spot 0, L Back to start Back to List 0 0, L 1 1, L : :, L, L 0 0, L 1 1, L : :, L, R Done! 1, R Go to end 0 0, R 1 1, R : :, R 0 0, R 1 1, R : :, R Find open, R spot 1, L 0, R 1, R :, R Clear next :, R 0 0, R 1 1, R : :, R Go to end, R 0 0, R 1 1, R : :, R Find open spot :, L

Turing Machine Memory Turing machines often contain many seemingly replicated states in order to store a finite amount of extra information. A Turing machine can remember one of k different constants by copying its states k times, once for each possible value, and wiring those states appropriately.

Turing Machines and Lists Turing machines can perform many operations on lists: Concatenate two lists. Reverse a list. Sort a list. Find the maximum element of a list. And a whole lot more!

The Power of Turing Machines Turing machines can Perform standard arithmetic operations (addition, subtraction, multiplication, division, exponentiation, etc.) Manipulate lists of elements (searching, sorting, reversing, etc.) What else can Turing machines do?

The Hailstone Sequence Consider the following procedure, starting with some n N, where n > 0: If n = 1, you are done. If n is even, set n = n / 2. Otherwise, set n = 3n + 1. Repeat. Question: Given a number n, does this process terminate?

52 11 34 17 26 13 40 20 10 16 8 If If n = 1, 1, stop. stop. If If n is is even, even, set set n = n // 2. 2. Otherwise, set set n = 3n 3n + 1. 1. Repeat. Repeat. 5 4 2 1

The Hailstone Sequence Let Σ = {1} and consider the language L = { 1 n n > 0 and the hailstone sequence terminates for n }. Could we build a TM for L?

The Hailstone Turing Machine Intuitively, we can build a TM for the hailstone language as follows: the machine M does the following: If the input is ε, reject. While the input is not 1: If the input has even length, halve the length of the string. If the input has odd length, triple the length of the string and append a 1. Accept.

Does this Turing machine always accept?

The Collatz Conjecture It is unknown whether this process will terminate for all natural numbers. In other words, no one knows whether the TM described in the previous slides will always stop running! The conjecture (claim) that this always terminates is called the Collatz Conjecture.

An Important Observation Unlike the other automata we've seen so far, Turing machines choose for themselves whether to accept or reject. It is therefore possible for a TM to run forever without accepting or rejecting.

Some Important Terminology Let M be a Turing machine. M accepts a string w if it enters the accept state when run on w. M rejects a string w if it enters the reject state when run on w. M loops infinitely (or just loops) on a string w if when run on w it enters neither the accept or reject state. M does not accept w if it either rejects w or loops infinitely on w. M does not reject w w if it either accepts w or loops on w. M halts on w if it accepts w or rejects w. does not reject does not accept Accept Loop Reject halts

The Language of a TM The language of a Turing machine M, denoted L( M), is the set of all strings that M accepts: L(M) = { w Σ* M accepts w } For any w L( M), M accepts w. For any w L( M), M does not accept w. It might loop forever, or it might explicitly reject. A language is called recognizable iff it is the language of some TM. Notation: RE is the set of all recognizable languages. L RE iff L is recognizable

Time Out For Announcements!

Office Hours Schedule We've update our office hours schedule to shift office hours more toward Monday. Check the website for the updated schedule!

Your Questions!

What is your favorite 103 topic and why? Stay Stay tuned... we're about to to get get there!

Worklist Algorithms

A) Double the contents of the string after M. B) Replace III with U. C) Remove UU D) Append U if the string ends in I. MI A MII A MIIII D MIIIIU B MUIU A MUIUUIU C MUIIU

A Recognizable Language Let Σ = { M, I, U } and consider the language L = { w Σ* Using the four provided rules, it is possible to convert w into MU } Some strings are in this language (for example, MU L, MIII L, MUUU L). Some strings are not in this language (for example, I L MI L MIIU L). Could we build a Turing machine for L?

TM Design Trick: Worklists It is possible to design TMs that search over an infinite space using a worklist. Conceptually, the TM Finds all possible options one step away from the original input, Appends each of them to the end of the worklist, Clears the current option, then Grabs the next element from the worklist to process. This Turing machine is not guaranteed to halt.

The Power of TMs The worklist approach makes that all of the following languages are recognizable: Any context-free language: simulate all possible production rules and see if the target string can be derived. Solving a maze use the worklist to explore all paths of length 0, 1, 2, until a solution is found. Determining whether a polynomial has an integer zeros: try 0, -1, +1, -2, +2, -3, +3, until a result is found.

Searching and Guessing

Nondeterminism Revisited Recall: One intuition for nondeterminism is perfect guessing. The machine has many options, and somehow magically knows which guess to make. With regular languages, we could generalize DFAs with NFAs. What happens if we do this for Turing machines?

Nondeterministic TMs A nondeterministic Turing machine (or NTM) is a variant on a Turing machine where there can be any number of transitions for a given state/tape symbol combination. Notation: Turing machine or TM refers to a deterministic Turing machine unless specified otherwise. The term DTM specifically represents a deterministic TM. The NTM accepts iff there is some possible series of choices it can make such that it accepts.

Questions for Now How can we build an intuition for nondeterministic Turing machines? What sorts of problems can we solve with NTMs? What is the relative power of NTMs and DTMs?

Designing NTMs When designing NTMs, it is often useful to use the approach of guess and check: Nondeterministically guess some object that can prove that w L. Deterministically verify that you have guessed the right object. If w L, there will be some guess that causes the machine to accept. If w L, then no guess will ever cause the machine to accept.

Composite Numbers A natural number n 2 is called composite iff it has a factor other than 1 and n. Equivalently: there are two natural numbers r 2 and s 2 such that rs = n. Let Σ = {1} and consider the language L = { 1 n n is composite } How might we design an NTM for L?

A Sketch of the NTM We saw how to build a TM that checks for correct multiplication. Have our NTM Nondeterministically guess two factors, then Deterministically run the multiplication TM. 1 1 1 1 1 1 1 1 1 1

q rej, L start Go left 1 1, L Write = =, L Write 1 st 1 1, L Write 2 nd 1 1, L 1, L Guess 1s 1, L Write 2 nd 1 1, L Write 1 st 1, L Guess 1s 1, L, R run old TM

Nondeterminism and States When working with NFAs, we could think of the NFA as being in multiple states at the same time. You cannot think of NTMs this way. In NFAs, the only memory is the current state. In an NTM, memory includes the current state and the tape contents. If you're using the massive parallelism intuition, think about the machine cloning itself for all possible next steps, with each machine getting its own copy of the tape.

Designing NTMs Suppose that we have a CFG G. Can we build a TM M where L( M) = L( G)? Idea: Nondeterministically guess which productions ought to be applied. Keep the original string on the input tape. Keep guessing productions until no nonterminals remain. Accept if the resulting string matches.

The Story So Far We now have two different models of solving search problems: Build a worklist and explicitly step through all options. Use a nondeterministic Turing machine. Are these two approaches equivalent? That is, are NTMs and DTMs equal in power?

Next Time The Church-Turing Thesis Just how powerful are Turing machines? Encodings How do we compute over arbitrary objects? The Universal Turing Machine Can TMs compute over themselves? The Limits of Turing Machines (ITA) A language not in RE.