0

Suppose I would like to generate n clauses, in 3-CNF form, that would give a unique solution for m variables (m<n). Example: for m=6, I've got {a,b,c,d,e,f} = 111010

How to generate these n 3-CNF clauses while minimizing this number of clauses (to avoid redundancies)? What would be the minimum number of clauses to generate ?

More precisely: I'm trying to find a boolean formula in 3-CNF with a minimal number of clauses that is satisfied only by the truth assignment.

2 Answers2

1

For simplicity, I assume that such a clause contains exactly $3$ litterals, and that those litterals are on different variables.

To create such a clause, you can do the following:

  • choose the $3$ variables that appear in the clause. There are $\binom{m}3$ such choices;
  • there are $2^3=8$ possibilities to create a clause with $3$ variables (each litteral can be positive, some variable $x$, or negative, the negation of a variable $\neg x$). Among those $8$ possibilities, only one create a clause that is not satisfied by the truth assignment (the only one where each litteral is negated by the truth assignment).

That means that there is a total of $7\binom{m}3$ different clauses. If $n$ is smaller than that, it is possible to generate $n$ different clauses.

Nathaniel
  • 15,071
  • 2
  • 27
  • 52
  • Thank you for your answer. Your method is corret but it doesn't generate the n minimum clauses. It generates 7 exclusions for each triplet. Some exclusions are redondant. – PeterMacGonagan Jan 19 '23 at 14:59
  • What do you call a minimum clause? A clause in a 3-CNF always contains exactly 3 litterals, so all clause are the same size. – Nathaniel Jan 19 '23 at 15:03
  • I would like to limit the number of 3-CNF clauses. If you take my example, m=6 (a,b,c,d,e,f), I can generate 7 * 6!/(3! 3!) clauses = 720 = 140 clauses. 7{A,B,C}, 7*{A,B,D}, etc. But, I suppose that there is no need to generate 140 clauses. May be it's possible to obtain a unique solution with only 30 clauses (I don't know the answer) because there are redondancies between clauses. – PeterMacGonagan Jan 19 '23 at 16:00
  • 1
    What you are asking is very confusing. What does "redondancies between clauses" mean? What is your expected output? Are you trying to find a boolean formula in 3-CNF with a minimal number of clauses that is satisfied by the truth assignment? Are you trying to find a boolean formula in 3-CNF with a minimal number of clauses that is satisfied only by the truth assignment? Please clarify. – Nathaniel Jan 19 '23 at 16:11
  • I'm trying to find a boolean formula in 3-CNF with a minimal number of clauses that is satisfied only by the truth assignment. Thank you – PeterMacGonagan Jan 20 '23 at 12:15
1

Since the question has been clarified (by my comment) and its content is quite different than its initial formulation, I am posting a new answer.

Assume $\mathcal{V} = \{x_1, x_2, …, x_n\}$ is a set of variables and $\mu \in \{0,1\}^{\mathcal{V}}$ is a truth assignment. For $i\in \{1, …, n\}$, consider $\mu_i$ to be the restriction of $\mu$ to the $i$ first variables $\{x_1, …, x_i\}$. For $i\in \{1, …, n\}$, denote $\ell_i$ the litteral of variable $x_i$ that is satisfied by $\mu$ (meaning if $\mu(x_1) = 1$, then $\ell_1 = x_1$, if $\mu(x_4) = 0$, then $\ell_4 = \neg x_4$). Depending on what you call a clause, the solution could be different.

  • If a clause can contain only one litteral, then the formula $\varphi = (\ell_1)\land (\ell_2) \land … \land (\ell_n)$ is in 3-CNF and is satisfied only by $\mu$. It contains exactly $n$ clauses.
  • If a clause must contain 3 litterals, but can contain the same litteral multiple times, then the formula: $$\varphi = (\ell_1\lor \ell_1 \lor \ell_1)\land (\ell_2\lor \ell_2 \lor \ell_2) \land … \land (\ell_n\lor \ell_n \lor \ell_n)$$ is again in 3-CNF and satisfied only by $\mu$, and still contains $n$ clauses.
  • If $n\geqslant 3$ and a clause must contain 3 litterals with different variables, one can construct a formula by induction on $n$:
    • if $n=3$, then the formula: $$\varphi_3 = (\ell_1\lor \ell_2\lor \ell_3)\land (\ell_1 \lor \ell_2 \lor \neg \ell_3)\land (\ell_1\lor \neg\ell_2\lor \ell_3)\land(\neg\ell_1\lor \ell_2\lor \ell_3)\land(\ell_1\lor \neg\ell_2\lor \neg\ell_3)\land(\neg\ell_1\lor \ell_2\lor \neg\ell_3)\land(\neg\ell_1\lor \neg\ell_2\lor \ell_3)$$ (all possible clauses except $\neg\ell_1\lor \neg\ell_2\lor \neg\ell_3$) is in 3-CNF and satisfied only by $\mu$. It is of minimal size in that aspect (otherwise another truth assignment could satisfy $\varphi$).

    • if $n\geqslant 3$, then consider $\varphi_{n-1}$ a formula that is satisfied by $\mu_{n-1}$ ($\mu$ restricted to the first $n-1$ variables) and no other truth assignment over $\{x_1, …, x_{n-1}\}$. The formula: $$\varphi_n = \varphi_{n-1} \land (\neg \ell_1 \lor \neg \ell_2 \lor \ell_n)$$ is in 3-CNF and satisfied only by $\mu$. It contains exactly $n+4$ clauses.

      Now assume that there exists $i>3$ and a formula $\psi$ satisfied only by $\mu_i$ with $i+3$ clauses or less. Consider such a $i$ minimal.

      Since $\psi$ is not satisfied when swapping the truth value of $x_i$, that means that $\psi$ contains a clause $C = a\lor b \lor \ell_i$, and $\mu(a) = \mu(b) = 0$.

      Now consider $\sigma$ obtained from $\psi$ by: - deleting the clause $C$; - in each other clause, replacing $\ell_i$ with any $\ell_j$ such that $j < i$, and replacing $\neg \ell_i$ with any $\neg \ell_j$ such that $j<i$, in each case with $j$ corresponding to a variable not already in the clause (possible given that $i > 3$).

      Then $\sigma$ must be satisfied only by $\mu_{i-1}$ but contains $(i-1) +3$ clauses or less, which contradicts the choice of $i$. By contradiction, we conclude that this construction is indeed minimal in the number of clauses.

Nathaniel
  • 15,071
  • 2
  • 27
  • 52