Can You Reduce K-Independent Set to 2-SAT - algorithm

This is a homework question to start out. I just have some questions before I begin.
Our problem is:
"Reduce from k-Independent Set to 2−SAT as follows. Given a graph G with n vertices form n propositions, one per vertex. Each proposition xi for vertex i is set to true iff the vertex i belongs to an indepdenent set. Now for every edge (u,v) write a clause that says both u and v cannot belong to the independent set."
My question is that everything I read says 2-SAT is not an NP-Complete problem. How can we be reducing from the Independent Set problem then?

There is an important difference between finding any independent set and finding a maximum independent set (independent set of maximum size).
Finding any independent set nicely reduces to 2-SAT, using the reduction you described in your question. Neither problem is NP-complete. Note that the reduction you described in your question does not constrain the number of nodes in the independent set in any way. Even the empty set will satisfy the 2-SAT problem that is produced by this reduction, because the empty set also is an independent set!
Finding a maximum independent set (or k-independent set) however is an NP-complete problem. It does not reduce to 2-SAT.
Or in other words: The k in "k-Independent Set" is an additional constraint that is not part of this 2-SAT reduction (that's why the k is not even mentioned in the description of the reduction). You could add additional clauses to the SAT problem to count the number of included nodes and enforce that this number is at least k, but you can't do that by adding only 2-clauses. So adding the k is the step where your 2-SAT problem becomes an NP-complete general SAT problem.
MAX-2-SAT is an NP-complete extension of 2-SAT that can also be used to solve the maximum independent set problem using the reduction you posted. (You'd need two trivial modifications to the reduction: (1) Add 1-clauses for each proposition and (2) duplicate the 2-clauses for weighting.)

Related

The problem complexity of the Maximum Coverage problem with set size constraint (P or NP)

The classic Maximum Coverage (MC) problem is an NP-hard optimization problem. Consider d elements U = {e1, e2, ... ed} and c sets T1, T2 ... Tc. Each set contains some elements in U. The problem aims to find at most b sets, such that the cardinality of the union of these sets is maximized.
For example, T1={e1, e3}, T2={e1, e2, e3} and T3={e3, e4}. When b=2, the optimal solution picks T2 and T3.
I am considering a variation of the classic MC problem, which imposes a set size constraint. Consider 1 < k <= d, if the size of all sets is bounded by k. Call this problem k-MC. Is the problem still NP-hard?
My conjecture is that k-MC is still NP-hard, but I am struggling to come up with a polynomial reduction from a proven NP-hard problem, like MC.
For an arbitrary instance of Maximum coverage, if I could find a polynomial reduction to my problem for all k>1, I can conclude that my problem is also NP-hard.
Here is what I got so far:
When k=d, the problem is trivially equivalent to the classic Maximum Coverage.
When k=d-1, we look at the given MC instance and see if there exist a set with size d. If there is, simply pick that. Otherwise, it reduces to the k-MC problem with k=d-1.
When k is less than d-1, I resort to dynamic programming to complete the reduction. However, this yields a non-polynomial time reduction, which defeat the purpose of reduction from a NP-hard problem.
If anyone could give me some pointers on how I should tackle this problem, or even just make an educated guess on the problem complexity of k-MC (P or NP), I'd really appreciate it.
2-MC is easy -- interpret the sets of size 2 as a graph and run your favorite matching algorithm for non-bipartite graphs. Once you exceed the matching cardinality, you're stuck picking singletons.
3-MC is hard. You can encode an instance of 3-partition as 3-MC by taking the sets to be the triples that sum to the target, then decide if it's solvable by checking coverage for b = n/3.

Puzzle 8 Compatible States

I need to know if is there any algorithm that allows to know beforehand, without searching for every possible solution to the the initial set, if we can reach a second given set.
For example:
[1,0,2,3,5,6,4,8,7] -> [2,3,4,5,8,0,7,1,6]
This algorithm would return True if the second set is reachable from the first one, and False otherwise.
I thought a bit about it and I can certainly say that if the initial set is solvable (it is possible to put all the squares in order) and so is the second one, then this algorithm would return True, because:
[1,2,3,4,5,6,7,0,8] <-> [1,2,3,4,5,6,7,8,0] <-> [1,2,3,4,5,0,7,8,6]
For any given puzzle that is solvable it can be reversed to obtain the original set.
On the other hand, if one of the sets is solvable and the second one is not solvable the algorithm would surely return False because, if you could reach the solvable set starting on the unsolvable set than we would have a contradiction.
Now, the real problem is when both sets are unsolvable. For some reason I'm positive that given an unsolvable set, it is possible to reach any other unsolvable set configuration, since that's what happens when the set is solvable. But I can't find proof or any documentation on it! Can someone enlighten me?
Since there is a finite amount of board states (9! = 362,880), there is a finite amount of translations between a pair for board states (9!^2 = 131,681,894,400 = 17 GB of information). So brute force once, and be happy for ever.

Is finding a subset with exact cut with other given subsets NP-hard?

I am trying to figure out whether the following problem is NP-hard:
Given G_1,..,G_n subsets of {1..m}
c_1,..,c_n non-negative integers in {0..m}
Find T subset of {1..m}
S.T. for all i=1..n, T intersects G_i in exactly c_i elements
I tried to find reductions to NP problems such as coloring, or P problems such as matching, but on both cases could think of exponential conversion algorithm (i.e. one that takes into account all subsets of G_i of size c_i), which doesn't help me much :(
A side note: would any restrictions on the parameters make this problem much easier?
For instance, would m<< n make a computational difference (we would still be looking for an algorithm that is polynomial in m)?
What if we knew that some of the constants c_i were zero?
Would appreciate any insight :)
This is NP-Complete problem, and is a generalization of Hitting Set Problem. Proof of NP-Completeness follows.
The problem is in NP (trivial - given a solution T, it is easy to check the intersection with each of Gi, and verify if its size is Ci).
It is also NP-Complete, assuming you are looking for minimal such T, with reduction from Exact Hitting Set Problem:
Where the decision problem of exact hitting set is:
Given a universe of elements U, subsets S1,...,Sk, and a number
m - is there a subset S of U of size at most m that contains
exactly one element from each Si?
Given instance of hitting-set problem (S1,S2,...Sk,d) - reduce it to this problem with Gi=Si, ci = 1, if the minimal solution of this problem is of size d, there is also a solution to exact hitting set of size d (and vise versa).

SAT/CNF optimization

Problem
I'm looking at a special subset of SAT optimization problem. For those not familiar with SAT and related topics, here's the related Wikipedia article.
TRUE=(a OR b OR c OR d) AND (a OR f) AND ...
There are no NOTs and it's in conjunctive normal form. This is easily solvable. However I'm trying to minimize the number of true assignments to make the whole statement true. I couldn't find a way to solve that problem.
Possible solutions
I came up with the following ways to solve it:
Convert to a directed graph and search the minimum spanning tree, spanning only a subset of vertices. There's Edmond's algorithm but that gives a MST for the complete graph instead of a subset of the vertices.
Maybe there's a version of Edmond's algorithm that solves the problem for a subset of the vertices?
Maybe there's a way to construct a graph out of the original problem that's solvable with other algorithms?
Use a SAT solver, a LIP solver or exhaustive search. I'm not interested in those solutions as I'm trying to use this problem as lecture material.
Question
Do you have any ideas/comments? Can you come up with other approaches that might work?
This problem is NP-Hard as well.
One can show an east reduction from Hitting Set:
Hitting Set problem: Given sets S1,S2,...,Sn and a number k: chose set S of size k, such that for every Si there is an element s in S such that s is in Si. [alternative definition: the intersection between each Si and S is not empty].
Reduction:
for an instance (S1,...,Sn,k) of hitting set, construct the instance of your problem: (S'1 AND S'2 And ... S'n,k) where S'i is all elements in Si, with OR. These elements in S'i are variables in the formula.
proof:
Hitting Set -> This problem: If there is an instance of hittins set, S then by assigning all of S's elements with true, the formula is satisfied with k elements, since for every S'i there is some variable v which is in S and Si and thus also in S'i.
This problem -> Hitting set: build S with all elements whom assigment is true [same idea as Hitting Set->This problem].
Since you are looking for the optimization problem for this, it is also NP-Hard, and if you are looking for an exact solution - you should try an exponential algorithm

solving the Longest-Path-Length. Is my solution correct?

This is the question [From CLRS]:
Define the optimization problem LONGEST-PATH-LENGTH as the relation that
associates each instance of an undirected graph and two vertices with the number
of edges in a longest simple path between the two vertices. Define the decision
problem LONGEST-PATH = {: G=(V,E) is an undirected
graph, u,v contained in V, k >= 0 is an integer, and there exists a simple path
from u to v in G consisting of at least k edges}. Show that the optimization problem
LONGEST-PATH-LENGTH can be solved in polynomial time if and only if
LONGEST-PATH is contained in P.
My solution:
Given an algorith A, that can solve G(u,v) in polytime, so we run the A on G(u,v) if it returns 'YES" and k' such that k' is the longest path in G(u,v), now all we have to do it compare if
k =< k'
if then the longest path length is solved. If we recieve "NO" or k>=k', then there exists no solution.
so polytime to run A + constant for comparsion, then to find the longest path length it takes poly time. Also this is only possible since G(u,v) runs in Polytime (in P), thus G(u,v,k) runs also in polytime (in P), therefore since longest path can be reduced to longest-path-length, then longest-path-length is in P.
we can solve it the oposite way, what we do is, run G(u,v,k') for k'=0 to n, every time check if the k==k', is so we solved it.
run time analysis for this:
n*polytime+ n*(constant comparsion)=polytime
Can someone tell me if my answer is reasonable? if not please tell me where i've gone wrong
Also can you give me some advice to how to study algorithms ,and what approch i should take to solve a algorith question (or a graph question)
please and thankyou
Your answer is reasonable but I would try to shore it up a little bit formally (format the cases separately in a clear manner, be more precise about what polynomial time means, that kind of stuff...)
The only thing that I would like to point out is that in your second reduction (showing the decision problem solves the optimization problem) the for k=0 to N solution is not general. Polynomial time is determined in relation to the length of input so in problems where N is a general number (such as weight or something) instead of a number of a count of items from the input (as in this case) you need to use a more advanced binary search to be sure.

Resources