next up previous contents index
Next: Terms and Constraints Up: The CLP() Programmer's Manual Previous: Introduction

Syntax and Simple Examples

 

A CLP( tex2html_wrap_inline4020 ) program is a collection of rules. The definition of a rule is similar to that of a PROLOG clause, but it differs in two important ways: rules can contain constraints as well as atoms in the body, and the definition of terms is more general. A goal is a rule without a head, as usual.   

The body of a rule may contain any number of arithmetic constraints, separated by commas in the usual way. Constraints are equations or inequalities, built up from real constants, variables, +, -, *, /, and =, >=, <=, >, < where all of these symbols have the usual meanings and parentheses may be used in the usual way to resolve ambiguity. Unary arithmetic negation is also available, as are some special interpreted function symbols which will be described later. Any variable that appears in an arithmetic constraint is said to be an arithmetic variable, and cannot take a non-arithmetic value. These constraints may be thought of as built-in predicates written infix, but they are really much more powerful, as we shall see later. Goals are also similar to those in PROLOG, and may contain explicit constraints as well.

Comments in the program are either in the PROLOG style, beginning with a ``%'' and continuing to the end of the line, or also in the form of C style comments, starting with ``/*'' and ending with ``*/'' (comments can contain newlines). Unlike normal C comments, these can be nested so that code already containing comments can be commented easily.  





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