Lecture 8 · Resolution and Unification II; First-Order Theories

Introduction to Automated Reasoning · Lecture 08。个人学习讲义与配套实验,按主题整理并持续修订。

课程源码 ZIP ↓

个人整理的学习笔记,非官方讲义;课程来源与整理说明见课程介绍。配套示例未逐一运行验证。

本篇目录

Maps to: Stanford CS 257 Introduction to Automated Reasoning (Winter 2026), Lecture 8 · Thu 01/29/2026 · FOL: resolution, unification II, first-order theories (Hanna Lachnitt). Homework 2 due, Homework 3 released. Reading: Bradley & Manna (CC) Chapter 2 (resolution) and §3.1 (first-order theories). Basis: The Stanford slides are on Canvas and not public. This lecture follows two public Iowa decks (CS:4980, Cesare Tinelli, Spring 2024), which say they are adapted from slides by Clark Barrett, Caroline Trippel and Andrew (Haoze) Wu (Stanford):

  • the end of Proof systems for First-order Logic: the resolution system with INST, refutational completeness, non-termination, the need for equality and theories;
  • the first half of Satisfiability Modulo Theories: first-order theories, T-interpretations, T-satisfiability and T-validity, axiomatic theories, completeness and decidability, the common SMT theories.

“The slides” below means those decks. These notes add:

  • a resolution prover with factoring, the given-clause loop, subsumption, the set-of-support strategy, hyperresolution and equality axioms;
  • checkable proofs;
  • Herbrand’s theorem in action (ground instances + CDCL);
  • the lifting lemma checked on random clauses;
  • Pelletier’s problems against Lecture 7’s tableau;
  • group theory;
  • a machine check of the slides’ clause-set examples, which finds two of them misstated;
  • axiomatic theories explored with the prover and the model finder.

The experiments and their code were designed for these notes and do not reflect what was said in class. Code: code/lecture08/ (4 scripts + 1 module; Python standard library only; from 3 to about 80 seconds each) Reading time: 3–4 hours including running the code


0. How to read this lecture

0.1 Learning goals

After this lecture you should be able to:

  1. State binary resolution and factoring for first-order clauses, apply them with unification, and say why both are needed.
  2. Explain refutational completeness through Herbrand’s theorem and the lifting lemma.
  3. Describe the given-clause algorithm, its fairness, and the roles of clause selection, subsumption, the set of support and hyperresolution.
  4. Read and check a resolution proof.
  5. Explain why equality needs special treatment, and what paramodulation and superposition do.
  6. Explain why resolution is a semi-decision procedure, and what a prover and a model finder can do together.
  7. Define a first-order theory, T-satisfiability and T-validity, axiomatic theories, and complete and decidable theories.

0.2 Prerequisites and scope

AssumedIntroduced hereDeveloped later
clausal form, unification, model finding (Lecture 7)first-order resolution as a proverquantifier instantiation in SMT (Lecture 17)
ground resolution, completeness (Lecture 2)lifting, Herbrand’s theorem (preview)Herbrand’s theorem in full (Lecture 17)
CDCL and proof checking (Lecture 5)checkable FO proofs; Gilmore’s method with CDCL—
FOL semantics (Lecture 7)theories, T-validity, completenessDPLL(T), the theories of SMT (Lectures 10–18)

0.3 Map

§1  first-order resolution: rules, soundness, factoring, lifting, Herbrand              ← code 01
§2  the given-clause algorithm and checkable proofs                                       ← code 02
§3  redundancy and strategies: subsumption, set of support, hyperresolution              ← code 02
§4  equality                                                                              ← code 03
§5  semi-decidability: what a prover can and cannot do                                    ← code 04
§6  first-order theories                                                                  ← code 03
§7 summary   §8 common pitfalls   §9 exercises   §10 further reading   §11 next lecture

0.4 Notation

