(builtin predicates)

Arithmetic comparison

(:== @evaluable @evaluable)

Arithmetic equal

True if both numbers are equal.

(:>= @evaluable @evaluable)

Arithmetic greater than or equal to

True if the first number is greater than or equal to the second one.

(:> @evaluable @evaluable)

Arithmetic greater than

True if the first number is greater than the second one.

(:<= @evaluable @evaluable)

Arithmetic less than or equal to

True if the first number is less than or equal to the second one.

(:< @evaluable @evaluable)

Arithmetic less than

True if the first number is less than the second one.

(:/== @evaluable @evaluable)

Arithmetic not equal

True if the compared numbers are not equal.

Arithmetic evaluation

(is ?term @evaluable)

Evaluate expression

(is Result Expression) is true if and only if evaluating Expression as an expression gives Result as a result.

(succ +integer -integer)
(succ -integer +integer)

Return the successor of a positive number

(succ Int Succ) is true if and only of Int is greater than or equal to 0 and Succ is Int + 1.

Atom processing

(atom_chars +atom ?string)
(atom_chars -atom +string)

Express an atom as a list of characters

(atom_chars Atom List) succeeds if and only if List is made up of characters that in order form Atom.

(atom_concat ?atom ?atom +atom)
(atom_concat +atom +atom -atom)

Concatenate atoms

(atom_concat Start End Whole) is true if and only if Whole is the atom obtained by adding the characters of End at the end of Start. If Whole is the only argument instantiated, atom_concat/3 will obtain all possible decompositions of it.

(atom_length +atom ?integer)

Length of an atom

(atom_length Atom Length) is true if and only if the number of characters in the name of Atom is equal to Length. If Length is not instantiated, atom_length/2 will calculate the length of Atom's name.

(char_code +character ?character_code)
(char_code -character +character_code)

Character code of a character

(char_code Char Code) succeeds if and only if Code is the character code of Char.

Clause manipulation

(asserta @clause)

Add term to the Herbrand database

(asserta Clause) is true. It has for side effect the addition of the clause Clause to the database, placing it before any other facts or rules with the same functor.

(assertz @clause)

Add term to the Herbrand database

(assertz Clause) is true. Same side effect as asserta/1, but placing Clause after all the facts and rules with the same functor.

(retract +clause)

Delete term from Herbrand database

(retract Clause) is true if there's at least one predicate in the database with the clause Clause. It has for side effect the removal of that predicate.

(retractall +clause)

Removes rules and clauses which unify with a term

(retractall Head) removes all the clauses and rules whose heads unify with Head.

Control constructs

(and ... +callable_term)

Conjunction

(and | Goals) is true if and only if every goal in Goals is true.

(call +callable_term ... +term)

Invoke a callable term as a goal

(call Goal | Args) is true if and only if Goal represents a goal which is true after appending Args to its list of arguments.

(catch +callable_term ?term +callable_term)

Enable recovery from exceptions

(catch Goal Catcher Handler) behaves as call/1 if no exception is raised when executing Goal. If an exception is raised using throw/1 while Goal executes, and the Goal is the innermost goal for which Catcher unifies with the argument of throw/1, all choice points generated by Goal are cut, the system backtracks to the start of catch/3 while preserving the thrown exception term, and Handler is called as in call/1.

(!)

Cut

(!) is true. All choice points between the cut and the parent goal are removed. The effect is commit to use of both the current clause and the substitutions found at the point of the cut.

(false)

Alwais fail

(false) is always false.

(findall ?term +callable_term ?list)

Find all the values that would make a goal succeed

(findall Template Goal Instances) is true if and only if Instances is a list of values in the form Templates that would make the goal Goal succeed. Usually, Template and Goal share some variables, so Instances is filled with the values that make Goal succeed. If there is not a single value that make Goal unify, Instances will be an empty list.

(halt +number)

Terminate a Herbrand processor and return message

(halt X) exits the processor and returns to the system that invoked the processor, passing a message through the X variable.

(ite :callable_term :callable_term :callable_term)

If-Then-Else

(ite If Then Else) is true if and only if If is true and Then is true for the first solution of If, or if If is false and Else is true for the first value with which If fails.

(not @callable_term)

Not provable

(not Term) is true if and only if (call Term) is false.

(once @callable_term)

Evaluate a term just once

(once Term) is true. once/1 makes sure that Term fails or succeeds just once.

(or ... +callable_term)

Disjunction

(or | Goals) is true if and only if any goal in Goals is true.

(repeat)

Provide infinite choice points

(repeat) is true. It provides infinite choice points, what makes it perfect for creating loops.

(throw +term)

Raise an exception

(throw Exception) raise the Exception exception. The system looks for the innermost catch/3 ancestor for which Exception unifies with the Catcher argument of the catch/3 call.

(true)

Alwais succeed

(true) is always true.

Herbrand flags

(current_herbrand_flag ?flag ?term)

Check Herbrand flag and flag values

(current_herbrand_flag Flag Value) is true if and only if Flag is a valid Herbrand flag and Value is its value.

(set_herbrand_flag +flag @nonvar)

Set value of flag

(set_herbrand_flag Flag Value) sets the Herbrand flag Flag value to Value. This can either succeed or raise an exception.

Loading source files

(consult +string)

Read a file as a Herbrand source file

(consult Path) is true when Path is a valid Herbrand source file.

(import +atom_or_string)

Load a Herbrand module

(import Module) is true when Module is a valid Herbrand module.

Term comparison

(== @term @term)

Term identical

True if the compared terms are identical.

(>= @term @term)

Term greater than or equal to

True if the first term is greater than or equal to the second one.

(> @term @term)

Term greater than

True if the first term is greater than the second one.

(<= @term @term)

Term less than or equal to

True if the first term is less than or equal to the second one.

(< @term @term)

Term less than

True if the first term is less than the second one.

(/== @term @term)

Term not identical

True if the compared terms are not identical.

Term unification

(/= ?term ?term)

Not term unification

(/= X Y) is true if and only if X and Y are not unifiable. True if the unification fails.

(= ?term ?term)

Term unification

(= X Y) is true if and only if X and Y are unifiable. True if the unification succeeds.

Type testing

(atom @term)

Check if atom

(atom X) is true if and only if X is an atom.

(char @term)

Check if char

(char X) is true if and only if X is a char.

(float @term)

Check if float

(float X) is true if and only if X is a float.

(ground @term)

Check if ground term

(ground Term) is true if and only if Term holds no free variables.

(integer @term)

Check if integer

(integer X) is true if and only if X is an integer.

(list @term)

Check if list

(list X) is true if and only if X is a list.

(nonvar @term)

Check if not variable

(nonvar X) is true if and only if X is not a variable.

(number @term)

Check if number

(number X) is true if and only if X is a number.

(string @term)

Check if string

(string X) is true if and only if X is a string.

(var @term)

Check if variable

(var X) is true if and only if X is a variable.