I think we should probably get a unit test built around each of the predicates called out below. My thought is we could either create an issue for each one or maybe one for each group.
From this link:
https://www.cis.upenn.edu/~matuszek/Concise%20Guides/Concise%20Prolog.html
Built-in Predicates
Prolog has a large number of built-in predicates. The following is a partial list of predicates which should be present in all implementations.
Input predicates
read(X) -- Read one clause from the current input and unify it with X. If there is no further input, X is unified with end_of_file.
get(X) -- Read one printing character from the current input file and unify the ASCII code of that character (an integer) with X.
get0(X) -- Read one character from the current input file and unify the ASCII code of that character with X.
see(File) -- Open File as the current input file.
seen -- Close the current input file.
Output predicates
write(X) -- Write the single value X to the current output file.
writeq(X) -- Write X with quotes as needed so it can be read in again.
tab(N) -- Write N blanks to the current output file.
nl -- Write a newline to the current output file.
put(X) -- Write the character whose ASCII value is X to the current output file.
tell(File) -- Open File as the current output file.
told -- Close the current output file.
Control predicates
X ; Y -- X or Y. Try X first; if it fails (possibly after being backtracked into), try Y.
(X -> Y) -- If X, then try Y, otherwise fail. Y will not be backtracked into.
(X -> Y ; Z) -- If X, then try Y, else try Z. X will not be backtracked into.
not X -- (Sometimes written +X or not(X)) Succeed only when X fails.
true -- Succeed once, but fail when backtracked into.
repeat -- Always succeed, even when backtracked into.
fail -- Never succeed.
! -- (Pronounced "cut".) Acts like true, but cannot be backtracked past, and prevents any other clauses of the predicate it occurs in from being tried.
abort -- Return immediately to the top-level Prolog prompt.
Database manipulation predicates
assert(X) -- Add X to the database. For syntactic reasons, if X is not a base clause, use assert((X)).
asserta(X) -- Add X to the database in front of other clauses of this predicate.
assertz(X) -- Add X to the database after other clauses of this predicate.
retract(X) -- Remove X from the database. For syntactic reasons, if X is not a base clause, use retract((X)).
abolish(F,A) -- Remove all clauses with functor F and arity A from the database.
clause(X,V) -- Find a clause in the database whose head (left hand side) matches X and whose body (right hand side) matches V. To find a base clause, use true for V.
save(F) -- Save the entire program state on File F (usu. as a binary image).
restore(F) -- Replace the program state with the one on File F.
Arithmetic predicates
X is E -- Evaluate E and unify the result with X.
X + Y -- When evaluated, yields the sum of X and Y.
X - Y -- When evaluated, yields the difference of X and Y.
X * Y -- When evaluated, yields the product of X and Y.
X / Y -- When evaluated, yields the quotient of X and Y.
X mod Y -- When evaluated, yields the remainder of X divided by Y.
X =:= Y -- Evaluate X and Y and compare them for equality.
X == Y -- Evaluate X and Y and succeed if they are not equal.
...and similarly for >, <, >=, =<.
Listing and debugging predicates.
listing(P) -- Display predicate P. P may be a predicate name, a structure of the form Name/Arity, or a bracked list of the above.
trace -- Turn on tracing.
notrace -- Turn off tracing.
spy P -- Turn on tracing when predicate P is called. P may be a predicate name, a structure of the form Name/Arity, or a non-bracked list of the above.
nospy P -- Turn off spying for P.
nospyall -- Turn off all spypoints.
debug -- Enable spypoints (allow them to initiate tracing.).
nodebug -- Disable spypoints (without removing them).
Tracing -- Control over tracing is very system-dependent, but is probably like this:
Enter key -- Single-step to next line of trace.
h -- Provide help on tracing commands.
s -- (On a CALL) Skip over this call.
l -- Leap without tracing to the next spypoint.
n -- Turn off tracing.
- -- Set a spypoint here.
[missing (see if it was in link and just removed during copy paste) Remove the spypoint here.
Trace terminology: CALL is the initial entry to a predicate; EXIT is a successful return; REDO is when it is backed into for another answer; FAIL is when it finds no more solutions. A sequence of calls may be viewed as forming a chain.
Tests
atom(X) -- Succeed if X is an atom (an empty list is considered an atom).
atomic(X) -- Succeed if X is an atom or number.
number(X) -- Succeed if X is a number.
integer(X) -- Succeed if X is an integer.
float(X) -- Succeed if X is a real number.
var(X) -- Succeed if X is unbound (a non-instantiated variable).
nonvar(X) -- Succeed if X is bound.
X == Y -- Succeed if X and Y are identical (but do not unify them).
X == Y -- Succeed if X and Y are not identical.