11 Knowledge Representation 22-08-2024
11 Knowledge Representation 22-08-2024
Representation Using
Rule-Based System
The importance of knowledge
representation
Inference Engine
Explanation Facilities
User Interface
User
23
■ The human mental process is internal, and it is too
complex to be represented as an algorithm.
However, most experts are capable of expressing
their knowledge in the form of rules for problem
solving.
25
Rules as a knowledge representation technique
IF IF antecedent
antecedent 1 AND 1 OR
ante.cedent 2
. .
ante.cedent 2
AND antecedent OR antecedent
n
THEN consequent THEN consequent
n
27
■ The antecedent of a rule incorporates two parts: an
object (linguistic object) and its value. The object and
its value are linked by an operator.
■ The operator identifies the object and assigns the
value. Operators such as is, are, is not, are not are
used to assign a symbolic value to a linguistic object.
■ Expert systems can also use mathematical operators
to define an object as numerical and assign it to the
numerical value.
IF ‘age of the customer’ <
18 AND ‘cash withdrawal’ >
1000
THEN ‘signature of the parent’
is required 28
Rules can represent relations, recommendations,
directives, strategies and heuristics:
■ Relation
IF the ‘fuel tank’ is
empty THEN the car is dead
■ Recommendation
IF the season is
autumn AND the sky is cloudy
AND the forecast is
drizzle
THEN the advice is ‘take
an umbrella’the car is dead
■ DirectivePearson
Negnevitsky, the ‘fuel tank’
Education, is empty
2011
IF the action is ‘refuel the car’
AND 29
THEN
■ Str ategy
IF the car is dead
THEN the action is ‘check the fuel tank’;
step1 is complete
IF step1 is complete
AND the ‘fuel tank’ is full
THEN the action is ‘check the battery’;
step2 is complete
■ Heuristic
IF the spill is liquid
AND the ‘spill pH’ <
AND 6
THEN the ‘spill smell’
is vinegar
the ‘spill 30
material’ is
Forward chaining and backward chaining
■. The inference engine compares each rule stored
in the knowledge base with facts contained in the
database. When the IF
(condition) part of the rule matches a fact, the rule
is fired and its THEN (action) part is executed.
■ The matching of the rule IF parts to the facts
produces inference chains. The inference chain
indicates how an expert system applies the rules to
reach a conclusion.
31
Forward chaining
■ Forward chaining is the data-driven reasoning.
The reasoning starts from the known data and
proceeds forward with that data. Each time
only the topmost rule is executed. When fired,
the rule adds a new fact in the database. Any rule
can be executed only once. The match-fire cycle
stops when no further rules can be fired.
32
Types of Rule-Based Systems
• Forward Chaining:
Process: Starts with known facts and applies rules
to infer new facts until a goal is achieved. Example: In a
medical diagnosis system, starting with symptoms and
applying rules to infer the possible disease.
• Backward Chaining:
Process: Begins with a goal and works backward to
determine the facts needed to achieve that goal.
Example: In legal reasoning, starting with the conclusion
of guilt and determining what evidence is needed to
support this conclusion.
Forward Chaining
Backward chaining or goal-driven inference works towards a final state, and by looking at the
working memory to see if goal already there. If not look at the actions (THEN-parts) of rules that will
establish goal, and set up subgoals for achieving premises of the rules (IF-part).
This continues until some rule can be applied, apply to achieve goal state.
Advantage of backward chaining:search is directed Disadvantage of backward chaining:goal has to
be known
Example of Rule-Based System
• Example: Medical Diagnosis System
Scenario: A system that helps diagnose diseases based on
patient symptoms.
Rules:
• "If a patient has a sore throat and a fever, then suspect a throat
infection."
• "If a patient has a rash and a fever, then suspect measles."
Process:
• The system starts with known symptoms (facts) and applies the rules to
diagnose the disease.
Outcome: The system concludes that the patient may have a
throat infection based on the symptoms provided.
Advantages of Rule-Based Systems
• Easy to Understand and Implement:Rule-based
systems are straightforward to design and implement.
Rules are intuitive and can be easily updated or
modified.
• Transparent Reasoning Process:The decision-
making process is transparent, making it easier to trace
how a particular conclusion was reached. This is
especially important in fields like medicine or law,
where decisions must be explainable.
• Flexibility in Modifying Rules:Rules can be added,
removed, or modified without restructuring the entire
system, allowing for easy maintenance and updates as
Disadvantages of Rule-Based
Systems
• Scalability Issues: As the number of rules increases, the
system can become complex and slow, leading to
performance issues.
• Handling Uncertainty and Conflicting Rules: Rule-based
systems struggle with uncertainty and may have difficulty
resolving conflicts between rules. For example, if two rules
suggest different actions under the same conditions, the
system may not know which to follow.
• Limited Learning Capability: These systems do not learn or
adapt on their own. They rely entirely on predefined rules,
which limits their ability to handle new or evolving situations
without manual updates.
Applications of Rule-Based Systems
• Expert Systems:Medical Diagnosis: Systems like
MYCIN, which assists doctors in diagnosing infections
and recommending treatments based on patient
symptoms.
• Decision Support Systems:Financial Decision-
Making: Systems that assist in making investment
decisions by applying rules to financial data.
• Game AI:Strategic Games: Rule-based logic is used
in games like chess to determine the best possible
moves based on the current game state.
Enhancing Rule-Based Systems
• Incorporation of Fuzzy Logic:Purpose: Handle
uncertainty by allowing rules to operate with degrees of
truth rather than binary true/false values.Example: "If
the temperature is high, then increase the cooling" can
be handled more flexibly with fuzzy logic to account for
varying levels of "high" temperature.
• Integration with Machine Learning:Purpose: Enable
the system to adapt and evolve by learning from data,
allowing for the automatic generation or refinement of
rules.Example: A fraud detection system that learns
new fraud patterns over time and updates its rules
accordingly.
• Use of Meta-Rules:
Purpose: Introduce rules about the rules themselves,
allowing for more sophisticated reasoning and decision-
making processes.
Example: Meta-rules could determine which rule to
apply when multiple conflicting rules are triggered.
Facts (Family Information):
03/12/2024 55
Semantic Net - Reasoning in
Semantic Net
Reasoning in semantic networks allows us to draw
inferences from structured knowledge through:
1.Inheritance Reasoning: Where concepts inherit
properties from parent concepts.
2.Deductive Reasoning: Where we derive conclusions
based on relationships and known rules.
3.Analogical Reasoning: Where we infer properties
based on similarity between concepts.
• These reasoning mechanisms make semantic networks
a powerful tool for knowledge representation and
inference in AI systems.
Inheritance Reasoning
• Inheritance reasoning in a semantic network allows objects or concepts to inherit properties or relationships
from other objects or concepts higher in the hierarchy.
frame(car, [
color: red,
wheels: 4,
engine_type: combustion
• 2 Linking to Other Frames
Slots can be used to link one frame to another.
This helps in organizing knowledge hierarchically, modeling
relationships between objects, or inheriting properties.
frame(car, [
wheels: 4,
engine: frame(combustion_engine, [
fuel_type: petrol,
horsepower: 200
])
]).
In this example, the engine slot in the car frame links to
another frame called combustion_engine, which has its
own set of attributes (fuel_type, horsepower).
• Example Use of Slots, Values, and Links
frame(vehicle, [
type: nil, % Slot initially unfilled
wheels: 4, % Default value
engine: nil, % Slot linking to another frame
color: unknown % Value unfilled, could be filled later
]).
frame(car, [
type: sedan,
engine: frame(combustion_engine, [
fuel_type: petrol,
horsepower: 180
])
]).
frame(hotel_room, [
room_number: 101,
room_type: double,
price_per_night: 150,
bed: frame(hotel_bed, [
bed_type: queen,
mattress: frame(mattress, [
size: queen,
firmness: medium,
material: memory_foam
])
]),
chair: frame(hotel_chair, [
chair_type: armchair,
material: leather,
comfort_level: high
]),
phone: frame(hotel_phone, [
phone_type: landline,
service_options: [room_service,
front_desk],
model: 'HotelPro-1000'
])
]).
• Frames can also support inferencing through slot-
filling and default reasoning.
Types of Inferencing in Frames:
1.Default Reasoning: If a slot has a default value, that
value is assumed unless explicitly changed.
1.Example: If the slot "Sound" in a Dog frame defaults to "Bark,"
all dogs can be assumed to bark unless specified otherwise.
2.Slot-Based Inference: Relationships can be inferred
from slot values.
1.Example: If a "Car" frame has a slot "Fuel Type" filled with
"Gasoline," we can infer that the car runs on gasoline.
Frame Network -
Example
university
a_part_of
d e p a rtm e n t h o stel
a _ p a rt_ o f is_a
ako
science_faculty
is_a
renuka
Detailed Representation of Frame
Network fra m e 0
f_name: university
pho ne : (default: - 0 11 6 8 6 9 7 1 )
address : (default - IIT Delhi)
fra m e 1 fra m e 2
f _ n a me : department f _ n a me : hostel
a_part_of : frame0 a_part_of : frame0
p r o g r a m m e : [Btech, Mtech, Ph.D] r o o m : (default - 100)
frame11 frame21