35
Ronald J. Brachman Hector J. Levesque Knowledge Representation and Reasoning AT&T Labs – Research Florham Park, New Jersey USA 07932 [email protected] Department of Computer Science University of Toronto Toronto, Ontario Canada M5S 3H5 [email protected] c 2003 Ronald J. Brachman and Hector J. Levesque

Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

Ronald J. Brachman

Hector J. Levesque

Knowledge Representationand

Reasoning

AT&T Labs – ResearchFlorham Park, New Jersey

USA [email protected]

Department of Computer ScienceUniversity of Toronto

Toronto, OntarioCanada M5S 3H5

[email protected]

c 2003 Ronald J. Brachman and Hector J. Levesque

Page 2: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

Contents

1 Introduction 1

2 FOL 3

3 Expressing knowledge 5

4 Resolution 9

5 Horn Toads 19

6 Procedural 23

7 Production Sissies 27

8 Frames 31

9 Descriptions 33

10 Inheritance 37

11 Defaults 39

12 Probability 43

13 Abduction 47

14 Action 49

15 Planning 53

16 Tradeoff 57

c iv

Bibliography 63

2003 R. Brachman and H. Levesque May 2, 2003

Page 3: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

Chapter 1

Introduction

These exercises are all taken from [4].

1. Consider a task requiring knowledge like baking a cake. Examine a recipeand state what needs to be known to follow the recipe.

2. In considering the distinction between knowledge and belief in this book,we take the view that belief is fundamental, and that knowledge is simplybelief where the outside world happens to be cooperating (the belief is true,is arrived at by appropriate means, is held for the right reasons, and so on).Describe an interpretation of the terms where knowledge is taken to be basic,and belief is understood in terms of it.

3. Explain in what sense reacting to a loud noise is and is not cognitively pen-etrable.

4. It has become fashionable to attempt to achieve intelligent behaviour in AIsystems without using propositional representations. Speculate on what sucha system should do when reading a book on South American geography.

5. Describe some ways in which the first-hand knowledge we have of sometopic goes beyond what we are able to write down in a language. What ac-counts for our inability to express this knowledge?

Page 4: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

fe

FOL

Chapter 2

8 8 8 ^ �

8 8 ^ �

8 8 �

��

groups

sets

No set is an element of itself.

A set is a subset of a set iff every element of is an elementof

x y z P x; y P y; z P x; z

x y P x; y P y; x x y

x y P a; y P x; b :

f e f e f

x f e; x f x; e x

x; i f x; i f i; x e:

x y; z f x; z y:

z x y:

x y x

y:

1. For each of the following sentences, give a logical interpretation that makesthat sentence false and the other two sentences true:

(a) [( ( ) ( )) ( )];

(b) [( ( ) ( )) ( = )];

(c) [ ( ) ( )]

2. This question involves formalizing the properties of mathematical inFOL. Recall that a set is considered to be a group relative to a binary function

and an object iff (1) is associative; (2) is an identity element for ,that is, for any , ( ) = ( ) = ; and (3) every element has an inverse,that is, for any there is an such that ( ) = ( ) = Formalize theseas sentences of FOLwith two non-logical symbols, a function symbol and aconstant symbol , and prove that the sentences logically entail the followingproperty of groups:

For every and there is a such that ( ) =

Explain how your proof shows the value of as a function of and

3. This question involves formalizing some simple properties of in FOL.Consider the following three facts:

1

1

Sub Eu

T

TT

T

T

T T

T

T

��

2003 R. Brachman and H. Levesque May 2, 2003

x y

x y:

x; y x y; e; x e

x; x; y x y:

x

x y:

x y y x:

A

z A z A:

z x x

z x

x; x:

u

Something is an element of the union of two sets and iffit is an element of or an element of

Hint:

Anyone who does not shave himself must be shavedby the barber.

Whomever the barber shaves, must not shave himself.

barber’s paradox

c 4

(a) Represent the facts as sentences of FOL. As non-logical symbols, use( ) to mean “ is a subset of ” ( ) to mean “ is an element

of ” and ( ) to mean “the union of and ” Instead of usinga special predicate to assert that something is a set, you may simplyassume that in the domain of discourse (assumed to be non-empty),everything is a set.

Call the resulting set of sentences .

(b) Show using logical interpretations that entails that is a subset ofthe union of and

(c) Show using logical interpretations that does not entail that the unionof and is equal to the union of and

(d) Let be any set. Show using logical interpretations that entails thatthere is a set such that the union of and is a subset of

(e) Does entail that there is a set such that for any set the union ofand is a subset of ? Explain.

(f) Write a sentence which asserts the existence of singleton sets, that is,for any the set whose only element is is with this sentenceadded.

(g) Prove that is not finitely satisfiable (again, assuming the domain isnon-empty). in a finite domain, consider , the object interpretedas the union of all the elements in the domain.

(h) Prove or disprove that entails the existence of an empty set.

4. In a certain town, there are the following regulations concerning the townbarber:

Show that no barber can fulfill these requirements. That is, formulate therequirements as sentences of FOL, and show that in any interpretation wherethe first regulation is true, the second one must be false. (This is called the

and is due to Bertrand Russell.)

Page 5: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

Chapter 3

Expressing knowledge

Tony, Mike, and John belong to the Alpine Club. Every member ofthe Alpine Club who is not a skier is a mountain climber. Moun-tain climbers do not like rain, and anyone who does not like snowis not a skier. Mike dislikes whatever Tony likes, and likes what-ever Tony dislikes.

Joe, Sally, Bill, Ellen, are the only members of the club. Joe ismarried to Sally. Bill is Ellen’s brother. The spouse of every mar-ried person in the club is also in the club.

not

1. (Adapted from from [6], and see follow-up Exercise 2 of Chapter 4)Consider the following piece of knowledge:

(a) Prove that the given sentences logically entail that there is a member ofthe Alpine Club who is a mountain climber but not a skier.

(b) Suppose we had been told that Mike likes whatever Tony dislikes (asabove), but we had not been told that Mike dislikes whatever Tony likes.Prove that the resulting set of sentences no longer logically entail thatthere is a member of the Alpine Club who is a mountain climber butnot a skier.

2. Consider the following facts about the Elm Street Bridge Club:

From these facts, most people would be able to determine that Ellen is notmarried.

(a) Represent these facts as sentences in FOL, and show semantically thatby themselves, they do entail that Ellen is not married.

�����

henri pierre

gauche

2003 R. Brachman and H. Levesque May 2, 2003

Huey is younger than the boy in the green tee-shirt.

The five year-old wore the tee-shirt with the camel design.

Dewey’s tee-shirt was yellow.

Louie’s tee-shirt bore the giraffe design.

The panda design was not featured on the white tee-shirt.

A traveler in remote Quebec comes to a fork in the road and doesnot know which way to go to get to Chicoutimi. Henri and Pierreare two local inhabitants nearby who do know the way. One ofthem always tells the truth, and the other one never does, but thetraveler does not know which is which. Is there a single questionthe traveler can ask Henri (in French, of course) that will be sureto tell him which way to go?

inhabitantsFrench questions

c 6

(b) Write in FOL some additional facts that most people would be expectedto know, and show that the augmented set of sentences now entails thatEllen is not married.

3. Donald and Daisy Duck took their nephews aged 4, 5 and 6 on an outing.Each boy wore a tee-shirt with a different design on it and of a differentcolour. You are also given the following information:

(a) Represent these facts as sentences in FOL.

(b) Using your formalization, is it possible to conclude the age of each boytogether with the colour and design of the tee-shirt they’re wearing?Show semantically how you determined your answer.

(c) If your answer was ‘no’, indicate what further sentences you wouldneed to add so that you could conclude the age of each boy togetherwith the colour and design of the tee-shirt they’re wearing.

4. A Canadian variant of an old puzzle:

We will formalize this problem in FOL. Assume there are only two sorts ofobjects in our domain, denoted by the constants and ,and , that Henri and Pierre can answer. These questions aredenoted by the following terms:

, which asks if if the traveler should take the left branch of thefork to get to Chicoutimi;

Page 6: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

��

��

��

��

��

j �

x; q x

qx; q x

q

; ;

x x

x; q x

q

q q

x; q x

q

x; q x

q

t

; t :

2003 R. Brachman and H. Levesque May 2, 2003

dit oui

dit non

dit non henri dit oui pierre gauche

Truth teller

Answer yes

True

Go left

gauche

dit oui

dit non

Answer yes henri Go left

One of Henri or Pierre is a truth teller, and one is not.

An inhabitant will answer yes to a question iff he is a truth tellerand the correct answer is yes, or he is not a truth teller and thecorrect answer is not yes.

The question is correctly answered yes iff the proper direc-tion is to go is left.

A question is correctly answered yes iff will answeryes to the question .

A question is correctly answered yes iff will not an-swer yes to .

c 7

( ), which asks if inhabitant would answer yes to the Frenchquestion ;

( ), which asks if inhabitant would answer no to the Frenchquestion ;

Obviously this is a somewhat impoverished dialect of French, although aphilosophically interesting one. For example, the term

( ( )))

represents a French question that might be translated as “Would Henry an-swer no if I asked him if Pierre would say yes I should go to the left to get toChicoutimi?” The predicate symbols of our language are the following:

( ), which holds when inhabitant is a truth teller;

( ), which holds when inhabitant will answer yes toFrench question ;

( ), which holds when the correct answer to the question is yes;

, which holds if the direction to get to Chicoutimi is to go left.

For purposes of this puzzle, these are the only constant, function, and predi-cate symbols.

(a) Write FOL sentences for each of the following:

( )

( )

Imagine that these facts make up the entire KB of the traveler.

(b) Show that there is a ground term such that

KB = [ ( ) ]

t

Go left

2003 R. Brachman and H. Levesque May 2, 2003c 8

In other words, there is a question that can be asked to Henri (andthere is an analogous one for Pierre) that will be answered yes iff properdirection to get to Chicoutimi is to go left.

(c) Show that this KB does not entail which direction to go, that is, showthat there is an interpretation satisfying the KB where is true,and another one where it is false.

Page 7: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

9 8 8 � � �

Chapter 4

Resolution

x y z P y Q z P x Q x :

1. Determine whether the following sentence is valid using Resolution:

(( ( ) ( )) ( ( ) ( )))

2. (Follow-up to Exercise 1 of Chapter 3)Use Resolution with answer extraction to find the member of the Alpine Clubwho is a mountain climber but not a skier.

3. (Adapted from [3])Victor has been murdered, and Arthur, Bertram, and Carleton are the onlysuspects (meaning exactly one of them is the murderer). Arthur says thatBertram was the victim’s friend, but that Carleton hated the victim. Bertramsays that he was out of town the day of the murder, and besides he didn’t evenknow the guy. Carleton says that he saw Arthur and Bertram with the victimjust before the murder. You may assume that everyone – except possibly forthe murderer – is telling the truth.

(a) Use Resolution to find the murderer. In other words, formalize the factsas a set of clauses, prove that there is a murderer, and extract his identityfrom the derivation.

(b) Suppose we discover that we were wrong: we cannot assume that therewas only a single murderer (there may have been a conspiracy). Showthat in this case, the facts do not support anyone’s guilt. In other words,for each suspect, present a logical interpretation that supports all thefacts but where that suspect is innocent and the other two are guilty.

sets

factoring

1 2

1 1 2 2

1 2

1 1 2 2

1 2

2003 R. Brachman and H. Levesque May 2, 2003

: :

� �

f g f g

