ARTIFICIAL INTELLIGENCE Russell & Norvig Chapter 8. First-Order Logic, part 2
Interacting with FOL KBs • Tell the system assertions • Facts : • Tell (KB, person (John) ) • Rules: • Tell (KB, ∀ x, person(x) ⇒ likes(x, McDonalds)) • Ask questions • Ask (KB, person(John)) • Ask (KB, likes(John, McDonalds)) • Ask (KB, likes(x, McDonalds))
Types of Answers • Fact is in the KB • Yes. • Fact is not in the KB • Yes (if it can be proven from the KB) • No (otherwise) • Text uses • AskVars (KB, Person(x)) • Expects a list of bindings for which the fact can be proven, e.g. ((x Fred) (x Mary) … )
Kinship Axioms in Prolog father(X,Y) :- � parent(X,Y), � male(X). � brother(X,Y) :- � male(X), � mother(M,X), � mother(M,Y), � father(F,X), � father(F,Y), � not(X=Y). �
More kinship examples daughter(D,P) :- � female(D), � parent(P,D). � � grandchild(Z,X) :- � parent(X,Y), � parent(Y,Z). � � greatgrandparent(GGP, C) :- � parent(GGP,P), � grandchild(C,P). � � �
Kinship Example • From exercise 8.14
Kinship Facts married(george,mum). � parent(george,elizabeth). � married(spencer,kydd). � parent(mum,elizabeth). � married(philip,elizabeth). � parent(spencer,diana). � married(charles,diana). � parent(kydd,diana). � … � parent(elizabeth,charles). � male(andrew). � parent(philip,charles). � male(edward). � parent(elizabeth,anne). � male(william). � parent(philip,anne). � male(harry). � parent(elizabeth,andrew). � … � parent(philip,andrew). � female(elizabeth). � parent(diana,william). � female(margaret). � parent(charles,william). � female(diana). � parent(diana,harry). � female(anne). � parent(charles,harry). � female(sarah). � … � … �
Wumpus World Examples • Percept[Stench, Breeze, Glitter, Bump, Scream] • Suppose a wumpus-world agent is using a FOL KB and perceives a smell and breeze (but no glitter) at t=5 • TELL(KB, Percept([Stench, Breeze, None, None, None],5)) • ASK(KB, ∃ a Action(a, 5)) • i.e. does the KB entail any particular action at t=5? • Answer: Yes, {a/Shoot} <- substitution (binding list)
Knowledge Base for Wumpus World • “ Perception ” ∀ s, g, m, c, t Percept([s, Breeze, g, m, c], t) ⇒ Breeze(t) ∀ s, b, m, c, t Percept([s, b, Glitter, m, c], t) ⇒ Glitter(t) • “ Reflex ” • ∀ t Glitter(t) ⇒ BestAction(Grab, t) Big advantage for FOL: ∀ x, y, a, b Adjacent([x,y], [a,b]) ó (x=a ∧(y=b-1 !∨ !y=b+1)) !∨ !(y=b !∧ !(x=a-1 !∨ !x=a+1))
Inferring properties of squares If agent is at square s at time t and there is a Breeze percept at time t, then square s is Breezy. ∀ s,t At(Agent, s, t) ∧ Breeze(t) ⇒ Breezy(s) Then in FOL, locating Pits is summarized in one axiom: ∀ s Breezy(s) ó ∃ r Adjacent(r,s) ∧ Pit(r) Can also quantify over time: ∀ t HaveArrow(t+1) ó HaveArrow(t) ∧ ¬ Action(Shoot, t))
Recommend
More recommend