Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 39

CSNB234 Artificial Intelligence

Outline
• Formal Logic
• Semantic Networks
• Conceptual Graph
• Frames
• Scripts
• Production Rule
• Reasoning Methods in Production Rule Systems

1
CSNB234 Artificial Intelligence

Introduction
• Humans are best at understanding, reasoning, and
interpreting knowledge.
• Human knows things, which is knowledge and as
per their knowledge they perform various actions
in the real world.
• But how machines do all these things comes
under knowledge representation and reasoning?

2
CSNB234 Artificial Intelligence

Introduction
• So It is crucial for representing information about
the real world to a machine
• By doing that, computer/machine can
understand and can utilize this knowledge to
solve the complex real world problems such as
diagnosis a medical condition or communicating
with humans in natural language.
• Knowledge representation is not just storing
data into some database, but it also enables an
intelligent machine to learn from that
knowledge and experiences so that it can
behave intelligently like a human.
3
CSNB234 Artificial Intelligence

Introduction

– Knowledge - awareness or familiarity gained by


experiences of facts, data, and situations.
– Knowledge representation and reasoning (KR, KRR) is
the part of Artificial intelligence which need AI agents
thinking and how thinking contributes to intelligent
behavior of agents.

4
CSNB234 Artificial Intelligence

Knowledge Representation
• Types of knowledge which needs to be represented in
AI systems:
– Object: All the facts about objects in our world domain.
E.g., Guitars contains strings, trumpets are brass
instruments.
– Events: Events are the actions which occur in our world.
– Performance: It describe behavior which involves
knowledge about how to do things.
– Meta-knowledge: It is knowledge about what we know.
– Facts: Facts are the truths about the real world and what
we represent.
– Knowledge-Base: The central component of the
knowledge-based agents is the knowledge base. It is
represented as KB. The Knowledgebase is a group of the
Sentences (Here, sentences are used as a technical term
5
and not identical with the English language).
CSNB234 Artificial Intelligence

Knowledge Representation Techniques


• There are mainly four techniques of knowledge
representation :

6
CSNB234 Artificial Intelligence

Knowledge Representation Techniques

• Logical representation is a language with some


concrete rules which deals with propositions and has
no ambiguity in representation.
• Logical representation means drawing a conclusion
based on various conditions.
• This representation lays down some important
communication rules.
• It consists of precisely defined syntax and semantics
which supports the sound inference.
• Each sentence can be translated into logics using
syntax and semantics.
• Logical representation is categorized into 2:
• Propositional Logic and Predicate Logic (we learnt
this in chapter 3) 7
CSNB234 Artificial Intelligence

Knowledge Representation Techniques

Syntax:
•Syntaxes are the rules which decide how we
can construct legal sentences in the logic.
•It determines which symbol we can use in
knowledge representation.
•How to write those symbols.
Semantics:
Semantics are the rules by which we can interpret the
sentence in the logic.
Semantic also involves assigning a meaning to each
sentence. 8
CSNB234 Artificial Intelligence

Knowledge Representation Techniques

• A semantic net has a binary relation


• Concepts are represented by nodes
• Links between nodes represent the relationships
• Drawbacks:
• Disjunctive and conjunctive information
cannot be included into semantic nets
• E.g. apple can be either green or red
• E.g. panda has color black and white
9
CSNB234 Artificial Intelligence

Knowledge Representation Techniques

Examples of relationship labeled on arcs (notice that there


is an underscore)
is_a
has_a
has_part
Examples of concepts (nodes)
bird
person
book
famous
intelligent
10
CSNB234 Artificial Intelligence

Knowledge Representation Techniques

Please look at the arrow. When statement


said, Jerry is a cat, then the arrow 
EXAMPLE 1
Statements:
must pointing from Jerry to cat, and the
1.Jerry is a cat. label of the arrow is : is-a.
2.Jerry is a mammal
3.Jerry is owned by Priya.
4.Jerry is brown colored.
5.All Mammals are
animal.

11
CSNB234 Artificial Intelligence

Knowledge Representation Techniques

Example 2:
Draw a semantic network for the following description: Lab
is a room. Lab has a door. Lab has many computers. Printer
is in lab. Laser printer is a Printer.

has_a
DOOR

is_a
LAB ROOM
has

in COMPUTERS

is_a
PRINTERS LASER_PRINTER
12
CSNB234 Artificial Intelligence

