Updates to files, about to reshuffle names

This commit is contained in:
John Clements 2010-04-22 09:52:48 -07:00
parent c8d5f5cc12
commit 3a1fe8722f
5 changed files with 66 additions and 18 deletions

View File

@ -1,5 +1,13 @@
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

View File

@ -3,6 +3,14 @@ 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.
...
Schelog is for you if you are interested in any or all
@ -37,9 +45,3 @@ produces a directory called "schelog". In it is a file
called INSTALL which contains detailed installation
instructions. Read INSTALL now.
*** 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.

View File

@ -1,10 +1,15 @@
#lang racket
(require "../schelog.scm"
schemeunit)
;The following is the "Biblical" database from "The Art of
;Prolog", Sterling & Shapiro, ch. 1.
;(%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))))
@ -12,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
@ -31,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
@ -47,6 +52,9 @@
(%which (cc)
(%children-1 'terach cc))))
(check-equal? (terachs-kids-test)
`((cc (haran nachor abraham))))
(define dad-kids-test
;find a father and all his children. Returns
;f = terach, cc = (haran nachor abraham).
@ -56,6 +64,9 @@
(%which (f cc)
(%children-1 f cc))))
(check-equal? (dad-kids-test)
`((f terach) (cc (haran nachor abraham))))
(define terachs-kids-test-2
;find all the kids of Terach, using %set-of.
;returns kk = (abraham nachor haran)
@ -68,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

View File

@ -1,3 +1,7 @@
# 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

View File

@ -1,7 +1,27 @@
#lang scheme
#lang racket
;; TODO: figure out what should actually be 'provide'd.
(provide (all-defined-out))
;; A Note on changes: define-macro isn't so nice, but
;; someone (Dorai?) helpfully provided commented-out
;; versions of each macro in syntax-rules style.
;; Unfortunately, they didn't compile, but this seemed
;; related to an inability to capture the '!' name.
;; The easiest way to fix this was just to take the
;; classic "make 'em put the identifier in there" approach,
;; which means that uses of cut and rel must now include
;; a bang explicitly. It wouldn't be too hard to change
;; back to a capturing macro; I know syntax-case can do
;; it, I don't know if syntax-rules can.
;; Also, I changed a few top-level mutable bindings into
;; boxed bindings.
;;-- JBC, 2010-04-22
;MzScheme version of
;schelog.scm
@ -718,12 +738,12 @@
;the above could also have been written in a more
;Prolog-like fashion, viz.
'(define %member
#;'(define %member
(%rel ! (x xs y ys)
((x (cons x xs)))
((x (cons y ys)) (%member x ys))))
'(define %if-then-else
#;'(define %if-then-else
(%rel ! (p q r)
((p q r) p ! q)
((p q r) r)))
@ -742,8 +762,11 @@
; deprecated names -- retained here for backward-compatibility
(define == %=)
(define %notunify %/=)
;; JBC, 2010-04-22 -- don't think backward compatibility counts any more. commenting
;; these out.
#;(define == %=)
#;(define %notunify %/=)
#;(define-macro %cut
(lambda e