Knowledge and Reasoning
Knowledge and Reasoning
TER
3 Knowledge and Reasoning
Unitll S
Syllabus
A
Nhowledge Based Agent, Overview
of Propositional Logic, First Order Predicate Logic, Interence
Predicate Logic: Forward and in First Order
Backward Chaining, Resolution.
Introduction:
Understanding theoretical or
practical aspects of a subject is called as
experience acquired based on the knowledge. We can gain knowledge
facts, information, etc. about the subject. through
After gaining
knowledge about some
problems related to that subject based onsubject we can apply that knowledge to derive conclusions about various
some reasoning.
We have studied various types of
agents in chapter 1. In this
chapter
agent", with a very interesting game example.
we are
going to see what is "knowledge based
We are also going to study how do
they store knowledge, how do they infer next level of
set. In turn, we are
studying various knowledge representation and inference methods in knowledge from the existing
this chapter
3.1 A
Knowledge Based Agent
As shown Fig. 3.1.1, a
knowledge based agents can be described at
Inference Engine. different levels:
Knowledge Base (KB) and an
Interence engine
Domain-independent algorithms
Knowledge base
Domain-specific content
Fig. 3.1.1: Levels of
1. Knowledge level knowledge base
Knowledge level is a base level of an
agent, which consists of
In this level agent has domain-specific content.
facts/information about the surrounding
not consider the actual
implementation. environment in which they does
2.
Implementation level are working, it o
Declarative approach of building an agent makes use of TELL and ASK mechanism.
it has received. Lastly, it performs the selected action with the help of effectors
plementation level.
1 Knowledge level
2. Logical level
3. Implementation level
Knowledge Level
what it
The knowledge level describes agent by saying
It is the most abstract level of agent implementation.
knows. That is what knowledge the agent has as the initial knowledge.
that knowledge are defined in his level. Initial knowedge of
Basic data structures and procedures to access
predicate logic.
discussed in detail in the turther sections.
Both these representation techniques are
(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.
Logic is successfully used to define ways to infer new sentences from the existing ones. There are certain logics that
are used for the representation of information, and range in terms of their expressiveness. There are logic that are
more expressive and are more useful in translation of sentences from natural languages into the logical ones. There
areseveral logics that are widely used
Propositional logic : These are restricted kinds that make use of propositions (sentences that are either true or
false but not both) which can be either true or false. Proposition logic is also known as propositional calculus,
sentential calculus or Boolean algebra.
2. First order predicate logic: These are much more expressive and make use
of variables, constants, predicates,
connectives explained already in previous section.
functions and quantifiers along with the
order predicate logic by using
order predicate logic is distinguished from first
3. Higher order predicate logic: Higher
semantics.
additional quantifiers and stronger
existence ofin between TRUE and FALSE or fuzziness in all logics
4Fuzzylogic: These indicate the
valued logic, modal logics and temporal logics.
5.
Otherlogic:These include multiple
() Productlon rule representation rules.
as IF-THEN
knowledge is to use production rules, it is also known
One of the widest used methods to represent
Syntax
IF condition THEN action
premise THEN conclusion
trie
proposition pl and proposition p2
are
Fish is an Animal.
O Cats love Milk.
O All mammals are animals.
Mammal s a Animal
ls a
ls a
Grey Owned by
Sam
Flg. 3.4.1
aual Graph: It is a recent scnee uEd Tor
semantic network, finite
oraph. The nodes represent either introduced by John Sowa, has a
connected, bipar e labelled
arcs.
concepts or conceptual
For relations. revious
co
l e d k a o n l e
Artificial Intelligence (MU-Sem. 7-1T) 3-12
Knowledge and Reasoning
Ram
Brothers Laxman Cat Colour Grey
Bharat
Fig.3.4.2
(d) Frame representation
(STATE(VALUE mh))
(ZIP(VALUE400615)
3.4.1 Ontology
Ontology is study 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 is a 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
the truth
value of one
statement
value o
between
(i.e. The relationship
relativity of truth values.
other statement)
3.5.1 Syntax
as follows
8asic syntax followed by the propositional logic can be given
C, etc.
Propositional symbols are denoted with capital letters like : A, B,
crisp nature (1.e. 0 (false) and 1 (truell
values have a
Propositional logic constants have a truth value generally truth
values vary in the range
of 0 and 1.
But for fuzzy logic truth can
is denoted as (..).
atomic sentence. It
Propositional logic make use of wrapping parenthesis while writing
And AB Conjunction
V
Or AvB Disjunction
Not -A Negation
To define logical connectives truth tables are used. Iruth table 3.5.2 shows five logical connectives.
Table 3.5.2
A AABAVBAAA
False false false False true true true
False true false True true true false
True false false false false false
True true true True false true true
T d
UDiitati0n*
K n o u k e
Artificial Intelligence (MU-Sem. 7-1T) 3-14 Knowledge and Reasoning
Take an example, where A A B, i.e. Find the value of AA B where A is true and B is false. Third row of the Table 3.5.2
shows this condition, now see third row of the third column where, A a B shows result as false. Similarly other logical
connectives can be mapped in the truth table.
3.5.2 Semantics
World is set of facts which we want to represent to form propositional logic. In order to represent these tacts
propositional symbols can be used where each propositional symbol's interpretation can be mapped to the real world
feature.
Techasastedge
PUbIIeations
Artificial Intelligence (MU-Sem. 3-15
Knowledge and Reason
7-1)
nave (HTa and
HM)-> RN then it means "Ifitis hot and humid, then it is raining so
on
First we have to create the possible models for a knowledge base. To do this we need to
assignments of true or false value for Sentence A, Band C. Then verify the truth table
ble for
consider all the posgh
the
total 8 validity.
possibilities as shown below: There can
Sentence HT Sentence HM Sentence RN Validity
False False False Valid
Techlnd
uDIUCa"
Artificial Intelligence (MU-Sem. 7-IT)
3-18 Knowledge and Reasoning
3.5.8 Advantages of Propositional Logic
Propositional logic is simple knowledge representation
a
language.
t is sufficient and efficient technique for
solving some artificial intelligence based
problems.
Propositional logic forms the foundation for higher logics like First Order
Logic (FOL), etc.
Propositional logic is NP complete and reasoning is decidable.
The process of inference can be illustrated by PL
3.5.9 Disadvantages of Propositional Logic
Propositional logic is cannot express complex artificial intelligence
problems.
Propositional logic can be impractical for even small worlds, think about WUMPUS hunter
problem.
Even if we try to make use of
propositional logic to express complex artificial intelligence problems, it can be very
wordy and lengthy.
PL is a weak knowledge representation language because :
With PL it is hard to
identify if the used entity is "individual". For example : If there are entities like Priya,
Mumbai, 123, etc.
PL cannot directly represent properties of individual entities or relations between individual entities. For
example, Pooja is tall.
PL cannot express
specialization, generalizations, or patterns, etc. For example : All rectangles have 4 sides.
3.6 First Order Predicate Logic
MU-May 14
a. Write a short note on predicate logic.
(May14,5 Marks)
Because of the inadequacy of PL discussed above there was a need for more expressive type of logic. Thus First-Order
Logic (FOL) was developed. FOL is more expressive than PL, it can represent information using relations, variables and
quantifiers, e.g, which was not possible with propositional logic.
today(Sunday)
First Order Logic(FOL}is also called as First Order Predicate Logic (FOPL). Since FOPL is much more expressive as a
knowledge representation language than PL it is more commonly used in artificial intelligence.
Assuming that "X" is a domain of values, we can define a term with following rules:
1. Constant term : It is a term with fixed value which belongs to the domain.
. Function : Say " is a function of "n" arguments. If we assume that t , t t , are terms then ft,t , t) is also
called as a term.
eckededgd
PuDEations
3-19
ground
term. A
sentence
variables
common. Hence, it also. Supports called as a
variables it is
have any
term does not
erm: If a "wel1-formed formula"
are quantified is
called as a
object.
is mapped with
an
o Every ground term objects.
a relation. the terms'
is mapped to between
Every condition (predicate) te's relation
holds
is evaluate.
considered as true if the predice If the
predecessor d to
A Bround atom is and
successor.
1. Universal Quantifier'V'
all the variables in the predicate
Pronounced as "for al" and it is applicable to
3x(Dog(X) white(X))
Note
Typicaliy. is the main connective with y
Data
edleeiedye
Pubiteattans
3-21
data-driven
as a
"Forward chaining" is called
Example
Given
Rule: human(A) -> mortal(A)
Data: human(Mandela)
To prove: mortal(Mandela)
Mandela
Forward Chaining Solution
get A
=
we can
Rule. So,
Side of the
matches Left Hand
Human tMandela)
mortal(Mandela) in a forward direction ti .
. from
get: operation
s t a t e m e n t we can
based on the rule as it performs
systems",
by the "design expert
Forward chaining is used
start to the end).
5. Missile is a weapon.
Owns (Nono, x)
Missile(x)
4. All the missiles were sold to Nono by Colonel
West.
Missile(x)A owns(Nono, x)=> Sell(\West, x,
Nono)
5. Missile is a weapon.
Missile(x)=> weapontx)
6. Colonel West is American.
American (West)
To
Knowledge and Reasoning
ArtificialIntelligence (MU-Sem.7-1T) 3-22
forward chaining
Proof by ution
us to
nroof will start from the given facts. And as we can derive other facts from those, it will lead
The pr the sou
Olase refer to Fig. 3.8.2 As we observe from the given facts we can reach to the predicate Criminal (West)
Pleas
American (West) Missile (x)|Owns (Nono,)|| Enemy
(Nono,America)
Sell
Weapon()|(West, x, Nono)
Criminal (West)
Fig. 3.8.2: Proof by forward chaining
TecaKnewiedg
i atrans
3-23 wledge and Reasoni
Artificial Intelligence (MU-Sem. 7-1T)
Example can be solved
using Dackward chainino
used in forward
chaining ng.
ds understand how the same example
Ciminal (west)
True
True
True True
True
enfirafie
Tec
exhaustive and precise. This vocabulary
is called as ontology of the thin8s exist in the Uhtology iis
domain
what kind of
e
s been
defined. That is,
defined, it means, the existence of the domain is
decided. defines axioms
for
knowledge engineer all he
th
this step the : In
n g of general knowledge about the domain
enables expert
to c r o s s
check the vocabulary and and the cabulary co
contents
of each term. This
vocabulary terms by define meaning
this point by
redoing step
3.
it can be fixed at
or gaps,
" n e Tinds any misinterpretations
is encoded using
the defined ontology. Thissto
step v
instance
5. ncode the problem: In this step, the specific
problem
atomic s e n t e n c e s
about problem inct
properly. Encoding m e a n s writing tances
be very easy if the tology is defined program.
data for a computer
w n are already part of ontology. It can
be analogues to input
are done,
all input for the
system is set and now is atime
ime to
all the above steps inferred from the prouia.
6. Query the Knowledgebase: Once interested tacts
in order to get some
8 e n e r a t e some output from the system. So,
procedure will operate on the
axioms and
facts derive
The inference
Knowledge, we can query the knowledgebase. specific programs.
write application
interences. This lessens the task of a programmer to
the new
or check the
toughness of the knowledgebase In
which one can prove
7. knowledgebase: This is the step in or it stops in
between
Debug the appropriate answers to all
the queries asked
the sense, if the inference procedure is able to give If one o b s e r v e s the reasoning chain
identified by debugging
process.
Decause of the incomplete axioms; will be easily of a missing or a wea
it is an indication
could not be answered then,
stopping in between or some of the queries and system can be claimed to
the required steps
axIoms. Then the corrective m e a s u r e s can
be taken by repeating
Procedure Unify(,t
Inputs
g i atoms Output
exists otherwise
t, and t, if it
or
most general wnifier of
Local
statements
E: a set of equality
S: substitution
E-ft,=t
S=i
while ( 1 }
seiect and
remove x =y from E
SsVfUS
x)
y:3x Apolicy (y) -agent (x)> sells (x, y,
shaves (X, Y)
(IVx y: barber (x) a person (y) A -shaves (y,
y)
Soln.
() Vx vy: kills (x, animal)-- loves (y, x)
breez (X* 1, Y)
breez (x- 1, y) a
3.11 Resolution
Resolution is a valid inference rule. Resolution produces a new clause which is implied
by two clauses contal
complementary literals. This resolution rule was discovered by Alan Robinson in the mid 1960's.
We have seen that a literal is an atomic symbol or a negation of the atomic symbol (i.e. A, -A).
Resolution is the only interference rule you need, in order to build a sound
entence
T e c h l a s i
Publical
Artificial Intelligence (MU-Sem. 7-IT) 3-28 Knowledge and Reasoning
Given:
A clause X containing the literal Z
Let knowledge base be a set of true sentences which do not have any contradictions, and Z be a sentence that we
want to prove.
The ldea is based on the proof by negation. So, we should assume -Z and then try to find a contradiction (You must
have followed such methods while solving eeometry proofs). Then based on the Intuition that, if all the knowledge
base sentences are true, and assuming-Z creates a contradiction then Z must be inferred from knowledge base. Then
we need to convert knowledge base U {-Z) to clause form.
if there is a contradiction in knowledge base, that means Z is proved. Terminate the process after that.
Otherwise select two clauses and add their resolvents to the current knowledge base. If we do not find any resolvable
clauses then the procedure fails and then we terminate. Else, we have to start finding if there is a contradiction in
knowledge base, and so on.
MU- May 16
a. Explain the steps involved in converting the propositionallogiostatementinto CNF with a suitable example
(May 16, 10 Marks)
) A(B CACB)
(i) (A (B> C)) (A >(C B))
Converting to CNF.
Applying Rule,
Tech Ksnewledge
PuDItati ns