� [ �

� f j 2 2 2 g [ f � j 2 2 2 g

f g �

f g � f g

P x ; P y P u ; P v

C C

D C D C �

D � � D � � :

C D � C D �:

D D

C m C m

C m c c C;m = c;m = c c m c C;m = c;m c :

C p; q ; p; a; b ; p; c ; d; e C p

a; b ; c ; d; e C p q ; d; e :

c 10

4. (See follow-up Question 3 of Chapter 5)The general form of Resolution with variables presented here is not completeas it stands, even for deriving the empty clause. In particular, note that thetwo clauses

[ ( ) ( )] and [ ( ) ( )]

are together unsatisfiable.

(a) Argue that the empty clause cannot be derived from these two clauses.

A slightly more general rule of Resolution handles cases such as these:

Suppose that and are clauses with disjoint atoms. Suppose thatthere are of literals and and a substitutionsuch that = and = Then, we conclude by Resolutionthe clause: ( ) ( )

The form of Resolution considered here simply took and to be single-ton sets.

(b) Show a refutation of the two clauses with this generalized form of Res-olution.

(c) Another way to obtain completeness is to leave the Resolution rule un-changed (that is, dealing with pairs of literals rather than pairs of setsof literals as above), but to add a second rule of inference, sometimescalled , to make up the difference. Present such a rule of in-ference and show that it properly handles the above example.

In the remaining questions of this chapter, we consider a number of procedures fordetermining whether or not a set of propositional clauses is satisfiable. In mostcases, we also would like to return a satisfying interpretation, if one exists.

5. In defining procedures for testing satisfiability, it is useful to have the follow-ing notation. When is a set of clauses, and is a literal, define tobe the following set of clauses

= ( )

For example, if = [ ] [ ] [ ] [ ] , then we get that =[ ] [ ] [ ] and = [ ] [ ]

Prove the following two properties of Resolution derivations:

Page 8: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

1

sans

1 2

1 2

1

[

� �

2003 R. Brachman and H. Levesque May 2, 2003

inputoutput

procedureif thenif then

if then

end

C

CC

p C

C p

C p

C m c k C c k

c c c m

C p n C p n C

n n

p

C

p p p

C

C

m m C m

C m

The version considered here is actually closer to the variant presented by Davis, Logemann andLoveland Putnam.

c 11

Figure 4.1: The DP procedure

: a set of clauses: are the clauses satisfiable, YES or NO?

DP( )is empty return YEScontains [] return NO

let be some atom mentioned inDP( ) = YES return YES

otherwise return DP( )

(a) If derives clause in steps, then derives in steps, whereis either itself or the clause [ ].

(b) If derives [] in steps and derives [] in steps, thenderives [] in no more than ( + + 1) steps.

6. A very popular procedure for testing the satisfiability of a set of propositionalclauses is the Davis-Putnam procedure (henceforth DP), shown in Figure 4.1,and named after the two mathematicians who first presented it.

(a) Sketch how DP could be modified to return a satisfying assignment (asa set of literals) instead of YES when the clauses are satisfiable.

(b) The main refinements to this procedure that have been proposed in theliterature involve the choice of the atom . As stated, the choice is leftto chance. Argue why it is useful to do at least the following: ifcontains a singleton clause [ ] or [ ], then choose as the next atom.

(c) Another refinement is the following: once it is established that is notempty and does not contain [], check to see if mentions some literal

but not its complement . In this case, we return DP( ) directlyand do not bother with . Explain why this is correct.

(d) Among all known propositional satisfiability procedures, recent exper-imental results suggest that DP (including the refinements mentioned

¿

0 0

���

k

i

k

1 1 2 2

1

1

N

N N N N

N N

Ni

N N

k

1 2 ( 1+ 2)

( 1+ + )

Hint:

two

tableau

���

��

`

` [ f g ` `

[ f g ` [ f [ g `

[ f g `

[ f g `

2003 R. Brachman and H. Levesque May 2, 2003

k C k

C k

p

p

p C

p C

p C

C

p C

p C

: n n

L

C

C c c

C N

C c C c c C c

C c C c c c

m ; ;m

i C m

C m ; ;m :

c 12

above) is the fastest one in practice. Somewhat surprisingly, it is possi-ble to prove that DP can take an exponential number of steps on someinputs. Use the results from Question 5 and Haken’s result mentionedin Section to prove an exponential lower bound on the running timeof DP. Prove by induction on that if DP( ) returns NO aftersteps, then derives [] by Resolution in no more than steps.

(e) As stated, the choice of the next atom is left to chance. However,a number of selection strategies have been proposed in the literature,such as, choosing an atom where

appears in the most clauses in , orappears in the fewest clauses in , oris the most balanced atom in (the number of positive occur-

rences in is closest to the number of negative occurrences), oris the least balanced atom in , orappears in the shortest clause(s) in .

Choose any of the above selection strategies, implement two ver-sions of DP, and compare how well they run (in terms of the numberof recursive calls) on some hard test cases. To generate some sets ofclauses that are known to be hard for DP (see [5] for details), randomlygenerate about 4 2 clauses of length 3, where is the number of atoms.(Each clause can be generated by choosing three atoms at random andflipping the polarity of each with a probability of .5.)

7. Up until recently, a very popular way of testing the satisfiability of a set ofpropositional clauses was the method. Rather than computing resol-vents, the procedure TAB in Figure 4.2 tries to construct an interpretationthat satisfies a set of clauses by picking literals from each clause.

In this question, we begin by showing that the TAB procedure, like the DPprocedure of Question 6, must have exponential running time on some inputs.First we use the notation to mean that clause (or a subset of it) can bederived by Resolution from the set of clauses in steps (or less). Observethat if and , then , just by stacking thetwo derivations together.

(a) Prove that if [], then ( ) .

(b) Prove using part (a) and the observation above that if . . . areliterals, and for each , [ ] [], then

[ . . . ] []

Page 9: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

1

1

r

r

fg

2

f 2 j 2 g [ f g

f g

[ f g

2003 R. Brachman and H. Levesque May 2, 2003

C

C C

C L

CL m m

c C

m c

c C m = c L m

N C l ; ; l

N

C l ; ; l N

C C

: n

n

: n

: n

inputoutput

procedure

procedureif thenif then

for doif

thenend for

end

¿

c 13

Figure 4.2: The TAB procedure

: a set of clauses: are the clauses satisfiable, YES or NO?

TAB( ) = TAB1( , )

TAB1( , )is empty return YEScontains some and return NO

otherwise, let be any clause in

TAB1( , )=YESreturn YES

return NO

(c) Prove by induction on and using part (b) that if TAB1( , . . . )returns NO after a total of procedure calls, then there is a Resolutionrefutation of ( [ ] . . . [ ] ) that takes at most steps.

(d) As in Question 6, use Haken’s result from Section and part (c) toprove that there is a set of clauses for which TAB( ) makes an ex-ponential number of recursive procedure calls.

Finally, we consider an experimental question:

(e) As mentioned in Question 6, it was shown in [5] that the DP procedureoften runs for a very long time with about 4 2 randomly generatedclauses of length 3 (where is the number of atoms in the clauses). Withfewer than 4 2 clauses, DP usually terminates quickly; with more,again DP usually terminates quickly.

Confirm (or refute) experimentally that the tableau method TAB alsoexhibits the same easy-hard-easy pattern around 4 2 on sets of clausesrandomly generated as in Question 6.

Note

0 1

0

1

I I

I

I j 2

�2

I 6j

2

� I �

I

I

2 I

I

2 � I

2003 R. Brachman and H. Levesque May 2, 2003

C n

C C n= C n=

C d

c c C

d

C

c C c

m c

C m d

n=

n

C m

c Cd C

m c d

C m

inputoutput

procedure or

procedureif thenif thenif then

for doif

thenend for

end

c 14

Figure 4.3: The LS procedure

: a set of clauses , over atoms: are the clauses satisfiable, YES or NO?

LS( ) = LS1( , , 2) LS1( , , 2)

LS1( , , )= , for every , return YES

0 return NO[] return NO

otherwise, let be any clause in such that =

LS1( , , 1) = YESreturn YES

return NO

8. Another method was proposed in [2] for testing the satisfiability of a set ofpropositional clauses. The procedure LS (for local search) tries to find aninterpretation that satisfies a set of clauses by searching to within a certaindistance from a given set of start points. In the simplest version, we considertwo start points: the interpretation which assigns all atoms false; and theinterpretation which assigns all atoms true. It is not hard to see that ev-ery interpretation lies within a distance of 2 from one of these two startpoints, where is the number of atoms, and where the distance between twointerpretations is the number of atoms where they differ (the Hamming dis-tance). The procedure is shown in Figure 4.3 using the notation fromQuestion 5.

: The correctness of the procedure depends on the following fact (dis-cussed in [2]): in the final step, suppose is a clause not satisfied by .Then there is an interpretation within distance of that satisfies iff forsome literal , there is an interpretation within distance 1 of thatsatisfies .

Page 10: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

i

i

i

i i i

RES

RES Hint

fg

2 : � [ f g

[ f: g

[ f g

::

2003 R. Brachman and H. Levesque May 2, 2003

C n

C

C

T

i n

c R c T p

T T p

T T p

T

R S ;

S:

c c:

T

p p ; p :

S R

R;

R;

R R:

R S

inputoutput

procedure

for toif

thenelse

end forreturn

end

c 15

Figure 4.4: The RES-SAT procedure

: a set of clauses over atoms: an interpretation satisfying

RES-SAT( ):=

:= 1there is a clause such that

:=:=

Confirm (or refute) experimentally that the LS method also exhibits the sameeasy-hard-easy pattern noted in Question 7.

9. In some applications we are given a set of clauses that is known to be satisfi-able, and our task is to find an interpretation that satisfies the clauses. We canuse variants of the procedures presented in Questions 6, 7, or 8 to do this. Butwe can also use Resolution itself. First we generate = ( ) the set ofall resolvents derivable from Then, we run the procedure RES-SAT shownin Figure 4.4.

Note that refers to the set of literals that are the complements of those inAlso, we are treating an interpretation as a set of literals containing exactlyone of or for each atom

(a) Show an example where this procedure would not correctly locate asatisfying interpretation if the original set were used instead of inthe body.

(b) Given that the procedure works correctly for some set prove that itwould also work correctly on just the minimal elements of that is,on those clauses in for which no proper subset is a clause in

(c) Prove that the procedure correctly finds a satisfying interpretation when= ( ). : Begin by showing that

1 2 1

2

I

I j I

I

I I

2 : �

: � [ f g

: � [ f: g

I

C

C

C

i

j

C

p

C

p

T c R c T;

c c R c T p

c T p :

2003 R. Brachman and H. Levesque May 2, 2003

tries flips

tries flipstries

flips

flips

tries

inputoutput

procedurefor to do

for to doif then return

end forend forreturn

c 16

Figure 4.5: The GSAT procedure

: a set of clauses , and two parameters, and: an interpretation satisfying , or failure

GSAT( , , ):= 1

:= a randomly generated truth assignment:= 1

=:= an atomic symbol such that a change in its truth

assignment gives the largest increase in the totalnumber of clauses in that are satisfied by

:= with the truth assignment of reversed

“no satisfying interpretation found”

For any , if for no clause do we have that thenthere cannot be clauses and in such thatand

Then use induction to do the rest.

10. In [7], a procedure called GSAT is presented for finding interpretations forsatisfiable sets of clauses. This procedure, shown in Figure 4.5, seems tohave some serious drawbacks: it does not work at all on unsatisfiable setsof clauses, and even with satisfiable ones, it is not guaranteed to eventuallyreturn an answer. Nonetheless, it appears to work quite well in practice.

The procedure uses two parameters: determines how many times theatoms in should be flipped before starting over with a new random inter-pretation; determines how many times this process should be repeatedbefore giving up and declaring failure. Both parameters need to be set bytrial and error.

Implement GSAT and compare its performance to one of the other satisfiabil-ity procedures presented in these exercises on some satisfiable sets of clauses

Page 11: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

2003 R. Brachman and H. Levesque May 2, 2003c 17

of your own choosing. Note that one of the properties of GSAT is that be-cause it counts the number of clauses not yet satisfied by an interpretation,it is very sensitive to how a problem is encoded as a set of clauses (that is,logically equivalent formulations could have very different properties).

Page 12: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

S

S

S S

Chapter 5

Horn Toads

compactness

1. Write, test, and document a program that determines the satisfiability of aset of propositional Horn clauses by forward-chaining and that runs in lineartime, relative to the size of the input. Use the following data structures:

(a) a global variable STACK containing a list of letters known to be true,but waiting to be propagated forward.

(b) for each clause, a letter CONCLUSION which is the positive literalappearing in the clause (or NIL if the clause contains only negativeliterals), and a number REMAINING which is the number of lettersappearing negatively in the clause that are not yet known to be true.

(c) for each letter, a flag VISITED indicating whether or not the letter hasbeen propagated forward, and a list ON-CLAUSES of all the clauseswhere the letter appears negatively.

You may assume the input is in suitable form. Include in the documentationan argument as to why your program runs in linear time. (If you choose touse Lisp property lists for your data structures, you may assume that it takesconstant time to go from an atom to any of its properties.)

2. As noted in Chapter 4, Herbrand’s theorem allows us to convert a first-ordersatisfiability problem into a propositional (variable-free) one, although thesize of the Herbrand base, in general, is infinite. One way to deal with aninfinite set of clauses, is to look at progressively larger subsets of it to seeif any of them are unsatisfiable, in which case must be as well. In fact,the converse is true: if is unsatisfiable, then some finite subset of isunsatisfiable too. This is called the property of FOL.

1i n

k

k

S

S

S

S

j jj j

j j �

I

j

I j

I 6j

I 6j [ f g

[ f g

2 [

[ f g

�2003 R. Brachman and H. Levesque May 2, 2003

S

t; tmax t f t ; ; t :

S S

� S t � t k:

S

k; H ; H

S:S k;

S

S

p S p

S S

S S

S c

c S c

S T

S c

c T S T

S

c S cc 20

One way to generate progressively larger subsets of is as follows:

For any term let be defined as 0 for variables andconstants, and 1 + for terms ( . . . )

Now for any set of formulas, define to be thoseelements of such that every term of has

(a) Write and test a program which when given a finite set of first-orderclauses and a positive number returns as value where is theHerbrand base of

(b) When the original set is Horn, then for any your program returnsa finite set of propositional Horn clauses. These can be checked forsatisfiability using a propositional program like the one in Question 1.Briefly compare this way of testing the satisfiability of to the morestandard way using SLD Resolution, as in Prolog.

3. Consider the more general version of Resolution discussed in Question 4 ofChapter 4. Is that generalization required for SLD-resolution? Explain.

4. In this question, we will explore the semantic properties of propositionalHorn clauses. For any set of clauses , define to be the interpretationthat satisfies an atom iff = .

(a) Show that if is a set of positive Horn clauses, then = .

(b) Give an example of a set of clauses where = .

(c) Suppose that is a set of positive Horn clauses and that is a negativeHorn clause. Show that if = then is unsatisfiable.

(d) Suppose that is a set of positive Horn clauses and that is a set ofnegative ones. Using part (c) above, show that if is satisfiablefor every , then is satisfiable also.

(e) In the propositional case, the normal Prolog interpreter can be thoughtas taking a set of positive Horn clauses (the program) and a singlenegative clause (the query) and determining whether or notis satisfiable. Use part (d) above to conclude that Prolog can be used totest the satisfiability of an arbitrary set of Horn clauses.

5. In this question, we will formalize a fragment of high school geometry. Wewill use a single binary predicate symbol, which we write here as =. Theobjects in this domain are points, lines, angles, and triangles. We will use

Page 13: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

SAS:

SSS

6

6 6

6 6

6 6

6 6

4

� �� �

� �

� 4 � 4

� �

� � � �

4 � 4[ � j �

4 � 4

2003 R. Brachman and H. Levesque May 2, 2003

AB; A B

ABC

ABC:

XY Y X:

XY Z ZY X:

XY Z UVW;XY UV ; XY Z UVW;

XY UV ; XY Z UVW; Y Z VW;

XY Z UVW:

AB AC ABC ACB:

BC D ABD ACD

is an equivalence relation.

If then the corresponding lines andangles are congruent ( etc.).

If andthen

c 21

constants only to name the points we need, and for the other individuals,we will use function symbols that take points as arguments: first, a functionwhich given two points, is used to name the line between them, which wewrite here as where and are points; next, a function which giventhree points, names the angle between them, which we write here as ;and finally, a function which given three points, names the triangle betweenthem, which we write here as

Here are the axioms of interest:

=

=

=

== =

= = ==

(a) Show that these axioms imply that the base angles of an isosceles tri-angle must be equal, that is, that

Axioms = = =

Since the axioms can be formulated as Horn clauses, and the other twosentences are atomic, it is sufficient to present an SLD-derivation.

(b) The geometry theorem can also be proven by constructing the midpointof the side (call it ), and showing that = (byusing , the fact that two triangles are congruent if the correspondingsides are all congruent). What difficulties do you foresee in automatedreasoning with constructed points like this?

Page 14: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

1

1

1

not

not

YN

YN Y

NY N

Chapter 6

n i

i

n

i i

n

i i

Procedural

� 2

� 2

ab ac bd (c)e c, gf d, e

nega-tion as failure

q a ; ; a n ; q a

p p ; p q

a

qq a ; ; a

a a

q

q a ; ; a

a a

q

The exercises here all concern generalizing Horn derivations to incorporate. For these questions, assume that a KB consists of a list of rules of

the form ( . . . ) where 0 is an atom, and each is either of theform or ( ) where is an atom. The in this case is called the conclusion ofthe rule, and the make up the antecedent of the rule.

1. The forward-chaining procedure presented in Chapter 5 for Horn clause sat-isfiability can be extended to handle negation as failure, by marking atomsincrementally with either a (when they are known to be solved), or with an

(when they are known to be unsolvable), using the following procedure:

For any unmarked letter ,

if there is a rule ( . . . ) KB, where allthe positive are marked and all the negativeare marked , then mark with ;

if for every rule ( . . . ) KB, some pos-itive is marked or some negative is marked

, then mark with .

(a) Show how the procedure would label the atoms in the following KB:

1

1

1

Y N Y

Y N

n

i i

i

n

i i

i

n

f (b), gg (h), (f)

2

� �

2

� � �

f g

notnot not

not

not

not notnot

strongly stratified

weakly stratified

2003 R. Brachman and H. Levesque May 2, 2003f

q a ; ; a

i n f q > f a f p

f p

g

q a ; ; a

i n g q g a g p

g p

g

g

q ; ; q ;

p

c 24

(b) Give an example of a KB where the above procedure fails to label anatom as either or , but where the atom is intuitively , according tonegation as failure.

(c) A KB is defined to be iff there is a function fromatoms to numbers such that for every rule ( . . . ) KB, andfor every 1 , we have that ( ) ( ), where ( ( )) =

( ). (In other words, the conclusion of a rule is always assigned ahigher number than any atom used positively or negatively in the an-tecedent of the rule.) Is the example KB of part (a) strongly stratified?

(d) Prove by induction that the above procedure will label every atom of astrongly stratified KB.

(e) A KB is defined to be iff there is a function fromatoms to numbers such that for every rule ( . . . ) KB, andfor every 1 , ( ) ( ), where in this case, ( ( )) =1 + ( ). (In other words, the conclusion of a rule is always assigned anumber no lower than than any atom used positively in the antecedentof the rule, and higher than any atom used negatively in the antecedentof the rule.) Is the example KB of part (a) weakly stratified?

(f) Give an example of a weakly stratified KB where the procedure abovefails to label an atom.

(g) Assume you are given a KB that is weakly stratified and you are alsogiven the function in question. Sketch a forward-chaining procedurethat uses the to label every atom in the KB either or .

2. Write, test, and document a program that performs the forward-chaining ofthe previous question and that runs in linear time, relative to the size of theinput. You should use data structures inspired by those of Question 1 ofChapter 5. Include in the documentation an argument as to why your programruns in linear time. Show that your program works properly on at least theKB of the previous question.

3. There are many ways of making negation as failure precise, but one way isas follows: we try to find a set of “negative assumptions” we can make,

( ) . . . ( ) such that if we were to add these to the KB anduse ordinary logical reasoning (now treating a ( ) as if it were a new

Page 15: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

1

0

+1

+1

not

Hint:

n

k k

k

k k

k

k

k

k

not

not

not

not

f g

f gf j [ 6j g

2

f 2 j g

[ j [ j

2003 R. Brachman and H. Levesque May 2, 2003

p

q ; ; q

NN q N q

N

N N k p

p = N

N

g

k r N k; r

N k; r q N g q < r :

k p g p r

N p N k; r p:

p

g

p k r r < k N k ; r

N k ; r : k

k r < k

N k ; r N k ; r k

r < k N k ; r N k ; r

c 25

atom unrelated to ), the set of atoms we could derive would be exactly. . . .

More precisely, we define a sequence of sets as follows

== ( ) KB =

The reasoning procedure then is this: we calculate the , and if the sequenceconverges, that is, if = for some , then we consider any atomsuch that ( ) to be derivable by negation as failure.

(a) Show how this procedure works on the KB of Question 1, by giving thevalues of .

(b) Give an example of a KB where the procedure does not terminate.

(c) Explain why the procedure does the right thing for KBs that are pureHorn, that is, do not contain the operator.

(d) Suppose a KB is weakly stratified wrt , as defined in Question 1. Forany pair of natural numbers and , define ( ) by

( ) = ( ) ( )

It can be shown that for any and any atom where ( ) =

KB = iff KB ( ) =

In other words, for a weakly stratified KB, when trying to prove , weneed only consider negative assumptions whose value is lower than

. Use this fact to prove that for any and where , ( +1 ) =( + 2 ) prove this by induction on . In the induction step,

this will require assuming the claim for (which is that for any ,( + 1 ) = ( + 2 )) and then proving the claim for + 1 (which

is that for any + 1, ( + 2 ) = ( + 3 ).)

(e) Use part (d) to conclude that the negation as failure reasoning procedureabove always terminates for a KB that is weakly stratified.

Page 16: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

Chapter 7

double row

i j k

i j; k

i p p

p

p i

Production Sissies

(line sq1 sq2 sq3 )

(occupied square player ) X O(want-move player )

(move player square ).

1. Consider the following strategy for playing tic-tac-toe:

Put your mark in an available square that satisfies the first of theseconditions:

(i) a square that gives you three in a row(ii) a square that would give your opponent three in a row

(iii) a square that is a double row for you

(iv) a square that would be a double row for your opponent(v) a center square

(vi) a corner square(vii) any square

In the above, a square for a player is an available square that givesthe player two in a row on two distinct lines (where the third square of eachline is still available, obviously).

(a) Encode this strategy as a set of production rules, and state what conflictresolution is assumed.Assumptions: To simplify matters, you may assume that there are el-ements in WM of the form , for any threesquares , , that form a straight line in any order. You may also as-sume that for each occupied square, there is an element in WM of theform where is either or . Finally,assume an element of the form , that should bereplaced once a move has been determined by something of the form

� �

n m k b

i d j i d j

on peg A disksolve

on peg C disk done

n

n n

i ;

i; :

i ; i;

n m

n m k n m b ; k

n m b :

d i j

2003 R. Brachman and H. Levesque May 2, 2003

(DIGIT-MINUS top bot ans borrow )

(DIGIT-MINUS top 7 bot 3 ans 4 borrow 0)(DIGIT-MINUS top 3 bot 7 ans 6 borrow 1)

(TOP-NUM pos digit left ) (BOT-NUM pos digit left )

c 28

(b) It is impossible to guarantee a win at tic-tac-toe, but it is possible toguarantee a draw. Describe a situation where your ruleset fails to chosethe right move to secure a draw.

(c) Suggest a small addition to your ruleset that is sufficient to guarantee adraw.

2. In the famous Towers of Hanoi problem, you are given 3 pegs A, B, and C,and disks of different sizes with holes in them. Initially all the disks arelocated on peg A arranged in order, with the smallest one at the top. Theproblem is to get them all to peg C, but where only the top disk on a peg canbe moved, a disk can only be moved from one peg to another, and at no timecan a disk be placed on top of a smaller disk.

While this problem has an elegant recursive solution, it also has a less wellknown iterative solution as follows. First, we arrange the pegs in a circle, sothat clockwise we have A, B, C, and then A again. Following this, assumingwe never move the same disk twice in a row, there will always only be onedisk that can be legally moved, and we transfer it to the first peg it can occupy,moving in a clockwise direction, if is even, and counter-clockwise, if isodd.

Write a collection of production rules that implement this procedure. Ini-tially, the working memory will have elements ( ) for eachdisk and an element ( ) When your rules stop firing, you should have( ) for each disk and ( ) in working memory.

3. This question concerns performing subtraction using a production system.Assume that WM initially contains information to deal with individual digitsin the following form:

, where and areany digits, and if , then is and is 0 else is10 + and is 1

For example, would be in WM,as would . The working memoryalso specifies the first and second arguments of a subtraction problem (thesubtrahend and minuend):

and ,where is a digit, and and are indices indicating the currentposition of the digit and its neighbour to the left, respectively.

Page 17: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

not

i d j

2003 R. Brachman and H. Levesque May 2, 2003

(TOP-NUM pos 0 digit 5 left 1)(TOP-NUM pos 1 digit 6 left 2)(TOP-NUM pos 2 digit 4 left 3)

(START)(START)(ANS-NUM pos digit left )

c 29

For example, if the subtrahend were 465, the WM would contain

Finally, the WM contains the goal . Your job is to write a collectionof production rules which removes and eventually stops with addi-tional elements in WM of the form , indicatingdigit by digit what the answer of the subtraction is. Be sure to specify whichconflict resolution strategy you are using; you may use any strategy describedin the text. You may use any arithmetic operators in your rules.

Page 18: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

Frames

Chapter 8

Classroom scheduler

IF-NEEDED IF-ADDED

IF-ADDED

LodgingStayTravelStep

LodgingStay lodgingCityarrivingTravelStep departingTravelStep Travel-

Step TravelStep origin destinationpreLodgingStay postLodgingStay

LodgingStay LodgingStayTravelStep

LodgingStayTravelStep lodg-ingCity preLodgingStay

1. Imagine a frame-based travel-planning assistant, as discussed in the text. Letus focus on two frames, (which represents a hotel stay in a citywhile on a trip) and (which represents any travel from one city toanother). A has a , in which the lodging is located,an , and a , both of which are

s. A has an and a , each of which is a city,a possible , and a possible , each of whichis a . For simplicity, assume that there is always abetween any two s.

Write in English some combination of and/or proce-dures that could be attached to the city slots of the various and

frames to keep them consistent. Statements like “set theof my to be the same as this one” in a procedure are

fine. Make sure that a change to one of these city slots does not cause aninfinite loop.

In the the remaining exercises, we consider two possible frame-based applications:

Imagine we want to build a program that helps schedulerooms for classes of various size at a university, using the sort of frame tech-nology (frames, slots, and attached procedures) discussed in the text. Slots offrames might be used to record when and where a class is to be held, the ca-pacity of a room, etc., and and other procedures might be used toencode constraints as well as to fill in implied values when the KB is updated.

In this problem, we want to consider updating the KB in several ways: (1)asserting that a class of a given size is to be held in a given room at a given

e.g.

Olympic assistant

IF-ADDED IF-NEEDED

IF-ADDEDIF-NEEDED

2003 R. Brachman and H. Levesque May 2, 2003c 32

time; the system would either go ahead and add this to its schedule, or alertthe user that it was not possible to do so; (2) asserting that a class of a givensize is to be held at a given time, with the system providing a suitable room(if one is available) when queried; (3) asserting that a class of a given size isdesired, with the system providing a time and place when queried.

Imagine we want to help the International Olympic Committeein the smooth running of the next Olympic games. In particular, we want toselect an event and write a program to deal with that event including facilitiesfor handling the preliminary rounds/heats and finals. Slots of frames might beused to record athletes in a heat/final, the location and time of that heat/final,etc. and / and other procedures might be used toencode constraints as well as fill in implied values when the knowledge baseis updated.

We particularly wish to consider several ways of updating the knowledgebase: (1) asserting that a heat will take place with certain athletes. The sys-tem should add this and determine what time and the location of the venuethe athletes need to be at for their heat, etc; (2) asserting that a particularsemi-final/final should take place, the system should determine the partici-pating athletes; and, (3) asserting that the medal ceremony should take placeat a particular time and location, the system should add this and provide themedallists plus appropriate national anthem when queried. To simplify mat-ters, we assume that an athlete takes part in only the event we have chosen.

2. For either application, the questions are the same:

(a) Design a set of frames and slots to represent the schedule and any an-cillary information needed by the assistant.

(b) For all slots of all frames, write in English pseudocode theor procedures that would appear there. Annotate theseprocedures with comments explaining why they are there ( whatconstraints they are enforcing).

(c) Briefly explain how your system would work (what procedures wouldfire and what they would do) on concrete examples of your choosingillustrating each of the three situations (1, 2, and 3) mentioned in theapplication.

Page 19: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

1

1 1

n

n n

��

��

Chapter 9

Descriptions

r

r:

n r

n r

rr r

r r r

r; s; t;

r s t

r s t s t

:Child :Parent

:Parent :BrotherInlaw Rich

FILLS EXISTS

SOME

AT-MOST

INVERSEINVERSE

COMPOSE

ALL COMPOSE

ALL COMPOSE SOME

ALL AND ALL EXISTS ALL AT-MOST

1. In this chapter, we considered the semantics of a description logic languagethat includes concept-forming operators such as and , but norole-forming operators. In this question, we extend the language with newconcept-forming operators and role-forming operators.

(a) Present a formal semantics in the style of the text for the followingconcept-forming operators:

[ ] Role existence.Something with at least 1[ ] Maximum role cardinality.Something with at most ’s.

(b) Do the same for the following role-forming operators:

[ ] Role inverse.So the role could be defined as [ ].[ . . . ] Role composition.The ’s of the ’s . . . of the ’s.So [ [ ] ] would meansomething all of whose uncles are rich (where an uncle is a brother-in-law of a parent).

(c) Use this semantic specification to show that for any roles andthe concept

[ [ ] [ ]]

subsumes the concept

[ [ [ [ 2 ]] [ [ 2 ]]]]

n m

n n m

m

irole chain

difference

:Brother :Friend :Sister :Enemy

1 1

1 1

1 1

1 2 3 4

1 2 5 2 5 3 4

1 2 3 4

1 2 3 4

1 2

1 2

1

2

2003 R. Brachman and H. Levesque May 2, 2003

r r s s

r r r s

s s

r

r r r r

r r r r r r r :

r r r r

r r r r :

d d ;

d d :

d p q r

d q t p s r

AMONG

AMONG

AMONG

AMONG

AMONG

AND AMONG ALL AMONG

AMONG

AMONG

AND ANDAND AND AND

c 34

by showing that the extension of the latter concept is always a subsetof the extension of the former.

2. Consider a new concept-forming operator, which takes two argu-ments, each of which can be a (a sequence of one or more roles).The description [ ( . . . ) ( . . . )] is intended to apply to anindividual whose ’s of its ’s of its . . . of its ’s are a subset of its ’sof its ’s of its . . . of its ’s. For example,

[ ( ) ( )]

would mean “something whose friends of its brothers are among the enemiesof its sisters.”

(a) Give a formal semantics for in the style of the text.

(b) Use this semantics to show that for any roles , the concept

[ ( ) ( )]

subsumes the concept

[ [ ( ) ( )] [ [ ( ) ( )]]]

(c) Does the subsumption also work in the opposite direction (that is, arethe two concepts equivalent)? Show why or why not.

(d) Construct an interpretation that shows that neither of the following twoconcepts subsumes the other:

[ ( ) ( )]

and[ ( ) ( )]

3. When building a classification hierarchy, once we have determined that oneconcept subsumes another it is often useful to calculate thebetween the two: the concept that needs to be conjoined to to produceAs a trivial example, if we have

= [ [ ]]= [ [ ] [ ] ]

Page 20: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

��

2

1

2 1 2

2 1 2

1 2

t s d

d t s :

d d d d d

d d d

d d :

2003 R. Brachman and H. Levesque May 2, 2003

concept concept conceptconcept role conceptconcept atomrole atom

AND

AND AND

ANDALL

ANDAND

AND ALL EXISTSAT-MOST

AND ALLALL AND

EXISTSAT-MOST

AND ALL EXISTSALL AND ALL

Nothing Thing

:Employee Canadian:Employee American Canadian

:Employee:Employee

:Friend Teacher:Friend Teacher Person

c 35

then the difference in question is [ ] since is equivalent to

[ [ ]]

(a) Implement and test a procedure which takes as arguments two conceptsin the following simple language, and when the first subsumes the sec-ond, returns a difference as above. You may assume that your input iswell-formed. The concept language to use is

< > ::= [ < > . . . < >]< > ::= [ < > < >]< > ::= < >< > ::= < >

with the semantics as presented in the text.

(b) The above definition of “difference” is not precise. If all we are afteris a concept such that is equivalent to [ ], then itselfwould qualify as the difference, since is equivalent to [ ],whenever subsumes Make the definition of what your programcalculates precise.

4. For this question, you will need to write, test and document a program thatperforms normalization and subsumption for a description logic language.The input will be a pair of syntactically correct expressions encoded in a list-structured form. Your system should output a normalized form of each, anda statement of which subsumes the other, or that neither subsumes the other.

The description language your program needs to handle should contain theconcept-forming operators , , and (as described in the text),

(as used in Question 1), but no role-forming operators, so that rolesare all atomic. You may assume that all named concepts and roles other than

and are primitive, so that you do not have to maintain a symboltable or classification hierarchy. Submit output from your program workingon at least the following pairs of descriptions

(1) [ [ ]](2) [ [ ]]

(1) [ 0 ](2) [ 2 ]

(1) [ [ [ 3 ]][ [ [ ]

��

2003 R. Brachman and H. Levesque May 2, 2003

AT-MOSTALL ALL

EXISTSAND EXISTS ALL

EXISTSAND AT-MOST ALL

AND ALL EXISTSALL

AND AT-MOSTALL AT-MOST

ANDALL

ANDALL

AND ALL

Teacher:Friend Teacher Female

TeacherTeacher Teacher Male

TeacherTeacher Teacher Male

:Cousin :Friend:Employee Female

:Employee:Friend :Cousin

ThingThing

c 36

[ 2 ]]]](2) [ [ ]]

(1) [ 1 ](2) [ [ 2 ] [ ]]

(1) [ 1 ](2) [ [ 2 ] [ ]]

(1) [ [ [ 0 ]][ ]]

(2) [ [ 0 ][ [ 3 ]]]

5. This question involves writing and running a program to do a simple form ofnormalization and classification, building a concept hierarchy incrementally.We will use the very simple description language specified by the grammarin Question 3a. The atomic concepts here are either primitives or the namesof previously classified descriptions.

There are two main programs to write: NORMALIZE and CLASSIFY.

NORMALIZE takes a concept description as its single argument, and returnsa normal form description: an expression where every argument is ei-ther a primitive atom or an expression whose concept argument is itselfin normal form. Within this , primitives should occur at most once,and expressions with the same role should be combined. Non-primitiveatomic concepts need to be replaced by their definitions. (It may simplify thecode to leave out the atoms and within normalized descriptions,and just deal with the lists.)

CLASSIFY should take as its argument, an atom, and a description. The ideais that a new concept of that name is being defined, and CLASSIFY shouldfirst link the name to a normalized version of the description as its definition.CLASSIFY should then position the newly defined concept in a hierarchy ofpreviously defined concepts. Initially, the hierarchy should contain a singleconcept named . Subsequently, all new concepts can work their waydown the hierarchy to their correct position starting at , as explained inthe text. (Something will need to be done if there is already a defined conceptat that position).

Page 21: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

Chapter 10

Inheritance

George:

Polly:

Dick:

In the exercises below, we consider three collections of assertions:

For each collection, the questions are the same (and see the follow-up Question 1in Chapter 11):

1. Represent the assertions in an inheritance network.

George is a Marine.George is a chaplain.A Marine is typically a beer drinker.A chaplain is typically not a beer drinker.A beer drinker is typically overweight.A Marine is typically not overweight.

Polly is a platypus.Polly is an Australian animal.A platypus is typically a mammal.An Australian animal is typically not a mammal.A mammal is typically not an egg layer.A platypus is typically an egg layer.

Dick is a Quaker.Dick is a Republican.Quakers are typically pacifists.Republicans are typically not pacifists.Republicans are typically pro-military.Pacifists are typically not pro-military.Pro-military (people) are typically politically active.Pacifists are typically politically active.

2003 R. Brachman and H. Levesque May 2, 2003c 38

2. What are the credulous extensions of the network?

3. Which of them are preferred extensions?

4. Give a conclusion that a credulous reasoner might make but that a skepticalreasoner would not.

5. Are there conclusions where a skeptical reasoner and an ideally skepticalreasoner would disagree given this network.

Page 22: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

Defaults

Chapter 11

Canadians are typically not francophones.All Quebecois are Canadians.Quebecois are typically francophones.Robert is a Quebecois.

not

All Quebecois are abnormal Canadians.

Quebecois are typically abnormal Canadians.

1. Although the inheritance networks of Chapter 10 are in a sense much weakerthan the other formalisms considered in this chapter for default reasoning,they use default assertions more fully.

Consider the following assertions:

Here is a case where it seems plausible to conclude by default that Robert isa francophone.

(a) Represent these assertions in an inheritance network (treating the sec-ond one as defeasible), and argue that it unambiguously supports theconclusion that Robert is a francophone.

(b) Represent them in first-order logic using two abnormality predicates,one for Canadians and for one for Quebecois, and argue that as it stands,minimizing abnormality would be sufficient to conclude that Robertis a francophone.

(c) Show that minimizing abnormality would work if we add the assertion

but will not work if we only add

B

e

e

0

0

0

6

8 8 : � 6

[ f: j 6j g

8 ^ : : �

Chilly Tweety

Bird Fly Fly

q;

c; f

c c

x y x; y x y :

t t :

x x x x :

Ab

Ab

Ab

Ab Ab

disjunctive

strong

2003 R. Brachman and H. Levesque May 2, 2003c 40

(d) Repeat the exercise in default logic: Represent the assertions as twofacts and two normal default rules, and argue that the result has twoextensions. Eliminate the ambiguity using a non-normal default rule.You may use a variable-free version of the problem where the letters

and stand for the propositions that Robert is Quebecois, Canadian,and francophone respectively, and where defaults are considered onlywith respect to Robert.

(e) Write a variable-free version of the assertions in autoepistemic logic,and show that the procedure described in the text generates two stableexpansions. How can the unwanted expansion be eliminated?

2. Consider the Chilly and Tweety KB presented in the text.

(a) We showed that for this KB, if we write the default that birds fly using anabnormality predicate, the resulting KB minimally entails that Tweetyflies. Prove that without ( = ), the conclusion no longerfollows.

(b) Suppose that for any two constants and , we hoped to conclude bydefault that they were unequal. Imagine that we have a binary predicate

and a FOL sentence

( ( ) ( = ))

Would using minimal entailment work? Explain.

3. Consider the following proposal for default reasoning: as with minimal en-tailment, we begin with a KB that uses one or more predicates. Then,instead of asking what is entailed by the KB, we ask what is entailed by KB ,where

KB = KB ( ) KB = ( )

Compare this form of default reasoning to minimal entailment. Show anexample where the two methods disagree on some default conclusions. Statea sufficient condition for them to agree.

4. This question concerns the interaction between defaults and knowledge thatis . Starting with autoepistemic logic, there are different ways onemight represent a default like “Birds fly.” The first way, as in the text, is whatwe might call a default:

( ( ) ( ) ( ))

Page 23: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

weak

B B

B B B

x x x x :

x x x x :

x x :

8 ^ : : �_ :

8 ^ : : �

h ) � i

2003 R. Brachman and H. Levesque May 2, 2003

Bird Fly Fly

Bird(a) Bird(b) (Bird(c) Bird(d)) Fly(b)

Bird Fly Fly

TRUE Bird Fly

c 41

Another way is what we might call a default:

( ( ) ( ) ( ))

In this question, we will work with the following KB:

, , , ,

where we assume that all names denote distinct individuals.

(a) Propositionalize and show that the strong and weak defaults lead todifferent conclusions about flying ability.

(b) Consider the following version of the default:

( ( ) ( ) ( ))

Show that this version does not lead to reasonable conclusions.

(c) Now consider using default logic and circumscription to represent thedefault. Show that one of them behaves more like the strong default,while the other is more like the weak one.

(d) Consider the following representation of the default in default logic:

[ ( ) ( )]

Discuss how this representation handles disjunctive knowledge.

Page 24: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

X

n

ni

i

1 2

=1

Chapter 12

Probability

statisticallyindependent

j j \ j j j

j\ \ j \ � j �

j j �\

[

\ �

\ j j � j

Pr PrPr

Pr Pr Pr Pr

Pr Pr Pr Pr

Pr Pr

Pr

Pr Pr PrPr Pr Pr

a b

a b b

a b a b = b : a ; a

a u ; u

u

a b c a b c b c c :

a b b a a = b :

b ; b ; b

a;

a a b :a b

a b

a b a b a b

a b c a c b c :

1. One way to understand probabilities is to imagine taking a snapshot of all theentities in the domain of discourse (assuming there are only finitely many),and looking at the proportion of them having certain properties. We can thenuse elementary set theory to analyze the relationships among various prob-abilities. Under this reading, the probability of given is defined as thenumber of elements in both and divided by the number of elements inalone: ( ) = Similarly, ( ) the probability of itself canbe thought of as ( ) where is the entire domain of discourse. Notethat according to this definition, the probability of is 1 and the probabilityof the empty set is 0.

Use this simple model of probability to do the following:

(a) Prove that ( ) = ( ) ( ) ( )

(b) Prove Bayes’ Theorem: ( ) = ( ) ( ) ( )

(c) Suppose that . . . are mutually exclusive events of which onemust occur. Prove that for any event we have that

( ) = ( )

(d) Derive (and prove correct) an expression for ( ) that does not useeither disjunction or conjunction.

(e) Recall that two statistical variables and are said to beiff ( ) = ( ) ( ). However, just because and

are independent, it does not follow that (( ) ) = ( ) ( )Explain why.

j j

j j

j j

j j

j j

PrPr PrPr PrPr PrPr PrPr Pr

2003 R. Brachman and H. Levesque May 2, 2003

a

b c

d e

a :

b a : b a :

c a : c a :

e c : e c :

d b; c : d b; c :

d b; c : d b; c :

a; b; c

a

c f t

v

Metastatic cancer is a possible cause of a brain tumorand is also an explanation for an increased total serumcalcium. In turn, either of these could cause a patientto fall into an occasional coma. Severe headache couldalso be explained by a brain tumor.

a priori

The fire alarm in a building can go off if there is a fire inthe building or if the alarm is tampered with by vandals.If the fire alarm goes off, this can cause crowds to gatherat the front of the building and firetrucks to arrive.

c 44

2. Consider the following example:

(a) Represent these causal links in a belief network. Let stand for “meta-static cancer,” for “increased total serum calcium,” for “brain tu-mor,” for “occasional coma,” and for “severe headaches.”

(b) Give an example of an independence assumption that is implicit in thisnetwork.

(c) Suppose the following probabilities are given:

( ) = 2( ) = 8 ( ) = 2( ) = 2 ( ) = 05( ) = 8 ( ) = 6( ) = 8 ( ) = 8( ) = 8 ( ) = 05

and assume that it is also given that some patient is suffering from se-vere headaches, but has not fallen into a coma. Calculate joint proba-bilities for the 8 remaining possibilities (that is, according to whether

and are true or false).

(d) According to the numbers above, the probability that the patienthas metastatic cancer is .2. Given that the patient is suffering fromsevere headaches but has not fallen into a coma, are we now more orless inclined to believe the hypothesis? Explain.

3. Consider the following example:

(a) Represent these causal links in a belief network. Let stand for “alarmsounds”, for “crowd gathers”, for “fire exists”, for “firetruck ar-rives”, and for “vandalism exists”

Page 25: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

j j j j

j j

j : j :

j: j:

j: : j: :

jj:

Pr Pr Pr Pr

Pr PrPr PrPr PrPr PrPrPrPrPr

2003 R. Brachman and H. Levesque May 2, 2003

t v t v t a; v t a; v

ar

ah ae te

dh

ah ar; dh ae ar; te :

ah ar; dh ae ar; te :

ah ar; dh ae ar; te :

ah ar; dh ae ar; te :

te ar :

te ar :

ar :

dh : :

a priori

Aching elbows and aching hands may be the result ofarthritis. Arthritis is also a possible cause of tennis el-bow, which in turn may cause aching elbows. Dishpanhands may also cause aching hands.

c 45

(b) Give an example of an independence assumption that is implicit in thisnetwork.

(c) What are the 10 conditional probabilities that need to be specified tofully determine the joint probability distribution? Suppose that there isa crowd in front of the building one day, but that no firetrucks arrive.What is the chance that there is a fire, expressed as some function ofthe 10 given conditional probabilities?

(d) Suppose we find out that in addition to setting off the fire alarm, vandalscan cause a firetruck to arrive by phoning the Fire Department directly.How would your belief network need to be modified. Assuming all thegiven probabilities remain the same (including the probabilityof vandalism), there would still not be enough information to calculatethe full joint probability distribution. Would it be sufficient to be given

( ) and ( )? How about being told ( ) and ( )instead? Explain your answers.

4. Consider the following example:

(a) Represent these facts in a belief network. Let stand for “arthritis,”for “aching hands,” for “aching elbow,” for “tennis elbow,”

and for “dishpan hands.”

(b) Give an example of an independence assumption that is implicit in thisnetwork.

(c) Write the formula for the full joint probability distribution over all 5variables.

(d) Suppose the following probabilities are given:

( ) = ( ) = 1( ) = ( ) = 99( ) = ( ) = 99( ) = ( ) = 00001( ) = 0001( ) = 01( ) = 001( ) = 01

Pr Pr

j j:

apriori

te ar te ar : :

2003 R. Brachman and H. Levesque May 2, 2003c 46

Assume that we are interested in determining whether it is more likelythat a patient has arthritis, tennis elbow, or dishpan hands.

i. With no observations at all, which of the three is most likely?

ii. If we observe that the patient has aching elbows, which is now themost likely?

iii. If we observe that the patient has both aching hands and elbows,which is the most likely?

iv. How would your rankings change if there were no causal con-nection between tennis elbow and arthritis, where for example,

( ) = ( ) = 00999

Show the calculations justifying your answers.

Page 26: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

2

0 0

Σ Σ

Σ

Chapter 13

Abduction

Hint:

relevant

Note:

2 2

6j � f g

2 2

j � f g� f g

2 2

: 6j � f g

c

: ;

c:

c :

S p p

S

S p

S p

c S � c

S c � � S

c S � c

S c � S S S S c

c �

S S

p c S � c � p

� p S c �

S p

S pS

1. In Chapter 4, we saw that Resolution was logically complete for the emptyclause, but not for clauses in general. Prove that Resolution is complete forprime implicants that are not tautologous. Assume that is a primeimplicant of a set of clauses Then there is a derivation of given and thenegation of Show how to modify this derivation to obtain a new Resolutionderivation that ends with but uses only the clauses in

2. In this question we explore what it could mean to say that a KB “says some-thing” about some topic. More precisely, we say that a set of propositionalclauses is to an atom iff appears (either positively or nega-tively) in a non-tautologous prime implicate of .

(a) Give an example of a consistent set of clauses where an atom ismentioned, but where is not relevant to .

(b) Suppose we have a clause , and a literal . Show that if= , then appears in a prime implicate of .

(c) Suppose we have a clause , and a literal . Show that if= , then is logically equivalent to where is with

replaced by .

(d) Suppose is consistent. Use parts (b) and (c) to show that is relevantto iff there is a non-tautologous clause with , where =or = such that = .

(e) Use part (d) to argue that there is polynomial time procedure that takesa set of Horn clauses and an atom as arguments and decides whether

is relevant to . the naive way of doing this would take expo-nential time since can have exponentially many prime implicates.

io

ii

f

��

��

ff

I1 I2 I3 O1

10 1

P P P

� � �

P P P

� � �

P P P

� � �

2003 R. Brachman and H. Levesque May 2, 2003c 48

Figure 13.1: A circuit for AND

31

2

1

3. Consider the binary circuit for logical AND depicted in Figure 13.1, where, , and are logical inverters, and is an OR gate.

(a) Write sentences describing this circuit: its components, connectivity,and normal behaviour.

(b) Write a sentence for a fault model saying that a faulty inverter has itsoutput the same as its input.

(c) Assuming the above fault model and that the output is given inputs ofand , generate the three abductive explanations for this behaviour.

(d) Generate the three consistency-based diagnoses for this circuit underthe same conditions.

(e) Compare the abductive and consistency-based diagnoses and explaininformally why they are different.

Page 27: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

0

0 0

1 2 1

2

Action

Chapter 14

locations tiles

Poss

Pots of water:

15 puzzle:

p; w; s p

w s:p

p p; p

p p p p

t; l

t l;

t; s

t s

l ; l l

l :

Contains, Contains

emptytransfer

move

loc loc

Adjacent

Adjacent

In the exercises below, and in the follow-up exercises of Chapter 15, we considerthree application domains where we would like to be able to reason about actionand change:

Consider a world with pots that may contain water. There is a sin-gle fluent, where ( ) is intended to say that a potcontains litres of water in situation There are only two possible actions,which can always be executed: ( ) which discards all the water con-tained in the pot , and ( ), which pours as much water as possiblewithout spilling from pot to , with no change when = . To simplifythe formalization, we assume that the usual arithmetic constants, functionsand predicates are also available. (You may assume that axioms for thesehave already been provided or built-in.)

The 15-puzzle consists of 15 consecutively numbered tiles located in a4 4 grid. The object of the puzzle is to move the tiles within the grid sothat each tile ends up at its correct location, as shown in Figure 14.1. The do-main consists of , numbered 1 to 16, , numbered 1 to 15, and ofcourse, actions and situations. There will be a single action ( ) whoseeffect is to move tile to location when possible. We will also assume asingle fluent, which is a function , where ( ) refers to the locationof tile in situation . The only other non-logical terms we will use is thesituation calculus predicate and, to simplify the formalization, a pred-icate ( ) which holds when location is one move away fromlocation For example, location 5 is adjacent only to locations 1, 6, and 9.(You may assume that axioms for have already been provided.)

-

� �

Locloc

puton

t; l; s

t; s l

x; y x

C

D

F

A

B E

Blocks world:

2003 R. Brachman and H. Levesque May 2, 2003c 50

Figure 14.1: The 15-puzzle

goal stateinitial state

4321

8765

1211109

1514139 14 11 12

13 5 4

10 2 7 15

1 6 3 8

Figure 14.2: The blocks word

Note that in the text we concentrated on fluents that were predicates. Herewe have a fluent that is a function. Instead of writing ( ), you will bewriting ( ) = .

Imagine that we have a collection of blocks on a table, and thatwe have a robot arm that is capable of picking up blocks and putting themelsewhere as shown in Figure 14.2

We assume that the robot arm can hold at most one block at a time. Wealso assume that the robot can only pick up a block if there is no otherblock on top of it. Finally, we assume that a block can only support orbe supported by at most one other block, but that the table surface is largeenough that all blocks can be directly on the table. There are only two ac-tions available: ( ) which picks up block and moves it onto block

Page 28: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

y x x

x; y; s x y

x; s x

putonTableOn

OnTable

2003 R. Brachman and H. Levesque May 2, 2003c 51

, and ( ) which moves block onto the table. Similarly, we haveonly two fluents: ( ) which holds when block is on block , and

( ) which holds when block is on the table.

For each application, the questions are the same:

1. Write the precondition axioms for the actions.

2. Write the effect axioms for the actions.

3. Show how successor state axioms for the fluents would be derived from theseeffect axioms. Argue that the successor state axioms are not logically entailedby the effect axioms, by briefly describing an interpretation where the effectaxioms are satisfied but the successor state ones are not.

4. Show how frame axioms are logically entailed by the successor state axioms.

Page 29: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

0

9

0 0

Planning

Chapter 15

s:�

e S

a; e a e

e

Pots of water:

15 puzzle:

Blocks world:

do

(Do not attemptto write down a derivation!)

The exercises below are continuations of the exercises from Chapter 14. For eachapplication, we consider a planning problem involving an initial setup and a goal.

Imagine that in the initial situation, we have two pots, a 5-litre onefilled with water, and an empty 2-litre one. Our goal is to obtain 1 litre ofwater in the 2-litre pot.

Assume that every tile is initially placed in its correct position, exceptfor tile 9 which is in location 13, tile 13 in location 14, tile 14 in location15, and tile 15 in location 16. The goal, of course, is to get every tile placedcorrectly.

In the initial situation, the blocks are arranged as in Figure 14.2 ofChapter 14. The goal is to get them arranged as in Figure 15.1.

For each application, the questions are the same:

1. Write a sentence of the situation calculus of the form which asserts theexistence of the final goal situation.

2. Write a ground situation term (that is, a term that is either or of the form( ) where is a ground action term and is itself a ground situation

term) such that denotes the desired goal situation.

3. Explain how you could use Resolution to automatically solve the problemfor any initial state: how would you generate the clauses, and assuming theprocess stops, how would you extract the necessary moves?

Explain why you need to use the successor stateaxioms, and not just effect axioms.

� �

��

C

D

E

A

B F

x

x x

x y x y y

finalposition

strips

strips

strips

2003 R. Brachman and H. Levesque May 2, 2003c 54

Figure 15.1: The blocks word goal

4. Suppose we were interested in formalizing the problem using a repre-sentation. Decide what the operators should be, and then write the precondi-tion, add list, and delete list for each operator. You may change the languageas necessary.

5. Consider the database corresponding to the initial state of the problem. Foreach operator, and each binding of its variables such that the precon-dition is satisfied, state what the database progressed through this operatorwould be.

6. Consider the final goal state of the problem. For each operator, de-scribe the bindings of its variables for which the operator can be the finalaction of a plan, and in those cases, what the goal regressed through the op-erator would be.

7. Without any additional guidance, a very large amount of search is usuallyrequired to solve planning problems. There are often, however, application-dependent heuristics that can be used to reduce the amount of search. Forexample,

for the 15-puzzle, we should get the first row and first column of tilesinto their correct positions (tiles 1, 2, 3, 4, 5, 9, 13); then recursivelysolve the remaining 8-puzzle without disturbing these outside tiles;

for the blocks world, we should never move a block that is in its, where a block is considered to be in its final position iff

either (a) is on the table and will be on the table in the goal state or(b) is on another block , will be on in the goal state, and is alsoin its final position.

Page 30: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

golog

golog

2003 R. Brachman and H. Levesque May 2, 2003c 55

Explain how the complex actions of from Chapter 14 can be usedto define a more restricted search problem which incorporates heuristics likethese. Sketch briefly what the program would look like.

Page 31: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

x x x x :8 � _

_

_

Tradeoff

Chapter 16

sub-sumes

taxonomy

Mammal Rodent CarnivorousMammal

Turtle fred Cat fred

Gerbil stan Hamster stan

1. Many of the disjunctive facts that arise in practice state that a specific in-dividual has one property or another, where the two properties are similar.For example, we may want to represent the fact that a person is either 4 or5 years old, that a car is either a Chevrolet or a Pontiac, or that a piece ofmusic is either by Mozart or by Haydn. In general, to calculate the entail-ments of a KB containing such facts, we would need to use a mechanismthat considered each case individually, such as Resolution. However, whenthe conditions being disjoined are sufficiently similar, a better strategy mightbe to try to sidestep the case analysis by finding a single property that

the disjoined ones. For example, we might treat the original fact as ifit merely said that the person is a pre-schooler, that the car is made by GM,and that the music is by a classical composer, none of which involve explicitdisjunctions.

Imagine that you have a KB which contains among other things aof one place predicates like in Figure 16.1 that can be used to find subsumingcases for disjunctions. Assume that this taxonomy is understood as exhaus-tive, so that, for example, it implies

[ ( ) ( ) ( )]

(a) Given the above taxonomy, what single atomic sentence could be usedto replace the disjunction ( ( ) ( ))? Explain why noinformation is lost in this translation.

(b) What atomic sentence would replace the disjunction

( ( ) ( ))?

1 n i

C C C

sound

does

Dog sam Snake sam Rabbit sam

_ _

_ _

j _ j j

_ j _ _ 6j _ 6j

j _ 6j 6j

6j _

P a P a ; P

� �

� � � �

p q p q p q p p q q

S � � S � � S � S �

� �

2003 R. Brachman and H. Levesque May 2, 2003

XXXXXXXHHH

��

( ( ( ( ( ( ( ( ( ( (

��� � � �

# #� � � �

JJ

JJJ

BB

BBB

QQQ

� � � �

��

! ! ! ! !

��

� � � � � � � �

� � � � � � �

��

��

� � � � � �

��

��

c 58

Figure 16.1: A taxonomy of pets

guppyhamster goldfishgerbilmousedogferretcatsnaketurtle

rodentrodenteater

carnivorousmammal

fisheater

fishmammalcarnivorereptile

pet

In this case, information about Stan is lost. Give an example of a sen-tence that follows from the original KB containing the disjunction, butthat no longer follows once the disjunction is eliminated.

(c) What should happen to the disjunction

( ( ) ( ) ( ))?

(d) Present informally a procedure which, given a taxonomy like the aboveand a disjunction ( ( ) . . . ( )) where the are predicates thatmay or may not appear in the taxonomy, replaces it by a disjunctioncontaining as few cases as possible.

(e) Argue that a reasoning process that first eliminates disjunctions as wehave done above will always be .

2. In Chapter 11, we saw that under the closed world assumption, complexqueries can be broken down to queries about their parts. In particular, re-stricting ourselves to the propositional case, for any formulas and , wehave that KB = ( ) iff KB = or KB = . This way of handlingdisjunction clearly does not work for regular entailment since, for instance,( ) = ( ) but ( ) = and ( ) = .

(a) Prove that this way of handling disjunction work for regular en-tailment when the KB happens to be a complete set of literals (that is,containing every atom or its negation).

(b) Show that the completeness of the KB matters here by finding a set ofliterals and formulas and such that = ( ), = , = ,and = ( ).

Page 32: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

1

1 1

0

0

00 0

0

0

00

dog animal

j _

j j

f g

f � � g

^

� � ^

definitions

Hint:

Hint:n

n n i

i i

i i

i ii i

i i i i

i i i i

i i i i i

i

2003 R. Brachman and H. Levesque May 2, 2003

� � � �

� �

VA q ; ; q A

D q � ; ; q � �

A

D q �

� D � �

� � q �

� D �

� V � �

V

D

q � D

� � V

V � q � D

q � � q � D

q � r r

q � q � r

r

c 59

(c) Prove that when a KB is a set of literals (not necessarily complete) andalso and have no atoms in common, then once again KB = ( )iff KB = or KB = .

3. In this question we will consider reasoning with a vivid KB and ,in a simple propositional form. So assume that a KB consists of two parts,a vivid part , which is a complete and consistent set of literals over someset of atoms , and for some set of atoms . . . not in , a set ofdefinitions = ( ) . . . ( ) , where each is an arbitrarypropositional formula whose atoms are all from . Intuitively, we are using

to define as . We want to examine the conditions under which we canreason efficiently with such a KB.

(a) Prove that for any propositional formula , that entails ( ),where is like except with replaced by . show by induc-tion on the size of that any interpretation satisfying will satisfyiff it satisfies .

(b) Using part (a), prove that for any propositional formula , KB entailsiff entails , where is as above.

(c) Explain using part (b) how it is possible to efficiently determine whetherKB entails an arbitrary propositional . State precisely what assump-tions are needed regarding the sizes of the various formulas.

(d) Would this this still work if were a collection of propositional Hornclauses? Explain briefly.

(e) Suppose that contained “necessary but not sufficient conditions” (likewe saw in description logics) of the form ( ). might contain,for example, ( ). For efficiency reasons, it would be nice tostill replace by and then use , as we did above. Give an exampleshowing that the resulting reasoning process would not be sound.

(f) Under the same conditions as part (e), suppose that instead of usingand , we use , defined as follows: when ( ) is in , wereplace in by as before; but when ( ) is in , we replace

by ( ), where is some new atom used nowhere else. The ideahere is that we are treating ( ) as if it were ( ( )) forsome atom about which we know nothing. Show that the reasoningprocess is now both sound and complete. repeat the argumentfrom part (b).

4. Consider the following KB:

¿

�j j

� �

ANDAND

sound

incomplete

_

8 �

:

:

[

[

j j �

j

j j j

x x x

P t

P u t u

Q t P u P Q:

::

� �

�;

�;

2003 R. Brachman and H. Levesque May 2, 2003

Man sandy Woman sandyPerson Woman mother

Female(mother(sandy)),

Man Person MaleWoman Person Female

Person Male Female

c 60

( ) ( )[ ( ) ( ( ))]

From this KB, we would like to conclude that butobviously this cannot be done as is using ordinary Resolution, without sayingmore about the predicates involved.

Imagine a version of Theory Resolution that works with Description Logicfrom Chapter 9 as follows: for unary predicates, instead of requiring ( ) inone clause and ( ) in the other (where and are unifiable), we insteadallow ( ) in one clause and ( ) in the other provided that subsumesThe assumption here is that some of the unary predicates in the KB will haveassociated definitions in Description Logic. In the above example, assumewe have the following:

= [ ]= [ ]

where , , and are primitive concepts.

(a) Show using Theory Resolution that the conclusion now follows.

(b) Show that this derivation is by writing meaning postulates MPfor the two definitions such that the conclusion is entailed by KB MP.

(c) Show that this form of Theory Resolution is by finding asentence that is entailed by KB MP, but not derivable from KB usingTheory Resolution as above.

5. We saw in Section that it was possible to determine entailments efficientlywhen a KB was an arbitrary set of literals (not necessarily complete) andthe query was small relative to the size of the KB. In this question, we willgeneralize this result to Horn KBs. More precisely, assume that KB2 , where KB is a set of propositional Horn clauses, and is an arbitrarypropositional sentence. Prove that it is possible to decide whether KB entails

in time that is polynomial in |KB|. Why does this not work if is the samesize as the KB?

6. In this question, we will explore a different way of dealing with the compu-tational intractability of ordinary deductive reasoning than what we saw inthe text. The idea is that instead of determining if KB = which can betoo difficult in general, we determine if KB = where = is a variant of =that is easier to calculate. To define this variant, we first need two auxiliarydefinitions:

Page 33: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

1 2 1

2 1 2

1 1

2

2

Definition 1

Definition 2

Definition 3

2003 R. Brachman and H. Levesque May 2, 2003

I2 I

f j 2 2

2 6 g I

I

2

" f j 2 62 62 g [ f � j 2 62 2 g

" "

f g

2 I j I j " I j

j

j [ f g

S c S; c

c:

H

HS T S x ; x c S; x

c; x c; x x : S

S T S :

S; S ;

S;

S: x; x S;

S x c c S; x c; x c c x c S; x c; x c :

S S x S;

S x; S x

S S

p ; p; s ; q; q ; s; r; u; v ; q ; r ; p; q; t; u

S S

S

S

S S

S x x S; S S x x;

p;

p

p p

An interpretation a set of (propositional)clauses iff for every clause satisfies some literal in (as usual),and falsifies at most one of the literals in

For any set of (propositional) clauses let BP which is theof be the set of clauses resulting from resolving away

all unit clauses in More formally, for any literal such that letThen

BP is the result of starting with and any unit clause in calculatingand then repeating this process with (assuming it contains a unit

clause) and so on, until no unit clauses remain.

BP

BP

BP

BP

iff BP is not maximally satisfiable.

c 61

maximally satisfies

(a) If a set of clauses has a maximally satisfying interpretation then it isclearly satisfiable, but the converse need not hold. Present a set ofclauses (with no unit clauses) that is satisfiable but not maximally sat-isfiable.

(b) Let be a set of Horn clauses with no unit clauses and no empty clause.Show that is always maximally satisfiable.

(c) For any set of clauses, let ( ) = [ ] for some= Prove that when contains no unit clauses,

maximally satisfies iff satisfies ( )

In the second definition, we eliminate unit clauses from a set of clauses:

( )binary propagation

[ ]=

( ) [ ]

(d) What is ( ) when is

[ ] [ ] [ ] [ ] [ ] [ ] [ ] ?

(e) Present an example of a unsatisfiable set of clauses such that ( )contains the empty clause, and another unsatisfiable set such that

( ) does not contain the empty clause.

(f) Prove that is satisfiable iff ( ) is satisfiable. It is sufficient to provethat for any and such that [ ] = iff = and =and the rest follows by induction.

Finally, we define KB = where for simplicity, we assume that KB is a setof clauses and is atomic:

KB = (KB [ ] )

p

H

H

p

S

S

j

j

j

j

j

j

Hint:

Hint:BP

BPi.e.

generalized Horn

2003 R. Brachman and H. Levesque May 2, 2003c 62

(g) Present an example KB and a query such that = does not give thesame answer as =. Use part (a) above. Explain whether reasoningwith = is unsound or incomplete (or both).

(h) Prove that reasoning with = is both sound and complete for a KB that isHorn. Where is Horn, consider the cases according to whether

( ) contains the empty clause, and use parts (b) and (f) above.

(i) Argue that for any KB it is possible to determine if KB = in poly-nomial time. You may use the fact that ( ) can be calculated inpolynomial time, and that 2SAT ( satisfiability restricted to clausesof length 2) can also be solved in polynomial time.

(j) Call a set of clauses if a set of Horn clauses could beproduced by inverting some of its atomic formulas, that is, by replacingall occurrences of the letter by its negation. Is = sound and completefor a KB that is generalized Horn? Explain.

Page 34: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,

n� = k

289

Bibliography

Knowledge Representation and Reasoning

Theoretical Computer Science

Logical Foundations of Artificial Intelli-gence

The Logic of Knowledge Bases

Proceedings of the National Conference on Artificial Intelligence(AAAI-92)

Problem Solving Methods in Artificial Intelligence

Proceedings of the National Conference on ArtificialIntelligence (AAAI-92)

[1] R. Brachman and H. Levesque, .Morgan Kaufmann, to appear.

[2] E. Dantsin, A. Goerdt, E. A. Hirsch, R. Kannan, J. Kleinberg, C. Papadim-itriou, P. Raghavan, and U. Schning, A deterministic (2 2 ( + 1)) algo-rithm for k-sat based on local search. (1),69–83, 2002.

[3] M. Genesereth and N. Nilsson,. Morgan Kaufmann, Los Altos, 1987.

[4] H. J. Levesque and G. Lakemeyer, . MITPress, Cambridge, 2000.

[5] D. Mitchell, B. Selman, and H. Levesque, Hard and easy distributions of SATproblems.

, AAAI Press/MIT Press, 459–465, 1992.

[6] N. Nilsson, . McGraw-Hill, Toronto, 1971.

[7] B. Selman, H. Levesque, and D. Mitchell, A new method for solving hard in-stances of satisfiability.

, AAAI Press/MIT Press, 440–446, 1992.

Page 35: Knowledge Representation and Reasoning · Whomever the barber shaves, must not shave himself. barber’s paradox c 4 (a) Represent the facts as sentences of FOL. As non-logical symbols,