new foundations of arti cial...

57
Foundations of Artificial Intelligence 9. Predicate Logic Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution Wolfram Burgard, Maren Bennewitz, and Marco Ragni Albert-Ludwigs-Universit¨ at Freiburg

Upload: others

Post on 12-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Foundations of Artificial Intelligence9. Predicate Logic

Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Wolfram Burgard, Maren Bennewitz, and Marco Ragni

Albert-Ludwigs-Universitat Freiburg

Page 2: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 2 / 57

Page 3: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Motivation

We can already do a lot with propositional logic. It is, however, annoyingthat 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 3 / 57

Page 4: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

The Alphabet of First-Order Predicate Logic

Symbols:

Operators: ¬, ∨, ∧, ∀, ∃, =

Variables: x, x1, x2, . . . , x′, x′′, . . . , 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 atoms0-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 4 / 57

Page 5: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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, thenP (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 5 / 57

Page 6: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 6 / 57

Page 7: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Alternative Notation

Here Elsewhere

¬ϕ ∼ϕ ϕ

ϕ ∧ ψ ϕ&ψ ϕ • ψ ϕ,ψ

ϕ ∨ ψ ϕ|ψ ϕ;ψ ϕ+ ψ

ϕ⇒ ψ ϕ→ ψ ϕ ⊃ ψϕ⇔ ψ ϕ↔ ψ ϕ ≡ ψ∀xϕ (∀x)ϕ ∧ xϕ∃xϕ (∃x)ϕ ∨ xϕ

(University of Freiburg) Foundations of AI 7 / 57

Page 8: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 theuniverse (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 8 / 57

Page 9: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Semantics of PL1-Logic

Interpretation: I = 〈D, •I〉 where D is an arbitrary, non-empty set and •Iis 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 〈tI1, . . . , tIn〉 ∈ P I

(University of Freiburg) Foundations of AI 9 / 57

Page 10: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 10 / 57

Page 11: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Example (2)

D = {1, 2, 3, . . .}1I = 1

2I = 2

· · ·EvenI = {2, 4, 6, . . .}succI = {(1 7→ 2), (2 7→ 3), . . .}

I |= Even(2)

I 6|= Even(succ(2))

(University of Freiburg) Foundations of AI 11 / 57

Page 12: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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

(f(t1, . . . , tn))I,α = f I(tI,α1 , . . . , tI,αn )

Satisfaction of atomic formulae:

I, α |= P (t1, . . . , tn) iff 〈tI,α1 , . . . , tI,αn 〉 ∈ P I

(University of Freiburg) Foundations of AI 12 / 57

Page 13: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Example

α = {(x 7→ d1), (y 7→ d2)}I, α |= Red(x)

I, α[y/d1] |= Block(y)

(University of Freiburg) Foundations of AI 13 / 57

Page 14: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 〈tI,α1 , . . . , tI,αn 〉 ∈ P I,α

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 14 / 57

Page 15: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Example

T = {Block(a),Block(b),∀x(Block(x)⇒ Red(x))}D = {d1, . . . , dn | n > 1}

aI = d1

bI = d2

BlockI = {d1}

RedI = 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 15 / 57

Page 16: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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,zare 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 modelrelationship symbol:

I |= ϕ

(University of Freiburg) Foundations of AI 16 / 57

Page 17: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 17 / 57

Page 18: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Prenex Normal Form

Because of the quantifiers, we cannot produce the CNF form of a formuladirectly.

First step: Produce the prenex normal form

quantifier prefix + (quantifier-free) matrix

Qx1Qx2Qx3 . . . Qxn ϕ

(University of Freiburg) Foundations of AI 18 / 57

Page 19: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 19 / 57

Page 20: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 20 / 57

Page 21: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 normalform of any formula.

(University of Freiburg) Foundations of AI 21 / 57

Page 22: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Derivation in PL1

Why is prenex normal form useful?

Unfortunately, there is no simple law as in propositional logic that allowsus to determine satisfiability or general validity (by transformation intoDNF or CNF).

But: we can reduce the satisfiability problem in predicate logic to thesatisfiability problem in propositional logic. In general, however, thisproduces a very large number of propositional formulae (perhaps infinitelymany)

Then: apply resolution.

(University of Freiburg) Foundations of AI 22 / 57

Page 23: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Skolemization

Idea: Elimination of existential quantifiers by applying a function thatproduces the “right” element.

Theorem (Skolem Normal Form): Let ϕ be a closed formula in prenexnormal form such that all quantified variables are pair-wise distinct and thefunction symbols g1, g2, . . . do not appear in ϕ. Let

ϕ = ∀x1 · · · ∀xi∃yψ,

then ϕ is satisfiable iff

ϕ′ = ∀x1 · · · ∀xiψ[

ygi(x1,...,xi)

]is satisfiable.

Example: ∀x∃y[P (x)⇒ Q(y)] → ∀x[P (x)⇒ Q(g(x))]

(University of Freiburg) Foundations of AI 23 / 57

Page 24: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 everyclosed formula ϕ.

Example: ∃x((∀xP (x)) ∧ ¬Q(x))

∃y((∀xP (x)) ∧ ¬Q(y))

∃y(∀x(P (x) ∧ ¬Q(x)))

∀x(P (x) ∧ ¬Q(g0))

develops as follows:

Note: This transformation is not an equivalence transformation; it onlypreserves satisfiability!

Note: . . . and is not unique.

(University of Freiburg) Foundations of AI 24 / 57

Page 25: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Ground Terms & Herbrand Expansion

The set of ground terms (or Herbrand Universe) over a set of SNFformulae θ* is the (infinite) set of all ground terms formed from thesymbols of θ* (in case there is no constant symbol, one is added). Thisset is denoted by D(θ*).

The Herbrand expansion E(θ*) is the instantiation of the Matrix ψi of allformulae in θ* through all terms t ∈ D(θ*):

E(θ*) = {ψi[x1t1 , . . . ,xntn

] | (∀x1, . . . , xnψi) ∈ θ*, tj ∈ D(θ*)}

Theorem (Herbrand): Let θ* be a set of formulae in SNF. Then θ* issatisfiable 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 25 / 57

Page 26: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Infinite Propositional Logic Theories

Can a finite proof exist when the set is infinite?

Theorem (compactness of propositional logic): A (countable) set offormulae of propositional logic is satisfiable if and only if every finitesubset is satisfiable.

Corollary: A (countable) set of formulae in propositional logic isunsatisfiable if and only if a finite subset is unsatisfiable.

Corollary: (compactness of PL1): A (countable) set of formulae inpredicate logic is satisfiable if and only if every finite subset is satisfiable.

(University of Freiburg) Foundations of AI 26 / 57

Page 27: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 bystep.

Theorem: The set of valid (and unsatisfiable) formulae in PL1 isrecursively enumerable.

What about satisfiable formulae?

Theorem (undecidability of PL1): It is undecidable, whether a formula ofPL1 is valid.

(Proof by reduction from PCP)

Corollary: The set of satisfiable formulae in PL1 is not recursivelyenumerable.

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 27 / 57

Page 28: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Derivation in PL1

Clausal Form instead of Herbrand Expansion.

Clauses are universally quantified disjunctions of literals; all variables areuniversally quantified

(∀x1, . . . , xn)(l1 ∨ . . . ∨ ln) written as

l1 ∨ . . . ∨ ln or

{l1, . . . , ln}

(University of Freiburg) Foundations of AI 28 / 57

Page 29: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Production of Clausal Form from SNF

Skolem Normal Formquantifier 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 closedformula ϕ.

Note: Same remarks as for SNF

(University of Freiburg) Foundations of AI 29 / 57

Page 30: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 30 / 57

Page 31: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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. Eachexistential variable is replaced by a Skolem function of the enclosinguniversally 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 31 / 57

Page 32: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 canalso be understood as sets of literals. The empty set of literals is denotedby �.

Set of clauses: ∆

Set of literals: C, D

Literal: l

Negation of a literal: l

(University of Freiburg) Foundations of AI 32 / 57

Page 33: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Propositional Resolution

C1∪{l}, C2∪{l}C1 ∪ C2

C1 ∪ C2 are called resolvents of the parent clauses C1∪{l} and C2∪{l}. land 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 followsfrom them!

Notation: R(∆) = ∆ ∪ {C | C is a resolvent of two clauses from ∆}

(University of Freiburg) Foundations of AI 33 / 57

Page 34: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 34 / 57

Page 35: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Substitutions

A substitution s = {v1t1 , . . . ,vntn} substitutes variables vi for terms ti (ti

does NOT contain vi).

Applying a substitution s to an expression ϕ yields the expression ϕswhich is ϕ with all occurrences of vi replaced by ti for all i.

(University of Freiburg) Foundations of AI 35 / 57

Page 36: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Substitution Examples

P (x, f(y), B)

P (z, f(w), B) s = {xz,y

w}

P (x, f(A), B) s = { yA}

P (g(z), f(A), B) s =

{x

g(z),y

A

}P (C, f(A), A)

(University of Freiburg) Foundations of AI 36 / 57

Page 37: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Composing Substitutions

Composing substitutions s1 and s2 gives s1s2 which is that substitutionobtained by first applying s2 to the terms in s1 and adding remainingterm/variable pairs (not occurring in s1) to s1.

Example:{

zg(x,y)

}{xA ,

yB ,

wC ,

zD

}={

zg(A,B) ,

xA ,

yB ,

wC

}Application example: P (x, y, z) → P (A,B, g(A,B))

(University of Freiburg) Foundations of AI 37 / 57

Page 38: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Properties of substitutions

For a formula ϕ and substitutions s1, s2

(ϕs1)s2 = ϕ(s1s2)

(s1s2)s3 = s1(s2s3) associativity

s1s2 6= s2s1 no commutativity!

(University of Freiburg) Foundations of AI 38 / 57

Page 39: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Unification

Unifying a set of expressions {wi}

Find substitution s such that wis = wjs for all i, j

Example{P (x, f(y), B), P (x, f(B), B)}s = { yB ,

zA} not the simplest unifier

s = { yB} most general unifier (mgu)

The most general unifier, the mgu, g of {wi} has the property that if s isany unifier of {wi} then there exists a substitution s′ such that{wi}s = {wi}gs′

Property: The common instance produced is unique up to alphabeticvariants (variable renaming)

(University of Freiburg) Foundations of AI 39 / 57

Page 40: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Subsumption Lattice

a)

b)

