Add documentation
This commit is contained in:
66
docs/CMakeLists.txt
Normal file
66
docs/CMakeLists.txt
Normal file
@@ -0,0 +1,66 @@
|
||||
SET (CODES
|
||||
web/bootstrap/doxy-boot.js
|
||||
web/bootstrap/footer.html
|
||||
web/bootstrap/header.html
|
||||
web/bootstrap/customdoxygen.css
|
||||
offcanvas.css
|
||||
offcanvas.js
|
||||
solarized-light.css
|
||||
theme.css
|
||||
yap.css
|
||||
bootstrap.min.css
|
||||
bootstrap.min.js
|
||||
font-awesome.min.css
|
||||
jquery-2.0.3.min.js
|
||||
application.js
|
||||
pygments.css
|
||||
misc/icons/yap_64x64x32.png
|
||||
misc/icons/yap_256x256x32.png
|
||||
misc/icons/yap_128x128x32.png
|
||||
misc/icons/yap_48x48x32.png
|
||||
)
|
||||
|
||||
SET (DOCS
|
||||
builtins.md
|
||||
chr.md
|
||||
clpqr.md
|
||||
download.md
|
||||
extensions.md
|
||||
fli.md
|
||||
install.md
|
||||
packages.md
|
||||
run.md
|
||||
swi.md
|
||||
syntax.md
|
||||
yap.md
|
||||
)
|
||||
|
||||
|
||||
|
||||
# add a target to generate API documentation with Doxygen
|
||||
|
||||
find_package(Doxygen)
|
||||
option(WITH_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen)" ${DOXYGEN_FOUND})
|
||||
|
||||
if(WITH_DOCUMENTATION)
|
||||
if(NOT DOXYGEN_FOUND)
|
||||
message(FATAL_ERROR "Doxygen is needed to build the documentation.")
|
||||
endif()
|
||||
|
||||
set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
|
||||
set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
|
||||
|
||||
|
||||
configure_file(${doxyfile_in} ${doxyfile} @ONLY)
|
||||
|
||||
add_custom_target(doc
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen"
|
||||
VERBATIM)
|
||||
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${docdir})
|
||||
install(FILES ${CODES} DESTINATION ${docdir})
|
||||
|
||||
endif()
|
||||
|
2427
docs/Doxyfile.in
Normal file
2427
docs/Doxyfile.in
Normal file
File diff suppressed because it is too large
Load Diff
530
docs/chr.md
Normal file
530
docs/chr.md
Normal file
@@ -0,0 +1,530 @@
|
||||
|
||||
CHR: Constraint Handling Rules {#chr}
|
||||
==============================
|
||||
|
||||
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.
|
||||
|
||||
The CHR system of SWI-Prolog is the K.U.Leuven CHR system. The
|
||||
runtime environment is written by Christian Holzbaur and Tom
|
||||
Schrijvers while the compiler is written by Tom Schrijvers. Both are
|
||||
integrated with SWI-Prolog and licenced under compatible conditions
|
||||
with permission from the authors. Porting and maintenance on YAP is
|
||||
the entire responsability of Vítor Santos Costa.
|
||||
|
||||
The main reference for SWI-Prolog's CHR system is:
|
||||
|
||||
+ T. Schrijvers, and B. Demoen, <em>The K.U.Leuven CHR System: Implementation and Application</em>, First Workshop on Constraint Handling Rules: Selected
|
||||
Contributions (Fruwirth, T. and Meister, M., eds.), pp. 1--5, 2004.
|
||||
|
||||
# Introduction
|
||||
|
||||
Constraint Handling Rules (CHR) is a committed-choice bottom-up language
|
||||
embedded in Prolog. It is designed for writing constraint solvers and is
|
||||
particularily useful for providing application-specific constraints.
|
||||
It has been used in many kinds of applications, like scheduling,
|
||||
model checking, abduction, type checking among many others.
|
||||
|
||||
CHR has previously been implemented in other Prolog systems (SICStus,
|
||||
Eclipse, Yap), Haskell and Java. This CHR system is based on the
|
||||
compilation scheme and runtime environment of CHR in SICStus.
|
||||
|
||||
In this documentation we restrict ourselves to giving a short overview
|
||||
of CHR in general and mainly focus on elements specific to this
|
||||
implementation. For a more thorough review of CHR we refer the reader to
|
||||
[Freuhwirth:98]. More background on CHR can be found at the CHR web site.
|
||||
|
||||
### Syntax and Semantics
|
||||
|
||||
We present informally the syntax and semantics of CHR.
|
||||
|
||||
|
||||
#### CHR Syntax
|
||||
|
||||
The syntax of CHR rules in hProlog is the following:
|
||||
|
||||
~~~~~
|
||||
rules --> rule, rules.
|
||||
rules --> [].
|
||||
|
||||
rule --> name, actual_rule, pragma, [atom(`.`)].
|
||||
|
||||
name --> atom, [atom(`@`)].
|
||||
name --> [].
|
||||
|
||||
actual_rule --> simplification_rule.
|
||||
actual_rule --> propagation_rule.
|
||||
actual_rule --> simpagation_rule.
|
||||
|
||||
simplification_rule --> constraints, [atom(`<=>`)], guard, body.
|
||||
propagation_rule --> constraints, [atom(`==>`)], guard, body.
|
||||
simpagation_rule --> constraints, [atom(`\`)], constraints, [atom(`<=>`)],
|
||||
guard, body.
|
||||
|
||||
constraints --> constraint, constraint_id.
|
||||
constraints --> constraint, [atom(`,`)], constraints.
|
||||
|
||||
constraint --> compound_term.
|
||||
|
||||
constraint_id --> [].
|
||||
constraint_id --> [atom(`#`)], variable.
|
||||
|
||||
guard --> [].
|
||||
guard --> goal, [atom(`|`)].
|
||||
|
||||
body --> goal.
|
||||
|
||||
pragma --> [].
|
||||
pragma --> [atom(`pragma`)], actual_pragmas.
|
||||
|
||||
actual_pragmas --> actual_pragma.
|
||||
actual_pragmas --> actual_pragma, [atom(`,`)], actual_pragmas.
|
||||
|
||||
actual_pragma --> [atom(`passive(`)], variable, [atom(`)`)].
|
||||
|
||||
~~~~~
|
||||
|
||||
Additional syntax-related terminology:
|
||||
|
||||
+ *head:* the constraints in an `actual_rule` before
|
||||
the arrow (either `<=>` or `==>`)
|
||||
|
||||
|
||||
#### Semantics Semantics
|
||||
|
||||
In this subsection the operational semantics of CHR in Prolog are presented
|
||||
informally. They do not differ essentially from other CHR systems.
|
||||
|
||||
When a constraint is called, it is considered an active constraint and
|
||||
the system will try to apply the rules to it. Rules are tried and executed
|
||||
sequentially in the order they are written.
|
||||
|
||||
A rule is conceptually tried for an active constraint in the following
|
||||
way. The active constraint is matched with a constraint in the head of
|
||||
the rule. If more constraints appear in the head they are looked for
|
||||
among the suspended constraints, which are called passive constraints in
|
||||
this context. If the necessary passive constraints can be found and all
|
||||
match with the head of the rule and the guard of the rule succeeds, then
|
||||
the rule is committed and the body of the rule executed. If not all the
|
||||
necessary passive constraint can be found, the matching fails or the
|
||||
guard fails, then the body is not executed and the process of trying and
|
||||
executing simply continues with the following rules. If for a rule,
|
||||
there are multiple constraints in the head, the active constraint will
|
||||
try the rule sequentially multiple times, each time trying to match with
|
||||
another constraint.
|
||||
|
||||
This process ends either when the active constraint disappears, i.e. it
|
||||
is removed by some rule, or after the last rule has been processed. In
|
||||
the latter case the active constraint becomes suspended.
|
||||
|
||||
A suspended constraint is eligible as a passive constraint for an active
|
||||
constraint. The other way it may interact again with the rules, is when
|
||||
a variable appearing in the constraint becomes bound to either a nonvariable
|
||||
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.
|
||||
|
||||
### Rules
|
||||
|
||||
There are three different kinds of rules, each with their specific semantics:
|
||||
|
||||
+ simplification
|
||||
The simplification rule removes the constraints in its head and calls its body.
|
||||
|
||||
+ propagation
|
||||
The propagation rule calls its body exactly once for the constraints in
|
||||
its head.
|
||||
|
||||
+ simpagation
|
||||
The simpagation rule removes the constraints in its head after the
|
||||
`\` and then calls its body. It is an optimization of
|
||||
simplification rules of the form: \[constraints_1, constraints_2 <=>
|
||||
constraints_1, body \] Namely, in the simpagation form:
|
||||
|
||||
~~~~~
|
||||
constraints1 \ constraints2 <=> body
|
||||
~~~~~
|
||||
_constraints1_
|
||||
constraints are not called in the body.
|
||||
|
||||
|
||||
|
||||
#### Rule Names
|
||||
|
||||
Naming a rule is optional and has no semantical meaning. It only functions
|
||||
as documentation for the programmer.
|
||||
|
||||
### Pragmas
|
||||
|
||||
The semantics of the pragmas are:
|
||||
|
||||
+ passive(Identifier)
|
||||
The constraint in the head of a rule _Identifier_ can only act as a
|
||||
passive constraint in that rule.
|
||||
|
||||
|
||||
Additional pragmas may be released in the future.
|
||||
|
||||
### CHR_Options Options
|
||||
|
||||
It is possible to specify options that apply to all the CHR rules in the module.
|
||||
Options are specified with the `option/2` declaration:
|
||||
|
||||
~~~~~
|
||||
option(Option,Value).
|
||||
~~~~~
|
||||
|
||||
Available options are:
|
||||
|
||||
+ check_guard_bindings
|
||||
This option controls whether guards should be checked for illegal
|
||||
variable bindings or not. Possible values for this option are
|
||||
`on`, to enable the checks, and `off`, to disable the
|
||||
checks.
|
||||
|
||||
+ optimize
|
||||
This is an experimental option controlling the degree of optimization.
|
||||
Possible values are `full`, to enable all available
|
||||
optimizations, and `off` (default), to disable all optimizations.
|
||||
The default is derived from the SWI-Prolog flag `optimise`, where
|
||||
`true` is mapped to `full`. Therefore the commandline
|
||||
option `-O` provides full CHR optimization.
|
||||
If optimization is enabled, debugging should be disabled.
|
||||
|
||||
+ debug
|
||||
This options enables or disables the possibility to debug the CHR code.
|
||||
Possible values are `on` (default) and `off`. See
|
||||
`debugging` for more details on debugging. The default is
|
||||
derived from the prolog flag `generate_debug_info`, which
|
||||
is `true` by default. See `-nodebug`.
|
||||
If debugging is enabled, optimization should be disabled.
|
||||
|
||||
+ mode
|
||||
This option specifies the mode for a particular constraint. The
|
||||
value is a term with functor and arity equal to that of a constraint.
|
||||
The arguments can be one of `-`, `+` or `?`.
|
||||
The latter is the default. The meaning is the following:
|
||||
|
||||
+ -
|
||||
The corresponding argument of every occurrence
|
||||
of the constraint is always unbound.
|
||||
+ +
|
||||
The corresponding argument of every occurrence
|
||||
of the constraint is always ground.
|
||||
+ ?
|
||||
The corresponding argument of every occurrence
|
||||
of the constraint can have any instantiation, which may change
|
||||
over time. This is the default value.
|
||||
|
||||
The declaration is used by the compiler for various optimizations.
|
||||
Note that it is up to the user the ensure that the mode declaration
|
||||
is correct with respect to the use of the constraint.
|
||||
This option may occur once for each constraint.
|
||||
|
||||
+ type_declaration
|
||||
This option specifies the argument types for a particular constraint. The
|
||||
value is a term with functor and arity equal to that of a constraint.
|
||||
The arguments can be a user-defined type or one of
|
||||
the built-in types:
|
||||
|
||||
+ int
|
||||
The corresponding argument of every occurrence
|
||||
of the constraint is an integer number.
|
||||
+ float
|
||||
...{} a floating point number.
|
||||
+ number
|
||||
...{} a number.
|
||||
+ natural
|
||||
...{} a positive integer.
|
||||
+ any
|
||||
The corresponding argument of every occurrence
|
||||
of the constraint can have any type. This is the default value.
|
||||
|
||||
|
||||
Currently, type declarations are only used to improve certain
|
||||
optimizations (guard simplification, occurrence subsumption, ...{}).
|
||||
|
||||
+ type_definition
|
||||
This option defines a new user-defined type which can be used in
|
||||
type declarations. The value is a term of the form
|
||||
`type(` _name_`,` _list_`)`, where
|
||||
_name_ is a term and _list_ is a list of alternatives.
|
||||
Variables can be used to define generic types. Recursive definitions
|
||||
are allowed. Examples are
|
||||
|
||||
~~~~~
|
||||
type(bool,[true,false]).
|
||||
type(complex_number,[float + float * i]).
|
||||
type(binary_tree(T),[ leaf(T) | node(binary_tree(T),binary_tree(T)) ]).
|
||||
type(list(T),[ [] | [T | list(T)]).
|
||||
~~~~~
|
||||
|
||||
|
||||
|
||||
The mode, type_declaration and type_definition options are provided
|
||||
for backward compatibility. The new syntax is described below.
|
||||
|
||||
|
||||
|
||||
### CHR in Prolog Programs
|
||||
|
||||
|
||||
The CHR constraints defined in a particulary chr file are
|
||||
associated with a module. The default module is `user`. One should
|
||||
never load different chr files with the same CHR module name.
|
||||
|
||||
|
||||
|
||||
#### Constraint Declarations
|
||||
|
||||
|
||||
Every constraint used in CHR rules has to be declared.
|
||||
There are two ways to do this. The old style is as follows:
|
||||
|
||||
~~~~~
|
||||
option(type_definition,type(list(T),[ [] , [T|list(T)] ]).
|
||||
option(mode,foo(+,?)).
|
||||
option(type_declaration,foo(list(int),float)).
|
||||
:- constraints foo/2, bar/0.
|
||||
~~~~~
|
||||
|
||||
The new style is as follows:
|
||||
|
||||
~~~~~
|
||||
:- chr_type list(T) ---> [] ; [T|list(T)].
|
||||
:- constraints foo(+list(int),?float), bar.
|
||||
~~~~~
|
||||
|
||||
|
||||
|
||||
#### Compilation
|
||||
|
||||
The
|
||||
SWI-Prolog CHR compiler exploits term_expansion/2 rules to translate
|
||||
the constraint handling rules to plain Prolog. These rules are loaded
|
||||
from the library chr. They are activated if the compiled file
|
||||
has the chr extension or after finding a declaration of the
|
||||
format below.
|
||||
|
||||
~~~~~
|
||||
:- constraints ...
|
||||
~~~~~
|
||||
|
||||
It is adviced to define CHR rules in a module file, where the module
|
||||
declaration is immediately followed by including the chr
|
||||
library as examplified below:
|
||||
|
||||
~~~~~
|
||||
:- module(zebra, [ zebra/0 ]).
|
||||
:- use_module(library(chr)).
|
||||
|
||||
:- constraints ...
|
||||
~~~~~
|
||||
|
||||
Using this style CHR rules can be defined in ordinary Prolog
|
||||
pl files and the operator definitions required by CHR do not
|
||||
leak into modules where they might cause conflicts.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### CHR Debugging
|
||||
|
||||
The CHR debugging facilities are currently rather limited. Only tracing
|
||||
is currently available. To use the CHR debugging facilities for a CHR
|
||||
file it must be compiled for debugging. Generating debug info is
|
||||
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.
|
||||
|
||||
#### Ports
|
||||
|
||||
vFor CHR constraints the four standard ports are defined:
|
||||
|
||||
+ call
|
||||
A new constraint is called and becomes active.
|
||||
+ exit
|
||||
An active constraint exits: it has either been inserted in the store after
|
||||
trying all rules or has been removed from the constraint store.
|
||||
+ fail
|
||||
An active constraint fails.
|
||||
+ redo
|
||||
An active constraint starts looking for an alternative solution.
|
||||
|
||||
|
||||
In addition to the above ports, CHR constraints have five additional
|
||||
ports:
|
||||
|
||||
+ wake
|
||||
A suspended constraint is woken and becomes active.
|
||||
+ insert
|
||||
An active constraint has tried all rules and is suspended in
|
||||
the constraint store.
|
||||
+ remove
|
||||
An active or passive constraint is removed from the constraint
|
||||
store, if it had been inserted.
|
||||
+ try
|
||||
An active constraints tries a rule with possibly
|
||||
some passive constraints. The try port is entered
|
||||
just before committing to the rule.
|
||||
+ apply
|
||||
An active constraints commits to a rule with possibly
|
||||
some passive constraints. The apply port is entered
|
||||
just after committing to the rule.
|
||||
|
||||
#### Tracing
|
||||
|
||||
Tracing is enabled with the chr_trace/0 predicate
|
||||
and disabled with the chr_notrace/0 predicate.
|
||||
|
||||
When enabled the tracer will step through the `call`,
|
||||
`exit`, `fail`, `wake` and `apply` ports,
|
||||
accepting debug commands, and simply write out the other ports.
|
||||
|
||||
The following debug commans are currently supported:
|
||||
|
||||
~~~~~
|
||||
CHR debug options:
|
||||
|
||||
<cr> creep c creep
|
||||
s skip
|
||||
g ancestors
|
||||
n nodebug
|
||||
b break
|
||||
a abort
|
||||
f fail
|
||||
? help h help
|
||||
~~~~~
|
||||
|
||||
Their meaning is:
|
||||
|
||||
+ creep
|
||||
Step to the next port.
|
||||
+ skip
|
||||
Skip to exit port of this call or wake port.
|
||||
+ ancestors
|
||||
Print list of ancestor call and wake ports.
|
||||
+ nodebug
|
||||
Disable the tracer.
|
||||
+ break
|
||||
Enter a recursive Prolog toplevel. See break/0.
|
||||
+ abort
|
||||
Exit to the toplevel. See abort/0.
|
||||
+ fail
|
||||
Insert failure in execution.
|
||||
+ help
|
||||
Print the above available debug options.
|
||||
|
||||
|
||||
#### CHR Debugging Predicates
|
||||
|
||||
|
||||
The chr module contains several predicates that allow
|
||||
inspecting and printing the content of the constraint store.
|
||||
|
||||
+ chr_trace
|
||||
Activate the CHR tracer. By default the CHR tracer is activated and
|
||||
deactivated automatically by the Prolog predicates trace/0 and
|
||||
notrace/0.
|
||||
|
||||
### CHR_Examples Examples
|
||||
|
||||
Here are two example constraint solvers written in CHR.
|
||||
|
||||
+
|
||||
The program below defines a solver with one constraint,
|
||||
`leq/2`, which is a less-than-or-equal constraint.
|
||||
|
||||
~~~~~
|
||||
:- module(leq,[cycle/3, leq/2]).
|
||||
:- use_module(library(chr)).
|
||||
|
||||
:- constraints leq/2.
|
||||
reflexivity @ leq(X,X) <=> true.
|
||||
antisymmetry @ leq(X,Y), leq(Y,X) <=> X = Y.
|
||||
idempotence @ leq(X,Y) \ leq(X,Y) <=> true.
|
||||
transitivity @ leq(X,Y), leq(Y,Z) ==> leq(X,Z).
|
||||
|
||||
cycle(X,Y,Z):-
|
||||
leq(X,Y),
|
||||
leq(Y,Z),
|
||||
leq(Z,X).
|
||||
~~~~~
|
||||
|
||||
+
|
||||
The program below implements a simple finite domain
|
||||
constraint solver.
|
||||
|
||||
~~~~~
|
||||
:- module(dom,[dom/2]).
|
||||
:- use_module(library(chr)).
|
||||
|
||||
:- constraints dom/2.
|
||||
|
||||
dom(X,[]) <=> fail.
|
||||
dom(X,[Y]) <=> X = Y.
|
||||
dom(X,L1), dom(X,L2) <=> intersection(L1,L2,L3), dom(X,L3).
|
||||
|
||||
intersection([],_,[]).
|
||||
intersection([H|T],L2,[H|L3]) :-
|
||||
member(H,L2), !,
|
||||
intersection(T,L2,L3).
|
||||
intersection([_|T],L2,L3) :-
|
||||
intersection(T,L2,L3).
|
||||
~~~~~
|
||||
|
||||
|
||||
|
||||
### Compatibility with SICStus CHR
|
||||
|
||||
|
||||
There are small differences between CHR in SWI-Prolog and newer
|
||||
YAPs and SICStus and older versions of YAP. Besides differences in
|
||||
available options and pragmas, the following differences should be
|
||||
noted:
|
||||
|
||||
+ [The handler/1 declaration]
|
||||
In SICStus every CHR module requires a `handler/1`
|
||||
declaration declaring a unique handler name. This declaration is valid
|
||||
syntax in SWI-Prolog, but will have no effect. A warning will be given
|
||||
during compilation.
|
||||
|
||||
+ [The rules/1 declaration]
|
||||
In SICStus, for every CHR module it is possible to only enable a subset
|
||||
of the available rules through the `rules/1` declaration. The
|
||||
declaration is valid syntax in SWI-Prolog, but has no effect. A
|
||||
warning is given during compilation.
|
||||
|
||||
+ [Sourcefile naming]
|
||||
SICStus uses a two-step compiler, where chr files are
|
||||
first translated into pl files. For SWI-Prolog CHR
|
||||
rules may be defined in a file with any extension.
|
||||
|
||||
### Guidelines
|
||||
|
||||
In this section we cover several guidelines on how to use CHR to write
|
||||
constraint solvers and how to do so efficiently.
|
||||
|
||||
+ [Set semantics]
|
||||
The CHR system allows the presence of identical constraints, i.e.
|
||||
multiple constraints with the same functor, arity and arguments. For
|
||||
most constraint solvers, this is not desirable: it affects efficiency
|
||||
and possibly termination. Hence appropriate simpagation rules should be
|
||||
added of the form:
|
||||
|
||||
~~~~~
|
||||
{constraint \ constraint <=> true}.
|
||||
~~~~~
|
||||
|
||||
+ [Multi-headed rules]
|
||||
Multi-headed rules are executed more efficiently when the constraints
|
||||
share one or more variables.
|
||||
|
||||
+ [Mode and type declarations]
|
||||
Provide mode and type declarations to get more efficient program execution.
|
||||
Make sure to disable debug (`-nodebug`) and enable optimization
|
||||
(`-O`).
|
||||
|
||||
|
121
docs/clpqr.md
Normal file
121
docs/clpqr.md
Normal file
@@ -0,0 +1,121 @@
|
||||
Constraint Logic Programming over Rationals and Reals {#clpqr}
|
||||
=====================================================
|
||||
|
||||
|
||||
YAP now uses the CLP(R) package developed by <em>Leslie De Koninck</em>,
|
||||
K.U. Leuven as part of a thesis with supervisor Bart Demoen and daily
|
||||
advisor Tom Schrijvers, and distributed with SWI-Prolog.
|
||||
|
||||
This CLP(R) system is a port of the CLP(Q,R) system of Sicstus Prolog
|
||||
and YAP by Christian Holzbaur: Holzbaur C.: OFAI clp(q,r) Manual,
|
||||
Edition 1.3.3, Austrian Research Institute for Artificial
|
||||
Intelligence, Vienna, TR-95-09, 1995,
|
||||
<http://www.ai.univie.ac.at/cgi-bin/tr-online?number+95-09> This
|
||||
port only contains the part concerning real arithmetics. This manual
|
||||
is roughly based on the manual of the above mentioned *CLP(QR)*
|
||||
implementation.
|
||||
|
||||
Please note that the clpr library is <em>not</em> an
|
||||
`autoload` library and therefore this library must be loaded
|
||||
explicitely before using it:
|
||||
|
||||
~~~~~
|
||||
:- use_module(library(clpr)).
|
||||
~~~~~
|
||||
|
||||
### Solver Predicates {#CLPQR_Solver_Predicates}
|
||||
|
||||
The following predicates are provided to work with constraints:
|
||||
|
||||
|
||||
### Syntax of the predicate arguments {#CLPQR_Syntax}
|
||||
|
||||
|
||||
The arguments of the predicates defined in the subsection above are
|
||||
defined in the following table. Failing to meet the syntax rules will
|
||||
result in an exception.
|
||||
|
||||
~~~~~
|
||||
<Constraints> ---> <Constraint> \ single constraint \
|
||||
| <Constraint> , <Constraints> \ conjunction \
|
||||
| <Constraint> ; <Constraints> \ disjunction \
|
||||
|
||||
<Constraint> ---> <Expression> {<} <Expression> \ less than \
|
||||
| <Expression> {>} <Expression> \ greater than \
|
||||
| <Expression> {=<} <Expression> \ less or equal \
|
||||
| {<=}(<Expression>, <Expression>) \ less or equal \
|
||||
| <Expression> {>=} <Expression> \ greater or equal \
|
||||
| <Expression> {=\=} <Expression> \ not equal \
|
||||
| <Expression> =:= <Expression> \ equal \
|
||||
| <Expression> = <Expression> \ equal \
|
||||
|
||||
<Expression> ---> <Variable> \ Prolog variable \
|
||||
| <Number> \ Prolog number (float, integer) \
|
||||
| +<Expression> \ unary plus \
|
||||
| -<Expression> \ unary minus \
|
||||
| <Expression> + <Expression> \ addition \
|
||||
| <Expression> - <Expression> \ substraction \
|
||||
| <Expression> * <Expression> \ multiplication \
|
||||
| <Expression> / <Expression> \ division \
|
||||
| abs(<Expression>) \ absolute value \
|
||||
| sin(<Expression>) \ sine \
|
||||
| cos(<Expression>) \ cosine \
|
||||
| tan(<Expression>) \ tangent \
|
||||
| exp(<Expression>) \ exponent \
|
||||
| pow(<Expression>) \ exponent \
|
||||
| <Expression> {^} <Expression> \ exponent \
|
||||
| min(<Expression>, <Expression>) \ minimum \
|
||||
| max(<Expression>, <Expression>) \ maximum \
|
||||
~~~~~
|
||||
|
||||
|
||||
### Use of unification {#CLPQR_Unification}
|
||||
|
||||
Instead of using the `{}/1` predicate, you can also use the standard
|
||||
unification mechanism to store constraints. The following code samples
|
||||
are equivalent:
|
||||
|
||||
+ Unification with a variable
|
||||
|
||||
~~~~~
|
||||
{X =:= Y}
|
||||
{X = Y}
|
||||
X = Y
|
||||
~~~~~
|
||||
|
||||
+ Unification with a number
|
||||
|
||||
~~~~~
|
||||
{X =:= 5.0}
|
||||
{X = 5.0}
|
||||
X = 5.0
|
||||
~~~~~
|
||||
|
||||
|
||||
#### Non-Linear Constraints {#CLPQR_NonhYlinear_Constraints}
|
||||
|
||||
|
||||
In this version, non-linear constraints do not get solved until certain
|
||||
conditions are satisfied. We call these conditions the _isolation_ axioms.
|
||||
They are given in the following table.
|
||||
|
||||
~~~~~
|
||||
A = B * C when B or C is ground or // A = 5 * C or A = B * 4 \\
|
||||
A and (B or C) are ground // 20 = 5 * C or 20 = B * 4 \\
|
||||
|
||||
A = B / C when C is ground or // A = B / 3
|
||||
A and B are ground // 4 = 12 / C
|
||||
|
||||
X = min(Y,Z) when Y and Z are ground or // X = min(4,3)
|
||||
X = max(Y,Z) Y and Z are ground // X = max(4,3)
|
||||
X = abs(Y) Y is ground // X = abs(-7)
|
||||
|
||||
X = pow(Y,Z) when X and Y are ground or // 8 = 2 ^ Z
|
||||
X = exp(Y,Z) X and Z are ground // 8 = Y ^ 3
|
||||
X = Y ^ Z Y and Z are ground // X = 2 ^ 3
|
||||
|
||||
X = sin(Y) when X is ground or // 1 = sin(Y)
|
||||
X = cos(Y) Y is ground // X = sin(1.5707)
|
||||
X = tan(Y)
|
||||
~~~~~
|
||||
|
303
docs/solarized-light.css
Normal file
303
docs/solarized-light.css
Normal file
@@ -0,0 +1,303 @@
|
||||
@import url(http://fonts.googleapis.com/css?family=Inconsolata);
|
||||
@import url(http://fonts.googleapis.com/css?family=PT+Sans);
|
||||
@import url(http://fonts.googleapis.com/css?family=PT+Sans+Narrow:400,700);
|
||||
article,
|
||||
aside,
|
||||
details,
|
||||
figcaption,
|
||||
figure,
|
||||
footer,
|
||||
header,
|
||||
hgroup,
|
||||
nav,
|
||||
section,
|
||||
summary {
|
||||
display: block;
|
||||
}
|
||||
audio,
|
||||
canvas,
|
||||
video {
|
||||
display: inline-block;
|
||||
}
|
||||
audio:not([controls]) {
|
||||
display: none;
|
||||
height: 0;
|
||||
}
|
||||
[hidden] {
|
||||
display: none;
|
||||
}
|
||||
html {
|
||||
font-family: sans-serif;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
-ms-text-size-adjust: 100%;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
a:focus {
|
||||
outline: thin dotted;
|
||||
}
|
||||
a:active,
|
||||
a:hover {
|
||||
outline: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
}
|
||||
abbr[title] {
|
||||
border-bottom: 1px dotted;
|
||||
}
|
||||
b,
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
dfn {
|
||||
font-style: italic;
|
||||
}
|
||||
mark {
|
||||
background: #ff0;
|
||||
color: #000;
|
||||
}
|
||||
code,
|
||||
kbd,
|
||||
pre,
|
||||
samp {
|
||||
font-family: monospace, serif;
|
||||
font-size: 1em;
|
||||
}
|
||||
pre {
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
q {
|
||||
quotes: "\201C" "\201D" "\2018" "\2019";
|
||||
}
|
||||
small {
|
||||
font-size: 80%;
|
||||
}
|
||||
sub,
|
||||
sup {
|
||||
font-size: 75%;
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
img {
|
||||
border: 0;
|
||||
}
|
||||
svg:not(:root) {
|
||||
overflow: hidden;
|
||||
}
|
||||
figure {
|
||||
margin: 0;
|
||||
}
|
||||
fieldset {
|
||||
border: 1px solid #c0c0c0;
|
||||
margin: 0 2px;
|
||||
padding: 0.35em 0.625em 0.75em;
|
||||
}
|
||||
legend {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
}
|
||||
button,
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
font-family: inherit;
|
||||
font-size: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
button,
|
||||
input {
|
||||
line-height: normal;
|
||||
}
|
||||
button,
|
||||
html input[type="button"],
|
||||
input[type="reset"],
|
||||
input[type="submit"] {
|
||||
-webkit-appearance: button;
|
||||
cursor: pointer;
|
||||
}
|
||||
button[disabled],
|
||||
input[disabled] {
|
||||
cursor: default;
|
||||
}
|
||||
input[type="checkbox"],
|
||||
input[type="radio"] {
|
||||
box-sizing: border-box;
|
||||
padding: 0;
|
||||
}
|
||||
input[type="search"] {
|
||||
-webkit-appearance: textfield;
|
||||
-moz-box-sizing: content-box;
|
||||
-webkit-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
input[type="search"]::-webkit-search-cancel-button,
|
||||
input[type="search"]::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
button::-moz-focus-inner,
|
||||
input::-moz-focus-inner {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
}
|
||||
textarea {
|
||||
overflow: auto;
|
||||
vertical-align: top;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
html {
|
||||
font-family: 'PT Sans', sans-serif;
|
||||
}
|
||||
pre,
|
||||
code {
|
||||
font-family: 'Inconsolata', sans-serif;
|
||||
}
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
font-family: 'PT Sans Narrow', sans-serif;
|
||||
font-weight: 700;
|
||||
}
|
||||
html {
|
||||
background-color: #eee8d5;
|
||||
color: #657b83;
|
||||
margin: 1em;
|
||||
}
|
||||
body {
|
||||
background-color: #fdf6e3;
|
||||
margin: 0 auto;
|
||||
max-width: 23cm;
|
||||
border: 1pt solid #93a1a1;
|
||||
padding: 1em;
|
||||
}
|
||||
code {
|
||||
background-color: #eee8d5;
|
||||
padding: 2px;
|
||||
}
|
||||
a {
|
||||
color: #b58900;
|
||||
}
|
||||
a:visited {
|
||||
color: #cb4b16;
|
||||
}
|
||||
a:hover {
|
||||
color: #cb4b16;
|
||||
}
|
||||
h1 {
|
||||
color: #d33682;
|
||||
}
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
color: #859900;
|
||||
}
|
||||
pre {
|
||||
background-color: #fdf6e3;
|
||||
color: #657b83;
|
||||
border: 1pt solid #93a1a1;
|
||||
padding: 1em;
|
||||
box-shadow: 5pt 5pt 8pt #eee8d5;
|
||||
}
|
||||
pre code {
|
||||
background-color: #fdf6e3;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.8em;
|
||||
}
|
||||
h2 {
|
||||
font-size: 2.4em;
|
||||
}
|
||||
h3 {
|
||||
font-size: 1.8em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.4em;
|
||||
}
|
||||
h5 {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
h6 {
|
||||
font-size: 1.15em;
|
||||
}
|
||||
.tag {
|
||||
background-color: #eee8d5;
|
||||
color: #d33682;
|
||||
padding: 0 0.2em;
|
||||
}
|
||||
.todo,
|
||||
.next,
|
||||
.done {
|
||||
color: #fdf6e3;
|
||||
background-color: #dc322f;
|
||||
padding: 0 0.2em;
|
||||
}
|
||||
.tag {
|
||||
-webkit-border-radius: 0.35em;
|
||||
-moz-border-radius: 0.35em;
|
||||
border-radius: 0.35em;
|
||||
}
|
||||
.TODO {
|
||||
-webkit-border-radius: 0.2em;
|
||||
-moz-border-radius: 0.2em;
|
||||
border-radius: 0.2em;
|
||||
background-color: #2aa198;
|
||||
}
|
||||
.NEXT {
|
||||
-webkit-border-radius: 0.2em;
|
||||
-moz-border-radius: 0.2em;
|
||||
border-radius: 0.2em;
|
||||
background-color: #268bd2;
|
||||
}
|
||||
.ACTIVE {
|
||||
-webkit-border-radius: 0.2em;
|
||||
-moz-border-radius: 0.2em;
|
||||
border-radius: 0.2em;
|
||||
background-color: #268bd2;
|
||||
}
|
||||
.DONE {
|
||||
-webkit-border-radius: 0.2em;
|
||||
-moz-border-radius: 0.2em;
|
||||
border-radius: 0.2em;
|
||||
background-color: #859900;
|
||||
}
|
||||
.WAITING {
|
||||
-webkit-border-radius: 0.2em;
|
||||
-moz-border-radius: 0.2em;
|
||||
border-radius: 0.2em;
|
||||
background-color: #cb4b16;
|
||||
}
|
||||
.HOLD {
|
||||
-webkit-border-radius: 0.2em;
|
||||
-moz-border-radius: 0.2em;
|
||||
border-radius: 0.2em;
|
||||
background-color: #d33682;
|
||||
}
|
||||
.NOTE {
|
||||
-webkit-border-radius: 0.2em;
|
||||
-moz-border-radius: 0.2em;
|
||||
border-radius: 0.2em;
|
||||
background-color: #d33682;
|
||||
}
|
||||
.CANCELLED {
|
||||
-webkit-border-radius: 0.2em;
|
||||
-moz-border-radius: 0.2em;
|
||||
border-radius: 0.2em;
|
||||
background-color: #859900;
|
||||
}
|
18
docs/theme.css
Normal file
18
docs/theme.css
Normal file
@@ -0,0 +1,18 @@
|
||||
body {
|
||||
padding-top: 70px;
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
|
||||
.theme-dropdown .dropdown-menu {
|
||||
position: static;
|
||||
display: block;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.theme-showcase > p > .btn {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
.theme-showcase .navbar .container {
|
||||
width: auto;
|
||||
}
|
1120
docs/yap.md
Normal file
1120
docs/yap.md
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user