0% found this document useful (0 votes)
27 views23 pages

Module 1 - Knowledge Based Logic Lecture Notes. 16861418577270

Uploaded by

rashmidarling172
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views23 pages

Module 1 - Knowledge Based Logic Lecture Notes. 16861418577270

Uploaded by

rashmidarling172
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

UNIT II

Knowledge Based Agents A knowledge-based agent needs a KB and an inference


mechanism. It operates by storing sentences in its knowledge base, inferring new sentences
with the inference mechanism, and using them to deduce which actions to take The
interpretation of a sentence is the fact to which it refers.

Knowledge base = set of sentences in a formal language Declarative approach to building an


agent (or other system): Tell it what it needs toknow - Thenitcan Askitselfwhattodo—
answersshouldfollowfromtheKB Agents can be viewed at the knowledge leveli.e., what they
know, regardless of howimplemented or at the implementation leveli.e.,data
structuresinKBand algorithmsthatmanipulatethem. The Wumpus World:

A variety of "worlds" are being used as examples for Knowledge Representation, Reasoning,
and Planning. Among them the Vacuum World, the Block World, and the Wumpus World.
The Wumpus World was introduced by Genesereth, and is discussed in Russell-Norvig. The
Wumpus World is a simple world (as is the Block World) for which to represent knowledge
and to reason. It is a cave with a number of rooms, represented as a 4x4 square
Rules of the Wumpus World The neighborhood of a node consists of the four squares north,
south, east, and west of the given square. In a square the agent gets a vector of percepts, with
components Stench, Breeze, Glitter, Bump, Scream For example [Stench, None, Glitter,
None, None]  Stench is perceived at a square iff the wumpus is at this square or in its
neighborhood.  Breeze is perceived at a square iff a pit is in the neighborhood of this
square.  Glitter is perceived at a square iff gold is in this square  Bump is perceived at a
square iff the agent goes Forward into a wall  Scream is perceived at a square iff the
wumpus is killed anywhere in the cave An agent can do the following actions (one at a time):
Turn (Right), Turn (Left), Forward, Shoot, Grab, Release, Climb  The agent can go forward
in the direction it is currently facing, or Turn Right, or Turn Left. Going forward into a wall
will generate a Bump percept.  The agent has a single arrow that it can shoot. It will go
straight in the direction faced by the agent until it hits (and kills) the wumpus, or hits (and is
absorbed by) a wall.  The agent can grab a portable object at the current square or it can
Release an object that it is holding.  The agent can climb out of the cave if at the Start
square.The Start square is (1,1) and initially the agent is facing east. The agent dies if it is in
the same square asthe wumpus. The objective of the game is to kill the wumpus, to pick up
the gold, and to climb out with it. Representing our Knowledge about the Wumpus World
Percept(x, y) Where x must be a percept vector and y must be a situation. It means that at
situation y theagentperceives x.For convenience we introduce the following definitions: 
Percept([Stench,y,z,w,v],t) = > Stench(t)  Percept([x,Breeze,z,w,v],t) = > Breeze(t) 
Percept([x,y,Glitter,w,v],t) = > AtGold(t) Holding(x, y)

Where x is an object and y is a situation. It means that the agent is holding the object x in
situation y. Action(x, y) Where x must be an action (i.e. Turn (Right), Turn (Left), Forward,)
and y must be a situation. It means that at situation y the agent takes action x. At(x,y,z)
Where x is an object, y is a Location, i.e. a pair [u,v] with u and v in {1, 2, 3, 4}, and z is a
situation. It means that the agent x in situation z is at location y. Present(x,s) Means that
object x is in the current room in the situation s. Result(x, y) It means that the result of
applying action x to the situation y is the situation Result(x,y).Notethat Result(x,y) is a term,
not a statement. For example we can say  Result(Forward, S0) = S1 
Result(Turn(Right),S1) = S2 These definitions could be made more general. Since in the
Wumpus World there is a single agent, there is no reason for us to make predicates and
functions relative to a specific agent. In other"worlds" we should change things
appropriately.