(University of Freiburg) Foundations of AI 40 / 57

Page 41: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 41 / 57

Page 42: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Unification Algorithm

Unify(Terms):

Initialize k ← 0;Initialize Tk = Terms;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 intk, continue. Otherwise, exit with failure.

sk+1 ← sk{vktk };

Tk+1 ← Tk{vktk };

k ← k + 1;

Goto *.

(University of Freiburg) Foundations of AI 42 / 57

Page 43: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Example

{P (x, f(y), y), P (z, f(B), B)}

(University of Freiburg) Foundations of AI 43 / 57

Page 44: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Binary Resolution

C1∪{l1}, C2∪{l2}[C1 ∪ C2]s

where s = mgu(l1, l2), the most general unifier [C1 ∪ C2]s is the resolventof the parent clauses C1∪{l1} and C2∪{l2}.

C1∪{l1} and C2∪{l2} do not share variables l1 and l2 are the resolutionliterals.

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 44 / 57

Page 45: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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)) andR(g(y)) ∨ ¬Q(f(A))

Substitution s = { xA} Resolvent P (A) ∨R(g(y))

Resolve P (x) ∨Q(x, y) and ¬P (A) ∨ ¬R(B, z)

Standardizing the variables apart

Substitution s = { xA} and Resolvent Q(A, y) ∨ ¬R(B, z)

