AM601PC Knowledge Representation and Reasoning UNIT-5
AM601PC Knowledge Representation and Reasoning UNIT-5
Knowledge Engineering
● Definition: The application of logic and ontology to create computable models for solving
domain-specific problems within constraints like budgets and deadlines.
● Example: A knowledge engineer models a traffic light system where the light alternates between
red and green automatically or can be manually controlled under special conditions.
● Challenge: Informal, natural language descriptions must be translated into precise, computable
formats.
Example:
Informal Spec: "A traffic light automatically turns red or green but has manual control."
Formal Spec:
▪ Variables: currentColor (red/green), autoSwitch (on/off).
▪ Rules:
▪ If autoSwitch = on, green lasts gg seconds, then turns red.
▪ If autoSwitch = off, manual inputs control the light.
Declarative Approach
Procedural Approach
This summary distills key aspects of knowledge engineering with concrete examples, emphasizing how
informal ideas are formalized into practical, computable systems.
Here’s a more detailed explanation of frames and their role in knowledge representation, elaborated with
examples from the provided text:
A frame is a structured way of representing knowledge about a specific, stereotypical situation or object.
Think of a frame as a template or schema that describes what is typically true in a particular scenario or
for an object.
For instance:
● A living room frame might include slots for furniture, such as a sofa, a TV, and lamps, along with
their expected characteristics (e.g., the TV should be placed against a wall).
● A birthday party frame might include slots for decorations, a cake, and gifts, specifying expected
actions like blowing out candles.
Structure of Frames
1. Top Levels: Represent facts that are always true about the scenario.
Example: In a "Traffic Light" frame, the fact that it cycles through colors (red, yellow, green) would be at
the top level.
2. Slots: Represent attributes or variables specific to instances of the frame. These can be filled with
specific data.
Example: For a "Traffic Light," slots might include:
o currentColor: The current state of the light (e.g., "green").
o redTime: Duration for which the light stays red.
o autoSwitch: A boolean indicating if the light changes automatically.
3. Conditions: Specify rules for filling slots or constraints for their values.
o A slot may require a specific type of value, such as "Duration" for redTime or "Color" for
currentColor.
● Supertype: "Object" indicates that a TrafficLight inherits general properties from the Object
frame.
● Slots:
o currentColor: Can only take values from "red," "green," or "yellow."
o redTime: Duration for which the light stays red (e.g., "60 seconds").
o autoSwitch: Indicates whether the traffic light switches automatically, with possible values "on" or
"off."
Merged Representation:
The TrailerTruck frame effectively combines the inherited slots from the Truck frame, with its own
specific details:
● This representation expresses the same information in a logical form, where each slot is a predicate
applied to the instance Blinky.
Multiple Inheritance
Frames allow multiple inheritance, where an instance or type can belong to multiple supertypes.
Advantages of Frames
1. Organized Knowledge: Frames group related knowledge into logical units, making it easier to
manage.
2. Inference: Inheritance allows for efficient inference, as properties from supertypes propagate to
subtypes or instances.
3. Flexible Representation: Frames can represent complex conditions and relationships using
constraints in slots.
Limitations
1. Frames lack the expressive power to handle negations or implications (e.g., “There is no
hippopotamus in this room”).
2. Arithmetic computations or more complex logic often require external systems or procedural
attachments.
Summary
Frames are a powerful tool for structuring and organizing knowledge in AI. They represent a scenario or
object as a set of attributes (slots) with specific constraints and allow for hierarchical inheritance, making
knowledge representation both efficient and intuitive. Examples like "TrafficLight" and "TrailerTruck"
demonstrate how frames encapsulate knowledge in a reusable and logical format.
Key Differences:
Common Logical Foundations: Both systems rely on the existential-conjunctive (EC) subset of logic,
using two main inference rules:
● Planner (1971, MIT): Combined forward and backward chaining with relational databases.
● MYCIN (Stanford, 1976): A backward-chaining system for diagnosing bacterial infections.
● OPS5 (Carnegie-Mellon): A forward-chaining system that became the foundation for commercial
expert systems, such as CLIPS.
● Prolog: Developed in Europe, combined backward-chaining with logical operations, influencing
database integration.
● Systems like Microplanner, Prolog, and SQL use backtracking to solve queries:
o Search relevant relations to find the desired data.
o Backtracking tries different options if a goal cannot be met.
Optimization
● In SQL databases, optimizations like indexing, hash coding, and goal reordering
improve query performance.
● In contrast, systems like Prolog and Microplanner require manual goal ordering or use
preprocessors for optimization.
Overall, expert systems and relational databases share a logical foundation, with a convergence in
their capabilities due to the integration of relational operations and logical inference techniques.
The provided passage discusses how different knowledge representation and query languages— SQL,
Prolog, and CLIPS—can express operations to solve queries while adhering to the same logical
foundations but using distinct syntaxes and mechanisms. Let's break this down step by step with concrete
examples.
Key Concepts
Conceptual graphs translate natural language questions into a graph form that closely mirrors the
semantics of natural language.
1. SQL
In SQL, queries are formulated to select data from tables by filtering, grouping, and joining.
SQL Translation:
CREATE VIEW sup_color AS SELECT supporter, color FROM supports, objects WHERE supportee =
id;
● This query defines a view sup_color that groups supporter and color by selecting data from the
supports and objects tables.
● The WHERE clause ensures that only those rows where supportee matches id in the objects table
are selected.
2. Prolog
Prolog uses a rule-based logical syntax, emphasizing backward chaining and pattern matching.
o It searches for a combination of S and X that meets the conditions in the database.
3. CLIPS
CLIPS is a forward-chaining rule-based system and is commonly used in expert systems. It emphasizes
pattern matching and proactive updates.
o If ?x is a box and ?x supports some object ?y, it asserts that ?x contains ?y.
o This proactively updates the database's contains relationships to maintain constraints (e.g., boxes
containing anything they support).
Key Comparisons
4. Conceptual Graph Representation In Conceptual Graphs, queries are expressed in a graph
format close to natural language.
For Example:
● Here:
o {*} represents plurals.
o The query asks to group blocks collectively supported by exactly 3 pyramids. Practical
Implications
● Backward Chaining (Prolog, SQL): Focuses on deducing results by exploring relationships
backward through known facts.
● Forward Chaining (CLIPS): Updates the database by proactively ensuring relationships (e.g.,
boxes containing contents).
o Prolog uses recursion and pattern matching but lacks native support for some database operations.
Conclusion
● Different systems (SQL, Prolog, CLIPS) have distinct syntaxes but share logical core principles.
● Translating natural language queries into these systems requires conceptual mapping and
abstraction.
Each system's choice depends on its specific goals and constraints, like performance, scalability, data
relationships, and querying complexity.
● OOPS combine declarative (specifying objects) and procedural (defining actions) styles.
● Instead of separating data and actions, they integrate data and operations into a single package.
Example: Truck Class
Imagine we have a class Truck. In Java, it’s declared as:
Java Code:
public class Truck extends Vehicle { private int unloadedWeight; private int maxGrossWeight; private int
cargoCapacity;
Text Explanation:
2. Encapsulation
Encapsulation restricts direct access to an object's internal data. Only class methods or subclasses can
interact with these private variables.
Text Explanation:
● In parsing, backward chaining refers to converting grammar rules into recursive calls.
Text Example:
If your system needs to parse a sentence ("The truck is moving"), it uses recursive descent parsing to
break down the sentence into individual parts (subject, verb, object).
Observable inventory = new Observable(); // The main inventory system Observer warehouseManager =
new Observer(); // Dependent warehouse system
Text Explanation:
Encapsulation ensures that only the right parts of the code interact with an object's data.
● A Truck object's operations (e.g., loading, delivery) are determined by its internal methods rather
than direct access by external programs.
Text Explanation:
● Encapsulation allows operations like loading cargo or navigating routes to remain hidden inside
the class, ensuring data remains safe and error-free.
● In these systems, procedures encode logical propositions instead of explicitly stating them.
Example: Converting PowerLoom Frames to C++
● In PowerLoom, logical frames are automatically converted into C++ declarations, maintaining
compatibility across programming systems.
Text Explanation:
● This ensures automatic conversion of logical rules into code, maintaining efficiency and
accuracy.
● Systems often have interactive displays allowing detailed zoom-ins or broader zoom- outs of
processes and states.
Text Explanation:
● Such visualizations help programmers and analysts understand complex interactions efficiently
by focusing on relevant details.
Example // Method to get the truck's cargo capacity public int cargoCapacity() {
return cargoCapacity;
}
Text Explanation:
● These comments serve as a bridge between the code and human understanding, ensuring
clarity for both programmers and non-technical users.
● Understanding language requires background knowledge about the world and context.
Example: In a request about the movie Casablanca:
The system must know:
Casablanca is a movie, not a city.
Humphrey Bogart is an actor, not just a name.
This knowledge is difficult for computers to acquire automatically.
Conceptual graph:
[Association] contains [Industrialists]
● Many words have multiple meanings, which must be resolved with context and syntax.
Example:
"Mezzogiorno" means "noon" or "the south of Italy".
Context determines whether it refers to time or location.
6. Inference & Knowledge Representation
Key Takeaways
● Natural languages are rich but challenging for computers due to their ambiguity and vast
background knowledge requirements.
● Artificial languages have strict rules but lack the expressive flexibility of natural languages.
● Language processing relies on understanding syntax, semantics, and background knowledge,
which current AI systems still struggle to handle fully.
Ron Brachman divided representation into 5 levels, focusing on how knowledge is organized and
implemented:
Rodney Brooks outlined 8 levels of competence for mobile robots, showing increasing sophistication:
Zachman’s Matrix
Key Takeaways