documentation for inheritance

parent 8c64adc3
......@@ -1917,7 +1917,7 @@ AnC / (B u D)
Q = (A/B)c n (C/D)c = (B u Ac) n (C u Dc) = .. It implements complementable set and setmaps from different underlying vhash datastructures.as before
@node implementations
@sqection implementations
@section implementations
This api is reached from @code{(ice-9 vset)}. It implements complementable set and setmaps from different underlying vhash datastructures.
@section API
......@@ -2210,7 +2210,114 @@ order? : if ordering of this key is important
@node inheritance
@chapter inheritance
a
Consider a set of objects and that we can add arrow links between the objects that forms a forest of acyclic directed graphs. This is the same as defining a multiple inheritance relation to the objects. What we can compile is lookup structures that enables fast understanding if one object is an ancester to another object or not, use function @code{compile-sup-sub}. and vice versa. Another useful lookup structure origiates from associating each set obect with a value and then ask for all objects of an object and all it's decendants. This is a kind of tree lookup and one needs to reorder the objects to enable an effective lookup, this is dine in the special compiliation function, @code{compile-set-representation} or @code{order-the-set}. It's possible to build a search tree through function @code{mktree}. To use this lookup tree one can use @code{fold-matching-sets} which folds all decendants from a paren set object.
@chapter API
@verbatim
this code is found in (logic guile-log inheritance)
scm (make-set-theory) : make a fresh new set theory
scm (make-set-theory parent) : make a new set theory with parent theory
fluid *current-set-theory* : contains current set theory
scm (print-theory) : print current set theory
scm (print-theory th) : print theory th
scm (new-set set) : add a new set element to the current theory
scm (new-set theory set) : add a new set element to the theory and
return it
scm (lookup set) : lookup set object o's coding from current
theory
scm (lookup theory set) : lookup set object o's coding from theory
scm (reverse-lookup set) : lookup the set object from coding using
current theory
scm (reverse-lookup theory set) : lookup the set object from coding using
theory
scm (a->b a b) : add an arrow link from a to b in current
theory
scm (a->b theory a b) : add an arrow link from a to b in theory and
retrun the new theory
scm (a->b-o a b) : add an arrow link from a to b in current
theory and update parenthood information
assuming that all perents have no parent yet.
scm (a->b-o theory a b) : add an arrow link from a to b in theory
and update parenthood information assuming
that all perents have no parent yet. returns
the new theory.
scm (compile-sup-sub) : compile the parenthood information in current
theory
scm (compile-sup-sub theory) : compile the parenthood information theory
and return the new theory.
scm (compile-set-representation) :
compile all remaining datastructures for inheritance analysis using all
set objects in current theory.
scm (compile-set-representation setbits) :
compile all remaining datastructures for inheritance analysis using all
set objects in setbits in current theory.
scm (compile-set-representation theory) :
compile all remaining datastructures for inheritance analysis using all
set objects in theory.
scm (compile-set-representation theory setbits) :
compile all remaining datastructures for inheritance analysis using all
set objects in setbits in theory.
scm (order-the-set) :
compile all remaining datastructures for inheritance analysis using all
set objects in current theory. updates current theory
scm (order-the-set theory) :
compile all remaining datastructures for inheritance analysis using all
set objects in theory.
scm (mk-tree i->f #:key (setbits current-setmask)) :
make a lookup tree using equal? hash-table, i->f, and including setbits
mask in current theory
scm (mk-tree theory i->f #:key (setbits theory-setmask)) :
make a lookup tree using equal? hash-table, i->f, and including setbits
mask in theory
scm (set< x y) :
checks if x is a parent of y in current theory
scm (set< theory x y) :
checks if x is a parent of y in theory
scm (assoc=>tree theory a) :
Take an assoc list and make a inherentance lookup tree for the values
scm (find-matching-sets theory set tree) :
find all decendants to set using the lookup structure tree in theory
scm (fold-matching-sets f seed set tree) :
fold all decendand data for set (set-object value) using f and seed for
current theory and lookup tree tree.
(f set-object value seed) -> new seed
scm (fold-matching-sets f seed theory set tree)
fold all decendand data for set (set-object value) using f and seed for
theory and lookup tree tree.
(f set-object value seed) -> new seed
@end verbatim
@node kanren
@chapter Kanren
......
......@@ -56,7 +56,7 @@ Previous: <a href="persistance.html#persistance" accesskey="p" rel="prev">persis
</div>
<hr>
<a name="Index-of-the-guile_002dlog-api"></a>
<h2 class="chapter">21 Index of the guile-log api</h2>
<h2 class="chapter">22 Index of the guile-log api</h2>
<a name="Index-1"></a>
<h2 class="unnumbered">Index</h2>
......
......@@ -57,7 +57,7 @@ Next: <a href="persistance.html#persistance" accesskey="n" rel="next">persistanc
</div>
<hr>
<a name="Garbage-Collection"></a>
<h2 class="chapter">18 Garbage Collection</h2>
<h2 class="chapter">19 Garbage Collection</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>
......
......@@ -57,13 +57,13 @@ Next: <a href="minikanren.html#minikanren" accesskey="n" rel="next">minikanren</
</div>
<hr>
<a name="Kanren"></a>
<h2 class="chapter">14 Kanren</h2>
<h2 class="chapter">15 Kanren</h2>
<p>Almost all of the kanren interface is implemented ontop of guile-log to use it import <code>logic guile-log kanren</code>. One could say that the kanren interface is the functional sister to guile-log which is more a macro framework as such guile-log is about 2x faster the kanren, but kanren has more beutifull semantics.
E.g. the kanren operation maps function arguments to functions. The kanren interface is divided into two categories of functionals, facts and relations. One combine facts into relations. The main difference is that fact functions have standardized arguments and relations have customized arguments. Also conversely evaluating the relation will return back a fact.
</p>
<a name="The-fact-building-blocks"></a>
<h3 class="section">14.1 The fact building blocks</h3>
<h3 class="section">15.1 The fact building blocks</h3>
<a name="index-succeed"></a>
<a name="index-fail"></a>
<a name="index-sfail"></a>
......@@ -134,7 +134,7 @@ skipp multiples of similar sucesses e.g. if <code>(all f1 f2)</code> is a succes
<p><code>_</code>, produces a fress new logical variable in it&rsquo;s place.
</p>
<a name="relations"></a>
<h3 class="section">14.2 relations</h3>
<h3 class="section">15.2 relations</h3>
<a name="index-relation"></a>
<a name="index-fact"></a>
<a name="index-extend_002drelation"></a>
......@@ -202,7 +202,7 @@ variables <code>id ...</code>. E.g.
</p>
<a name="Queries"></a>
<h3 class="section">14.3 Queries</h3>
<h3 class="section">15.3 Queries</h3>
<a name="index-query"></a>
<a name="index-solve"></a>
......@@ -215,7 +215,7 @@ variables <code>id ...</code>. E.g.
<p><code>(solution (v ...) g ...</code>, This is the same as <code>(solve 1 (v ...) g ...)</code>.
</p>
<a name="Misc"></a>
<h3 class="section">14.4 Misc</h3>
<h3 class="section">15.4 Misc</h3>
<a name="index-trace_002dvars"></a>
<a name="index-partially_002deval_002dsgl"></a>
......@@ -224,7 +224,7 @@ variables <code>id ...</code>. E.g.
<p><code>partially-eval-sgl</code>, not implemented, because guile-log is also directed towards stacks and assq lists and hence usually uses another kind of implementation for the interleaving constructs.
</p>
<a name="Examples"></a>
<h3 class="section">14.5 Examples</h3>
<h3 class="section">15.5 Examples</h3>
<pre class="verbatim">Example 1, any-union,
(let* ((fact1 (fact () 'x1 'y1))
(fact2 (fact () 'x2 'y2))
......
......@@ -57,7 +57,7 @@ Next: <a href="garbage_002dcollect.html#garbage_002dcollect" accesskey="n" rel="
</div>
<hr>
<a name="Prolog"></a>
<h2 class="chapter">17 Prolog</h2>
<h2 class="chapter">18 Prolog</h2>
<p>Guile log also sports an 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 sure it is currently alpha software and help is very very much appriciated. With this most programs written in iso prolog should probably work. The intention is to enhance this interface so that the bulk of already written prolog programs should be able to 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 library to tell how you want the dynamism to work at a fine grained level.
</p>
<table class="menu" border="0" cellspacing="0">
......
......@@ -5,13 +5,17 @@
#:export
(
bits-to-is get-high-bit get-rest-bits
make-set-theory
*current-set-theory*
new-set a->b a->b-o set->f
print-theory print-set
compile-sup-sub
compile-set-representation
mktree
find-matching-setsx
find-matching-sets
fold-matching-sets
get-translation-data
order-the-set
inh-comb
......@@ -19,6 +23,9 @@
mk-get-set!
set<
assoc=>tree
lookup
reverse-lookup
))
;; Syntax helpers
......@@ -555,6 +562,20 @@ from c-land in the indexer.
(cons (reverse-lookup theory (car l)) (lp (cdr l)))
'()))))
(define fold-matching-sets
(case-lambda
((f seed set tree)
(fold-matching-sets f seed (fluid-ref *current-theory* set tree)))
((f seed theory set tree)
(let ((ih (get-i (get-i->subs theory) (lookup theory set))))
(fold-dynlist-lr
(lambda (x seed)
(f (reverse-lookup theory (vector-ref x 0))
(vector-ref x 1) seed))
tree 0
(lambda (x)
(not (= (logand x ih) 0))))))))
(define get-translation-data
(case-lambda
(() (get-translation-data (fluid-ref *current-set-theory*)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment