- for any each element , it appears in exactly one triplet ,
- sum of every triplet is the same
Let 3DM be the decision version of 3-dimensional matching that given the sets , decide whether there exists a 3-dimensional matching satisfying the properties above. An instance of 3DM is defined as .
Let XYL be the decision problem that given two sets of natural numbers and (they can be multi-sets, too) where and and decide if it is possible to form triples such that and and all the triples have the same sum, and each element is used exactly once. An instance of XYL is defined as .
It is well-known that 3DM is -complete, show that is -complete.
Hint: what if you add a big number to every element in (or or both)?
In order to prove that XYL is NP complete, we will use a karp reduction. Firstly let's note that XYL is in NP, this is true because given a collection of triples satisfying the constraints, we can easily verify that they all have the correct properties in polynomial time with respect to the size of the input.
Now moving to the reduction, what we must do is to take an instance of 3DM and in polynomial time, we must construct an instance of XYL, and then prove that the answer to 3DM is yes if and only if the answer to XYL is yes.
Suppose we have an instance of 3DM, let and define , we construct the instance of XYL by using . Now suppose that the answer to 3DM with the instance is yes, therefore we have the set satisfying all the properties listed in the question. Since we get triples, then for any two triples of the form , we know that , therefore we conclude also that this is because applying simply just adds a constant to each side, but we observe that the triples and are arbitrary triples in having the same sum and there are exactly of these triples (by mapping the original ones through ), thus we've just shown there are triples all having the same value using each value exactly once (since is an injection). So the answer to XYL is yes.
Suppose that the answer to XYL is yes, so that we have tuples using each value exactly once, and all having the same sum. Without further inspection it seems that a tuple of the form or may be possible to exist within the tuples, but we will actually prove that specifically it must be of the form , that is to say, we cannot use two elements of nor two elements of as part of any tuple.
With different tuples, we must have that each that each element of is used exactly once, if they were not they we wouldn't not be able to form tuples or if we go over, one of them would be duplicated. Now, there are two situations, either there will exist a tuple of the form or or else they will all be of the form (up to a re-ordering) .
In the initial case of , we observe that by the definition of , but since will exist in exactly one tuple (or else we cannot create tuples), then clearly this specific tuple will have a sum which is greater and thus not equal to the sum of , which contradictions our assumption that XYL answers yes.
Similarly suppose there is a triple of the form , since another tuple of the form cannot exist as just noted, then there must be a tuple of the form , we'll note
and then a chain of inequalities
Therefore we've found two tuples which have different value within they tuples that supposedly all had the same value which is a contradiction, so every tuple is of the form . With that said there is a simple injective mapping which takes this tuple to the tuple , which is a valid element of 3DM, we also note that if then we know that as the function only adds a constant to each side. Therefore by using this injective mapping, we produce tuples for 3DM, each of which have the same sum, and since the tuples in XYL used each element exactly once, then this property also holds when in 3DM, therefore these tuples form a 3-dimensional matching and so the answer to 3DM is yes, as needed.
Thus we know that XYL is in NP and we've found a reduction from an NP-complete problem to it, thus we can conlude that XYL is NP-complete as needed.
We'll show that , since , if it was NP-hard, then which we assume is false, so we know that cannot be the case.
To show it's in we must construct a polynomial time solution with respect to the size of the input. Before we do this we'll note the following:
Suppose that we have some formula that has clauses and varaibles, construct a bi-partite graph by putting a node for each clause on the left, and then a node for each varaible on the right. Connect from left to right by taking some clause and then connecting it to every varaible used in that clause. Note that a perfect matching in this graph induces a valid truth assignment, this is because in the matching every variable is assigned to some clause, and so for those varaibles we set them to be true, if the negation of that variable is used in the clause set it to false. This means that at least one term in the clauses evaluates to true, since this holds for all clauses the entire statement evaluates to true because of the structure of conjuctive normal form.
Note that this all relies on the fact that we can produce a perfect matching, recall Hall's Marriage theorem which states that you can find a perfect matching for some bi-partite graph iff for any , . We'll now focus on showing this property so that we can always find a perfect matching.
Let such that , for each clause in there are four edges going out into because each clause uses 4 unique variables, at the same time, for any variable it has at most edges going into it this is because each variable is used at most four times. If then they could only intake for some incoming edges, but we need them to be able to intake , which is impossible, and therefore we must have that
Therefore we can conclude that there is always a perfect matching, and thus every formula is satisfiable. What this means that there is a polynomial algorithm to answer the decision problem, it simply returns true, and runs in constant time, which is what we need for our initial paragraph to make sense.
For example given the set then we can take the subsets and where both have sum . So the answer is yes. For in this case you cannot, so the answer is no.
We will do a karp reduction to show that . Suppose we are given an instance of subset sum, so that we have some finite set and a target value , and we want to construct an instance of set partition such that it will answer yes iff subset sum answers yes.
Recall that if set partition finds a solution, then the value that both partitions sum to is exactly half that of the original set. We can use this to our advantage.
We do a reduction from set partition. Suppose that , which then is an instance of set partition, and let . We construct an instance of squared sum partition with and with integers
Suppose that is a solution to the set partition problem, therefore , therefore we have that which shows that squared sum partition holds true.
Suppose that is a solution to the squared sum partition problem, so we have that for the sake of contradiction let's assume that , since we know that since they form a partition then we know that there exists some such that wlog and , if that's true then we have and this is a contradiction because we require that , therefore we must have that which means that set partition holds true.
- Input: An undirected graph and an integer .
- Question: Is there a partition of into such that at least edges have one endpoint in and the other in ?
- Input: A 2-CNF formula and an integer . (In a 2-CNF formula, each clause has exactly two literals.)
- Question: Does there exist a truth assignment under which at least clauses of are satisfied?
Max-2-sat is in NP because given a truth assignment we just verify that at least clauses of hold true which can be done in polytime.
Next we'll make a reduction starting with an instance of max-cut . Start by making variables for each and for each edge we create the clauses and .
We'll next show that for each cut, we can define a unique truth assignment associated with it. To do this if we have the cut having a cut with edges. Then we simply construct the assignment . Then for each edge in the cut,
Note that we can partition all edges of into those that are entirely contained in : ( respectively) and those which are part of the cut . For every edge we see that whereas , symetrically we see that for any we have that and .
On the other hand for every we see that . Which is to say that the number of satisfied clauses is given by
Therefore by using which is the disjunction of all of the edge clauses, and with we clearly can say that max-2-sat is satisifed.
On the other hand given and it's assignment we get a unique cut with at least edges involved in the cut.