updates to documentation
This commit is contained in:
parent
57ecd61b95
commit
882eaca30c
@ -495,7 +495,8 @@
|
||||
|
||||
@file absmi.c
|
||||
|
||||
@page Efficiency Efficiency Considerations
|
||||
@defgroup Efficiency Efficiency Considerations
|
||||
@ingroup YAPProgramming
|
||||
|
||||
We next discuss several issues on trying to make Prolog programs run
|
||||
fast in YAP. We assume two different programming styles:
|
||||
@ -508,10 +509,6 @@ loop(Env) :-
|
||||
do_something(Env,NewEnv),
|
||||
loop(NewEnv).
|
||||
~~~~~
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
60
docs/chr.md
60
docs/chr.md
@ -1,7 +1,10 @@
|
||||
|
||||
@section CHR CHR: Constraint Handling Rules
|
||||
@defgroup CHR CHR: Constraint Handling Rules
|
||||
|
||||
@ingroup SWILibrary
|
||||
|
||||
@{
|
||||
|
||||
This chapter is written by Tom Schrijvers, K.U. Leuven for the hProlog
|
||||
system. Adjusted by Jan Wielemaker to fit the SWI-Prolog documentation
|
||||
infrastructure and remove hProlog specific references.
|
||||
@ -97,9 +100,7 @@ the arrow (either `<=>` or `==>`)
|
||||
|
||||
@}
|
||||
|
||||
|
||||
|
||||
@defgroup Semantics Semantics
|
||||
@defgroup Semantics Semantics
|
||||
@ingroup CHR_Syntax_and_Semantics
|
||||
@{
|
||||
|
||||
@ -136,7 +137,7 @@ or another variable involved in one or more constraints. In that case the
|
||||
constraint is triggered, i.e. it becomes an active constraint and all
|
||||
the rules are tried.
|
||||
|
||||
|
||||
@}
|
||||
|
||||
|
||||
|
||||
@ -169,16 +170,14 @@ constraints are not called in the body.
|
||||
|
||||
@defgroup CHR_Rule_Names Rule Names
|
||||
@ingroup CHR_Rule_Types
|
||||
@{
|
||||
|
||||
|
||||
Naming a rule is optional and has no semantical meaning. It only functions
|
||||
as documentation for the programmer.
|
||||
|
||||
@}
|
||||
|
||||
|
||||
|
||||
|
||||
@defgroup CHRPragmas Pragmas
|
||||
@defgroup CHRPragmas Pragmas
|
||||
@ingroup CHR
|
||||
@{
|
||||
|
||||
@ -192,10 +191,10 @@ passive constraint in that rule.
|
||||
Additional pragmas may be released in the future.
|
||||
|
||||
|
||||
|
||||
@}
|
||||
|
||||
|
||||
@defgroup CHR_Options Options
|
||||
@defgroup CHR_Options Options
|
||||
@ingroup CHR
|
||||
@{
|
||||
|
||||
@ -300,7 +299,7 @@ for backward compatibility. The new syntax is described below.
|
||||
|
||||
@}
|
||||
|
||||
@defgroup CHR_in_YAP_Programs CHR in Prolog Programs
|
||||
@defgroup CHR_in_YAP_Programs CHR in Prolog Programs
|
||||
@ingroup CHR
|
||||
@{
|
||||
|
||||
@ -310,10 +309,8 @@ associated with a module. The default module is `user`. One should
|
||||
never load different chr files with the same CHR module name.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@defgroup Constraint_declaration Constraint declaration
|
||||
@defgroup Constraint_declaration Constraint Declarations
|
||||
@ingroup CHR_in_YAP_Programs
|
||||
@{
|
||||
|
||||
@ -337,8 +334,8 @@ The new style is as follows:
|
||||
|
||||
|
||||
|
||||
@defgroup Compilation Compilation
|
||||
@ingroup CHR_in_YAP
|
||||
@defgroup Compilation Compilation
|
||||
@ingroup CHR_in_YAP_Programs
|
||||
|
||||
The
|
||||
SWI-Prolog CHR compiler exploits term_expansion/2 rules to translate
|
||||
@ -371,7 +368,7 @@ leak into modules where they might cause conflicts.
|
||||
|
||||
|
||||
@defgroup CHR_Debugging CHR Debugging
|
||||
@ingroup CHR_in_YAP
|
||||
@ingroup CHR_in_YAP_Programs
|
||||
@{
|
||||
|
||||
|
||||
@ -382,11 +379,7 @@ controlled by the CHR option debug, whose default is derived
|
||||
from the SWI-Prolog flag `generate_debug_info`. Therefore debug
|
||||
info is provided unless the `-nodebug` is used.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@defgroup Ports Ports
|
||||
@defgroup Ports Ports
|
||||
@ingroup CHR_Debugging
|
||||
|
||||
|
||||
@ -423,12 +416,7 @@ An active constraints commits to a rule with possibly
|
||||
some passive constraints. The apply port is entered
|
||||
just after committing to the rule.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@defgroup Tracing Tracing
|
||||
@defgroup Tracing Tracing
|
||||
@ingroup CHR_Debugging
|
||||
|
||||
|
||||
@ -490,11 +478,11 @@ Activate the CHR tracer. By default the CHR tracer is activated and
|
||||
deactivated automatically by the Prolog predicates trace/0 and
|
||||
notrace/0.
|
||||
|
||||
@}
|
||||
@}
|
||||
|
||||
|
||||
|
||||
@defgroup CHR_Examples Examples
|
||||
@defgroup CHR_Examples Examples
|
||||
@ingroup CHR
|
||||
@{
|
||||
|
||||
@ -618,4 +606,12 @@ Make sure to disable debug (`-nodebug`) and enable optimization
|
||||
@}
|
||||
|
||||
|
||||
@}
|
||||
|
||||
@}
|
||||
|
||||
@}
|
||||
|
||||
@}
|
||||
|
||||
@}
|
||||
|
@ -786,7 +786,12 @@ WARN_LOGFILE =
|
||||
# INPUT = /Users/vsc/git/yap-6.3/packages/cplint/mcintyre.pl
|
||||
#INPUT = /Users/vsc/git/yap-6.3/packages/R/R.pl
|
||||
|
||||
INPUT = foreigns.yap docs/yap.md docs/chr.md docs/threads.md docs/syntax.md docs/clpqr.md \
|
||||
INPUT = foreigns.yap \
|
||||
docs/yap.md \
|
||||
docs/chr.md \
|
||||
docs/threads.md \
|
||||
docs/syntax.md \
|
||||
docs/clpqr.md \
|
||||
pl \
|
||||
C \
|
||||
H \
|
||||
|
@ -1,7 +1,6 @@
|
||||
@defgroup Syntax YAP Syntax
|
||||
@ingroup YAPProgramming
|
||||
@{
|
||||
@page YAPSyntax Syntax
|
||||
|
||||
We will describe the syntax of YAP at two levels. We first will
|
||||
describe the syntax for Prolog terms. In a second level we describe
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
@defgroup Threads Threads
|
||||
@defgroup Threads Threads
|
||||
@ingroup YAPExtensions
|
||||
|
||||
@{
|
||||
|
||||
YAP implements a SWI-Prolog compatible multithreading
|
||||
library. Like in SWI-Prolog, Prolog threads have their own stacks and
|
||||
@ -10,18 +10,10 @@ global non-backtrackable data. The package is based on the POSIX thread
|
||||
standard (Butenhof:1997:PPT) used on most popular systems except
|
||||
for MS-Windows.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@defgroup Creating_and_Destroying_Prolog_Threads Creating and Destroying Prolog Threads
|
||||
@defgroup Creating_and_Destroying_Prolog_Threads Creating and Destroying Prolog Threads
|
||||
@ingroup Threads
|
||||
|
||||
|
||||
|
||||
|
||||
@pred thread_create(: _Goal_, - _Id_, + _Options_)
|
||||
|
||||
@pred thread_create(: _Goal_, - _Id_, + _Options_)
|
||||
|
||||
Create a new Prolog thread (and underlying C-thread) and start it
|
||||
by executing _Goal_. If the thread is created successfully, the
|
||||
@ -62,10 +54,6 @@ This implies further instantiation of this term in either thread does
|
||||
not have consequences for the other thread: Prolog threads do not share
|
||||
data from their stacks.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@defgroup Monitoring_Threads Monitoring Threads
|
||||
@ingroup Threads
|
||||
|
||||
@ -153,6 +141,7 @@ attributes, but the clause-list is different in each thread.
|
||||
|
||||
|
||||
@defgroup Thread_Synchronisation Thread Synchronisation
|
||||
@ingroup Threads
|
||||
|
||||
All
|
||||
internal Prolog operations are thread-safe. This implies two Prolog
|
||||
@ -187,3 +176,4 @@ change_address(Id, Address) :-
|
||||
|
||||
|
||||
|
||||
@}
|
||||
|
232
docs/yap.md
232
docs/yap.md
@ -1,32 +1,32 @@
|
||||
|
||||
This file documents the YAP Prolog System version 6.3.4, a high-performance Prolog compiler developed at LIACC, Universidade do Porto. YAP is based on David H. D. Warren's WAM (Warren Abstract Machine), with several optimizations for better performance. YAP follows the Edinburgh tradition, and is largely compatible with DEC-10 Prolog, Quintus Prolog, and especially with C-Prolog.
|
||||
|
||||
+ @subpage DownloadInstall
|
||||
+ @ref DownloadInstall
|
||||
|
||||
+ @subpage Run describes how to invoke YAP
|
||||
+ @ref Run describes how to invoke YAP
|
||||
|
||||
+ @subpage YAPLoading presents the main predicates and
|
||||
+ @ref YAPLoading presents the main predicates and
|
||||
directives available to load files and to control the Prolog
|
||||
environment.
|
||||
|
||||
+ @ref YAPConsulting
|
||||
+ @ref YAPModules introduces the YAP module system and meta-predicates.
|
||||
|
||||
+ @subpage YAPBuiltins describes predicates providing core YAP
|
||||
+ @ref YAPBuiltins describes predicates providing core YAP
|
||||
functionality:
|
||||
|
||||
+ @subpage YAPExtensions presents several extensions over standard
|
||||
+ @ref YAPExtensions presents several extensions over standard
|
||||
Prolog
|
||||
|
||||
+ @subpage YAPProgramming
|
||||
+ @ref YAPProgramming
|
||||
|
||||
+ @subpage ChYInterface
|
||||
+ @ref ChYInterface
|
||||
|
||||
+ @subpage YAPLibrary
|
||||
+ @ref YAPLibrary
|
||||
|
||||
+ @subpage SWILibrary
|
||||
+ @ref SWILibrary
|
||||
|
||||
+ @subpage Packages
|
||||
+ @ref Packages
|
||||
|
||||
|
||||
\author Vitor Santos Costa,
|
||||
@ -125,12 +125,12 @@ authorization to include these packages.
|
||||
|
||||
The packages are, in alphabetical order:
|
||||
|
||||
+ The CHR package developed by Tom Schrijvers,
|
||||
+ The CHR package developed by Tom Schrijvers,
|
||||
Christian Holzbaur, and Jan Wielemaker.
|
||||
|
||||
+ The CLP(BN) package and Horus toolkit developed by Tiago Gomes, and Vítor Santos Costa.
|
||||
|
||||
+ The CLP(R) package developed by Leslie De Koninck, Bart Demoen, Tom
|
||||
+ The CLP(R) package developed by Leslie De Koninck, Bart Demoen, Tom
|
||||
Schrijvers, and Jan Wielemaker, based on the CLP(Q,R) implementation
|
||||
by Christian Holzbaur.
|
||||
|
||||
@ -139,7 +139,6 @@ laboratory at the University of Ferrara. Please see
|
||||
|
||||
<http://www.ing.unife.it/Docenti/FabrizioRiguzzi/>
|
||||
|
||||
|
||||
+ The CUDA interface package developed by Carlos Martínez, Jorge
|
||||
Buenabad, Inês Dutra and Vítor Santos Costa.
|
||||
|
||||
@ -150,9 +149,9 @@ Buenabad, Inês Dutra and Vítor Santos Costa.
|
||||
+ The Logtalk Object-Oriented system is developed at the University
|
||||
of Beira Interior, Portugal, by Paulo Moura:
|
||||
|
||||
<http://logtalk.org/>
|
||||
<http://logtalk.org/>
|
||||
|
||||
Logtalk is no longer distributed with YAP. Please use the Logtalk standalone
|
||||
Logtalk is no longer distributed with YAP. Please use the Logtalk standalone
|
||||
installer for a smooth integration with YAP.
|
||||
|
||||
+ The minisat SAT solver interface developed by Michael Codish,
|
||||
@ -185,7 +184,6 @@ for more information on SWI-Prolog and the SWI packages.
|
||||
|
||||
@page DownloadInstall Downloading, Compiling, and Installing YAP
|
||||
|
||||
|
||||
The latest development version of Yap-6 is yap-6.3.4 and can be
|
||||
obtained from the repositories
|
||||
|
||||
@ -577,79 +575,81 @@ yap [-s n] [-h n] [-a n] [-c IP_HOST port ] [filename]
|
||||
|
||||
All the arguments and flags are optional and have the following meaning:
|
||||
|
||||
+ -?
|
||||
+ -?
|
||||
print a short error message.
|
||||
+ -s _Size_
|
||||
+ -s _Size_
|
||||
allocate _Size_ KBytes for local and global stacks. The user may
|
||||
specify <tt>M</tt> bytes.
|
||||
+ -h _Size_
|
||||
+ -h _Size_
|
||||
allocate _Size_ KBytes for heap and auxiliary stacks
|
||||
+ -t _Size_
|
||||
+ -t _Size_
|
||||
allocate _Size_ KBytes for the trail stack
|
||||
+ -L _Size_
|
||||
+ -L _Size_
|
||||
SWI-compatible option to allocate _Size_ K bytes for local and global stacks, the local stack
|
||||
cannot be expanded. To avoid confusion with the load option, _Size_
|
||||
must immediately follow the letter `L`.
|
||||
+ -G _Size_
|
||||
+ -G _Size_
|
||||
SWI-compatible option to allocate _Size_ K bytes for local and global stacks; the global
|
||||
stack cannot be expanded
|
||||
+ -T _Size_
|
||||
+ -T _Size_
|
||||
SWI-compatible option to allocate _Size_ K bytes for the trail stack; the trail cannot be expanded.
|
||||
+ -l _YAP_FILE_
|
||||
+ -l _YAP_FILE_
|
||||
compile the Prolog file _YAP_FILE_ before entering the top-level.
|
||||
+ -L _YAP_FILE_
|
||||
+ -L _YAP_FILE_
|
||||
compile the Prolog file _YAP_FILE_ and then halt. This option is
|
||||
useful for implementing scripts.
|
||||
+ -g _Goal_
|
||||
+ -g _Goal_
|
||||
run the goal _Goal_ before top-level. The goal is converted from
|
||||
an atom to a Prolog term.
|
||||
+ -z _Goal_
|
||||
+ -z _Goal_
|
||||
run the goal _Goal_ as top-level. The goal is converted from
|
||||
an atom to a Prolog term.
|
||||
+ -b _BOOT_FILE_
|
||||
+ -b _BOOT_FILE_
|
||||
boot code is in Prolog file _BOOT_FILE_. The filename must define
|
||||
the predicate `'$live'/0`.
|
||||
+ -c <tt>IP_HOST</tt> <tt>port</tt>
|
||||
+ -c <tt>IP_HOST</tt> <tt>port</tt>
|
||||
connect standard streams to host <tt>IP_HOST</tt> at port <tt>port</tt>
|
||||
+ filename
|
||||
+ filename
|
||||
restore state saved in the given file
|
||||
+ -f
|
||||
+ -f
|
||||
do not consult initial files
|
||||
+ -q
|
||||
+ -q
|
||||
do not print informational messages
|
||||
+ --
|
||||
+ --
|
||||
separator for arguments to Prolog code. These arguments are visible
|
||||
through the [unix/1](@ref unix) built-in predicate.
|
||||
through the unix/1 built-in predicate.
|
||||
|
||||
|
||||
Note that YAP will output an error message on the following conditions:
|
||||
|
||||
+
|
||||
+
|
||||
a file name was given but the file does not exist or is not a saved
|
||||
YAP state;
|
||||
+
|
||||
|
||||
+
|
||||
the necessary amount of memory could not be allocated;
|
||||
+
|
||||
|
||||
+
|
||||
the allocated memory is not enough to restore the state.
|
||||
|
||||
|
||||
When restoring a saved state, YAP will allocate the
|
||||
|
||||
When restoring a saved state, YAP will allocate the
|
||||
same amount of memory as that in use when the state was saved, unless a
|
||||
different amount is specified by flags in the command line. By default,
|
||||
YAP restores the file startup.yss from the current directory or from
|
||||
the YAP library.
|
||||
|
||||
+
|
||||
+
|
||||
YAP usually boots from a saved state. The saved state will use the default
|
||||
installation directory to search for the YAP binary unless you define
|
||||
the environment variable YAPBINDIR.
|
||||
|
||||
+
|
||||
+
|
||||
YAP always tries to find saved states from the current directory
|
||||
first. If it cannot it will use the environment variable YAPLIBDIR, if
|
||||
defined, or search the default library directory.
|
||||
first. If it cannot it will use the environment variable YAPLIBDIR, if
|
||||
defined, or search the default library directory.
|
||||
|
||||
+
|
||||
+
|
||||
YAP will try to find library files from the YAPSHAREDIR/library
|
||||
directory.
|
||||
|
||||
@ -746,6 +746,7 @@ they must be sent directly to the argv built-in. Hence, running
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
./dump_args test
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
will write `test` on the standard output.
|
||||
|
||||
@defgroup YAPLoading Loading and Organising YAP Programs
|
||||
@ -768,7 +769,8 @@ Prolog programs.
|
||||
In the description of the arguments of functors the following notation
|
||||
will be used:
|
||||
|
||||
+ a preceding plus sign will denote an argument as an "input argument" - it cannot be a free variable at the time of the call;
|
||||
+ a preceding plus sign will denote an argument as an "input
|
||||
argument" - it cannot be a free variable at the time of the call;
|
||||
+ a preceding minus sign will denote an "output argument";
|
||||
+ an argument with no preceding symbol can be used in both ways.
|
||||
|
||||
@ -776,33 +778,32 @@ will be used:
|
||||
|
||||
@page Core Core Prolog Built-Ins
|
||||
|
||||
+ @ref YAPControl
|
||||
+ @ref YAPControl
|
||||
|
||||
+ @ref arithmetic
|
||||
+ @ref arithmetic
|
||||
|
||||
+ @ref YAP_Terms
|
||||
+ @ref YAP_Terms
|
||||
|
||||
+ @ref InputOutput.
|
||||
+ @ref InputOutput.
|
||||
|
||||
+ @ref YAPOS
|
||||
+ @ref YAPOS
|
||||
|
||||
+ @ref Database
|
||||
+ @ref Database
|
||||
|
||||
+ @ref Sets
|
||||
+ @ref Sets
|
||||
|
||||
+ @ref Grammars
|
||||
+ @ref Grammars
|
||||
|
||||
+ @ref Term_Modification
|
||||
+ @ref Term_Modification
|
||||
|
||||
+ @ref LoadForeign
|
||||
+ @ref LoadForeign
|
||||
|
||||
+ @ref Predicates_on_Atoms
|
||||
|
||||
+ @ref Deb_Preds
|
||||
+ @ref Predicates_on_Atoms
|
||||
|
||||
+ @ref Deb_Preds
|
||||
|
||||
@defgroup ChYInterface Foreign Language interface to YAP
|
||||
|
||||
|
||||
YAP provides the user with three facilities for writing
|
||||
predicates in a language other than Prolog. Under Unix systems,
|
||||
most language implementations were linkable to `C`, and the first interface exported the YAP machinery to the C language. YAP also implements most of the SWI-Prolog foreign language interface.
|
||||
@ -815,135 +816,128 @@ being designed to work with the swig (@url(www.swig.org}) interface compiler.
|
||||
|
||||
@defgroup YAPExtensions Extensions to core Prolog.
|
||||
|
||||
@page YAP Extensions
|
||||
|
||||
+ @subpage Rational_Trees
|
||||
+ @ref Rational_Trees
|
||||
|
||||
+ @subpage CohYroutining
|
||||
+ @ref CohYroutining
|
||||
|
||||
+ @subpage Attributed_Variables
|
||||
+ @ref Attributed_Variables
|
||||
|
||||
+ @subpage DepthLimited
|
||||
+ @ref DepthLimited
|
||||
|
||||
+ @subpage Tabling
|
||||
+ @ref Tabling
|
||||
|
||||
+ @subpage Threads
|
||||
+ @ref Threads
|
||||
|
||||
+ @subpage Profiling
|
||||
+ @ref Profiling
|
||||
|
||||
+ @subpage YAPArrays
|
||||
+ @ref YAPArrays
|
||||
|
||||
+ @subpage Parallelism
|
||||
+ @ref Parallelism
|
||||
|
||||
@defgroup YAPLibrary The YAP Library
|
||||
|
||||
@page LIbrary The YAP Library
|
||||
|
||||
+ @subpage maplist introduces macros to apply an operation over
|
||||
+ @ref maplist introduces macros to apply an operation over
|
||||
all elements of a list
|
||||
|
||||
+ @subpage Apply Apply Macros
|
||||
+ @ref Apply Apply Macros
|
||||
|
||||
+ @subpage Association_Lists Association Lists
|
||||
+ @ref Association_Lists Association Lists
|
||||
|
||||
+ @subpage AVL_Trees AVL Trees
|
||||
+ @ref AVL_Trees AVL Trees
|
||||
|
||||
+ @subpage Exo_Intervals Exo Intervals
|
||||
+ @ref Exo_Intervals Exo Intervals
|
||||
|
||||
+ @subpage Heaps Heaps
|
||||
+ @ref Heaps Heaps
|
||||
|
||||
+ @subpage Lists List Manipulation
|
||||
+ @ref Lists List Manipulation
|
||||
|
||||
+ @subpage LineUtilities Line Manipulation Utilities
|
||||
+ @ref LineUtilities Line Manipulation Utilities
|
||||
|
||||
+ @subpage matrix Matrix Library
|
||||
+ @ref matrix Matrix Library
|
||||
|
||||
+ @subpage NonhYBacktrackable_Data_Structures Non-Backtrackable Data Structures
|
||||
+ @ref NonhYBacktrackable_Data_Structures Non-Backtrackable Data Structures
|
||||
|
||||
+ @subpage Ordered_Sets Ordered Sets
|
||||
+ @ref Ordered_Sets Ordered Sets
|
||||
|
||||
+ @subpage Pseudo_Random Pseudo Random Number Integer Generator
|
||||
+ @ref Pseudo_Random Pseudo Random Number Integer Generator
|
||||
|
||||
+ @subpage Queues Queues
|
||||
+ @ref Queues Queues
|
||||
|
||||
+ @subpage Random Random Number Generator
|
||||
+ @ref Random Random Number Generator
|
||||
|
||||
+ @subpage RedhYBlack_Trees Red-Black Trees
|
||||
+ @ref RedhYBlack_Trees Red-Black Trees
|
||||
|
||||
+ @subpage RegExp Regular Expressions
|
||||
+ @ref RegExp Regular Expressions
|
||||
|
||||
+ @subpage Splay_Trees Splay Trees
|
||||
+ @ref Splay_Trees Splay Trees
|
||||
|
||||
+ @subpage System Calling The Operating System from YAP
|
||||
+ @ref System Calling The Operating System from YAP
|
||||
|
||||
+ @subpage Terms Utilities On Terms
|
||||
+ @ref Terms Utilities On Terms
|
||||
|
||||
+ @subpage Tries Trie DataStructure
|
||||
+ @ref Tries Trie DataStructure
|
||||
|
||||
+ @subpage Cleanup Call Cleanup
|
||||
+ @ref Cleanup Call Cleanup
|
||||
|
||||
+ @subpage Timeout Calls With Timeout
|
||||
+ @ref Timeout Calls With Timeout
|
||||
|
||||
+ @subpage Trees Updatable Binary Trees
|
||||
+ @ref Trees Updatable Binary Trees
|
||||
|
||||
+ @subpage UGraphs Unweighted Graphs
|
||||
+ @ref UGraphs Unweighted Graphs
|
||||
|
||||
+ @subpage DGraphs Directed Graphs
|
||||
+ @ref DGraphs Directed Graphs
|
||||
|
||||
+ @subpage UnDGraphs Undirected Graphs
|
||||
+ @ref UnDGraphs Undirected Graphs
|
||||
|
||||
+ @subpage DBUsage Memory Usage in Prolog Data-Base
|
||||
+ @ref DBUsage Memory Usage in Prolog Data-Base
|
||||
|
||||
+ @subpage Lambda Lambda Expressions
|
||||
+ @ref Lambda Lambda Expressions
|
||||
|
||||
+ @subpage Block_Diagram Block Diagram
|
||||
+ @ref Block_Diagram Block Diagram
|
||||
|
||||
+ @subpage Invoking_Predicates_on_all_Members_of_a_List Invoking Predicates on all Members of a List
|
||||
+ @ref Invoking_Predicates_on_all_Members_of_a_List Invoking Predicates on all Members of a List
|
||||
|
||||
@defgroup YAPProgramming Programming in YAP
|
||||
|
||||
@page Programming Programming in YAP
|
||||
|
||||
+ @subpage Syntax
|
||||
+ @ref Syntax
|
||||
|
||||
+ @subpage Indexing
|
||||
|
||||
+ @subpage Deb_Interaction
|
||||
+ @ref Indexing
|
||||
|
||||
+ @ref Deb_Interaction
|
||||
|
||||
@defgroup SWILibrary SWI-Prolog Libraries and Packages
|
||||
|
||||
@page SWI The SWI-Prolog Library and Packages
|
||||
|
||||
|
||||
+ @subpage Read_Utilities Read Utilities
|
||||
+ @ref Read_Utilities Read Utilities
|
||||
|
||||
+ @subpage shlib SWI-Prolog's shlib library
|
||||
+ @ref shlib SWI-Prolog's shlib library
|
||||
|
||||
+ @subpage Lambda Lambda Expressions
|
||||
+ @ref Lambda Lambda Expressions
|
||||
|
||||
+ archive
|
||||
+ @ref archive
|
||||
|
||||
+ @subpage CHR
|
||||
+ @ref CHR
|
||||
|
||||
+ @subpage CLPQR
|
||||
+ @ref CLPQR
|
||||
|
||||
+ zlib
|
||||
+ @ref zlib
|
||||
|
||||
@defgroup YAPPackages The YAP packages
|
||||
|
||||
@page Packages The YAP Packages
|
||||
|
||||
+ @subpage REAL
|
||||
+ @ref REAL
|
||||
|
||||
+ @subpage BDDs
|
||||
+ @ref BDDs
|
||||
|
||||
+ @subpage Gecode
|
||||
|
||||
+ @subpage MYDDAS
|
||||
|
||||
|
||||
+ @ref Gecode
|
||||
|
||||
+ @ref MYDDAS
|
||||
|
||||
@page Compatibility Compatibility with Other Prolog systems
|
||||
|
||||
|
@ -103,7 +103,7 @@ fetch_key(Keys, Index, Size, Key, CmpF, ActualIndex) :-
|
||||
fetch_key(Keys, I1, Size, Key, CmpF, ActualIndex)
|
||||
).
|
||||
|
||||
/** b_hash_size_lookup( +_Key_, +_Hash_, +NewVal )
|
||||
/** b_hash_update( +_Key_, +_Hash_, +NewVal )
|
||||
|
||||
Update to the value associated with the ground term _Key_ in table _Hash_ to _NewVal_.
|
||||
*/
|
||||
@ -114,11 +114,11 @@ b_hash_update(Hash, Key, NewVal):-
|
||||
array_element(Vals, ActualIndex, Mutable),
|
||||
update_mutable(NewVal, Mutable).
|
||||
|
||||
/** b_hash_size_lookup( +_Key_, -_OldVal_, +_Hash_, +NewVal )
|
||||
/** b_hash_update( +_Key_, -_OldVal_, +_Hash_, +NewVal )
|
||||
|
||||
Update to the value associated with the ground term _Key_ in table _Hash_ to _NewVal_, and unify _OldVal_ with the current value.
|
||||
*/
|
||||
b_hash_update(Hash, Key, OldVal, NewVal):-§
|
||||
b_hash_update(Hash, Key, OldVal, NewVal):-
|
||||
Hash = hash(Keys, Vals, Size, _, F, CmpF),
|
||||
hash_f(Key,Size,Index,F),
|
||||
fetch_key(Keys, Index, Size, Key, CmpF, ActualIndex),
|
||||
|
@ -1039,9 +1039,13 @@ c_links :-
|
||||
open('foreigns.yap', write, S),
|
||||
clinks(S).
|
||||
|
||||
clinks(S) :-
|
||||
exported( ( _-M:F/A :- _-M1:F1/A ) ),
|
||||
format( S, ':- export( ~a:~a/~d , ~a:~a/~d ).~n', [M,F,A , M1,F1,A] ),
|
||||
fail.
|
||||
clinks(S) :-
|
||||
node( M, P, File-Line, c(F)),
|
||||
format( S, ':- foreign_predicate( ~q , ~q, ~q, ~d ).~n', [M:P, F, File, Line] ),
|
||||
format( S, ':- foreign_predicate( ~q , ~q , ~q , ~d ).~n', [M:P, F, File, Line] ),
|
||||
fail.
|
||||
clinks(S) :-
|
||||
close(S).
|
||||
@ -1212,7 +1216,7 @@ preprocess_file(F,F).
|
||||
|
||||
|
||||
%%%%%%%
|
||||
%% declare a concept exportable
|
||||
%% declare a concept export1able
|
||||
public( F, M, op(X,Y,Z) ) :-
|
||||
retract( private( F, M:op(X,Y,Z) ) ),
|
||||
fail.
|
||||
|
@ -6,10 +6,15 @@ This library provides an interface to the BDD package CUDD. It requires
|
||||
CUDD compiled as a dynamic library. In Linux this is available out of
|
||||
box in Fedora, but can easily be ported to other Linux
|
||||
distributions. CUDD is available in the ports OSX package, and in
|
||||
cygwin. To use it, call `:-use_module(library(bdd))`.
|
||||
cygwin. To use it, call
|
||||
|
||||
~~~~~
|
||||
:-use_module(library(bdd))`.
|
||||
~~~~~
|
||||
|
||||
The following predicates construct a BDD:
|
||||
|
||||
\toc
|
||||
|
||||
*/
|
||||
|
||||
@ -42,27 +47,56 @@ tell_warning :-
|
||||
|
||||
:- catch(load_foreign_files([cudd], [], init_cudd),_,fail) -> true ; tell_warning.
|
||||
|
||||
/**
|
||||
@pred bdd_new(? _Exp_, - _BddHandle_)
|
||||
|
||||
% create a new BDD from a tree.
|
||||
/** @defgroup BDDs Binary Decision Diagrams and Friends
|
||||
@ingroup YAPPackages
|
||||
@{
|
||||
create a new BDD from the logical expression _Exp_. The expression
|
||||
may include:
|
||||
|
||||
This library provides an interface to the BDD package CUDD. It requires
|
||||
CUDD compiled as a dynamic library. In Linux this is available out of
|
||||
box in Fedora, but can easily be ported to other Linux
|
||||
distributions. CUDD is available in the ports OSX package, and in
|
||||
cygwin. To use it, call `:-use_module(library(bdd))`.
|
||||
+ Logical Variables:
|
||||
|
||||
The following predicates construct a BDD:
|
||||
a leaf-node can be a logical variable.
|
||||
|
||||
+ `0` and `1`
|
||||
|
||||
a leaf-node can also be bound to the two boolean constants.
|
||||
|
||||
+ `or( _X_, _Y_)`, `_X_ \/ _Y_`, `_X_ + _Y_`
|
||||
|
||||
disjunction
|
||||
|
||||
+ `and( _X_, _Y_)`, `_X_ /\ _Y_`, `_X_ * _Y_`
|
||||
|
||||
conjunction
|
||||
|
||||
+ `nand( _X_, _Y_)`
|
||||
|
||||
negated conjunction@
|
||||
|
||||
+ `nor( _X_, _Y_)`
|
||||
|
||||
negated disjunction
|
||||
|
||||
+ `xor( _X_, _Y_)`
|
||||
|
||||
exclusive or
|
||||
|
||||
+ `not( _X_)`, or `-_X_`
|
||||
|
||||
negation.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
bdd_new(T, Bdd) :-
|
||||
term_variables(T, Vars),
|
||||
bdd_new(T, Vars, Bdd).
|
||||
|
||||
/**
|
||||
@pred bdd_new(? _Exp_, +_Vars_, - _BddHandle_)
|
||||
|
||||
Same as bdd_new/2, but receives a term of the form
|
||||
`vs(V1,....,Vn)`. This allows incremental construction of BDDs.
|
||||
|
||||
*/
|
||||
bdd_new(T, Vars, cudd(M,X,VS,TrueVars)) :-
|
||||
term_variables(Vars, TrueVars),
|
||||
VS =.. [vs|TrueVars],
|
||||
@ -72,9 +106,7 @@ bdd_new(T, Vars, cudd(M,X,VS,TrueVars)) :-
|
||||
|
||||
Convert a _List_ of logical expressions of the form above, that
|
||||
includes the set of free variables _Vars_, into a BDD accessible
|
||||
through _BddHandle_.
|
||||
|
||||
|
||||
through _BddHandle_.
|
||||
*/
|
||||
% create a new BDD from a list.
|
||||
bdd_from_list(List, Vars, cudd(M,X,VS,TrueVars)) :-
|
||||
@ -173,8 +205,6 @@ sum
|
||||
subtraction
|
||||
+ or( _X_, _Y_), _X_ \/ _Y_
|
||||
logical or
|
||||
|
||||
|
||||
|
||||
*/
|
||||
mtbdd_new(T, Mtbdd) :-
|
||||
|
@ -1,4 +1,40 @@
|
||||
/**
|
||||
@defgroup CUDD CUDD Interface
|
||||
@ingroup BDDs
|
||||
|
||||
@brief Interface to the CUDD Library
|
||||
|
||||
CUDD represents a BDD as a tree of DdNode structures. Each tree has a manager DdManager and a list of booleaan variables, also represented as DdNode structures. Mapping from an Prolog tree to a ground BDD involves the following steps:
|
||||
|
||||
1. Collect all logical variables in the Prolog term, and map each
|
||||
variable $V$ to a boolean variable $i$ in the BDD. This is easily done
|
||||
by having the variable as the argument argument $i$ of a Prolog
|
||||
term. The implementation uses vars_of_term/2 and =../2.
|
||||
|
||||
2. Allocate an array of boolean variables.
|
||||
|
||||
3. Perform a posfix visit of the Prolog term, so that a new DdNode is
|
||||
always obtained by composing its children nodes.
|
||||
|
||||
YAP supports a few tricks:
|
||||
|
||||
+ A term of the form `cudd(_Address_)` refers to a compiled BDD. Thus,
|
||||
we can pass a BDD to another BDD, ie:
|
||||
|
||||
~~~~~.pl
|
||||
bdd(BDD) :-
|
||||
Vs = vs(X,Y,Z),
|
||||
bdd_new(X+(Y*Z),Vs,BDD0),
|
||||
bdd_new(xor(BDD0,-(nand(X,BDD0) + nor(Y,BDD0)) ), Vs, BDD).
|
||||
~~~~~
|
||||
|
||||
This is useful to construct complex BDDs quickly, but does not mean
|
||||
CUDD will generate better/faster code.
|
||||
|
||||
|
||||
2.
|
||||
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "config.h"
|
||||
@ -857,3 +893,6 @@ init_cudd(void)
|
||||
YAP_UserCPredicate("cudd_print", p_cudd_print, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
*@}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user