AI Tech-Knowledge Unit 4
AI Tech-Knowledge Unit 4
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.
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
returns actíon
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
NStenché
2 (Breeze
1 (Breeze
PIT
Start
1 2 3
WUMPUS
WORLD Environment.
D e s c r i b e
Move:
forward direction,
To move in
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
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
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
V B
OK OK
OK OK
P?
OK OK
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
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
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
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
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
Syatax:
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
TechKnowledge
Artificial Intelligence (SPPU) 4-14
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).
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
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?
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".
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
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 :
Fig. 4.7.1
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
Tech Knouledge
Artificial Intelligence (SPPU)
4-24 Knowledge
Review Questions