Validity And Satisfiability

A sentence is valid

if it is true in all models, e.g.,True,A∨¬A, A⇒A,(A𝖠(A⇒B)) ⇒B Validity is connected to


inference via the Deduction Theorem: KB |= αif and onlyif(KB⇒α) isvalid
Asentenceissatisfiableifitistrue insome model e.g., A∨B, C Asentence
isunsatisfiableifitistrueinnomodels e.g., A 𝖠¬A Satisfiability is connected to inference via
the following: KB|=α iff(KB𝖠¬α)isunsatisfiable i.e., prove α by reductionandabsurdum

Proof Methods

Proof methods divide into (roughly)two kinds:

Application of inference rules – Legitimate(sound)generationofnewsentencesfromold –


Proof=asequenceofinferenceruleapplicationscanuseinferencerulesasoperatorsinastand
ardsearch algorithm – Typicallyrequiretranslationofsentencesintoanormalform Model
checking – Truthtableenumeration(alwaysexponentialinn) –
Improved backtracking,e.g.,Davis–Putnam–Loge Mann–Loveland – Heuristic
search in modelspace(soundbutincomplete) e.g.,min-conflicts-likehillclimbingalgorithms

Forward and Backward Chaining

Horn Form (restricted) KB = conjunction of Horn clauses Horn clause = – proposition


symbol;or – (conjunctionofsymbols) ⇒ symbol Example KB: C𝖠(B ⇒ A) 𝖠 (C𝖠D ⇒
B)
Modus Ponens (for Horn Form): complete for Horn

KBs α1,...,αn,α1𝖠···𝖠α⇒ β β

Can be used with forward chaining or backward chaining. These algorithms


are very natural and run in linear time.,
Forward Chaining
Idea: If any rule whose premises are satisfied in
theKB, add its conclusion to the KB,until query is found
Forward Chaining Algorithm
Proof of Completeness

FC derives every atomic sentence that is entailed by KB


1. FCreachesafixedpointwherenonewatomicsentencesarederived

2. Considerthefinalstateasamodelm,assigningtrue/falsetosymbols

3. Every clause in the original KB is true inm i. Proof:Supposeaclausea1𝖠...𝖠ak⇒bisfalsei


nm Then a1𝖠. . . 𝖠akis true in m and b is false in m
Thereforethealgorithmhasnotreachedafixedpoint ! 4. Hence m is a model ofKB 5.
IfKB|=q,thenqistrueineverymodelofKB,includingm a. Generalidea:
constructanymodelofKBby soundinference,checkα

Backward Chaining

Idea:workbackwardsfromthequeryq: to prove q byBC, check if q is known already, or prove


by BC all premises of some rule concluding q Avoidloops:
checkifnewsubgoalisalreadyonthegoalstack Avoid repeated work: check if new subgoal 1.
has already been proved true, or 2. has alreadyfailed
Forward vs Backward Chaining

FC is data-driven, cf. automatic, unconscious processing,


e.g.,objectrecognition,routinedecisions Maydolotsofworkthatisirrelevanttothegoal BC is goal-
driven, appropriate forproblem-solving, e.g., Where are my keys? How do I get into a PhD
program? Complexity of BC can be much less than linear in size of KB
FIRST ORDER LOGIC:
PROCEDURAL LANGUAGES AND PROPOSITIONAL LOGIC:

Drawbacks of Procedural Languages

 Programming languages (such as C++ or Java or Lisp) are by far the largest class of formal
languages in common use. Programs themselves represent only computational processes. Data
structures within programs can represent facts.

For example, a program could use a 4 × 4 array to represent the contents of the wumpus world.
Thus, the programming language statement World*2,2+← Pit is a fairly natural way to assert that
there is a pit in square [2,2].

What programming languages lack is any general mechanism for deriving facts from other facts;
each update to a data structure is done by a domain-specific procedure whose details are derived by
the programmer from his or her own knowledge of the domain.

 A second drawback of is the lack the expressiveness required to handle partial information . For
