The minikanren.org site offers more insights.
I ask the more experienced AHK if they can implement the minikanren language in AHK, in order to be able to check out the enormous potential that it offers, maybe before thinking about implementing it natively.
It could also be a remarkable exercise to enter the minikanren.org site to demonstrate the flexibility of AHK, but this is out of my reach and requires master AHK knowledge.
Having a native implementation would be a big plus: today, the only environment that internally integrates with minikanren is Clojure, a Lisp derived language that works in a Java environment.
Only 40 lines of code written in the Scheme language would allow to implement the core of minikanren!
Search online for HemannMuKanren2013.pdf implementation document in Scheme Language, reported below:
Code: Select all
(define (var c) (vector c))
(define (var? x) (vector? x))
(define (var=? x1 x2) (= (vector-ref x1 0) (vector-ref x2 0)))
(define (walk u s)
(let ((pr (and (var? u) (assp (λ (v) (var=? u v)) s))))
(if pr (walk (cdr pr) s) u)))
(define (ext-s x v s) `((,x . ,v) . ,s))
(define (≡ u v)
(λg(s/c)
(let ((s (unify u v (car s/c))))
(if s (unit `(,s . ,(cdr s/c))) mzero))))
(define (unit s/c) (cons s/c mzero))
(define mzero '())
(define (unify u v s)
(let ((u (walk u s)) (v (walk v s)))
(cond
((and (var? u) (var? v) (var=? u v)) s)
((var? u) (ext-s u v s))
((var? v) (ext-s v u s))
((and (pair? u) (pair? v))
(let ((s (unify (car u) (car v) s)))
(and s (unify (cdr u) (cdr v) s))))
(else (and (eqv? u v) s)))))
(define (call/fresh f)
(λg(s/c)
(let ((c (cdr s/c)))
((f (var c)) `(,(car s/c) . ,(+ c 1))))))
(define (disj g1 g2) (λg(s/c) (mplus (g1 s/c) (g2 s/c))))
(define (conj g1 g2) (λg(s/c) (bind (g1 s/c) g2)))
(define (mplus $1 $2)
(cond
((null? $1) $2)
((procedure? $1) (λ$() (mplus $2 ($1))))
(else (cons (car $1) (mplus (cdr $1) $2)))))
(define (bind $ g)
(cond
((null? $) mzero)
((procedure? $) (λ$() (bind ($) g)))
(else (mplus (g (car $)) (bind (cdr $) g)))))