lecture 10 first-order logic saturation-based reasoning...

27
Lecture 10 First-Order Logic Saturation-Based Reasoning COMP24412: Symbolic AI Giles Reger February 2019 Giles Reger Lecture 10 February 2019 1 / 23

Upload: others

Post on 06-Oct-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Lecture 10 First-Order LogicSaturation-Based Reasoning

COMP24412: Symbolic AI

Giles Reger

February 2019

Giles Reger Lecture 10 February 2019 1 / 23

Page 2: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Aim and Learning Outcomes

The aim of this lecture is to:

Give the idea behind the completeness of resolution, introduce orderedresolution, and discuss clause selection

Learning Outcomes

By the end of this lecture you will be able to:

1 State what it means for an inference system to be (refutationally)complete

2 Describe the general idea behind the model construction approach

3 Describe, with examples, a fair clause selection approach

4 Apply the given clause algorithm with resolution (etc) to a set ofclauses

Giles Reger Lecture 10 February 2019 2 / 23

Page 3: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

First-Order Logic Stuff

Syntax (propositional logic with predicates and quantifiers)

Semantics in terms of models

Clausal representation

Reasoning with Clauses using Resolution

Reasoning with Equality with Paramodulation (and Equality Resolution)

Transformation to Clausal Form

Giles Reger Lecture 10 February 2019 3 / 23

Page 4: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Today

Ground resolution is sound and complete

The completeness argument allows us to optimise its application

We can lift it to first-order resolution

Need fairness, get given clause algorithm

Giles Reger Lecture 10 February 2019 4 / 23

Page 5: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Ground Resolution: Soundness

We consider the ground case. Reminder:

l ∨ C ¬l ∨ DC ∨ D

where l is a ground atom and C ,D are ground clauses.

This rule is sound, we only derive true things.

For any model M if M � l ∨ C and M � ¬l ∨ D then M � C ∨ D.

Two cases

1. M � l and therefore M � D

2. M � ¬l and therefore M � C

Note that l ∨ ¬l is a tautology.

Giles Reger Lecture 10 February 2019 5 / 23

Page 6: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Ground Resolution: Completeness

We consider the ground case. Reminder:

l ∨ C ¬l ∨ DC ∨ D

where l is a ground atom and C ,D are ground clauses.

This rule is refutationally complete, if it is unsat we can show it.

Let N be a set of ground clauses and N∗ be the set saturated with respectto the above rule. Then N � false if and only if false ∈ N∗.

If direction by soundness of resolution.

Only if direction by constructing a model of N from N∗ if false /∈ N∗.

Giles Reger Lecture 10 February 2019 6 / 23

Page 7: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Ordering Clauses

A partial ordering (irreflexive, transitive) � is well-founded if there exist noinfinite chains a0 � a1 � a2 � . . .

Assume a well-founded partial order � on ground atoms. We could use asimple ‘dictionary’ order, which would also be total.

First, lift to literals such that ¬l � l for every atom l

Now, lift to clauses: C � D if for every l in D/C there is a l ′ � l in C/D

Example, given p � q � r

p ∨ q � p � ¬q ∨ r � q ∨ r

Giles Reger Lecture 10 February 2019 7 / 23

Page 8: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Observations on Clause Ordering

� on clauses is total and well-founded

Let max(C ) be the maximal literal in C , this exists and is unique

If max(C ) � max(D) then C � D

If max(C ) = max(D) but max(C ) is neg and max(D) pos then C � D

This gives a stratification of clause sets by maximal literal

Giles Reger Lecture 10 February 2019 8 / 23

Page 9: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Stratified Clause SetsWell-Founded Orderings Stratified Clause Sets

Stratified Structure of Clause SetsLet A ≻ B. Clause sets are then stratified in this form:

