You are on page 1of 19

Knowledge and Reasoning

Knowledge and Reasoning:


humans are very good at acquiring new information by
combining raw knowledge, experience with reasoning.
AI-slogan: “Knowledge is power” (or “Data is power”?)

Examples:
Medical diagnosis --- physician diagnosing a patient
infers what disease, based on the knowledge he/she
acquired as a student, textbooks, prior cases
Common sense knowledge / reasoning ---
common everyday assumptions / inferences
e.g., “lecture starts at four” infer pm not am;
when traveling, I assume there is some way to get from the
airport to the hotel.
What is Logic?
Logic is the key behind any knowledge. It allows a person to filter the necessary information
from the bulk and draw a conclusion. In artificial intelligence, the representation of
knowledge is done via logics.
•There are three main components of logic, which are as follows:
•Syntax: It is the sequence of a specific language which should be followed in order to form
a sentence. Syntax is the representation of a  language. Every language has its own syntax.
•For example, ax2+bx+c is a well-formed syntax of a quadratic equation.
•Semantics: The sentence or the syntax which a logic follows should be meaningful.
Semantics defines the sense of the sentence which relates to the real world.
•For example, Indian people celebrate Diwali every year. This sentence represents the true
fact about the country and its people who are Indians. Therefore, the sentence is syntactically
as well as semantically correct.
•Logical Inference: Inference means to infer or draw some conclusions about some fact or a
problem. Logical inference is thinking all the possible reasons which could lead to a proper
result. Inference algorithms are used to perform logical inference.

2
Logical agents:
Agents with some representation of the
complex knowledge about the world / its environment,
and uses inference to derive new information from that
knowledge combined with new inputs (e.g. via perception).

Key issues:
1- Representation of knowledge
What form? Meaning / semantics?
2- Reasoning and inference
processes
Efficiency.
Knowledge-base Agents
• Key issues:
– Representation of knowledge  knowledge base
– Reasoning processes  inference/reasoning

Knowledge base = set of sentences in a formal language
representing facts about the world(*)

(*) called Knowledge Representation (KR) language


• Key aspects: Knowledge bases
– How to add sentences to the knowledge base
– How to query the knowledge base

Both tasks may involve inference – i.e. how to derive new sentences from old
sentences

Logical agents – inference must obey the fundamental requirement that when one
asks a question to the knowledge base, the answer should follow from what has
been told to the knowledge base previously. (In other words the inference
process should not “make things” up…)
A simple knowledge-based agent

• The agent must be able to:


– Represent states, actions, etc.
– Incorporate new percepts
– Update internal representations of the world
– Deduce hidden properties of the world
– Deduce appropriate actions
A knowledge-based agent
• A knowledge-based agent includes a knowledge base and an
inference system.
• A knowledge base is a set of representations of facts of the
world.
• Each individual representation is called a sentence.
• The sentences are expressed in a knowledge representation
language.
• The agent operates as follows:
1. It TELLs the knowledge base what it perceives.
2. It ASKs the knowledge base what action it should perform.
3. It performs the chosen action.

7
Architecture of a
knowledge-based agent
• Levels of a Knowledge-based agent
• Knowledge Level: In this level, the behavior of an agent is decided by
specifying the following :
• The agent’s current knowledge it has percieved.
• The goal of an agent.
• Implementation Level: This level is the physical representation of the
knowledge level. Here, it is understood that “how the knowledge-based
agent actually implements its stored knowledge.”
• For example, Consider an automated air conditioner. The inbuilt
knowledge stored in its system is that “ It would adjust its temperature
according to the weather.” This represents the knowledge level of the agent.
The actual working and its adjustment define the implementation level of
the knowledge-based agent.

8
The architecture of knowledge-based
agent:

• The above diagram is representing a generalized architecture for a knowledge-


based agent. The knowledge-based agent (KBA) take input from the
environment by perceiving the environment. The input is taken by the inference
engine of the agent and which also communicate with KB to decide as per the
knowledge store in KB. The learning element of KBA regularly updates the KB
by learning new knowledge.
9
Approaches used to build a
Knowledge-based agent
• There are following two approaches used to design the behavior of
a knowledge-based system:
• Declarative Approach: Feeding the necessary information in an empty
knowledge-based system. Such type of approach is used to design a
knowledge-based system. The agent designer TELLS sentences to the
empty system one by one until the system becomes knowledgeable
enough to deal with the environment.
• Procedural Approach: In this approach, knowledge is stored into an
empty system in the form of program code. It is a contrasting approach
to the declarative approach. It designs the behavior of the system via
coding.

10
The Wumpus World environment
• 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 which is called Wumpus, who eats anyone who enters the room. The
Wumpus can be shot by the agent, but the agent has a single arrow.
• In the Wumpus world, there are some Pits rooms which are bottomless, and if agent falls
in Pits, then he will be stuck there forever.
• The exciting thing with this cave is that in one room there is a possibility of finding a heap
of gold.
• So the agent goal is to find the gold and climb out the cave without fallen into Pits or
eaten by Wumpus. The agent will get a reward if he comes out with gold, and he will get a
penalty if eaten by Wumpus or falls in the pit.

11
A typical Wumpus world
• The agent always starts in the
field [1,1].
• The task of the agent is to find
the gold, return to the field [1,1]
and climb out of the cave.
1. The rooms adjacent to the
Wumpus room are smelly, so that
it would have some stench.
2. The room adjacent to PITs has a
breeze, so if the agent reaches
near to PIT, then he will perceive
the breeze.
3. There will be glitter in the room if
and only if the room has gold.
4. The Wumpus can be killed by the
agent if the agent is facing to it,
and Wumpus will emit a horrible
scream which can be heard
anywhere in the cave.

12
PEAS description of Wumpus world:
• Performance measure:
• +1000 reward points if the agent comes out of the cave with the gold.
• -1000 points penalty for being eaten by the Wumpus or falling into the pit.
• -1 for each action, and -10 for using an arrow.
• The game ends if either agent dies or came out of the cave.
• Environment:
• A 4*4 grid of rooms.
• The agent initially in room square [1, 1], facing toward the right.
• Location of Wumpus and gold are chosen randomly except the first square
[1,1].
• Each square of the cave can be a pit with probability 0.2 except the first square.

13
Actuators:
•Left turn,
•Right turn
•Move forward
•Grab
•Release
•Shoot.
Sensors:
•The agent will perceive the stench if he is in the room adjacent to the Wumpus. (Not diagonally).
•The agent will perceive breeze if he is in the room directly adjacent to the Pit.
•The agent will perceive the glitter in the room where the gold is present.
•The agent will perceive the bump if he walks into a wall.
•When the Wumpus is shot, it emits a horrible scream which can be perceived anywhere in the cave.
•These percepts can be represented as five element list, in which we will have different indicators for each sensor.
•Example if agent perceives stench, breeze, but no glitter, no bump, and no scream then it can be represented as:
[Stench, Breeze, None, None, None].

14
Agent's First step:
•Initially, the agent is in the first room or on the square [1,1], and we
already know that this room is safe for the agent, so to represent on the
below diagram (a) that room is safe we will add symbol OK. Symbol A is
used to represent agent, symbol B for the breeze, G for Glitter or gold, V
for the visited room, P for pits, W for Wumpus.
•At Room [1,1] agent does not feel any breeze or any Stench which
means the adjacent squares are also OK.

15
Agent's second Step:
•Now agent needs to move forward, so it will either move to [1, 2], or [2,1].
Let's suppose agent moves to the room [2, 1], at this room agent perceives
some breeze which means Pit is around this room. The pit can be in [3, 1], or
[2,2], so we will add symbol P? to say that, is this Pit room?
•Now agent will stop and think and will not make any harmful move. The
agent will go back to the [1, 1] room. The room [1,1], and [2,1] are visited by
the agent, so we will use symbol V to represent the visited squares.

16
Agent's third step:
•At the third step, now agent will move to the room [1,2] which is OK. In the
room [1,2] agent perceives a stench which means there must be a Wumpus
nearby. But Wumpus cannot be in the room [1,1] as by rules of the game, and also
not in [2,2] (Agent had not detected any stench when he was at [2,1]). Therefore
agent infers that Wumpus is in the room [1,3], and in current state, there is no
breeze which means in [2,2] there is no Pit and no Wumpus. So it is safe, and we
will mark it OK, and the agent moves further in [2,2].

17
Agent's fourth step:
•At room [2,2], here no stench and no breezes present so let's suppose
agent decides to move to [2,3]. At room [2,3] agent perceives glitter, so it
should grab the gold and climb out of the cave.

18
Summary
• Intelligent agents need knowledge about the world for making good
decisions.
• The knowledge of an agent is stored in a knowledge base in the form of
sentences in a knowledge representation language.
• A knowledge-based agent needs a knowledge base and an inference
mechanism. It operates by storing sentences in its knowledge base,
inferring new sentences with the inference mechanism, and using them
to deduce which actions to take.
• A representation language is defined by its syntax and semantics,
which specify the structure of sentences and how they relate to the facts
of the world.
• The interpretation of a sentence is the fact to which it refers. If this
fact is part of the actual world, then the sentence is true.

19

You might also like