automated reasoning systems

41
Automated Reasoning Systems Automated Reasoning Systems For first order Predicate Logic For first order Predicate Logic

Upload: shannon-mcleod

Post on 03-Jan-2016

23 views

Category:

Documents


1 download

DESCRIPTION

Automated Reasoning Systems. For first order Predicate Logic. Is F a logical consequence of T ?. AR: general context. Given is a knowledge base in predicate logic: T. is a set of formulae in first order logic formally also called: a “Theory’’. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Automated Reasoning Systems

Automated Reasoning SystemsAutomated Reasoning Systems

For first order Predicate LogicFor first order Predicate Logic

Page 2: Automated Reasoning Systems

2

AR: general context.AR: general context. Given is a knowledge base in predicate logic: Given is a knowledge base in predicate logic: TT

is a set of formulae in first order logicis a set of formulae in first order logic

formally also called: a formally also called: a “Theory’’“Theory’’

Given is also an additional first order formula: Given is also an additional first order formula: FF

Is Is FF a logical consequence of a logical consequence of TT ? ? Notation: Notation: T T |=|= FF ( (T T impliesimplies F F) )

Find reasoning techniques that allow to decide Find reasoning techniques that allow to decide

on this for EACH on this for EACH FF and and TT..

RequirementsRequirements:: correctness -- completeness -- efficiencycorrectness -- completeness -- efficiency

Page 3: Automated Reasoning Systems

3

AR: decidability.AR: decidability.

There There CANNOT EXIST AN ALGORITHMCANNOT EXIST AN ALGORITHM that decides that decides

whether whether TT |=|= FF, for any theory , for any theory TT and any formula and any formula FF..

Theorem Church ‘36:Theorem Church ‘36:

There exists a reasoning techniqueThere exists a reasoning technique, such that for , such that for

any theory any theory TT and formula and formula FF, such that , such that TT |=|= FF, the , the

reasoning technique reasoning technique provesproves TT |= |= FF..

SOSO: if : if FF follows from follows from TT, then we find a proof, else it , then we find a proof, else it

is possible that the procedure doesn’t terminate.is possible that the procedure doesn’t terminate.

BUT: semi-decidable ! BUT: semi-decidable !

Completeness Theorem of Goedel ‘31:Completeness Theorem of Goedel ‘31:

Page 4: Automated Reasoning Systems

4

Wrong !Wrong ! Let: Let: T =T = {{smart(Kelly)smart(Kelly)}} en en F =F = strong(Kelly)strong(Kelly) Although Although strong(Kelly) strong(Kelly) ~strong(Kelly)~strong(Kelly) is always is always

true, we have:true, we have: neither: neither: {{smart(Kelly)smart(Kelly)}} |= |= strong(Kelly)strong(Kelly) nor: nor: {{smart(Kelly)smart(Kelly)}} |= |= ~strong(Kelly)~strong(Kelly)

The theorems of Church and Goedel are The theorems of Church and Goedel are contradicting: We can try to prove F and ~F in contradicting: We can try to prove F and ~F in parallel, and according to Goedel’s theorem one of parallel, and according to Goedel’s theorem one of these must succeed after a finite time. these must succeed after a finite time.

Wait a second ...Wait a second ...

Page 5: Automated Reasoning Systems

5

AR: general outline (1).AR: general outline (1). First we sketch First we sketch the most generally used approach the most generally used approach

for automated reasoning in first-order logic:for automated reasoning in first-order logic:

backward resolutionbackward resolution

The The different technical componentsdifferent technical components will only be will only be explained in full detail in a second pass (explained in full detail in a second pass (outline outline (2)(2)).).

Page 6: Automated Reasoning Systems

6

AR: general outline (2) .AR: general outline (2) . We study We study different subsetsdifferent subsets of predicate logic: of predicate logic:

ground Horn clause logicground Horn clause logic Horn clause logicHorn clause logic Clausal logic Clausal logic full predicate logicfull predicate logic

In In each caseeach case we study semi-deciding we study semi-deciding procedures. procedures.

Each extension requires the introduction of Each extension requires the introduction of new new techniquestechniques..

Page 7: Automated Reasoning Systems

Backward Reasoning ResolutionBackward Reasoning Resolution

… … in a nutshellin a nutshell

Page 8: Automated Reasoning Systems

8

Backward resolution:Backward resolution:

0) The task: an example. 0) The task: an example.

1) Proof by inconsistency. 1) Proof by inconsistency.

2) Conversion to clausal form. 2) Conversion to clausal form.

3) Unification.3) Unification.

4) The resolution step.4) The resolution step.

5) (Backward) resolution proofs.5) (Backward) resolution proofs.

Page 9: Automated Reasoning Systems

9

0) The TASK (example):0) The TASK (example):

Are axioms:Are axioms: describe knowledge about some describe knowledge about some world. world.

z ~ q(z)z ~ q(z)y p(f(y))y p(f(y))x p(x) x p(x) q(x) q(x) r(x) r(x)

TT

How to prove such theorems in general?How to prove such theorems in general?

u u r(f(u))r(f(u))

In this world, is In this world, is always always true ?true ?

FF

pp = parent= parentff = father= fatherrr = rich= richqq = old= old

Page 10: Automated Reasoning Systems

10

1) Proof by inconsistency1) Proof by inconsistency

u u r(f(u))r(f(u))

FF Don’t prove Don’t prove FF directly: directly:

But add the But add the negationnegation of of FF to the axioms and to the axioms and prove that this extension is inconsistent. prove that this extension is inconsistent.

~ ~ u r(f(u))u r(f(u)) z ~ q(z)z ~ q(z)y p(f(y))y p(f(y))x p(x) x p(x) q(x) q(x) r(x) r(x)

NEW TASK:NEW TASK:

is inconsistent.is inconsistent.

the 4 axioms are never true in 1 same the 4 axioms are never true in 1 same interpretation. interpretation.

Page 11: Automated Reasoning Systems

11

2) Clausal form:2) Clausal form:= Normalize the formulae to a (more simple) standard form. = Normalize the formulae to a (more simple) standard form.

NoticeNotice: “: “xx y …y … zz““ can be dropped.can be dropped.

EachEach set of axioms can be transformed into a new set of axioms can be transformed into a new set of formulae, that contains set of formulae, that contains onlyonly formulae of the formulae of the form:form:xxy…y…zz p(…)p(…) q(…)q(…) …… r(…)r(…) t(…) t(…) s(…)s(…) … … u(…)u(…)

which is which is inconsistentinconsistent if and only ifif and only if the original set the original set was inconsistent.was inconsistent.

only left; only left; only right only right no no ~~ ; no ; no

Page 12: Automated Reasoning Systems

12

Example:Example:

PsPs: usually requires much more work! : usually requires much more work!

: is already in clausal form: ( P : is already in clausal form: ( P P P truetrue))

~ ~ u u r(f(u))r(f(u))

u false u false r(f(u)) r(f(u))

z ~ z ~ q(z)q(z)

z false z false q(z) q(z)

y p(f(y))y p(f(y))

x p(x) x p(x) q(x) q(x) r(x) r(x)

x q(x) x q(x) r(x) r(x) p(x) p(x)

Page 13: Automated Reasoning Systems

13

3) Unification:3) Unification: Given 2 atomic formulae:Given 2 atomic formulae:

ExEx.: p(f(A),y) p(x, g(x)).: p(f(A),y) p(x, g(x))

find their find their most general common instancemost general common instance..

ExEx.: x must become: f(A).: x must become: f(A)

g(x) must become: g(f(A))g(x) must become: g(f(A))

y must become: g(f(A))y must become: g(f(A))

p(f(A), g(f(A)))p(f(A), g(f(A)))

Most general unifier (Most general unifier (mgumgu) : x -> f(A)) : x -> f(A) y -> g(f(A))y -> g(f(A))

Page 14: Automated Reasoning Systems

14

4) The resolution step4) The resolution step Proposition logic:Proposition logic:

P P QQPP Q Q

P P QQ ~Q~Q~P ~P

P1P1 P2P2 … … Pn Pn Q1Q1 ...... QmQmR1 R1 … … RkRk P1P1 S1S1 … … SlSlP2P2 … … Pn Pn R1 R1 … … RkRk Q1Q1 ...... Qm Qm S1S1 … … SlSl

Q Q P PP P true trueQQ true true

Q Q P Pfalse false Q Q false false P P

Page 15: Automated Reasoning Systems

15

De resolutie step (2):De resolutie step (2): Predicate logic:Predicate logic:

Example:Example:p(p(xx,,f(A)f(A))) q(g( q(g(xx))))

r(r(zz) ) p(p(BB,,zz))

r(r(f(A)f(A)) ) q(g( q(g(BB)) )) mgu(mgu(p(p(xx,,f(A)f(A))),, p(p(BB,,zz)) )) == xx -> -> BB zz -> -> f(A)f(A)