Knowledge Representation Techniques

• The idea behind frames is to store information in


meaningful chunks.
• A frame is also known as slot-filter knowledge
representation in artificial intelligence. It consists of a
collection of slots and slot values. These slots may be
of any type and sizes.
• This frame has 4 slots:
BOOK
Title : Qualitative Reasoning
Author : Ken D. Forbus
Publisher : Prentice-Hall
Year : 2000 13
CSNB234 Artificial Intelligence

Knowledge Representation Techniques

• Let's suppose we are taking an entity, Peter.


Peter is an engineer as a profession, and his age
is 25, he lives in city London, and the country is
England. So following is the frame
representation for this:

14
CSNB234 Artificial Intelligence

Knowledge Representation Techniques

Advantages of frame representation:


• The frame knowledge representation makes the
programming easier by grouping the related data.
• The frame representation is comparably flexible
and used by many applications in AI.
• It is very easy to add slots for new attribute and
relations.
• It is easy to include default data and to search
for missing values.
• Frame representation is easy to understand and
visualize. 15
CSNB234 Artificial Intelligence

Knowledge Representation Techniques

• The human mental process is too complex to be represented as an


algorithm
• However, most experts are capable of expressing their knowledge in the
form of rules for their problem solving
• Production rules system consist of (condition, action) pairs which
mean, "If condition then action". It has mainly three parts:
• Facts, rules and inference engines are required to execute a rule-based
expert system
• Most Expert Systems (ES) are rule-based
– i.e. the knowledge-base of the ES consists of a huge set of
production rules (or just “rules”)
• Production-rules system captures knowledge in simple “if-then” format.
• e.g.
• IF the traffic-light is green THEN the action is go 16
CSNB234 Artificial Intelligence

Production Rules (cont.)

• A production rule model consists of two parts:


– the IF part, called antecedent or premise or
condition, and
– the THEN part, called consequent or conclusion or
action
condition
• In our earlier example:
• IF <the traffic-light is green> THEN <go>
• IF <the traffic-light is red> THEN <stop>

action
17
CSNB234 Artificial Intelligence

Production Rules
• The human mental process is too complex to be
represented as an algorithm
• However, most experts are capable of expressing
their knowledge in the form of rules for their
problem solving
• Facts, rules and inference engines are required to
execute a rule-based expert system
• Most Expert Systems (ES) are rule-based
– i.e. the knowledge-base of the ES consists of a huge set of
production rules (or just “rules”)
• Production-rules system captures knowledge in simple
“if-then” format.
• e.g.
• IF the traffic-light is green THEN the action is go 18
CSNB234 Artificial Intelligence

Production Rules (cont.)


• Multiple conditions are joined by the keywords AND
(conjunction), OR (disjunction) or a combination of
both.
• Example:
IF <condition-1>
IF <condition-1>
AND <condition-2>
OR <condition-2>
:
:
AND <condition-n>
OR <condition-n>
THEN <action>
THEN <action>
• Rule-based ES also use mathematical operators to
define an object as numerical and assign it to the
numerical value.
IF Age of the student < 21
AND SPM no. of A’s >= 8
THEN Admit the student to BIT 19
CSNB234 Artificial Intelligence

Production Rules (cont.)


• Rules can represent relations, recommendations,
directives and heuristics as follows:
Relations:

IF the fuel tank is empty


THEN the car will not start

Recommendation:

IF you study hard


AND you study smart
AND you never absent
THEN you will get an “A” 20
CSNB234 Artificial Intelligence

Production Rules (cont.)


Heuristics: Strategy:

IF the spill is liquid IF the car is dead


THEN check fuel tank
AND the spill pH is < 6
step 1 is complete
AND the smell is vinegar
THEN the spill material is acetic IF step 1 is complete
acid AND the fuel tank is full
THEN check battery
Directive: step 2 is complete

IF the fuel tank is empty IF step 2 is complete


THEN refuel the car AND the battery is replaced
THEN check electrical fuel lines
:
:

21
CSNB234 Artificial Intelligence

“Firing” of Rules
• When the condition part of a rule is satisfied,
the rule is said to fire and the action part is
executed.
• The inference engine carries out the reasoning
whereby the expert system reaches a solution.
It links the rules given in the KB with the facts
provided in the DB.
• The explanation facility enables the user to ask
questions such as “why” & “how”.

