Common Lisp Package: PAIPROLOG

README:

FUNCTION

Public

< (NUMBER &REST MORE-NUMBERS)

Return T if its arguments are in strictly increasing order, NIL otherwise.

= (NUMBER &REST MORE-NUMBERS)

Return T if all of its arguments are numerically equal, NIL otherwise.

> (NUMBER &REST MORE-NUMBERS)

Return T if its arguments are in strictly decreasing order, NIL otherwise.

>= (NUMBER &REST MORE-NUMBERS)

Return T if arguments are in strictly non-increasing order, NIL otherwise.

ATOM (OBJECT)

Return true if OBJECT is an ATOM, and NIL otherwise.

CATCH (TAG &BODY BODY)

CATCH tag form* Evaluate TAG and instantiate it as a catcher while the body forms are evaluated in an implicit PROGN. If a THROW is done to TAG within the dynamic scope of the body, then control will be transferred to the end of the body and the thrown values will be returned.

CHAR-CODE (CHAR)

Return the integer code of CHAR.

IF (TEST THEN &OPTIONAL ELSE)

IF predicate then [else] If PREDICATE evaluates to true, evaluate THEN and return its values, otherwise evaluate ELSE and return its values. ELSE defaults to NIL.

READ (&OPTIONAL (STREAM *STANDARD-INPUT*) (EOF-ERROR-P T) (EOF-VALUE NIL) (RECURSIVE-P NIL))

Read the next Lisp value from STREAM, and return it.

THROW (TAG RESULT)

THROW tag form Do a non-local exit, return the values of FORM from the CATCH whose tag is EQ to TAG.

WRITE (OBJECT &KEY ((STREAM STREAM) *STANDARD-OUTPUT*) ((ESCAPE *PRINT-ESCAPE*) *PRINT-ESCAPE*) ((RADIX *PRINT-RADIX*) *PRINT-RADIX*) ((BASE *PRINT-BASE*) *PRINT-BASE*) ((CIRCLE *PRINT-CIRCLE*) *PRINT-CIRCLE*) ((PRETTY *PRINT-PRETTY*) *PRINT-PRETTY*) ((LEVEL *PRINT-LEVEL*) *PRINT-LEVEL*) ((LENGTH *PRINT-LENGTH*) *PRINT-LENGTH*) ((CASE *PRINT-CASE*) *PRINT-CASE*) ((ARRAY *PRINT-ARRAY*) *PRINT-ARRAY*) ((GENSYM *PRINT-GENSYM*) *PRINT-GENSYM*) ((READABLY *PRINT-READABLY*) *PRINT-READABLY*) ((RIGHT-MARGIN *PRINT-RIGHT-MARGIN*) *PRINT-RIGHT-MARGIN*) ((MISER-WIDTH *PRINT-MISER-WIDTH*) *PRINT-MISER-WIDTH*) ((LINES *PRINT-LINES*) *PRINT-LINES*) ((PPRINT-DISPATCH *PRINT-PPRINT-DISPATCH*) *PRINT-PPRINT-DISPATCH*) ((SUPPRESS-ERRORS *SUPPRESS-PRINT-ERRORS*) *SUPPRESS-PRINT-ERRORS*))

Output OBJECT to the specified stream, defaulting to *STANDARD-OUTPUT*.

Undocumented

?

Private

!/0 (CONT)

7.8.4

</2 (?E1 ?E2 CONT)

8.7.3

=/2 (?ARG1 ?ARG2 CONT)

8.2.1

=:=/2 (?E1 ?E2 CONT)

8.7.3

=</2 (?E1 ?E2 CONT)

8.7.3

==/2 (?X ?Y CONT)

8.4.1: Are the two arguments EQUAL with no unification, but with dereferencing? If so, succeed.

=\=/2 (?E1 ?E2 CONT)

8.7.3

>/2 (?E1 ?E2 CONT)

8.7.3

>=/2 (?E1 ?E2 CONT)

8.7.3

@</2 (?X ?Y CONT)

8.4.3

@=</2 (?X ?Y CONT)

8.4.4

\=/2 (?ARG1 ?ARG2 CONT)

8.2.3

\==/2 (?X ?Y CONT)

8.4.2

ADD-CLAUSE (CLAUSE &KEY ASSERTA)

Add a clause to the data base, indexed by head's predicate.

