Knowledge Based Agents
Knowledge Based Agents
o Forward chaining
o Backward chaining
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.
At the logical level, an 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.
Knowledge-based agents have explicit representation of knowledge that can
be reasoned. They maintain internal state of knowledge, reason over it, update
it and perform actions accordingly. These agents act intelligently according to
requirements.
Knowledge based agents give the current situation in the form of sentences.
They have complete knowledge of current situation of mini-world and its
surroundings. These agents manipulate knowledge to infer new things at
“Knowledge level”.
Problem Statement:
The Wumpus world is a cave with 16 rooms (4×4). Each room is connected
to others through walkways (no rooms are connected diagonally). The
knowledge-based agent starts from Room[1, 1]. The cave has – some pits,
a treasure and a beast named Wumpus. The Wumpus can not move but
eats the one who enters its room. If the agent enters the pit, it gets stuck
there. The goal of the agent is to take the treasure and come out of the cave.
The agent is rewarded, when the goal conditions are met. The agent is
penalized, when it falls into a pit or being eaten by the Wumpus.
Some elements support the agent to explore the cave, like -The wumpus’s
adjacent rooms are stenchy. -The agent is given one arrow which it can use
to kill the wumpus when facing it (Wumpus screams when it is killed). –
The adjacent rooms of the room with pits are filled with breeze. -The
treasure room is always glittery.
Propositional logic
Propositional logic is a fundamental aspect of artificial intelligence (AI),
particularly in the areas of knowledge representation, reasoning, and automated
theorem proving. Here's a brief overview of how propositional logic is utilized
in AI
Basics of Propositional Logic
AND (∧)
OR (∨)
NOT (¬)
IMPLIES (→)
IF AND ONLY IF (↔)
Applications in AI
1. Knowledge Representation:
o Declarative Knowledge: Propositional logic is used to represent
facts about the world. Each fact is represented as a proposition.
o Rules: Logical rules can be formulated to describe how different
propositions relate to each other.
2. Automated Reasoning:
o Inference Engines: Systems like rule-based systems use
propositional logic to infer new information from known facts and
rules.
o Theorem Proving: Automated theorem provers check the validity
of logical statements and derive new conclusions.
3. Search Algorithms:
o Propositional logic is used to define the states and transitions in
search problems. For example, in game playing, each possible
move can be represented as a proposition.
4. Expert Systems:
o These systems use a knowledge base of propositional logic
statements and an inference engine to make decisions or solve
problems in specific domains, such as medical diagnosis or
financial advice.
6. Planning:
o In AI planning, actions are represented as logical operators that
transform states represented by propositions. Planners use logical
inference to determine sequences of actions that achieve a goal.
Example
P∧Q→RP ∧ Q → RP∧Q→R (If the car has fuel and the battery is
charged, then the car starts)
¬R→(¬P∨¬Q)¬R → (¬P ∨ ¬Q)¬R→(¬P∨¬Q) (If the car does not start,
then either the car has no fuel or the battery is not charged)
Given observations (e.g., the car does not start), the system can use
propositional logic to infer possible causes (e.g., the car might have no fuel or
the battery might be discharged).
Challenges
1. Objects:
Objects can denote any real-world entity or any variable.
E.g., A, B, colours, theories, circles etc.
2. Relations:
Relations represent the links between different objects. Relations can be
unary(relations defined for a single term) and n-ary(relations defined for
n terms). E.g., blue, round (unary); friends, siblings (binary); etc.
3. Functions:
Functions map their input object to the output object using their
underlying relation. Eg: father_of(), mother_of() etc.
In the subsequent sections, we present the parts of First Order Logic in AI, i.e.,
the syntax and the semantics.
1. Syntax:
Syntax represents the rules to write expressions in First Order Logic in
Artificial Intelligence.
2. Semantics:
Semantics refers to the techniques that we use to evaluate an expression
of First Order Logic in AI. These techniques use various known relations
and facts of the respective environment to deduce the boolean value of
the given First Order Logic expression.
We elaborate on the syntax of First Order Logic in AI in the following sections.
Meaning
Element Example
1, 2, A, John, Mumbai, Values that can not be changed
Constant
cat, ....
Can take up any value and can also change
Variables x, y, z, a, b, ....
Defines a relationship between its input
Predicates Brother, Father, >, .... terms
Atomic Sentences
Atomic sentences are the most basic expressions of First Order Logic in AI.
These sentences comprise a predicate followed by a set of terms inside a
parenthesis. Formally stating, the structure of an atomic sentence looks like the
following.
Predicate ( term 1, term 2, term 3,...) Predicate ( term 1, term 2, term 3,...)
Quantifiers in First Order Logic in AI, as the name suggests, are used to
quantify any entity in a given environment. Quantification refers to the
identification of the total number of an entity that is present in the environment
and satisfies a given expression in First Order Logic in Artificial Intelligence.
Quantifiers enable us to determine the range and scope of a variable in a logical
expression. Two types of quantifiers are stated as follows.
1. Universal Quantifier
2. Existential Quantifier
Universal Quantifier
For example, let us take the sentence, "All cats like fish". Let us take a
variable 𝑥x which can take the value of "cat". Let us take a
predicate cat (𝑥) cat (x) which is true if 𝑥x is a cat. Similarly, let us take another
predicate likes (𝑥,𝑦) likes (x,y) which is true if 𝑥x likes 𝑦y. Therefore, using the
universal quantifier ∀∀, we can write
∀𝑥 cat (𝑥)⟹ likes (𝑥, fish ).∀x cat (x)⟹ likes (x, fish ).
This expression is read as "For all 𝑥x, if 𝑥x is a cat, then 𝑥x likes to fish".
Existential Quantifier
For example, let us take the sentence, "Some students like ice cream". 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 (𝑥,𝑦) likes (x,y), which is true if 𝑥x likes 𝑦y. Therefore,
using the existential quantifier ∃∃, we can write
∃𝑥 student (𝑥)∧ likes (𝑥, ice-cream )∃x student (x)∧ likes (x, ice-cream )
This expression reads, "There exists some 𝑥x such that 𝑥x is a student and also
likes ice cream".
While using quantifiers in writing expressions for First Order Logic in Artificial
Intelligence, we need to keep the following points in mind.
Example
Inference rule: If a dog is up for adoption and someone is looking to adopt it, that person is
free to adopt it.
Here, the decision can be reached as person b can adopt the dog from person A. This is how
forward chaining works to make a decision.
Advantages
Disadvantages
Inference rule: If a person wants to adopt a dog, he can if there is any up for adoption.
Here, the inference engine will begin with the goal and look if the conditions are met. If both
conditions are met, the stated decision can be concluded.
While backward chaining has its benefits, it also has certain drawbacks, both enlisted below:
Advantages
Easier process
Efficiently drives correct solutions
Disadvantages
Less flexibility
Difficult to execute