Complexity. Complexity Theory Lecture 3. Decidability and Complexity. Complexity Classes

Similar documents
Complexity Theory 112. Space Complexity

Intro to Theory of Computation

satisfiability (sat) Satisfiability unsatisfiability (unsat or sat complement) and validity Any Expression φ Can Be Converted into CNFs and DNFs

Polynomial Time Computation. Topics in Logic and Complexity Handout 2. Nondeterministic Polynomial Time. Succinct Certificates.

Computability and Complexity

CS151 Complexity Theory. Lecture 1 April 3, 2017

Could we potentially place A in a smaller complexity class if we consider other computational models?

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

CSE 105 THEORY OF COMPUTATION

Advanced topic: Space complexity

Notes for Lecture Notes 2

Chapter 7: Time Complexity

Notes on Complexity Theory Last updated: December, Lecture 2

De Morgan s a Laws. De Morgan s laws say that. (φ 1 φ 2 ) = φ 1 φ 2, (φ 1 φ 2 ) = φ 1 φ 2.

1 Computational Problems

CISC 4090 Theory of Computation

Lecture 16: Time Complexity and P vs NP

Theory of Computation Time Complexity

CS5371 Theory of Computation. Lecture 18: Complexity III (Two Classes: P and NP)

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

CP405 Theory of Computation

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

Computational Complexity

Computability and Complexity CISC462, Fall 2018, Space complexity 1

JASS 06 Report Summary. Circuit Complexity. Konstantin S. Ushakov. May 14, 2006

P and NP. Or, how to make $1,000,000.

Time Complexity (1) CSCI Spring Original Slides were written by Dr. Frederick W Maier. CSCI 2670 Time Complexity (1)

Umans Complexity Theory Lectures

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

Lecture 20: PSPACE. November 15, 2016 CS 1010 Theory of Computation

Computability and Complexity

P vs. NP Classes. Prof. (Dr.) K.R. Chowdhary.

Computational Models Lecture 11, Spring 2009

1 Circuit Complexity. CS 6743 Lecture 15 1 Fall Definitions

NP-Completeness. Algorithmique Fall semester 2011/12

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

NP and Computational Intractability

Lecture 20: conp and Friends, Oracles in Complexity Theory

Exam Computability and Complexity

Lecture 8: Complete Problems for Other Complexity Classes

COL 352 Introduction to Automata and Theory of Computation Major Exam, Sem II , Max 80, Time 2 hr. Name Entry No. Group

Computer Sciences Department

Complexity (Pre Lecture)

CSE 105 Theory of Computation

CSCI3390-Lecture 14: The class NP

1 PSPACE-Completeness

Theory of Computation

Lecture 19: Finish NP-Completeness, conp and Friends

CSE 105 THEORY OF COMPUTATION

Space Complexity. then the space required by M on input x is. w i u i. F ) on. September 27, i=1

Limits of Feasibility. Example. Complexity Relationships among Models. 1. Complexity Relationships among Models

COMPLEXITY THEORY. PSPACE = SPACE(n k ) k N. NPSPACE = NSPACE(n k ) 10/30/2012. Space Complexity: Savitch's Theorem and PSPACE- Completeness

Announcements. Friday Four Square! Problem Set 8 due right now. Problem Set 9 out, due next Friday at 2:15PM. Did you lose a phone in my office?

Turing Machines and Time Complexity

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

SOLUTION: SOLUTION: SOLUTION:

Notes for Lecture 3... x 4

Complexity Theory Part II

Lecture 4 : Quest for Structure in Counting Problems

The Complexity of Optimization Problems

Computability Theory. CS215, Lecture 6,

Review of Complexity Theory

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

Lecture 4. 1 Circuit Complexity. Notes on Complexity Theory: Fall 2005 Last updated: September, Jonathan Katz

Complexity Theory. Knowledge Representation and Reasoning. November 2, 2005

MTAT Complexity Theory October 13th-14th, Lecture 6

P, NP, NP-Complete, and NPhard

CS154, Lecture 13: P vs NP

CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT

BBM402-Lecture 11: The Class NP

Introduction to Complexity Theory

Lecture 17: Cook-Levin Theorem, NP-Complete Problems

CSE200: Computability and complexity Space Complexity

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

The Class NP. NP is the problems that can be solved in polynomial time by a nondeterministic machine.

Computability Theory

POLYNOMIAL SPACE QSAT. Games. Polynomial space cont d

A An Overview of Complexity Theory for the Algorithm Designer

CS154, Lecture 13: P vs NP

CS5371 Theory of Computation. Lecture 23: Complexity VIII (Space Complexity)

1 Non-deterministic Turing Machine

Definition: Alternating time and space Game Semantics: State of machine determines who

CSE 200 Lecture Notes Turing machine vs. RAM machine vs. circuits

CSE 135: Introduction to Theory of Computation NP-completeness

NP-Completeness. Until now we have been designing algorithms for specific problems

Part I: Definitions and Properties

Lecture Notes 4. Issued 8 March 2018

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

COP 4531 Complexity & Analysis of Data Structures & Algorithms

The P-vs-NP problem. Andrés E. Caicedo. September 10, 2011

Principles of Knowledge Representation and Reasoning

Time to learn about NP-completeness!

Lecture 25: Cook s Theorem (1997) Steven Skiena. skiena

Logarithmic space. Evgenij Thorstensen V18. Evgenij Thorstensen Logarithmic space V18 1 / 18

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

6.045 Final Exam Solutions

Lecture 6: Oracle TMs, Diagonalization Limits, Space Complexity

Quantum Computing Lecture 8. Quantum Automata and Complexity

Transcription:

Complexity Theory 1 Complexity Theory 2 Complexity Theory Lecture 3 Complexity For any function f : IN IN, we say that a language L is in TIME(f(n)) if there is a machine M = (Q, Σ, s, δ), such that: L = L(M); and The running time of M is O(f(n)). Anuj Dawar University of Cambridge Computer Laboratory Easter Term 2011 http://www.cl.cam.ac.uk/teaching/1011/complexity/ Similarly, we define SPACE(f(n)) to be the languages accepted by a machine which uses O(f(n)) tape cells on inputs of length n. In defining space complexity, we assume a machine M, which has a read-only input tape, and a separate work tape. We only count cells on the work tape towards the complexity. Complexity Theory 3 Complexity Theory 4 Decidability and Complexity Complexity Classes For every decidable language L, there is a computable function f such that L TIME(f(n)) A complexity class is a collection of languages determined by three things: A model of computation (such as a deterministic Turing machine, or a nondeterministic TM, or a parallel Random Access Machine). A resource (such as time, space or number of processors). If L is a semi-decidable (but not decidable) language accepted by M, then there is no computable function f such that every accepting computation of M, on input of length n is of length at most f(n). A set of bounds. This is a set of functions that are used to bound the amount of resource we can use.

Complexity Theory 5 Complexity Theory 6 Polynomial Bounds Polynomial Time By making the bounds broad enough, we can make our definitions fairly independent of the model of computation. The collection of languages recognised in polynomial time is the same whether we consider Turing machines, register machines, or any other deterministic model of computation. The collection of languages recognised in linear time, on the other hand, is different on a one-tape and a two-tape Turing machine. We can say that being recognisable in polynomial time is a property of the language, while being recognisable in linear time is sensitive to the model of computation. P = TIME(n k ) k=1 The class of languages decidable in polynomial time. The complexity class P plays an important role in our theory. It is robust, as explained. It serves as our formal definition of what is feasibly computable One could argue whether an algorithm running in time θ(n 100 ) is feasible, but it will eventually run faster than one that takes time θ(2 n ). Making the distinction between polynomial and exponential results in a useful and elegant theory. Complexity Theory 7 Complexity Theory 8 Example: Reachability The Reachability decision problem is, given a directed graph G = (V, E) and two nodes a, b V, to determine whether there is a path from a to b in G. A simple search algorithm as follows solves it: This algorithm requires O(n 2 ) time and O(n) space. The description of the algorithm would have to be refined for an implementation on a Turing machine, but it is easy enough to show that: Reachability P 1. mark node a, leaving other nodes unmarked, and initialise set S to {a}; 2. while S is not empty, choose node i in S: remove i from S and for all j such that there is an edge (i, j) and j is unmarked, mark j and add j to S; To formally define Reachability as a language, we would have to also choose a way of representing the input (V, E, a, b) as a string. 3. if b is marked, accept else reject.

