computational complexity theory lecture 1: intro; turing machines; class p and np indian institute...

112
Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Upload: august-hubbard

Post on 01-Jan-2016

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Computational Complexity Theory

Lecture 1: Intro; Turing machines; Class P and NP

Indian Institute of Science

Page 2: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

About the courseComputational complexity attempts to

classify computational problems based on the amount of resources required by algorithms to solve them.

Page 3: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

About the courseComputational complexity attempts to

classify computational problems based on the amount of resources required by algorithms to solve them.

Computational problems come in various flavors:

Page 4: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

About the courseComputational complexity attempts to

classify computational problems based on the amount of resources required by algorithms to solve them.

Computational problems come in various flavors:

a. Decision problem Example: Is vertex t reachable from vertex s in graph G? (…output is YES/NO)

Page 5: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

About the courseComputational complexity attempts to

classify computational problems based on the amount of resources required by algorithms to solve them.

Computational problems come in various flavors:

a. Decision problem b. Search problem Example: Find a satisfying assignment of a boolean formula, if it exists.

Page 6: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

About the courseComputational complexity attempts to

classify computational problems based on the amount of resources required by algorithms to solve them.

Computational problems come in various flavors:

a. Decision problem b. Search problem c. Counting problem Example: Find the number of cycles in a graph

Page 7: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

About the courseComputational complexity attempts to classify

computational problems based on the amount of resources required by algorithms to solve them.

Computational problems come in various flavors:

a. Decision problem b. Search problem c. Counting problem d. Optimization problem Example: Find a minimum size vertex cover in a graph

Page 8: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

About the courseComputational complexity attempts to

classify computational problems based on the amount of resources required by algorithms to solve them.

Algorithms are methods of solving problems; they are studied using formal models of computation, like Turing machines.

Page 9: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

About the courseComputational complexity attempts to

classify computational problems based on the amount of resources required by algorithms to solve them.

Algorithms are methods of solving problems; they are studied using formal models of computation, like Turing machines.

• a memory with head (like a RAM)

Page 10: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

About the courseComputational complexity attempts to

classify computational problems based on the amount of resources required by algorithms to solve them.

Algorithms are methods of solving problems; they are studied using formal models of computation, like Turing machines.

• a memory with head (like a RAM)

• a finite control (like a processor)

Page 11: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

About the courseComputational complexity attempts to

classify computational problems based on the amount of resources required by algorithms to solve them.

Algorithms are methods of solving problems that are studied using formal models of computation. E.g. Turing machines. (…more later)

Page 12: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

About the courseComputational complexity attempts to

classify computational problems based on the amount of resources required by algorithms to solve them.

Computational resources (required by models of computation) can be:

• Time (bit operations)• Space (memory cells)

Page 13: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

About the courseComputational complexity attempts to

classify computational problems based on the amount of resources required by algorithms to solve them.

Computational resources (required by models of computation) can be:

• Time (bit operations)• Space (memory cells)• Random bits• Communication (bit exchanges)

Page 14: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity theory

Structural complexity (P, NP, etc.)

Role of Randomness

Approximation algorithms

Average-case complexity

Secrecy & security

Some topics in complexity theory

Page 15: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity theory

Structural complexity (P, NP, etc.)

Role of Randomness

Approximation algorithms

Average-case complexity

Secrecy & security

Some topics in complexity theory

Page 16: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Structural ComplexityClasses P, NP, NP-completeness.

Page 17: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Structural ComplexityClasses P, NP, NP-completeness.

How hard is it to check satisfiability of a boolean formula that has exactly one or no satisfying assignment?

Page 18: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Structural ComplexityClasses P, NP, NP-completeness.Space bounded computation.

Page 19: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Structural ComplexityClasses P, NP, NP-completeness.Space bounded computation.

How much space is required to check s-t connectivity?

Page 20: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Structural ComplexityClasses P, NP, NP-completeness.Space bounded computation.Counting complexity.

Page 21: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Structural ComplexityClasses P, NP, NP-completeness.Space bounded computation.Counting complexity.

How hard is it to count the number of perfect matchings in a graph?

