Skip to content
Kudos AI
Lire en français
Logic and Knowledge

A Million Clauses, or Sixty-One

Converting one short formula to conjunctive normal form by distributing gives 1,048,576 clauses and 20,971,520 literals; naming the subformulas gives 61 clauses and 160 literals, a factor of 131,072 in literals, and loses nothing at all - the two have the same number of models, checked exhaustively. The encoding is where a satisfiability problem is won or lost, not the solver.

4 min readKudos AI

Prerequisites: Logic and Knowledge Representation

A formula rewritten into clauses, two clauses with a complementary pair sliding together to produce their resolvent, and the chain closing on the empty clause.

Resolution has one inference rule and it needs its input in conjunctive normal form: a conjunction of disjunctions of literals. Every propositional formula has a CNF equivalent, which is usually stated as though it settled the matter.

Here is a formula that makes the difference between "has one" and "you can afford it".

φ  =  (x1∧y1)∨(x2∧y2)∨⋯∨(x20∧y20).\varphi \;=\; (x_1 \wedge y_1) \vee (x_2 \wedge y_2) \vee \dots \vee (x_{20} \wedge y_{20}).

Twenty conjunctions, forty variables, one line.

A. Distributing

The textbook conversion distributes ∨\vee over ∧\wedge. Each of the twenty disjuncts contributes either its xx or its yy to each clause, independently, so the result has one clause per choice:

220=1,048,576 clauses,2^{20} = 1{,}048{,}576 \text{ clauses},

each twenty literals long: 20,971,520 literals in total. For thirty disjuncts it is 1,073,741,824 clauses. The conversion is correct, terminating, and useless.

B. Naming the subformulas

The alternative is to give each conjunction a name. Introduce tit_i and assert ti↔(xi∧yi)t_i \leftrightarrow (x_i \wedge y_i), which is three clauses:

(¬ti∨xi),(¬ti∨yi),(ti∨¬xi∨¬yi),(\neg t_i \vee x_i), \qquad (\neg t_i \vee y_i), \qquad (t_i \vee \neg x_i \vee \neg y_i),

and then say that at least one of them holds: (t1∨⋯∨t20)(t_1 \vee \dots \vee t_{20}).

That is 3×20+1=613 \times 20 + 1 = \mathbf{61} clauses and 160 literals, against 20,971,520. A factor of 131,072 in literals, from a rewriting rule rather than from a better solver. This is the Tseitin transformation, and it is what every SAT solver's front end does.

C. What it costs

The usual summary is that the result is equisatisfiable rather than equivalent, which sounds like a concession. It is worth being precise about how small the concession is.

The new formula has twenty extra variables, so it is a formula about a different vocabulary and cannot be equivalent to φ\varphi in the strict sense. But each tit_i is forced: the three clauses pin it to the truth value of xi∧yix_i \wedge y_i, with no freedom left. Every model of φ\varphi therefore extends to exactly one model of the encoding, and counting them confirms it:

nnmodels of φ\varphimodels of the encoding
111
277
33737
4175175

Checked by enumerating every assignment, 22n2^{2n} of them for φ\varphi and 23n2^{3n} for the encoding. Satisfiability is preserved, the solutions are preserved, and even the model count is preserved. What is not preserved is the variable list, and the price of that is a projection step at the end.

Interactive: a million clauses, or sixty-one

Log axis. Both encodings are drawn; the toggle picks the one described.

110010k1M100M15101520ndistributed, clausesdistributed, literalsTseitin, clausesTseitin, literals
Clauses in this encoding
1,048,576
Literals in this encoding
20,971,520
Models, either encoding
1,096,024,843,375
Distributed over Tseitin, literals
131,072x
Distributed over Tseitin, clauses
17,190x
The first clauses: (x1 ∨ x2 ∨ x3 ∨ x4 ∨ x5 ∨ x6 ∨ x7 ∨ x8 ∨ x9 ∨ x10 ∨ x11 ∨ x12 ∨ x13 ∨ x14 ∨ x15 ∨ x16 ∨ x17 ∨ x18 ∨ x19 ∨ x20), (y1 ∨ x2 ∨ x3 ∨ x4 ∨ x5 ∨ x6 ∨ x7 ∨ x8 ∨ x9 ∨ x10 ∨ x11 ∨ x12 ∨ x13 ∨ x14 ∨ x15 ∨ x16 ∨ x17 ∨ x18 ∨ x19 ∨ x20), (x1 ∨ y2 ∨ x3 ∨ x4 ∨ x5 ∨ x6 ∨ x7 ∨ x8 ∨ x9 ∨ x10 ∨ x11 ∨ x12 ∨ x13 ∨ x14 ∨ x15 ∨ x16 ∨ x17 ∨ x18 ∨ x19 ∨ x20), ... 1,048,576 clauses in all.

