Artificial Intelligence-UNIT-3
Artificial Intelligence-UNIT-3
Unit-3
Knowledge Representation
Definition:
Knowledge representation in AI refers to the methods used to encode information about
the world into a format that an AI system can understand and use to make decisions. It is a
crucial component of AI that bridges the gap between raw data and meaningful reasoning.
By representing knowledge in a structured way, AI systems can interpret data, draw
inferences, and apply reasoning techniques to solve problems.
What to Represent:
In AI, what to represent refers to the types of knowledge that an AI system must
understand and manipulate to perform tasks effectively. The types of knowledge
represented can vary depending on the application and the problem the AI is trying to
solve. Below are key types of knowledge that are typically represented in AI systems:
AI systems often need to represent physical or abstract objects (e.g., cars, people, concepts)
and their properties (e.g., color, size, name). For instance, a self-driving car needs to
understand the entities on the road such as vehicles, pedestrians, and traffic signs.
Events (what happens) and actions (what the AI can do) are essential in dynamic
environments. For example, in a game AI, knowledge about player moves and game events
is crucial for making strategic decisions.
AI often needs to represent relationships between objects, such as “is a part of” or “is
related to.” Hierarchical relationships are especially useful in complex systems where
different levels of abstraction are involved (e.g., a dog is a type of animal).
4. Facts and Rules
Facts represent specific pieces of information, while rules define the logic that governs how
facts are used. For example, an expert system might use the rule “If a patient has a fever
and a sore throat, they may have the flu” to make a diagnosis.
5. Uncertainty
Real-world knowledge often involves uncertainty. AI systems need to represent and reason
with uncertain knowledge, such as predicting stock prices or diagnosing medical conditions
based on incomplete or noisy data.
1. Declarative Knowledge
What it is: This type of knowledge refers to facts or statements that describe the world,
often in the form of “knowing what.” It is static and doesn’t involve actions or procedures.
2. Procedural Knowledge
What it is: Procedural knowledge describes “how” to perform tasks or solve problems. It is
dynamic and action-oriented, focusing on processes and methods.
Example: Knowing how to solve a mathematical equation or how to bake a cake are
examples of procedural knowledge.
3. Structural Knowledge
What it is: This type of knowledge deals with the relationships between entities or
concepts, organizing knowledge into structures like hierarchies or networks.
Example: Understanding that a dog is a type of animal and a poodle is a type of dog reflects
structural knowledge.
4. Meta Knowledge
5. Heuristic Knowledge
Example: A heuristic might be “If a website loads slowly, refresh the page” — it’s not
always guaranteed to work, but it’s often useful.
1. Perception
Description: The process begins with AI systems perceiving data from their environment.
This data could come from sensors, cameras, user inputs, or databases.
Example: A self-driving car uses sensors to perceive its surroundings, such as detecting
pedestrians and other vehicles.
2. Learning
Description: After perceiving data, the system learns by identifying patterns, relationships,
and trends from the data. This can involve supervised learning, unsupervised learning, or
reinforcement learning techniques.
Example: An AI algorithm can learn from historical sales data to predict future trends,
helping businesses make data-driven decisions.
Description: In this stage, the system organizes the learned data into structured
knowledge, allowing it to reason and draw conclusions. This is where the AI uses
knowledge representation techniques to encode the information it has learned.
Description: The system uses the represented knowledge to plan actions based on goals
and constraints. Planning involves selecting the best course of action based on the available
knowledge.
Example: In robotics, AI systems use planning to determine the most efficient path for a
robot to navigate through a room while avoiding obstacles.
5. Execution
Description: Finally, the system executes the planned actions, completing the cycle. After
execution, the AI system can receive feedback and adjust its knowledge and actions
accordingly.
Example: A robot executing the planned actions to pick up and move objects based on the
knowledge it has about the environment.
Cognitive science studies how humans represent knowledge and use it to solve problems.
AI systems often draw inspiration from cognitive science, simulating human reasoning
processes through knowledge representation techniques such as semantic networks,
frames, and production rules. This alignment between cognitive science and AI enhances
our ability to build intelligent systems that mimic human thought processes.
The ability to reason—drawing conclusions from known facts and rules—is a hallmark of
intelligence in both humans and AI. AI systems that possess knowledge can perform logical
reasoning, make inferences, and predict outcomes. This capability is critical for
applications like medical diagnosis, autonomous driving, and financial forecasting.
1. Logical Representation
Example: In an expert system for medical diagnosis, logical statements like “If a patient has
a fever and a cough, then they might have the flu” can be represented as rules using
propositional logic or predicate logic.
Strengths: Logical representations are precise and allow for powerful inference
mechanisms.
Weaknesses: They can be rigid and may not handle uncertainty or incomplete information
well.
Example: A semantic network for animals might include nodes representing “dog,”
“mammal,” and “animal,” with edges showing hierarchical relationships (e.g., “A dog is a
mammal”).
Weaknesses: Can become complex and difficult to manage as the network grows.
3. Frame Representation
Strengths: Frames are effective for representing structured, hierarchical knowledge and
allow easy modification or extension of attributes.
4. Production Rules
Description: Production rules consist of “if-then” statements that define actions based on
conditions. This method is often used in rule-based systems and expert systems.
Example: “If the temperature is above 30°C, then turn on the air conditioning” is a simple
production rule that can guide the behavior of a thermostat system.
Strengths: Simple and intuitive, production rules are effective in systems that need to
apply a set of predefined rules for decision-making.
Weaknesses: Can lead to rule conflicts and may become unmanageable in large systems
with numerous rules.
Description: This approach represents knowledge as simple facts in the form of relations
between entities. It uses tables or relational databases to store information about objects
and their relationships.
Example: A table in a database could store the relationship between students and their
courses, with columns for student names, course names, and grades.
2. Inheritable Knowledge
Description: Inheritable knowledge uses hierarchies and inheritance to represent general
and specific information about objects. This approach allows entities to inherit properties
from higher-level categories.
Example: In a knowledge base, a “dog” might inherit properties from the more general
category “mammal,” such as being warm-blooded and having fur.
Weaknesses: Can be challenging to represent exceptions or unique cases that don’t follow
the inheritance structure.
3. Procedural Knowledge
Example: An AI system for controlling a robot might use procedural knowledge to define
the steps required for the robot to pick up an object: locate the object, move towards it, and
grip it with an arm.
Strengths: Useful for automating tasks and guiding AI systems through well-defined
procedures.
Weaknesses: Not suitable for tasks requiring complex reasoning or flexible decision-
making.
4. Inferential Knowledge
Description: This approach involves representing knowledge in a way that allows the AI to
infer new information from existing facts and rules. Logical reasoning is applied to draw
conclusions.
Example: Given the facts “All humans are mortal” and “Socrates is a human,” an AI system
using inferential knowledge can infer that “Socrates is mortal.”
1. Representational Adequacy
Description: The system must be able to represent all relevant knowledge about the
domain effectively. This includes facts, relationships, and rules that are necessary for
reasoning and decision-making.
Example: In a medical diagnosis AI, the system must represent knowledge about
symptoms, diseases, and treatments in a way that allows for accurate diagnosis.
Challenge: Ensuring that the system can accommodate the vast and diverse knowledge of a
domain without becoming too complex.
2. Inferential Adequacy
Description: The system should be able to generate new knowledge by applying inference
mechanisms, such as deduction, induction, or abduction, to the represented knowledge.
Example: An AI system might use inferential reasoning to deduce that a person with a high
fever and sore throat likely has the flu based on existing rules and facts.
Challenge: Developing efficient algorithms that can handle large datasets while providing
fast and accurate inferences.
3. Inferential Efficiency
Description: The system must be capable of making inferences quickly and efficiently. It
should use resources such as memory and processing power in an optimal manner.
Example: A financial AI needs to infer stock market trends in real time to make investment
decisions, requiring both speed and accuracy in its inferences.
Challenge: Balancing the complexity of inferences with the need for rapid decision-making,
especially in time-sensitive applications.
4. Acquisitional Efficiency
Description: The system must be able to easily acquire and integrate new knowledge as it
becomes available. This includes updating existing knowledge structures and incorporating
new data without disrupting the system.
Example: An AI system designed for customer service should be able to incorporate new
FAQs and policies dynamically as the business evolves.
Challenge: Ensuring that the system remains scalable and adaptive as new knowledge is
continuously added over time.
5. Consistency
Description: The knowledge representation system must maintain consistency across all
facts, rules, and relationships. Inconsistent or contradictory information can lead to
incorrect reasoning and unreliable results.
Example: In an AI system for legal reasoning, if the system contains contradictory laws or
regulations, it may struggle to provide accurate legal advice.
Challenge: Ensuring that as the knowledge base grows, mechanisms are in place to detect
and resolve inconsistencies.
Predicate logic, also known as first-order logic (FOL), extends propositional logic by
allowing AI systems to represent relationships between objects and their properties. This
makes predicate logic a powerful tool for knowledge representation and reasoning. It
enables AI systems to understand relationships like “John is the father of Mary” or “All
humans are mortal.”
In AI, propositional logic forms the foundation for logical reasoning, allowing systems to
represent facts and rules about a problem domain. These rules help the system infer new
information or make decisions based on the given inputs.
Propositional logic simplifies knowledge representation by breaking down reasoning
into atomic statements or propositions. For example, an AI system used in home
automation might have propositions such as:
Using logical connectives, the system can combine these propositions to represent more
complex statements like:
“If the light is on and the window is open, turn off the light.”
By using propositional logic, AI systems can reason effectively and perform tasks
like automated decision-making, knowledge representation, and game playing.
Example:
2. Atomic Propositions:
These are simple, indivisible statements that cannot be broken down further. Each atomic
proposition represents a basic fact or condition.
3. Compound Propositions:
Multiple atomic propositions can be combined using logical connectives (like AND, OR,
NOT) to create compound propositions.
Every proposition has a binary truth value: it can only be True (1) or False (0). There are
no intermediate states. This simplicity makes propositional logic ideal for clear-cut
decisions.
5. Logical Connectives Combine Propositions:
Logical connectives such as AND, OR, NOT, IF-THEN, and IF AND ONLY IF allow us to create
more complex propositions from simple ones.
The syntax of propositional logic defines the rules for creating valid propositions. In
propositional logic, we combine atomic propositions using logical connectives to form
more complex statements, known as compound propositions.
Atomic Propositions:
Example:
P: “It is raining.”
Logical Connectives:
IF-THEN ( → ): True unless the first proposition is true and the second is false.
IF AND ONLY IF ( ↔ ): True if both propositions have the same truth value.
Compound Propositions:
These are more complex statements formed by connecting atomic propositions using
logical connectives.
Example:
“If it is raining and the heater is on, then the room will be warm.”
P: “It is raining.”
Let’s explore a real-world scenario where propositional logic is applied in AI. Consider a
home automation system that needs to decide whether to turn on the air conditioner based
on the weather conditions and indoor temperature.
Scenario:
Using propositional logic, we can represent the system’s decision-making with the
following compound proposition:
(P∧¬Q)→R
“If it is hot outside AND the windows are not open, then turn on the air conditioner.”
AND ( ∧ ) ensures that both conditions must be true (hot outside and windows closed) for
the air conditioner to turn on.
IF-THEN ( → ) states that if the first part is true, the second part (turning on the AC) will
follow.
True unless the first is true and (P → Q): “If it rains, then it will
IF-THEN →
second is false. flood.”
IF AND ONLY True if both propositions are either (P ↔ Q): “It rains if and only if
↔
IF true or false. it is cloudy.”
These connectives allow us to create logical rules that AI systems can use to make
decisions. Let’s take a quick look at how each works:
1. AND ( ∧ ):
2. OR ( ∨ ):
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.
P: “It is raining.”
We can build a truth table to evaluate the compound proposition P ∧ Q (It is raining AND
the ground is wet).
P Q P∧Q
P: “It is hot.”
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).
P Q R (P ∨ Q) ∧ R
They ensure correct reasoning by listing all possibilities, making them a vital tool
for AI systems that rely on logical reasoning.
Precedence of Connectives in Propositional Logic
When evaluating compound propositions with multiple logical connectives, it’s important
to follow a specific order of precedence to ensure accurate results. Similar to arithmetic
operations, logical operators are evaluated in a defined sequence, from highest to lowest
precedence.
Order of Precedence
¬P∨(Q∧R)
The final result depends on the proper evaluation order, ensuring the correct outcome.
To avoid ambiguity, it’s good practice to use parentheses in complex expressions. For
example:
(P∨Q)→R
P≡Q
This means that both P and Q yield identical truth values for all possible cases. Logical
equivalence allows AI systems to simplify complex expressions without changing their
meaning.
1. De Morgan’s Laws:
¬(P∧Q)≡(¬P∨¬Q)
¬(P∨Q)≡(¬P∧¬Q)
2. Double Negation:
¬(¬P)≡P
P→Q≡¬P∨Q
Tautology:A tautology is a statement that is always true, no matter the truth values
of its individual propositions.
Example: P∨¬P≡True
Example: P∧¬P≡False
1. De Morgan’s Laws
These laws describe how negations distribute over AND ( ∧ ) and OR ( ∨ ) operations:
First Law:
¬(P∧Q)≡(¬P∨¬Q)
This means that the negation of a conjunction is equivalent to the disjunction of the
negated propositions.
Second Law:
¬(P∨Q)≡(¬P∧¬Q)
This means that the negation of a disjunction is equivalent to the conjunction of the
negated propositions.
2. Commutative Property
This property states that the order of the propositions does not affect the result of AND
( ∧ ) and OR ( ∨ ) operations:
AND:
P∧Q≡Q∧P
OR:
P∨Q≡Q∨P
3. Associative Property
AND:
(P∧Q)∧R≡P∧(Q∧R)
OR:
(P∨Q)∨R≡P∨(Q∨R)
4. Distributive Property
This property states that AND distributes over OR, and vice versa:
P∧(Q∨R)≡(P∧Q)∨(P∧R)P
OR over AND:
P∨(Q∧R)≡(P∨Q)∧(P∨R)
AI agents use logical rules to make decisions (e.g., robot vacuum cleaners deciding
when to start cleaning).
Helps analyze text and respond logically (e.g., chatbots understanding weather-
related queries).
4. Game-Playing AI:
2. No Handling of Uncertainty
It works only with true or false values and cannot deal with probabilities or
uncertain outcomes, limiting its use in real-world applications involving
incomplete data.
3. Limited Expressiveness
It cannot represent time-based sequences or dynamic events, which are crucial in
some AI systems like speech recognition and robotics.
4. Scalability Issues
Predicate logic, also known as first-order logic (FOL), is an extension of propositional logic
that allows us to express relationships between objects and their properties. In AI,
predicate logic is widely used to represent knowledge and perform reasoning in more
complex scenarios where relationships matter.
Unlike propositional logic, which deals with simple true/false statements, predicate logic
introduces predicates, variables, constants, and quantifiers. These elements help in
modeling real-world problems that involve multiple objects and their interactions.
Reasoning: AI systems use predicate logic to infer new information from existing
facts, making it suitable for decision-making tasks.
Example:
This expression tells us that there is a relationship (Father) between two objects (John
and Mary). Predicate logic enables us to model and reason about such relationships
effectively.
Components of Predicate Logic:
1. Predicates:
A predicate is a function that returns either true or false based on the relationship
between its arguments.
2. Variables:
Variables are placeholders for objects within a domain. They allow us to represent
general statements that apply to multiple objects.
3. Constants:
Structure of Predicates
Predicate consists of two key elements: the predicate symbol and arguments. Predicates
are enhanced with quantifiers to specify the scope of variables involved.
1. Predicate Symbol
Example:
Predicates are named based on the relationship or property they represent. The
symbol is followed by arguments enclosed in parentheses.
Examples:
X(a, b, c): A predicate with 3 arguments (arity = 3), representing something like “a
+ b + c = 0.”
Quantifiers allow us to specify the scope of variables. There are two main types:
1. Existential Quantifier ( ∃ )
Meaning: There exists at least one object that satisfies the given condition.
Example: ∃x IsHungry(x)
This statement means that at least one person is hungry.
2. Universal Quantifier ( ∀ )
Meaning: The given condition holds for all objects in the domain.
Example: ∀x (IsHuman(x)→IsMortal(x))
This means that all humans are mortal.
Predicate: IsHungry(John)
Meaning: This predicate represents the state of whether John is hungry. It
takes one argument (John) and returns true if John is hungry, otherwise
false.
Application in AI:
In NLP-based chatbots, predicates like this could help infer the user’s intent.
For example, if a chatbot detects that the user is hungry, it could suggest
nearby restaurants.
Predicate: E(x,y)≡(x=y)
Application in AI:
Predicate: X(a,b,c)≡(a+b+c=0)
Meaning: This predicate checks whether the sum of a, b, and c equals zero. It
returns true if the equation holds, otherwise false.
Application in AI:
Application in AI:
In family tree AI systems, relationship predicates are used to infer
relationships among family members. For instance, if M(John, Mary) is
true, the system can infer that John is Mary’s spouse.
Expression: ∀x (IsHuman(x)→IsMortal(x))
Application in AI:
Expression: ∃x IsHungry(x)
Meaning: This reads as “There exists at least one x such that x is hungry.”
It indicates that at least one object in the domain satisfies the condition of
being hungry.
Application in AI:
Application in AI:
This logic is often used in social network AI models to analyze
relationships. In a family tree system, the model could use such logic to
infer relationships between family members.
In predicate logic, multiple quantifiers can be used within a single proposition to express
more complex ideas. The order of quantifiers is crucial, as it can change the meaning of
the statement.
∀x∃y (Parent(x,y))
Meaning: For every person x, there exists at least one person y such that x is the
parent of y.
Example in AI: In a family tree system, this could represent the rule that every
parent must have at least one child.
∃y∀x (Parent(x,y))
Meaning: There exists a person y such that every person x is the parent of y.
∀x∃y (RobotCanPerform(x,y))
Meaning: For every task x, there exists a robot y that can perform the task.
∃y∀x (RobotCanPerform(x,y))
AI Application: This would imply that a single robot can perform all tasks, which
may not always be practical.
Impact of Quantifier Order on Meaning
As seen in the examples above, changing the order of quantifiers can completely change
the meaning of a proposition. In AI systems, it’s essential to use the correct order of
quantifiers to ensure that logical statements align with the desired behavior or knowledge
representation.
Knowledge representation is a critical part of AI, enabling systems to store, reason, and
derive new facts from existing information. Predicate logic offers a structured way to
represent complex relationships, facts, and rules in a logical and understandable format.
Example: Married(John,Mary)
AI systems can use inference rules to derive new facts from stored
knowledge.
Robot Planning Systems: In a warehouse, robots use predicate logic to plan tasks
based on conditions like:
∃x TaskRequires(x,Charging)
Expert Systems:
Predicate logic is used in expert systems (like medical diagnosis tools) to store if-
then rules and infer new facts about diseases based on symptoms.
Quantifiers Supports existential (∃) and universal (∀) No quantifiers are used.
quantifiers.
Overview:
LISP was created by John McCarthy in 1958 and is one of the oldest high-level
programming languages.
It is primarily used for tasks that involve symbolic processing, AI, and machine
learning.
LISP is known for its powerful features for recursion, dynamic typing,
automatic garbage collection, and excellent support for functional
programming.
Key Features:
1. List-based syntax:
o LISP is named for its use of lists as its fundamental data structure. Programs
are written as nested lists (also called S-expressions), making it a very
flexible and compact way to express code.
2. Homoiconicity:
o In LISP, the code itself is written in the same structure as the data (i.e., lists).
This allows for code manipulation as data (metaprogramming), which is
very powerful for building macros or modifying behavior dynamically.
3. Recursive functions:
o LISP heavily utilizes recursion, making it particularly suited for problems
that involve complex structures like trees and graphs.
4. Dynamic Typing:
o LISP doesn't require you to specify types for variables or functions, allowing
for more flexibility in handling different kinds of data.
5. Garbage Collection:
6. Functional Programming:
Applications:
Overview:
Key Features:
1. Logic Programming:
2. Declarative Nature:
3. Backtracking:
4. Pattern Matching:
o PROLOG uses pattern matching to match data against facts or rules, allowing
for automatic reasoning based on predefined logic.
5. Knowledge Representation:
6. Unification:
Applications:
Theorem Proving: Used in mathematics and formal verification tasks to prove the
correctness of algorithms or systems.
Comparison of LISP and PROLOG:
Syntax Based on lists and S-expressions Based on facts, rules, and queries