39
All rights res erved L. Manevitz Lecture 5 1 Artificial Intelligence Logic Part 2 L. Manevitz

Artificial Intelligence Logic Part 2

  • Upload
    gaye

  • View
    50

  • Download
    0

Embed Size (px)

DESCRIPTION

Artificial Intelligence Logic Part 2. L. Manevitz. Unification. P(x,f(y),B). Alphabetic variant. Term substitution. “Ground”. S 1 ={z/x,w/y}. P(z,f(w),B). S 2 ={g(z)/x,A/y}. P(g(z),f(A),B). S 3 ={C/x,A/y}. P(C,f(A),B). P(a). P(a). P(a) Q(a). P(x) Q(x). Q(a). Example. - PowerPoint PPT Presentation

Citation preview

Page 1: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 1

Artificial IntelligenceLogic Part 2

L. Manevitz

Page 2: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 2

Unification

• Alphabetic variant.

• Term substitution.

• “Ground”.

P(x,f(y),B)

S1={z/x,w/y}

S2={g(z)/x,A/y}

S3={C/x,A/y}

P(z,f(w),B)

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

P(C,f(A),B)

Page 3: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 3

Example

x [P(x) Q(x)]

P(a)

Q(a)

x [ P(x) Q(x)]

P(x) Q(x)

P(a) Q(a)

P(a)

P(a)

Q(a)

Substitution

Page 4: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 4

Unification cont.

m.g.u g: s s’

{Ei}s = {Ei}g s’

{A(x),A(z)} {A(x),A(z)}

{A(a)} {A(x)}S1={a/x,a/

z}S2={x/z}

{Ei} S1 = {Ei}g S2

Page 5: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 5

Example of m.g.u

{P(x),P(A)}

{P[f(x),y,g(y)],P[f(x),x,g(z)]}

{P[f(x,g(A,y)),g(A,y)],P[f(x,z),z]}

P(A)

P[f(x),x,g(x)]

P[f(x,g(A,y)),g(A,y)]

Page 6: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 6

Unification – Algorithm

Unify(E1,E2)

• If E1 or E2 is an atom (that is, a predicate symbol, a function symbol, a constant symbol, a negation symbol or a variable),

interchange the arguments E1 and E2 (if necessary) so that E1 is an atom, and do:

Page 7: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 7

Unification – Algorithm cont.

2. Begin:1. If E1 and E2 are identical, return NIL.2. If E1 is a variable, do:3. Begin:

2. If E1 occurs in E2, return FAIL.3. Return {E2 / E1}.

4. End.5. If E2 is a variable, return {E1 / E2}.6. Return FAIL.

3. End.

Page 8: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 8

Unification – Algorithm cont.

4. F1the first element of E1, T1 the rest of E1.

5. F2 the first element of E2, T2 the rest of E2.

6. Z1UNIFY(F1,F2).

7. If Z1 = FAIL, return FAIL.

Page 9: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 9

Unification – Algorithm cont.

8. G1result of applying Z1 to T1.

9. G2result of applying Z1 to T2.

10. Z2UNIFY(G1,G2).

11. If Z2 = FAIL, return FAIL.

12. Return the composition of Z1and Z2.

Page 10: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 10

4Trace of Unification

• Unify ((fxx), (fAy))– 4. F1 = f; T1 = (xx) ; F2 = f; T2 =(Ay)– 6. Unify (f, f)

