►Implementation Considerations | This section is about the YAP implementation, and is mostly of interest to hackers |
The Abstract Machine Emulator | |
Short-lived memory allocation | Support for short-lived memory allocation |
►Memory Allocation in YAP | Memory organization and Auxiliary Memory Access Data-structures and routines |
Using a scratch buffer | Use a scratch buffer (maybe even many), |
Stack Discipline Memory Allocation | Memory who lives during a stack activation |
Implementation of Blobs | |
►Error Handling | |
Error Handling | The error handler is called when there is an execution error or a warning needs to be displayed |
Exception Descriptor Manipulation | Manipulate error/throw descriptors |
Indexing | The indexation mechanism restricts the set of clauses to be tried in a procedure by using information about the status of the instantiated arguments of the goal |
Summary of YAP Predefined Operators | The Prolog syntax caters for operators of three main kinds: |
Scanner Implementation. | Convert Prolog text into tokens |
Text Processing Support Routines | Support for text processing: |
►An object oriented interface for YAP. | C++ wrapper to terms, predicates and queries |
Prolog Atoms | Symbols and associated propeeties |
Data-Base Component of YAP interface. | These classes define the main data-structures stored to represent compiled programs: |
Error Handling in the YAP interface. | Error handling in C++ and OO languages |
Query Handling in the YAP interface. | Engine and Query Management |
Term Handling in the YAP interface. | These classes offer term construction and access |
Installing YAP | |
►YAP Core Built-ins | |
Predicates on Atoms and Strings | The following predicates are used to manipulate atoms, strings, lists of codes and lists of chars |
The Blackboard | YAP implements a blackboard in the style of the SICStus Prolog blackboard |
Copying Terms | |
►Internal Data Base | Some programs need global information for, e.g |
Atom to Atomic Family of Built-ins. | Maintain a light-weight map where the key is an atom, and the value can be any constant |
Supporting features of the Prolog language. | Prolog includes a number of features that allow program and predicate manipulation |
►Arithmetic in YAP | |
Arithmetic Functions | YAP implements several arithmetic functions, they are defined as fields in three enumerations, such that there is one enumeration per each different arity:
|
Arithmetic Comparison Predicates | |
Predicates that perform arithmetic | |
►Prolog Flags | |
C-code to handle Prolog flags. | Low-level code to support flags |
Predicates to access Prolog flags. | Following builins provide read-write access the Prolog flags |
Prolog Support | |
YAP Global Flags | |
YAP Thread-local flags | Prolog flags that can take different values in different threads and/or modules |
►Input/Output Predicates | ⁸
|
Aliases to Stream Names | Aliases: This file defines the main operations on aliases, a second name for a file |
Character-Based Input/Output | YAP implements most of the ISO-Prolog built-ins |
Character Encoding and Manipulation. | The Prolog library includes a set of built-in predicates designed to support manipulation of sequences of text, represented either as lists, atoms or strings |
Memory Streams | |
Formatted Output | This file includes the definition of the formatted output predicates |
Term Writing in Prolog. | %! |
YAP Old Style Socket and Pipe Interface | Autoload the socket/pipe library |
File and Directory Operations |
|
File Name Resolution | Support for file name resolution through absolute_file_name/3 and friends |
Access to Operating System Functionality | The following built-in predicates allow access to underlying Operating System functionality |
Format | %! |
StreamM | %! %! |
►Control Predicates | |
Message Handling | The interaction between YAP and the user relies on YAP's ability to portray messages |
Handling Undefined Procedures | A predicate in a module is said to be undefined if there are no clauses defining the predicate, and if the predicate has not been declared to be dynamic |
Global Variables | Global variables are associations between names (atoms) and terms |
Freeze System Configuration |
- This protects current code from further changes and also makes it impossible for some predicates to be seen in user-space
|
Dialects | |
Error generating type-checking | This code is based oon the SWI predicates to simplify error generation and checking |
Grammar Rules | Grammar rules in Prolog are both a convenient way to express definite clause grammars and an extension of the well known context-free grammars |
list predicates in a module | |
Operators | |
Collecting Solutions to a Goal | When there are several solutions to a goal, if the user wants to collect all the solutions he may be led to use the data base, because backtracking will forget previous solutions |
System Status | |
►Term Manipulation | |
Inlined Tests and Term Manipulation | |
Term Visit and Manipulation | |
Top-Level and Boot Predicates | |
►YAP Library | |
Extension of arg/3 |
|
Association Maps | The following association list manipulation predicates are available once included with the use_module(library(assoc)) command |
SWI-Like autoloader | |
AVL Trees | Supports constructing AVL trees |
Backtrackable Hash Tables |
|
Block Diagram | This library provides a way of visualizing a prolog program using modules with blocks |
Concurrent Alarms | This library provides a concurrent signals |
Operations on Sequences of Codes. | Term to sequence of codes conversion, mostly replaced by engine code |
Clause Manipulation | This library supports a number of useful utilities that come up over and over again when manipulating Prolog programs |
Old Call Cleanup | % call_cleanup/1 and call_cleanup/2 allow predicates to register code for execution after the call is finished |
Co-Logic Programming |
|
Non-backtrackable queues in YAP. | A library to implement queues of NB Terms |
Memory Usage in Prolog Data-Base | This library provides a set of utilities for studying memory usage in YAP |
Directed Graphs | The following graph manipulation routines use the red-black tree library to try to avoid linear-time scans of the graph for all graph operations |
Exo Intervals | This package assumes you use exo-compilation, that is, that you loaded the pedicate using the exo option to load_files/2 , In this case, YAP includes a package for improved search on intervals of integers |
Flag Manipulation in Prolog |
- Routines to manipulate flags: they allow defining, set, resetting
|
Generate a new symbol. |
- Predicates to create new atoms based on the prefix Atom
|
Heaps | A heap is a labelled binary tree where the key of each node is less than or equal to the keys of its sons |
Tries for ILP | |
MPI Interface | This library provides a set of utilities for interfacing with LAM MPI |
Line Manipulation Utilities | This package provides a set of useful predicates to manipulate sequences of characters codes, usually first read in as a line |
Apply a predicate to all arguments of a term | |
►Map List and Term Operations |
- This library provides a set of utilities for applying a predicate to all elements of a list
|
Apply Interface to maplist | This library provides a SWI-compatible set of utilities for applying a predicate to all elements of a list |
MATLAB Package Interface | The MathWorks MATLAB is a widely used package for array processing |
Matrix Library | This package provides a fast implementation of multi-dimensional matrices of integers and floats |
Non-Backtrackable Data Structures | The following routines implement well-known data-structures using global non-backtrackable variables (implemented on the Prolog stack) |
Ordered Sets | The following ordered set manipulation routines are available once included with the use_module(library(ordsets)) command |
Automating test generation | This library aims at facilitating test generation in a logic program, namely when interfacing to foreign code |
Queues | The following queue manipulation routines are available once included with the use_module(library(queues)) command |
►Random Number Generator | Since YAP-4.3.19 YAP uses the O'Keefe public-domain algorithm, based on the "Applied Statistics" algorithm AS183 |
Pseudo Random Number Integer Generator | The following routines produce random non-negative integers in the range 0 |
Red-Black Trees |
|
Reading Lines and Files | Read full lines and a full file in a single call |
Regular Expressions | This library includes routines to determine whether a regular expression matches part or all of a string |
Range-List (RL) trees |
|
Splay Trees | Splay trees are explained in the paper "Self-adjusting Binary Search
Trees", by D.D |
Operating System Functionality | Portable Interaction with the OS, be it Unix, Linux, OSX, or Windows |
Utilities On Terms | The next routines provide a set of commonly used utilities to manipulate terms |
Calls With Timeout | The time_out/3 command relies on the alarm/3 built-in to implement a call with a maximum time of execution |
Updatable Binary Trees | The following queue manipulation routines are available once included with the use_module(library(trees)) command |
Trie DataStructure | Engine Independent trie library |
Unweighted Graphs | The following graph manipulation routines are based in code originally written by Richard O'Keefe |
Undirected Graphs | The following graph manipulation routines use the red-black tree graph library to implement undirected graphs |
Variabilize term. | |
Weighted Directed Graphs |
|
Weighted Graphs | Weighted Graph Processing Utilities |
Weighted Undirected Graphs |
|
Yap PreProcessing | |
Low-level access |
|
List Predicates in the Prolog Library |
|
SICStus compatible socket library | Uses SWI code |
►YAP Extensions | |
Named Arrays | The YAP system includes experimental support for arrays |
Global Variables | Global variables are associations between names (atoms) and terms |
Rational Trees | Prolog unification is not a complete implementation |
►Attributed Variables | |
►Low-level support for Attributed | Variables |
SICStus-style Constraints in C | |
SWI-style Constraints in C | |
►SICStus Style attribute declarations | |
SICStus style attribute declarations |
|
predicate | |
Android Support | |
Log Output of Tests in Markdown format. |
- These primitives support writing a user-specified log of execution to an output file
|
Parallelism in YAP | There has been a sizeable amount of work on an or-parallel implementation for YAP, called YAPOr |
►Profiling Prolog Programs | YAP includes two profilers |
Tick Profiler | The tick profiler works by interrupting the Prolog code every so often and checking at each point the code was |
Counting Calls |
|
The Count Profiler | The count profiler works by incrementing counters at procedure entry or backtracking |
►Loading files into YAP | We present the main predicates and directives available to load files and to set-up the Prolog environment |
►The Predicates that Read Source Files | |
►Directing and Configuring the Compiler | The YAP system also includes a number of primitives designed to set compiler parameters and to track the state of the compiler |
Internal Clause Rewriting | YAP supports several clause optimisation mechanisms, that are designed to improve execution of arithmetic and term construction built-ins |
YAP Style Checker | YAP implements a style-checker thay currently verifies whether: |
Conditional Compilation | Conditional compilation builds on the same principle as term_expansion/2 , goal_expansion/2 and the expansion of grammar rules to compile sections of the source-code conditionally |
Declaring Properties of Predicates | The YAP Compiler allows the programmer to include declarations with important pproprties of predicates, such as where they can be modified during execution time, whether they are meta-predicates, or whether they can be defined across multiple files |
Conditional Compilation | Conditional compilation builds on the same principle as term_expansion/2 , goal_expansion/2 and the expansion of grammar rules to compile sections of the source-code conditionally |
Loading Large Tables | Fast and Exo Loading % |
►Creating and Using a saved state | |
C-support for saved states. | |
►Interacting with the debugger | Debugging with YAP is similar to debugging with C-Prolog |
Implementation of the Debugger | Prolog code to do debugging |
Debugger Control | The following predicates are available to control the debugging of programs: |
Depth Limited Search | YAP implements various extensions to the default Prolog search |
Prolog Directives | @
|
Extended Abstract Machine | |
Compiled Form of Arithmetic Expressions in Prolog |
|
Predicate Import Mechanism |
|
Access to Foreign Language Programs | |
►predicate | |
The Module System versus the meta-call. |
|
Module Support |
|
Module Interface Predicates |
|
Configuration of the Prolog file search path | Prolog systems search follow a complex search on order to track down files |
The Clausal Data Base | Predicates in YAP may be dynamic or static |
Declaring a type of predicate: | |
Tabling | YAPTab is the tabling engine that extends YAP's execution model to support tabled evaluation for definite programs |
►Threads | YAP implements a SWI-Prolog compatible multithreading library |
Creating and Destroying Prolog Threads | |
Monitoring Threads | Normal multi-threaded applications should not need these the predicates from this section because almost any usage of these predicates is unsafe |
Signalling Threads | These predicates provide a mechanism to make another thread execute some goal as an interrupt |
Thread Synchronisation | All internal Prolog operations are thread-safe |
Thread communication | Prolog threads can exchange data using dynamic predicates, database records, and other globally shared data |
Threads and Dynamic Predicates | Besides queues threads can share and exchange data using dynamic predicates |
Or-Parallelism | @ |
►Arrays | |
Implementation Notes | This file works together with pl/arrays.yap and arrays.h |
►ChYInterface | C-Interface to YAP |
Term Handles or Slots | Term handles correspond to SWI-Prolog's term_t datatype: they are a safe representation of terms |
Term Handles | Also known as term handles, slots are offsets to entries in the local stack |
Parser Implementation | As expected for Prolog, this is a recursive top-down parser |
YapError | The file YapErrors.h contains a list with all the error classes known internally to the YAP system |
Rl | |
►Library | Read full lines and a full file in a single call |
expressions | This library provides lambda expressions to simplify higher order programming based on call/N |
►SWI Compatible attributes | |
Implementing Attributed Variables and Co-Routining |
|
YAPTypes | |
Comparing_Terms | |
User Defined Extensions | User Defined Extensions |