The Ciao Prolog Systemciao-lang.org/legacy/files/ciao/ciao.pdf · The Ciao Prolog System...

989
The Ciao Prolog System A Next Generation Multi-Paradigm Programming Environment REFERENCE MANUAL The Ciao System Documentation Series http://www.ciaohome.org/ Generated/Printed on: 26 April 2006 Technical Report CLIP 3/97-<version below> Version 1.10#7 (2006/4/26, 19:22:13 CEST) Edited by: F. Bueno D. Cabeza M. Carro M. Hermenegildo P. L´ opez G. Puebla The Computational logic, Languages, Implementation, and Parallelism (CLIP) Group [email protected] http://www.cliplab.org/ School of CS, Technical University of Madrid CS and ECE Departments, University of New Mexico

Transcript of The Ciao Prolog Systemciao-lang.org/legacy/files/ciao/ciao.pdf · The Ciao Prolog System...

  • The Ciao Prolog SystemA Next Generation Multi-Paradigm Programming Environment

    REFERENCE MANUALThe Ciao System Documentation Series

    http://www.ciaohome.org/

    Generated/Printed on: 26 April 2006Technical Report CLIP 3/97-Version 1.10#7 (2006/4/26, 19:22:13 CEST)

    Edited by:

    F. BuenoD. CabezaM. CarroM. HermenegildoP. LópezG. Puebla

    The Computational logic, Languages,Implementation, and Parallelism (CLIP) [email protected]

    http://www.cliplab.org/

    School of CS, Technical University of MadridCS and ECE Departments, University of New Mexico

  • Copyright c© F. Bueno, D. Cabeza, M. Carro, M. Hermenegildo, P. López, and G. Puebla

    This document may be freely read, stored, reproduced, disseminated, translated or quoted byany means and on any medium provided the following conditions are met:

    1. Every reader or user of this document acknowledges that is aware that no guarantee is givenregarding its contents, on any account, and specifically concerning veracity, accuracy andfitness for any purpose.

    2. No modification is made other than cosmetic, change of representation format, translation,correction of obvious syntactic errors, or as permitted by the clauses below.

    3. Comments and other additions may be inserted, provided they clearly appear as such;translations or fragments must clearly refer to an original complete version, preferably onethat is easily accessed whenever possible.

    4. Translations, comments and other additions or modifications must be dated and their au-thor(s) must be identifiable (possibly via an alias).

    5. This licence is preserved and applies to the whole document with modifications and additions(except for brief quotes), independently of the representation format.

    6. Any reference to the "official version", "original version" or "how to obtain original versions"of the document is preserved verbatim. Any copyright notice in the document is preservedverbatim. Also, the title and author(s) of the original document should be clearly mentionedas such.

    7. In the case of translations, verbatim sentences mentioned in (6.) are preserved in thelanguage of the original document accompanied by verbatim translations to the languageof the traslated document. All translations state clearly that the author is not responsiblefor the translated work. This license is included, at least in the language in which it isreferenced in the original version.

    8. Whatever the mode of storage, reproduction or dissemination, anyone able to access adigitized version of this document must be able to make a digitized copy in a format directlyusable, and if possible editable, according to accepted, and publicly documented, publicstandards.

    9. Redistributing this document to a third party requires simultaneous redistribution of thislicence, without modification, and in particular without any further condition or restriction,expressed or implied, related or not to this redistribution. In particular, in case of inclusionin a database or collection, the owner or the manager of the database or the collection re-nounces any right related to this inclusion and concerning the possible uses of the documentafter extraction from the database or the collection, whether alone or in relation with otherdocuments.

    Any incompatibility of the above clauses with legal, contractual or judiciary decisions or con-straints implies a corresponding limitation of reading, usage, or redistribution rights for thisdocument, verbatim or modified.

  • i

    Table of Contents

    Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.1 About this manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 About the Ciao Prolog development system . . . . . . . . . . . . . . . . . . . 31.3 ISO-Prolog compliance versus extensibility . . . . . . . . . . . . . . . . . . . . 41.4 About the name of the System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.5 Referring to Ciao . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.6 Syntax terminology and notational conventions . . . . . . . . . . . . . . . . 5

    1.6.1 Predicates and their components . . . . . . . . . . . . . . . . . . . . . 51.6.2 Characters and character strings . . . . . . . . . . . . . . . . . . . . . 51.6.3 Predicate specs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.6.4 Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.6.5 Properties and types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.6.6 Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.6.7 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    1.7 A tour of the manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.7.1 PART I - The program development environment . . . . . 71.7.2 PART II - The Ciao basic language (engine) . . . . . . . . . . 81.7.3 PART III - ISO-Prolog library (iso) . . . . . . . . . . . . . . . . . . 81.7.4 PART IV - Classic Prolog library (classic) . . . . . . . . . . . . 81.7.5 PART V - Annotated Prolog library (assertions) . . . . . . 81.7.6 PART VI - Ciao Prolog library miscellanea . . . . . . . . . . . 81.7.7 PART VII - Ciao Prolog extensions . . . . . . . . . . . . . . . . . . 81.7.8 PART VIII - Interfaces to other languages and systems

    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.7.9 PART IX - Abstract data types . . . . . . . . . . . . . . . . . . . . . . 91.7.10 PART X - Miscellaneous standalone utilities . . . . . . . . . 91.7.11 PART XI - Contributed libraries . . . . . . . . . . . . . . . . . . . . 91.7.12 PART XII - Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    1.8 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.9 Version/Change Log (ciao) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    2 Getting started on Un*x-like machines . . . . . . . . 212.1 Testing your Ciao Un*x installation . . . . . . . . . . . . . . . . . . . . . . . . . . 212.2 Un*x user setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.3 Using Ciao from a Un*x command shell . . . . . . . . . . . . . . . . . . . . . . 22

    2.3.1 Starting/exiting the top-level shell (Un*x) . . . . . . . . . . . 222.3.2 Getting help (Un*x) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222.3.3 Compiling and running programs (Un*x) . . . . . . . . . . . . 222.3.4 Generating executables (Un*x) . . . . . . . . . . . . . . . . . . . . . 232.3.5 Running Ciao scripts (Un*x) . . . . . . . . . . . . . . . . . . . . . . . 232.3.6 The Ciao initialization file (Un*x) . . . . . . . . . . . . . . . . . . . 242.3.7 Printing manuals (Un*x) . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

    2.4 An introduction to the Ciao emacs environment (Un*x) . . . . . . . 242.5 Keeping up to date (Un*x) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

  • ii The Ciao Prolog System

    3 Getting started on Windows machines . . . . . . . . 273.1 Testing your Ciao Win32 installation. . . . . . . . . . . . . . . . . . . . . . . . . 273.2 Using Ciao from the Windows explorer and command shell . . . . 27

    3.2.1 Starting/exiting the top-level shell (Win32) . . . . . . . . . . 273.2.2 Getting help (Win32) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283.2.3 Compiling and running programs (Win32) . . . . . . . . . . . 283.2.4 Generating executables (Win32) . . . . . . . . . . . . . . . . . . . . 283.2.5 Running Ciao scripts (Win32) . . . . . . . . . . . . . . . . . . . . . . 293.2.6 The Ciao initialization file (Win32) . . . . . . . . . . . . . . . . . . 293.2.7 Printing manuals (Win32) . . . . . . . . . . . . . . . . . . . . . . . . . . 29

    3.3 An introduction to the Ciao emacs environment (Win32) . . . . . . 293.4 Keeping up to date (Win32) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

    PART I - The program development environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    4 The stand-alone command-line compiler . . . . . . 334.1 Introduction to building executables . . . . . . . . . . . . . . . . . . . . . . . . . 334.2 Paths used by the compiler during compilation . . . . . . . . . . . . . . . 344.3 Running executables from the command line . . . . . . . . . . . . . . . . . 344.4 Types of executables generated . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354.5 Environment variables used by Ciao executables . . . . . . . . . . . . . . 374.6 Intermediate files in the compilation process . . . . . . . . . . . . . . . . . . 374.7 Usage (ciaoc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    5 The interactive top-level shell . . . . . . . . . . . . . . . . 415.1 Shell invocation and startup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415.2 Shell interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415.3 Entering recursive (conjunctive) shell levels . . . . . . . . . . . . . . . . . . . 425.4 Usage and interface (ciaosh) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445.5 Documentation on exports (ciaosh) . . . . . . . . . . . . . . . . . . . . . . . . . 44

    use module/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44use module/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44ensure loaded/1 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44make exec/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45include/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45use package/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45consult/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45compile/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45./2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46make po/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46unload/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46set debug mode/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . 46set nodebug mode/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . 46make actmod/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46force lazy/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47undo force lazy/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . 47dynamic search path/1 (pred) . . . . . . . . . . . . . . . . . . . . . . 47(multifile)/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

    5.6 Documentation on internals (ciaosh) . . . . . . . . . . . . . . . . . . . . . . . . 47sourcenames/1 (prop). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

  • iii

    6 The interactive debugger . . . . . . . . . . . . . . . . . . . . . 496.1 Marking modules and files for debugging in the top-level debugger

    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496.2 The debugging process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506.3 Marking modules and files for debugging with the embedded

    debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516.4 The procedure box control flow model. . . . . . . . . . . . . . . . . . . . . . . . 526.5 Format of debugging messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536.6 Options available during debugging . . . . . . . . . . . . . . . . . . . . . . . . . . 546.7 Calling predicates that are not exported by a module . . . . . . . . . 566.8 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

    7 Predicates controlling the interactive debugger. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597.1 Usage and interface (debugger) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597.2 Documentation on exports (debugger) . . . . . . . . . . . . . . . . . . . . . . . 59

    debug module/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59nodebug module/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 59debug module source/1 (pred) . . . . . . . . . . . . . . . . . . . . . . 59debug/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60nodebug/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60trace/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60notrace/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60spy/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60nospy/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60nospyall/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61breakpt/6 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61nobreakpt/6 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61nobreakall/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61list breakpt/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62debugging/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62leash/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62maxdepth/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62call in module/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

    7.3 Documentation on internals (debugger) . . . . . . . . . . . . . . . . . . . . . . 63multpredspec/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

    7.4 Known bugs and planned improvements (debugger). . . . . . . . . . . 63

    8 The script interpreter . . . . . . . . . . . . . . . . . . . . . . . . 658.1 How it works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 658.2 Command line arguments in scripts . . . . . . . . . . . . . . . . . . . . . . . . . . 66

    9 Customizing library paths and path aliases . . . . 679.1 Usage and interface (libpaths) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679.2 Documentation on exports (libpaths) . . . . . . . . . . . . . . . . . . . . . . . 67

    get alias path/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679.3 Documentation on multifiles (libpaths) . . . . . . . . . . . . . . . . . . . . . 67

    file search path/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . 67library directory/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 68

  • iv The Ciao Prolog System

    10 Using Ciao inside GNU emacs . . . . . . . . . . . . . . . 6910.1 Conventions for writing Ciao programs under Emacs . . . . . . . . . 6910.2 Checking the installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7010.3 Functionality and associated key sequences (bindings) . . . . . . . . 7010.4 Syntax coloring and syntax-based editing . . . . . . . . . . . . . . . . . . . . 7010.5 Getting on-line help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7010.6 Loading and compiling programs . . . . . . . . . . . . . . . . . . . . . . . . . . . 7110.7 Commands available in toplevel and preprocessor buffers . . . . . 7210.8 Locating errors and checking the syntax of assertions . . . . . . . . . 7410.9 Commands which help typing in programs . . . . . . . . . . . . . . . . . . 7410.10 Debugging programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7410.11 Preprocessing programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7510.12 Version control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7610.13 Generating program documentation . . . . . . . . . . . . . . . . . . . . . . . . 7910.14 Setting top level preprocessor and documenter executables. . . 7910.15 Other commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8010.16 Traditional Prolog Mode Commands . . . . . . . . . . . . . . . . . . . . . . . 8010.17 Coexistence with other Prolog interfaces . . . . . . . . . . . . . . . . . . . 8010.18 Getting the Ciao/Prolog mode version . . . . . . . . . . . . . . . . . . . . . 8110.19 Using Ciao/Prolog mode capabilities in standard shells . . . . . . 8110.20 Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

    10.20.1 Ciao general variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8110.20.2 CiaoPP variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8210.20.3 LPdoc variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8310.20.4 Faces used in syntax-based highlighting (coloring) . . 83

    10.21 Installation of the Ciao/Prolog emacs interface . . . . . . . . . . . . . 8610.22 Emacs version compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8710.23 Acknowledgments (ciao.el) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

    PART II - The Ciao basic language (engine) . . . . . . 89

    11 The module system . . . . . . . . . . . . . . . . . . . . . . . . . 9111.1 Usage and interface (modules) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9111.2 Documentation on internals (modules) . . . . . . . . . . . . . . . . . . . . . . 91

    module/3 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91module/2 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92export/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92use module/2 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92use module/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93import/2 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93reexport/2 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93reexport/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93(meta predicate)/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . 93modulename/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . 94metaspec/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

    12 Directives for using code in other files . . . . . . . 9512.1 Usage and interface (loading_code) . . . . . . . . . . . . . . . . . . . . . . . . 9512.2 Documentation on internals (loading_code) . . . . . . . . . . . . . . . . 95

    ensure loaded/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95include/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95use package/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

  • v

    13 Control constructs/predicates . . . . . . . . . . . . . . . 9713.1 Usage and interface (basiccontrol) . . . . . . . . . . . . . . . . . . . . . . . . 9713.2 Documentation on exports (basiccontrol) . . . . . . . . . . . . . . . . . 97

    ,/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97;/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97-> /2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97!/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97(\+)/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97if/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98true/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98fail/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98repeat/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98call/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98

    13.3 Documentation on internals (basiccontrol) . . . . . . . . . . . . . . . . 99|/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

    14 Basic builtin directives. . . . . . . . . . . . . . . . . . . . . 10114.1 Usage and interface (builtin_directives) . . . . . . . . . . . . . . . . 10114.2 Documentation on internals (builtin_directives) . . . . . . . . . 101

    (multifile)/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101(discontiguous)/1 (decl). . . . . . . . . . . . . . . . . . . . . . . . . . . 101impl defined/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101redefining/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102initialization/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102on abort/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

    15 Basic data types and properties . . . . . . . . . . . . 10315.1 Usage and interface (basic_props) . . . . . . . . . . . . . . . . . . . . . . . . 10315.2 Documentation on exports (basic_props). . . . . . . . . . . . . . . . . . 103

    term/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103int/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103nnegint/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103flt/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103num/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104atm/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104struct/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104gnd/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104constant/1 (regtype). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104callable/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104operator specifier/1 (regtype) . . . . . . . . . . . . . . . . . . . . . 104list/1 (regtype). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105list/2 (regtype). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105member/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105sequence/2 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105sequence or list/2 (regtype) . . . . . . . . . . . . . . . . . . . . . . . 106character code/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . 106string/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106predname/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106atm or atm list/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . 106compat/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106iso/1 (prop). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107not further inst/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . 107sideff/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107regtype/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107native/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

  • vi The Ciao Prolog System

    native/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

    16 Extra-logical properties for typing . . . . . . . . . . 10916.1 Usage and interface (term_typing) . . . . . . . . . . . . . . . . . . . . . . . . 10916.2 Documentation on exports (term_typing). . . . . . . . . . . . . . . . . . 109

    var/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109nonvar/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109atom/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110integer/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110float/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110number/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110atomic/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110ground/1 (prop). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111type/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

    17 Basic term manipulation . . . . . . . . . . . . . . . . . . . 11317.1 Usage and interface (term_basic) . . . . . . . . . . . . . . . . . . . . . . . . . 11317.2 Documentation on exports (term_basic) . . . . . . . . . . . . . . . . . . . 113

    = /2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113arg/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113functor/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113=.. /2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114copy term/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114C/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

    18 Comparing terms . . . . . . . . . . . . . . . . . . . . . . . . . . 11518.1 Usage and interface (term_compare) . . . . . . . . . . . . . . . . . . . . . . . 11518.2 Documentation on exports (term_compare) . . . . . . . . . . . . . . . . 115

    == /2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115\== /2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115@< /2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116@=< /2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116@> /2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116@>= /2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116compare/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

    19 Basic predicates handling names of constants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11919.1 Usage and interface (atomic_basic) . . . . . . . . . . . . . . . . . . . . . . . 11919.2 Documentation on exports (atomic_basic) . . . . . . . . . . . . . . . . 119

    name/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119atom codes/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119number codes/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . 120number codes/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . 120atom number/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120atom length/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120atom concat/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121sub atom/4 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

  • vii

    20 Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12320.1 Usage and interface (arithmetic) . . . . . . . . . . . . . . . . . . . . . . . . . 12320.2 Documentation on exports (arithmetic) . . . . . . . . . . . . . . . . . . . 123

    is/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123< /2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123=< /2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124> /2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124>= /2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124=:= /2 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124=\= /2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124arithexpression/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . 125

    21 Basic file/stream handling . . . . . . . . . . . . . . . . . 12721.1 Usage and interface (streams_basic) . . . . . . . . . . . . . . . . . . . . . . 12721.2 Documentation on exports (streams_basic) . . . . . . . . . . . . . . . 127

    open/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127open/4 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127open option list/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . 128close/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128set input/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128current input/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128set output/1 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129current output/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 129character count/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 129line count/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129line position/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129flush output/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130flush output/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130clearerr/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130current stream/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 130stream code/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130absolute file name/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . 130absolute file name/7 (pred) . . . . . . . . . . . . . . . . . . . . . . . 131sourcename/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . 131stream/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132stream alias/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . 132io mode/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

    21.3 Documentation on multifiles (streams_basic) . . . . . . . . . . . . . . 133file search path/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 133library directory/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . 133

  • viii The Ciao Prolog System

    22 Basic input/output . . . . . . . . . . . . . . . . . . . . . . . . 13522.1 Usage and interface (io_basic) . . . . . . . . . . . . . . . . . . . . . . . . . . . 13522.2 Documentation on exports (io_basic) . . . . . . . . . . . . . . . . . . . . . 135

    get code/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135get code/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135get1 code/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135get1 code/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136peek code/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136peek code/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136skip code/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136skip code/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136skip line/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136skip line/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136put code/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137put code/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137nl/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137nl/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137tab/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137tab/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137code class/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138getct/2 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138getct1/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138display/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138display/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139displayq/2 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139displayq/1 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

    23 Exception handling . . . . . . . . . . . . . . . . . . . . . . . . 14123.1 Usage and interface (exceptions) . . . . . . . . . . . . . . . . . . . . . . . . . 14123.2 Documentation on exports (exceptions) . . . . . . . . . . . . . . . . . . . 141

    catch/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141intercept/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141throw/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141halt/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142halt/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142abort/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

    24 Changing system behaviour and various flags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14324.1 Usage and interface (prolog_flags) . . . . . . . . . . . . . . . . . . . . . . . 14424.2 Documentation on exports (prolog_flags) . . . . . . . . . . . . . . . . 144

    set prolog flag/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . 144current prolog flag/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . 144prolog flag/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144push prolog flag/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . 145pop prolog flag/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 145prompt/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145gc/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145nogc/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145fileerrors/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145nofileerrors/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

    24.3 Documentation on multifiles (prolog_flags) . . . . . . . . . . . . . . . 146define flag/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

  • ix

    25 Fast/concurrent update of facts . . . . . . . . . . . . 14725.1 Usage and interface (data_facts) . . . . . . . . . . . . . . . . . . . . . . . . . 14725.2 Documentation on exports (data_facts) . . . . . . . . . . . . . . . . . . . 147

    asserta fact/1 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147asserta fact/2 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147assertz fact/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148assertz fact/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148current fact/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148current fact/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148retract fact/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148retractall fact/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . 148current fact nb/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 149retract fact nb/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . 149close predicate/1 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . 149open predicate/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 149set fact/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149erase/1 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

    25.3 Documentation on internals (data_facts). . . . . . . . . . . . . . . . . . 150(data)/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150(concurrent)/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150reference/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150

    26 Extending the syntax . . . . . . . . . . . . . . . . . . . . . . 15126.1 Usage and interface (syntax_extensions) . . . . . . . . . . . . . . . . . 15126.2 Documentation on internals (syntax_extensions) . . . . . . . . . . 151

    op/3 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151new declaration/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . 151new declaration/2 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . 151load compilation module/1 (decl) . . . . . . . . . . . . . . . . . . 152add sentence trans/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . 152add term trans/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . 152add goal trans/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . 153add clause trans/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . 153translation predname/1 (regtype) . . . . . . . . . . . . . . . . . . 153

    27 Message printing primitives . . . . . . . . . . . . . . . . 15527.1 Usage and interface (io_aux) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15527.2 Documentation on exports (io_aux) . . . . . . . . . . . . . . . . . . . . . . . 155

    message/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155message lns/4 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155error/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156warning/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156note/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156message/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156debug/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156inform user/1 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157display string/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157display list/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157display term/1 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

    27.3 Known bugs and planned improvements (io_aux) . . . . . . . . . . . 157

  • x The Ciao Prolog System

    28 Attributed variables . . . . . . . . . . . . . . . . . . . . . . . 15928.1 Usage and interface (attributes) . . . . . . . . . . . . . . . . . . . . . . . . . 15928.2 Documentation on exports (attributes) . . . . . . . . . . . . . . . . . . . 159

    attach attribute/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . 159get attribute/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159update attribute/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . 159detach attribute/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . 160

    28.3 Documentation on multifiles (attributes) . . . . . . . . . . . . . . . . . 160verify attribute/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 160combine attributes/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . 160

    28.4 Other information (attributes) . . . . . . . . . . . . . . . . . . . . . . . . . . 160

    29 Gathering some basic internal info . . . . . . . . . . 16329.1 Usage and interface (system_info) . . . . . . . . . . . . . . . . . . . . . . . . 16329.2 Documentation on exports (system_info). . . . . . . . . . . . . . . . . . 163

    get arch/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163get os/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163this module/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164current module/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 164ciaolibdir/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

    29.3 Documentation on internals (system_info) . . . . . . . . . . . . . . . . 165internal module id/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . 165

    30 Other predicates and features defined by default. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16730.1 Usage and interface (default_predicates) . . . . . . . . . . . . . . . . 16730.2 Documentation on exports (default_predicates) . . . . . . . . . . 167

    op/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167current op/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . 167append/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167delete/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167select/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167nth/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168last/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168reverse/2 (udreexp). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168length/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168use module/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . 168use module/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . 168ensure loaded/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . 168^ /2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168findnsols/5 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168findnsols/4 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168findall/4 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168findall/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168bagof/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169setof/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169wellformed body/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . 169(data)/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169(dynamic)/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . 169current predicate/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . 169current predicate/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . 169clause/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169clause/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169abolish/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169retractall/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

  • xi

    retract/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169assert/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170assert/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170assertz/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170assertz/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170asserta/2 (udreexp). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170asserta/1 (udreexp). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170second prompt/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . 170read top level/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . 170read term/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170read term/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170read/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170read/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170printable char/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . 171prettyvars/1 (udreexp). . . . . . . . . . . . . . . . . . . . . . . . . . . . 171numbervars/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . 171portray clause/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . 171portray clause/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . 171write list1/1 (udreexp). . . . . . . . . . . . . . . . . . . . . . . . . . . . 171print/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171print/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171write canonical/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . 171write canonical/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . 171writeq/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171writeq/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171write/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172write/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172write option/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . 172write term/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . 172write term/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . 172put char/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172put char/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172peek char/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172peek char/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172get char/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172get char/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172put byte/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172put byte/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173peek byte/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173peek byte/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173get byte/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173get byte/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173number chars/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . 173atom chars/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . 173char code/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173unify with occurs check/2 (udreexp) . . . . . . . . . . . . . . . 173sub atom/5 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173compound/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . 173once/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173\= /2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174format control/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . 174format/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174format/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174keylist/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174keysort/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174sort/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174

  • xii The Ciao Prolog System

    between/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174cyg2win/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174rename file/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . 174delete directory/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . 174delete file/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174chmod/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175chmod/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175fmode/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175modif time0/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . 175modif time/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . 175file properties/6 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . 175file property/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . 175file exists/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175file exists/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175mktemp/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175directory files/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . 175wait/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175exec/8 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176exec/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176exec/4 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176popen mode/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . 176popen/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176system/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176system/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176shell/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176shell/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176shell/0 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176cd/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176working directory/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . 176make dirpath/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . 177make dirpath/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . 177make directory/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . 177make directory/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . 177umask/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177current executable/1 (udreexp) . . . . . . . . . . . . . . . . . . . . 177current host/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . 177get pid/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177extract paths/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . 177setenvstr/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177getenvstr/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177datime struct/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . 177datime/9 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178datime/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178time/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178pause/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178new atom/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178garbage collect/0 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . 178current atom/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . 178predicate property/2 (udreexp) . . . . . . . . . . . . . . . . . . . . 178statistics/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178statistics/0 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178close file/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178told/0 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178telling/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179tell/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179seen/0 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

  • xiii

    seeing/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179see/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179current key/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . 179recorded/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179recordz/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179recorda/3 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179ttydisplay string/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . 179ttyskipeol/0 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179ttydisplayq/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . 179ttydisplay/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180ttyflush/0 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180ttytab/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180ttyskip/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180ttyput/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180ttynl/0 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180ttyget1/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180ttyget/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180

    PART III - ISO-Prolog library (iso) . . . . . . . . . . . . . 181

    31 ISO-Prolog package . . . . . . . . . . . . . . . . . . . . . . . . 18331.1 Usage and interface (iso) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

    32 All solutions predicates . . . . . . . . . . . . . . . . . . . . 18532.1 Usage and interface (aggregates) . . . . . . . . . . . . . . . . . . . . . . . . . 18532.2 Documentation on exports (aggregates) . . . . . . . . . . . . . . . . . . . 185

    setof/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185bagof/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186findall/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186findall/4 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186findnsols/4 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186findnsols/5 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187^ /2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

    33 Dynamic predicates. . . . . . . . . . . . . . . . . . . . . . . . 18933.1 Usage and interface (dynamic) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18933.2 Documentation on exports (dynamic) . . . . . . . . . . . . . . . . . . . . . . 189

    asserta/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189asserta/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189assertz/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190assertz/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190assert/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190assert/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190retract/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190retractall/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191abolish/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191clause/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191clause/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191current predicate/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . 192current predicate/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . 192(dynamic)/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192(data)/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192wellformed body/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . 192

    33.3 Documentation on multifiles (dynamic) . . . . . . . . . . . . . . . . . . . . 193do on abolish/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

  • xiv The Ciao Prolog System

    34 Term input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19534.1 Usage and interface (read) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19534.2 Documentation on exports (read) . . . . . . . . . . . . . . . . . . . . . . . . . 195

    read/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195read/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195read term/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195read term/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196read top level/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . 196second prompt/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 196

    34.3 Documentation on multifiles (read) . . . . . . . . . . . . . . . . . . . . . . . . 196define flag/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

    34.4 Documentation on internals (read) . . . . . . . . . . . . . . . . . . . . . . . . 197read option/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

    34.5 Known bugs and planned improvements (read) . . . . . . . . . . . . . 197

    35 Term output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19935.1 Usage and interface (write) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19935.2 Documentation on exports (write) . . . . . . . . . . . . . . . . . . . . . . . . 199

    write term/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199write term/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199write option/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200write/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200write/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201writeq/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201writeq/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201write canonical/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 201write canonical/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 201print/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201print/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202write list1/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202portray clause/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . 202portray clause/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . 202numbervars/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202prettyvars/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202printable char/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . 203

    35.3 Documentation on multifiles (write) . . . . . . . . . . . . . . . . . . . . . . . 203define flag/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203portray attribute/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . 203portray/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203

    36 Defining operators . . . . . . . . . . . . . . . . . . . . . . . . . 20536.1 Usage and interface (operators) . . . . . . . . . . . . . . . . . . . . . . . . . . 20536.2 Documentation on exports (operators) . . . . . . . . . . . . . . . . . . . . 205

    op/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205current op/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206current prefixop/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . 206current infixop/4 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 206current postfixop/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . 206

  • xv

    37 The Iso Byte Char module . . . . . . . . . . . . . . . . . 20737.1 Usage and interface (iso_byte_char) . . . . . . . . . . . . . . . . . . . . . . 20737.2 Documentation on exports (iso_byte_char) . . . . . . . . . . . . . . . 207

    char code/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207atom chars/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207number chars/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207get byte/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207get byte/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207peek byte/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208peek byte/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208put byte/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208put byte/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208get char/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208get char/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208peek char/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208peek char/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208put char/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209put char/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

    38 Miscellaneous ISO Prolog predicates . . . . . . . . 21138.1 Usage and interface (iso_misc) . . . . . . . . . . . . . . . . . . . . . . . . . . . 21138.2 Documentation on exports (iso_misc) . . . . . . . . . . . . . . . . . . . . . 211

    \= /2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211once/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211compound/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211sub atom/5 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211unify with occurs check/2 (pred) . . . . . . . . . . . . . . . . . . 212

    39 Incomplete ISO Prolog predicates . . . . . . . . . . 21339.1 Usage and interface (iso_incomplete) . . . . . . . . . . . . . . . . . . . . . 21339.2 Documentation on exports (iso_incomplete) . . . . . . . . . . . . . . 213

    close/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213stream property/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . 213

    PART IV - Classic Prolog library (classic) . . . . . . . 215

    40 Definite clause grammars . . . . . . . . . . . . . . . . . . 21740.1 Usage and interface (dcg) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219

    41 Definite clause grammars (expansion) . . . . . . . 22141.1 Usage and interface (dcg_expansion) . . . . . . . . . . . . . . . . . . . . . . 22141.2 Documentation on exports (dcg_expansion) . . . . . . . . . . . . . . . 221

    phrase/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221phrase/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221dcg translation/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 221

    42 Formatted output . . . . . . . . . . . . . . . . . . . . . . . . . 22342.1 Usage and interface (format) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22342.2 Documentation on exports (format) . . . . . . . . . . . . . . . . . . . . . . . 224

    format/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224format/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224format control/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . 224

  • xvi The Ciao Prolog System

    43 List processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22943.1 Usage and interface (lists) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22943.2 Documentation on exports (lists) . . . . . . . . . . . . . . . . . . . . . . . . 229

    nonsingle/1 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229append/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229reverse/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229reverse/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230delete/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230delete non ground/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . 230select/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230length/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230nth/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231add after/4 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231add before/4 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231list1/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231dlist/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231list concat/2 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231list insert/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232insert last/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232contains ro/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232contains1/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232nocontainsx/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232last/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232list lookup/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232list lookup/4 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232intset insert/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232intset delete/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232intset in/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233intset sequence/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 233intersection/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233union/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233difference/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233sublist/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233subordlist/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233equal lists/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233list to list of lists/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . 234powerset/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234cross product/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

    44 Sorting lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23544.1 Usage and interface (sort) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23544.2 Documentation on exports (sort) . . . . . . . . . . . . . . . . . . . . . . . . . 235

    sort/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235keysort/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235keylist/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

    44.3 Documentation on internals (sort) . . . . . . . . . . . . . . . . . . . . . . . . 236keypair/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236

  • xvii

    45 compiler (library) . . . . . . . . . . . . . . . . . . . . . . . . . 23745.1 Usage and interface (compiler) . . . . . . . . . . . . . . . . . . . . . . . . . . . 23745.2 Documentation on exports (compiler) . . . . . . . . . . . . . . . . . . . . . 237

    make po/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237ensure loaded/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . 237ensure loaded/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . 237use module/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237use module/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237use module/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237unload/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238set debug mode/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . 238set nodebug mode/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . 238set debug module/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . 238set nodebug module/1 (pred) . . . . . . . . . . . . . . . . . . . . . 238set debug module source/1 (pred) . . . . . . . . . . . . . . . . . 238mode of module/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . 238module of/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238

    46 Enumeration of integers inside a range . . . . . . 23946.1 Usage and interface (between) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23946.2 Documentation on exports (between) . . . . . . . . . . . . . . . . . . . . . . 239

    between/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

    47 Operating system utilities . . . . . . . . . . . . . . . . . . 24147.1 Usage and interface (system) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24147.2 Documentation on exports (system) . . . . . . . . . . . . . . . . . . . . . . . 241

    pause/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241time/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241datime/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241datime/9 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242datime struct/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . 242getenvstr/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242setenvstr/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242extract paths/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242get pid/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243current host/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243current executable/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . 243umask/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243make directory/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 243make directory/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 243make dirpath/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244make dirpath/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244working directory/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . 244cd/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244shell/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244shell/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244shell/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245system/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245system/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245popen/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245popen mode/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . 245exec/4 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245exec/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245exec/8 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245wait/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246

  • xviii The Ciao Prolog System

    directory files/2 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . 246mktemp/2 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246file exists/1 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246file exists/2 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247file property/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247file properties/6 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . 247modif time/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247modif time0/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247fmode/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248chmod/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248chmod/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248delete file/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248delete directory/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 248rename file/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248cyg2win/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249

    47.3 Documentation on multifiles (system) . . . . . . . . . . . . . . . . . . . . . 249define flag/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249

    47.4 Known bugs and planned improvements (system) . . . . . . . . . . . 249

    48 Prolog system internal predicates. . . . . . . . . . . 25148.1 Usage and interface (prolog_sys) . . . . . . . . . . . . . . . . . . . . . . . . . 25148.2 Documentation on exports (prolog_sys) . . . . . . . . . . . . . . . . . . . 251

    statistics/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251statistics/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251predicate property/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . 252current atom/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253garbage collect/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . 253new atom/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

    48.3 Documentation on internals (prolog_sys). . . . . . . . . . . . . . . . . . 253time option/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . 253memory option/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . 253garbage collection option/1 (regtype) . . . . . . . . . . . . . . 253symbol option/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . 253time result/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . 254memory result/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . 254gc result/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254symbol result/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . 254

    48.4 Known bugs and planned improvements (prolog_sys) . . . . . . 254

    49 DEC-10 Prolog file IO . . . . . . . . . . . . . . . . . . . . . 25549.1 Usage and interface (dec10_io) . . . . . . . . . . . . . . . . . . . . . . . . . . . 25549.2 Documentation on exports (dec10_io) . . . . . . . . . . . . . . . . . . . . . 255

    see/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255seeing/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255seen/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255tell/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255telling/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255told/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255close file/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

  • xix

    50 Quintus-like internal database . . . . . . . . . . . . . . 25750.1 Usage and interface (old_database) . . . . . . . . . . . . . . . . . . . . . . . 25750.2 Documentation on exports (old_database) . . . . . . . . . . . . . . . . 257

    recorda/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257recordz/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257recorded/3 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257current key/2 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258

    51 ttyout (library) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25951.1 Usage and interface (ttyout) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25951.2 Documentation on exports (ttyout) . . . . . . . . . . . . . . . . . . . . . . . 259

    ttyget/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259ttyget1/1 (pred). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259ttynl/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259ttyput/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259ttyskip/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259ttytab/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259ttyflush/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259ttydisplay/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260ttydisplayq/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260ttyskipeol/0 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260ttydisplay string/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . 260

    52 Enabling operators at run-time . . . . . . . . . . . . . 26152.1 Usage and interface (runtime_ops) . . . . . . . . . . . . . . . . . . . . . . . . 261

    PART V - Annotated Prolog library (assertions). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263

    53 The Ciao assertion package . . . . . . . . . . . . . . . . 26553.1 More info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26553.2 Some attention points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26553.3 Usage and interface (assertions) . . . . . . . . . . . . . . . . . . . . . . . . . 26653.4 Documentation on new declarations (assertions) . . . . . . . . . . 266

    pred/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266pred/2 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267calls/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267calls/2 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267success/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267success/2 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267comp/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268comp/2 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268prop/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268prop/2 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269entry/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269modedef/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269decl/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270decl/2 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270comment/2 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270

    53.5 Documentation on exports (assertions) . . . . . . . . . . . . . . . . . . . 270check/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270trust/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271true/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271false/1 (pred) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271

  • xx The Ciao Prolog System

    54 Types and properties related to assertions . . 27354.1 Usage and interface (assertions_props) . . . . . . . . . . . . . . . . . . 27354.2 Documentation on exports (assertions_props) . . . . . . . . . . . . 273

    assrt body/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273head pattern/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274complex arg property/1 (regtype) . . . . . . . . . . . . . . . . . 274property conjunction/1 (regtype) . . . . . . . . . . . . . . . . . . 275property starterm/1 (regtype) . . . . . . . . . . . . . . . . . . . . . 275complex goal property/1 (regtype) . . . . . . . . . . . . . . . . . 275nabody/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276dictionary/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276c assrt body/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . 276s assrt body/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . 276g assrt body/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . 277assrt status/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . 277assrt type/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277predfunctor/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . . 278propfunctor/1 (regtype) . . . . . . . . . . . . . . . . . . . . . . . . . . 278docstring/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

    55 Declaring regular types . . . . . . . . . . . . . . . . . . . . 27955.1 Defining properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27955.2 Usage and interface (regtypes) . . . . . . . . . . . . . . . . . . . . . . . . . . . 28255.3 Documentation on new declarations (regtypes) . . . . . . . . . . . . 282

    regtype/1 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282regtype/2 (decl) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

    56 Properties which are native to analyzers . . . . 28556.1 Usage and interface (native_props) . . . . . . . . . . . . . . . . . . . . . . . 28556.2 Documentation on exports (native_props) . . . . . . . . . . . . . . . . 285

    covered/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285linear/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285mshare/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286nonground/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286fails/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286not fails/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286possibly fails/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286covered/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287not covered/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287is det/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287non det/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287possibly nondet/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . 287mut exclusive/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . 287not mut exclusive/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . 287size lb/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288size ub/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288steps lb/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288steps ub/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288steps/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288finite solutions/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . 289terminates/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289indep/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289indep/2 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289ground/1 (prop). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289nonvar/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

  • xxi

    var/1 (prop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290regtype/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290native/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290native/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290sideff/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290term/1 (udreexp). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290int/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290nnegint/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290flt/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291num/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291atm/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291struct/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291gnd/1 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291instance/2 (udreexp) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291

    57 ISO-Prolog modes . . . . . . . . . . . . . . . . . . . . . . . . . 29357.1 Usage and interface (isomodes) . . . . . . . . . . . . . . . . . . . . . . . . . . . 29357.2 Documentation on new modes (isomodes). . . . . . . . . . . . . . . . . . 293

    (+)/1 (modedef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293(@)/1 (modedef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293(-)/1 (modedef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293(?)/1 (modedef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293* /1 (modedef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293(+)/2 (modedef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294(@)/2 (modedef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294(-)/2 (modedef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294(?)/2 (modedef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294* /2 (modedef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294

    58 Classical Prolog modes . . . . . . . . . . . . . . . . . . . . 29558.1 Usage and interface (basicmodes) . . . . . . . . . . . . . .