About this manual

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

This manual has been generated using the LPdoc semi-automatic documentation generator for LP/CLP programs [HC97,Her00]. lpdoc processes Ciao files (and files in Prolog and other CLP languages) adorned with assertions and machine-readable comments, which should be written in the Ciao assertion language [PBH97,PBH00]. From these, it generates manuals in many formats including postscript, pdf, texinfo, info, HTML, man, etc., as well as on-line help, ascii README files, entries for indices of manuals (info, WWW, ...), and maintains WWW distribution sites.

The big advantage of this approach is that it is easier to keep the on-line and printed documentation in sync with the source code [Knu84]. As a result, this manual changes continually as the source code is modified. Because of this, the manual has a version number. You should make sure the manual you are reading, whether it be printed or on-line, coincides with the version of the software that you are using.

The approach also implies that there is often a variability in the degree to which different libraries or system components are documented. Many libraries offer abundant documentation, but a few will offer little. The latter is due to the fact that we tend to include libraries in the manual if the code is found to be useful, even if they may still contain sparse documentation. This is because including a library in the manual will at the bare minimum provide formal information (such as the names of exported predicates and their arity, which other modules it loads, etc.), create index entries, pointers for on-line help in the electronic versions of the manuals, and command-line completion capabilities inside emacs. Again, the manual is being updated continuously as the different libraries (and machine-readable documentation in them) are improved.

About the Ciao development system

The Ciao system is a full programming environment for developing programs in the Prolog language and in several other languages which are extensions and modifications of Prolog and (Constraint) Logic Programming in several interesting and useful directions. The programming environment offers a number of tools such as the Ciao standalone compiler (ciaoc), a traditional-style top-level interactive shell (ciaosh or ciao), an interpreter of scripts written in Ciao (ciao-shell), a Ciao (and Prolog) emacs mode (which greatly helps the task of developing programs with support for editing, debugging, version/change tracking, etc.), numerous libraries, a powerful program preprocessor (ciaopp [BGH99,HPB99,HBPLG99,BLGPH04,HPBLG05], which supports static debugging and optimization from program analysis via source to source program transformation), and an automatic documentation generator (lpdoc) [HC97,Her00]. A number of execution visualization tools [CGH93,CH00d,CH00c] are also available.

This manual documents the first four of the tools mentioned above [see PART I - The program development environment], and the Ciao language and libraries. The ciaopp and lpdoc tools are documented in separate manuals.

The Ciao language [see PART II - The Ciao basic language] has been designed from the ground up to be small, but to also allow extensions and restrictions in a modular way. This allows modular program development with clear program semantics, as well as automatic program manipulation and optimization. Ciao includes a robust module system [CH00a], module-based automatic incremental compilation [CH99b], and modular global program analysis, debugging and optimization [PH99], based on a rich assertion language [see PART III - Assertions and auto-documentation] for declaring (optional) program properties (including types, modes, determinacy, etc.), which can be checked either statically or dynamically. The program analysis, static debugging and optimization tasks related to these assertions are performed by the ciaopp preprocessor, as mentioned above. These assertions (together with special comment-style declarations) are also the ones used by the lpdoc autodocumenter to generate documentation for programs (the comment-style declarations are documented in the lpdoc manual).

Moreover, the modular design allows powerful extensions such as constraint logic programming, multi-paradigm features (higher-order, functional notation, etc.), alternative search and evaluation strategies, concurrency (threads), distributed and parallel execution, foreign language interfaces, restrictions such as working with pure horn clauses [see PART IV - Language extensions], as well as supporting standard ISO-Prolog [see PART V - Compatibility].

Ciao includes a collection of standard and additional libraries and utilities see [see PART VI - Data structures and algorithms, PART VII - Standard libraries, and PART VIII - Additional libraries]. Apart from these, many other tools and libraries, such as language bindings) to several languages and systems are distributed as separate bundles.

ISO-Prolog compliance and extensibility

One of the innovative features of Ciao is that it has been designed to subsume transparently ISO-Prolog (International Standard ISO/IEC 13211-1, PROLOG: Part 1--General Core [DEDC96]), while at the same time extending it in many important ways. The intention is to ensure that all ISO-compliant Prolog programs run correctly under Ciao. At the same time, the Ciao module system (see PART II - The Ciao basic language and [CH00a] for a discussion of the motivations behind the design) 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 also to build small executables. Also, this module system makes it possible to develop extensions using these purer subsets (or even the full ISO-standard) as a starting point. Using these features, the Ciao distribution includes libraries which significantly extend the language both syntactically and semantically.

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 differences between the Ciao and the prescribed ISO-Prolog behaviours, if any, are commented appropriately. There is also functionality (see ISO-Prolog package) which makes the standard ISO-Prolog predicates available by default in the modules that use traditional module declarations or that load this package explicitly. Thus, ISO-compliance is active transparently for ported programs.

The intention of the Ciao developers is to maintain and continuously improve the compliance of Ciao with the published parts of the ISO standard, with other reasonable extensions of the standard that may be published in the future, and with those features that the Prolog developer community agrees widely on. At the same time, since one of the design objectives of Ciao is to address some shortcomings of previous implementations of Prolog and logic programming in general, we also encourage and work towards making some of the better ideas present in the system reach the standards and also be adopted by other systems.

About the name of the System

Ciao is short for ``Ciao Prolog,'' a name which has an interesting (and not unintended) interpretation. Ciao is an interesting word which means both hello and goodbye. 'Ciao Prolog' intends to be a really good, all-round, freely available ISO-Prolog system which can be used as a classical Prolog, in both academic and industrial environments (and, in particular, to introduce users to Prolog and to constraint and logic programming --the hello part). An indeed many programmers use it just that way. But Ciao is also a new-generation, multiparadigm programming language and program development system which goes well beyond Prolog and other classical logic programming languages. And it has the advantage (when compared to other new-generation LP systems) that it does so while keeping full Prolog compatibility when needed.

Referring to Ciao

If you find Ciao or any of its components useful, we would appreciate very much if you added a reference to this manual in your work. The following is an appropriate BiBTeX entry with the relevant data:

  author = {F.~Bueno and M.~Carro and M.~V.~Hermenegildo 
            and P.~L\'{o}pez-Garc\'{\i}a and 
            and J.F.~Morales (Eds.)},
  title = {{T}he {C}iao {S}ystem. {R}ef. {M}anual (V1.16)},
  month = {July},
  year = 2017,
  url = {},
  butype = {techreport},
  note = {Available at \texttt{}}


The Ciao system is a joint effort on one hand of some present (Francisco Bueno, Manuel Carro, Manuel Hermenegildo, Pedro López, and Jose F. Morales) and past (Daniel Cabeza, María José García de la Banda, Germán Puebla) main members of the CLIP group at the School of Computer Science, Technical University of Madrid and at the IMDEA Software Institute, and on the other hand of many colleagues and students that have collaborated with us over the years. These names are listed generally in the documentation of each library or part of the system and appear in the Author index chapters of the different manuals, as well as the references. In addition, the following is an (inevitably incomplete) list of other colleagues and sources that have contributed to the development of Ciao:

If you feel you have contributed to the development of Ciao and we have forgotten to add your name to this list or to the acknowledgements given in the different chapters and indices, please let us know and we will be glad to give proper credits.