43
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen

zeph-nieves
• Category

## Documents

• view

41

3

description

CSCI 4325 / 6339 Theory of Computation. Zhixiang Chen. Chapter 6 Computational Complexity. NP. NP-complete. P. The New World. Polynomially Bounded TM’s. Definition. A TM M=(K, ∑, δ ,s,H) is said to be polynomially bounded if there is polynomial p(n) such that the following is true: - PowerPoint PPT Presentation

### Transcript of CSCI 4325 / 6339 Theory of Computation

CSCI 4325 / 6339Theory of Computation

Zhixiang Chen

Chapter 6 Computational Complexity

The New World

P

NP

NP-complete

Polynomially Bounded TM’s

Definition. A TM M=(K,∑,δ,s,H) is said to be polynomially bounded if there is polynomial p(n) such that the following is true: For any input x, the computation of M on x ends in

no more p(|x|)+1 steps.

Polynomially Decidable Languages Definition. A language is called polynomially

decidable is there is a polynomially bounded TM that decides it.

The Class P

Definition. The class P is the set of all polynomially decidable languages.

Examples. The set of even integers The set of connected graphs Other examples?

Quantitative Refinement of the Church-Turing Thesis Any problem which is intuitively feasibly

solvable is solvable by a polynomially bounded TM.

Any problem which is solvable by a polynomially bounded TM is intuitively feasibly solvable.

Theorem

Theorem 6.1.1. The class P is closed under complement.

Proof. (Prove in class.)

Something not in P

Definition. Define E={encode(M)encode(w):

M accepts w in but steps}

Theorem. Proof. By contradiction. Consider a special case of E:

M accepts encode(M) but

steps}

Prove

1||2 w

||2 w

.PE

