Go to the first, previous, next, last section, table of contents.


Introduction

NOTE: This (semi-automatically generated) manual is still incomplete. It is however being updated regularly as the machine-readable documentation of the different libraries is completed.

This is the Reference Manual for the Ciao Prolog development system. It contains basic information on how to install Ciao Prolog and how to write, debug, and run Ciao Prolog programs, both from the command line and from inside GNU emacs. It also documents all the libraries available in the standard distribution.

About the Ciao Prolog development system

The Ciao system comprises Ciao Prolog and its programming environment, which includes a number of programming tools such as the Ciao compiler (ciaoc), top-level interactive shell (ciaosh or ciao), a Prolog-script interpreter (ciao-shell), a Prolog emacs mode which helps program developing with support for tasks as editing, debugging and version/change tracking, a program preprocessor (ciaopp), which supports static debugging and optimization from program analysis via source to source program transformation, an automatic documentation generator (lpdoc) [Her99b], and a number of execution visualization tools.

This manual documents the first four of the abovementioned tools [PART I - The program development environment]), and the Ciao Prolog language and library [PART II - The Ciao basic language (engine)]. ciaopp and lpdoc are documented in separated manuals.

The Ciao language has been designed from the ground up to be minimal but also highly extensible (in a modular way). The first objective allows producing small executables (including only those builtins used by the program), providing basic support for pure logic programming, and support for writing scripts in Prolog. The second one allows adding support for standard ISO-Prolog [PART III - ISO-Prolog library (iso)], as well as extensions such as constraint logic programming, functional logic programming, and object-oriented logic programming [PART VII - Ciao Prolog extensions].

Based on the same motivation for modularity, Ciao design has also been focused on allowing modular program development, automatic manipulation and optimization. Ciao includes a robust module system [CH99a], module-based automatic incremental compilation [CH99b], and modular global program analysis, debugging and optimization [PH99], based on a rich assertion language [PART V - Annotated Prolog library (assertions)] for declaring (optional) program properties (including types and modes), which can be checked either statically or dynamically. All program analysis and static debugging and optimization tasks are performed by the ciaopp preprocessor.

Ciao also includes several other features and utilities, such as support for several forms of executables, concurrency (threads), distributed and parallel execution, high-order, WWW programming, interfaces to other languages like C and Java, etc.

ISO-Prolog compliance

Ciao has been designed to subsume ISO-Prolog [DEDC96] (International Standard ISO/IEC 13211-1, PROLOG: Part 1--General Core), while extending it in many ways. The intention is to ensure that all ISO-compliant Prolog programs should run correctly under Ciao. At the same time, Ciao allows selectively avoiding the loading of most ISO-builtins (and changing some other ISO characteristics) when not needed, so that it is possible to work with purer subsets of Prolog, and develop extensions using these purer subsets as a starting point. Also, Ciao allows the development of libraries which significantly extend the language both syntactically and semantically.

Given that the final version of the ISO standard has only been recently published, total compliance with ISO is still not achieved. There are some minor deviations in, e.g., the treatment of characters, the syntax, some of the arithmetic functions, and part of the error system. However, despite this, Ciao has been reported by independent sources (members of the standarization body) to be one of the most conforming Prologs at the moment of this writing, and the first one to be able to compile all the standard-conforming test cases.

Also, Ciao does not offer a strictly conforming mode which rejects uses of non-ISO features. However, in order to aid programmers who wish to write standard compliant programs, library predicates that correspond to those in the ISO-Prolog standard are marked specially in the manuals, and any differences between the Ciao and the prescribed ISO-Prolog behaviours, if any, commented appropriately.

The intention of the Ciao developers is to progressively complete the compliance of Ciao with the published parts of the ISO standard as well as with the other parts which are currently in preparation and may be published in the future.

Finally, as stated elsewhere, one of the design objectives of Ciao is to address some shortcomings of previous implementations of Prolog and logic programming in general. Given this, we also hope that some of the better ideas present in the Ciao system will make it eventually into the standard.

Syntax terminology and notational conventions

In Prolog, procedures are called predicates and predicate calls literals. They all have the classical syntax of procedures (and of logic predications and of mathematical functions). Predicates are identified in this manual by a keyword 'PREDICATE' at the right margin of the place where they are documented.

Prolog instructions are expressions made up of control constructs (section Control constructs/predicates) and literals, and are called goals. Literals are also (atomic) goals.

A predicate definition is a sequence of clauses. A clause has the form H :- B. (ending in '.'), where H is syntactically the same as a literal and is called the clause head, and B is a goal and is called the clause body. A clause with no body is written H. and is called a fact. Clauses with body are also called rules. A Prolog program is a sequence of predicate definitions.

Characters and character strings

We adopt the following convention for delineating character strings in the text of this manual: when a string is being used as a Prolog atom it is written thus: user or 'user'; but in all other circumstances double quotes are used.

When referring to keyboard characters, printing characters are written thus: a, while control characters are written like this: ^A. Thus ^C is the character you get by holding down the CTL key while you type c. Finally, the special control characters carriage-return, line-feed and space are often abbreviated to RET, LFD and SPC respectively.

Predicate specs

Predicates in Prolog are distinguished by their name and their arity. We will call name/arity a predicate spec. The notation name/arity is therefore used when it is necessary to refer to a predicate unambiguously. For example, concatenate/3 specifies the predicate which is named "concatenate" and which takes 3 arguments.

(Note that different predicates may have the same name and different arity. Conversely, of course, they may have the same arity and different name.)

Modes

When documenting a predicate, we will often describe its usage with a mode spec which has the form name(Arg1, ..., ArgN) where each Arg may be preceded by a mode. A mode is a functor which is wrapped around an argument (or prepended if defined as an operator). Such a mode allows documenting in a compact way the instantiation state on call and exit of the argument to which it is applied. The set of modes which can be used in Ciao is not fixed. Instead, arbitrary modes can be defined by in programs using the modedef/1 declarations of the Ciao assertion language (section The Ciao assertion package for details). Modes are identified in this manual by a keyword 'MODE'.

Herein, we will use the set of modes defined in the Ciao isomodes library, which is essentially the same as those used in the ISO-Prolog standard (section ISO-Prolog modes).

Properties and types

Although Ciao Prolog is not a typed language, it allows writing (and using) types, as well as (more general) properties. There may be properties of the states and of the computation. Properties of the states allow expressing characteristics of the program variables during computation, like in sorted(X) (X is a sorted list). Properties of the computation allow expressing characteristics of a whole computation, like in is_det(p(X,Y)) (such calls yield only one solution). Properties are just a special form of predicates (section Declaring regular types) and are identified in this manual by a keyword 'PROPERTY'.

Ciao types are regular types (section Declaring regular types), which are a special form of properties themselves. They are identified in this manual by a keyword 'REGTYPE'.

Declarations

A declaration is an instruction to one of the Ciao environment tools to do something, which is interspersed in the code of a program. Usually the target tool is either the compiler (telling it that a predicate is dynamic, or a meta-predicate, etc.) or the preprocessor (which understands declarations of properties and types, assertions, etc.).

A declaration has the form :- D. where D is syntactically the same as a literal. Declarations are identified in this manual by a keyword 'DECLARATION'.

Operators

An operator is a functor (or predicate name) which has been declared as such, thus allowing its use in a prefix, infix, or suffix fashion, instead of the standard procedure-like fashion. E.g., declaring + as an infix operator allows writing X+Y instead of '+'(X,Y) (which may still, of course, be written).

Operators in Ciao are local to the module/file where they are declared. However, some operators are standard and allowed in every program. See section Standard operators. This manual documents the operator declarations in each (library) module where they are included.

Acknowledgments

The Ciao system is a joint effort on one side of the present ( Francisco Bueno, Daniel Cabeza, Manuel Carro, Manuel Hermenegildo, Pedro López, and Germán Puebla) and past ( Mar'{@dotless{i}a José Garc'{@dotless{i}}a de la Banda}) members of the CLIP group at the School of Computer Science, Technical University of Madrid , and on the other side of several colleagues and students that have collaborated with us over the years of its development. The following is an (inevitably incomplete) list of those that have contributed to the development of Ciao:

If you feel you have contributed to the development of Ciao and we have forgotten adding your name, please let us know and we will be glad to give proper credits.

Known bugs and planned improvements (ciao)

Version/Change Log (ciao)

Version 1.4 (1999/11/27, 19:0:0 MEST)
Version 1.3 (1999/6/16, 17:5:58 MEST)
Development version following even 1.2.
Version 1.2 (1999/6/14, 16:54:55 MEST)
Temporary version.
Version 1.1 (1999/6/4, 13:30:37 MEST)
Development version following even 1.0.
Version 1.0 (1999/6/4, 13:27:42 MEST)
Version 0.9 (1999/3/10, 17:3:49 CET)
Version 0.8 (1998/10/27, 13:12:36 MET)
Version 0.7 (1998/9/15, 12:12:33 MEST)
Version 0.6 (1998/7/16, 21:12:7 MET DST)
Version 0.5 (1998/3/23)
Version 0.4 (1998/2/24)
Version 0.3 (1997/8/20)
Version 0.2 (1997/4/16)
Version 0.1 (1997/2/13)
First Ciao version, based on &-prolog system.


Go to the first, previous, next, last section, table of contents.