22
CSNB234 Artificial Intelligence

Reasoning Methods in Production Rule Systems

• There are two reasoning methods often use in


rule-based ES:

Forward Backward
chaining chaining
• Data-driven • Goal-driven
reasoning reasoning

23
CSNB234 Artificial Intelligence

Forward Chaining
• This is the data-driven reasoning.
• The reasoning starts from the known fact or
data and proceeds forward with the data.
• Each time only the topmost rule is executed.
• When fired, the rule adds a new fact in the
database. Powerful
mechanism
• Any rule can be executed only once.
• The match-fire cycle stops when no further
rules can be fired.

24
CSNB234 Artificial Intelligence

Forward Chaining (cont.)


• In the simplest sense, in forward chaining, it is
to:
– Collect the rule in KB whose condition
matches a fact in the DB
– Do actions indicated by the rule
• Add facts to the database or delete facts from DB
• Until the problem is solved or no condition match.

25
CSNB234 Artificial Intelligence

Forward Chaining (Example)


Given a rule-based Expert System with 4 rules:
• Rule 1: If A and C Then F
• Rule 2: If A and E Then G
• Rule 3: If B Then E
• Rule 4: If G Then D
Question: Prove If A and B true, then D is true.

KB DB
Rule 1: If A and C Then F
Rule 2: If A and E Then G
Rule 3: If B Then E
AB
Rule 4: If G Then D

26
CSNB234 Artificial Intelligence

Rule-based system
(Forward reasoning example)

27
CSNB234 Artificial Intelligence

Forward Chaining (Exercise)


Given a rule-based Expert System with 9 rules whose purpose is to advise you on how your health
is influenced by certain foods and other factors.
The rules are:
What if you are catholic, eat poultry and work 4 hours today? Advise the person on his health
situation.
Final Recommendation: The person is Healthy.

Rules that fired are: R9, R4, R2, R6 & Stopped.

R1: IF you eat beef or eggs THEN high cholesterol


R2: IF you eat fish or poultry and no beef THEN low cholesterol
R3: IF you eat no beef and no fish and no poultry THEN low cholesterol
R4: IF you are Catholic and today is Friday THEN you eat no fish and no beef
R5: IF you are a vegetarian THEN you eat no fish, no beef and no poultry
R6: IF low cholesterol THEN healthy
R7: IF high cholesterol THEN unhealthy
R8: IF you eat veal THEN you eat beef
R9: If you work 6 hours or less today THEN it is Friday
28
CSNB234 Artificial Intelligence

Forward Chaining (Exercise)


Question 1 (a):
Run a forward chaining system to determine the health
state of a person who eats veal.

Final goal: the person is R1: IF you eat beef or eggs THEN high
cholesterol
Unhealthy.
R2: IF you eat fish or poultry and no beef THEN
Rules that fired are: R8, R1, low cholesterol
R7 & Stopped. R3: IF you eat no beef and no fish and no
poultry THEN low cholesterol
R4: IF you are Catholic and today is Friday THEN
• Note: Conditions of other you eat no fish and no beef
rules are not satisfied thus R5: IF you are a vegetarian THEN you eat no
they are not executed in the fish, no beef and no poultry
R6: IF low cholesterol THEN healthy
forward chaining system to
R7: IF high cholesterol THEN unhealthy
conclude the “unhealthy” R8: IF you eat veal THEN you eat beef
decision. R9: If you work 6 hours or less today THEN it is
Friday 29
CSNB234 Artificial Intelligence

Forward Chaining (Exercise)


Given a rule-based Expert System with 9 rules whose purpose is to advise you on how your health is
influenced by certain foods and other factors.
The rules are:

R1: IF you eat beef or eggs THEN high cholesterol


R2: IF you eat fish or poultry and no beef THEN low cholesterol
R3: IF you eat no beef and no fish and no poultry THEN low cholesterol
R4: IF you are Catholic and today is Friday THEN you eat no fish and no beef
R5: IF you are a vegetarian THEN you eat no fish, no beef and no poultry
R6: IF low cholesterol THEN healthy
R7: IF high cholesterol THEN unhealthy
R8: IF you eat veal THEN you eat beef
R9: If you work 6 hours or less today THEN it is Friday

What if you are catholic, eat poultry and work 4 hours today? Advise the person on his health
situation.
Final Recommendation: The person is Healthy.

