Unit III
Unit III
Knowledge
Representation
Dr. Praveen Kumar Loharkar
Introduction
• Definition:
• Knowledge representation and reasoning (KR, KRR)
is a part of AI concerned with how AI agents think
and how thinking contributes to intelligent
behavior.
• It involves representing information about the real
world so that a computer can understand and
utilize this knowledge to solve complex problems.
Introduction :What to Represent
Following are the kind of knowledge which needs to be represented
in AI systems:
• Object: Facts about objects (e.g., guitars have strings).
• Events: Actions occurring in the world.
• Performance: Knowledge about how to do things.
• Meta-knowledge: Knowledge about what we know.
• Facts: Truths about the real world.
Introduction:Types of Knowledge
• Declarative Knowledge:
• Knowing about something (concepts, facts, objects).
• Expressed in declarative sentences.
• Procedural Knowledge:
• Knowing how to do something (rules, strategies, procedures).
• Directly applied to tasks.
• Meta-knowledge:
• Knowledge about other types of knowledge.
• Heuristic Knowledge:
• Expert knowledge based on experience (rules of thumb).
• Structural Knowledge:
• Basic knowledge for problem-solving (relationships between concepts).
Relationship Between Knowledge and Intelligence
• Importance of Knowledge:
• Vital for demonstrating intelligent behavior in AI agents.
• Agents act intelligently based on knowledge and experience.
AI Knowledge Cycle
• Components:
• Perception: Retrieves information from the environment.
• Learning: Learns from data captured by perception.
• Knowledge Representation and Reasoning: Shows
intelligence in machines.
• Planning and Execution: Depends on analysis of
knowledge representation and reasoning.
Approaches to Knowledge Representation
Approaches to Knowledge Representation
Approaches to Knowledge Representation
Approaches to Knowledge Representation
Techniques of Knowledge Representation
Techniques of Knowledge Representation
Knowledge representation is a crucial aspect of artificial intelligence
(AI) that involves capturing and storing human knowledge in a way
that machines can understand and use.
Here are some common techniques of knowledge representation:
Logical Representation:
• Uses formal logic to represent knowledge.
• Involves propositions and predicates to express facts and
relationships.
• Examples include propositional logic and predicate logic.
Techniques of Knowledge Representation
Semantic Networks: Example:
• Jerry is a cat
• Represents knowledge in the form • Jerry is a mammal
of a graph with nodes and edges. • Jerry is owned by Priya
• Jerry is white-colored
• Nodes represent concepts or • All mammals are Animals
objects, and edges represent
relationships between them.
• Useful for representing hierarchical
relationships like “is-a” and "part-
of“.
Techniques of Knowledge Representation
Frame Representation:
• Uses data structures called
frames to represent stereotyped
situations.
• Each frame consists of slots
(attributes) and fillers (values).
• Frames can be linked to
represent complex structures
and inheritance.
• Example: Frame of a Book
Techniques of Knowledge Representation
Production Rules:
• Represents knowledge in the form
of “if-then” rules.
• Useful for encoding procedural
knowledge and decision-making
processes.
• Often used in expert systems.
• These techniques help AI systems
reason, make decisions, and solve
problems by providing a structured
way to represent and manipulate
knowledge.
Introduction
Knowledge-based agents
agents that reason by operating on internal representations of knowledge.
Example of Knowledge Statements
• If it didn't rain, Harry visited Hagrid today.
• Harry visited Hagrid or Dumbledore today, but not both.
• Harry visited Dumbledore today.
Conclusion
Harry did not visit Hagrid today.
It rained today.
Introduction
Sentence
an assertion about the world in a knowledge
representation language
Propositional Logic
Proposition Symbols
• Can be represented using Letters such as: P,Q,R
Logical Connectives
¬
→
not and implication or
↔
biconditional
Convert into Propositional Logic
Convert into Propositional Logic
Not (¬)
P ¬P
false true
true false
And ()
P Q PQ
false false false
P Q PQ
false false false
{P = true, Q = f a l s e }
knowledge base
a set of sentences known by a knowledge-based
agent
Entailmen
t
α⊨ β
It rained today.
inference
the process of deriving new sentences
from old ones
P: It is a Tuesday.
Q: It is raining.
R: Harry will go for a run.
P: It is a Tuesday.
Q: It is raining.
R: Harry will go for a run.
KB: (P ¬Q) → R P ¬Q
Inference R
:
Does
KB ⊨ α
?
Model
Checking
Model
Checking
• To determine if KB ⊨ α:
• Enumerate all possible models.
• If in every model where KB is true, α is true, then
KB entails α.
• Otherwise, KB does not entail α.
P: It is a Tuesday. Q: It is raining. R: Harry will go for a run.
KB: (P ¬Q) → R P ¬Q
Query: R P Q R KB
false false false
false false true
false true false
false true true
true false false
true false true
true true false
P: It is a Tuesday. Q: It is raining. R: Harry will go for a run.
KB: (P ¬Q) → R P ¬Q
Query: R P Q R KB
AR R B H KB Reason
TRUE TRUE TRUE TRUE FALSE due to S4
TRUE TRUE TRUE FALSE FALSE due to S4
TRUE TRUE FALSE TRUE FALSE due to S2
TRUE TRUE FALSE FALSE TRUE
TRUE FALSE TRUE TRUE FALSE due to S4
TRUE FALSE TRUE FALSE FALSE due to S4
TRUE FALSE FALSE TRUE FALSE due to S2
TRUE FALSE FALSE FALSE FALSE due to S3
FALSE TRUE TRUE TRUE FALSE due to S4
FALSE TRUE TRUE FALSE FALSE due to S4
FALSE TRUE FALSE TRUE FALSE due to S2
FALSE TRUE FALSE FALSE FALSE due to S1
FALSE FALSE TRUE TRUE FALSE due to S4
FALSE FALSE TRUE FALSE FALSE due to S4
FALSE FALSE FALSE TRUE FALSE due to S2
FALSE FALSE FALSE FALSE FALSE due to S3
Solution: Steps
AR R B H KB Reason
TRUE TRUE TRUE TRUE FALSE due to S4
TRUE TRUE TRUE FALSE FALSE due to S4
TRUE TRUE FALSE TRUE FALSE due to S2
TRUE TRUE FALSE FALSE TRUE
TRUE FALSE TRUE TRUE FALSE due to S4
TRUE FALSE TRUE FALSE FALSE due to S4
TRUE FALSE FALSE TRUE FALSE due to S2
TRUE FALSE FALSE FALSE FALSE due to S3
FALSE TRUE TRUE TRUE FALSE due to S4
FALSE TRUE TRUE FALSE FALSE due to S4
FALSE TRUE FALSE TRUE FALSE due to S2
FALSE TRUE FALSE FALSE FALSE due to S1
FALSE FALSE TRUE TRUE FALSE due to S4
FALSE FALSE TRUE FALSE FALSE due to S4
FALSE FALSE FALSE TRUE FALSE due to S2
FALSE FALSE FALSE FALSE FALSE due to S3
Problem for Practice
Explain model checking algorithm with the help of example below.
• Hari will go swimming if it is not raining.
• Hari will either go swimming, or jogging, not both.
• Pradeep meets Ria if and only if it is not raining.
• Pradeep meets Ria.
Query – Did Hari go for jogging?
Problem for Practice
Explain model checking algorithm with the help of example below.
• Hari will go swimming if it is not raining.
• Hari will either go swimming, or jogging, not both.
(Hint:(P ∨ Q) ∧ ¬(P ∧ Q))
• Pradeep meets Ria if and only if it is not raining.
• (Hint: P ¬Q)
• Pradeep meets Ria.
Query – Did Hari go for jogging?
Inference Rules
• Modus Ponens
Inference Rules
• And Elimination
Inference Rules
• Double Negation Elimination
Inference Rules
• Implication Elimination
Inference Rules
• Biconditional Elimination
Inference Rules :De Morgan's
Law
Inference Rules :De Morgan's
Law
Inference Rules: Distributive
Property
Inference Rules: Distributive
Property
Search Problems
Theorem Proving
Resolution
Resolution
Resolution
Resolution
Clause
It is a disjunction of
literals
Conjunctive Normal Form
Predicate Symbol:
Represents Property or a
relationship
Predicate Logic or First Order
Logic(FOL)
Predicate Logic or First Order
Logic(FOL)
Predicate Logic or First Order
Logic(FOL)
First Order Logic :Universal
Quantification
Universal quantification in First Order Logic (FOL) is a way to express that a
certain property or statement applies to all elements within a particular
domain.
It is denoted by the symbol
∀
(which stands for “for all”).
For example,
if we want to say that “all humans are mortal,” we can express this in FOL
as:
∀x(Human(x)→Mortal(x))
Predicate Logic or First Order
Logic(FOL)
First Order Logic :Universal
Quantification
First Order Logic :Universal
Quantification
First Order Logic :Existential
Quantification
• Existential quantification in First Order Logic (FOL) is used to express
that there exists at least one element in the domain of discourse for
which a given property or statement holds true. It is denoted by the
symbol
∃
(which stands for “there exists”).
• For example,
• if we want to say that “there exists a human who is a philosopher,”
we can express this in FOL as: ∃x(Human(x)∧Philosopher(x))
First Order Logic :Existential
Quantification
First Order Logic :Existential
Quantification
First Order Logic :Existential
Quantification
First Order Logic :Few more
examples
Example Statements: Show
using First Order or Predicate
Logic
Example Statements: Show
using First Order or Predicate
Logic
Example Statements: Show
using First Order or Predicate
Logic
Translate English sentences into Predicate form and then clause form
Example 1:
Fido is a dog
All dogs are animals
All animals will die
Addition Link for Practicing FOL Conversion:
Microsoft Word - FOL.docx (idm-lab.org)
Resolution in FOL:Conversion from FOL to
Conjunctive Normal Form (CNF) or Clause form
Resolution in FOL: Conversion propositions to
Conjunctive Normal Form (CNF) or Clause form
Forward chaining
It is a form of reasoning that starts with atomic sentences in the knowledge
base and applies inference rules in the forward direction to extract more
data until a goal is reached.
The Forward-chaining algorithm starts from known facts, triggers all rules
whose premises are satisfied, and add their conclusion to the known facts.
This process repeats until the problem is solved.
Properties:
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 reach the goal state
Forward chaining approach is also called data-driven as we reach to goal
using available data.
Forward chaining approach is commonly used in the expert system.
Backward-chaining
• Backward-chaining is also known as a backward deduction or backward
reasoning method when using an inference engine.
• A backward chaining algorithm is a form of reasoning, which starts with the
goal and works backward, chaining through rules to find known facts that
support the goal.
Properties :
• It is known as a top-down approach.
• Backward-chaining is based on modus ponens inference rule.
• In backward chaining, the goal is broken into sub-goal or sub-goals to prove
the facts true.
• It is called a goal-driven approach, as a list of goals decides which rules are
selected and used.
Key Differences Between Forward and
Backward Reasoning in AI