Complexity 6-1 The Class P Complexity Andrei Bulatov.

Slides:



Advertisements
Similar presentations
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Advertisements

Computability and Complexity
Complexity 7-1 Complexity Andrei Bulatov Complexity of Problems.
Complexity 11-1 Complexity Andrei Bulatov NP-Completeness.
Complexity 12-1 Complexity Andrei Bulatov Non-Deterministic Space.
Computability and Complexity 23-1 Computability and Complexity Andrei Bulatov Search and Optimization.
Complexity 15-1 Complexity Andrei Bulatov Hierarchy Theorem.
Complexity 11-1 Complexity Andrei Bulatov Space Complexity.
Computability and Complexity 9-1 Computability and Complexity Andrei Bulatov Logic Reminder (Cnt’d)
Computability and Complexity 13-1 Computability and Complexity Andrei Bulatov The Class NP.
Computability and Complexity 15-1 Computability and Complexity Andrei Bulatov NP-Completeness.
Complexity 5-1 Complexity Andrei Bulatov Complexity of Problems.
The Theory of NP-Completeness
Complexity 19-1 Complexity Andrei Bulatov More Probabilistic Algorithms.
Computability and Complexity 20-1 Computability and Complexity Andrei Bulatov Class NL.
Computability and Complexity 24-1 Computability and Complexity Andrei Bulatov Approximation.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
Lecture 22 More NPC problems
Theory of Computation, Feodor F. Dragan, Kent State University 1 NP-Completeness P: is the set of decision problems (or languages) that are solvable in.
Advanced Topics in Propositional Logic Chapter 17 Language, Proof and Logic.
1 3-COLOURING: Input: Graph G Question: Does there exist a way to 3-colour the vertices of G so that adjacent vertices are different colours? 1.What could.
The class P Section 7.2 CSC 4170 Theory of Computation.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
Complexity 25-1 Complexity Andrei Bulatov Counting Problems.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
Computability Heap exercise. The class P. The class NP. Verifiers. Homework: Review RELPRIME proof. Find examples of problems in NP.
1 Suppose I construct a TM M f which: 1. Preserves its input u. 2. Simulates a machine M b on input ε. 3. If M b hangs on input ε, force an infinite loop.
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 7 Time Complexity Some slides are in courtesy.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
NPC.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
1 1. Which of these sequences correspond to Hamilton cycles in the graph? (a) (b) (c) (d) (e)
Computability Examples. Reducibility. NP completeness. Homework: Find other examples of NP complete problems.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
Theory of Computational Complexity Probability and Computing Chapter Hikaru Inada Iwama and Ito lab M1.
The NP class. NP-completeness
Chapter 10 NP-Complete Problems.
Computational Complexity Theory
Probabilistic Algorithms
Richard Anderson Lecture 26 NP-Completeness
CSC 4170 Theory of Computation The class P Section 7.2.
Polynomial-Time Reduction
Computability and Complexity
Richard Anderson Lecture 26 NP-Completeness
(xy)(yz)(xz)(zy)
CSC 4170 Theory of Computation The class P Section 7.2.
NP-Completeness Yin Tat Lee
Intro to Theory of Computation
Intro to Theory of Computation
Computability and Complexity
Other Models of Computation
CS154, Lecture 16: More NP-Complete Problems; PCPs
ICS 353: Design and Analysis of Algorithms
Richard Anderson Lecture 25 NP-Completeness
1. for (i=0; i < n; i+=2) if (A[i] > A[i+1]) swap(A[i], A[i+1])
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
Theory of Computability
CS21 Decidability and Tractability
NP-Completeness Yin Tat Lee
NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and Johnson, W.H. Freeman and Company, 1979.
CSE 589 Applied Algorithms Spring 1999
Instructor: Aaron Roth
Theory of Computability
CHAPTER 7 Time complexity
Lecture 23 NP-Hard Problems
Presentation transcript:

Complexity 6-1 The Class P Complexity Andrei Bulatov

The Class of “Easy” Problems Complexity 6-2 The Class of “Easy” Problems Requirements to such a class: Practical Must capture the idea of tractable problems Theoretical Must be robust, that is independent of the model of computation Must be closed under substitutions

centuries 3855 6.5 years 58 minutes .059 seconds 366 35.7 12.7 days Complexity 6-3 centuries 3855 6.5 years 58 minutes .059 seconds 366 35.7 12.7 days 17.9 1.0 .001 13.0 5.2 1.7 24.3 3.2 .1 .216 .125 .064 .027 .008 .0036 .0025 .0016 .0009 .0004 .0001 .00006 .00005 .00004 .00003 .00002 .00001 n 60 50 40 30 20 10 Size n Time comp- lexity

Different Models of Computation Complexity 6-4 Different Models of Computation Lemma 1. We can simulate t steps of a k-tape TM with an equivalent one-tape TM in steps. Lemma 2. We can simulate t steps of a RAM computation with a 3-tape TM in steps. It seems that improving our machines we can obtain any polynomial speed-up!

Different Encodings Lemma 3. Complexity 6-5 Different Encodings Lemma 3. For any number n, the length of the encoding of n in base and the length of the encoding of n in base are related by a constant factor (provided ) Lemma 4. For any graph G, the length of the encoding of G as an adjacency matrix, and the length of the encoding of G as a list of edges, are both related by a polynomial factor to the number of vertices It seems that improving encodings we can shorten the input by a polynomial factor!

The Class P Definition Note: Complexity 6-6 The Class P Definition The class P contains all classes TIME[t(n)], where t(n) is a polynomial of finite degree Note:

