add support for conjunctive queries.

This commit is contained in:
Mark Thom
2017-05-07 15:26:36 -06:00
parent 9687878219
commit f155b5b2c2
17 changed files with 2109 additions and 1475 deletions

View File

@@ -8,11 +8,11 @@ pure Prolog.
## Progress
Prolog is implemented as a simple REPL. It is without without meta- or
Prolog is implemented as a simple REPL. It is without meta- or
extra-logical operators, or side effects of any kind, with the lone
exception of cut. In terms of the tutorial pacing, the work covers in
some form all of the WAM book, including lists, cuts, Debray
allocation, and indexing.
allocation, indexing, and conjunctive queries.
## Tutorial
To enter a multi-clause predicate, the brackets ":{" and "}:" are used
@@ -76,6 +76,29 @@ Press ; to continue or . to abort.
;
no
```
and so do conjunctive queries:
```
prolog> ?- member([X,X],[a,b,c,[d,d],[e,d]]), member(X, [a,b,c,d,e,f,g]), member(Y, [X, a, b, c, d]).
yes
Y = d
X = d
Press ; to continue or . to abort.
Y = a
X = d
Press ; to continue or . to abort.
Y = b
X = d
Press ; to continue or . to abort.
Y = c
X = d
Press ; to continue or . to abort.
Y = d
X = d
Press ; to continue or . to abort.
no
prolog>
```
Note that the values of variables belonging to successful queries are
printed out, on one line each. Uninstantiated variables are denoted by