Theory of Computation

Similar documents
CSCE 551 Final Exam, Spring 2004 Answer Key

Computational Models Lecture 8 1

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

Announcements. CompSci 230 Discrete Math for Computer Science. The Growth of Functions. Section 3.2

Introduction to Turing Machines

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

Computability and Complexity

Computational Models Lecture 8 1

Chapter 8. Turing Machine (TMs)

Algorithms and Their Complexity

CSE 105 THEORY OF COMPUTATION

Advanced topic: Space complexity

TURING MAHINES

Lecture 12: Mapping Reductions

Computational Models Lecture 8 1

3. Algorithms. What matters? How fast do we solve the problem? How much computer resource do we need?

Discrete Mathematics CS October 17, 2006

CS21 Decidability and Tractability

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

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

1 Showing Recognizability

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

CS151 Complexity Theory. Lecture 1 April 3, 2017

Introduction to Turing Machines. Reading: Chapters 8 & 9

Computation Histories

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

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

CpSc 421 Homework 9 Solution

CS294: Pseudorandomness and Combinatorial Constructions September 13, Notes for Lecture 5

Theory of Computation Lecture Notes. Problems and Algorithms. Class Information

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

V Honors Theory of Computation

Turing Machines and Time Complexity

Time-bounded computations

Q = Set of states, IE661: Scheduling Theory (Fall 2003) Primer to Complexity Theory Satyaki Ghosh Dastidar

CSCC63 Worksheet Turing Machines

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

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Decidability (What, stuff is unsolvable?)

CMPT 710/407 - Complexity Theory Lecture 4: Complexity Classes, Completeness, Linear Speedup, and Hierarchy Theorems

Computability Theory. CS215, Lecture 6,

Chapter 1 - Time and Space Complexity. deterministic and non-deterministic Turing machine time and space complexity classes P, NP, PSPACE, NPSPACE

Theory of Computation

CSCI3390-Assignment 2 Solutions

Computable Functions

Computability Crib Sheet

Turing Machines. The Language Hierarchy. Context-Free Languages. Regular Languages. Courtesy Costas Busch - RPI 1

Turing Machines Part II

Notes for Lecture 3... x 4

Theory of Computer Science. Theory of Computer Science. D7.1 Introduction. D7.2 Turing Machines as Words. D7.3 Special Halting Problem

1 Acceptance, Rejection, and I/O for Turing Machines

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

CS 125 Section #10 (Un)decidability and Probability November 1, 2016

Non-emptiness Testing for TMs

Decidability: Reduction Proofs

Undecidable Problems and Reducibility

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

Most General computer?

15.1 Proof of the Cook-Levin Theorem: SAT is NP-complete

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CSE 105 THEORY OF COMPUTATION

Chapter 2 Algorithms and Computation

COSE215: Theory of Computation. Lecture 21 P, NP, and NP-Complete Problems

COMP 182 Algorithmic Thinking. Algorithm Efficiency. Luay Nakhleh Computer Science Rice University

CS154 Final Examination

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

A Universal Turing Machine

Announcements. CompSci 102 Discrete Math for Computer Science. Chap. 3.1 Algorithms. Specifying Algorithms

Theory of Computation

Great Theoretical Ideas in Computer Science. Lecture 7: Introduction to Computational Complexity

CSE 105 THEORY OF COMPUTATION

1 Circuit Complexity. CS 6743 Lecture 15 1 Fall Definitions

Turing Machine properties. Turing Machines. Alternate TM definitions. Alternate TM definitions. Alternate TM definitions. Alternate TM definitions

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

CS4026 Formal Models of Computation

Busch Complexity Lectures: Turing Machines. Prof. Busch - LSU 1

CPSC 421: Tutorial #1

Verifying whether One-Tape Turing Machines Run in Linear Time

CS 7220 Computational Complexity and Algorithm Analysis

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

Testing Emptiness of a CFL. Testing Finiteness of a CFL. Testing Membership in a CFL. CYK Algorithm

Advanced Undecidability Proofs

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

Further discussion of Turing machines

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

Theory of Computation

198:538 Lecture Given on February 23rd, 1998

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

