• No results found

Lecture 8: Resolution theorem-proving

N/A
N/A
Protected

Academic year: 2022

Share "Lecture 8: Resolution theorem-proving"

Copied!
36
0
0

Loading.... (view fulltext now)

Full text

(1)

Comp24412 Symbolic AI

Lecture 8: Resolution theorem-proving

Ian Pratt-Hartmann

Room KB2.38: email: [email protected]

2014–15

(2)

In the previous Lecture, we met SATCHMO, a first-order theorem-prover implemented in a single page of Prolog.

It has nice termination properties, but it not practically very useful.

This lecture introduces a more serious approach to constructing proofs in first-order logic: resolution.

Resolution is the basis of many widely-used theorem-provers today.

(3)

We would like to be able to determine logical relationships such as validity

For example,

∀x(artist(x) → ∃y (beekeeper(y ) ∧ admire(x, y )))

∀x(beekeeper(y ) → ∀y (artist(y ) ∧ admire(y , x) → despise(x, y )))

∀x(artist(x) → ∃y (beekeeper(y ) ∧ despises(y , x) ∧ admire(x, y )))

(4)

Here is a more complex example

∀x∀y ∀z(p(x, y ) ∧ p(y , z) → p(x, z))

∀x∀y ∀z(q(x, y ) ∧ q(y , z) → q(x, z))

∀x∀y (p(x, y ) → p(y , x))

∀x∀y (p(x, y ) ∨ q(x, y ))

∀x∀yp(x, y ) ∨ ∀x∀yq(x, y )

(5)

As with Satchmo, we first convert toclause form.

Aliteral is an atomic formula or an atomic formula prefixed by

¬.

Thus, p, q(a), ¬r (x , y ) are all literals; p ∨ p, q(x ) ∧ p and

¬¬r (x, y ) are not literals.

A clauseis a literal or a collection of literals all joined by ∨.

Thus ¬p, p ∨ q(x ), ¬p(a) ∨ ¬r (a, b) ∨ r are all clauses;

p ∧ q(a), p → p and ¬¬r (x , y ) are not clauses.

(6)

The following result is easily established:

Let ϕ be a quantifier-free formula. Then there exist clauses C1, . . . , Cn such that

|= ϕ ↔ (C1∧ C2∧ . . . ∧ Cn).

In other words, any quantifier-free formula is logically equivalent to the conjunction of some collection of clauses.

(7)

A formula in the predicate calculus in which all the quantifiers are at the front is said to be inprenex form.

The formulas

∀x(man(x) → mortal(x))

∀x∃y loves(x, y ) are in prenex form

The formulas

∀x(boy(x) → ∃y (girl(y ) ∧ loves(x, y )))

∀x((boy(x) ∧ ∃y (girl(y ) ∧ loves(x, y ))) → happy(x)) are not.

(8)

The following result can easily be established:

Let ϕ be a formula. Then there exists a prenex form formula ψ such that

|= ϕ ↔ ψ.

In other words, any formula is logically equivalent to a formula with all the quantifiers at the front.

(9)

Example

∀x(boy(x) →∃y(girl(y ) ∧ loves(x , y ))) is equivalent to

∀x∃y(boy(x ) → (girl(y ) ∧ loves(x , y )))

Example

∀x((boy(x) ∧ ∃y(girl(y ) ∧ loves(x , y ))) → happy(x )) is equivalent to

∀x∀y((boy(x ) ∧ girl(y ) ∧ loves(x , y )) → happy(x ))

(10)

Given a prenex formula, existential quantifiers can be eliminated.

Consider

(∃x )(man(x ) ∧ philosopher(x ))

This is equisatisfiablewith

man(a) ∧ philosopher(a).

(This name must be new: i.e. not occurring in any other formulas.)

Similarly

(∃y )(∀x )(loves(x , y )) is equisatisfiable with

(∀x )(loves(x , b)).

(11)

Things are different however, for:

(∀x )(∃y )(loves(x , y )).

This formula is equisatisfiable with:

(∀x )(loves(x , f (x )))

where f is a function (called aSkolem function).

Note the use of a function (rather than a constant): the formula says that everyone loves someone or other – but not necessarily the same person.

We need a function whenever we want to eliminate an existential quantifier which is to the right of some universal quantifiers.

(12)

These new constants and functions are called Skolem constantsand Skolem functions, respectively.

The process of replacing existentially quantified variables with Skolem constants and functions is called Skolemization.

Notice that Skolemization does not produce logically equivalent formulas; but it does produce equisatisfiable formulas.

(13)

Suppose then, we put a formula ϕ in prenex form, and Skolemize.

The result will be

∀x1. . . ∀xnχ where χ is quantifier-free.

But the universal quantifiers convey no information any more, so we might as well write:

