Complexity - Introduction + Complexity classes

Similar documents
Limitations of Algorithm Power

Tractable & Intractable Problems

Artificial Intelligence. 3 Problem Complexity. Prof. Dr. Jana Koehler Fall 2016 HSLU - JK

CHAPTER 3 FUNDAMENTALS OF COMPUTATIONAL COMPLEXITY. E. Amaldi Foundations of Operations Research Politecnico di Milano 1

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

VIII. NP-completeness

ECS122A Handout on NP-Completeness March 12, 2018

Turing Machines and Time Complexity

Tractability. Some problems are intractable: as they grow large, we are unable to solve them in reasonable time What constitutes reasonable time?

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA.

Computational Complexity. IE 496 Lecture 6. Dr. Ted Ralphs

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

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

NP-Complete Problems and Approximation Algorithms

NP Completeness and Approximation Algorithms

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

The P = NP Problem Bristol Teachers Circle, June P.D.Welch, University of Bristol

Analysis of Algorithms. Unit 5 - Intractable Problems

In complexity theory, algorithms and problems are classified by the growth order of computation time as a function of instance size.

NP-completeness. Chapter 34. Sergey Bereg

NP Complete Problems. COMP 215 Lecture 20

Data Structures in Java

Computer Sciences Department

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

Lecture 19: Finish NP-Completeness, conp and Friends

Lecture 4: NP and computational intractability

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

NP-Completeness. f(n) \ n n sec sec sec. n sec 24.3 sec 5.2 mins. 2 n sec 17.9 mins 35.

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

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

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

Advanced topic: Space complexity

Notes for Lecture 21

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

CS/COE

Computational Complexity

CS 350 Algorithms and Complexity

Introduction to Complexity Theory

Computability Theory. CS215, Lecture 6,

Computational Models Lecture 11, Spring 2009

Computational Complexity

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms

CS 350 Algorithms and Complexity

CS6901: review of Theory of Computation and Algorithms

ECE 695 Numerical Simulations Lecture 2: Computability and NPhardness. Prof. Peter Bermel January 11, 2017

CMPT307: Complexity Classes: P and N P Week 13-1

CMSC 441: Algorithms. NP Completeness

Correctness of Dijkstra s algorithm

NP-Completeness. NP-Completeness 1

Turing Machines Part III

CSC 421: Algorithm Design & Analysis. Spring 2018

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

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

1. Introduction Recap

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

Computational Complexity

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9

Review of unsolvability

UNIT-VIII COMPUTABILITY THEORY

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

6.5.3 An NP-complete domino game

Comparison of several polynomial and exponential time complexity functions. Size n

Computability and Complexity Theory

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

P,NP, NP-Hard and NP-Complete

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

CS3719 Theory of Computation and Algorithms

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

Complexity Theory Part I

ECS 120 Lesson 24 The Class N P, N P-complete Problems

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

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

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

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

CS151 Complexity Theory. Lecture 1 April 3, 2017

1 Showing Recognizability

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

Intractable Problems [HMU06,Chp.10a]

1 Computational problems

Quantum Computing Lecture 8. Quantum Automata and Complexity

1 Computational Problems

NP-Completeness Review

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

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

ITCS:CCT09 : Computational Complexity Theory Apr 8, Lecture 7

Problems, and How Computer Scientists Solve Them Manas Thakur

DESIGN AND ANALYSIS OF ALGORITHMS. Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS

Unit 6 Chapter 17 TRACTABLE AND NON-TRACTABLE PROBLEMS

NP-Completeness. ch34 Hewett. Problem. Tractable Intractable Non-computable computationally infeasible super poly-time alg. sol. E.g.

Notes for Lecture Notes 2

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

Theory of Computation - Module 4

NP-Completeness. Algorithmique Fall semester 2011/12

Data Structures and Algorithms

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: NP-Completeness I Date: 11/13/18

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

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

7.1 The Origin of Computer Science

Computers and Intractability. The Bandersnatch problem. The Bandersnatch problem. The Bandersnatch problem. A Guide to the Theory of NP-Completeness

CS Lecture 29 P, NP, and NP-Completeness. k ) for all k. Fall The class P. The class NP

Transcription:

Complexity - Introduction + Complexity classes Computability - is a problem solvable? Part I: via Turing machines Part II: via Church s Lambda calculus..now.. Part III: Complexity is concerned with how difficult a solvable problem is to solve.. its consumption of resources....not concerned with unsolvable problems. In practice - if a problem cannot be solved in reasonable time it is no better than unsolvable to someone needing the solution. We classify solvable problems into Complexity Classes..

