Builtin 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 nonzero
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 nonassociative
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 nonassociative operator
applies must be of lower precedence than the operator itself. Thus,
nonassociative operators may not be repeated without bracketing the subterms
(as without brackets the precedence of the nested term will be equal to that
of the operator).
Table 1: NonAssociative Operators
Operator  Precedence 
:  1200 
?  1200 
mode  1150 
public  1150 
dynamic  1150 
 
Operator  Precedence 
multifile  1150 
+  500 
  500 
?  500 

Table 2: Associative Operators
Operator  Precedence 
not  900 
\+  900 
 
Operator  Precedence 
spy  900 
nospy  900 

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 nonassociative.
Table 3: NonAssociative Operators
Operator  Precedence 
:  1200 
>  1200 
=  700 
is  700 
=..  700 
==  700 
\==  700 
@<  700 
@>  700 
 
Operator  Precedence 
@=<  700 
@>=  700 
=:=  700 
=\=  700 
<  700 
>  700 
=<  700 
>=  700 
mod  300 

Table 4: Associative Operators
RightAssociative Operators 
Operator  Precedence 
:  1200 
;  1100 
>  1050 
=>  1050 
,  1000 
rad  650 
to  650 
at  650 
aligned  625 
^  200 
 
LeftAssociative Operators 
Operator  Precedence 
/\  500 
\/  500 
+  500 
  500 
*  400 
/  400 
//  400 
<<  400 
>>  400 