Rules that fired are: R9, R4, R2, R6 & Stopped.

30
CSNB234 Artificial Intelligence

Forward Chaining (Exercise)


Question 1 (b):
What if you are catholic, eat poultry and work 4 hours today? Advise the
person on his health situation. Justify your answer.
Final Recommendation: The person is Healthy.

Rules that fired are: R9, R4, R2, R6 & Stopped.

Students are required to give reason for why R9 is first fired?


Why was it chained to R4, etc.

• Also, students need to mention why other rules are not used.
• An example is given below:
– R1 is not used because no clue on ‘egg’.
– R3 is not fired because the person eats poultry. So the condition is false.
– R5 is not used since not told that he is a vegetarian.
– R8 is not fired since ‘”eat veal” is unknown.
31
CSNB234 Artificial Intelligence

Forward Chaining (Exercise)


Question 2:
• Suppose you have the following rules in your Knowledge base:
Rule 1: IF X is true
AND B is true Suppose a forward chaining (data-driven) system is
AND E is true used.
THEN Y is true
What “goal” would the system return if A, B, C, E are
true?
Rule 2: IF Y is true
AND D is true Explain how the result is obtained (e.g. show the
THEN Z is true reasoning path).

Rule 3: IF A is true Answer:


THEN X is true The system will return “W” as the goal.

How? By firing R3, R1, and R4. Other rules all failed.
Rule 4: IF Y is true
AND C is true
THEN W is true
32
CSNB234 Artificial Intelligence

MID TERM – TOP 12

1. Abbod Abdulrahman Salem Mohammed 47/48


2. Alzahrani Yara Khalid M 45/48
3. Ali Osman Rahman , Nur Mawaddah 43/48
4. Muhammad Hafeez Muhammad Ramizal 39.5
5. Al-Juhi Abdul Ghani, Khado Sultan Adel
38.5/48
6. Muhammad Ariff 37/48
7. Muhammad Bazly 36.5/48
8. Abdul Hakiim, Muhammad Denial Haiqal,
Muneera Said 36/48 33
CSNB234 Artificial Intelligence

Backward Chaining
• Backward chaining is the goal-driven reasoning.
• Best applied when we want to find out the
reason once something has occurred.
• In this reasoning method, the expert system is
trying to satisfy a goal (i.e. there is a
hypothetical solution) and the inference engine
move attempts to find the evidence to prove it.
• If evidences are found, the goal is proved.
• If not, backtracking is initiated.

34
CSNB234 Artificial Intelligence

Backward Chaining (cont.)


• Thus the inference engine puts the rule it is
working with (the rule is said to stack on) and
sets up a new goal (i.e. subgoal), to prove the
IF-part of this rule.
• Then the knowledge base is searched again for
rules that can prove the subgoal.
• The inference engine repeats the process of
stacking the rules until no rules are found in the
knowledge base to prove the current subgoal.
Backtracking
is done here
35
CSNB234 Artificial Intelligence

Backward Chaining (cont.)


• In the simplest sense, in backward chaining, to
prove a goal G, it is to check:
– If G is a fact then it is proven & stop.
– Otherwise, find a rule which can be used to
conclude G, and try to prove each of that
rule’s conditions.
• In proving G, try to prove each premise
(preconditions) of the rule that infers G.
• G is said to be proven (i.e. it is TRUE) if all the
premises are true (valid/hold).

36
CSNB234 Artificial Intelligence

Backward Chaining (Example)


Rules:
1. IF wake up at 4:00
THEN pack at 4:30
2. IF pack at 4: 30
THEN leave home by 5:00
3. IF leave home at 5:00
THEN park car by 5:15
4. IF park car at 5:15
THEN check in by 5:30
5. IF check in by 5:30
THEN catch 6:00 flight KNOWN GOAL

Procedure: Start with the rule that has the goal in its THEN part: catch the
6:00 flight (rule 5). Match that rule’s IF part to a preceding rule’s
THEN part (rule 4). Proceed in this way to arrive at the satisfying
premise (the IF part of rule 1):
Wake up at 4:00.
37
CSNB234 Artificial Intelligence

Backward Chaining (Example)

38
CSNB234 Artificial Intelligence

Summary
• Formal Logic
• Semantic Networks
• Conceptual Graph
• Frames
• Scripts
• Production Rule
• Reasoning Methods in Production Rule Systems

39

You might also like