Skip to content

Commit

Permalink
Added Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldsonjw committed Mar 9, 2014
1 parent 04bf2c1 commit e9ca6c8
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 46 deletions.
16 changes: 12 additions & 4 deletions Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 $@
Expand All @@ -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

Expand Down Expand Up @@ -191,7 +199,7 @@ $(EUCLASSDIR):


check-syntax: .afile
$(BIGLOO) -afile .afile -syntax-check ${CHK_SOURCES}
$(BIGLOO) -afile .afile -syntax-check -L $(DISTDIR) ${CHK_SOURCES}



Expand Down
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# bkanren Readme


## Description

bkanren is a port of minikanren as found at <https://github.com/miniKanren/miniKanren> to Bigloo Scheme. For detailed information on minikanren, please visit <http://minikanren.org/>.


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/<bigloo-version>. 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/<bigloo-version>.

### 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")


67 changes: 35 additions & 32 deletions recette/testbkanren.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

)


25 changes: 15 additions & 10 deletions src/Llib/mk.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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+)))
Expand Down

0 comments on commit e9ca6c8

Please sign in to comment.