Anda di halaman 1dari 15

Next: First Order Logic - Up: Advanced Knowledge Base Programming Previous: Propositional and Predicate Logic Subsections

Applying Modus Ponens Soundness of Modus Ponens Completeness of Modus Ponens Non-Horn Clause Example Normal Form o Normal Form Conversion Algorithm: Example of Normal Form Conversion Soundness and Completeness of Resolution Applying Resolution Key points

Propositional Logic - Rules of Inference


In this chapter we shall investigate several rules of inference and determine their soundness and completeness. We shall restrict ourselves First Order Logic sentences that do not contain variables. These are called groundsentences. Therefore our early results will be for Propositional Logic not full First Order Logic (this is covered in Chapter 4.

Applying Modus Ponens


In its simplest form Modus Ponens is expressed as:

We shall use the example in (Ginsberg, 1993, Page 126) to introduce these ideas. Suppose we have the situation described below: 1. 2. 3. 4. John is a lawyer Lawyers are rich Rich people have big houses Big houses are a lot of work to maintain

Representing this in First Order Logic, we get:


1. lawyer(john)

2. 3. 4.

P.lawyer(P) PH.house(P,H) H.big(H)

rich(P) rich(P) big(H) work(H) P.house(P,H)

This is not sufficient to represent the English since we must ensure that John has a house. So we ensure that the house-of function generates houses:
P.house(P,house-of(P))

So our logical sentences are


1. lawyer(john)

2.

P.lawyer(P)

rich(P)

3.
1. 2. 4.
P.house(P,house-of(P)) PH.house(P,H) rich(P) big(H) P.house(P,H) work(H)

H.big(H)

By writing these sentences in terms of john we have ground sentences and we can apply Modus Ponens as stated above.
1. lawyer(john)

2. lawyer(john)

rich(john)

3.
1. house(john,house-of(john))

2. house(john,house-of(john)) 4. big(house-of(john))
of(john))

rich(john)

big(house-of(john)) work(house-

house(john,house-of(john))

So now we start the inferences.

1. We can apply Modus Ponens


lawyer(john) rich(john)

(2)

lawyer(john)

(1)

rich(john)

(5)

2.
3.

Now we need to apply Modus Ponens to 3a, 5, and 3b, so we introduce an extended form of Modus Ponens:

4.
5.

Applying this to 3a, 5, and 3b gives


house(john,house-of(john)) rich(john) big(house-of(john))

(3b)

house(john,house-of(john)) rich(john)

(3a)

(5) (6).

big(house-of(john))

6. 7. Finally we can apply this extended form of Modus Ponens again


big(house-of(john)) house(john,house-of(john)) work(house-of(john))

(4)

big(house-of(john))

(6) (3a)

house(john,house-of(john))

work(house-of(john))

We in fact can give a generalised form of Modus Ponens that is equivalent to the earlier versions.

We can apply this rule three times to shorten the inference that John's house is a lot of work in the example above.

Soundness of Modus Ponens


Having seen the application of Modus Ponens to a logical problem, let us now investigate the properties associated with this rule of inference.

Proposition: Modus Ponens is sound. Proof: Suppose it is not sound. Then there is some model in which the premises of the Modus Ponens rule holds but the conclusion does not. Since the conclusion fails then it must be the case that holds - but It must also be the case that does not.

hold. Furthermore, since the 2nd premise in the Modus Ponens rule holds in this model then also holds. Therefore

holds and so from the 1st Modus Ponens rule premise

holds in the model.

This is a contradiction and so we have shown that every model in which the premises of Modus Ponens holds is also a model in which the conclusion holds. Therefore Modus Ponens is sound.

We should note that not all rules of inference are sound. As an example let us consider the very useful but unsound rule of inference - Abduction.

Proposition: Abduction is not sound. Proof: There is a model in which the premises of the Abductive rule holds but the conclusion does not; i.e. is false, and is true.

Examples include: If it rains then the pavements are wet the pavements are wet therefore it has rained! But the pavements may be wet for a completely different reason. However we may argue that this is a useful (despite being unsound) rule of inference since it is plausible to reason that it has rained. Now consider a doctor's diagnostic rule

If the patient has red spots then the patient has measles. Is the doctor applying a sound rule of inference when he is faced with a patient covered in red spots?

Completeness of Modus Ponens


The sentences in the examples above have all been of the form

Note: b and each

are atoms.

The facts like lawyer(john) fit this definition: T lawyer(john) The ``rules'' are also expressed as implications and so fit this definition. But what if we know only
lawyer(john) lecturer(john) rich(john) rich(john) rich(john)

or
lecturer(john) lawyer(john)

Neither of these sentences fit this definition, although is equivalent to


lawyer(john)

and so clearly does. We shall see that sentences of this form are important and so we name the class.

A Prolog program is a Horn database; it contains only Horn Clauses.

Proposition: Modus Ponens is complete for Horn databases. Proof: Suppose D is a Horn Clauses database and

D must contain a Horn Clause of the form

otherwise any model in which but does not.

hold but

does not will allow D to hold

Next apply Modus Ponens for each of the trivial Horn Clauses

for

The remaining task is to remove ``spare'' s. Suppose D must contain a Horn Clause of the form

for

. Then

otherwise any model in which hold but Apply Modus Ponens does not.

hold, but

and

do not, will allow D to

Repeat until only

are left and so

Horn databases and Modus Ponens are important because Horn Databases provide a effective representation; non-Horn implications are rare. Also notice that Horn databases with Modus Ponens are sound and complete. Furthermore, there is a simple deduction mechanism to apply using Modus Ponens: Deduction Algorithm: For each sentence in the database:

If there is a sentence then add to the database.

This means that every consequent of a Horn database containing no function constants is either in the database originally or added during the procedure. It can also be shown that determining whether an atom follows or not takes at most ND steps where N is the maximum number of antecedents in any implication and D is the number of Horn clauses in the database.

Non-Horn Clause Example


There exist databases that are not Horn databases; e.g. they contain disjunctions. Modus Ponens is not complete for these and so we must find a more general rule of inference. Suppose the IKBP lecturer must have all their teaching on Tuesday, and Thursday, or Monday and Friday. Suppose the two IKBP lectures must each occur at 9am. Suppose also that CS4 already has a class on Tuesday at 9am and CM3 already has a class on Friday at 9am. Can the two IKBP lectures be scheduled? No. Now try to represent this knowledge.

T T T

tt(ikbp, 0900)

mf(ikbp, 0900)

booked(tuesday, 0900) booked(friday, 0900) booked(tuesday, 0900) booked(friday, 0900) conflict(ikbp) conflict(ikbp)

tt(ikbp, 0900) mf(ikbp, 0900)

Applying Modus Ponens exhaustively allows us to deduce the following:


T tt(ikbp, 0900) mf(ikbp, 0900) tt(ikbp, 0900) mf(ikbp, 0900) conflict(ikbp) conflict(ikbp)

It is clear that IKBP cannot be scheduled for Tuesday / Thursday at 9am or Monday / Friday at 9am. But we have to reason by cases. The problem is that we need a more general representation than Horn clauses; here we need disjunctions as conclusions of

implications. If we enlarge the sentences to include disjunctions then we need a more general rule of inference to achieve completeness.

Normal Form
We need to define a more general form of sentence than Horn clauses that allow us to handle examples like the timetabling one above.

Although Horn Clauses are a proper subset of Predicate Logic, in fact any Predicate Logic database can be re-written in Normal Form using the following algorithm. Therefore, unlike Horn databases, databases in Normal Form are just as expressive as Predicate Logic. Normal Form Conversion Algorithm:
1. Eliminate using the 2. Use de Morgan's Laws1

fact that

is equivalent to

so that negation applies to atoms only.

3. Apply the Distribution Laws2


to write the result as a conjunction of disjunctions. 4. Split the conjunction. 5. Combine the negated terms.

6. Re-introduce

to get sentences in normal form.

Example of Normal Form Conversion


If a house is big and old then it is a lot of work to maintain unless it comes with a cleaning lady and does not have a garden.
big(house) work(house) old(house) garden(house))

