-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.txt
100 lines (73 loc) · 3.58 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
PLL: Programming in Logic in Lisp
=================================
PLL is a set of implementations of Prolog in Scheme. It is not supposed
to be efficient, but rather as a simple way to teach the fundamentals of
Logic Programming and the internal working of a Prolog interpreter
(conceptually only -- a real implementation would be radically
different). This interpreter is based on a simple implementation of the
AMB operator.
PLL is very small (less than 500 lines of code, including different
versions of the interpreter).
Each variant is built on top of the other.
- Pure prolog: no variables, no assertions, only plain Prolog
and SLD-resolution.
- Prolog w/built-ins: with an extensible set of built-in predicates.
Only the built-ins within a list are allowed.
- Prolog w/Scheme functions: call any Scheme function from Prolog.
- Prolog w/local vars: this version has support for "IS" and local
Prolog variables.
- Prolog w/meta-predicates: this version has support for "assert"
and "retract".
- Prolog w/cut: this version supports cuts.
One last implementation is missing, that would allow for writing and
reading the database (so it would be possible to store and retrieve
programs). This is very simple to implement and planned for the near
future.
This interpreter is implemented in three files:
- `prolog-core.scm`: this is the main program, where all the above
variants of Prolog are implemented. Each variant differs from the
previous only slightly, and the difference is made clear in
code comments.
- `amb.scm`: handles non-determinism. This is a simple and usual
implementation of the AMB operator.
- `unify.scm`: contains code for unification.
There are also two files used to load the interpreter:
- `pll.scm`: contains an R7RS library declaration (for Chibi users:
`pll.sld` is a symlink to `pll.scm`, and works as expected)
- `pll-standalone.scm`: contains code to load the interpreter, without
creating any libraries or modules. Will override identifiers!
Supported Scheme implementations
--------------------------------
I have made an effort to get the interpreter working in as many Scheme
implementations as I could. Below is a list of supported and not
supported Schemes. "Supported" means I ran the example code pieces (in
prolog-examples.scm) and they worked as sxpected. I did no further
tests.
There are two ways to use PLL:
(load "pll-standalone.scm") ;; this works on all supported schemes.
(import (pll)) ;; only on the systems marked as having
;; support for R7RS modules
Scheme version R7RS module Note
-----------------------------------------------
Chicken 4.* Y
Gauche 0.9.4 Y
Guile 2.* -
Chibi 0.7.2 Y
Husk 3.19.1 -
SISC 1.16.6 -
Saggitarius 0.7.1 Y
Gambit 4.7 - Needs -:s flag for syntax rules, and SRFI-1
MIT Scheme 9.1.1 -
STklos 1.10 -
Scheme48 - Needs ,open srfi-1
Currently not supported:
SigScheme (syntax-rules is disabled in sigscheme for now)
TinyScheme (syntax-rules not implemented)
Scheme9 (very strange behavior -- needs investigation)
Kawa (AMB doesn't work because of some different call/cc behavior)
Foment (the Hanoi towers example eats up 100% CPU and never finishes)
SCM (support for neither cond-expand nor syntax-rules)
SIOD (syntax-rules not implemented)
Documentation
-------------
A very short manual is included (manual.md, manual.txt, manual.pdf).