COGENT Online
CONTENTS
COGENT Version 2.3 Help

Built-in Operators

Most Prologs predefine a number standard of unary and binary operators in order to simplify the representation of certain terms. Definitions of these operators are also provided within COGENT. This appendix lists the complete set of predefined COGENT operators.

Prefix Operators

Prefix operators are unary operators that occur before their argument. The unary logical operator not is a classic example. If term is a valid Prolog expression, then not (term) is also a valid Prolog expression. Note here the space between the operator and the bracketed term. The space is optional, but recommended. (Without it, the operator is actually being used as a functor of arity one.)

The brackets around the term to which the operator applies are not always necessary. The rule for their use relies on the notion of precedence. Every valid term in the representation language has a precedence, which is an integer ranging from 0 to 1200. A ``normal'' term consisting of a functor followed by its bracketed arguments has a precedence of 0. Lists also have a precedence of 0. Terms containing operators, however, may have non-zero precedence. In fact, if such terms are unbracketed (i.e., are not contained within a set of round brackets), then their precedence is given by the precedence of the principal operator within the term, as specified in the tables below. Thus, a term of the form 3 + 4 has precedence 500 (from the entry for binary + in the tables below). This contrasts with the term (3 + 4) which has precedence 0 (because of the surrounding brackets.

Unary operators may be divided into associative and non-associative operators. The term to which an associative operator applies must be of equal or lower precedence than the operator itself. Thus, associative operators may be repeated without brackets (as the precedence of the nested term will be equal to that of the operator). The term to which a non-associative operator applies must be of lower precedence than the operator itself. Thus, non-associative operators may not be repeated without bracketing the sub-terms (as without brackets the precedence of the nested term will be equal to that of the operator).

Table 1: Non-Associative Operators

OperatorPrecedence
:-1200
?-1200
mode1150
public1150
dynamic1150
OperatorPrecedence
multifile1150
+500
-500
?500

Table 2: Associative Operators

OperatorPrecedence
not900
\+900
OperatorPrecedence
spy900
nospy900

Infix Operators

Infix operators are binary operators that are written between their two arguments. The arithmetic operators of * (multiplication) and / (division) are standard examples. As in the unary case, operators can be associative or non-associative.

Table 3: Non-Associative Operators

OperatorPrecedence
:-1200
-->1200
=700
is700
=..700
==700
\==700
@<700
@>700
OperatorPrecedence
@=<700
@>=700
=:=700
=\=700
<700
>700
=<700
>=700
mod300

Table 4: Associative Operators

Right-Associative Operators
OperatorPrecedence
:1200
;1100
->1050
=>1050
,1000
rad650
to650
at650
aligned625
^200
Left-Associative Operators
OperatorPrecedence
/\500
\/500
+500
-500
*400
/400
//400
<<400
>>400


COGENT Online
CONTENTS
COGENT Version 2.3 Help