Page 22: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Structural ComplexityClasses P, NP, NP-completeness.Space bounded computation.Counting complexity.Polynomial Hierarchy.

Page 23: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Structural ComplexityClasses P, NP, NP-completeness.Space bounded computation.Counting complexity.Polynomial Hierarchy.

How hard is it to find a minimum size circuit computing the same boolean function as a

given boolean circuit?

Page 24: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Structural ComplexityClasses P, NP, NP-completeness.Space bounded computation.Counting complexity.Polynomial Hierarchy.Boolean circuits and circuit lower

bounds.

Page 25: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Structural ComplexityClasses P, NP, NP-completeness.Space bounded computation.Counting complexity.Polynomial Hierarchy.Boolean circuits and circuit lower

bounds.A central topic in classical complecity theory; Proving P≠NP boils down to showing circuit

lower bounds.

Page 26: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Role of Randomness in Computation

Probabilistic complexity classes.

Page 27: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Role of Randomness in Computation

Probabilistic complexity classes.

• Does randomization help in improving efficiency?

• Quicksort has O(n log n) expected time but O(n^2) worst case time.

• Can SAT be solved in polynomial time using randomness?

Page 28: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Role of Randomness in Computation

Probabilistic complexity classes.Probabilistically Checkable Proofs

(PCPs).

Page 29: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Role of Randomness in Computation

Probabilistic complexity classes.Probabilistically Checkable Proofs

(PCPs).Unconditional hardness of approximation results

Page 30: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Role of Randomness in Computation

Probabilistic complexity classes.Probabilistically Checkable Proofs

(PCPs).A glimpse of randomness extractors

and pseudorandom generators (if time permits).

Page 31: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Role of Randomness in Computation

Probabilistic complexity classes.Probabilistically Checkable Proofs

(PCPs).A glimpse of randomness extractors

and pseudorandom generators (if time permits).Can every polynomial-time randomized

algorithm be derandomized to a deterministic polynomial-time algorithm?

Page 32: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Average-case ComplexityDistributional problems.

Page 33: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Average-case ComplexityDistributional problems.

How hard is it to solve the clique problem on inputs chosen from a “real-

life” distribution?

Page 34: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Average-case ComplexityDistributional problems.Hardness amplification: From weak to

strong hardness.

Page 35: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Average-case ComplexityDistributional problems.Hardness amplification: From weak to

strong hardness.

In cryptographic applications, we need hard functions for secure encryptions.

Page 36: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Basic Course InfoCourse title: Computational Complexity TheoryCredits: 3:1 Instructor: Chandan SahaTA: Vineet Nair ( [email protected] )Class timings : Tuesday, Thursday: 9:30-11am.Venue: CSA lecture hall 117.Primary reference: Computational Complexity

– A Modern Approach by Sanjeev Arora and Boaz Barak.

Page 37: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Basic Course InfoPrerequisites : Basic familiarity with algorithms;

Some mathematical maturity will be helpful.

Grading policy : Assignments - 30%

Scribing – 20% Mid-term - 25% End-term - 25%

Course homepage: drona.csa.iisc.ernet.in/~chandan/courses/complexity15/home.html

Page 38: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Let’s begin…

Page 39: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines

An algorithm is a set of instructions or rules.

To understand the performance of an algorithm we need a model of computation. Turing machine is one such natural model.

Page 40: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines

An algorithm is a set of instructions or rules.

To understand the performance of an algorithm we need a model of computation. Turing machine is one such natural model.

A TM consists of:

• Memory tape(s)• A finite set of rules

Page 41: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing MachinesAn algorithm is a set of instructions or rules.To understand the performance of an algorithm

we need a model of computation. Turing machine is one such natural model.

A TM consists of:

Turing machines A mathematical way to

describe algorithms.

• Memory tape(s)• A finite set of rules

Page 42: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines

An algorithm is a set of instructions or rules.To understand the performance of an

algorithm we need a model of computation. Turing machine is one such natural model.

A TM consists of:

(e.g. of a physical realization a TM is a simple adder)

• Memory tape(s)• A finite set of rules

