eyemind 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -3
- package/SPEC.md +595 -344
- package/package.json +1 -1
- package/src/builtins.js +26 -1
- package/src/digest.js +162 -0
- package/src/engine.js +3 -1
- package/src/proof.js +1 -1
- package/src/version.js +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ eyemind is a **JavaScript rule language** with forward and backward reasoning an
|
|
|
7
7
|
|
|
8
8
|
[Playground](https://eyereasoner.github.io/eyemind/playground/) · [Specification](https://eyereasoner.github.io/eyemind/SPEC) · [Conformance](https://eyereasoner.github.io/eyemind/conformance/) · [Examples](https://eyereasoner.github.io/eyemind/examples/)
|
|
9
9
|
|
|
10
|
-
The playground runs programs in your browser; the specification defines the language, its canonical text, the proof format and the C1–C10 checks. The examples are
|
|
10
|
+
The playground runs programs in your browser; the specification defines the language, its canonical text, the proof format and the C1–C10 checks. The examples are 99 runnable programs, each with a card deck and saved conclusions, proofs and check reports. The conformance suite has 1353 cases that test any implementation of the specification through its command line; run it [in your browser](https://eyereasoner.github.io/eyemind/playground/conformance).
|
|
11
11
|
|
|
12
12
|
## Contents
|
|
13
13
|
|
|
@@ -19,6 +19,7 @@ The playground runs programs in your browser; the specification defines the lang
|
|
|
19
19
|
- [Deriving rules](#deriving-rules)
|
|
20
20
|
- [Inspecting rules](#inspecting-rules)
|
|
21
21
|
- [RDF 1.2](#rdf-12)
|
|
22
|
+
- [Notation3](#notation3)
|
|
22
23
|
- [How eyemind reasons](#how-eyemind-reasons)
|
|
23
24
|
- [Proofs, and what checking one means](#proofs-and-what-checking-one-means)
|
|
24
25
|
- [Why negation and collection are safe](#why-negation-and-collection-are-safe)
|
|
@@ -58,7 +59,7 @@ Prolog, Datalog, N3 and SRL already exist, and eyemind adds no new logic: rules
|
|
|
58
59
|
When eyemind is not the right tool:
|
|
59
60
|
|
|
60
61
|
- If you do not need proofs, use the mature tools: SWI-Prolog and XSB have tabling, and Soufflé is fast at scale.
|
|
61
|
-
- N3 and SRL are designed around RDF and Web data. eyemind does not compete there: RDF comes in as data (see [RDF 1.2](#rdf-12)).
|
|
62
|
+
- N3 and SRL are designed around RDF and Web data. eyemind does not compete there: RDF comes in as data (see [RDF 1.2](#rdf-12)), and N3 programs compile to eyemind (see [Notation3](#notation3)).
|
|
62
63
|
- eyemind is for cases where someone else has to be able to check why a conclusion holds: audits, compliance, and decisions between parties that do not trust each other.
|
|
63
64
|
|
|
64
65
|
## Install and run
|
|
@@ -123,7 +124,7 @@ Now add `fact(parent('carol', 'dave'))`, or remove a rule, and watch which answe
|
|
|
123
124
|
|
|
124
125
|
**An array is a conjunction:** `implies([p(X), q(X)], [r(X), s(X)])`. Disjunction is `or(A, B)`, negation is `not(G)`, and collection is `findall(T, G, L)`, alongside `call` and `once`.
|
|
125
126
|
|
|
126
|
-
**Text is atoms:** `atom_chars`, `atom_concat` and `atom_length` take them apart, and `regex_match(P, T)`, `regex_find(P, T, Groups)` and `regex_replace(P, T, R, U)` search them with ECMAScript regular expressions.
|
|
127
|
+
**Text is atoms:** `atom_chars`, `atom_concat` and `atom_length` take them apart, `atom_lower` and `atom_upper` change their case, `regex_match(P, T)`, `regex_find(P, T, Groups)` and `regex_replace(P, T, R, U)` search them with ECMAScript regular expressions, `digest('sha256', A, Hex)` hashes them, and `term_text(T, A)` writes a ground term as its canonical text.
|
|
127
128
|
|
|
128
129
|
### Terms and names
|
|
129
130
|
|
|
@@ -185,6 +186,30 @@ eyemind has no built-in RDF; RDF arrives as data through [rdf-interchange](https
|
|
|
185
186
|
|
|
186
187
|
A Skolem term becomes a blank node, the same one for the same rule firing. The `rdf12-*` examples show triple terms, annotations, directional strings, typed numbers and named graphs.
|
|
187
188
|
|
|
189
|
+
### Notation3
|
|
190
|
+
|
|
191
|
+
N3 programs run on eyemind through [n3-interchange](https://github.com/eyereasoner/n3-interchange). `n3-to-eyemind` compiles N3 facts and rules into an eyemind program, with the N3 built-ins it uses written as eyemind rules, and `eyemind-to-n3` writes the conclusions back as N3; `eyemind-n3` does both around a run:
|
|
192
|
+
|
|
193
|
+
```sh
|
|
194
|
+
npm install -g n3-interchange
|
|
195
|
+
eyemind-n3 examples/n3-family.n3 # answers as N3
|
|
196
|
+
n3-to-eyemind examples/n3-family.n3 -o /tmp/n3-family.js # compile a program to inspect
|
|
197
|
+
node bin/eyemind.js /tmp/n3-family.js # run it with eyemind
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Triples are `rdf(Subject, Predicate, Object)`, with IRIs, blank nodes and literals written as in the RDF table above and N3 numbers as eyemind numbers. `=>` becomes `implies`, `<=` becomes `implied_by`, and scoped negation and collection become `not` and `findall`, so an N3 run has a proof that eyemind checks like any other. The n3-interchange README lists its measured coverage and current limits.
|
|
201
|
+
|
|
202
|
+
Five examples pair the original N3 with a compiled JavaScript program:
|
|
203
|
+
[family queries](https://eyereasoner.github.io/eyemind/examples/deck/n3-family),
|
|
204
|
+
[scoped negation](https://eyereasoner.github.io/eyemind/examples/deck/n3-scoped-negation),
|
|
205
|
+
[invoice collection](https://eyereasoner.github.io/eyemind/examples/deck/n3-invoice),
|
|
206
|
+
[French cities](https://eyereasoner.github.io/eyemind/examples/deck/n3-french-cities), and
|
|
207
|
+
[existential witnesses](https://eyereasoner.github.io/eyemind/examples/deck/n3-witnesses).
|
|
208
|
+
The saved `.js` programs run directly in the playground and with eyemind;
|
|
209
|
+
compiling the `.n3` sources or writing answers back as N3 uses n3-interchange.
|
|
210
|
+
Each deck shows the N3 result and what its saved proof establishes, including
|
|
211
|
+
any remaining obligations.
|
|
212
|
+
|
|
188
213
|
## How eyemind reasons
|
|
189
214
|
|
|
190
215
|
The statement chooses the direction:
|