ANON-VARS-IN (TREE SEEN-ONCE SEEN-MORE)

Walk the data structure TREE, returning a list of variabless seen once, and a list of variables seen more than once.

ANONYMOUS-VARIABLES-IN (TREE)

Return a list of all variables that occur only once in tree.

ARG/3 (?N ?TERM ?ARG CONT)

8.5.2

ARGS (X)

The arguments of a relation

ASSERTA/1 (?CLAUSE CONT)

8.9.1

ASSERTZ/1 (?CLAUSE CONT)

8.9.2

ATOM-CHARACTERS/2 (?ATOM ?CHARACTERS CONT)

for Common Lisp

ATOM-CHARS/2 (?ATOM ?LIST CONT)

8.16.4

ATOM-CODES/2 (?ATOM ?CODES CONT)

8.16.5

ATOM-CONCAT/3 (?ATOM1 ?ATOM2 ?ATOM12 CONT)

8.16.2

ATOM-LENGTH/2 (?ATOM ?LENGTH CONT)

8.16.1

ATOM/1 (X CONT)

8.3.2

ATOMIC/1 (X CONT)

8.3.5

BAGOF/3 (EXP GOAL RESULT CONT)

8.10.2: Find all solutions to GOAL, and for each solution, collect the value of EXP into the list RESULT.

BIND-NEW-VARIABLES (BINDINGS GOAL)

Extend bindings to include any unbound variables in goal.

BIND-UNBOUND-VARS (PARAMETERS EXP)

If there are any variables in exp (besides the parameters) then bind them to new vars.

BIND-VARIABLES-IN (EXP BINDINGS)

Bind all variables in exp to themselves, and add that to bindings (except for variables already bound).

CALL/1 (?G CONT)

7.8.3: Try to prove goal by calling it.

CATCH/3 (?GOAL ?CATCH ?RECOVER CONT)

7.8.9

CHAR-CODE/2 (?CHAR ?CODE CONT)

8.16.6

CLAUSE/2 (?HEAD ?BODY CONT)

8.8.1

CLAUSES-WITH-ARITY (CLAUSES TEST ARITY)

Return all clauses whose head has given arity.

CLEAR-DB

remove all clauses (for all predicates) from the data base.

CLEAR-PREDICATE (PREDICATE)

remove the clauses for a single predicate.

CLOSE/1 (?STREAM-OR-ALIAS CONT)

8.11.7

CLOSE/2 (?STREAM-OR-ALIAS ?OPTIONS CONT)

8.11.8

COMPILE-ARG (ARG BINDINGS)

Generate code for an argument to a goal in the body.

COMPILE-BODY (BODY CONT BINDINGS)

Compile the body of a clause.

COMPILE-CALL (PREDICATE ARGS CONT)

Compile a call to a prolog predicate.

COMPILE-CLAUSE (PARMS CLAUSE CONT)

Transform away the head, and compile the resulting body.

COMPILE-IF (PRED THEN-PART)

Compile a Lisp IF form. No else-part allowed.

COMPILE-PREDICATE (SYMBOL ARITY CLAUSES)

Compile all the clauses for a given symbol/arity into a single LISP function.

COMPILE-UNIFY (X Y BINDINGS)

Return 2 values: code to test if x and y unify, and a new binding list.

COMPILE-UNIFY-VARIABLE (X Y BINDINGS)

X is a variable, and Y may be.

COMPOUND/1 (X CONT)

8.3.6

CONTINUE-P

Ask user if we should continue looking for solutions.

COPY-TERM/2 (?TERM1 ?TERM2 CONT)

8.5.4

CURRENT-INPUT/1 (?STREAM CONT)

8.11.2

CURRENT-OUTPUT/1 (?STREAM CONT)

8.11.3

DEBUG (&REST IDS)

Start dbg output on the given ids.

DEREF-COPY (EXP)

Copy the expression, replacing variables with new ones. The part without variables can be returned as is.

DEREF-EQUAL (X Y)

Are the two arguments EQUAL with no unification, but with dereferencing?

DEREF-EXP (EXP)

Build something equivalent to EXP with variables dereferenced.

EXPAND-PAT-MATCH-ABBREV (PAT)

Expand out all pattern matching abbreviations in pat.

FAIL-IF/1 (RELATION CONT)

8.15.1: Negation by failure: If you can't prove G, then (not G) true.