Page 43: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines

Definition. A k-tape Turing Machine M is described by a tuple (Γ, Q, δ) such that

Page 44: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines

Definition. A k-tape Turing Machine M is described by a tuple (Γ, Q, δ) such that

M has k memory tapes (input/work/output tapes) with heads;

Γis a finite set of alphabets. (Every memory cell contains an element of Γ)

Page 45: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines

Definition. A k-tape Turing Machine M is described by a tuple (Γ, Q, δ) such that

M has k memory tapes (input/work/output tapes) with heads;

Γis a finite set of alphabets. (Every memory cell contains an element of Γ)

has a blank symbol

Page 46: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines

Definition. A k-tape Turing Machine M is described by a tuple (Γ, Q, δ) such that

M has k memory tapes (input/work/output tapes) with heads;

Γis a finite set of alphabets. (Every memory cell contains an element of Γ)

Q is a finite set of states. (special states: qstart , qhalt)

δis a function from Q x Γ to Q x Γ x {L,S,R}

k k k

Page 47: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines

Definition. A k-tape Turing Machine M is described by a tuple (Γ, Q, δ) such that

M has k memory tapes (input/work/output tapes) with heads;

Γis a finite set of alphabets. (Every memory cell contains an element of Γ)

Q is a finite set of states. (special states: qstart , qhalt)

δis a function from Q x Γ to Q x Γ x {L,S,R}

k k k

known as transition function that captures the dynamics of M

Page 48: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines: Computation

Start configuration. All tapes other than the input tape contain

blank symbols. The input tape contains the input string. All the head positions are at the start of the

tapes. The machine is in the start state qstart .

Page 49: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines: ComputationStart configuration.

All tapes other than the input tape contain blank symbols.

The input tape contains the input string. All the head positions are at the start of the tapes. The machine is in the start state qstart .

Computation. A step of computation is performed by applying δ.

Halting. Once the machine enters qhalt it stops computation.

Page 50: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines: Running time

Let f: {0,1}* {0,1}* and T: N N and M be a Turing machine.

Definition. We say M computes f if on every x in {0,1}*, M halts with f(x) on its output tape beginning from the start configuration with x on its input tape.

Page 51: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines: Running time

Let f: {0,1}* {0,1}* and T: N N and M be a Turing machine.

Definition. We say M computes f if on every x in {0,1}*, M halts with f(x) on its output tape beginning from the start configuration with x on its input tape.

Definition. M computes f in T(|x|) time, if M computes f and for every x in {0,1}*, and M halts within T(|x|) steps of computation.

Page 52: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines

In this course, we would be dealing with

Turing machines that halt on every input. Computational problems that can be solved by

Turing machines.

Page 53: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines

In this course, we would be dealing with

Turing machines that halt on every input. Computational problems that can be solved by

Turing machines.

Can every computational problem be solved using Turing machines?

Page 54: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines: Uncomputability

There are problems for which there exists no TM that halts on every input instances of the problem and outputs the correct answer.

Input: A system of polynomial equations in many variables with integer coefficients.

Output: Check if the system has integer solutions . Question: Is there an algorithm to solve this problem?

Page 55: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines: Uncomputability

There are problems for which there exists no TM that halts on every input instances of the problem and outputs the correct answer.

A typical input instance:

x2y + 5y3 = 3

x2 + z5 – 3y2 = 0

y2 – 4z6 = 0

Integer solutions for x, y, z?

Page 56: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines: Uncomputability

There are problems for which there exists no TM that halts on every input instances of the problem and outputs the correct answer.

Input: A system of polynomial equations in many variables with integer coefficients.

Output: Check if the system has integer solutions . Question: Is there an algorithm to solve this problem?

(Hilbert’s tenth problem, 1900)

Page 57: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines: Uncomputability

There are problems for which there exists no TM that halts on every input instances of the problem and outputs the correct answer.

Input: A system of polynomial equations in many variables with integer coefficients.

Output: Check if the system has integer solutions . Question: Is there an algorithm to solve this problem?

