Knowledge Representation in AI Agents
Knowledge Representation in AI Agents
Artificial Intelligence
Module 3 Knowledge Representation
Agents
Agent is Anything that perceives its environment through sensors and acts upon it
using actuators.
Types of Agents
1. Simple Reflex Agent – Acts on condition-action rules.
2. Model-Based Agent – Uses internal state to track world.
3. Goal-Based Agent – Chooses actions to achieve goals.
4. Utility-Based Agent – Maximizes performance measure.
5. Learning Agent – Improves performance with experience.
Problem-Solving Agent
• An agent that searches for solutions to reach a goal.
• Works in well-defined problems (start → actions → goal).
• Example: Solving a maze or 8-puzzle.
Example: A reflex agent may follow a rule like “If there is an obstacle → turn
left.”It will turn left when an obstacle appears, but it cannot explain why it did
so. It only acts, without giving reasons.
knowledge-based agent
There must be a way to add new sentences to the knowledge base (KB) and a way
to query what is known. The standard names for these operations are TELL (to add
information) and ASK (to query). Both operations may involve inference, which
means deriving new sentences from old. The agent’s answers must come only from
what it already knows, it should not guess.
Explanation
Wumpus World
• Wumpus World is a classic AI problem that teaches how agents can use
knowledge, logic, and inference to make safe decisions in a dangerous,
partially unknown environment.
• Wumpus World is a grid-based cave environment used in AI to test
knowledge-based agents.
• The agent starts at position [1,1] and tries to find the gold and escape safely.
• The world is partially observable, meaning the agent does not see everything
directly but must infer from clues.
• At the start [1,1], there is no danger → so the nearby squares [1,2] and [2,1]
are safe.
• The agent moves to [2,1] and feels a Breeze → so a pit is nearby (either at
[2,2] or [3,1]).
• The agent goes back and tries [1,2], feels a Stench → the Wumpus must be at
[1,3].
• Since there is no Breeze at [1,2], [2,2] must be safe → therefore the pit is at
[3,1].
• With this logic, the agent keeps moving safely until it finds Glitter (gold).
• It uses Grab to pick up the gold, then returns to [1,1] and uses Climb to escape.
In each case for which the agent draws a conclusion from the available information,
that conclusion is guaranteed to be correct if the available information is correct This
is a fundamental property of logical reasoning
1. Performance Measure
• +1000 → For climbing out of the cave with the gold.
• –1000 → For falling into a pit or being eaten by the Wumpus.
• –1 → For each action taken (to avoid unnecessary moves).
• –10 → For using the arrow.
• Game ends → When the agent dies or successfully climbs out.
2. Environment
• A grid of rooms (commonly 4×4 or 9×4).
• Agent always starts at [1,1], facing right.
• Locations of gold and Wumpus are chosen randomly (not in [1,1]).
• Each non-start square may contain a pit with probability 0.2.
4. Sensors (Percepts)
• Stench → Wumpus is in the same or adjacent square.
• Breeze → Pit is in an adjacent square.
• Glitter → Gold is in the current square.
• Bump → Agent walked into a wall.
• Scream → Wumpus has been killed (heard anywhere).
Logic
Propositional logic deals with simple statements that are either true or false, and it
helps in representing basic facts and rules. First-order logic (FOL) is more powerful,
allowing representation of objects, their properties, and relationships using
quantifiers like “for all” (∀) and “there exists” (∃). While propositional logic is
simple and easy to use, FOL can express complex knowledge and enable AI systems
to make more detailed inferences. These types of logic form the foundation for
logical agents to reason, solve problems, and make intelligent decisions.
Propositional logic
Propositional logic is used for solving complex problems using simple statements.
These statements can either be true or false but cannot be both at same time. These
propositions form knowledge representation, reasoning and decision-making in AI
systems.
Propositional logic works with statements called propositions, which can be either
true or false. These statements represent facts or conditions about a situation. We
use symbols for the propositions and logical operators to connect them. This helps
us understand how different facts are related.
Syntax of Propositional Logic
The syntax tells us how to form valid sentences in propositional logic.
• P: "It is raining."
• ¬P: "It is not raining."
[Link] (P ∧ Q) → P AND Q
3. Disjunction (P ∨ Q) → P OR Q
o True if at least one of P or Q is true.
4. Implication (P → Q) → If P then Q
o False only if P is true and Q is false.
• P: "It rains."
• Q: "The ground gets wet."
• P → Q: "If it rains, then the ground gets wet."
Logical Connectives
We use symbols to combine propositions into more complex statements.
• P ∧ Q: "The sky is blue AND it is raining." (This is true only if both P and Q
are true.)
• P ∨ Q: "The sky is blue OR it is raining." (This is true if at least one of P or
Q is true.)
• ¬P: "It is NOT true that the sky is blue." (This is true if P is false means the
sky is not blue.)
• Variables are symbols that can take several values inside a particular domain.
Commonly used symbols for variables are x,y,z. If the domain consists of
students, then x could represent any student in the class.
• Functions map elements to distinct values. They take arguments in the form
of input elements and return a single value as output. For example −
Age(Alice) = 25 → means "Alice's age is 25."
• Quantifiers tell whether a sentence is true for all objects in the domain or just
one. For example − xLikes(x,Math) → "All students like Mathematics." and
xLikes(x,Math) → "There exists at least one student who likes Mathematics."
• Logical connectives enable to logically combine numerous statements or
propositions. They allow complicated statements to be constructed from
simpler ones. For example −
CompletesTraining(x)→EligibleForPromotion(x). If an employee x
completes the required training, then they automatically become eligible for a
promotion.
Components Examples
Constants 1, 5, Apple, Bob, India
Variables x, y, z, a, b
Predicates Father, Teacher, Brother
Functions sqrt, LeftLegOf, AgeOf, add(x, y)
Quantifiers ∀ (for all), ∃ (there exists)
Connectives ∧ (and), ∨ (or), ¬ (not), → (implies), ↔ (if and only if)
The syntax of FOL describes the form of valid assertions by employing constants,
variables, predicates, functions, quantifiers, and logical connectives. Statements are
composed of words (which represent objects) and atomic formulae (which convey
facts).
The semantics of first-order logic (FOL) define the meaning of assertions by
interpreting predicates and words throughout a domain. An interpretation gives
real-world meaning to objects and relationships.
Example
The following example demonstrates how syntax and semantics are applied in
First-Order Logic (FOL) to represent a real-world statement −
• Consider a statement "Every customer who makes a purchase receives an
invoice".
• The FOL representation of the statement using syntax and semantics is as
follows x(Customer(x)Purchases(x,Product)→ReceivesInvoice(x))
• Thus, syntax defines the structure, and semantics give it meaning.
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 (x) which is
true if x is a cat. Similarly, let us take another predicate likes (x,y) which is true if x
likes y. Therefore, using the universal quantifier ∀, we can write
∀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 (x,y) , which is true if x likes y . Therefore, using the existential
quantifier ∃, we can write
∃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".
In First-Order Logic (FOL), sentences are used to represent facts and relationships.
These sentences can be classified into atomic sentences and complex sentences.
Atomic Sentences
An atomic sentence is the most basic form of a statement in First-Order Logic. It
consists of a predicate and arguments, which can be either constants or variables.
An atomic statement asserts a fact about things without using logical connectives.
Structure of Atomic Sentences: Predicate(Argument 1,Argument 2,...,Argument n)
where −
• The predicate represents a property or relationship.
• The arguments represent objects (constants or variables).
Example
The following example demonstrate the use of atomic sentences in First-Order
Logic to represent facts and relationships −
• Teacher(John, Mathematics) This atomic sentence states that John is a
teacher of Mathematics.
Complex sentence
Two or more atomic statements connected by logical connectives like AND, OR,
NOT (¬), Implies (→), and Bi-conditional create a complex sentence. These
sentences allow us to express more complex logical statements.
Example
The following examples demonstrate the use of complex sentences in First-Order
Logic to represent facts and relationships −
• (y Teacher(y) Teaches(y, Math)) "There exists at least one teacher who
teaches Mathematics."
• (x Customer(x) → Buys(x, TutorialsPointCourses)) "For all customers, if x
is a customer, then x buys courses from Tutorials Point."
• (y Employee(y) WorksFor(y, TutorialsPoint)) "There exists at least one
employee who works for Tutorials Point."
Ontological engineering
1. Individuals
Individuals represent the most basic and specific objects or entities in an ontology.
These are the instances of concepts defined within the ontology.
• Definition: Individuals are real-world objects, events, or entities.
• Example:
• In a healthcare ontology, an individual could be a specific patient
named “John Doe.”
• In an e-commerce ontology, an individual could be a product like
“iPhone 15.”
Use Case: Individuals help AI systems model specific data instances, such as
identifying a particular symptom, product, or user.
2. Classes
Classes are groups or sets of individuals that share common characteristics. They
represent concepts or categories in an ontology and help organize individuals
meaningfully.
• Definition: Classes define the categories to which individuals belong.
• Example:
• In a medical ontology:
• Class: Disease
• Individuals: “Diabetes,” “Hypertension.”
• In an e-commerce ontology:
• Class: Electronics
• Individuals: “Laptop,” “Smartphone.”
a) Primitive Classes
• Definition: These are the basic categories defined directly without depending
on other classes.
• They are fundamental building blocks in an ontology.
• They do not require rules or conditions from other classes to exist.
Examples:
• In a Medical Ontology:
o Disease, Patient, Doctor
o “Diabetes” belongs to the Disease class.
• In an E-commerce Ontology:
o Electronics, Clothing, Furniture
o “Laptop” belongs to the Electronics class.
b) Derived Classes
• Definition: These classes are formed based on conditions, restrictions, or
combinations of other classes.
• They depend on primitive classes and are often defined using logical rules.
Examples:
• In a Medical Ontology:
o Chronic Disease (Derived from Disease with the condition “long-
lasting”)
o “Diabetes” and “Hypertension” belong here.
• In an E-commerce Ontology:
o Discounted Electronics (Derived from Electronics + condition
“hasDiscount = true”)
o “Smartphone on sale” belongs here.
Relations
b)Associative Relations
Definition:
Axioms are logical statements that define rules, constraints, or truths within an
ontology. They ensure consistency and enable reasoning/inferencing.
Characteristics:
• Define domain rules.
• Prevent contradictions.
• Support reasoning engines.
Examples:
• All vehicles must have at least one engine.
• A person cannot be both a passenger and a driver of the same vehicle at the
same time.
Types of Axioms in Transportation Ontology:
1. Cardinality Axiom: Specifies number-based constraints.
o Example: A vehicle must have exactly four wheels.
2. Disjointness Axiom: Ensures concepts are mutually exclusive.
o Example: A person cannot be both a Driver and a Passenger for the
same trip.
3. Existence Axiom: Specifies that certain entities must exist or be linked.
o Example: Every bus must be assigned to at least one route.
Types of Ontologies
1. Informal Ontologies
Informal ontologies are the simplest type of ontology. They use natural language or
simple lists, glossaries, and taxonomies. They are easy for humans to read and
understand. For example, a list of animals grouped as mammals, birds, and reptiles,
or a glossary of terms, is an informal ontology. The limitation is that computers
cannot use them for reasoning, because they do not follow strict rules. They are
mainly used for organizing knowledge and explaining concepts to humans.
[Link] Ontologies
Formal ontologies are designed to be understood and processed by computers. They
use logic-based languages such as OWL (Web Ontology Language) or Description
Logics to represent knowledge in a structured and precise way. This structure allows
computers to automatically check for errors, discover new facts, and make logical
conclusions. Formal ontologies are more reliable than informal ontologies because
they follow strict rules and can be used in intelligent systems, AI applications, and
the semantic web.
a)Decidable ontologies
Decidable ontologies are simple and follow clear rules, so computers can easily
reason with them, check for mistakes, and infer new knowledge. An example is
OWL DL, which is widely used in AI and the semantic web. Decidable ontologies
are like clear instructions a computer can always follow without confusion.
b)Undecidable ontologies
Ontologies can also be categorized based on how broad or specific their knowledge
is, i.e., their scope or level of generality. This classification helps decide which
ontology to use depending on the application or domain. The main types are:
1. Upper Ontologies (Top-Level Ontologies)
• These provide very general concepts that are not tied to any specific domain.
• They describe basic categories such as time, space, objects, events, causality,
or relationships.
• They are useful because these general concepts can be reused across many
domains, ensuring consistency in knowledge representation.
• Simple explanation: Think of upper ontologies as the “skeleton” of
knowledge that can support any type of domain-specific information.
2. Reference Ontologies
• These provide standardized vocabularies and conceptual frameworks for
specific communities or fields.
• They ensure that knowledge is represented consistently and understood the
same way by everyone in that community.
• Example: Gene Ontology (GO) standardizes terms for biological processes,
molecular functions, and gene products in life sciences.
• Simple explanation: Reference ontologies are like an official dictionary or
handbook that everyone in a field agrees to use.
3. Domain Ontologies
• These focus on knowledge specific to a particular field or area of interest.
• They describe concepts, relationships, and rules relevant to that domain.
• Example: An ontology for the automobile industry might include concepts
like engines, vehicles, car models, and manufacturers.
• Simple explanation: Domain ontologies are like specialized guides for a
particular field, providing detailed knowledge for experts or systems.
4. Application Ontologies
• These are designed to support specific applications or tasks.
• They usually extend or refine domain ontologies to suit a particular system
or problem.
• Example: A medical diagnosis application might use an application ontology
that combines medical knowledge with rules to help reason about patient
cases.
• Simple explanation: Application ontologies are like customized toolkits that
adapt general or domain knowledge for a specific use case.
1. Complexity:
2. Ambiguity:
3. Scalability:
As ontologies grow in size, ensuring that they can handle large amounts of data
efficiently becomes difficult. Performance issues may arise when reasoning over or
querying very large ontologies.
Example: An e-commerce ontology for millions of products must remain fast for
search and recommendation queries.
4. Consistency:
Ontologies must avoid contradictions and maintain logical consistency. Adding new
concepts or relationships can inadvertently create conflicts with existing ones.
Example: If an ontology defines “All birds can fly” but later adds “Penguins are
birds,” consistency rules must handle exceptions.
Ontological Categories and objects
Physical Composition
Physical composition describes how an object is made up of smaller parts and their
arrangement, capturing “part–whole” relationships.
Example (Bicycle): A bicycle consists of a frame, wheels, pedals, chain, and seat.
Each part can be further broken down (e.g., a wheel has a rim, spokes, and tire).
Representing this in ontology helps in tasks like repair, assembly, or inventory
management.
Things: These are discrete, identifiable objects that exist independently and can be
counted. They have a distinct identity, meaning each “thing” can be distinguished
from another. Things are often what we interact with in daily life. In ontology,
representing things allows systems to reason about individual entities, their
properties, and relationships.
Example: Water, air, wood, and metal are considered stuff. A bicycle, for instance,
is made of metal, rubber, and plastic , the metal and rubber are the “stuff” that
composes the bicycle.
Importance: Including both things and stuff in an ontology allows for a complete
representation of the physical world. Things represent objects, while stuff represents
their material composition. This distinction is crucial in applications like robotics,
manufacturing, healthcare, or e-commerce, where understanding both the entity and
the materials it consists of improves reasoning, decision-making, and knowledge
sharing.
Time Interval: A period with a start and end (e.g., 2:00 PM to 3:00 PM)
Duration: The length of time something lasts (e.g., the meeting lasted 30 minutes)
Why does time matter in Al --- Scheduling systems, like calendar apps or delivery
systems, must manage time intervals and durations.
Fluents
Fluents in ontology are properties or conditions of entities that can change over
time. Unlike static properties (like a bicycle’s color or weight), fluents represent
dynamic aspects that may vary depending on circumstances or moments.
Why they are important:
1. Capture change: Many real-world scenarios involve states that evolve.
Fluents allow ontologies to represent these changes accurately.
2. Support reasoning: By modeling fluents, intelligent systems can predict
outcomes, detect state changes, or make decisions based on current
conditions.
3. Temporal understanding: Fluents are crucial for representing time-dependent
knowledge, such as a person’s location, a machine’s status, or a room’s
temperature.
Examples:
• A traffic light’s state (red, yellow, green)
• A patient’s health condition (stable, critical)
• A door’s status (open, closed)
fluents make ontologies dynamic, enabling systems to understand and reason about
changes over time, which is essential for applications like robotics, healthcare, and
event monitoring.
Sources of Uncertainty
In AI and agent systems, uncertainty arises from several factors in the environment
or the agent’s knowledge. The main sources are:
1. Partial Observability: The agent cannot see the entire state of the
environment.
Example: A robot navigating a room with obstacles it cannot fully detect.
2. Nondeterminism: Actions may have unpredictable outcomes.
Example: A robot trying to pick up a fragile object might sometimes drop it.
3. Incomplete Knowledge: The agent lacks full information about the world.
Example: A doctor diagnosing a patient without knowing all symptoms.
4. Ambiguity: The same observation can have multiple possible explanations.
Example: Seeing wet streets could mean it rained, or someone watered the
garden.
5. Dynamic Environment: The world can change independently of the agent’s
actions.
Example: Traffic conditions changing while a self-driving car is moving.
6. Sensor Noise: Sensors may give inaccurate or noisy readings.
Example: A robot’s camera may misread the position of an object due to
poor lighting.
Representing Uncertainty
In AI and ontology, uncertainty is represented so that agents can reason and make
decisions even when they don’t have complete or certain knowledge. Common
ways to represent uncertainty include:
[Link]
[Link] Logic