The completeness theorem for says that whenever a sentence follows from others, it has a derivation from them. It does not say how to find one, and the search is hard to steer: at every step one may appeal to excluded middle for any formula at all, or instantiate a quantifier at any term, and nothing on the page says which choice leads anywhere.
Semantics offers a second route. By definition, fails exactly when some model of makes false. So instead of looking for a derivation we may look for such a model, a counter-model. If the search finds one, the entailment fails, and the model shows it. If the search is systematic and fails, the entailment holds. This chapter is about making that search precise, mechanical and fast.
The search comes down to something simple. As far as a given question is concerned, a structure is pinned down by which basic facts hold in it: whether this element has that property, whether those two are related. Each basic fact is a switch, on or off, and a model is a setting of the switches that makes every sentence true. Programs that look for such settings are called SAT solvers.
SAT solvers are among the most used tools of logic. Whenever a problem comes down to “find a choice of yes-or-no settings that obeys all these constraints, or show that there is none”, a solver can be put to work on it, and many problems do.
Hardware. Chip makers check that an optimised circuit computes the same function as its specification, and search for inputs that drive a design into a bad state within a given number of clock cycles. A bug found this way costs nothing; one found after manufacture can cost a fortune.
Software. Questions about programs (can this index go out of bounds? can these two versions of a function ever disagree? can anyone outside this account read this file?) are translated into satisfiability questions, usually through the SMT solvers of Remark 7.48, which run a SAT solver at their core.
Configuration. Installing software means choosing versions of packages so that every dependency is met and no two conflict, and several package managers hand that problem to a SAT solver. Configuring a product with options that exclude or require one another is the same problem.
Planning and scheduling. Timetables, rosters and plans are written as “at each step, which actions happen”, and the solver finds a plan or shows that none exists.
Mathematics. Solvers have settled open combinatorial questions by exhaustive search, among them the Boolean Pythagorean triples problem in 2016, with a certificate of some two hundred terabytes that an independent program checked.
In none of these does anybody write the solver’s input by hand. The problem is stated in a natural language of its own, with quantifiers and arrows and arithmetic, and a program translates it into the shape the solver wants. This chapter studies both halves: the translation and the search.
The chapter first solves a simpler problem, and then reduces the real one to it.
Propositional. Given constraints on finitely many switches, is there a setting that obeys them all?
Section 7.1 shows that entailment and validity are questions of satisfiability, and that once the things to be talked about are named, the question is propositional.
Section 7.2 grows a setting one switch at a time, and asks what the search must be able to read off its constraints.
Section 7.3 puts every constraint into the shape that makes this easy, conjunctive normal form, and draws it as a matrix through which a satisfying setting is a path.
Section 7.4 proves that the resulting search, DPLL, is correct, and Section 7.5 shows how a program runs it with sets and a single operation on them.
First-order. Sections 7.6 to 7.8 name every “someone”, prove that a search may look only at the things it has named, and hand the resulting switches to DPLL, level by level.
Two optional sections follow. Section 7.9 opens the black box of Section 7.6, and Section 7.10 shows that a failed search is itself a proof, that some such proofs must be long, and how the instances that can clash are found without listing the rest. The main line quotes some of their results but none of their proofs.
7.1 Satisfiability
This section makes the idea of the introduction exact. It names the property a solver decides, satisfiability, shows that entailment and validity reduce to it, and explains why the heart of the matter is propositional. Throughout, is a signature, and structures and sentences are -structures and -sentences, as in Chapter 6.
Definition 7.1 (satisfiable). A set of sentences is satisfiable if it has a model.
Formally, a set of sentences is satisfiable if
and unsatisfiable otherwise; a sentence is satisfiable if is.
Definition 7.2 (counter-model). A counter-model is a structure that shows an entailment to fail.
Formally, a counter-model to is a structure with
Lemma 7.3 (reduction to satisfiability). For every set of sentences and every sentence ,
if and only if is unsatisfiable;
is valid if and only if is unsatisfiable.
Proof. A model of is exactly a counter-model to , and an entailment holds exactly when it has none. Part (ii) is part (i) with empty. □
In words: every question about what follows from what, and about what is valid, is a question about whether some set of sentences has a model.
The lemma is close to a tautology, but it changes what we look for. A proof that may now be a failed attempt to build a model of , provided the attempt is systematic enough to show that every way of building one collapses.
Example 7.4 (the company: a policy change and a bug report). Harriet Ashworth looks after the platform of the company of Chapter 6. She has been asked to sign off two rules for its access policy, that engineers report to managers and that managers are not engineers:
Their point is that no engineer reports to an engineer:
Harriet looks for a counter-model. Suppose some engineer, call her , reports to an engineer. By , ’s boss is a manager; by , ’s boss is not an engineer; but she is. Every line was forced by the lines above it, so there is no counter-model, and .
A colleague proposes dropping , so that a senior engineer can lead a team. The same search now runs out of demands instead of collapsing. Suppose an engineer reports to an engineer . By , is a manager, and nothing forbids that; by again, ’s boss is a manager, and the simplest choice is herself. What is left is a structure: two engineers, with a manager and the boss of both, naming , empty and identity. It satisfies and falsifies at . That is not a failed proof but a bug report: the weakened policy allows an engineer who manages an engineer. (Example 7.77 finds a counter-model with one person.)
So the question to hand to a program is whether a finite set of sentences has a model. We call the members of such a set its constraints, since each is a sentence the model must make true, and a program that decides whether a finite set of constraints has a model is a solver. We ask more of a solver than a verdict: we want evidence that can be checked without trusting it. For “yes” the evidence is a model, which, if finite, anyone can check by evaluating the sentences in it. For “no” it must be a finite object showing that every attempt to build a model collapses; Section 7.4 builds one.
Switches
A solver cannot list structures: a model may have five elements, or be the natural numbers, and there is no list to go through. It does what the search of Example 7.4 did. It names the things it needs, and records for each atomic sentence about them, such as or , whether it holds. Each atomic sentence is a switch, and what the search builds is a setting of the switches. A setting can be written down, finitely many switches have finitely many settings, and a search through them can be seen to have failed. Section 7.7 shows that nothing is lost: a set of constraints has a model exactly when some setting of the switches about its names obeys every instance of the constraints. The core of the problem is therefore propositional, and the next four sections solve it.
Propositional logic
Once the switches are fixed, what is inside an atomic sentence plays no part, and might as well be a single letter. So until Section 7.6 we fix a set of letters, the switches of the search, write , , for letters, and build formulas by the grammar
with the bracket conventions of Chapter 6 and abbreviating . Here is a connective in its own right rather than an abbreviation of . The two readings always agree in truth value, and having as a connective lets the translations of Section 7.3 say directly what they do to a negation.
A structure for a signature of letters amounts to a valuation
(the propositional case of satisfaction), which is exactly a setting of the switches. We write , and “satisfiable” with the meanings of Chapter 6. One more notion is needed: when two formulas allow the same settings, one may replace the other.
Definition 7.5 (equivalent formulas). Two formulas are equivalent when every valuation gives them the same value.
Formally, if, for every valuation ,
Equivalence is a congruence: replacing a part of a formula by an equivalent part gives an equivalent formula, since the value of a formula is computed from the values of its parts.
7.2 Growing a Valuation
A search for a satisfying valuation could try the rows of the truth table one by one. That is correct and hopeless: a hundred letters give more rows than there are stars in the observable universe, and the problems solvers meet in practice have millions of letters. A search by hand does better. It sets one switch at a time, and stops as soon as the constraints are settled one way or the other. This section sets up the language for such a search: what a valuation looks like half-built, how it grows, and the one move that is always safe. It ends with the question that shapes the rest of the propositional part: how can the search tell that a half-built valuation has settled a constraint?
Partial valuations
Halfway through the search some letters have a value and the rest have none yet. Two definitions describe that state: a literal says how one switch is set, and a partial valuation says how several are.
Definition 7.6 (literal). A literal says that one switch is on, or that it is off.
Formally, a literal is a letter or a negated letter . We write for a literal, and for its complement:
Definition 7.7 (partial valuation). A partial valuation gives some letters a truth value and leaves the rest undecided.
Formally, a partial valuation is a partial function
defined on finitely many letters. A letter is decided by if is defined, and undecided otherwise. On literals we set
The partial valuation that decides nothing is written .
A partial valuation is not a valuation with gaps filled in arbitrarily: on an undecided letter it has no opinion, and neither nor holds. Writing for the one that decides nothing is apt, since a function defined nowhere is, as a set of pairs, empty.
Definition 7.8 (extension). One partial valuation extends another when it keeps everything the other has decided.
Formally, a partial valuation or valuation extends a partial valuation , written , if
Three facts follow at once.
Extension is transitive: if and , then .
Everything extends .
What makes true, every extension makes true: if and , then .
Definition 7.9 (adding a literal). Adding a literal sets one more switch, so as to make the literal true.
Formally, for a partial valuation and a literal whose letter is undecided by , the partial valuation agrees with on the letters decides, decides nothing else besides , and sets
So is “ with on” and is “ with off”; unlike the update of an assignment, it only fills a blank. A partial valuation is fixed by the literals it makes true, so we name it by listing them in braces: is the partial valuation with on, off and every other letter undecided, the one reached from by adding and then . In this notation
and , the partial valuation that decides nothing, is the empty list, as its name says. The proofs below use one fact about adding a literal, which is read off the definition: for every valuation ,
Definition 7.10 (alive, dead). A partial valuation is alive for a set of formulas if some way of finishing it satisfies the set, and dead otherwise.
Formally, is alive for if
and dead for otherwise.
In words: is alive when a search that has made the choices recorded in can still succeed. So a set is satisfiable exactly when is alive for it, and the search decides this by following the question down, from to . For a single formula , “alive for ” means alive for .
Splitting
The first move needs no information at all: pick an undecided letter and try both values.
Lemma 7.11 (splitting). Let be a set of formulas, a partial valuation and a letter undecided by . Then
Proof. A valuation that extends or extends . Conversely, a valuation that extends makes true or false, and so extends or . □
The choice of a letter and the two tries are a decision. The lemma says that a decision loses nothing, provided both sides are tried.
Remark 7.12 (why the search must be able to go back). It is tempting to try one side only: go through the letters in order and set each for good, on unless that makes some constraint false. On the constraints
in the order , , , this sets on (no constraint is yet false), and then either value of falsifies a constraint, and the method is stuck. Yet off and on satisfy all three. Without the other side of the split, a search can answer “no” when the answer is “yes”.
What the search must read off
Splitting is always safe, but on its own it is the truth table again, one letter at a time. What makes a search fast is knowing when to stop and when not to guess. Under a partial valuation the search wants to know, for each constraint, which of three things holds:
every valuation that extends satisfies it, so it can be forgotten;
no valuation that extends satisfies it, so is dead;
it has only one way left to be satisfied, so the next switch is forced.
For an arbitrary formula none of these can be seen by looking. Whether is dead for is the question whether is satisfiable, which is the very problem we are trying to solve.
For one shape of constraint, though, all three are visible at a glance. A disjunction of switches set on or off, such as
is satisfied by every extension of as soon as makes one disjunct true; it is dead as soon as makes every disjunct false; and when makes all disjuncts but one false, the last one must be made true. A conjunction of such disjunctions is satisfied when each conjunct is, and dead when one conjunct is. So we want every constraint in that shape. The shape is called conjunctive normal form, and it is the subject of the next section.
7.3 Conjunctive Normal Form
Section 7.2 asked for constraints whose status under a partial valuation can be read at a glance, and found the shape: a conjunction of disjunctions of switches set on or off. It is also the shape every constraint has in principle. A constraint can only forbid: its value is fixed by the values of its letters, so all it can do is rule out some combinations of them. The constraint is false in exactly one row of its truth table, the one with on, on and off, so it says no more than “not that row”, that is, “ off, or off, or on”: the disjunction . A constraint that forbids several rows is several such disjunctions, joined by . This section defines the shape, shows how to reach it from any formula in two stages, and draws it as a matrix in which a satisfying valuation is a path.
Definition 7.13 (clause). A clause is a list of literals of which at least one must hold.
Formally, a clause is a disjunction
of literals, with ; its literals are . For it is , the empty clause, written . A clause with one literal is a unit clause. We write , for clauses.
A valuation satisfies a clause when it makes one of its literals true; the empty clause is satisfied by nothing. Since is commutative, associative and idempotent, neither the order of the literals nor repetition changes what a clause says: , and are equivalent.
Definition 7.14 (conjunctive normal form). A formula is in conjunctive normal form when it is a list of clauses, all of which must hold.
Formally, a formula is in conjunctive normal form if it is a conjunction
of clauses, with ; for it is . Its clauses are .
A valuation satisfies a formula in conjunctive normal form exactly when it satisfies each of its clauses. A finite set of formulas in conjunctive normal form can be read as the single conjunction of all their clauses, and we do so without comment.
Example 7.15 (the platform: five rules). Harriet’s platform has a hundred feature switches and a file of rules that they must obey together. Three of the switches are fast-sync, offline-mode and compression, written , and , and five rules concern them: fast-sync needs offline-mode; offline-mode needs fast-sync; the mobile app needs at least one of the two; with both on, compression must be on, or the sync saturates the link; and with both on, compression must be off, since the offline cache cannot read compressed packets. As clauses, with the pattern each forbids:
The rule file is the formula in conjunctive normal form. No setting avoids all five patterns: the first three force and on, and then and disagree about . The file has a bug; Example 7.25 shows it in the matrix, and Example 7.34 shows DPLL finding it.
Two stages
Reading the clauses off the truth table is out of the question, since thirty letters give a billion rows. The conversion works on the formula itself, in two stages.
Push every negation down to the letters and remove the arrows, so that only and stand above the literals. After this stage every letter occurs as a switch that is plainly on or plainly off.
Push every below every . After this stage the formula is a list of clauses.
Stage 1: negation normal form
The negations are pushed down by De Morgan’s laws, double negation and the truth table of the arrow,1 each checked by a truth table of four rows or two:
Definition 7.16 (negation normal form). A formula is in negation normal form when negation occurs only on letters and the only other connectives are and .
Formally, a formula is in negation normal form if it is built from literals, and by and alone.
Definition 7.17 (the translation into negation normal form). The translation applies the laws above from the outside in.
Formally, is defined by recursion on the size of , by the equations
Exactly one equation applies to each formula. The recursion is on size rather than shape, since an equation may call on , which is not a part of ; but is smaller than , so the recursion ends.
Lemma 7.18 (negation normal form is faithful). For every formula , the formula is in negation normal form, and .
Proof. The shape of is read off the equations, each of which returns a literal, or , or combines results of by or . The equivalence is by induction on the size of . The first equation is trivial; for and use the induction hypothesis and the congruence; each of the other five replaces by the right-hand side of one of the laws and applies the induction hypothesis to the smaller formulas there, as in
□
Stage 2: multiplying out
The law that moves below is distributivity,
school algebra’s with for times and for plus. Two conjunctions of clauses multiply out like , every clause of one against every clause of the other:
For clauses and we write for the clause whose literals are those of followed by those of .
Lemma 7.19 (multiplying out). For formulas and in conjunctive normal form,
Proof. Under a valuation the right-hand side is false exactly when some is, that is, when some and some are both false, which is exactly when both conjunctions on the left are false. □
In words: a disjunction of two lists of demands is the list of all pairwise disjunctions of their demands, just as is .
Definition 7.20 (the translation into conjunctive normal form). The translation multiplies out every over every , from the inside out.
Formally, for in negation normal form, is defined by recursion on the shape of , by the equations
where in the last equation and , and in the one before it the conjunction lists the clauses of both sides. The conjunctive normal form of an arbitrary formula is .
Proposition 7.21 (the conjunctive normal form is equivalent). For every formula , the formula is in conjunctive normal form, and .
Proof. By the faithfulness of negation normal form (Lemma 7.18) it suffices that for in negation normal form, by induction on the shape of : the first three equations change nothing, the fourth is the induction hypothesis with associativity of , and the fifth is the induction hypothesis with the lemma on multiplying out (Lemma 7.19). The shape of the result is read off the equations. □
Example 7.22 (a conjunctive normal form). Take . Stage 1 gives
and Stage 2 multiplies out:
The two clauses forbid exactly the rows that make false: and off, and on with off.
The matrix
A formula in conjunctive normal form is a switchboard, and it reads best laid out as one. Write it as a matrix, with one column for each clause and the literals of the clause stacked in its column. For instance,
A valuation that satisfies the formula makes some entry of every column true. Reading one such entry from each column, left to right, traces a way through the matrix, and the entries on it are never complementary, since a valuation cannot make both and true. That is the whole of satisfiability.
Definition 7.23 (path). A path through a formula in conjunctive normal form picks one literal from each clause.
Formally, let be in conjunctive normal form. A path through is a sequence in which each is a literal of . Two complementary literals on a path form a connection, and a path without a connection is consistent.
In the matrix above, is a consistent path and is not: its first two entries form a connection. A formula with the empty clause among its clauses has no paths at all, since nothing can be picked from an empty column; the formula , with no clauses, has exactly one path, the empty one, and it is consistent.
Lemma 7.24 (paths). A valuation satisfies a formula in conjunctive normal form if and only if it makes every literal of some path through it true. Hence the formula is satisfiable if and only if some path through it is consistent.
Proof. Let . If , choose for each a literal of that makes true; the choices form a path whose literals makes true. Conversely, a valuation that makes every literal of a path true makes a literal of each clause true. For the second claim, a path whose literals are all true under one valuation has no connection; and a consistent path has a valuation making all its literals true, namely one that sets each letter on the path so as to make its occurrences there true, which consistency allows, and sets the other letters at will. □
In words: a formula in conjunctive normal form is satisfiable exactly when there is a way through its matrix that never throws a switch both ways. Section 7.4 searches for such a way without listing the paths, whose number is the product of the lengths of the clauses.
Example 7.25 (the platform, cont’d: no way through). The matrix of the five rules of Example 7.15 is drawn in Figure 7.1, with one of its paths. Every path through , , without a connection contains both and ; a path that continues without a connection must then take from and from , and those two form a connection. So no path is consistent, and by the lemma no setting obeys the five rules.
Remark 7.26 (looking for connections). The matrix and its paths are the picture behind the connection method of automated reasoning, which looks at the lemma on paths from the other side. Instead of searching for one consistent path, it shows that there is none: a formula is unsatisfiable exactly when every path through its matrix contains a connection, so a refutation can be presented as a set of connections that between them block every path.2 The search of Section 7.4 can be read the same way: a closed branch shows that every path through the matrix clashes with the literals set on that branch.
The cost, and a way round it
Multiplying out multiplies the counts. The formula
has letters and clauses in its conjunctive normal form, one for each way of choosing or from every pair; thirty pairs give a billion clauses. Solvers avoid this by giving up equivalence and keeping only what they need, the verdict.
Definition 7.27 (equisatisfiable). Two sets of formulas are equisatisfiable when both are satisfiable or neither is.
Formally, sets and of formulas, propositional or first-order, are equisatisfiable if
Equisatisfiability keeps the verdict but not the evidence: and are equisatisfiable, and a valuation that satisfies one need not satisfy the other. So every rewriting of this chapter that is not an equivalence comes with a way back: a way of turning whatever satisfies the new set into something that satisfies the old one.
Remark 7.28 (at work: Tseitin’s translation). Each compound subformula of the input gets a new letter , with at most three clauses saying what it means. For , with letters and for the parts, the clauses , and say that is on exactly when and are; the other connectives are alike, and one unit clause asserts the whole formula. For pairs that is clauses rather than . The result is not equivalent to , since it mentions new letters, but it is equisatisfiable with , and the way back is to forget the new letters (Exercise 7.3).3
From here on, a constraint without quantifiers is a formula in conjunctive normal form.
7.4 DPLL
The search of Section 7.2 can now be run on constraints in the shape of Section 7.3. Let be a finite set of formulas, a formula, and the conjunction of the clauses of the conjunctive normal forms of the members of . Then
The three steps are the reduction lemma, the equivalence of the normal form, and the lemma on paths. So the task is to find a valuation that satisfies a formula in conjunctive normal form, or a consistent path through its matrix, or to show that there is none. A valuation that is found is a counter-model in miniature, a setting under which holds and fails; a proof that there is none is a proof that . This section makes the three readings of Section 7.2 precise for clauses, adds the second move of the search, the forced move, and proves that the resulting search, DPLL, is correct.
Reading the clauses
Section 7.2 asked for three readings of a constraint under a partial valuation, and for a clause each is a matter of looking at its literals.
Definition 7.29 (the status of a clause). Under a partial valuation a clause may be satisfied, falsified, or a unit.
Formally, let be a partial valuation. A clause is
satisfied under , written , if for some literal of ;
falsified under if for every literal of ;
a unit under , with undecided literal , if is a literal of whose letter does not decide, and for every literal of other than .
We write if for every clause of .
For instance, under :
The empty clause is falsified under every partial valuation, since it has no literal to make true.
In the matrix, a partial valuation ticks every entry it makes true and crosses out every entry it makes false. A column with a tick is satisfied; a column whose entries are all crossed out is falsified; and a column with no tick and a single entry left is a unit, and every consistent path that agrees with must go through that entry.
Lemma 7.30 (the status of a clause). Let be a partial valuation, a clause and a valuation with .
If , then .
If is falsified under , then .
If is a unit under with undecided literal , then if and only if .
Proof. Every literal true under is true under . In (i) some literal of is true under ; in (ii) every literal of is false under , hence under ; in (iii) every literal other than is false under , so is true exactly when is. □
In words: however the blanks are filled in, a satisfied clause stays satisfied and a falsified clause stays falsified, and a unit says how one blank must be filled. In particular, a partial valuation under which some clause of is falsified is dead for , and one with is alive.
Propagation
The second move of the search, after splitting, uses the third reading.
Lemma 7.31 (propagation: the other branch is empty). Let be a formula in conjunctive normal form and a partial valuation. If a clause of is a unit under with undecided literal , then is dead for , and so
Proof. A valuation that extends extends and makes false, so it falsifies by part (iii) of the lemma on the status of a clause (Lemma 7.30). The rest is the splitting lemma (Lemma 7.11). □
In words: when a clause has only one way left to be satisfied, the search may take that way without losing anything. Its literal is forced: a decision on its letter would be a waste, since one side of it is dead before it is tried. Unit propagation makes forced moves for as long as some clause is a unit and none is falsified. Each forced move may create new units, and on a good day propagation alone ends the search.
Chains of extensions
With both moves in hand, a search builds a chain of partial valuations, each the one before with a single literal added:
Each literal is forced by a unit or is one side of a decision, and by transitivity a valuation that extends the last link extends every link. Call the last link . The chain stops in one of two ways.
. Every valuation that extends satisfies , and the search has found what it wanted.
Some clause is falsified under . Then is dead. The search backs up to the last decision and starts a new chain from its other side.
Nothing is lost on the way: a forced step keeps every satisfying valuation, by propagation (Lemma 7.31), and a decision keeps them all between its two sides, by splitting (Lemma 7.11), provided the other side is tried when this one dies.
DPLL trees
Decisions, forced moves, and backing up from a dead end to the other side of the last decision make a method called DPLL, after the initials of the four people who wrote it down, in two papers two years apart.4 A run of it is a tree, grown from the root down: each node carries the literal a move added, and a decision forks. Figure 7.2 gives the rules: when what is above the bar holds of a branch, what is below may be written under it, and a vertical bar forks the branch.
Definition 7.32 (DPLL tree). A DPLL tree is a tree of literals grown from the root by the rules of Figure 7.2.
Formally, a DPLL tree for a formula in conjunctive normal form is a finite tree whose root carries no literal and whose other nodes carry literals, obtained from the root alone by applying unit and decide, each at the foot of a branch on which no clause of is falsified. The partial valuation of a branch whose literals, from the root down, are is , and a clause is satisfied, falsified or a unit on if it is so under .
In words: a DPLL tree is the record of a search. Each branch is one chain of extensions, and its literals are the decisions and forced moves made along it. Each rule adds a literal on a letter the branch leaves undecided, so is defined. The rules close and finish add no literal; they mark the foot of a branch with or .
Definition 7.33 (closed and complete). A branch is closed when it ends in a cross, finished when it ends in a tick, and complete when it ends in either.
Formally, a branch of a DPLL tree for is
closed if some clause of is falsified on , and open otherwise;
finished if ;
complete if it is closed or finished.
The tree is closed if every branch is closed, and complete if every branch is complete.
Example 7.34 (the platform, cont’d: the switches that follow). Harriet runs the search on the five rules of Example 7.15. No clause is a unit, so she decides , on first. Beside each node is the rule that wrote it, d for a decision and a clause for a forced move; a cross carries the clause it falsifies.
Branch by branch:
The tree is closed: five nodes and one decision, against eight rows of the truth table.
Remark 7.35 (what a closed branch knows). In Example 7.34 everything under node 1 closed, so is dead: the five rules entail , though none of them says so. In general, when every branch below a node closes, the partial valuation there is dead (the proof of soundness below shows it), and entails the clause made of the complements of the literals on the way down. Such a clause is worth keeping, since it records a dead end the search need never visit again; the optional Section 7.10 shows how solvers keep them, as learned clauses, and what the closed tree as a whole proves.
Correctness
Three things need proof: that a search can be carried to the end, that a closed tree is never wrong, and that an unsatisfiable formula always yields one.
Lemma 7.36 (termination). Let be a formula in conjunctive normal form with letters.
No branch of a DPLL tree for has more than nodes below the root.
There is a complete DPLL tree for .
Proof. Each rule adds a literal on an undecided letter, which gives (i). For (ii), apply rules to incomplete branches for as long as possible; by (i) this stops, after fewer than nodes. A branch that is neither closed nor finished has a clause neither satisfied nor falsified, hence an undecided letter, and decide applies; so when nothing applies the tree is complete. □
Theorem 7.37 (soundness of DPLL). If a formula in conjunctive normal form is satisfiable, then no DPLL tree for is closed.
Proof. We prove the contrapositive by working up a closed tree from its leaves: the status of a clause kills the leaves, and splitting and propagation carry death up to the root. For a node let be the partial valuation of the branch from the root to ; we show by induction on the number of nodes below that is dead for .
is a leaf. Its branch is closed, so some clause is falsified under , and is dead.
has two children, by a decision on . They carry and , both dead, so is dead by splitting (Lemma 7.11).
has one child, by unit with literal . It carries , which is dead, so is dead by propagation (Lemma 7.31).
At the root, is dead, so no valuation satisfies . □
In words: a closed DPLL tree is a certificate of unsatisfiability. Exercise 7.6 gives a second proof, which follows a satisfying valuation down the tree instead.
Proposition 7.38 (finished branches). If is a finished branch of a DPLL tree for , then for every valuation with .
Proof. Part (i) of the lemma on the status of a clause (Lemma 7.30), for each clause of . □
Theorem 7.39 (completeness of DPLL). If a formula in conjunctive normal form is unsatisfiable, then every complete DPLL tree for is closed.
Proof. An open branch of a complete tree is finished, and by the proposition every valuation extending it satisfies ; there is one, setting the remaining letters false. □
In words: when is unsatisfiable, every search carried to the end produces the certificate, whatever its choices. Reading a valuation off an open branch is the truth lemma of the completeness proof of Chapter 6 in miniature.
7.5 DPLL in Practice
The mathematics of Section 7.4 leaves a program three things to settle: how to store the constraints, how to store the valuation as it grows, and how to see quickly which clauses are units and which are falsified. The answers are sets, and an operation on them that throws one switch at a time and simplifies the constraints to match.
Clause sets
The matrix of Section 7.3 already ignored two things a formula records: the order of the columns, and the order and repetition of the entries in a column. Neither changes what the formula says, since and are commutative, associative and idempotent. A program stores only what matters, and that is a set of sets.
Definition 7.40 (clause set). A clause set records which clauses occur, each as the set of its literals.
Formally, the clause of is the set , a clause set is a finite set of clauses, and the clause set of is the set of the clauses of . We write , for clauses and for clause sets.
We still write a clause as the disjunction of its members, so that , and are now the same clause, , and the empty clause is the empty set of literals. A valuation satisfies a clause set when it satisfies each of its clauses. Satisfaction, paths and the statuses of a clause depend only on which literals occur, so everything in Section 7.4 holds for clause sets as it stands, a DPLL tree for being one for the formula whose clause set is . From here on the constraints are a clause set .
Definition 7.41 (clause form). The clause form of a formula is the clause set of its conjunctive normal form.
Formally, is the clause set of , and , for a finite set of formulas, is the union of the clause forms of its members.
A valuation satisfies exactly when it satisfies . For instance, the clause form of the formula of Example 7.22 is
Partial valuations as sets
A program stores a partial valuation as the set of literals it makes true,
which is the set we have been writing all along; conversely, a finite set of literals containing no letter together with its negation is a partial valuation. The definitions of Section 7.2 become operations on sets:
Throwing a switch
Each step of the search throws one switch. It is simpler to throw the switch in the clause set itself than to keep the clause set fixed and look up every literal in at every step. Turning on settles every clause that contains , which can be forgotten, and crosses out of every other clause, since can no longer help.
Definition 7.42 (restriction). Restricting a clause set to a literal turns the literal on and simplifies the clauses to match.
Formally, for a clause set and a literal , the restriction of to is
For literals we write
and for when is a partial valuation.
In words: is what the constraints still demand once is true. In the matrix, the columns with a tick disappear and the crossed-out entries are erased. For the five rules of Example 7.15,
The notation needs the order of the not to matter, and the first part of the next lemma says that it does not.
Lemma 7.43 (restriction). Let be a clause set and a partial valuation, and write for the set of complements of the members of .
In whatever order the members of are taken,
For every valuation with ,
The partial valuation is alive for if and only if is satisfiable.
Proof. Part (i) is by induction on the number of members of , one at a time: restricting to deletes the clauses containing and removes from the rest, and the two operations for different letters do not interfere. For (ii), a clause deleted in contains a literal of , which makes true; and a literal removed from a clause is the complement of a literal of , which makes false, so removing it does not change whether satisfies the clause. For (iii), if with , then by (ii). Conversely, mentions no letter that decides, by (i), so a valuation that satisfies it can be changed on those letters to agree with and still satisfy it; the changed valuation extends , and it satisfies by (ii). □
In words: throwing the switches of one at a time, in any order, leaves exactly what remains to be done, and the search may forget what it has already settled.
The three readings of a clause now become three things to look for in , which is all the procedure below ever inspects. By the first part of the lemma, for a clause of :
is satisfied under exactly when it has disappeared from ;
is falsified under exactly when it has become ;
is a unit under with undecided literal exactly when it has become the unit clause .
So when is empty, is a dead end when , and a unit clause of names a forced move.
The procedure
In pseudocode, with a clause set and a set of literals:
procedure DPLL(S)
return SEARCH(S, {}) -- nothing switched yet
procedure SEARCH(S, u) -- S is the clause set restricted to u
F := [] -- the forced moves of this call
while S contains a unit clause l and not the empty clause:
S := S|l; u := u + l; F := F, l -- a forced move
if S contains the empty clause: return CLOSED(F; CROSS)
if S is empty: return OPEN(u)
p := a letter of S -- any letter of S will do
r := SEARCH(S|p, u + p)
if r is OPEN(u'): return r
s := SEARCH(S|not p, u + not p)
if s is OPEN(u'): return s
T1, T2 := the trees in r and s -- both answers are CLOSED
return CLOSED(F; FORK(p: T1, not p: T2))
Here l is a literal , not p is , {} is , [] is the empty list, S|l is , and u + l is , that is, .
A “no” has to come with its evidence, and the procedure builds it as it goes. The T in CLOSED(T) is a piece of tree, to be hung below the node at which the call started:
F; CROSSis a chain of nodes carrying the forced literals ofF, in order, ending in a cross;F; FORK(p:\ T1, not p:\ T2)is the same chain ending in a fork, with a node aboveT1and a node aboveT2.
By the reading of above, each forced move is an application of unit, the fork is an application of decide, and CROSS and OPEN are written exactly when close and finish apply. So a run grows a DPLL tree for the original clause set, and a CLOSED answer hands back the whole of it. On the five rules of Example 7.34, for instance, the call on returns CLOSED(q, r; CROSS), the call on returns CLOSED(q; CROSS), and the top call, which forced nothing, returns
CLOSED(FORK(p: (q, r; CROSS), not p: (q; CROSS)))
which is the tree drawn there.
Theorem 7.44 (correctness of DPLL). For every clause set , the procedure stops, and
it returns some
CLOSED(T)if and only if is unsatisfiable, and thenT, hung below a root, is a closed DPLL tree for ;when it returns
OPEN(u), every valuation with satisfies .
Proof. Each forced move and each recursive call removes a letter from the clause set and adds it to , so with letters the loop runs at most times in each call and the recursion is at most deep.
An answer OPEN(u) comes with empty, so , and every valuation extending satisfies by the lemma on the status of a clause (Lemma 7.30).
For CLOSED, show by induction on the depth of the recursion, from the deepest calls up, that a call that returns CLOSED(T) has grown T by the rules of DPLL below a branch with partial valuation , and that every branch of T is closed. The literals of F are forced moves, by the reading of above. If the call ends in CROSS, the empty clause it found is a clause of falsified on the branch. If it ends in a fork, the two recursive calls returned CLOSED(T1) and CLOSED(T2), and by the induction hypothesis T1 and T2 are closed pieces grown below and below . At the top call, , so T hung below a root is a closed DPLL tree for , and is unsatisfiable by soundness (Theorem 7.37).
Conversely, if is unsatisfiable, no answer OPEN(u) is possible, since it would give a valuation that satisfies ; as the procedure stops, it returns CLOSED. □
In words: DPLL decides satisfiability, and whichever the answer, it hands back the evidence: a setting for yes, a closed tree for no.
Example 7.45 (the platform, cont’d: a setting). The colleague who wrote the rules looks at Harriet’s closed tree and admits that the second is wrong: offline-mode does not need fast-sync. Harriet runs the procedure on . Nothing is forced, so it decides , and the two sides run
The first line closes, and the call on returns CLOSED(q, r; CROSS); the second empties the clause set, and the procedure returns OPEN with : fast-sync off, offline-mode on, and compression as you please.
Remark 7.46 (at work: restriction without copying). Written out, is a new clause set, and a search that may have to go back must keep the old ones too. Solvers do not copy. They keep as it is and the literals of on a stack, and compute what they need of on demand. A clause can only become a unit or empty when its last but one live literal is crossed out, so a solver watches two live literals in each clause and looks at the clause only when one of them is crossed out.5 The restriction is the mathematics; the watched literals are the bookkeeping that makes it cheap.
Choosing the letter
The procedure leaves one choice open, which letter to decide, and much of the engineering of a solver lies in this branching heuristic. On
deciding on forces , and and finishes at once, while deciding , or first forces nothing. A common rule of thumb is to decide a letter that occurs in many short clauses. The results above hold for every order; what the order changes is the size of the tree, sometimes enormously.6
Easy to check, hard to find
The two answers come with evidence of very different sizes. OPEN(u) comes with , checked by finding a literal of in each clause. CLOSED(T) comes with the tree T, checked node by node against Figure 7.2, at a cost proportional to its size, and the tree can be exponential. For some clause sets it must be: the optional Section 7.10 shows that for the pigeonhole sets, which say that pigeons do not fit into holes, every closed tree is exponential in .
The asymmetry is the shape of the problem, not a fault of the method. Deciding whether a clause set is satisfiable is the problem sat, the first problem shown to be NP-complete.7 That means two things. Its “yes” answers can be checked quickly. And every problem whose “yes” answers can be checked quickly reduces to it quickly. (“Quickly” means in a number of steps bounded by a polynomial in the size of the input.) The problems whose “yes” answers can be checked quickly form the class NP, and those that can be decided quickly the class P. Whether sat can be decided quickly is the question whether , and nobody knows. What is known is that the procedure of this chapter decides it, that solvers built on it settle instances with millions of switches, and that no method is known to be fast on every instance.
Remark 7.47 (three strategies). Three habits of the procedure are worth keeping whenever a problem is a search among finitely many choices.
Propagate before you branch. A forced move costs a lookup and loses nothing; a decision may double the work below it.
Encode by forbidding. Ask what must never happen and write one clause for each forbidden pattern; “exactly one of these” is easy as “not none, and never two”.
Ask what a failure tells you. A closed branch proves that the literals on it cannot hold together, a fact the constraints imply but do not state (Remark 7.35); write it down and never pay for it twice.
Remark 7.48 (SAT and SMT). Questions about programs and hardware are often about numbers, arrays and bit-strings, where an atomic formula such as is true or false according to the values of and . An SMT solver, for satisfiability modulo theories, reads each atomic formula as a letter and runs DPLL; whenever the search has set some atomic formulas, it asks a decision procedure for the theory (arithmetic, arrays, equality) whether they can hold together, and if not, as with and , adds the reason as a new clause. The engine is the procedure of this section.
7.6 From Sentences to Clauses
The propositional problem is solved: a question without quantifiers becomes a clause set, and DPLL decides it, with a certificate either way. The questions we started from are not of that kind. Their constraints say “every” and “some”, and no setting of finitely many switches says either. The next three sections bring a first-order question down to propositional ones, in three moves.
Put the quantifiers in one place. Each sentence is rewritten, without changing what it says, so that all its quantifiers stand in a row at the front.
Name the existentials. Each “some” is replaced by a name for its witness, a new function of the universal variables before it, as a search by hand names the someone it is looking for. Only universal quantifiers are left, and the sentence becomes a set of clauses with variables in them.
Instantiate the universals. The clauses are tested at the names, one instance at a time, and each instance is a clause over switches (Section 7.7). The instances go to
DPLLlevel by level (Section 7.8).
The first two moves are routine rewriting, and this section treats them as a black box: what goes in, what comes out, and what is guaranteed (the optional Section 7.9 opens the box). The third move is where the mathematics is, and it takes the next two sections. From here on the formulas are again the first-order formulas of Chapter 6, over a signature .
Remark 7.49 (a second route: SMT). Removing the quantifiers first is a choice. An SMT solver (Remark 7.48) keeps them and deals with them on the side, adding instances of the universal sentences to its propositional problem as the search goes. Removing them first has an advantage: a single theorem, Herbrand’s, then explains why instances are enough. The two routes meet in Section 7.8.
What comes out of the box is a set of clauses with variables in them, and the first thing to settle is what such a clause means.
Definition 7.50 (first-order clause). A first-order clause is built like a propositional clause, but its literals are atomic formulas about terms, and the terms may contain variables.
Formally, a clause over is a finite set of literals, that is, of atomic -formulas and their negations, possibly with variables, and a clause set is a finite set of clauses. A clause with no variables is a ground clause.
For instance, of the two clauses
the second is ground.
Definition 7.51 (satisfying a first-order clause set). A structure satisfies a clause when the clause holds of everybody: whatever its variables stand for, one of its literals is true.
Formally, let be a -structure and a clause over . Then if
and , for a clause set , if for every .
In words: a clause is read as the universal closure of the disjunction of its literals. For a clause with variables ,
In particular, for a ground clause , exactly when in the sense of Section 7.3, where is the valuation that gives each atomic sentence its truth value in . One warning, which matters later: each clause binds its own variables, so the of one clause has nothing to do with the of another, and a variable may be renamed within a clause at will.
The box adds symbols to the signature. If is with some symbols added, a -structure has a restriction to ,
the same domain with the added symbols forgotten, as in the completeness proof of Chapter 6. A -sentence mentions none of the added symbols, so it is true in exactly when it is true in .
Theorem 7.52 (the clause form). There is an algorithm that takes each finite set of -sentences to a clause set over a signature , which is with new function and constant symbols added, such that
is satisfiable if and only if is;
if , then .
The clause set that the algorithm returns is called the clause form of . In words: the clause form keeps the verdict, by (i), and comes with a way back, by (ii): forget the new symbols. It does not keep the meaning, since it speaks of symbols that does not have, so and are equisatisfiable rather than true in the same structures.
The new symbols name the witnesses of the existential quantifiers, and are called Skolem functions and Skolem constants. For instance, “everyone has someone who earns more”, , becomes the single clause
with naming whoever earns more than , over ; and “someone earns more than everyone”, , becomes over , with the constant naming that someone. The optional Section 7.9 gives the algorithm and the proof; for the problem sheets and the rest of the chapter, the theorem is all that is needed.
Example 7.53 (the company, cont’d: the policy as clauses). To decide whether , Harriet needs the clause form of , a set of sentences over the company signature . The two rules have no existential quantifier, and says that some engineer reports to an engineer; its witness gets the Skolem constant , the name her first search in Example 7.4 gave it. So , and the clause form is four clauses:
By the reduction lemma (Lemma 7.3) and the theorem on the clause form (Theorem 7.52),
The colleague’s weaker policy is , which is satisfiable: the two-person company of Example 7.4, with naming the engineer who reports to an engineer, has , and is the counter-model of that example.
Remark 7.54 (equality). The symbol is a relation symbol like any other, and in a clause set it is treated as one: nothing in the definitions above knows that it means identity. A set of sentences that is to reason about identity must say what identity is, through the equality axioms, and so must a clause set. Those axioms are infinitely many, one for every formula; for a clause set over a finite signature, finitely many clauses do the same work, and we call them the equality clauses. They are reflexivity, symmetry, transitivity, and one congruence clause for each argument place of each function symbol and of each relation symbol other than , saying that equals may be put for equals in that place. For itself no congruence clause is needed: symmetry and transitivity already do the work. For a signature with a one-place function symbol , one-place relation symbols and , and a two-place relation symbol besides , the congruence clauses are
Exercise 7.12 writes out the rest and puts a question about identity through the machinery of this chapter. A structure that satisfies such a clause set interprets as some relation that behaves like identity but need not be it. A remark in the next section shows how to recover from it a structure in which is identity.
7.7 Herbrand’s Theorem
After the first two moves, the question has become whether a set of clauses with variables, all read universally, is unsatisfiable. A clause with a variable speaks of every element of every structure (five people, the natural numbers, the real line), and no solver can look at every structure. A search by hand, such as the one in Example 7.4, does something much smaller: it looks only at the things it can name. This section proves that this is enough, in two steps.
If a clause set is satisfied by any structure at all, it is satisfied by one made of names, and such a structure is a setting of the switches, one for each atomic sentence about the names.
If it has no model, finitely many of its instances at those names already show it.
The names are built from the symbols that the clauses actually use. The signature may have others (the clauses of Example 7.53 mention neither nor ), but symbols a clause set does not mention make no difference to whether it is satisfiable: a structure can be restricted to the smaller signature, and expanded back by giving the other symbols any meaning.
Definition 7.55 (the signature of a clause set). The signature of a clause set is the vocabulary it actually uses.
Formally, the signature of a clause set consists of the constant, function and relation symbols that occur in , with one new constant symbol added if no constant occurs in .
The extra constant is needed because a signature without constants names nothing, and the names are to serve as the domain of a structure, which must not be empty. A structure for a larger signature satisfies exactly when its restriction does (with the added constant, if there is one, naming any element).
Definition 7.56 (Herbrand universe). The Herbrand universe of a clause set is the set of everything the clause set can name.
Formally, the Herbrand universe of a clause set is the set of closed -terms.
In words: start from the constants and apply the function symbols in every possible way. For a clause set whose only constant is and whose only function symbol is a one-place , the universe is , , , and so on.
Definition 7.57 (level). The level of a closed term is the depth to which function symbols are nested in it.
Formally, the level of a closed term is defined by recursion on the shape of :
For a clause set and , we write for the set of terms of of level at most .
For instance, has level , and in the universe above .
Measuring terms by depth is a choice; any measure would do for which there are finitely many terms of each size, and depth is the simplest. What matters is that every is finite and each contains the one before,
while together they make up the whole universe, which is infinite as soon as there is a function symbol. A search must therefore work through the universe one level at a time. Figure 7.3 shows how fast the levels grow with a constant and two one-place function symbols: each level holds twice as many terms as the one below.
Definition 7.58 (Herbrand base). The Herbrand base of a clause set is the set of atomic sentences it can form about its names: the switches of a first-order search.
Formally, the Herbrand base of a clause set is the set of atomic -sentences , with an -place relation symbol of and .
For instance, if above has one relation symbol, a one-place , the base is , , , and so on.
Definition 7.59 (Herbrand structure, Herbrand model). A Herbrand structure is a structure whose elements are names, each naming itself.
Formally, let be a clause set. A Herbrand structure for is a -structure in which
for each constant symbol ;
for each -place function symbol ;
is any set of -tuples of closed terms, for each -place relation symbol .
A Herbrand model of is a Herbrand structure for that is a model of , that is, with .
In words: the domain is the names, the constants and function symbols do nothing but build names, and all the freedom is in the relations. So a Herbrand structure is nothing more than a choice of true or false for each atomic sentence of the base: a Herbrand structure is a valuation of the Herbrand base, a setting of one switch for each atomic sentence about the names. A search for a Herbrand model is a search for a setting.
Remark 7.60 (looking back: the term structure). The completeness proof of Chapter 6 built its structure out of closed terms, each naming itself, with the relations chosen by a maximal consistent set. That structure was a Herbrand structure, for the signature with the witnesses added, and the truth lemma said that it satisfied the set. Nothing in this section is new in kind; what is new is that the relations are now chosen by a search rather than by a construction that lists every sentence.
Example 7.61 (the company, cont’d: the names of the policy). The clause set of Example 7.53 is over , the company signature with added, but it uses only four of its symbols: has the constant , the function symbol and the relation symbols and , and no or . Its Herbrand universe is
one term for each level: , , and so on. It is infinite, because can be applied again to its own result, and in a Herbrand structure the chain of bosses never comes back on itself. The base is the atomic sentences and for in the universe. If a Herbrand structure makes every and every true, for instance, then and .
Instances
To say what a clause demands of a Herbrand structure, we put names in for its variables, several variables at once. The tool for that is a substitution.
Definition 7.62 (substitution). A substitution is a finite list of instructions, each saying which term to put in for one variable.
Formally, a substitution is a finite list of pairs, each of a term and a variable , in which the variables are distinct. We also write it .
For instance, says: put for and for . It says nothing about , which it leaves alone. The empty list is a substitution too, and changes nothing.
Substitutions are applied to terms, atomic formulas, literals and clauses, which for short we call expressions.
Definition 7.63 (applying a substitution). Applying a substitution to an expression puts the terms in for the variables, everywhere and all at once.
Formally, let be a substitution. For an expression , the expression is defined by recursion on the shape of :
In the third line may be a constant, with , and then is . In words: every occurrence of each is replaced by , and the terms put in are not looked at again. That is what “all at once” means: is , whereas putting for and then for , one after the other, would give . An expression has no quantifiers, so nothing in it can capture a variable, and no renaming is ever needed.
Remark 7.64 (looking back: substitution for one variable). For one variable, is the substitution of Chapter 6, restricted to formulas without quantifiers. Its side conditions, which stop a quantifier of from capturing a variable of , never arise here.
Definition 7.65 (instance, ground instance). An instance of a clause is what the clause says about particular terms, and a ground instance is what it says about particular names.
Formally, let be a clause. An instance of is a clause , for a substitution . If is a clause of a clause set , with variables , a ground instance of is a clause with .
For instance, the clause has the instance , by ; in a clause set with the constant it has the ground instance , by . A ground instance is a ground clause, since every variable of has been given a closed term.
Definition 7.66 (the ground instances of a clause set). The ground instances of a clause set are everything its clauses say about its names, and those at level use only names of level at most .
Formally, let be a clause set. We write for the set of all ground instances of all clauses of , and, for , for the set of those ground instances , with and its variables, in which .
Each is a finite clause set over the Herbrand base, and is their union, infinite as soon as the universe is and some clause has a variable. The level bounds the terms put in for the variables, not the terms that end up in the clause: a clause may carry closed terms of its own, and a term put in may land inside a function symbol. So can mention terms of any level; in Example 7.67, contains although .
Example 7.67 (the company, cont’d: the ground instances of the policy). For the four clauses of Example 7.53, has four clauses, the two rules instantiated at and the two units; has six:
Lemma 7.68 (a Herbrand structure is a valuation). For a Herbrand structure for , write for the valuation of the Herbrand base that makes an atomic sentence true exactly when it is true in . Then
Proof. First, every closed term names itself, : by induction on , a constant names itself by the first item of the definition of a Herbrand structure, and names by the second and the induction hypothesis.
Now let be a clause of with variables . An assignment into gives each a closed term , which names itself; so, by the substitution lemma, a literal of is true under exactly when the literal of is true in outright. Every ground instance of is for some assignment , the one that sends each to the term put in for it, so exactly when every ground instance of has a literal true in . A ground literal is true in exactly when makes it true, by the atomic clause of the definition of satisfaction and the definition of ; so exactly when for every ground instance of . □
In words: to say what a Herbrand structure does to a clause set is to run through the ground instances, and that is a propositional matter.
Lemma 7.69 (Herbrand models suffice). A clause set is satisfiable if and only if it has a Herbrand model.
Proof. A Herbrand model is a model, so only the forward direction needs an argument. Let . By the paragraph after the definition of we may take to be a -structure. Let be the Herbrand structure in which an atomic sentence of the base is true exactly when it is true in . By the lemma it is enough to show that for every ground instance of every clause of .
Since , some literal of is true in under the assignment that sends each to the element of ; by the substitution lemma, that literal with put in is true in outright. It is a literal of , a ground literal, and by the definition of it is true in , that is, makes it true. So , hence , and is a Herbrand model of . □
In words: given a structure that satisfies the clause set, read off which atomic sentences about names it makes true and forget everything else; what is left is a structure made of names that satisfies it too. The reason is that clauses are universal: what holds of every element of holds in particular of the elements that terms name, and those are all a Herbrand structure keeps.
So a search for a counter-model may confine itself to the things it can name: if a counter-model exists at all, one exists that is made of names. One more step turns “among those” into “among finitely many of those”, and it needs a consequence of the completeness of .
Lemma 7.70 (compactness). Let be a set of sentences over a countable signature. If every finite subset of has a model, then has a model.
Proof. We prove the contrapositive: if has no model, some finite subset has none. Suppose has no model. Then , since there is no model of in which fails, and by the completeness of there is a derivation of from . A derivation is a finite tree, so it has finitely many open hypotheses, which form a finite subset of with . By soundness , so has no model. □
In words: an infinite set of demands can only fail for a finite reason, and the reason is that proofs are finite.
Theorem 7.71 (Herbrand’s theorem). For every clause set , the following are equivalent:
there is no structure with ;
there is a finite with no valuation , reading as a propositional clause set over the Herbrand base;
there is a with no valuation .
Proof. One implication at a time.
(ii) implies (i). Suppose . By the lemma that Herbrand models suffice (Lemma 7.69) there is a Herbrand structure , and by the lemma before it , so for every .
(i) implies (ii). The ground clauses of , each read as the disjunction of its literals, are sentences over a finite, hence countable, signature, and no structure satisfies them all: the truth values of the ground atomic sentences in such a structure would give a valuation , hence a Herbrand model of by the lemma that a Herbrand structure is a valuation (Lemma 7.68). By compactness (Lemma 7.70) some finite has no model, and by the same argument no valuation .
(ii) and (iii) are equivalent. A finite uses finitely many closed terms, and if is the largest of their levels, ; a valuation that satisfies satisfies . And is itself a finite subset of .
□
In words: a set of constraints about everybody has no model exactly when finitely many of its instances, at finitely many names, already clash.
Example 7.72 (the company, cont’d: six clauses). No valuation satisfies , the six clauses of Example 7.67, and unit propagation alone shows it:
These are the lines of Harriet’s first search, one for one: is an engineer, so her boss is a manager, so her boss is not an engineer, but her boss is. By Herbrand’s theorem (Theorem 7.71) is unsatisfiable, so by the reduction lemma (Lemma 7.3) and the theorem on the clause form (Theorem 7.52), .
The four clauses of do not suffice: the valuation that makes , and true and false satisfies them. The clash needs the second rule at , one level up, which is the line of her search that applied to ’s boss.
What the theorem does not say
Herbrand’s theorem (Theorem 7.71) gives no bound on the level at which the clash appears, and the level needed can be large. Nor does it say anything when no clash appears. If are each satisfiable, the theorem does not say that is, and it cannot. For the clause set
every is satisfiable, and so is the set; for another set, every up to some large may be satisfiable and the next one not.
The trouble is the evidence. For a satisfiable set the evidence has to be a structure that satisfies it, and a valuation that satisfies the instances of a single level is not one: it is a choice of truth values for the atomic sentences that occur in , and says nothing about the instances above. Can any finite amount of work ever certify that a clause set is satisfiable? This chapter raises the question and does not settle it.
Remark 7.73 (equality in a Herbrand structure). When is among the symbols and the equality clauses of Remark 7.54 are in , a Herbrand structure that satisfies interprets as some relation on the closed terms that is reflexive, symmetric, transitive and respected by every symbol, which is all the clauses say. But need not be identity: may hold in it while and are different terms. To obtain a structure in which is identity, identify the terms that relates: the elements are the classes of terms, and the congruence clauses are exactly what makes the functions and relations well defined on the classes. The completeness proof of Chapter 6 makes the same move, for the same reason.
7.8 A Procedure for First-Order Logic
This section puts the pieces together into a program, and then asks how good it is. DPLL decides one finite clause set, and a first-order clause set has infinitely many ground instances. But by Herbrand’s theorem (Theorem 7.71) a clause set is unsatisfiable exactly when some is, and each is a finite clause set whose letters are the atomic sentences occurring in it: just what DPLL decides. So we try the levels in turn:
procedure REFUTE(S) -- S a clause set, possibly with variables
k := 0
loop:
if DPLL(GROUND(S, k)) is CLOSED(T): return UNSAT -- the instances at level k
k := k + 1
The procedure has no other exit, and that is not an oversight.
Theorem 7.74 (the first-order procedure). For every clause set , the call
returns
UNSATif is unsatisfiable;runs for ever if is satisfiable.
Proof. If is unsatisfiable, some is unsatisfiable by Herbrand’s theorem (Theorem 7.71), and by the correctness of DPLL (Theorem 7.44) the call returns CLOSED at the latest at that , each earlier call having stopped by termination (Lemma 7.36). If is satisfiable, some Herbrand structure satisfies it, and satisfies every , so by soundness (Theorem 7.37) no call returns CLOSED and REFUTE never stops. □
In words: the procedure is a complete method for “no”, and no method at all for “yes”. Procedures of this kind have a name.
Definition 7.75 (semi-decision procedure). A semi-decision procedure for a property answers “yes” on every input that has the property, and never on one that lacks it.
Formally, let be a set of inputs. A procedure is a semi-decision procedure for if, for every input , it stops and answers that is in when , and never gives that answer when .
So REFUTE is a semi-decision procedure for the set of unsatisfiable clause sets. Through the reduction lemma (Lemma 7.3) and the clause form, this gives a way of certifying in finite time every first-order entailment from finitely many premisses that holds, and nothing for one that fails.
Example 7.76 (the company, cont’d: the policy, by machine). Harriet gives the four clauses of Example 7.53 to REFUTE. At level the four ground clauses of Example 7.72 go to DPLL, which propagates , , and , finds every clause satisfied, and returns OPEN. At level the six ground clauses go to DPLL, which propagates , and , finds falsified, and returns CLOSED without a decision. The loop returns UNSAT: the rules entail the claim, by a single branch with no guess, like Harriet’s first search.
With the weaker policy the loop never returns. Figure 7.4 sets out both runs level by level. At levels and forced moves alone satisfy the ground clauses. At level there are five clauses and a decision, since is forced but nothing decides ; and so on. Each level returns OPEN with a partial valuation that makes every and it mentions true: the Herbrand structure in which everybody is an engineer and a manager, seen one level at a time. Harriet knows, from Example 7.4, that the weaker policy has a two-person counter-model. The procedure does not, and will not find out.
| Policy | Level | Ground clauses | Decisions | Verdict |
|---|---|---|---|---|
OPEN | ||||
CLOSED, so UNSAT | ||||
OPEN | ||||
OPEN | ||||
OPEN | ||||
| … | OPEN, for ever |
A warning about the inner answers. When returns OPEN, it has found a setting that obeys the instances at level and nothing more; the instances one level up may still clash, as in Example 7.72. So OPEN at a level is not a verdict about , and REFUTE rightly ignores it. The question raised after Herbrand’s theorem (Theorem 7.71), whether a finite amount of work can certify that a clause set is satisfiable, therefore has an answer for this procedure: no finite level of instances does, and the loop does not try. Whether a cleverer procedure could is the question of Chapter 8.
Choosing the instances
The loop lists every instance at a level, and most of what it lists is useless. A clash between instances of two clauses needs an atomic sentence that one instance contains and the other contains negated. Before anything is listed, the two clauses carry literals such as
and the instances that can clash on them are those in which the two atomic formulas become the same, here by putting for . Finding such a substitution means solving an equation between them, written with to keep it apart from the relation symbol ,
and that can be done by machine. A short procedure, unification, either finds the most general solution, of which every other solution is an instance, or shows that there is none, in which case the two literals never clash at any level. Adding, before grounding, the instances that unification picks out never changes the verdict of the loop and never costs a level, and it often lets the loop close much sooner. The optional Section 7.10 gives the procedure and proves these claims.
Looking for small structures
There is a second search, the one everybody runs by hand when looking for a small counter-model: use as few elements as possible, start with one, and give every symbol the laziest meaning that works. It too is a propositional search. “Is satisfied by a structure with exactly elements?” becomes a clause set in three steps.
Name the elements , and take a letter for each atomic sentence over the names and for each equation , with clauses saying that each has exactly one value.
Instantiate every clause of at every choice of names, replacing each term by a name and adding the literal .
Run
DPLL: a setting that comes back is an -element structure that satisfies , andCLOSEDsays that none exists.
For instance, with , step 2 turns the clause at into two clauses, one for each value may take:
that is, if is in and is , then is in ; and the same again at . Run this for alongside REFUTE, and one of the two answers whenever is unsatisfiable or satisfied by a finite structure. Exercise 7.11 carries the encoding out.
Example 7.77 (the company, cont’d: a company of one). For the weaker policy the search for small structures answers already at : a company of one, an engineer and manager who is her own boss, obeys , and . So the two-person company of Example 7.4 was not the smallest counter-model.
Remark 7.78 (at work: SMT solvers and quantifiers). SMT solvers handle universal quantifiers much as the loop does when it chooses its instances. They keep a ground problem for their SAT engine, and from time to time add to it instances of the universal sentences. They choose the instances by heuristics rather than level by level. One adds an instance when the terms it needs turn up in the ground problem; another looks at the setting found so far, finds a universal sentence it breaks, and adds the instance that shows where. Like REFUTE, they may run for ever, and when they stop without a refutation they may answer “unknown” rather than produce a model.
A search that may not stop
Every DPLL run stops for one reason only: the switches are finitely many, and each branch ends when they run out. The first-order procedure has no such bound. It stops when instances clash and only then, and whether they ever will is exactly the question being asked. A cleverer order of instances would not help, for on some questions no instances ever clash, in any order, although a small counter-model exists. The clause set
is one. Its ground instances have the shapes
so a clash needs to be and to be , that is, to be , which no term is. Yet the structure with two elements, each -related to the other, with sending each to the other and sending each to itself, satisfies the set, and the search for small structures, run alongside, finds it at .
Worse, some satisfiable sets are satisfied only by infinite structures. The sentences
are satisfied by the natural numbers with for , and by no finite structure, since a finite chain of ever-greater elements must come back on itself and break the second sentence or the third. On such a set the loop never stops, the search for small structures never stops, and both are right not to (Examples 7.79 and 7.80 read both questions in the company).
Example 7.79 (the company, cont’d: a question that never closes). Does “everyone has someone who earns more than them” entail “someone earns more than everyone”? The clause form of the question is together with , the second from the negated claim, : the clause set above, with for . So the loop runs for ever, and choosing the instances by unification adds nothing, since the two atomic formulas never unify. Yet a company of two in which each earns more than the other is a counter-model, which the search for small structures finds at , once has closed.
Example 7.80 (the company, cont’d: only infinite companies). The three constraints “everyone has someone who earns more”, “nobody earns more than themselves” and “if earns more than and more than then more than ” are the three sentences above, with for . No finite company obeys them all, and on them neither search ever stops.
So the first-order procedure is a semi-decision procedure, and this chapter cannot say whether that is the best possible. A reader who has watched the loop run for ever on a question with a two-person answer will suspect that a cleverer search would stop; Chapter 8 is about that suspicion. What this chapter can say is where the cost sits. The Herbrand universe grows at least exponentially with the level as soon as there are two function symbols, or one with two places, and equality multiplies the instances further. Unification tames the extra instances; nothing tames the growth of the universe.
7.9 Prenex and Skolem Form (optional)
This section and the next are optional: the main line quotes some of their results but none of their proofs. This one opens the black box of Section 7.6, giving the algorithm behind the theorem on the clause form (Theorem 7.52) and proving the theorem. The algorithm is what a careful person does by hand, and the only real idea in it is the last step, naming the witnesses.
What makes a quantifier awkward? A search by hand applies each constraint to the things it has named, and a constraint of the form “for every , …” is ready for that: put a name in for and read what results. A constraint with “some” in it is not. “Some is …” does not say which, and the search has to invent a name for the someone before it can go on. Nor is a constraint ready when its quantifiers are buried inside it, under an arrow or a negation. There it is not even clear whether a quantifier says “every” or “some”: in
the says that someone is not an engineer.
The section first brings buried quantifiers to the front, and then names the witnesses. Here is a connective in its own right, as in Section 7.3, and abbreviates .
Negations first
As in Section 7.6, a literal is an atomic formula or the negation of one, and a formula is in negation normal form if it is built from literals, and by , , and alone. The translation of Section 7.3 gets four more equations, two for the quantifiers and two for a negation in front of one:
In words: the negation of “everyone is …” is “someone is not …”, and the negation of “someone is …” is “nobody is …”. These are De Morgan’s laws for the quantifiers. The first equation of the definition now leaves every literal alone, atomic formulas and their negations included.
The lemma that negation normal form is faithful gains four cases, and the two with a negation in front of a quantifier are the ones of substance: they are the quantifier clauses of the definition of satisfaction, read against the new equations. Take the equation for , and let be a structure and an assignment. The induction hypothesis holds under every assignment, so under each , and
by the clause for , the induction hypothesis, the clause for and the clause for , in turn. The equation for is the same with the quantifiers exchanged, and the two equations without a negation pass the claim straight down. So is true in a structure under an assignment exactly when is.
Quantifiers to the front
Why bring the quantifiers to the front at all? The rest of this section replaces each by a function of the universal variables that depends on, and those are the universal variables whose quantifiers stand above . In a formula like
finding them takes some looking. In a formula whose quantifiers all stand at the front they are read off the row: they are the universal variables to the left of .
Definition 7.81 (prenex form). A formula is in prenex form when all its quantifiers stand at the front.
Formally, a formula is in prenex form if it is
with each one of and , and quantifier-free. The string is its prefix and its matrix. The prefix may be empty.
For instance,
is in prenex form, with prefix and matrix , while
is not, since its quantifier sits under an arrow.
In negation normal form every quantifier sits under conjunctions and disjunctions only, and it can be pulled through those, provided its variable has nothing to do with the other side.
Lemma 7.82 (pulling a quantifier out). Let not occur free in , let be either quantifier and either of and . Then, for every structure and assignment ,
Proof. Take to be and to be ; the other seven cases are alike, and three of them are Exercise 7.13. This is where the side condition is used: since is not free in , the relevance lemma gives
So holds exactly when, for every , or .
If , this holds, and so does .
If not, it holds exactly when for every , which is , and so again exactly when .
Two of the other seven cases, with and with , also use that a domain is never empty: over an empty domain would say no more than , while would be true. □
When is free in , the lemma does not apply. The remedy is to rename the bound variable first: by the substitution lemma, and are true under the same assignments when is a new variable, and likewise for .
Example 7.83 (a quantifier pulled out carelessly). Without the side condition, the pull-out goes wrong. Take the formula
whose second is free, in a structure in which not everyone is an engineer, and let that stand for someone who is one. There the formula is false: its first disjunct fails because not everyone is an engineer, and its second because that person is one. Pulling the quantifier out regardless gives
which is true everywhere: the quantifier has captured the free , which no longer speaks of the engineer it stood for. Renaming the bound variable first, to , gives
which is false at that engineer, as it should be.
Pulling the quantifiers out one at a time, renaming where needed, puts every formula in negation normal form into prenex form. Written as a function, the equations for and first put the two parts into prenex form and then rename them apart: each bound variable of one part that occurs in the other is replaced by a new variable. Write the renamed parts as and , with prefixes and ; after the renaming, none of occurs in the second and none of in the first.
Definition 7.84 (prenex translation). The prenex translation of a formula in negation normal form pulls its quantifiers to the front, renaming bound variables apart as it goes.
Formally, for in negation normal form, the formula is defined by recursion on the shape of , by the equations
where, in the second and third, and are and with each bound variable of one that occurs in the other replaced by a new variable. The prenex form of an arbitrary formula is .
In words: translate the parts, rename so that the two prefixes cannot interfere, and write one prefix after the other. Which prefix comes first is a choice, and the lemma allows either; Example 7.88 shows that the choice can matter.
Lemma 7.85 (the prenex translation is faithful). For every formula , is in prenex form, and for every structure and assignment ,
Proof. By the faithfulness of negation normal form (Lemma 7.18) it is enough to show, for every formula in negation normal form, that is true in exactly the same structures under exactly the same assignments as . We do so by induction on the shape of .
The first equation changes nothing.
The equation for . The renaming leaves the truth values of the parts alone, by the substitution lemma. The pull-out lemma then moves the quantifiers to the front one at a time, first those of and then those of , and each move is permitted because the renaming keeps the variable moved out of the other side. The equation for is the same.
The two quantifier equations. The induction hypothesis, which holds under every assignment, passes the claim straight down.
That the result is prenex is read off the definition. □
Example 7.86 (the company, cont’d: the policy and two salary rules in prenex form). Harriet’s two rules and the claim have one quantifier each, at the front already, so only the arrows need to go. The claim is negated, as a search for a counter-model needs. The negation normal forms are
the last by the equation for , then the equation for , then double negation. All three are in prenex form.
Two salary rules have their quantifiers in the way of each other: “someone earns more than everyone” and “everyone has someone who earns more than them” are
Does the first entail the second? A counter-model would be a model of the first together with the negation of the second, that is, of
Its negation normal form is
The two prefixes share their variables, so the second is renamed before the pull-out:
Naming the witnesses
Every sentence now has its quantifiers in a row at the front. The universal ones are ready for a search: “for every , …” can be tested at any name by putting the name in for . The existential ones are not, since “for some , …” does not say which .
In a prenex sentence, an existential quantifier says that for each choice of the universally quantified variables before it there is a witness. A search by hand gives the witness a name. When the witness depends on the earlier variables, a name is not enough, and a function of them is needed. In
the person who earns more than depends on , and we write for whoever it is:
With two existentials, each gets its own symbol, applied to the universal variables to its left:
Definition 7.87 (Skolem form). The Skolem form of a prenex sentence replaces each existentially quantified variable by a new function symbol applied to the universally quantified variables that precede it.
Formally, for a prenex formula and a list of variables, the formula is defined by recursion on the prefix of , by the equations
where, in the last, is a -place function symbol not in the signature and not used before (a constant symbol when ). The Skolem form of a prenex sentence , written , is , with the empty list; the new function and constant symbols are its Skolem functions and Skolem constants.
In words: walk along the prefix, remembering the universal variables passed. Keep a universal quantifier. At an existential one, name the witness as a function of the universal variables so far and drop the quantifier. What results is a universal sentence,
in a larger signature.
The substitution must not capture a variable, and it cannot as long as no variable is bound twice in the prefix, for then the variables , bound in front of , are bound nowhere inside . A prefix such as is renamed apart first, to , and from now on we take every prefix to bind distinct variables.
Example 7.88 (the company, cont’d: Skolem forms). The Skolem form of from Example 7.86 is
with the Skolem constant : the name Harriet’s first search in Example 7.4 gave to the engineer who reports to an engineer. The Skolem forms of the two salary rules are
the first names one person, the second a person for each .
The Skolem form of the four-quantifier sentence of Example 7.86 is
where , which came after , became . The order of the prefix changes the form. Had the other prefix come first, would have become a constant and a function of ; and if both existentials come out before either universal, as the pull-out lemma (Lemma 7.82) also allows, there are two constants and no function symbol at all, which gives the shortest Skolem terms.
The symbol must be new each time. Skolemise and with the same constant , and the results and are unsatisfiable together with the negation of . The two sentences would seem to entail that someone is both an engineer and a manager, but a company with one engineer and one manager, different people, shows that they do not.
Is Skolemising safe? It changes the sentence, and the new sentence is not true in the same structures as the old. What it must keep is the verdict, and the evidence must come back with it. The next theorem says that both survive.
Theorem 7.89 (Skolem’s theorem). Let be a prenex sentence and its Skolem form.
Every structure that satisfies satisfies .
Every structure that satisfies satisfies , once the Skolem functions and constants are given suitable meanings.
In particular, and are equisatisfiable.
Proof. Each existential quantifier is removed by one step of the definition of the Skolem form, and it is enough to prove both parts for one step, that is, for
where may still have quantifiers. The theorem then follows by induction on the number of existential quantifiers in the prefix, since each step starts from a prenex sentence.
(i). There is a derivation in of from . For it has three steps:
The side condition of (I) is met, since is not free in the only open hypothesis, which is a sentence; and is substitutable for in , since the prefix binds distinct variables and so is bound nowhere inside . For larger , instantiate times and generalise times. By the soundness of , every structure that makes true makes true.
(ii). Let . For every -tuple of elements of , the quantifier clauses give an element with
by the relevance lemma the assignment does not matter, since the free variables of are among and . Choose one such for each , and let the new symbol denote the function that sends to it. Call the expanded structure . The other symbols mean in what they meant in , and does not occur in , so makes true under the same assignments as . Under the term has the value chosen for , so by the substitution lemma
that is, . And still makes true.
Equisatisfiability follows from the two parts. □
In words: dropping an existential quantifier in favour of a name costs nothing, in either direction.
The two parts do different jobs, and the chapter needs both.
Part (i) brings the evidence back. A structure that satisfies the Skolem form, with the new symbols forgotten, satisfies the original sentence. This is the way back that every rewriting must come with, and it is the three-line derivation in : this chapter set out to avoid derivations, because they are hard to find, yet here one does the job.
Part (ii) makes refutations count. If the Skolem form has no model, neither has the sentence, since a model of the sentence would expand to one of the Skolem form. This is the half a refutation relies on, and it needs a choice, one witness for each , which no derivation makes for us.8
Only universals left
After Skolem form a sentence is universal, with quantifier-free, and the matrix can be turned into clauses by the clause form of Section 7.5, with the atomic formulas in the role of the letters. The universal quantifiers are then dropped and left understood, and the clauses are read as in Section 7.6.
Definition 7.90 (clause form of a sentence). The clause form of a sentence is the clause form of the matrix of its Skolem form.
Formally, for a sentence , let be the Skolem form of ; the clause form of is , with the atomic formulas of in the role of letters. The clause form of a finite set of sentences is the union of the clause forms of its members, with Skolem symbols new to the whole set.
In words: bring the negations down and the quantifiers to the front, name the witnesses, drop the universal quantifiers, and turn what is left into clauses.
This is the algorithm of the theorem on the clause form (Theorem 7.52), and the theorem can now be proved.
Proof of Theorem 7.52. The rewritings are taken one at a time.
Negation normal form and prenex form. Both translations are faithful, so is satisfied by the same structures as the set of prenex forms of its members.
Skolem form. By Skolem’s theorem (Theorem 7.89), applied to each member with its own new symbols, that set is equisatisfiable with the set of Skolem forms , and a structure that satisfies the Skolem forms satisfies the prenex forms.
Clause form. It remains to see that exactly when satisfies every clause of . Fix an assignment , and let be the valuation that gives each atomic formula of its truth value in under . Then
and says that some literal of each clause of is true in under . The sentence is true in exactly when is true under every assignment, and satisfies the clause set exactly when, under every assignment, some literal of each clause is true; so the two agree.
□
Remark 7.91 (at work: how provers clausify). The clause form of a sentence can blow up for the reason of Section 7.3, and provers avoid it by Tseitin’s translation. A subformula with free variables has no single truth value, so it gets a new -place relation symbol rather than a letter, with the definition added and put for ; when occurs only positively, the half is enough.9 A disjunction of conjunctions then gives clauses rather than . Provers also skip the prenex form and Skolemise straight from negation normal form, so that each Skolem function takes only the universal variables in whose scope its quantifier actually stands.
7.10 Resolution and Unification (optional)
This optional section answers three questions the main line raised and left open. What is a solver’s “no” worth: is a closed tree a proof? How large must such a proof be? And how can the first-order procedure choose its instances instead of listing them all? The main line quotes three of the answers, but none of their proofs: the long pigeonhole refutations (Section 7.5), unification (Section 7.8), and the first-order procedure with unification (Chapter 8).
Start with the first question. When the procedure closes a branch, it has found a clause falsified there, which says that the setting on the branch is forbidden. But that clause is not all the branch knows, nor the most useful thing it knows. Suppose a branch dies because is falsified, with , and all on, and was not a choice: the clause forced it. What the branch has discovered is that and cannot both be on, and no single clause of the set says so (node 4 of Example 7.34 is such a branch).
This section gives the rule by which such discoveries are written down, and shows that a closed DPLL tree is a proof in that rule. So the “no” of a solver is a proof, which a small program can check.
Definition 7.92 (resolution). Resolution combines two clauses that disagree about one switch into a clause that does not mention it.
Formally, let and be clauses and a letter with and . The resolvent of the clauses and , that is, of and , on is the clause , that is, the union ; and the rule of resolution passes from two clauses to their resolvent:
Two clauses are resolvable on if one contains and the other .
In words: if at least one of and the literals of holds, and at least one of and the literals of holds, then at least one of the literals of and holds, since and cannot both. When and are both empty the resolvent is the empty clause, and the rule has found that and were both demanded.
The resolvent of and on is : the two clauses say what must do when and are both on, and between them they say that and cannot both be on. The resolvent of and on is , which is the clause . Two clauses may be resolvable on more than one letter, as and are; the rule is applied on one letter at a time, and resolving on gives , a clause that forbids nothing.
Lemma 7.93 (soundness of resolution). Every valuation that satisfies two clauses resolvable on a letter satisfies their resolvent on .
Proof. Let satisfy and , with and .
makes true. Then does not make true, so to satisfy it makes some literal of true, which is a literal of .
makes false. Then to satisfy it makes some literal of true, which is a literal of .
In either case satisfies . □
So a resolvent of two clauses of can be added to without changing which valuations satisfy the set, and so can a resolvent of clauses already added. A clause reached in this way is a consequence of , and a sequence of such steps is a proof.
Definition 7.94 (resolution derivation). A resolution derivation is a tree of clauses in which every step is a resolution.
Formally, for a clause set , a resolution derivation from is a finite tree of clauses, root at the bottom, in which
each leaf is a clause of ;
each other node is the resolvent, on some letter, of its two children.
Its conclusion is the clause at the root, and its size is its number of resolution steps, that is, of its nodes that are not leaves. We write if there is a resolution derivation from with conclusion .
The tree is drawn as a derivation, with the two premisses of each step above the bar and the letter resolved on beside it. From a clause set containing , and ,
is a derivation from with conclusion and size two. A clause of may appear at several leaves, since a derivation may use it more than once.
Definition 7.95 (resolution refutation). A refutation derives the empty clause, the clause that nothing satisfies.
Formally, a resolution refutation of a clause set is a resolution derivation from with conclusion .
So has a resolution refutation exactly when .
Corollary 7.96 (refutations are sound). If then is unsatisfiable.
Proof. By the lemma, applied at each step from the leaves down, a valuation satisfying would satisfy every clause of the refutation; and no valuation satisfies . □
So a resolution refutation is a certificate of unsatisfiability, checked one step at a time against the definition of a resolvent.
The definition of a resolution derivation makes it a tree, so a clause that is needed twice must be derived twice, once in each subtree. If instead a derived clause may be used as often as one likes, the derivation is a directed acyclic graph, a dag, rather than a tree. Such a derivation is called general or dag-like, and a derivation in the sense of that definition is called tree-like when the contrast matters. Every general derivation can be unfolded into a tree-like one by copying the shared subderivations, so the two prove the same clauses; the difference is in the size, and the end of this section returns to it.
A closed tree is a refutation
Remark 7.35 promised that a closed DPLL tree, read from the leaves up, is a resolution proof. Here is the promise kept: every closed DPLL tree can be turned into a tree-like resolution refutation of about the same size. The idea is to label every node of the tree with a clause that the branch to that node has falsified: at a leaf, the clause that closed it; at a decision, a resolvent of the labels of the two children; at a node whose one child was forced, a resolvent of the child’s label with the clause that forced the child. The label at the top is then falsified by a branch with no literals on it, and such a clause is empty.
Theorem 7.97 (a closed DPLL tree is a tree-like resolution refutation). Let be a closed DPLL tree for . Then by a tree-like refutation of size at most the number of nodes of below the root.
Proof. For a node of , let be the branch from the root to , and say that a clause is falsified at if every literal of it is false under the partial valuation of . We show, by induction on the height of , that for every node below the root there is a tree-like derivation from whose conclusion is falsified at and whose size is at most one less than the number of nodes of the subtree below and including . The same three cases, applied once more to the root, then give the theorem. (If the root itself is a closed branch, a clause of is falsified with no literal false, so and there is nothing to prove.)
is a leaf. The branch is closed, so some clause of is falsified on it, that is, at . The one-node derivation with conclusion has size .
has one child , added by unit. Let be the label of , forced by the clause , so that every literal of other than is false at . By the induction hypothesis there is a derivation whose conclusion is falsified at . The literals false at are those false at together with .
If , then is already falsified at , and will do.
If , resolve with on the letter of . The resolvent is , every literal of which is false at . The new derivation has one more step than , and the subtree at has one more node than the subtree at .
has two children and , added by a decision on , labelled and . By the induction hypothesis there are derivations and with conclusions , falsified at , and , falsified at . The literals false at are those false at together with , and at those false at together with .
If , then is falsified at , and will do; likewise if .
Otherwise and , and the resolvent of and on is , every literal of which is false at . The derivation that resolves with has one more step than the two together, and the subtree at has one more node than the subtrees at and together, so the bound holds with room to spare.
Applied to the root, whose branch carries no literals, the decision case or the unit case gives a derivation of size at most the number of nodes below the root. Its conclusion has every literal false on a branch on which no literal is false, so the conclusion is . The derivation is tree-like because each step combines the derivations of two different subtrees of , or one of them with a clause of , and uses each once. □
In words: label each dead branch with the constraint it broke, and resolve the labels upwards; what arrives at the root is the empty clause. A closed DPLL tree is a resolution refutation with the clauses left unwritten.
Example 7.98 (the platform, cont’d: the reason, written down). Harriet labels the closed tree of Example 7.34. Node 4 is closed by and node 5 by . Then upwards.
Node 4 was forced by , and its label contains , the complement of the forced literal; resolving on gives , the label of node 3.
Node 3 was forced by , and contains ; resolving on gives , the label of node 1.
Node 5 was forced by , and its label contains ; resolving on gives , the label of node 2.
Nodes 1 and 2 are the decision on ; their labels and resolve to .
The refutation, drawn as a derivation:
It has four steps, for a tree with five nodes below the root. The clause in the middle is the rule nobody wrote down: the two rules about compression say between them that fast-sync and offline-mode cannot both be on, and the first rule then says that fast-sync cannot be on at all. The tree knew this at node 3, and the derivation says it.
The converse holds too, and with no loss. A tree-like resolution refutation of with nodes can be read as a DPLL tree for with at most nodes below the root: the letter resolved on at each step is the letter decided at the corresponding fork. The two kinds of certificate are the same up to a change of notation.10 So the smallest closed DPLL tree for and the smallest tree-like refutation of are of the same size up to a constant, and to ask how large a DPLL tree must be is to ask about resolution proofs. The rest of this section answers it for two families of clause sets.
Pigeonholes
Put pigeons into holes, and some hole holds two. As a clause set, with a letter for “pigeon is in hole ”: for each pigeon a clause , saying that it is in some hole, and for each hole and each pair of pigeons a clause , saying that they are not both in it. The set is unsatisfiable, for the reason just given, and a person proves it in a line.
Every resolution refutation of it, tree-like or not, has size at least for some constant .11 So every closed DPLL tree for it is exponential in , whatever letters are decided on and in whatever order, and no branching heuristic can help. The counting argument that a person uses is not available to resolution, which has no counting: it can only combine clauses two at a time. The exercises ask the reader to watch a solver fail on these sets as the number of holes grows.
Trees against graphs
A second result about resolution points at what the solvers add to the procedure. There are clause sets that have general refutations of size proportional to and no tree-like refutation of size less than for some . The sets themselves have a number of clauses proportional to , each of at most four literals.12
They are the pebbling sets, built from a directed graph in which every vertex above the bottom rests on two vertices below it. Each vertex has two letters and , and “ holds” means that one of the two is on. The clauses say that each vertex at the bottom holds, that a vertex holds whenever the two it rests on hold (four clauses of four literals, one for each choice of a true letter below), and that the vertex at the top does not.
Working from the bottom up, the short refutation derives the clause once for each vertex , and uses it at each vertex that rests on ; a tree-like refutation has to derive it again for every use. No cleverer tree avoids the repetition. The proof goes through a game of pebbles played on the graph, which gives the sets their name, and is beyond this chapter. On these sets the procedure is exponential although a short proof exists, and the reason is in the theorem that a closed tree is a refutation: a DPLL tree is a tree, and a tree cannot share a subproof.
Solvers get round the tree by keeping what the labelling finds. A clause derived from a closed branch is a consequence of , by the soundness of resolution (Lemma 7.93), so it can be added to the clause set without changing which valuations satisfy it, and unit propagation then uses it on every branch that follows. These are the learned clauses of Remark 7.35. A proof that uses one is no longer a tree, since the clause is derived once and used wherever the search meets it.
Example 7.99 (the platform, cont’d: the same lemma, many times). Harriet’s rule file has the five clauses of Example 7.15, on three switches, and ninety-seven more switches, which occur in other rules and, for the sake of the example, force nothing. Suppose the procedure decides on those ninety-seven first. Under each of those settings it builds the two branches of Example 7.34 again, and the labelling of the conversion theorem derives the clause , then and , from the same five rules: the same four steps of work, times over. The refutation it yields is the four-step one of Example 7.98, since at a decision on an irrelevant switch both children are labelled and one copy is kept. A good order defuses this: decide first, and the ninety-seven switches are never decided. Nobody knows the good order in advance, and no order defuses the pebbling sets.
Learning defuses it whatever the order. The first time the search sets on, whatever the other switches say, the branch closes by propagation alone, and the labelling gives its node the label . A learned clause with a single literal holds whatever has been decided, so the solver jumps back to the root, undoing every decision, and adds there. At the root, propagation now forces , then forces , and is falsified, with no decision anywhere above. The labelling gives this closed branch the label , and and the learned resolve to . A falsified clause at the root, with nothing left to undo, is how the solver knows that the clause set is unsatisfiable: two closed branches, and the ninety-seven other switches never come into it again.
Every solver of the kind this chapter is about, which is most of the solvers in use today, learns at every closed branch. The clause it learns often has all but one of its literals false already at a node far above the leaf that produced it. Then the solver does not step back to the last decision. It jumps back to the first such node, undoing the irrelevant decisions in between, and there the new clause forces its last literal. The proofs such a solver produces are general resolution refutations, and by the separation above, learning is not a refinement of the procedure but a change of proof system.
This is conflict-driven clause learning, and the chapter stops at its door. What lies behind it is the subject of the standard survey (Marques-Silva et al., 2021), and of the rest of a course on solvers: which clause to learn when a branch closes, how far to jump back, when to restart the search, which learned clauses to forget, and how to propagate without reading every clause at every step.
Unification
The rest of the section proves the claims made under “Choosing the instances” in Section 7.8: it gives the procedure that finds the instances worth writing down, and shows that it misses none.
A clash needs an atomic sentence that one instance contains and another contains negated. Before any instance is written, two clauses carry literals such as and , and the question is what to put for the variables so that the two atomic formulas (atoms, for short) become the same. Since a clause speaks of everybody, its variables are its own, and we may first rename them so that the two clauses share none, renaming them apart: becomes . Then the equation to solve is , and the answer is to put for . Solving equations of this kind is called unification.
Renaming apart is not a formality. Without it, the clauses and give the equation , which nothing solves, since is always longer than ; yet their ground instances and clash. Renamed apart, the second is , and is solved by putting for .
Definition 7.100 (equation). An equation asks for two expressions to be made identical.
Formally, an equation is a pair of terms, or a pair of atomic formulas, written .
We write rather than , since may be a relation symbol of the signature, and an equation asks for something else: that two expressions become identical, symbol for symbol.
Definition 7.101 (unifier). A unifier is a substitution that solves a set of equations.
Formally, let be a finite set of equations. A unifier of is a substitution such that and are the same expression for every equation in .
For instance, the equation has both of the substitutions
as unifiers. The first makes both sides , and the second makes both sides . The equation has no unifier at all, since would have to be both and , and no substitution makes and the same: the second always comes out longer.
The two unifiers of are not equally good. Applying the first and then to any expression gives the same result as applying the second, so the second is the first followed by a further decision, about who is, that nothing in the equation asked for. A unifier that makes no such decision is the one to compute.
Definition 7.102 (most general unifier). A most general unifier solves the equations while fixing nothing it does not have to.
Formally, let be a finite set of equations. A unifier of is a most general unifier of if for every unifier of there is a substitution with for every expression .
In words: every other solution is the most general one followed by some further substitution, and we say that is followed by . For that equation, the second unifier is the first followed by , and the first is most general: it puts for and only what the equation forces, and leaves alone.
The procedure
Equations between terms are solved from the outside in. If both sides start with the same symbol, a substitution makes them identical exactly when it makes the parts identical, so match the parts. If they start with different symbols, nothing will ever make them equal. When one side is a bare variable, the equation says what that variable must be, so write it down and put it in everywhere else. The one exception is a variable that occurs inside the other side, as in : nothing solves that, since the right-hand side always comes out longer. Figure 7.5 sets this out as six rules on a set of equations, each naming the equation it acts on and what replaces it.
| Rule | Equation | Replaced by |
|---|---|---|
| (delete) | nothing | |
| (decompose) | ||
| (clash) | , with | fail |
| (orient) | , with not a variable | |
| (occurs) | , with in and | fail |
| (eliminate) | , with not in but in another equation | , with put for in every other equation |
Here and stand for function, constant or relation symbols, and for their lists of arguments, for a variable and for a term or an atom; “ in ” means that occurs in . A constant is a symbol with no arguments, so (decompose) simply deletes , and (clash) fails on . The test that (occurs) makes is called the occurs check.
Definition 7.103 (solved form). A set of equations is in solved form when it is a list of answers for some of the variables, one each, that can be read off as a substitution.
Formally, a finite set of equations is in solved form if it is with distinct variables, none of which occurs in any of . Its substitution is .
In words: each equation has a variable on the left, and a variable that has been given an answer occurs nowhere else. The set of the two equations and is in solved form, with substitution ; the set of and is not, since has an answer and also occurs in the first equation.
Definition 7.104 (the unification procedure). The unification procedure applies the rules of unification until one fails or none applies.
Formally, the unification procedure takes a finite set of equations and applies the rules of Figure 7.5 to it, one at a time and in any order, until a rule fails or no rule applies. In the first case it fails; in the second it succeeds, and its result is the set of equations it then has.
Theorem 7.105 (unification). For every finite set of equations, the unification procedure, run on with the rules applied in any order, stops, and:
it fails exactly when has no unifier;
otherwise its result is in solved form, and the substitution of the result is a most general unifier of .
Proof sketch.
The four rules that do not fail keep the unifiers. A substitution unifies the set after such a step exactly when it unifies the set before. For (decompose), a substitution makes and identical exactly when it makes each and identical. For (eliminate), the equation stays in the set, and a substitution that makes and identical does the same to another equation whether or not has been put for in it. Deleting and turning an equation round change nothing either.
The two rules that fail are right to. No substitution makes expressions with different first symbols identical; and none makes identical with a term that contains it, since would contain as a proper part and so be longer.
A solved form is its own most general unifier. Let . No occurs in any , so , and is a unifier. Every unifier of the solved form has , and leaves every other variable alone, so for every : the unifier is followed by itself.
The procedure stops. Call a variable solved if it occurs exactly once in the set, on the left of an equation. Each step lowers, in dictionary order, the triple: the number of unsolved variables, which (eliminate) lowers and no rule raises; the size of the set in symbols, which (decompose) and (delete) lower; and the number of equations with a non-variable on the left, which (orient) lowers. Triples of natural numbers cannot go down for ever.
When no rule applies, every equation has a variable on the left (else (delete), (decompose), (clash) or (orient) would apply), that variable is not in its right-hand side (else (occurs), or (delete) if the right-hand side is the variable itself), and it is in no other equation (else (eliminate)): the set is in solved form.
Since every stage has exactly the unifiers of , a failure means that has none, and a solved form at the end gives a most general unifier of . As the procedure always stops, (i) and (ii) follow. □
In words: take the equations apart from the outside in, and you either hit a contradiction or arrive at the most general solution, which every other solution refines.
Example 7.106 (the company, cont’d: two equations). Harriet runs the procedure on the equation :
No rule applies, and the set is in solved form, with most general unifier
On the equation with no unifier,
and (occurs) fails on the last equation: no substitution makes and the same term. In the company Thorne is her own boss, but unification looks only at terms, and and are different terms.
Instances that can clash
Now the use. Two clauses can clash only through a pair of literals, one from each, with opposite signs and the same atom once the variables are filled in; and unification finds the most general way of filling them in.
Lemma 7.107 (instances that can clash). Let and be clauses with no variable in common, a literal of and a literal of . If some ground instances and have , then the equation has a most general unifier , and and are instances of and by one and the same substitution: and for some .
Proof. The substitution puts terms for the variables of , and for those of . This is where the hypothesis is used: since and share no variable, and never disagree, and together they form one substitution with and . It is a unifier of the equation, since . By the unification theorem (Theorem 7.105) the procedure finds a most general unifier , and is followed by some : so , and likewise . □
In words: every clash between instances of two clauses is an instance of one clash, the one unification computes. So for each pair of clauses, renamed apart, and each pair of literals of opposite sign, the instances worth writing down are and , when exists. When the procedure fails, the two literals can never clash at all, however far up the levels a search goes: a clash would give a unifier, and by the unification theorem (Theorem 7.105) there is none.
Example 7.108 (the company, cont’d: four instances, none listed). Harriet looks for clashes among the four clauses of Example 7.53, with renamed to . Five pairs of literals have opposite signs and the same relation symbol, and three of them do the work.
in against , the unit : the unifier is , and gives .
in against , the unit : the unifier is , and gives .
in against in : the unifier is , and gives , a clause with a variable, standing for all its instances at once. Its instance at is the clause of the second item, and is left as it was.
The other two pairs, in against and in against , give at and at , which the clash does not need. With the units and , the first two instances are the four ground clauses of the clash of Example 7.72, found without listing anything.
The procedure with unification
REFUTE can now choose its instances instead of listing them all, and the lemma on instances that can clash (Lemma 7.107) says that it loses nothing by doing so. Take two clauses and , with replaced by a copy whose variables are renamed, in some fixed way, apart from those of . Take a literal of and a literal of opposite sign in whose atoms unify, and let be the most general unifier that the unification procedure computes. The instances worth writing down are and . For a clause set , write for the set of all such instances, for all pairs of clauses of (a clause may be paired with a renamed copy of itself) and all such pairs of literals; it is finite, since is. A procedure that adds them before it grounds is:
procedure REFUTE-U(S) -- REFUTE, with the instances chosen by unification
S' := S
k := 0
loop:
S' := S' + CLASHES(S') -- the instances in which two clauses of S' can clash
if DPLL(GROUND(S', k)) is CLOSED(T): return UNSAT
k := k + 1
The new clauses are instances of clauses of , so they say nothing that did not already say; they only bring the useful instances down to a level the procedure reaches early.
Proposition 7.109 (the first-order procedure with unification). For every clause set , the call
returns
UNSATif is unsatisfiable, at a level no higher than the one at which does;runs for ever if is satisfiable.
Proof. First, each round stops: stays finite, unification stops, and DPLL stops. A most general unifier of two literals uses only the symbols in them, so every clause added to uses only the symbols of , and has the Herbrand universe of ; here is . Every clause added to is an instance of a clause already in , so, by induction on the rounds, of a clause of ; hence every clause of is a ground instance of a clause of .
is satisfiable. Some Herbrand structure satisfies it, by the lemma that Herbrand models suffice (Lemma 7.69). Then satisfies , and hence every clause set . By the soundness of DPLL no call of
DPLLreturnsCLOSED, andREFUTE-Unever stops.is unsatisfiable. By the theorem on the first-order procedure, closes at some level , so is unsatisfiable. Since contains and has the same Herbrand universe, contains , and a clause set that contains an unsatisfiable one is unsatisfiable. So by the correctness of DPLL (Theorem 7.44), has closed already when it reaches level , or closes then.
□
In words: choosing the instances by unification never costs a level and never changes the verdict; on a satisfiable set it runs for ever, as REFUTE does.
Example 7.110 (the company, cont’d: the policy, with unification). Harriet runs REFUTE-U on the four clauses of the policy. In the first round adds the five clauses of Example 7.108, one for each pair of literals found there. At level their ground instances, with those of the policy, are the six clauses of in Example 7.67, and DPLL closes them by three forced moves, without a decision. Plain REFUTE needed level .
The finance director’s question of Chapter 6, worked through by hand in Exercise 7.12, closes at level too. A machine run counts ground clauses there, where plain REFUTE needs level and clauses. And the weaker policy still never stops: unification only ever adds instances of the rules, and instances of rules that have a model cannot clash.
Remark 7.111 (unification at work). Unification is older than the solvers and more widely used. The type checker of a language such as ML or Haskell infers the type of a program by writing down equations between types and solving them by these rules. The occurs check is why it rejects : for to be well typed, would need a type equal to , which contains it. Prolog runs a program by unifying the goal with the heads of its clauses, and pattern matching in a functional language is the special case in which only one side has variables.
Resolution with variables
REFUTE-U finds the instances and in which two clauses can clash, and then grounds them for DPLL. Resolution can skip the grounding: it resolves and directly, on the literal that unification made complementary, and the resolvent, with its variables still in it, stands for all of its instances at once. From and , with the most general unifier , it derives . Resolution on clauses with variables, with unification choosing the instance, is the proof system on which first-order theorem provers were built for a generation; the History says who built it. This chapter stays with the propositional core, which is where the solvers of today have their engine, and leaves the lifted rule to a later course.
History
The ideas of this chapter arrived in the opposite order from the one in which it told them: the first-order machinery came first, and the propositional procedure was built to serve it. The chain begins with Löwenheim, who showed in 1915 that a satisfiable first-order sentence has a countable model, and with Skolem, who simplified the proof in 1920 by reducing every sentence to a normal form whose existential quantifiers are witnessed by chosen functions, the form that bears his name. In 1928 Skolem gave, in all but name, the result that a universal sentence is satisfiable exactly when its instances at the closed terms are jointly satisfiable.13 Herbrand’s thesis of 1930 proved what is now called his theorem, in the form that a prenex existential sentence is valid exactly when some finite disjunction of its instances is a propositional tautology, which is the dual of the form in this chapter. His proof analysed derivations directly, in a Hilbert-style system, which has axioms where has rules, and it had a gap, found and repaired three decades later.14 The route taken in this chapter, through Herbrand structures and compactness, is the modern one and owes more to Skolem than to Herbrand.
The procedures came thirty years later, when the first computers made it worth asking what a program could prove. Gilmore programmed the instance enumeration on an IBM 704 in 1960, testing each finite set of instances by multiplying it out into a disjunction of conjunctions, and the multiplying defeated the machine on small examples.15 Davis and Putnam (1960) replaced the test. Their paper is titled A computing procedure for quantification theory. The method Skolemises, enumerates the quantifier-free instances “in lexicographic order”, and tests the first of them for propositional consistency with three rules on clause sets: the unit rule of this chapter, the pure-literal rule, and a rule that eliminates a letter by replacing every pair of clauses that disagree about it with their resolvent. They wrote that the approach “goes back to Herbrand”, and reported that Gilmore’s program had run for twenty-one minutes without result on a formula their procedure settles by hand.
The last rule can increase the number and the length of the clauses at each application. When Davis, Logemann and Loveland (1962) programmed the procedure for the IBM 704 at New York University, with its words of core memory, they replaced that rule by the decision step of this chapter, the splitting rule, which costs no memory beyond the current branch. The initials of the four, DPLL, now name the second procedure, and “Davis–Putnam” is often used for either. Their program, like this chapter’s first-order procedure, was a first-order prover with a propositional core.
The enumeration of instances was the weak point, and Prawitz had seen in 1960 that the instances worth trying could be found by solving equations between terms instead of listing them.16 Robinson (1965) made that into the resolution principle: the elimination rule of the first paper, applied to clauses with variables, with a unification algorithm choosing the instance. His abstract describes the method as based on “the fundamental theorem of Herbrand”. The rule-by-rule presentation of unification used in this chapter is that of Martelli and Montanari (1982). Resolution made the propositional core dispensable and became the engine of automated theorem proving for a generation, which is why DPLL was, for thirty years, the less famous of the two descendants of the 1960 paper. The other road, generating instances by unification and handing them to a propositional solver, as REFUTE-U does, was taken up again in the 2000s by the instance-based provers, of which iProver is the best known (Ganzinger and Korovin, 2003; Korovin, 2008). The theorem that a closed DPLL tree is a tree-like refutation is usually stated without attribution; a careful statement of both directions is in the Handbook of Satisfiability, in its chapter on proof complexity (Buss and Nordström, 2021).
The translation that makes clause sets a general-purpose input, a new letter for each subformula, is Tseitin’s. He presented it at a Leningrad seminar in 1966 and published it two years later (Tseitin, 1968), in a paper that also gave the first lower bounds on the size of resolution proofs of a restricted kind. The general question of how large resolution proofs must be became pressing after Cook (1971) showed that sat is NP-complete (Levin (1973) proved the corresponding result independently). A proof system in which every unsatisfiable set had a short refutation would show , that every problem whose “yes” answers can be checked quickly has “no” answers that can be checked quickly too, which is not expected. Haken (1985) showed that resolution is not such a system: the pigeonhole sets have no refutation smaller than exponential. The separation of tree-like from general resolution was proved by Bonet, Esteban, Galesi and Johannsen (2000) and sharpened to the near-optimal bound quoted above by Ben-Sasson, Impagliazzo and Wigderson (2004).
DPLL’s second life began in the 1990s, when the verification of hardware produced propositional instances with hundreds of thousands of letters, and solvers that learn clauses were developed to meet them. The survey of Marques-Silva et al. (2021) tells their story. Their proofs have become objects of study in their own right. A solver’s “no” is now expected to come with a proof in a standard format, DRAT, a list of the clauses learned and deleted that an independent program can check (Wetzler et al., 2014). Heule, Kullmann and Marek (2016) settled the Boolean Pythagorean triples problem, whether the numbers can be split into two sets neither of which contains a triple with : the answer was no. The computation took two days on eight hundred processors, and the proof, nearly two hundred terabytes long, was checked by an independent program: nobody had to trust the solver.
The whole enterprise is classical. Passing from “no model of makes false” to “every model of makes true” is bivalence, and in derivations the same step is double negation, which derives from excluded middle and cannot. refutes , deriving , but not itself, and a search for a world in which is false collapses at once. An intuitionist would say that the collapse shows only that cannot be false, which is less than showing it true; in a logic where the two differ, the method of this chapter does not apply as it stands. Figure 7.6 collects the dates.
| Who | When | What |
|---|---|---|
| Löwenheim; Skolem | 1915; 1920 | countable models; existentials as functions |
| Skolem | 1928 | satisfiability by instances at closed terms |
| Herbrand | 1930 | the fundamental theorem |
| Gilmore | 1960 | instances enumerated and multiplied out |
| Davis & Putnam | 1960 | instances tested on clause sets; the unit rule |
| Prawitz | 1960 | instances found by solving equations |
| Davis, Logemann & Loveland | 1962 | the splitting rule: DPLL |
| Robinson | 1965 | resolution, with unification |
| Tseitin | 1968 | a new letter for each subformula |
| Cook; Levin | 1971; 1973 | sat is NP-complete |
| Martelli & Montanari | 1982 | unification as rules on equations |
| Haken | 1985 | pigeonholes need exponential proofs |
| Bonet, Esteban, Galesi, Johannsen | 2000 | tree-like resolution is weaker |
| Ben-Sasson, Impagliazzo, Wigderson | 2004 | the separation made near optimal |
| Wetzler, Heule & Hunt | 2014 | DRAT: checkable proofs |
| Heule, Kullmann & Marek | 2016 | Pythagorean triples: 200 terabytes |
Summary
A sentence follows from a theory exactly when the theory together with its negation has no model. So a proof can be a failed search for a counter-model, and once the things to be talked about are named, the search is propositional. The chapter solved that problem first.
A valuation is grown one switch at a time. Splitting on a letter loses nothing, as long as both sides are tried; greedy setting, which cannot go back, can miss a solution. To know when to stop and when a switch is forced, the search needs constraints it can read at a glance, and conjunctive normal form provides them. It is reached by pushing negations to the letters and multiplying out, and it is drawn as a matrix, through which a satisfying valuation is a path without a connection. Under a partial valuation a clause is satisfied, falsified or a unit, and a unit leaves the other branch empty, so its literal is forced. Setting what is forced, deciding what is not, and giving up on a branch as soon as a clause is falsified is DPLL, which is sound, complete and always stops.
A program stores the constraints as a clause set and the valuation as a set of literals, and throws each switch by restriction: it deletes the clauses the switch satisfies and crosses its complement out of the rest. A finished branch is a setting that anyone can check by plugging it in, and a closed tree is a certificate that anyone can check node by node. Each closed branch also proves a clause that the constraints imply without stating it, and solvers learn it. The first certificate is always short and the second need not be: deciding satisfiability is NP-complete, and whether it can always be done quickly is the open question whether . SMT solvers push richer questions down to the same engine.
Then the chapter reduced the first-order problem to the simpler one. Once every “someone” has been given a name, by a Skolem function of the things it depends on, the search need look only at structures made of names, and such a structure is a setting of switches, one for each atomic sentence about the names. A set of constraints has a model exactly when its ground instances at the closed terms have one, and when it has none, finitely many instances already clash. Running DPLL level by level on the ground instances, the first-order procedure certifies every entailment from finitely many premisses that holds, and never answers for one that fails: a semi-decision procedure. On some questions it runs for ever while a two-person counter-model exists, and on some every counter-model is infinite. The finiteness is the finiteness of a derivation in .
The optional sections add two things. First, the clause form is computed by bringing the quantifiers to the front and naming the witnesses, and the half of Skolem’s theorem that turns a model of the Skolem form back into a model of the sentence is an derivation three lines long. Second, a closed tree is a tree-like resolution refutation, a proof in a system of its own, and that proof system has limits: resolution cannot refute the pigeonhole sets in less than exponential size, so neither can DPLL. And some sets have short general refutations and only exponential tree-like ones, because a tree cannot reuse a lemma. The solvers in use today learn the lemma and add it to the clause set. Unification, solving equations between terms from the outside in, finds the instances that can clash without listing the rest.
Exercises
The exercises run from practice to proof.
Exercises 7.1 to 7.3 are about satisfiability and the two normal forms;
Exercises 7.10 to 7.12 are about Herbrand’s theorem and the procedure for first-order logic;
Exercises 7.13 to 7.20 go with the two optional sections, and are optional too.
Exercise 7.1. Show that two sentences and are true in the same structures if and only if is unsatisfiable, so that equivalence, like entailment and validity, is a question of satisfiability.
Exercise 7.2. Turn each constraint into conjunctive normal form by the two steps, and beside each clause write the pattern it forbids.
;
;
;
“exactly one of , , is on” (write the clauses directly).
Why is the empty clause false under every valuation, and the conjunction of no clauses, , true under every valuation?
Exercise 7.3. This exercise works out Tseitin’s translation, sketched in Remark 7.28. For a formula , give every compound subformula a new letter , and for a letter let be . For each compound , with for and , for the letters of its parts, the defining clauses of are
and , if is ;
, and , if is ;
, and , if is ;
, and , if is ;
and the unit clause is added if occurs. The translation is the set of all these clauses together with the unit clause . Call a valuation honest for if it makes each true exactly when it makes true.
Let be . Compute and , naming the three conjunctions , , , the inner disjunction and the whole formula , and count the clauses of each.
Give a valuation that satisfies but not , so that the two are not equivalent.
Show, by induction on , that a valuation satisfies all the defining clauses of exactly when it is honest for .
Deduce that every valuation that satisfies agrees on the letters of with one that satisfies , and that every valuation that satisfies satisfies . Which of the two is the way back, and why does the second make and equisatisfiable together with the first?
Exercise 7.4. Run unit propagation on the clause set ; ; ; ; ; , writing down each forced literal and the clause that forced it, and say what the procedure returns.
Exercise 7.5. Run the procedure on the clause set ; ; ; ; , deciding on with the “on” side first, and draw the tree. Read off the setting it returns and check it against the five clauses.
Exercise 7.6. Give a second proof of the soundness of DPLL, which follows one satisfying valuation down the tree instead of working up from the leaves. Let , and call a branch of a DPLL tree for faithful to if .
Show that every DPLL tree for has a faithful branch.
Show that a faithful branch is open, and conclude that no DPLL tree for is closed.
Hint: for (a), argue by induction on the construction of the tree, one case for each rule. The root alone is a faithful branch, since . At a decide step on a faithful branch, makes true or false; at a unit step, use part (iii) of the lemma on the status of a clause; a step on another branch leaves the faithful branch as it was.
Exercise 7.7. The first of the two DPLL papers had a second rule, which the trees of this chapter leave out. Let be a clause set and a partial valuation. A literal is pure under if its letter is undecided by and belongs to no clause with . The pure-literal rule passes from to without a decision.
Show that if is pure under , then is alive for if and only if is. (Hint: given a valuation that extends and satisfies , change the value of one letter.)
Let and . Show that and are both pure. Of the four valuations of and , how many satisfy , and how many satisfy ?
At the rule replaces the question about by the same question about . Show that the two sets are equisatisfiable, but need not be equivalent or have the same number of satisfying valuations. What is the way back, in the sense of Section 7.1? Why must a program that counts the satisfying valuations of a clause set, rather than finding one, switch the rule off, and need it switch off unit propagation too?
Exercise 7.8. The order of the decisions can change the size of a DPLL tree enormously. For let be the clause set
Show that is unsatisfiable by drawing a DPLL tree that decides first. How many nodes does it have below the root?
Now let the procedure decide first, in that order and each on first, and only then . Draw the tree for , and show that for every it has closed branches and nodes below the root.
Which letter does the rule of thumb “decide a letter that occurs in many short clauses” pick first?
Exercise 7.9. Encode “three pigeons in two holes” as a clause set, with for “pigeon in hole ”, and run the procedure, deciding on first and otherwise propagating. Draw the tree and count its nodes.
Exercise 7.10. Let consist of the clauses , and .
Write down , and , and the Herbrand base up to level .
Give a Herbrand structure that satisfies the first two clauses, as a set of atomic sentences.
Run
REFUTEby hand: write , and and say at which levelDPLLreturnsCLOSED, and by which forced moves.
Exercise 7.11. Let be a constant, and one-place function symbols, and one-place relation symbols and a two-place relation symbol. Encode the question whether the clause set
has a model with one element as a propositional clause set, as the search for small structures of Section 7.8 describes, and run DPLL on it. Then do the same with two elements for the clause set , , and read off the structure.
Exercise 7.12. Let be the signature with a constant , a one-place function symbol , one-place relation symbols and , and two-place relation symbols and . Do the two sentences
together with the equality axioms, entail ?
Write the two sentences and the negated claim as clauses, with a Skolem constant .
Write the equality clauses for : reflexivity, symmetry, transitivity, and the congruence clauses of Remark 7.54.
Find five ground clauses, at level at most , that no valuation satisfies, and say which forced moves show it.
(Optional.) The clause set of (a) and (b) has, at level , well over two hundred ground instances. Say in a sentence why unification would find the five of (c) without listing the rest.
Exercise 7.13. (Optional.) Prove three more cases of the pull-out lemma, for not free in : , and . Then, for a one-place relation symbol , show by a counterexample that and are not in general true in the same structures, and say which quantifier the arrow turns the first into.
Exercise 7.14. (Optional.) Let and be one-place relation symbols, a two-place relation symbol and a one-place function symbol. Give the prenex form and the Skolem form of each sentence, and say what the Skolem symbols stand for.
;
;
;
, Skolemised once correctly and once with the same constant for both, and a structure that satisfies the first result and not the second.
Exercise 7.15. (Optional.) Write out the derivation of the sentence from its Skolem form , and check the side conditions of the two (I) steps.
Exercise 7.16. (Optional.) Run the unification procedure on each equation, writing the set of equations after every rule as in Example 7.106, and give the most general unifier or say which rule fails. Here and are constants, and function symbols and a relation symbol.
;
;
;
.
Exercise 7.17. (Optional.) Take the clause set of Exercise 7.10: , and .
Find the instances that adds in its first round. (Pair the second clause with a renamed copy of itself too.)
Show that
REFUTE-Ucloses at level , and say which forced moves close it. PlainREFUTEneeded level .
Exercise 7.18. (Optional.) Resolution is sound, and only just.
Write out the proof that every valuation satisfying and satisfies , in its two cases.
Show that the resolvent need not follow from either premiss alone: give a valuation that satisfies but not the resolvent of and .
The clauses and disagree about two letters. Show that “resolving on both at once”, which would give , is not sound, and say what the two legitimate resolvents are.
Exercise 7.19. (Optional.) Let be ; ; ; . Draw the DPLL tree that decides on , label its nodes as in the proof of the theorem that a closed tree is a refutation, and draw the resolution refutation that results.
Exercise 7.20. (Optional.) Implement DPLL in a language of your choice, with the branching heuristic “the first undecided letter”, and then REFUTE on top of it, with clauses as lists of literals and terms as nested lists.
Run
DPLLon the pigeonhole sets with pigeons and holes for , counting the nodes of the tree. Say what you expect to see and why, and stop when a run takes longer than a minute.Run
REFUTEon the clause setwith a constant, a one-place function symbol and , one-place relation symbols, and then on the same set without its second clause, printing the level and the verdict at each level, and stop the second run by hand.
References
- Eli Ben-Sasson, Russell Impagliazzo, and Avi Wigderson. Near optimal separation of tree-like and general resolution. Combinatorica, 24(4):585–603, 2004.
- Maria Luisa Bonet, Juan Luis Esteban, Nicola Galesi, and Jan Johannsen. On the relative complexity of resolution refinements and cutting planes proof systems. SIAM Journal on Computing, 30(5):1462–1484, 2000.
- Samuel R. Buss. On Herbrand’s theorem. In Logic and Computational Complexity, volume 960 of Lecture Notes in Computer Science, pages 195–209. Springer, 1995.
- Samuel R. Buss and Jakob Nordström. Proof complexity and SAT solving. In Armin Biere, Marijn Heule, Hans van Maaren, and Toby Walsh, editors, Handbook of Satisfiability, pages 233–350. IOS Press, Amsterdam, second edition, 2021.
- Stephen A. Cook. The complexity of theorem-proving procedures. In Proceedings of the Third Annual ACM Symposium on Theory of Computing, pages 151–158, 1971.
- Martin Davis and Hilary Putnam. A computing procedure for quantification theory. Journal of the ACM, 7(3):201–215, 1960.
- Martin Davis, George Logemann, and Donald Loveland. A machine program for theorem-proving. Communications of the ACM, 5(7):394–397, 1962.
- Harald Ganzinger and Konstantin Korovin. New directions in instantiation-based theorem proving. In Proceedings of the 18th Annual IEEE Symposium on Logic in Computer Science (LICS), pages 55–64, 2003.
- Paul C. Gilmore. A proof method for quantification theory: its justification and realization. IBM Journal of Research and Development, 4(1):28–35, 1960.
- Armin Haken. The intractability of resolution. Theoretical Computer Science, 39:297–308, 1985.
- Jacques Herbrand. Recherches sur la théorie de la démonstration. PhD thesis, Université de Paris, 1930. Printed as Prace Towarzystwa Naukowego Warszawskiego, Wydział III, no. 33, Warsaw, 1930. English translation in Logical Writings, ed. W. D. Goldfarb, Harvard University Press, 1971.
- Marijn J. H. Heule, Oliver Kullmann, and Victor W. Marek. Solving and verifying the Boolean Pythagorean triples problem via cube-and-conquer. In Theory and Applications of Satisfiability Testing – SAT 2016, volume 9710 of Lecture Notes in Computer Science, pages 228–245. Springer, 2016.
- Konstantin Korovin. iProver – an instantiation-based theorem prover for first-order logic (system description). In Automated Reasoning (IJCAR 2008), volume 5195 of Lecture Notes in Computer Science, pages 292–298. Springer, 2008.
- L. A. Levin. Universal sequential search problems. Problems of Information Transmission, 9(3):265–266, 1973.
- João Marques-Silva, Inês Lynce, and Sharad Malik. Conflict-driven clause learning SAT solvers. In Armin Biere, Marijn Heule, Hans van Maaren, and Toby Walsh, editors, Handbook of Satisfiability, pages 133–182. IOS Press, Amsterdam, second edition, 2021.
- Alberto Martelli and Ugo Montanari. An efficient unification algorithm. ACM Transactions on Programming Languages and Systems, 4(2):258–282, 1982.
- Matthew W. Moskewicz, Conor F. Madigan, Ying Zhao, Lintao Zhang, and Sharad Malik. Chaff: Engineering an efficient SAT solver. In Proceedings of the 38th Design Automation Conference (DAC 2001), pages 530–535. ACM, 2001.
- Dag Prawitz. An improved proof procedure. Theoria, 26(2):102–139, 1960.
- J. A. Robinson. A machine-oriented logic based on the resolution principle. Journal of the ACM, 12(1):23–41, 1965.
- Thoralf Skolem. Logisch-kombinatorische Untersuchungen über die Erfüllbarkeit oder Beweisbarkeit mathematischer Sätze nebst einem Theoreme über dichte Mengen. Videnskapsselskapets skrifter, I. Matematisk-naturvidenskabelig klasse, 4:1–36, 1920. English translation in van Heijenoort 1967.
- Thoralf Skolem. Über die mathematische Logik. Norsk matematisk tidsskrift, 10:125–142, 1928. English translation in van Heijenoort 1967.
- G. S. Tseitin. On the complexity of derivation in propositional calculus. In A. O. Slisenko, editor, Studies in Constructive Mathematics and Mathematical Logic, Part II, volume 8 of Zapiski Nauchnykh Seminarov LOMI, pages 234–259. Nauka, Leningrad, 1968. In Russian. English translation in J. H. Siekmann and G. Wrightson (eds.), Automation of Reasoning 2, Springer, 1983, pp. 466–483.
- Jean van Heijenoort, editor. From Frege to Gödel: A Source Book in Mathematical Logic, 1879–1931. Harvard University Press, Cambridge, MA, 1967.
- Nathan Wetzler, Marijn J. H. Heule, and Warren A. Hunt, Jr. DRAT-trim: Efficient checking and trimming using expressive clausal proofs. In Theory and Applications of Satisfiability Testing – SAT 2014, volume 8561 of Lecture Notes in Computer Science, pages 422–429. Springer, 2014.
- Claus-Peter Wirth, Jörg Siekmann, Christoph Benzmüller, and Serge Autexier. Lectures on Jacques Herbrand as a logician. SEKI Report SR-2009-01, DFKI, 2009. arXiv:0902.4682.
Notes
The arrow’s truth table makes a conditional true whenever its antecedent is false, so that “if the moon is made of cheese, then ” comes out true. The table is Philo of Megara’s, from the fourth century BC, and the argument about it is as old: by Sextus Empiricus’s report, the poet Callimachus wrote that even the crows on the rooftops were cawing about which conditionals are true. For how to live with it, seek spiritual guidance from your nearest philosopher, or from the History of Chapter 6. ↩
The method is Bibel’s, and Andrews’s matings are the same idea; both were developed for first-order logic around 1980, where a connection may need a substitution to become one. ↩
The translation is Tseitin’s (1968); the History says more. ↩
Davis and Putnam (1960) and Davis et al. (1962); the History says what each paper did. ↩
The two watched literals are due to Moskewicz et al. (2001). The first of the two DPLL papers stated its rules as operations on the clause set, in the manner of restriction. ↩
Exercise 7.8 gives clause sets on which one order closes the tree in four nodes and another needs more than branches, and Example 7.99, in the optional Section 7.10, shows the same effect at scale. Modern solvers choose each letter as the search goes, from what it has seen. The best known heuristic, VSIDS, raises the score of the letters in each newly learned clause and every so often scales all scores down, so that recent failures count most (Moskewicz et al., 2001). The first of the two DPLL papers had a further rule, the pure-literal rule, which solvers still use when preparing their input; Exercise 7.7 shows what it keeps and what it loses. ↩
By Cook (1971), and independently by Levin (1973). ↩
When the domain is infinite the choosing is an application of the axiom of choice. ↩
The one-directional definitions are due to Plaisted and Greenbaum (1986); Nonnengart and Weidenbach’s chapter in the Handbook of Automated Reasoning (2001) surveys how provers compute small clause forms. ↩
Buss and Nordström (2021), in their section on DPLL, state both directions, with the small point that a tree-like refutation may resolve on the same letter twice along a path, and the corresponding part of the proof is first pruned away. ↩
Ben-Sasson et al. (2004), improving an earlier separation by Bonet et al. (2000). ↩
Skolem (1920), Skolem (1928); see van Heijenoort (1967) for both in translation. ↩
Herbrand (1930); the repair is due to Dreben, Andrews and Aanderaa, and Gödel had noticed the gap earlier without publishing (Buss, 1995). ↩
Prawitz (1960). Herbrand had described a procedure for solving such equations in his thesis; Wirth et al. (2009) print its original text. ↩