Theorem. There does not exist any algorithm (realizable by a TM) to solve this problem.

Page 58: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Why Turing Machines?

Page 59: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Why Turing Machines?

TMs are natural and intuitive.

Church-Turing thesis: “Every physically realizable computation device – whether it’s based on silicon, DNA, neurons or some other alien technology – can be simulated by a Turing machine”.

--- [quote from Arora-Barak’s book]

Page 60: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Why Turing Machines?

TMs are natural and intuitive.

Church-Turing thesis: “Every physically realizable computation device – whether it’s based on silicon, DNA, neurons or some other alien technology – can be simulated by a Turing machine”.

--- [quote from Arora-Barak’s book]Several other computational models can be

simulated by TMs.

Page 61: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Basic facts about TMs

Page 62: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines

Time constructible functions. A function T: N N is time constructible if T(n) ≥ n and there’s a TM that computes the function that maps x to T(|x|) in O(T(|x|)) time.

Examples: T(n) = n2, or 2n, or n log n

Page 63: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines

Time constructible functions. A function T: N N is time constructible if T(n) ≥ n and there’s a TM that computes the function that maps x to T(|x|) in O(T(|x|)) time.

Examples: T(n) = n2, or 2n, or n log n

in binary

Page 64: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines: Robustness

Let f: {0,1}* {0,1}* and T: N N be a time constructible function.

Binary alphabets suffice. If a TM M computes f in T(n) time using Γas the

alphabet set then there’s another TM M’ that computes f in time 4.log |Γ| . T(n)) using {0, 1, blank} as the alphabet set.

Page 65: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines: Robustness

Let f: {0,1}* {0,1}* and T: N N be a time constructible function.

Binary alphabets suffice. If a TM M computes f in T(n) time using Γas the

alphabet set then there’s another TM M’ that computes f in time 4.log |Γ| . T(n)) using {0, 1, blank} as the alphabet set.

A single tape suffices. If a TM M computes f in T(n) time using k tapes

then there’s another TM M’ that computes f in time 5k . T(n)2 using a single tape that is used for input, work and output.

Page 66: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines: As strings

Every TM can be represented by a finite string over {0,1}. …simply encode the description of the TM.

Page 67: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines: As strings

Every TM can be represented by a finite string over {0,1}.

Every string over {0,1} represents some TM. …invalid strings map to a fixed, trivial TM.

Page 68: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines: As strings

Every TM can be represented by a finite string over {0,1}.

Every string over {0,1} represents some TM.

Every TM has infinitely many string representations. … allow padding with arbitrary number of 0’s

Page 69: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines: As strings

Every TM can be represented by a finite string over {0,1}.

Every string over {0,1} represents some TM.

Every TM has infinitely many string representations.

α Mα{0,1} string

TM corresponding to α

Page 70: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Turing Machines: As strings

Every TM can be represented by a finite string over {0,1}.

Every string over {0,1} represents some TM.

Every TM has infinitely many string representations.

A TM (i.e. its string representation) can be given as an input to another TM!

Page 71: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Universal Turing Machines

Theorem. There exists a TM U that on every input x, αin {0,1}* outputs Mα(x).

Further, if Mα halts within T steps then U halts within C. T. log T steps, where C is a constant that depends only on Mα ’s alphabet size, number of states and number of tapes.

Page 72: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Universal Turing Machines

Theorem. There exists a TM U that on every input x, αin {0,1}* outputs Mα(x).

Further, if Mα halts within T steps then U halts within C. T. log T steps, where C is a constant that depends only on Mα ’s alphabet size, number of states and number of tapes.

Physical realization of UTMs are modern day electronic computers.

Page 73: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity classes P and NP

Page 74: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Decision Problems

In the initial part of this course, we’ll focus primarily on decision problems.

Page 75: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Decision Problems

In the initial part of this course, we’ll focus primarily on decision problems.

Decision problems can be naturally identified with boolean functions, i.e. functions from {0,1}* to {0,1}.

Page 76: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Decision Problems

In the initial part of this course, we’ll focus primarily on decision problems.