{

{...

...≺

A

B. . . ∨ B

. . .. . . ∨ B ∨ B

. . .¬B ∨ . . .

. . . ∨ A. . .

. . . ∨ A ∨ A. . .

¬A ∨ . . .. . .

all Dwhere max(D) = B

all Cwhere max(C) = A

Ruzica Piskac First-Order Logic - Syntax, Semantics, Resolution 70 / 125Giles Reger Lecture 10 February 2019 9 / 23

Page 10: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Model Construction

Idea:

Build up an interpretation M incrementally

Look at clauses from smallest to largest

If C is already true in I then carry on

Otherwise, make the maximal literal in C true in I

We use MC for the interpretation after processing C and ∆C for the newclauses produced by C . Then

MC =⋃

C�D ∆D

∆C =

{{l} if MC 6� C and l = max(C ) and l is pos∅ otherwise

If ∆C = {l} we say that C is produces l and C is productive

Giles Reger Lecture 10 February 2019 10 / 23

Page 11: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Example

Let p5 � p4 � p3 � p2 � p1 � p0

clauses MC ∆C Remark

¬p0 ∅ ∅ true in MC

p0 ∨ p1 ∅ {p1}p1 ∨ p2 {p1} ∅ true in MC

¬p1 ∨ p2 {p1} {p2}¬p1 ∨ p3 ∨ p0 {p1, p2} {p3}

¬p1 ∨ p4 ∨ p3 ∨ p0 {p1, p2, p3} ∅ true in MC

¬p1 ∨ ¬p4 ∨ p3 {p1, p2, p3} ∅ true in MC

¬p4 ∨ p5 {p1, p2, p3} {p5}

So M = {p1, p2, p3, p5}

Giles Reger Lecture 10 February 2019 11 / 23

Page 12: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Observations

We use these next:

If C = ¬l ∨ C ′ then C does not produce l and no D � C ′ produces l

Therefore, if l in M then some smaller clause most produce l

If C is productive then ∆C � C , hence M � C

Giles Reger Lecture 10 February 2019 12 / 23

Page 13: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Model Existence

Let M be the model constructed from N∗ where false /∈ N∗.We have M � N∗.

Proof by contradiction. Suppose M 6� N∗.

There must be a smallest C in N∗ s.t. M 6� C

C is not productive, hence l = max(C ) is negative

C = ¬l ∨ C ′, hence M 6� C ′ and M � l

As M � l there is some D = l ∨ D ′, C � D s.t. D produces l

So M 6� D ′ (as D produces l)

By resolution, C ′ ∨ D ′ ∈ N∗ and M 6� C ′ ∨ D ′

but C � C ′ ∨ D ′ thus C is not the smallest such clause

Giles Reger Lecture 10 February 2019 13 / 23

Page 14: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Compactness

Compactness of propositional logic follows.

A set of propositional formulas N is unsatisfiable if and only if there is afinite subset of N that is unsatisfiable.

The if part is non-trivial.

If N is unsatisfiable then N∗ is unsatisfiable, thus false ∈ N∗

There must be a finite number of resolution steps required to derive false

Let P be the clauses in the resolution proof and M = P ∩ N

M is finite, M is unsatisfiable and M ⊆ N

Giles Reger Lecture 10 February 2019 14 / 23

Page 15: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Ordered Resolution

Given the previous model construction we can observe that certaininferences can be excluded and the model construction still works.

If we resolve on either a maximal or negative literal then we do allinferences required by model construction.

This gives us ordered resolution:

l1 ∨ C ¬l1 ∨ D

(C ∨ D)θ

where l1 is maximal in l1 ∨ C .

We’re also allowed to arbitrarily select at least one negative literal in aclause and restrict inferences to the selected literals.

Giles Reger Lecture 10 February 2019 15 / 23

Page 16: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Less Work

Two choices of inference.

¬rich(giles) ∨ happy(giles) rich(giles) ¬happy(giles)

Giles Reger Lecture 10 February 2019 16 / 23

Page 17: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Less Work

One choice.

¬rich(giles) ∨ happy(giles) rich(giles) ¬happy(giles)

Giles Reger Lecture 10 February 2019 16 / 23

Page 18: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Lifting

Now let N be a set of non-ground clauses.

Let GΣ(N) be the grounding of N using Σ

If N is saturated wrt non-ground resolution then GΣ(N) is saturated wrtground resolution

We can apply the model construction with GΣ(N) and the result is amodel of N

Compactness lifts in a similar way

We can do something similar with equality but much more work (andrequires replacing paramodulation with something else)

Giles Reger Lecture 10 February 2019 17 / 23

Page 19: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Missing Rule

Usually we also have the (positive) factoring rule

C ∨ l1 ∨ l2θ(C ∨ l1)

θ = mgu(l1, l2)

which is required in some cases

1 p(u) ∨ p(f (u))2 ¬p(v) ∨ p(f (w))3 ¬p(x) ∨ ¬p(f (x))

Resolvents

4 p(u) ∨ p(f (w)) (1, 2)5 p(u) ∨ ¬p(f (f (u))) (1, 3)

We’re only going to get clauses with 2 literals.However, we can factor (4) to p(f (w))Resolving with (3) gives ¬p(f (f (z))) then with p(f (w)) gives false

Giles Reger Lecture 10 February 2019 18 / 23

Page 20: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Missing Rule

Usually we also have the (positive) factoring rule

C ∨ l1 ∨ l2θ(C ∨ l1)

θ = mgu(l1, l2)

which is required in some cases

1 p(u) ∨ p(f (u))2 ¬p(v) ∨ p(f (w))3 ¬p(x) ∨ ¬p(f (x))

Resolvents

4 p(u) ∨ p(f (w)) (1, 2)5 p(u) ∨ ¬p(f (f (u))) (1, 3)

We’re only going to get clauses with 2 literals.However, we can factor (4) to p(f (w))Resolving with (3) gives ¬p(f (f (z))) then with p(f (w)) gives false

Giles Reger Lecture 10 February 2019 18 / 23

Page 21: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Missing Rule

Usually we also have the (positive) factoring rule

C ∨ l1 ∨ l2θ(C ∨ l1)

θ = mgu(l1, l2)

which is required in some cases

1 p(u) ∨ p(f (u))2 ¬p(v) ∨ p(f (w))3 ¬p(x) ∨ ¬p(f (x))

Resolvents

4 p(u) ∨ p(f (w)) (1, 2)5 p(u) ∨ ¬p(f (f (u))) (1, 3)

We’re only going to get clauses with 2 literals.However, we can factor (4) to p(f (w))Resolving with (3) gives ¬p(f (f (z))) then with p(f (w)) gives false

Giles Reger Lecture 10 February 2019 18 / 23

Page 22: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Missing Rule

Usually we also have the (positive) factoring rule

C ∨ l1 ∨ l2θ(C ∨ l1)

θ = mgu(l1, l2)

which is required in some cases

1 p(u) ∨ p(f (u))2 ¬p(v) ∨ p(f (w))3 ¬p(x) ∨ ¬p(f (x))

Resolvents4 p(u) ∨ p(f (w)) (1, 2)

5 p(u) ∨ ¬p(f (f (u))) (1, 3)

We’re only going to get clauses with 2 literals.However, we can factor (4) to p(f (w))Resolving with (3) gives ¬p(f (f (z))) then with p(f (w)) gives false

Giles Reger Lecture 10 February 2019 18 / 23

Page 23: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Missing Rule

Usually we also have the (positive) factoring rule

C ∨ l1 ∨ l2θ(C ∨ l1)

θ = mgu(l1, l2)

which is required in some cases

1 p(u) ∨ p(f (u))2 ¬p(v) ∨ p(f (w))3 ¬p(x) ∨ ¬p(f (x))

Resolvents4 p(u) ∨ p(f (w)) (1, 2)5 p(u) ∨ ¬p(f (f (u))) (1, 3)

We’re only going to get clauses with 2 literals.However, we can factor (4) to p(f (w))Resolving with (3) gives ¬p(f (f (z))) then with p(f (w)) gives false

Giles Reger Lecture 10 February 2019 18 / 23

Page 24: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Missing Rule

Usually we also have the (positive) factoring rule

C ∨ l1 ∨ l2θ(C ∨ l1)

θ = mgu(l1, l2)

which is required in some cases

1 p(u) ∨ p(f (u))2 ¬p(v) ∨ p(f (w))3 ¬p(x) ∨ ¬p(f (x))

Resolvents4 p(u) ∨ p(f (w)) (1, 2)5 p(u) ∨ ¬p(f (f (u))) (1, 3)

We’re only going to get clauses with 2 literals.However, we can factor (4) to p(f (w))Resolving with (3) gives ¬p(f (f (z))) then with p(f (w)) gives false

Giles Reger Lecture 10 February 2019 18 / 23

Page 25: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Fairness: Clause Selection

The above view is static, it assumes we have the saturated set

In reality we need to generate it but what if we infinitely delay performingan inference?

We lose the partial decidability

A saturation process is fair if no clause is delayed infinitely often

Two fair clause selection strategies:

First-in first-out

Smallest (in number of symbols) first

(there are a finite number of terms with at most k symbols)

Giles Reger Lecture 10 February 2019 19 / 23

Page 26: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Given Clause Algorithm

input: Init: set of clauses;

var active, passive, unprocessed : set of clauses;var given, new : clause;active := ∅; unprocessed := Init;loop

while unprocessed 6= ∅new:=pop(unprocessed);if new = 2 then return unsatisfiable;add new to passive

if passive = ∅ then return satisfiable or unknowngiven := select(passive); (* clause selection *)move given from passive to active;unprocessed:=infer(given, active); (* generating inferences *)

Giles Reger Lecture 10 February 2019 20 / 23

Page 27: Lecture 10 First-Order Logic Saturation-Based Reasoning ...syllabus.cs.manchester.ac.uk/ugt/2018/COMP24412/2018slides/lecture10.pdfLecture 10 First-Order Logic Saturation-Based Reasoning

Complete Example

∀x .(happy(x)↔ ∃y .(loves(x , y)))∀x .(rich(x)← loves(X ,money))

rich(giles)

� happy(giles)

Giles Reger Lecture 10 February 2019 21 / 23