Complexity Theory 9 Complexity Theory 10 Example: Euclid s Algorithm Consider the decision problem (or language) RelPrime defined by: {(x, y) gcd(x, y) = 1} The number of repetitions at step 2 of the algorithm is at most O(log x). why? The standard algorithm for solving it is due to Euclid: 1. Input (x, y). 2. Repeat until y = 0: x x mod y; Swap x and y 3. If x = 1 then accept else reject. This implies that RelPrime is in P. If the algorithm took θ(x) steps to terminate, it would not be a polynomial time algorithm, as x is not polynomial in the length of the input. Complexity Theory 11 Complexity Theory 12 Primality Boolean Expressions Consider the decision problem (or language) Prime defined by: The obvious algorithm: {x x is prime} For all y with 1 < y x check whether y x. requires Ω( x) steps and is therefore not polynomial in the length of the input. Is Prime P? Boolean expressions are built up from an infinite set of variables X = {x 1, x 2,...} and the two constants true and false by the rules: a constant or variable by itself is an expression; if φ is a Boolean expression, then so is ( φ); if φ and ψ are both Boolean expressions, then so are (φ ψ) and (φ ψ).

Complexity Theory 13 Complexity Theory 14 Evaluation Boolean Evaluation If an expression contains no variables, then it can be evaluated to either true or false. Otherwise, it can be evaluated, given a truth assignment to its variables. There is a deterministic Turing machine, which given a Boolean expression without variables of length n will determine, in time O(n 2 ) whether the expression evaluates to true. The algorithm works by scanning the input, rewriting formulas according to the following rules: Examples: (true false) ( false) (x 1 false) (( x 1 ) x 2 ) (x 1 false) ( x 1 ) (x 1 ( x 1 )) true Complexity Theory 15 Complexity Theory 16 Rules (true φ) true (φ true) true (false φ) φ (false φ) false (φ false) false (true φ) φ ( true) false Each scan of the input (O(n) steps) must find at least one subexpression matching one of the rule patterns. Applying a rule always eliminates at least one symbol from the formula. Thus, there are at most O(n) scans required. The algorithm works in O(n 2 ) steps. ( false) true

Complexity Theory 17 Complexity Theory 18 Satisfiability Circuits For Boolean expressions φ that contain variables, we can ask Is there an assignment of truth values to the variables which would make the formula evaluate to true? The set of Boolean expressions for which this is true is the language SAT of satisfiable expressions. This can be decided by a deterministic Turing machine in time O(n 2 2 n ). An expression of length n can contain at most n variables. For each of the 2 n possible truth assignments to these variables, we check whether it results in a Boolean expression that evaluates to true. Is SAT P? A circuit is a directed graph G = (V, E), with V = {1,...,n} together with a labeling: l : V {true, false,,, }, satisfying: If there is an edge (i, j), then i < j; Every node in V has indegree at most 2. A node v has indegree 0 iff l(v) {true,false}; indegree 1 iff l(v) = ; indegree 2 iff l(v) {, } The value of the expression is given by the value at node n. Complexity Theory 19 Complexity Theory 20 CVP Composites A circuit is a more compact way of representing a Boolean expression. Identical subexpressions need not be repeated. Consider the decision problem (or language) Composite defined by: {x x is not prime} CVP - the circuit value problem is, given a circuit, determine the value of the result node n. CVP is solvable in polynomial time, by the algorithm which examines the nodes in increasing order, assigning a value true or false to each node. This is the complement of the language Prime. Is Composite P? Clearly, the answer is yes if, and only if, Prime P.