next up previous contents index
Next: Some Simple Programs Up: Syntax and Simple Examples Previous: Syntax and Simple Examples

Terms and Constraints

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:

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 conventiongif. 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 tex2html_wrap_inline4115 where tex2html_wrap_inline4117 , f is an N-ary uninterpreted functor and tex2html_wrap_inline4123 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 tex2html_wrap_inline4127 where tex2html_wrap_inline4129 and tex2html_wrap_inline4131 are arithmetic terms and tex2html_wrap_inline4133 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 tex2html_wrap_inline4135 where each of tex2html_wrap_inline4129 and tex2html_wrap_inline4131 is either a variable or a functor term. We shall sometimes refer to a functor constraint as a functor equation below.


next up previous contents index
Next: Some Simple Programs Up: Syntax and Simple Examples Previous: Syntax and Simple Examples

Alan Borning
Fri Oct 8 12:51:18 PDT 1999