PDF&Rendition=1
PDF&Rendition=1
KNOWLEDGE REPRESENTATION
Knowledge-Based agents
• An intelligent agent needs knowledge about the real world for taking decisions and
reasoning to act efficiently.
• Knowledge-based agents are those agents who have the capability of maintaining an
internal state of knowledge, reason over that knowledge, update their knowledge after
observations and take actions. These agents can represent the world with some formal
representation and act intelligently.
Knowledge-based agents are composed of two main parts:
• Knowledge-base and
• Inference system.
A knowledge-based agent must able to do the following:
• An agent should be able to represent states, actions, etc.
• An agent Should be able to incorporate new precepts
• An agent can update the internal representation of the world
• An agent can perform appropriate actions.
The architecture of knowledge-based agent:
1. function KB-AGENT(percept):
2. persistent: KB - a knowledge base, t - a counter initially 0, indicating time
3. TELL(KB, MAKE-PERCEPT-SENTENCE(percept, t))
4. Action = ASK(KB, MAKE-ACTION-QUERY(t))
5. TELL(KB, MAKE-ACTION-SENTENCE(action, t))
6. t = t + 1
7. return action
Each time when the function is called, it performs its three operations:
• Firstly it TELLs the KB what it perceives.
• Secondly, it ASKS KB what action it should take
• Third agent program TELLS the KB that which action was chosen.
• The MAKE-PERCEPT-SENTENCE generates a sentence as setting that the agent
perceived the given percept at the given time.
• The MAKE-ACTION-QUERY generates a sentence to ask which action should be
done at the current time.
• MAKE-ACTION-SENTENCE generates a sentence which asserts that the chosen
action was executed.
Problem definition: The Wumpus world is a cave which has 4/4 rooms connected with
passageways. So there are total 16 rooms which are connected with each other. We have a
knowledge-based agent who will go forward in this world. The cave has a room with a beast
There are also some components which can help the agent to navigate the cave. These
components are given as follows:
❖ The rooms adjacent to the Wumpus room are smelly, so that it would have some stench.
❖ The room adjacent to PITs has a breeze, so if the agent reaches near to PIT, then he will
perceive the breeze.
❖ There will be glitter in the room if and only if the room has gold.
❖ The Wumpus can be killed by the agent if the agent is facing to it.
Propositional Logic
• Propositional logic (PL) is the simplest form of logic where all the statements are made
by propositions.
• A proposition is a declarative statement which is either true or false. It is a technique of
knowledge representation in logical and mathematical form.
Example:
a) It is Sunday.
b) The Sun rises from West (False proposition)
• A square is breezy if and only if there is a pit in a neighbouring square. This has to be
stated for each square; for now, we include just the relevant squares:
• Now we include the breeze percept for the first two squares visited in the specific world
the agent is in
• The knowledge base, then, consists of sentences R1 through R5.It can also be
considered as a single sentence-the conjunction R1 A Rz A R3 A R4 A R5-because it
asserts that all the individual sentences are true.
Inference
For propositional logic, models are assignments of true or false to every proposition symbol.
Returning to our wumpus-world example, the relevant proposition symbols are B1,1, B2,1, P1,1,
P1,2,P2,1, P2,2 and P3,1.With seven symbols, there are 27=128 possible models; in three of these,
KB is true.
Modus Ponens:
Example:
Statement-1: "If I am sleepy then I go to bed" ==> P→ Q
Statement-2: "I am sleepy" ==> P
Conclusion: "I go to bed." ==> Q.
Hence, we can say that, if P→ Q is true and P is true then Q will be true.
Modus Tollens:
And elimination:
First-Order Logic
• In propositional logic, we can only represent the facts, which are either true or false. PL
is not sufficient to represent the complex sentences or natural language statements. The
propositional logic has very limited expressive power.
First-Order logic:
•First-order logic is another way of knowledge representation in artificial intelligence.
It is an extension to propositional logic.
SAHANA K BGS FGC Mysuru
• FOL is sufficiently expressive to represent the natural language statements in a concise
way.
• First-order logic is also known as Predicate logic or First-order predicate logic. First-
order logic is a powerful language that develops information about the objects in an
easier way and can also express the relationship between those objects.
• First-order logic (like natural language) does not only assume that the world contains
facts like propositional logic but also assumes the following things in the world:
Objects: A, B, people, numbers, colors, wars, theories, squares, pits, wumpus, ......
Relations: It can be unary relation such as: red, round, is adjacent, or n-any relation such
as: the sister of, brother of, has color, comes between
Function: Father of, best friend, third inning of, end of, ......
• As a natural language, first-order logic also has two main parts:
1) Syntax
2) Semantics
Syntax of First-Order logic:
The syntax of FOL determines which collection of symbols is a logical expression in first-order
logic. The basic syntactic elements of first-order logic are symbols.
Basic Elements of First-order logic:
Following are the basic elements of FOL syntax:
Variables x, y, z, a, b,....
Connectives ∧, ∨, ¬, ⇒, ⇔
Equality ==
Quantifier ∀, ∃
Atomic sentences:
Atomic sentences are the most basic sentences of first-order logic. These sentences are formed
from a predicate symbol followed by a parenthesis with a sequence of terms.
We can represent atomic sentences as Predicate (term1, term2, ......, term n).
Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).
Complex Sentences:
Complex sentences are made by combining atomic sentences using connectives.
First-order logic statements can be divided into two parts:
Subject: Subject is the main part of the statement.
Predicate: A predicate can be defined as a relation, which binds two atoms together in a
statement.
Example: >(1,2)V≤(1,2) => True
Universal Quantifier:
• Universal quantifier is a symbol of logical representation, which specifies that the
statement within its range is true for everything or every instance of a particular thing.
• The Universal quantifier is represented by a symbol ∀, which resembles an inverted A.
• If x is a variable, then ∀x is read as:
o For all x
o For each x
o For every x.
Existential Quantifier:
Existential quantifiers are the type of quantifiers, which express that the statement within its
scope is true for at least one instance of something. It is denoted by the logical operator ∃. If x
is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as:
o There exists a 'x.'
o For some 'x.'
o For at least one 'x.'
Let us take a variable x which can take the value of “student”. Let us take a predicate student(x)
which is true if x is a student. Similarly let us take another predicate likes(x,y) which is true if
x likes y.
Properties of Quantifiers:
Equality
We can use the equality symbol to make statements to the effect that two terms refer to the
same object. For example,
Father(John) = Henry
says that the object referred to by Father(John) and the object referred to by Henry are the same.
Using FOL
Sentences are added to a knowledge base using TELL, exactly as in propositional logic. Such
sentences are called assertions. For example, we can assert that John is a king and that kings
are persons:
We can ask questions of the knowledge base using ASK. For example,
Rule 2: IF A is true
AND B is true
AND C is true
THEN Y is true
Rule 3: IF Y is true
AND D is true
THEN Z is true
Forward Chaining:
• Forward chaining is a form of reasoning which start with atomic sentences in the
knowledge base and applies inference rules (Modus Ponens) in the forward direction to
extract more data until a goal is reached.
Properties of Forward-Chaining:
• It is a down-up approach, as it moves from bottom to top.
• It is a process of making a conclusion based on known facts or data, by starting from
the initial state and reaches the goal state.
• Forward-chaining approach is also called as data-driven as we reach to the goal using
available data.
Example:
Rule 1: IF student is excellent in academics
AND he is good in sports
THEN he is all rounder (Goal)
Rule 2: IF student gets marks > 80
AND he is good in genera knowledge
THEN he is excellent in academics
Rule 3: IF student is making centuries
THEN he is good in sports