What is Euclid
Syntax
Domains Covered
Operational Semantics
Solved Examples
Implementation
The Theory behind

The Syntax of Euclid

This document presents a rough guide to the syntax of Euclid. The conventions followed when moving from constraint normal forms to computer language statements are these employed by Prolog and CLP(R). A working knowledge of Prolog and/or CLP(R) is assumed.

A Quick Reference to the terminology used:

Programs, constraint clauses, constraints

A Euclid program is a collection of constraint clauses. Each constraint clause is a statement about the problem in hand. Constraint clauses have a standard form which is based on the constraint normal form. Clauses do not offer the full expresionality of the logic but they offer easy computational manipulation (and as can be later seen the expressive power is not that limited).

A constraint clause is a logical statement of the form:

	Head :- {C1,...,Cn},Body
where Head is an atom, C1,...,Cn are D-domain constraints and Body is a conjunction of atoms.

A D-domain constraint is a relation defined (internally) on a specific domain(Euclid contains a number of different domains). Syntactically it is an atom with some restrictions on the terms it contains.
Example 1
 1 gravity_force_field(M,G,F):-
 2      reals([M,G]),
 3      formula(F),
 4      F=(M*G)//X.
 5 object_dynamics(F,M,A):-
 6      formulae([F,A]),
 7      real(M),
 8      (1/M)*F=A. 

Here the program is made of two constraint clauses (lines 1-4 and lines 5-8). There are no body atoms since all relations in lines 2,3,4,6,7 and 8 are constraints. The constraints reals([...]) and formulae([..]) constraint the variables in their lists to the respective domains (should any of the variables be already tagged from a different domain the constraint simply fails). Line 4 is a constraint from the domain of formulæ equating domain variable F with the domain term (M*G)//X a formula on the variable X (which as it happens does not appear)

Terms, D-domain terms, Classical Terms, Variables

A euclid term is either a constant or a variable or a function containing euclid terms. All terms are divided into classic, D-domain or mixed (general) terms.

D-domain terms are special symbols (variables, constants and functions) defined for each external domain. Their meaning (interpretation) is fixed at the creation of the language. In order to avoid using a great number of different symbols variables are (internally) tagged and constants take their meaning from the current context (e.g. 0 can be a constant for both reals and vectors).

Any term not made of D-domain elements (variables, constants or functions) is a classical term. Of course it is entirely possible (and many times highly desirable) to have mixed terms made up from classic or D-domain variables or constants and classic function symbols.

In Euclid variables are tagged; they belong to a specific domain. They start their life belonging to the Herbrand domain. These variables can take any symbolic value and are open to all interpretations. In the course of a computation some variables can migrate from Herbrand to other domains: after that stage their values are limited to domain terms (constructs from domain variables,constants and functions) and their interpretation fixed by the language to the intended one. Thus if X is a real variable it can only be substituted by a real constant (e.g. 5), or a more complex domain term (e.g. 5+cos(Y) where Y is a real variable).

Examples:

  • 3*X^2-5.0*cos(2*pi) is a real term. cos is a d-domain function and pi a d-domain constant (as are ofcourse all the real numbers. In this example, the variable X will be tagged as belonging to the domain of the reals.
  • job(3,Z+5) is a mixed term; job is a classical function symbol but 3,+ are d-domain symbols (from the domain of reals).
  • cos([1,2]) is an illegal term. This term is not part of the language. In the current version of Euclid, the interpreter will simply fail upon execution of the statement containing the term. Strictly speaking a syntax error should be given (the checking happens at runtime when more knowledge of the context is available).

External Domains

For each external domain attached to the language a number of constant, function and relation symbols are introduced. Since variables are tagged there is no need to introduce domain variables as symbols. The relation `=' is defined on all external domains (semantic equality) and the definition of the same symbol on the domain of terms plays the role of the standard unification (syntactic equality).

Currently Euclid contains the domains of Reals, Real Intervals, Real Vectors, Real Formulae and Real Symbolic Functions. A more detailed presentation of the domains contains all the symbols (and their respective meaning) defined for each domain. These symbols are reserved and cannot change their meaning during program execution.

Queries (Goals)

Euclid performs its computation by returning answers (answer substitutions) together with list of constraints to queries. A query or goal is a rule without a head. An answer substitution is an assignment of terms to variables that when substituted to the original query the statement becomes true in the logic. The set of constraints returned with the answer is a set of (possibly) satisfiable constraints that need to hold so that the original query could be satisfied. Logically this answer processes can be viewed as partial computation where constraints are carried over until the end and a trusted method simplifies them to a presentable set.

Examples:

  • gravity_force_field(M,G,F). will return the constrains between the real variables M,G and F.
  • gravity_force_field(10,9.81,F). will return the value of the force acting on a mass of 10 mass units if the gravitational acceleration is 9.81 acceleration units.

 

© 1995 Dr. K J Dryllerakis
Please read the Legal Information concerning Euclid.
CLP(R) is a Trademark of IBM Watson Research Centre, Quintus Prolog is a trademark of Quintus Corporation, USA. SunOS is a trademark of Sun MicroSystems.