[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5. Solving Queries

When the simulator is running, the user may pose queries that he/she wishes to have solved in the usual logic programming style. The simulator is typically activated in a state in which the code in a particular module is available for parsing and solving queries. This may happen through the invocation of a command such as the following

 
gluttony% tjsim lists

Execution of this particular command will cause the code from the module lists.mod (that should previously have been compiled to produce the byte code file lists.lp) to be loaded and made available for the purpose of answering queries. At the end of this process, the user will be greeted with the prompt

 
[lists] ?-

Queries may be entered at this prompt, terminated, as usual, by a full stop (.).

By omitting a module name in the command shown above, the simulator can be started up with only the builtin predicates and constants available for interpreting and answering queries. The (query) prompt in this case will take the form

 
[toplevel] ?-

The simulator can also be activated from within the integrated Lambda Prolog development environment. Note that if the code in a module is to be used in this case, then the module must be loaded (using the #load directive) before the simulator is started up (using the #query directive) with the code in the module providing the background environment for queries.

The global sorts, type constructors, operators and constants defined in a module are added to the builtin ones for the purpose of interpreting a query relative to the module. New sorts, type constructors and constants may be introduced implicitly in the query. (This `feature' may disappear in a later version of the system so should be used sparingly.)

Teyjus does not at present support the full syntax for goals available through the use of the logic of hereditary Harrop formulas at the query level. In particular implications are not permitted in queries at this point. This restriction will be lifted when interpretation is integrated with the present compilation based model for execution. (See Special Characteristics of the Teyjus Implementation. for a further discussion of this point.)

The query stop will exit the simulator, returning to the top level if you are running `teyjus'. The query halt will terminate the current Lambda Prolog session.

Queries can also be specified on the command line as is done in the following example:

 
gluttony% tjsim lists "append L1 L2 [1,2,3,4]."

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Gopalan Nadathur on October, 20 2007 using texi2html 1.76.