Download 11. Predicate Logic Syntax and Semantics, Normal Forms, Herbrand

Document related concepts

Modal logic wikipedia , lookup

Model theory wikipedia , lookup

Axiom of reducibility wikipedia , lookup

Catuṣkoṭi wikipedia , lookup

History of logic wikipedia , lookup

Structure (mathematical logic) wikipedia , lookup

History of the function concept wikipedia , lookup

Sequent calculus wikipedia , lookup

Unification (computer science) wikipedia , lookup

Curry–Howard correspondence wikipedia , lookup

Syllogism wikipedia , lookup

Quantum logic wikipedia , lookup

Mathematical logic wikipedia , lookup

Foundations of mathematics wikipedia , lookup

Law of thought wikipedia , lookup

First-order logic wikipedia , lookup

Intuitionistic logic wikipedia , lookup

Combinatory logic wikipedia , lookup

Laws of Form wikipedia , lookup

Propositional calculus wikipedia , lookup

Propositional formula wikipedia , lookup

Principia Mathematica wikipedia , lookup

Transcript
Foundations of Artificial Intelligence
11. Predicate Logic
Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution
Wolfram Burgard, Bernhard Nebel, and Martin Riedmiller
Albert-Ludwigs-Universität Freiburg
July 15, 2011
Contents
1
Motivation
2
Syntax and Semantics
3
Normal Forms
4
Reduction to Propositional Logic: Herbrand Expansion
5
Resolution & Unification
6
Closing Remarks
(University of Freiburg)
Foundations of AI
July 15, 2011
2 / 57
Motivation
We can already do a lot with propositional logic. It is, however, annoying
that there is no structure in the atomic propositions.
Example:
“All blocks are red”
“There is a block A”
It should follow that “A is red”
But propositional logic cannot handle this.
Idea: We introduce individual variables, predicates, functions, . . . .
→ First-Order Predicate Logic (PL1)
(University of Freiburg)
Foundations of AI
July 15, 2011
3 / 57
The Alphabet of First-Order Predicate Logic
Symbols:
Operators: ¬, ∨, ∧, ∀, ∃, =
Variables: x, x1 , x2 , . . . , x0 , x00 , . . . , y, . . . , z, . . .
Brackets: (), [], {}
Function symbols (e.g., weight(), color ())
Predicate symbols (e.g., block (), red ())
Predicate and function symbols have an arity (number of arguments).
0-ary predicate: propositional logic atoms
0-ary function: constant
We suppose a countable set of predicates and functions of any arity.
“=” is usually not considered a predicate, but a logical symbol
(University of Freiburg)
Foundations of AI
July 15, 2011
4 / 57
The Grammar of First-Order Predicate Logic (1)
Terms (represent objects):
1. Every variable is a term.
2. If t1 , t2 , . . . , tn are terms and f is an n-ary function, then
f (t1 , t2 , . . . , tn )
is also a term.
Terms without variables: ground terms.
Atomic Formulae (represent statements about objects)
1. If t1 , t2 , . . . , tn are terms and P is an n-ary predicate, then
P (t1 , t2 , . . . , tn ) is an atomic formula.
2. If t1 and t2 are terms, then t1 = t2 is an atomic formula.
Atomic formulae without variables: ground atoms.
(University of Freiburg)
Foundations of AI
July 15, 2011
5 / 57
The Grammar of First-Order Predicate Logic (2)
Formulae:
1. Every atomic formula is a formula.
2. If ϕ and ψ are formulae and x is a variable, then
¬ϕ, ϕ ∧ ψ, ϕ ∨ ψ, ϕ ⇒ ψ, ϕ ⇔ ψ, ∃xϕ and ∀xϕ
are also formulae.
∀, ∃ are as strongly binding as ¬.
Propositional logic is part of the PL1 language:
1. Atomic formulae: only 0-ary predicates
2. Neither variables nor quantifiers.
(University of Freiburg)
Foundations of AI
July 15, 2011
6 / 57
Alternative Notation
(University of Freiburg)
Here
Elsewhere
¬ϕ
∼ϕ
ϕ∧ψ
ϕ&ψ
ϕ∨ψ
ϕ|ψ
ϕ⇒ψ
ϕ→ψ
ϕ⊃ψ
ϕ⇔ψ
ϕ↔ψ
ϕ≡ψ
∀xϕ
(∀x)ϕ ∧ xϕ
∃xϕ
(∃x)ϕ ∨ xϕ
ϕ
ϕ•ψ
ϕ; ψ
Foundations of AI
ϕ, ψ
ϕ+ψ
July 15, 2011
7 / 57
Meaning of PL1-Formulae
Our example: ∀x[Block (x) ⇒ Red (x)], Block (a)
For all objects x: If x is a block, then x is red and a is a block.
Generally:
Terms are interpreted as objects.
Universally-quantified variables denote all objects in the universe.
Existentially-quantified variables represent one of the objects in the
universe (made true by the quantified expression).
Predicates represent subsets of the universe.
Similar to propositional logic, we define interpretations, satisfiability,
models, validity, . . .
(University of Freiburg)
Foundations of AI
July 15, 2011
8 / 57
Semantics of PL1-Logic
Interpretation: I = hD, •I i where D is an arbitrary, non-empty set and •I
is a function that
maps n-ary function symbols to functions over D:
f I ∈ [Dn 7→ D]
maps individual constants to elements of D:
aI ∈ D
maps n-ary predicate symbols to relations over D:
P I ⊆ Dn
Interpretation of ground terms:
(f (t1 , . . . , tn ))I = f I (tI1 , . . . , tIn )
Satisfaction of ground atoms P (t1 , . . . , tn ):
I |= P (t1 , . . . , tn ) iff htI1 , . . . , tIn i ∈ P I
(University of Freiburg)
Foundations of AI
July 15, 2011
9 / 57
Example (1)
D = {d1 , . . . , dn | n > 1}
aI = d1
bI = d2
cI = . . .
Block I = {d1 }
Red I = D
I |= Red (b)
I 6|= Block (b)
(University of Freiburg)
Foundations of AI
July 15, 2011
10 / 57
Example (2)
D = {1, 2, 3, . . .}
1I = 1
2I = 2
···
Even I = {2, 4, 6, . . .}
succ I = {(1 7→ 2), (2 7→ 3), . . .}
I |= Even(2)
I 6|= Even(succ(2))
(University of Freiburg)
Foundations of AI
July 15, 2011
11 / 57
Semantics of PL1: Variable Assignment
Set of all variables V . Function α : V 7→ D
Notation: α[x/d] is the same as α apart from point x.
For x : α[x/d](x) = d.
Interpretation of terms under I, α:
xI,α = α(x)
aI,α = aI
I,α
(f (t1 , . . . , tn ))I,α = f I (tI,α
1 , . . . , tn )
Satisfaction of atomic formulae:
I,α
I
I, α |= P (t1 , . . . , tn ) iff htI,α
1 , . . . , tn i ∈ P
(University of Freiburg)
Foundations of AI
July 15, 2011
12 / 57
Example
α = {(x 7→ d1 ), (y 7→ d2 )}
I, α |= Red (x)
I, α[y/d1 ] |= Block (y)
(University of Freiburg)
Foundations of AI
July 15, 2011
13 / 57
Semantics of PL1: Satisfiability
A formula ϕ is satisfied by an interpretation I and a variable assignment
α, i.e., I, α |= ϕ:
I, α |= >
I, α 6|= ⊥
I, α |= ¬ϕ iff I, α 6|= ϕ
···
and all other propositional rules as well as
I, α |= P (t1 , . . . , tn )
iff
I,α
I,α
htI,α
1 , . . . , tn i ∈ P
I, α |= ∀xϕ
iff
for all d ∈ D, I, α[x/d] |= ϕ
I, α |= ∃xϕ
iff
there exists a d ∈ D with I, α[x/d] |= ϕ
(University of Freiburg)
Foundations of AI
July 15, 2011
14 / 57
Example
T = {Block (a), Block (b), ∀x(Block (x) ⇒ Red (x))}
D = {d1 , . . . , dn | n > 1}
aI = d1
bI = d 2
Block I = {d1 }
Red I = D
α = {(x 7→ d1 ), (y 7→ d2 )}
Questions:
1. I, α |= Block (b) ∨ ¬Block (b)?
2. I, α |= Block (x) ⇒ (Block (x) ∨ ¬Block (y))?
3. I, α |= Block (a) ∧ Block (b)?
4. I, α |= ∀x(Block (x) ⇒ Red (x))?
5. I, α |= >?
(University of Freiburg)
Foundations of AI
July 15, 2011
15 / 57
Free and Bound Variables
∀x[R( y , z ) ∧ ∃y{¬P (y, x) ∨ R(y, z )}]
The boxed appearances of y and z are free. All other appearances of x,y,z
are bound.
Formulae with no free variables are called closed formulae or sentences.
We form theories from closed formulae.
Note: With closed formulae, the concepts logical equivalence, satisfiability,
and implication, etc. are not dependent on the variable assignment α (i.e.,
we can always ignore all variable assignments).
With closed formulae, α can be left out on the left side of the model
relationship symbol:
I |= ϕ
(University of Freiburg)
Foundations of AI
July 15, 2011
16 / 57
Terminology
An interpretation I is called a model of ϕ under α if
I, α |= ϕ
A PL1 formula ϕ can, as in propositional logic, be satisfiable, unsatisfiable,
falsifiable, or valid.
Analogously, two formulae are logically equivalent (ϕ ≡ ψ) if for all I, α:
I, α |= ϕ iff I, α |= ψ
Note: P (x) 6≡ P (y)!
Logical Implication is also analogous to propositional logic.
Question: How can we define derivation?
(University of Freiburg)
Foundations of AI
July 15, 2011
17 / 57
Prenex Normal Form
Because of the quantifiers, we cannot produce the CNF form of a formula
directly.
First step: Produce the prenex normal form
quantifier prefix + (quantifier-free) matrix
Qx1 Qx2 Qx3 . . . Qxn ϕ
(University of Freiburg)
Foundations of AI
July 15, 2011
18 / 57
Equivalences for the Production of Prenex Normal Form
(∀xϕ) ∧ ψ ≡ ∀x(ϕ ∧ ψ) if x not free in ψ
(∀xϕ) ∨ ψ ≡ ∀x(ϕ ∨ ψ) if x not free in ψ
(∃xϕ) ∧ ψ ≡ ∃x(ϕ ∧ ψ) if x not free in ψ
(∃xϕ) ∨ ψ ≡ ∃x(ϕ ∨ ψ) if x not free in ψ
∀xϕ ∧ ∀xψ ≡ ∀x(ϕ ∧ ψ)
∃xϕ ∨ ∃xψ ≡ ∃x(ϕ ∨ ψ)
¬∀xϕ ≡ ∃x¬ϕ
¬∃xϕ ≡ ∀x¬ϕ
. . . and propositional logic equivalents
(University of Freiburg)
Foundations of AI
July 15, 2011
19 / 57
Production of Prenex Normal Form
1. Eliminate ⇒ and ⇔
2. Move ¬ inwards
3. Move quantifiers outwards
Example:
¬∀x[(∀xP (x)) ⇒ Q(x)]
→ ¬∀x[¬(∀xP (x)) ∨ Q(x)]
→ ∃x[(∀xP (x)) ∧ ¬Q(x)]
And now?
(University of Freiburg)
Foundations of AI
July 15, 2011
20 / 57
Renaming of Variables
ϕ[ xt ] is obtained from ϕ by replacing all free appearances of x in ϕ by t.
Lemma: Let y be a variable that does not appear in ϕ. Then it holds that
∀xϕ ≡ ∀yϕ[ xy ] and ∃xϕ ≡ ∃yϕ[ xy ]
Theorem: There exists an algorithm that calculates the prenex normal
form of any formula.
(University of Freiburg)
Foundations of AI
July 15, 2011
21 / 57
Derivation in PL1
Why is prenex normal form useful?
Unfortunately, there is no simple law as in propositional logic that allows
us to determine satisfiability or general validity (by transformation into
DNF or CNF).
But: we can reduce the satisfiability problem in predicate logic to the
satisfiability problem in propositional logic. In general, however, this
produces a very large number of propositional formulae (perhaps infinitely
many)
Then: apply resolution.
(University of Freiburg)
Foundations of AI
July 15, 2011
22 / 57
Skolemization
Idea: Elimination of existential quantifiers by applying a function that
produces the “right” element.
Theorem (Skolem Normal Form): Let ϕ be a closed formula in prenex
normal form such that all quantified variables are pair-wise distinct and the
function symbols g1 , g2 , . . . do not appear in ϕ. Let
ϕ = ∀x1 · · · ∀xi ∃yψ,
then ϕ is satisfiable iff
ϕ0 = ∀x1 · · · ∀xi ψ
h
y
gi (x1 ,...,xi )
i
is satisfiable.
Example: ∀x∃y[P (x) ⇒ Q(y)] → ∀x[P (x) ⇒ Q(g(x))]
(University of Freiburg)
Foundations of AI
July 15, 2011
23 / 57
Skolem Normal Form
Skolem Normal Form: Prenex normal form without existential quantifiers.
Notation: ϕ* is the SNF of ϕ.
Theorem: It is possible to calculate the Skolem normal form of every
closed formula ϕ.
Example: ∃x((∀xP (x)) ∧ ¬Q(x))
develops as follows:
∃y((∀xP (x)) ∧ ¬Q(y))
∃y(∀x(P (x) ∧ ¬Q(x)))
∀x(P (x) ∧ ¬Q(g0 ))
Note: This transformation is not an equivalence transformation; it only
preserves satisfiability!
Note: . . . and is not unique.
(University of Freiburg)
Foundations of AI
July 15, 2011
24 / 57
Ground Terms & Herbrand Expansion
The set of ground terms (or Herbrand Universe) over a set of SNF
formulae θ* is the (infinite) set of all ground terms formed from the
symbols of θ* (in case there is no constant symbol, one is added). This
set is denoted by D(θ*).
The Herbrand expansion E(θ*) is the instantiation of the Matrix ψi of all
formulae in θ* through all terms t ∈ D(θ*):
E(θ*) = {ψi [ xt11 , . . . , xtnn ] | (∀x1 , . . . , xn ψi ) ∈ θ*, tj ∈ D(θ*)}
Theorem (Herbrand): Let θ* be a set of formulae in SNF. Then θ* is
satisfiable iff E(θ*) is satisfiable.
Note: If D(θ*) and θ* are finite, then the Herbrand expansion is finite
→ finite propositional logic theory.
Note: This is used heavily in AI and works well most of the time!
(University of Freiburg)
Foundations of AI
July 15, 2011
25 / 57
Infinite Propositional Logic Theories
Can a finite proof exist when the set is infinite?
Theorem (compactness of propositional logic): A (countable) set of
formulae of propositional logic is satisfiable if and only if every finite
subset is satisfiable.
Corollary: A (countable) set of formulae in propositional logic is
unsatisfiable if and only if a finite subset is unsatisfiable.
Corollary: (compactness of PL1): A (countable) set of formulae in
predicate logic is satisfiable if and only if every finite subset is satisfiable.
(University of Freiburg)
Foundations of AI
July 15, 2011
26 / 57
Recursive Enumeration and Decidability
We can construct a semi-decision procedure for validity, i.e., we can give a
(rather inefficient) algorithm that enumerates all valid formulae step by
step.
Theorem: The set of valid (and unsatisfiable) formulae in PL1 is
recursively enumerable.
What about satisfiable formulae?
Theorem (undecidability of PL1): It is undecidable, whether a formula of
PL1 is valid.
(Proof by reduction from PCP)
Corollary: The set of satisfiable formulae in PL1 is not recursively
enumerable.
In other words: If a formula is valid, we can effectively confirm this fact.
Otherwise, we can end up in an infinite loop.
(University of Freiburg)
Foundations of AI
July 15, 2011
27 / 57
Derivation in PL1
Clausal Form instead of Herbrand Expansion.
Clauses are universally quantified disjunctions of literals; all variables are
universally quantified
(∀x1 , . . . , xn )(l1 ∨ . . . ∨ ln )
written as
l1 ∨ . . . ∨ ln
or
{l1 , . . . , ln }
(University of Freiburg)
Foundations of AI
July 15, 2011
28 / 57
Production of Clausal Form from SNF
Skolem Normal Form
quantifier prefix + (quantifier-free) matrix
∀x1 ∀x2 ∀x3 · · · ∀xn ϕ
1. Put Matrix into CNF using distribution rule
2. Eliminate universal quantifiers
3. Eliminate conjunction symbol
4. Rename variables so that no variable appears in more than one clause.
Theorem: It is possible to calculate the clausal form of every closed
formula ϕ.
Note: Same remarks as for SNF
(University of Freiburg)
Foundations of AI
July 15, 2011
29 / 57
Conversion to CNF (1)
Everyone who loves all animals is loved by someone:
∀x[∀yAnimal (y) ⇒ Loves(x, y)] ⇒ [∃yLoves(y, x)]
1. Eliminate biconditionals and implications
∀x¬[∀y¬Animal (y) ∨ Loves(x, y)] ∨ [∃yLoves(y, x)]
2. Move ¬ inwards: ¬∀xp ≡ ∃x¬p, ¬∃xp ≡ ∀x¬p
∀x[∃y¬(¬Animal (y) ∨ Loves(x, y))] ∨ [∃yLoves(y, x)]
∀x[∃y¬¬Animal (y) ∧ ¬Loves(x, y)] ∨ [∃yLoves(y, x)]
∀x[∃yAnimal (y) ∧ ¬Loves(x, y)] ∨ [∃yLoves(y, x)]
(University of Freiburg)
Foundations of AI
July 15, 2011
30 / 57
Conversion to CNF (2)
3. Standardize variables: each quantifier should use a different one
∀x[∃yAnimal (y) ∧ ¬Loves(x, y)] ∨ [∃zLoves(z, x)]
4. Skolemize: a more general form of existential instantiation. Each
existential variable is replaced by a Skolem function of the enclosing
universally quantified variables:
∀x[Animal (F (x)) ∧ ¬Loves(x, F (x))] ∨ [Loves(G(x), x)]
5. Drop universal quantifiers:
[Animal (F (x)) ∧ ¬Loves(x, F (x))] ∨ [Loves(G(x), x)]
6. Distribute ∧ over ∨:
[Animal (F (x)) ∨ Loves(G(x), x)] ∧ [¬Loves(x, F (x)) ∨ Loves(G(x), x)]
(University of Freiburg)
Foundations of AI
July 15, 2011
31 / 57
Clauses and Resolution
Assumption: All formulae in the KB are clauses.
Equivalently, we can assume that the KB is a set of clauses.
Due to commutativity, associativity, and idempotence of ∨ , clauses can
also be understood as sets of literals. The empty set of literals is denoted
by .
Set of clauses: ∆
Set of literals: C, D
Literal: l
Negation of a literal: l
(University of Freiburg)
Foundations of AI
July 15, 2011
32 / 57
Propositional Resolution
˙
˙
C1 ∪{l},
C2 ∪{l}
C1 ∪ C2
˙
˙
C1 ∪ C2 are called resolvents of the parent clauses C1 ∪{l}
and C2 ∪{l}.
l
and l are the resolution literals.
Example: {a, b, ¬c} resolves with {a, d, c} to {a, b, d}.
Note: The resolvent is not equivalent to the parent clauses, but it follows
from them!
Notation: R(∆) = ∆ ∪ {C | C is a resolvent of two clauses from ∆}
(University of Freiburg)
Foundations of AI
July 15, 2011
33 / 57
What Changes?
Examples
{{Nat(s(0)), ¬Nat(0)}, {Nat(0)}} ` {Nat(s(0))}
{{Nat(s(0)), ¬Nat(x)}, {Nat(0)}} ` {Nat(s(0))}
{{Nat(s(x)), ¬Nat(x)}, {Nat(0)}} ` {Nat(s(0))}
We need unification, a way to make literals identical.
Based on the notion of substitution, e.g., { x0 }.
(University of Freiburg)
Foundations of AI
July 15, 2011
34 / 57
Substitutions
A substitution s = { vt11 , . . . , vtnn } substitutes variables vi for terms ti (ti
does NOT contain vi ).
Applying a substitution s to an expression ϕ yields the expression ϕs
which is ϕ with all occurrences of vi replaced by ti for all i.
(University of Freiburg)
Foundations of AI
July 15, 2011
35 / 57
Substitution Examples
P (x, f (y), B)
P (z, f (w), B)
P (x, f (A), B)
P (g(z), f (A), B)
x y
s={ , }
z w
y
s={ }
A
x y
s=
,
g(z) A
P (C, f (A), A)
(University of Freiburg)
Foundations of AI
July 15, 2011
36 / 57
Composing Substitutions
Composing substitutions s1 and s2 gives s1 s2 which is that substitution
obtained by first applying s2 to the terms in s1 and adding remaining
term/variable pairs (not occurring in s1 ) to s1 .
o
o
n
n z
x y w z
x y w
z
Example: g(x,y)
,
,
,
=
,
,
,
A B C D
g(A,B) A B C
Application example: P (x, y, z) → P (A, B, g(A, B))
(University of Freiburg)
Foundations of AI
July 15, 2011
37 / 57
Properties of substitutions
For a formula ϕ and substitutions s1 , s2
(ϕs1 )s2 = ϕ(s1 s2 )
(s1 s2 )s3 = s1 (s2 s3 )
associativity
s1 s2 6= s2 s1
(University of Freiburg)
no commutativity!
Foundations of AI
July 15, 2011
38 / 57
Unification
Unifying a set of expressions {wi }
Find substitution s such that wi s = wj s for all i, j
Example
{P (x, f (y), B), P (x, f (B), B)}
not the simplest unifier
s = { By , Az }
y
s = {B }
most general unifier (mgu)
The most general unifier, the mgu, g of {wi } has the property that if s is
any unifier of {wi } then there exists a substitution s0 such that
{wi }s = {wi }gs0
Property: The common instance produced is unique up to alphabetic
variants (variable renaming)
(University of Freiburg)
Foundations of AI
July 15, 2011
39 / 57
Subsumption Lattice
a)
b)
(University of Freiburg)
Foundations of AI
July 15, 2011
40 / 57
Disagreement Set
The disagreement set of a set of expressions {wi } is the set of sub-terms
{ti } of {wi } at the first position in {wi } for which the {wi } disagree
Examples
{P (x, A, f (y)), P (v, B, z)}
gives
{x, v}
{P (x, A, f (y)), P (x, B, z)}
gives
{A, B}
{P (x, y, f (y)), P (x, B, z)}
gives
{y, B}
(University of Freiburg)
Foundations of AI
July 15, 2011
41 / 57
Unification Algorithm
Unify(T erms):
Initialize k ← 0;
Initialize Tk = T erms;
Initialize sk = {};
*If Tk is a singleton, then output sk . Otherwise continue.
Let Dk be the disagreement set of Tk .
If there exists a var vk and a term tk in Dk such that vk does not occur in
tk , continue. Otherwise, exit with failure.
sk+1 ← sk { vtkk };
Tk+1 ← Tk { vtkk };
k ← k + 1;
Goto *.
(University of Freiburg)
Foundations of AI
July 15, 2011
42 / 57
Example
{P (x, f (y), y), P (z, f (B), B)}
(University of Freiburg)
Foundations of AI
July 15, 2011
43 / 57
Binary Resolution
˙ 1 }, C2 ∪{l
˙ 2}
C1 ∪{l
[C1 ∪ C2 ]s
where s = mgu(l1 , l2 ), the most general unifier [C1 ∪ C2 ]s is the resolvent
˙ 1 } and C2 ∪{l
˙ 2 }.
of the parent clauses C1 ∪{l
˙ 1 } and C2 ∪{l
˙ 2 } do not share variables l1 and l2 are the resolution
C1 ∪{l
literals.
Examples: {{Nat(s(0)), ¬Nat(0)}, {Nat(0)}} ` {Nat(s(0))}
{{Nat(s(0)), ¬Nat(x)}, {Nat(0)}} ` {Nat(s(0))}
{{Nat(s(x)), ¬Nat(x)}, {Nat(0)}} ` {Nat(s(0))}
(University of Freiburg)
Foundations of AI
July 15, 2011
44 / 57
Some Further Examples
Resolve P (x) ∨ Q(f (x)) and R(g(x)) ∨ ¬Q(f (A))
Standardizing the variables apart gives P (x) ∨ Q(f (x)) and
R(g(y)) ∨ ¬Q(f (A))
x
}
Substitution s = { A
Resolvent P (A) ∨ R(g(y))
Resolve P (x) ∨ Q(x, y) and ¬P (A) ∨ ¬R(B, z)
Standardizing the variables apart
x
Substitution s = { A
} and Resolvent Q(A, y) ∨ ¬R(B, z)
(University of Freiburg)
Foundations of AI
July 15, 2011
45 / 57
Factoring
˙ 1 }∪{l
˙ 2}
C1 ∪{l
[C1 ∪ {l1 }]s
where s = mgu(l1 , l2 ) is the most general unifier.
Needed because:
{{P (u), P (v)}, {¬P (x), ¬P (y)}} |= but cannot be derived by binary resolution
Factoring yields:
{P (u)} and {¬P (x)} whose resolvent is .
(University of Freiburg)
Foundations of AI
July 15, 2011
46 / 57
Derivations
Notation: R(∆) = ∆ ∪ {C | C is a resolvent or a factor of two clauses
from ∆}
We say D can be derived from ∆, i.e.,
∆ ` D,
if there exist C1 , C2 , C3 , . . . , Cn = D such that
Ci ∈ R(∆ ∪ {C1 , . . . , Ci−1 }) for 1 ≤ i ≤ n.
(University of Freiburg)
Foundations of AI
July 15, 2011
47 / 57
Example
From Russell and Norvig:
The law says it is a crime for an American to sell weapons to hostile
nations. The country Nono, an enemy of America, has some missiles,
and all of its missiles were sold to it by Colonel West, who is
American.
Prove that Col. West is a criminal.
(University of Freiburg)
Foundations of AI
July 15, 2011
48 / 57
Example
. . . it is a crime for an American to sell weapons to hostile nations:
American(x) ∧ weapon(y) ∧ Sells(x, y, z) ∧ Hostile(z) ⇒ Criminal (x)
Nono . . . has some missiles, i.e., ∃xOwns(Nono, x) ∧ Missile(x):
Owns(Nono, M1 ) and Missile(M1 )
. . . all of its missiles were sold to it by Colonel West.
∀xMissiles(x) ∧ Owns(Nono, x) ⇒ Sells(West, x, Nono)
Missiles are weapons:
Missile(x) ⇒ Weapon(x)
An enemy of America counts as “hostile”:
Enemy(x, America) ⇒ Hostile(x)
West, who is American . . .
American(West)
The country Nono, an enemy of America
Enemy(Nono, America)
(University of Freiburg)
Foundations of AI
July 15, 2011
49 / 57
An Example
¬American(x) ∨ ¬Weapon(y) ∨ ¬Sells(x,y,z) ∨ ¬Hostile(z) ∨ Criminal(x)
American(West)
¬Missile(x) ∨ Weapon(x)
Missile(M1)
¬Missile(x) ∨ ¬Owns(Nono,x) ∨ Sells(West,x,Nono)
Missile(M1)
Owns(Nono,M1)
¬Enemy(x,America) ∨ Hostile(x)
Enemy(Nono,America)
(University of Freiburg)
¬Criminal(West)
¬American(West) ∨ ¬Weapon(y) ∨ ¬Sells(West,y,z) ∨ ¬Hostile(z)
¬Weapon(y) ∨ ¬Sells(West,y,z) ∨ ¬Hostile(z)
¬Missile(y) ∨ ¬Sells(West,y,z) ∨ ¬Hostile(z)
¬Sells(West,M1,z) ∨ ¬Hostile(z)
¬Missile(M1) ∨ ¬Owns(Nono,M1) ∨ ¬Hostile(Nono)
¬Owns(Nono,M1) ∨ ¬Hostile(Nono)
¬Hostile(Nono)
¬Enemy(Nono,America)
Foundations of AI
July 15, 2011
50 / 57
Another Example
Cat(Tuna)
Animal(Tuna)
¬Cat(x) ∨ Animal(x)
Kills(Jack, Tuna) ∨ Kills(Curiosity, Tuna)
¬Loves(y, x) ∨ ¬Animal(z) ∨ ¬Kills(x, z)
¬Loves(y, x) ∨ ¬Kills(x, Tuna)
¬Loves(y, Jack)
(University of Freiburg)
Kills(Jack, Tuna)
¬Kills(Curiosity, Tuna)
¬Loves(x,F(x)) ∨ Loves(G(x), x)
¬Animal(F(Jack)) ∨ Loves(G(Jack), Jack)
¬Animal(x) ∨ Loves(Jack, x)
Animal(F(x)) ∨ Loves(G(x), x)
Loves(G(Jack), Jack)
Foundations of AI
July 15, 2011
51 / 57
Properties of Resolution
Lemma: (soundness) If ∆ ` D, then ∆ |= D.
Lemma: resolution is refutation-complete:
∆ is unsatisfiable implies ∆ ` .
Theorem: ∆ is unsatisfiable iff ∆ ` .
Technique: to prove that ∆ |= C
negate C and prove that ∆ ∪ {¬C} ` .
(University of Freiburg)
Foundations of AI
July 15, 2011
52 / 57
The Lifting Lemma
Lemma: Let C1 and C2 be two clauses with no shared variables, and let
C10 and C20 be ground instances of C1 and C2 . If C 0 is a resolvent of C10
and C20 , then there exists a clause such that
(1) C is a resolvent of C1 and C2
(2) C 0 is a ground instance of C
Can be easily generalized to derivations
(University of Freiburg)
Foundations of AI
July 15, 2011
53 / 57
The General Picture
Any set of sentences S is representable in clausal form
↓
Assume S is unsatisfiable, and in clausal form
↓
←−−−−−−−−−−−− Herbrand’s theorem
Some set S 0 of ground instances is unsatisfiable
↓
←
−−−−−−
− Ground resolution theorem
Resolution can find a contradiction in S 0
↓ ←−−−−−−−−−−−−−−−−− Lifting lemma
There is a resolution proof for the contradiction in S
(University of Freiburg)
Foundations of AI
July 15, 2011
54 / 57
Closing Remarks: Processing
PL1-Resolution: forms the basis of
most state of the art theorem provers for PL1
the programming language Prolog
only Horn clauses
considerably more efficient methods.
not dealt with : search/resolution strategies
Finite theories: In applications, we often have to deal with a fixed set of
objects. Domain closure axiom:
∀x[x = c1 ∨ x = c2 ∨ . . . ∨ x = cn ]
Translation into finite propositional theory is possible.
(University of Freiburg)
Foundations of AI
July 15, 2011
55 / 57
Closing Remarks: Possible Extensions
PL1 is definitely very expressive, but in some circumstances we would
like more . . .
Second-Order Logic: Also over predicate quantifiers
∀x, y[(x = y) ⇔ {∀p[p(x) ⇔ p(y)]}]
Validity is no longer semi-decidable (we have lost compactness)
Lambda Calculus: Definition of predicates, e.g.,
λx, y[∃zP (x, z) ∧ Q(z, y)] defines a new predicate of arity 2
Reducible to PL1 through Lambda-Reduction
Uniqueness quantifier: ∃!xϕ(x) - there is exactly one x . . .
Reduction to PL1:
∃x[ϕ(x) ∧ ∀y{ϕ(y) ⇒ x = y}]
(University of Freiburg)
Foundations of AI
July 15, 2011
56 / 57
Summary
PL1 makes it possible to structure statements, thereby giving us
considerably more expressive power than propositional logic.
Formulae consist of terms and atomic formulae, which, together with
connectors and quantifiers, can be put together to produce formulae.
Interpretations in PL1 consist of a universe and an interpretation
function.
The Herbrand Theory shows that satisfiability in PL1 can be reduced to
satisfiability in propositional logic (although infinite sets of formulae can
arise under certain circumstances).
Resolution is refutation complete
Validity in PL1 is not decidable (it is only semi-decidable)
(University of Freiburg)
Foundations of AI
July 15, 2011
57 / 57