FAIL/0 (CONT)

7.8.1

FIND-ANYWHERE-IF (PREDICATE TREE)

does predicate apply to any atom in the tree?

FINDALL/3 (TERM GOAL BAG CONT)

8.10.1: Find all solutions to GOAL, and for each solution, collect the value of TERM into the list BAG.

FIRST-MATCH-POS (PAT1 INPUT START)

Find the first position that pat1 could possibly match input, starting at position start. If pat1 is non-constant, then just return start.

FLUSH-OUTPUT/0 (CONT)

8.11.9

FLUSH-OUTPUT/1 (?STREAM-OR-ALIAS CONT)

8.11.10

FOLLOW-BINDING (VAR BINDINGS)

Get the ultimate binding of var according to bindings.

FUNCTOR/3 (?TERM ?NAME ?ARITY CONT)

8.5.1

GET-CHAR/1 (?CHAR CONT)

8.12.1

GET-CHAR/2 (?STREAM-OR-ALIAS ?CHAR CONT)

8.12.2

HAS-VARIABLE-P (X)

Is there a variable anywhere in the expression x?

INTEGER/1 (X CONT)

8.3.3

IS/2 (VAR EXP CONT)

8.6.1

MAKE-ANONYMOUS (EXP &OPTIONAL (ANON-VARS (ANONYMOUS-VARIABLES-IN EXP)))

Replace variables that are only used once with ?.

MAKE-PARAMETERS (ARITY)

Return the list (?arg1 ?arg2 ... ?arg-arity)

MAKE-PREDICATE (SYMBOL ARITY)

Return the symbol: symbol/arity

MATCH-AND (PATTERNS INPUT BINDINGS)

Succeed if all the patterns match the input.

MATCH-IF (PATTERN INPUT BINDINGS)

Test an arbitrary expression involving variables. The pattern looks like ((?if code) . rest).

MATCH-IS (VAR-AND-PRED INPUT BINDINGS)

Succeed and bind var if the input satisfies pred, where var-and-pred is the list (var pred).

MATCH-NOT (PATTERNS INPUT BINDINGS)

Succeed if none of the patterns match the input. This will never bind any variables.

MATCH-OR (PATTERNS INPUT BINDINGS)

Succeed if any one of the patterns match the input.

MAYBE-ADD-UNDO-BINDINGS (COMPILED-EXPS)

Undo any bindings that need undoing. If there are any, bind the trail before we start.

NL/0 (CONT)

8.12.5

NL/1 (?STREAM-OR-ALIAS CONT)

8.12.6

NONVAR/1 (X CONT)

8.3.7

NUMBER-CHARS/2 (?NUMBER ?LIST CONT)

8.16.7

NUMBER-CODES/2 (?NUMBER ?LIST CONT)

8.16.8

NUMBER/1 (X CONT)

8.3.8

OCCURS-CHECK (VAR X BINDINGS)

Does var occur anywhere inside x?

ONCE/1 (THING CONT)

8.15.2

OPEN/4 (?SOURCE/SINK ?MODE ?STREAM ?OPTIONS CONT)

8.11.6

PAT-MATCH-ABBREV (SYMBOL EXPANSION)

Define symbol as a macro standing for a pat-match pattern.

PROLOG-COMPILE (SYMBOL &OPTIONAL (CLAUSES (GET-CLAUSES SYMBOL)))

Compile a symbol; make a separate function for each arity.

PROLOG-COMPILE-SYMBOLS (&OPTIONAL (SYMBOLS *UNCOMPILED*))

Compile a list of Prolog symbols. By default, the list is all symbols that need it.

PROLOG-COMPILER-MACRO (NAME)

Fetch the compiler macro for a Prolog predicate.

PROPER-LISTP (X)

Is x a proper (non-dotted) list?

PROVE (GOAL BINDINGS OTHER-GOALS)

Return a list of possible solutions to goal.

PROVE-ALL (GOALS BINDINGS)

Find a solution to the conjunction of goals.

PUT-CHAR/1 (?CHAR CONT)

8.12.3

PUT-CHAR/2 (?STREAM-OR-ALIAS ?CHAR CONT)

8.12.4

REAL/1 (X CONT)

8.3.4

RELATION-ARITY (RELATION)

The number of arguments to a relation. Example: (relation-arity '(p a b c)) => 3

RENAME-VARIABLES (X)

replace all variables in x with new ones.

REPEAT/0 (CONT)

8.15.3

REPLACE-?-VARS (EXP)

Replace any ? within exp with a var of the form ?123.

RETRACT-CLAUSE (CLAUSE)

Retract a clause from the data base

RETRACT-SAME-ARITY-CLAUSE (CLAUSE)

Retract a clause from the data base

RETRACT/1 (?CLAUSE CONT)

8.9.3

RULE-BASED-TRANSLATOR (INPUT RULES &KEY (MATCHER 'PAT-MATCH) (RULE-IF #'FIRST) (RULE-THEN #'REST) (ACTION #'SUBLIS))

Find the first rule in rules that matches input, and apply the action to that rule.

RUN-PROLOG (PROCEDURE CONT)

Run a 0-ary prolog procedure with a given continuation.

SEGMENT-MATCH (PATTERN INPUT BINDINGS &OPTIONAL (START 0))

Match the segment pattern ((?* var) . pat) against input.

SEGMENT-MATCH+ (PATTERN INPUT BINDINGS)

Match one or more elements of input.

SEGMENT-MATCH-FN (X)

Get the segment-match function for x, if it is a symbol that has one.

SEGMENT-MATCH? (PATTERN INPUT BINDINGS)

Match zero or one element of input.

SEGMENT-MATCHER (PATTERN INPUT BINDINGS)

Call the right function for this kind of segment pattern.

SEGMENT-PATTERN-P (PATTERN)

Is this a segment-matching pattern like ((?* var) . pat)?

SET-BINDING! (VAR VALUE)

Set var's binding to value, after saving the variable in the trail. Always returns t.

SET-INPUT/1 (?STREAM-OR-ALIAS CONT)

8.11.4

SET-OUTPUT/1 (?STREAM-OR-ALIAS CONT)

8.11.5

SET-STREAM-POSITION/2 (?STREAM-OR-ALIAS ?POSITION CONT)

8.11.14

SETOF/3 (EXP GOAL RESULT CONT)

8.10.3: Find all unique solutions to GOAL, and for each solution, collect the value of EXP into the list RESULT.

SHOW-PROLOG-VARS (VARS BINDINGS OTHER-GOALS)

Print each variable with its binding. Then ask the user if more solutions are desired.

SHOW-PROLOG-VARS/2 (VAR-NAMES VARS CONT)

Display the variables, and prompt the user to see if we should continue. If not, return to the top level.

SINGLE-MATCH-FN (X)

Get the single-match function for x, if it is a symbol that has one.

SINGLE-MATCHER (PATTERN INPUT BINDINGS)

Call the right function for this kind of single pattern.

SINGLE-PATTERN-P (PATTERN)

Is this a single-matching pattern? E.g. (?is x predicate) (?and . patterns) (?or . patterns).

STRING-ATOM/2 (?STRING ?ATOM CONT)

for Common Lisp

SUB-ATOM/4 (?ATOM ?START ?LENGTH ?SUB-ATOM CONT)

8.16.3

SUBST-BINDINGS (BINDINGS X)

Substitute the value of variables in bindings into x, taking recursively bound variables into account.

SYMBOL (&REST ARGS)

Concatenate symbols or strings to form an interned symbol

THROW/1 (?BALL CONT)

7.8.10

TOP-LEVEL-PROVE (GOALS)

Prove the list of goals by compiling and calling it.

TRUE/0 (CONT)

7.8.2

UNBOUND-VAR-P (EXP)

Is EXP an unbound var?

UNDO-BINDINGS! (OLD-TRAIL)

Undo all bindings back to a given point in the trail.

UNIFIER (X Y)

Return something that unifies with both x and y (or fail).

UNIFY (X Y &OPTIONAL (BINDINGS NO-BINDINGS))

See if x and y match with given bindings.

UNIFY! (X Y)

Destructively unify two expressions

UNIFY-VARIABLE (VAR X BINDINGS)

Unify var with x, using (and maybe extending) bindings.

UNIFY-WITH-OCCURS-CHECK/2 (?ARG1 ?ARG2 CONT)

8.2.2

UNIQUE-FIND-ANYWHERE-IF (PREDICATE TREE &OPTIONAL FOUND-SO-FAR)

return a list of leaves of tree satisfying predicate, with duplicates removed.

VAR-BINDING (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

VAR-NAME (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

VAR/1 (X CONT)

8.3.1

VARIABLES-IN (EXP)

Return a list of all the variables in EXP.

Undocumented

=.. (?TERM ?LIST CONT)

@>2/2 (?X ?Y CONT)

@>=/2 (?X ?Y CONT)

ABOLISH/1 (?PI CONT)

AT-END-OF-STREAM/0 (CONT)

AT-END-OF-STREAM/1 (?STREAM-OR-ALIAS CONT)

ATOMICP (EXP)

BOUND-P (VAR)

CLAUSE-BODY (CLAUSE)

CLAUSE-HEAD (CLAUSE)

COPY-VAR (INSTANCE)

CURRENT-PREDICATE/1 (?PI CONT)

DESTRUCTURE-IF-THEN-ELSE (GOAL)

EXPLODE (SYMBOL)

GET-CLAUSES (PRED)

GET-CODE/1 (?CODE CONT)

GET-CODE/2 (?STREAM-OR-ALIAS ?CODE CONT)

GOAL-AND-P (GOAL)

GOAL-CONJUNCTION-P (GOAL)

GOAL-CUT-P (GOAL)

GOAL-DISJUNCTION-P (GOAL)

GOAL-IF-P (GOAL)

GOAL-IF-THEN-ELSE-P (GOAL)

GOAL-IF-THEN-P (GOAL)

GOAL-OR-P (GOAL)

IGNORE (&REST ARGS)

IMPLODE (LIST)

INSERT-DEREF (EXP)

MAKE-= (X Y)

MAKE-RENAMED-COPY (TERM)

MAKE-VAR (&KEY ((NAME DUM0) NIL) ((BINDING DUM1) UNBOUND))

NON-ANON-VARIABLE-P (X)

NONVARP (EXP)

PREDICATE (RELATION)

PROLOG-TRANSLATE-GOALS (GOALS)

PUT-CODE/1 (?CODE CONT)

PUT-CODE/2 (?STREAM-OR-ALIAS ?CODE CONT)

READ/1 (EXP CONT)

SELF-CONS (X)

STRING-LIST/2 (?STRING ?LIST CONT)

TERM-PRECEDES (X Y)

SETFVAR-BINDING (NEW-VALUE INSTANCE)

SETFVAR-NAME (NEW-VALUE INSTANCE)

VAR-P (OBJECT)

WRITE/1 (EXP CONT)

MACRO

Public

<- (&REST CLAUSE)

Add a clause to the data base.

<-- (&REST CLAUSE)

Retract a same arity clause from the data base, and add a clause to the data base.

PROLOG (&REST GOALS)

Run Prolog in the surrounding Lisp environment which is accessed from lisp functor.

PROLOG-COLLECT ((&REST VARS) &BODY BODY)

collect all bindings of vars

PROLOG-FIRST ((&REST VARS) &BODY BODY)

return first bindding of vars

Undocumented

?- (&REST GOALS)

AND (&REST FORMS)

OR (&REST FORMS)

Private

DEF-PROLOG-COMPILER-MACRO (NAME ARGLIST &BODY BODY)

Define a compiler macro for Prolog.

DEREF (EXP)

Follow pointers for bound variables.

WITH-UNDO-BINDINGS (&BODY BODY)

Undo bindings after each expression in body except the last.

Undocumented

WITH-STREAM ((S-VAR S) &BODY BODY)

GENERIC-FUNCTION

Public

CLOSE (STREAM &KEY ABORT)

Close the given STREAM. No more I/O may be performed, but inquiries may still be made. If :ABORT is true, an attempt is made to clean up the side effects of having created the stream.

Private

Undocumented

BALL (CONDITION)

VARIABLE

Private

*DB-PREDICATES*

a list of all predicates stored in the database.

*OCCURS-CHECK*

Should we do the occurs check?

*PREDICATE*

The Prolog predicate currently being compiled

*UNCOMPILED*

Prolog symbols that have not been compiled.

Undocumented

*TRAIL*

*VAR-COUNTER*

CLASS

Public

Undocumented

INTEGER

NUMBER

REAL

VAR

CONDITION

Private

Undocumented

PROLOG-THROW

CONSTANT

Public

Undocumented

FAIL

Private

Undocumented

UNBOUND