0% found this document useful (0 votes)
85 views24 pages

AI Tech-Knowledge Unit 4

The document discusses knowledge-based agents, their architecture, and the Wumpus World environment as a practical example. It explains the levels of knowledge representation, including knowledge, logical, and implementation levels, and introduces the TELL and ASK mechanisms for knowledge management. The Wumpus World is described as a grid-based game where an agent navigates through rooms, facing challenges like a monster and bottomless pits, while aiming to collect gold and return safely.

Uploaded by

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

AI Tech-Knowledge Unit 4

The document discusses knowledge-based agents, their architecture, and the Wumpus World environment as a practical example. It explains the levels of knowledge representation, including knowledge, logical, and implementation levels, and introduces the TELL and ASK mechanisms for knowledge management. The Wumpus World is described as a grid-based game where an agent navigates through rooms, facing challenges like a monster and bottomless pits, while aiming to collect gold and return safely.

Uploaded by

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

4 KNOWLEDGE

syllabus

Agents, Knowledge-based Agents, The Wumpus World, Logic, Propositional Logic : AVery Simple Logic
Logical First-
Theorem Proving, Effective Propositional Model Checking, Agents Based on Propositional Logic,
Propositional

OrderLogic,
Revisited, Syntax and Semantics of First-Order Logic, Using First-Order Logic, Knowledge
Representation

Logic.
Engineering in First-Order

Introduction

IInderstanding theoretical or practical aspects of a subject is called as knowledge. We can gain knowledge
gaining knowledge about
through experience acquired based on the facts, information, etc. about the subject. After
related to that subject based
some subject we can apply that knowledge toderive conclusions about various problems
on some reasoning.
"knowledge
We have studied various types of agents in Chapter 1. In this chapter we are going to see what is
store knowledge, how do
based agent", with a very interesting game example. We are also going tostudy how do they
representation
they infer next level of knowledge from the existing set. In turn, we are studying various knowledge
and inference methods in this chapter.

4.1 AKnowledge Based (KB) Agent


Q. What is Knowledge based Agent ?
Base (KB) and
As shown Fig.4.1.1, a knowledge based agents can be described at different levels :Knowledge
an Inference Engine.

Inference engine Domain-independent algorithms

Knowledge base Domain-specific content

Fig. 4.1.1:Levels of Knowledge Base


1. Knowledge level:
Knowledge level is a base level of an agent, which consists of domain-specific content.
In this level agent has facts/information about the surrounding environment in which they are working, it
does not consider the actual implementation.
Artificial Intelligence (SPPU) 4-2

2. Implementation level: Knowledg


Implementation level consists of domain independent algorithms. At this level, agents
can
data structures used in knowledge base and algorithms which use them. For recognize
the
and resolution. (We will be learning about logic and resolution in this chapter). example, propositional
Knowledge based agents are crucial to use in partially observable
logjc
environments. Before
action, knowledge based agents make use of the existing knowledge along with the choosing
current inputs from an
environment in order to infer hidden aspects of the current state. the
As we have learnt that knowledge base is a set of
representations of
surrounding environment (real world). Every single representation in the setfacts/information about
is called as a sentenes the
sentences are expresses with the help of formal representation
language. We can say that sentence ;.
statement which is a set of words that express some truth about
the real world with the heln
representation language. of knowledge
Declarative approach of building an agent makes use of TELL and ASK
mechanism.
TELL the agent, about surrounding environment (what
it needs to know in order to perform som
action). TELL mechanism is similar to taking input for a
system.
Then the agent can ASK itself what action should be
carried out to get desired output. ASK mechanism
similar to producing output for a system. However ASK
base to decide what it should mechanism makes use of the knowledge
do.
TELL and ASK mechanism involve inference.
When you run ASK function, the answer is
the help of knowledge base, based on the generated with
knowledge which was added with TELL function previously.
1, TELL(K) :Is a function that adds knowledge Kto the
2
knowledge base.
ASK(K) : Isa function that queries the agent about the
truth of K.
An agent carries out following
operations : First, TELLs the knowledge base about
perceives with the help of sensors. Then, it ASKs facts/information it
the knowledge base what action
based on the inputit has received. Lastly, it should be carried out
performs the selected action with the help of effectors.
4.1.1 Architecture of aKB Agent
Q. Explain in detail the knowledge based agent.
Knowledge based agents can be implemented at three
levels namely, knowledge level, logical level
implementation level. and
1. Knowledge level
2 Logical level
3. Implementation level

1. Knowledge level:
It is the most abstract level of agent implementation.
The knowledge level describes agent by saying wha
knows. That is what knowledge the agent has as the initial
knowledge.
Basic data structures and procedures to access that knowledge are
defined in his level. Initial knowle
knowledge base is called as background knowledge.

RG Tech Kn
Knowledge
ArtificialIntelligence (SPPU) 4-3

knowledge level can be viewed as an agent for which one only need to specify what the agent
Agents
at the
what. its goals are in ordertospecify its behavior, regardless of how it is to be implemented.
knows and
Francisco with the
example : Ataxi driving agent mnight know that the Golden Gate Bridge connects San
For
marin county.

Logical l e v e l :

2. logical level, the knowledge is encoded into sentences. This level uses some formal language to
At the logic
represent
the knowledge the agent has. The two types of representations we have are propositional
predicate logic.
and first order or
techniques are discussed in detail in the further sections.
representation
Both these

For example
: Links (Golden Gate Bridge,San Francisco, Marin County).
level :
I m p l e m e n t a t i o n

3. sentences is done. This level also


