0% found this document useful (0 votes)
19 views

Module V

The document discusses different complexity classes like P, NP, NP-hard and NP-complete problems. It provides examples of NP-complete problems like circuit satisfiability, 3-CNF satisfiability, clique and vertex cover problems. Reduction proofs are given to show these problems are NP-complete. The subset sum problem is also discussed and reduced from 3-CNF satisfiability problem.

Uploaded by

olu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Module V

The document discusses different complexity classes like P, NP, NP-hard and NP-complete problems. It provides examples of NP-complete problems like circuit satisfiability, 3-CNF satisfiability, clique and vertex cover problems. Reduction proofs are given to show these problems are NP-complete. The subset sum problem is also discussed and reduced from 3-CNF satisfiability problem.

Uploaded by

olu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Theory of Computation – Module V

Programs and Recursive Functions


Church’s Thesis
Collection of functions computed by an algorithm is the same as that computed by
a Turing Machine
Computer programs look like algorithm. Hence functions computed by computer
is same as that by Turing Machine.
Implemented by Universal Turing Machine

Complexity Classes

P Problem
Number of steps is bounded by a polynomial.
Produce correct answer for any input string of length n in at most n k steps, where
k is s constant independent of n.
e.g., Merge sort, Quick sort etc.

NP Problem
Verifiable in polynomial time by a nondeterministic Turing machine. (A non
deterministic Turing machine is a "parallel" Turing machine which can take many
computational paths simultaneously, with the restriction that the parallel Turing
machines cannot communicate.)
A P-problem is always also NP. If a problem is known to be NP, and a solution to
the problem is somehow known, then demonstrating the correctness of the
solution can always be reduced to a single P verification.
If P and NP are not equivalent, then the solution of NP-problems requires (in the
worst case) an exhaustive search.

NP- hard
An algorithm for solving the problem can be translated into one for solving any
other NP-problem.

NP-Complete
A problem which is both NP and NP-hard.
Hardest of NP problems.

NP Complete Examples

1. Circuit Satisfiability
Given a Boolean combinational circuit composed of AND, OR and NOT gates, is
the circuit satisfiable (output is 1).

