4
$\begingroup$

Is the problem of deciding whether a SAT instance, where at most two clauses are false (that is, any given variable assignment will either lead to all clauses being true, all but one, or all but two), is satisfiable solvable in polynomial time?

This is a follow-up from my previous question. The problem presented in that question (at most one false clause) was solvable in polynomial time, because we could take advantage of the fact that the set of truth assignments that make a clause false is disjoint to that of any other clause. With two or more clauses, the sets that make a clause false can overlap with each other. Does this mean that problems with at most two (or more) false clauses (when I say "or more," I do not mean that the number can change with the problem size. A problem with five clauses where at most five are false is a trivial version of regular SAT, but what about a problem of a few million clauses where are most five can be false?) are NP-complete, or are all versions of SAT where you limit the number of false clauses solvable in polynomial time?

$\endgroup$

2 Answers 2

4
$\begingroup$

Yes. You can solve this in polynomial time. The same strategy as in Are SAT problems with at most one false clause NP-complete? works.

Let $\varphi$ denote the CNF formula you care about, and $n$ the number of variables in $\varphi$. Let $A_{i,j}$ denote the number of truth assignments that do not satisfy clauses $i$ or $j$ of $\varphi$, let $A_i$ denote the number of truth assignments that do not satisfy clause $i$ but do satisfy all other clauses of $\varphi$, and let $A$ denote the number of truth assignments that satisfy all clauses of $\varphi$.

These three cases are mutually exclusive. Therefore,

$$\sum_{i,j} A_{i,j} + \sum_i A_i + A = 2^n,$$

where $n$ counts the number of variables in the formula. In other words,

$$A = 2^n - \sum_{i,j} A_{i,j} - \sum_i A_i.$$

You can compute $A_i$. Let $S_i$ denote the set of variables mentioned in clause $i$. There is only one assignment to the variables in $S_i$ that will make clause $i$ false, so substitute in those values for the variables in $S_i$ and simplify the formula; the result is a CNF formula $\varphi'$ where we are guaranteed that every assignment to the remaining $n-|S_i|$ variables satisfies at most one clause, so https://cs.stackexchange.com/a/115849/755 tells us how to count the number of satisfying assignments to $\varphi'$, say $n_i$. Then $A_i = n_i$.

You can compute $A_{i,j}$. It is either $2^{n-|S_i \cup S_j|}$ or $0$, depending on whether there is any variable $x_k$ such that both $x_k$ and $\neg x_k$ appear in those clauses $i$ and $j$ of $\varphi$.

Therefore, you can compute $A$, the number of assignments that satisfy the formula. Now, if $A \ne 0$, then you know that the formula is satisfiable; if $A=0$, the formula is not satisfiable.

$\endgroup$
5
  • $\begingroup$ @DmitriUrbanowicz, oops, good point! That was a serious flaw in my previous answer. Thank you for pointing that out. See revised answer, where I have attempted to fix things up. Does it look correct now? Did I miss anything else? $\endgroup$
    – D.W.
    Commented Nov 1, 2019 at 18:17
  • $\begingroup$ looks good. But I also think you could avoid the simplification step. If $B_i$ denotes number of "at least one"-type assignments, then it seems that $\sum_{i}{B_i} = \sum_{i}{A_i} + 2 \sum_{i,j}{A_{i, j}}$. $\endgroup$ Commented Nov 2, 2019 at 8:20
  • $\begingroup$ @DmitriUrbanowicz, oh, good point, that is a nice alternate solution. I like it. Thank you. (I don't understand why the 2 though.) $\endgroup$
    – D.W.
    Commented Nov 3, 2019 at 6:08
  • $\begingroup$ I assume $A_{i,j}$ is only defined when $i<j$. Every pair $i,j$ from $A_{i,j}$ will have two appearances then: one in $B_i$ and another in $B_j$. $\endgroup$ Commented Nov 3, 2019 at 14:53
  • $\begingroup$ @DmitriUrbanowicz, cool, that makes sense. Thank you. $\endgroup$
    – D.W.
    Commented Nov 3, 2019 at 18:50
-2
$\begingroup$

It depends on the availability of data...

If you store the relaitonships between the data rather than trying to compute at runtime then it is an o1 operation with massive storage requirements...

Otherwise arbitrarily hard..

$\endgroup$
1
  • $\begingroup$ How does your post answer the question? $\endgroup$
    – Evil
    Commented Nov 1, 2019 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.