There is a new SWI-Prolog documentation server -- link opens in new window.
S should be a symbolic atom, e.g., help(assert).
Stops Prolog, resume operating system.
Turns trace on and off, respectively.
Always succeeds as a goal.
Always fails as a goal.
Loads program from the file F. F should be bound to file designator expression, e.g., F='[root.programs.prolog]prog.pro' or F='/home/user/prolog/sample.pl', depending on the file system.
Like consult except that each predicate already defined has its definition replaced by the new defintion being loaded.
Bracket notation, meaning consult F1, then consult F2, then ...
N > M , N < M, N =< M, N >= M
These relations test what they look like they test. Of course, M and N should be bound to numbers in order for these goals to either succeed or fail (and not to cause error).
Tests whether X is bound to a symbolic atom. For example,?- atom(foot).integer(X)
Tests whether X is bound to an integer.
Tests whether X is bound to a real number.
Tests whether X is bound to a string.
X = Y, X \=Y
Tests whether X and Y can be unified, or cannot, respectively. For example,?- [X,Y|R] = [a,b,c].X ==Y, X \== Y
X = a, Y = b, R = [c]
?- [X,Y,Z] = [a,b].
Tests whether X and Y are currently co-bound, i.e., have been bound to or share same value, or not, respectively. For example,?- X = 3, Y = 1 * 3, X == Y.
?- X = a, [Y|_]= [a,b,c], X == Y.
X = a, Y = a
Force P to be a goal; succeed if P does, else fail.
Prolog cut predicate.
Tests whether G has unbound logical variables.
Tests whether X is bound to a Prolog variable.
Assert clause C into database above other clauses with the same key predicate. The key predicate of a clause is the first predicate encountered when the clause is read from left to right.
Assert clause C into database below other clauses with the same key predicate.
Retract C from the database. C must be sufficiently instantiated to determine the predicate key.
X is E
Binds logical variable V to the numerical value of E. The expression E must either be a number or be a number-valued expression, conventionally parenthesized, such as, for example, (2*Z + W)/ (4* Z -W), assuming that Z and W themselves are bound to numbers at the time of evaluating this expression.?- X is 22, Y is X * 3, Z is sqrt(Y).
X = 22 .
Y = 66 .
Z = 8.12404 .
Negation-as-failure, as if defined by:not(Q) :- call(Q), !, fail.
Succeeds if X is (or can be) bound to current read port. X=user is keybord input.
Opens port for input file bound to X. Subsequent input for 'read' is then taken from that port.
Closes any selected input port/file, and causes 'read' to look at user.
Reads Prolog type expression from current port, storing value in X.
Succeeds if X is (or can be) bound to current output port; X=user is screen.
Opens port for output file bound to X. Subsequent output from 'write' or 'display' is sent to that port.
Closes any selected output port/file and reverts to screen output.
Writes Prolog expression bound to E into current output port.
Next line (line feed).
Write N spaces to selected output port.
Retrieves clauses in memory whose head matches H and body matches B. H must be sufficiently instantiated to determine the main predicate of the head.
E must be bound to a functor expression of the form 'f(...)'. F will be bound to 'f', and N will be bound to the number of arguments that f has.
E must be bound to a functor expression, N is a whole number, and A will be bound to the Nth argument of E (or fail).
Convert between atom and list.?- name('.pl',L). L = [46,112,108]. ?- writeln("prog"). [112, 114, 111, 103] Yes ?- append("prog",[46,112,108],F), name(N,F). F = [112, 114, 111, 103, 46, 112, 108] N = 'prog.pl'
'univ' converts between term and list. For example,?- parent(a,X) = .. L.
L = [parent, a, _X001]
?- yes = .. L.
L = [yes]
:- op(P,T,O).Patience is sometimes required to assign appropriate precedence values for the user's operators, so that they will be read in with the intended meaning.
Declare an operator symbol. For example, with source program ...:- op(500,xfx,'has_color').Then ...
a has_color red.
b has_color blue.?- b has_color C.P is precedence, an integer. Larger P has less precedence (ability to group). Precedence number values for built-ins depend upon the actual Prolog system. User needs to find out what these values are. (See the reference materials or use the help facility with keyword 'operator').
C = red
?- What has_color red.
What = a
T is operator type:xfx infix nonassociativeO is the name of the operator. Which symbols are usable may depend upon the Prolog expression reader (i.e., which kind of Prolog you are using).
xfy infix right-associative
yfx infix left-associative
fx prefix nonassociative
fy prefix right-associative
xf postfix nonassociative
yf postfix left-associative
Built-ins, in order of precedence ("ability to group", least ability first)::- xfx, fx larger P value ?- fx ; xfy , xfy not fy is, =.. , <, etc. xfx +, - yfx, fx *, / yfx ^ xfy smaller P value
Compute all Things which satisfy the GoalExpresssion and collect them in the list Bag. If the GoalExpression fails, Bag will be the empty list . findall treats all variables in GoalExpression as if they are existentially quantified.
Compute all Things which satisfy the GoalExpresssion and collect them in the list Bag. bagof fails if GoalExpression fails. Free variables in GoalExpression could be bound, yielding many bags. See examples in Section 2.12.
Compute all Things which satisfy the GoalExpresssion and collect them in the list Bag. Similar to bagof except that Bag will not contain duplicates and it will be sorted.