CIRCUIT-SAT = { <C> : C is a satisfiable boolean combinational circuit.>

http://nutlearners.co.cc –1– http://www.nutlearners.tk


Theory of Computation – Module V

The above problem cannot be solved in polynomial time but can be verified. Hence
it belong to NP category.

2. Formula Satisfiablility
Given a boolean formula circuit, is the formula satisfiable (output is 1).
Given right certificates, can be verified in polynomial time. Hence
problem is NP.
To prove this to be NP-complete, reduce CIRCUIT-SAT to this.
CIRCUIT-SAT p FORMULA-SAT

Steps
i. Name all output lines.

ii. Find AND of all output lines.


= x10 of (x4 x3)
(x5 (x1 x2))
(x6 x4)
(x7 (x1 x2 x4))
(x8 (x5 x6))
(x9 (x6 x7))
(x10 (x7 x8 x9))

3. 3 CNF Satisfiability
Given a boolean formula is in CNF, if it ie expressed as an AND of
clauses, each of which is the OR of one or more literals. A boolean
formula is in 3-CNF, if each clause has exactly three literals. And
satisfiable if output is 1.

http://nutlearners.co.cc –2– http://www.nutlearners.tk


Theory of Computation – Module V

Given right certificates, can be verified in polynomial time. Hence


problem is NP.
To prove this to be NP-complete, reduce FORMULA-SAT to this.
FORMULA-SAT p 3-CNF-SAT

Steps
= ((x1 x2) (( x1 x3) x4)) x2

i. Create parse tree

ii. Create truth table


Find the truth value for each output line. For example, truth value for the
first line can be written as
1 ’ = y1 (y2 x2)

y1 y2 x2 y1 (y2 x2)

1 1 1 0
1 1 0 1
1 0 1 0
1 0 0 0
0 1 1 1
0 1 0 0
1 0 1 1
0 0 0 1

1 ’’
= (y1 y2 x2) (y1 y2 x2) (y1 y2 x2) ( y1
y2 x2)

http://nutlearners.co.cc –3– http://www.nutlearners.tk


Theory of Computation – Module V

Applying de Morgan’s law


1 ’’’ = ( y1 y2 x2) ( y1 y2 x2) ( y1 y2 x2)
(y1 y2 x2)

Similarly find all i’’’s and find the AND of all i’’’s.

iii. If all clauses has three distinct literals, select all. Else
a. If all clause contain two distinct literal, introduce new
literal p. Add two more clauses
(l1 l2 p) and (l1 l2 p)
b. If all clause contain only one literal, introduce two new
literals p and q. Add four more clauses
(l1 p q), (l1 p q), (l1 p q)and (l1 p q)

4. Clique problem
Clique in an undirected graph G = (V, E) is a subset V’ V of vertices,
each pair of which is connected by an edge in E. In other words, a clique is
a complete graph. The size of a clique is the number of vertices it contains.
The clique problem is the optimization problem of finding a clique of
maximum size in a given graph.
CLIQUE = { <G, k> : G is a graph with a clique of size k }
To prove this to be NP-complete, reduce 3-CNF-SAT to this. 3-CNF-SAT
CLIQUE.
Steps

= ( x1 x2 x3 ) ( x1 x2 x3 ) ( x1 x2 x3 ) x1 = 0, x2 =
0, x3 =1

i. Let be a Boolean expression with k clauses. Construct a graph G


such that is satisfiable if and only if graph has a clique of size k.
ii. Graph can be constructed as
a. For each clause Cr = (l1 r l2r l3r) in , place a triple of
vertices v1r, v2r , v3 r into V. Put an edge between two vertices if both
of the following hold.
vir and vjr are in different triples, that is, r s, and
their corresponding literals are consistent, that is, lir
is not the negation of ljs

Please share lecture notes and other study materials that you have
with us. It will help a lot of other students. Send your contributions to
[email protected]

http://nutlearners.co.cc –4– http://www.nutlearners.tk


Theory of Computation – Module V

iii. Each C r contains at least one literal lir that is assigned a, each such
literal corresponds to vertex vir. Pick one such literal from each clause
yields a set V’ of k vertices.

5. Vertex cover problem


Vertex cover in an undirected graph G = (V, E) is a subset V’ V such
that if (u,v) V’, then u V’ or v V’ or both. The clique vertex
cover problem is to find a vertex cover of minimum size in a given graph.
VERTEX-COVER = { <G, k> : G has a vertex cover of size k }
To prove this to be NP-complete, reduce 3- CLIQUE to this. Reduce
CLIQUE VERTEX-COVER

Steps
i. Given G = (V, E), V’ V where V’ is a clique.
ii. Find complement of G, G’ = (V, E ), where E = {(u,v) : u,v V,
u v and (u,v) E }
as graph formed by all edges not in G
iii. Take an edge (u,v) in G’. Either u or v or both are not present
in V’. Hence vertices not present in V’ form cover of G’.

http://nutlearners.co.cc –5– http://www.nutlearners.tk


Theory of Computation – Module V

6. Subset sum Problem


Finding what subset of a list of integers has a given sum .
SUBSET-SET SUM = { <s,t> : there exists a subset S’ S such that t =
S S'
S
Reduce 3-CNF-SAT SUBSET-SUM

Assumptions
1. No clasuse contains variable and its completment ( x i and xi )
2. Include all variables in every clause

e.g. Given a 3-CNF-SAT equation


= (x1 x2 x3 ) ( x1 x2 x3 ) ( x1 x2 x3) (x1 x2 x3)

Steps
1. Add 2 numbers for each varioables and clauses.
2. Form numbers consisting of n+k digits, where n is the number of varioables and k is
the number of clauses
3. Form target as a number of the form 111…444…. Where number of 1’s equal to
number of variables and number of 4’s eqaul to number of clauses.

Table created for is given below.


x1 x2 x3 c1 c2 c3 c4
v1 1 0 0 1 0 0 1
v1' 1 0 0 1 1 1 1
v2 0 1 0 0 0 0 1
v2' 0 1 0 1 1 1 0
v3 0 0 1 0 0 1 1
v3' 0 0 1 1 1 0 0
S1 0 0 0 1 0 0 0
S1' 0 0 0 2 0 0 0
S2 0 0 0 0 1 0 0
S2' 0 0 0 0 2 0 0
S3 0 0 0 0 0 1 0
S3' 0 0 0 0 0 2 0
S4 0 0 0 0 0 0 1
S4' 0 0 0 0 0 0 2
Target 1 1 1 4 4 4 4

S’ can be created as :
1. If xi = 1 pick vi else vi’.
In above example select v1’, v2’, v3.
They will add 1’s to digit corresponding to variables and maximum of 3 to
digits corresponding to variables.
2. Select appropriate slack Si’s to make sum as 4 for clauses.

http://nutlearners.co.cc –6– http://www.nutlearners.tk


Theory of Computation – Module V

In above example select S1, S1’, S2, S2’, S3, S4, S4’.
Hence we have S’ = { v1’, v2’, v3, S1, S1 ’, S2, S2’, S3, S4, S4’}

So we proved that we can reduce 3-CNF-SAT to Subset-Sum problem.


But 3-CNF-SAT is NP-Complete hence Subset-Sum problem is also NP-
Complete.

Please share lecture notes and other study materials that you have
with us. It will help a lot of other students. Send your contributions to
[email protected]

http://nutlearners.co.cc –7– http://www.nutlearners.tk

You might also like