,

CP405 Theory of Computation

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

Chapter 3: The Church-Turing Thesis

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

Lecture Notes: The Halting Problem; Reductions

Boolean circuits. Lecture Definitions

Part I: Definitions and Properties

Automata Theory CS S-FR2 Final Review

The purpose here is to classify computational problems according to their complexity. For that purpose we need first to agree on a computational

Chapter 6: Turing Machines

Equivalent Variations of Turing Machines

Transcription:

Theory of Computation Unit 4-6: Turing Machines and Computability Decidability and Encoding Turing Machines Complexity and NP Completeness Syedur Rahman syedurrahman@gmail.com

Turing Machines Q The set of finite states Σ The finite set of input symbols Γ The complete set of tape symbols. Σ zγ F A set of finite or accepting states. F z Q δ The transition function, where arguments (q, X) are the current state q and the tape symbol the head is on, X, such that δ(q, X) gives a triple (p, Y, D), the destination state p, the tape symbol Y that will replace X, and the direction the tape head moves afterwards, i.e. or B or Џ The blank tape symbol.

The following Turing Machine M 1 accepts the language expressed as 0 n 1 n where nen n>0. The tape alphabet is {0, 1, X, Y, Џ) where Џ is the blank symbol.

The given Turing Machine is designed to perform proper subtraction on two numbers m and n input on the tape as 0 m 10 n. After the completion of its operation, it leaves 0max(m n, 0) surrounded by blanks on the tape.

Further Reading You should read up on the following topics which were covered in class: A run of a Turing Machine showing each configuration i.e. (tape symbols on left of head, current state, rest of tape symbols) Non-deterministic Turing Machines (not examinable) Multi-tape Turing Machines (not examinable)

Encoding Turing Machines We shall assume the states are q 1, q 2, q 3,, q k for some k, where the start state is q 1 and q 2 is the only accepting state. We shall assume the tape symbols are X 1, X 2, X m for some m. X 1 and X 2 will always be 0 and 1, whereas X 3 will be Џ. Other symbols can be X 4, X 5 etc. We shall refer to directions and as D 1 and D 2 respectively.

A sample encoding M = ({q1, q2, q3}, {0, 1}, {0, 1, Џ}, δ, q1, Џ, {q2}) Where δ consists of the following rules: δ(q1, 1) = (q3, 0, ) δ(q3, 0) = (q1, 1, ) δ(q3, 1) = (q2, 0, ) δ(q3, Џ) = (q3, 1, )

A sample encoding M = ({q1, q2, q3}, {0, 1}, {0, 1, Џ}, δ, q1, Џ, {q2}) Where δ consists of the following rules: Binary Encoding: δ(q1, 1) = (q3, 0, ) 0100100010100 δ(q3, 0) = (q1, 1, ) 0001010100100 δ(q3, 1) = (q2, 0, ) 00010010010100 δ(q3, Џ) = (q3, 1, ) 0001000100010010 Complete Encoding for Machine M 01001000101001100010101001001100010010010100110001000100010010

Decidability Problems that can be solved are called decidable. A language L is recursively enumerable (RE) if L = L(M) for some TM M, i.e. there exists a Turing Machine that will halt and accept when a string that is a member of L is input into it. However, if strings that are not members of L are input into M, the machine may either halt in a non-accepting state or continue to run indefinitely. In any case it will not accept that particular string. For a decidable or recursive language however the TM must not only halt and accept strings which are members of L but it also must halt and reject (by entering a non-accept state) string which are not members of L. Intuitively, all decidable languages are RE but not all RE languages are decidable.

RE but Undecidable: An Example There are Recursively Enumerable languages that are undecidable. E.g. the Universal Language L U consists of pairs (M, w) such that: 1. M is the binary coding of a Turing Machine 2. w is a string of 0 s and 1 s 3. M accepts input w This problem is RE since one can construct the TM M and then run w on it, and M would halt if it is accepted. However we can not be sure what will happen is w is not a member of L(M), so the language is not decidable.