SymbolMeaning
C∪{L}C \cup \{L\}a clause containing literal LL; clauses are sets, and their variables are universal
σ=mgu(L,L′)\sigma = \mathrm{mgu}(L, L')the most general unifier of two atoms
CσC\sigmathe clause with σ applied; □ is the empty clause
C⪯DC \preceq DCC subsumes DD: Cσ⊆DC\sigma \subseteq D for some σ
T=⟨Σ,M⟩T = \langle \Sigma, M \ranglea theory: a signature and a class of interpretations
⊨T\models_Tentailment / validity in TT

0.5 The code of this lecture

One module, prover.py, built on Lecture 7’s clausal_form and unify. It contains:

  • normalized clauses;
  • the inference rules: binary resolution, factoring, positive hyperresolution;
  • subsumption by matching;
  • saturate, the given-clause loop, with:
    • weight / age selection;
    • forward and backward subsumption;
    • an optional set of support;
    • budgets on given, generated or kept clauses, or on seconds;
  • prove(goal, axioms), which clausifies axioms ∧ ¬goal, adds equality axioms when = occurs, and saturates;
  • proofs with check_proof, an independent step checker;
  • herbrand_refute, Gilmore’s method with Lecture 5’s CDCL.

1. First-order resolution

1.1 The rules

Lecture 7 ended with the idea of resolution for clauses with variables: unify the two clashing literals instead of guessing instances.

Binary resolution. Rename the clauses apart first (they share no variables): C∪{L}D∪{¬L′}σ=mgu(L,L′)(C∪D)σ\frac{C \cup \{L\} \qquad D \cup \{\neg L'\} \qquad \sigma = \mathrm{mgu}(L, L')}{(C \cup D)\sigma}

Factoring. C∪{L,L′}σ=mgu(L,L′)(C∪{L})σ\frac{C \cup \{L, L'\} \qquad \sigma = \mathrm{mgu}(L, L')}{(C \cup \{L\})\sigma}

The slides’ INST derivation (Lecture 7, §6) needed two hand-picked instances. The prover finds the same refutation itself in two steps (script 01):

      1. {¬P(x0), Q(x0)}                          input
      2. {P(a)}                                   input
      3. {¬Q(x0)}                                 input
      4. {Q(a)}                                   resolve 1, 2 on ¬P(x0) / P(a), σ = {x0 ← a}
      5. □                                        resolve 4, 3 on Q(a) / ¬Q(y0), σ = {y0 ← a}
  check_proof: valid: 2 inference steps from 3 input clauses

Every line records its parents, the clashing literals and the mgu. check_proof redoes each step without trusting the search, which is the same idea as DRUP for CDCL (Lecture 5).

On the slides’ second example the prover computes the slides’ resolvent. The clauses are {P(x,y),Q(a,f(y))}\{P(x, y), Q(a, f(y))\} and {¬Q(z,f(b)),R(g(z))}\{\neg Q(z, f(b)), R(g(z))\}, with zz renamed y0y_0, and the result is {P(x,b),R(g(a))}\{P(x, b), R(g(a))\}.

1.2 Soundness

If both parents hold for all values of their variables, they hold for the values σ picks. Ordinary propositional resolution then applies to the two instances. Unification only chooses instances.

Script 01 also checks this semantically. For 116 resolvents and 41 factors of random clauses, the model finder found no structure of size ≤ 3 in which the parents hold and the conclusion fails.

1.3 Factoring is needed

{P(x),P(y)}\{P(x), P(y)\} and {¬P(u),¬P(v)}\{\neg P(u), \neg P(v)\} is unsatisfiable: the first says PP holds everywhere, the second that it holds nowhere. Script 01:

rulesresultgivengeneratedproof lines
with factoringPROVED455
binary resolution onlySATURATED24–

Every binary resolvent of two 2-literal clauses has two literals again, so □ is never reached and the loop saturates. It would report “satisfiable”.

Factoring merges P(x)P(x) and P(y)P(y) into P(x)P(x), and one step gives □. Robinson’s original rule combined resolution with factoring; provers keep them as separate rules.

1.4 Completeness: Herbrand and lifting

Refutational completeness. If a clause set is unsatisfiable, resolution (with factoring) derives □. The proof has two parts.

  1. Herbrand’s theorem. An unsatisfiable clause set has a finite set of ground instances (variables replaced by terms built from the set’s own symbols) that is propositionally unsatisfiable. By Lecture 2’s completeness of ground resolution, those instances have a ground refutation. Lecture 17 develops this theorem in full.
  2. The lifting lemma. Every ground resolution step between instances Cθ1C\theta_1 and Dθ2D\theta_2 is an instance of a first-order step between (factors of) CC and DD. The ground refutation therefore lifts, step by step.

Script 01 checks the lifting lemma. It takes 892 ground resolution steps between instances (over the terms aa, f(a)f(a), f(f(a))f(f(a))) of random clauses, and finds each one subsumed by a first-order resolvent of the original clauses or their factors.

Gilmore’s method. Herbrand’s theorem alone gives a procedure (Gilmore 1960): enumerate the ground instances over a growing universe, and ask a SAT solver. Here the SAT solver is Lecture 5’s CDCL. Script 01 compares it with resolution:

problemresolutionGilmore: ground instances + CDCLinstances in the core
the slides’ INST example5 lines, 3 generatedlevel 0: 3 ground clauses3
Pelletier 183 lines, 1 generatedlevel 1: 4 ground clauses2
Pelletier 2410 lines, 9 generatedlevel 1: 96 ground clauses7
Pelletier 2633 lines, 390 generatedlevel 1: 25,825 ground clauses15
Pelletier 366 lines, 12 generatedBUDGET at level 2 (153,328 ground clauses)–

The unsatisfiable cores, found by Lecture 5’s backward proof check, are tiny: 2 to 15 instances. The enumeration that finds them grows like ∣universe∣variables per clause|\text{universe}|^{\text{variables per clause}}. Unification instead picks the useful instances directly.

Modern provers combine the two ideas. Instance-based methods and SMT quantifier instantiation (Lecture 17) generate ground instances cleverly and hand them to a SAT/SMT solver.


2. The given-clause algorithm

The slides’ resolution system says which inferences are allowed, not in which order to make them. Applying “any rule to any pair” either repeats work or misses pairs.

Provers since Otter (McCune, 1990s) use the given-clause loop:

PASSIVE := input clauses;  ACTIVE := ∅
while PASSIVE ≠ ∅:
    given := pick(PASSIVE)                     # lightest clause; every k-th pick the oldest
    if some active clause subsumes given: discard it; continue
    remove the active clauses that given subsumes
    ACTIVE := ACTIVE ∪ {given}
    for each factor of given, and each resolvent of given with an ACTIVE clause (given included):
        if it is □: PROVED
        unless it is a tautology or subsumed: add it to PASSIVE
SATURATED                                       # every inference has been made: satisfiable

What the invariant gives. All inferences among ACTIVE clauses have been made. Each pair is therefore tried exactly once.

Fairness. Every passive clause is eventually picked, thanks to the age picks; otherwise a heavy but needed clause could wait forever. Fairness together with the completeness of the rules makes the loop refutationally complete.

Selection. The weight is the number of literals first (unit preference: □ has none, and proofs are built from short clauses), then the number of symbols. Every fifth pick takes the oldest clause instead.

Budgets. A prover that has not found □ may simply not have searched long enough, so every run needs a limit. Real provers use a time limit. The scripts count work instead: the number of generated clauses (max_generated). A run that stops on its budget then prints the same numbers on every machine, and a slow machine does not look like a weaker prover.

Script 02 traces the loop on Pelletier 20, shows the proof, and checks it.

Pelletier’s problems, again. Script 02 runs Lecture 7’s 21 problems through the prover. All 21 are proved, and all 21 proofs pass check_proof. That includes P26, which the tableau could not prove within 5,000 lines.

Clausal form takes the ⇔ apart once and for all, and unification instantiates variables only when two literals actually clash. A tableau, by contrast, tries every term on every branch. Most proofs have 3–15 lines. The largest are P29 (51 lines), P26 (33 lines, from 390 generated clauses) and P43 (23 lines, from 677 generated clauses, the largest search).


3. Redundancy and strategies

A prover lives or dies by the clauses it does not generate or keep.

Tautologies (containing LL and ¬L\neg L) are deleted.

Subsumption. CC subsumes DD if Cσ⊆DC\sigma \subseteq D for some σ; for example {P(x,y)}\{P(x, y)\} subsumes {P(a,b),¬Q(c)}\{P(a, b), \neg Q(c)\}. Anything DD could contribute, CC contributes too, so DD is redundant. Subsumption is decided by matching (Lecture 7), with backtracking over literals. Deciding it is NP-complete in general, and script 03 runs into a bad case (§6.2).

  • Forward subsumption: a new clause subsumed by an active one is discarded.
  • Backward subsumption: active clauses subsumed by the given clause are removed.

Set of support (Wos, Robinson and Carson 1965). Only clauses descended from the negated goal are ever given; the axioms only serve as partners. The axioms are never resolved with each other, which is the main source of useless consequences. The strategy is complete as long as the axioms are consistent.

Positive hyperresolution (Robinson 1965). Resolve all negative literals of a clause (the nucleus) at once, each with a positive clause (an electron), under one simultaneous unifier. The result is again positive.

For Horn clauses with facts this is forward chaining: from facts it derives facts in one step, and the half-finished resolvents that bury binary resolution are never stored. Hyperresolution with factoring is refutationally complete.

What matters, measured (script 02). The problem set is the 21 Pelletier problems plus four group facts (§3.1). Every configuration gets the same budget of 3,000 generated clauses per problem:

configurationprovednot provedclauses generated (all problems)
weight + age (default)21 / 254 group facts14,078
weight only20 / 25P26, P29 + 3 group facts17,859
age only (breadth-first)18 / 25P26, P29, P43 + 4 group facts23,614
no subsumption17 / 25P26, P29, P33, P43 + 4 group facts25,972
set of support23 / 252 group facts9,033
hyperresolution25 / 25–2,034

What the table shows. With equal work, “proved” measures how well each configuration spends it.

  • Selection. The default proves all 21 Pelletier problems. Without the age picks (weight only), P26 and P29 are lost: a heavy clause that the proof needs can wait indefinitely. Breadth-first selection also loses P43.
  • Subsumption. Without it each inference is cheaper (it is the fastest binary configuration), but the prover keeps redundant clauses that generate more redundant clauses. It proves the fewest problems, four fewer than the default.
  • Set of support. The group facts defeat plain binary resolution. The set of support proves two of them.
  • Hyperresolution proves all 25 with a seventh of the default’s clauses.

3.1 Group theory: every group with x⋅x=ex \cdot x = e is commutative

In the classic relational encoding (Chang and Lee 1973), P(x,y,z)P(x, y, z) means x⋅y=zx \cdot y = z:

  • associativity as two clauses, for example ¬P(x,y,u)∨¬P(y,z,v)∨¬P(u,z,w)∨P(x,v,w)\neg P(x, y, u) \vee \neg P(y, z, v) \vee \neg P(u, z, w) \vee P(x, v, w);
  • P(e,x,x)P(e, x, x) and P(x,e,x)P(x, e, x);
  • P(x,x,e)P(x, x, e).

The assumption is P(a,b,c)P(a, b, c). Script 02:

goalbinary + set of supporthyperresolution
c⋅b=ac \cdot b = aPROVED: 42 given, 997 generatedPROVED: 11 given, 106 generated
a⋅c=ba \cdot c = bPROVED: 13 given, 162 generatedPROVED: 7 given, 39 generated
b⋅c=ab \cdot c = aPROVED: 117 given, 7,238 generatedPROVED: 12 given, 120 generated
b⋅a=cb \cdot a = c (commutativity)BUDGET: 128 given, 10,245 generatedPROVED: 14 given, 154 generated

The budget is 10,000 generated clauses per run. On the reference machine, binary resolution needs about 7 seconds for b⋅c=ab \cdot c = a and gives up on commutativity after about 12; hyperresolution proves commutativity in under 0.1 seconds.

The hyperresolution proof, checked by check_proof:

      8. {P(a, c, b)}      hyper 1, 5, 3, 6      a·c = b   (from a·b = c, a·a = e, e·b = b)
      9. {P(b, c, a)}      hyper 2, 4, 8, 5      b·c = a   (from a·c = b, b·b = e, b·e = b)
     10. {P(b, a, c)}      hyper 1, 5, 3, 9      b·a = c   (from b·c = a, b·b = e, e·c = c)
     11. □                 hyper 7, 10

Three facts, each one step through an associativity clause, give commutativity.


4. Equality

The slides end their resolution deck with clause sets that “need specialized rules for equality”, and with clause sets that are “satisfiable in FOL” but unsatisfiable in arithmetic. Script 03 checks each one, as printed and with constants:

slides’ claimas printedresolution, no = axioms+ equality axiomsmodel (built-in =)
equality{x ≐ y}, {¬y ≐ x}PROVEDPROVEDnone
equalitywith constants a, bSATURATEDPROVEDnone
arithmetic{x < y}, {y < z}, {¬x < z}PROVED–none
arithmeticwith constantsSATURATED–size 2
arithmetic{¬(x + y ≐ y + x)}SATURATEDPROVEDnone
arithmeticwith constantsSATURATEDBUDGETsize 2
arithmetic{x < x} and {¬(x + 0 ≐ x)}SATURATED– / BUDGETsize 1 / size 2

What the table shows. Clause variables are universally quantified.

  • The equality sets as printed do not need equality reasoning. {x≐y}\{x \doteq y\} says every pair is related, and {¬(y≐x)}\{\neg (y \doteq x)\} that no pair is. That is contradictory for any binary relation, so plain resolution refutes them.
  • The intended examples use constants, the Skolem constants of a negated goal such as ∀x. ∀y. (x≐y⇒y≐x)\forall x.\ \forall y.\ (x \doteq y \Rightarrow y \doteq x). Then = must mean equality: without equality reasoning resolution saturates (a wrong “satisfiable”), and with equality axioms it refutes.
  • Two of the four arithmetic sets, as printed, are not satisfiable in FOL. {x<y},{y<z},{¬x<z}\{x < y\}, \{y < z\}, \{\neg x < z\} is refuted by plain resolution. {¬(x+y≐y+x)}\{\neg(x + y \doteq y + x)\} has no model, because = is reflexive (take y=xy = x). With constants, all four are FOL-satisfiable and unsatisfiable in arithmetic, which is the slides’ point.

Equality as axioms. Equality can be added as clauses:

  • reflexivity {u≐u}\{u \doteq u\};
  • symmetry;
  • transitivity;
  • one congruence axiom per argument position of every function and predicate symbol, for example {¬a0≐b, i(a0)≐i(b)}\{\neg a_0 \doteq b,\ i(a_0) \doteq i(b)\}.

This is sound and complete, and script 03 shows how expensive it is. The equational group axioms (e⋅x=xe \cdot x = x, i(x)⋅x=ei(x) \cdot x = e, associativity) imply x⋅e=xx \cdot e = x and x⋅i(x)=ex \cdot i(x) = e. Neither is proved within the budget of 3,000 generated clauses; about 2,700 clauses are kept with binary resolution and 2,456 with hyperresolution.

Symmetry and transitivity resolve with every equation, and congruence rewrites any subterm anywhere, in both directions.

The real solution is to build equality into the inference rules.

  • Paramodulation (Robinson and Wos 1969) replaces equals by equals inside clauses.
  • Superposition (Bachmair and Ganzinger, 1990s) orders terms, so that each equation is used in one direction only, from bigger to smaller.

Provers such as E, Vampire and SPASS are built on superposition and prove these group facts in milliseconds. Our prover reaches the same theorems through the relational encoding of §3.1, which avoids = altogether.


5. Semi-decidability

The slides: the resolution system is “refutation-sound and complete”, but it “is not, and cannot be, terminating”.

SATURATED proves satisfiability, when it happens. For {P(a)},{¬P(x),Q(x)},{¬Q(b)}\{P(a)\}, \{\neg P(x), Q(x)\}, \{\neg Q(b)\} the loop saturates after 5 given clauses. Every derivable clause is derived and □ is not among them, so the set is satisfiable.

Infinite saturation. For {P(a)},{¬P(x),P(f(x))}\{P(a)\}, \{\neg P(x), P(f(x))\} (script 04):

given clauses allowed10204080
clauses kept30873241,388

The prover keeps deriving P(f(a)),P(f(f(a))),…P(f(a)), P(f(f(a))), \dots and longer chains ¬P(x)∨P(fk(x))\neg P(x) \vee P(f^k(x)), so no budget is enough. Yet a one-element model exists, with ff mapping the element to itself, and the model finder finds it at once. Resolution never identifies aa with f(a)f(a).

Only infinite models. The set “irreflexive, transitive, every element has a larger one” is satisfiable (ℕ with <), but every finite strict order has a largest element. Script 04 runs both tools on it:

  • the prover runs out of its budget of 3,000 generated clauses, with 2,732 clauses kept;
  • the model finder finds nothing up to size 7.

Both tools fail, and necessarily so.

Two searches together (script 04, decide). Try to prove ⊨ α, and try to find a finite counter-model:

formulatruthverdictevidence
drinker paradoxvalidvalidproof with 3 lines
Pelletier 39 (Russell)validvalidproof with 5 lines
∀∃ ⇒ ∃∀invalidinvalidcounter-model of size 2
everything is P or nothing isinvalidinvalidcounter-model of size 2
at most 4 elementsinvalid (needs 5)unknown—
no infinite strict orderinvalid (needs an infinite model)unknown—

The theory behind the table:

  • Gödel’s completeness theorem (1929) says every valid formula has a proof. With a fair complete prover, validity is therefore semi-decidable: the prover terminates on every valid input.
  • Church and Turing (1936) showed that validity is undecidable. Some invalid formulas, such as the last row, escape every procedure.

Practical automated reasoning therefore takes one of two routes:

  • accept “unknown”;
  • restrict the logic to decidable fragments and theories, the subject of the rest of the course.

6. First-order theories

6.1 Motivation

Are these valid?

  • ∀x. ¬(x<x)\forall x.\ \neg(x < x)
  • ¬∃x. x<0\neg\exists x.\ x < 0
  • ∀x,y,z. (x<y∧y<z⇒x<z)\forall x, y, z.\ (x < y \wedge y < z \Rightarrow x < z)

Not in FOL: < can mean anything. Script 03’s model finder gives the counter-models:

  • << as a self-loop on one element;
  • 0<00 < 0;
  • <={(0,1),(1,0)}< = \{(0,1), (1,0)\}.

In practice we do not care about all interpretations, only the intended ones: integers, arrays, strings. As the slides put it, theories “formalize this domain-specific reasoning”. There is also a computational reason: validity in particular theories, or in fragments of them, can be decidable.

6.2 Definitions

A theory T=⟨Σ,M⟩T = \langle \Sigma, M \rangle is a signature together with a class MM of Σ-interpretations. MM must be closed under variable re-assignment.

Examples from the slides:

  • real arithmetic TRAT_{RA}: Real is ℝ, and +,−,∗,≤+, -, *, \le have their usual meaning;
  • ternary strings: all strings over a, b, c, with concatenation and alphabetical order.

T-interpretations. A formula may use symbols outside Σ (uninterpreted symbols, like a function log next to real arithmetic). A T-interpretation is any interpretation of a larger signature whose reduct to Σ is in MM.

The slides’ exercise for TRAT_{RA}:

  • interpreting Real as the rationals is not a TRAT_{RA}-interpretation;
  • adding a sort String, or interpreting an extra log as the successor function, is fine.

Satisfiability and validity in a theory.

  • T-satisfiable: some T-interpretation satisfies the formula.
  • T-valid: every T-interpretation satisfies it.
  • Γ⊨Tα\Gamma \models_T \alpha: every T-interpretation satisfying Γ satisfies α.
  • As before, α is T-valid iff ¬α is T-unsatisfiable.
  • FOL itself is the theory TFOLT_{FOL}, whose MM is all interpretations.

The slides’ TRAT_{RA} exercise:

formulaT-satisfiable?T-valid?
(x0+x1≤0.5)∧(x0−x1≤2)(x_0 + x_1 \le 0.5) \wedge (x_0 - x_1 \le 2)yesno
∀x0. (x0+x1≤1.7⇒x1≤1.7−x0)\forall x_0.\ (x_0 + x_1 \le 1.7 \Rightarrow x_1 \le 1.7 - x_0)yesyes
∀x0. ∀x1. (x0+x1≤1)\forall x_0.\ \forall x_1.\ (x_0 + x_1 \le 1)nono

Axiomatic theories (CC, Chapter 3) are given by a set of Σ-sentences, the axioms. MM is the class of their models, and Γ⊨Tα\Gamma \models_T \alpha becomes ordinary entailment from the axioms. That is something the prover can attempt and the model finder can refute.

Script 03 tries the theory of strict partial orders (irreflexive, transitive):

formulaprover (axioms ⊨ formula)counter-modelverdict
∀x. ∀y. (x < y ⇒ ¬(y < x))PROVEDnone ≤ 4T-valid
∀x. ∀y. (x < y ∨ y < x ∨ x = y)BUDGETsize 2, < emptynot T-valid
∃x. ∀y. (x = y ∨ x < y)BUDGETsize 2, < emptynot T-valid
∀x. ∃y. x < yBUDGETsize 1, < emptynot T-valid

The prover gets only 300 generated clauses here. Transitivity resolved with itself produces ever longer chains ¬x0<x1∨¬x1<x2∨…\neg x_0 < x_1 \vee \neg x_1 < x_2 \vee \dots. Checking whether one chain subsumes another means trying many ways to map literals to literals, and subsumption is NP-complete in general. On ∀x. ∃y. x<y\forall x.\ \exists y.\ x < y, each given clause from the 13th on takes over a second. Profiling that run puts about 95% of its time in the subsumption test. This is why real provers index their clauses and filter subsumption candidates carefully.

Not every theory is axiomatizable. The slides’ example is the theory of ℕ with 0,S,+,<0, S, +, <. Any first-order axiom set also has non-standard models, which contain extra chains of elements beyond the natural numbers. Those models falsify sentences that are true in ℕ, such as ∀x. (x≐0∨∃y. x≐S(y))\forall x.\ (x \doteq 0 \vee \exists y.\ x \doteq S(y)). So axiomatic theories are strictly less general than ⟨Σ,M⟩\langle \Sigma, M \rangle.

6.3 Completeness and decidability

Complete theories. A Σ-theory is complete if for every Σ-sentence α, either α or ¬α is T-valid.

  • Any theory with a single intended interpretation, such as TRAT_{RA}, is complete.
  • The theory of monoids is not. Script 03’s model finder exhibits a commutative monoid (1 element) and a non-commutative one (3 elements). The prover proves neither commutativity nor its negation, as it must fail.
  • Dense linear orders without endpoints form a complete theory: the slides’ Example 3, a classical result.

Decidable theories. A theory is decidable if the set of its valid formulas is decidable. A fragment restricts the syntax, for example to quantifier-free or linear formulas.

The slides’ Theorem 2: a complete and recursively axiomatizable theory is decidable. Enumerate all proofs from the axioms; since the theory is complete, a proof of α or of ¬α must eventually appear. Applying this to DLO needs equality reasoning beyond our prover (§4).

The theories of SMT. SMT (Lectures 10–18) studies theories whose quantifier-free fragment is decidable, ideally efficiently:

theoryfull theoryquantifier-free fragment
EUF: all interpretations, i.e. FOL with equalitysemi-decidableconjunctions decidable in polynomial time (congruence closure, Lecture 10)
real arithmetic TRAT_{RA}decidable, doubly exponentiallinear conjunctions: polynomial (simplex, Lecture 11)
integer arithmetic TIAT_{IA}not even semi-decidableundecidable with ×; linear (Presburger): decidable but hard (Lecture 12)
arrays with extensionalityundecidabledecidable fragments (Lecture 13)

7. Summary

  1. First-order resolution is binary resolution plus factoring, both through unification, on clauses renamed apart.
    • It is sound.
    • Without factoring it is incomplete ({P(x),P(y)},{¬P(u),¬P(v)}\{P(x), P(y)\}, \{\neg P(u), \neg P(v)\} saturates).
    • Herbrand’s theorem plus the lifting lemma (all 892 ground steps checked) give refutational completeness.
  2. Gilmore’s method (ground instances + CDCL) finds tiny unsatisfiable cores, but its enumeration explodes. Unification picks instances on demand.
  3. The given-clause loop makes inferences fairly and exactly once. With unit preference and subsumption it proves all 21 Pelletier problems, P26 included. Its proofs are checked step by step.
  4. Strategies matter:
    • selection with age picks, and subsumption (without either, Pelletier problems are lost on the same budget);
    • the set of support;
    • above all hyperresolution, which proves “x·x = e ⇒ commutative” from 154 generated clauses, where binary resolution runs out of a budget of 10,000.
  5. Equality as axioms is correct but drowns the prover. Paramodulation and superposition build it in. Two of the slides’ illustrative clause sets are misstated when read literally.
  6. Resolution is a semi-decision procedure. With a finite model finder it decides formulas with a proof or a finite counter-model; formulas with only infinite counter-models escape both.
  7. Theories restrict interpretations to the intended ones.
    • Axiomatic theories reduce T-validity to entailment.
    • Some theories (ℕ) are not axiomatizable; some (monoids) are incomplete.
    • Complete, recursively axiomatizable theories are decidable.
    • SMT targets decidable quantifier-free fragments.

8. Common pitfalls

  • Forgetting to rename clauses apart. {P(x)}\{P(x)\} and {¬P(f(x))}\{\neg P(f(x))\} resolve only after renaming. Without it, unification fails on xx vs f(x)f(x) and a refutation is missed.
  • Dropping factoring. Binary resolution alone is incomplete (§1.3).
  • “SATURATED means nothing was found.” It means satisfiable, when it really happens. A budget running out means nothing at all.
  • Set of support on inconsistent axioms. The strategy is complete only when the axioms alone are satisfiable.
  • Clause variables vs free variables. Clause variables are universal; the free variables of a formula in an entailment belong to the interpretation. §4’s misstated examples come from mixing the two.
  • Equality as just another predicate. Without equality axioms or rules, = is uninterpreted, and a≐b∧¬f(a)≐f(b)a \doteq b \wedge \neg f(a) \doteq f(b) looks satisfiable.
  • “Valid in the theory” vs “valid”. ∀x. ¬(x<x)\forall x.\ \neg(x < x) is valid in arithmetic but not in FOL. Always say which theory.
  • “The theory of ℕ is the Peano axioms.” No first-order axiom set pins down ℕ: non-standard models exist.

9. Exercises

Answers are collapsed; try each exercise first.

1. (resolution) Resolve {P(x,f(x)),Q(x)}\{P(x, f(x)), Q(x)\} with {¬P(g(y),y),R(y)}\{\neg P(g(y), y), R(y)\}. Give the mgu and the resolvent.

Answer

Unify P(x,f(x))P(x, f(x)) with P(g(y),y)P(g(y), y). From x←g(y)x \leftarrow g(y), we need f(g(y))≐yf(g(y)) \doteq y, but yy occurs in f(g(y))f(g(y)). The occurs check fails, so there is no resolvent.

(Rename apart first; here the clauses already share no variables.)

2. (factoring) Refute {P(x),P(f(y))}\{P(x), P(f(y))\}, {¬P(f(a))}\{\neg P(f(a))\}, {¬P(z),¬P(f(z))}\{\neg P(z), \neg P(f(z))\}. Is factoring needed?

Answer sketch
  1. Resolve the first clause on P(f(y))P(f(y)) with {¬P(f(a))}\{\neg P(f(a))\} (y←ay \leftarrow a): {P(x)}\{P(x)\}.
  2. Resolve {P(x)}\{P(x)\} with {¬P(z),¬P(f(z))}\{\neg P(z), \neg P(f(z))\}: {¬P(f(z))}\{\neg P(f(z))\}.
  3. Resolve that with {P(x)}\{P(x)\}: □.

No factoring is needed, because a unit clause was obtained first. Factoring is needed only when every refutation must merge literals (§1.3).

3. (lifting) The ground clauses {P(a),P(a)}={P(a)}\{P(a), P(a)\} = \{P(a)\} and {¬P(a)}\{\neg P(a)\} resolve to □. Which first-order clauses C={P(x),P(y)}C = \{P(x), P(y)\} and D={¬P(z)}D = \{\neg P(z)\} step lifts it, and why is factoring involved?

Answer

The ground step merges literals. The ground instance of CC (with x,y←ax, y \leftarrow a) merged two literals into one. A first-order binary resolvent of CC and DD is {P(y)}\{P(y)\} (or {P(x)}\{P(x)\}), not □.

Two ways to recover it.

  • One more resolution with DD gives □.
  • Factor CC into {P(x)}\{P(x)\} first, and then one step gives □.

The lifting lemma is stated with factors for exactly this reason: a merge in the ground step corresponds to factoring before the first-order step.

4. (subsumption) Which subsume which? C1={P(x,y)}C_1 = \{P(x, y)\}, C2={P(a,y),Q(y)}C_2 = \{P(a, y), Q(y)\}, C3={P(a,b),Q(b),R}C_3 = \{P(a, b), Q(b), R\}, C4={P(x,x)}C_4 = \{P(x, x)\}.

Answer
  • C1C_1 subsumes C2C_2 and C3C_3 (match x←ax \leftarrow a, and yy as needed), and also C4C_4 (y←xy \leftarrow x).
  • C2C_2 subsumes C3C_3 (y←by \leftarrow b).
  • C4C_4 subsumes neither C2C_2 nor C3C_3, since P(a,b)P(a, b) does not match P(x,x)P(x, x).

5. (set of support) Why is the set-of-support strategy complete when the axioms are consistent? Why not otherwise?

Answer

Consistent axioms. If the axioms are satisfiable, every refutation of axioms ∪ goal must use a goal clause somewhere. Otherwise the axioms alone would be refutable, hence unsatisfiable. One can show that refutations can be rearranged so that every step involves a goal descendant.

Inconsistent axioms. Then a refutation may need axiom-only steps, which the strategy forbids. The prover may report “saturated” without having found the refutation.

6. (hyperresolution) Write the hyperresolution step that derives P(a,c,b)P(a, c, b) in §3.1. Give the nucleus, the electrons and the unifier.

Answer

Nucleus: the first associativity clause, ¬P(x,y,u)∨¬P(y,z,v)∨¬P(u,z,w)∨P(x,v,w)\neg P(x, y, u) \vee \neg P(y, z, v) \vee \neg P(u, z, w) \vee P(x, v, w).

Electrons, one per negative literal:

negative literalelectronbindings
¬P(x,y,u)\neg P(x, y, u)P(a,a,e)P(a, a, e), an instance of P(x,x,e)P(x, x, e)x=ax = a, y=ay = a, u=eu = e
¬P(y,z,v)\neg P(y, z, v)P(a,b,c)P(a, b, c)z=bz = b, v=cv = c
¬P(u,z,w)\neg P(u, z, w)P(e,b,b)P(e, b, b), an instance of P(e,x,x)P(e, x, x)w=bw = b

Result: P(x,v,w)σ=P(a,c,b)P(x, v, w)\sigma = P(a, c, b), i.e. a⋅c=ba \cdot c = b. In words: a⋅(a⋅b)=(a⋅a)⋅b=e⋅b=ba \cdot (a \cdot b) = (a \cdot a) \cdot b = e \cdot b = b.

This is line 8 of script 02’s proof. Its σ uses the normalized variable names x0,…,x5x_0, \dots, x_5 of the stored clause.

7. (equality) Show by hand, with the equality axioms, that {a≐b}\{a \doteq b\} and {¬f(a)≐f(b)}\{\neg f(a) \doteq f(b)\} are contradictory.

Answer

Take the congruence axiom {¬x≐y, f(x)≐f(y)}\{\neg x \doteq y,\ f(x) \doteq f(y)\}.

  1. Resolve it with {a≐b}\{a \doteq b\} (x←ax \leftarrow a, y←by \leftarrow b): {f(a)≐f(b)}\{f(a) \doteq f(b)\}.
  2. Resolve that with {¬f(a)≐f(b)}\{\neg f(a) \doteq f(b)\}: □.

Two steps. The prover (the “with constants” row of §4’s table) finds the same two steps in the other order: it resolves the congruence axiom with the negated clause first, giving {¬a≐b}\{\neg a \doteq b\}, and then □.

8. (semi-decidability) Explain why “validity in FOL is semi-decidable” and “satisfiability in FOL is not semi-decidable” are consistent.

Answer

Validity is semi-decidable. If α is valid, a fair prover eventually refutes ¬α. So the set of valid formulas can be enumerated (it is r.e.).

Satisfiability is not. α is satisfiable iff ¬α is not valid. Satisfiability is therefore the complement of an r.e. set (co-r.e.). If it were also r.e., validity would be decidable: run both enumerations side by side. That contradicts Church and Turing.

Finite satisfiability is semi-decidable, by model search. That is why the two-sided procedure decides everything except the formulas with only infinite counter-models.

9. (theories) Is ∀x. ∃y. x<y\forall x.\ \exists y.\ x < y valid in the theory of the integers? Of the naturals? Of {0,1,2}\{0, 1, 2\} with the usual order? Is the theory of ⟨{0,1,2},<⟩\langle \{0,1,2\}, < \rangle complete?

Answer
  • In the integers and the naturals: yes, it is valid.
  • In {0,1,2}\{0,1,2\}: no, since 2 has no larger element.
  • The theory of a single structure (all sentences true in it) is always complete. So the theory of ⟨{0,1,2},<⟩\langle \{0,1,2\}, < \rangle is complete, and since the structure is finite it is also decidable: evaluate every sentence.

10. (incompleteness) Using find_model, show that the theory of groups is incomplete. Give one sentence that some groups satisfy and others do not, and find the smallest models of each side.

Answer sketch

Take commutativity:

  • a commutative group: size 1, the trivial group;
  • a non-commutative group: size 6, as in Lecture 7, script 02.

Another sentence is “every element is its own inverse”: the Klein group (size 4) satisfies it, Z3\mathbb{Z}_3 (size 3) does not.

11. (programming) Add ordered resolution to prover.py. Fix a precedence on predicate symbols, and resolve only on maximal literals. Measure the effect on script 02’s ablation.

Answer sketch

The rule. A literal is maximal in its clause if no other literal is greater under the chosen ordering (e.g. the predicate precedence, then term size). In resolvents, only consider pairs where both clashing literals are maximal.

Why it is safe. Ordered resolution with factoring is refutationally complete (Bachmair–Ganzinger), and superposition generalizes it.

What to expect. Fewer generated clauses on the Pelletier problems. Report the ablation counts.


10. Further reading

  • J. A. Robinson, “A Machine-Oriented Logic Based on the Resolution Principle”, JACM 1965; and “Automatic Deduction with Hyper-Resolution”, IJCM 1965.
  • L. Wos, G. Robinson, D. Carson, “Efficiency and Completeness of the Set of Support Strategy in Theorem Proving”, JACM 1965.
  • C.-L. Chang, R. C.-T. Lee, Symbolic Logic and Mechanical Theorem Proving, Academic Press 1973: the classic textbook, with the group examples.
  • W. McCune, Otter 3.3 reference manual (2003): the given-clause loop.
  • L. Bachmair, H. Ganzinger, “Resolution Theorem Proving”, Chapter 2 of the Handbook of Automated Reasoning (2001); and R. Nieuwenhuis, A. Rubio, “Paramodulation-Based Theorem Proving”, Chapter 7.
  • S. Schulz, “E — a Brainiac Theorem Prover”, AI Communications 2002; L. Kovács, A. Voronkov, “First-Order Theorem Proving and Vampire”, CAV 2013.
  • A. Bradley, Z. Manna, The Calculus of Computation, Chapter 3: first-order theories.
  • G. Sutcliffe, the TPTP problem library (tptp.org): thousands of benchmark problems, including the GRP group-theory domain.

11. Next lecture

Lecture 9: applications, model checking. We leave pure logic for systems that run forever: transition systems, invariants and safety properties.

  • Bounded model checking unrolls a system kk steps into a propositional formula for Lecture 5’s CDCL solver.
  • k-induction and IC3/PDR turn the SAT solver into a verifier for unbounded runs.

We build mc.py on top of cdcl.py and verify a mutual-exclusion protocol, a counter and a buggy arbiter.

← 返回课程目录