example data structures in programs lack the easy way to say, “There is a pit in *2,2+ or *3,1+” or “If
the wumpus is in *1,1+ then he is not in *2,2+.”

Advantages of Propositional Logic

 The declarative nature of propositional logic, specify that knowledge and inference are separate,
and inference is entirely domain-independent.  Propositional logic is a declarative language because
its semantics is based on a truth relation between sentences and possible worlds.  It also has
sufficient expressive power to deal with partial information, using disjunction and negation.

 Propositional logic has a third COMPOSITIONALITY property that is desirable in


representation languages, namely, compositionality. In a compositional language, the meaning of a
sentence is a function of the meaning of its parts. For example, the meaning of “S1,4𝖠 S1,2” is
related to the meanings of “S1,4” and “S1,2.

Drawbacks of Propositional Logic  Propositional logic lacks the expressive power to concisely
describe an environment with many objects.

For example, we were forced to write a separate rule about breezes and pits for each square, such
as B1,1⇔ (P1,2 ∨ P2,1) .
 In English, it seems easy enough to say, “Squares adjacent to pits are breezy.”  The syntax and
semantics of English somehow make it possible to describe the environment concisely

SYNTAX AND SEMANTICS OF FIRST-ORDER LOGIC

Models for first-order logic :

The models of a logical language are the formal structures that constitute the possible worlds under
consideration. Each model links the vocabulary of the logical sentences to elements of the possible
world, so that the truth of any sentence can be determined. Thus, models for propositional logic
link proposition symbols to predefined truth values. Models for first-order logic have objects. The
domain of a model is the set of objects or domain elements it contains. The domain is required to be
nonempty—every possible world must contain at least one object.

A relation is just the set of tuples of objects that are related.  Unary Relation: Relations relates to
single Object  Binary Relation: Relation Relates to multiple objects Certain kinds of relationships are
best considered as functions, in that a given object must be related to exactly one object.

For Example:

Richard the Lionheart, King of England from 1189 to 1199; His younger brother, the evil King John,
who ruled from 1199 to 1215; the left legs of Richard and John; crown
Unary Relation : John is a king Binary Relation :crown is on head of john , Richard is brother ofjohn
The unary "left leg" function includes the following mappings: (Richard the Lionheart) ->Richard's
left leg (King John) ->Johns left Leg

Symbols and interpretations

Symbols are the basic syntactic elements of first-order logic. Symbols stand for objects,
relations, and functions.

The symbols are of three kinds:  Constant symbols which stand for objects; Example: John,
Richard  Predicate symbols, which stand for relations; Example: OnHead, Person, King, and Crown
 Function symbols, which stand for functions. Example: left leg

Symbols will begin with uppercase letters.

Interpretation The semantics must relate sentences to models in order to determine truth. For this
to happen, we need an interpretation that specifies exactly which objects, relations and functions
are referred to by the constant, predicate, and function symbols.

For Example:

 Richard refers to Richard the Lionheart and John refers to the evil king John.  Brother refers to
the brotherhood relation  OnHead refers to the "on head relation that holds betweenthe crown
and King John;  Person, King, and Crown refer to the sets of objects that are persons, kings, and
crowns.  LeftLeg refers to the "left leg" function,

The truth of any sentence is determined by a model and an interpretation for the sentence's
symbols. Therefore, entailment, validity, and so on are defined in terms of all possiblemodels and all
possible interpretations. The number of domain elements in each model may be unbounded-for
example, the domain elements may be integers or real numbers. Hence, the number of possible
models is anbounded, as is the number of interpretations.

Term
A term is a logical expression that refers to an object. Constant symbols are therefore terms.
Complex Terms A complex term is just a complicated kind of name. A complex term is formed by a
function symbol followed by a parenthesized list of terms as arguments to the function symbol For
example: "King John's left leg" Instead of using a constant symbol, we use LeftLeg(John). The formal
semantics of terms :

