M3 Knowledge Representation and Reasoning M3
M3 Knowledge Representation and Reasoning M3
Techniques in AI
Module 3
Knowledge Representation
• What is Knowledge Representation (KR)?
- A method to structure and store knowledge
- Enables machines to reason and act
• AI systems need to understand, process, and make
decisions using knowledge about the world.
• Knowledge Representation (KR) allows encoding this
knowledge in a structured format that machines can
interpret.
• It's crucial for tasks like natural language processing,
planning, problem-solving, and reasoning.
Objectives of KR:
- Represent real-world knowledge
- Enable logical reasoning
- Facilitate understanding and learning
Knowledge Representation Types in AI
• Logical Representation
– Propositional Logic
– Predicate Logic
• Semantic Networks
– Graph-based structure (nodes and edges)
• Frames
– Slot-filler structures similar to objects
• Procedural Representation
– Rules and procedures (e.g., IF-THEN)
• Production Rules
– Condition-action rules used in expert systems
• Probabilistic Representation
– Bayesian Networks
– Probabilistic graphical models
• Scripts and Schemas
– Represent stereotypical sequences of events
1)Logical Representation
Propositional Logic
• Propositional Logic (also called Boolean Logic)
is a type of formal logic that deals with
propositions — statements that can either be
true or false, but not both.
• It is the simplest form of logic used in AI for
knowledge representation and reasoning.
Component Description Example
A statement that is either
Proposition It is raining.
true or false
Common Logical Connectives
Example
Let:
•P: "It is raining"
•Q: "The ground is wet"
Then:
•P → Q: If it is raining, then the ground is wet.
•¬P ∨ Q: Either it is not raining, or the ground is wet.
Why Use Propositional Logic in AI?
• To model facts and rules about the world.
• To perform inference (e.g., Modus Ponens).
• Foundation for more complex systems like Predicate Logic.
Limitations
• Cannot express relationships within propositions (e.g., "All
humans are mortal").
• Doesn't deal with objects, properties, or quantifiers.
• Not ideal for large and complex knowledge bases.
Applications in AI
• Rule-based systems
• Decision-making systems
• Logic programming (e.g., Prolog)
• Digital circuit design
• Game AI and expert systems
2) Predicate Logic is a formal language that represents
facts and rules about the world.
• Predicate Logic is an extension of Propositional Logic that
allows reasoning about objects, their properties, and their
relationships.
Example: Loves(John, IceCream) means John loves ice cream.
•Quantifiers:
– Universal (∀): Applies to all members of a group.
e.g., ∀x (Student(x) → Studies(x)) → All students study.
– Existential (∃): Applies to at least one member.
e.g., ∃x (Teacher(x) ∧ Teaches(x, Math)) → Some teacher
teaches math
Basic Elements of Predicate Logic
• Components:
- Constants (e.g., John)
- Predicates (e.g., Likes(John, IceCream))
- Variables (e.g., x, y)
- Quantifiers: ∀ (forall), ∃ (exists)
Predicate Logic Example & Pros/Cons
• Used in expert systems and theorem provers.
• Can chain multiple logical statements to draw conclusions.
• Example reasoning:
– ∀x (Cat(x) → Animal(x))
Cat(Tom)
⇒ Animal(Tom)
• But it's abstract and not very human-readable.
Example:
"Everyone loves ice cream"
∀x Loves(x, IceCream)
• Advantages:
- Precise and supports inference
• Limitations:
- Not intuitive
- Hard to scale
Why is Predicate Logic Useful in AI?
• Describes complex situations and facts about the
world
• Supports reasoning and inference
• Foundation for expert systems, knowledge bases,
natural language understanding, and planning
• Frame Name :
– Each frame represents a specific concept or object and is
given a unique name.
Example: "Dog," "Car," "Person."
• Slots :
– Slots represent attributes or properties of the concept or
object.
Example: For a "Dog" frame, slots might include "Color,"
"Breed," "Age," and "Owner."
• Facets (or Fillers) :
– Facets define the characteristics of a slot, such as its value,
default value, range of possible values, or constraints.
Example: For the "Age" slot in a "Dog" frame, the facet might
specify that the value must be a positive integer.
• Values :
– Values are the data assigned to slots, representing specific
instances of the concept.
Example: For a "Dog" frame, the "Color" slot might have the
value "Brown."
• Inheritance :
– Frames can inherit attributes from more general frames
(parent frames), reducing redundancy.
Example: A "Labrador" frame might inherit attributes like
"CanBark" and "IsMammal" from a more general "Dog"
frame.
• Procedural Attachments :
– Frames can include procedures or functions that define
how to compute or manipulate certain attributes.
Example: A "Temperature" slot might include a procedure to
convert Celsius to Fahrenheit.
Structure of a Frame
• Here’s an example of a simple frame for a "Dog":
Frame: Dog
--------------------------
| Slot | Value |
--------------------------
| Type | Animal |
| Species | Canine |
| Legs |4 |
| Color | Brown |
| Owner | John |
| CanBark | True |
| Default Age | 5 years |
--------------------------------
• Type : Specifies that "Dog" is a type of
"Animal."
• Species : Describes the biological classification
of the dog.
• Legs : Specifies the number of legs a dog has.
• Color : Indicates the dog's color.
• Owner : Specifies who owns the dog.
• CanBark : Indicates whether the dog can bark.
• Default Age : Provides a default value for the
dog's age if no specific age is given.
Types of Slots in Frames
• Attribute Slots :
– Represent properties of the object.
Example: "Color," "Weight," "Height."
• Relationship Slots :
– Represent relationships between objects.
Example: "Owner" (relationship between a dog and a person).
• Procedural Slots :
– Contain procedures or functions to compute values dynamically.
Example: A "Temperature" slot might include a function to convert units.
• Default Slots :
– Provide default values for attributes when no specific value is given.
Example: A "Car" frame might have a default "Color" of "Silver."
• Constraint Slots :
– Specify restrictions on the values a slot can take.
Example: A "Temperature" slot might only allow values between -273°C
and 1000°C.
Advantages of Frames
• Structured Representation :
– Frames organize information in a clear, hierarchical manner, making it
easier to understand and manage.
• Inheritance :
– Attributes from parent frames can be inherited by child frames,
reducing redundancy and promoting modularity.
Example: A "Labrador" frame inherits attributes from a "Dog" frame.
• Default Values :
– Default values allow frames to handle incomplete information
gracefully.
• Procedural Attachments :
– Procedures can be attached to slots to perform computations or
actions dynamically.
• Flexibility :
– Frames can represent a wide variety of knowledge types, including
facts, rules, and behaviors.
• Reusability :
– Frames can be reused across different domains and applications.
Limitations of Frames
• Complexity :
– As the number of frames and slots grows, the system can
become difficult to manage.
• Ambiguity :
– Without proper constraints, frames can lead to ambiguity
in interpretation.
• Scalability :
– Large-scale systems with many interconnected frames can
become computationally expensive.
• Lack of Formal Semantics :
– Unlike formal logic systems, frames do not always have
precise rules for interpretation.
• Limited Expressiveness :
– Some types of relationships or constraints may be difficult
to represent.
Applications of Frames
• Expert Systems :
– Frames are widely used in expert systems to represent domain-specific
knowledge.
Example: MYCIN, an early expert system for diagnosing bacterial infections, used
frames to represent medical knowledge.
• Natural Language Processing (NLP) :
– Frames help in understanding and generating natural language by modeling
the structure of sentences and concepts.
Example: FrameNet, a lexical database, uses frames to represent semantic roles
in sentences.
• Object-Oriented Programming :
– The concept of frames influenced object-oriented programming (OOP), where
objects have attributes (slots) and methods (procedures).
• Robotics :
– Frames are used to model the environment and objects in robotics
applications.
Example: A robot might use frames to represent objects it interacts with, such as
"Table" or "Chair."
Example of a Frame System Frame: SportsCar (inherits from Car)
• --------------------------
Frame: Vehicle • | Slot | Value |
• --------------------------
• | Slot | Value |
• --------------------------
• -------------------------- • | Inherits From| Car |
• | Type | Object | • | Top Speed | 200 mph |
• | Wheels |4 | • | Color | Red |
• | Engine | Yes |
• --------------------------
• | Default Color| Black |
• --------------------------
• The "SportsCar" frame inherits
Frame: Car (inherits from Vehicle) attributes like "Wheels" and
• --------------------------
• | Slot | Value |
"Engine" from the "Vehicle"
• -------------------------- frame, and "Doors" and
• | Inherits From| Vehicle | "Trunk" from the "Car" frame.
• | Doors |4 | It overrides the "Color" slot
• | Trunk | Yes | with a specific value ("Red")
• --------------------------
and adds a new slot, "Top
Speed."
Frames vs Semantic Networks
While semantic networks focus on representing relationships
between concepts using nodes and edges, frames provide a
more structured and detailed representation of knowledge.
Here’s a comparison:
Example:
• It is raining → Ground is wet → Car may slip → Accident
may occur
Applications:
- Monitoring systems
- Real-time decision making
Forward Chaining - Pros & Cons
Advantages:
- Efficient with many facts
- Good for real-time systems
Disadvantages:
- Can produce irrelevant facts
- Inefficient for specific goals
Backward Chaining
Starts with a goal and works backward to check if data
supports it.
Working:
- Start with goal
- Find rules to support it
- Check or prove each condition recursively
Example:
• Accident? ← Car slips? ← Ground is wet? ← It is raining
Applications:
- Diagnostic systems
- Expert systems (e.g., medical)
Backward Chaining - Pros & Cons
Advantages:
- Efficient for specific goals
- Avoids unnecessary rules
Disadvantages:
- Can struggle with sub-goals
- May loop without controls
Comparison: Forward vs Backward
Chaining
Forward Chaining:
- Data to goal
- Data-driven
- Good for monitoring
Backward Chaining:
- Goal to data
- Goal-driven
- Good for diagnosis
Real-World Examples
Forward Chaining:
- Home automation
- Weather prediction
- Fraud detection
Backward Chaining:
- Medical diagnosis
- Legal reasoning
- Tech support
Resolution in Propositional Logic
What is Resolution?
• Resolution is a rule of inference used for automated
theorem proving in AI.
• It helps derive new knowledge or contradictions from a
set of known facts and rules.
• Example:
• If it rains, the ground is wet.
• It rains.
• ∴ The ground is wet.
2. Modus Tollens
• Form:
• P→Q
• ¬Q
• ∴ ¬P
• Example:
• If the alarm rings, there is a fire.
• There is no fire.
• ∴ Alarm does not ring.
3. Disjunctive Syllogism
• Form:
• P∨Q
• ¬P
• ∴Q
• Example:
• It's either Monday or Tuesday.
• It's not Monday.
• ∴ It is Tuesday.
4. Hypothetical Syllogism
• Form:
• P→Q
• Q→R
• ∴P→R
• Example:
• If I study, I pass.
• If I pass, I graduate.
• ∴ If I study, I graduate.
5. Addition
If a statement is true, then the disjunction (“or”) of
that statement with any other statement is also
true.
• If P is T
• ∴ P ∨ Q is T
• Example:
• It’s sunny.
• ∴ It’s sunny or raining.
6. Simplification
If a conjunction (“and”) is True, then each of its
conjuncts is also True.
• P ∧ Q is T
• ∴ P is T
• P ∧ Q is T
• ∴ Q is T
• Example:
• It’s warm and sunny.
• ∴ It’s warm.
7. Conjunction
If two statement are True, Then their conjunction
(“and”) is also True.
• P
• Q
• ∴P∧Q
• Example:
• It’s hot.
• It’s humid.
• ∴ It’s hot and humid.
8. Resolution Rule
• Form:
• P∨Q
• ¬Q ∨ R
• ∴P∨R
• Example:
• John is smart or he studies.
• He doesn’t study or he passes.
• ∴ John is smart or he passes.
Applications of Inference in AI
• Medical Research and Diagnoses: AI aids in
medical research and diagnoses by analyzing
patient data to provide optimized treatment
plans and prognoses.
• Recommendation Systems and Personalized
Advertisements: E-commerce platforms utilize
inference to suggest products based on user
preferences, enhancing user experience and
engagement.
• Self-Driving Vehicles: Inference enables self-
driving cars to interpret sensor data and navigate
through dynamic environments safely and
efficiently.
Resolution Principle
• Based on the refutation principle:
To prove a statement, assume its negation and show a
contradiction.
• Limitations:
- Computationally intensive(Resolution logic, while
theoretically elegant, can be computationally
intensive due to the potential for an unbounded
search space and the need to track and manage a
large number of clauses)
- CNF conversion can be complex