P..the Class of tractable problems that can be solved efficiently (in polynomial time: p-time). intractable problems are solvable but any algorithmic solution runs in exponential time (or slower) in the worst case. Practically unsolvable except for small inputs, unless average case much better than the worst. NP..the class of problems which can be solved in p-time by a non-deterministic algorithm. Do they have deterministic p-time solutions? P = NP? if so, then all NP problems are in P..this has not been proved either way, but it is thought most likely that P NP, so problems in NP \P remain intractable (but not proved to be so). NP-Complete problems..the hardest problems in NP. All NPcomplete problems reduce to each other in p-time. Cook s theorem demonstrates that there are NP-complete problems (i.e. NP-complete is not an empty set)

Why do we study Complexity?.. it guides us towards the tractable problems solvable with fast algorithms...but we often encounter NP-complete problems in practice..so it will avoid (practically) hopeless searches for fast algorithms. the reducibility of every NP-complete problem to every other gives us a higher level view of solvability and the notion of algorithm and its formalism by TMs. We will: define the run time function of a Turing machine introduce non-deterministic TMs and their run-time function formalise fast reduction of one problem to another examine NP and NP-complete problems

Some problems we will use in discussing complexity: 1. The Minimal Spanning Tree problem: Given a connected weighted graph, G, find a spanning tree of the graph which has the shortest total weight. 2. The Hamiltonian Circuit problem: Given a connected graph is there a circuit through the graph which visits each node exactly once. (the start/finish node counts once only) 3. The Travelling Salesman Problem Given a complete weighted graph (there is an edge between every pair of nodes), and a value, d, is there a circuit which visits every node exactly once, with total path weight d?

4. The Propositional Satisfaction Problem (PSAT) We write formulae of propositional logic, with alphabet I which includes: atoms p1, p2, p3,.. connectives ( ) A formula is a word of I - can be input to a TM. PSAT: given a formula A, is A satisfiable? i.e. is there an assignment of true/false values to the atoms of A such that h(a) = true? This has exponential run-time - it is an NP-complete problem.

Definition: Turing Machines for yes/no problems a TM M is said to accept a word w of its input alphabet if M Halts and Succeeds on input w a TM M is said to reject a word w of its input alphabet if M Halts and Fails on input w M solves a yes/no problem A if every instance of A is a word of M s input alphabet and M accepts all yes-instances of A M rejects no-instances of A

Examples of yes/no problems Problem instances yes-instances no-instances is w prime? binary rep. bin. rep. bin. rep. of of numbers of primes non-primes Halting all pairs (code(m),w) all (codem),w) all (code(m),w) Problem M a standard TM, s.t. M H & S s.t. M does not (HP) w a word of C on input w H & S on input w Hamiltonian all finite graphs graphs with a graphs without Circuit Hamiltonian a Hamiltonian Problem (HCP) circuit circuit Travelling all pairs (G,d), pairs (G,d) s.t. pairs (G,d) s.t. Salesman G a weighted graph G has a HC with G has no HC with Problem (TSP) d 0 length d length d

We consider: problems with infinitely many yes-instances and infinitely many no-instances.. if finite.. could hard-wire them into the TM by just recognising whether the input was one of the finite number of (say) yes-instances Halt and Succeed, and otherwise Halt and Fail...with no calculation being done by the TM. yes yes-instances produce yes or no no-instances produce no The result of running a TM to solve a yes/no problem: Halt & Succeed: yes Halt & Fail: no We do not need output on the tape to get a result

The run-time function of a Turing Machine M = (Q,, I, q 0, δ,f) for input words w of length n (n=1, 2, 3..): M runs a varying number of steps for various words w of length n. define time M (n) = length of longest run of M for input of length n the function time M (n) : {0, 1, 2,..} {0, 1, 2,, } is the run-time function of M.

Polynomial-time (p-time) Turing Machines M runs in polynomial time..means there is p(n) = a 0 +a 1 n+a 2 n 2 +a 3 n 3 +..+a k n k (a 0, a 1, a 2, a 3,..a k all non-negative integers) such that time M (n) p(n), all n = 0,1,2,3.. Such a Turing Machine is FAST p-time Turing Machines ALWAYS HALT.

Tractable problems A yes/no problem is tractable if it can be solved by a TM running in p-time intractable if it can be solved algorithmically, but not in p-time An algorithm is tractable if it can be implemented by a p-time TM intractable if it cannot be implemented by a p-time TM. (the Cook-Karp thesis: p-time TMs are fast ). P is the class of tractable problems : i.e. they can be implemented by a p-time TM. The complement of a problem in P: exchange yes and no eg. is n prime? is n composite? complement

co-p: class of complements of problems in P. P is closed under complementation: if problem A P, then the complement of A P. to complement A: M M solves problem A in p-time Halting states No applicable instruction M' Rewire M to Get M solving complementary problem to A in p-time P is closed under complementation

