artificial intelligence, lecture 12.3, page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf ·...

22
Variables Variables are universally quantified in the scope of a clause. A variable assignment is a function from variables into the domain. Given an interpretation and a variable assignment, each term denotes an individual and each clause is either true or false. A clause containing variables is true in an interpretation if it is true for all variable assignments. c D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 1

Upload: others

Post on 28-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Variables

Variables are universally quantified in the scope of a clause.

A variable assignment is a function from variables into thedomain.

Given an interpretation and a variable assignment,each term denotes an individual andeach clause is either true or false.

A clause containing variables is true in an interpretation if it istrue for all variable assignments.

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 1

Page 2: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Queries and Answers

A query is a way to ask if a body is a logical consequence of theknowledge base:

?b1 ∧ · · · ∧ bm.

An answer is either

an instance of the query that is a logical consequence of theknowledge base KB, or

no if no instance is a logical consequence of KB.

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 2

Page 3: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Example Queries

KB =

in(kim, r123).part of (r123, cs building).in(X ,Y )← part of (Z ,Y ) ∧ in(X ,Z ).

Query Answer

?part of (r123,B).

part of (r123, cs building)?part of (r023, cs building). no?in(kim, r023). no?in(kim,B). in(kim, r123)

in(kim, cs building)

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 3

Page 4: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Example Queries

KB =

in(kim, r123).part of (r123, cs building).in(X ,Y )← part of (Z ,Y ) ∧ in(X ,Z ).

Query Answer

?part of (r123,B). part of (r123, cs building)?part of (r023, cs building).

no?in(kim, r023). no?in(kim,B). in(kim, r123)

in(kim, cs building)

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 4

Page 5: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Example Queries

KB =

in(kim, r123).part of (r123, cs building).in(X ,Y )← part of (Z ,Y ) ∧ in(X ,Z ).

Query Answer

?part of (r123,B). part of (r123, cs building)?part of (r023, cs building). no?in(kim, r023).

no?in(kim,B). in(kim, r123)

in(kim, cs building)

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 5

Page 6: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Example Queries

KB =

in(kim, r123).part of (r123, cs building).in(X ,Y )← part of (Z ,Y ) ∧ in(X ,Z ).

Query Answer

?part of (r123,B). part of (r123, cs building)?part of (r023, cs building). no?in(kim, r023). no?in(kim,B).

in(kim, r123)in(kim, cs building)

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 6

Page 7: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Example Queries

KB =

in(kim, r123).part of (r123, cs building).in(X ,Y )← part of (Z ,Y ) ∧ in(X ,Z ).

Query Answer

?part of (r123,B). part of (r123, cs building)?part of (r023, cs building). no?in(kim, r023). no?in(kim,B). in(kim, r123)

in(kim, cs building)

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 7

Page 8: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Logical Consequence

Atom g is a logical consequence of KB if and only if:

g is a fact in KB, or

there is a rule

g ← b1 ∧ . . . ∧ bk

in KB such that each bi is a logical consequence of KB.

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 8

Page 9: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Debugging false conclusions

To debug answer g that is false in the intended interpretation:

If g is a fact in KB, this fact is wrong.

Otherwise, suppose g was proved using the rule:

g ← b1 ∧ . . . ∧ bk

where each bi is a logical consequence of KB.I If each bi is true in the intended interpretation, this clause is

false in the intended interpretation.I If some bi is false in the intended interpretation, debug bi .

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 9

Page 10: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Electrical Environment

light

two-wayswitch

switchoff

on

poweroutlet

circuit breaker

outside powercb1

s1

w1s2 w2

w0

l1

w3s3

w4

l2p1

w5

cb2

w6

p2

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 10

Page 11: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Axiomatizing the Electrical Environment

% light(L) is true if L is a lightlight(l1). light(l2).% down(S) is true if switch S is downdown(s1). up(s2). up(s3).% ok(D) is true if D is not brokenok(l1). ok(l2). ok(cb1). ok(cb2).

?light(l1). =⇒

yes?light(l6). =⇒ no?up(X ). =⇒ up(s2), up(s3)

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 11

Page 12: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Axiomatizing the Electrical Environment

% light(L) is true if L is a lightlight(l1). light(l2).% down(S) is true if switch S is downdown(s1). up(s2). up(s3).% ok(D) is true if D is not brokenok(l1). ok(l2). ok(cb1). ok(cb2).

?light(l1). =⇒ yes?light(l6). =⇒

no?up(X ). =⇒ up(s2), up(s3)

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 12

Page 13: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Axiomatizing the Electrical Environment

% light(L) is true if L is a lightlight(l1). light(l2).% down(S) is true if switch S is downdown(s1). up(s2). up(s3).% ok(D) is true if D is not brokenok(l1). ok(l2). ok(cb1). ok(cb2).

