improved when, recurrent safe, dif tested

parent bcca3bff
......@@ -2499,6 +2499,19 @@ Guile prolog coroutining is a development ontop of attributed variables, it cont
@code{prolog freezeBig(Var, Goal, Unwinder)}, the same as above, but @code{Unwinder}, will be called at backtracking over this signal.
@verbatim
prolog@(guile-user)> freeze(X,write(bound)),X=1.
bound
X = #(<#gp X0>)
Y = X1
more (y/n/a/s) >
prolog@(guile-user)> freeze(X,write(bound)),X=Y.
X = #(<#gp X0>)
Y = X1
more (y/n/a/s) >
@end verbatim
@code{prolog frozen(Var, Goal)}, find the goals @code{Goal} associated to fromzen var @code{Var}
@code{freezeId}, the identity of the attribute associated with @code{freeze}
......@@ -2509,11 +2522,22 @@ Guile prolog coroutining is a development ontop of attributed variables, it cont
@code{prolog whenBig(Signal, Goal, PreGoal, Unwinder)}, the same as above, but @code{PreGoal} is executed before the binding is done, and @code{Unwinder} is code that is executed at the unwinding of an successful signaled.
@verbatim
prolog@(guile-user)> when(X=1,write(bang)),X=2.
X = 2
more (y/n/a/s) > n
prolog@(guile-user)> when(X=1,write(bang)),X=1.
bang
X = 1
more (y/n/a/s) > n
@end verbatim
@code{prolog whenBig(Signal, Goal, Off, PreGoal, Unwinder)} The same as above but with an @code{Off} variable.
@code{with_coroutines(X,Constructor, Code)}, this will apply a coroutine constructor @code{Constructor}, and in that there is a reference to @code{X}, that needs to be an attribute, this will then be a model for variables that are created under an auto atributize environmentm kike using a functor @code{adaptable_vars}. inside the @code{Code} goal.
@code{prolog with_coroutines(X,References,Constr,Code)}, the same as above, but all variables inside @code{References} will not be copied but referenced. The default is to copy.
@code{prolog with_coroutines(X,[References,...],Constr,Code)}, the same as above, but all variables inside @code{References} will not be copied but referenced. The default is to copy.
@verbatim
/* code -----------------------*/
......@@ -2528,7 +2552,7 @@ f1(X) :- X=[1,Y],Y=1.
f2(X) :- X=[1,Y],Y=2.
/* --------------------------- */
/* interaction */
prolog@(guile-user)> with_coroutines(X,[X,Z],when((nonvar(X),X=1,X=Z),
prolog@(guile-user)> with_coroutines(X,[Z],when((nonvar(X),X=1,X=Z),
write(ok))
,(Z=2,f1(Y))).
......@@ -2537,7 +2561,7 @@ prolog@(guile-user)> with_coroutines(X,[X,Z],when((nonvar(X),X=1,X=Z),
Y = [1, 1]
prolog@(guile-user)> with_coroutines(X,[X,Z],when((nonvar(X),X=1,X=Z),
prolog@(guile-user)> with_coroutines(X,[Z],when((nonvar(X),X=1,X=Z),
write(ok))
,(Z=1,f1(Y))).
ok
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
<html lang="en">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>expressions - Preliminary Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Preliminary Manual">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="parsing.html#parsing" title="parsing">
<link rel="prev" href="parser-combinators.html#parser-combinators" title="parser combinators">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<title>Preliminary Manual: expressions</title>
<meta name="description" content="Preliminary Manual: expressions">
<meta name="keywords" content="Preliminary Manual: expressions">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Index.html#Index" rel="index" title="Index">
<link href="parsing.html#parsing" rel="up" title="parsing">
<link href="sed_002fgrep.html#sed_002fgrep" rel="next" title="sed/grep">
<link href="parser-combinators.html#parser-combinators" rel="prev" title="parser combinators">
<style type="text/css">
<!--
This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body>
<div class="node">
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="expressions"></a>
<div class="header">
<p>
Previous:&nbsp;<a rel="previous" accesskey="p" href="parser-combinators.html#parser-combinators">parser combinators</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="parsing.html#parsing">parsing</a>
<hr>
Previous: <a href="parser-combinators.html#parser-combinators" accesskey="p" rel="prev">parser combinators</a>, Up: <a href="parsing.html#parsing" accesskey="u" rel="up">parsing</a> &nbsp; [<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Expressions"></a>
<h3 class="section">9.3 Expressions</h3>
<p>This is a configureable expression parser that can be used for prolog parsing as well as parsing C and C++ expressions. To note is that the data is functionally updated and hence one can store the state at will and later reinstate the parser. The parser ideom is a direct translation of the commonly described prolog parser written in prolog to guile-log. It is then extended to allow ternial operators like <code>?</code> in c as well. To use it load the module <code>(logic guile-log parsing operator-parser)</code>
</p>
<a name="Api-2"></a>
<h4 class="subsection">9.3.1 Api</h4>
<p><a name="index-make_002dopdata-236"></a><code>(make-opdata)</code>, initiates a datastructure to containe needed operator data. The result is a fluid pointing to a functional datastructure.
<p><a name="index-add_002doperator-237"></a><code>(add-operator data type name level lf)</code>, This will add operator data to the opdata fluid <code>data</code>. <code>type</code> is the type of operator e.g. any of <code>xf,yf,fx,fy,xfx,xfy,yfx</code>, as of the standard meaning of these operators in prolog. <code>name</code> is a string or symbol representing the name of the operator and <code>level</code> is the anti binding strength of the operator e.g. higher value bind less. <code>lf</code> is a parser function that represents possible values to the right of the op-symbol matched, typically this will be <code>tok-ws</code>, but also for e.g. <code>?</code> it can be a parser function matching the middle part of in this operayor which ends with <code>:</code>.
<p><a name="index-rem_002doperator-238"></a><code>(rem-operator data type name)</code>, removes from the opdata fluid <code>data</code>, the slot represented by the type <code>type</code> and the operator name <code>name</code>.
<p><a name="index-mk_002doperator_002dexpression-239"></a><code>(mk-operator-expression atom rest-atom data)</code>, will return a parser meta function representing the operator configuration in <code>data</code>, with atom parser function <code>atom</code> and a secondary choised atom if that fails in <code>rest-atom</code>. The returned meta parser function, say <code>ff</code> is typically turned into a parser function for the expression through:
<p><code>(ff high-level)</code>, with <code>high-level</code>, the highes level found in the table.
<p>The generator parser <code>f</code> can then be used to match an expression and outpits a syntactic tree with nodes according to e.g.
<pre class="verbatim">(parse ``1 + -2'' f)
-->
<a name="index-make_002dopdata"></a>
<p><code>(make-opdata)</code>, initiates a datastructure to containe needed operator data. The result is a fluid pointing to a functional datastructure.
</p>
<a name="index-add_002doperator"></a>
<p><code>(add-operator data type name level lf)</code>, This will add operator data to the opdata fluid <code>data</code>. <code>type</code> is the type of operator e.g. any of <code>xf,yf,fx,fy,xfx,xfy,yfx</code>, as of the standard meaning of these operators in prolog. <code>name</code> is a string or symbol representing the name of the operator and <code>level</code> is the anti binding strength of the operator e.g. higher value bind less. <code>lf</code> is a parser function that represents possible values to the right of the op-symbol matched, typically this will be <code>tok-ws</code>, but also for e.g. <code>?</code> it can be a parser function matching the middle part of in this operayor which ends with <code>:</code>.
</p>
<a name="index-rem_002doperator"></a>
<p><code>(rem-operator data type name)</code>, removes from the opdata fluid <code>data</code>, the slot represented by the type <code>type</code> and the operator name <code>name</code>.
</p>
<a name="index-mk_002doperator_002dexpression"></a>
<p><code>(mk-operator-expression atom rest-atom data)</code>, will return a parser meta function representing the operator configuration in <code>data</code>, with atom parser function <code>atom</code> and a secondary choised atom if that fails in <code>rest-atom</code>. The returned meta parser function, say <code>ff</code> is typically turned into a parser function for the expression through:
</p>
<p><code>(ff high-level)</code>, with <code>high-level</code>, the highes level found in the table.
</p>
<p>The generator parser <code>f</code> can then be used to match an expression and outpits a syntactic tree with nodes according to e.g.
</p><pre class="verbatim">(parse ``1 + -2'' f)
--&gt;
(('xfy ``+'' _ _) (#:number 1) (('yf ``-'' _ _) (#:number 2) 4 0) 2 0)
</pre>
<p>That is a binary oparator is of the form,
</p>
<p><code>((type operator-name level _) term-left term-right column line)</code>
</p>
<p>And a unary operator is matched by
</p>
<p><code>((type operator-name level _) term column line)</code>.
</p>
<hr>
<div class="header">
<p>
Previous: <a href="parser-combinators.html#parser-combinators" accesskey="p" rel="prev">parser combinators</a>, Up: <a href="parsing.html#parsing" accesskey="u" rel="up">parsing</a> &nbsp; [<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
<p>That is a binary oparator is of the form,
<p><code>((type operator-name level _) term-left term-right column line)</code>
<p>And a unary operator is matched by
<p><code>((type operator-name level _) term column line)</code>.
</body></html>
</body>
</html>
<html lang="en">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>garbage-collect - Preliminary Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Preliminary Manual">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="prev" href="prolog.html#prolog" title="prolog">
<link rel="next" href="Index.html#Index" title="Index">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<title>Preliminary Manual: garbage-collect</title>
<meta name="description" content="Preliminary Manual: garbage-collect">
<meta name="keywords" content="Preliminary Manual: garbage-collect">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Index.html#Index" rel="index" title="Index">
<link href="index.html#Top" rel="up" title="Top">
<link href="Index.html#Index" rel="next" title="Index">
<link href="prolog-coroutines.html#prolog-coroutines" rel="prev" title="prolog coroutines">
<style type="text/css">
<!--
This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body>
<div class="node">
<a name="garbage-collect"></a>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="garbage_002dcollect"></a>
<div class="header">
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Index.html#Index">Index</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="prolog.html#prolog">prolog</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
Next: <a href="Index.html#Index" accesskey="n" rel="next">Index</a>, Previous: <a href="prolog.html#prolog" accesskey="p" rel="prev">prolog</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Prolog-1"></a>
<h2 class="chapter">13 Prolog</h2>
<p>Guile log sports full garbage collection of logical variables which makes it suitable to run server like prolog code. It is experimental but working. Unfourtunately the bdw-gc that guile uses does not allow this to work effectively and hence you need to download and replace the standard bdw-gc with a modified version of it. You may find it at
</p>
<p><code>https://gitorious.org/bdw-gc-logical-mod</code>
</p>
<p>Now you typically build this and make sure to save the old gc.so that guile is using (you can google how to find which shared libraries guile is using) and then clobber the bdw-gc .so file with the newly created one (sic). This is of cause not a simple thing to do, but until we can get some comparable feature in bdw-gc this is what you need to do. Then finally when configureing guile log do something like
</p>
<p><code>./configure --with-logical-gc</code>
</p>
<p>And then make, make install and you will run guile-log with garbage collection on. Then on to happy hacking!.
</p>
<p>To note is that only variables and cons cells allocated from stacks will support garbage collecting. Knaren style variables is fundamentally broken with respect to this and one need for that style use other techniques like making use of return variables in functions and the small but potent hacks you may find in the kanren sources. Another option is to make use of guile-log&rsquo;s <code>&lt;call&gt;</code> that will basically only transfer the set of variables in the result essentially skiping all intermediate allocations.
</p>
<p><code>https://gitorious.org/bdw-gc-logical-mod</code>
<p>Now you typically build this and make sure to save the old gc.so that guile is using (you can google how to find which shared libraries guile is using) and then clobber the bdw-gc .so file with the newly created one (sic). This is of cause not a simple thing to do, but until we can get some comparable feature in bdw-gc this is what you need to do. Then finally when configureing guile log do something like
<p><code>./configure --with-logical-gc</code>
<p>And then make, make install and you will run guile-log with garbage collection on. Then on to happy hacking!.
<p>To note is that only variables and cons cells allocated from stacks will support garbage collecting. Knaren style variables is fundamentally broken with respect to this and one need for that style use other techniques like making use of return variables in functions and the small but potent hacks you may find in the kanren sources. Another option is to make use of guile-log's <code>&lt;call&gt;</code> that will basically only transfer the set of variables in the result essentially skiping all intermediate allocations.
</body></html>
</body>
</html>
This diff is collapsed.
<html lang="en">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Preliminary Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Preliminary Manual">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="../index.html#dir" title="(dir)">
<link rel="next" href="umatch.html#umatch" title="umatch">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<title>Preliminary Manual: Top</title>
<meta name="description" content="Preliminary Manual: Top">
<meta name="keywords" content="Preliminary Manual: Top">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="#Top" rel="start" title="Top">
<link href="Index.html#Index" rel="index" title="Index">
<link href="../dir/index.html" rel="up" title="(dir)">
<link href="umatch.html#umatch" rel="next" title="umatch">
<style type="text/css">
<!--
This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body>
<h1 class="settitle">Preliminary Manual</h1>
<div class="node">
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<h1 class="settitle" align="center">Preliminary Manual</h1>
<a name="Top"></a>
<div class="header">
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="umatch.html#umatch">umatch</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="../index.html#dir">(dir)</a>
<hr>
Next: <a href="umatch.html#umatch" accesskey="n" rel="next">umatch</a>, Up: <a href="../dir/index.html" accesskey="u" rel="up">(dir)</a> &nbsp; [<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Guile-Log"></a>
<h1 class="top">Guile Log</h1>
<p>Documentation for the Guile-Log Logic Programming Environment for Guile 2.0 v0.4
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="umatch.html#umatch" accesskey="1">umatch</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">low level infrastructure.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="guile_002dlog.html#guile_002dlog" accesskey="2">guile-log</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">This is the guile-log basic macro environment
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="acumulators_002fgenerators.html#acumulators_002fgenerators" accesskey="3">acumulators/generators</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Hot to collect and generate sequences of solutions.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="postpone.html#postpone" accesskey="4">postpone</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">To postpone a search.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="dynamics.html#dynamics" accesskey="5">dynamics</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">catch prompt abort
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="dynamic_002dfunctions.html#dynamic_002dfunctions" accesskey="6">dynamic-functions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Dynamicaly add, remove and execute clauses
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="memoizing.html#memoizing" accesskey="7">memoizing</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Memoizing and tablating and recursiviness
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="attributes.html#attributes" accesskey="8">attributes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">meta programming and customized unification
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="parsing.html#parsing" accesskey="9">parsing</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A parsing framework.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="sed_002fgrep.html#sed_002fgrep">sed/grep</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Sed and grep functionalities for scheme
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="kanren.html#kanren">kanren</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Kanren implemented ontop of guile-log
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="prolog.html#prolog">prolog</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">iso-prolog
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="garbage_002dcollect.html#garbage_002dcollect">garbage-collect</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to enable full garbage colection of logical variables
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="Index.html#Index">Index</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Complete index.
</td></tr>
</table>
<h2 class="unnumbered">Guile Log</h2>
<p>Documentation for the Guile-Log Logic Programming Environment for Guile 2.0 v0.4
<hr>
<div class="header">
<p>
Next: <a href="umatch.html#umatch" accesskey="n" rel="next">umatch</a>, Up: <a href="../dir/index.html" accesskey="u" rel="up">(dir)</a> &nbsp; [<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
<ul class="menu">
<li><a accesskey="1" href="umatch.html#umatch">umatch</a>: low level infrastructure.
<li><a accesskey="2" href="guile_002dlog.html#guile_002dlog">guile-log</a>: This is the guile-log basic macro environment
<li><a accesskey="3" href="acumulators_002fgenerators.html#acumulators_002fgenerators">acumulators/generators</a>: Hot to collect and generate sequences of solutions.
<li><a accesskey="4" href="postpone.html#postpone">postpone</a>: To postpone a search.
<li><a accesskey="5" href="dynamics.html#dynamics">dynamics</a>: catch prompt abort
<li><a accesskey="6" href="dynamic_002dfunctions.html#dynamic_002dfunctions">dynamic-functions</a>: Dynamicaly add, remove and execute clauses
<li><a accesskey="7" href="memoizing.html#memoizing">memoizing</a>: Memoizing and tablating and recursiviness
<li><a accesskey="8" href="attributes.html#attributes">attributes</a>: meta programming and customized unification
<li><a accesskey="9" href="parsing.html#parsing">parsing</a>: A parsing framework.
<li><a href="sed_002fgrep.html#sed_002fgrep">sed/grep</a>: Sed and grep functionalities for scheme
<li><a href="kanren.html#kanren">kanren</a>: Kanren implemented ontop of guile-log
<li><a href="prolog.html#prolog">prolog</a>: iso-prolog
<li><a href="garbage_002dcollect.html#garbage_002dcollect">garbage-collect</a>: How to enable full garbage colection of logical variables
<li><a href="Index.html#Index">Index</a>: Complete index.
</ul>
</body></html>
</body>
</html>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<html lang="en">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>postpone - Preliminary Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Preliminary Manual">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="prev" href="acumulators_002fgenerators.html#acumulators_002fgenerators" title="acumulators/generators">
<link rel="next" href="dynamics.html#dynamics" title="dynamics">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<title>Preliminary Manual: postpone</title>
<meta name="description" content="Preliminary Manual: postpone">
<meta name="keywords" content="Preliminary Manual: postpone">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Index.html#Index" rel="index" title="Index">
<link href="index.html#Top" rel="up" title="Top">
<link href="dynamics.html#dynamics" rel="next" title="dynamics">
<link href="acumulators_002fgenerators.html#acumulators_002fgenerators" rel="prev" title="acumulators/generators">
<style type="text/css">
<!--
This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body>
<div class="node">
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="postpone"></a>
<div class="header">
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="dynamics.html#dynamics">dynamics</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="acumulators_002fgenerators.html#acumulators_002fgenerators">acumulators/generators</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
Next: <a href="dynamics.html#dynamics" accesskey="n" rel="next">dynamics</a>, Previous: <a href="acumulators_002fgenerators.html#acumulators_002fgenerators" accesskey="p" rel="prev">acumulators/generators</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Postpone_002c-a-framework-for-postponing-guile_002dlog-evaluations_002e"></a>
<h2 class="chapter">4 Postpone, a framework for postponing guile-log evaluations.</h2>
<p>This code is available from <code>(logic guile-log postpone)</code> You may have noticed that guile log is a framework to do tree searches to meet a certain criteria and during the path in the tree create data structures that are able to undo and also redo it's state. Most people when approaching this will sooner or later be bitten by the NP hardness of many interesting problems. The solution might then be to try intelligent guesses in which branch the gold is hiding. What one would like to do is try a set of branches, freeze the different states and at that point create some sort of index that represent the likelihood of the gold lying buried beneath. Then an overall global decision can be taken and only the most promising paths will be further examined. It is for this use case the following system is constructed. Postpone mix well with the rest of prolog, but especially the <code>&lt;zip&gt;</code>, forms might behave unexpectedly due to teh postpone mechansim interfering with the synch and produce bad result.
<p>This code is available from <code>(logic guile-log postpone)</code> You may have noticed that guile log is a framework to do tree searches to meet a certain criteria and during the path in the tree create data structures that are able to undo and also redo it&rsquo;s state. Most people when approaching this will sooner or later be bitten by the NP hardness of many interesting problems. The solution might then be to try intelligent guesses in which branch the gold is hiding. What one would like to do is try a set of branches, freeze the different states and at that point create some sort of index that represent the likelihood of the gold lying buried beneath. Then an overall global decision can be taken and only the most promising paths will be further examined. It is for this use case the following system is constructed. Postpone mix well with the rest of prolog, but especially the <code>&lt;zip&gt;</code>, forms might behave unexpectedly due to teh postpone mechansim interfering with the synch and produce bad result.
</p>
<a name="Api_002e"></a>
<h3 class="section">4.1 Api.</h3>
<a name="index-postpone"></a>
<a name="index-postpone_002dframe"></a>
<p><a name="index-postpone-171"></a><a name="index-postpone_002dframe-172"></a>
<pre class="verbatim">G.L. (postpone val power)
G.L. (postpone-frame limit fact maxsize)
</pre>
To be able to postpone we must have a baseline from which we will base our restarts e.g. <code>postpone-frame</code>. The <code>postpone</code> command will basically evaluate <code>val</code> and postpone if it's larger then a certain limit that is governed by an initial value <code>limit</code> and <code>fact</code> - a factor that adds to the limit each postpone turn. The <code>power</code> is the sorting index used to manage a list of possible restarts for and this list is sorted so that we at restarts will try to use <code>maxsize</code> first elements of the list. The list is never larger then <code>10 * maxsize</code>.
</pre><p>To be able to postpone we must have a baseline from which we will base our restarts e.g. <code>postpone-frame</code>. The <code>postpone</code> command will basically evaluate <code>val</code> and postpone if it&rsquo;s larger then a certain limit that is governed by an initial value <code>limit</code> and <code>fact</code> - a factor that adds to the limit each postpone turn. The <code>power</code> is the sorting index used to manage a list of possible restarts for and this list is sorted so that we at restarts will try to use <code>maxsize</code> first elements of the list. The list is never larger then <code>10 * maxsize</code>.
</p>
<hr>
<div class="header">
<p>
Next: <a href="dynamics.html#dynamics" accesskey="n" rel="next">dynamics</a>, Previous: <a href="acumulators_002fgenerators.html#acumulators_002fgenerators" accesskey="p" rel="prev">acumulators/generators</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p>
</div>
</body></html>
</body>
</html>
<html lang="en">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>prolog - Preliminary Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Preliminary Manual">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="prev" href="kanren.html#kanren" title="kanren">
<link rel="next" href="garbage_002dcollect.html#garbage_002dcollect" title="garbage-collect">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<title>Preliminary Manual: prolog</title>
<meta name="description" content="Preliminary Manual: prolog">
<meta name="keywords" content="Preliminary Manual: prolog">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Index.html#Index" rel="index" title="Index">
<link href="index.html#Top" rel="up" title="Top">
<link href="running.html#running" rel="next" title="running">
<link href="kanren.html#kanren" rel="prev" title="kanren">
<style type="text/css">
<!--
This is a preliminary manual of guile-log package for guile-2.0
Copyright (C) 2012 Stefan Israelsson Tampe-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: