4 Ask and Tell |
To add a clause to the knowledge base you issue the command:
cilog: tell clause.
Example.
You could tell the system some genealogy knowledge:
cilog: tell parent(X,Y) <- mother(X,Y).
cilog: tell parent(X,Y) <- father(X,Y).
cilog: tell grandfather(X,Y) <- father(X,Z) & parent(Z,Y).
cilog: tell grandmother(X,Y) <- mother(X,Z) & parent(Z,Y).
cilog: tell father(randy,sally).
cilog: tell father(randy,joe).
cilog: tell mother(sally,mary).
cilog: tell father(joe,sue).
cilog: ask query.where query is an expression. The system will respond with either an instance of the query that is a consequence of the knowledge base or "No. query doesn't follow from the knowledge base" if there are no answers. When the system have given an answer you can reply with:
Example.
Given the knowledge base after Example 4, you can ask queries of the knowledge base:
cilog: ask grandfather(randy,mary).
Answer: grandfather(randy,mary).
[ok,more,how,help]: ok.
It has thus told you that grandfather(randy,mary) is a consequence of the knowledge base.
cilog: ask grandfather(joe,mary).
No. grandfather(joe,mary) doesn't follow from the knowledge base.
which means grandfather(joe,mary) is not a consequence of the knowledge base.
You can ask queries with free variables:
cilog: ask grandfather(G,C). Answer: grandfather(randy,mary). [ok,more,how,help]: more. Answer: grandfather(randy,sue). [ok,more,how,help]: more. No more answers.This means there are two instances of the query grandfather(G,C) that are consequences of the knowledge base.
4 Ask and Tell |