Not RE: An Example Some languages are not recursively enumerable at all. E.g.: The self-diagonalisation language L d, is the set of strings w i such that w i is not in L(M i ). That is L d consists of all strings w such that the TM M whose code is w does not accept when given w as input. Lets say we constructed a TM M i such that L(M i ) = L d and the coding for M i is w i. If w i is in L d, then M i accepts w i. But w i can not be a member of Ld if it is accepted by its machine M i. So w i can not be a member of L d. If w i is not a member of L d, it will not be accepted by M i. So, since w i is not accepted by its own machine M i, w i must be a member of L d. As a result of this contradiction, we conclude such a Turing Machine M i such that L(M i ) = L d can never be constructed so the language L d is not recursively enumerable.

Reduction If we can convert instances of a problem P1 into instances of another problem P2 that have the same answer, then we say that P1 reduces to P2. We can therefore say P2 is at least as hard as P1. Theorem: If P1 is reducible to P2 then: If P1 is undecidable, then so is P2. If P1 is non-re, then so is P2. Please note this does not work the other way round!

Classes P and NP A Turing Machine M is said to be of time complexity T(n) if whenever M is given an input of length n, M halts after making at most T(n) moves, regardless of whether this leads to an accept state. T(n) can be any function. E.g. T(n) = 10n or T(n) = n 2 +10 or T(n) = 2 n +10n We say a language L is in class P if a deterministic TM M exists such that L(M) = L and its time complexity T(n) is a polynomial. We say a language L is in class NP if a non-deterministic TM M exists such that L(M) = L and its time complexity T(n) is a polynomial. Needless to say, all P problems are NP problems as well.

Quick Revision of Complexity Big-O (upper bound): Let f and g be functions from the set of integers or the set of real numbers to the set of real numbers. We say that f(x) is O(g(x)) if there are constants C and k such that: f(x) C g(x) whenever x>k. We say that f(x) grows no faster than g(x). E.g. x 2 + x + 1 is O(x 2 ), can be proved if C=3 and k=2 7x 2 is O(x 3 ), can be proved if C=1 and k=7 x 2 is O(x 2 + x + 1), can be proved if C=1 and k=1 Big-Omega (lower bound): Let f and g be functions from the set of integers or the set of real numbers to the set of real numbers. We say that f(x) is Ω(g(x)) if there are constants C and k such that: f(x) g(x) whenever x>k. Generally if f(x) is Ω(g(x)) then g(x) is O(f(x)). We say that f(x) grows no faster than g(x). Big-Theta (upper and lower bound): Let f and g be functions from the set of integers or the set of real numbers to the set of real numbers. We say that f(x) is Θ(g(x)), if and only if f(x) is O(g(x)) and g(x) is O(f(x)). We say that f(x) is of order g(x).

Commonly Used Terminology for Complexity of Algorithms Complexity O(1) O(log n) O(n) O(n log n) O(n k ) O(k n ), where k>1 O(n!) Terminology Constant Complexity Logarithmic Complexity Linear Complexity n log n Complexity Polynomial Complexity Exponential Complexity Factorial Complexity This list is in order of increasing complexity. n is a variable whereas k is a constant.

P, NP and Reductions Let us assume P1 is reducible to P2. Therefore, in order for an instance of P1 to be reduced to instance(s) of P2, a construction algorithm C must perform some conversion. If P2 is in class P then Is P1 in P?

P, NP and Reductions Let us assume P1 is reducible to P2. Therefore, in order for an instance of P1 to be reduced to instance(s) of P2, a construction algorithm C must perform some conversion. If P2 is in class P then Is P1 in P? Answer: Only if the construction algorithm C is of polynomial time complexity. What if C is of exponential time complexity? If P2 is O(n k ) and C is O(e n ), then P1 is O(n k +e n ) i.e. O(e n ), i.e. P1 is not in class P

NP Complete and NP Hard A language problem L is NP-Complete if: L is in NP For every language L in NP, there is a polynomial-time reduction of L to L. NP-Complete z NP P If L is not in NP, we call it NP-Hard. It is generally acceptable to use intractable to mean NP-Hard and it is enough to show that L can only be solved in exponential time or worse, to prove it is NP-Hard.