:)({1 MencodeE ||2 w

1||2 w

.1 PE

New Notations

For simplicity We use “M” to denote the encode(M) of a TM M We also use “w” to denote the encode(w) of a

string w.

Some Coments

Comments on polynomial time bounded decidability Practically feasible? It’s based on worst-case performance analysis How about average-case performance analysis?

Problems vs. Languages

Given any TM M and any input w, will M halts on w? This is a problem.

Define This is a language.

The fact The problem and the language are equivalent!

}:"""{" wonhaltsMwMH

Problems vs. Languages

Given any string w, will w have property P? This is a problem.

Define This is a language.

The fact again The problem and the language are equivalent!

Conclusion: A problem is a language. A language is a problem.

}:{ PpropertyhaswwH

Eulerian Graphs

Euler Cycle Problem: Given a graph G, is there a closed path in G that uses each edge exactly once?

A graph that has a Euler cycle is called Eulerian.

Ex’s

Eulerian Graphs

Euler Cycle Problem is in P. That is,

is in P.

Proof. By Euler Theorem: Euler Theorem. A graph G is Eulerian iff the following two

conditions are true: For any pair of nodes u, v in G, there is a path from u to v. All nodes have equal numbers of incoming and outgoing

edges

}:)({ EulerianisGGL

Hamiltonian Graphs

Hamilton Cycle Problem: Given a graph G, is there a cycle that passes through each node of G exactly once?

A graph with a Hamilton cycle is called Hamiltonian

Is Hamilton Cycle Problem in P? Do you know the answer? Do you have an algorithm for solving Hamilton

Cycle Problem? What is the complexity of your algorithm?

Yes/No Problems

A yes/no problem is a problem with a yes or no answer.

Euler Cycle Problem and Hamilton Cycle Problem are yes/no problems.

Optimization Problems

Traveling Salesman Problem. Given a weighted graph G, find a shortest path touring all nodes in a graph.

Translate Optimization Problem to Yes/No Problem: Given an integer and an distance matrix and

an integer find a Hamiltonian cycle with distance

The above optimization problem and the yes/no problem are “equivalent”.

In general, any optimization problem can translated to an “equivalent” yes/no problem.

nn

.B

,2n ,ijd

,0B

Independent Set Problem

Given an undirected graph G=(V,E) and an integer

is there a subset C of V with

such that for all there is no edge between and

Ex’s?

KC ||

Vvu ji ,

,2K

iu ?jv

Clique Problem

Given an undirected graph G=(V,E) and an integer

is there a subset C of V with

such that for all there is an edge between and

Ex’s?

KC ||Cvu ji ,

,2K

iu ?jv

Node Cover Problem

Given an undirected graph G=(V,E) and an integer

is there a subset C of V with

such that C covers all edges of G?

Note: C covers an edge if it contains at least on endpoint of the edge.

Ex’s?

BC ||,2B

Integer Partition Problem

Given a set of n nonnegative integers

represented in binary, is there a subset

such that

Ex’s?

},,2,1{ nP

?

Pi

iPi

i aa

naaa ,,, 21

Solution to Integer Partition Problem Compute If H is not an integer then stop and say no Otherwise compute B(i) for

b is the sum of some subset of }

Algorithm for computing B(i): B(0)={0} For do

For do

:{)( HbiB },,{ 1 iaa

n

iiaH

12

1

)1()( iBiB

ni ,,2,1

Haaaj iii ,,2,1, )1( iBaj i

j

Example

Work on the following set of integers to determine the answer to the partition problem.

H = 151 B(0) = {0} B(1) = {0, 38} B(2) = {0, 17, 38, 55} B(3) = {0, 17, 38, 52, 55, 69, 90, 107} B(4) = {0, 17, 38, 52, 55, 61, 69, 78, 90, 107, 113, 116, 130, 151} … B(7) = {…, 151} Answer: yes.

.25,88,21

,61,52,17,38

765

4321

aaa

aaaa

Complexity of the Algorithm for Computing B(i) The complexity if O(nH)

Outer loop runs n times Inner loop runs H times

So, it the Partition Problem in P? Just from O(nH), it seems the problem in P. What is wrong???????

Boolean Satisfiability Problem Definition.

Let be a finite set of Boolean variables, and let be the set of negations of variables in X.

Call elements in as literals

Negations of variables are called negative literals.

},,,{ 21 nxxxX

},,,{ 21 nxxxX

XX

Boolean Satisfiability Problem Definition.

Clause: A clause C is a nonempty set of literals, i.e.

Boolean formula in CNF: A Boolean CNF is a set of clauses

.XXC

Examples

Let

Clauses:

CNF:

},,,{},,,{ 321321 xxxXxxxX

},,{},,,{ 321321 xxxxxx

}},,{},,,{},,{{ 32132121 xxxxxxxx

Boolean Satisfiability Problem Truth Assignment:

a map from X to {0,1} 0 means false 1 means true

A clause is true under an assignment if that assignment make at least of its literals true.

A CNF is true under an assignment if that assignment makes all clauses true.

A CNF is satisfiable, if there is an assignment making it true.

Ex’s?

.XXC

Boolean Satisfiability Problem The SAT Problem: Given a Boolean CNF F,

is F satisfiable? The 2-SAT Problem: Given a Boolean CNF F

such that each clause in F has at most two literals, is F satisfiable?

The 3-SAT Problem: Given a Boolean CNF F such that each clause in F has at most three literals, is F satisfiable?

2-SAT Problem

Theorem. 2-SAT is in P.

2-SAT Problem Algorithm solving 2-SAT

Phase 1. Purge Process Repeat

Scan clause in the input CNF F to find a single literal x Set x to be true. And remove all clauses with x from F, and

remove negative x from these clause containing negative x Fail if an empty clause is generated, and stop and say no.

Until no more single clause in F. Phase 2. Try Two Values Process

Repeat Choose a literal x in the remained F

Set x to be true, and do “Purge Process” Set x to be false and do “purge Process”

If both processes fail, then stop and say no. Until no more literal left.

Phase 3. Final Checking Say true, if no fail occurs in Phase 2.

2-SAT Problem

The complexity of previous algorithm Let n be the number of distinct variables in F Let m be the number of clauses in F Phase 1 Time

Phase 2 time

Total time

Conclusion. 2-Sat is in P.

)( 2mnO

)( 2mnO

)(nmO

Nondeterministic Ploynomially Bounded TM’s Definition. A NTM M=(K,∑,Δ,s,H) is said to

be polynomially bounded is there is polynomial p(n) such that the following is true: For any input x, all possible computations of M on

x ends in no more p(|x|)+1 steps. In other words, the depth of the computation tree

of M on x is no more than p(|x|)+1.

The NP Class

Definition. The class NP is the set of all languages that are decided by ploynomially bounded NTM’s

Poly-Bounded Computation Trees )_,( s

),( vauh

………………Tree depth p(|w|)

Problems in NP

Problems in NP: SAT Hamilton Cycle Problem TSP Independent Set Problem Clique Problem Covering Problem Partition Problem

Proving a Problem in NP

Two steps: Nondeterministically guess an answer in poly-time Deterministically verify the guessed answer is

Show proof examples in class.

Exponentially Bounded Deterministic TM’s Definition. A TM M=(K,∑,δ,s,H) is said to be

exponentially bounded is there is polynomial p(n) such that the following is true: For any input x, the computation of M on x ends in no

more than steps.|)(|2 xp

The Class EXP

Definition. The class EXP is the set of all problems that are decidable by exponentially-bounded TM’s.

P, NP, vs. EXP

Theorem. If L is in NP, then L is in EXP. Proof. A poly-bounded computation tree can be

simulated an exponentially bounded computation.

Theorem. Proof. Consider the exponentially bounded version

of H.

.EXPP

The New World

P

NP

EXP

Open Questions

EXPNP

NPP

?

?