In this section we study the optimization problem NearestOtherSolution. We first consider the polynomial-time cases and then the cases of higher complexity.
Polynomial-Time Cases
Since we cannot take advantage of clone closure, we must proceed differently. We use the following result based on a theorem by Baker and Pixley [5].
Proposition 32 (Jeavons et al. [19])
Every bijunctive constraintR(x1,…,xn) is equivalent to the conjunction\(\bigwedge _{1 \leq i \leq j} R_{ij}(x_{i},x_{j})\), whereRijis the projection ofRto the coordinatesiandj.
Proposition 33
If Γ is bijunctive (Γ ⊆iD2) thenNOSol(Γ) is in PO.
Proof
According to Proposition 32 we may assume that the formula φ is a conjunction of atoms R(x, y) or a unary constraint R(x, x) of the form [x] or [¬x].
Unary constraints fix the value of the constrained variable and can be eliminated by propagating the value to the other clauses. For each of the remaining variables, x, we attempt to construct a model mx of φ with mx(x)≠m(x) such that hd(mx,m) is minimal among all models with this property. This can be done in polynomial time as described below. If the construction of mx fails for every 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 m′.
It remains to describe the computation of mx. Initially we set mx(x) to 1 − m(x) and mx(y) := m(y) for all variables y≠x, and mark x as flipped. If mx satisfies all atoms we are done. Otherwise let R(u, v) be an atom falsified by mx. If u and v are marked as flipped, the construction fails, a model mx with the property mx(x)≠m(x) does not exist. Otherwise R(u, v) contains a uniquely determined variable v not marked as flipped. Set mx(v) := 1 − m(v), mark v as flipped, and repeat this step. This process terminates after flipping every variable at most once.
Proposition 34
If\({\Gamma } \subseteq \text {iS}_{00}^{k}\)or\({\Gamma } \subseteq \text {iS}_{10}^{k}\)forsomek ≥ 2 thenNOSol(Γ) is in PO.
Proof
We perform the proof only for \(\text {iS}_{00}^{k}\). Proposition 16 implies the same result for \(\text {iS}_{10}^{k}\).
The co-clone \(\text {iS}_{00}^{k}\) is generated by Γ′ := {ork,[x → y],[x],[¬x]}. In fact, Γ′ is even a plain base of \(\text {iS}_{00}^{k}\) [12], meaning that every relation in Γ can be expressed as a conjunctive formula over relations in Γ′, without existential quantification or explicit equalities. Hence we may assume that φ is given as a conjunction of Γ′-atoms.
Note that x ∨ y is a polymorphism of Γ′, i.e., for any two solutions m1, m2 of φ their disjunction m1 ∨ m2 – defined by (m1 ∨ m2)(x) = m1(x) ∨ m2(x) for all x – is also a solution of φ. Therefore we get the optimal solution m′ of an instance (φ, m) by flipping in m either some ones to zeros or some zeros to ones, but not both. To see this, assume the optimal solution m′ flips both ones and zeros. Then m′∨ m is a solution of φ that is closer to m than m′, which contradicts the optimality of m′.
Unary constraints fix the value of the constrained variable and can be eliminated by propagating the value to the other clauses (including removal of disjunctions containing implied positive literals and shortening disjunctions containing implied negative literals). This propagation does not lead to contradictions since m is a model of φ. For each of the remaining variables, x, we attempt to construct a model mx of φ with mx(x)≠m(x) such that hd(mx,m) is minimal among all models with this property. This can be done in polynomial time as described below. If the construction of mx fails for every 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 m′.
It remains to describe the computation of mx. If m(x) = 0, we flip x to 1 and propagate this change iteratively along the implications, i.e., if x → y is a constraint of φ and m(y) = 0, we flip y to 1 and iterate. This kind of flip never invalidates any disjunctions, it could only lead to contradictions with conditions imposed by negative unit clauses (and since their values were propagated before such a contradiction would be immediate). For m(x) = 1 we proceed dually, flipping x to 0, removing x from disjunctions if applicable, and propagating this change backward along implications y → x where m(y) = 1. This can possibly lead to immediate inconsistencies with already inferred unit clauses, or it can produce contradictions through empty disjunctions, or it can create the necessity for further flips from 0 to 1 in order to obtain a solution (because in a disjunctive atom all variables with value 1 have been flipped, and thus removed). In all these three cases the resulting assignment does not satisfy φ, and there is no model that differs from m in x and that can be obtained by flipping in one way only. Otherwise, the resulting assignment satisfies φ, and this is the desired mx. Our process terminates after flipping every variable at most once, since we flip only in one way (from zeros to ones or from ones to zeros). Thus, mx is computable in polynomial time.
Hard Cases
Proposition 35
Let Γ be a constraint language. If iI1 ⊆〈Γ〉 or iI0 ⊆〈Γ〉 holds then it isNP-complete to decide whether a feasible solution forNOSol(Γ) exists. Otherwise,NOSol(Γ) ∈poly-APX.
Proof
Finding a feasible solution to NOSol(Γ) corresponds exactly to the decision problem AnotherSAT(Γ) which is NP-hard if and only if iI1 ⊆〈Γ〉 or iI0 ⊆〈Γ〉 according to Juban [20]. If AnotherSAT(Γ) is polynomial-time 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 in the input.
Tightness Results
It will be convenient to consider the following decision problem asking for another solution that is not the complement, i.e., that does not have maximal distance from the given one.
-
Problem:
:
-
AnotherSATnc(Γ)
-
Input:
:
-
A conjunctive formula φ over relations from Γ and an assignment m satisfying φ.
-
Question:
:
-
Is there another satisfying assignment m′ of φ, different from m, such that hd(m, m′) < n, where n is the number of variables in φ?
Remark 36
AnotherSATnc(Γ) is NP-complete for iI0 ⊆〈Γ〉 and iI1 ⊆〈Γ〉, since already AnotherSAT(Γ) is NP-complete for these cases, as shown in [20]. Moreover, AnotherSATnc(Γ) is polynomial-time decidable if Γ is Horn (Γ ⊆iE2), dual Horn (Γ ⊆iV2), bijunctive (Γ ⊆iD2), or affine (Γ ⊆iL2), for the same reason as for AnotherSAT(Γ): For each variable xi we flip the value of m[i], substitute \(\overline {m}(x_{i})\) for xi, and construct another satisfying assignment if it exists. Consider now the solutions which we get for every variable xi. Either there is no solution for any variable, then AnotherSATnc(Γ) has no solution; or there are only the solutions which are the complement of m, then AnotherSATnc(Γ) has no solution as well; or else we get a solution m′ with hd(m, m′) < n, leading also to a solution for AnotherSATnc(Γ). Hence, taking into account Proposition 38 below, we obtain a dichotomy result also for AnotherSATnc(Γ).
Note that AnotherSATnc(Γ) is not compatible with existential quantification. Let φ(y, x1,…,xn) with model m be an instance of AnotherSATnc(Γ) and let m′ be a solution satisfying hd(m, m′) < n + 1. Now consider the formula φ1(x1,…,xn) = ∃yφ(y, x1,…,xn), obtained by existentially quantifying the variable y, and the tuples m1 and \(m^{\prime }_{1}\) obtained from m and m′ by omitting the first component. Both, m1 and \(m^{\prime }_{1}\), are still solutions of φ′, but we cannot guarantee \(\text {hd}(m_{1}, m^{\prime }_{1}) < n\). Hence we need the equivalent of Proposition 15 for this problem, whose proof is analogous.
Proposition 37
The reductionAnotherSATnc(Γ′) ≤mAnotherSATnc(Γ) holds for all constraint languages Γ and Γ′satisfying Γ′⊆〈Γ〉∧.
Proposition 38
If a constraint language Γ satisfies 〈Γ〉 = iI or iN ⊆〈Γ〉⊆iN2, thenAnotherSATnc(Γ) is NP-complete.
Proof
Containment in NP is clear, it remains to show hardness. Since the problem AnotherSATnc is not compatible with existential quantification, we cannot use clone theory, but have to consider the three co-clones iN2, iN, and iI separately and make use of minimal weak bases.
Case 〈Γ〉 = iN Putting R := {000,101,110}, we present a reduction from the problem AnotherSAT({R}), which is NP-hard [20] as 〈{R}〉 = iI0. The problem remains NP-complete if we restrict it to instances (φ, 0), since R is 0-valid and any given model m other than the constant 0-assignment admits the trivial solution m′ = 0. Thus we can perform a reduction from this restricted problem.
Consider the relation RiN = {0000,1010,1100,1111,0101,0011}. Given a formula φ over R, we construct a formula ψ over RiN by replacing every constraint R(x, y, z) with a new constraint RiN(x, y, z, w), where w is a new global variable. Moreover, we set m to the constant 0-assignment. This construction is a many-one reduction from the restricted version of AnotherSAT({R}) to AnotherSATnc({RiN}).
To see this, observe that the tuples in RiN that have a 0 in the last coordinate are exactly those in R ×{0}. Thus any solution of φ can be extended to a solution of ψ by assigning 0 to w. Conversely we observe that any solution m′ of the AnotherSATnc({RiN})-instance (ψ, 0) is different from 0 and 1. As RiN is complementive, we may assume m′(w) = 0. Then m′ restricted to the variables of φ solves the AnotherSAT({R})-instance (φ, 0).
Finally, observe that RiN is a minimal weak base and Γ is a base of the co-clone iN, therefore we have RiN ∈〈Γ〉∧ by Theorem 1. Now the NP-hardness of AnotherSATnc(Γ) follows from the one of AnotherSATnc({RiN}) by Proposition 37.
Case 〈Γ〉 = iN2 We give a reduction from AnotherSATnc({RiN}), which is NP-hard by the previous case. By Theorem 1, 〈Γ〉∧ contains the relation \(R_{\text {iN}_{2}} = \{ m\overline {m}\mid {m \in R_{\text {iN}}}\}\). For an RiN-formula φ(x1,…,xn), we construct a corresponding \(R_{\text {iN}_{2}}\)-formula \(\psi (x_{1}, \ldots , x_{n}, x_{1}^{\prime }, \ldots , x_{n}^{\prime })\) by replacing every constraint RiN(x, y, z, w) with a new constraint \(R_{\text {iN}_{2}}(x, y, z, w, x^{\prime }, y^{\prime }, z^{\prime }, w^{\prime })\). Assignments m for φ extend to assignments M for ψ by setting \(M(x^{\prime }):= \overline {m}(x)\). Conversely, assignments for ψ yield assignments for φ by restricting them to the variables in φ. Because every variable x1,…,xn assigned by models of φ actually occurs in some RiN-atom in φ and hence in some \(R_{\text {iN}_{2}}\)-atom of ψ, and because of the structure of \(R_{\text {iN}_{2}}\), any model of ψ distinct from M and \(\overline {M}\) restricts to a model of φ other than m or \(\overline {m}\). Consequently, this construction is again a reduction from \(\textsf {AnotherSAT}_{\textsf {nc}}(\{R_{\text {iN}}\})\) to \(\textsf {AnotherSAT}_{\textsf {nc}}(\{R_{\text {iN}_{2}}\})\), reducing itself to AnotherSATnc(Γ) by Proposition 37.
Case 〈Γ〉 = iI We proceed as in Case 〈Γ〉 = iN, but use RiI = {0000,0011,0101,1111} instead of RiN, and {000,011,101} for R. Note that the RiI-tuples with first coordinate 0 are exactly those in {0}× R. The relation RiI is not complementive, but (as every variable assigned by any model of ψ occurs in some atomic RiI-constraint) the only solution m′ such that m′(w) = 1 is the constant 1-assignment, which is ruled out by the requirement hd(m, m′) < n. Hence we may again assume m′(w) = 0.
Proposition 39
For a constraint language Γ satisfying 〈Γ〉 = iI or iN ⊆〈Γ〉⊆iN2and anyε > 0 there is no polynomial-timen1−ε-approximationalgorithm forNOSol(Γ), unless P = NP.
Proof
Assume there is a constant ε > 0 with a polynomial-time n1−ε-approximation algorithm for NOSol(Γ). We show how to use this algorithm to solve AnotherSATnc(Γ) in polynomial time. Proposition 38 completes the proof.
Let (φ, m) be an instance of AnotherSATnc(Γ) with n variables. If n = 1, then we reject the instance. Otherwise, we construct a new formula φ′ and a new assignment m′ as follows. Let k be the smallest integer greater than 1/ε. Choose a variable x of φ and introduce nk − n new variables xi for i = 1,…,nk − n. For every i ∈{1,…,nk − n} and every constraint R(y1,…,yℓ) in φ, such that x ∈{y1,…,yℓ}, construct a new constraint \(R({z_{1}^{i}}, \ldots , z_{\ell }^{i})\) by \({z_{j}^{i}} = x^{i}\) if yj = x and \({z_{j}^{i}} = y_{j}\) otherwise; add all the newly constructed constraints to φ in order to get φ′. Moreover, we extend m to a model of φ′ by setting m′(xi) = m(x). Now run the n1−ε-approximation algorithm for NOSol(Γ) on (φ′, m′). If the answer is \(\overline {m^{\prime }}\) then reject, otherwise accept.
We claim that the algorithm described above is a correct polynomial-time algorithm for the decision problem AnotherSATnc(Γ) when Γ is complementive. Polynomial runtime is clear. It remains to show its correctness. If the only solutions to φ are m and \(\overline {m}\), then, as n > 1, the only models of φ′ are m′ and \(\overline {m^{\prime }}\). Hence the approximation algorithm must answer \(\overline {m^{\prime }}\) and the output is correct. Now assume that there is a satisfying assignment ms different from m and \(\overline {m}\). The relation [φ] is complementive, hence we may assume that ms(x) = m(x). It follows that φ′ has a satisfying assignment \(m_{s}^{\prime }\) for which \(0<\text {hd}(m_{s}^{\prime }, m^{\prime })<n\) holds. But then the approximation algorithm must find a satisfying assignment m″ for φ′ with hd(m′, m″) < n ⋅ (nk)1−ε = nk(1−ε)+ 1. Since the inequality k > 1/ε holds, it follows that hd(m′, m″) < nk. Consequently, m″ is not the complement of m′ and the output of our algorithm is again correct.
When Γ is not complementive but both 0-valid and 1-valid (〈Γ〉 = iI), we perform the expansion algorithm described above for each variable of the formula φ and reject if the result is the complement for each run. The runtime remains polynomial. If \([\varphi ] = \{m,\overline {m}\}\), then indeed every run results in the corresponding \(\overline {m^{\prime }}\), and we correctly reject. Otherwise, we have a model \(m_{s}\in [\varphi ]\smallsetminus \{m,\overline {m}\}\), so there is a variable x of φ, where \(m_{s}(x)\neq \overline {m}(x)\), i.e. ms(x) = m(x). For this instance (φ′, m′) the approximation algorithm does not return \(\overline {m^{\prime }}\), wherefore we correctly accept.
MinDistance-Equivalent Cases
In this section we show that affine co-clones lead to problems equivalent to MinDistance. We thereby add the missing details to the rather superficial treatment of this matter given in [6].
Lemma 40
For affine constraint languages Γ (Γ ⊆iL2) we haveNOSol(Γ) ≤APMinDistance.
Proof
Let the formula φ and the satisfying assignment m be an instance of NOSol(Γ) over the variables x1,…,xn. The input φ can be written as Ax = b, with m being a solution of this affine system. A tuple m′ is a solution of Ax = b if and only if it can be written as m′ = m + m0 where m0 is a solution of Ax = 0. The Hamming distance is invariant with respect to affine translations: namely we have hd(m′, m) = hd(m′ + m″, m + m″) for any tuple m″, in particular, for m″ = −m we obtain hd(m′, m) = hd(m′− m, 0). Therefore m′≠m is a solution of Ax = b with minimal Hamming distance to m if and only if m0 = m′− m is a non-zero solution of the homogeneous system Ax = 0 with minimum Hamming weight. Hence, the problem NOSol(Γ) for affine languages Γ is equivalent to computing the non-trivial solutions of homogeneous systems with minimal weight, which is exactly the MinDistance problem.
We need to express an affine sum of even number of variables by means of the minimal weak base for each of the affine co-clones. In the following lemma, the existentially quantified variables are uniquely determined, therefore the existential quantifiers serve only to hide superfluous variables and do not pose any problems as they were mentioned before.
Lemma 41
For every\(n\in \mathbb {N}\),n ≥ 1, theconstraintx1 ⊕ x2 ⊕⋯ ⊕ x2n = 0 can be equivalently expressed by each of the following formulas:
-
1.
\(\exists y_{0},\ldots ,y_{n} \left (\begin {array}{@{}l@{}} y_{0} = 0\land y_{n} = 0\land {}\\ R_{\text {iL}}(y_{0},x_{1},x_{2},y_{1}) \land {}\\ R_{\text {iL}}(y_{1},x_{3},x_{4},y_{2}) \land \cdots \land R_{\text {iL}}(y_{n-1},x_{2n-1},x_{2n},y_{n}) \end {array} \right )\),
-
2.
\(\exists y_{0},\ldots ,y_{2n} \left (\begin {array}{l@{}l@{}} R_{\text {iL}_{0}}(y_{0},x_{1},y_{1},y_{0}) \land {}\\ R_{\text {iL}_{0}}(y_{1},x_{2},y_{2},y_{0}) \land \cdots \land R_{\text {iL}_{0}}(y_{2n-1},x_{2n},y_{2n},y_{2n}) \end {array} \right )\),
-
3.
\(\exists y_{0},\ldots ,y_{2n} \left (\begin {array}{l@{}l@{}} R_{\text {iL}_{1}}(y_{0},x_{1},y_{1},y_{0}) \land {}\\ R_{\text {iL}_{1}}(y_{1},x_{2},y_{2},y_{0}) \land \cdots \land R_{\text {iL}_{1}}(y_{2n-1},x_{2n},y_{2n},y_{2n}) \end {array} \right )\),
-
4.
∃y0,…,yn,z0,…,zn,w1,…,w2n\(\left (\begin {array}{l@{}l@{}} y_{0} = 0 \land y_{n} = 0 \land {}\\ R_{\text {iL}_{3}}(y_{0},x_{1},x_{2},y_{1},z_{0},w_{1},w_{2},z_{1}) \land {}\\ R_{\text {iL}_{3}}(y_{1},x_{3},x_{4},y_{2},z_{1},w_{3},w_{4},z_{2}) \land \cdots \land {}\\ R_{\text {iL}_{3}}(y_{n-1},x_{2n-1},x_{2n},y_{n},z_{n-1},w_{2n-1},w_{2n},z_{n}) \end {array} \right )\),
-
5.
∃y0,…,y2n,z0,…,z2n,w1,…,w2n\(\left (\begin {array}{l@{}l@{}} R_{\text {iL}_{2}}(y_{0},x_{1},y_{1},z_{0},w_{1},z_{1},y_{0},z_{0}) \land {}\\ R_{\text {iL}_{2}}(y_{1},x_{2},y_{2},z_{1},w_{2},z_{2},y_{0},z_{0}) \land \cdots \land {}\\ R_{\text {iL}_{2}}(y_{2n-1},x_{2n},y_{2n},z_{2n-1},w_{2n},z_{2n}, y_{2n},z_{2n}) \end {array} \right )\),
where the number of existentially quantified variables is linearly bounded in thelength of the constraint. Note moreover that in each case any model ofx1 ⊕ x2 ⊕⋯ ⊕ x2n = 0 uniquely determines the values of the existentially quantified variables.
Proof
Write out the constraint relations following the existential quantifiers as (conjunctions of) equalities. From this uniqueness of valuations for the existentially quantified variables is easy to see, and likewise that any model of \(\bigoplus _{i = 1}^{2n} x_{i} = 0\) also satisfies each of the formulas 1. up to 5. Adding up the equalities behind the existential quantifiers shows the converse direction.
The following lemma shows that MinDistance is AP-equivalent to a restricted version, containing only constraints generating the minimal weak base, for each co-clone in the affine case.
Lemma 42
For each co-clone\(\mathcal {B}\in \{\text {iL},\text {iL}_{0},\text {iL}_{1},\text {iL}_{2},\text {iL}_{3}\}\)wehave\(\text {\textsf {MinDistance}}\le _{\text {AP}} \text {\textsf {NOSol}}(\{R_{\mathcal {B}},[\neg x]\})\).
Proof
Consider a co-clone \(\mathcal {B}\in \{\text {iL},\text {iL}_{0},\text {iL}_{1},\text {iL}_{2},\text {iL}_{3}\}\) and a MinDistance-instance represented by a matrix \(A\in \mathbb {Z}_{2}^{k\times l}\). If one of the columns of A, say the i-th, is zero, then the i-th unit vector is an optimal solution to this instance with optimal value 1. Hence, we assume from now on that none of the columns equals a zero vector.
Every row of A expresses the fact that a sum of n ≤ l variables equals zero. If n is odd, we extend this sum to one with n + 1 summands, thereby introducing a new variable v, which we existentially quantify and confine to zero using a unary [¬x]-constraint. Then we replace the expanded sum by the existential formula from Lemma 41 corresponding to the co-clone \(\mathcal {B}\) under consideration. This way we have introduced only linearly many new variables in l for every row, and for any feasible solution for the MinDistance-problem the values of the existential variables needed to encode it are uniquely determined. Thus, taking the conjunction over all these formulas we only have a linear growth in the size of the instance.
Next, we show how to deal with the existential quantifiers: First we transform the expression to prenex normal form getting a formula ψ of the form
$$\exists y_1,\dotsc,y_p \varphi(y_1,\dotsc,y_p,x_1,\dotsc,x_l), $$
which holds if and only if Ax = 0 for x = (x1,…,xl). We use the same blow-up construction regarding x1,…,xl as in Proposition 7 and Lemma 11 to make the influence of y1,…,yp on the Hamming distance negligible. For this we put J := {1,…,t} and introduce new variables \({x_{i}^{j}}\) where 1 ≤ i ≤ l and j ∈ J. If u is among x1,…,xl, we define its blow-up set to be \(B(u) = \{{x_{i}^{j}}|{j\in J}\}\), otherwise, for u ∈{y1,…,yp}, we set B(u) = {u}. Now for each atom R(u1,…,uq) of φ we form the set of atoms \(\{R(u_{1}^{\prime },\dotsc ,u_{q}^{\prime })| {(u_{1}^{\prime },\dotsc ,u_{q}^{\prime })\in \prod _{i = 1}^{q} B(u_{i})}\}\), and define the quantifier free formula φ′ to be the conjunction of all atoms in the union of these sets. Note that this construction takes time polynomial in the size of ψ and hence in the size of the input MinDistance-instance whenever t is polynomial in the input size because the atomic relations in ψ are at most octonary.
If s is an assignment of values to x making Ax = 0 true, we define \(s^{\prime }({x_{i}^{j}}):= s(x_{i})\) and extend this to a model of φ′ assigning the uniquely determined values to y1,…,yp. Let m′ be the model arising in this way from the zero assignment m. If s′ is any model of φ′, then for every 1 ≤ i ≤ l, all j ∈ J and each atom R(u1,…,uq) of φ, s′ satisfies, in particular, the conjunction \(R(u_{1}^{\prime },\dotsc ,u_{q}^{\prime })\land R(u_{1}^{\prime \prime },\dotsc ,u_{q}^{\prime \prime })\) where for u ∈{u1,…,uq} we have u′ = u″ = u if u ∈{y1,…,yp}, \(u^{\prime }={x_{i}^{1}}\), \(u^{\prime \prime } = {x_{i}^{j}}\) if u = xi, and \(u^{\prime }=u^{\prime \prime }={x_{k}^{1}}\) if u = xk for some \(k\in \{1,\dotsc ,l\}\smallsetminus \{i\}\). Hence, the vectors \((s^{\prime }({x_{1}^{1}}),\dotsc ,s^{\prime }({x_{l}^{1}}))\) and \((s^{\prime }({x_{1}^{1}}),\dotsc ,s^{\prime }(x_{i-1}^{1}),s^{\prime }({x_{i}^{j}}),s^{\prime }(x_{i + 1}^{1}),\dotsc , s^{\prime }({x_{l}^{1}}))\) both belong to the kernel of A and so does their difference, which is \(s^{\prime }({x_{i}^{j}}) - s^{\prime }({x_{i}^{1}})\) times the i-th unit vector. As the i-th column of A is non-zero, we must have \(s^{\prime }({x_{i}^{j}}) = s^{\prime }({x_{i}^{1}})\). This also implies that if s′ is zero on \({x_{1}^{1}},\dotsc ,{x_{n}^{1}}\), then it must be zero on all \({x_{i}^{j}}\) (1 ≤ i ≤ l, j ∈ J) and thus it must coincide with m′. Therefore, every feasible solution to the NOSol-instance (φ′, m′) yields a non-zero vector \((s^{\prime }({x_{1}^{1}}),\dotsc ,s^{\prime }({x_{l}^{1}}))\) in the kernel of A.
Further, if s′ is an r-approximation to an optimal solution, i.e., if hd(s′, m′) ≤ r OPT(φ′, m′), then, as \(s^{\prime }({x_{i}^{1}})=s^{\prime }({x_{i}^{j}})\) holds for all j ∈ J and all 1 ≤ i ≤ l, we obtain a solution to the MinDistance problem with Hamming weight w such that t ⋅ w ≤hd(s′, m′). Also, any optimal solution to the MinDistance-instance can be extended to a not-necessarily optimal solution s″ of (φ′, m′), for which one can bound the distance to m′ as follows: OPT(φ′, m′) ≤hd(s″, m′) ≤ t ⋅OPT(A) + p. Combining these inequalities, we can infer t ⋅ w ≤ r ⋅ t ⋅OPT(A) + r ⋅ p, or w ≤OPT(A) ⋅ (r + r/OPT(A) ⋅ p/t). We noted above that p is linearly bounded in the size of the input, thus choosing t quadratic in the size of the input bounds w by OPT(A)(r + o(1)), whence we have an AP-reduction with α = 1.
Lemma 43
For constraint languages Γ, where one can decide the existence of and also find a feasible solution ofNOSol(Γ) in polynomial time, we have the reduction\(\text {\textsf {NOSol}}({\Gamma }) \le _{\text {AP}} \text {\textsf {NOSol}}(({\Gamma }\smallsetminus \{[x],[\neg x]\})\cup \{\approx \})\).
Proof
If an instance (φ, m) does not have feasible solutions, then it does not have nearest other solutions either. So we map it to the generic unsolvable instance ⊥. Consider now formulas φ over variables x1,…,xn with models m where some feasible solution s0≠m exists (and has been computed).
We can assume φ to be of the form \(\psi (x_{1},\dotsc ,x_{n}) \land \bigwedge _{i\in I_{1}} [x_{i}] \land \bigwedge _{i\in I_{0}} [\neg x_{i}]\), where ψ is a \(({\Gamma }\smallsetminus \{[x],[\neg x]\})\)-formula and I1,I0 ⊆{1,…,n}. We transform φ to \(\varphi ^{\prime }:= \psi (x_{1},\dotsc ,x_{n}) \land \bigwedge _{i\in I_{1}} x_{i} \approx y_{1} \land \bigwedge _{i\in I_{0}} x_{i} \approx z_{1} \land \bigwedge _{i = 1}^{1+n^{2}} (y_{i} \approx y_{1} \land z_{i} \approx z_{1})\) and extend models of φ to models of φ′ in the natural way. Conversely, if s′ is a model of φ′ and s′(yi) = 1 and s′(zi) = 0 hold for all 1 ≤ i ≤ 1 + n2, then we can restrict it to a model of φ. Other models of φ′ are not optimal and are mapped to s0. It is not hard to see that this provides an AP-reduction with α = 1.
Proposition 44
For every constraint language Γ satisfying iL ⊆〈Γ〉⊆iL2we haveMinDistance ≡APNOSol(Γ).
Proof
Since we lack compatibility with existential quantification, we shall deal with each co-clone \(\mathcal {B} = \langle {\Gamma }\rangle \) in the interval {iL,iL0,iL1,iL2,iL3} separately. First we perform the reduction from Lemma 42 to \(\textsf {NOSol}(\{R_{\mathcal {B}}, [\neg x]\})\). We need to find a reduction to \(\textsf {NOSol}(\{R_{\mathcal {B}}\})\) as this reduces to NOSol(Γ) by Proposition 15 and Theorem 1.
This is simple in the case of iL0 and iL2 since \([\neg x] = \{x\mid R_{\text {iL}_{0}}(x,x,x,x)\}\in \langle {\{R_{\text {iL}_{0}}\}\rangle }_{\land }\) (see Proposition 15) and \([\neg x] = \{x\mid \exists y(R_{\text {iL}_{2}}(x,x,x,y,y,y,x,y))\}\), where the existential quantifier can be handled by an AP-reduction with α = 1 which drops the quantifier and extends every model by assigning 1 to all previously existentially quantified variables. Thereby (optimal) distances between models do not change at all.
In the remaining cases, we reduce \(\textsf {NOSol}(\{R_{\mathcal {B}},[\neg x]\})\le _{\text {AP}} \textsf {NOSol}(\{R_{\mathcal {B}},[x],[\neg x]\})\) and the latter to \(\textsf {NOSol}(\{R_{\mathcal {B}}, \approx \})\) by Lemma 43, which now has to be reduced to \(\textsf {NOSol}(\{R_{\mathcal {B}}\})\). This is obvious for \(\mathcal {B} = \text {iL}\) where equality constraints x ≈ y can be expressed as RiL(x, x, x, y) ∈〈{RiL}〉∧ (cf. Proposition 15). For iL1 the same can be done using the formula \(\exists z(R_{\text {iL}_{1}}(x,y,z,z))\), where the existential quantifier can be removed by the same sort of simple AP-reduction with α = 1 as employed for iL2. Finally, for iL3 we want to express equality as \(\exists u\exists v(R_{\text {iL}_{3}}(x,x,x,y,u,u,u,v))\). Here, in an AP-reduction, the quantifiers cannot simply be disregarded, as the values of the existentially quantified variables are not constant for all models. They are uniquely determined by the values of x and y for each particular model, though, which allows us to perform a similar blow-up construction as in the proof of Lemma 42.
In more detail, given a \(\{R_{\text {iL}_{3}}, \approx \}\)-formula ψ containing variables x1,…,xl, first note that each atomic \(R_{\text {iL}_{3}}\)-constraint \(R_{\text {iL}_{3}}(x_{1},\dotsc ,x_{8})\) can be represented as a linear system of equations, namely \(\oplus _{i = 1}^{4} x_{i} = 0\) and xi ⊕ xi+ 4 = 1 for 1 ≤ i ≤ 4. Since equalities xi ≈ xj can be written as xi ⊕ xj = 0, the formula ψ is equivalent to an expression of the form Ax = b where x = (x1,…,xl). Replacing each equality constraint by the existential formula above and bringing the result into prenex normal form, we get a formula ∃y1,…,yp(φ(y1,…,yp,x1,…,xl)), which is equivalent to ψ and where φ is a conjunctive \(\{R_{\text {iL}_{3}}\}\)-formula. By construction any two models of φ that agree on x1,…,xl must coincide. Thus, introducing variables \({x_{i}^{j}}\) for 1 ≤ i ≤ l and j ∈ J := {1,…,t} and defining φ′ in literally the same way as in the proof of Lemma 42, any model s of ψ yields a model s′ of φ′ by putting \(s^{\prime }({x_{i}^{j}}):=s(x_{i})\) for 1 ≤ i ≤ l and j ∈ J and extending this with the unique values for y1,…,yp satisfying φ(y1,…,yp,x1,…,xl). In this way we obtain a model m′ of φ′ from a given solution m of ψ. Besides, if s′ is any model of φ′, then as in Lemma 42, the vectors \((s^{\prime }({x_{1}^{1}}),\dotsc ,s^{\prime }({x_{l}^{1}}))\) and \((s^{\prime }({x_{1}^{1}}),\dotsc ,s^{\prime }(x_{i-1}^{1}),s^{\prime }({x_{i}^{j}}),s^{\prime }(x_{i + 1}^{1}),\dotsc , s^{\prime }({x_{l}^{1}})))\) both satisfy ψ, and thus their difference is in the kernel of A. Since the variable xi occurs in at least one of the atoms of ψ, the i-th column of A is non-zero, implying that \(s^{\prime }({x_{i}^{j}}) = s^{\prime }({x_{i}^{1}})\) for j ∈ J and all 1 ≤ i ≤ l. Thus, any model s′≠m′ of φ′ gives a model s≠m of ψ by defining \(s(x_{i}):= s^{\prime }({x_{i}^{1}})\) for all 1 ≤ i ≤ l.
The presented construction is an AP-reduction with α = 1, which can be proven completely analogously to the last paragraph of the proof of Lemma 42, choosing t quadratic in the size of ψ.
MinHornDeletion-Equivalent Cases
As in Proposition 38 the need to use conjunctive closure instead of 〈 〉 causes a case distinction in the proof of the following result, which is the dual variant of [6, Lemma 16]. Correspondingly, Lemma 46 then replaces [6, Lemma 17].
Lemma 45
If Γ is exactly dual Horn (iV ⊆〈Γ〉⊆iV2) then one of the following relations is in〈Γ〉∧:[x → y],[x → y] ×{0},[x → y] ×{1}, or [x → y] ×{01}.
Proof
The co-clone 〈Γ〉 is equal to iV, iV0, iV1, or iV2. In the case 〈Γ〉 = iV the relation RiV belongs to 〈Γ〉∧ by Theorem 1; because of RiV(y, y, y, x) = [x → y] we have [x → y] ∈〈RiV〉∧⊆〈Γ〉∧. The case 〈Γ〉 = iV1 leads to [x → y] ×{1}∈〈Γ〉∧ in an analogous manner. The cases 〈Γ〉 = iV0 and 〈Γ〉 = iV2 lead to [x → y] ×{0}∈〈Γ〉∧ and [x → y] ×{01}∈〈Γ〉∧, respectively, by observing that [S1(y, y, x)] = [S0(¬y,¬y,¬x,¬y)] = [(¬y ∧¬y) ≈ (¬y ∧¬x)] = [x → y].
Lemma 46
If Γ is exactly dual Horn (iV ⊆〈Γ〉⊆iV2), then the problemNOSol(Γ) isMinHornDeletion-hard.
Proof
There are four cases to consider, namely 〈Γ〉∈{iV,iV0,iV1,iV2}. For simplicity we only present the situation where 〈Γ〉 = iV1; the case 〈Γ〉 = iV2 is very similar, and the other possibilities are even less complicated. At the end we shall give a few hints how to adapt the proof in these cases.
The basic structure of the proof is as follows: we choose a suitable weak base of iV1 consisting of an irredundant relation R1, and identify a relation H1 ∈〈{R1}〉∧ which allows us to encode a sufficiently complicated variant of the MinOnes-problem into NOSol({H1}). Thus by Theorem 1 and Lemma 45 we have H1 ∈〈{R1}〉∧⊆〈Γ〉∧ and [x → y] ×{1}∈〈Γ〉∧, wherefore Proposition 15 implies NOSol(Γ′) ≤APNOSol(Γ) where Γ′ = {H1,[x → y] ×{1}}. According to [22, Theorem 2.14(4)], MinHornDeletion is equivalent to MinOnes(Δ) for constraint languages Δ being dual Horn, not 0-valid and not implicative hitting set bounded+ with any finite bound, that is, if 〈Δ〉∈{iV1,iV2}. The key point of the construction is to choose R1 and H1 in such a way that we can find a relation G1 satisfying iV1 ⊆〈{G1}〉⊆iV2 and ((G1 ×{1}) ∪{0}) ×{1} = H1. The latter property will allow us to prove an AP-reduction MinHornDeletion ≡APMinOnes({G1}) ≤APNOSol(Γ′), completing the chain.
We first check that R1 = V1 ∘〈χ4〉 satisfies 〈{R1}〉 = iV1: namely, by construction, this relation is preserved by the disjunction and by the constant operation with value 1, i.e., 〈R1〉⊆iV1. This inclusion cannot be proper, since 0∉R1 (〈R1〉⫅̸iI0) and x ∨ (y ∧ z)∉R1 while x = (e1 ∘ β) ∨ (e4 ∘ β), y = (e1 ∘ β) ∨ (e2 ∘ β) and z = (e1 ∘ β) ∨ (e3 ∘ β) belong to V1 ∘〈χ4〉 (cf. before Theorem 2 for the notation), i.e. the generating function (x, y, z)↦x ∨ (y ∧ z) of the clone S00 [13, Figure 2, p. 8] fails to be a polymorphism of R1. For later we note that when β is chosen such that the coordinates of χ4 are ordered lexicographically (and we are going to assume this from now on), then this failure can already be observed within the first seven coordinates of R1. Now according to Theorem 2, the sedenary relation R1 := V1 ∘〈χ4〉 is a weak base relation for iV1 without duplicate coordinates, and a brief moment of inspection shows that none of them is fictitious either. Therefore, R1 is an irredundant weak base relation for iV1. We define H1 to be {(x0,…,x8)∣(x0,…,x7,x8,…,x8) ∈ R1}, then clearly H1 ∈〈{R1}〉∧. Now we put \(G_{1} := G_{1}^{\prime }\smallsetminus \{\boldsymbol {0}\}\) where \(G_{1}^{\prime } := \{(x_{0},\dotsc ,x_{6})\mid {(x_{0},\dotsc ,x_{8})\in H_{1}}\}\), and one quickly verifies that ((G1 ×{1}) ∪{0}) ×{1} = H1. Since \(G_{1}^{\prime }\in \langle {H_{1}}\rangle \subseteq \langle {R_{1}}\rangle = \text {iV}_{1}\) and removing the bottom-element 0 of a non-trivial join-semilattice with top-element still yields a join-semilattice with top-element, we have G1 ∈iV1. With the analogous counterexample as for the relation R1 above, we can show that (x, y, z)↦x ∨ (y ∧ z) is not a polymorphism of G1 (because the non-membership is witnessed among the first seven coordinates). Thus, 〈{G1}〉 = iV1; in particular G1, and any relation conjunctively definable from it, is not 0-valid.
For the reduction let now φ(x) = G1(x1) ∧⋯ ∧ G1(xk) be an instance of MinOnes({G1}). We construct a corresponding Γ′-formula φ′ as follows.
$$\begin{array}{@{}rcl@{}} \varphi^{\prime\prime}(\boldsymbol{x},y,z) &=& H_{1}({\boldsymbol{x}_{1}},y,z) \land \cdots \land H_{1}({\boldsymbol{x}_{k}},y,z) \\ \varphi^{\prime\prime\prime}(\boldsymbol{x}, {\boldsymbol{x}^{(\boldsymbol{2})}}, \dotsc, {\boldsymbol{x}^{(\boldsymbol{\ell})}},z) &=& \bigwedge_{i = 1}^{\ell} \left( (x_{i} \xrightarrow{z = 1} x_{i}^{(2)}) \land \bigwedge_{j = 2}^{\ell-1} (x_{i}^{(j)} \xrightarrow{z = 1} x_{i}^{(j + 1)}) \land (x_{i}^{\ell} \xrightarrow{z = 1} x_{i}) \right)\\ \varphi^{\prime}(\boldsymbol{x}, {\boldsymbol{x}^{(\boldsymbol{2})}}\mkern-\thickmuskip, \dotsc, {\boldsymbol{x}^{(\boldsymbol{\ell})}}\mkern-\thickmuskip,y,z) &=& \varphi^{\prime\prime}(\boldsymbol{x},y,z) \land \varphi^{\prime\prime\prime}(\boldsymbol{x}, {\boldsymbol{x}^{(\boldsymbol{2})}}, \dotsc,{\boldsymbol{x}^{(\boldsymbol{\ell})}},z) \end{array} $$
where ℓ = |x| is the number of variables of φ, y and z are new global variables, and where we have written \((u\xrightarrow {w = 1}v)\) to denote ([x → y] ×{1})(u, v, w). Let m0 be the assignment to the ℓ2 + 2 variables of φ′ given by m0(z) = 1 and m0(x) = 0 elsewhere. It is clear that (φ′, m0) is an instance of NOSol(Γ′), since m0 satisfies φ′. The formula φ″′ only multiplies each variable x from φℓ-times and forces x ≈ x(2) ≈⋯ ≈ x(ℓ), which is just a technicality for establishing an AP-reduction. The main idea of this proof is the correspondence between the solutions of φ and φ″.
For each solution s of φ(x) there exists a solution s′ of φ″(x, y) with s′(y) = 1 (and s′(z) = 1). Each solution s′ of φ″ has always s′(z) = 1 and either s′(y) = 0 or s′(y) = 1. Because every variable from x is part of one of the xi, the assignment m0 restricted to (x, y, z) is the only solution s′ of φ″ satisfying s′(y) = 0. If otherwise s′(y) equals 1, then s′ restricted to the variables x satisfies φ(x), following the correspondence between the relations G1 and H1.
For r ∈ [1,∞) let s′ be an r-approximate solution of the \(\textsf {NOSol}(\Gamma ^{\prime })\)-instance (φ′, m0). Let \(s := s^{\prime }\!\upharpoonright _{\boldsymbol {x}}\) be the restriction of s′ to the variables of φ. Since s′≠m0, by what we showed before, s′(y) = 1 and s is a solution of φ(x). We have \(\text {OPT}(\varphi ^{\prime }, m_{0}) \geq 2\) and OPT(φ) ≥ 1, since solutions of the \(\textsf {NOSol}(\Gamma ^{\prime })\)-instance \((\varphi ^{\prime },m_{0})\) must be different from m0, whereby y is forced to have value 1, and \([\varphi ]\in \langle {\{G_{1}\}}\rangle _{\wedge }\) is not 0-valid. Moreover, \(\text {hw}(s) = \text {hd}(\boldsymbol {0}, s)\), hd(s′, m0) = ℓ hw(s) + 1, \(\text {OPT}(\varphi ^{\prime },m_{0}) = \ell \text {OPT}(\varphi ) + 1\), and \(\text {hd}(s^{\prime },m_{0})\leq r\text {OPT}(\varphi ^{\prime },m_{0})\). From this and OPT(φ) ≥ 1 it follows that
$$\begin{array}{@{}rcl@{}} \ell\text{hw}(s) < \ell\text{hw}(s)+ 1 = \text{hd}(s^{\prime},m_{0})&\leq& r\text{OPT}(\varphi^{\prime},m_{0}) = r\ell\text{OPT}(\varphi) + r\\ &\leq& r\ell\text{OPT}(\varphi) + r\text{OPT}(\varphi)\\ &\leq& r\ell\text{OPT}(\varphi) + r\text{OPT}(\varphi) + (r-1)\ell\text{OPT}(\varphi)\\ &=& (2r-1+r/\ell)\ell\text{OPT}(\varphi)\\ &=& (1 + 2(r-1) +r/\ell)\ell\text{OPT}(\varphi). \end{array} $$
Hence s is an (1 + α(r − 1) + o(1))-approximate solution of the instance φ of the problem MinOnes({G1}) where α = 2.
In the case when 〈Γ〉 = iV2, the proof goes through with minor changes: \(R_{2} = \mathrm {V}_{2}\circ \langle {\chi _{4}}\rangle = R_{1}\smallsetminus \{\boldsymbol {1}\}\), so we define H2 and G2 like H1 and G1 just using R2 and H2 in place of R1 and H1. Then we have \(H_{2} = H_{1}\smallsetminus \{\boldsymbol {1}\}\), \(G_{2} = G_{1}\smallsetminus \{\boldsymbol {1}\}\) and 〈{G2}〉 = iV2. Moreover, for the reduction we shall need an additional global variable w for φ″′ (and φ′) since the encoding of the implication from Lemma 45 requires it (and forces it to zero in every model).
For 〈Γ〉 = iV0 we can use R0 = V0 ∘〈χ4〉 = R2 ∪{0}; then, letting H0 = {(x0,…,x7) | (x0,…,x7,x7,…,x7) ∈ R0}∈〈{R0}〉∧, we have H0 = (G2 ×{1}) ∪{0}. On a side note, we observe that H0 = V0 ∘〈χ3〉, which we can use alternatively without detouring via R0. Given the relationship between G2 and H0, we do not need the global variable z in the definition of φ″, but we need to have it in the definition of φ″′, where the relation given by Lemma 45 necessitates atoms of the form \((u\xrightarrow {z = 0}v)\) forcing z to zero in every model.
The case where 〈Γ〉 = iV is similar to the previous: we can use the irredundant weak base relation H = V ∘〈χ3〉 = H0 ∪{1} = (G1 ×{1}) ∪{0}. Except for y in the definition of φ″ no additional global variables are needed in the definition of φ′, because [u → v] atoms are directly available for φ″′.
Corollary 47
If Γ is exactly Horn (iE ⊆〈Γ〉⊆iE2) or exactly dual-Horn (iV ⊆〈Γ〉⊆iV2) thenNOSol(Γ) isMinHornDeletion-completeunder AP-Turing-reductions.
Proof
Hardness follows from Lemma 46 and duality. Moreover, NOSol(Γ) can be AP-Turing-reduced to NSol(Γ ∪{[x],[¬x]}) as follows: Given a Γ-formula φ and a model m, we construct for every variable x of φ a formula \(\varphi _{x}= \varphi \land (x\approx \overline {m}(x))\). Then for every x where [φx]≠∅ we run an oracle algorithm for NSol(Γ ∪{[x],[¬x]}) on (φx,m) and output one result of these oracle calls that is closest to m.
We claim that this algorithm provides indeed an AP-Turing reduction. To see this observe first that the instance (φ, m) has feasible solutions if and only if this holds for (φx,m) and at least one variable x. Moreover, we have \(\text {OPT}(\varphi ,m) = \min _{x,[\varphi _{x}]\neq \emptyset }(\text {OPT}(\varphi _{x}, m))\). Let A(φ, m) be the answer of the algorithm on (φ, m) and let B(φx,m) be the answers to the oracle calls. Consider a variable x∗ such that \(\text {OPT}(\varphi ,m) = \min _{x,[\varphi _{x}]\neq \emptyset }(\text {OPT}(\varphi _{x},m)) = \text {OPT}(\varphi _{x^{*}},m)\), and assume that \(B(\varphi _{x^{*}}, m)\) is an r-approximate solution of \((\varphi _{x^{*}},m)\). Then we get
$$\frac{\text{hd}(m, A(\varphi, m))}{\text{OPT}(\varphi, m)} = \frac{\min_{y,[\varphi_y]\neq\emptyset}(\text{hd}(m, B(\varphi_y, m))}{\text{OPT}(\varphi_{x^*}, m)} \leq \frac{\text{hd}(m, B(\varphi_{x^*}, m))}{\text{OPT}(\varphi_{x^*}, m)} \leq r . $$
Thus the algorithm is indeed an AP-Turing-reduction from NOSol(Γ) to NSol(Γ ∪{[x],[¬x]}). Note that for Γ ⊆iV2 the problem NSol(Γ ∪{[x],[¬x]}) reduces to MinHornDeletion according to Propositions 29 and 27. Duality completes the proof.