SWI-Prolog 5.8.1 Reference Manual In

SWI-Prolog 5.8.1 Reference Manual In

University of Amsterdam Kruislaan 419, 1098 VA Amsterdam VU University Amsterdam De Boelelaan 1081a, 1081 HV Amsterdam The Netherlands SWI-Prolog 5.8 Reference Manual Updated for version 5.8.1, November 2009 Jan Wielemaker J.Wielemaker@cs.vu.nl http://www.swi-prolog.org SWI-Prolog is a Prolog implementation based on a subset of the WAM (Warren Ab- stract Machine). SWI-Prolog was developed as an open Prolog environment, providing a powerful and bi-directional interface to C in an era this was unknown to other Prolog implementations. This environment is required to deal with XPCE, an object-oriented GUI system developed at SWI. XPCE is used at SWI for the development of knowledge- intensive graphical applications. As SWI-Prolog became more popular, a large user-community provided requirements that guided its development. Compatibility, portability, scalability, stability and provid- ing a powerful development environment have been the most important requirements. Edinburgh, Quintus, SICStus and the ISO-standard guide the development of the SWI- Prolog primitives. This document gives an overview of the features, system limits and built-in predicates. Copyright c 1990–2009, University of Amsterdam Contents 1 Introduction 10 1.1 SWI-Prolog....................................... 10 1.1.1 Books about Prolog............................... 10 1.2 Status.......................................... 11 1.3 Compliance to the ISO standard............................ 11 1.4 Should you be using SWI-Prolog?........................... 11 1.5 The XPCE GUI system for Prolog........................... 12 1.6 Release Notes...................................... 13 1.7 Donate to the SWI-Prolog project........................... 19 1.8 Acknowledgements................................... 19 2 Overview 21 2.1 Getting started quickly................................. 21 2.1.1 Starting SWI-Prolog.............................. 21 2.1.2 Executing a query............................... 22 2.2 The user’s initialisation file............................... 22 2.3 Initialisation files and goals............................... 23 2.4 Command-line options................................. 23 2.5 GNU Emacs Interface.................................. 26 2.6 Online Help....................................... 27 2.7 Command-line history................................. 28 2.8 Reuse of top-level bindings............................... 28 2.9 Overview of the Debugger............................... 29 2.10 Compilation....................................... 32 2.10.1 During program development......................... 32 2.10.2 For running the result.............................. 33 2.11 Environment Control (Prolog flags).......................... 36 2.12 An overview of hook predicates............................ 44 2.13 Automatic loading of libraries............................. 45 2.14 Garbage Collection................................... 47 2.15 Syntax Notes...................................... 47 2.15.1 ISO Syntax Support.............................. 47 2.16 Infinite trees (cyclic terms)............................... 50 2.17 Wide character support................................. 50 2.17.1 Wide character encodings on streams..................... 51 2.18 System limits...................................... 52 2.18.1 Limits on memory areas............................ 52 2.18.2 Other Limits.................................. 53 2.18.3 Reserved Names................................ 55 2.19 SWI-Prolog and 64-bit machines............................ 55 SWI-Prolog 5.8 Reference Manual Contents 3 2.19.1 Supported platforms.............................. 55 2.19.2 Comparing 32- and 64-bits Prolog....................... 55 2.19.3 Choosing between 32- and 64-bits Prolog................... 56 3 Initialising and Managing a Prolog Project 57 3.1 The project source-files................................. 57 3.1.1 File Names and Locations........................... 57 3.1.2 Project Special Files.............................. 58 3.1.3 International source files............................ 59 3.2 Using modules..................................... 59 3.3 The test-edit-reload cycle................................ 60 3.3.1 Locating things to edit............................. 60 3.3.2 Editing and incremental compilation...................... 61 3.4 Using the PceEmacs built-in editor........................... 61 3.4.1 Activating PceEmacs.............................. 61 3.4.2 Bluffing through PceEmacs.......................... 62 3.4.3 Prolog Mode.................................. 64 3.5 The Graphical Debugger................................ 66 3.5.1 Invoking the window-based debugger..................... 66 3.6 The Prolog Navigator.................................. 67 3.7 Cross referencer..................................... 67 3.8 Accessing the IDE from your program......................... 69 3.9 Summary of the IDE.................................. 70 4 Built-in predicates 71 4.1 Notation of Predicate Descriptions........................... 71 4.2 Character representation................................ 71 4.3 Loading Prolog source files............................... 72 4.3.1 Conditional compilation and program transformation............. 79 4.3.2 Loading files, active code and threads..................... 82 4.3.3 Quick load files................................. 83 4.4 Listing and Editor Interface............................... 83 4.5 Verify Type of a Term.................................. 85 4.6 Comparison and Unification of Terms......................... 86 4.6.1 Standard Order of Terms............................ 87 4.6.2 Special unification and comparison predicates................. 88 4.7 Control Predicates.................................... 90 4.8 Meta-Call Predicates.................................. 91 4.9 ISO compliant Exception handling........................... 94 4.9.1 Debugging and exceptions........................... 95 4.9.2 The exception term............................... 96 4.9.3 Printing messages............................... 96 4.10 Handling signals.................................... 97 4.10.1 Notes on signal handling............................ 99 4.11 The ‘block’ control-structure.............................. 100 4.12 DCG Grammar rules.................................. 100 4.13 Database......................................... 101 SWI-Prolog 5.8 Reference Manual 4 4.13.1 Update view.................................. 103 4.13.2 Indexing databases............................... 104 4.14 Declaring predicates properties............................. 104 4.15 Examining the program................................. 106 4.16 Input and output..................................... 109 4.16.1 ISO Input and Output Streams......................... 109 4.16.2 Edinburgh-style I/O............................... 115 4.16.3 Switching Between Edinburgh and ISO I/O.................. 117 4.16.4 Write onto atoms, code-lists, etc......................... 118 4.17 Status of streams.................................... 118 4.18 Primitive character I/O................................. 120 4.19 Term reading and writing................................ 123 4.20 Analysing and Constructing Terms........................... 128 4.20.1 Non-logical operations on terms........................ 130 4.21 Analysing and Constructing Atoms........................... 131 4.22 Character properties................................... 134 4.22.1 Case conversion................................ 135 4.22.2 White space normalization........................... 136 4.22.3 Language specific comparison......................... 136 4.23 Representing text in strings............................... 136 4.24 Operators........................................ 137 4.25 Character Conversion.................................. 138 4.26 Arithmetic........................................ 139 4.26.1 Special purpose integer arithmetic....................... 139 4.26.2 General purpose arithmetic........................... 140 4.27 Adding Arithmetic Functions.............................. 147 4.28 Misc arithmetic support predicates........................... 148 4.29 Built-in list operations................................. 148 4.30 Finding all Solutions to a Goal............................. 149 4.31 Forall.......................................... 150 4.32 Formatted Write..................................... 151 4.32.1 Writef...................................... 151 4.32.2 Format..................................... 152 4.32.3 Programming Format.............................. 154 4.33 Terminal Control.................................... 155 4.34 Operating System Interaction.............................. 156 4.34.1 Dealing with time and date........................... 158 4.34.2 Controlling the PLWIN.EXE console window................. 163 4.35 File System Interaction................................. 164 4.36 User Top-level Manipulation.............................. 167 4.37 Creating a Protocol of the User Interaction....................... 168 4.38 Debugging and Tracing Programs........................... 169 4.39 Obtaining Runtime Statistics.............................. 171 4.40 Execution profiling................................... 171 4.40.1 Profiling predicates............................... 173 4.40.2 Visualizing profiling data............................ 173 4.40.3 Information gathering............................. 174 SWI-Prolog 5.8 Reference Manual Contents 5 4.41 Memory Management.................................. 175 4.42 Windows

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    411 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us