Automata Theory CS S-FR2 Final Review

Similar documents
Decidability. Linz 6 th, Chapter 12: Limits of Algorithmic Computation, page 309ff

CSE 105 THEORY OF COMPUTATION

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

Computability and Complexity

Lecture Notes: The Halting Problem; Reductions

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction)

Undecidability. We are not so much concerned if you are slow as when you come to a halt. (Chinese Proverb)

Notes for Lecture Notes 2

Solutions to Old Final Exams (For Fall 2007)

Turing s thesis: (1930) Any computation carried out by mechanical means can be performed by a Turing Machine

Exam Computability and Complexity

1 Computational Problems

SD & Turing Enumerable. Lecture 33: Reductions and Undecidability. Lexicographically Enumerable. SD & Turing Enumerable

} Some languages are Turing-decidable A Turing Machine will halt on all inputs (either accepting or rejecting). No infinite loops.

Decidability: Reduction Proofs

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 8 Nancy Lynch

6.045J/18.400J: Automata, Computability and Complexity. Quiz 2. March 30, Please write your name in the upper corner of each page.

CSE 105 Theory of Computation

Turing Machine Recap

1 Reducability. CSCC63 Worksheet Reducability. For your reference, A T M is defined to be the language { M, w M accepts w}. Theorem 5.

Data Structures and Algorithms

Computability and Complexity

Midterm II : Formal Languages, Automata, and Computability

Reductions in Computability Theory

CS481F01 Solutions 8

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Computational Models Lecture 9, Spring 2009

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 10 Nancy Lynch

CS20a: Turing Machines (Oct 29, 2002)

problem X reduces to Problem Y solving X would be easy, if we knew how to solve Y

CSCE 551 Final Exam, Spring 2004 Answer Key

Turing Machines Part III

Theory of Computation

CS154, Lecture 10: Rice s Theorem, Oracle Machines

There are two main techniques for showing that problems are undecidable: diagonalization and reduction

Automata Theory CS S-18 Complexity Theory II: Class NP

CS154, Lecture 17: conp, Oracles again, Space Complexity

CSE 105 THEORY OF COMPUTATION

Undecidability and Rice s Theorem. Lecture 26, December 3 CS 374, Fall 2015

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

Automata Theory CS Complexity Theory I: Polynomial Time

Undecidable Problems and Reducibility

Lecture 12: Mapping Reductions

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

Theory of Computation

On Rice s theorem. Hans Hüttel. October 2001

Introduction to Turing Machines

Computability Crib Sheet

Decidability and Undecidability

CSE 105 Theory of Computation

CSE 105 THEORY OF COMPUTATION

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

6.045 Final Exam Solutions

BBM402-Lecture 11: The Class NP

Undecidability. Andreas Klappenecker. [based on slides by Prof. Welch]

Non-emptiness Testing for TMs

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

Computational Models Lecture 8 1

Computational Models Lecture 8 1

CSCI3390-Lecture 6: An Undecidable Problem

CSCE 551 Final Exam, April 28, 2016 Answer Key

1 From previous lectures

CP405 Theory of Computation

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

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

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

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

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

Decidability: Church-Turing Thesis

Computational Models Lecture 8 1

Computability Theory. CS215, Lecture 6,

The Unsolvability of the Halting Problem. Chapter 19

Advanced topic: Space complexity

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

1 Showing Recognizability

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CS151 Complexity Theory. Lecture 1 April 3, 2017

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability

CpSc 421 Homework 9 Solution

Introduction to Turing Machines. Reading: Chapters 8 & 9

CSE 105 THEORY OF COMPUTATION

uring Reducibility Dept. of Computer Sc. & Engg., IIT Kharagpur 1 Turing Reducibility

Turing Machines Part Three

Limits of Computability

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

conp, Oracles, Space Complexity

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

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

Turing Machines Part II

Turing Machines and Time Complexity

17.1 The Halting Problem

CPSC 421: Tutorial #1

Equivalent Variations of Turing Machines

Computability and Complexity CISC462, Fall 2018, Space complexity 1

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

4.2 The Halting Problem

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

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

CSCI3390-Lecture 14: The class NP

Transcription:

Automata Theory CS411-2015S-FR2 Final Review David Galles Department of Computer Science University of San Francisco

FR2-0: Halting Problem e(m) e(w) Halting Machine takes as input an encoding of a Turing Machine e(m) and an encoding of an input string e(w), and returns yes if M halts on w, and no if M does not halt on w. Like writing a Java program that parses a Java function, and determines if that function halts on a specific input Halting Machine yes no

FR2-1: Halting Problem Halting Machine takes as input an encoding of a Turing Machine e(m) and an encoding of an input string e(w), and returns yes if M halts on w, and no if M does not halt on w. Like writing a Java program that parses a Java function, and determines if that function halts on a specific input How might the Java version work? Check for loops while (<test>) <body> Use program verification techniques to see if test can ever be false, etc.

FR2-2: Halting Problem The Halting Problem is Undecidable There exists no Turing Machine that decides it There is no Turing Machine that halts on all inputs, and always says yes if M halts on w, and always says no if M does not halt on w Prove Halting Problem is Undecidable by Contradiction:

FR2-3: Halting Problem e(m) e(w) e(m) Prove Halting Problem is Undecidable by Contradiction: Assume that there is some Turing Machine that solves the halting problem. Halting Machine yes no We can use this machine to create a new machine Q: Q e(m) e(m) Halting Machine yes no yes runs forever

FR2-4: Halting Problem e(m) Q e(m) e(m) Halting Machine yes no yes runs forever yes R M DUPLICATE M HALT no yes

FR2-5: Halting Problem Machine Q takes as input a Turing Machine M, and either halts, or runs forever. What happens if we run Q on e(q)? If M HALT says Q should run forever on e(q), Q halts If M HALT says Q should halt on e(q), Q runs forever Q must not exist but Q is easy to build if M HALT exists, so M HALT must not exist

FR2-6: Halting Problem (Java) Quick sideline: Prove that there can be no Java program that takes as input two strings, one containig source code for a Java program, and one containing an input, and determines if that program will halt when run on the given input. boolean Halts(String SourceCode, String Input);

FR2-7: Halting Problem (Java) boolean Halts(String SourceCode, String Input); void Contrarian(String SourceCode) { if (Halts(SourceCode, SourceCode)) while (true); else return; }

FR2-8: Halting Problem (Java) boolean Halts(String SourceCode, String Input); void Contrarian(String SourceCode) { } if (Halts(SourceCode, SourceCode)) else while (true); return; Contrarian("void Contrarian(String SourceCode { \ } "); What happens? if (Halts(SourceCode, SourceCode)) \...

FR2-9: Undecidable Once we have one undecidable problem, it is (easier) to find more Use a reduction

FR2-10: Reduction Reduce Problem A to Problem B Convert instance of Problem A to an instance of Problem B Problem A: Power x y Problem B: Multiplication x y If we can solve Problem B, we can solve Problem A If we can multiply two numbers, we can calculate the power x y

FR2-11: Reduction If we can reduce Problem A to Problem B, and Problem A is undecidable, then: Problem B must also be undecidable Because, if we could solve B, we could solve A

FR2-12: Reduction To prove a problem B is undecidable: Start with a an instance of a known undecidable problem (like the Halting Problem) Create an instance of Problem B, such that the answer to the instance of Problem B gives the answer to the undecidable problem If we could solve Problem B, we could solve the halting problem...... thus Problem B must be undecidable

FR2-13: Reduction Professor Shadey has given a reduction from a problem P new to the Halting Problem Given any instance of P new : Create an instance of the halting problem Use the solution to the halting problem to find a solution for P new What has Professor Shadey shown?

FR2-14: Reduction Professor Shadey has given a reduction from a problem P new to the Halting Problem Given any instance of P new : Create an instance of the halting problem Use the solution to the halting problem to find a solution for P new What has Professor Shadey shown? NOTHING!

FR2-15: More Reductions... Given two Turing Machines M 1, M 2, is L[M 1 ] = L[M 2 ]?

FR2-16: More Reductions... Given two Turing Machines M 1, M 2, is L[M 1 ] = L[M 2 ]? Start with an instance M,w of the halting problem Create M 1, which accepts everything Create M 2, which ignores its input, and runs M,w through the Universal Turing Machine. Accept if M halts on w. If M halts on w, then L[M 2 ] = Σ, and L[M 1 ] = L[M 2 ] If M does not halt on w, then L[M 2 ] = {}, and L[M 1 ] L[M 2 ]

