Tutorials
Definite Clause Deduction

Back to tutorials.

Tutorial Five (Supplementary): Syntax

For the most part, the syntax that the applet uses is the syntax used by CILog. However, it does not implement all of CILog's built-in features and functionality. There are three components in the language: terms, atoms, and clauses.

Terms: A term is a variable, a constant, or a compound term. A variable is a sequence of alphanumeric characters that starts with an uppercase letter. The only exception is "_", which is a variable that can unify with anything. A constant is either a sequence of alphanumeric characters starting with a lowercase letter or an integer. Finally, a compound term has the form f(t1,...,tn), where f is a function symbol (a sequence of alphanumeric characters starting with a lowercase letter) and the ti are terms. However, arithmetic expressions are also considered to be compound terms. Some atoms require arithmetic expressions as arguments. The infix functions "+", "-", "*", and "mod" are implemented, with the usual interpretation.

Atoms: Atoms, also called goals, are almost identical in syntax to compound terms. They are of the form p(t1,...,tn), where p is a predicate symbol (a sequence of alphanumeric characters starting with a lowercase letter) and the ti are terms. It is also possible to have a goal with no terms and only a predicate symbol. As with compound terms, there are also (infix) built-in predicates:

  • X < Y, where X and Y must be ground arithmetic expressions when called, is true if the value of X is less than the value of Y.
  • X > Y, where X and Y must be ground arithmetic expressions when called, is true if the value of X is greater than the value of Y.
  • X =< Y, where X and Y must be ground arithmetic expressions when called, is true if the value of X is less than or equal to the value of Y.
  • X => Y, where X and Y must be ground arithmetic expressions when called, is true if the value of X is greater than or equal to the value of Y.
  • X =\= Y, where X and Y must be ground arithmetic expressions when called, is true if the value of X is different from the value of Y.
  • V is E, where E must be a ground arithmetic expression when called, is true if expression E evaluates to V.
  • X \= Y, where X and Y denote different objects under the unique names assumption, or are different compound terms.
An atom may also be negated: ~ g is true if g fails finitely. If g is an arithmetic expression that is not yet ground, it does not fail in finitely many steps. The depth bound for negation as failure queries is the same as the depth bound for the search tree.

Clauses: Clauses, which are also called rules, are made up of two parts. The first part, the head, is simply a goal. Every clause must have a head, and must end with a period. The body of a clause is a conjunction of atoms g1 & ... & gn. Thus, the clause is either of the form h. or h <- b where h is the head of the clause and b is the body.

Back to tutorials.

Valid HTML 4.0 Transitional