Knowledge Representation
Knowledge Representation
decisions based on that knowledge. Just like humans use their knowledge to understand and
act in the world, AI systems need a method to understand information and use it to make
smart choices.
It is how to represent and structure information (knowledge) in a way that machines can use it
for reasoning, problem-solving, and decision-making.
Knowledge=Information +rules
1. Storing information about the world in a way that computers can understand.
2. Using that information to solve real-life problems, like diagnosing a medical issue
or chatting with people in a natural way.
Instead of just storing data in a database, Knowledge Representation helps AI learn from
experiences and data, enabling it to make better decisions in the future.
Types of knowledge
These types of knowledge make AI more versatile by enabling it to handle facts, perform
actions, choose methods, rely on useful rules of thumb, and understand relationships between
concepts.
Let's suppose if you met some person who is speaking in a language which you don't know,
then how you will able to act on that. The same thing applies to the intelligent behavior of the
agents.
As we can see in below diagram, there is one decision maker which act by sensing the
environment and using knowledge. But if the knowledge part will not present then, it cannot
display intelligent behavior.
● Facts are stored in a table format, showing relationships between entities. It’s
commonly used in databases with limited inference capabilities.
● Example:
Player1 65 23
Player2 58 18
● This approach uses logic to derive new facts from existing knowledge. It enables
reasoning based on rules and premises.
● Example:
o "Marcus is a man" and "All men are mortal" → Infer "Marcus is mortal."
Propositional Logic:-
Propositional logic is a type of logic that deals with statements, called propositions. These
statements can only be either true or false.
For example:
Alphabet set:-
In propositional logic, an alphabet refers to the collection of symbols used to form logical
expressions. These symbols can be divided into the following sets:
2. Logical Constant
● What it is:
Logical constants are fixed values that represent the truth values True (T) and False
(F).
● Examples:
o T: Always true.
o F: Always false.
● Usage:
Logical constants are used as default values in expressions, such as:
o P∨T=T (A proposition OR true is always true).
o P∧F=F (A proposition AND false is always false).
3. Two Parentheses
● What it is:
Parentheses ( and )are used to group logical expressions and ensure the correct order
of operations.
● Examples:
Consider the expression (P∨Q)∧R:
o The parentheses ensure that P∨Q is evaluated first, before applying ∧R.
● Usage:
Parentheses prevent ambiguity in complex expressions and follow the same priority
rules as in mathematics.
P↔Q=(P⟹Q)∧(Q⟹P).
This means:
atomic propositions and compound propositions are key concepts used to form and analyze
logical statements.
1. Atomic Proposition
1. Predicate: A predicate is a function that takes an argument (or multiple arguments)
and returns a truth value. It is like a statement that becomes true or false depending on
the values of its variables.
o Example:
▪ P(x) could represent "x is a student".
▪ If x = John, then P(John) becomes "John is a student".
2. Variables: These are symbols (like x, y, z) that represent an object in the domain. The
truth of a predicate depends on the value assigned to these variables.
3. Domain: The set of possible values that variables can take is called the domain (also
called the universe of discourse).
Quantifiers are used to express the extent to which a predicate or statement applies to the
variables in question.
Inference refers to the process of deriving new information or conclusions from existing facts
or evidence. In Artificial Intelligence (AI), inference helps the system generate logical
conclusions from known data.
Inference Rules:
Inference rules are logical guidelines or templates used to derive conclusions or proofs. In AI,
these rules are applied to create valid arguments or deduce information based on given
premises.
The basic concept of inference involves logical implications among propositions. Here are
key terms and examples related to inference rules:
P Q P → Q Modus Ponens
TT T T
TF F F
F T T -does not apply
P Q P → Q Modus Ponens
F F T -does not apply
P Q P → Q ¬Q ¬P Modus Tollens
TT T F F -
TF F T F T
F T T F T -
F F T T T -
T (It is raining) F (The ground is not wet) F T F - (Does not apply; P→Q is false)
F (It is not raining) T (The ground is wet) T F T - (Does not apply; Q is true)
F (It is not raining) F (The ground is not wet) T T T Yes (Applies; ( \neg P = \text{True})
Process:
Example of Unification:
Consider two expressions:
1. P(X, Y)
2. P(a, b)
To unify these two expressions, we look for a substitution that makes both expressions
identical.
● Here, X can be unified with a and Y can be unified with b.
● So, the unification result would be the substitution:
o {X -> a, Y -> b}
If we apply this substitution to father(X, Y), we get father(a, b), which matches the second
term.
Resolution:
Resolution is a rule of inference used in propositional logic and first-order logic. It is a
method for deriving a conclusion from a set of premises by eliminating variables through
unification.
In logic, resolution is typically used in conjunctive normal form (CNF), where all logical
expressions are expressed as a conjunction of disjunctions.
Key Points:
Process of Resolution:
Example of Resolution:
Let's consider two clauses:
● P(X) ∨ R(X)
In this case:
Key Purpose: Helps in categorizing and defining concepts based on generalization and
specialization.
2. Assertional Networks
Assertional networks represent specific facts or assertions about individual instances of
concepts. These networks describe properties or attributes related to particular entities.
Example:
● "Rex is a Dog."
● "Rex has Brown Fur."
In this case:
● "Rex" is an individual instance, and the assertion is that Rex is a member of the
concept "Dog."
● It also asserts that "Rex" has a particular property (brown fur).
Key Purpose: Used to describe specific attributes or facts about individual entities.
3. Implicational Networks
Implicational networks represent logical implications between concepts. They focus on how
certain relationships imply other knowledge, allowing AI systems to infer new facts from
existing ones.
Example:
Here, the implicational network uses the relationship that "All Dogs are Mammals" to infer
that if "Rex is a Dog," then "Rex must also be a Mammal."
Key Purpose: Allows logical reasoning and the ability to infer new knowledge from existing
facts.
4. Executable Networks
Executable networks represent procedural knowledge. The relationships in these networks
include actions or sequences of events that can be executed or carried out by an AI system.
Example:
In this case:
5. Learning Networks
Learning networks are dynamic networks that evolve over time as the system learns new
information. They update their relationships and nodes based on new data or experiences,
allowing the AI system to adapt.
Example:
● A learning network may update its knowledge about "Dog" as it encounters new
breeds or traits.
As the system learns more about the concept of "Dog," it could include new attributes such as
specific breed types or behaviors.
Key Purpose: Used to represent evolving knowledge that changes with experience and new
data.
6. Hybrid Networks
Hybrid networks combine elements from two or more types of semantic networks, allowing
for a more complex and versatile representation of knowledge. These networks can
represent both the general structure of concepts and specific facts or relationships.
Example:
Key Purpose: Provides a flexible and detailed representation of knowledge that can address
multiple needs (e.g., definitions and specific instances).
Frames in AI
Frames are a data structure used in Artificial Intelligence (AI) to represent knowledge about
the world. A frame is a collection of attributes or properties, called slots, that describe an
object or concept, along with the values these attributes can take. Frames are particularly
useful for representing structured knowledge, like how we think about objects in the world.
Frames are similar to objects in object-oriented programming (OOP), where each frame
represents a concept or object, and the slots represent its features or properties. This allows
the AI system to organize knowledge in a way that is easy to understand and manipulate.
Structure of a Frame:
Example:
Imagine representing a "Car" in a frame:
In this example, the frame represents a "Car" object, and the slots describe various attributes
of that car.
Exception Frames
Exception frames are a type of frame used to represent special cases or exceptions to general
rules. They are used when there is a need to handle exceptions or special conditions that do
not conform to the default or usual behavior represented by the general frames.
Example:
Imagine a frame for a "Bird" object, which is typically used to represent general birds.
However, an exception could be made for a penguin, which is a type of bird that cannot fly.
In this case, we create an exception frame for the penguin:
Here, the "Penguin" frame represents an exception to the general "Bird" frame, where the
property Can Fly is overridden by the specific case of the penguin.
Key Purpose of Exception Frames: To handle cases where the normal rules do not apply,
allowing AI systems to account for special conditions or exceptions to general knowledge.
Default Frames
Default frames are used to represent general assumptions or typical behavior that can be
applied unless explicitly overridden. They provide default values for attributes or properties
that can be assumed to be true in the absence of specific information.
Example:
Let’s consider a "Person" frame:
However, there may be a situation where we need to represent a Person with no hair, such as
a bald person. In this case, the default assumption that the person has hair would be
overridden:
In this case, the default frame for "Person" assumes the presence of hair, but the "Bald
Person" frame provides a specific override for the Has Hair slot.
Key Purpose of Default Frames: To provide initial or default values that can be applied
unless there is specific information to override them. It helps the system avoid redundancy
when many objects share similar attributes.
Exception Handle special cases where normal rules "Penguin" frame overrides the "Can
Frames don't apply. Overriding default behavior. Fly" property of the "Bird" frame.
.
Inconsistent and Incomplete Knowledge:
Truth Maintenance Systems
A truth maintenance system (TMS) in artificial intelligence is designed to manage and
maintain the consistency of beliefs and knowledge within a reasoning system. It keeps track
of dependencies between propositions, allowing a system to retract beliefs when the
supporting evidence changes, thereby ensuring that the knowledge base remains consistent.
Concept of Uncertainty
Uncertainty in AI refers to the difficulty in accurately predicting outcomes due to incomplete
knowledge, variability in data, or inherent randomness in systems. It can stem from various
sources such as measurement errors, model limitations, and unpredictability in the
environment. Handling uncertainty is crucial for making reliable predictions and decisions in
AI applications.
Reasoning refers to the process of drawing conclusions from available information or facts.
In Artificial Intelligence (AI), reasoning is the mechanism that allows machines to simulate
human cognitive abilities, such as problem-solving, decision-making, and inference
generation. AI systems need to reason in order to understand the world, make decisions,
and predict outcomes based on evidence or knowledge.
Reasoning is often categorized into different types based on the structure and process of how
the reasoning is performed. The two primary types of reasoning are deductive reasoning and
inductive reasoning. These types can further be broken down into various sub-categories,
each serving a distinct purpose
Deductive Reasoning
2. Inductive Reasoning
3. Abductive Reasoning
● Definition: Abductive reasoning infers the best or most likely explanation for a set of
observations. It is used when there is incomplete information.
● Approach: Hypothesis-driven.
● Example:
o Observation: The ground is wet.
o Possible Explanation 1: It rained.
o Possible Explanation 2: Someone watered the garden.
o Best Explanation: It probably rained.
4. Analogical Reasoning
5. Monotonic Reasoning
6. Probabilistic Reasoning
Bayes’ Theorem
Bayes' theorem, also known as Bayes' rule or Bayes' law, is a fundamental concept in
probability theory and statistics. It provides a way to update the probability of a hypothesis
based on new evidence. This theorem is named after Reverend Thomas Bayes and has
significant applications in artificial intelligence (AI) and machine learning.
Bayes' theorem allows updating the probability prediction of an event by observing new
information of the real world.
Example: If cancer corresponds to one's age then by using Bayes' theorem, we can determine
the probability of cancer more accurately with the help of age.
Bayes' theorem can be derived using product rule and conditional probability of event A with
known event B:
The above equation (a) is called as Bayes' rule or Bayes' theorem. This equation is basic of
most modern AI systems for probabilistic inference.
It shows the simple relationship between joint and conditional probabilities. Here,
P(A|B) is known as posterior, which we need to calculate, and it will be read as Probability
of hypothesis A when we have occurred an evidence B.
P(B|A) is called the likelihood, in which we consider that hypothesis is true, then we
calculate the probability of evidence.
P(A) is called the prior probability, probability of hypothesis before considering the
evidence
In the equation (a), in general, we can write P (B) = P(A)*P(B|Ai), hence the Bayes' rule can
be written as:
Where A1, A2, A3,........, An is a set of mutually exclusive and exhaustive events.
Question: what is the probability that a patient has diseases meningitis with a stiff neck?
Given Data:
A doctor is aware that disease meningitis causes a patient to have a stiff neck, and it occurs
80% of the time. He is also aware of some more facts, which are given as follows:
P(a|b) = 0.8
P(b) = 1/30000
P(a)= .02
Hence, we can assume that 1 patient out of 750 patients has meningitis disease with a stiff
neck.
Example-2:
Question: From a standard deck of playing cards, a single card is drawn. The
probability that the card is king is 4/52, then calculate posterior probability
P(King|Face), which means the drawn face card is a king card.
Solution:
o It is used to calculate the next step of the robot when the already executed step is
given.
o Bayes' theorem is helpful in weather forecasting.
o It can solve the Monty Hall problem.