Knowledge and search Points Properties of knowledge The role of search
Download
Report
Transcript Knowledge and search Points Properties of knowledge The role of search
Knowledge and search
Points
Properties of knowledge
Completeness
Objectivity
Certainty
Formalizability
The role of search
A small case study
CSI 4106, Winter 2005
Knowledge and search, page 1
Properties of knowledge:
completeness
"Knowledge is always incomplete":
true or false?
What do we need to know when we
• play a game?
• make a holiday plan?
• recognize a picture?
CSI 4106, Winter 2005
Knowledge and search, page 2
... completeness (2)
Even in a very restricted real-life domain
there may be unexpected situations. Find
examples of such situations in
• buying groceries,
• fixing a car.
Knowledge contained in an AI software
system for some application is necessarily
much less complete than what we know
about this application: true or false?
CSI 4106, Winter 2005
Knowledge and search, page 3
Properties of knowledge:
objectivity
Knowledge may be objective or subjective: we have
to make a distinction between facts and beliefs.
Beliefs are associated with agents.
• Jack is planning a gift for his mother. He believes
that she dislikes classical music. Will he buy a
Mozart CD for her?
• Is there anything subjective in the game of chess?
• Is there anything objective in art appreciation?
CSI 4106, Winter 2005
Knowledge and search, page 4
Properties of knowledge:
certainty
Knowledge may be certain or uncertain. Diagnostic
expert systems are a good example: faults and repair
advice do not always logically follow from observations
or symptoms.
What (if anything) can we conclude with certainty from
• a sick person's short breath?
• a car engine noise?
• a position in a chess game?
Probability plays an essential role here -- more to come,
later.
CSI 4106, Winter 2005
Knowledge and search, page 5
Properties of knowledge:
formalizability
Knowledge may or may not be easily formalized
-- written down in some symbolic language
(recall the physical-symbol systems).
People often operate in an approximate manner
and allow themselves a margin of error.
Perhaps the same should be possible for
intelligent systems, except that systems only
have explicit knowledge that has been put into
them.
CSI 4106, Winter 2005
Knowledge and search, page 6
... formalizability (2)
People rely on experience; systems must have
experience formalized as well.
Which of the following can be formalized
(represented!) with little effort:
• the rules of ice hockey?
• the relationship between moods and colours?
• the decision-making of a loan officer in a bank?
• a surgical procedure?
CSI 4106, Winter 2005
Knowledge and search, page 7
The role of search
Intelligent behaviour requires knowledge.
There is a hypothesis is that intelligent
action can be reduced to search.
While intelligence is certainly more than
search, the hypothesis is attractive:
search is well understood, easily
mechanized, manageable, and so on.
Formally represented knowledge can also
be easily used in search.
CSI 4106, Winter 2005
Knowledge and search, page 8
The role of search (2)
Search means systematic traversal
of a space of possible solutions of a
problem.
A search space is usually a graph
(often as simple as a tree).
A node represents a partial solution.
An edge represents a step in the
construction of a solution.
CSI 4106, Winter 2005
Knowledge and search, page 9
The role of search (3)
The purpose of search may be:
• to find a path in the graph from a start node
to a goal node (that is, from an initial to a final
situation),
• to find a goal node.
Examples in textbooks are often puzzles and
games -- not surprisingly, because these
problems are the easiest to present as
search. The challenge is to try it with other
kinds of problems.
CSI 4106, Winter 2005
Knowledge and search, page 10
The role of search (4)
Examples of such problems:
• Analyze an English sentence.
• Debug a Pascal procedure.
• Program a robot.
CSI 4106, Winter 2005
Knowledge and search, page 11
A small case study
A farmer has a wolf, a goat and a cabbage.
He wants to cross the river from the south
bank to the north bank.
There is a boat that can only carry the
farmer and at most one of his possessions.
The wolf left alone with the goat will eat it.
The goat left alone with the cabbage will eat
it.
How can the farmer cross the river and lose
none of the three?
CSI 4106, Winter 2005
Knowledge and search, page 12
... case study (2)
This is a classical example of a planning problem. We
must find a sequence of actions that will take the farmer
across the river. At each moment, the whole situation is
in one of its possible states.
A state describes the position of the farmer, his three
possessions and the boat with respect to the north and
south bank of the river.
An action is one crossing of the river, north or south. As
a result of such an action, the farmer, the boat and
possibly one of the three objects transfer from one bank
to the other. There are constraints on actions, as no
action should leave to an unsafe state.
CSI 4106, Winter 2005
Knowledge and search, page 13
... case study (3)
In the initial situation, everything is on the south bank.
In the desired final situation the farmer and his three
possessions are on the north bank.
We will represent a situation as a four-tuple of
locations: of the farmer, the wolf, the goat and the
cabbage. We do not need to represent the position of
the boat, because in is always located on the same
bank as the farmer. For example, in the situation
situation(s, n, s, n)
the farmer and the goat are on the south bank, and
the other two on the north bank. Is this situation safe?
CSI 4106, Winter 2005
Knowledge and search, page 14
... case study (4)
We represent the initial situation as
situation(s,s,s,s)
and the final situation as
situation(n,n,n,n)
Four actions are possible in each situation. The
farmer transfers himself to the opposite bank; he
also transfers nothing, or the wolf, or the goat, or
the cabbage.
We will represent these actions as Prolog terms:
moved( nothing )
moved( wolf )
moved( goat )
moved( cabbage )
CSI 4106, Winter 2005
Knowledge and search, page 15
... case study (5)
A situation is safe if it is safe both for the goat and
the cabbage. The goat is safe if the farmer is on the
same bank of the river, or when the wolf is not. The
cabbage is safe if the farmer is on the same bank,
or when the goat is not.
We can express in Prolog everything we know
about this problem. First, the main predicate:
successfulMoves( Mvs ) :movesLeadingTo( Mvs,
situation( n, n, n, n ) ).
Mvs is a list of representations of actions.
CSI 4106, Winter 2005
Knowledge and search, page 16
... case study (6)
No actions are necessary to stay in the initial situation:
movesLeadingTo( [],
situation( s, s, s, s ) ).
Otherwise, let Mvs1 be a list of legal actions leading to
situation S1. Perform one more action and add it to
Mvs1:
movesLeadingTo( Mvs, S ) :movesLeadingTo( Mvs1, S1 ),
transforms( Mv, S1, S ),
append( Mvs1, [Mv], Mvs ),
safe( S ).
CSI 4106, Winter 2005
Knowledge and search, page 17
... case study (7)
North is opposite south:
opposite( n, s ).
opposite( s, n ).
The four possible actions:
transforms( moved( nothing ),
situation( X, Z1, Z2, Z3 ),
situation( Y, Z1, Z2, Z3 ) )
opposite( X, Y ).
transforms( moved( wolf ),
situation( X, X, Z2, Z3 ),
situation( Y, Y, Z2, Z3 ) )
opposite( X, Y ).
:-
:-
continued
CSI 4106, Winter 2005
Knowledge and search, page 18
... case study (8)
transforms( moved( goat ),
situation( X, Z1, X, Z3 ),
situation( Y, Z1, Y, Z3 ) )
opposite( X, Y ).
transforms( moved( cabbage ),
situation( X, Z1, Z2, X ),
situation( Y, Z1, Z2, Y ) )
opposite( X, Y ).
:-
:-
The safety rules are as discussed earlier:
safe( S ) :safe_for_goat( S ),
safe_for_cabbage( S ).
CSI 4106, Winter 2005
Knowledge and search, page 19
... case study (9)
The farmer and the goat together:
safe_for_goat(
situation( X, Z1, X, Z3 ) ).
The wolf and the goat separated:
safe_for_goat(
situation( X, Z1, Y, Z3 ) ) :opposite( Z1, Y ).
CSI 4106, Winter 2005
Knowledge and search, page 20
... case study (10)
The same for the goat and the cabbage:
safe_for_cabbage(
situation( X, Z1, Z2, X ) ).
safe_for_cabbage(
situation( X, Z1, Z2, Y ) ) :opposite( Z2, Y ).
And finally here is a solution:
?- successfulMoves( Mvs ).
Mvs = [moved(goat), moved(nothing),
moved(wolf), moved(goat), moved(cabbage),
moved(nothing), moved(goat)]
Yes
CSI 4106, Winter 2005
Knowledge and search, page 21
... case study (11)
This program requires cuts in the definitions of
safe_for_cabbage and safe_for_goat if it is
to lose its annoying nondeterminism. It will then
quickly deliver the other optimal solution:
Mvs = [moved(goat), moved(nothing),
moved(cabbage), moved(goat),
moved(wolf), moved(nothing),
moved(goat)]
After that, the program begins to deliver nonoptimal solutions, longer and longer, with the
unproductive moved(X), moved(X) inserted
just about everywhere.
CSI 4106, Winter 2005
Knowledge and search, page 22