FR2-17: More Reductions... Given two Turing Machines M 1, M 2, is L[M 1 ] = L[M 2 ]? put M 2 M 1 input (ignored) e(m) e(w) Universal Turing Machine (ignored) yes

FR2-18: More Reductions... If we had a machine M same that took as input the encoding of two machines M 1 and M 2, and determined if L[M 1 ] = L[M 2 ], we could solve the halting problem for any pair M,w: Create a Machine that accepts everything (easy!). Encode this machine. Create a Machine that first erases its input, then writes e(m),e(w) on input, then runs Universal TM. Encode this machine Feed encoded machines into M same. If M same says yes, then M halts on w, otherwise M does not halt on w

FR2-19: Rice s Theorem Determining if the language accepted by a Turing machine has any non-trivial property is undecidable Non-Trivial property means: At least one recursively enumerable language has the property Not all recursively enumerable languages have the property Example: Is the language accepted by a Turing Machine M regular?

FR2-20: Rice s Theorem Problem: Is the language defined by the Turing Machine M recursively enumerable? Is this problem decidable?

FR2-21: Rice s Theorem Problem: Is the language defined by the Turing Machine M recursively enumerable? Is this problem decidable? YES! All recursively enumerable languages are recursively enumerable. The question is trivial

FR2-22: Rice s Theorem Problem: Does the Turing Machine M accept the string w in k computational steps? Is this problem decidable?

FR2-23: Rice s Theorem Problem: Does the Turing Machine M accept the string w in k computational steps? Is this problem decidable? YES! Problem is not language related we re not asking a question about the language that is accepted, but about the language that is accepted within a certain number of steps

FR2-24: Rice s Theorem Proof We will prove Rice s theorem by showing that, for any non-trivial property P, we can reduce the halting problem to the problem of determining if the language accepted by a Turing Machine has Property P. Given any Machine M, string w, and non-trivial property P, we will create a new machine M, such that either L[M ] has property P if and only if M halts on w L[M ] has property P if and only if M does not halt on w

FR2-25: Rice s Theorem Proof Let P be some non-trivial property of a language. Two cases: The empty language {} has the property The empty language {} does not have the property

FR2-26: Rice s Theorem Proof Properties that the empty language has: Regular Languages Languages that do not contain the string aab Languages that are finite Properties that the empty language does not have: Languages containing the string aab Languages containing at least one string Languages that are infinite

FR2-27: Rice s Theorem Proof Let M be any Turing Machine, w be any input string, and P be any non-trivial property of a language, such that {} has property P. Let L NP be some recursively enumerable language that does not have the property P, and let M NP be a Turing Machine such that L[M NP ] = L NP We will create a machine M such that M has property P if and only if M does not halt on w.

FR2-28: Rice s Theorem Proof M : Save input Erase input, simulate running M on w Restore input Simulates running M NP on input

FR2-29: Rice s Theorem Proof M : Save input Erase input, simulate running M on w Restore input Simulates running M NP on input If M halts on w, L[M ] = L NP, and L[M ] does not have property P If M does not halt on w, L[M ] = {}, and L[M ] does have property P

FR2-30: Rice s Theorem Proof Let M be any Turing Machine, w be any input string, and P be any non-trivial property of a language, such that {} does not have property P. Let L NP be some recursively enumerable language that does have the property P, and let M P be a Turing Machine such that L[M P ] = L P We will create a machine M such that M has property P if and only if M does halt on w.

FR2-31: Rice s Theorem Proof M : Save input Erase input, simulate running M on w Restore input Simulates running M P on input

FR2-32: Rice s Theorem Proof M : Save input Erase input, simulate running M on w Restore input Simulates running M P on input If M halts on w, L[M ] = L P, and L[M ] does have property P If M does not halt on w, L[M ] = {}, and L[M ] does not have property P

FR2-33: Language Class P A language L is polynomially decidable if there exists a polynomially bound Turing machine that decides it. A Turing Machine M is polynomially bound if: There exists some polynomial function p(n) For any input string w, M always halts within p( w ) steps The set of languages that are polynomially decidable is P

