Knowledge Based Agents - 1
Knowledge Based Agents - 1
26 Artificial Intelligence
Complexity: Managing dependencies between beliefs and assumptions can be cor
especially when dealing with multiple, conflicting beliefs.
. Integration with 0ther AlTechniques: Combining TMS with other Al techniques, suth.
machine learning or natural language processing. can be challenging due to their dife
knowledge representation and reasoning mechanisms.
Wumpus problem using Inference Rules
-S,,>W,,A¬W,,^¬W
-W,, A¬W,,^-Wa
Apply Modus Ponens with ¬S11 and R1
" Apply And-Elimination Rule: After we apply And-elimination rule to ¬W11 A-W12 A¬W2!
we will see three statements: ¬W11,¬W12, and W21.
Apply Modus Ponens to ¬S21, and R2: We will now apply Modus Ponens to ¬S21 and h
which is ¬S21 ’ ¬W21 A¬ W22 A¬W31, which will give the Output as -W21 A¬W22 A :
¬W,,^W,,A ¬W,
Apply Modus Ponens to S21and R2
W21 A
" Apply And -Elimination rule: Again we will now apply And-elimination rule to
W22 A¬ W31, We will see three statenents:¬W21, ¬W22, and ¬W31. WI'V
WI3 y,
Apply MP to S12 and R4: Apply Modus Ponens to S12 and R4 which is S12 ’ \
W22 v. W11, we wil!l get the output as W13 V W12V w22 VW11.
Knowledge based Agents 4.27
W,vW,,vW,vW,,
Apply Modus Ponens to S12 and R4
" Apply Unit resolution on W13 v W12 vw22 vW11 and ¬w11 : After applying Unit
resolution formulaon W13 v W12 v W22 VW11 and ¬W11 we will see W13 v W12 v W22
W,vW,;vW,vW,, -W1
(W,,vW,,VW,)
Apply Unit resolution on W13vW12vW22vW11 and-¬W11
Apply Unit resolution on W13 v W12 v W22 v W11 and ¬W11: After applying Unit
resolution formula on W13v W12 v W22 v W11 and ¬W11 we willsee W13 v W12 vW22.
W,,vW,,v W,av W,, -W11
(W,,vW,V W,)
Apply Unit resolution on W13vW12vW22vW11 and¬W11
Apply Unit resolution on W13 vW12 vW22 and ¬W22 :After applying Unit resolution on
W13v wi2 v W22, and ¬W22, we will get W13 v W12 as output.
W,,vW,vWaa -W2
W,,v W,2
Apply Unit resolution on W13vW12vW22 andW22
4.28 Artificial lntelligence
Apply Unit Resolution on W13 VW12 and ¬W12 : After Applying Unit resolution on W1).
W12 and ¬W12,we willsee W13 as an output, therefore, it is proved that the Wumpus is in
room [1, 3].
W,,vWa -Wi2
W,s Proved
Ruler(CAESAR )
Predicate
constant
Vx Vy Loves (x,y)
quantified
var iables
Example :2
Invalid wffs.
function Predicate
Man (~JOHN) Constants should not be negated. Only the predicates can be negated
but not the terms.
Constant
P(x) ’ Q(x) Predicate symbols should not be quantified
Married (Man, Women) Predicates cannot have predicates as arguments.
Predicates
Svntax:
~ (vx)F(x)
=3x(~ F (x))
~ (3x) F(x)
= Vx(~ F ())
Example :3
For the following set of sentences write wffs in predicate logic.
1. Marcus was a man.
Ruler(Caesar)
5. All Romans were either loyal to Caesar or hated him.
Vx: Roman(x) ’ loyalto (x, Caesar) Vhate(x, Caesar)
6. Everyone is loyal to someone.
Vx 3y: loyalto(x,y)
7. People only try to assassinate rulers they are not loyal to.
Vx vy:person(x) ^ ruler(y) ^tryassassinate(xy) ’ loyalto(x.y)
8. Marcus tried to assassinate Caesar.
tryassassinate(Marcus, Caesar)
9. Men only try to assassinate rulers they are not loyal to
Vw: Vu :(Man(w) ^ Ruler (u) ^ tryassassinate(w, u) ’ loyalto(w,u)
10. All Pompeians died in 79AD
Vx:( Pompeian(x)-’ Died (x, 79AD))
Knowledge based Agents 4.31
Example :4
Convert all the given statements into first order predicate logic.
a. John likes allkind of food.
b. Apple and vegetable are food
c. Anything anyone eats and not killed is food.
d. Anil eats peanuts and still alive
e. Harry eats everything that Anil eats.
f. John likes peanuts.
a. tx: food (x) ’ likes (john, x)
b. food (Apple) Afood (vegetables)
c. Vx ty: eats (x, y) ^¬ killed (x) ’ food (y)
d. eats (Anil, Peanuts) Aalive (Anil)
e. x:eats (Anil, x)’ eats (Harry, x)
f. likes (John, Peanuts)
Example :5
Write wffs in predicate logic for the following
1. Everybody loves Raymond.
2. Everybody loves somebody.
3. There is somebody whom everybody loves.
4. There is somebody who Raymond doesn't love.
5. There is somebody whom no one loves.
Let Variables x,y denote people and L(x,y) denotes "x loves y".
Therefore the translation is as follows
1. Vx :L(x, Raymond)
2. vx 3y :L(x,y)
3. By x :L(x,y)
4. By:-L(Raymond.y)
5. By Vx: ¬L(x,y)
Example :6
Consider the following
1. Policeman goes wherever thief goes
2. Thief is at bank
Represent these statements in FOPL.
4.32 Artificial Intelligence
Example :7
Consider the following facts
1. The members of the Elm St. Bridge Club are Joe, Sally, Bill and Ellen.
2. Joe is married to Sally.
3. Bill is Ellen's brother.
4. The spouse of every married person in the club is also in the club.
5. The last meeting of the club was at Joe's house.
Represent these facts in FOPL.
1. Member(Joe, SBC) AMember(Sally, SBC) AMember(Bill, SBC)A Member(Ellen, SBC)
2. Married(Joe) ’ Husband(Joe, Sally)
3. Brother(Bill, Ellen)
4. Vx Vy: (Married(x) ^Member(x, SBC)) ’ Husband(x,y) APresent(y, SBC)
5. LastMeeting(SBC, JoeHouse)
Example:8
1. All people who are not poor and are smart are happy.
2. Those people who read are not stupid.
3. John can read and is wealthy.
4. Happy people have exciting lives.
1. (x){ poor (x) a smart (x)}’ happy(x)]
2. (vy)[read (y)’ stupid(y)]
3. read (Join) ~ Poor (John)
4. (7y) [happy (z) exciting (2)]
Example :9
1. Mary loves everyone.
2. Mary loves everyone.
3. No one talks.
4. Everyone loves himself.
5. Everyone loves everyone.
6. Everyone loves everyone except himself.
7. Every student smiles.
8. Every student except George smiles.
9. Everyone walks or talks.
10. Every student walks or talks
11. Every student who walks talks.
12. Every student who loves Mary is happy.
13. Every boy who loves Mary hates every boy who Mary loves.
14. Every boy who loves Mary hates every other boy who Mary loves.
Knowledge based Agents 4.33
1. Vx: love (Mary, x)
2. Vx: (person(x) + love (Mary, x))
3. VX:talk(x)
4. Vx: love (x, x)
5. Vx:Vy love (x, y)
6. Vx:Vy(x=y love (x, y))
7. Vx: (student(x) ’ smile( x))
8. Vx: ((student(x)’ (x* George + smile( x)
9. Vx: (walk (x) Vtalk (x))
10. V: (student(x) ’ (walk (x) v talk (x)
11. V: ((student(x) Awalk (x)) ’ talk (x)
12. Vx: ((student(x) a love (x, Mary)) ’ happy (x))
13. Vx:((boy(x) a love (x, Mary)) ’ y((boy(y) love
14. Vx:((boy(x) a love (x, Mary)) ’ Vy((boy(y) a
(Mary, y))+ hate (x,y))
love(Mary, y) ^y *x) ’ hate (x,y)
Summary
Knowledge is the basic element for ahuman brain to know and understand the
logically. When a person becomes knowledgeable about something, he is able to do thatthings
in a better way. In Al, the agents which copy such an element of human beings are thing
known as
knowledge-based agents.
Types of Knowledge : Meta Knowledge, Heuristic Knowledge, Procedural
Declarative Knowledge, Structural Knowledge Knowledge,
Knowledge-based agents represent searchable knowledge that can be reasoned. These
agents maintain an internal state of knowledge, take decisions regarding it, update the data,
and perform actions on this data based on the decision. Basically, they are intelligent and
respond to stimuli like how humans react to different situations
" Aknowledge-based system comprises of two distinguishable features they are
A Knowledge base & An Inference Engine
Knowledge-base is required for updating knowledge for an agent to learn with experiences
and take action as per the knowledge.
Interence system generates new facts so that an agent can update the KB. An inference
system works mainly in two rules which are given as: Forward chaining &Backward chaining
Various level of Knowledge based agent : Knowledge level, Logical level &Implementation
level.
" Declarative approach &Procedural approach are the twO approaches todesign a knowledge
based agent.
he three major components of logic: Syntax, Semantic &Logical inference.
Propositional logic (PL) is the simplest form of logic where all the statements are made
oy propositions, A proposition is a declarative statement which is either true or false. It is a
technique of knowledge representation in logical and mathematical Iform.
Atomic means a single preposition like "the sky is blue, 'hot days are humid, water is liquid,
etc. It ismade up of only one proposition sign. These are the sentences that must be true or
untrue in order to pass.
4.34 Artificial lntelligence
" Complex prepositions are those, which have been formed by connecting one, two, or
sentences. In propositional logic, there are five symbols((logical connectives) to more
syntax to represent the connection of two or more sentences. create the
Logical connectives are usedto connecttwo simpler propositions or representing a:
logically. We can create compound propositions with the help of logical connectives sentence
" The proposition symbols P,Qetc are sentences
o IfP is a sentence, ¬P is a sentence (negation)
o IfP andQ are sentences, PAQis a sentence (conjunction)
o IfP and Q
are sentences, PVQis a sentence (disjunction)
o If P and Q are sentences, P’ Q is a sentence (implication)
o IfP and Qare sentences, P > Qisa sentence (biconditional)
" Logical equivalence is one of the features of propositional logic. Two propositions are said
to be logically equivalent if and only if the columns in the truth table are identical to each
other.
First-Order Logic (FOL) is a logical way of allowing us to use statements to express
relationships between things. It is also known as First-Order Predicate Calculus or First
Order Predicate Logic, adds quantifiers, variables, and predicates to propositional logic.
The basic elements of First Order Logic in Artificial Intelligence- Constants, Variables
Predicates, Function, Connectives, Equality &Quantifiers.
" In First-Order Logic, quantifiers allow us to discuss collections of objects, qualities, or
relationships as a group. They help us in expressing our thoughts on whether particular
statements apply toall members of a group or apply to particular members that fit aspecified
requirement.
" The Universal Quantifier () is a logic concept that allows you to make statements abour
each and every individual member in agroup. It's equivalent to stating "for ll' or "for every'
It states a condition that holds true for every member of a set or collection in mathematical
and logical terms.
The Existential Quantifier (3) is a key idea in logic that allows you to say that at least
one member in a group or domain meets a certain condition. In other words, it's the sae
as stating "there is" or "there exists" in daily speech. It states the presence of at least ote
member who fits a specific requirement in logical terms
Modus ponens, Modus Tollens, Universal Instantiation,Universal Generalization, Existenta
Instantiation,Existential Generalisation - Rules of Inference in FOL
Unification in First-Order Logic deals with finding a common substitution for varia
in different terms to make them match. The goal of unification is to make two expres
identical by assigning values to variables in a way that preserves their meanings. It invo
substituting terms for variables in a way that the resulting expressions match.
" In First-Order Logic (FOL), resolution is a fundamental inference method for theoh
proving and logical reasoning. It's very beneficial for showing the truth of statements throu
contradiction. The resolution principle helps in the generation of new clauses from old o
resulting in the resolution of difficult logical issues.
Knowledge based Agents 4.35