Distributing picks x or y from each of the 20 disjuncts independently, so it writes 1,048,576 clauses of 20 literals each. The literal ratio is 2 to the power n - 3, so every extra disjunct doubles the gap. Both have 1,096,024,843,375 models, 4 to the n minus 3 to the n, because each new variable is forced to the value of the conjunction it names.

D. The rule itself

Resolution takes two clauses containing a complementary pair and produces their resolvent:

(α∨ℓ)(β∨¬ℓ)(α∨β).\frac{(\alpha \vee \ell) \qquad (\beta \vee \neg \ell)}{(\alpha \vee \beta)}.

It is not complete for deriving arbitrary consequences - from PP it will never derive P∨QP \vee Q, which is entailed - but it is refutation-complete: if a set of clauses is unsatisfiable, repeated resolution derives the empty clause. That is enough, because KB⊨α\text{KB} \models \alpha exactly when KB∧¬α\text{KB} \wedge \neg\alpha is unsatisfiable.

On the clauses {P∨Q,  ¬P∨R,  ¬Q∨R,  ¬R}\{P \vee Q,\; \neg P \vee R,\; \neg Q \vee R,\; \neg R\} a four-step refutation exists:

  1. ¬R\neg R with ¬P∨R\neg P \vee R gives ¬P\neg P
  2. ¬R\neg R with ¬Q∨R\neg Q \vee R gives ¬Q\neg Q
  3. P∨QP \vee Q with ¬P\neg P gives QQ
  4. QQ with ¬Q\neg Q gives the empty clause.

Saturating blindly instead - resolving every pair until nothing new appears - derives 8 new clauses and reaches a closure of 12 before it gets there. On four clauses the difference is nothing. It is the same difference that separates a modern conflict-driven solver from the algorithm as written in a textbook, and at scale it is everything.

The figure runs the same rule on a different knowledge base, the Wumpus breeze rule B1,1⇔(P1,2∨P2,1)B_{1,1} \Leftrightarrow (P_{1,2} \vee P_{2,1}) with ¬B1,1\neg B_{1,1}: four clauses plus the negated query, and every answer is checked against the eight possible worlds.

Interactive: a refutation, clause by clause

Answered twice: by resolution, and by enumerating the eight worlds.

Knowledge base in CNF, with the negated query last

  • !B11 v P12 v P21
  • !P12 v B11
  • !P21 v B11
  • !B11
  • P12
Clauses to start
5
New clauses derived
5
Empty clause
yes
Model checking agrees
yes

Resolvents, in the order the prover found them

  • !P12 v B11 + !B11 -> !P12
  • !P21 v B11 + !B11 -> !P21
  • !P12 v B11 + P12 -> B11
  • !B11 v P12 v P21 + !P12 -> !B11 v P21
  • P12 + !P12 -> []
ask whether the knowledge base entails

The empty clause appeared after 5 new clauses, and an empty disjunction is false in every model. So the knowledge base together with the negated query cannot be satisfied, which is precisely what it means for the knowledge base to entail the query. Model checking, enumerating all eight worlds and sharing no code with any of this, agrees.

E. What to take from it

  • The translation is part of the algorithm. A problem that is impossible after distributing and routine after Tseitin was never a hard problem; it was a badly encoded one.
  • Count literals, not clauses. The distributed form above is bad in both, but encodings that look comparable by clause count often differ by an order of magnitude in literals, which is what propagation actually walks.
  • "There exists a CNF equivalent" is a statement about existence. So is "every problem in NP reduces to SAT". Both are true, and neither says anything about the size of what you get.

References & further reading

  • Stuart Russell, Peter Norvig, Artificial Intelligence: A Modern Approach, Pearson (3rd edition), 2010· Kudos AI reference library

Copyrighted works are cited for reference only and are not hosted here; please consult the publisher for access.

Related reading

9 min readLogic and Knowledge

Logic and Knowledge Representation

Reasoning about what must be true: models and entailment worked by exhaustive enumeration, soundness and completeness, why propositional logic runs out of expressive power, and where first-order logic picks up.

Knowledge RepresentationArtificial Intelligence
7 min readSearch and Games

Game Theory and Nash Equilibrium

Strategic reasoning when players are not strictly opposed: dominant strategies, the prisoner's dilemma worked from its payoff matrix, Nash equilibrium, Pareto optimality, and why equilibrium and efficiency can conflict.

Game TheoryArtificial IntelligenceMathematics
4 min readProbability Foundations

Which Wrong Distribution Do You Want?

One bimodal target, one Gaussian, and two directions of the same divergence. Minimising KL(P||Q) puts the Gaussian across both modes with almost no mass where the target actually lives; minimising KL(Q||P) puts it on one mode at a value of 0.6931 nats, which is ln 2 to four decimals and not a coincidence. Each fit is judged catastrophic by the other objective, 2.0976 against 15.2799.

Machine LearningMathematics
← Back to all articles