Complexity 6-7 Robustness of P The class P is the same for all existing models of computation (except for quantum computation) The class P is the same for all existing methods of encoding The class P is said to be robust — it is a mathematical object that does not depend on the exact details of the computational model or encoding In fact, P can be define in ways that do not refer to machines at all (but we will not pursue that idea here)

Complexity 6-8 P  doable? The class P is a reasonable mathematical model of the class of Problems which are tractable or “solvable in practice” However, the correspondence is not exact: When the degree of the polynomial is high then the time grows so fast that in practice the problem is not solvable The constants may also be very large (These problems usually seem to arise only in artificially created problems; for naturally defined problems the polynomials and constants are not too large) Some algorithms, exponential in principal, works satisfactory in practice (e.g. Simplex method for Linear Programming)

Proving a Problem is in P Complexity 6-9 Proving a Problem is in P The most direct way to show that a problem is in P is to give a a polynomial time algorithm that solves it Even a naive polynomial time algorithm often provides a good insight into how the problem can be solved efficiently To find such an algorithm we generally need to identify an approach to the problem that is considerably better than “brute-force” search Because of robustness, we do not generally need to specify all the details of the machine model or even the encoding (e.g. pseudo-code is sufficient)

A Problem in P Greatest Common Divisor (GCD) Complexity 6-10 A Problem in P Instance: 3 integers, a, b and g. Question: Does GCD(a,b)=g? Greatest Common Divisor (GCD) (When g=1 this is equivalent to the problem Relatively Prime)

Proof: GCD(a,b) can be computed by Euclid’s algorithm Complexity 6-11 Proof: GCD(a,b) can be computed by Euclid’s algorithm Function GCD(a,b) : integer begin if b=0 then GCD(a,b):= a else GCD := GCD(b,a mod b) end This algorithm polynomial in the length of the input numbers (logarithmic in their value)

The Satisfiability Problem Complexity 6-12 The Satisfiability Problem Instance: A conjunctive normal form . Question: Is  satisfiable? Satisfiability Instance: A conjunctive normal form  every clause of which contains exactly k literals. Question: Is  satisfiable? k-Satisfiability

Resolution Axioms: a set of clauses Proof rules: resolution Complexity 6-13 Resolution Axioms: a set of clauses Proof rules: resolution C = (X  C), D  X  D C, D  C  D (C  D is called the resolvent of C and D) R

A 2-Satisfiability instance, , is unsatisfiable if and only if    Complexity 6-14 Theorem A 2-Satisfiability instance, , is unsatisfiable if and only if    R Example: (1) (2) (3) (4) (5) Proof: This algorithm works in , because the number of all possible 2-clauses is related by a quadratic factor to the number of variables

A Better Algorithm for 2-Satisfiability Complexity 6-15 A Better Algorithm for 2-Satisfiability Declare all clauses unsatisfied and literals unassigned Select an arbitrary unassigned variable X and assign X true, X false Select an unsatisfied clause Repeat step 3, until either if neither literal is assigned, ignore; if either literal is assigned true, declare clause satisfied; if both are false, restart the algorithm setting X false, and X true. If a conflict occurs again, declare unsatisfiable if one literal false, other unsatisfied, set the other to true, its negation to false, and declare the clause satisfied all clauses are satisfied, return satisfiable All clauses remaining unsatisfied have no variables assigned. In this case return to step 1

Polynomial-time reducibility Complexity 6-16 Polynomial-time reducibility Another way to prove that a problem is in P is to use a reduction Definition A language A is polynomially reducible to a language B , denoted A  B, if a polynomial-time computable function f exists such that for all This fundamental tool of complexity theory was introduced by Karp in 1972

Key Property of Polynomial-time Reducibility Complexity 6-17 Key Property of Polynomial-time Reducibility Lemma A  B and B  P implies A  P Proof: The composition of polynomials is a polynomial

Reductions in P Almost all members of P can be reduced to each other Complexity 6-18 Reductions in P Almost all members of P can be reduced to each other Theorem If B is any language in P, B  , B  *, then for any A  P, A  B Proof: Choose w  B and some w  B. Define the function f by setting Since A  P, f is computable in polynomial-time, and is a reduction from A to B

Colourability Let G  (V,E) be a graph, with nodes V and edges E Complexity 6-19 Colourability Let G  (V,E) be a graph, with nodes V and edges E A function f : V  {1,…,n} is a (proper) colouring if connected nodes are assigned different values ( colours) Instance: A graph G. Question: Is there a colouring of G using at most k colours? k-Colourability (When k = 2 this is equivalent to Bipartite)

2-Colourability  2-Satisfiability Complexity 6-20 2-Colourability  2-Satisfiability We can reduce 2-COLOURABILITY to 2-SATISFIABILITY For each vertex the graph we create a variable For each edge we add two clauses This translation of a 2-COLOURABILITY problem to a 2-SATISFIABILITY problem is computable in polynomial time. Now we check it satisfies the reducibility condition: If graph is 2-colourable, use 2-colouring to assign truth values to variables (one colour is true, the other false) If formula satisfiable, define 2-colouring by setting true variables to colour 1 and false to colour 2, if adjacent vertices get same colour one of the associated clauses is not satisfied, hence must have 2-colouring

An Aside Some problems have been shown to be in P by non-constructive Complexity 6-21 An Aside Some problems have been shown to be in P by non-constructive arguments (i.e. by proving a polynomial time algorithm must exist). E.g. the problem Knotlessness — can a given graph be embedded in 3-dimensional space without knots In these cases we may not even know how to find an exponential algorithm! (See Bovet and Cresceni for more discussion of this)