= mgu = mgu applied toapplied to r(r(zz) ) q(g(q(g(xx))))

Clauses on which resolution is performed Clauses on which resolution is performed must not have any variables in common. must not have any variables in common.

Page 16: Automated Reasoning Systems

16

5) Resolution proofs:5) Resolution proofs:

In order to prove a set of clauses inconsistent:In order to prove a set of clauses inconsistent:

select 2 of them, for which resolution is possibleselect 2 of them, for which resolution is possible

apply resolution and add the result to the setapply resolution and add the result to the set

ifif you obtain the clause you obtain the clause false false : : STOP !STOP !

This means inconsistency of the last setThis means inconsistency of the last set

AND AND inconsistency of the original setinconsistency of the original set

ANDAND that that FF was implied by was implied by TT

Page 17: Automated Reasoning Systems

17

Example:Example:

q(x) q(x) r(x) r(x) p(x) p(x) false false r(f(u)) r(f(u))

false false q(z) q(z)

p(f(y))p(f(y))

q(f(u)) q(f(u)) p( p(f(u)f(u)) )

x -> f(u)x -> f(u)

false false p( p(f(u)f(u)))

z -> f(u)z -> f(u)

false false

y -> uy -> u SoSo: inconsistent !: inconsistent !

Page 18: Automated Reasoning Systems

A deeper study:A deeper study:

Modus ponensModus ponensGround Horn LogicGround Horn Logic

UnificationUnificationHorn LogicHorn Logic

ResolutionResolution Clausal LogicClausal Logic

NormalizationNormalizationFull Predicate LogicFull Predicate Logic

Page 19: Automated Reasoning Systems

19

Horn clause logicHorn clause logic

x1 … xk A B1 B2 … Bn

All formulae in All formulae in TT are of the form: are of the form:

where where A, B1, B2,…,BnA, B1, B2,…,Bn are are atomsatoms.. An An atomatom is a formula of the form is a formula of the form p(p(t1,…,tmt1,…,tm)), with , with

pp a predicate symbol and a predicate symbol and t1,…,tmt1,…,tm terms. terms. Horn clause formulae are Horn clause formulae are universally quantifieduniversally quantified

over all variables that occur in them.over all variables that occur in them. B1,…,BnB1,…,Bn are called are called body-atomsbody-atoms of the Horn of the Horn

clause; clause; AA is the is the headhead of the Horn clause. of the Horn clause. nn may be 0: in this case we say that the Horn may be 0: in this case we say that the Horn

clause is a clause is a factfact..

Page 20: Automated Reasoning Systems

20

Wich kind of formulaeWich kind of formulaecan we prove?can we prove?

x1 … xk B1 B2 … Bn

In Horn clause logic, we limit ourselves to prove In Horn clause logic, we limit ourselves to prove formulae formulae FF of the form: of the form:

where where B1, B2, …, BnB1, B2, …, Bn are again atoms. are again atoms.

All variables are existentially quantified ! All variables are existentially quantified !

Page 21: Automated Reasoning Systems

21

A very simple example:A very simple example: Bosmans is a showmaster Bosmans is a showmaster

(1)(1)

Showmasters are rich (2)Showmasters are rich (2)

Rich people have big houses (3)Rich people have big houses (3)

Big houses need a lot of maintenance (4)Big houses need a lot of maintenance (4)Goal:Goal: automatically deduce that Bosmans’ house automatically deduce that Bosmans’ house

needs a lot of maintenance. needs a lot of maintenance.

Page 22: Automated Reasoning Systems

22

Representation in Horn logica:Representation in Horn logica:

Bosmans is a showmaster Bosmans is a showmaster (1)(1)

Showmasters are rich (2)Showmasters are rich (2)

Rich people have big houses (3)Rich people have big houses (3)

Big houses need a lot of maintenance Big houses need a lot of maintenance (4)(4)

To prove:To prove:

showmaster(Bosmans)showmaster(Bosmans)

p rich(p) p rich(p) showmaster(p) showmaster(p)

p big(house(p)) p big(house(p)) rich(p) rich(p)

p lot_maint(house(p)) p lot_maint(house(p)) big(house(p)) big(house(p))

Lot_maint(house(Bosmans))Lot_maint(house(Bosmans))

Page 23: Automated Reasoning Systems

AR for ground AR for ground Horn clause logicHorn clause logic

Backward reasoning proof procedures Backward reasoning proof procedures based on generalized Modus Ponensbased on generalized Modus Ponens

