Information Technology Reference
In-Depth Information
Consider, for example, the Prolog clause
u:-p,b.
This can be represented by the Prolog term [u,p,b] . Similarly, a knowledge base can
be represented as a list whose elements represent the clauses. Consider, for example,
the following simple Prolog knowledge base:
a.
b.
u:-p,b.
p:-a.
This knowledge base can be represented using the following Prolog term:
[ [a], [b], [u,p,b], [p,a] ].
Of course, this list is not a knowledge base itself, but it can be used to represent one
as a Prolog term. Each element of this list is a nonempty list representing a clause.
(Atomic clauses are represented as lists with a single element.) Similarly, a query is
represented as a list of atoms.
With these list representations, there are now sentences in Prolog that talk about
the properties of knowledge bases and queries, just as previous sentences talked
about properties of people. In particular, the predicate est
should hold if the
query represented by q can be established by back-chaining from the knowledge base
represented by k . In other words, the following behavior is desired:
?- est([[a],[b],[u,p,b],[p,a]], [p,b]).
Yes
(
k , q
)
?- est([[a],[b],[u,p,b],[p,a]], [c]).
No
The first query should succeed because the knowledge base represented by the first
argument (that is, the four clauses just listed) logically entails both p and b , the query
represented by the second argument. The second query should fail because that same
knowledge base does not logically entail c .
How should this est predicate be defined? Keeping in mind that one is working
not with knowledge bases and queries but with symbolic representations of them as
lists, one can encode what was said about back-chaining in figure 11.1:
The predicate est
holds if one of the following holds:
1. q is the empty list (where k can be anything).
(
k , q
)
 
Search WWH ::




Custom Search