KRR Unit I Notes
KRR Unit I Notes
NOTES
UNIT I - INTRODUCTION
Introduction: The Key Concepts, Need for Knowledge Representation and Reasoning - The Role of
Logic. The Language of First-Order Logic: Introduction-The Syntax- The Semantics-The Semantics-
Explicit and Implicit.
1.1 The Key Concepts: Knowledge, Representation, and Reasoning:
Knowledge representation and Reasoning(KR&R) is the field of artificial intelligence dedicated to
representing information about the world in a form that a computer system can utilize to solve
complex tasks.
The class of systems that derive from this approach are called knowledge based(KB) systems or
agents.
A KB agent maintains a knowledge base of facts expressed in a declarative language. The KB is
the agent’s representation of the world.
Knowledge Representation and Reasoning (KR&R) is a core area of Artificial Intelligence (AI) that
deals with how knowledge can be stored, organized, and used to make intelligent decisions. It focuses
on:
Knowledge – Information about the world, including facts, rules, and relationships.
Representation – A way to structure and store knowledge efficiently.
Reasoning – The process of drawing conclusions from available knowledge.
Example:
Imagine a medical diagnosis system:
Knowledge – “If a patient has a fever and cough, they might have the flu.”
Representation – This rule can be stored using logic or databases.
Reasoning – Given patient symptoms, the system deduces that flu is a likely diagnosis.
1.2 Need for Knowledge Representation and Reasoning:
KR&R is essential in AI and intelligent systems because it allows machines to store, retrieve,
and process information effectively.
KR&R is essential for building knowledge-based systems that solve problems using stored
knowledge.
Different types of Knowledge:
1. Declarative Knowledge: It includes concepts, facts, and objects and expressed in a declarative
sentence.
2. Structural Knowledge: It is a basic problem-solving knowledge that describes the relationship
between concepts and objects.
3. Procedural Knowledge: This is responsible for knowing how to do something and includes
rules, strategies, procedures, etc.
4. Meta Knowledge: Meta Knowledge defines knowledge about other types of Knowledge.
5. Heuristic Knowledge: This represents some expert knowledge in the field or subject.
1. Enabling Knowledge-Based Systems:
A Knowledge-Based System (KBS) is an AI system that utilizes stored knowledge to make
intelligent decisions.
Example: Medical Expert Systems – A doctor’s assistant AI can analyze symptoms and
suggest possible diagnoses based on medical knowledge.
Example: Legal AI Systems – AI can analyze past cases and legal rules to provide legal
advice.
2. Efficient Storage and Management of Knowledge:
Helps in structuring large amounts of data into a meaningful and accessible format.
Reduces redundancy by allowing reusable knowledge structures like ontologies and
semantic networks.
Example: Google Knowledge Graph organizes billions of facts to provide direct answers to
user queries instead of just links.
3. Enabling Intelligent Decision-Making:
KR&R allows systems to make logical decisions by applying reasoning techniques to
knowledge.
Deductive Reasoning – Drawing specific conclusions from general facts.
Example: If "All humans are mortal" and "Socrates is a human," then "Socrates is mortal."
Inductive Reasoning – Generalizing from specific cases.
Example: If a student gets good grades after attending extra classes, we infer that extra classes
help improve performance.
Abductive Reasoning – Inferring the most likely explanation.
Example: If a patient has a fever and a sore throat, the most probable explanation is an
infection.
4. Handling Incomplete and Uncertain Information:
Real-world problems often have missing or uncertain data. KR&R helps by:
Using probabilistic reasoning to make the best possible decisions with incomplete data.
Allowing default reasoning (assuming certain facts unless proven otherwise).
Example: Autonomous Vehicles – Self-driving cars must make decisions even when sensor data
is unclear (e.g., foggy conditions).
5. Automating Problem-Solving and Learning:
KR&R enables AI to solve complex problems automatically.
Helps in machine learning by providing structured knowledge that AI can use to improve
performance.
Example: AI Tutors – Personalized education systems use KR&R to adapt lessons based on
student progress.
6. Enabling Natural Language Understanding and Communication:
KR&R is crucial in Natural Language Processing (NLP), where AI needs to understand
and generate human language.
Helps AI disambiguate meanings (e.g., "bank" can mean a financial institution or a
riverbank).
Supports semantic search and conversational AI (e.g., chatbots, virtual assistants).
Example: Siri/Alexa use KR&R to interpret user requests and provide relevant responses.
7. Supporting AI Applications in Various Domains:
KR&R is widely used in:
Healthcare – Disease diagnosis, patient monitoring, treatment recommendations.
Finance – Fraud detection, risk assessment, automated trading.
Robotics – Object recognition, motion planning, autonomous decision-making.
E-commerce – Personalized recommendations, customer service chatbots.
1.2.1 Knowledge-Based System (KBS):
A Knowledge-Based System (KBS) is an AI system that uses stored knowledge and reasoning
mechanisms to solve complex problems in a specific domain. It mimics human expertise by processing
structured knowledge and drawing logical conclusions.
Key Components of a Knowledge-Based System:
1. Knowledge Base:
Stores facts, rules, and heuristics (rules of thumb) related to a specific domain.
Can be represented using logic, ontologies, semantic networks, or databases.
Example:
In a medical expert system, the knowledge base includes:
Symptoms and diseases
Treatment guidelines
Drug interactions
2. Inference Engine:
The reasoning mechanism that applies logical rules to the knowledge base to deduce new
facts or solutions.
Uses forward chaining (data-driven) or backward chaining (goal-driven) reasoning.
Example:
A loan approval system uses inference rules to determine eligibility based on credit history,
income, and loan amount.
A chess-playing AI evaluates board positions to decide the best move.
3. User Interface:
Allows interaction between the user and the system.
Can be text-based, graphical, or voice-based.
Example:
Chatbots like Siri and Alexa use a natural language interface to interact with users.
Medical diagnostic tools allow doctors to input symptoms and receive recommendations.
Types of Knowledge-Based Systems:
1. Expert Systems:
Simulate human expert decision-making in specific fields.
Example: MYCIN – A medical expert system for diagnosing bacterial infections.
2. Decision Support Systems (DSS):
Help in decision-making by analyzing data and suggesting the best action.
Example: SAP Business Intelligence – Assists companies in strategic planning
3. Natural Language Processing (NLP) Systems:
Understand and generate human language.
Example: Google Translate – Uses a knowledge base of languages to translate text.
4. Recommendation Systems:
Suggest products, movies, or content based on user preferences.
Example: Netflix recommendation engine – Suggests movies based on user viewing history.
5. Robotics and Automations:
Robots use knowledge bases to navigate environments, recognize objects, and make
decisions.
Example: Autonomous vehicles (Tesla) – Use stored traffic rules and sensor data to drive
safely.
1.2.2 Why Knowledge Representation?
Knowledge Representation (KR) is crucial in AI because it allows systems to store, retrieve, and
process information efficiently. It organizes data into a structured format so that machines can
understand and use it for decision-making.
Key Reasons for Knowledge Representation in AI:
1. Efficient Storage and Organization of Knowledge:
AI systems need to store large amounts of data in a way that makes retrieval and
processing efficient.
KR provides structured formats like logic, ontologies, and semantic networks to manage
knowledge effectively.
Example:
A medical knowledge base stores diseases, symptoms, and treatments in an organized structure
so AI can quickly retrieve relevant information.
2. Facilitates Logical Reasoning:
KR enables AI to derive new knowledge from existing facts using reasoning techniques.
Allows AI to infer missing information and make intelligent decisions.
Example:
If we store the rule:
"All birds can fly except penguins and ostriches,"
and we ask, "Can a sparrow fly?", AI can deduce the answer using reasoning.
3. Enables Human-Like Understanding:
AI must understand real-world concepts, relationships, and context.
KR helps systems interpret ambiguous or incomplete information.
Example:
A self-driving car needs to understand road signs, traffic rules, and pedestrian behavior to
navigate safely.
4. Supports Communication Between Humans and Machines:
KR bridges the gap between human knowledge and machine processing.
Enables chatbots, virtual assistants, and NLP systems to interact meaningfully.
Example:
Siri and Alexa process and store knowledge to answer user queries accurately.
5. Standardization for AI Systems:
KR provides a universal structure for knowledge, making AI systems interoperable across
different platforms.
Used in Semantic Web, Expert Systems, and Ontologies.
Example:
Google’s Knowledge Graph connects concepts like “Apple” (company) and “Apple” (fruit) to
improve search accuracy.
Techniques of Knowledge Representation in AI:
1. Logical Representation:
Logical representation is a language with some definite rules which deal with propositions and
has no ambiguity in representation. It represents a conclusion based on various conditions and
lays down some important communication rules. Also, 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 and Semantics:
Syntax: The atomic symbols of the logical language, and the rules
for constructing well-formed, nonatomic expressions (symbol
structures) of the logic.
Semantics: The meanings of the atomic symbols of the logic, and
the rules for determining the meanings of nonatomic
expressions of the logic.
Proof Theory: The rules for determining a subset of logical
expressions, called theorems of the logic.
It decides how we can construct legal sentences in logic.
It determines which symbol we can use in knowledge representation. Also, how to write
those symbols.
Semantics are the rules by which we can interpret the sentence in the logic.
It assigns a meaning to each sentence.
Advantages:
Logical representation helps to perform logical reasoning.
This representation is the basis for the programming languages.
Disadvantages:
Logical representations have some restrictions and are challenging to work with.
This technique may not be very natural, and inference may not be very efficient.
2. Semantic Networks:
Semantic networks work as an alternative of predicate logic for knowledge representation. In
Semantic networks, you can represent your knowledge in the form of graphical networks. This
network consists of nodes representing objects and arcs which describe the relationship
between those objects. Also, it categorizes the object in different forms and links those objects.
This representation consist of two types of relations:
IS-A relation (Inheritance)
Kind-of-relation
Advantages:
Semantic networks are a natural representation of knowledge.
Also, it conveys meaning in a transparent manner.
These networks are simple and easy to understand.
Disadvantages:
Semantic networks take more computational time at runtime.
Also, these are inadequate as they do not have any equivalent quantifiers.
These networks are not intelligent and depend on the creator of the system.
3. Frame Representation:
A frame is a record like structure that consists of a collection of attributes and values to
describe an entity in the world. These are the AI data structure that divides knowledge into
substructures by representing stereotypes situations. Basically, it consists of a collection of slots
and slot values of any type and size. Slots have names and values which are called facets.
Advantages:
It makes the programming easier by grouping the related data.
Frame representation is easy to understand and visualize.
It is very easy to add slots for new attributes and relations.
Also, it is easy to include default data and search for missing values.
Disadvantages:
In frame system inference, the mechanism cannot be easily processed.
The inference mechanism cannot be smoothly proceeded by frame representation.
It has a very generalized approach.
4. Production Rule:
In production rules, agent checks for the condition and if the condition exists then production
rule fires and corresponding action is carried out. The condition part of the rule determines
which rule may be applied to a problem. Whereas, the action part carries out the associated
problem-solving steps. This complete process is called a recognize-act cycle.
The production rules system consists of three main parts:
The set of production rules
Working Memory
The recognize-act-cycle
Advantages:
The production rules are expressed in natural language.
The production rules are highly modular and can be easily removed or modified.
Disadvantages:
It does not exhibit any learning capabilities and does not store the result of the problem for
future uses.
During the execution of the program, many rules may be active. Thus, rule-based
production systems are inefficient
Approaches to Knowledge Representation in AI:
1. Simple Relational Knowledge:
It is the simplest way of storing facts which uses the relational method. Here, all the facts about
a set of the object are set out systematically in columns. Also, this approach of knowledge
representation is famous in database systems where the relationship between different entities
is represented. Thus, there is little opportunity for inference.
Example:
NAME AGE EMP ID
John 25 100071
Sam 23 100056
Joel 27 100063
2. Inheritable Knowledge:
In the inheritable knowledge approach, all data must be stored into a hierarchy of classes and
should be arranged in a generalized form or a hierarchal manner. Also, this approach contains
inheritable knowledge which shows a relation between instance and class, and it is called
instance relation. In this approach, objects and values are represented in Boxed nodes.
Example:
3. Inferential Knowledge:
The inferential knowledge approach represents knowledge in the form of formal logic. Thus, it
can be used to derive more facts. Also, it guarantees correctness.
Example:
Statement 1: John is a cricketer.
Statement 2: All cricketers are athletes.
Then it can be represented as;
Cricketer(John) ∀ x = Cricketer (x) ———-> Athelete (x)s
1.2.3 Why Reasoning?
Reasoning is the process of drawing conclusions from known facts. AI needs reasoning to solve
problems, make decisions, and handle uncertainty.
Key Reasons for Reasoning in AI:
1. Deriving New Knowledge:
AI can infer unknown facts from given data.
Uses deductive, inductive, and abductive reasoning.
Example:
Given: "All humans are mortal."
Given: "Socrates is a human."
AI infers: "Socrates is mortal."
2. Handling Uncertainty:
Many real-world problems involve incomplete or ambiguous data.
AI uses probabilistic reasoning to make the best possible decision.
Example:
A spam filter uses probability to decide whether an email is spam based on keywords and
sender history.
3. Decision-Making:
AI systems must choose optimal solutions based on available knowledge.
Used in automated planning, robotics, and AI assistants.
Example:
A self-driving car reasons whether to stop or accelerate based on traffic conditions.
4. Problem-Solving and AI Planning:
AI analyzes constraints and rules to find a solution to a given problem.
Used in pathfinding, logistics, and automated workflows.
Example:
Google Maps reasons the shortest route by analyzing traffic data.
5. Learning from Experience:
AI adapts over time by updating its knowledge and reasoning mechanisms.
Used in machine learning, recommendation systems, and fraud detection.
Example:
Netflix AI reasons about user preferences and improves recommendations based on past watch
history.
1.3 Role of Logic:
Logic is a fundamental tool in Knowledge Representation and Reasoning (KR&R). It provides a
formal structure for representing knowledge and ensures that reasoning processes are precise,
consistent, and reliable.
Logic is the study of correct reasoning.
It is not a particular KRR language.
There are many systems of logic (logics).
AI KRR research can be seen as a hunt for the “right” logic.
1.3.1 Why Logic is Important in AI:
Logic plays a critical role in AI by:
1. Providing a formal language – Expresses knowledge in a structured way.
2. Ensuring consistency – Prevents contradictions in knowledge.
3. Supporting automated reasoning – Enables AI to infer new facts.
4. Allowing verification – Helps check the correctness of conclusions.
1.3.2 Types of Logic Used in KR&R
1. Propositional Logic(PL):
The simplest form of logic, dealing with statements (propositions) that are either true or
false.
Uses logical operators like AND (∧ ), OR (∨ ), NOT (¬), and IMPLIES (→).
Example:
P: "It is raining."
Q: "The ground is wet."
Rule: P → Q (If it is raining, then the ground is wet).
Given P is true, we can conclude Q is also true.
2. First-Order Logic (FOL) (Predicate Logic):
Extends propositional logic by introducing objects, relations, and quantifiers.
More expressive than PL and widely used in AI.
Example:
∀ x (Human(x) → Mortal(x)) → "All humans are mortal."
Human(Socrates) → "Socrates is a human."
Since the first rule applies to all humans, we deduce Mortal(Socrates).
3. Description Logic (DL):
A subset of FOL used in ontologies and semantic web applications.
Represents knowledge using concepts, roles, and individuals.
Example:
Concept: Person
Role: hasParent
Fact: John hasParent Mary → Means "Mary is John's parent."
Used in healthcare, e-commerce, and intelligent search engines.
4. Modal Logic:
Deals with possibility and necessity (e.g., belief, knowledge, time, obligation).
Used in AI planning, game theory, and agent-based systems.
Example:
◇P → "It is possible that P is true."
□P → "It is necessarily true that P."
1.3.3 How Logic is Used in AI Systems:
Application Logic type used Example
Expert system First Order Logic Medical diagnosis, legal Al
Search engines Description Logic Google Knowledge Graph
Robotics Temporal and Modal Logic Robot motion planning
AI planning Propositional and Predicate Automated scheduling
Logic systems
Chatbots&NLP First Order and Probabilistic Siri, Alexa
Logic
These connectives helps to create logical rules that AI systems can use to make decisions.
1. AND ( ∧ ):
The result is True only if both propositions are true.
Example: If P is “It is hot” and Q is “The fan is on”, then (P ∧ Q) means both conditions are
satisfied.
2. OR ( ∨ ):
The result is True if at least one of the propositions is true.
Example: (P ∨ Q) will be true if either it is hot or the fan is on.
3. NOT ( ¬ ):
This inverts the truth value of the proposition.
Example: If P is true, ¬P will be false.
4. IF-THEN ( → ):
This implies that if the first proposition is true, the second must also be true for the compound
statement to be true.
Example: “If it rains, then the ground will be wet” (P → Q).
5. IF AND ONLY IF ( ↔ ):
This is true only when both propositions have the same truth value (either both true or both
false).
Example: “It is cloudy if and only if it will rain” (P ↔ Q).
Truth Table:
A truth table is a useful tool for determining the truth value of a compound proposition based on the
truth values of its atomic propositions. It systematically lists all possible combinations of truth values
and the corresponding output for a given logical expression.
How Truth Tables Work:
Let’s consider two propositions:
P: “It is raining.”
Q: “The ground is wet.”
We can build a truth table to evaluate the compound proposition P ∧ Q (It is raining AND the ground
is wet).
P: “It is hot.”
Q: “The air conditioner is on.”
R: “The windows are closed.”
We can create a truth table for the compound proposition (P ∨ Q) ∧ R (It is hot OR the air
conditioner is on, AND the windows are closed.
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.
Proof by Truth table:
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
Proof by Truth table:
3. Hypothetical Syllogism:
The Hypothetical Syllogism rule state that if P→R is true whenever P→Q is true, and Q→R is
true. It can be represented as the following notation:
If p → q and q → r, then p → r.
Example:
Statement-1: If you have my home key then you can unlock my home. P→Q
Statement-2: If you can unlock my home then you can take my money. Q→R
Conclusion: If you have my home key then you can take my money. P→R
Proof by truth table:
4. Disjunctive Syllogism:
The Disjunctive syllogism rule state that if P∨ Q is true, and ¬P is true, then Q will be true. It
can be represented as:
Example:
Statement-1: Today is Sunday or Monday. ==>P∨ Q
Statement-2: Today is not Sunday. ==> ¬P
Conclusion: Today is Monday. ==> Q
Proof by truth-table:
5. Addition:
The Addition rule is one the common inference rule, and it states that If P is true, then P∨ Q
will be true.It can be represented as:
Example:
Statement: I have a vanilla ice-cream. ==> P
Statement-2: I have Chocolate ice-cream.
Conclusion: I have vanilla or chocolate ice-cream. ==> (P∨ Q)
Proof by truth-table:
6. Simplification:
The simplification rule state that if P∧ Q is true, then Q or P will also be true. It can be
represented as:
Proof by truth-table:
7. Resolution:
The Resolution rule state that if P∨ Q and ¬ P∧ R is true, then Q∨ R will also be true. It can be
represented as:
Proof by Truth-Table:
A tuple (d1, d2, ..., dn) belongs to the relation I [P] if and only if the characteristic function
returns 1.
If P is a propositional symbol (arity 0), then I[P] is either 0 (false) or 1 (true).
Interpretation in Propositional Logic:
For the propositional subset of FOL:
The domain D is ignored.
The interpretation is simply a mapping from propositional symbols to 0 or 1.
This structured approach to interpretation in FOL allows us to formally assign meaning to logical
statements and evaluate their truth based on a given interpretation.
Example 1 :
Consider a simple domain D consisting of three people: {Alice, Bob, Charlie}.
Let Bigger Than(x, y) be a binary predicate representing "x is bigger than y".
Suppose I [BiggerThan] = (Dog, Cat), (Dog, Bird), (Cat, Bird), meaning Dog is bigger than
both Cat and Bird, and Cat is bigger than Bird.
Let sound(x) be a function mapping each animal to its characteristic sound.
Suppose I[sound]= (Dog," Bark"), (Cat," Meow"), (Bird, "Chirp")
Using this interpretation:
2. Check if Charlie is in I[Teacher] → Since Charlie ∈ {Alice, Charlie}, the formula is true.
Thus, Teacher(bestFriend(Bob)) is satisfied in this interpretation.
2. Satisfaction of Logical Connectives:
Given an interpretation (D, I, μ), we determine whether logical statements AND ( ∧ ), OR (
∨ ), NOT ( ¬ ) hold.
Example 2: Checking Logical Operators:
Let:
D = {1, 2, 3, 4}
I[Even(x)] = {2, 4} (i.e., 2 and 4 are even)
I[Odd(x)] = {1, 3} (i.e., 1 and 3 are odd)
Checking Satisfaction:
1. Even(2) ∧ Odd(2):
Even(2) is true because 2 is in {2, 4}.
Odd(2) is false because 2 is not in {1, 3}.
Since one part of the AND statement is false, Even(2) ∧ Odd(2) is false.
2. Even(2) ∨ Odd(2):
Even(2) is true.
Odd(2) is false.
Since at least one side is true, Even(2) ∨ Odd(2) is true.
3. ¬Even(2):
Even(2) is true.
So, ¬Even(2) is false.
3. Satisfaction of Quantified Formulas:
Quantified formulas involve ∀ (for all) and ∃ (there exists).
Example: Universal and Existential Quantification:
Consider a domain of students and teachers:
D = {Alice, Bob, Charlie}
I[isStudent] = {Alice, Bob} (Alice and Bob are students)
I[isTeacher] = {Charlie} (Charlie is a teacher)
Checking Universal and Existential Statements
1. ∀ x. isStudent(x):
Alice is a student (true).
Bob is a student (true).
Charlie is NOT a student (false).
Since one element (Charlie) makes the formula false, (D, I) ⊭ ∀ x. isStudent(x).
2. ∃ x. isStudent(x):
There exists at least one element in D (Alice or Bob) that satisfies isStudent(x).
Since Alice and Bob satisfy the condition, (D, I) |= ∃ x. isStudent(x).
4. Example of a Model:
A model satisfies all formulas in a given set S.
Example: A Logical Model
Let:
D = {0, 1, 2, 3, 4, 5}
I[LessThan(x, y)] = { (0,1), (1,2), (2,3), (3,4), (4,5) } (Defines a natural number order)
Consider the set S:
1. ∀ x ∃ y. LessThan(x, y)
For x = 0, y = 1 satisfies LessThan(0,1).
For x = 1, y = 2 satisfies LessThan(1,2).
For x = 4, y = 5 satisfies LessThan(4,5).
But for x = 5, there is no y such that LessThan(5, y).
Since one value of x (x=5) makes the formula false, (D, I) ⊭ ∀ x ∃ y. LessThan(x, y).
Thus, (D, I) is not a model of S.
5. Logical Truth and Models:
If a formula is true in all possible models, it is logically valid (tautology).
If a formula is false in at least one model, it is not logically valid.
If a model satisfies a set of formulas S, we say (D, I) is a model of S.
Example: Checking Logical Truth
Let:
D = {0, 1, 2}
I[Equal(x, y)] means x and y are equal.
Consider the formula ∀ x. Equal(x, x):
For x = 0, Equal(0, 0) is true.
For x = 1, Equal(1, 1) is true.
For x = 2, Equal(2, 2) is true.
Since this is true for all x, we conclude:
(D, I) |= ∀ x. Equal(x, x)
This means ∀ x. Equal(x, x) is logically valid in this model.