Syntactically, a term is either a simple term or a compound term constructed from simple terms. A term is then either an arithmetic term or a functor term. The simple terms are:
There are also some handy metric conversion ratios predefined:
(Note that new constants can be created by using new_constant/2.) bsphackfloatpenalty -Mii floatpenalty-Miii parmoderrfloatpenalty@ nextcurrboxfreelist currbox-4floatpenalty@ fltovf currboxtempboxa tempboxa @floatesphack
Also any sequence of characters delimited by single quotes ``''' is allowed, e.g. 'foo + bar' is a functor constant (atom) with that name including the blanks. The special constant ``[]'' denotes the empty list or nil. Note also that the special arithmetic function symbols, though having the same syntax, are arithmetic terms and not functor terms.
bsphackfloatpenalty -Mii floatpenalty-Miii parmoderrfloatpenalty@ nextcurrboxfreelist currbox-2floatpenalty@ fltovf currboxtempboxa tempboxa @floatesphackbsphackfloatpenalty -Mii floatpenalty-Miii parmoderrfloatpenalty@ nextcurrboxfreelist currbox-3floatpenalty@ fltovf currboxtempboxa tempboxa @floatesphack An arithmetic term is either a variable, numeric constant or a compound term built up from arithmetic terms in the usual way using the arithmetic function symbols: +, -, *, /, sin, arcsin, cos, arccos, pow, abs, min and max. bsphackfloatpenalty -Mii floatpenalty-Miii parmoderrfloatpenalty@ nextcurrboxfreelist currbox-4floatpenalty@ fltovf currboxtempboxa tempboxa @floatesphack For example,
X
3.14159
42e-8
X + Y
sin(X + 2.0)
(X + Y) / 4
are all valid arithmetic terms. However,
f(a)
c + 5.0
cos(f(3))
are not. The arithmetic terms are interpreted as having their usual meaning as arithmetic expressions. Operator precedences for the arithmetic function symbols follow the normal convention. Parentheses can be also used to escape the application of the default operator precedences.
Functor terms are either variable or functor constant terms or compound terms. A compound functor term has the form where , f is an N-ary uninterpreted functor and are (not necessarily functor) terms. The functor is uninterpreted, meaning that the functor is simply to be treated as a symbolic constant, as opposed to the arithmetic terms, which are interpreted. The allowable syntax of the functor symbol f is that of any functor constant term. The other compound functor terms are lists, which are specified using the usual PROLOG list notation ([L]), for example ``[a, b]''. A dot notation for lists, as in ``a.b.[]'', may also be used. For example, the following are valid terms:
[a, 1+X]
f([3.12, g(a)])
f(c)
f(X)
f(3.14159)
g(22, h(4))
f(X + 3)
A constraint is either an arithmetic constraint or a functor constraint. The former is defined to be of the the form where and are arithmetic terms and is one of the arithmetic relations =, >=, <=, >, and <. For example,
X > 5.0
X + Y + Z = 3
X <= Y
X = V
3 = sin(X)
1.234 + X < Y
are all valid arithmetic constraints, while the following are not.
c > Y
X = 3.0 < Y
pow(X = Y, 3)
4 < X < 5
A functor constraint is of the form where each of and is either a variable or a functor term. We shall sometimes refer to a functor constraint as a functor equation below.