Documentation of minikanren

parent 0e23fc43
......@@ -2515,46 +2515,51 @@ the orders of fact1 and fact2 etc in the definitions of R1 and R2.
minikanren is a more modern streamlined kanren. The traditional implementation is interesting, but we implement the semantic differently using guile-log internals in stead. The basic implementation in minikanren is to construct a special trampolines that enables code to search the space of solutions in a breth first way. Also there is a logaritmic addition of clauses meaning that the first clauses in an or have higher rate of trying then the last one so that by ordering the most likely clauses first you get a higher hit ratio. Also in minikanren one maintains multiple stack datastructures and does a great degree of groveling in them in order to implement the needed features. Here we take anothre approach and use attributes instead. In all we reproduce the sematics of minikanren but with a completely different appoach that mix well with the rest of guile-log. The minikanren primitives is also used to enable those in guile-prolog and a few operators is defined that enable the minikanren features in prolog programs.
@chapter API
To use this library reference @code{(logic guile-log minikanren)}.
The method of the api is to combine functions and finally evaluate the result yielding the logic program. A minikanren goal @code{mk-goal} can be executed in guile log as @code{(mk-goal)} and you can construct a minikanren goal directly by wrapping it in @code{(<lambda> () ...)}.
@findex conde
@code{mk-goal (conde (mk-goal ....) ...)}, This will produce a minkanren goal from 'or'-ing a sequence ao 'and'-ing. This construct will do breath first like search and is safe from producing unwanted infinite searches.
@findex conda
@findex condas
@code{mk-goal (conda (mk-goal ....) ...)}, This will produce a minkanren goal from 'or'-ing a sequence of 'and'-ing. The first value will produce only one value.
@findex condu
@findex condus
@findex condx
@findex condxn
@findex condo
@findex conde
@findex conds
@findex condes
@findex alls
@code{mk-goal (condu (mk-goal ....) ...)}, This will produce a minkanren goal from 'or'-ing a sequence of 'and'-ing. As @code{conda}, but the whole ideom will produce only one solution.
@findex once
@code{mk-goal (once mk-goal)}, Makes a goal that take only one solution from the goal @code{mk-goal}.
@findex fresh
@findex freshs
@findex freshx
@code{mk-goal (fresh (v1 ...) mk-goal ...)}, this will bind a set of variables @code{v1 ...} and then execute the minikanren goals according to an @code{and} in a safe way regarding unwanted infinities in the search
@findex ==
@code{mk-goal (== a b)}, will unify scheme object @code{a} with scheme object @code{b}.
@findex =/=
@findex symbolo
@code{mk-goal (=/= a b)}, will put a non equal constraint on the scheme objects @code{a},@code{b}.
@findex symbolo
@code{mk-goal (symbolo a)}, Constrain @code{a} to be a scheme symbol.
@findex numbero
@code{mk-goal (numbero a)}, Constrain @code{a} to be a scheme number.
@findex booleano
@findex run
@findex run*
@code{mk-goal (booleano a)}, Constrain @code{a} to be a scheme boolean.
@findex absento
@code{mk-goal (absento a b)}, Constrain @code{a} to not be included in the @code{b} datastructure consisting og atoms and conses.
@findex pko
@findex pkdyno
@findex similar
@findex project
@findex var
@findex true
@findex define-delay
@findex counter
@findex count-up
@findex once
@findex validate
@code{mk-goal (project (v ...) mk-goal ...}, This will walk all @code{v ...} values and then execute the goals @code{mk-goal ...} inside @code{and}. This ideom is safe for infinites in the searching.
@findex run
@code{scm (run n (v ...) mk-goal ...)}, execute a list of mk-goals, @code{mk-goal ...} inside an @code{and} in a infinite searching safe way using logical variables @code{v ...}. A list of list of variable values of no more than @code{n} solution(s) results.
@findex run*
@code{scm (run* (v ...) mk-goal ...}, the same as @code{run}, but with no limit on the number of solutions, my stall.
@node prolog
@chapter Prolog
This diff is collapsed.
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