MODULE-2 - AI Man
MODULE-2 - AI Man
Knowledge representation and reasoning (KR, KRR) is the part of Artificial intelligence
which concerned with “AI agents thinking and how thinking contributes to intelligent
behavior of agents.”
• It is responsible for representing information about the real world so that a
computer can understand and can utilize this knowledge to solve the complex
real world problems such as diagnosis a medical condition or communicating
with humans in natural language.
• Knowledge representation is not just storing data into some database, but it also
enables an intelligent machine to learn from that knowledge and experiences
so that it can behave intelligently like a human.
Add a footer 3
What to Represent:
Following are the kind of knowledge which needs to be represented in AI systems:
• Object: All the facts about objects in our world domain. E.g., Guitars contains strings,
trumpets are brass instruments.
• Events: Events are the actions which occur in our world.
• Performance: It describe behavior which involves knowledge about how to do things.
• Meta-knowledge: It is knowledge about what we know.
• Facts: Facts are the truths about the real world and what we represent.
• Knowledge-Base: The central component of the knowledge-based agents is the knowledge
base. It is represented as KB. The Knowledgebase is a group of the Sentences (Here,
sentences are used as a technical term and not identical with the English language).
• Knowledge: Knowledge is awareness or familiarity gained by experiences of facts, data,
and situations.
4
Types of knowledge
Following are the various types of knowledge:
knowledge about the structure of a problem or
system and is often used to help AI systems decompose
heuristic knowledge are a hypothesis, common sense,
complex problems into simpler sub-problems that can
rule of thumb, and intuition.
be solved more easily. It is the basic knowledge of
problem-solving.
2. Procedural Knowledge
• It is also known as imperative knowledge.
• Procedural knowledge is a type of knowledge which is responsible for knowing how to
do something.
• It can be directly applied to any task.
• It includes rules, strategies, procedures, agendas, etc.
• Procedural knowledge depends on the task on which it can be applied.
3. Meta-knowledge:
• Knowledge about the other types of knowledge is called Meta-knowledge.
4. Heuristic knowledge:
• Heuristic knowledge is representing knowledge of some experts in a filed or subject.
• Heuristic knowledge is rules of thumb based on previous experiences, awareness of
approaches, and which are good to work but not guaranteed.
5. Structural knowledge:
• Structural knowledge is basic knowledge to problem-solving.
• It describes relationships between various concepts such as kind of, part of, and grouping
of something.
• It describes the relationship that exists between concepts or objects.
7
AI knowledge cycle:
The relation between knowledge and intelligence:
• Knowledge of real-worlds plays a vital role in intelligence and same for creating artificial
intelligence. Knowledge plays an important role in demonstrating intelligent behavior in AI
agents.
An Artificial intelligence system has the following components for displaying intelligent
behavior:
1. Perception
2. Learning
3. Knowledge Representation and Reasoning
4. Planning
5. Execution
Add a footer 8
• The above diagram is showing how an AI system can interact with the real world
and what components help it to show intelligence.
• AI system has Perception component by which it retrieves information from its
environment. It can be visual, audio or another form of sensory input. The
learning component is responsible for learning from data captured by Perception
comportment.
• In the complete cycle, the main components are knowledge representation and
Reasoning.
• These two components are involved in showing the intelligence in machine-like
humans. These two components are independent with each other but also
coupled together. The planning and execution depend on analysis of Knowledge
representation and reasoning.
Approaches to knowledge representation:
1. Simple relational knowledge:
2. Inheritable knowledge
• Logical Representation
• Semantic Network Representation
• Frame Representation
• Production Rules
1. Logical representation
Logical representation is a language with some concrete rules which deals with propositions
and has no ambiguity in representation. Logical representation means drawing a conclusion
based on various conditions. It consists of precisely defined syntax and semantics which
supports the sound inference. Each sentence can be translated into logics using syntax and
semantics.
Syntax:
Syntaxes are the rules which decide how we can construct legal sentences in the logic.
It determines which symbol we can use in knowledge representation.
How to write those symbols.
Semantics:
Semantics are the rules by which we can interpret the sentence in the logic.
Semantic also involves assigning a meaning to each sentence.
Logical representation can be categorised into
mainly two logics:
• Propositional Logics
• Predicate logics
2. Semantic Network Representation
• Setworks are alternative of predicate logic for knowledge representation.
• In Semantic networks, we can represent our knowledge in the form of graphical networks.
• This network consists of nodes representing objects and arcs which describe the relationship between those
objects.
• Semantic networks can categorize the object in different forms and can also link those objects.
This representation consist of mainly two types of relations:
Statements:
Jerry is a cat.
Jerry is a mammal
Jerry is owned by Priya.
Jerry is brown colored.
All Mammals are animal.
Drawbacks in Semantic representation:
• Semantic networks take more computational time at runtime as we need to traverse the
complete network tree to answer some questions. It might be possible in the worst case
scenario that after traversing the entire tree, we find that the solution does not exist in this
network.
• Semantic networks try to model human-like memory (Which has 1015 neurons and links) to
store the information, but in practice, it is not possible to build such a vast semantic network.
• These types of representations are inadequate as they do not have any equivalent quantifier,
e.g., for all, for some, none, etc.
• Semantic networks do not have any standard definition for the link names.
Advantages of Semantic network:
• Semantic networks are a natural representation of knowledge.
• Semantic networks convey meaning in a transparent manner.
• These networks are simple and easily understandable.
3. Frame Representation
A frame is a record like structure which consists of a collection of attributes and its values
to describe an entity in the world.
Frames are the AI data structure which divides knowledge into substructures by
representing stereotypes situations.
It consists of a collection of slots and slot values. These slots may be of any type and sizes.
Slots have names and values which are called facets.
The above example was of a frame for a book
Add a footer 27
There are also some components which can help the agent to navigate the cave. These
components are given as follows:
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.
10/16/2024
Add a footer 28
PEAS description of Wumpus world:
• To explain the Wumpus world we have given PEAS description as below:
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.
10/16/2024
Add a footer 29
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.
Exploring the Wumpus world:
Now we will explore the Wumpus world and will determine how the agent will find its
goal by applying logical reasoning.
30
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.
Add a footer 31
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.
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].
Add a footer 32
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.
Add a footer 33
Propositional logic (PL)
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)
• c) 3+3= 7(False proposition)
• d) 5 is a prime number.
Add a footer 34
• Following are some basic facts about propositional logic:
✓In propositional logic, we use symbolic variables to represent the logic, and we
can use any symbol for a representing a proposition, such A, B, C, P, Q, R, etc.
10/16/2024
Add a footer 35
✓The propositions and connectives are the basic elements of the propositional logic.
✓Connectives can be said as a logical operator which connects two sentences.
✓A proposition formula which is always true is called tautology, and it is also called a valid
sentence.
✓A proposition formula which is always false is called Contradiction.
✓A proposition formula which has both true and false values is called Contingency.
• Statements which are questions, commands, or opinions are not propositions such as
"Where is Rohini", "How are you", "What
10/16/2024
Add a footer 36
Syntax of propositional logic:
• The syntax of propositional logic defines the allowable sentences for the knowledge
representation. There are two types of Propositions:
• Atomic Propositions
• Compound propositions
10/16/2024 37
2.Compound proposition: Compound propositions are constructed by combining simpler
or atomic propositions, using parenthesis and logical connectives.
Example:
10/16/2024
Add a footer 38
Logical Connectives:
• Logical connectives are used to connect two simpler propositions or
representing a sentence logically. We can create compound propositions with the
help of logical connectives.
10/16/2024
Add a footer 40
Table for Propositional Logic Connectives:
Truth Table:
In propositional logic, we need to know the truth values of
propositions in all possible scenarios. We can combine all the possible
combination with logical connectives, and the representation of these
combinations in a tabular format is called Truth table. Following are
the truth table for all logical connectives:
10/16/2024
Add a footer 41
10/16/2024
Add a footer 42
• Limitations of Propositional logic:
• We cannot represent relations like ALL, some, or none with propositional logic.
Example:
• All the boys are intelligent.
• Some apples are sweet.
• Propositional logic has limited expressive power.
• In propositional logic, we cannot describe statements in terms of their properties
or logical relationships.
10/16/2024
Add a footer • 43
10/16/2024
Add a footer 44
Knowledge representation using
predicate 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.
Function: Father of, best friend, third inning of, end of, ......
As a natural language, first-order logic also has two main parts:
Syntax
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. We write
statements in short-hand notation in FOL.
Basic Elements of First-order logic:
Atomic sentences vs. Complex sentences
▪Atomic sentences are the most basic sentences of first-order logic.
▪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.
Consider the statement: "x is an integer.",
it consists of two parts,
the first part x is the subject of the statement and
second part "is an integer," is known as a predicate.
Quantifiers in First-order logic:
▪A quantifier is a language element which generates quantification,
and quantification specifies the quantity of specimen in the universe
of discourse.
▪These are the symbols that permit to determine or identify the range
and scope of the variable in the logical expression. There are two
types of quantifier:
Universal Quantifier, (for all, everyone, everything)
Existential quantifier, (for some, at least one).
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.
For all x
For each x
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 ∃, which resembles as inverted E. When
it is used with a predicate variable then it is called as an existential quantifier.
3. Decide on vocabulary
▪In this logic circuit, there are four types of gates used: AND,
OR, XOR, and NOT.
▪All these gates have one output terminal and two input
terminals (except NOT gate, it has one input terminal).
Process is to select functions, predicate, and constants to represent
the circuits, terminals, signals, and gates.
▪Each gate is represented as an object which is named by a constant, such
as, Gate(X1).
▪The functionality of each gate is determined by its type, which is taken as constants such
as AND, OR, XOR, or NOT.
▪For gate input, we will use the function In(1, X1) for denoting the first input terminal of the
gate, and for output terminal we will use Out (1, X1).
▪The function Arity(c, i, j) is used to denote that circuit c has i input, j output.
▪The connectivity between gates can be represented by predicate Connect(Out(1, X1), In(1,
X1)).
▪We use a unary predicate On (t), which is true if the signal at a terminal is on.
To encode the general knowledge about the logic circuit, we need some following rules:
▪If two terminals are connected then they have the same input signal, it can be represented as:
∀ t1, t2 Terminal (t1) ∧ Terminal (t2) ∧ Connect (t1, t2) → Signal (t1) = Signal (t2).
▪Signal at every terminal will have either value 0 or 1, it will be represented as:
▪Output of AND gate will be zero if and only if any of its input is zero.
∀ g Gate(g) ∧ Type(g) = XOR → Signal (Out(1, g)) = 1 ⇔ Signal (In(1, g)) ≠ Signal (In(2, g))
▪All the gates in the above circuit have two inputs and one output (except NOT gate)
∃ i1, i2, i3 Signal (In(1, C1))=i1 ∧ Signal (In(2, C1))=i2 ∧ Signal (In(3, C1))= i3
∧ Signal (Out(1, C1)) =0 ∧ Signal (Out(2, C1))=1
7. Debug the knowledge base:
▪Now we will debug the knowledge base, and this is the last step of the complete process. In this step,
we will try to debug the issues of knowledge base.
In the knowledge base, we may have omitted assertions like 1 ≠ 0
END OF MODULE 2