Builtin predicates
The predicates below behave as in ISO Prolog, unless the notes say something else. Errors are thrown as ISO error terms, such as type_error(integer, foo).
Control
| Predicates | Notes |
|---|---|
,/2, ;/2, ->/2, !/0 |
Conjunction, disjunction, if-then-else, and cut. |
\+/1 |
Negation as failure. |
call/1 to call/8 |
Calls a goal, adding the extra arguments to it. A cut inside it stays inside it. |
once/1, ignore/1, forall/2 |
|
true/0, fail/0, false/0 |
|
catch/3, throw/1 |
All solutions
| Predicates | Notes |
|---|---|
findall/3 |
|
bagof/3, setof/3 |
Free variables group the solutions, and ^ marks variables that do not. |
Unification and comparison
| Predicates | Notes |
|---|---|
=/2, \=/2 |
|
unify_with_occurs_check/2 |
|
==/2, \==/2 |
|
@</2, @>/2, @=</2, @>=/2, compare/3 |
The standard order of terms. |
Type checks
var/1, nonvar/1, atom/1, integer/1, float/1, number/1, atomic/1, compound/1, callable/1, is_list/1.
Arithmetic
| Predicates | Notes |
|---|---|
is/2 |
|
=:=/2, =\=/2, </2, >/2, =</2, >=/2 |
|
between/3 |
Arithmetic works on integers of any size and on floats. When an integer and a float are mixed, the result is a float.
| Functions | Notes |
|---|---|
+, -, *, min, max, abs, sign |
|
/ |
Always gives a float, as in ISO Prolog. 7 / 2 is 3.5, and 4 / 2 is 2.0. |
//, mod, rem, div |
Integers only. |
** |
Always gives a float. 2 ** 3 is 8.0. |
^ |
Gives an integer for two integers, and a float otherwise. |
/\, \/, xor, \, <<, >> |
Integers only. |
float, float_integer_part, float_fractional_part |
|
truncate, round, ceiling, floor |
Give an integer. round rounds a half away from zero. |
sqrt, sin, cos, tan, asin, acos, atan/1, atan/2, atan2/2, exp, log |
Give a float. |
pi, e |
Constants. |
An integer and a float are compared by their exact values, so 1 =:= 1.0 is true. In the standard order, 1.0 comes before 1. Division by zero throws evaluation_error(zero_divisor). A float result that is too large throws evaluation_error(float_overflow), and a result that is not a number, such as sqrt(-1), throws evaluation_error(undefined).
Terms
functor/3, arg/3, =../2, copy_term/2.
Database
| Predicates | Notes |
|---|---|
assertz/1, assert/1, asserta/1 |
|
retract/1 |
|
abolish/1 |
|
clause/2 |
|
current_predicate/1 |
|
dynamic/1 |
Makes a predicate with no clauses, so that a call fails instead of throwing an error. |
All predicates defined by clauses can be changed with assert and retract. A running call sees the clauses that existed when it started.
Atoms and characters
atom_length/2, atom_concat/3, sub_atom/5, atom_chars/2, atom_codes/2, char_code/2, number_chars/2, number_codes/2.
Lengths and positions count Unicode code points.
Lists
append/3, member/2, memberchk/2, length/2, reverse/2, nth0/3, nth1/3, last/2, select/3, msort/2, sort/2, keysort/2.
append/3, member/2, memberchk/2, reverse/2, nth0/3, nth1/3, last/2, and select/3 are library predicates. If your program defines its own clauses for one of them, your definition replaces it.
Flags
current_prolog_flag/2, set_prolog_flag/2. The flags are occurs_check and double_quotes (which can be changed), and bounded, max_arity, and integer_rounding_function. double_quotes takes codes (the default), chars, or atom.
Debugging
trace/0, notrace/0, spy/1, nospy/1. spy/1 and nospy/1 take Name/Arity, Name for all arities, or a list of them. They only choose which calls are reported. The host shows the report, such as the command line tool or the playground. In a C# app without a tracer, they do nothing. See C# API.
In the CSProlog.Syntax package
| Predicates | Notes |
|---|---|
op/3, current_op/3 |
|
write/1, print/1, writeq/1, write_canonical/1, write_term/2 |
write_term/2 takes quoted/1, ignore_ops/1, and numbervars/1. |
nl/0, tab/1 |
|
phrase/2, phrase/3 |
|
discontiguous/1, initialization/1 |
|
listing/0, listing/1 |
listing/1 takes Name or Name/Arity. listing/0 lists all user predicates. |
In the command line tool only
consult/1, [File], halt/0, halt/1. See Command line tool.