Rewrote documentation and working on cut
This commit is contained in:
parent
3653883b02
commit
1b4cd42d5c
|
@ -1,85 +0,0 @@
|
|||
Installing Schelog
|
||||
|
||||
|
||||
*** JBC, 2010-04-22: I conjecture that (as a collection
|
||||
within the PLT tree) installation directions are now
|
||||
superfluous. The below is preserved for posterity.
|
||||
|
||||
|
||||
|
||||
|
||||
-
|
||||
|
||||
First, obtain the Schelog distribution. This is
|
||||
available at
|
||||
|
||||
http://www.ccs.neu.edu/~dorai/schelog/schelog.html
|
||||
|
||||
Gunzipping and untarring this file produces a directory
|
||||
called "schelog". This directory contains, among other
|
||||
subsidiary files:
|
||||
|
||||
the Schelog code file "schelog.scm";
|
||||
|
||||
the file INSTALL, which you are now reading.
|
||||
|
||||
-
|
||||
|
||||
The file schelog.scm in the distribution loads in
|
||||
MzScheme (and some other Scheme dialects) without
|
||||
configuration. If it does not load in your
|
||||
dialect, you can configure Schelog for it using
|
||||
the scmxlate package, which is available at
|
||||
http://www.ccs.neu.edu/~dorai/scmxlate/scmxlate.html
|
||||
|
||||
Start your Scheme in the schelog directory, and load
|
||||
the file scmxlate/scmxlate.scm , using the correct
|
||||
relative or full pathname. You will be asked what your
|
||||
Scheme dialect is. Answer appropriately. The
|
||||
following symbols are used by the porting
|
||||
mechanism to identify the corresponding Scheme
|
||||
dialects: bigloo (Bigloo); gambit (Gambit); guile
|
||||
(Guile); mitscheme (MIT Scheme); mzscheme (MzScheme);
|
||||
petite (Petite Chez Scheme); pscheme (Pocket Scheme);
|
||||
scm (SCM); stk (STk).
|
||||
|
||||
scmxlate will generate a file called
|
||||
"my-schelog.scm", which you may rename to
|
||||
"schelog.scm".
|
||||
|
||||
Load schelog.scm into your Scheme in order to use
|
||||
Schelog.
|
||||
|
||||
The distribution comes with an "examples" subdirectory
|
||||
containing some sample Schelog programs. In order to
|
||||
try an example file, load it into your Scheme after
|
||||
ensuring that "schelog.scm" has already been loaded.
|
||||
Follow the instructions in the example file.
|
||||
|
||||
-
|
||||
|
||||
The file "schelog.tex" contains a tutorial on Schelog. Run it
|
||||
through (plain) TeX to obtain viewable/printable
|
||||
documentation. (You will need to run TeX twice to resolve
|
||||
cross references.)
|
||||
|
||||
You can get a browsable version of the document by
|
||||
calling
|
||||
|
||||
tex2page schelog.tex
|
||||
|
||||
This browsable version is also available for Web
|
||||
viewing at
|
||||
|
||||
http://www.ccs.neu.edu/~dorai/schelog/schelog.html
|
||||
|
||||
tex2page is available at
|
||||
|
||||
http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html
|
||||
|
||||
-
|
||||
|
||||
Concise bug reports, questions, and suggestions
|
||||
may be emailed to
|
||||
|
||||
ds26 at gte dot com
|
|
@ -1,55 +0,0 @@
|
|||
README
|
||||
Schelog
|
||||
Dorai Sitaram
|
||||
ds26@gte.com
|
||||
|
||||
|
||||
*** JBC 2010-04-22: this package has been TAMPERED WITH in an unscrupulous and
|
||||
undisciplined way by John Clements 2010-04-22 in order to see how difficult it
|
||||
would be to get it to compile in PLT 4.2.5. The answer is "not hard", but it's
|
||||
certainly not portable any more, and crucially the two macros that cause
|
||||
capture of the ! symbol now require uses of the macro to supply the bang, thus
|
||||
making them non-capturing.
|
||||
|
||||
TODO:
|
||||
- pull some part of the docs across from their tex format
|
||||
- figure out what to do with the makefile (delete it?)
|
||||
- turn more of the implicit test cases into explicit test cases
|
||||
- clean up this README file
|
||||
- figure out whether there are copyright issues
|
||||
|
||||
|
||||
...
|
||||
|
||||
Schelog is for you if you are interested in any or all
|
||||
of the following: Scheme, Prolog, logic, logic
|
||||
programming, AI, and expert systems.
|
||||
|
||||
Schelog is an embedding of logic programming a la
|
||||
Prolog in Scheme. "Embedding" means you don't lose
|
||||
Scheme: You can use Prolog-style and conventional
|
||||
Scheme code fragments alongside each other. Schelog
|
||||
contains the full repertoire of Prolog features,
|
||||
including meta-logical and second-order ("set")
|
||||
predicates, leaving out only those features that could
|
||||
be more easily and more efficiently done with Scheme
|
||||
subexpressions. The Schelog distribution includes
|
||||
examples and comprehensive documentation.
|
||||
|
||||
Schelog has been tested successfully on the following
|
||||
Scheme dialects:
|
||||
|
||||
Bigloo, Gambit, Guile, MIT Scheme, MzScheme, Petite
|
||||
Chez Scheme, Pocket Scheme, SCM, and STk.
|
||||
|
||||
...
|
||||
|
||||
The Schelog distribution is available at the URL:
|
||||
|
||||
http://www.cs.rice.edu/CS/PLT/packages/schelog/
|
||||
|
||||
Unpacking (using gunzip and tar xf) the Schelog distribution
|
||||
produces a directory called "schelog". In it is a file
|
||||
called INSTALL which contains detailed installation
|
||||
instructions. Read INSTALL now.
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
;(%father X Y) :- X is the father of Y.
|
||||
|
||||
(define %father
|
||||
(%rel ! ()
|
||||
(%rel ()
|
||||
(('terach 'abraham)) (('terach 'nachor)) (('terach 'haran))
|
||||
(('abraham 'isaac)) (('haran 'lot)) (('haran 'milcah))
|
||||
(('haran 'yiscah))))
|
||||
|
@ -17,14 +17,14 @@
|
|||
;(%mother X Y) :- X is the mother of Y.
|
||||
|
||||
(define %mother
|
||||
(%rel ! () (('sarah 'isaac))))
|
||||
(%rel () (('sarah 'isaac))))
|
||||
|
||||
(define %male
|
||||
(%rel ! ()
|
||||
(%rel ()
|
||||
(('terach)) (('abraham)) (('isaac)) (('lot)) (('haran)) (('nachor))))
|
||||
|
||||
(define %female
|
||||
(%rel ! ()
|
||||
(%rel ()
|
||||
(('sarah)) (('milcah)) (('yiscah))))
|
||||
|
||||
;AoP, ch. 17. Finding all the children of a particular
|
||||
|
@ -36,13 +36,13 @@
|
|||
(define %children-1
|
||||
|
||||
(letrec ((children-aux
|
||||
(%rel ! (x a cc c)
|
||||
(%rel (x a cc c)
|
||||
((x a cc)
|
||||
(%father x c) (%not (%member c a)) !
|
||||
(children-aux x (cons c a) cc))
|
||||
((x cc cc)))))
|
||||
|
||||
(%rel ! (x cc)
|
||||
(%rel (x cc)
|
||||
((x cc) (children-aux x '() cc)))))
|
||||
|
||||
(define terachs-kids-test
|
||||
|
@ -79,7 +79,7 @@
|
|||
;Uses set predicate %bag-of
|
||||
|
||||
(define %children
|
||||
(%rel ! (x kids c)
|
||||
(%rel (x kids c)
|
||||
((kids) (%set-of c (%father x c) kids))))
|
||||
|
||||
(define dad-kids-test-2
|
||||
|
|
|
@ -11,47 +11,47 @@
|
|||
;The file england2.scm uses a Scheme-like syntax.
|
||||
|
||||
(define %male
|
||||
(%rel ! ()
|
||||
(%rel ()
|
||||
(('philip)) (('charles)) (('andrew)) (('edward))
|
||||
(('mark)) (('william)) (('harry)) (('peter))))
|
||||
|
||||
(define %female
|
||||
(%rel ! ()
|
||||
(%rel ()
|
||||
(('elizabeth)) (('anne)) (('diana)) (('sarah)) (('zara))))
|
||||
|
||||
(define %husband-of
|
||||
(%rel ! ()
|
||||
(%rel ()
|
||||
(('philip 'elizabeth)) (('charles 'diana))
|
||||
(('mark 'anne)) (('andrew 'sarah))))
|
||||
|
||||
(define %wife-of
|
||||
(%rel ! (w h)
|
||||
(%rel (w h)
|
||||
((w h) (%husband-of h w))))
|
||||
|
||||
(define %married-to
|
||||
(%rel ! (x y)
|
||||
(%rel (x y)
|
||||
((x y) (%husband-of x y))
|
||||
((x y) (%wife-of x y))))
|
||||
|
||||
(define %father-of
|
||||
(%rel ! ()
|
||||
(%rel ()
|
||||
(('philip 'charles)) (('philip 'anne)) (('philip 'andrew))
|
||||
(('philip 'edward)) (('charles 'william)) (('charles 'harry))
|
||||
(('mark 'peter)) (('mark 'zara))))
|
||||
|
||||
(define %mother-of
|
||||
(%rel ! (m c f)
|
||||
(%rel (m c f)
|
||||
((m c) (%wife-of m f) (%father-of f c))))
|
||||
|
||||
(define %child-of
|
||||
(%rel ! (c p)
|
||||
(%rel (c p)
|
||||
((c p) (%father-of p c))
|
||||
((c p) (%mother-of p c))))
|
||||
|
||||
(define %parent-of
|
||||
(%rel ! (p c)
|
||||
(%rel (p c)
|
||||
((p c) (%child-of c p))))
|
||||
|
||||
(define %brother-of
|
||||
(%rel ! (b x f)
|
||||
(%rel (b x f)
|
||||
((b x) (%male b) (%father-of f b) (%father-of f x) (%/= b x))))
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
(list 'person name country sport)))
|
||||
|
||||
(define %games
|
||||
(%rel ! (clues queries solution the-men
|
||||
(%rel (clues queries solution the-men
|
||||
n1 n2 n3 c1 c2 c3 s1 s2 s3)
|
||||
((clues queries solution)
|
||||
(%= the-men
|
||||
|
@ -29,7 +29,7 @@
|
|||
(%games-queries the-men queries solution))))
|
||||
|
||||
(define %games-clues
|
||||
(%rel ! (the-men clue1-man1 clue1-man2 clue2-man1 clue2-man2 clue3-man)
|
||||
(%rel (the-men clue1-man1 clue1-man2 clue2-man1 clue2-man2 clue3-man)
|
||||
((the-men
|
||||
(list
|
||||
(%did-better clue1-man1 clue1-man2 the-men)
|
||||
|
@ -46,7 +46,7 @@
|
|||
(%sport clue3-man 'cricket))))))
|
||||
|
||||
(define %games-queries
|
||||
(%rel ! (the-men man1 man2 aussies-name dicks-sport)
|
||||
(%rel (the-men man1 man2 aussies-name dicks-sport)
|
||||
((the-men
|
||||
(list
|
||||
(%member man1 the-men)
|
||||
|
@ -61,25 +61,25 @@
|
|||
(list 'richard 'plays dicks-sport))))))
|
||||
|
||||
(define %did-better
|
||||
(%rel ! (a b c)
|
||||
(%rel (a b c)
|
||||
((a b (list a b c)))
|
||||
((a c (list a b c)))
|
||||
((b c (list a b c)))))
|
||||
|
||||
(define %name
|
||||
(%rel ! (name country sport)
|
||||
(%rel (name country sport)
|
||||
(((person name country sport) name))))
|
||||
|
||||
(define %country
|
||||
(%rel ! (name country sport)
|
||||
(%rel (name country sport)
|
||||
(((person name country sport) country))))
|
||||
|
||||
(define %sport
|
||||
(%rel ! (name country sport)
|
||||
(%rel (name country sport)
|
||||
(((person name country sport) sport))))
|
||||
|
||||
(define %first
|
||||
(%rel ! (car cdr)
|
||||
(%rel (car cdr)
|
||||
(((cons car cdr) car))))
|
||||
|
||||
;;With the above as the database, and also loading the file
|
||||
|
|
|
@ -29,25 +29,25 @@
|
|||
(lambda (hue nation pet drink cigarette)
|
||||
(list 'house hue nation pet drink cigarette)))
|
||||
|
||||
(define %hue (%rel ! (h) (((house h (_) (_) (_) (_)) h))))
|
||||
(define %nation (%rel ! (n) (((house (_) n (_) (_) (_)) n))))
|
||||
(define %pet (%rel ! (p) (((house (_) (_) p (_) (_)) p))))
|
||||
(define %drink (%rel ! (d) (((house (_) (_) (_) d (_)) d))))
|
||||
(define %cigarette (%rel ! (c) (((house (_) (_) (_) (_) c) c))))
|
||||
(define %hue (%rel (h) (((house h (_) (_) (_) (_)) h))))
|
||||
(define %nation (%rel (n) (((house (_) n (_) (_) (_)) n))))
|
||||
(define %pet (%rel (p) (((house (_) (_) p (_) (_)) p))))
|
||||
(define %drink (%rel (d) (((house (_) (_) (_) d (_)) d))))
|
||||
(define %cigarette (%rel (c) (((house (_) (_) (_) (_) c) c))))
|
||||
|
||||
(define %adjacent
|
||||
(%rel ! (a b)
|
||||
(%rel (a b)
|
||||
((a b (list a b (_) (_) (_))))
|
||||
((a b (list (_) a b (_) (_))))
|
||||
((a b (list (_) (_) a b (_))))
|
||||
((a b (list (_) (_) (_) a b)))))
|
||||
|
||||
(define %middle
|
||||
(%rel ! (a)
|
||||
(%rel (a)
|
||||
((a (list (_) (_) a (_) (_))))))
|
||||
|
||||
(define %houses
|
||||
(%rel ! (row-of-houses clues queries solution
|
||||
(%rel (row-of-houses clues queries solution
|
||||
h1 h2 h3 h4 h5 n1 n2 n3 n4 n5 p1 p2 p3 p4 p5
|
||||
d1 d2 d3 d4 d5 c1 c2 c3 c4 c5)
|
||||
((clues queries solution)
|
||||
|
@ -62,7 +62,7 @@
|
|||
(%houses-queries row-of-houses queries solution))))
|
||||
|
||||
(define %houses-clues
|
||||
(%rel ! (row-of-houses abode1 abode2 abode3 abode4 abode5 abode6 abode7
|
||||
(%rel (row-of-houses abode1 abode2 abode3 abode4 abode5 abode6 abode7
|
||||
abode8 abode9 abode10 abode11 abode12 abode13 abode14 abode15)
|
||||
((row-of-houses
|
||||
(list
|
||||
|
@ -126,7 +126,7 @@
|
|||
(%hue abode15 'blue))))))
|
||||
|
||||
(define %houses-queries
|
||||
(%rel ! (row-of-houses abode1 abode2 zebra-owner water-drinker)
|
||||
(%rel (row-of-houses abode1 abode2 zebra-owner water-drinker)
|
||||
((row-of-houses
|
||||
(list
|
||||
(%member abode1 row-of-houses)
|
||||
|
|
|
@ -9,21 +9,21 @@
|
|||
;; is this different from the %member provided by schelog? fencing that one out.
|
||||
|
||||
(define %member
|
||||
(%rel ! (X Xs Y Ys)
|
||||
(%rel (X Xs Y Ys)
|
||||
((X (cons X Xs)))
|
||||
((X (cons Y Ys)) (%member X Ys))))
|
||||
|
||||
;(%members x y) holds if x is a subset of y
|
||||
|
||||
(define %members
|
||||
(%rel ! (X Xs Ys)
|
||||
(%rel (X Xs Ys)
|
||||
(((cons X Xs) Ys) (%member X Ys) (%members Xs Ys))
|
||||
(('() Ys))))
|
||||
|
||||
;(%select x y z) holds if z is y with one less occurrence of x
|
||||
|
||||
(define %select
|
||||
(%rel ! (X Xs Y Ys Zs)
|
||||
(%rel (X Xs Y Ys Zs)
|
||||
((X (cons X Xs) Xs))
|
||||
((X (cons Y Ys) (cons Y Zs))
|
||||
(%select X Ys Zs))))
|
||||
|
@ -35,26 +35,26 @@
|
|||
(list 'region name color neighbors)))
|
||||
|
||||
(define %color-map
|
||||
(%rel ! (Region Regions Colors)
|
||||
(%rel (Region Regions Colors)
|
||||
(((cons Region Regions) Colors)
|
||||
(%color-region Region Colors) (%color-map Regions Colors))
|
||||
(('() Colors))))
|
||||
|
||||
(define %color-region
|
||||
(%rel ! (Name Color Neighbors Colors Colors1)
|
||||
(%rel (Name Color Neighbors Colors Colors1)
|
||||
(((region Name Color Neighbors) Colors)
|
||||
(%select Color Colors Colors1)
|
||||
(%members Neighbors Colors1))))
|
||||
|
||||
(define %test-color
|
||||
(%rel ! (Name Map Colors)
|
||||
(%rel (Name Map Colors)
|
||||
((Name Map)
|
||||
(%map Name Map)
|
||||
(%colors Colors)
|
||||
(%color-map Map Colors))))
|
||||
|
||||
(define %map
|
||||
(%rel ! (A B C D E F G H I L P S)
|
||||
(%rel (A B C D E F G H I L P S)
|
||||
(('test (list
|
||||
(region 'a A (list B C D))
|
||||
(region 'b B (list A C E))
|
||||
|
@ -76,7 +76,7 @@
|
|||
(region 'austria A (list I S G)))))))
|
||||
|
||||
(define %colors
|
||||
(%rel ! ()
|
||||
(%rel ()
|
||||
(('(red yellow blue white)))))
|
||||
|
||||
;ask (%which (M) (%test-color 'test M)) or
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
; solve([]).
|
||||
|
||||
(define %solve-puzzle
|
||||
(%rel ! (clues queries solution)
|
||||
(%rel (clues queries solution)
|
||||
((clues queries solution)
|
||||
(%solve clues)
|
||||
(%solve queries))))
|
||||
|
||||
(define %solve
|
||||
(%rel ! (clue clues)
|
||||
(%rel (clue clues)
|
||||
(((cons clue clues))
|
||||
clue
|
||||
(%solve clues))
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
;(%length l n) holds if length(l) = n
|
||||
|
||||
(define %length
|
||||
(%rel ! (h t n m)
|
||||
(%rel (h t n m)
|
||||
(('() 0))
|
||||
(((cons h t) n) (%length t m) (%is n (+ m 1)))))
|
||||
|
||||
;(%delete x y z) holds if z is y with all x's removed
|
||||
|
||||
(define %delete
|
||||
(%rel ! (x y z w)
|
||||
(%rel (x y z w)
|
||||
((x '() '()))
|
||||
((x (cons x w) y) (%delete x w y))
|
||||
((x (cons z w) (cons z y)) (%not (%= x z)) (%delete x w y))))
|
||||
|
@ -23,7 +23,7 @@
|
|||
;(%remdup x y) holds if y is x without duplicates
|
||||
|
||||
(define %remdup
|
||||
(%rel ! (x y z w)
|
||||
(%rel (x y z w)
|
||||
(('() '()))
|
||||
(((cons x y) (cons x z)) (%delete x y w) (%remdup w z))))
|
||||
|
||||
|
@ -31,31 +31,31 @@
|
|||
;counting duplicates
|
||||
|
||||
'(define %count
|
||||
(%rel ! (x n y)
|
||||
(%rel (x n y)
|
||||
((x n) (%remdup x y) (%length y n))))
|
||||
|
||||
;same thing
|
||||
|
||||
(define %count
|
||||
(letrec ((countaux
|
||||
(%rel ! (m n m+1 x y z)
|
||||
(%rel (m n m+1 x y z)
|
||||
(('() m m))
|
||||
(((cons x y) m n)
|
||||
(%delete x y z) (%is m+1 (+ m 1)) (countaux z m+1 n)))))
|
||||
(%rel ! (x n)
|
||||
(%rel (x n)
|
||||
((x n) (countaux x 0 n)))))
|
||||
|
||||
;(%append x y z) holds if z is the concatenation of x and y
|
||||
|
||||
(define %append
|
||||
(%rel ! (x y z w)
|
||||
(%rel (x y z w)
|
||||
(('() x x))
|
||||
(((cons x y) z (cons x w)) (%append y z w))))
|
||||
|
||||
;(%reverse x y) holds if the y is the reversal of x
|
||||
|
||||
'(define %reverse
|
||||
(%rel ! (x y z yy)
|
||||
(%rel (x y z yy)
|
||||
(('() '()))
|
||||
(((cons x y) z) (%reverse y yy) (%append yy (list x) z))))
|
||||
|
||||
|
@ -63,16 +63,16 @@
|
|||
|
||||
(define %reverse
|
||||
(letrec ((revaux
|
||||
(%rel ! (x y z w)
|
||||
(%rel (x y z w)
|
||||
(('() y y))
|
||||
(((cons x y) z w) (revaux y (cons x z) w)))))
|
||||
(%rel ! (x y)
|
||||
(%rel (x y)
|
||||
((x y) (revaux x '() y)))))
|
||||
|
||||
;(%fact n m) holds if m = n!
|
||||
|
||||
'(define %fact
|
||||
(%rel ! (n n! n-1 n-1!)
|
||||
(%rel (n n! n-1 n-1!)
|
||||
((0 1))
|
||||
((n n!) (%is n-1 (- n 1)) (%fact n-1 n-1!) (%is n! (* n n-1!)))))
|
||||
|
||||
|
@ -80,9 +80,9 @@
|
|||
|
||||
(define %fact
|
||||
(letrec ((factaux
|
||||
(%rel ! (n! m x m-1 xx)
|
||||
(%rel (n! m x m-1 xx)
|
||||
((0 n! n!))
|
||||
((m x n!) (%is m-1 (- m 1)) (%is xx (* x m))
|
||||
(factaux m-1 xx n!)))))
|
||||
(%rel ! (n n!)
|
||||
(%rel (n n!)
|
||||
((n n!) (factaux n 1 n!)))))
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
#lang setup/infotab
|
||||
|
||||
(define scribblings
|
||||
'(("schelog.scrbl" (multi-page) (tool))))
|
||||
|
|
3
collects/schelog/main.rkt
Normal file
3
collects/schelog/main.rkt
Normal file
|
@ -0,0 +1,3 @@
|
|||
#lang racket
|
||||
(require "schelog.rkt")
|
||||
(provide (all-from-out "schelog.rkt"))
|
|
@ -1,48 +0,0 @@
|
|||
# JBC, 2010-04-22:
|
||||
# this makefile could probably be usefully rendered in scheme... but
|
||||
# I'm not going to try.
|
||||
|
||||
|
||||
TRIGGER_FILES = history manifest makefile version.tex \
|
||||
schelog.scm schelog.tex
|
||||
|
||||
default:
|
||||
@echo Please read the file INSTALL.
|
||||
|
||||
%.html: %.tex
|
||||
tex2page $(@:%.html=%)
|
||||
while grep -i "rerun: tex2page" $(@:%.html=%.hlog); do \
|
||||
tex2page $(@:%.html=%); \
|
||||
done
|
||||
|
||||
schelog.pdf: schelog.tex
|
||||
pdftex $^
|
||||
|
||||
schelog.tar:
|
||||
echo tar cf schelog.tar schelog/manifest > .tarscript
|
||||
for f in `grep "^[^;]" manifest`; do \
|
||||
echo tar uf schelog.tar schelog/$$f >> .tarscript; \
|
||||
done
|
||||
chmod +x .tarscript
|
||||
cd ..; schelog/.tarscript
|
||||
mv ../schelog.tar .
|
||||
|
||||
schelog.tar.bz2: $(TRIGGER_FILES)
|
||||
make schelog.tar
|
||||
bzip2 -f schelog.tar
|
||||
|
||||
schelog.tar.gz: $(TRIGGER_FILES)
|
||||
make schelog.tar
|
||||
gzip -f schelog.tar
|
||||
|
||||
html: schelog.html
|
||||
|
||||
pdf: schelog.pdf
|
||||
|
||||
dist: schelog.tar.bz2
|
||||
|
||||
webdist: schelog.tar.gz html
|
||||
|
||||
clean:
|
||||
@rm -f *~ *.bak
|
||||
cd dialects; rm -f *~ *.bak
|
|
@ -1,20 +0,0 @@
|
|||
COPYING
|
||||
README
|
||||
manifest
|
||||
makefile
|
||||
schelog-version.tex
|
||||
INSTALL
|
||||
history
|
||||
schelog.tex
|
||||
schelog.scm
|
||||
schelog.bib
|
||||
dialects/*.scm
|
||||
examples/bible.scm
|
||||
examples/england.scm
|
||||
examples/england2.scm
|
||||
examples/games.scm
|
||||
examples/holland.scm
|
||||
examples/houses.scm
|
||||
examples/mapcol.scm
|
||||
examples/puzzle.scm
|
||||
examples/toys.scm
|
|
@ -1 +0,0 @@
|
|||
2003-06-01% last change
|
|
@ -1,95 +0,0 @@
|
|||
|
||||
@book{sicp,
|
||||
author = "Harold Abelson and Gerald Jay {Sussman with Julie Sussman}",
|
||||
title = "\urlp{Structure and Interpretation of
|
||||
Computer Programs (``SICP'')}{http://mitpress.mit.edu/sicp/full-text/book/book.html}",
|
||||
edition = "2nd",
|
||||
publisher = "MIT Press",
|
||||
year = 1996,
|
||||
}
|
||||
|
||||
@book{aop,
|
||||
author = "Leon Sterling and Ehud Shapiro",
|
||||
title = "\urlh{http://mitpress.mit.edu/book-home.tcl?isbn=0262193388}{The Art
|
||||
of Prolog}",
|
||||
publisher = "MIT Press",
|
||||
year = 1994,
|
||||
edition = "2nd",
|
||||
}
|
||||
|
||||
@book{tls,
|
||||
author = "Daniel P Friedman and Matthias Felleisen",
|
||||
title = "\urlh{http://www.ccs.neu.edu/~matthias/BTLS}{The Little Schemer}",
|
||||
publisher = "MIT Press",
|
||||
year = 1996,
|
||||
edition = "4th",
|
||||
}
|
||||
|
||||
@book{tss,
|
||||
author = "Daniel P Friedman and Matthias Felleisen",
|
||||
title = "\urlh{http://www.ccs.neu.edu/~matthias/BTSS}{The Seasoned Schemer}",
|
||||
publisher = "MIT Press",
|
||||
year = 1996,
|
||||
}
|
||||
|
||||
@book{eopl,
|
||||
author = "Daniel P Friedman and Mitchell Wand and Christopher T Haynes",
|
||||
title = "\urlh{http://mitpress.mit.edu/book-home.tcl?isbn=0262061457}{Essentials
|
||||
of Programming Languages}",
|
||||
publisher = "MIT Press, McGraw-Hill",
|
||||
year = 1992,
|
||||
}
|
||||
|
||||
@book{bratko,
|
||||
author = "Ivan Bratko",
|
||||
title = "Prolog Programming for Artificial Intelligence",
|
||||
publisher = "Addison-Wesley",
|
||||
year = 1986,
|
||||
}
|
||||
|
||||
@book{campbell,
|
||||
editor = "J A Campbell",
|
||||
title = "Implementations of Prolog",
|
||||
publisher = "Ellis Horwood",
|
||||
year = 1984,
|
||||
}
|
||||
|
||||
@book{ok:prolog,
|
||||
author = "Richard A O'Keefe",
|
||||
title = "\urlh{http://mitpress.mit.edu/book-home.tcl?isbn=0262150395}{The
|
||||
Craft of Prolog}",
|
||||
publisher = "MIT Press",
|
||||
year = 1990,
|
||||
}
|
||||
|
||||
@inproceedings{logick,
|
||||
author = "Christopher T Haynes",
|
||||
title = "{Logic continuations}",
|
||||
booktitle = "{J Logic Program}",
|
||||
year = 1987,
|
||||
note = "vol 4",
|
||||
pages = "157--176",
|
||||
}
|
||||
|
||||
@misc{r5rs,
|
||||
author = "Richard Kelsey and William Clinger and
|
||||
Jonathan {Rees (eds)}",
|
||||
title = "\urlp{Revised\^{}5
|
||||
Report on the Algorithmic Language Scheme
|
||||
(``R5RS'')}{http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs.html}",
|
||||
year = 1998,
|
||||
}
|
||||
|
||||
@misc{t-y-scheme,
|
||||
author = "Dorai Sitaram",
|
||||
title = "\urlp{Teach Yourself Scheme
|
||||
in Fixnum Days}{http://www.ccs.neu.edu/~dorai/t-y-scheme/t-y-scheme.html}",
|
||||
}
|
||||
|
||||
@techreport{mf:prolog,
|
||||
author = "Matthias Felleisen",
|
||||
title = "{Transliterating Prolog into Scheme}",
|
||||
institution = "{Indiana U Comp Sci Dept}",
|
||||
year = 1985,
|
||||
number = 182,
|
||||
}
|
|
@ -113,11 +113,11 @@
|
|||
|
||||
;the unify predicate
|
||||
|
||||
(define *schelog-use-occurs-check?* #f)
|
||||
(define schelog-use-occurs-check? (make-parameter #f))
|
||||
|
||||
(define schelog:occurs-in?
|
||||
(lambda (var term)
|
||||
(and *schelog-use-occurs-check?*
|
||||
(and (schelog-use-occurs-check?)
|
||||
(let loop ((term term))
|
||||
(cond ((eqv? var term) #t)
|
||||
((schelog:ref? term)
|
||||
|
@ -223,17 +223,18 @@
|
|||
(let* ,(map (lambda (g) `(__fk ((schelog:deref* ,g) __fk))) gg)
|
||||
__fk))))
|
||||
|
||||
(define (! fk) (error '! "May only be used inside goal expression."))
|
||||
|
||||
;cut
|
||||
|
||||
;; rather arbitrarily made this macro non-
|
||||
;; capturing by requiring ! to be supplied at
|
||||
;; macro use... not changing docs... -- JBC 2010
|
||||
(define-syntax %cut-delimiter
|
||||
(syntax-rules ()
|
||||
((%cut-delimiter ! g)
|
||||
(define-syntax (%cut-delimiter stx)
|
||||
(syntax-case stx ()
|
||||
((%cut-delimiter g)
|
||||
(with-syntax ([! #'!])
|
||||
(syntax/loc stx
|
||||
(lambda (__fk)
|
||||
(let ((! (lambda (__fk2) __fk)))
|
||||
((schelog:deref* g) __fk))))))
|
||||
((schelog:deref* g) __fk))))))))
|
||||
|
||||
#;(define-macro %cut-delimiter
|
||||
(lambda (g)
|
||||
|
@ -243,9 +244,11 @@
|
|||
|
||||
;Prolog-like sugar
|
||||
|
||||
(define-syntax %rel
|
||||
(syntax-rules ()
|
||||
((%rel ! (v ...) ((a ...) subgoal ...) ...)
|
||||
(define-syntax (%rel stx)
|
||||
(syntax-case stx ()
|
||||
((%rel (v ...) ((a ...) subgoal ...) ...)
|
||||
(with-syntax ([! #'!])
|
||||
(syntax/loc stx
|
||||
(lambda __fmls
|
||||
(lambda (__fk)
|
||||
(call-with-current-continuation
|
||||
|
@ -259,7 +262,7 @@
|
|||
...)
|
||||
(__sk __fk))))
|
||||
...
|
||||
(__fk 'fail))))))))))
|
||||
(__fk 'fail))))))))))))
|
||||
|
||||
#;(define-macro %rel
|
||||
(lambda (vv . cc)
|
||||
|
@ -548,7 +551,7 @@
|
|||
%fail))
|
||||
|
||||
(define-syntax %assert
|
||||
(syntax-rules (!)
|
||||
(syntax-rules ()
|
||||
((%assert rel-name (v ...) ((a ...) subgoal ...) ...)
|
||||
(set! rel-name
|
||||
(let ((__old-rel rel-name)
|
||||
|
@ -558,7 +561,7 @@
|
|||
(apply __new-addition __fmls))))))))
|
||||
|
||||
(define-syntax %assert-a
|
||||
(syntax-rules (!)
|
||||
(syntax-rules ()
|
||||
((%assert-a rel-name (v ...) ((a ...) subgoal ...) ...)
|
||||
(set! rel-name
|
||||
(let ((__old-rel rel-name)
|
||||
|
@ -730,7 +733,7 @@
|
|||
|
||||
(define %if-then-else
|
||||
(lambda (p q r)
|
||||
(%cut-delimiter !
|
||||
(%cut-delimiter
|
||||
(%or
|
||||
(%and p ! q)
|
||||
r))))
|
||||
|
@ -749,14 +752,14 @@
|
|||
((p q r) r)))
|
||||
|
||||
(define %append
|
||||
(%rel ! (x xs ys zs)
|
||||
(%rel (x xs ys zs)
|
||||
(('() ys ys))
|
||||
(((cons x xs) ys (cons x zs))
|
||||
(%append xs ys zs))))
|
||||
|
||||
(define %repeat
|
||||
;;failure-driven loop
|
||||
(%rel ! ()
|
||||
(%rel ()
|
||||
(())
|
||||
(() (%repeat))))
|
||||
|
||||
|
|
1422
collects/schelog/schelog.scrbl
Normal file
1422
collects/schelog/schelog.scrbl
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user