χ

Now we replace χ (the quantifier-free rump) by an equivalent collection of clauses.

The result is said to be theclause form for ϕ.

(14)

So we can massage any formula of the predicate calculus into a collection of clause form expressions (containing variables) of the form

L1∨ . . . ∨ LN where the Li are literals

Example:

∀x(boy(x) → ∃y (girl(y ) ∧ love(x, y ))) has, as its clausal form,

¬boy(x) ∨ girl(f (x)) ¬boy(x) ∨ love(x, f (x))

Since we can equisatisfiably convert to clausal forms, we need only inference procedures which work on clausal forms.

(15)

First, we look at the ground case.

The rulemodus ponens:

p → q p

q

Re-writing:

¬p ∨ q p

q

Generalizing to longer clauses:

¬p ∨ C p ∨ D

C ∨ D

(16)

This gives us a way to make inferences.

Consider the formulas

boy(john) → (girl(mary) → loves(john, mary)), boy(john), girl(mary), ¬loves(john, mary).

It should be obvious that these formulas are not (simultaneously satisfiable)

In clausal form:

¬boy(john) ∨ ¬girl(mary) ∨ loves(john, mary), boy(john), girl(mary), ¬loves(john, mary).

(17)

We can apply resolution repeatedly as follows:

¬loves(j, m)

boy(j)

girl(m) ¬boy(j) ∨ ¬girl(m) ∨ loves(j, m)

¬boy(j) ∨ loves(j, m) loves(j, m)

⊥.

Since the empty clause ⊥ has been derived, it is evident (even to a computer) that the formulas we started with are not satisfiable.

(18)

This gives us a way to test validity.

For suppose we want to test whether ϕ1, . . . ϕn|= ψ.

We convert

ϕ1, . . . ϕn, ¬ψ

to clausal form and try to use resolution and factoring to obtain a contradiction. If we succeed, the sequent is valid.

In particular, we have shown the validity of the argument with premises

boy(john) → (girl(mary) → loves(john, mary)) boy(john) girl(mary)

and conclusionloves(john, mary).

(19)

Next, we look at the non-groundcase.

To apply resolution to non-ground clauses, we need the concept of unification.

If A and A0 are atoms, we say that A and A0 are unifiable if there is a substitution σ of terms for variables such that Aσ = A0σ.

(20)

Example 1:

man(x ) man(socrates) unify, under the substitution σ : x 7→ socrates.

Example 2:

q(x , f (x )) q(u, v )

unify, under the substitution σ : u 7→ x ; v 7→ f (x ).

Example 3:

p(x ) q(u)

do not unify.

Example 4:

p(x , f (x )) p(f (y ), y ) do not unify either.

(21)

We noted that

q(x , f (x )) q(u, v ) unify, under the substitution

σ : u 7→ x ; v 7→ f (x ) making the common term

q(x , f (x )).

But they also unify under the substitution, say, σ : u 7→ a; v 7→ f (a); x 7→ a, making the common term

q(a, f (a)).

(22)

If A and A0 are unifiable, then there is a substitution θ such that Aθ = A0θ and, for any substitution σ such that

Aσ = A0σ, we have σ = θρ for some substitution ρ.

We say that θ is a most general unifier (m.g.u).

The m.g.u. is unique up to renaming of variables.

It can be efficiently computed . . .

(23)

Now back to the analogue of modus ponens for non-ground clauses:

¬p(x) ∨ q(x) p(a)

q(a) .

Generalizing again:

¬A ∨ C A0∨ D

(C ∨ D)θ ,

where A and A0 areunifiable atoms withm.g.u. θ

This rule of inference is known as theresolution rule

(24)

It is obvious that we can remove repeated literals from clauses:

p ∨ p ∨ p ∨ C p ∨ C ,

Generalizing to the non-ground case gives thefactoring rule:

C (C θ)0,

with θ the m.g.u of some literals in C and 0 denoting deletion of repeated literals

(25)

Again, we can use resolution and factoring to construct proofs:

¬lv(john, mary)

boy(john)

girl(mary) ¬boy(x) ∨ ¬girl(y ) ∨ lv(x, y )

¬boy(x) ∨ lv(x, mary) lv(john, mary)

⊥.