FR2-34: Language Class NP A language L is non-deterministically polynomially decidable if there exists a polynomially bound non-deterministic Turing machine that decides it. A Non-Deterministic Turing Machine M is polynomially bound if: There exists some polynomial function p(n) For any input string w, M always halts within p( w ) steps, for all computational paths The set of languages that are non-deterministically polynomially decidable is NP

FR2-35: Language Class NP If a Language L is in NP: There exists a non-deterministic Turing machine M M halts within p( w ) steps for all inputs w, in all computational paths If w L, then there is at least one computational path for w that accepts (and potentially several that reject) If w L, then all computational paths for w reject

FR2-36: NP vs P A problem is in P if we can generate a solution quickly (that is, in polynomial time A problem is in NP if we can check to see if a potential solution is correct quickly Non-deterministically create (guess) a potential solution Check to see that the solution is correct

FR2-37: NP vs P All problems in P are also in NP That is, P NP If you can generate correct solutions, you can check if a guessed solution is correct

FR2-38: Reduction Redux Given a problem instance P, if we can Create an instance of a different problem P, in polynomial time, such that the solution to P is the same as the solution to P Solve the instance P in polynomial time Then we can solve P in polynomial time

FR2-39: NP-Complete A language L is NP-Complete if: L is in NP If we could decide L in polynomial time, then all NP languages could be decided in polynomial time That is, we could reduce any NP problem to L in polynomial time

FR2-40: NP-Complete How do you show a problem is NP-Complete? Given any polynomially-bound non-deterministic Turing machine M and string w: Create an instance of the problem that has a solution if and only if M accepts w

FR2-41: NP-Complete First NP-Complete Problem: Satisfiability (SAT) Given any (possibly non-deterministic) Turing Machine M, string w, and polynomial bound p(n) Create a boolean formula f, such that f is satisfiable if and only of M accepts w

FR2-42: More NP-Complete Problems So, if we could solve Satisfiability in Polynomial Time, we could solve any NP problem in polynomial time Including factoring large numbers... Satisfiability is NP-Complete There are many NP-Complete problems Prove NP-Completeness using a reduction

FR2-43: Proving NP-Complete To prove that a problem P new is NP-Complete Start with an instance of a known NP-Complete problem NP Use this instance of NP to create an instance of P new, such that the solution of P new gives us a solution to the instance of NP If we could solve P new in polynomial time, we could solve NP in polynomial time, hence P new is NP-Complete

FR2-44: Proving NP-Complete What does it mean if I could reduce a new problem to a known NP-Complete problem?

FR2-45: Proving NP-Complete What does it mean if I could reduce a new problem to a known NP-Complete problem? If I could solve the NP-Complete problem quickly, I could solve the new poblem quickly

FR2-46: Proving NP-Complete What does it mean if I could reduce a new problem to a known NP-Complete problem? If I could solve the NP-Complete problem quickly, I could solve the new poblem quickly But if I could solve the NP-Complete problem quickly, then I could solve any problem quickly

FR2-47: Proving NP-Complete What does it mean if I could reduce a new problem to a known NP-Complete problem? If I could solve the NP-Complete problem quickly, I could solve the new poblem quickly But if I could solve the NP-Complete problem quickly, then I could solve any problem quickly Haven t learned anything

FR2-48: Proving NP-Complete To prove P new is NP-Complete: Need to reduce a know NP-Complete problem to P new Not the other way around Can be confusion the first (or second) time you see it

FR2-49: NP-Complete Problems Undirected Hamilton Cycle is NP-Complete How would we show this?

FR2-50: NP-Complete Problems Undirected Hamilton Cycle is NP-Complete Start with a known NP-Complete problem Reduce the NP-Complete problem to Undirected Hamilton Cycle What would be a good choice, given what we ve already proven NP-Complete in this class?

FR2-51: NP-Complete Problems Undirected Hamilton Cycle is NP-Complete Reduction from Directed Hamilton Cycle Given any instance of Directed Hamilton Cycle: Create an insance of Undirected Hamilon Cycle Show that the solution to Undirected Hamilton Cycle gives solution to Directed Hamilton Cycle

FR2-52: Undir. Ham. Cycle v

FR2-53: Undir. Ham. Cycle v v v 0 1 2