5 Loading and Listing Knowledge Bases

You can also tell the system a set of clauses from a file. The command:

ailog: load 'filename'.

where 'filename' is the name (enclosed in single quotes) of a file that contains a sequence of clauses (each clause ending with a period), adds the clauses to the knowledge base as though they had been told to the system. Note that the file does not contain tell commands; it just contains the clauses.

Within files (and at any prompt), comments can be included between a "%" and the end of a line, or between "/*" and "*/".

Loading a file adds the clauses to the database. It does not replace definitions. To clear the knowledge base you can issue the command:

ailog: clear.

To remove all clauses with head atom from the knowledge base, you issue the command:

ailog: clear atom.

To list the contents of the knowledge base you can issue the command:

ailog: listing.

This gives a listing of the whole knowledge base that is suitable for copying to a file and loading in a subsequent AILog session.

To get a listing of all clauses in the knowledge base whose head unifies with atom, you can issue the command:

ailog: listing atom.

Note that in listings, and any time atoms with free variables are written, the variables are renamed. The system does not remember the names you gave the variables. It just calls them A, B, C, etc.

Example. Suppose the file "genealogy.cil" contains the rules from Example 4. The following shows how the file can be loaded and listed.
ailog: load 'genealogy.cil'.
AILog theory genealogy.cil loaded.
ailog: listing.
parent(A,B) <- mother(A,B).
parent(A,B) <- father(A,B).
grandfather(A,B) <- father(A,C) & parent(C,B).
grandmother(A,B) <- mother(A,C) & parent(C,B).
father(randy,sally).
father(randy,joe).
mother(sally,mary).
father(joe,sue).
ailog: 

To load a file that uses Prolog syntax, you can issue the command:

ailog: prload 'filename'.

This assumes the clauses in the file use the Prolog implication :- and use a comma for conjunction. This does not allow the use of Prolog extra-logical predicates.

One useful command to check your knowledge base is the command:

ailog: check.

This lists the rules in the knowledge base with atoms in the body which don't unify with the head of any clause in the knowledge base (or any askable or assumable). This is a simple check that the rule can never be used in a proof. This is useful as this is usually an indication that there is a problem with the knowledge base.

This static check replaces the dynamic "undefined predicate" exception of Prolog, but is more useful in that it can be done before asking any queries, it finds clauses that contain atoms that must immediately fail (even if there are other clauses with the same predicate symbol). The warning can be ignored if that is what you intended (for example if you intend to add appropriate clauses later).