AIML_U2Notes
AIML_U2Notes
Topic
Sub-Topic
I. Knowledge Representation in AI
Knowledge representation (KR) in AI refers to encoding information about the world into
formats that AI systems can utilize to solve complex tasks. This process enables machines to
reason, learn, and make decisions by structuring data in a way that mirrors human
understanding.
AI systems operate on data. However, raw data alone does not lead to intelligence. AI must
transform data into structured knowledge. KR achieves this by defining formats and methods
for organizing information. With clear representations, AI systems solve problems, make
decisions, and learn from new experiences.
Types of Knowledge in AI
Declarative Knowledge (Descriptive Knowledge):
It consists of facts and information about the world that AI systems store and retrieve
when needed. It represents "what" is known rather than "how" to do something. Often
stored in structured formats like databases.
E.g. A fact such as "Paris is the capital of France"
Common-Sense knowledge
Common-sense knowledge represents basic understanding about the world that humans
acquire naturally but is challenging for AI to learn. It includes facts like "water is wet" or "if
you drop something, it will fall."
AI systems often struggle with this type of knowledge because it requires contextual
understanding beyond explicit programming.
Researchers are integrating common-sense reasoning into AI using large-scale knowledge
bases such as ConceptNet, which helps machines understand everyday logic and improve
their interaction with humans.
Domain-Specific Knowledge
Domain-specific knowledge focuses on specialized fields such as medicine, finance, law, or
engineering. It includes highly detailed and structured information relevant to a particular
industry.
E.g. In the medical field, AI-driven diagnostic systems rely on knowledge about symptoms,
diseases, and treatments.
Logical Representation: It is the basic method used to represent the knowledge of a machine. The
term logic means to apply intelligence over the stored knowledge. It is a language with some
concrete rules which deals with propositions and has no ambiguity in representation. Each sentence
can be translated into logics using syntax and semantics.
A. Propositional Logic
Propositional logic, also known as propositional calculus, statement logic, or sentential logic, is a
fundamental method of knowledge representation in artificial intelligence. It is used to represent and
process information about what is true and what is false.
Applies Boolean logic to convert real-world data into a computer-readable format. Expresses
knowledge in logical and mathematical terms.
Basic Concepts:
A proposition is a declarative statement that can be either true or false, but not both at the same
time.
Example:
"It is raining" → P
"The sky is blue" → Q
Non-Propositions:
Types of Propositions
1. Atomic Propositions
These are simple assertions that contain only one proposition and must be either true or false.
• Example:
o "2 + 2 = 4" → True (✔)
o "The Sun is cold" → False (✘)
2. Compound Propositions
• Example:
o "It is raining today, and the street is wet."
o "Ankit is a doctor, and his clinic is in Mumbai."
Logical connectives (also called logical operators) are used to link two or more propositions to form
compound statements.
B. First-Order Logic:
First-order logic (FOL), also known as predicate logic, is a powerful formalism used
for knowledge representation in artificial intelligence and computer science. It extends
propositional logic by allowing the use of quantifiers and predicates, enabling the
representation of complex statements about objects and their relationships. Here are the key
components and concepts of knowledge representation in first-order logic:
Key Components of First-Order Logic
1. Constants:
• Definition: Constants are symbols that represent specific objects in the domain.
• Examples: If a, b, and c are constants, they might represent specific individuals like
Alice, Bob, and Charlie.
2. Variables:
• Definition: Variables are symbols that can represent any object in the domain.
• Examples: Variables such as x, y, and z can represent any object in the domain.
3. Predicates:
• Definition: Predicates represent properties of objects or relationships between
objects.
• Examples: P(x) could mean "x is a person", while Q(x, y) could mean "x is friends
with y".
4. Functions:
• Definition: Functions map objects to other objects.
• Examples: f(x) could represent a function that maps an object x to another object,
like "the father of x".
5. Quantifiers:
• Universal Quantifier (∀): Indicates that a statement applies to all objects in the
domain. For example, ∀x P(x) means "P(x) is true for all x".
• Existential Quantifier (∃): Indicates that there exists at least one object in the
domain for which the statement is true. For example, ∃x P(x) means "There exists an
x such that P(x) is true".
6. Logical Connectives:
• Definition: These include ∧ (and), ∨ (or), ¬ (not), → (implies), and ↔ (if and only if).
• Examples: P(x) ∧ Q(x, y) means "P(x) and Q(x, y) are both true".
7. Equality:
• Definition: States that two objects are the same.
• Examples: x = y asserts that x and y refer to the same object.
Syntax of First-Order Logic
The syntax of FOL defines the rules for constructing well-formed formulas:
• Atomic Formulas: The simplest formulas, which can be predicates applied to terms
(e.g., P(a)P(a), Q(x,y)Q(x,y)).
• Complex Formulas: Formed by combining atomic formulas using logical
connectives and quantifiers (e.g., ∀x(P(x)∨¬Q(x,f(y)))∀x(P(x)∨¬Q(x,f(y)))).
Semantics of First-Order Logic
The semantics define the meaning of FOL statements:
• Domain: A non-empty set of objects over which the variables range.
• Interpretation: Assigns meanings to the constants, functions, and predicates, specifying
which objects the constants refer to, which function the function symbols denote, and
which relations the predicate symbols denote.
• Truth Assignment: Determines the truth value of each formula based on the interpretation.
Examples of Knowledge Representation in FOL¶
1. Facts: Simple statements about objects.
• P(a) (Object a has property P).
• Q(a, b) (Objects a and b are related by Q).
2. Rules: Implications that describe general relationships.
• ∀x(P(x)→Q(x))∀x(P(x)→Q(x)) (If x has property P, then x also has property Q).
3. Existential Statements: Indicate the existence of objects with certain properties.
• ∃xP(x)∃xP(x) (There exists an x such that P(x) is true).
4. Universal Statements: Apply to all objects in the domain.
• ∀x(P(x)∨¬Q(x))∀x(P(x)∨¬Q(x)) (For all x, either P(x) is true or Q(x) is not true).
Example Knowledge Base in FOL
Consider a knowledge base representing a simple family relationship:
1. Constants:
• John, Mary
2. Predicates:
• Parent(x, y): x is a parent of y.
• Male(x): x is male.
• Female(x): x is female.
3. Statements:
• Parent(John, Mary)
• Male(John)
• Female(Mary)
• ∀x∀y(Parent(x,y)→¬(x=y))∀x∀y(Parent(x,y)→¬(x=y)) (No one is their own parent).
Applications of First-Order Logic in Knowledge Representation
1. Expert Systems: FOL is used to represent expert knowledge in various domains such as
medicine, finance, and engineering, enabling systems to reason and make decisions based
on logical rules.
2. Natural Language Processing: FOL provides a formal framework for representing the
meaning of natural language sentences, facilitating semantic analysis and understanding
in NLP tasks.
3. Semantic Web: FOL is foundational to ontologies and knowledge graphs on the Semantic
Web, enabling precise and machine-interpretable representations of knowledge.
4. Robotics: FOL is employed in robotic systems to represent spatial relationships, object
properties, and task constraints, aiding in robot planning, navigation, and manipulation.
5. Database Systems: FOL-based query languages such as SQL enable expressive querying and
manipulation of relational databases, allowing for complex data retrieval and manipulation.
Challenges & Limitations of First-Order Logic in Knowledge Representation
Challenges of First-Order Logic in Knowledge Representation
1. Complexity: Representing certain real-world domains accurately in FOL can lead to complex
and unwieldy formulas, making reasoning and inference computationally expensive.
2. Expressiveness Limitations: FOL has limitations in representing uncertainty, vagueness, and
probabilistic relationships, which are common in many AI applications.
3. Knowledge Acquisition: Encoding knowledge into FOL requires expertise and manual effort,
making it challenging to scale and maintain large knowledge bases.
4. Inference Scalability: Reasoning in FOL can be computationally intensive, especially in large
knowledge bases, requiring efficient inference algorithms and optimization techniques.
5. Handling Incomplete Information: FOL struggles with representing and reasoning with
incomplete or uncertain information, which is common in real-world applications.
Limitations of First-Order Logic in Knowledge Representation
1. Inability to Represent Recursive Structures: FOL cannot directly represent recursive
structures, limiting its ability to model certain types of relationships and processes.
2. Lack of Higher-Order Reasoning: FOL lacks support for higher-order logic, preventing it from
representinghhh and reasoning about properties of predicates or functions.
3. Difficulty in Representing Context and Dynamics: FOL struggles with representing dynamic
or context-dependent knowledge, such as temporal relationships or changes over time.
4. Limited Representation of Non-binary Relations: FOL primarily deals with binary relations,
making it less suitable for representing complex relationships involving multiple entities.
5. Difficulty in Handling Non-monotonic Reasoning: FOL is not well-suited for non-monotonic
reasoning, where new information can lead to retraction or modification of previously
inferred conclusions.
A semantic network is a form of knowledge representation that visually illustrates how concepts are
related to each other. In AI, it helps in structuring and organizing data in a way that machines can
interpret, process, and use it for decision-making. The nodes in a semantic network represent
concepts, and the edges define the relationships between these concepts, such as "is a," "part of," or
"related to."
For example, in a simple semantic network, the concept "Dog" might be connected to "Animal" with
an "is a" relationship, indicating that a dog is a type of animal.
Semantic networks can be categorized into various types based on the nature and purpose of the
relationships they represent.
1. Definitional Networks
Definitional networks are used to represent hierarchical relationships, often used in taxonomies or
ontologies. They define concepts by their relationships to more general or more specific concepts.
In a definitional network, "Dog" might be defined as a type of "Mammal," which is in turn a type of
"Animal."
2. Assertional Networks
Assertional networks represent specific facts or assertions about individual instances of concepts.
They often describe properties or attributes of specific entities.
An assertional network might represent the fact that "Rex is a Dog" and "Rex has Brown Fur."
3. Implicational Networks
Implicational networks focus on representing logical implications between concepts. They are used
to infer new knowledge from existing relationships.
If "All Dogs are Mammals" and "Rex is a Dog," an implicational network can infer that "Rex is a
Mammal."
4. Executable Networks
Executable networks are designed to represent procedural knowledge, where the relationships
include actions or sequences that can be executed by an AI system.
An executable network might represent the steps in a recipe, such as "Add Water to Pot" followed by
"Boil Water."
5. Learning Networks
Learning networks are dynamic and evolve as the AI system learns new information. They update
relationships and nodes based on new data or experiences.
In a learning network, an AI might update its understanding of "Dog" as it encounters new breeds or
characteristics.
6. Hybrid Networks
Hybrid networks combine elements from two or more of the above types, allowing for more complex
and versatile representations of knowledge.
A hybrid network might integrate definitional and assertional aspects, representing both the general
concept of "Dog" and specific instances like "Rex."
1. Lexical Components
• Labels: Descriptive names or identifiers associated with the nodes, providing a way to refer
to the concepts they represent.
2. Structural Components
• Edges/Links: The connections between nodes, representing relationships such as "is a," "part
of," "causes," or "associated with."
• Types of Relationships: These can include hierarchical relationships (e.g., "is a"), associative
relationships (e.g., "related to"), and functional relationships (e.g., "causes" or "results in").
3. Semantic Components
• Meanings of Nodes: The specific meanings or interpretations of the nodes within the context
of the network.
• Interpretation of Relationships: The understanding of what the edges or links between
nodes signify in real-world terms, ensuring the relationships are meaningful and accurately
reflect the domain.
4. Procedural Part
• Inference Rules: Rules that allow the network to derive new knowledge from existing
relationships. For example, if "Dog is a Mammal" and "Mammal is an Animal," the network
can infer that "Dog is an Animal."
• Query Mechanisms: Procedures for retrieving information from the network based on
specific queries or criteria.
• Update Mechanisms: Rules and processes for adding, modifying, or removing nodes and
links as new information is introduced.
The working of semantic networks involves several processes that allow AI systems to represent,
infer, and reason about knowledge:
1. Knowledge Representation: The first step in working with a semantic network is to define
the concepts (nodes) and the relationships (edges) between them. This involves creating a
network that accurately reflects the domain of knowledge.
2. Inference and Reasoning: AI systems can traverse the network to make inferences based on
the relationships between nodes. This process involves following the edges between nodes
to derive new information or answer queries.
3. Querying the Network: The network can be queried to retrieve specific information. Queries
can be made to find relationships between concepts, identify categories, or extract particular
data points.
4. Updating the Network: As new information becomes available, the network can be updated
by adding, modifying, or deleting nodes and edges. This keeps the network accurate and
reflective of the most current knowledge.
Semantic networks are a powerful tool for representing relationships and classifications across
various domains. Here are some examples illustrating how semantic networks can be applied in
different fields to organize and understand complex information.
2. Food Hierarchy
This semantic network models a food hierarchy. "Apple" and "Banana" are connected to "Fruit," and
"Lion" is connected to "Animal" with an "is a" relation. The "eaten by" link connects "Fruit" to
"Herbivore" and "Animal" to "Carnivore," illustrating the dietary relationships in the food chain.
3. Programming Concepts
This example demonstrates a semantic network in the domain of programming. "Python" and "Java"
are linked to "Programming Language" with an "is a" relation, indicating they are types of
programming languages. "Data Types" are linked to "Integer" with a "has" relation, and both are
connected to "Numeric Type," showing the classification of data types in programming.
Frame Representation
Frames are data structures used in AI to represent stereotypical situations or scenarios. They
encapsulate information about objects, events, and their interrelationships within a particular
context. Each frame consists of a set of attributes and values, forming a template for understanding
specific situations.
For instance, a "restaurant" frame might include attributes such as "menu," "waitstaff," and "tables,"
each with its own set of details.
Concept of Frames
The frame concept was introduced by Minsky in 1974 and is foundational in the field of knowledge
representation. Frames are designed to provide a structured way to capture the essential aspects of
a situation, facilitating easier retrieval and manipulation of information. They are akin to schemas or
blueprints that organize knowledge into manageable chunks.
Frames are essential for structuring knowledge in AI, and understanding their key components helps
in effectively utilizing them.
Here are the main components of frames, along with examples to illustrate their use:
1. Slots
Slots are attributes or properties of a frame. They represent the different aspects or characteristics of
the frame's concept.
2. Facets
Facets provide additional details or constraints for slots, defining acceptable values or specifying how
slots should be used.
• Type: Integer
• Range: 0 to 120
• Default Value: 30
3. Default Values
Default values are predefined values assigned to slots if no specific value is provided. They offer a
baseline that can be overridden with more specific information.
4. Procedures
Procedures are methods or functions associated with frames that define how the information within
the frame should be processed or utilized.
o Slots:
o ISBN: "978-0-06-112008-4"
o Genre: "Fiction"
o Facets:
o Publication Year:
o Type: Integer
o ISBN:
o Default Values:
o Procedures:
+-------------------------------------------------+
| Book Frame |
+-------------------------------------------------+
| Slots: |
| Title: "To Kill a Mockingbird" |
| Author: "Harper Lee" |
| Publication Year: 1960 |
| ISBN: "978-0-06-112008-4" |
| Genre: "Fiction" |
+-------------------------------------------------+
| Facets: |
| Publication Year: |
| - Type: Integer |
| - Range: 1450 to current year |
| ISBN: |
| - Format: 13-digit number |
+-------------------------------------------------+
| Default Values: |
| Genre: "Unknown" (if not specified) |
+-------------------------------------------------+
| Procedures: |
| CheckAvailability: Method to check if the book |
| is currently available in the library. |
| UpdateRecord: Method to update the book’s |
| record when it is borrowed or returned. |
+-------------------------------------------------+
This frame encapsulates all necessary information about a book and provides mechanisms to interact
with that information.
Frame inheritance is a method used in knowledge representation systems to manage and organize
information efficiently. It allows one frame (child) to inherit attributes and properties from another
frame (parent), creating a hierarchical structure. This method facilitates the reuse and extension of
existing knowledge.
1. Parent Frame: The frame from which attributes and properties are inherited. It defines
general attributes that are common to all its child frames.
2. Child Frame: The frame that inherits attributes and properties from the parent frame. It can
add new attributes or override existing ones to represent more specific information.
3. Inheritance Hierarchy: A tree-like structure where frames are organized hierarchically. Each
child frame can inherit from multiple parent frames, forming a network of relationships.
4. Overriding: When a child frame modifies or replaces an attribute inherited from the parent
frame with a more specific value or definition.
5. Extension: Adding new attributes or properties to a child frame that are not present in the
parent frame.
1. Define Parent Frame: Create a general frame with common attributes. For example, a
"Vehicle" frame might include attributes like "Make," "Model," and "Year."
2. Create Child Frame: Define a more specific frame that inherits from the parent frame. For
example, a "Car" frame might inherit attributes from the "Vehicle" frame and add specific
attributes like "Number of Doors."
3. Use Inherited Attributes: The child frame automatically includes all attributes from the
parent frame, providing a structured way to build on existing knowledge.
4. Override or Extend: Modify or add attributes in the child frame as needed to refine the
representation. For example, the "Car" frame might override the "Year" attribute to specify a
range of acceptable values.
o Attributes:
o Title
o Author
o Publication Year
o Extended Attributes:
o ISBN
o Genre
o Extended Attributes:
o Issue Number
o Publisher
In this example:
• The "Book" frame inherits the common attributes from the "LibraryItem" frame and adds
specific attributes related to books.
• The "Magazine" frame also inherits from "LibraryItem" but adds attributes specific to
magazines.
Applications of Frames in AI
1. Natural Language Processing (NLP): In NLP, frames are used to understand the context of
words and sentences. For example, a "booking" frame might be used to interpret requests
for reservations, extracting relevant information such as date, time, and number of people.
2. Expert Systems: Expert systems use frames to represent knowledge about specific domains.
For instance, a medical diagnosis system might employ frames to represent various diseases,
symptoms, and treatment options.
3. Robotics: Frames help robots make sense of their environment by providing structured
information about objects and their properties. This allows robots to perform tasks such as
object recognition and manipulation.
4. Cognitive Modeling: Frames are used in cognitive modeling to simulate human thought
processes. By representing knowledge in frames, researchers can create models that mimic
human reasoning and decision-making.
• Organized Knowledge: Frames help in structuring information in a way that mirrors real-
world scenarios, making it easier for AI systems to understand and process.
• Flexibility: Frames can be easily modified or extended to incorporate new information or
adapt to changing contexts.
• Reusability: Once defined, frames can be reused across different applications or scenarios,
promoting consistency and efficiency.
• Complexity: As the number of frames and their interrelationships increase, managing and
maintaining the frames can become complex.
• Context Sensitivity: Frames may struggle to adapt to highly dynamic or ambiguous situations
where predefined structures may not fit.
• Scalability: For large-scale systems, the sheer volume of frames and their interactions can
pose challenges in terms of performance and resource management.
Production Rules
Production System in AI
In artificial intelligence (AI), a production system refers to a type of rule-based system that is
designed to provide a structured approach to problem solving and decision-making. This framework
is particularly influential in the realm of expert systems, where it simulates human decision-making
processes using a set of predefined rules and facts.
Scenario: A patient comes to a healthcare facility with the following symptoms: fever, severe
headache, sensitivity to light, and stiff neck.
2. Processing:
• MediDiagnose reviews its knowledge base for rules that match the given symptoms.
• It identifies several potential conditions but recognizes a strong match for meningitis
based on the combination of symptoms.
3. Output:
• The system suggests that meningitis could be a possible diagnosis and recommends
further tests to confirm, such as a lumbar puncture.
• It also provides a list of other less likely conditions based on the symptoms for
comprehensive differential diagnosis.
MediDiagnose uses its rule-based system to quickly filter through vast amounts of medical data to
provide preliminary diagnoses. This assists doctors in focusing their investigative efforts more
efficiently and potentially speeds up the process of reaching an accurate diagnosis.
1. Knowledge Base: This is the core repository where all the rules and facts are stored. In AI,
the knowledge base is critical as it contains the domain-specific information and the if-then
rules that dictate how decisions are made or actions are taken.
2. Inference Engine: The inference engine is the mechanism that applies the rules to the known
facts to derive new facts or to make decisions. It scans the rules and decides which ones are
applicable based on the current facts in the working memory. It can operate in two modes:
• Forward Chaining (Data-driven): This method starts with the available data and uses
the inference rules to extract more data until a goal is reached.
• Backward Chaining (Goal-driven): This approach starts with a list of goals and works
backwards to determine what data is required to achieve those goals.
3. Working Memory: Sometimes referred to as the fact list, working memory holds the
dynamic information that changes as the system operates. It represents the current state of
knowledge, including facts that are initially known and those that are deduced throughout
the operation of the system.
4. Control Mechanism: This governs the order in which rules are applied by the inference
engine and manages the flow of the process. It ensures that the system responds
appropriately to changes in the working memory and applies rules effectively to reach
conclusions or solutions.
Production systems in AI can be categorized based on how they handle and process knowledge. This
categorization includes Rule-Based Systems, Procedural Systems, and Declarative Systems, each
possessing unique characteristics and applications.
1. Rule-Based Systems
• Rule-based systems operate by applying a set of pre-defined rules to the given data
to deduce new information or make decisions. These rules are generally in the form
of conditional statements (if-then statements) that link conditions with actions or
outcomes.
• Diagnostic Systems: Like medical diagnosis systems that infer diseases from
symptoms.
• Fraud Detection Systems: Used in banking and insurance, these systems analyze
transaction patterns to identify potentially fraudulent activities.
2. Procedural Systems
• Interactive Voice Response (IVR) Systems: Guide users through a series of steps to
resolve issues or provide information, commonly used in customer service.
3. Declarative Systems
• Declarative systems are based on facts and information about what something is,
rather than how to do something. These systems store knowledge that can be
queried to make decisions or solve problems.
• Knowledge Bases in AI Assistants: Power virtual assistants like Siri or Alexa, which
retrieve information based on user queries.
Each type of production system offers different strengths and is suitable for various applications,
from straightforward rule-based decision-making to complex systems requiring intricate procedural
or declarative reasoning.
• Match: The inference engine checks which rules are triggered based on the current facts in
the working memory.
• Select: From the triggered rules, the system (often through the control mechanism) selects
one based on a set of criteria, such as specificity, recency, or priority.
• Execute: The selected rule is executed, which typically modifies the facts in the working
memory, either by adding new facts, changing existing ones, or removing some.
Production systems are used across various domains where decision-making can be encapsulated
into clear, logical rules:
• Expert Systems: For diagnosing medical conditions, offering financial advice, or making
environmental assessments.
• Automated Planning: Used in logistics to optimize routes and schedules based on current
data and objectives.
• Game AI: Manages non-player character behavior and decision-making in complex game
environments.