?light(l1). =⇒ yes?light(l6). =⇒ no?up(X ). =⇒

up(s2), up(s3)

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 13

Page 14: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Axiomatizing the Electrical Environment

% light(L) is true if L is a lightlight(l1). light(l2).% down(S) is true if switch S is downdown(s1). up(s2). up(s3).% ok(D) is true if D is not brokenok(l1). ok(l2). ok(cb1). ok(cb2).

?light(l1). =⇒ yes?light(l6). =⇒ no?up(X ). =⇒ up(s2), up(s3)

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 14

Page 15: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

connected to(X ,Y ) is true if component X is connected to Y

connected to(w0,w1)← up(s2).

connected to(w0,w2)← down(s2).

connected to(w1,w3)← up(s1).

connected to(w2,w3)← down(s1).

connected to(w4,w3)← up(s3).

connected to(p1,w3).

?connected to(w0,W ). =⇒

W = w1

?connected to(w1,W ). =⇒ no?connected to(Y ,w3). =⇒ Y = w2, Y = w4, Y = p1?connected to(X ,W ). =⇒ X = w0,W = w1, . . .

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 15

Page 16: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

connected to(X ,Y ) is true if component X is connected to Y

connected to(w0,w1)← up(s2).

connected to(w0,w2)← down(s2).

connected to(w1,w3)← up(s1).

connected to(w2,w3)← down(s1).

connected to(w4,w3)← up(s3).

connected to(p1,w3).

?connected to(w0,W ). =⇒ W = w1

?connected to(w1,W ). =⇒

no?connected to(Y ,w3). =⇒ Y = w2, Y = w4, Y = p1?connected to(X ,W ). =⇒ X = w0,W = w1, . . .

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 16

Page 17: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

connected to(X ,Y ) is true if component X is connected to Y

connected to(w0,w1)← up(s2).

connected to(w0,w2)← down(s2).

connected to(w1,w3)← up(s1).

connected to(w2,w3)← down(s1).

connected to(w4,w3)← up(s3).

connected to(p1,w3).

?connected to(w0,W ). =⇒ W = w1

?connected to(w1,W ). =⇒ no?connected to(Y ,w3). =⇒

Y = w2, Y = w4, Y = p1?connected to(X ,W ). =⇒ X = w0,W = w1, . . .

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 17

Page 18: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

connected to(X ,Y ) is true if component X is connected to Y

connected to(w0,w1)← up(s2).

connected to(w0,w2)← down(s2).

connected to(w1,w3)← up(s1).

connected to(w2,w3)← down(s1).

connected to(w4,w3)← up(s3).

connected to(p1,w3).

?connected to(w0,W ). =⇒ W = w1

?connected to(w1,W ). =⇒ no?connected to(Y ,w3). =⇒ Y = w2, Y = w4, Y = p1?connected to(X ,W ). =⇒

X = w0,W = w1, . . .

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 18

Page 19: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

connected to(X ,Y ) is true if component X is connected to Y

connected to(w0,w1)← up(s2).

connected to(w0,w2)← down(s2).

connected to(w1,w3)← up(s1).

connected to(w2,w3)← down(s1).

connected to(w4,w3)← up(s3).

connected to(p1,w3).

?connected to(w0,W ). =⇒ W = w1

?connected to(w1,W ). =⇒ no?connected to(Y ,w3). =⇒ Y = w2, Y = w4, Y = p1?connected to(X ,W ). =⇒ X = w0,W = w1, . . .

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 19

Page 20: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

% lit(L) is true if the light L is lit

lit(L)← light(L) ∧ ok(L) ∧ live(L).

% live(C ) is true if there is power coming into C

live(Y )←connected to(Y ,Z ) ∧live(Z ).

live(outside).

This is a recursive definition of live.

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 20

Page 21: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Recursion and Mathematical Induction

above(X ,Y )← on(X ,Y ).

above(X ,Y )← on(X ,Z ) ∧ above(Z ,Y ).

This can be seen as:

Recursive definition of above: prove above in terms of a basecase (on) or a simpler instance of itself; or

Way to prove above by mathematical induction: the base caseis when there are no blocks between X and Y , and if you canprove above when there are n blocks between them, you canprove it when there are n + 1 blocks.

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 21

Page 22: Artificial Intelligence, Lecture 12.3, Page 1franconi/teaching/artint.info/slides/ch12/lect3.pdf · 1 ^^ b m: An answeris either an instance of the query that is a logical consequence

Limitations

Suppose you had a database using the relation:

enrolled(S ,C )

which is true when student S is enrolled in course C .You can’t define the relation:

empty course(C )

which is true when course C has no students enrolled in it.This is because empty course(C ) doesn’t logically follow from aset of enrolled relations. There are always models where someoneis enrolled in a course!

c©D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 12.3, Page 22