Page 24: Automated Reasoning Systems

24

Restricting to groundRestricting to groundHorn clauses: Horn clauses:

showmaster(Bosmans)rich(Bosmans) showmaster(Bosmans)big(house(Bosmans)) rich(Bosmans)lot_maint(house(Bosmans)) big(house(Bosmans))

So, for now: Horn clauses without variables:So, for now: Horn clauses without variables: Example:Example:

lot_maint(house(Bosman))

Prove:Prove:

Page 25: Automated Reasoning Systems

25

Easy with modus ponens !Easy with modus ponens !

big(house(Bos)) rich(Bos)big(house(Bos))

3 applications of modus ponens:3 applications of modus ponens:

showm(Bos)rich(Bos) showm(Bos)rich(Bos)

gives the desired conclusion.gives the desired conclusion.

lot_maint(house(Bos)) big(house(Bos))lot_maint(house(Bos))

Page 26: Automated Reasoning Systems

26

Modus ponens in AR:Modus ponens in AR:

BA B

A

For any interpretation making both B and A B true (= any model of {B , A B} )

Modus ponens is correct:Modus ponens is correct:

A is also true in this interpretation (see truth tables)

ProblemProblem: how to organize this into a procedure : how to organize this into a procedure which is also which is also completecomplete (for ground Horn clauses)?(for ground Horn clauses)?

Page 27: Automated Reasoning Systems

27

Inconsistency:Inconsistency:

T implies F iff Each model of T makes F true iff Each model of T makes ~F false iff T {~F} has no model iff T {~F} is inconsistent

A theory A theory TT is inconsistent if it has NO model. is inconsistent if it has NO model.

Let T be a theory and F a formula.T implies F if and only if T {~F} is inconsistent.

TheoremTheorem::

Proof:Proof:

Page 28: Automated Reasoning Systems

28

The extended example:The extended example: Prove that the Prove that the

theory:theory:showm(Bos)belg(Bos)european(Bos) belg(Bos)rich(Bos) showm(Bos) european(Bos)big(house(Bos)) rich(Bos)lot_maint(house(Bos)) big(house(Bos))~ lot_maint(house(Bos))

is inconsistent.is inconsistent.

Problem:Problem: this is NOT a Horn clause theory !? this is NOT a Horn clause theory !?

Page 29: Automated Reasoning Systems

29

Refutation proofs:Refutation proofs:the “false” predicate the “false” predicate

false

We introduce a new predicate symbol:We introduce a new predicate symbol:

We agree that We agree that falsefalse has the truth value ‘false’ has the truth value ‘false’ under under everyevery interpretation. interpretation.

Imagine that we defined Imagine that we defined falsefalse as : as : falsefalse p p ~p ~p

for some predicate for some predicate pp

Page 30: Automated Reasoning Systems

30

““definite” goals:definite” goals: In the Horn logic setting In the Horn logic setting FF has the form: has the form:

x1 … xm B1 B2 … Bn

So what is the form of So what is the form of ~F~F??

~(x1 … xm B1 B2 … Bn)

x1 … xm ~(B1 B2 … Bn)

x1 … xm false ~(B1 B2 … Bn)

x1 … xm false B1 B2 … BnA ~B A B

Observe: Observe: ~F~F is again a Horn clause !! is again a Horn clause !!

Page 31: Automated Reasoning Systems

31

Back to the exampleBack to the example

a ground Horn clause theory !a ground Horn clause theory !

showm(Bos)belg(Bos)european(Bos) belg(Bos)rich(Bos) showm(Bos) european(Bos)big(house(Bos)) rich(Bos)lot_maint(house(Bos)) big(house(Bos))false lot_maint(house(Bos))

The extended theory (to be proven The extended theory (to be proven inconsistent) now is:inconsistent) now is:

Page 32: Automated Reasoning Systems

32

Modus ponensModus ponensgeneralized:generalized:

Ordinary Modus ponens is the special case with:Ordinary Modus ponens is the special case with: n = i = 1 and m =0n = i = 1 and m =0

CorrectnessCorrectness: via truth tables: via truth tables

A B1 B2 … Bi … BnBi C1 C2 … Cm

A B1 B2 … C1 C2 … Cm … Bn

Page 33: Automated Reasoning Systems

33

Some backward reasoning steps Some backward reasoning steps in the example:in the example:

and so on ...and so on ...

false lot_maint(house(Bos))lot_maint(house(Bos)) big(house(Bos))

false big(house(Bos))

