Unit III
Unit III
• Knowledge Representations:
• Knowledge Engineering, Representing
structure in frames, Rules and data, Object-
oriented systems, Natural language Semantics,
Levels of representation
•
• Knowledge Engineering
• Definition:
– Knowledge engineering applies logic and ontology
to create computable models for specific domains
and purposes.
– It is distinct from pure mathematics and empirical
sciences due to its focus on practical problem-
solving within constraints like budgets and
deadlines.
• Purpose:
– Transforms domain-specific knowledge into
computable formats to address real-world
challenges.
• Informal Specifications:
– Translating informal descriptions into executable
programs requires addressing ambiguities and implicit
knowledge.
– Example: A traffic light system specification involves
clarifying terms like "automatic," "manual control,"
and "special circumstances."
• Challenges in Formalization:
– Experts’ "obvious" terms are puzzles for knowledge
engineers.
– Example: A medical expert might say "monitor vitals,"
assuming the engineer understands it involves heart rate,
blood pressure, etc.
– Computers, like Martians unfamiliar with Earth, lack the
background knowledge required to interpret informal
specifications.
– Example: A computer wouldn't understand the phrase
"book a table" without explicit instructions about
restaurants and reservations.
– Alan Perlis emphasized the difficulty of translating informal
to formal specifications due to extensive background
knowledge required.
• Example of Formalization:
– Informal description of a traffic light system
expanded to:
• States: Red or Green.
• Controls: Automatic switch (On/Off).
• Rules: Define color durations (e.g., Green for g seconds,
Red for r seconds).
– Formalization relies on assumptions and detailed
background knowledge from experts or
references.
• Principles of Knowledge Representation (KR):
• Outlined by Davis, Schrobe, and Szolovits (1993), these
principles define the purpose and structure of KR:
• Surrogate: KR uses symbols to represent external
systems, enabling computers to simulate or reason
about them.
• For example, a traffic light's behavior is modeled
through variables like time and color.
• Ontological Commitments: KR embodies the
designer's assumptions about the domain, such as
categories and types of entities.
• For instance, the traffic light example uses templates
to define variables (e.g., color, time) and their
constraints.
• Fragmentary Theory of Reasoning: KR describes how
domain entities behave and interact, forming a
partial theory. It could be encoded as explicit axioms
or executable programs.
• Efficient Computation: KR must be designed for
effective processing on available hardware, balancing
expressiveness with performance.
• For example, simulation programs for a traffic light
might use loops or declarative axioms.
• Human Expression Medium: A good KR facilitates
communication between knowledge engineers and
domain experts. Conceptual graphs, diagrams, and
structured English help bridge this gap.
• # Procedural Approach
• 1. Focus: Specifies "how" to perform a task or solve a problem.
• 2. Representation: Uses algorithms, procedures, and rules to represent
knowledge.
• 3. Example: A recipe that lists step-by-step instructions on how to make a
dish.
• # Declarative Approach
• 1. Focus: Specifies "what" is true or false, without detailing how to
achieve it.
• 2. Representation: Uses statements, facts, and constraints to represent
knowledge.
• 3. Example: A statement that says "The capital of France is Paris" without
explaining how to find the capital.
• To illustrate the difference:-
• Procedural: "To make a cup of coffee, boil water, add coffee grounds, and
stir." (Focuses on the steps)-
• Declarative: "A cup of coffee is made with coffee grounds and hot
water." (Focuses on the fact)
• Surrogate Model for Traffic Light:
• What is a Surrogate Model?
A computational model represents real-world
systems (e.g., traffic lights) using variables like time
(current time) and light_color (traffic light state).
• Procedural Approach
• Uses programs or rules to update variables.
• Key steps:
– Define events as operations (e.g., change light to green
after 30 seconds).
– Use a control loop to trigger operations when conditions
are met.
– Simulate system behavior by running the program.
• Efficient but less flexible for reasoning.
• Declarative Approach
• Defines system behavior with logic and constraints.
• Key steps:
– Represent the starting state with logical formulas.
– Add rules for events and transformations.
– Use theorem-proving to calculate system state over time.
• Adaptable for reasoning but computationally intensive.
• Comparison
• Procedural: Direct and efficient for execution.
• Declarative: Better for reasoning and flexibility but
slower without optimization.
Ontological Commitments and Traffic Light
Representation
• Procedural Approach:
The system uses a simple program to change the lights (red → green → yellow → red)
based on time.
Example: A loop that switches lights every 30 seconds. It’s efficient but cannot explain
why a light changes.
• Declarative Approach:
•
Rules for traffic lights are written in logic-based systems like Prolog (e.g., "Green
follows Red if no pedestrians"). This allows reasoning, such as predicting the next
state.
• Hybrid Approach:
•
Combines both approaches, using rules for reasoning and efficient procedures for
execution.
• Example: A rule triggers when a pedestrian presses a button, and a procedural loop
efficiently changes the light
• Traffic Light Example and Ontological Commitments
• Significant Entities:
Variables represent key components of the traffic light
system:
– Light itself
– Current time and color
– Time when the color last changed
– Duration of red/green lights
– Switch for automatic/manual control
• Representation Methods:
These commitments can be modeled using:
– Predicate Calculus: Using variables and relationships
– Graphs: Concepts as nodes
– Data Structures: Frames, schemas, or templates
• CLIPS Template:
Example of a trafficLight template with six slots:
– AutoSwitch Slot: Defaults to on but can be set to off for manual control.
• Logical Correspondence:
– Each slot corresponds to a relation in logic, like redTime(x, y), where x is
the traffic light and y is the red light duration.
• Programming Analogy:
– The template resembles a record or structure in programming.
– Each assertion initializes storage for a specific traffic light instance.
• This setup enables both simulation and reasoning about traffic
light behavior in various control scenarios.
Efficient Computation in Traffic Light
Simulation:
• Here’s a more condensed version:
• Efficient Traffic Light Simulation:
• Procedural Approach:
– A loop alternates between red and green lights.
– Limitation: It doesn't track or explain why the light
changes or keep any records.
• Declarative Approach:
– Uses logic rules (e.g., "if red time is over, turn green").
– Allows reasoning and answering queries like "When will
the light turn green?"
– Prolog example: turns_green(X, T2) :- traffic_light(X),
turns_red(X, T), red_time(X, R), sum_times(T, R, T2).
• Hybrid (Forward-Chaining):
– Mixes both procedural and declarative logic.
– Monitors and updates states (e.g., light turns
green when red time is over).
• Inference Engines:
– Backward-Chaining: Inference based on known
facts (like Prolog).
– Forward-Chaining: Continuously updates based on
real-time conditions (e.g., light turning green).
• Reasoning Strategies for Traffic Lights:
• Procedural Loop:
– How it works: Step-by-step simulation (turn red, wait, then turn green).
– Strengths: Simple and mirrors the problem’s sequence.
– Weaknesses: Not suitable for complex, non-sequential problems or parallel
operations.
• Logical Formulas:
– How it works: Uses logic to describe relationships (e.g., "If red time ends, turn
green").
– Strengths: Great for complex, interdependent relationships.
– Weaknesses: Needs extra constructs to handle time and parallel processes.
• Forward-Chaining Rules:
– How it works: Rules activate based on conditions (e.g., red time finishes, then
turn green).
– Strengths: Good for real-time, dynamic systems.
– Weaknesses: Can get complex with unpredictable events.
• When to Use Each Approach:
• Procedural Loop: Use for problems with clear, sequential steps.
• Logic: Best for complex relationships without a natural sequence.
• Forward-Chaining: Ideal for systems that react to real-time changes.
MEDIUM FOR HUMAN ExPRESSION.
• Communication with Experts: Knowledge engineers need to use simple
languages and diagrams to talk to experts in other fields, avoiding
technical jargon.
• Conceptual Graphs (CGs):
– Visual representations of rules, easier to understand than text-based formulas.
– But, new users need an explanation of how CGs work (e.g., meaning of arrows,
boxes).
• Simpler Notation (Stylized English):
– You can explain rules in simpler language like: "If the light turns red at time t, it
turns green after r seconds."
• Familiar Diagrams:
– Experts prefer using diagrams they know (like flow charts or circuit diagrams)
rather than complex notations.
• Converting Between Formats:
– It's easier to convert formal rules into simple diagrams or code, using tools that
automatically do this translation.
• In short, visual and simple language representations help knowledge
Simulation vs Theorem Proving:
• Simulation vs Theorem Proving:
– Simulation predicts what happens in specific cases but can’t prove
general rules.
– Theorem Proving can prove general rules with certainty, like how often
Blinky turns green.
• Limitations of Simulation:
– Simulation shows patterns, but they might be random or based on
specific starting conditions.
– Theorem proving explains why those patterns happen.
• Benefits of Theorem Proving:
– Provides proven rules, like how long the traffic light stays red.
– Helps verify and explain patterns seen in simulations.
• Combining Both:
– Use simulation to suggest patterns, then theorem proving to confirm
them.
• Declarative vs Procedural:
– Declarative (e.g., logic rules) is concise and easier to verify.
• Persistence in Simulation:
– While simulations can tell us when the traffic light changes color, they don't
explain what happens in between those changes. The light should stay the
same color until the next scheduled change.
• Persistence Rules:
– Additional rules (called persistence axioms) are needed to say that the light
stays the same color until a new change happens. For example, if the light
turns red at time t1 and stays red for r minutes, it remains red for that entire
duration.
• Leibniz’s Principle:
– According to Leibniz’s principle, nothing changes without a reason. So, the
traffic light stays the same color unless something else (like time passing)
causes it to change.
• The Frame Problem:
– Computers can struggle with the idea that everything else stays the same
unless explicitly told to change. These persistence axioms help the system
understand that the light should remain the same color until a reason for
change occurs.
• In short, persistence axioms ensure that the light's color stays the
same until the rules tell it to change, helping to solve the frame
problem in simulations.
3.2 Representing Structure in Frames:
• A knowledge representation language must
analyze knowledge into low-level primitives,
organize it into high-level structures like
graphs, and provide methods for grouping or
nesting to manage complex structures
efficiently.
SCHEMATA
• Aristotle: Introduced "schema" for patterns of valid
syllogisms.
• Kant (1787): Schemata are rules for constructing
general concepts (e.g., a "triangle" applies to all types
of triangles, not just a specific one).
• Bartlett (1932): Schemata organize past experiences
into cohesive units that guide responses (e.g., knowing
how to ride a bike without relearning every step).
• Selz (1913, 1922): Schemata as concept networks
direct thought by filling in missing information (e.g.,
solving a puzzle by identifying missing pieces).
FRAMES
• Definition (Minsky, 1975): A frame is a data
structure representing stereotyped situations,
with fixed "top levels" and variable "slots" for
specific data (e.g., a frame for a birthday
party).
• Components: Frames include slots with
conditions for specific assignments (e.g., a slot
for "currentColor" in a traffic light frame must
be either red or green).
• Inheritance: Frames use hierarchies, where
subtypes inherit attributes from supertypes,
overriding conflicts when necessary (e.g., a
"TrailerTruck" inherits properties from "Truck"
but specifies 18 wheels).
• AI Impact: Minsky's paper inspired numerous
frame systems, such as FRL (1977) and KRL
(1977), emphasizing the need for structured
knowledge representation.
• Modern Protocols: Generic Frame Protocol
(GFP) supports frame-based knowledge
sharing with a neutral syntax.
MAPPING FRAMES TO LOGIC:
1.Declarative Information to Logic:
– Frames can be mapped to first-order logic (FOL)
using existential conjunctive (EC) subsets with only
existential quantifiers (∃) and conjunction (∧).
2.Instance Example in Conceptual Graphs (CG):
• [TrafficLight: Blinky](currentColor) ~ [Color:
green]
• Maps to: (∃x: TrafficLight) (x = Blinky ∧
currentColor(x, green)).
3.Type Definitions in CG:
• Example:
– Truck: [Vehicle: ?x] → (UnloadedWt) ~ [WtMeasure].
– TrailerTruck: [Truck: ?x] → (HasPart) ~ [Trailer] ∧
(NumberOfWheels) ~ [Integer: 18].
4.Predicate Calculus Mapping:
• Truck: (∀x: Vehicle)(∃y1: WtMeasure)
unloadedWt(x, y1) ∧ ….
• TrailerTruck: (∀x: Truck)(∃y1: Trailer) hasPart(x,
y1) ∧ ….
5.Unification in Logic:
• Instantiating frames merges type slots with instance slots using
unification rules.
• Example 1: Matching Two Statements
• 👉 Goal: Find X so both statements become identical.
• 1 Statement 1: parent(X, John)
2 Statement 2: parent(Mary, John)
• 🔹 Unification: X = Mary
✅ Result: parent(Mary, John)
• 9.Beyond EC Logic:
• Arithmetic computations and advanced logical expressions
require procedural attachments or external programming.
• Rules and Data
• During the 1970s, universities pioneered
expert systems, while Ted Codd developed
relational databases at IBM.
• Although expert systems and database
systems differ in scale, their functionalities are
converging as database systems handle more
complex operations and expert systems are
applied to larger data sets.
• Key Differences:
• Expert Systems: Focus on executing repeated
rules on small data sets.
• Database Systems: Execute short chains of
rules on large data sets.
• Common Logical Foundations: Both systems
rely on the existential-conjunctive (EC) subset
of logic, using two main inference rules:
• Modus Ponens: From p and (p → q), infer q
(Forward Chaining).
• Modus Tollens: From ¬q and (q → p), infer ¬p
(Backward Chaining).
Modus Ponens:
• If p is true and p → q (if p then q) is true, then
we can infer that q is true.
• ✅ Logical Form:
• p,(p→q)
• If it rains, the ground will be wet. (p → q)
• It is raining. (p)
• Therefore, the ground is wet. (q)
• 2. Modus Tollens (Backward Chaining)
• If q is false and q → p (if q then p) is true, then
we can infer that p is false.
• ✅ Logical Form:
• ¬q,(q→p)
• Example:
• If the alarm is ringing, there is a fire. (q → p)
• The alarm is NOT ringing. (¬q)
• Therefore, there is NO fire. (¬p)
• Application in AI & Expert Systems
• Forward Chaining (Modus Ponens) → Used in
rule-based systems (e.g., medical diagnosis,
inference engines).
• Backward Chaining (Modus Tollens) → Used
in goal-driven reasoning (e.g., Prolog,
theorem proving).
Historical Developments and Key Systems
• 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.
• Integration of Systems and Query Techniques
• Systems like Microplanner, Prolog, and SQL
use backtracking to solve queries:
– Search relevant relations to find the desired data.
– Backtracking tries different options if a goal
cannot be met.
• Microplanner
• Derived from the Planner language.
• Used for expert systems and relational
databases.
• Implemented in SHRDLU by Terry Winograd
(1972) for natural language understanding.
• Supports both forward-chaining (commands)
and backward-chaining (queries).
• Uses goal-based logic with variables marked
by ?.
• Performs backtracking to satisfy conditions.
• Prolog
• Logic programming language based on
predicate logic.
• Uses uppercase variables and omits explicit
goal statements.
• Performs backtracking to find valid solutions.
• Syntax example: objects(X1,block,*) &
objects(X2,pyramid,*) & supports(X1,X2).
• Queries follow logical rules without
predefined execution order.
• SQL
• Structured Query Language for relational databases.
• Uses a verbose syntax with SELECT, FROM, and WHERE
clauses.
• Performs optimizations like indexing and reordering to
reduce backtracking.
• Syntax example: SELECT supporter FROM supports,
objects X1, objects X2 WHERE X1.shape = 'block' AND
X2.shape = 'pyramid' AND supporter = X1.id AND
supportee = X2.id;
• Query execution is optimized based on database
structure.
• All three use backtracking for query resolution, but SQL
optimizes execution dynamically, while Prolog and
Microplanner require manual goal ordering.
• 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.
• PLURALS AND SETS
• Handling plural expressions in logic is more
cumbersome than in English.
• Microplanner uses find operators to find
multiple matches.
• In Prolog, the setof predicate accumulates
search results into a list.
• SQL includes built-in operations such as
GROUP BY and HAVING clauses to efficiently
manipulate large sets of data.
• 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.
• Microplanner
• Uses the find operator to retrieve multiple
results.
• (find all ?xl
• (goal (objects ?xl block?))
• (find 3 ?x2
• (goal (objects ?x2 pyramid?))
• (goal (supports ?x2 ?xl))))
• Paraphrase: Find all xl (blocks) where three x2
(pyramids) support xl.
• 2. Prolog
• Prolog uses a rule-based logical syntax, emphasizing
backward chaining and pattern matching.
• Prolog Rule for sup_color:
• sup_color(S, C) :- supports(S, X), objects(X, *, C).
• In this Prolog rule:
– sup_color(S, C) is true if S supports some object X, and X
has a color C.
– 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.
• Forward-Chaining Rule in CLIPS to maintain
contains relationships:
• (defrule checkForBoxSupporter
• (supports ?x ?y)
• (objects ?x box ?)
• =>
• (assert (contains ?x ?y)))
• In this CLIPS rule:
– If ?x is a box and ?x supports some object ?y, it
asserts that ?x contains ?y.
– This proactively updates the database's contains
relationships to maintain constraints (e.g., boxes
containing anything they support).
• 4. Conceptual Graph Representation
• In Conceptual Graphs, queries are expressed
in a graph format close to natural language.
• For Example:
• Natural Language Query:
"Which blocks are supported by 3 pyramids?“
• CG Representation:
• [Person: ?]~(Inst)~[Like]-(Thme)-[IceCream].
• Breakdown of the Expression:
• [Person: ?]:
– This represents a Person. The ? is a variable, meaning the identity of the
person is unknown (we're looking for someone who has this property).
• ~(Inst):
– This is the relation between Person and the Like concept. The Inst
(instrument) indicates that the Person is the instrument or subject
performing the action of liking.
• [Like]:
– The Like is the action or relation, indicating the act of liking.
• -(Thme)-:
– The Thme (theme) is another relation, indicating the object or the thing
being liked. Here, it connects the Like relation to the object IceCream.
• [IceCream]:
– The object being liked is IceCream.
• A conceptual graph consists of:
• Concept Nodes → Represent entities, objects,
or ideas
– Example: [Car: Tesla], [Person: Alice]
• Relation Nodes → Represent relationships
between concepts
– Example: (Drives), (HasColor), (Supports)
• Edges → Connect concepts to relations
• [Person: Alice] → (Drives) → [Car: Tesla]
• 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).
• Each system has trade-offs:
– SQL excels at simple, declarative queries with large datasets.
– Prolog uses recursion and pattern matching but lacks native
support for some database operations.
– CLIPS provides fast updates and real-time constraint checks.
3.4 Object-Oriented Systems
• Integration of Declarations and Operations: