//----------------------------------------------------------------------------------- // Readme File for aplquery // Gregory Gelfond //----------------------------------------------------------------------------------- //----------------------------------------------------------------------------------- Prior to Installation: //----------------------------------------------------------------------------------- 1. In order to use aplquery you must have a Prolog system installed on your computer. The current development version of aplquery has been tested with Sicstus and SWI prolog. For best results, Sicstus Prolog is preferred. 2. In addition, you will need to make sure that either the LPARSE/SMODELS system or the DLV system is installed, and that the MKatoms postprocessor is installed on your system as well. On a UNIX system, these are typically installed in the directory /usr/local/bin. Make sure this directory is in your path. To add it to your path, edit your .bashrc or .profile files (if your shell is bash), or your .cshrc file (if your are using csh, or tcsh). For example, if you are using bash, then you would add $HOME/bin to the list of directories in your PATH settings: PATH=$PATH:$HOME/bin 3. Create a directory named bin in your home directory, this directory is where the aplquery_prep preprocessor is installed. //----------------------------------------------------------------------------------- Installing the preprocessor (aplquery_prep): //----------------------------------------------------------------------------------- In order to install aplquery_prep, capy the aplquery_prep directory to your home directory. Then do the following: $ cd aplquery_prep $ make $ make install $ make clean At this point, the aplquery_prep preprocessor is installed. //----------------------------------------------------------------------------------- Using aplquery: //----------------------------------------------------------------------------------- Suppose that we have the following AProlog program, saved in the file test.apl (written in the language of SModels) a(0..1). p(X) | q(X) :- a(X). r(b) :- p(1). In order to use the system, we first compute the answer sets of the program as follows: $ lparse test.apl | smodels 0 | mkatoms | aplquery_prep > models This command computes all of the answer sets of the program, and converts them to a Prolog program saved to the file 'models' which acts as a database for the aplquery system. Then, we do the following: $ sicstus -l aplquery % compiling /Users/gregory/Desktop/aplquery/aplquery.p... % compiled /Users/gregory/Desktop/aplquery/aplquery.p in module user, 20 msec 4772 bytes SICStus 3.11.1 (powerpc-darwin-7.2.0): Fri Feb 20 18:44:10 CET 2004 Licensed to ttu.edu | ?- [models]. Now both the query engine, and the database are loaded into the prolog interpreter, and we can begin asking queries. Ground queries have the following general form (here Q is a variable denoting the actual query): answer(sometimes, Q, yes). answer(sometimes, Q, no). answer(always, Q, yes). answer(always, Q, no). Non-ground queries have the general form: answer(sometimes, Q, S). answer(always, Q, S).