In implementation level, the physical representation of logical level
data manipulation.
describes data structures used in knowledge base and algorithms that used for
For example : Links (Golden Gate Bridge, SanFrancisco, Marin County).
returns an action
function KB - Agent (percept)
KB, a knowledge base
static :
t, a counter, initially o, indicating time
TeLL. (KB, MAKE PERCEPT-SENTENCE(percept, t)
action - AsK (KB, MAKE-ACTION-QUERY())
TELL(KB, MAKE-AcTION-SENTENCE(action, t))
t-t+ 1

returns actíon

Fig. 4.1.2:General function of knowledge based agent


TELL and ASK are the sub procedures
Fig. 4.1.2 is the general implementation of knowledge based agent.
implemented to perform the respective actions.
tasks:
The knowledge base agent must be able to perform following
Represent states, actions, etc.
Incorporate new precepts.
Update internal representations of the world.
Deduce hidden properties of the world.
Deduce appropriate actions.
4.2
The WUMPUS World Environment
University Question
Explain WUMPUS World Environment giving its PEAS description.
SPPU : Dec. 15,May 16, May 17, Dec. 17, May 18, 10 Marks

ETech Knowledge
Artificial Intelligence (SPPU) 4-4
You have learnt about
vacuum world problem,
Knowledge
block world problem so far. Similarly we have
problem. Fig. 4.2.1 shows the WUMPUS world. WUMPUS world
WUMPUS is an early computer game also known as "Hunt
the Wumpus". WUMPUS was developed
Yob in 1972/1973. It was originally written in BASIC by Gregory
(Beginner's All-purpose Symbolic Instruction Code)
WUMPUS is a map-based game. Let's understand
the game :
WUMPUS world is like a cave which represents number
of rooms, rooms, which are connected by
ways. We willtake a 4 x 4 grid to passas
understand the game.
WUMPUS isa monster who lives in one of the
rooms of the cave. WÜMPUS eats the player
(agent) comes in the same room. Fig. 4.2.1 shows that (agent) if plaver
room (3, 1)where WUMPUS is staying.
Player (agent) starts from any random
(1, 1)position. position in cave and has to explore the cave.
We are starting from
There are various sprites in the game
Let's understand this like pit. stench, breeze, gold, and
arrow. Every sprite has some feature.
one-by-one:
Few rooms have bottomless pits
which trap the plaver (agent) if he
Fig. 4.2.1 that room (1, 3), (3, 3) comes to that room. You can see in
and (4, 4) have bottomless pit. the
Stench experienced in a room Note that even WUMPUS can fall into a
which has a WUMPUS in its pit.
(2, 1), (3, 2) and (4, 1) have
Stench.
neighborhood room. See the Fig. 4.2.1, here
room
Breeze is experienced in a room
which has a pit in its
(1,4), (2, 3), (3, 2), (3, 4) and (4,3) neighborhood room. Fig. 4.2.1 shows that
consists of Breeze. room (1, 2),
Player (Agent) has arrows and he
can shoot these arrows in
One of the rooms consists of straight line to kill WUMPUS.
gold, this room glitters. Fig. 4.2.1
Apart from above features player shows that room (3,2) has Gold.
is generated if player (agent) can accept two types of percepts which
(agent) walks into a wall. While a are: Bump and scream. A
WUMPUS is killed. sad scream created bump
everywhere in the cave when the

NStench
4
Breeze PIT

Breezo

~Stench PIT (Breeze

NStenché
2 (Breeze

1 (Breeze
PIT
Start
1 2 3

Fig. 4.2.1:The WUMPUS World


Artificial Intelligence (SPPU)
4-5
Knowledge
Description of the WUMPUS World
4 2 1

WUMPUS
WORLD Environment.
D e s c r i b e

receives percepts while exploring the rooms of cave.


Every percepts can be represented with
A na g e n t

list, which is [stench, breeze, glitter, bump, the nep


of
fiveelement
scream]. Note that player (agent) cannot
o w nl o c a t i o n .
perceive s
percept as [Stench, Breeze, None, None, Nonel. Then
(agent) gets
f t h ep l a y e r it means that there is a stench and
bump, and no sCrean in the WUMPUS
glitter, no
but no world at that position in the game.
Let'stake a look at the actions which can be performed by the player (agent) in WUMPUS World :
a b r e e z e ,

Move:
forward direction,
To move in

Turn:To turn right by 90 degrees or left by 90 degrees,


Grab: To pick up gold if it is in the same room as the player (agent),
Shoot: To Shoot an arrow in a straight line in the direction faced by the player (agent).
These actions are repeated till the player (agent) kills the WUMPUS or if the player (agent) is killed. If the
/WUMPUS is killed then it is a winning condition, else if the player (agent) is killed then it is a losing condition
is Over.
and the game

Came developer can keep a restriction on the number of arrows which can be used by the player (agent). So if
n allow agent to have only one arrow, then only the first shoot action will have some effect. If this shoot action
ills the WUMPUS then you win the game, otherwise it reduces the probability of winning the game.
Iactlythere is a die action:It takes places automatically if the agent enters in a room with a bottomless pit or in
a room with WUMPUS. Die action is irreversible.
Goal of thegame:

Main aim of the game is that player (agent) should grab the gold and return to starting room(here its (1, 1))
without being killed by the monster (WUMPUS).
Awardand punishment points are assigned to a player (Agent) based on the actions it performs.
Points can be given as follows :
100 points are awarded if player (agent) comes out of the cave with the gold.
lpoint is taken away for every action taken.
10 pointS are taken away if the arrow is used.
200 points are taken away if the player (agent) gets killed.
4.2.2
PEAS Properties of WUMPUS World
Specify PEAS properties and type of environment for the same.
SIVe PEASdescriptors for wUMPUS world.
L Performance measure
+100 for
grabbing the gold and coming back to the starting position,
- 200 if the player (agent) is
killed.
-1 per action,

EE Tech Knowledge
PuttlIcati Drs
Artificial Intelligence (SPPU) 4-6

2.
10for using the arrow.
Environment
Kngwledge
Empty Rooms.
Room with WUMPUS.
Rooms neighbouring to WUMPUSwhich are smelly.
Rooms with bottomless pits
Rooms neighbouring to bottomless pits which are breezy.
Room with gold which is glittery.
Arrow to shoot the WUMPUS.
3. Sensors (assuming a robotic agent)
Camera toget the view
Odour sensor to smell the stench
Audio sensor to listen to the scream
and bump.
4.
Effectors (assuming a robotic agent)
Motor to move left, right
Robot arm to grab the gold
Robot mechanism to shoot the
arrow.
The WUMPUS world agent has
following characteristics :
1 Fully observable 2. Deterministic
3 Episodic 4. Static
5 Discrete
6. Single agent
4.2.3 Exploring a WUMPUS World
Let's try to understand the WUMPUS
world problem in step by step manner.
Keep Fig. 4.2.2 as a reference.
4.1 4.2 4.3 4.4
A -Agent
B- Breeze
3.1 3.2 3.3 3.4 G- Glitter, Gold
OK- Safe square
2.1 2.2 2.3 P- Pit
2.4
S-Stench
V - Visited
1.1 1.2 1.3 1.4
W -Wumpus
A OK OK

Fig. 4.2.2(a) : WUMPUS world with


player in room (1, 1)
The knowledge base initially contains only the rules
(facts) of the WUMPUS world environment.
Tech Knouledge
Publicatiors
ArtittciaU
l , n t e l l i g e n c e( S P P U ) 4-7 Knowledge
(agent) isi
in the room (1,1). See Fig.
Initially the player 4.2.2(a).
by the player is (none, none, none,
received
of
1: percept none, none]. (remember percept consists
Sep
The first glitter,, bump, scream])
breeze,
stench,

move tO
room (1, ,2) or (2, 1) as they are safe cells.
Playercan

move
to
rOom
(1, 2). See Fig. 4.2.2(b).
Letus
2:
4.1 4.2 4.3 44
Step

A-Agent
3.1 3.2 3.3 3.4 B- Breeze

2.1 2.2 2.3 2.4 G- Glitter, Gold

1.1 1.2 1.3 1,4 OK- Safe square


P? P- Pit
A
S- Stench
OK
V-Visited
OK
W-Wumpus
Fig. 4.2.2(b) : WUMPUS world with player in room (1, 2)
breeze,
1) is: visited you can see "V mark in that room. The player receives following percept: none,
As room(1,
none, none, none].

a bottomless
e brpp1e percept is received room (1, 2) is marked with "B" and it can be predicted that there is
room.
pit in the neighboring
Youce
can see that room (1, 3) and room (2, 2) is marked with "P?". So room (1,3) and (2, 2) is not safe to move in.
Thus plaver should return to room (1, 1) and try to find other, safe room to move to.

Step 3:
4.1 4.2 4.3 4.4

3.1 3,2 13.3 3.4

2.1 2.2 2.3 2,4

1.1 1.2 .3 1.4


A A

V B
OK OK

Fig. 4.2.2(c): WUMPUS World with player moving back to room


(1, 1) and then moves to other safe room (2, 1)
As seen in Fig. 4.2.2(c). Player in now in room (2, 1), where it receives a percept as follows :(stench, none, none,
none, none] which means that there is a WUMPUS in neighboring room (i.e. either room (2, 2) or (3, 1) has
WUMPUS).
BG TechKnowledge
PublicaLions
F Artificial Intelligence (SPPU) 4-8
Knowledge
As we did not get breeze percept in this room, we can understand that room (2, 2) cannot have any nit and
Step 2 we can understand that room (2, 2) cannot have WUMPUS because room (1, 2) did not shoW
percept. stench
Thus room (2, 2) is safe to move in
Step 4: Player receives [none, none, none, none, none] percept when it comes to room (2, 2). From Fig.
4.2.2(d) vos
can understand that room (2, 3) and room (3, 2) are safe to move in.
4.1 4.2 4.3 4.4

3.1 3.2 3.3 3.4

2.1 2.2 2.3 2.4


A A
OK
1.1 1.2 1.3 1.4
P?

OK OK

Fig. 4.2.2(d) : WUMPUS world with player moving


to room (2,2)
Step 5: Let's move to room (3, 2). Here, player
receives [stench, breeze, glitter, none, none] percept. See
Fig. 4.2.2(e). Field 1 of the percept shows that room
(3, 1), (3, 3) and (4, 2) can have WUMPUS. Field 2 of
percept shows that room (3, 1), (3,3), (2, 2) and (4, 2) can the
have bottomless pit. Field 3 of the percept shows
that room (3, 2) has gold. So, the player grabs the
gold first. As the aim of this game is to grab the gold and
go back to the starting position, without being killed by
the WUMPUS.
4.1 4.2 4.3 4.4

P?

|3.1 3.2 ¬OK3.3 |3.4


P?
P?

2.1 2.2 2.3 2.4


A

1.1 : 1.2 1.3 1.4


P?

OK OK

Fig. 4.2.2(e) : WUMPUS world with player moving to room (3, 2)

TechK
Pubi
(SPPU) 4-9 Knowledge
I n t e l l i g e n c e

Artificial

a go back to the starting position i.e. room (1, 1) without getting killed by WUMPUS. From steps
have to
we.
Non,
know
that room (1,1). (1, 2), (2, 1) and (2, 2) are safe rooms. so, we can go back to room (1, 1) by
cleSand.4We .(2, 2), (2, 1), (1, 1) or (2, 2), (1, 2), (1, 1).
paths: i.e.
folowinganyo f fthe two
seen in Fig. 4.2.2(t). We will go from room (2, 2) to room (2. 1) and from room (2, 1) to roon
be
As can
6:
we won
the WUMPUS World game!!!
(1,1).7
Step
Thus
4.1 4.2 |4.3 |4.4

W?
P?
3.1 3.2 3.3 3.4

W? W?
P? P?
2.1 2.2 2.3 2.4

A OK
A
OK
1.1 1.2 1.3 1.4

A
OK OK V

moving back to room (1, 1) with gold


Fig.4.2.2(): WUMPUS world with player

43 Logic
in artificial intelligence ?
What is reasoning ? What is its role
medical diagnostic.
Explain therole of probabilistic reasoning in
validity to performa
is carried out or it is review based on strict rule of
a
can be called as reasoning which
Logic
specified task. representation and
that any of logic's particular form cannot bind logical
In case of intelligent systems we say
particular form oflogic.
Teasoning, they are independent of any extent and when knowledge is
beneficial only if the knowledge is represented in small
Make a note that logic is
considered valuable.
epresented in large quantity the logic is not it is shows that sentences
need
configurations of an agent,
also
depicts that sentences are physical from old ones.
o o physical configurations
reasoning is a process offorming new
e lnis means that Need Sentence

emantic
Sentences
Semantic
Representation
Real world

Features of the
Features of the real world
Follows
real world

representation
Correspondence between real world and its
Pig. 4.3.1l: TechKnowledge
PubcaLiors
5 Artificial Intelligence (SPPU) 4-10

Logical reasoning should make sure that the new configurations represent features of the
follow the features of the world that the old configurations represented. world
that
4.3.1 Role of Reasoning in Al actay
Fig, 4.3.2 shows how logic can be seen as a knowledge representation language. There are variOus
logic and most fundamental type of logic is propositional logic. \evels to the
Multi-valued logic Modal Temporal Non-monotonic logic
logic logic
Higher order
logic
Probabilistic logic
First order predicate
logic
Fuzzy logic Proposltional logic

Fig. 4.3.2 : Logic as Knowledge Representation language


Propositional logic can be considered at fuzzy logic level, where rules are values between
level is also called as probabilistic logic level using which first order predicate range of 0and 1.
logic is implemented. Net
In this Fig. 4.3.2 that there are two more levels above
higher order logic which are multi-valued and s
monotonic logic levels and they consist of modal logic and temporal logic
respectively.All these types of loete
basic building blockS of intelligent systems and they all use
reasoning in order to represent sentences. Henes
reasoning plays avery important role in Al.
4.4 Representation of Knowledge using Rules
Explain various method of knowledge representation techniques.
Knowledge can be considered to be represented at generally two levels:
) Knowledge level: This level describes the facts.
(ii) Symbol level : This level deals with using the symbols for representing the
objects, which can be
manipulated in programs.
Knowledge can be represented using the following rules:
(a) Logical representations (b) Production rule representations.
(c) Semantic networks (d) Frame representations

(a) Logical representation


The logical representations are mostly concerned with truth of statements regarding the world. These

statements are most generally represented using statements like TRUE or FALSE.
certain
Logic is successfully used to define ways to infer new sentences from the existing ones. There are
There
logics that are used for the representation of information, and range in terms of their expressiveness.

languages
are logic that are more expressive and are more useful in translation of sentences from natural
into the logical ones. There are several logics that are widely used :
Publicatiog
t e l l i g e n c e( S P P U )
4-11 Knowledge
ACal
hte
Propositionallogic: These are restricted kinds that make use of propositions (sentences that are eithner
but not both) which can be either true or false. Proposition logic is also known as
false

propositional calculus, sententialIcalculus or boolean algebra.


true
or

propositions
ar either true or false,
All Leaves are green (ii) Violets are blue.
example : ()
For
Sentence Truth Value Proposition
Sky is blue true yes

Roses are red true yes

2+2=5 false yes

Order Predicate Logic : These are much more expressive and make use of variables, constants,
2. First ,functionssand quantifiers along with the connectives explained already in previous section.
p r e d i c a t e s , .

her Order Predicate Logic : Higher order predicate logic is distinguished from first order predicate
additional quantifiers and: stronger semantics.
logic by using
or fuzziness in all logics.
.Tugzy Logic : These indicate the existence of in between TRUE and FALSE
logics.
eother Logic : These include multiple valued logic, modal logics and temporal
Production Rule Representation

production rules, it is also known as IF-THEN


As af the widest used methods to represent knowledge is to use
rules.

Syatax:

IF condition THEN action

IF premise THEN Conclusion


IF propositionp1 and proposition p2 are true
THEN proposition p3 is true
Example :
IF pressure is high, THEN volume is small.
IF the road is slippery, THEN driving is dangerous.
defining a relatively small and, at
Ome of the benefits of IF-THEN rules are that they are modular, each
least in principle,, independent piece of knowledge. New rules may be added and old ones deleted usually

Independently of other rules.


Production rules are simple but powerful forms of representing knowledge, they provide flexibility for
The major advantage of
he35 Procedural and decarative renresentations in a unified manner.
production rules are that they are modular, independent of other rules with the provision for addition new
rüles and deleting older
ones.
Semantic networks
These represent knowledge in the form of graphical networks, since graphs are easy to be stored inside
programs as they are concisely represented by nodes and edges.
Tech Knowledge
Public ations
Artificial Intelligence (SPPU) 4-12

Asemantic network basically comprises of nodes that are named:and represent


concepts, and Knowedg
representing relations between concepts. Nodes represent both types and tokens. labelled Hinks
For example,the semantic network in Fig. 4.4.1 expresses the knowledge to represent the
Bom is grey in color. following data:
Tom is owned by Sam.
Tom is a Mammal.
Fish is an Animal.
Cats love Milk.
All mammals are animals.
) Mammal Animal
lsa

Isa |Is a
Loves
Milk Cat Fish
Caught a

Color is Tom

Grey Owned by
Sam

Fig. 4.4.1
Conceptual Graph: Itis a recent scheme used for
connected, bipartite graph. The nodes semantic network, introduced by John
represent either concepts or conceptual Sowa, has a finite.
previous method that it does not use relations. It differs from the
labelled arcs. For example: Ram,
cat color is grey can be
represented as shown in Fig, 4.4.2. Laxman and Bharat are Brothers or
Ram
Brothers Laxman Cat Colour Grey

Bharat

Fig. 4.4.2
(d) Frame Representation
This concept was introduced by
Marvin
complex and needs more structured Minsky in 1975. They are mostly used when the task becomes
representation. More structured the system quite
the requirement of using becomes more would be
frames which would prove beneficial.
that consists of a collection of slots or Generally frames
attributes and the corresponding slot values.are record like structures
Slots can be of any size and type.
The slots have names and values
have names or numbers to0. Asimple (subfields) called as facets, Facets can
frame is shown in the Fig. 4.4.2 for a
person Ram.
(Ram)
(PROFESSION (VALUE professor)
(AGE(VALUE 50)
(WIFE(VALUE sita)
Artificial Intelligence (SPPU) 4-13 Knowledge

(CHILDREN(VALUE luv kush))


(ADDRESS (STREET(VALUE 4C gb road))
CITY(VALUE banaras))
(STATE(VALUE mh))
(ZIP(VALUE400615))
4.4.1 Ontology
Ontology isstudy about what kind of things or entities exist in the universe. In Al, ontology is the specification of
conceptualizations, used to help programs and humans to share knowledge about a particular domain. In turn,
ontology isa set of concepts, like entity, relationships among entities, events that are expressed in a uniform way
in order to create a vocabulary for information exchange. An ontology should also enable a person to verify what
a symbol means. That is,given a concept, they want to be able to find the symbol, and, given the symbol, they
want to be able to determine what it means. Typically, it specifies what types of individuals will be modelled,
specifies what properties will be used, and gives some axioms that restrict the use of that vocabulary. Ontologies
are usually written independently of a particular application and often involve a community to agree on the
meanings of symbols
For example : Consider a map showing hotels, railway station, buildings, schools, hospitals in a particular
locality. In this map the symbols used to indicate these entities are enough to describe them. Hence the
community who knows the meaning of these symbols can easily recognize it. Hence that becomes ontology of
that map. In this ontology, it may define a building as human-constructed artifacts. It may give some restriction
on the size of buildings so that shoeboxes cannot be buildings or that cities cannot be buildings. It may also state
that a building cannot be at two geographically dispersed locations at the same time.
4.5 Propositional Logic (PL)
What is prepositional logic ? Explain with example.
Propositional Logic (PL) is simple but powerful for some artificial intelligence problems. You have learnt
simple mathematical logic in which uses atomic formulas are used. (Atomic formula is a formula that has no
strict sub-formulas). Atomic logic formulas are called propositions.
In case of artificial intelligence propositional logic is not categorized as the study of truth values, but it is based
on relativity of truth values. (i.e. The relationship between the truth value of one statement to that of the truth
value of other statement).
4.5.1 Syntax
Write syntax and semantics and example sentences for propositional logic.

Basic syntax followed by the propositional logic can be given as follows:


Propositional symbols are denoted with capital letters like : A, B, C, etc.
Propositional logic constants have a truth value generally truth values have a crisp nature (i.e. 0 (false) and 1
(true)).But for fuzzy logic truth values can vary in the range of 0and 1.
Propositional logic make use of wrapping parenthesis while writing atomic sentence. It is denoted as '(...)".

TechKnowledge
Artificial Intelligence (SPPU) 4-14

Literal is an atomic sentence or it can be negation of atomic sentence. (A, ¬A)


IfAis a sentence,then ¬A is a sentence.
Kngwedge
Propositional logic makes use of relationships between propositions and it is denoted by
are propositions. Connectives used in proposition logic can be seen in the Table 4.5.1. Connectives, if Aand
B
Table 4.5.1:Connectives used in Propositional logic
Connective Name of the
Relationship between Name of the
symbol Connective symbol Relationship
Propositional symbols Propositional symbolsbetween
And A^B
Conjunction
Or
AvB
Disjunction
Not
A
Negation
Implies AB
Implication/ conditional
is equivalent/ if and
only if A B
Biconditional
To define logicalconnectives
truth tables are used. Truth Table 4.5.2 shows five
logical connectives.
Table 4.5.2
A B
AAB AvB
AB AB
False false false False true tråe true
False true false True true true
True
false
false false True false false false
True true true True false tråe
Take an example, where true
AAB, i.e. Find the value of
Table 4.5.2 shows this AAB where A is true andB is false.
condition, now see third row of the Third row of the
Similarly other logical connectives can third column where, A AB shows result
be mapped in the truth table. as false.
4.5.2 Semantics
Q Write syntax and semantics and
example sentences for propositional
World is set logic.
facts which we want to
represent to form propositional logic. In
propositional symbols can be used where each order to
feature. propositional symbol's interpretation can be represent these facts
L
mapped to the real world
Semantics of a sentence is meaning ofa
sentence. Semantics determine the
For example: You can define interpretation of a sentence.
semantics of each propositional symbol in
1. A
means "It is hot following manner :
2 Bmeans "It is humid", etc.

er
Artificial Intelligence (SPPU) 4-15 Knowledge

Sentence is considered true when its interpretation in the real worldis true. Everysentence results from a finite
number of usages of the rules. For example, if AandB are sentences then (AA B), (A v B), (B ’ A) and (A t+ B)
are sentences. The knoWledge base is a set of sentences as we have seen in previous section.
Thus we can say that real world is a model of the knowledge base when the knowledge base is true for that
world. In other words a model can be thought of as a truth assignment tothe symbols.
its truth value (1.e.
If truth values of all symbols in a sentence are given then it can be evaluated for determining
we can say if it is true or false).

4.5.3 What is Propositional Logic ?


natural language words and sentences may have diferent
AAB and BA A should have same meaning but in
meanings. Say for an example,
1. Radha started feeling feverish and Radha went to the doctor.
Radha went to the doctor and Radha started feeling feverish.
Here, sentence 1 and sentence 2 have different meanings.
statement to that of
relationship between the truth value of one
Inartificial intelligence propositional logic is a
the truth value of other statement.

4.5.4 PL Sentence - Example

Take example of a weather problem.


Semantics of each propositional symbolcan
be defined as follows:
Symbol A isa sentence which means "It
is hot".
SymbolB is a sentence which means
"It is humid".
raining".
SymbolCis a sentence which means "It is
are easy to understand, like :
We can also choose symbols which
HT for "It is hot".
HM for"It is humid".

RN for "It is raining":


then it is hot".
If you have HM HT then that means "If it is humid,
raining" and so on.
have (HT A HM) ’ RN then it means "If it is hot and humid, then it is
If you consider all the possible
possible models for a knowledge base. To do this we need to
First we have to create the
Sentence A, B and C. Then verify the
truth table for the validity. There can
assignments of true or false values for
be total 8 possibilities as follows:
Sentence HM Sentence RN Validity
Sentence HT
False Valid
False False
True Valid
False False
False Not Valid
False True
True Not Valid
False True

False False Valid


True

Tedh Kaeudedge
PutsCaLi
Artificial Intelligence (SPPU) 4-16

Sentence HT
Knowledge
Sentence HM Sentence RN Validity
True False True Valid
True True False Not Valid
True True True Valid
Now, if the knowledge base is [HM, HM ’ HT, (HT A
HM) ’ RNI(.e. ["It is humid", "If it is humid,,then
"Ifit is hot and humid, then it is raining"] ), then "True -True -True" is the it is hot',
only possible valid model.
Tautology and Contradiction
Tautology means valid sentence. It is a sentence which is true
for allthe interpretations.
For example: (A ¬A) ("Aor not A") :"It is
hot or It is not hot"
Contradiction means an inconsistent sentence. It is a sentence
which is false for all the interpretations.
For example: Aa A ("A and not
A"):"It is hot and it is not hot."
Xentails Y, is shown as X|= Y. It means that
whenever sentence Xis True, sentenceY willbe rue.
For Example : if, X= Priya is Pooja's
Mother's Sister and Y=Priya is Pooja's Aunty. Then
4.5.5 X|= Y(X entails Y).
Inference Rules
Explain the inference process in case of
propositional logic with suitable examples.
New sentences are formed with the
logical inference. For example : If A= B
come across this example many times and B= Cthen A=C. You must have
it implies that if knowledge base has
that "A = C". "A= B" and"B = C" then we can infer
In short inference rule says
that new sentence can be create by
knowledge base. logically following the set of sentences
of the
Table 4.5.3: Inference Rules

Inference Rules Premise (KB) Conclusion


Modus Ponens X, X-’Y Y

Substitution X’Z &Y’Z X=Y


Chain rule X’Y, YZ X’Z
AND introduction X,Y X^Y

Transposition X’Y
Entailment is represented as: KB |= and Derivation is represented
as: KB|-Q.
There are two types of inference rules:
1. Sound inference
2. Complete inference
Artificial Intelligence (SPPU) 4-17 Knowledge

Sound inference
1,
Soundness property of inference says that, if "X is derived from the knowledge base" using given set of
arotocols of inference, then "X is entailed by knowledge base". Soundness property can be represented as :
"If KB |- Xthen KB |= X".
Eor Modus Ponens (MP) rule we assume that knowledge base has (A, A ’ B], from this we can conclude
table:
that knowledge base can have B. See following truth
A B A ’B Valid?

TRUE TRUE TRUE Yes

TRUE FALSE FALSE Yes

FALSE TRUE TRUE Yes

FALSE FALSE TRUE Yes

In general,
where there is a substitution 0 such that
For atomic sentences p, p, and g,
P, PPg-P P,^P^PgAa p,»)
SUBST (0, pi) = SUBST (O, pi) for
all i, SUBST (0,)
implication.
N+1 premises = N atomic sentences + one
Example :
A : It is rainy.
B : I will stay at home.
A+B : If it is rainy, I will stay at home.
Modus Tollens
false.
"if A, then B," it is valid to conclude that A is also
When B is known to be false, and if there is a rule
2. Complete inference
property of inference says that, if "X is entailed
Complete inference is converse of soundness. Completeness
base" using the inference protocols.
by knowledge base" then "X can be derived from the knowledge
Completeness property can be represented as:"If KB |= Qthen KB
|- 0".

4.5.6 Horn Clause

Explain Horn Clause with example.


sentence. In a horn clause a
Clauses are generally written as sets of literals. Horn clause is also called as horn
conjunction of 0 or more symbols is to the left of "" and 0 or 1 symbols to the right. See following formula :
A,AA,aAg ...AA,Bm where n >= 0and mis in range {0, 1}
ere can be followingspecial cases in horn clause in the above mentioned formula:
For n = 0and m=1:A (This condition shows that assert Ais true)
For n >0 and m=0:AAB’ (This constraint shows that both Aand B cannot be true)
For n =0 and m=0:(This condition shows empty clause)
TecKaowledge
PubtiCatiors
Artificial Intelligence (SPPU) 4-18

Conjunctive normal form is a conjunction of clauses and by its set of clauses it is determined
For a horn clause coniunctive normal form can be used where, each
sentence is a
up to equivale Knowledpe
disjunction of l alence.
most one non-negative literal as shown in the following formula : ¬AA,V¬Az .. VA, VB with at literals
Thiscan also be represented as : (A’ B)=(A vB)
Significance of horn logic
Horn sentences can be used in first order logic. Reasoning
processes is simpler with horn clauses.
a propositional knowledge base is NP complete.
which will make it true).
(Satisfiability means the process of finding
values for .Satistiability of
For rerestricting knowledge base to
symbols
horn sentences, satisfiability is in A. Due to this
sentences are the basis for prolog and datalog reason, first
languages. order logic horn
Let's take one example which gives
entailment for horn formulas.
Find out if following horn
formula is
(true -’ X)a (XAY’ Z) A(2!W)A satisfiable?
(ZAW’ false) (true -’Y)
From the above equation, we entail
if the query atom is false.
that true ’X and true Y, so Equation shows that there are clauses
we can assign Xand Yto
true value (i.e. true ’XAY). which stata
Then we can say that all
premises of XA YZ are true, based
that we can see all on this information we
premises of Z’ Ware true, so we can assign Z to true, After
As now all premises of ZA can assign Wto true.
W’ false are true, from this we
horn formula is not can entailthat the query
satisfiable. atom is false. Therefore, the
4.5.7
Propositional Theorem Proving
Sequence of sentences form a
sentences in the proof based on"Proof". A sentence can be premise or it can be a sentence
the
Query/goal is the last sentence of the inference rule. Whatever we want to prove is called derived from earlier
theorem in the proof. as a query or a goal.
Take Example of the "weather
problem" which we have seen above.
HT for"It is hot".
HM for"It is humid".
RN for "It is raining".
1. HM
Premise (initial sentence)
"It's humid"
2 HM >HT
Premise(initial sentence)
"If it's humid,
3. HT it's hot"
Modus ponens(1,2) (sentence derived
from 1 and 2) "I's ho
4. (HT AHM)-’RN Premise(initial sentence) "If it's hot and
5. HT AHM humid, it's raining
And introduction(1, 3)
"It's hot and
6.
humid"
RN
Modus ponens(4, 5) (sentence derived from 4 and 5)
"It's raining"

Techknewle
newiedgu
PubCatiars
Artificial Intelligence (SPPU) 4-19 Knowledge

Advantages of Propositional Logic


4.5.8

Propositionalllogic is asimpleeknowledge representation language.


efficient technique for solving some artificial intelligence based problems.
and
Itisssufficient
Propositional logicforms the foundation for higher logics like First Order Logic (FOL), etc.
andIreasoning is decidable.
Propositional
| logic is NP complete
can be illustrated
by PI.
inference
Theprocess of
Logic
Disadvantages of Propositional
4.5.9

Drawbacks of propositional
logic.
O.
Write a short note on :
problems.
complex artificial intelligence
Propositional logic is cannot express
WUMPUS hunter problem.
logic can be impractical for even small worlds, think about
Pronositional it can be
artificial intelligence problems,
propositional logic to express complex
Even if we try to makeuse of
very wordy and lengthy.
representation language because:
PL is aweak knowledge "individual". For example : If there are
entities like :

With PL it is hard to identify


if the used entity is
Priya, Mumbai, 123, etc. individual entities. For
properties of individual entities or relations between
PL cannot directly represent
example, Pooja is tall. example : All rectangles have 4
specialization, generalizations, or patterns, etc. For
PL cannot express
sides.

4.6 First Order Predicate Logic


What is first order logic ?
Write short note on predicate logic. Thus First
discussed above there was a need
for more expressive type of logic.
Because of the inadequacy of PL information using relations,
developed. FOL ismore expressive than PL, it can represent
Order Logic (FOL) was
variables and quantifiers, e.g., which was
not possible with propositional logic.
"Gorilla is Black" can be represented as:
Gorilla(x) -Black(x)

"It is Sunday today" can be represented as :


today(Sunday)
much more
Order Predicate Logic (FOPL). Since FOPL is
First Order Logic (FOL) is also called as First
expressive as a knowledge representation language than
PL it is more commonly used in artificial intelligence.

4.6.1 Syntactic Elements, Semantic and Syntax

Write syntax and semantics of FOL with example.

FOL Symbol can be a constant term, a variable term or a function.


g TechKaouledge
Pubticatien
Artificial Intelligence (SPPU) 4-20

Assuming that "X" is a domain of values,we can define a term


Knowledge
with following rules :
1,
Constant term:It is a term with fixed value which belongs to the
2.
domain.
Variable term: It is a term which can be assigned values
3
in the domain.
Function :Say "P" is a function of "n" arguments. If we
also called as a term. assume that ttz, t are terms then f(t,tz, , t)is
All the terms are generated by
applying the above three protocols.
First order predicate logic makes use of
FOPL are common. propositional logic as a base logic, so the connectves used
Hence, it also supports A in PL and
implication. conjunction, v disjunction, negation, >implication and double
Ground Term :If a term does not have
anv variahles it is called as a
variables are quantified is called as a ground term. Asentence in which all the
"well-formed formula".
Every ground term is
mapped with an object.
Every condition (predicate)
is mapped to a
Aground atom is relation.
considered as true if the predicate's
Rules in FOL: In predicate logic relation holds
between the terms' objects.
rule has two parts predecessor
TRUE successor will be true. It and successor. If the
uses the implication >
svymbol. Rule represents If-then
predecessor is evaluated to
Example: The sentence "If the bag is types of sentences.
of blue colour, I will buy
blue) >buy(bag) it" Will be represented
as colour (bag,
Quantifiers
Apart from these connectives
FOPL makes
variables taking part in the relation or use of quantifiers. As the name suggests they quantify the
obeying the rule. number of
1. Universal Quantifier
Pronounced as "for all" and it is applicable to
all the variables in the
"x A" means Ais true for
every replacement of
predicate.
x.
Example: "Every Gorilla is Black" can be
represented as:
"yx (Gorilla(x) ’ Black(x))
2. Existential Quantifier'a
Pronounced as "there exists"
"Sx A" means Ais true for at least
one replacement of x.
Example: "There isa white dog" can be
represented as,
3x (Dog(X) ^ white(X)
Note:
1
Typically, ’ is the main connective with
Example : "Everyone at MU is smart" is
represented as
Vx At(x, MU) ’ smart(x)
2. Typically, Ais the main connective with
Artificial Intelligence (SPPU) 4-21 Knowledge

Evample:Someone killed the cat and is guilty.


ax killed(x, cat) ^ guilty(x)
Equality:term1 = termz is true under a given interpretation if andonly if term1 and term2 refer to the same
object.
Example: Richard has at least two brothers

3x, By Brother (x, Richard) ABrother (y, Richard) A¬(x=y)

4 Knowledge Engineering in First-Order Logic


knowledge- engineering. In
The process of constructing a knowledge-base in first-order logic is called as
knowledge-engineering, someone who investigates a particular domain,
learns important concept of that
knowledge engineer.
domain, and generates a formal representation of the objects, is known as
engineering process in an electronic circuit domain, which
is
In this topic, we willunderstand the Knowledge
already familiar. Thisapproach is mainly suitable for creating special-purpose knowledge base.
Following are the steps of knowledge engineering steps :
1. Identify the task.
2. Assemble the relevant knowledge.
constants.
3 Decide on a vocabulary of predicates, functions,and
4 Encode general knowledge about the domain.
instance.
5 Encode a description of the specific problem
answers.
6. Pose queries tothe inference procedure and get
7. Debug the knowledge base. digital circuit (One-bit
knowledge base which will allow us to reason about
Using these steps, we will develop a
fulladder) which is given in the Fig. 4.7.1.
1
2

Fig. 4.7.1

Identify the task:


the digital circuit, there are various reasoning
The first step of the process is to identify the task, and for
tasks.
of the circuit :
At the first level or highest level, we will examine the functionality
Does the circuit add properly?
What willbe the output of gate A, if all the inputs are high?
Tech Kaeuledge
Artificial Intelligence (SPPU) 4-22

At the second level, we will examine the circuit structure details such as:
Knowledge
Which gate is connected to the first input terminal?
Does the circuit have feedback loops?
2 Assemble the relevant knowledge:
In the second step, we will assemble the relevant knowledge which is required for digital circuits. So f
digital circuits, we have the following required knowledge :
Logiccircuits are made up of wires and gates.
Signal flows through wires to the input terminal of the gate, and each
gate produces the corresponding
output which flows further.
In this logic circuit, there are four types of gates used:
AND, OR, XOR, and NoT:
All these gates have one output terminal and two input terminals
(except NOT gate, it has one input
terminal).
3. Decide on vocabulary:
The next step of the process is to select
functions, predicate, and constants to represent the
terminals, signals, and gates. Firstly we will distinguish the circuits,
bach gate is represented as an object which is gates from each other and from other objects.
named by a constant, such as, Gate(XJ. The
each gate is determined by its type, which is functionality of
be identified by a predicate taken as constants such as AND, OR, XOR, or
: Circuit (C). NOT. C)rcuits will
For the terminal, we will use
predicate :
For gate input, we will use the function Terminal(x).
In(1, X,) for denoting the first input
output terminal we will use Out (1, terminal of the gate, and for
X,).
The function Arity(c, i, i) is used to
denote that circuit c has i input, joutput.
Theconnectivity between gates can be
represented by predicate Connect(0ut(1, X;), In(1,
We use a unary predicate On (t), X)).
which is true if the signal at a terminal is on.
4. Encode general knowledge about the domain :
To encode the general knowledge
about the logic circuit, we need some
following rules :
If twoterminals are connected
then they have the same input signal,
it can be represented as:
Vtt, Terminal (t;) ATerminal (t) A
Connect (t t) ’ Signal (t;) =Signal (2).
Signal at every terminal will have either value 0
or 1, it will be represented as :
Vt Terminal (t) Signal (t) =1 vSignal (t) =0.
Connect predicates are commutative:
V tt, Connect (t,, t,)’ Connect (tz, t,).
Representation of types of gates :
g Gate(g) Ar=Type (g) ’r=OR Vr= AND
Vr= XOR Vr= NOT.
Output of AND gate will be zero if and only if any of
its input is zero.
gGate(g) ^Type (e) =AND Signal (Out(1, g)) =0 In Signal (In(n, g))= 0.
Artificial Intelligence (SPPU) 4-23 Knowledge

Output of OR gate is 1 if and only if any of its input is 1:


VgGate(g) AType(g) =0R -’ Signal (Out(1, g))= 1 Bn Signal (In(n, g))= 1
Output of XOR gate is 1if and only if its inputs are different:
Vg Gate(g) AType(g) =XOR’ Signal (Out(1, g)) =1 Signal (In(1, g)) ÷Signal (In(2 8).
Output of NOT gate is invert of its input:
Vg Gate(g) ^Type(g) = NOT ’ Signal (In(1, g)) Signal (Out(1, g).
All the gates in the above circuit have two inputs and one output (except NOT gate).
Vg Gate(g) ^ Type(g) = NOT ’ Arity(g, 1, 1)
VgGate(g) Ar=Type(g) A(r= AND Vr= OR Vr= XOR) ’ Arity (g, 2, 1).
Allgates are logic circuits :
gGate(g) ’ Circuit (g).
5. Encode a description of the problem instance :
circuit and its gate components. 1This step 1s
Now we encode problem of circuit C, firstly we categorize the
atomics
thought. This step involves the writing simple
easy if ontology about the problem is already
sentences of instances of concepts, which is known as ontology.
in atomic sentences as below :
For the given circuit C4, we can encode the problem instance
these gates will
AND, and one OR gate so atomic sentences for
Since in the circuit there are two XOR, two
be:

1. For XOR gate: Type(x)= XOR, Type(X,]) =XOR


2. For AND gate: Type(A) =AND, Type(A)= AND
3. For 0R gate: Type (0,) = 0R.
all the gates.
And then represent the connections between
answers :
6 Pose queries to the inference procedure and get
all the terminal for the adder circuit. The first query
In this step, we willfind all the possible set of values of
will be:
the first output of circuit C1, as 0 and a
What should be the combination of input which would generate
second output to be 1?
1. i1,i2, i3 Signal (In(1, C)) =i1 ASignal (In(2, C,)) =i2 ASignal (In(3, C)) =i3
2. ASignal (Out(1, C)) =0A Signal (Out(2, C)) =1
Debug the knowledge base:
Now we will debug the knowledge base, and this is the last step of the complete process. In this step, we
willtry to debug the issues of knowledge base.
In the knowledge base, we may have omitted assertions like 1+ 0.

Tech Knouledge
Artificial Intelligence (SPPU)
4-24 Knowledge
Review Questions

Q. 1 What is Knowledge based Agent ?


and type of environment for the same.
Q.2 Describe WUMPUS WORLDEnvironment. Specify PEASproperties
Q. 3 What is Logic ? Explain various knowledge representation techniques.
Q. 4
What is propositional logic ? Write syntax and semantics and example sentences for propositional logic.
Q. 5 Explain the inference process in case of propositional logic with suitable examples.
Q. 6 Explain Horn Clause with example.
Q. 7 Explain various method of knowledge representation with example.
Q. 8 Give PEAS descriptors for WUMPUS world.
Q. 9 Explain backward chaining giving suitable example.
Q. 10 Write short note on Predicate Logic.
Q. 11 Explain various methods of knowledge
representation with example.
Q. 12 Give PEAS descriptors for
WUMPUS world.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy