Unit 4
Unit 4
2. Similarly, identifying the relationships among the attributes in the representation is equally important.
Reasoning about values that are taken up also adds up complexities in the selection process. Hence, proper
selection of the attributes impacts the relationships.
3. Handling the issue of level or up to what depth the mapping of the knowledge is to be done defines the
granularity. This is governed by the availability of facts and the level upto which it is possible to split them and
represent them. Sometimes, splitting can prove to be an option to handle the issue, making the easy
accessibility, but sometimes, it adds complexities to handle the data.
5. Finally, selection of correct structure is the most important part to have a proper representation
Various levels of knowledge-based agents
1. Knowledge level
• Knowledge level is the first level of knowledge-based agent, and in this level, we need to specify what the agent
knows, and what the agent goals are.
• With these specifications, we can fix its behavior.
• For example, suppose an automated taxi agent needs to go from a station A to station B, and he knows the way
from A to B, so this comes at the knowledge level.
2. Logical level
• At this level, we understand that how the knowledge representation of knowledge is stored.
• At this level, sentences are encoded into different logics, and encoding of knowledge into logical sentences occurs.
• At the logical level we can expect to the automated taxi agent to reach to the destination B.
3. Implementation level
• This is the physical representation of logic and knowledge.
• At the implementation level agent perform actions as per logical and knowledge level.
• At this level, an automated taxi agent actually implement his knowledge and logic so that he can reach to the
destination.
Wumpus world
• The Wumpus world is a simple world example to illustrate the worth of a knowledge-based agent and to
represent knowledge representation.
• It was inspired by a video game Hunt the Wumpus by Gregory Yob in 1973.
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.
Wumpus World
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
• Wumpus will emit a horrible scream which
can be heard anywhere in the cave.
PEAS description of Wumpus world:
Performance measure: Actuators:
• Left turn,
• +1000 reward points if the agent comes out of
• Right turn
the cave with the gold. • Move forward
• -1000 points penalty for being eaten by the • Grab
Wumpus or falling into the pit. • Release
• Shoot.
• -1 for each action, and -10 for using an arrow. Sensors:
• The game ends if either agent dies or came • The agent will perceive the stench if he is in the
out of the cave. room adjacent to the Wumpus. (Not diagonally).
• The agent will perceive breeze if he is in the
Environment: room directly adjacent to the Pit.
• A 4*4 grid of rooms. • The agent will perceive the glitter in the room
where the gold is present.
• The agent initially in room square [1, 1], facing • The agent will perceive the bump if he walks
toward the right. into a wall.
• Location of Wumpus and gold are chosen • When the Wumpus is shot, it emits a horrible
randomly except the first square [1,1]. scream which can be perceived anywhere in the
cave.
• Each square of the cave can be a pit with
probability 0.2 except the first square.
The Wumpus world Properties
• Commutativity:
• P ∧ Q= Q ∧ P, or
• P ∨ Q = Q ∨ P.
• Associativity:
• (P ∧ Q) ∧ R = P ∧ (Q ∧ R),
• (P ∨ Q) ∨ R= P ∨ (Q ∨ R).
• Identity element:
• P ∧ True = P,
• P ∨ True= True.
• Distributive:
• P ∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
• P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
• DE Morgan's Law:
• ¬(P ∧ Q) = (¬P) ∨ (¬Q),
• ¬(P ∨ Q) = (¬ P) ∧ (¬Q).
• Double-negation elimination:
• ¬(¬P) = P.
Propositional Logic - Reasoning
• The reasoning is the mental process of deriving logical conclusion
and making predictions from available knowledge, facts, and
beliefs.
• "Reasoning is a way to infer facts from existing data."
• It is a general process of thinking rationally, to find valid
conclusions.
Types of Reasoning
• Deductive reasoning
• Inductive reasoning
• Abductive reasoning
• Common Sense Reasoning
• Monotonic Reasoning
• Non-monotonic Reasoning
Propositional Logic - Reasoning
1. Deductive reasoning:
2. Inductive Reasoning:
3. Abductive reasoning:
Abductive reasoning is a form of logical reasoning which starts with single or
multiple observations then seeks to find the most likely explanation or conclusion
for the observation.
Example:
• Implication: Cricket ground is wet if it is raining
• Axiom: Cricket ground is wet.
Reasoning
6. Non-monotonic Reasoning
• In Non-monotonic reasoning, some conclusions may be
invalidated if we add some more information to our knowledge
base.
Example:
• Birds can fly
• Penguins cannot fly
• Pitty is a bird
• So from the above sentences, we can conclude that Pitty can
fly.
• However, if we add one another sentence into knowledge base
"Pitty is a penguin", which concludes "Pitty cannot fly", so it
invalidates the above conclusion.
Propositional Logic - Reasoning
1. If it didn’t rain, Harry visited Hagrid today.
2. Harry visited Hagrid or Dumbledore today, but not both.
3. Harry visited Dumbledore today.
• Looking at sentence 3, we know Harry visited Dumbledore.
• Looking at sentence 2, we know Harry visited either Dumbledore
or Hagrid, and thus we can conclude 4. Harry did not visit
Hagrid.
• Now, looking at sentence 1, we understand that if it didn’t rain,
Harry would have visited Hagrid.
• However, knowing sentence 4, we know that this is not the case.
• Therefore, we can conclude 5. It rained today.
Inferences
• Inference signifies the art of drawing conclusions and making decisions by utilizing the
power of available information or data.
Inference rules:
• Inference rules are the templates for generating valid arguments. Inference rules are
applied to derive proofs in artificial intelligence, and the proof is a sequence of the
conclusion that leads to the desired goal.
• Implication: It is one of the logical connectives which can be represented as P → Q. It is
a Boolean expression.
• Converse: The converse of implication, which means the right-hand side proposition
goes to the left-hand side and vice-versa. It can be written as Q → P.
• Contrapositive: The negation of converse is termed as contrapositive, and it can be
represented as ¬ Q → ¬ P.
• Inverse: The negation of implication is called inverse. It can be represented as ¬ P → ¬
Q.
Inference Rules
Inference Rules in Proposition Logic
Types of Inference rules:
1. Modus Ponens:
• The Modus Ponens rule is one of the most important rules
of inference, and it states that if P and P → Q is true, then
we can infer that Q will be true. It can be represented as:
• 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.
Types of Inference rules:
2. Modus Tollens:
The Modus Tollens rule state that if P→ Q is true and ¬ Q is true, then
¬ P will also true. It can be represented as:
Example
Statement-1: "If I am sleepy then I go to bed" ==> P→ Q
Statement-2: "I do not go to the bed."==> ~Q
Statement-3: Which infers that "I am not sleepy" => ~P
Forward Chaining: