diff --git a/Makefile.inc b/Makefile.inc index 5d02bfd..8cac9be 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -91,7 +91,11 @@ $(UCLASSDIR)/%.class:src/Llib/%.scm #targets -all: .jfile .afile .etags lib recette/test$(LIBNAME) +c: .afile .etags lib recette/test$(LIBNAME) + +jvm: .jfile .afile .etags libj + +all: c jvm .afile: $(BIGLOOSRCS) @@ -103,7 +107,9 @@ all: .jfile .afile .etags lib recette/test$(LIBNAME) .etags: $(BIGLOOSRCS) $(BGLTAGS) -o $@ $^ -heap: $(DISTDIR)/$(LIBNAME).heap $(DISTDIR)/$(LIBNAME).jheap +heap: $(DISTDIR)/$(LIBNAME).heap + +jheap: $(DISTDIR)/$(LIBNAME).jheap $(DISTDIR)/$(LIBNAME).heap: $(DISTDIR) $(HEAPSRC) $(BIGLOO) $(BHEAPFLAGS) $(HEAPSRC) -addheap $@ @@ -125,7 +131,9 @@ $(EUCLASSDIR)/make_lib.class:src/Misc/make_lib.scm $(BIGLOO) -jvm -c $(BUNSAFEFLAGS) -o $@ $^ -lib: init heap lib_s lib_u lib_s.a lib_u.a lib_es lib_eu jar_s jar_u jar_es jar_eu +lib: init heap lib_s lib_u lib_s.a lib_u.a lib_es lib_eu + +libj: init jheap heap jar_s jar_u jar_es jar_eu init: $(DISTDIR) $(DISTDIR)/$(LIBNAME).init @@ -191,7 +199,7 @@ $(EUCLASSDIR): check-syntax: .afile - $(BIGLOO) -afile .afile -syntax-check ${CHK_SOURCES} + $(BIGLOO) -afile .afile -syntax-check -L $(DISTDIR) ${CHK_SOURCES} diff --git a/README.md b/README.md new file mode 100644 index 0000000..a200bdf --- /dev/null +++ b/README.md @@ -0,0 +1,93 @@ +# bkanren Readme + + +## Description + +bkanren is a port of minikanren as found at to Bigloo Scheme. For detailed information on minikanren, please visit . + + +It supports the following operators: + +### Logical Operators + +* fresh +* conde + +### Interface Operators + +* run +* run* + +### Constraint Operators + +* =/= +* symbolo +* numbero +* absento + +### Operators from The Reasoned Schemer + +* caro +* cdro +* conso +* nullo +* eqo +* pairo +* listo +* lolo +* twinso +* listofo +* loto +* membero +* eq-caro +* memo +* rembero +* appendo +* unwrapo +* swappendo +* flatteno +* flattenrevo +* anyo +* nevero +* alwayso +* salo + + +### Building + +Both the Bigloo native and jvm backends are supported. To build the native libraries, just execute + + make + +To build the jvm libraries, execute + + make jvm + +To build both, execute + + make all + + +### Installation + +To Install the libraries, execute + + make install + +This by default installs the libraries into the directory /usr/lib/bigloo/. If you have Bigloo installed to a different prefix, execute + + make install DESTDIR=/path/prefix + +This will result in the libraries being installed to /path/prefix/lib/bigloo/. + +### Interpretor + +The bkanren library can be dynamically loaded into the interpretor with + + (library-load 'bkanren) + +If you have not installed the bkanren library in a standard location, you may need to pass path as a second argument. + + (libary-load 'bkanren "/path/to/libdir") + + diff --git a/recette/testbkanren.scm b/recette/testbkanren.scm index dc8f603..28d8015 100644 --- a/recette/testbkanren.scm +++ b/recette/testbkanren.scm @@ -6,36 +6,39 @@ (print (run* (q) (== #t q))) - ; (print (run* (q) - ; (fresh (x) - ; (== #t x) - ; (== x q)))) - - ; (print (run* (x) - ; (conde ((== 'olive x) succeed) - ; ((== 'oil x) succeed) - ; (else fail)))) - - ; (print (run* (r) - ; (fresh (x y) - ; (caro '(grape raisin pear) x) - ; (caro '((a) (b) (c)) y) - ; (== (cons x y) r)))) - - - ; (print (run 1 (q) - ; alwayso - ; (== #t q))) - - - ; (print (run 1 (q) - ; (== #f q) - ; (== #t q))) - - ; ;;; why does this work - ; (print (run 5 (q) - ; (conde ((== #f q) alwayso) - ; ((== #t q) alwayso) - ; (else fail)) - ; (== #t q))) + (print (run* (q) + (fresh (x) + (== #t x) + (== x q)))) + + (print (run* (x) + (conde ((== 'olive x) succeed) + ((== 'oil x) succeed) + (else fail)))) + + (print (run* (r) + (fresh (x y) + (caro '(grape raisin pear) x) + (caro '((a) (b) (c)) y) + (== (cons x y) r)))) + + + (print (run 1 (q) + alwayso + (== #t q))) + + + (print (run 1 (q) + (== #f q) + (== #t q))) + + ;;; why does this work + (print (run 5 (q) + (conde ((== #f q) alwayso) + ((== #t q) alwayso) + (else fail)) + (== #t q))) + ) + + diff --git a/src/Llib/mk.scm b/src/Llib/mk.scm index bdb8ecd..3a2eacb 100644 --- a/src/Llib/mk.scm +++ b/src/Llib/mk.scm @@ -24,7 +24,12 @@ (static (final-class %var - sym))) + sym) + (final-class %package + (S (default '())) + (D (default '())) + (A (default '())) + (T (default '()))))) ;; add missing r6rs remp function @@ -45,15 +50,15 @@ #f))) ;; original minikanren file -(define c->S (lambda (c) (car c))) +(define c->S (lambda (c::%package) (-> c S))) -(define c->D (lambda (c) (cadr c))) +(define c->D (lambda (c::%package) (-> c D))) -(define c->A (lambda (c) (caddr c))) +(define c->A (lambda (c::%package) (-> c A))) -(define c->T (lambda (c) (cadddr c))) +(define c->T (lambda (c::%package) (-> c T))) -(define empty-c '(()()()())) +(define empty-c (instantiate::%package)) (define mzero (lambda () #f)) @@ -132,11 +137,11 @@ (define subsume-A+ (lambda (x* S D A T) (cond - ((null? x*) `(,S ,D ,A ,T)) + ((null? x*) (instantiate::%package (S S) (D D) (A A) (T T))) (else (let ((x (car x*))) (let ((D/T (update-D/T x S D A T))) (let ((D (car D/T)) (T (cdr D/T))) - `(,S ,D ,A ,T)))))))) + (instantiate::%package (S S) (D D) (A A) (T T))))))))) (define ext-A (lambda (x tag pred S A) @@ -182,7 +187,7 @@ (let ((D+ (subsume A D+))) (let ((D+ (subsume T D+))) (let ((D (append D+ D))) - (unit `(,S ,D ,A ,T))))))))))) + (unit (instantiate::%package (S S) (D D) (A A) (T T)))))))))))) (define prefix-S (lambda (S+ S) @@ -323,7 +328,7 @@ (cond ((null? x*) (let ((T (append T+ T))) - `(,S ,D ,A ,T))) + (instantiate::%package (S S) (D D) (A A) (T T)))) (else (let ((x (car x*)) (x* (cdr x*))) (let ((D/T (update-D/T x S D A T+)))