Minimal Distance of Propositional Models Mike Behrisch‡ Technische Universität Wien, Vienna, Austria
[email protected] arXiv:1502.06761v1 [cs.CC] 24 Feb 2015
Miki Hermann∗ Stefan Mengel† LIX (UMR CNRS 7161), École Polytechnique, Palaiseau, France {hermann,mengel}@lix.polytechnique.fr Gernot Salzer‡ Technische Universität Wien, Vienna, Austria
[email protected] February 25, 2015
Abstract We investigate the complexity of three optimization problems in Boolean propositional logic related to information theory: Given a conjunctive formula over a set of relations, find a satisfying assignment with minimal Hamming distance to a given assignment that satisfies the formula (NearestOtherSolution, NOSol) or that does not need to satisfy it (NearestSolution, NSol). The third problem asks for two satisfying assignments with a minimal Hamming distance among all such assignments (MinSolutionDistance, MSD). For all three problems we give complete classifications with respect to the relations admitted in the formula. We give polynomial time algorithms for several classes of constraint languages. For all other cases we prove hardness or completeness regarding APX, poly-APX, NPO, or equivalence to well-known hard optimization problems.
1
Introduction
We investigate the solution spaces of Boolean constraint satisfaction problems built from atomic constraints by means of conjunction and variable identification. We study three minimization problems in connection with Hamming distance: Given an instance of a constraint satisfaction problem in the form of a generalized conjunctive formula over a set of atomic constraints, the first problem asks to find a satisfying assignment with minimal Hamming distance to a given assignment (NearestSolution, NSol). Note that for this problem we do not assume the given assignment to satisfy the formula. For the second problem one is also given an instance of a constraint satisfaction problem and has to find a satisfying assignment with minimal Hamming distance to a given assignment that satisfies the formula (NearestOtherSolution, NOSol). The third problem is to find two satisfying assignments with minimal Hamming distance among all satisfying assignments (MinSolutionDistance, MSD). As it is common, we analyze the complexity of our optimization problems through a parameter, representing the atomic constraints allowed to be used in the constraint satisfaction problem. We give a ∗
Supported by ANR-11-ISO2-003-01 Blanc International grant ALCOCLAN. Supported by QUALCOMM grant administered by École Polytechnique. ‡ Supported by Austrian Science Fund (FWF) grant I836-N23. †
1
complete classification of the complexity of approximation with respect to this parameterization. It turns out that our problems can either be solved in polynomial time, or they are complete for a well-known optimization class, or else they are equivalent to well-known hard optimization problems. Our study can be understood as a continuation of the minimization problems investigated by Khanna et al. in [16], especially that of MinOnes. The MinOnes optimization problem asks for a solution of a constraint satisfaction problem with the minimal Hamming weight, i.e., minimal Hamming distance to the 0-vector. Our work generalizes this by allowing the given vector to be any, potentially also non-0vector. Moreover, our work can also be seen as a generalization of questions in coding theory. In fact, our problem MSD restricted to affine relations is the well-known problem MinDistance of computing the minimum distance of a linear code. This quantity is of central importance in coding theory, because it determines the number of errors that the code can detect and correct. Moreover, our problem NSol restricted to affine relations is the problem NearestCodeword of finding the nearest codeword to a given word, which is the basic operation when decoding messages received through a noisy channel. Thus our work can be seen as a generalization of these well-known problems from affine to general relations. Finally, Hamming distance also plays an important role in belief revision. The result of revising/updating a formula ϕ by another formula ψ is characterized by the set of models of ψ, which are the closest to the models of ϕ. Dalal [9] selects the models of ψ having a minimal Hamming distance to models of ϕ to be the models that result from the change. The first problem (NSol) is compatible with existential quantification of variables, therefore we can apply clone theory to it (see e.g. [5]). The other two problems (NOSol, MSD) lack this compatibility property, therefore we can only work with weak co-clones closed under conjunction. To circumvent this restriction we apply the theory developed by Schnoor and Schnoor [19], as well as the weak bases of co-clones investigated by Lagerkvist [17].
2
Preliminaries
An n-ary Boolean relation R is a subset of {0, 1}n ; its elements (b1 , . . . , bn ) are also written as b1 · · · bn . Let V be a set of variables. An atomic constraint, or an atom, is an expression R(x), where R is an n-ary relation and x is an n-tuple of variables from V . Let Γ be a non-empty finite set of Boolean relations, also called a constraint language. A Γ-formula is a finite conjunction of atoms R1 (x1 ) ∧ · · · ∧ Rk (xk ), where the Ri are relations from Γ and the xi are variable tuples of suitable arity. An assignment is a mapping m : V → {0, 1} assigning a Boolean value m(x) to each variable x ∈ V . If we arrange the variables in some arbitrary but fixed order, say as a vector (x1 , . . . , xn ), then the assignments can be identified with vectors from {0, 1}n . The i-th component of a vector m is denoted by m[i] and corresponds to the value of the i-th variable, i.e., m[i] = m(xi ). The Hamming weight hw(m) = |{i | m[i] = 1}| of m is the number of 1s in the vector m. The Hamming distance hd(m, m0 ) = |{i | m[i] 6= m0 [i]}| of m and m0 is the number of coordinates on which the vectors disagree. The complement m of a vector m is its pointwise complement, m[i] = 1 − m[i]. An assignment m satisfies the constraint R(x1 , . . . , xn ) if (m(x1 ), . . . , m(xn )) ∈ R holds. It satisfies the formula ϕ if it satisfies all of its atoms; m is said to be a model or solution of ϕ in this case. We use [ϕ] to denote the set of models of ϕ. Note that [ϕ] represents a Boolean relation. In sets of relations represented this way we usually omit the brackets. A literal is a variable v, or its negation ¬v. Assignments m are extended to literals by defining m(¬v) = 1 − m(v). Throughout the text we refer to different types of Boolean constraint relations following Schaefer’s terminology [18] (see also the monograph [7] and the survey [5]). A Boolean relation R is (1) 1-valid if 1 · · · 1 ∈ R and it is 0-valid if 0 · · · 0 ∈ R, (2) Horn (dual Horn) if R can be represented by a formula in conjunctive normal form (CNF) having at most one unnegated (negated) variable in each clause, (3) monotone if it is both Horn and dual Horn, (4) bijunctive if it can be represented by a CNF having 2
Co-Clone iE iE0 iE1 iE2 iN iN2 iI
Weak Base (x1 ≡ x2 ∧ x3 ) ∧ (x2 ∨ x3 → x4 ) (x1 ≡ x2 ∧ x3 ) ∧ (x2 ∨ x3 → x4 ) ∧ ¬x5 (x1 ≡ x2 ∧ x3 ) ∧ x4 (x1 ≡ x2 ∧ x3 ) ∧ ¬x4 ∧ x5 even4 (x1 , x2 , x3 , x4 ) ∧ (x1 ∧ x4 ≡ x2 ∧ x3 ) even4 (x1 , x2 , x3 , x4 ) ∧ (x1 ∧ x4 ≡ x2 ∧ x3 ) ∧ (xi 6= xi+4 ) for i = 1, . . . , 4 (x1 ≡ x2 ∧ x3 ) ∧ (¬x4 ≡ ¬x2 ∧ ¬x3 )
Table 1: List of weak bases for a selection of co-clones taken from [17]. at most two variables in each clause, (5) affine if it can be represented by an affine system of equations Ax = b over Z2 , (6) complementive if for each m ∈ R also m ∈ R. A set Γ of Boolean relations is called 0-valid (1-valid, Horn, dual Horn, monotone, affine, bijunctive, complementive) if every relation in Γ is 0-valid (1-valid, Horn, dual Horn, monotone, affine, bijunctive, complementive). A formula constructed from atoms by conjunction, variable identification, and existential quantification is called a primitive positive formula (pp-formula). We denote by hΓi the set of all relations that can be expressed using relations from Γ, conjunction, variable identification, and existential quantification. The set hΓi is called the co-clone generated by Γ. A base of a co-clone B is a set of relations Γ, such that hΓi = B. The co-clones form a lattice (see Figure 1) ordered by set inclusion. The co-clones in this lattice and their respective bases, which were studied in [6], are listed in Table 3. The set of relations that are 0-valid, 1-valid, complementive, Horn, dual Horn, affine, bijunctive, 2affine (both bijunctive and affine) and monotone each form a co-clone denoted by iI0 , iI1 , iN2 , iE2 , iV2 , iL2 , iD2 , iD1 , and iM2 , respectively. We will also use a weaker closure than hΓi, called weak co-clone closure and denoted by hΓi6∃ , where the constraint language Γ is closed under conjunction and variable identification, but not under existential quantification. Note that this closure notion has been used before, for example in [8, 11]. We will be interested in so-called weak bases of co-clones which are bases with certain additional properties. Since we will use only some of those properties, we will not define weak bases but refer the reader to [17, 19]. The following property of weak bases is central for our work. Theorem 1 (Schnoor and Schnoor [19]). Let C be a clone, iC its corresponding co-clone, and let Γ be a weak base of iC. Then the inclusion Γ ⊆ hΓ0 i6∃ holds for any base Γ0 of iC. Lagerkvist computed weak bases for all co-clones in [17]. Table 1 presents his results for a selection of co-clones that will be of interest for us later. We assume that the reader has a basic knowledge of approximation algorithms and complexity theory, see e.g. [3, 7]. For reductions among decision problems we use polynomial-time many-one reduction denoted by ≤m . Many-one equivalence between decision problems is denoted by ≡m . For reductions among optimization problems we use approximation preserving reductions, also called APreductions, denoted by ≤AP . AP-equivalence between optimization problems is denoted by ≡AP . We use the following approximation complexity classes in the hierarchy PO ⊆ APX ⊆ poly-APX ⊆ NPO. We introduce the following slightly non-standard variation of AP-reductions. We say that an optimization problem Π1 AP-Turing-reduces to another optimization problem Π2 if there is a polynomialtime oracle algorithm A and a constant α such that on input x for Π1 • if all oracle calls with an input x0 for Π2 are answered with a feasible solution y for Π2 on input x, then A outputs a feasible solution for Π1 on x, and • if for every call the oracle answers with an r-approximate solution, then A computes a (1+(r −1)α+ o(1)) approximate solution for Π1 on x. 3
It is straightforward to check that AP-Turing-reductions are transitive. Moreover, if Π1 AP-Turingreduces to Π2 with constant α and Π2 has an f (n)-approximation algorithm, then there is an αf (n)approximation algorithm for Π1 . We will relate our problems to well-known optimization problems. To this end we make the following convention: Let P and Q be optimization problems. The problem P is called Q-complete if P ≡AP Q. To prove our results, we refer to the following optimization problems defined and analyzed in [16]. Note that like our problems they are parameterized by a constraint language Γ. Problem MinOnes(Γ) Input: Conjunctive formula ϕ over relations from Γ. Solution: An assignment m satisfying ϕ. Objective: Minimum Hamming weight hw(m). Problem WeightedMinOnes(Γ) Input: Conjunctive formula ϕ over relations from Γ and a weight function w : V → N assigning nonnegative integer weights to the variables of ϕ. Solution: An assignment m P satisfying ϕ. Objective: Minimum value x:m(x)=1 w(x). We now define some well-studied problems to which we will relate our problems. Note that these problems do not depend on any parameter. Problem NearestCodeword and a vector m ∈ Zl2 . Input: Matrix A ∈ Zk×l 2 Solution: A vector x ∈ Zk2 . Objective: Minimum Hamming distance hd(xA, m). Problem MinDistance Input: Matrix A ∈ Zk×l 2 . Solution: A non-zero vector x ∈ Zl2 with Ax = 0. Objective: Minimum Hamming weight hw(x). Problem MinHornDeletion Input: Conjunctive formula ϕ over relations from {x ∨ y ∨ ¬z, x, ¬x}. Solution: An assignment m to ϕ. Objective: Minimum number of unsatisfied conjuncts of ϕ. NearestCodeword, MinDistance and MinHornDeletion are known to be NP-hard to approximate 1−ε within a factor 2Ω(log (n)) for every ε [1, 10, 16]. Thus if a problem P is equivalent to any of these problems, it follows that P ∈ / APX unless P = NP. We also use the classic satisfiability problem SAT(Γ), given a conjunctive formula ϕ over relations from Γ, asking if ϕ is satisfiable. Schaefer presented in [18] a complete classification of complexity for SAT. His dichotomy theorem proves that SAT(Γ) is polynomial-time decidable if Γ is 0-valid (Γ ⊆ iI0 ), 1-valid (Γ ⊆ iI1 ), Horn (Γ ⊆ iE2 ), dual Horn (Γ ⊆ iV2 ), bijunctive (Γ ⊆ iD2 ), or affine (Γ ⊆ iL2 ); otherwise it is NP-complete. Moreover, we need the decision problem AnotherSAT(Γ), given a conjunctive formula ϕ and an assignment m satisfying ϕ, asking if there exists another satisfying assignment m0 for ϕ, different from m. Juban gave in [15] a complete classification of complexity for AnotherSAT. His dichotomy theorem proves that AnotherSAT(Γ) is polynomial-time decidable if Γ is both 0- and 1-valid (Γ ⊆ iI), complementive (Γ ⊆ iN2 ), Horn (Γ ⊆ iE2 ), dual Horn (Γ ⊆ iV2 ), bijunctive (Γ ⊆ iD2 ), or affine (Γ ⊆ iL2 ); otherwise it is NP-complete. 4
3
Results
This section presents the problems we consider and our results; the proofs follow in subsequent sections. The input to all our problems is a conjunctive formula over a set of relations. The satisfying assignments of the formula, which are the solutions of the formula, constitute the codewords of the associated code. The minimization target is always the Hamming distance. The three problems differ in the information additionally available for computing the required Hamming distance. Given a formula and an arbitrary assignment solutions, the first problem asks for a solution closest to the given assignment. Problem NearestSolution(Γ), NSol(Γ) Input: A conjunctive formula ϕ over relations from Γ and an assignment m not required to satisfy ϕ. Solution: An assignment m0 satisfying ϕ. Objective: Minimum Hamming distance hd(m, m0 ). Theorem 2. The optimization problem NSol(Γ) is (i) in PO if Γ is (a) 2affine (Γ ⊆ iD1 ) or (b) monotone (Γ ⊆ iM2 ); (ii) APX-complete if (a) hΓi contains the relation [x ∨ y] and Γ ⊆ hx1 ∨ · · · ∨ xk , x → y, ¬x, xi (iS20 ⊆ hΓi ⊆ iSk00 ) for some k ∈ N or (b) Γ is bijunctive and hΓi contains the relation [x ∨ y] (iS20 ⊆ hΓi ⊆ iD2 ) or (c) hΓi contains the relation [¬x ∨ ¬y] and Γ ⊆ h¬x1 ∨ · · · ∨ ¬xk , x → y, ¬x, xi (iS21 ⊆ hΓi ⊆ iSk10 ) or (d) Γ is bijunctive and hΓi contains the relation [¬x ∨ ¬y] (iS21 ⊆ hΓi ⊆ iD2 ), for k ≥ 2; (iii) NearestCodeword-complete if Γ is exactly affine (iL ⊆ hΓi ⊆ iL2 ); (iv) MinHornDeletion-complete if Γ is (a) exactly Horn (iE ⊆ hΓi ⊆ iE2 ) or (b) exactly dual Horn (iV ⊆ hΓi ⊆ iV2 ); (v) poly-APX-complete if Γ does not contain an affine relation and it is (a) either 0-valid (iN ⊆ hΓi ⊆ iI0 ) (b) or 1-valid (iN ⊆ hΓi ⊆ iI1 ); and (vi) NPO-complete otherwise (iN2 ⊆ hΓi). The proof of Theorem 2 is given in Section 5. Given a constraint and one of its solutions, the second problem asks for another solution closest to the given one. Problem NearestOtherSolution(Γ), NOSol(Γ) Input: A conjunctive formula ϕ over relations from Γ and an assignment m satisfying ϕ. Solution: Another assignment m0 satisfying ϕ. Objective: Minimum Hamming distance hd(m, m0 ). The difference between the problems NearestSolution and NearestOtherSolution is the knowledge, or its absence, whether the input assignment satisfies the constraint. Moreover, for NearestSolution we may output the given assignment if it satisfies the formula while for NearestOtherSolution we have to output an assignment different from the one given as the input. 5
Theorem 3. The optimization problem NOSol(Γ) is (i) in PO if (a) Γ is bijunctive (Γ ⊆ iD2 ) or (b) Γ ⊆ hx1 ∨ · · · ∨ xk , x → y, ¬x, xi (Γ ⊆ iSk00 ) or (c) Γ ⊆ h¬x1 ∨ · · · ∨ ¬xk , x → y, ¬x, xi (Γ ⊆ iSk10 ) for k ∈ N; (ii) MinDistance-complete if Γ is exactly affine (iL ⊆ hΓi ⊆ iL2 ); (iii) MinHornDeletion-complete under AP-Turing-reductions if Γ is (a) exactly Horn (iE ⊆ hΓi ⊆ iE2 ) or (b) exactly dual Horn (iV ⊆ hΓi ⊆ iV2 ); (iv) in poly-APX if Γ is (a) exactly both 0-valid and 1-valid (hΓi = iI) or (b) exactly complementive (iN ⊆ hΓi ⊆ iN2 ), where NOSol(Γ) is n-approximable but not (n1−ε )-approximable unless P = NP; and (v) NPO-complete otherwise (iI0 ⊆ hΓi or iI1 ⊆ hΓi). The proof of Theorem 3 is given in Section 6. The third problem does not take any assignments as input, but asks for two solutions which are as close to each other as possible. We optimize once more the Hamming distance between the solutions. Problem MinSolutionDistance(Γ), MSD(Γ) Input: A conjunctive formula ϕ over relations from Γ. Solution: Two assignments m, m0 satisfying ϕ. Objective: Minimum Hamming distance hd(m, m0 ). Theorem 4. The optimization problem MSD(Γ) is (i) in PO if Γ is (a) bijunctive (Γ ⊆ iD2 ) or (b) Horn (Γ ⊆ iE2 ) or (c) dual Horn (Γ ⊆ iV2 ); (ii) MinDistance-complete if Γ is exactly affine (iL ⊆ hΓi ⊆ iL2 ); (iii) in poly-APX if Γ is both 0-valid and 1-valid, but does not contain an affine relation (iN ⊆ hΓi ⊆ iI), where MSD(Γ) is n-approximable but not (n1−ε )-approximable unless P = NP; and (iv) NPO-complete otherwise (iN2 ⊆ hΓi or iI0 ⊆ hΓi or iI1 ⊆ hΓi). The proof of Theorem 4 is given in Section 7. The three optimization problems can be transformed into decision problems in the usual way. We add a bound k ∈ N to the input and ask if the Hamming distance satisfies the inequation hd(m, m0 ) ≤ k. This way we obtain the corresponding decision problems NOSold , NSold , and MSDd , respectively. Their complexity follows immediately from the theorems above. All cases in PO become polynomial-time decidable, whereas the other cases, which are APX-hard, become NP-complete. This way we obtain dichotomy theorems classifying the decision problems as polynomial or NP-complete for all sets Γ of relations.
4
Applicability of Clone Theory and Duality
In this section we show that clone theory is applicable to the problem NSol, as well as a possibility to exploit the duality between co-clones, which shortens several proofs in the sequel.
6
4.1
Nearest Solution
There are two natural versions of NSol(Γ). In one version the formula ϕ is quantifier free while in the other one we do allow existential quantification. We call the former version NSol(Γ) and the latter NSolpp (Γ). Fortunately, we will now see that both versions are equivalent. Let NSold (Γ) and NSoldpp (Γ) be the decision problems corresponding to NSol(Γ) and NSolpp (Γ), asking whether there is a satisfying assignment within a given bound. Lemma 5. Let Γ be a set of constraints. Then we have NSold (Γ) ≡m NSoldpp (Γ) and NSol(Γ) ≡AP NSolpp (Γ). Proof. The reduction from left to right is trivial in both cases. For the other direction, consider first an instance with formula ϕ, assignment m, and bound k for NSoldpp (Γ). Let x1 , . . . , xn be the free variables of ϕ and let y1 , . . . , y` be the existentially quantified variables. For each variable z we define a set B(z) as follows. ( {xji | j ∈ {1, . . . , (n + ` + 1)2 }} if z = xi for i ∈ {1, . . . , n}, B(z) = {yi } if z = yi for i ∈ {1, . . . , `}. S S We construct a quantifier-free formula ϕ0 over the variables ni=1 B(xi ) ∪ `i=1 B(yi ) that contains for every atom R(z1 , . . . , zs ) from ϕ the atom R(z10 , . . . , zs0 ) for every combination (z10 , . . . , zs0 ) ∈ B(z1 )×· · ·×B(zs ). Moreover, we construct an assignment B(m) of ϕ0 by assigning to every variable xji the value m(xi ) and to yi the value 0. Note that because Γ is finite, this is a polynomial time construction. We claim that ϕ has a solution m0 with hd(m, m0 ) ≤ k if and only if ϕ0 has a solution m00 with hd(B(m), m00 ) ≤ k(n + ` + 1)2 + `. First, observe that if m0 with the desired properties exists, then there is an extension m0 of m0 to the yi that satisfies all atoms. Define m00 by setting m00 (xji ) := m0 (xi ) and m00 (yi ) := m0 (yi ) for all i and j. Then m00 is clearly a satisfying assignment of ϕ0 . Moreover, m00 and B(m) differ in at most k(n + ` + 1)2 variables among the xji . Since there are only ` of the yi , we get hd(m00 , B(m)) ≤ k(n + ` + 1)2 + ` as desired. Now let m00 be a satisfying assignment of ϕ0 with hd(B(m), m00 ) ≤ k(n + ` + 1)2 + `. Without loss of generality we may assume for each i that all variables xji take the same value in m00 . Indeed, if this is not the case, then setting all xji to B(m)(xji ) will give us a satisfying assignment closer to B(m). Now define an assignment m0 to ϕ by setting m0 (xi ) := m00 (x1i ). Then m0 satisfies ϕ, because the variables yi can be assigned values as in m00 . Moreover, whenever m(x) 6= m0 (x) holds, for every j the inequality B(m)(xji ) 6= m00 (xji ) holds. Thus (n + ` + 1)2 hd(m, m0 ) ≤ hd(B(m), m00 ) ≤ k(n + ` + 1)2 + `. This yields hd(m, m0 ) ≤ k + `/(n + ` + 1)2 and thus hd(m, m0 ) ≤ k. This completes the many-one reduction. We claim that the above construction is an AP-reduction. To this end, let m00 be an r-approximation for ϕ0 and B(m), i.e., hd(B(m), m00 ) ≤ r · OPT(ϕ0 , B(m)). Construct m0 as before, then we get (n + ` + 1)2 hd(m, m0 ) ≤ hd(B(m), m00 ) ≤ r · OPT(ϕ0 , B(m)). Since OPT(ϕ0 , B(m)) ≤ (n + ` + 1)2 OPT(ϕ, m) + ` holds as before, we get (n + ` + 1)2 hd(m, m0 ) ≤ r((n + ` + 1)2 OPT(ϕ, m) + `). This yields hd(m, m0 ) ≤ r · OPT(ϕ, m) + `/(n + ` + 1)2 = r · OPT(ϕ, m) + o(|ϕ|). This shows that the construction is an AP-reduction with α = 1. Remark 6. Note that in the reduction from NSoldpp (Γ) to NSold (Γ) we construct the assignment B(m) as an extension of m by setting all new variables to 0. In particular, if m is the constant 0-assignment, then so is B(m). We will use this observation in the sequel. Lemma 5 is very convenient, because it allows us to freely switch between formulas with quantifiers and those without. This allows us to give all upper bounds in the setting without quantifiers while freely using them in all hardness reductions. In particular it follows that we can use pp-definability when implementing a constraint language Γ by another constraint language Γ0 . Consequently, it suffices to consider the classes of Post’s lattice of co-clones to characterize the complexity of NSol(Γ) for every Γ. 7
Corollary 7. For every constraint language Γ we have the equalities NSold (Γ) ≡m NSold (hΓi) and NSol(Γ) ≡AP NSol(hΓi). Moreover, if Γ0 ⊆ hΓi holds then NSold (Γ0 ) ≤m NSold (Γ) and NSol(Γ0 ) ≤AP NSol(Γ). The following lemma shows that unit clauses in the formula do not change the complexity of NSol. Lemma 8. For every set Γ of Boolean relations for which the problem of finding a feasible solution of NSol(Γ) is polynomial-time decidable we have NSol(Γ) ≡AP NSol(Γ ∪ {[x], [¬x]}). Proof. The direction from left to right is obvious. For the other direction, we show an AP-reduction from NSol(Γ ∪ {[x], [¬x]}) to NSol(Γ ∪ {[x ≡ y]}). Since x ≡ y is by definition in every co-clone and thus in hΓi, the result follows from Corollary 7. The idea of the construction is to introduce two sets of variables y1 , . . . , yn2 and z1 , . . . , zn2 such that in any feasible solution all yi and all zi take the same value. Then setting m(yi ) = 1 and m(zi ) = 0 for each i, any feasible solution m0 of small Hamming distance to m will have m0 (yi ) = 1 and m0 (zi ) = 0 for all i as well, because deviating from this would be prohibitively expensive. Finally, we simulate unary relations x and ¬x by x ≡ y1 and x ≡ z1 , respectively. We now describe the reduction formally. Let the formula ϕ and the assignment m be a Γ ∪ {[x], [¬x]}-formula over the variables x1 , . . . , xn with a feasible solution. We construct a Γ ∪ {[x ≡ y}]-formula ϕ0 over the variables x1 , . . . xn , y1 , . . . , yn2 , z1 , . . . , zn2 and an assignment m0 . We get ϕ0 from ϕ by substituting every occurence of a constraint xi for some variable xi by xi ≡ y1 and substituting every occurence ¬xi for every variable xi by xi ≡ z1 . Finally, add yi ≡ yj for all i, j ∈ {1, . . . , n2 } and zi ≡ zj for all i, j ∈ {1, . . . , n2 }. Let m0 be the assignment of the variables of ϕ0 with m0 (xi ) = m(yi ) for i ∈ {1, . . . , n}, m0 (yi ) = 1 and m0 (zi ) = 0 for all i ∈ {1, . . . , n2 }. To any feasible solution m00 of ϕ0 we assign g(ϕ, m, m00 ) as follows. 1. If ϕ is satisfied by m, we define g(ϕ, m, m00 ) to be equal to m. 2. Else if m00 (yi ) = 0 holds for all i ∈ {1, . . . , n2 } or m00 (zi ) = 1 for all i ∈ {1, . . . , n2 }, we define g(ϕ, m, m00 ) to be any satisfying assignment of ϕ. 3. Otherwise, m00 (yi ) = 1 for all i ∈ {1, . . . , n2 } and m00 (zi ) = 0, we define g(ϕ, m, m00 ) to be the restriction of m00 onto x1 , . . . , xn . Observe that all variables yi and all zi are forced to take the same value in any feasible solution, respectively, so g(ϕ, m, m00 ) is always well-defined. We claim that the construction is an AP-reduction. Assume that m00 is an r-approximate solution. We will show that g(ϕ, m, m00 ) is also an r-approximate solution. Case 1:
g(ϕ, m, m00 ) computes the optimal solution, so there is nothing to show.
Case 2: Observe first that ϕ has a solution by assumption, so g(ϕ, m, m00 ) is well-defined and feasible by construction. Observe that m0 and m00 disagree on all yi or on all zi , so hd(m0 , m00 ) ≥ n2 holds. Moreover, since ϕ has a feasible solution, it follows that OPT(ϕ0 , m0 ) ≤ n. Since m00 is an r-approximation, we have that r ≥ hd(m0 , m00 )/OPT(ϕ0 , m0 ) ≥ n. Consequently, we have hd(m, g(ϕ, m0 , m00 )) ≤ n ≤ r ≤ r · OPT(ϕ, m), where the last inequality holds because ϕ is not satisfied by m and thus the distance of the optimal solution from m is at least 1. This completes this case. Case 3: We have that the variables xi , for which xi is a constraint, all have g(ϕ, m00 )(xi ) = 1 by construction. Moreover, we have g(ϕ, m, m00 )(xi ) = 0 for all xi for which ¬xi is a constraint of ϕ. Consequently, g(ϕ, m, m00 ) is feasible. Again, OPT(ϕ0 , m, m0 ) ≤ n, so the optimal solution to (ϕ0 , m0 ) must set all variables yi to 1 and all zi to 0. It follows that OPT(ϕ, m) = OPT(ϕ0 , m0 ). Thus we get hd(m, g(ϕ, m, m00 )) = hd(m0 , m00 ) ≤ r · OPT(ϕ0 , m0 ) = r · OPT(ϕ, m), which completes the proof. 8
4.2
Nearest Other Solution and Minimal Solution Distance vs Existential Quantification
Since the optimization problems NOSol and MSD are not compatible with existential quantification, we cannot prove the equivalent of Corollary 7 for them. However, similar results hold for weak co-clones, which will help us to prove the desired results. Proposition 9. Let Γ and Γ0 be constraint languages. If Γ0 ⊆ hΓi6∃ holds then NOSold (Γ0 ) ≤m NOSold (Γ) and NOSol(Γ0 ) ≤AP NOSol(Γ). If Γ0 ⊆ hΓi6∃ then MSDd (Γ0 ) ≤m MSDd (Γ) and MSD(Γ0 ) ≤AP MSD(Γ). Proof. We prove only the part that Γ0 ⊆ hΓi6∃ implies NOSol(Γ0 ) ≤AP NOSol(Γ). The other results will be clear from that reduction. The proof is generic therefore it holds for both NOSol and MSD, as well as for their decision variants. Suppose that a formula ϕ with an assignment m satisfying ϕ is an instance of NOSol(Γ0 ). Since 0 Γ ⊆ hΓi6∃ holds, every constraint R(x1 , . . . , xk ) of ϕ can be written as a conjunction of constraints upon relations from Γ. Substitute the latter into ϕ, obtaining the new formula ϕ0 . Now (ϕ0 , m) is an instance of NOSol(Γ), where ϕ0 is only polynomially larger than ϕ. It is clear that ϕ and ϕ0 have the same variables and therefore also the same satisfying assignments. Hence, also the nearest other satisfying assignments of ϕ and ϕ0 are the same.
4.3
Duality
Given a relation R ⊆ {0, 1}n , its dual relation is dual(R) = {m | m ∈ R}, i.e., the relation containing the complements vectors from R. Duality naturally extends to sets of relations and co-clones. We define dual(Γ) = {dual(R) | R ∈ Γ} as the set of dual relations to Γ. Duality is a symmetric relation. If a relation R0 (a set of relations Γ0 ) is a dual relation to R (a set of dual relations to Γ), then R (Γ) is also dual to R0 (to Γ0 ). By a simple inspection of the bases of co-clones in Figure 3, we can easily see that many co-clones are dual to each other. For instance iE2 is dual to iV2 . Duality is represented in the co-clone lattice by symmetry with respect to the main vertical axis BR—iBF (see Figure 1). We now show that it suffices to consider one half of Post’s lattice of co-clones. Lemma 10. For every set Γ of Boolean relations we have (1) NSold (Γ) ≡m NSold (dual(Γ)) and NSol(Γ) ≡AP NSol(dual(Γ)); (2) NOSold (Γ) ≡m NOSold (dual(Γ)) and NOSol(Γ) ≡AP NOSol(dual(Γ)); (3) MSDd (Γ) ≡m MSDd (dual(Γ)) and MSD(Γ) ≡AP MSD(dual(Γ)). Proof. Let ϕ be an Γ-formula and m an assignment to ϕ. We construct a dual(Γ)-formula ϕ0 by substitution of every atom R(x) by dual(R)(x). The assignment m satisfies ϕ if and only if m satisfies ϕ0 , where m is the complement of m. Moreover, hd(m, m0 ) = hd(m, m0 ).
5
Finding the Nearest Solution
In this section we study the optimization problem NearestSolution. We first consider the polynomialtime cases and then the cases of higher complexity.
5.1
Polynomial-Time Cases
Proposition 11. If Γ is both bijunctive and affine (Γ ⊆ iD1 ) then NSol(Γ) can be solved in polynomial time. Proof. If Γ is both bijunctive and affine, then every Γ-formula ϕ is equivalent to a linear system of equations over the Boolean ring Z2 of the type x + y = 1 (mod 2) and x = 1. Substitute the fixed values x = 1 into the equations of the type x + y = 1 (mod 2) and propagate. After an exhaustive 9
application of this rule only equations of the type x + y = 1 (mod 2) remain. Create a bipartite graph G = (L, R, E), whose vertices L ∪ R will be the unassigned variables and put an edge (x, y) into E for each equation x + y = 1 (mod 2). If G is not bipartite, then ϕ has no solutions, so we can reject the input. Otherwise, assume that G is connected, if not perform the following algorithm for each connected component. Assign the value 0 to each variable in L and the value 1 to each variable in R, giving the satisfying assignment m1 . Assign the value 1 to each variable in L and the value 0 to each variable in R, giving the satisfying assignment m2 . Return the smaller of the values hd(m, m1 ) and hd(m, m2 ). Proposition 12. If Γ is monotone (Γ ⊆ iM2 ) then NSol(Γ) can be solved in polynomial time. Proof. The co-clone iM2 is generated by te relations [x → y], [¬x], and [x]. The relations [¬x] and [x] determine the unique value of the considered variable, therefore we can eliminate the unit clauses built from the two latter relations and propagate. We consider formuals ϕ built only from the relation [x → y], i.e., formulas containing only binary implicative clauses of the type x → y. Let V the set of variables of the formula ϕ. According to the value assigned to the variables by the vector m, we can divide V into two disjoint subsets V0 and V1 , such that Vi = {x ∈ V | m(x) = i}. We transform the formula ϕ to an integer programming problem P . First, for each clause x → y from ϕ we add to P the relation y ≥ x. For each variable x ∈ V we add the constraints x ≥ 0 and x ≤ 1, with x ∈ {0, 1}. Finally, we construct the linear function X X fϕ (m) = xi + (1 − xj ) . xi ∈V0
xj ∈V1
Let m0 be a satisfying assignment of ϕ. Compare the vectors m and m0 . If the variables V are instantiated by m, the linear function fϕ (m) counts the number of variables changing their parity between m and m0 , i.e., it counts the distance hd(m, m0 ). Since the integer programming problem P is unimodular, the minimum m∗ of the linear function fϕ (m) can be computed in polynomial time (see e.g. [20]).
5.2
Hard Cases
We start off with an easy corollary of Schaefer’s dichotomy. Lemma 13. Let Γ be a finite set of relations. If iN2 ⊆ hΓi, then NSol(Γ) is NPO-complete. Otherwise, NSol(Γ) ∈ poly-APX. Proof. If iN2 ⊆ hΓi holds, finding a solution for NSol(Γ) is NP-hard by Schaefer’s theorem [18], hence NSol(Γ) is NPO-complete. We give an n-approximation algorithm for the other case. Let formula ϕ and model m be an instance of NSol(Γ). If m is a solution of ϕ, return m. Otherwise, compute an arbitrary solution m0 of ϕ, which is possible by Schaefer’s theorem, and return m0 . We claim that the approximation ratio of this algorithm is n. Indeed, if m satisfies ϕ, this is obviously true, because we return the exact solution. Otherwise, we have hd(OPT(ϕ, m), m) ≥ 1 and trivially hd(m, m0 ) ≤ n and the claim follows. 5.2.1 APX-Complete Cases We start with reductions from the optimization version of vertex cover. Since the relation [x ∨ y] is a straightforward Boolean encoding of vertex cover, we immediately get the following result. Proposition 14. NSol(Γ) is APX-hard for every constraint language Γ satisfying the inclusion iS20 ⊆ hΓi or iS21 ⊆ hΓi.
10
Proof. The co-clone iS20 is generated by the relation [x ∨ y], whereas the co-clone iS21 is generated by the relation [¬x ∨ ¬y]. We discuss the former case, the latter one being symmetric and provable from the first one by Corollary 7. We encode VertexCover. For each edge (x, y) ∈ E of a graph G = (V, E) we add the clause (x ∨ y) to the formula ϕG . The presence of a node u in the vertex cover C will be denoted by 1 assigned to the variable u, whereas its absence from C will be denoted by 0. Take m = 0 · · · 0. Then hd(0 · · · 0, m0 ) is minimal if and only if the number of 1s in m0 is minimal, i.e., if m0 is a minimal assignent of ϕG , i.e., if m0 represents a minimal vertex cover of G. Since VertexCover is APX-complete (see e.g. [3]), the result follows. We show our containment results for APX by standard linear programming methods. Proposition 15. Let Γ be a constraint language with Γ ⊆ iD2 . Then NSol(Γ) ∈ APX. Proof. Since {x ⊕ y, x → z} is a basis of iD2 it suffices to show that NSol({x ⊕ y, x → y}) ∈ APX by Corollary 7. Let ϕ, m be an input of this problem. Feasibility for ϕ can be written as an integer program as follows: Every constraint xi ⊕ xj induces a linear equation xi + xj = 1. Every constraint xi → xj can be written as xi ≤ xj . If we restrict all variables to {0, 1} by the appropriate inequalities, it is clear that any assignment m0 satisfies ϕ if it satisfies the linearP system. We complete Pthe construction of the linear program by adding the objective function c(m0 ) := i:m(xi )=1 m0 (xi )+ i:m(xi )=0 (1−m0 (xi )). Clearly, for every m0 we have c(m0 ) = hd(m, m0 ). Now the 2-approximation algorithm from [13] for integer linear programs, in which in every inequality appear only two variables, completes the proof. Proposition 16. Let Γ be a constraint language with Γ ⊆ iS`00 for some ` ≥ 2. Then NSol(Γ) ∈ APX. Proof. Since {x1 ∨. . .∨x` , x → y, ¬x, x} is a basis of iS`00 , it suffices to show the result for NSol({x1 ∨ . . . ∨ x` , x → y, ¬x, x}) ∈ APX by Corollary 7. Let formula ϕ and assignment m be an instance of that problem. We will use an approach similar to that for the corresponding case in [16]. We again write ϕ as an integer program. Every constraint xi1 ∨ · · · ∨ xi` is translated to a disequality xi1 + · · · + xi` ≥ 1. Every constraint xi → xj is written as xi ≤ xj . Each ¬xi is turned into xi = 0, every constraint xi yields xi = 1. Again, it is easy to check that feasibleP Boolean solutions ofP ϕ and the linear system 0 0 coincide. Define again the objective function c(m ) = i:m(xi )=1 m (xi ) + i:m(xi )=0 (1 − m0 (xi )). Again hd(m, m0 ) = c(m0 ) for every m0 , therefore it suffices to approximate the optimal solution for the linear program. To this end, let m00 be a (generally non-integer) solution to the relaxation of the linear program which can be computed in polynomial time. We construct m0 by setting m0 (xi ) = 0 if m00 (xi ) < 1/` and m0 (xi ) = 1 if m00 (xi ) ≥ 1/`. Obviously, c(m0 ) ≤ `c(m00 ) ≤ ` · OPT(ϕ, m). It is easy to check that m0 is a feasible solution, which completes the proof. 5.2.2 NearestCodeword-Complete Cases Our starting point is the following lemma, which follows directly from the results of [16] and which implies an immediate corollary. Proposition 17 (Khanna et al. [16]). MinOnes(iL) and MinOnes(iL2 ) are NearestCodeword-complete. Corollary 18. Let Γ be a constraint language with iL ⊆ hΓi. Then NSol(Γ) is NearestCodeword-hard. Proof. Turn any MinOnes(iL)-instance into a NSol(iL)-instance by adding the constant 0-function and use Corollary 7. Proposition 19. Let Γ be a constraint language with Γ ⊆ iL2 . Then NSol(Γ) ≤AP MinOnes(iL2 ).
11
Proof. The set {even4 , ¬x, x} is a basis of iL2 , therefore by Corollary 7 it is sufficient to show NSol({even4 , ¬x, x}) ≤AP MinOnes({even4 , ¬x, x}). It is convenient to make first an intermediate step. We reduce NSol(Γ) to NSolpp ({even4 , ¬x, x}), where we force the assignments in all instances to be constant 0-assignments. Note that (x ⊕ y) ≡ even4 (x, y, 0, 1) = (∃z∃z 0 (even4 (x, y, z, z 0 ) ∧ ¬z ∧ z 0 ) so we can freely use (x ⊕ y) in any {even4 , ¬x, x}-formula. Let formula ϕ and assignment m be an instance of NSol({even4 , ¬x, x}). We copy all clauses of ϕ to ϕ0 . For each variable x of ϕ for which m(x) = 1, we add a new variable x0 and the constraint x⊕x0 to ϕ0 . Moreover, we existentially quantify x. Clearly, there is an isomorphism I between the satisfying assignments of ϕ and those of ϕ0 . For every solution m of ϕ we get a solution m0 of ϕ0 by setting for each x0 introduced in the construction of ϕ0 the value I(m)(x0 ) to the complement of m(x). Moreover, for every satisfying assignment m00 to ϕ we have that hd(m, m00 ) = hd(0, I(m00 )). This yields a trivial AP-reduction. Then using Lemma 5 and Remark 6 yields the result. 5.2.3 MinHornDeletion-Complete Cases Proposition 20 (Khanna et al. [16]). MinOnes({x ∨ y ∨ ¬z, x ∨ y}) and WeightedMinOnes({x ∨ y ∨ ¬z, x ∨ y}) are MinHornDeletion-complete. Lemma 21. NSol(x ∨ y ∨ ¬z) ≤AP WeightedMinOnes({x ∨ y ∨ ¬z, x ∨ y}). Proof. Let formula ϕ and assignment m be an instance of NSol(x∨y∨¬z) over the variables x1 , . . . , xn . If m satisfies ϕ then the reduction is trivial. We assume in the remainder of the proof that OPT(ϕ, m) > 0. Let O(m) be the set of variables xi with m(xi ) = 1. We construct a {x ∨ y ∨ ¬z, x ∨ y}-formula from ϕ by adding for each xi ∈ O(m) the constraint xi ∨ x0i where x0i is a new variable. We set the weights of the variables of ϕ0 as follows. For xi ∈ O(m) we set w(xi ) = 0, all other variables get weight 1. To each satisfying assignment m0 of ϕ0 we construct the assignment m00 which is the restriction of m0 to the variables of ϕ. We claim that this construction is an AP-reduction. Note that m00 is feasible if m0 is. Let m0 be an r-approximation of OPT(ϕ0 ). Note that whenever for xi ∈ O(m) we have m0 (xi ) = 0 then m0 (x0i ) = 1. The other way round, we may assume that whenever m0 (xi ) = 1 for xi ∈ O(m) then m0 (x0i ) = 0. If this is not the case, then we can change m0 accordingly, decreasing the weight that way. It follows / O(m), m0 (xi ) = 1} + {i | xi ∈ O(m), m0 (xi ) = 0} w(m0 ) = {i | xi ∈ / O(m), m0 (xi ) 6= m(xi )} + {i | xi ∈ O(m), m0 (xi ) 6= m(xi )} = {i | xi ∈ = hd(m, m00 ). Analogously, the optima in both problems correspond, i.e. we also get OPT(ϕ0 ) = OPT(ϕ, m). From this we deduce the final inequality hd(m, m00 )/OPT(ϕ, m) = w(m0 )/OPT(ϕ0 ) ≤ r. Proposition 22. Let Γ be a constraint language such that Γ ⊆ iV2 . WeightedMinOnes({x ∨ y ∨ ¬z, x ∨ y}).
Then NSol(Γ) ≤AP
Proof. Since {x∨y ∨¬z, x, ¬x} is a basis of iV2 , following Corollary 7 it suffices to prove the reduction NSol({x ∨ y ∨ ¬z, x, ¬x}) ≤AP WeightedMinOnes({x ∨ y ∨ ¬z, x ∨ y}). To this end, first reduce NSol({x ∨ y ∨ ¬z, x, ¬x}) to NSol(x ∨ y ∨ ¬z) by Lemma 8 and then use Lemma 21. Proposition 23. Let Γ be a constraint language such that iV2 ⊆ hΓi. MinHornDeletion-hard.
Then NSol(Γ) is
Proof. By [16] we have that MinOnes(Γ) is MinHornDeletion-hard. Observing that MinOnes(Γ) is the special case of NSol(Γ) where the input assignment m is fixed to the constant 0-assignment, completes the proof. 12
5.2.4 poly-APX-Hardness Proposition 24. NSol({even4 , dup3 , x ≡ y}) is poly-APX-hard. Proof. We show a reduction from MinOnes(iI1 ) which is poly-APX-hard by [16]. It follows directly that NSol(iI1 ) is poly-APX-hard as well. We encode the implication as (x → y) = dup3 (0, x, y) = (∃z(dup3 (z, x, y) ∧ ¬z)). Since {even4 , x → y, ¬x} is a basis of iI1 , it follows by Corollary 7 that NSol({even4 , dup3 , ¬x, x ≡ y}) is poly-APX-hard. Using Lemma 8 directly yields the result. Proposition 25. Let Γ be a constraint language with iN ⊆ hΓi. Then NSol(Γ) is poly-APX-hard. Proof. We have {even4 , dup3 , x ≡ y} ⊆ iN ⊆ hΓi. The claim follows from Proposition 24 and Corollary 7.
6
Finding Another Solution Closest to the Given One
In this section we study the optimization problem NearestOtherSolution. polynomial-time cases and then the cases of higher complexity.
6.1
We first consider the
Polynomial-Time Cases
Since we cannot take advantage of clone theory any more, we must proceed differently. We first use the following result from Jeavons et al. [14], based on a previous result of Baker and Pixley [4], showing that it is sufficient to consider only binary relations when we study bijunctive constraint languages. Proposition 26 (Jeavons et al. [14]). Every n-ary bijunctive constraint R(x1 , . . . , xn ) is equivalent to V 1≤i≤j Rij (xi , xj ), where Rij is the projection of the relation R to the coordinates i and j. Proposition 27. If Γ is bijunctive (Γ ⊆ iD2 ) then NOSol(Γ) can be solved in polynomial time. Proof. According to Proposition 26 we may assume that the formula ϕ is a conjunction of atoms R(x, y), where R is one of the relations [x ∨ y], [¬x ∨ y], and [¬x ∨ ¬y], or a unary constraint R(x, x) in the form [x] or [¬x]. Unary constraints can be eliminated and their value propagated into the other clauses, since they fix the value for a given variable. Let m be a model of ϕ. For each variable x we construct a model mx of ϕ with mx (x) 6= m(x) such that hd(mx , m) is minimal among all models with this property. Initially we set mx (x) := 1 − m(x) and mx (y) := m(y) for all variables y 6= x and mark x as flipped. If mx satisfies all atoms we are done. Otherwise let R(x, y) be an atom falsified by mx . If both variables in R(x, y) are marked as flipped, the construction fails, a model mx with the property mx (x) 6= m(x) does not exist. Otherwise the uniquely determined other variable y in R(x, y) is not yet marked as flipped. Set mx (y) := 1 − m(y), mark y as flipped, and repeat the process. If mx does not exist for any variable x, then m is the sole model of ϕ and the problem is not solvable. Otherwise choose one of the variables x for which hd(mx , m) is minimal and return mx as second solution m0 . We need a similar result for the co-clones iSk00 and iSk10 as Proposition 26 to ensure the possibility to avoid existential quantification. 0 Lemma 28. Let Γ ⊆ iSk00 but iSk−1 00 ( hΓi for a k ≥ 2. Each pp-formula over Γ is equal to a formula ϕ k 0 constructed from relations in Γ only by conjunction and variable identification, such that [ϕ ] ⊆ iS00 .
13
Proof. The co-clone iSk00 is also called implication positive hitting set bounded by k (IHBk +, see for instance [7]), where each pp-formula ϕ is constructed from the relations [x1 ∨ · · · ∨ xk ], [x → y], [¬x], and [x] by means of existential quantification, conjunction, and variable identification. We will show how to eliminate the existential quantification. Suppose that an existentially quantified variable appears in a unit clause (xk ) or k ) in ϕ. When V(¬x k−1 it is a positive literal, we replace every clause (x1 ∨ · · · ∨ xk ) by the conjunction i=1 (xi → xi ), we shorten the clause (xk → y) to (y), and we replace the clause (y → xk ) by (y → y). When it is a negative literal, we eliminate the variable xk from the clause (x1 ∨ · · · ∨ xk ), resulting in a shortened clause (x1 ∨ · · · ∨ xk−1 ), we replace the clause (xk → y) by (y → y), and we shorten the clause (y → xk ) to (¬y). Suppose that an existentially quantified variable appears in ϕ only positively. Then we have two possibilities:Veither it is ∃xk (x1 ∨ · · · ∨ xk ) or ∃x2 (x1 → x2 ). We replace in ϕ0 the first one by the conjunction k−1 i=1 (xi → xi ) and the second one by (x1 → x1 ). Suppose that an existentially quantified variable appears in ϕ only negatively. There is only one possibility, namely ∃x(x → y). We replace it in ϕ0 by (y → y). Suppose that an existentially quantified variable appears in ϕ both positively and negatively, namely either in ∃xk (x1 ∨ · · · ∨ xk−1 ∨ xk ) ∧ (¬xk ∨ y) or in ∃x2 (x1 → x2 ) ∧ (x2 → x3 ). In the first case, we replace each pair of these two types of clauses by the new clause (x1 ∨ · · · ∨ xk−1 ∨ y), constructed by resolution. Note that the constructed clause also has k positive literals. In the second case we replace them by the new implication (x1 → x3 ), also constructed by resolution. It can be easily seen that in all cases the corresponding formulas have the same sets of solutions and that we never construct a clause with more than k literals. Proposition 29. If Γ ⊆ iSk00 or Γ ⊆ iSk10 for some k ≥ 2 then NOSol(Γ) can be solved in polynomial time. Proof. We perform the proof only for iSk00 . By Lemma 10 we directly get the same result for iSk10 . The co-clone iSk00 is generated by [x1 ∨ · · · ∨ xk ], [x → y], [x] and [¬x]. By Lemma 28 we may assume that our inputs are formulas over this set of relations without existential quantification. Let formula ϕ and model m be an input. Note that x ∨ y is a polymorphism of Γ, i.e., for any two solutions m1 ∨ m2 of ϕ we have that the assignment m1 ∨ m2 which is defined by (m1 ∨ m2 )(x) = m1 (x) ∨ m2 (x) for every x is also a solution of ϕ. It follows that we get the optimal solution m0 for the instance ϕ and m by either flipping some values 1 of m to 0 or flipping some values 0 of m to 1 but not both. To see this, assume the optimal solution m0 flips both ones and zeros, then m0 ∨ m is a solution of ϕ that is closer to m than m0 which is a contradiction. The idea of the algorithm is to compute for each variable x of ϕ the distance of the solution mx which is minimal under the solutions of ϕ which differ from m on the variable x and flip only ones or only zeros. Then the algorithm chooses the mx closest to m as m0 and returns it. Since m and m0 differ in at least one variable, this yields the correct result. We now describe the computation of mx . If m(x) = 0, we flip x to 1 and propagate iteratively along x → y-constraints, i.e., if x → y is a constraint of ϕ and m(y) = 0, we flip y to 1 and propagate. Note that this process terminates after at most n flips, because we only flip from 0 to 1 and each variable can be flipped at most once. If the resulting assignment satisfies ϕ, this is our mx . Otherwise, there is no satisfying assignment which we get by flipping x and only flipping 0 to 1 and thus no candidate mx with the desired properties. If m(x) = 1, we flip x to 0 and propagate backward along binary implications, i.e., if y → x is a constraint of ϕ and m(y) = 1, we flip y to 0 and iterate. Again, if the result satisfies ϕ, this is our mx . Otherwise, there is no candidate mx for this variable. Finally, return the candidate mx that is closest to m if it exists, otherwise there is no feasible solution. 14
6.2
Hard Cases
Lemma 30. Let Γ be a finite constraint language. If iI1 ⊆ hΓi or iI0 ⊆ hΓi holds then finding a feasible solution for NOSol(Γ) is NPO-hard. Otherwise, NOSol(Γ) ∈ poly-APX. Proof. Finding a feasible solution to NOSol(Γ) is exactly the problem AnotherSAT(Γ) which is NPhard if and only if iI1 ⊆ hΓi or iI0 ⊆ hΓi according to Juban [15]. If AnotherSAT(Γ) is polynomialtime decidable, we can always find a feasible solution for NOSol(Γ) if it exists. Obviously, every feasible solution is an n-approximation of the optimal solution, where n is the number of variables of the input. 6.2.1
Tightness results
It will be convenient to consider the following decision problem. Problem: AnotherSAT