CiaoPP is the abstract interpretation-based preprocessor of the Ciao multi-paradigm program development environment. CiaoPP can perform a number of program debugging, analysis, and source-to-source transformation tasks on (Ciao) Prolog programs. These tasks include:

The information generated by analysis, the assertions in the system specifications are all written in the same assertion language, which is in turn also used by the Ciao system documentation generator, lpdoc.

CiaoPP is distributed under the GNU general public license.

How to use this manual

This is a reference manual. You can use it to look up in it descriptions for the commands, flags, and options that can be used with CiaoPP. The Predicate/Method Definition Index may help you in locating commands. The Regular Type Definition Index may help in locating the definitions of the types associated to the arguments of commands. The Concept Definition Index may help in locating the part of the manual where a particular feature of CiaoPP is described. The Global Index includes all of the above plus references to pages where the command, type, or concept is used (not necessarily defined).

This chapter gives a brief overview of CiaoPP and its capabilities. It assumes some familiarity with the techniques that implement such functionalities. However, references are included to technical papers that explain in detail such techniques. An overview of the functionalities available is given in [BLGPH06] in the form of a tutorial on CiaoPP.


We are in the process of merging all CiaoPP functionality into the 1.2 version. In the meantime, the current distribution is marked as alpha and you may find that some functionality documented in this manual is not available or not working properly. Please bear with us in the meantime. Sorry for any inconvenience.

Getting started

A CiaoPP session consists in the preprocessing of a file. The session is governed by a menu, where you can choose the kind of preprocessing you want to be done to your file among several analyses and program transformations available. Clicking on the icon in the buffer containing the file to be preprocessed displays the menu, which will look (depending on the options available in the current CiaoPP version) something like the “Preprocessor Option Browser” shown in the following figure:

Except for the first and last lines, which refer to loading or saving a menu configuration (a predetermined set of selected values for the different menu options), each line corresponds to an option you can select, each having several possible values. You can select either analysis (analyze) or assertion checking (check_assertions) or certificate checking (check_certificate) or program optimization (optimize), and you can later combine the four kinds of preprocessing. The relevant options for the action group selected are then shown, together with the relevant flags. A description of the values for each option will be given as it is used in the corresponding section of this manual.

CiaoPP can help you to analyze your program, in order to infer properties of the predicates and literals in your program (which might be useful in the subsequent steps during the same session). You can use Cost Analysis to infer both lower and upper bounds on the computational time cost and sizes of terms of procedures in a program. Mode Analyses obtain at compile-time accurate variable groundness and sharing information and other variable instantiation properties. Type Analysis infers regular types. Regular types are explained in detail in Declaring regular types. Non-failure and Determinacy Analyses detect procedures and goals that can be guaranteed to not fail and/or to be deterministic.

CiaoPP also can help to optimize your program (by means of source-to-source program transformations), using program specialization, partial evaluation, program parallelization and granularity control, and other program transformations. Specialization can help to simplify your program w.r.t. the analysis information (eliminating dead code, predicates that are guaranteed to either succeed or fail, etc.), specialize it and then simplify it, or just specialize it, i.e., to unfold all versions of the predicates in your program. CiaoPP can also perform automatic parallelization of your source program during precompilation using several annotation algorithms, and granularity control on parallel programs, transforming the program in order to perform run--time granularity control, i.e., deciding parallel or sequential execution of goals depending on the estimated amount of work under them (estimated by cost analysis).

CiaoPP also helps in debugging your programs. It makes possible to perform static debugging, i.e., finding errors at compile-time, before running the program, and also dynamic debugging, in the sense of including run-time tests that will perform the checking for errors at run-time. Static debugging is performed by assertion checking. This includes checking the ways in which programs call the system library predicates and also checking the assertions present in the program or in other modules used by the program. Such assertions essentially represent partial specifications of the program. For dynamic checking, CiaoPP will include run-time tests for the parts of assertions which cannot be checked completely at compile-time.

Using assertions for preprocessing programs, gives an overview on the use of the assertion language in CiaoPP. In that chapter and the following ones, several existing properties that can be used in assertions are described. Programmers can also define their own properties (see the abovementioned chapters).

CiaoPP interfaces

There are three main levels of interaction with CiaoPP. There is a graphical menu interface, based on the emacs editor, that allows the selection of configuration options and the use of the different features of CiaoPP. If emacs is not available, this menu interface can be used as a text-based menu interface. There are several supplementary predicates for assisting the user and providing a kind of scripting language (based on the Ciao language). This interface is described in The CiaoPP high-level interface.

The second level of interaction with CiaoPP is the low-level interface, detailed in The CiaoPP low-level interface. This interface is intended for advanced developers, and contains the primitives used by the above mentioned menu-based interface for implementing the main features of the system.

And finally, the command-line interface allows the use of CiaoPP without direct interaction of the user. With this feature, the CiaoPP system can be integrated into other systems (as for example interactive web sites) by means of batch commands. It is described in The CiaoPP command-line interface.