Decision problems can be naturally identified with boolean functions, i.e. functions from {0,1}* to {0,1}.

Boolean functions can be naturally identified with sets of {0,1} strings, also called languages.

Page 77: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Decision Problems

Decision problems Boolean functions Languages

Definition. We say a TM M decides a language L ⊆ {0,1}* if M computes fL, where fL(x) = 1 iff x∈L.

Page 78: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class P

Let T: N N be some function.

Definion: A language L is in DTIME(T(n)) if there’s a TM that decides L in time c.T(n) for some constant c

Defintion: Class P = ∪ DTIME (nc).c > 0

Page 79: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class P

Let T: N N be some function.

Definion: A language L is in DTIME(T(n)) if there’s a TM that decides L in time c.T(n) for some constant c

Defintion: Class P = ∪ DTIME (nc).c > 0

Deterministic polynomial-time

Page 80: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class P : Examples

Cycle detection (DFS) Check if a given graph has a cycle.

Page 81: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class P : Examples

Cycle detection

Solvabililty of a system of linear equations (Gaussian elimination)

Given a system of linear equations over Q check if there exists a common solution to all the linear equations.

Page 82: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class P : Examples

Cycle detection

Solvabililty of a system of linear equations

Perfect matching (Edmonds 1965) Check if a given graph has a perfect matching

Page 83: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class P : Examples

Cycle detection

Solvabililty of a system of linear equations

Perfect matching

Primality testing (AKS test 2002) Check if a number is prime

Page 84: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Polynomial time Turing Machines

Definition. A TM M is a polynimial time TM if there’s a polynomial function q: N N such that for every input x∈{0,1}*, M halts within q(|x|) steps.

Page 85: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Polynomial time Turing Machines

Definition. A TM M is a polynimial time TM if there’s a polynomial function q: N N such that for every input x∈{0,1}*, M halts within q(|x|) steps.

q(n) = nc for some constant c

Page 86: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Class (functional) P

What if a problem is not a decision problem? Like the task of adding two integers.

Page 87: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Class (functional) P

What if a problem is not a decision problem? Like the task of adding two integers.

One way is to focus on the i-th bit of the output and make it a decision problem.

(Is the i-th bit, on input x, 1?)

Page 88: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Class (functional) P

What if a problem is not a decision problem? Like the task of adding two integers.

One way is to focus on the i-th bit of the output and make it a decision problem.

Alternatively, we define a class called functional P.

Page 89: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Class (functional) P

What if a problem is not a decision problem? Like the task of adding two integers.

One way is to focus on the i-th bit of the output and make it a decision problem.

We say that a problem or a function f: {0,1}* {0,1}* is in FP (functional P) if there’s a deterministic polynomial-time TM that computes f.

Page 90: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class FP : Examples

Greatest Common Divisor (Euclid ~300 BC)

Given two integers a and b, find their gcd.

Page 91: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class FP : Examples

Greatest Common Divisor

Counting paths in a DAG (homework) Find the number of paths between two vetices in a

directed acyclic graph.

Page 92: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class FP : Examples

Greatest Common Divisor

Counting paths in a DAG

Maximum matching (Edmonds 1965) Find a maximum matching in a given graph

Page 93: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class FP : Examples

Greatest Common Divisor

Counting paths in a DAG

Maximum matching

Linear Programming (Khachiyan 1979, Karmarkar 1984)Optimize a linear objective function subject to linear

(in)equality constraints

Page 94: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class NP

Solving a problem is generally harder than verifying a given solution to the problem.

Page 95: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class NP

Solving a problem is generally harder than verifying a given solution to the problem.

Class NP captures the set of decision problems whose solutions are efficiently verifiable.

Page 96: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class NP

Solving a problem is generally harder than verifying a given solution to the problem.

Class NP captures the set of decision problems whose solutions are efficiently verifiable.

Nondeterministic polynomial-time

Page 97: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class NP

Definition. A language L ⊆ {0,1}* is in NP if there’s a polynomial function p: N N and a polynomial time TM M (called the verifier) such that for every x,

x∈L ∃u ∈{0,1}p(|x|) s.t. M(x, u) = 1

