4 Ask and Tell

The general interaction with AILog is to tell it clauses and to ask it queries (which are bodies). It replies with answers, which are instances of the query that are consequences of its knowledge base. The user can then either explore how the system derived an answer or why the system didn't find another answer.

To add a clause to the knowledge base you issue the command:

ailog: tell clause.
Example. You could tell the system some genealogy knowledge:
ailog: tell parent(X,Y) <- mother(X,Y).
ailog: tell parent(X,Y) <- father(X,Y).
ailog: tell grandfather(X,Y) <- father(X,Z) & parent(Z,Y).
ailog: tell grandmother(X,Y) <- mother(X,Z) & parent(Z,Y).
ailog: tell father(randy,sally).
ailog: tell father(randy,joe).
ailog: tell mother(sally,mary).
ailog: tell father(joe,sue).

You can ask a query to determine if some body is a consequence of the knowledge base:

ailog: ask query.

where query is a body. 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:

to indicate that you don't want any more answers
to ask for more answers
to investigate how that answer was produced (see Section 6.1)
to get a menu of available answers (this option is available at all points where the system is asking for a response)

If you reply with more, the system either finds another answer or reports there are no more answers.

Example. Given the knowledge base after Example 4, you can ask queries of the knowledge base:
ailog: 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.

ailog: 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:

ailog: 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.