Intractable Problems..some problems have been proved to be intractable (cannot be solved by a p-time Turing Machine)...many problems do not have a tractable algorithm, but have not yet been proven to be either tractable or intractable problems..ie..is there a tractable algorithmic solution?..no proof yet, but considered unlikely. Examples: TSP, HCP, PSAT (propositional satisfaction problem)...characterised by having a finite number of possible solutions (but exponentially rising with the size of the problem instance)..checking one to see whether it is a solution, may be done in p-time..but in general there is an exponential number of these checks to do.

Exhaustive search in algorithms We have seen two main types of yes/no problems: ( ) is there a solution?..solved if we can find one we can check all possibilities, but this is intractable if the no. of possible solutions rises exponentially or ( ) is there NO solution? (complement of problem) we can check all possibilities..intractable if the no. of possible solutions rises exponentially Checking each possible solution can usually be done in p-time eg. HCP, TSP.

Exhaustive search in algorithms..continued A search strategy which homes in on a solution without exhaustive checking can render a problem tractable. eg. Minimum Spanning Tree The types and of problems each subdivide into those ( 1, 1) which have a search strategy, and those ( 2, 2) which have none ( ) problems..eg. is every spanning tree of length > d?..find a MST, calculate its weight, compare with d. this is the complement of a tractable problem. ( 2) and their complements ( 2) remain intractable.. is there a fast strategy to solve them? if so, such a problem is in P.. eg the minimal spanning tree problem if not..these are the NP-complete problems eg. Hamiltonian Circuit, Travelling Salesman

Summary We have introduced: the time function of a Turing Machine polynomial time function (p-time) TMs Tractable and Intractable problems and algorithms Complexity classes of problems P..can be solved by a deterministic TM in p-time (for NP and NP-complete see later lectures).

C240 Computability & Complexity Coursework 1: Sample solution The question asked for a 2-tape Turing machine; it is possible to use just one tape of a 2-tape TM, with the single read head moving between symbols of v and w, comparing them..similar to the is w 1 equal to w 2? TM in the notes, but with matching attempts starting in successive symbols of w, not just the first. Most of the solutions submitted copied either v or w to the second tape, started the first matching attempt with the leftmost symbols of v and w,and moved the read heads right together along v and w matching symbols; when a mismatch is found: if v has all been matched then H & S if the end of w has been reached without all of v matched, H & F else the heads are returned to the start of v and to one square in w after the start of the previous partial match, and symbol-by-symbol comparison of v with w restarts. In the cases where v=ε..h & S as ε is a substring of all strings where w=ε; H & F unless v=ε too. There were other variations: - shifting w left 1 square after each unsuccessful attempt to match, so that both v and unmatched part of w started in square 0 this was used in some 1-tape solutions using 2 tracks. -matching v starting with the last symbol of v and moving the heads together to the left; the first matching attempt either starting with the last symbol of w and successive attempts starting from 1 square further to the left each time, or starting with the leftmost possible match in the m th symbol of w with successive attempts starting 1 square to the right.

The Substring Turing machine ((x,^),(x,x),(1,1) if x ((x,y),(x,y),(0,-1)) if Head 2 not at squ 0 ((x,y),(x,y),(1,0) if x, and x and y ((*,^),(*,*),(1,0)) Copy-v Hd2-to-0 ((x,y),(x,y),(0,0)) Match-v 1 if Head 2 at squ 0 ((x,y),(x,y),(1,0)) if Head 2 at squ 0 ((x,x),(x,x),(1,1)) ((x,y),(x,y).(-1,-1)) if Head 2 not at squ 0 ((*,^),(*,^),(0,0)) H & S ((x,*),(x,*),(0,0)) Match-v i ((x,x),(x,x),(1,1)) ((x,y),(x,y),(0,0)) if x and x and y Try-again

Time Function. Worst case: for n> m, is where the first m-1 symbols of v match starting at each symbol of w: Eg w = aaaa aaa, v = aaab. n-m n Number of steps: Copy-v: m Transition to Hd2-to-0: 1 Hd2-to-0: m Transition to Match-v 1 : 1 Initialisation total: 2m+2 m For each of n-m+1 attempts to match v with w: Match v 1 to Match-v i :1 Transition to Try-again:1 Try-again: m-1 Transition to match-v 1 : 1 total for matches within w: ( n-m+1)x(2m+1) Final match attempt (fails at end of w) (no rewind) 1+m-1 TOTAL: 2m+2 +2mn+n-2m 2 -m+2m+1 +1+m-1 = 2mn-2m 2 +n+4m+3=2m(n-m+2) +(n+2)