(cleaner(house)

1.

Eliminate
(big(house) work(house) old(house)) (cleaner(house) garden(house))

2. De Morgan
big(house) work(house) old(house) (cleaner(house) garden(house))

3. Distribute ( (
big(house) big(house) old(house) old(house) work(house) work(house) cleaner(house)) garden(house))

4. Split
big(house) big(house) old(house) old(house) work(house) work(house) cleaner(house) garden(house)

5. De Morgan
(big(house) (big(house) old(house)) old(house) work(house) garden(house)) cleaner(house) work(house)

6.

Re-introduce
(big(house) (big(house) old(house)) old(house) (work(house) garden(house)) cleaner(house)) work(house)

Soundness and Completeness of Resolution

Applying the Resolution Rule to our timetabling example we can infer that
T T mf(ikbp, 0900) conflict(ikbp) T conflict(ikbp) conflict(ikbp)

and applying resolution again gives and hence


conflict(ikbp)

Proposition: The Resolution Rule is sound. Proof: Similar to before

Proposition: The Resolution Rule is complete.

Proof: See (Ginsberg, 1993, Pages 139-140) for a proof with respect to Normal Form databases. However any Predicate Logic database can be converted to Normal Form and so the result holds in general.

Applying Resolution
Suppose we have a database derive a contradiction ( and a query . We add ) using resolution; thus to our database and then is true.

Suppose our query is work(house-of(john)). Negating gives us


work(house-of(john)); T

i.e.

work(house-of(john))

but this is not in Normal Form since the conclusion of the implication is not a disjunction of atoms. However it is equivalent to
work(house-of(john)) F

This is in Normal Form and so can be used with Resolution. Our database is:
1. T lawyer(john) 2. lawyer(john) rich(john)

3.
1. T house(john,house-of(john)) 2. house(john,house-of(john)) rich(john) 4. big(house-of(john))
of(john)) house(john,house-of(john)) big(house-of(john)) work(house-

The Backward Chaining Reasoning can be noted formally as:


Sentence Source

(i) (ii) (iii) (iv) (v) (vi) (vii)


big(house-of(john))

work(house-of(john)) house(john,house-of(john)) big(house-of(john)) house(john,house-of(john)) rich(john) rich(john) lawyer(john) T

F F F F F F F

negated query resolve (i),4 resolve (ii), 3a resolve (iii), 3b resolve (iv), 3a resolve (v), 2 resolve (vi), 1

Notice that this demonstrates our normal backward chaining reasoning:


the goal work(house-of(john)) is changed into the sequence of subgoals


big(house-of(john), rich(john), lawyer(john).

Key points

Modus Ponens is sound for Propositional Logic. Modus Ponens is complete for Propositional Horn Clause databases. Resolution is both sound and complete for Propositional Logic.

Next: First Order Logic - Up: Advanced Knowledge Base Programming Previous: Propositional and Predicate Logic Susan Craw (s.craw@comp.rgu.ac.uk)
sdd

Anda mungkin juga menyukai