(University of Freiburg) Foundations of AI 45 / 57

Page 46: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Factoring

C1∪{l1}∪{l2}[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 46 / 57

Page 47: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Derivations

Notation: R(∆) = ∆ ∪ {C | C is a resolvent or a factor of two clausesfrom ∆}

We say D can be derived from ∆, i.e.,

∆ ` D,

if there exist C1, C2, C3, . . . , Cn = D such thatCi ∈ R(∆ ∪ {C1, . . . , Ci−1}) for 1 ≤ i ≤ n.

(University of Freiburg) Foundations of AI 47 / 57

Page 48: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Example

From Russell and Norvig:

The law says it is a crime for an American to sell weapons to hostilenations. The country Nono, an enemy of America, has some missiles,and all of its missiles were sold to it by Colonel West, who isAmerican.

Prove that Col. West is a criminal.

(University of Freiburg) Foundations of AI 48 / 57

Page 49: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 49 / 57

Page 50: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

An Example

¬American(x) ∨ ¬Weapon(y) ∨ ¬Sells(x,y,z) ∨ ¬Hostile(z) ∨ Criminal(x) ¬Criminal(West)

¬Enemy(Nono,America)Enemy(Nono,America)

¬Missile(x) ∨ Weapon(x) ¬Weapon(y) ∨ ¬Sells(West,y,z) ∨ ¬Hostile(z)

Missile(M1) ¬Missile(y) ∨ ¬Sells(West,y,z) ∨ ¬Hostile(z)

¬Missile(x) ∨ ¬Owns(Nono,x) ∨ Sells(West,x,Nono) ¬Sells(West,M1,z) ∨ ¬Hostile(z)

¬American(West) ∨ ¬Weapon(y) ∨ ¬Sells(West,y,z) ∨ ¬Hostile(z)American(West)

¬Missile(M1) ∨ ¬Owns(Nono,M1) ∨ ¬Hostile(Nono)Missile(M1)

¬Owns(Nono,M1) ∨ ¬Hostile(Nono)Owns(Nono,M1)

¬Enemy(x,America) ∨ Hostile(x) ¬Hostile(Nono)

(University of Freiburg) Foundations of AI 50 / 57

Page 51: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Another Example

¬Loves(y, Jack) Loves(G(Jack), Jack)

¬Kills(Curiosity, Tuna)Kills(Jack, Tuna) ∨ Kills(Curiosity, Tuna)¬Cat(x) ∨ Animal(x)Cat(Tuna)

¬Animal(F(Jack)) ∨ Loves(G(Jack), Jack) Animal(F(x)) ∨ Loves(G(x), x) ¬Loves(y, x) ∨ ¬Kills(x, Tuna)

Kills(Jack, Tuna)¬Loves(y, x) ∨ ¬Animal(z) ∨ ¬Kills (x, z)Animal(Tuna) ¬Loves(x,F(x)) ∨ Loves(G(x), x) ¬Animal(x) ∨ Loves(Jack, x)

(University of Freiburg) Foundations of AI 51 / 57

Page 52: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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 ∆ |= Cnegate C and prove that ∆ ∪ {¬C} ` �.

(University of Freiburg) Foundations of AI 52 / 57

Page 53: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

The Lifting Lemma

Lemma: Let C1 and C2 be two clauses with no shared variables, and letC ′1 and C ′2 be ground instances of C1 and C2. If C ′ is a resolvent of C ′1and C ′2, then there exists a clause such that

(1) C is a resolvent of C1 and C2

(2) C ′ is a ground instance of C

Can be easily generalized to derivations

(University of Freiburg) Foundations of AI 53 / 57

Page 54: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

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′ of ground instances is unsatisfiable↓ ←−−−−−−− Ground resolution theorem

Resolution can find a contradiction in S′

↓←−−−−−−−−−−−−−−−−− Lifting lemma

There is a resolution proof for the contradiction in S

(University of Freiburg) Foundations of AI 54 / 57

Page 55: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Closing Remarks: Processing

PL1-Resolution: forms the basis of

most state of the art theorem provers for PL1the programming language Prolog

only Horn clausesconsiderably more efficient methods.

not dealt with : search/resolution strategies

Finite theories: In applications, we often have to deal with a fixed set ofobjects. Domain closure axiom:

∀x[x = c1 ∨ x = c2 ∨ . . . ∨ x = cn]

Translation into finite propositional theory is possible.

(University of Freiburg) Foundations of AI 55 / 57

Page 56: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Closing Remarks: Possible Extensions

PL1 is definitely very expressive, but in some circumstances we wouldlike 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 56 / 57

Page 57: New Foundations of Arti cial Intelligencegki.informatik.uni-freiburg.de/.../gki/lectures/ai09.pdf · 2013. 6. 5. · (Proof by reduction from PCP) Corollary: The set ofsatis able

Summary

PL1 makes it possible to structure statements, thereby giving usconsiderably more expressive power than propositional logic.

Formulae consist of terms and atomic formulae, which, together withconnectors and quantifiers, can be put together to produce formulae.

Interpretations in PL1 consist of a universe and an interpretationfunction.

The Herbrand Theory shows that satisfiability in PL1 can be reduced tosatisfiability in propositional logic (although infinite sets of formulae canarise under certain circumstances).

Resolution is refutation complete

Validity in PL1 is not decidable (it is only semi-decidable)

(University of Freiburg) Foundations of AI 57 / 57