12.6. Programs and Queries

A program is a collection of axioms, which are facts or rules (which you have yet to meet). A query is a structure that can prove itself against a program. Figure 12.3 shows the Program and Query classes.

Figure 12.3. The Program and Query classes. A program is a collection of axioms and an implementation of the AxiomSource interface. The Query class has a constructor that accepts a source of axioms and a structure to unify with the axioms.

The following Java program creates a logic program, loads it with facts, and uses a query to extract all its results:

 package sjm.examples.engine; import sjm.engine.*; /** * Show ...

Get Building Parsers with Java™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.