html added as well

parent 9976237f
Stefan Israelsson Tampe: stefan.itampe@gmail.com
\ No newline at end of file
Version 0.3
* Faster and more thorough implementation of guarded variables.
* Fluids following the guile-log stack.
* Acumulators.
* and much more
Version 0.4
* Fast and scalable vhash version of the assoc variable binding system, OK-
* Functional Dynamic Functions, OK
* Functional Hash implementation using vhashes, OK-,
* Program flow dynamic varible analytics OK-.
* An iso prolog implementation, OK.
* Delimeted continuations, OK.
* A catch and throw system. OK.
* Tabling or memoization features Not yet implemented
\ No newline at end of file
/usr/local/share/automake-1.13/INSTALL
\ No newline at end of file
......@@ -65,6 +65,7 @@ SOURCES = \
logic/guile-log/guile-prolog/hash.scm \
logic/guile-log/guile-prolog/interleave.scm
info_TEXINFOS = doc/guile-log.texi
AM_MAKEINFOFLAGS=--force
AM_MAKEINFOHTMLFLAGS=--force
info_TEXINFOS = doc/guile-log.texi
EXTRA_DIST += env.in COPYING
......@@ -2,17 +2,24 @@ Prerequisits
This is a draft for guile-2.0.6 and later and works for linux.
You need to have guile-syntax-parse installed
You need to have guile-syntax-parse installed into the system
http://gitorious.org/guile-syntax-parse/guile-syntax-parse
Add this directory to guiles load-path
Install:
Go to main directory
issue
bash make.sh
Either do a system install:
============
autoreconfig
configure
make
make install
Or do a local install by:
============
autoreconfig
configure
make
add the repo directory to guile's load path
------------------------------------------------
Now you are ready to use it from guile through,
> (use-modules (logic guile-log))
......@@ -23,6 +30,15 @@ Or using the kanren interface
Html Docs: point a browser at doc/guile-log/index.html
Or iso-prolog,
> (use-modules (logic guile-log iso-prolog))
For documentation,
info guile-log at a system install.
Else in doc/guile-log the documentation in html is available
Have fun!
......
<html lang="en">
<head>
<title>acumulators - 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 href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
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>
</head>
<body>
<div class="node">
<a name="acumulators"></a>
<p>
<hr>
</div>
<h2 class="chapter">7 Overview</h2>
<p>In the guile-log chapter we defined the basic framework to fold a sequence of solutions into a variable. With this we can support e.g prolog's bagof and similar constructs. In the module <code>(guile-log logic collects)</code>, we have defined a few specialisations of the fold operator in order to standardize these common abstractions.
<h2 class="chapter">8 Api</h2>
<p>To explain the Api we have a <code>gl-thunk</code>, e.g. a guile-log lambda with zero arguments. <code>it</code>, will be the pattern to store. when it successes typically this variable will be copied and added to the resulting data structure which is <code>list, sum, ...</code>. There is a possibility to keep some elements fixed and this is the <code>-2</code> forms with the variable <code>fixed</code> naming the variable that needs to be fixated. e.g. first all solutions for the first found representation of the variable <code>fixed</code> will be found and added, then the then all solutions with the next found variant of the <code>fixed</code> will be used and so on, very much like how bagof in prolog is working. The <code>-step</code> versions of the acumulators will produce produce all the intermediate acumulator solutions.
<p><a name="index-g_t_003ccollect_003e-129"></a><a name="index-g_t_003ccollect_002d2_003e-130"></a><a name="index-g_t_003ccollect_002dstep_003e-131"></a><a name="index-g_t_003ccollect_002dstep_002d2_003e-132"></a>The following forms will cons all solutions to a list e.g. prodice lists in
reverse order.
<p><code>G.L. (&lt;collect&gt; gl-thunk it list)</code>
<p><code>G.L. (&lt;collect-2&gt; gl-thunk it fixed list)</code>
<p><code>G.L. (&lt;collect-step&gt; gl-thunk it list)</code>
<p><code>G.L. (&lt;collect-step-2&gt; gl-thunk it fixed list)</code>
<p>&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&ndash;
<p><a name="index-g_t_003csum_003e-133"></a><a name="index-g_t_003csum_002d2_003e-134"></a><a name="index-g_t_003csum_002dstep_003e-135"></a><a name="index-g_t_003csum_002dstep_002d2_003e-136"></a>The following forms will sum all solutions.
<p><code>G.L. (&lt;collect&gt; gl-thunk it sum)</code>
<p><code>G.L. (&lt;collect-2&gt; gl-thunk it fixed sum)</code>
<p><code>G.L. (&lt;collect-step&gt; gl-thunk it sum)</code>
<p><code>G.L. (&lt;collect-step-2&gt; gl-thunk it fixed sum)</code>
<p>&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;
<p><a name="index-g_t_003cprod_003e-137"></a><a name="index-g_t_003cprod_002d2_003e-138"></a><a name="index-g_t_003cprod_002dstep_003e-139"></a><a name="index-g_t_003cprod_002dstep_002d2_003e-140"></a>The following forms will take the product of all solutins
<p><code>G.L. (&lt;collect&gt; gl-thunk it prod)</code>
<p><code>G.L. (&lt;collect-2&gt; gl-thunk it fixed prod)</code>
<p><code>G.L. (&lt;collect-step&gt; gl-thunk it prod)</code>
<p><code>G.L. (&lt;collect-step-2&gt; gl-thunk it fixed prod)</code>
<p>&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&ndash;
<p><a name="index-g_t_003cmax_003e-141"></a><a name="index-g_t_003cmax_002d2_003e-142"></a><a name="index-g_t_003cmax_002dstep_003e-143"></a><a name="index-g_t_003cmax_002dstep_002d2_003e-144"></a>The following forms will take the max of all solutions.
<p><code>G.L. (&lt;max&gt; gl-thunk it max)</code>
<p><code>G.L. (&lt;max-2&gt; gl-thunk it fixed max)</code>
<p><code>G.L. (&lt;max-step&gt; gl-thunk it max)</code>
<p><code>G.L. (&lt;max-step-2&gt; gl-thunk it fixed max)</code>
<p>&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&ndash;
<p><a name="index-g_t_003cmin_003e-145"></a><a name="index-g_t_003cmin_002d2_003e-146"></a><a name="index-g_t_003cmin_002dstep_003e-147"></a><a name="index-g_t_003cmin_002dstep_002d2_003e-148"></a>The following forms will take the max of all solutions.
<p><code>G.L. (&lt;min&gt; gl-thunk it min)</code>
<p><code>G.L. (&lt;min-2&gt; gl-thunk it fixed min)</code>
<p><code>G.L. (&lt;min-step&gt; gl-thunk it min)</code>
<p><code>G.L. (&lt;min-step-2&gt; gl-thunk it fixed min)</code>
<p>&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&ndash;
<p><a name="index-g_t_003csoland_003e-149"></a><a name="index-g_t_003csoland_002d2_003e-150"></a><a name="index-g_t_003csoland_002dstep_003e-151"></a><a name="index-g_t_003csoland_002dstep_002d2_003e-152"></a>The following forms will take the and of all operations returning the last one
as a solution.
<p><code>G.L. (&lt;soland&gt; gl-thunk it and)</code>
<p><code>G.L. (&lt;soland-2&gt; gl-thunk it fixed and)</code>
<p><code>G.L. (&lt;soland-step&gt; gl-thunk it and)</code>
<p><code>G.L. (&lt;soland-step-2&gt; gl-thunk it fixed and)</code>
<p>&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&ndash;
<p><a name="index-g_t_003csolor_003e-153"></a><a name="index-g_t_003csolor_002d2_003e-154"></a><a name="index-g_t_003csolor_002dstep_003e-155"></a><a name="index-g_t_003csolor_002dstep_002d2_003e-156"></a>The following forms will take the or of all operations returning the first solution.
<p><code>G.L. (&lt;solor&gt; gl-thunk it or)</code>
<p><code>G.L. (&lt;solor-2&gt; gl-thunk it fixed or)</code>
<p><code>G.L. (&lt;solor-step&gt; gl-thunk it or)</code>
<p><code>G.L. (&lt;solor-step-2&gt; gl-thunk it fixed or)</code>
<p>&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&ndash;
</body></html>
<html lang="en">
<head>
<title>acumulators/generators - 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="guile_002dlog.html#guile_002dlog" title="guile-log">
<link rel="next" href="postpone.html#postpone" title="postpone">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
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>
</head>
<body>
<div class="node">
<a name="acumulators%2fgenerators"></a>
<a name="acumulators_002fgenerators"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="postpone.html#postpone">postpone</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="guile_002dlog.html#guile_002dlog">guile-log</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
</div>
<h2 class="chapter">9 Overview</h2>
<p>In the guile-log chapter we defined the basic framework to fold a sequence of solutions into a variable. With this we can support e.g prolog's bagof and similar constructs. In the module <code>(guile-log logic collects)</code>, we have defined a few specialisations of the fold operator in order to standardize these common abstractions.
<h2 class="chapter">10 Acumulators API</h2>
<p>To explain the Api we have a <code>gl-thunk</code>, e.g. a guile-log lambda with zero arguments. <code>it</code>, will be the pattern to store. when it successes typically this variable will be copied and added to the resulting data structure which is <code>list, sum, ...</code>. There is a possibility to keep some elements fixed and this is the <code>-2</code> forms with the variable <code>fixed</code> naming the variable that needs to be fixated. e.g. first all solutions for the first found representation of the variable <code>fixed</code> will be found and added, then the then all solutions with the next found variant of the <code>fixed</code> will be used and so on, very much like how bagof in prolog is working. The <code>-step</code> versions of the acumulators will produce produce all the intermediate acumulator solutions.
<p><a name="index-g_t_003ccollect_003e-151"></a><a name="index-g_t_003ccollect_002d2_003e-152"></a><a name="index-g_t_003ccollect_002dstep_003e-153"></a><a name="index-g_t_003ccollect_002dstep_002d2_003e-154"></a>The following forms will cons all solutions to a list e.g. prodice lists in
reverse order.
<p><code>G.L. (&lt;collect&gt; gl-thunk it list)</code>
<p><code>G.L. (&lt;collect-2&gt; gl-thunk it fixed list)</code>
<p><code>G.L. (&lt;collect-step&gt; gl-thunk it list)</code>
<p><code>G.L. (&lt;collect-step-2&gt; gl-thunk it fixed list)</code>
<p>&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&ndash;
<p><a name="index-g_t_003csum_003e-155"></a><a name="index-g_t_003csum_002d2_003e-156"></a><a name="index-g_t_003csum_002dstep_003e-157"></a><a name="index-g_t_003csum_002dstep_002d2_003e-158"></a>The following forms will sum all solutions.
<p><code>G.L. (&lt;collect&gt; gl-thunk it sum)</code>
<p><code>G.L. (&lt;collect-2&gt; gl-thunk it fixed sum)</code>
<p><code>G.L. (&lt;collect-step&gt; gl-thunk it sum)</code>
<p><code>G.L. (&lt;collect-step-2&gt; gl-thunk it fixed sum)</code>
<p>&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;
<p><a name="index-g_t_003cprod_003e-159"></a><a name="index-g_t_003cprod_002d2_003e-160"></a><a name="index-g_t_003cprod_002dstep_003e-161"></a><a name="index-g_t_003cprod_002dstep_002d2_003e-162"></a>The following forms will take the product of all solutins
<p><code>G.L. (&lt;collect&gt; gl-thunk it prod)</code>
<p><code>G.L. (&lt;collect-2&gt; gl-thunk it fixed prod)</code>
<p><code>G.L. (&lt;collect-step&gt; gl-thunk it prod)</code>
<p><code>G.L. (&lt;collect-step-2&gt; gl-thunk it fixed prod)</code>
<p>&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&ndash;
<p><a name="index-g_t_003cmax_003e-163"></a><a name="index-g_t_003cmax_002d2_003e-164"></a><a name="index-g_t_003cmax_002dstep_003e-165"></a><a name="index-g_t_003cmax_002dstep_002d2_003e-166"></a>The following forms will take the max of all solutions.
<p><code>G.L. (&lt;max&gt; gl-thunk it max)</code>
<p><code>G.L. (&lt;max-2&gt; gl-thunk it fixed max)</code>
<p><code>G.L. (&lt;max-step&gt; gl-thunk it max)</code>
<p><code>G.L. (&lt;max-step-2&gt; gl-thunk it fixed max)</code>
<p>&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&ndash;
<p><a name="index-g_t_003cmin_003e-167"></a><a name="index-g_t_003cmin_002d2_003e-168"></a><a name="index-g_t_003cmin_002dstep_003e-169"></a><a name="index-g_t_003cmin_002dstep_002d2_003e-170"></a>The following forms will take the max of all solutions.
<p><code>G.L. (&lt;min&gt; gl-thunk it min)</code>
<p><code>G.L. (&lt;min-2&gt; gl-thunk it fixed min)</code>
<p><code>G.L. (&lt;min-step&gt; gl-thunk it min)</code>
<p><code>G.L. (&lt;min-step-2&gt; gl-thunk it fixed min)</code>
<p>&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&ndash;
<p><a name="index-g_t_003csoland_003e-171"></a><a name="index-g_t_003csoland_002d2_003e-172"></a><a name="index-g_t_003csoland_002dstep_003e-173"></a><a name="index-g_t_003csoland_002dstep_002d2_003e-174"></a>The following forms will take the and of all operations returning the last one
as a solution.
<p><code>G.L. (&lt;soland&gt; gl-thunk it and)</code>
<p><code>G.L. (&lt;soland-2&gt; gl-thunk it fixed and)</code>
<p><code>G.L. (&lt;soland-step&gt; gl-thunk it and)</code>
<p><code>G.L. (&lt;soland-step-2&gt; gl-thunk it fixed and)</code>
<p>&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&ndash;
<p><a name="index-g_t_003csolor_003e-175"></a><a name="index-g_t_003csolor_002d2_003e-176"></a><a name="index-g_t_003csolor_002dstep_003e-177"></a><a name="index-g_t_003csolor_002dstep_002d2_003e-178"></a>The following forms will take the or of all operations returning the first solution.
<p><code>G.L. (&lt;solor&gt; gl-thunk it or)</code>
<p><code>G.L. (&lt;solor-2&gt; gl-thunk it fixed or)</code>
<p><code>G.L. (&lt;solor-step&gt; gl-thunk it or)</code>
<p><code>G.L. (&lt;solor-step-2&gt; gl-thunk it fixed or)</code>
<h2 class="chapter">11 Local Non backtracking Genrators API</h2>
<p>This tool is found directly in the module <code>(logic guile-log)</code>,
<p><code>G.L. (&lt;with-generators&gt; ((var init) ...) code ...)</code>, This will bound the variables <code>var ...</code> initiated to <code>init ...</code> inside <code>code ...</code>.
<p>These variables can then be changed by using <code>set!</code> and if the updating is functional, the state of the variables will be managed and store and restore will be managed in such a way that jumping below the initiation with <code>&lt;with-generators&gt;</code> and back will produce the same values, but inside this form it will not be restored to the old value. Especially a simple generator can be applied by using,
<p><code>G.L. (&lt;next-generator-value&gt; sum var val)</code>, e.g. perform <code>var &lt;- (sum var val)</code> each time this line is executed and no backtracking will be done.
&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&ndash;
</body></html>
<html lang="en">
<head>
<title>database - 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="dynamic_002dfunctions.html#dynamic_002dfunctions" title="dynamic-functions">
<link rel="next" href="parsing.html#parsing" title="parsing">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
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>
</head>
<body>
<div class="node">
<a name="database"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="parsing.html#parsing">parsing</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="dynamic_002dfunctions.html#dynamic_002dfunctions">dynamic-functions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
</div>
<h2 class="chapter">14 database</h2>
<p>Anything prolog like means that we need some kind of database for matching. And one such tool is included in guile-log. This is not a dynamic databas but one that we only can add elements and then compile and use it for lookup. It has some optimizations in it to be effective at looking the elements up still maintaining the introduced orders.
<h3 class="section">14.1 Api</h3>
<p><code>Scm (make-matcher-env)</code>, this will make a matcher db object.
<p><code>Scm (matcher-add db x y)</code>, this will add <code>x-&gt;y</code> in <code>db</code> this is nonfunctional object oriented way of treating db.
<p><code>Scm (get-matcher-db db)</code>, yield the db inside the matcher.
<p><code>Scm (compile-matcher)</code>, yield a compiled matcher for which we can work with. The resulting matcher will yield a list of nodes that matches a and that can be unified against in order to yield the prolog like db lookup.
<p><code>G.L. (&lt;db-lookup&gt; db x y)</code>, this will lookup <code>x</code> in the compiled database <code>db</code> and yield <code>y</code> as a result of the stored pairs <code>x-&gt;y</code>.
</body></html>
<html lang="en">
<head>
<title>dynamic-funcitons - 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 href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
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>
</head>
<body>
<div class="node">
<a name="dynamic-funcitons"></a>
<a name="dynamic_002dfuncitons"></a>
<p>
<hr>
</div>
<h2 class="chapter">1 Overview</h2>
<p>An interesting category of functionality in prolog is their dynamic function framework. They are a generalization of databases and allow to do matching in a scalable manner through indexing. Guile log also support a full indexer for a simplified matcher. And for all matched clauses they will be executed in order acording to how the database is setuped. One can add clauses to the head or to the end, remove clauses according to a pattern and also store states for later rewinding. The state guarding mechanism is either cheap (weak) e.g. it will not remember states as long as the action is above in the stack, else if it backtracks below the stack, state will be stored and restored at reentrence. We also support strong state storage at e.g. postpone support.
<h2 class="chapter">2 Api</h2>
<p><a name="index-define_002ddynamic-1"></a><a name="index-g_t_003cpush_002ddynamic_003e-2"></a><a name="index-g_t_003clambda_002ddyn_003e-3"></a><a name="index-g_t_003cappend_002ddynamic_003e-4"></a><a name="index-g_t_003cremove_002ddynamic_003e-5"></a><code>SCM (define-dynamic f)</code>, this will make a dynamic function object and bind it to <code>f</code>
<p><code>G.L. (&lt;push-dynamic&gt; f lambda-dyn)</code>, push a match onto the head of dynamic function <code>f</code>. <code>lambda-dyn</code> is a special lambda typically created through,
<p><code>SCM (&lt;lambda-dyn&gt; pat ... code)</code>, here <code>pat ...</code> will be simplified patterns only supporting <code>quote,unquote</code> all else directive is not allowed. <code>code</code> is evaluated in guile-log mode.
<p>Similarly we can add code to the end of the dynamic function, e.g.
<p><code>G.L. (&lt;append-dynamic&gt; f lambda-dyn)</code>.
<p>Also to remove elements one can use,
<p><code>G.L. (&lt;remove-dynamic&gt; (f a ...))</code>, where <code>f</code> is the dynamic function and <code>a ...</code> the patterns for the arguments that, which matches will be retracted.
<p><a name="index-g_t_003cwith_002ddynamic_002dfunctions_003e-6"></a><a name="index-g_t_003cguard_002ddynamic_002dfunctions_003e-7"></a>The previous set of API is typically what you get to use in prolog. The
downsise is that they posses problem w.r.t. leaking data and therefor the next ideom is preferable to use in order to make sure both that one undo any changes to the dynamic variable, but also at reinstation of a state inside the form, it will resore to the same state as when control left the inner of the ideom e.g.
<p><code>G.L. (&lt;with-dynamic-functions&gt; (f ...) code ...)</code>, for this form <code>f ...</code>, will be weakly guarded throughout the form e.g. if control leaves the form at then the state is stored id needed and at reinstationa state inside <code>code ...</code>, the old state of the dynamic variable will be reinstated. But inside the form nothing is done with the state of teh dynamic functions.
<p>A stronger form of guard can be used in case one would like to make sure that the dynamic functions state can be reinstated in case of e.g. postpone is used, then use,
<p><code>G.L. </code> (&lt;guard-dynamic-functions&gt; (f ...) code ...),
<p>Finally the last section conserns the ability to compile the dynamic function for as fast lookup as possible, use
<p><a name="index-g_t_003cdynamic_002dcompile_003e-8"></a><code>G.L. (&lt;dynamic-compile&gt; f ...)</code>, comiles the dynamic functions <code>f ...</code> for fast lookup. This ideom takes time and if used freely can cause a high memory consumption.
</body></html>
<html lang="en">
<head>
<title>dynamic-functions - 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="dynamics.html#dynamics" title="dynamics">
<link rel="next" href="database.html#database" title="database">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
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>
</head>
<body>
<div class="node">
<a name="dynamic-functions"></a>
<a name="dynamic_002dfunctions"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="database.html#database">database</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="dynamics.html#dynamics">dynamics</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
</div>
<h2 class="chapter">1 Overview</h2>
<p>An interesting category of functionality in prolog is their dynamic function framework. They are a generalization of databases and allow to do matching in a scalable manner through indexing. Guile log also support a full indexer for a simplified matcher. And for all matched clauses they will be executed in order acording to how the database is setuped. One can add clauses to the head or to the end, remove clauses according to a pattern and also store states for later rewinding. The state guarding mechanism is either cheap (weak) e.g. it will not remember states as long as the action is above in the stack, else if it backtracks below the stack, state will be stored and restored at reentrence. We also support strong state storage at e.g. postpone support.
<p>To use the api use <code>(use-modules (logic guile-log functional-database))</code>.
<h2 class="chapter">2 Api</h2>
<p><a name="index-define_002ddynamic-1"></a><a name="index-g_t_003cpush_002ddynamic_003e-2"></a><a name="index-g_t_003clambda_002ddyn_003e-3"></a><a name="index-g_t_003cappend_002ddynamic_003e-4"></a><a name="index-g_t_003cremove_002ddynamic_003e-5"></a><code>SCM (define-dynamic f)</code>, this will make a dynamic function object and bind it to <code>f</code>
<p><code>G.L. (&lt;push-dynamic&gt; f lambda-dyn)</code>, push a match onto the head of dynamic function <code>f</code>. <code>lambda-dyn</code> is a special lambda typically created through,
<p><code>SCM (&lt;lambda-dyn&gt; pat ... code)</code>, here <code>pat ...</code> will be simplified patterns only supporting <code>quote,unquote</code> all else directive is not allowed. <code>code</code> is evaluated in guile-log mode.
<p>Similarly we can add code to the end of the dynamic function, e.g.
<p><code>G.L. (&lt;append-dynamic&gt; f lambda-dyn)</code>.
<p>Also to remove elements one can use,
<p><code>G.L. (&lt;remove-dynamic&gt; (f a ...))</code>, where <code>f</code> is the dynamic function and <code>a ...</code> the patterns for the arguments that, which matches will be retracted.
<p><a name="index-g_t_003cwith_002ddynamic_002dfunctions_003e-6"></a><a name="index-g_t_003cguard_002ddynamic_002dfunctions_003e-7"></a>The previous set of API is typically what you get to use in prolog. The
downside is that they posses problem w.r.t. leaking data and therefor the next ideom is preferable to use in order to make sure both that one undo any changes to the dynamic variable, but also at reinstation of a state inside the form, it will resore to the same state as when control left the inner of the ideom e.g. The design is to favor fast lookup and adding and removing information is a bit expensive.
<p><code>G.L. (&lt;with-dynamic-functions&gt; (f ...) code ...)</code>, for this form <code>f ...</code>, will be weakly guarded throughout the form e.g. if control leaves the form then the state is stored if needed and at reinstation of state inside <code>code ...</code>, the old state of the dynamic variable will be reinstated. But inside the form state of the dynamic functions is not saved or restored.
<p>A stronger form of guard can be used in case one would like to make sure that the dynamic functions state can be reinstated in case of e.g. postpone is used, then use,
<p><code>G.L. (&lt;guard-dynamic-functions&gt; (f ...) code ...)</code>,
<p>Finally the last section conserns the ability to compile the dynamic function for as fast lookup as possible, use
<p><a name="index-g_t_003cdynamic_002dcompile_003e-8"></a><code>G.L. (&lt;dynamic-compile&gt; f ...)</code>, comiles the dynamic functions <code>f ...</code> for fast lookup. This ideom takes time and if used freely can cause a high memory consumption.
</body></html>
<html lang="en">
<head>
<title>dynamics - 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="postpone.html#postpone" title="postpone">
<link rel="next" href="dynamic_002dfunctions.html#dynamic_002dfunctions" title="dynamic-functions">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
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>
</head>
<body>
<div class="node">
<a name="dynamics"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="dynamic_002dfunctions.html#dynamic_002dfunctions">dynamic-functions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="postpone.html#postpone">postpone</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
</div>
<h2 class="chapter">15 Overview</h2>
<p>The main work has been to enable delimeted continuation in guile-log. To do this is not easy because we want to support interleaving, postponing, store/restore, zip like construct as well as acumulation all in one theoretically and computationally sound environment. It's not just to store and restore a stack as in scheme. Guile log is targetted to be effective reinstating states and keep a huge number of states in memory, to do this we note 1. we store a tree of states to compress the overall memory need and keep consing to a lower degree. 2. reinstating state information multiple times is cheap because there is no consing the second time for the main stack (we keep another dynamic stack where we need to reinstate new datastructures at each reinstation. All this means that we must reinstate the same datastructure. Also generally the cc and p fields at the in and out of the generated continuation needs to be patched and in order to support all of guile-log seamlessly one need to make use of guarded variables. In all stackless dynamics like kanren employ is not well suited because this is a nonfunctional modification. The resulting continuation will work almost as one would expect, but one can imagine problematics if the evaluation of the continuation returns a failure thunk intended to jump back into the continuation without normal backtracking. This is not a serious flaw and we do not try to add functionality to support this more than that we would implement new versions of the frameworks, looking at that source code it would be clear how to proceed.
<h2 class="chapter">16 Api</h2>
<p><a name="index-g_t_003cprompt_003e-181"></a><a name="index-g_t_003cabort_003e-182"></a><a name="index-g_t_003ccatch_003e-183"></a>
<code>G.L. (&lt;prompt&gt; tag data thunk handler)</code>, This will evaluate the guile-log version of a thunk and continue just as with any other thunk. But if an abort with a tag that matches the prompt tag or if the prompt tag is true, any abort will be catched. data will be guile-log dynamic data that will be captured at the abort and transferd back to the prompts context. The handler is of the form
<p><code>(handler tag next kk args ...)</code>, <code>tag</code> is the abort tag, next is a guile-log thunk, that evaluated will try the next handler in the stack. kk is a meta continuation. typically to get the continuaiton <code>k</code>, you do
<p><code>(let ((k (kk))) ...)</code>
<p>But we can also do
<p><code>(let ((k (kk new-handler))) ...)</code>, in cases where one want to use a new
handler for the continuation which is a common pattern in producing generators.
Technically this is not needed, but doing so means the difference between dog
slow code and performant code. Finally we can use,
<p><code>(let ((k (kk tag new-handler))) ...)</code>, with the obvious interpretation. The return continuation k will have a few arguments that represents the arguments used in the continuation of the abort.
<p>The arguments <code>(args ...)</code> are the arguments returned by the abort.
<p><code>G.L. (&lt;catch&gt; tag data thunk handler)</code> this is exactly the same interface
as with prompts, but with the difference that the handler has the form
<p><code>(handler tag next args ...)</code>, This is the same as prompts, but does not have any continuation argument. This ideom has significantly lower overhead.
<p><code>G.L. (&lt;abort&gt; tag lambda args ...)</code>, will look for a handler matching
the tag and then call the handler with <code>(args ...)</code>, see the doc for <code>&lt;prompt&gt;</code>. The lambda should be a guile-log lambda and defines the signature that the continuation inside the handler have.
<h2 class="chapter">17 Example</h2>
<pre class="verbatim">(use-modules (logic guile-log))
(use-modules (logic guile-log umatch))
(&lt;define> (f)
(&lt;values> (i x) (&lt;abort> 'tag (&lt;lambda> (i x) (&lt;cc> i x))))
(&lt;or-i>
(&lt;or> (&lt;=> x i) (&lt;=> x ,(+ i i)))
(&lt;or> (&lt;=> x ,(- i)) (&lt;=> x ,(- (+ i i))))))
(&lt;define> (test x y)
(&lt;prompt> 'tag #f f
(&lt;lambda> (tag next kk)
(&lt;let> ((k (kk)))
(&lt;zip> (x (k 1 x))
(y (k 10 y)))))))
(&lt;run> 10 (x y) (test x y))
--> $1 = ((1 10) (-1 -10) (2 20) (-2 -20))
</pre>
</body></html>
<html lang="en">
<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 href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
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>
</head>
<body>
<div class="node">
<a name="expressions"></a>
<p>
<hr>
</div>
<h2 class="chapter">23 Overview</h2>
<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>
<h3 class="section">23.1 Api</h3>
<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)
-->
(('xfy ``+'' _ _) (#:number 1) (('yf ``-'' _ _) (#:number 2) 4 0) 2 0)
</pre>
<p>That is a binary oparator is of the form,