Consider a term f (tl,. . . , t,). The function symbol frefers to some function in the model (F); the
argument terms refer to objects in the domain (call them d1….dn); and the term as a whole refers to
the object that is the value of the function Fapplied to dl, . . . , d,. For example,: the LeftLeg
function symbol refers to the function “ (King John) -+ John's left leg” and John refers to King John,
then LeftLeg(John) refers to King John's left leg. In this way, the interpretation fixes the referent of
every term.

Atomic sentences

An atomic sentence is formed from a predicate symbol followed by a parenthesized list of terms:
For Example: Brother(Richard, John).

Atomic sentences can have complex terms as arguments. For Example: Married (Father(Richard),
Mother( John)).

An atomic sentence is true in a given model, under a given interpretation, if the relation referred to
by the predicate symbol holds among the objects referred to by the arguments

Complex sentences Complex sentences can be constructed using logical Connectives, just as in
propositional calculus. For Example:
Thus, the sentence says, ―For all x, if x is a king, then x is a person.‖ The symbol x is called
a variable. Variables are lowercase letters. A variable is a term all by itself, and can also
serve as the argument of a function A term with no variables is called a ground term.

Assume we can extend the interpretation in different ways: x→ Richard the Lionheart, x→ King
John, x→ Richard’s left leg, x→ John’s left leg, x→ the crown

The universally quantified sentence ∀x King(x) ⇒Person(x) is true in the original model if the
sentence King(x) ⇒Person(x) is true under each of the five extended interpretations. That is, the
universally quantified sentence is equivalent to asserting the following five sentences:

Richard the Lionheart is a king ⇒Richard the Lionheart is a person. King John is a king ⇒King John is
a person. Richard’s left leg is a king ⇒Richard’s left leg is a person. John’s left leg is a king ⇒John’s
left leg is a person. The crown is a king ⇒the crown is a person.

Existential quantification (∃)

Universal quantification makes statements about every object. Similarly, we can make a statement
about some object in the universe without naming it, by using an existential quantifier.
“The sentence ∃x P says that P is true for at least one object x. More precisely, ∃x P is true in a
given model if P is true in at least one extended interpretationthat assigns x to a domain element.”
∃x is pronounced “There exists an x such that . . .” or “For some x . . .”.

For example, that King John has a crown on his head, we write ∃xCrown(x) 𝖠OnHead(x,

John) Given assertions:

Richard the Lionheart is a crown 𝖠Richard the Lionheart is on John’s head; King John is a crown
𝖠King John is on John’s head; Richard’s left leg is a crown 𝖠Richard’s left leg is on John’s head;
John’s left leg is a crown 𝖠John’s left leg is on John’s head; The crown is a crown 𝖠the crown is on
John’s head. The fifth assertion is true in the model, so the original existentially quantified sentence
is true in the model. Just as ⇒appears to be the natural connective to use with ∀, 𝖠is the natural
connective to use with ∃.

Nested quantifiers

One can express more complex sentences using multiple quantifiers.

For example, “Brothers are siblings” can be written as ∀x∀y Brother (x, y) ⇒Sibling(x, y).
Consecutive quantifiers of the same type can be written as one quantifier with several variables.

For example, to say that siblinghood is a symmetric relationship,

we can write∀x, y Sibling(x, y) ⇔Sibling(y, x).

In other cases we will have mixtures.

For example: 1. “Everybody loves somebody” means that for every person, there is someone that
person loves: ∀x∃y Loves(x, y) . 2. On the other hand, to say “There is someone who is loved by
everyone,” we write ∃y∀x Loves(x, y) .

Connections between ∀and ∃

Universal and Existential quantifiers are actually intimately connected with each other, through
negation.
Example assertions: 1. “ Everyone dislikes medicine” is the same as asserting “ there does not exist
someone who likes medicine” , and vice versa: “∀x ¬ Likes(x, medicine)” is equivalent to “ ¬ ∃ x
Likes(x, medicine)”. 2. “Everyone likes ice cream” means that “ there is no one who does not like ice
cream” : ∀xLikes(x, IceCream) is equivalent to ¬∃x ¬Likes(x, IceCream) .

Because ∀is really a conjunction over the universe of objects and ∃is a disjunction that they obey De
Morgan’s rules. The De Morgan rules for quantified and unquantified sentences are as follows:

Equality

First-order logic includes one more way to make atomic sentences, other than using a predicateand
terms .We can use the equality symbol to signify that two terms refer to the same object.

For example,

“Father(John) =Henry” says that the object referred to by Father (John) and the object referred to by
Henry are the same.

Because an interpretation fixes the referent of any term, determining the truth of an equality
sentence is simply a matter of seeing that the referents of the two terms are the same object.The
equality symbol can be used to state facts about a given function.It can also be used with negation
to insist that two terms are not the same object.

For example,

“Richard has at least two brothers” can be written as, ∃x, y Brother (x,Richard ) 𝖠Brother (y,Richard
) 𝖠¬(x=y) .
The sentence

∃x, y Brother (x,Richard ) 𝖠Brother (y,Richard ) does not have the intended meaning. In particular, it
is true only in the model where Richard has only one brother considering the extended
interpretation in which both x and y are assigned to King John. The addition of ¬(x=y) rules out such
models.

USING FIRST ORDER LOGIC Assertions and queries in first-order logic

Assertions:

Sentences are added to a knowledge base using TELL, exactly as in propositional logic. Such
sentences are called assertions.

For example,

John is a king, TELL (KB, King (John)). Richard is a person. TELL (KB, Person (Richard)). All kings are
persons: TELL (KB, ∀x King(x) ⇒Person(x)).

Asking Queries:

We can ask questions of the knowledge base using ASK. Questions asked with ASK are called
queries or goals.
For example,

ASK (KB, King (John)) returns true.

Anyquery that is logically entailed by the knowledge base should be answered affirmatively.

Forexample, given the two preceding assertions, the query:

“ASK (KB, Person (John))” should also return true.

Substitution or binding list

We can ask quantified queries, such as ASK (KB, ∃x Person(x)) .

The answer is true, but this is perhaps not as helpful as we would like. It is rather like answering
“Can you tell me the time?” with “Yes.”

If we want to know what value of x makes the sentence true, we will need a different function,
ASKVARS, which we call with ASKVARS (KB, Person(x)) and which yields a stream of answers.

In this case there will be two answers: {x/John} and {x/Richard}. Such an answer is called a
substitution or binding list.

ASKVARS is usually reserved for knowledge bases consisting solely of Horn clauses, because in such
knowledge bases every way of making the query true will bind the variables to specific values.

The kinship domain

The objects in Kinship domain are people.

We have two unary predicates, Male and Female.

Kinship relations—parenthood, brotherhood, marriage, and so on—are represented by binary


predicates: Parent, Sibling, Brother,Sister,Child, Daughter, Son, Spouse, Wife, Husband,
Grandparent,Grandchild, Cousin, Aunt, and Uncle.

We use functions for Mother and Father, because every person has exactly one of each of these.

We can represent each function and predicate, writing down what we know in termsof the other
symbols.
For example:- 1. one’s mother is one’s female parent: ∀m, c Mother (c)=m ⇔Female(m)
𝖠Parent(m, c) .

2. One’s husband is one’s male spouse: ∀w, h Husband(h,w) ⇔Male(h) 𝖠Spouse(h,w) .

3. Male and female are disjoint categories: ∀xMale(x) ⇔¬Female(x) .

4. Parent and child are inverse relations: ∀p, c Parent(p, c) ⇔Child (c, p) .

5. A grandparent is a parent of one’s parent: ∀g, c Grandparent (g, c) ⇔∃p Parent(g, p) 𝖠Parent(p, c)
.

