download

Matakuliah
Tahun
Versi
: T0264/Inteligensia Semu
: Juli 2006
: 2/1
Pertemuan 8
Representing Knowledge Using Rules
1
Learning Outcomes
Pada akhir pertemuan ini, diharapkan mahasiswa
akan mampu :
• << TIK-99 >>
• << TIK-99>>
2
Outline Materi
•
•
•
•
•
Materi 1
Materi 2
Materi 3
Materi 4
Materi 5
3
6.1 Procedural vs Declarative Knowledge
• A declarative representation is one in which
knowledge is specified, but the use to which that
knowledge is to be put is not given. To use a
declarative representation, we must augment it
with a program that specifies what is to be done to
the knowledge and how.
• A procedural representation is one in which the
control information that is necessary to use the
knowledge is considered to be embedded in the
knowledge it self. To use a procedural
representation, we need to augment it with an
interpreter that follows the instructions given in the
knowledge.
4
Procedural vs Declarative Knowledge
Consider the knowledge base :
man(Marcus)
man(Caesar)
person(Cleopatra)
x : man(x)  person(x)
Supose we want to answer the question
y : person(y)
5
Procedural vs Declarative Knowledge
We could answer with any one of :
y = Marcus
y = Caesar
y = Cleopatra
Now consider an alternative Knowledge Base :
man(Marcus)
man(Caesar)
x : man(x)  person(x)
person(Cleopatra)
6
6.2 Logic Programming
PROLOG
A PROLOG program is composed of a set of Horn
clauses.
A Horn clause is a clause that has at most one
positive literal.
Examples :
p
p  q
r  s r  s
7
Logic Programming
A Declarative and a Procedural
Representation
A Representation in Logic
x : pet(x)  small(x)  apartmentpet(x)
x : cat(x)  dog(x)  pet(x)
x : poodle(x)  dog(x)  small(x)
poodle(fluffy)
8
Logic Programming
A Representation in PROLOG
apartmentpet(x)
pet(x)
pet(x)
dog(x)
small(x)
poodle(fluffy).
: - pet(x), small(x).
: - cat(x).
: - dog(x).
: - poodle(x).
: - poodle(x).
9
Logic Programming
Answering Question in PROLOG
?- apartmentpet(x).
?- cat(fluffy).
?- cat(mittens).
10
6.3 Forward vs Backward Reasoning
Reasoning choose forward or backward
•
•
•
•
Number of start and goal states. We would like to
move from smaller set of state to the large set of state
Branching factor in each direction. We would like to
proceed in the direction with the lower branching factor
Need to justify reasoning. If so, it is important to
proceed in the direction that corresponds more closely
with the way the user will think.
Triggers for problem solving. If it is the arrival of new
fact, forward reasoning makes sense. If it is a query to
which a response is desired, backward reasoning ai
more natural.
11
Forward vs Backward Reasoning
Sample or the Rules for Solving the 8Puzzle
Assume the areas of the tray are numbered:
12
Forward vs Backward Reasoning
Square 1 empty and Square 2 contains tile n 
Square 2 empty and Square 1 contains tile n
Square 1 empty and Square 4 contains tile n 
Square 4 empty and Square 1 contains tile n
Square 2 empty and Square 1 contains tile n 
Square 1 empty and Square 2 contains tile n
13
Forward vs Backward Reasoning
An Example :
14
Forward vs Backward Reasoning
• Forward rules, which encode knowledge
about how to respond to certain input
configurations.
• Backward rules, which encode knowledge
about how to achieve particular goals.
15
Forward vs Backward Reasoning
A Bad Use of Heuristic Bidirectional
Search
16
6.4 Matching
• How we extract from the entire collection of rules
those that can be applied at a given point ?
• To do so requires some kind of matching
between the current state and the preconditions
of the rules.
• How should this be done ??
- Indexing
- Matching with Variable
- Complex and Approximate Matching
- Conflict Resolution
17
Indexing
• One legal chess move
18
Indexing
• Another Way to Describe Chess Move
White pawn at
Square(file e, rank 2)
AND
Square(file e, rank 3)  move pawn from
is empty
Square(file e, rank 2)
AND
to Square(file e, rank 4)
Square(file e, rank 4)
is empty
19
Matching with Variable
Many-to-Many Matching
• The temporal nature of data.
• Structural similarity in rules.
mammal(x)  feline(x)  carnivorous(x)  hasspots(x)  jaguar(x)
mammal(x)  feline(x)  carnivorous(x)  hasstripes(x)  tiger(x)
20
Matching with Variable
•
Persistance of variable binding
consistency.
son(x,y)  son(y,z)  grandparent(x,z)
21
Complex and Approximate Matching
A Bit of Dialogue with ELIZA
Person:
Men are all alike.
ELIZA:
In what way?
Person:
They’re always bugging us
about something or other.
ELIZA:
Can you think of a specific example?
Person:
Well, my boyfriend made me come
here.
ELIZA:
Your boyfriend made you come here.
22
Complex and Approximate Matching
Person:
ELIZA:
Person:
ELIZA:
Person:
ELIZA:
He says I’m depressed much of
the time.
I am sorry to hear you are
depressed.
It’s true. I am unhappy.
Do you think coming here will help
you not to be unhappy?
I need some help, that much
seems certain.
What would it mean to you if you
got some help?
23
Complex and Approximate Matching
Person:
ELIZA:
Perhaps I could learn to get along
with my mother.
Tell me more about your family.
24
Complex and Approximate Matching
• Some ELIZA - like rules
(X me Y)

(X you Y)
(I remember Z)  (Why do remember X just now ?)
(My {family-member} is Y)  (Who else in your
family is Y)
(X {family-member} Y)  (Tell me more about your
family)
25
Conflict Resolution
• Preferences based on rules
 Rule order
 Prefer special cases over more general
ones
• Preferences based on objects
 Prefer some objects to others
 location in STM
• Preferences based on states
26
6.5 Control Knowledge
Syntax for a Control Rule
Under conditions A and B,
Rules that do {not} mention X
{ at all,
in their left-hand side,
in their right-hand side}
27
Control Knowledge
will
{ definitely be useless,
probably be useless
...
probably be especially useful
definitely be especially useful}
28
Control Knowledge
•
•
1.
2.
3.
4.
Knowledge about which paths are most likely to
lead quickly to a goal state is often called search
control knowledge.
It can take many forms :
Knowledge about which states are more
preferable to others
Knowledge about which rule to apply in a given
situation
Knowledge about the other in which to pursue
subgoals
Knowledge about useful sequences of rules to
apply
29
<< CLOSING>>
End of Pertemuan 8
Good Luck
30