The completeness theorem for , Gentzen’s natural deduction with the law of the excluded middle, says that whenever a sentence follows from others, it has a derivation from them. It says nothing about how to find the derivation, and finding one can be hard. At every step there could be an instance of excluded middle for every formula one could think of, and a choice of term for every quantifier, and nothing on the page says which choice leads anywhere. So how does one check whether a given sentence is entailed by a set of sentences?
The proof of the completeness theorem contains a suggestion. It builds a model of out of a failure to derive from . So instead of searching for a derivation of from , we may search for such a model. If there is one, it shows that does not follow from ; if the search shows that there is none, then does follow. This idea has been one of the most effective in automated reasoning.
In the end the search comes down to something very simple. As far as the 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. Think of each basic fact as a switch, on when the fact holds in the structure being built and off when it does not. Building a model is then choosing a setting of the switches, one that makes every sentence true, and the programs that search for such a setting are called SAT solvers, SAT for satisfiability.
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.37, 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.
Here is the search in miniature. Suppose you want to know whether some constraints entail a claim, and a derivation will not come: at every step there is a guess to make, and nothing says which guess leads anywhere. Treat the question as you would a bug, and ask what a counterexample would look like. Suppose the claim fails, and give the “someone” who breaks it a name. Then read the constraints against what you have written, one named thing at a time, and write down what they force. Either the page collapses, with every line forced by the lines above it, and the constraints entail the claim; or the demands run out, and what is left on the page is a structure in which the constraints hold and the claim fails: a counter-model, which serves as a bug report. Example 7.4 runs this search on an access policy, twice.
The chapter asks four questions about such a search:
Why is a search for a counter-model as good as a proof?
How does a machine search for a setting of the switches, and what certifies its answer?
Why may the search look only at the things it has named?
Does the search always come to an end?
The chapter answers them by first solving a simpler problem, with no quantifiers at all (given constraints on finitely many switches, is there a setting that obeys them?), and then reducing the first-order problem to it.
Section 7.1 turns entailment into the question whether a set of sentences has a model.
Section 7.2 fixes one shape for constraints, the clause, which forbids some settings of the switches.
Section 7.3 solves the simpler problem with DPLL, and certifies the answer either way.
Section 7.4 gives every “someone” a name and turns sentences into clauses.
Section 7.5 proves that the names are enough.
Section 7.6 hands the instances, level by level, to DPLL.
Two optional sections follow: Section 7.7 opens the black box of Section 7.4, and Section 7.8 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. The History at the end tells who did what.
7.1 Satisfiability
This section turns the question we started from, whether a set of sentences entails a sentence , into the question that a solver answers: whether a set of sentences has a model. Throughout, is a signature, and structures and sentences are -structures and -sentences.
A sentence can be true in one structure and false in another, and the words we need sort sentences by the structures that make them true. A sentence is
true in a structure if ;
valid if it is true in every structure;
contingent if it is true in some structures and false in others.
Satisfiability, the case that matters here, gets a definition of its own. A programmer may read as a test and a structure as an input: then is satisfiable when some input passes the test, and valid when every input does.
Definition 7.1 (satisfiable). A sentence, or a set of sentences, is satisfiable if some structure makes it true.
Formally, a -sentence is satisfiable if for some -structure , and unsatisfiable otherwise. A set of -sentences is satisfiable if it has a model, that is, if some -structure satisfies it, , and unsatisfiable otherwise.
Three confusions are easy to make, and the definitions rule each of them out.
A sentence true in a structure need not be valid: another structure may make it false.
A satisfiable sentence need not be true in the structure one has in mind.
A sentence that is not valid need not be unsatisfiable: a contingent sentence and its negation are both satisfiable.
Example 7.2 (the company: eight sentences). Harriet Ashworth looks after the platform of the company of Chapter 6, and the company is her structure : Tuesday’s personnel table, in the company signature. Figure 7.1 classifies eight sentences of the company signature, with the evidence for each verdict.
| Sentence | Verdict | Evidence |
|---|---|---|
| valid | in every structure one disjunct is true | |
| valid | whatever names is one of everything | |
| contingent | true in the company; false in a one-person company whose chief executive is an engineer and not a manager | |
| contingent | false in the company; true when is interpreted as | |
| contingent | true in a company of managers; false in the company | |
| contingent | true in the company; false in a company of engineers | |
| unsatisfiable | the first conjunct needs an engineer, the second forbids one | |
| unsatisfiable | whatever names would be a manager and not one |
The table shows each of the three confusions at work.
The policy holds in the company, and a company with different staff can break it.
The sentence is satisfiable, though no sensible company makes it true: nothing in the signature says that comes from salaries.
The sentence is not valid, and neither is its negation, so both are satisfiable.
The evidence for such verdicts comes in two kinds. A verdict that something happens in some structure (satisfiable, or not valid) is backed by a single structure, and anyone can check it by evaluating the sentence there. A verdict that something happens in every structure, or in none (valid, or unsatisfiable), is backed by an argument that speaks of all structures at once, and no evaluation checks an argument of that kind (the third column of Figure 7.1 has both). This chapter produces the second kind of evidence by searching for the first.
Now the question we started from, whether . The entailment fails exactly when some model of makes false, and then a single model, evidence of the first kind, shows it. Such a model has a name.
Definition 7.3 (counter-model). A counter-model is a structure that shows an entailment to fail.
Formally, a counter-model to is a model of in which is false, that is, a structure with and .
By the definition of entailment, either holds or it has a counter-model.
Example 7.4 (the company, cont’d: a policy change and a bug report). Harriet has been asked to sign off a change to the company’s access policy. Two rules have been proposed, that engineers report to managers and that managers are not engineers:
Their point is that no engineer ever reports to another engineer:
Do and entail ? Forty minutes on a derivation in leave Harriet with a page of guesses, so she asks what a counterexample would look like. Suppose some engineer, call her , reports to an engineer. By , ’s boss is a manager. By , ’s boss is not an engineer. But ’s boss is an engineer, and every line was forced by the lines above it. No company obeying the two rules contains such an : the rules entail the claim.
The same afternoon a colleague proposes dropping , so that a senior engineer can lead a team. Harriet runs the same search. Suppose an engineer reports to an engineer . By , is a manager, and now nothing forbids a manager from being an engineer, so nothing collapses. By again, ’s boss must be a manager, and the simplest choice is herself, as the personnel table does for the chief executive. The demands run out, and what is left on the page is a structure: two engineers, with a manager and the boss of both. It obeys and breaks at . That is a bug report, not a failed proof: it says what the weakened policy allows, an engineer who manages an engineer.
So the two-person company is a counter-model to , once the symbols that the sentences do not mention are given a meaning:
names ;
is empty;
is identity.
Two people are not the smallest counter-model: Example 7.66 finds one with a single person. There is none for , as the first search showed.
Lemma 7.5 (reduction to satisfiability). For every set of sentences and all sentences and :
if and only if is unsatisfiable;
is valid if and only if is unsatisfiable;
and are true in the same structures if and only if is unsatisfiable.
Proof. A model of is a model of in which is false, since is true exactly when is not; that is, a counter-model to . So (i) says that an entailment holds exactly when it has no counter-model, which is the definition. Part (ii) is (i) with empty, and (iii) is Exercise 7.1. □
In words: every question about what follows from what, about validity and about saying the same thing is a question about whether some set of sentences has a model.
The lemma is nearly a tautology (in classical logic, where is true exactly when is not), and its use lies in what it suggests. A proof that can be a failed search: try to build a model of , and show that every way of doing so collapses. This is why a search for a counter-model is as good as a proof.
So the question to hand to a program is whether a set of sentences, such as , has a model. A program can only be handed finitely many sentences, so from now on such a set is finite. We call the members of the set its constraints, since each is a sentence that the model being sought must make true.
A program that decides whether a finite set of constraints has a model is a solver. We want it to give evidence for its verdict as well as the verdict itself, evidence that can be checked without trusting the solver.
When the answer is “yes, has a model”, the evidence is a structure that satisfies the set. When the structure is finite, anyone can check it by evaluating the sentences in it.
When the answer is “no, has no model”, the evidence has to be a finite object that shows every attempt to build a model collapsing. Section 7.3 builds one.
How is a solver to search for a model? It cannot go through the structures one by one: a structure that satisfies the constraints may have five elements, or be the natural numbers, or the real line, and there is no list of them to go through. A search by hand does something narrower. It names the things it needs, and records for each basic fact about them whether the fact holds. A basic fact of this kind is an atomic sentence about named things, such as or , and the structure being built either makes it true or makes it false.
So each atomic sentence works as a switch, on or off, and what the search builds is a setting of the switches: a choice of on or off for each of them. A setting is something a program can handle. It can be written down; finitely many switches have finitely many settings; and a search through them can be seen to have failed. This is why a solver searches for a setting rather than for a structure. Section 7.5 shows that nothing is lost by doing so: a set of constraints has a model exactly when some setting of the switches about its names obeys every instance of the constraints at those names.
To reach the switches, the constraints have to be rewritten, and one of the rewritings brings in new symbols. A search that gives the “someone” of a negated claim a name, , has brought in a new symbol. A rewritten set that mentions symbols the original does not is not true in the same structures as the original. What a rewriting must keep is the solver’s verdict: the new set must have a model exactly when the old one does. That property has a name.
Definition 7.6 (equisatisfiable). Two sets of sentences are equisatisfiable when both have a model or neither does.
Formally, sets and of sentences are equisatisfiable if is satisfiable exactly when is.
In words: for the purpose of the verdict, one set may stand in for the other. The notion is weaker than being true in the same structures. The sets and , for a one-place relation symbol , are equisatisfiable, since both have models; but in a structure with two elements, only one of them in , with naming the other, the first is true and the second false. Weaker is what we want, since it leaves room for exactly this kind of rewriting: naming a “someone”, or adding new symbols of any other kind, as long as the verdict survives.
Equisatisfiability is enough for the verdict, but not for the evidence. When the answer is yes, the solver returns a structure that satisfies the rewritten set , and what we asked for was one that satisfies the original set . The definition alone does not give one. The sets and are equisatisfiable, since both have models, but a structure that satisfies the second, in which names an element of , need not satisfy the first, in which it names an element of . A solver that rewrote the first set into the second would give the right verdict and evidence for the wrong question.
So each rewriting in this chapter comes with a way back: a way of turning every structure that satisfies into one that satisfies . For the naming of a “someone” the way back is simply to forget the name, as the theorem on the clause form in Section 7.4 shows.
7.2 Clauses
Section 7.1 turned the question whether into the question whether has a model. This section and the next solve that question for constraints without quantifiers; the quantifiers wait until Section 7.4, and nothing is lost by setting them aside, since once they have been dealt with every constraint is of the kind treated here. This section rewrites every constraint as a set of clauses, lists of switches each set on or off, of which at least one must hold.
Without quantifiers, a constraint is built from atomic sentences, such as and , by the connectives, and whether it is true in a structure depends only on which of its atomic sentences are true there. What is inside an atomic sentence plays no part. The sentence might as well be a single letter, say, that is either true or false: one switch.
So in this section we simplify the language. We fix a set of letters (the atomic sentences of a signature, say, each read as one letter), write , , for letters, and build formulas by the grammar
where , with the bracket conventions of Chapter 6 and with abbreviating . In this section the constraints are these formulas. Logic about letters alone is called propositional logic, as opposed to the predicate logic of Chapter 6, whose atomic formulas take arguments.
One choice here departs from Chapter 6, on purpose. There abbreviated ; here is a connective in its own right. The two readings always give the same truth value, so nothing is lost. What is gained is that the translations below can say directly what they do to a negation.
Definition 7.7 (valuation). A valuation sets each switch on or off, and so makes each formula true or false.
Formally, a valuation is a function . It is extended to formulas by recursion on the shape of the formula:
where , and are the operations on given by their truth tables: is true exactly when is false, exactly when both are true, and exactly when at least one is.
In words: a valuation is a row of a truth table, and is the entry of in that row. A program computes it as a circuit computes its output, gate by gate from the inputs.
Definition 7.8 (satisfaction by a valuation). A valuation satisfies a formula when it makes the formula true, and a set of formulas when it makes every member true.
Formally, let be a valuation. Then satisfies a formula , written , if ; and satisfies a set of formulas, written , if for every .
Definition 7.9 (satisfiable set of formulas). A set of formulas is satisfiable when some row of the truth table makes all of it true.
Formally, a set of propositional formulas is satisfiable if for some valuation , and unsatisfiable otherwise.
The words are those of satisfaction in a structure, on purpose. A structure for a signature of letters amounts to a valuation (Proposition 6.28), and then says exactly what says.
The rewritings of this section must not change which settings a constraint allows, and the next definition says what that means.
Definition 7.10 (equivalent formulas). Two formulas are equivalent when they take the same value in every row of the truth table.
Formally, formulas and are equivalent, written , if for every valuation .
The symbol is not a connective. Like , it states a fact about formulas from outside the language, and is not itself a formula. Equivalence is a congruence: replacing a part of a formula by an equivalent part gives an equivalent formula, since computes the value of a formula from the values of its parts. Every rewriting in this section replaces a formula by an equivalent one, and that is what entitles us to treat a constraint as nothing more than its truth table.
Remark 7.11 (Boolean algebra). The two truth values with , and form the smallest Boolean algebra, and they obey the laws that algebra is known for: and are commutative and associative, each distributes over the other, undoes itself, and turns into and back. Each law can be checked in a few rows of a truth table, and each is an equivalence.
A constraint, as the word suggests, forbids. When we care about deduction, what matters in a formula is how its parts are connected. When we care only about the switches, what matters is which settings the formula allows, and a constraint is nothing more than the settings it rules out. Take
read “if and are on, then must be on”. Its truth table has eight rows:
Only one row has F, the one with on, on and off. As a constraint on valuations, says no more than “never on, on and off at the same time”.
That is all a constraint can ever do. Its value is fixed by the values of its letters and by nothing else, so it can only rule out combinations of on and off. To rule out “ on, on, off” is to demand that at least one switch differ from it: off, or off, or on. So the constraint becomes
Each disjunct names one switch and says whether to or not to , and at least one of them must be obeyed. A constraint that rules out several settings becomes several such disjunctions, one for each. This is the shape we want every constraint in, and the rest of the section makes it precise.
Definition 7.12 (literal). A literal says one thing about one switch: that it 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: is , and is .
For instance, is a literal with complement , while and are not literals.
Definition 7.13 (clause, clause set). A clause is a constraint in its plainest shape: a list of literals of which at least one must hold.
Formally, a clause is a finite set of literals, written as the disjunction of its members; the empty clause, with no literals, is written . A clause set is a finite set of clauses, written, when it helps, as the conjunction of its members. We write , for clauses and for clause sets.
In words: a clause is an “at least one of these”, and a clause set is a list of such demands. Since a clause is a set, neither the order of its literals nor repetition matters: , and are the same clause. A clause with one literal is a unit clause.
Read as a disjunction and a conjunction, a clause and a clause set are formulas, and satisfaction needs no new definition. A valuation satisfies a clause when it makes one of its literals true, and a clause set when it satisfies every clause in it. So nothing satisfies the empty clause, which has no literal to make true, and everything satisfies the empty clause set, which makes no demand. A clause set is the switchboard made precise: a list of demands, each of which some switch must meet.
Example 7.14 (the platform: five rules). Harriet’s platform has a hundred feature switches, each on or off, and a file of rules that the switches must obey together. Three of its switches are fast-sync, offline-mode and compression, which we write as the letters , and , and five rules in the file concern them.
fast-syncneedsoffline-mode, since a fast sync resumes from the offline cache.offline-modeneedsfast-sync, since the cache is filled by fast syncs.The mobile app needs
fast-syncoroffline-mode; with neither it cannot work at all.With both
fast-syncandoffline-modeon,compressionmust be on, or the sync saturates the link.With both
fast-syncandoffline-modeon,compressionmust be off, since the offline cache cannot read compressed packets.
As clauses, with the pattern each forbids beside it:
The clause set asks whether some setting of , and avoids all five patterns. None does: the first three rules force fast sync and offline mode both on, and then rules 4 and 5 contradict each other. The file has a bug, and Example 7.29 shows DPLL finding it. With a hundred switches there are far too many settings to try, and Section 7.3 answers such questions without trying them all.
Converting to clauses
How is a constraint that is not a clause turned into a clause set? Its truth table would do it, one clause for each row with F, but a constraint on thirty letters has a billion rows. The conversion has to work on the formula itself, and it goes in two steps.
Move every negation inwards until it sits on a letter, and remove the arrows, so that only and stand above the literals.
Rearrange the s and s so that every sits below every . The conjuncts are then the clauses.
Step 1: negation normal form
The laws that move a negation inwards are De Morgan’s laws, together with double negation and the truth table of the arrow:1
Each says that its two sides are equivalent, as a truth table of four rows, or two, confirms. Since is a congruence, a law may be applied to any part of a formula, not only to the whole.
Definition 7.15 (negation normal form). A formula is in negation normal form when its only connectives are and , with negation allowed on letters.
Formally, a formula is in negation normal form if it is built from literals, and by and alone.
For instance, is in negation normal form, and and are not.
The translation applies the laws above wherever they fit, from the outside in, until every negation has reached a letter. Written as a function, each law becomes one equation.
Definition 7.16 (the translation into negation normal form). The translation removes the arrows and pushes every negation down to the letters.
Formally, for a formula , the formula is defined by recursion on the size of , by the equations
In words: leave a literal alone; pass through and ; replace an arrow by a disjunction; and when a negation stands over a compound formula, apply the law for that connective and carry on. Exactly one equation applies to each formula, since a negation is followed by a letter, , or one of the four connectives. The recursion is on size, not shape. An equation may call on , which is not a part of ; but is always smaller than , so the recursion ends.
Lemma 7.17 (negation normal form is faithful). For every formula , the formula is in negation normal form, and .
Proof. By induction on the size of , one case for each equation of the definition.
The first equation. A literal, and are in negation normal form already.
, . By the induction hypothesis for the two parts, since is a congruence.
The other five equations. Each replaces by the right-hand side of one of the laws above, and the induction hypothesis applies to the smaller formulas on that side. For instance, for ,
That the result is in negation normal form is read off the definition: every equation builds with and from results of , or returns a literal, or . □
Step 2: multiplying out
A formula in negation normal form is built from literals by and in any order. A clause set, read as a conjunction, has all its s below all its s. What remains is to move the s down, and one more law of the Boolean algebra does it, distributivity:
It is the law of school algebra that multiplies out brackets, , with for times and for plus. Two conjunctions of clauses multiply out in the same way, every clause of one against every clause of the other, as :
Lemma 7.18 (multiplying out). For clause sets and , read as conjunctions,
Here is the clause whose literals are those of together with those of , the set .
Proof. Fix a valuation . The right-hand side is false under exactly when some clause in it is false, that is, when some and some are both false. That says that is false and is false, which is exactly when the left-hand side is false. □
The second step applies the lemma from the inside out, one equation for each way a formula in negation normal form can be built.
Definition 7.19 (clause form). The clause form of a formula in negation normal form is the clause set obtained by multiplying out every over every .
Formally, for a formula in negation normal form, the clause set is defined by recursion on the shape of , by the equations
The clause form of an arbitrary formula is , and the clause form of a finite set of formulas is the union of the clause forms of its members.
In words: a conjunction pools the clauses of its two sides, and a disjunction joins every clause of one side to every clause of the other; the empty clause is satisfied by nothing, and the empty clause set by everything.
Proposition 7.20 (the clause form is equivalent). For every formula , .
Proof. By the lemma that negation normal form is faithful, it is enough to show that for every in negation normal form. We do so by induction on the shape of , one case for each equation.
The first three equations. The clause set is itself, read as a conjunction.
. By the induction hypothesis, since a conjunction of two clause sets is their union.
. The induction hypothesis gives , and the lemma on multiplying out gives the rest.
□
Example 7.21 (a clause form, step by step). Take the constraint . Step 1 gives
Step 2 works from the inside out:
The two clauses forbid exactly the settings that make false, off with off and on with off, as a truth table confirms.
The last equation of the definition of has a cost: the clause form of has one clause for every pair of a clause from one side and a clause from the other, so the counts multiply. The formula
has letters, and its clause form has clauses, one for each way of choosing a or a from every pair. For that is a billion clauses, for a constraint that fits on one line.
Remark 7.22 (at work: Tseitin’s translation). Solvers avoid the blow-up by giving up equivalence. Each compound subformula of the input gets a new letter , together with at most three clauses saying what the letter means. For , with letters and for the two parts, the clauses
say that is on exactly when and both are; the other connectives are alike. One more clause, the unit clause , says that the whole formula holds. For that gives ten clauses, and for pairs rather than . The result mentions letters that does not, so it is not equivalent to , but it is equisatisfiable with , and it comes with a way back: a valuation that satisfies it, with the new letters forgotten, satisfies (Exercise 7.3).2
Look back at what the two steps do. They take constraints written the way people write them, with arrows, negations over compound formulas and connectives nested at will, and turn them, by rules that a program can follow, into a clause set. The clause set may be bigger, much bigger, but it is flat, and it says outright which switches must be on and which off. A search for a setting can work with it directly. The rewriting is tedious by hand and easy to get wrong; for a computer it is a few dozen lines of code.
From here on, a constraint without quantifiers is a clause set, and a formula that is a conjunction of clauses is said to be in conjunctive normal form.
7.3 DPLL
Here is where the propositional problem stands. Take a finite set of formulas and a formula , and let be the clause form of . By the reduction lemma, read with valuations for structures (a structure for a signature of letters amounts to a valuation), and the proposition that the clause form is equivalent,
So the whole task is this: find a valuation with , or show that there is none. A valuation that is found is the propositional counterpart of a counter-model: a setting of the switches under which holds and fails; a proof that there is none is a proof that .
The idea is to grow by an algorithm, a letter at a time, letting the clauses decide each letter wherever they can, and guessing only where they cannot. Everything in the section serves that idea: partial valuations are what a valuation looks like while it is being grown, and extension is what growing means.
Truth tables
The first method needs no thought. A clause set over letters has rows in its truth table; try them all, and check each clause against each row. That is correct, complete and hopeless: ten letters are a thousand rows, and a hundred letters are more rows than there are stars in the observable universe. The clause sets that solvers meet in practice have millions of letters. A search by hand does something better. It never writes down a whole row: it fixes one switch at a time, and lets the clauses say, wherever they can, what the next switch has to be.
Partial valuations
A valuation that is being grown is, until the end, only part of a valuation. Only the letters that occur in matter, since two valuations that agree on them satisfy the same clauses, and halfway through the search some of those letters have a value and the rest have none yet. That is a function defined on some letters and not on others: a partial function.
Definition 7.23 (partial valuation). A partial valuation gives some letters a truth value and leaves the rest undecided.
Formally, a partial valuation is a partial function
that is defined on finitely many letters. A letter is decided by if is defined, and undecided otherwise. The partial valuation is extended to literals by
and is undefined otherwise. We write
In words: a partial valuation is a row of the truth table with some entries still blank, and says that the row already makes true. For a literal whose letter decides, exactly one of and holds; for any other literal, neither does.
A search fills in blanks and never rubs anything out. Each step keeps what was decided before and decides more, and the search ends at a valuation that agrees with everything decided along the way.
Definition 7.24 (extension). One partial valuation extends another when it keeps everything the other has decided and may decide more; a valuation extends a partial valuation when it fills in all the blanks.
Formally, let be a partial valuation, and a partial valuation or a valuation. Then extends , written
if for every letter decided by .
In words: says that is with some blanks filled in, and , for a valuation , that is one way of finishing . Three facts follow at once.
Extension is transitive: if and , then .
What makes true, every extension makes true: if and , then .
The partial valuation that decides nothing is extended by everything.
So a search starts from the partial valuation that decides nothing and extends it, one letter at a time, until it reaches a partial valuation that settles the question.
Representing a partial valuation
So much for what the search does; now for how. The first question is how to write a partial valuation down, and the answer is: as a set of literals, the ones it makes true. If , the literal is true under ; if , the literal is; and if is undecided, neither is. So we write as the set of those literals,
Conversely, a finite set of literals that contains no letter together with its negation is a partial valuation: the one that makes those literals true and decides nothing else. For instance, has
and for every other letter , neither nor . The partial valuation that decides nothing is the empty set .
In this notation the definitions become set membership. A partial valuation makes a literal true when the literal is in the set, and extending a partial valuation is literally adding to the set:
for partial valuations and . A valuation extends exactly when for every . When does not decide the letter of a literal , the set is again a partial valuation, the extension of that makes true as well. That is the one step a search ever takes.
The status of a clause
A clause set is like a set menu. Each clause is a course, and its literals are the dishes on offer; a satisfying valuation orders at least one dish from every course. The catch is that dishes clash in pairs: a valuation that orders has thereby refused , wherever appears on the menu. A partial valuation is an order half taken. Some dishes have been ordered, and each order rules out the dish it clashes with, so on any one course some dishes are ordered, some ruled out, and some still open. Three patterns matter: a dish from the course is already ordered; every dish on it has been ruled out; or every dish but one has been ruled out, and the last one has to be ordered.
Definition 7.25 (the status of a clause). Under a partial valuation a clause may already be satisfied, already be falsified, or be left with exactly one way to be satisfied.
Formally, let be a partial valuation. A clause is
satisfied under , written , if for some ;
falsified under if for every ;
a unit under , with undecided literal , if , the letter of is undecided by , and for every other literal .
For a clause set , we write if for every .
For instance, under :
A clause has at most one of the three statuses, since a satisfied clause has a literal in and the other two have none, and a unit has an undecided letter and a falsified clause has none. The empty clause has no literals, so “for every ” holds of anything: the empty clause is falsified under every partial valuation, included.
The point of the three statuses is what they say about the valuations with , which are the valuations the search might still end at.
Lemma 7.26 (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. Since , every literal true under is true under . And exactly when for some .
(i). Some has , so .
(ii). Every has , so , that is, . No literal of is true under .
(iii). Every literal of other than has , so . The only literal of that can make true 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 to fill one blank.
Unit propagation
Part (iii) of the lemma is the step a search by hand takes whenever a constraint leaves only one option. Suppose some clause is a unit under with undecided literal . Then
since gives . Replacing by therefore loses none of the valuations we are looking for. The move is forced: it needs no guess.
Unit propagation is the forced move made again and again, for as long as some clause of is a unit and none is falsified. Each move can turn other clauses into units, and on a good day the forced moves run on until the search is over without a single guess.
Decisions
Propagation stops when no clause of is a unit, or when one is falsified. If some clause is falsified, then by part (ii) of the lemma no with has , and is a dead end. If , then by part (i) every with has , and the search is over. Otherwise the clauses force nothing, and a guess is needed. Pick a letter of that does not decide, and try
if that leads only to dead ends, try
Every with makes true or false, so
Between them the two tries lose nothing. This choice of a letter is a decision.
Chains of extensions
Put together, the search builds a chain of partial valuations, each extending the one before by a single literal:
Each step of the chain is forced by a clause that is a unit or is a decision. The chain stops in one of two ways.
. Then for every with , and the search has found what it wanted.
Some clause is falsified under . Then no with satisfies . The search backs up to the last decision and starts a new chain from there, with the other side of it.
Every link keeps what came before: by transitivity, a valuation with extends every in the chain. Example 7.29 draws the chains of one search, growing down the page and forking at a decision. So the job of the search is to build, by machine, a chain of extensions that ends at a partial valuation under which every clause is satisfied, or to show that every such chain dies. A forced step loses no valuation that satisfies , and a decision loses none either, as long as the other side is tried when this one dies.
Propagation, decisions, 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 first wrote it down, in two papers two years apart.3
The procedure
In pseudocode, with a finite list of clauses and a partial valuation written as its set of literals:
procedure DPLL(S)
return SEARCH(S, {}) -- u decides nothing yet
procedure SEARCH(S, u)
u := PROPAGATE(S, u)
if some clause of S is falsified under u: return CLOSED
if every clause of S is satisfied under u: return OPEN(u)
p := a letter of S that u does not decide -- any such letter will do
r := SEARCH(S, u + {p})
if r is OPEN(u'): return r
return SEARCH(S, u + {not p})
procedure PROPAGATE(S, u)
while no clause of S is falsified under u, and some clause C of S
is a unit under u, with undecided literal l:
u := u + {l}
return u
In the code, l is a literal , not p is , and u + {l} is .
Each test in the code is one line of the definition of the status of a clause, and a computer checks it by looking up the literals of the clause in . The procedure answers CLOSED or OPEN(u). When it answers OPEN(u), we have , so by part (i) of the lemma for every with ; letters that leaves undecided may be set either way. That CLOSED is right, and that the procedure always stops, takes more work, and for that we record a run of the procedure as a tree.
DPLL trees
A run starts from the partial valuation that decides nothing, adds a literal at each forced move, and forks at each decision. Drawn out, it is a tree, drawn from the root down: each node carries the literal a step added, and each branch, read from the root, lists the literals added along it. Four rules say what may be written at the foot of a branch, and Figure 7.2 sets them out. Each is read as a rule: when what is above the bar holds of a branch, what is below it may be written under the branch, and a vertical bar forks the branch in two.
Definition 7.27 (DPLL tree). A DPLL tree is a tree of literals grown from the root by the rules of Figure 7.2.
Formally, let be a clause set. A DPLL tree for is a finite tree whose root carries no literal and whose other nodes are labelled by literals, obtained from the root alone by applying the rules unit and decide, each at the foot of a branch on which no clause of is falsified. For a branch , the partial valuation of the branch is the set of the literals on , and a clause is satisfied, falsified or a unit on if it is so under .
Each rule adds a literal whose letter the branch does not yet decide, so never contains a letter together with its negation, and it is a partial valuation, and each branch, read from the root, is one of the chains of extensions of the search. The rules close and finish add no literal: they mark the foot of a branch with or , and nothing is written below a mark.
Definition 7.28 (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, let be a DPLL tree for a clause set . A branch of is
closed if some clause of is falsified on ;
open if it is not closed;
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.
A run of the procedure builds a DPLL tree. Each call of SEARCH works on one branch: PROPAGATE applies the rule unit, the two recursive calls apply decide, CLOSED is returned exactly when close applies, and OPEN exactly when finish does. A tree does not say in what order the clauses were looked at, or which letter was decided on. Every choice gives a DPLL tree, and the results below hold for all of them.
Example 7.29 (the platform, cont’d: the switches that follow). Harriet runs the search on the five rules of Example 7.14. No clause is a unit at the start, since each has at least two literals, so she decides , trying it on first. The root carries the clause set. Beside each other node is the rule that wrote it: d for a decision, and the clause for a forced move. A closed branch ends in a cross, with the clause it falsifies.
In list form:
nodes 1 and 2 are the decision on ;
under , the clause is a unit and forces (node 3); under , the clause is a unit and forces (node 4); and under the clause is falsified;
under , the clause forces (node 5), and under the clause is falsified.
Both branches close, so the tree is closed: five nodes, one decision and two dead branches, against the eight rows of the truth table.
Choosing the letter
The one choice the procedure leaves open is which letter to decide on, the branching heuristic, and much of the engineering of a solver lies in choosing well. Take the clause set
Deciding first, and trying it on, forces , and by the first three clauses, and every clause is satisfied: one decision. Deciding , or first forces nothing, and a second decision is needed before the search ends. A common rule of thumb is to decide a letter that occurs in many short clauses, so that the decision forces as much as possible on both sides. Which side to try first is a choice too, and solvers make it by a second heuristic. Nothing in this chapter depends on the choice, since the results below hold for every order; what depends on it is the size of the tree.4
Correctness
Three things need checking: that the search stops, that a closed tree is never wrong, and that an unsatisfiable clause set always produces one.
Lemma 7.30 (termination). Let be a clause set with letters.
No branch of a DPLL tree for has more than nodes below the root.
There is a complete DPLL tree for .
stops.
Proof. One part at a time.
(i). A decide step and a unit step each add to a branch a literal whose letter the branch does not yet decide, and has only letters.
(ii). Start from the root, apply a step to a branch that is not complete, and repeat. A tree in which every node has at most two children and, by (i), every branch at most nodes below the root has fewer than nodes, and each step adds a node, so this stops. When it stops the tree is complete: a branch that is neither closed nor finished has a clause that is neither satisfied nor falsified, and so a literal whose letter does not decide, and that letter can be decided.
(iii). Each step of
PROPAGATEand each recursive call ofSEARCHadds a literal on an undecided letter of , so each call makes at most steps of propagation and the recursion is at most deep.
□
Theorem 7.31 (soundness of DPLL). If a clause set is satisfiable, then no DPLL tree for is closed.
Proof. Let . Call a branch faithful to if . We show, by induction on the construction of the tree, that every DPLL tree for has a faithful branch.
Start. The root alone is faithful, since its partial valuation is , and .
Decide, on a faithful branch . The valuation makes true or false, so or , and one of the two new branches is faithful.
Unit, on a faithful branch . The clause is a unit on with undecided literal , and , so by part (iii) of the lemma on the status of a clause. Hence , and the branch with added is faithful.
A step on another branch. It leaves the faithful branch as it was.
A faithful branch is open: if a clause were falsified on it, then by part (ii) of the lemma for that clause . So no DPLL tree for is closed. □
In words: a closed DPLL tree is a certificate that no valuation satisfies .
Proposition 7.32 (finished branches). Let be a finished branch of a DPLL tree for . Then for every valuation with .
Proof. The branch is finished, so for every , and part (i) of the lemma on the status of a clause gives . □
Theorem 7.33 (completeness of DPLL). If a clause set is unsatisfiable, then every complete DPLL tree for is closed.
Proof. Suppose a complete DPLL tree for has an open branch . Being complete and open, is finished. By the proposition on finished branches, for every with , and there is such a : give every letter that does not decide the value . So is satisfiable. □
In words: when no valuation satisfies , every search carried to the end produces the certificate.
Theorem 7.34 (correctness of DPLL). For every clause set , the procedure stops, and
it returns
CLOSEDif and only if is unsatisfiable;when it returns
OPEN(u), for every valuation with .
Proof. It stops by termination, and it returns one of two answers.
It returns
OPEN(u). Then , so for every with , by part (i) of the lemma on the status of a clause; in particular is satisfiable.It returns
CLOSED. The branches it built form a DPLL tree for , every one of them closed, so by soundness is unsatisfiable.
So it returns CLOSED exactly when is unsatisfiable. □
The proof did not use completeness, which says more: when is unsatisfiable, every search closes, however its choices go.
Remark 7.35 (looking back: the truth lemma). The proof of soundness followed a single valuation down the tree, and the proof of completeness read a valuation off a branch. That reading is the truth lemma of the completeness proof in Chapter 6, shrunk to one sentence.
Example 7.36 (the platform, cont’d: a setting). The colleague who wrote the rules looks at Harriet’s closed tree and says that the second rule is wrong: fast syncs fill the cache when there are any, but offline-mode does not need fast-sync. Harriet strikes out and runs the procedure on .
Nothing is forced, so the procedure decides . On the side, forces , forces , and is falsified. On the side, forces , and satisfies all four clauses: , and because , and because . The procedure returns OPEN with : fast-sync off, offline-mode on, and compression as you please. Four lines check the four rules against that setting, and Harriet ships it.
Easy to check, hard to find
Both answers of the procedure come with evidence that anyone can check without trusting the solver. The answer OPEN(u) comes with , and checking it means finding, in each clause, a literal of : one bit per letter, and one reading of each clause. The answer CLOSED comes with the tree, and checking it means checking each node against the rules of Figure 7.2; that needs no cleverness, but it costs as much as the tree is big, and the tree can be exponential. For some clause sets it must be: the optional Section 7.8 shows that for the pigeonhole sets, which say that pigeons do not fit into holes, every closed tree is exponential in . A search that does not know in advance which answer it will give may have to build most of such a tree before it can give either. The gap between checking an answer and finding one is not a fault of the method but the shape of the problem itself.
Deciding whether a clause set is satisfiable is the problem called sat, the first problem shown to be NP-complete.5 That means two things. Its “yes” answers can be checked quickly, by the certificate for OPEN. And every problem whose “yes” answers come with evidence that can be checked quickly can be turned, quickly, into an instance of sat, so a fast method for sat would be a fast method for all of them. (“Quickly” means in a number of steps bounded by a polynomial in the size of the input, such as its square or its cube.)
The problems whose “yes” answers can be checked quickly form the class NP, and those that can be decided quickly the class P. Whether a fast method for sat exists is the question whether , and nobody knows.
What is known is that the problem is decided, by the procedure of this chapter; that the solvers built on it settle instances with millions of switches; and that no method is known to be fast on every instance, nor is one known to be impossible.
Remark 7.37 (SAT and SMT). Many questions about programs and hardware are about numbers, arrays and bit-strings, and an atomic formula such as is true or false according to the values of and , not by a switch of its own. An SMT solver, for satisfiability modulo theories, pushes such questions down to sat. It reads each atomic formula as a letter and runs DPLL; whenever the search has set some atomic formulas true and others false, it asks a decision procedure for the theory (arithmetic, arrays, equality between terms) whether that combination can hold together, and if it cannot, as with and both on, the reason is added as a new clause. The engine is the procedure of this section.
7.4 From Sentences to Clauses
The simpler problem is solved. A question without quantifiers becomes a clause set, and DPLL decides whether some valuation satisfies it. Now for the problem we actually have. The constraints of a real question say “every” and “some”, and no setting of finitely many switches says either. The reduction of , quantifiers and all, to sat problems takes 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.5). The instances go to
DPLLlevel by level (Section 7.6).
The first two moves are routine rewriting, and this section treats them as a black box: it says what goes in, what comes out, and what is guaranteed. The optional Section 7.7 opens the box. The third move is where the work 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.38 (a second route: SMT). There is a second way to bring a first-order question to a SAT solver. An SMT solver (Remark 7.37) keeps the quantifiers and deals with them on the side, adding instances of the universal sentences to its propositional problem as the search goes. The route of this chapter removes the quantifiers first, and then proves that instances are enough. The two routes meet in Section 7.6.
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.39 (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.40 (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.2, where is the valuation that gives each atomic sentence its truth value in .
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.41 (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, (i), and the evidence comes back with it, (ii). It does not keep the meaning, since it speaks of symbols that does not have: and are equisatisfiable, not 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.7 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.42 (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 and the theorem on the clause form,
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.43 (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, by the equality axioms, which Definition 6.36 states for any signature, 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.10 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.5 Herbrand’s Theorem
Two moves of the reduction are made: the question has become whether a set of clauses with variables in them, all universal, is unsatisfiable. What is left is the third move, the universals. A clause with a variable speaks of every element of every structure (five people, the natural numbers, the real line), and a solver cannot look at every structure. It need not. A search by hand looks only at the things it can name, starting from the names it has, and this section proves that it is right to, 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 of the clauses. A clause set comes over some signature, and that signature may have symbols the clauses never use (the clauses of Example 7.42 mention neither nor ). A search should name things only through the symbols its clauses use, so this section works over the signature of the clauses themselves. Nothing is lost by doing so. Symbols that a clause set does not mention make no difference to whether it is satisfiable: a structure for the larger signature can be restricted to the smaller one, and a structure for the smaller one can be expanded by giving the other symbols any meaning.
Definition 7.44 (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 there because a signature with no constant names nothing, and a set of names that is to serve as the domain of a structure must not be empty. A structure for a larger signature satisfies exactly when its restriction does, the added constant, if any, being given some element to name.
Definition 7.45 (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.46 (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 .
The universe grows level by level, and it is worth seeing how fast. Figure 7.3 draws it for a clause set with a constant and two one-place function symbols and . Each level holds twice as many terms as the level below, so the picture is a pyramid standing on its point, and is everything from the point up to level . Every is finite, and each contains the one before:
and together they make up the whole universe, which is infinite. A search that works through the universe must therefore do so one level at a time, and that is how the first-order procedure of Section 7.6 works through it.
Definition 7.47 (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.48 (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. A Herbrand structure is therefore nothing more than a choice of true or false for each atomic sentence of the base; that is, a Herbrand structure is a valuation of the Herbrand base: a setting of the switches, one switch for each atomic sentence about the names. A search for a Herbrand model is therefore a search for a setting.
Remark 7.49 (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.50 (the company, cont’d: the names of the policy). The clause set of Example 7.42 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.51 (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.52 (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.53 (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.54 (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.55 (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.
Example 7.56 (the company, cont’d: the ground instances of the policy). For the four clauses of Example 7.42, has four clauses, the two rules instantiated at and the two units; has six:
Lemma 7.57 (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.58 (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 , where by the paragraph after the definition of we may take to be a -structure, and 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 it makes true and forget everything else; what is left is a structure made of names that satisfies it too. The proof is short because it uses only the quantifier clauses of the definition of satisfaction, the substitution lemma, and the fact that in a structure made of names every element has one.
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 that has not yet been named.
Lemma 7.59 (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.60 (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 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. By compactness 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.61 (the company, cont’d: six clauses). No valuation satisfies , the six clauses of Example 7.56, and unit propagation alone shows it. The unit must be true, so by the first clause must be; the unit must be true; and now the clause has both its literals false. 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 is unsatisfiable, so by the reduction lemma and the theorem on the clause form, .
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 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 every is satisfiable, and so is the set; for another set, every up to some large may be satisfiable and the next one not. 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.62 (equality in a Herbrand structure). When is among the symbols and the equality clauses of Remark 7.43 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.6 A Procedure for First-Order Logic
All three moves are made, and what is left is to run them. DPLL decides one finite clause set, and a first-order clause set has infinitely many ground instances. By Herbrand’s theorem, a clause set with variables is unsatisfiable exactly when some is, and is a finite clause set over finitely many letters, the atomic sentences that occur in it: just what DPLL decides. So:
procedure REFUTE(S) -- S a clause set, possibly with variables
k := 0
loop:
if DPLL(GROUND(S, k)) = CLOSED: return UNSAT -- the instances at level k
k := k + 1
The procedure has no other exit, and that is not an oversight.
Theorem 7.63 (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, and by the correctness of DPLL the call returns CLOSED at the latest at that , each earlier call having stopped by termination. If is satisfiable, some Herbrand structure satisfies it, and satisfies every , so by soundness 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.64 (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. For first-order logic, by the reduction lemma and the clause form of a set, that is a way of certifying in finite time every entailment that holds from finitely many premisses, and nothing for one that fails.
Example 7.65 (the company, cont’d: the policy, by machine). Harriet gives the four clauses of Example 7.42 to REFUTE. At level the four ground clauses of Example 7.61 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 |
When returns OPEN, it has found a setting of the atomic sentences that occur in the instances at level , one that obeys those instances. That valuation satisfies and nothing more. It does not satisfy , whose instances at level the search has not seen (in Example 7.61 the instances at level are satisfiable, and the clash comes one level up). The verdict OPEN at a level is not a verdict about , and REFUTE rightly ignores it. Here the question raised after Herbrand’s theorem returns: can any finite amount of work certify that a clause set is satisfiable? For this procedure the answer is no: no finite level of the instances certifies satisfiability, and the loop does not try to. 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; and then the two literals never clash, at any level. Adding the instances that unification picks out before grounding 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.8 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.9 carries the encoding out.
Example 7.66 (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.67 (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
A million switches is still a finite list, and that is the only reason every DPLL run stops: each branch ends when the switches run out, and once a question is cast as a finite clause set it is decided, however long the deciding takes. The first-order procedure has no such bound. It stops when the instances clash and only then, and whether they ever will is exactly the question being asked. A cleverer order of instances would not help: on some questions no instances ever clash, whatever the order, although a small counter-model exists. The clause set is one. A ground instance of the first clause has the shape and one of the second the shape , 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 , and 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.68 and 7.69 read both questions in the company).
Example 7.68 (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.69 (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.
The first-order procedure is a semi-decision procedure, then, and this chapter cannot say whether that is the best that can be done. The chapter’s own improvements were found by looking at where a method wasted its work, and each was real. 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; equality multiplies the instances further; unification tames the second and nothing tames the first.
7.7 Prenex and Skolem Form (optional)
This section and the next are optional: the main line uses some of the results proved in them, but none of the proofs. This one opens the box of Section 7.4: it gives the algorithm behind the theorem on the clause form, and proves the theorem.
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 deals with the second difficulty first, and then with the first. Here is a connective in its own right, as in Section 7.2, and abbreviates .
Negations first
As in Section 7.4, 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.2 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. The two of substance 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
that takes some looking. In a formula whose quantifiers all stand at the front it is read off the row: the universal variables that depends on are those to its left.
Definition 7.70 (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.
In words: a prenex formula is a row of quantifiers followed by a formula with none. 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.71 (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.11. 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, and the remedy is to rename the bound variable first: and are true under the same assignments when is a new variable, by the substitution lemma, and likewise for .
Example 7.72 (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. As a function: in the equations for and , the parts are first put into prenex form, and then renamed, each bound variable of one that occurs in the other being 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.73 (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.77 shows that the choice can matter.
Lemma 7.74 (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 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.75 (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.76 (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 capture nothing, and it captures nothing as long as no variable is bound twice in the prefix: 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.77 (the company, cont’d: Skolem forms). The Skolem form of from Example 7.75 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.75 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 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.78 (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 for the verdict, and the direction that matters for the evidence is a derivation.
Derivations are what this chapter set out to avoid, because they are hard to find, and here one does half of the theorem in three lines. That half supplies the way back that a rewriting must come with: a structure that satisfies the Skolem form, with the new symbols forgotten, satisfies the original sentence. The other half needs a choice, one witness for each , which no derivation makes for us.6
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.2, 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.4.
Definition 7.79 (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, and the theorem can now be proved.
Proof of Theorem 7.41. 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, 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.80 (at work: how provers clausify). The clause form of a sentence can blow up for the reason of Section 7.2, 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.7 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.8 Resolution and Unification (optional)
Like the last section, this one is optional. It says what a solver’s “no” is worth, how long a search must sometimes take, and how the first-order procedure of Section 7.6 can choose its instances instead of listing them. The main line quotes three of its results, but uses none of their proofs: the long pigeonhole refutations (Section 7.3), unification (Section 7.6), and the first-order procedure with unification (Chapter 8).
When the procedure closes a branch, it has found a clause falsified there. The literals on the branch form a partial valuation, and the clause says that this setting is forbidden. But the clause is not all that 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.29 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.81 (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.82 (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.83 (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.84 (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.85 (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 . □
In words: a resolution refutation is a certificate of unsatisfiability, and it is 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
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.86 (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.87 (the platform, cont’d: the reason, written down). Harriet labels the closed tree of Example 7.29. 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.8 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 .9 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.10
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, 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. A clause added in this way is a learned clause. 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.88 (the platform, cont’d: the same lemma, many times). Harriet’s rule file has the five clauses of Example 7.14, 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.29 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.87, 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 . Once is in the file, unit propagation forces it on every later branch, forces , and is falsified; the second closed branch gives the label , and and resolve to . The search is over after 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.
The method is called 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.6: 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.
Definition 7.89 (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.90 (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, which nothing in the equation asked for. A unifier that makes no such decision is the one to compute.
Definition 7.91 (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.92 (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.93 (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.94 (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.95 (the company, cont’d: two equations). Harriet runs the procedure on the equation :
No rule applies, and the set is in solved form: the most general unifier is . 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.96 (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 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 there is none.
Example 7.97 (the company, cont’d: four instances, none listed). Harriet looks for clashes among the four clauses of Example 7.42, 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.61, 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 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)) = CLOSED: 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.98 (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. By the lemma that Herbrand models suffice some Herbrand structure satisfies it, and satisfies , hence every . 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, 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.99 (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.97, 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.56, and DPLL closes them by three forced moves, without a decision. Plain REFUTE needed level .
The finance director’s question of Chapter 6 closes at level too, with ground clauses, where plain REFUTE needs level and clauses (Exercise 7.10). 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.100 (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.11 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.12 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.13 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 saw in the same year that the instances worth trying could be found by solving equations between terms instead of listing them.14 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. The chapter first solved a simpler problem, the propositional one. A constraint without quantifiers becomes a clause set, by moving negations inwards and multiplying out, and a clause set is decided by DPLL: set the switches that a clause forces, decide one that nothing forces, and give up on a branch as soon as it breaks a constraint. DPLL is sound, complete and always stops. 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. The first 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.8 to 7.10 are about Herbrand’s theorem and the procedure for first-order logic;
Exercises 7.11 to 7.18 go with the two optional sections, and are optional too.
Exercise 7.1. Prove part (iii) of the reduction lemma: two sentences and are true in the same structures if and only if is unsatisfiable.
Exercise 7.2. Turn each constraint into a clause set 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 empty clause set satisfied by every valuation?
Exercise 7.3. This exercise works out Tseitin’s translation, sketched in Remark 7.22. 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. Prove that the pure-literal rule is sound: if a letter that the partial valuation does not decide occurs only positively in the clauses with , and for some valuation with , then for some valuation with . Then give a clause set , a partial valuation under which the rule applies, and a valuation with , and .
Exercise 7.7. 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.8. 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.9. 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.6 describes, and run DPLL on it. Then do the same with two elements for the clause set , , and read off the structure.
Exercise 7.10. 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.43.
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.11. (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.12. (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.13. (Optional.) Write out the derivation of the sentence from its Skolem form , and check the side conditions of the two (I) steps.
Exercise 7.14. (Optional.) Run the unification procedure on each equation, writing the set of equations after every rule as in Example 7.95, and give the most general unifier or say which rule fails. Here and are constants, and function symbols and a relation symbol.
;
;
;
.
Exercise 7.15. (Optional.) Take the clause set of Exercise 7.8: , 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.16. (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.17. (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.18. (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.
- 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 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 first of the two papers had a further rule, which solvers still use when they prepare their input. If a letter that the branch has not decided occurs in the clauses not yet satisfied with one sign only, say as and never as , then may be set true without a decision: no clause can be falsified by it. Such a literal is pure, and the rule is sound (Exercise 7.6). The trees here leave it out, since it would add a case to every proof and saves only a side of a decision that could never find a valuation the other side missed. ↩
By Cook (1971), and independently by Levin (1973). ↩
When the domain is infinite the choosing is an application of the axiom of choice. Part (ii) is the direction the chapter relies on: it is what makes a refutation of the Skolem form a refutation of the original sentence. ↩
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. ↩