• 1. f = f so return NIL8. G1 = NIL(T1) = (xx) G2 = (Ay)10. Unify ((xx, Ay) 4. F1 = x F2 = A etc 6. Unify (x, A) 3.3 Return A/x

8. Apply A/x to (x) (y) get (A y) 10. Unify (A, y) get A/y Return composition of A/x and A/yResult is fAA.

Page 11: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 11

Example

1. Whoever can read is literate.

2. Dolphins are not literate.

3. Some dolphins are intelligent.

x [R(x) L(x)]

x [D(x) L(x)]

x [D(x) I(x)]

Page 12: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 12

Example cont.

To prove:

some who are intelligent can not read.

x [I(x) R(x)]

Page 13: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 13

Example cont.

Clause Form:

1. R(x) L(x)

2. D(y) L(y)

3. Divided to two: A is Skolem constant1. D(A)

2. I(A)

4. Negation of theory:

I(z) R(z)

Page 14: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 14

Example cont.

I(z) R(z) I(A)

R(A) R(x) L(x)

L(A) D(y) L(y)

D(A) D(A)

NIL

3.2 4

1

2

3.1

Page 15: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 15

Control Methods

• Breadth First.

• Set of Support.

• Linear Input.

Page 16: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 16

Breadth First - Example I(z) R(z)I(A)

R(A)

R(x) L(x)

L(A)

D(y) L(y)

L(A)

D(A)

NIL

I(z) L(z) R(y) D(y)

I(A) R(A) I(z) D(z) D(A)L(A)

Page 17: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 17

Set of Support - Example I(z) R(z) I(A)

R(A)

R(x) L(x)

L(A)

D(y) L(y) D(A)

I(A)

I(y) D(y)

D(A)

L(A)

D(A) D(A)

I(z) L(z)

Page 18: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 18

Linear Input - ExampleI(A)

R(A)

R(x) L(x)

L(A)

D(y) L(y) D(A)

I(A)

I(y) D(y)L(A) R(A)

I(z) L(z)

I(z) R(z)

R(y) D(y)

I(z) D(z)

L(A)

Page 19: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 19

A refutation tree(note: no linear input tree)

Q(x) P(x) Q(y) P(y)

Q(w) P(w)

P(A)

P(x)

Q(w)

NIL

Q(u) P(A)

Page 20: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 20

Ancestor Filtered

• Like linear input but also …

• Additional resolutions where one parent is the ancestor of the other one.

• Surprisingly, this is a complete strategy

Page 21: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 21

A refutation tree(note: no linear input tree)

Q(x) P(x) Q(y) P(y)

Q(w) P(w)

P(A)

P(x)

Q(w)

NIL

Q(u) P(A)

Page 22: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 22

Example no.1

x [AT(JOHN,x) AT(FIDO,x)]

AT(JOHN,School)

Where is FIDO ?

x [AT(FIDO,x)]

x [ AT(FIDO,x)]

AT(FIDO,x)

Page 23: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 23

Example no.1 cont.

Answer:

• Append negation of each clause that arises from negation of theorem to each leaf in derivation tree in which it appears.

• Follow structure of derivation tree.

• Use clause at root as answer.

Page 24: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 24

Example no.1 cont.AT(FIDO,x)Negation of Goal

AT(JOHN,y) AT(FIDO,y)Axiom 1

NIL

AT(JOHN,x)AT(JOHN,SCHOOL)

Axiom 2

y x

x SCHOOL

Page 25: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 25

Example no.1-Green’s Trick

AT(JOHN,y) AT(FIDO,y)

AT(FIDO,SCHOOL)

AT(JOHN,SCHOOL)

y x

x SCHOOL

AT(FIDO,x) AT(FIDO,x)

AT(JOHN,x) AT(FIDO,x)

Page 26: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 26

Example no.2

On (B,A)

On (A,Table)

T.S. Above (B,Table)

The axioms :

x y[On(x,y) Above(x,y)]

x y z[Above(x,y) Above(y,z) Above(x,z)]

Page 27: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 27

Example no.2 cont.

Clause form:

1. On(u,v) Above(u,v)

2. Above(x,y) Above(y,z) Above(x,z)

3. On(B,A)

4. On(A,Table)

5. Above(B,Table)

Page 28: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 28

Example no.2 – Resolution

Above(B,y) Above(y,Table)

On(y,Table) Above(B,y)

On(B,y) On(y,Table)

2 5

1

1

3

4 On(A,Table)

NIL

Page 29: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 29

Example no.3

Predicates:

On(A,Table)

On(B,A)

Function: PutonTable?

x On(x,Table) How to use the function?

Need to add situation parameter

Page 30: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 30

Frame Problem

AA

BB

BBAA

Operator:

•PutonTable(x):

•If x not on table, it puts x on table.

How should we represent this in logic ?How should we represent this in logic ?

Page 31: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 31

Making Situation Part of Logic

S0 – initial situation.

On(A,Table,S0)

On(B,A,S0)

PutonTable axiom:

z x [ On(x,Table,z) On(x,Table,PutonTable(x,z)]

(PutonTable is function P:Object X Situation Situation)

Page 32: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 32

Making Situation Part of Logic

Other axioms (how do we find them ?)

x y z [On(x,y,z) On(y,x,z)]

A = B

A = Table

B = Table

Page 33: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 33

Frame Problem cont.

When will B be on the Table? Apply Green’s TrickGoal: z On(B,Table,z)

z On(B,Table,z)Axioms: On(B,A,S0)

On(A,Table,S0) z x[ On(x,Table,z) On(x,Table,PutonTable(x,z))] z y x[On(y,x,z) x=Table On(y,Table,z)] x y z[On(y,x,z) On(x,y,z)]

negated

Page 34: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 34

Frame Problem cont.Clause form:1. On(B,A,S0)2. On(A,Table,S0)3. On(x,Table, S3) On(x,Table,PutonTable(x,S3))4. On(y,z,S4) z=Table On(y,Table,S4)5. (A=B)6. (B=Table)7. (A=Table)8. On(u,v,w) On(v,u,w)9. On(B,Table,s)

Goal Formula

Page 35: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 35

On(x,Table, S3) On(x,Table,PutonTable(x,S3)) On(B,Table,S)

On(B,Table, S3)

On(B,z,S3) z=Table (A=Table)

On(B,A,S3)

NIL

93

On(y,z,S4) z=Table On(y,Table,S4)4

7

On(B,A,S0)1

x B

y B S4 S3

z A

S3 S0

S PutonTable(B,S3)

Green’s Trick

On(B,Table,S)

On(B,Table, PutonTable(B,S3))

On(B,Table, PutonTable(B,S3))

On(B,Table, PutonTable(B,S0))

On(B,Table, PutonTable(B,S3))

Page 36: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 36

Frame Problem cont.

Do we know a state where both A and B

on table?

Goal: s[On(B,Table,s) On(A,Table,s)]

Negate + Clause:

On(B,Table,s) On(A,Table,s)

New formula no.9

Page 37: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 37

Slide Missing on Start of Proofof A and B on table

• Show where you get stuck

Page 38: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 38

Frame Problem cont.

The knowledge that A stays put

wasn’t put into logic !

Needs a “frame axiom” :

s x y z[On(x,y,s) x=z On(x,y,PutonTable(z,s))]

Clause form:

On(p,q,t) p=r On(p,q,PutonTable(r,t))

Formula no.10

Page 39: Artificial Intelligence Logic Part 2

All rights reserved L. Manevitz Lecture 5 39

On(p,q,t) p=r On(p,q,PutonTable(r,t))

On(A,Table,S0) A=B (A=B)

On(A,Table,S0)

NIL

10

5

On(A,Table,S0)2

p A r B

t S0

On(A,Table, PutonTable(B,S0))

9

q Table