false big(house(Bos))big(house(Bos)) rich(Bos)

false rich(Bos)

Page 34: Automated Reasoning Systems

34

The backward procedure:The backward procedure:the ideathe idea

Convert Convert FF into a definite goal: into a definite goal:

false B1 B2 … Bi … Bn

Apply generalized modus ponens to the body-Apply generalized modus ponens to the body-atoms atoms BiBi of the goal, using the Horn clauses of of the goal, using the Horn clauses of TT

untiluntil: is deduced.: is deduced. false

Then:Then: a false formula ia a consequence of a false formula ia a consequence of T T {~F}{~F}

we have proven inconsistency ofwe have proven inconsistency of T T {~F} {~F}

Page 35: Automated Reasoning Systems

35

Backwards procedureBackwards procedure

On top of this you need to apply On top of this you need to apply backtrackingbacktracking over over the selected clauses and the selected body atoms.the selected clauses and the selected body atoms.

If the algorithm stops because it has tried all these If the algorithm stops because it has tried all these alternatives: alternatives: FF was was notnot implied! implied!

Goal Goal := := false false B1 B1 B2 B2 … … Bn Bn ; ;RepeatRepeat

Select someSelect some BiBi atom from the body of atom from the body of GoalGoal Select some clauseSelect some clause Bi Bi C1 C1 C2 C2 … … Cm Cm fromfrom TT

ReplaceReplace BiBi in the body of in the body of GoalGoal by by C1 C1 C2 C2 … … Cm Cm

UntilUntil GoalGoal = = false false or no more Selections possible or no more Selections possible

Page 36: Automated Reasoning Systems

36

Back to the exampleBack to the exampleStep 0: Goal := false lot_maint(house(Bos)) select: lot_maint(house(Bos)) big(house(Bos)) Step 1: Goal := false big(house(Bos)) select: big(house(Bos)) rich(Bos)Step 2: Goal := false rich(Bos) select: rich(Bos) showm(Bos) european(Bos)Step 3: Goal := false showm(Bos) european(Bos) select: showm(Bos)Step 4: Goal := false european(Bos) select: european(Bos) belg(Bos)Step 5: Goal := false belg(Bos) select: belg(Bos)Step 6: Goal := false

Page 37: Automated Reasoning Systems

37

p p q q r rq q t tq q s s

r r n nr r o ossoonn

Another example (propositional)Another example (propositional)

Prove: Prove: pp Observe:Observe: non-determinism on both atom non-determinism on both atom

selection and on clause selection ! selection and on clause selection ! we only illustrate the clause selection herewe only illustrate the clause selection here

Page 38: Automated Reasoning Systems

38

Search tree traversed bySearch tree traversed bythe backward procedurethe backward procedure

p p q q r rq q t tq q s sr r n nr r o ossoonn

false false pp

false false qq r r

false false tt r r false false ss r r

false false rr

false false nn false false oo

false false false false

Page 39: Automated Reasoning Systems

39

The backwardThe backwardprocedure is efficientprocedure is efficient

The proof is The proof is goal directedgoal directed towards the theorem. towards the theorem. no exploration of no exploration of irrelevant rulesirrelevant rules

Different search methodesDifferent search methodes can be used to traverse can be used to traverse this search tree. this search tree.

Atom-selectionAtom-selection may influence efficiency too: may influence efficiency too: ex.: by detecting a failing branch soonerex.: by detecting a failing branch sooner

but has but has no impactno impact on whether or not we find a on whether or not we find a solutionsolution

(in case there are only (in case there are only finitely many groundfinitely many ground Horn Horn clauses)clauses)

Page 40: Automated Reasoning Systems

40

Completeness:Completeness: ExampleExample:: false false p p

p p p p (1)(1)p p (2)(2)

Possible derivations:Possible derivations:

false false p p

false false p p(1)(1)

false false p p(1)(1)

……(1)(1)

false false

(2)(2)

Is only complete if the search tree is Is only complete if the search tree is traversed using a complete search traversed using a complete search method.method.

Page 41: Automated Reasoning Systems

41

Representation-power of Representation-power of ground Horn clausesground Horn clauses

Is Is a subset of a subset of propositionalpropositional logic. logic.

showm(Bos) showm_Bos

big(house(Bos)) big_house_Bos

Example:Example:

In general, more expressive logics are needed.In general, more expressive logics are needed. EssenceEssence: with variables, one formula may be : with variables, one formula may be

equivalent to a very large number of propositional equivalent to a very large number of propositional formulae. formulae.