writeq works

parent fae6fc4f
......@@ -1805,30 +1805,39 @@ We can insert scheme expressions with the construct @code{scm[sexp]}. You can in
@node closures
@section closures in prolog
Closures is an interesting construct a schemer can't stay away from and we support theme in guile-log. There is a complication with logic programs, when we comparing closures we compare code, they may differ, but still produce the same logic hence when there is a high demand to find all solutions, e.g. the predicate is closed, we may produce the wrong answer. Unfourtunately it's impossible to verify if the closures logically are the same or not and hence we will need to in some circumstances throw an error when such a unification is under action. Also when unifying closures we need to open up the closures and unify the state as well. Also we support that quoted writes can read in the closures correctly with the straightforward logic. Also when we @code{assert*()} code that includes closures they will be compiled and handled just as with writes, e.g. the state of the code will be the world and connection outside that world will be lost e.g. in
Closures is an interesting construct a schemer can't stay away from and we support theme in guile-log. There is a complication with logic programs though, when we are comparing closures we compare code, they may differ, but still produce the same logic hence when there is a high demand to find all solutions, e.g. the predicate is closed, we may produce the wrong answer. Unfourtunately it's impossible to verify if the closures logically are the same or not and hence we will need to in some circumstances throw an error when such a unification is under action. Also when unifying closures we need to open up the closures and unify the state as well. We also support that quoted writes can read in the closures correctly with the straightforward logic of the logic beeing defined by the term. Also when we @code{assert*()} code that includes closures they will be compiled and handled just as with writes, e.g. the state of the code will be the world and connection outside that world will be lost e.g. in
@verbatim
f(X) :- Y=_,asserta(g :- {var(Y)}.),g.
@end verbatim
@code{Y} will be onbound although the @code{var(Y)} refers to the outside variable @code{Y}.
@code{Y} will be unbound although the @code{var(Y)} refers to the outside variable @code{Y}.
The semantic of the closure creation is basically through code inside curly brackets that are plased inside the code segments in prolog and will generate closure objects that can be treated just as with normal data. To define a closure that is closed used two curly braces e.g. @code{@{@{...def...@}@}}. The definition can be normal prolog definitions, and the last predicate will name and sellect
the code that will represent the closure. All other functions will represent local names and will not be reachable e.g. in
The semantic of the closure creation is basically through code inside curly brackets that defined the closure and it is placed at the code segments in prolog and the generated closure objects that can be treated just as with normal data. To define a closure that is closed used two curly braces e.g. @code{@{@{...def...@}@}}. The definition can be normal prolog definitions, and the last predicate will name and sellect the code that will represent the closure. All other functions will represent local names and will not be reachable e.g. in
@verbatim
f :- Y=_, h({{ a(X) : X=v(Y).
b(X) : Z=[v[Y],1],a(Z).
f :- Y=_, h({{ a(X) :- X=v(Y).
b(X) :- Z=[v[Y],1],a(Z).
}}).
@end verbatim
Then @code{a} is local and @code{b} will create a parent name of the closure which will be defined in the current module. The closure is closed and hence if @code{h} unifies the closure with another closure an error (that is controllable) may be thrown in case of backtracking. There is a posibilit to force a name on a closure by preficing the curly braces with a named symbol. Then the code with the matching name in the definitions will be used or for an annonymous construction it will name the annonymous code. Else if no name is supplied a automatically generated symbol will be used instead. There is two annanymous versions of one liners that can be used, for closures with arguments use e.g. @code{clos1@{A,B|...code...@}} and with no argument just use @code{clos2@{...code...@}}. To refere to a variable in the closest outer context use @code{var[X]}, or @code{v[X]}. Do not refere to global variables, that is dangerous and for that use @code{scm[X]}.
Then @code{a} is local and @code{b} will create a parent name of the closure which will be defined in the current module. The closure is closed and hence if @code{h} unifies the closure with another closure an error (that's controllable) may be thrown or it may backtrack. There is a possibility to force a name on a closure by prefixing the curly braces with a named symbol. Then the code with the one associated with matching name in the definition will be used unless the closure is a one liner annonymous construction, then it will name the annonymous code. Else for an annonymous closure if no name is supplied as a prefix a automatically generated symbol will be used instead. There is two annonymous versions of one liners that can be used, for closures with arguments use e.g. @code{clos1@{A,B|...code...@}} and with no argument just use @code{clos2@{...code...@}}. To refere to a variable in the closest outer context, where it is defined, use @code{var[X]}, or @code{v[X]}. Do not refere to global variables, that will throw an error, for that use @code{scm[X]} in which case the logic is flawed, don't practice this for logic programs.
To control the behavior of unification of closed closures, we will have the following api found in @code{[use-modules (logic guile-log prolog closed)]}.,
@code{prolog (error_at_closed_p_handle Handle)}, thei predicate fetches a Handle that is a fluid, then use @code{fluid_set}, to set the value. Also this handle can be guarded by the ideoms in the section about dynamic features so it is really simple to restrict the value to just one part of the code. For a @code{true} value of the handle, error will happen at a code missmatch in a unification with at least one closed closure, and else if @code{false}, backtracking will result or success if the negaiton is used.
@code{prolog error_at_closed_p_handle(Handle)}, this predicate fetches a handle that represent the predicate of issuing a fail at non matching unification of the codes part of a closed closure. This handle can be guarded by the ideoms in the section about dynamic features so it is really simple to restrict the value to just one part of the code. For a @code{true} value of the handle, error will happen at a code missmatch in a unification with at least one closed closure, and else if @code{false}, backtracking will result.
@code{prolog close_error_true/0 close_error_false/0}, these are convinience funcitons to turn the
@code{prolog close_error_true/0 close_error_false/0}, use these funcitons to turn on/off the throwing of error at unification missmatcehs of closed closures code part.
To reflect the closure we have from @code{[use-modules (logic guile-log guile-prolog closures)]}, and api.
@code{prolog closure_p(Cl)}, true if @code{Cl} is a closure.
@code{prolog closure_state_ref(Cl,L)}, will expose the state of the closure @code{Cl} into @code{L}.
@code{prolog closure_is_closed(Cl)}, true if @code{Cl} is a closed closure.
@code{prolog closure_code_ref(Cl,F)}, will expose the code of the closure @code{Cl} into @code{F}.
@node prolog-dynamic-functions
@section Explaing the guile-log dynamic functions
......
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.1, 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="previous" 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="previous">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">7.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">7.3.1 Api</h4>
<p><a name="index-make_002dopdata-217"></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-218"></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-219"></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-220"></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="previous">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>
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.1, 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="parsing.html#parsing" accesskey="7">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" accesskey="8">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" accesskey="9">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="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="parsing.html#parsing">parsing</a>: A parsing framework.
<li><a accesskey="8" href="sed_002fgrep.html#sed_002fgrep">sed/grep</a>: Sed and grep functionalities for scheme
<li><a accesskey="9" 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="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.1, 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="previous" 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="previous">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="previous">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.1, 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="Index.html#Index" title="Index">
<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="previous" 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: 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="prolog"></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="kanren.html#kanren">kanren</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="kanren.html#kanren" accesskey="p" rel="previous">kanren</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"></a>
<h2 class="chapter">10 Prolog</h2>
<p>Guile log sports also a iso-prolog interface as a logic programming interface besides kanren. The interface is pretty complete at this point appart a few points that have not yet been resolved but shure it is alpha software. With this most programs written in iso prolog should work. The intention is to enhance this interface so that the bulk of already written prolog programs should be able to be run on guile. We will also add the fetures unique to guile-log and hence enhance the prolog experience. Featurewise guile-log prolog is taking over many properties of scheme like closures, continuations, delimeted continuations, the interleaving constructs of kanren and a delicate system to treat dynamic objects like dynamic functions, dynamic hashes and a well thought out library to tell how you want the dynamism to work at a very fine grained level.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="running.html#running" accesskey="1">running</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to hook in prolog code
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="deviations.html#deviations" accesskey="2">deviations</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">What is different and not according to standard and why.
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="modules.html#modules" accesskey="3">modules</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to handle name spacing
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="scheme.html#scheme" accesskey="4">scheme</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Hooking in scheme expressions
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="closures.html#closures" accesskey="5">closures</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Using closures in prolog
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="prolog_002ddynamic_002dfunctions.html#prolog_002ddynamic_002dfunctions" accesskey="6">prolog-dynamic-functions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A discussion of guile log&rsquo;s version of this
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="dynamic_002dfeatures.html#dynamic_002dfeatures" accesskey="7">dynamic-features</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Special construct to manage dynamic objects
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="prolog_002dlibraries.html#prolog_002dlibraries" accesskey="8">prolog-libraries</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Libraries that exposes guile-log features
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="internals.html#internals" accesskey="9">internals</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A short discussion of the prolog internals used.
</td></tr>
</table>
<hr>
<div class="header">
<p>
Next: <a href="Index.html#Index" accesskey="n" rel="next">Index</a>, Previous: <a href="kanren.html#kanren" accesskey="p" rel="previous">kanren</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>
<ul class="menu">
<li><a accesskey="1" href="running.html#running">running</a>: How to hook in prolog code
<li><a accesskey="2" href="deviations.html#deviations">deviations</a>: What is different and not according to standard and why.
<li><a accesskey="3" href="modules.html#modules">modules</a>: How to handle name spacing
<li><a accesskey="4" href="scheme.html#scheme">scheme</a>: Hooking in scheme expressions
<li><a accesskey="5" href="closures.html#closures">closures</a>: Using closures in prolog
<li><a accesskey="6" href="prolog_002ddynamic_002dfunctions.html#prolog_002ddynamic_002dfunctions">prolog-dynamic-functions</a>: A discussion of guile log's version of this
<li><a accesskey="7" href="dynamic_002dfeatures.html#dynamic_002dfeatures">dynamic-features</a>: Special construct to manage dynamic objects
<li><a accesskey="8" href="prolog_002dlibraries.html#prolog_002dlibraries">prolog-libraries</a>: Libraries that exposes guile-log features
<li><a accesskey="9" href="internals.html#internals">internals</a>: A short discussion of the prolog internals used.
</ul>
</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.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>sed/grep - 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="parsing.html#parsing" title="parsing">
<link rel="next" href="kanren.html#kanren" title="kanren">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<title>Preliminary Manual: sed/grep</title>
<meta name="description" content="Preliminary Manual: sed/grep">
<meta name="keywords" content="Preliminary Manual: sed/grep">
<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="kanren.html#kanren" rel="next" title="kanren">
<link href="expressions.html#expressions" rel="previous" title="expressions">
<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}