6. A sibling is another child of one’s parents: ∀x, y Sibling(x, y) ⇔x _= y 𝖠∃p Parent(p, x)


𝖠Parent(p, y) .

Axioms:

Each of these sentences can be viewed as an axiom of the kinship domain. Axioms are commonly
associated with purely mathematical domains. They provide the basic factual information from
which useful conclusions can be derived.

Kinship axioms are also definitions; they have the form ∀x, y P(x, y) ⇔. . ..

The axioms define the Mother function, Husband, Male, Parent, Grandparent, and Sibling predicates
in terms of other predicates.

Our definitions “bottom out” at a basic set of predicates (Child, Spouse, and Female) in terms of
which the others are ultimately defined. This is a natural way in which to build up the representation
of a domain, and it is analogous to the way in which software packages are built up by successive
definitions of subroutines from primitive library functions.

Theorems:

Not all logical sentences about a domain are axioms. Some are theorems—that is, they are entailed
by the axioms.

For example, consider the assertion that siblinghood is symmetric: ∀x, y Sibling(x, y) ⇔Sibling(y, x) .
It is a theorem that follows logically from the axiom that defines siblinghood. If we ASK the
knowledge base this sentence, it should return true. From a purely logical point of view, a
knowledge base need contain only axioms and no theorems, because the theorems do not increase
the set of conclusions that follow from the knowledge base. From a practical point of view,
theorems are essential to reduce the computational cost of deriving new sentences. Without them,
a reasoning system has to start from first principles every time.

Axioms :Axioms without Definition

Not all axioms are definitions. Some provide more general information about certain predicates
without constituting a definition. Indeed, some predicates have no complete definition because we
do not know enough to characterize them fully.

For example, there is no obvious definitive way to complete the sentence

∀xPerson(x) ⇔. . .

Fortunately, first-order logic allows us to make use of the Person predicate without completely
defining it. Instead, we can write partial specifications of properties that every person has and
properties that make something a person:

∀xPerson(x) ⇒. . . ∀x . . . ⇒Person(x) .

Axioms can also be “just plain facts,” such as Male (Jim) and Spouse (Jim, Laura).Such facts form the
descriptions of specific problem instances, enabling specific questions to be answered. The answers
to these questions will then be theorems that follow from the axioms

Numbers, sets, and lists

Number theory

Numbers are perhaps the most vivid example of how a large theory can be built up from NATURAL
NUMBERS a tiny kernel of axioms. We describe here the theory of natural numbers or non-negative
integers. We need:

 predicate NatNum that will be true of natural numbers;  one PEANO AXIOMS constant symbol, 0;
 One function symbol, S (successor).  The Peano axioms define natural numbers and addition.
Natural numbers are defined recursively: NatNum(0) . ∀n NatNum(n) ⇒ NatNum(S(n)) .

That is, 0 is a natural number, and for every object n, if n is a natural number, then S(n) is a natural
number.

So the natural numbers are 0, S(0), S(S(0)), and so on. We also need axioms to constrain the
successor function: ∀n 0 != S(n) . ∀m, n m != n ⇒ S(m) != S(n) .

Now we can define addition in terms of the successor function: ∀m NatNum(m) ⇒ + (0, m) = m .
∀m, n NatNum(m) 𝖠 NatNum(n) ⇒ + (S(m), n) = S(+(m, n))

The first of these axioms says that adding 0 to any natural number m gives m itself. Addition is
represented using the binary function symbol “+” in the term + (m, 0);

To make our sentences about numbers easier to read, we allow the use of infix notation. We can
also write S(n) as n + 1, so the second axiom becomes :

∀m, n NatNum (m) 𝖠 NatNum(n) ⇒ (m + 1) + n = (m + n)+1 .

This axiom reduces addition to repeated application of the successor function. Once we have
addition, it is straightforward to define multiplication as repeated addition, exponentiation as
repeated multiplication, integer division and remainders, prime numbers, and so on. Thus, the
whole of number theory (including cryptography) can be built up from one constant, one function,
one predicate and four axioms.