If clause C is derivable from a set C of clauses by means of resolution and factoring, we write C ` C .

(26)

As before, this gives us a way to make inferences.

Consider the formulas

∀x(boy(x) → ∀y (girl(y ) → loves(x, y ))) boy(john)

girl(mary) ¬loves(john, mary).

In clausal form:

¬boy(x) ∨ ¬girl(y ) ∨ loves(x, y ) boy(john)

girl(mary) ¬loves(john, mary).

But these clauses imply ⊥.

Therefore, the original set of formulas is unsatisfiable.

(27)

As before: to test whether

ϕ1, . . . ϕn|= ψ,

convert

ϕ1, . . . ϕn, ¬ψ

to clausal form and try to use resolution and factoring to obtain a contradiction.

If you succeed, the sequent is valid

(28)

In particular, in showing that the set of formulas

∀x(boy(x) → ∀y (girl(y ) → loves(x, y ))) boy(john)

girl(mary) ¬loves(john, mary).

is unsatisfiable, we have shown that the argument

∀x(boy(x) → ∀y (girl(y ) → loves(x, y ))) boy(john)

girl(mary) loves(john, mary) is valid.

(29)

In fact, the following result can be proved:

Theorem

Let C be a set of clauses. Then C ` ⊥ if and only if the universal closure of C is unsatisfiable.

This means that resolution and factoring are all the rules we need to determine entailments

We say that the proof system in question is (sound and) complete.

To think about: Why does this not give us an algorithm for testing validity?

(30)

Let A be the collection of all atoms (over some signature).

Let ≺ be a partial order on A.

We say that ≺ is an A-ordering if, for all substitutions θ, A ≺ A0 implies Aθ ≺ A0θ.

We extend any A-ordering ≺ to literals by ignoring negations.

(31)

Example of A-ordering:

A ≺2 A0 iff A involves a unary predicate and A0 involves a binary predicate.

Example of A-ordering:

A ≺d A0 iff d (A) < d (A0) and

d (x , A) < d (x , A0) for all variables x in A, where d (A) is the depth of A and d (x , A) is the term depth of x in A.

(32)

Given an A-ordering ≺, ordered resolution is the same as resolution, namely

¬A ∨ C A0∨ D

(C ∨ D)θ ,

subject to the added restriction that, for every literal L in C , A 6≺ L, and for every literal L0 in D, A06≺ L0.

Similarly with ordered factoring.

If clause C is derivable from a set C of clauses by means of

≺-ordered resolution and factoring, we write C `C .

(33)

Amazingly, ordering restrictions never compromise completeness

Theorem

Let C be a set of clauses and ≺ an A-ordering. Then C `⊥ if and only if C is unsatisfiable.

(34)

Let us say that the1-variable fragment is the set of clauses C satisfying either of the following conditions:

every literal of C is ground;

there is a variable x such that, for every literal L of C , Vars(L) = {x }.

The clauses

p(a) ∨ q(b, f (a)), p(x ) ∨ ¬r (h(x , g (x )), x ) are in the 1-variable fragment, but

p(a) ∨ q(x , f (a)), p(x ) ∨ ¬r (y , x ) are not in the 1-variable fragment.

Note that resolution and factoring preserve membership in the 1-variable fragment.

(35)

In general, resolution increases the functional depth of clauses:

p(x ) ∨ q(fx ) ¬r (gx0) ∨ s(x0) ∨ ¬q(x0) p(x ) ∨ ¬r (gfx ) ∨ s(fx )

However, ≺d-ordered resolution and factoring do not:

p(x ) ∨ q(fx ) ¬r (x0) ∨ s(x0) ∨ ¬q(x0) p(x ) ∨ ¬r (fx ) ∨ s(fx )

(36)

Suppose we take a set C of clauses in the 1-variable fragment, and keep applying resolution and factoring to them.

Obviously, only clauses featuring the signature of C will be generated.

Because the functional depth is not increased, the total number of clauses that can be generated from C by

d-ordered resolution and factoring is bounded by an exponential function of the size of the signature.

Hence, the satisfiability of clauses in the 1-variable fragment (with a fixed depth-bound) can be algorithmically decided in exponential time.

References

Related documents

7 On the other hand, the theme of the mistress-servant relationship in the genre of Scholar-Beauty Romance, as the most common literary representation revolving around intimate

Of the 200 cancer patient cores, 34% of theintestinal type gastric cancers showed high expression for HE4, compared with 40% with low levels of expression and 26% that displayed

This fee shall be applicable for new connection, tatkal temporary connection, temporary connection, reduction and enhancement of load (depending on the final load),

Hydraulic oils based on synthetic esters now deliver very good properties with regard to shear stability (based on a natural, high VI), oxidation and hydrolytic stability..

If you want to take yourself (and your girlfriend) to the seventh heaven, following the anal path, there are some things you must take into consideration first. I think about anal

Interestingly, atelic predicates give rise to event- in-progress readings and telic non-past predicates give rise to future readings in the absence of future-oriented contexts

 主観的幸福感の測定自体の問題、推計におけるモデルの問題や因果関係の

Some of the tourists are like for the academician and researchers purpose; however still most of the informants agreed that as it is the home of lots of ancient potentials in