Page 98: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class NP

Definition. A language L ⊆ {0,1}* is in NP if there’s a polynomial function p: N N and a polynomial time TM M (called the verifier) such that for every x,

x∈L ∃u ∈{0,1}p(|x|) s.t. M(x, u) = 1

u is called a certificate or witness for x (w.r.t L and M) if x∈L

Page 99: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class NP

Definition. A language L ⊆ {0,1}* is in NP if there’s a polynomial function p: N N and a polynomial time TM M (called the verifier) such that for every x,

x∈L ∃u ∈{0,1}p(|x|) s.t. M(x, u) = 1

It follows that verifier M cannot be fooled!

Page 100: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Complexity Class NP

Definition. A language L ⊆ {0,1}* is in NP if there’s a polynomial function p: N N and a polynomial time TM M (called the verifier) such that for every x,

x∈L ∃u ∈{0,1}p(|x|) s.t. M(x, u) = 1

Class NP contains those problems (languages) which have such efficient verifiers.

Page 101: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Class NP : Examples

Vertex cover Given a graph G and an integer k, check if G

has a vertex cover of size k.

Page 102: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Class NP : Examples

Vertex cover

0/1 integer programming Given a system of linear (in)equalities with

integer coefficients, check if there’s a 0-1 assignment to the variables that satisfy all the (in)equalities.

Page 103: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Class NP : Examples

Vertex cover

0/1 integer programming

Integer factoring Given 3 numbers n, L, U, check if n has a prime

factor between L and U.

Page 104: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Class NP : Examples

Vertex cover

0/1 integer programming

Integer factoring

Graph isomorphismGiven 2 graphs, check if they are isomorphic

Page 105: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Is P = NP ?

Obviously, P ⊆ NP.

Whether or not P = NP is an outstanding open question in mathematics.

Page 106: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Is P = NP ?

Obviously, P ⊆ NP.

Whether or not P = NP is an outstanding open question in mathematics.

Solving a problem does seem harder than verifying its solution, so most people believe that P ≠ NP.

Page 107: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Is P = NP ?

Obviously, P ⊆ NP.

Whether or not P = NP is an outstanding open question in mathematics.

P = NP has many weird consequences, and if true, will pose a serious threat to secure and efficient crytography.

Page 108: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

Is P = NP ?

Obviously, P ⊆ NP.

Whether or not P = NP is an outstanding open question in mathematics.

Complexity theory has several such intriguing unsolved questions.

Page 109: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

A quote by David Hilbert (1862-1943)

“Proofs of impossibility were effected by the ancients… [and] in later mathematics, the question as to the impossibility of certain solutions plays a preminent part…

Page 110: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

A quote by David Hilbert (1862-1943)

“Proofs of impossibility were effected by the ancients… [and] in later mathematics, the question as to the impossibility of certain solutions plays a preminent part…

In other sciences also one meets old problems which have been settled in a manner most satisfactory and most useful to science by the proof of their impossibility…

Page 111: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

A quote by David Hilbert (1862-1943)

“Proofs of impossibility were effected by the ancients… [and] in later mathematics, the question as to the impossibility of certain solutions plays a preminent part…

In other sciences also one meets old problems which have been settled in a manner most satisfactory and most useful to science by the proof of their impossibility… After seeking in vain for the construction of a perpetual motion machine, the relations were investigated which must subsist between the forces of nature if such a machine is to be impossible;

Page 112: Computational Complexity Theory Lecture 1: Intro; Turing machines; Class P and NP Indian Institute of Science

A quote by David Hilbert (1862-1943)

“Proofs of impossibility were effected by the ancients… [and] in later mathematics, the question as to the impossibility of certain solutions plays a preminent part…

In other sciences also one meets old problems which have been settled in a manner most satisfactory and most useful to science by the proof of their impossibility… After seeking in vain for the construction of a perpetual motion machine, the relations were investigated which must subsist between the forces of nature if such a machine is to be impossible; and this inverted question led to the discovery of the law of the conservation of energy…” -- quote taken from Arora-Barak’s

book