Sets

The domain of sets is also fundamental to mathematics as well as to commonsense reasoning. Sets
can be represented as individualsets, including empty sets.

Sets can be built up by:  adding an element to a set or  Taking the union or intersection of two
sets.

Operations that can be performed on sets are:  To know whether an element is a member of a set
 Distinguish sets from objects that are not sets.

Vocabulary of set theory:


The empty set is a constant written as { }. There is one unary predicate, Set, which is true of sets.
The binary predicates are

 ∈x s (x is a member of set s)  s1⊆ s2 (set s1 is a subset, not necessarily proper, of set s2).

The binary functions are

 s1 ∩ s2 (the intersection of two sets),  s𝖴1 s2 (the union of two sets), and  ,x|s- (the set
resulting from adjoining element x to set s).

One possible set of axioms is as follows:

 The only sets are the empty set and those made by adjoining something to a set:∀sSet(s) ⇔(s={})
∨(∃x, s2 Set(s2) 𝖠s={x|s2}) .  The empty set has no elements adjoined into it. In other words, there
is no way to decompose {} into a smaller set and an element: ¬∃x, s {x|s}={} .  Adjoining an
element already in the set has no effect: ∀x, s x∈s ⇔s={x|s} .  The only members of a set are the
elements that were adjoined into it. We express this recursively, saying that x is a member of s if and
only if s is equal to some set s2 adjoined with some element y, where either y is the same as x or x is
a member of s2: ∀x, s x∈s ⇔∃y, s2 (s={y|s2} 𝖠(x=y ∨x∈s2))  A set is a subset of another set if and
only if all of the first set’s members are members of the second set: ∀s1, s2 s1 ⊆s2 ⇔(∀x x∈s1
⇒x∈s2)  Two sets are equal if and only if each is a subset of the other: ∀s1, s2 (s1 =s2) ⇔(s1 ⊆s2
𝖠s2 ⊆s1)

 An object is in the intersection of two sets if and only if it is a member of both sets:∀x, s1, s2
x∈(s1 ∩ s2) ⇔(x∈s1 𝖠x∈s2)  An object is in the union of two sets if and only if it is a member of
either set: ∀x, s1, s2 x∈(s1 𝖴s2) ⇔(x∈s1 ∨x∈s2)

Lists : are similar to sets. The differences are that lists are ordered and the same element canappear
more than once in a list. We can use the vocabulary of Lisp for lists:

 Nil is the constant list with no element;s  Cons, Append, First, and Rest are functions;  Find is the
predicate that does for lists what Member does for sets.  List? is a predicate that is true only of lists. 
The empty list is * +.  The term Cons(x, y), where y is a nonempty list, is wittren [x|y].  The
term Cons(x, Nil) (i.e., the list containing the element x) is written as [x].  A list of several elements,
such as [A,B,C], corresponds to the nested term  Cons(A, Cons(B, Cons(C, Nil))).

The wumpus world

Agents Percepts and Actions

The wumpus agent receives a percept vector with five elements. The corresponding first-order
sentence stored in the knowledge base must include both the percept and the time at which it
occurred; otherwise, the agent will get confused about when it saw what.We use integers for time
steps. A typical percept sentence would be

Percept ([Stench, Breeze, Glitter,None, None], 5).

Here, Percept is a binary predicate, and Stench and so on are constants placed in a list. The actions
in the wumpus world can be represented by logical terms:

Turn (Right), Turn (Left), Forward,Shoot,Grab, Climb.

To determine which is best, the agent program executes the query:

ASKVARS (∃a BestAction (a, 5)), which returns a binding list such as {a/Grab}.

The agent program can then return Grab as the action to take.

The raw percept data implies certain facts about the current state.

For example: ∀t, s, g, m, c Percept ([s, Breeze, g,m, c], t) ⇒Breeze(t) , ∀t, s, b, m, c Percept ([s, b,
Glitter,m, c], t) ⇒Glitter (t) ,

You might also like