eyemind 0.3.6 → 0.3.8
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 +349 -21
- package/SPEC.md +1 -1
- package/package.json +1 -1
- package/src/version.js +1 -1
package/README.md
CHANGED
|
@@ -3,34 +3,362 @@
|
|
|
3
3
|
[](https://doi.org/10.5281/zenodo.23824021)
|
|
4
4
|
[](https://www.npmjs.com/package/eyemind)
|
|
5
5
|
|
|
6
|
-
eyemind is a **JavaScript rule language** with forward and backward reasoning
|
|
7
|
-
and checkable proofs. You write facts and rules in plain JavaScript; eyemind
|
|
8
|
-
draws conclusions, and every conclusion can come with a proof that a separate
|
|
9
|
-
checker verifies against your program. It runs as a command-line program, a
|
|
10
|
-
JavaScript library, and a browser application, with no dependencies.
|
|
6
|
+
eyemind is a **JavaScript rule language** with forward and backward reasoning and checkable proofs. You write facts and rules in plain JavaScript; eyemind draws conclusions, and every conclusion can come with a proof that a separate checker verifies against your program. It runs as a command-line program, a JavaScript library, and a browser application, with no dependencies.
|
|
11
7
|
|
|
12
|
-
[
|
|
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/)
|
|
13
9
|
|
|
14
|
-
The
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 94 runnable programs, each with a card deck and saved conclusions, proofs and check reports. The conformance suite has 1329 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
|
+
|
|
12
|
+
## Contents
|
|
13
|
+
|
|
14
|
+
- [Why eyemind?](#why-eyemind)
|
|
15
|
+
- [Install and run](#install-and-run)
|
|
16
|
+
- [Your first program](#your-first-program)
|
|
17
|
+
- [Writing programs](#writing-programs)
|
|
18
|
+
- [Terms and names](#terms-and-names)
|
|
19
|
+
- [Deriving rules](#deriving-rules)
|
|
20
|
+
- [Inspecting rules](#inspecting-rules)
|
|
21
|
+
- [RDF 1.2](#rdf-12)
|
|
22
|
+
- [How eyemind reasons](#how-eyemind-reasons)
|
|
23
|
+
- [Proofs, and what checking one means](#proofs-and-what-checking-one-means)
|
|
24
|
+
- [Why negation and collection are safe](#why-negation-and-collection-are-safe)
|
|
25
|
+
- [Checking the translation](#checking-the-translation)
|
|
26
|
+
- [Examples and the playground](#examples-and-the-playground)
|
|
27
|
+
- [Command line](#command-line)
|
|
28
|
+
- [Troubleshooting](#troubleshooting)
|
|
29
|
+
- [JavaScript library](#javascript-library)
|
|
30
|
+
- [What is deliberately absent](#what-is-deliberately-absent)
|
|
31
|
+
- [Development](#development)
|
|
32
|
+
- [Releases](#releases)
|
|
33
|
+
- [The name](#the-name)
|
|
34
|
+
|
|
35
|
+
## Why eyemind?
|
|
36
|
+
|
|
37
|
+
Prolog, Datalog, N3 and SRL already exist, and eyemind adds no new logic: rules run to a least fixpoint, with stratified negation and aggregation. What it adds is that it does not stop at the answer. Every conclusion can come with a proof that a separate checker verifies against your program, without calling the reasoner.
|
|
38
|
+
|
|
39
|
+
1. **The proof covers everything that went into the answer.**
|
|
40
|
+
- Most engines show an answer, or at best a trace you have to trust.
|
|
41
|
+
- eyemind proofs include the hard parts:
|
|
42
|
+
- "nothing matched" (negation and collections), backed by a search certificate whose listings must be closed (C9);
|
|
43
|
+
- what a rule says exists, as the Skolem term of that rule firing (C8);
|
|
44
|
+
- whether each answer really answers the question asked (C10).
|
|
45
|
+
- A forged proof must never pass the check, so a result is something you can hand to someone who does not trust your engine.
|
|
46
|
+
2. **Programs are plain JavaScript.**
|
|
47
|
+
- There is no syntax to learn, no parser to install and no dependency.
|
|
48
|
+
- The same program runs on the command line, as a library and in a browser tab.
|
|
49
|
+
- Conclusions and proofs are data that is read back into terms without being run.
|
|
50
|
+
3. **Forward and backward reasoning in one program.**
|
|
51
|
+
- Classic Datalog is forward-only and has no function terms; Prolog is backward-only.
|
|
52
|
+
- eyemind does both: forward rounds compute what follows, backward search answers questions, the two call each other, and what a rule says exists becomes a Skolem term.
|
|
53
|
+
4. **A specification written for other implementers.**
|
|
54
|
+
- The specification and its black-box [conformance suite](https://eyereasoner.github.io/eyemind/conformance/) let someone else build an independent eyemind and test it.
|
|
55
|
+
- Agreement between independent implementations is what makes a proof worth more than "trust our code".
|
|
56
|
+
5. **Exact numbers.** Integers are BigInts and are never silently turned into floats.
|
|
57
|
+
|
|
58
|
+
When eyemind is not the right tool:
|
|
59
|
+
|
|
60
|
+
- 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
|
+
- 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
|
+
## Install and run
|
|
65
|
+
|
|
66
|
+
eyemind needs Node.js 18 or later and nothing else. Install the command with `npm install --global eyemind`, or run `node bin/eyemind.js` from a checkout:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
eyemind examples/socrates.js
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
prints
|
|
21
73
|
|
|
22
74
|
```js
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
implies([type(S, A), subclass_of(A, B)], type(S, B))
|
|
26
|
-
query(type(X, Y))
|
|
75
|
+
type('socrates', 'mortal')
|
|
76
|
+
type('socrates', 'human')
|
|
27
77
|
```
|
|
28
78
|
|
|
79
|
+
Ask for the explanation, and check it:
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
eyemind --proof examples/socrates.js > /tmp/socrates-proof.js
|
|
83
|
+
eyemind --check-proof /tmp/socrates-proof.js examples/socrates.js
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The report ends with `verdict('checked')`. `eyemind -c examples/socrates.js` does both in one command.
|
|
87
|
+
|
|
88
|
+
## Your first program
|
|
89
|
+
|
|
90
|
+
Save this as `/tmp/family.js`, or paste it into the [playground](https://eyereasoner.github.io/eyemind/playground/):
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
fact(parent('alice', 'bob'))
|
|
94
|
+
fact(parent('bob', 'carol'))
|
|
95
|
+
|
|
96
|
+
implies(parent(X, Y), ancestor(X, Y))
|
|
97
|
+
implies([ancestor(X, Y), parent(Y, Z)], ancestor(X, Z))
|
|
98
|
+
|
|
99
|
+
implied_by(related(X, Y), ancestor(X, Y))
|
|
100
|
+
implied_by(related(X, Y), ancestor(Y, X))
|
|
101
|
+
|
|
102
|
+
query(related('alice', 'carol'))
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`eyemind /tmp/family.js` prints `related('alice', 'carol')`. The `implies` rules run forward, adding conclusions until nothing new follows; the `implied_by` rules run backward, only when a goal asks for them. Without a `query`, a run prints the facts it derived; `--goal` asks a question from outside:
|
|
106
|
+
|
|
29
107
|
```sh
|
|
30
|
-
|
|
31
|
-
node bin/eyemind.js -c examples/socrates.js
|
|
32
|
-
node bin/eyemind.js --proof examples/socrates.js > /tmp/proof.js
|
|
33
|
-
node bin/eyemind.js --check-proof /tmp/proof.js examples/socrates.js
|
|
108
|
+
eyemind --goal "ancestor('alice', Who)" /tmp/family.js
|
|
34
109
|
```
|
|
35
110
|
|
|
111
|
+
Now add `fact(parent('carol', 'dave'))`, or remove a rule, and watch which answers appear or disappear.
|
|
112
|
+
|
|
113
|
+
## Writing programs
|
|
114
|
+
|
|
115
|
+
| Call | Meaning |
|
|
116
|
+
| --- | --- |
|
|
117
|
+
| `fact(...Heads)` | Each head holds. |
|
|
118
|
+
| `implies(Premise, Conclusion)` | A forward rule: whenever `Premise` holds, conclude `Conclusion`. |
|
|
119
|
+
| `implied_by(Conclusion, Premise)` | A backward rule: `Conclusion` holds when `Premise` does, decided when a goal asks. |
|
|
120
|
+
| `query(...Body)` | Publish every instance of `Body` that holds. |
|
|
121
|
+
| `contradiction(...Body)` | Stop with exit code 65 when `Body` holds: an integrity constraint. |
|
|
122
|
+
| `facts_from(path)`, `facts_from({text})` | State every expression of a document as a fact, without running it. |
|
|
123
|
+
|
|
124
|
+
**An array is a conjunction:** `implies([p(X), q(X)], [r(X), s(X)])`. Disjunction is `or(A, B)` and negation `not(G)`, alongside `call`, `once` and `findall`.
|
|
125
|
+
|
|
126
|
+
### Terms and names
|
|
127
|
+
|
|
128
|
+
- **Nothing to declare.** An undeclared name is a variable when it starts with a capital or `_` (`X`, `_Rest`) and a predicate otherwise (`parent`). `_` is a fresh variable at each use. JavaScript globals such as `Math` and `JSON` keep their meaning; `const range = preds('range')` declares a predicate whose name would otherwise clash. A misspelled statement such as `fcat(p(1))` states nothing, so eyemind stops with an error.
|
|
129
|
+
- **Terms are JavaScript values.** An atom is a string, `'socrates'`; a list is an array, with `[H, ...T]` for head and tail; a compound term is a call, `parent('alice', 'bob')`; `struct('hello world', X)` builds one whose name is not an identifier.
|
|
130
|
+
- **JavaScript computes the clauses.** Loops, functions and constants work as usual; once stated, a clause is a term, and reasoning calls none of your code:
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
for (let level = 1; level <= 10; level++) {
|
|
134
|
+
implied_by(type(X, `n${level}`), type(X, `n${level - 1}`))
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
- **Arithmetic is a term, not an operator.** `is(Y, add(X, 1))` computes and `gt(X, 1)` compares. `X + 1` or `X > 1` stops the program with a message saying what to write instead, and operators on plain numbers are JavaScript's own (`2 ** 60 + 1` arrives already rounded). The primitives are listed in [SPEC §4](https://eyereasoner.github.io/eyemind/SPEC#4-goals-and-primitives) and the arithmetic functions in [SPEC §5](https://eyereasoner.github.io/eyemind/SPEC#5-arithmetic).
|
|
139
|
+
- **Numbers are exact.** An integral number is an integer, `2` and `2.0` alike, and `float(2)` is a float; write integers beyond 2^53 as a `BigInt`, `9007199254740993n`. `1` and `float(1)` do not unify, yet compare equal.
|
|
140
|
+
- **Something exists.** A variable only a forward rule's conclusion mentions becomes a Skolem term of that firing: `implies(person(X), has_parent(X, P))` concludes `has_parent('ann', skolem(2, 'P', ['ann']))`.
|
|
141
|
+
- **Data is not a program.** Everything eyemind writes is a *document* of plain expressions. `facts_from` reads one as facts and never executes it, so it is the safe way to take in data you do not trust, and lets one run reason over another's proof, as [audited-grants](https://github.com/eyereasoner/eyemind/blob/main/examples/audited-grants.js) does.
|
|
142
|
+
|
|
143
|
+
### Deriving rules
|
|
144
|
+
|
|
145
|
+
A rule's conclusion may contain rules, written with the same calls:
|
|
146
|
+
|
|
147
|
+
```js
|
|
148
|
+
fact(enabled('demo'), p('a'), q('a'))
|
|
149
|
+
implies(enabled(Name), [
|
|
150
|
+
implies([p(X), q(X)], [r(Name, X), s(Name, X)]),
|
|
151
|
+
implied_by([known(Name, X), available(Name, X)], r(Name, X)),
|
|
152
|
+
])
|
|
153
|
+
query([known('demo', X), available('demo', X)])
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
This reports `and(known('demo', 'a'), available('demo', 'a'))`. `Name` is captured from the generating rule; `X`, mentioned only inside the templates, is fresh each time a derived rule is applied. Every potential derived rule takes part in stratification before reasoning starts, and a proof cites the generator's premises directly. See the [derived rule deck](https://eyereasoner.github.io/eyemind/examples/deck/derived-rule) and [SPEC §6.2](https://eyereasoner.github.io/eyemind/SPEC#62-inline-rule-templates).
|
|
157
|
+
|
|
158
|
+
### Inspecting rules
|
|
159
|
+
|
|
160
|
+
In a premise, the same calls match the program's own rules as data:
|
|
161
|
+
|
|
162
|
+
```js
|
|
163
|
+
fact(a('b'))
|
|
164
|
+
implies(a(X), c(X))
|
|
165
|
+
implies(implies(X, Y), test(X, Y))
|
|
166
|
+
query(test(X, Y))
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
The answer is `test(a(A), c(A))`, with the shared variable preserved. Inspection sees ordinary source rules only, not facts, queries, generators or itself, and its proof step names the source rule it matched. See the [rule inspection deck](https://eyereasoner.github.io/eyemind/examples/deck/rule-inspection) and [SPEC §6.3](https://eyereasoner.github.io/eyemind/SPEC#63-source-rule-inspection).
|
|
170
|
+
|
|
171
|
+
### RDF 1.2
|
|
172
|
+
|
|
173
|
+
eyemind has no built-in RDF; RDF arrives as data through [rdf-interchange](https://github.com/eyereasoner/rdf-interchange). `rdf-to-eyemind` turns Turtle, TriG, N-Triples or N-Quads into `rdf(Subject, Predicate, Object, Graph)` facts for `facts_from`, and `eyemind-to-rdf` turns a run's `rdf` or `result_rdf` conclusions back into RDF:
|
|
174
|
+
|
|
175
|
+
| RDF 1.2 | eyemind term |
|
|
176
|
+
| --- | --- |
|
|
177
|
+
| IRI | `iri('https://example.org/bob')` |
|
|
178
|
+
| Blank node | `bnode(Scope, Label)` |
|
|
179
|
+
| Typed literal | `literal('42', datatype('http://www.w3.org/2001/XMLSchema#integer'))` |
|
|
180
|
+
| Language string | `literal('chat', lang('fr'))`, or `lang('ar', 'rtl')` with a direction |
|
|
181
|
+
| Triple term | `triple(S, P, O)`, which may nest |
|
|
182
|
+
| Default graph, named graph | `'default_graph'`, `iri(Name)` |
|
|
183
|
+
|
|
184
|
+
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.
|
|
185
|
+
|
|
186
|
+
## How eyemind reasons
|
|
187
|
+
|
|
188
|
+
The statement chooses the direction:
|
|
189
|
+
|
|
190
|
+
| Strategy | Stated with | How it works |
|
|
191
|
+
| --- | --- | --- |
|
|
192
|
+
| **Forward** | `implies`, `query`, `contradiction` | From the facts, round after round, until a round adds nothing new. |
|
|
193
|
+
| **Backward** | `implied_by`, `fact` | When a goal asks: depth-first, left to right, in the order the clauses are written. |
|
|
194
|
+
|
|
195
|
+
Forward rules suit closures and classifications: `implies([path(X, Y), edge(Y, Z)], path(X, Z))` terminates on a cyclic graph. Backward rules suit computations driven by their inputs, such as arithmetic recursion and list processing. Backward chaining keeps no table of answers, so a backward rule that calls itself with the same goal runs until a bound stops it; such recursion belongs in a forward rule.
|
|
196
|
+
|
|
197
|
+
The two work together: a forward rule's premise can call a backward definition, and a backward goal sees the facts forward rules derived. Forward rules run stratum by stratum, so a negation or `findall` waits until everything it inspects is final. `--max-depth`, `--max-iterations` and `--max-inferences` bound a run, and exceeding one is an error, never a partial answer. [SPEC §8](https://eyereasoner.github.io/eyemind/SPEC#8-evaluation-and-conclusions) defines the details.
|
|
198
|
+
|
|
199
|
+
## Proofs, and what checking one means
|
|
200
|
+
|
|
201
|
+
A proof holds the claims, the source clauses it cites, and one `step(...)` per inference. Checking applies ten conditions:
|
|
202
|
+
|
|
203
|
+
| | Condition | What it establishes |
|
|
204
|
+
| --- | --- | --- |
|
|
205
|
+
| **C1** | resolution | Every step is an instance of a program clause |
|
|
206
|
+
| **C2** | well-foundedness | The derivation has no cycles |
|
|
207
|
+
| **C3** | justification | Every step's justification is known, well-formed and unique |
|
|
208
|
+
| **C4** | coverage | Every claim and premise is accounted for |
|
|
209
|
+
| **C5** | re-decision | Built-in calculations are recomputed, not trusted (math-library floats within 4 units in the last place) |
|
|
210
|
+
| **C6** | boundary consistency | No unsettled absence or collection is contradicted by the evidence |
|
|
211
|
+
| **C7** | relevance | Every claim answers the question, and every step serves a claim |
|
|
212
|
+
| **C8** | witness integrity | Every "something exists" uses the Skolem term of its own firing |
|
|
213
|
+
| **C9** | search closure | Every absence and collection the search certificate settles holds |
|
|
214
|
+
| **C10** | call fidelity | Each answer is an actual answer of the original question |
|
|
215
|
+
|
|
216
|
+
**The checker follows the certificate:** it never calls the reasoner, so a missing step fails rather than being quietly re-derived. **The source is the authority:** clauses a proof displays cannot override the program. Proofs are read as data, so checking someone else's proof runs none of their code, and every proof eyemind generates is checked before it is returned. The report is a document too:
|
|
217
|
+
|
|
218
|
+
```js
|
|
219
|
+
// Checked answers: these follow from the input program.
|
|
220
|
+
type('socrates', 'mortal')
|
|
221
|
+
type('socrates', 'human')
|
|
222
|
+
|
|
223
|
+
// C1-C10: resolution, acyclicity, justification, coverage, re-decision,
|
|
224
|
+
// boundary consistency, relevance, witness integrity, search closure and call fidelity.
|
|
225
|
+
condition('C1', 'resolution', 'ok', 3)
|
|
226
|
+
condition('C2', 'well_founded', 'ok', 3)
|
|
227
|
+
condition('C3', 'justification', 'ok', 3)
|
|
228
|
+
condition('C4', 'coverage', 'ok', 4)
|
|
229
|
+
condition('C5', 're_decision', 'ok', 0)
|
|
230
|
+
condition('C6', 'boundary_consistency', 'ok', 0)
|
|
231
|
+
condition('C7', 'relevance', 'ok', 5)
|
|
232
|
+
condition('C8', 'witness_integrity', 'ok', 0)
|
|
233
|
+
condition('C9', 'search_closure', 'ok', 0)
|
|
234
|
+
condition('C10', 'call_fidelity', 'ok', 2)
|
|
235
|
+
|
|
236
|
+
// Proof statistics: recorded steps and how they were checked.
|
|
237
|
+
steps(3)
|
|
238
|
+
verified(3)
|
|
239
|
+
recomputed(0)
|
|
240
|
+
composed(0)
|
|
241
|
+
trusted(0)
|
|
242
|
+
claims(2)
|
|
243
|
+
|
|
244
|
+
// This verdict applies to the claims above; it does not establish completeness.
|
|
245
|
+
verdict('checked')
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
A failed check gives `failure(Condition, Conclusion, Detail)` facts, `verdict(failed(N))` and exit code 2. What a certificate cannot settle stays an `obligation(...)` with the verdict `checked_with_obligations`; `--strict-proof` rejects those. To check answers to `--goal` questions, pass the same goals when checking. [SPEC §11](https://eyereasoner.github.io/eyemind/SPEC#11-proof-checking) defines every condition.
|
|
249
|
+
|
|
250
|
+
### Why negation and collection are safe
|
|
251
|
+
|
|
252
|
+
`not(G)` concludes from what is *absent* and `findall(T, G, L)` from *everything* present, so both are only right once nothing more can be derived:
|
|
253
|
+
|
|
254
|
+
- **Ask only once the answer is final.** Rules are ranked so that everything a negation or collection inspects reaches its fixpoint first; a program with no such ranking, such as `implies(not(q), p)` with `implies(p, q)`, is rejected.
|
|
255
|
+
- **Negate only what is bound.** The variables of `not(G)` must be bound when it runs; write `not(q(X, _))` for "no value at all".
|
|
256
|
+
- **Check the search, not just its result.** A proof ends with a search certificate: `searched(Call, Answers)` lists each call's answers and `derived(Pattern, Facts)` each consulted relation. The checker expands each call one level against the program, so a wrong table shows up as a disagreement.
|
|
257
|
+
- **Say what was taken on trust.** Anything the certificate cannot settle becomes an obligation, and evidence in the proof can still refute it (C6).
|
|
258
|
+
|
|
259
|
+
## Checking the translation
|
|
260
|
+
|
|
261
|
+
A checked proof shows that conclusions follow from the program, not that the program says what the law or the textbook says. `--unused` points at the clauses that make no difference, where a translation is most likely decorative, incomplete or untested:
|
|
262
|
+
|
|
263
|
+
```js
|
|
264
|
+
fact(p('a'))
|
|
265
|
+
fact(q('b'))
|
|
266
|
+
implied_by(s(X), q(X))
|
|
267
|
+
fact(z('c'))
|
|
268
|
+
implies([p('a'), not(s('a'))], ok)
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
```text
|
|
272
|
+
$ eyemind --unused program.js
|
|
273
|
+
unused(line(2), fact(q('b')))
|
|
274
|
+
unused(line(3), implied_by(s(X), q(X)))
|
|
275
|
+
unused(line(4), fact(z('c')))
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
A clause is listed when no conclusion's proof uses it; a clause only a negation consults, as `not(s('a'))` consults `q('b')`, is listed only if leaving it out changes no conclusion.
|
|
279
|
+
|
|
280
|
+
## Examples and the playground
|
|
281
|
+
|
|
282
|
+
The [examples](https://eyereasoner.github.io/eyemind/examples/) range from classics (Ackermann, the zebra puzzle) to planning, policy reasoning, mathematics, RDF 1.2 data and a hundred-thousand-level taxonomy. Each has its conclusions, proof and check report saved in `examples/output/`, `examples/proof/` and `examples/check/`, and a card deck for a wide audience. Change a fact, run it, and compare with the saved output.
|
|
283
|
+
|
|
284
|
+
The [playground](https://eyereasoner.github.io/eyemind/playground/) runs eyemind in a worker in your browser, so **Stop** ends a long run. Choose an example, edit it, pick an output (conclusions, proof, check of a saved proof, or unused clauses) and press **Run** or Ctrl+Enter. A line an error names is marked red, the options panel shows the equivalent command, and **Share link** copies a link with the program and options.
|
|
285
|
+
|
|
286
|
+
## Command line
|
|
287
|
+
|
|
288
|
+
```text
|
|
289
|
+
eyemind [OPTION ...] [FILE ...]
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
| Option | Meaning |
|
|
293
|
+
| --- | --- |
|
|
294
|
+
| (none) | Load the files, or standard input, as one program and print its conclusions. |
|
|
295
|
+
| `-p`, `--proof` | Print the proof instead. |
|
|
296
|
+
| `-c`, `--prove-and-check` | Generate a proof, check it, and print the checked answers with the report. |
|
|
297
|
+
| `--check-proof FILE` | Check a saved proof (`-` for standard input) against the program. |
|
|
298
|
+
| `--json` | With a checking mode, print the report as JSON. |
|
|
299
|
+
| `--goal GOAL` | Ask `GOAL` after forward reasoning; may be repeated. |
|
|
300
|
+
| `--strict-proof` | With a checking mode, reject proofs with any obligation. |
|
|
301
|
+
| `--unused` | List the clauses that make no difference to the conclusions. |
|
|
302
|
+
| `--stats` | Print reasoning statistics as JSON to standard error. |
|
|
303
|
+
| `--max-depth N`, `--max-iterations N`, `--max-inferences N` | Bound backward depth (1000000), forward rounds per stratum (1000) and goals started (1000000). |
|
|
304
|
+
| `-v`, `--version`, `-h`, `--help` | Print the version or the usage. |
|
|
305
|
+
|
|
306
|
+
Exit codes: 0 success, 1 error, 2 a proof that is not valid, 65 a contradiction.
|
|
307
|
+
|
|
308
|
+
## Troubleshooting
|
|
309
|
+
|
|
310
|
+
| What you see | What to do |
|
|
311
|
+
| --- | --- |
|
|
312
|
+
| `operators do not apply to terms` | Write `add(X, 1)` or `gt(X, 1)` instead of `X + 1` or `X > 1`, and `[g1, g2]` for a conjunction. |
|
|
313
|
+
| `true is not a term` | JavaScript decided `1 < 2` itself; write `lt(1, 2)`. |
|
|
314
|
+
| `fcat(...) on its own states nothing` | Wrap it in `fact(...)` or fix the spelling. |
|
|
315
|
+
| `negation requires a goal whose variables are bound` | Bind the variables before `not(...)`, or use `_`. |
|
|
316
|
+
| `unstratified negation or collection dependency` | A negation or collection depends on its own conclusion; see [why negation and collection are safe](#why-negation-and-collection-are-safe). |
|
|
317
|
+
| `exceeded max_depth` or another bound | Usually a left-recursive backward rule; make it forward, or raise the bound. |
|
|
318
|
+
| A goal with no arguments finds nothing | In goal text a bare name is a variable; write `p()` or `'p'`. |
|
|
319
|
+
| `this is a proof document, not a program` | Check it with `--check-proof PROOF PROGRAM`. |
|
|
320
|
+
|
|
321
|
+
## JavaScript library
|
|
322
|
+
|
|
323
|
+
```js
|
|
324
|
+
import { checkProof, loadText, run } from 'eyemind';
|
|
325
|
+
|
|
326
|
+
const socrates = loadText(`
|
|
327
|
+
fact(human('socrates'))
|
|
328
|
+
implies(human(X), mortal(X))
|
|
329
|
+
`);
|
|
330
|
+
const goals = ['mortal(X)'];
|
|
331
|
+
const result = run(socrates, { goals, proof: true });
|
|
332
|
+
console.log(result.answers);
|
|
333
|
+
console.log(result.bindings);
|
|
334
|
+
console.log(checkProof(socrates, result.proof, { goals }).valid);
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
`run()` returns `answers`, `bindings`, `inferred`, `stdout`, `proof`, `proofReport`, `stats` and `haltCode`, and takes `goal`, `goals`, `proof`, `maxDepth`, `maxIterations` and `maxInferences`; exceeding a bound throws an `EyemindError`. `loadSources([[text, filename], ...], io)` loads several sources as one program; pass `nodeIO` from `eyemind/node` as `io` to let `facts_from(path)` read files. `checkProof(program, document, { goals, allowTrusted })` checks C1–C10, and `allowTrusted: false` rejects every obligation. `checkReport`, `readTerm`, `readTerms` and `write` format reports and read and write the canonical text.
|
|
338
|
+
|
|
339
|
+
## What is deliberately absent
|
|
340
|
+
|
|
341
|
+
Cut, conditional commitment, mutable databases, attributed variables, constraint libraries, tabling, and filesystem or network built-ins. Without cut and a mutable database, a derivation is a function of the program and its input, which is what makes a certificate meaningful. Undefined predicates fail.
|
|
342
|
+
|
|
343
|
+
## Development
|
|
344
|
+
|
|
345
|
+
```sh
|
|
346
|
+
npm test # unit, examples, conformance, command line, playground
|
|
347
|
+
npm test -- unit examples # only these sections
|
|
348
|
+
npm test -- -k skolem # only tests whose line contains "skolem"
|
|
349
|
+
EYEMIND_PROPERTY_SCALE=20 npm test -- -k properties # deeper generated tests
|
|
350
|
+
node tools/update-examples.js # regenerate example artifacts after an intended change
|
|
351
|
+
node conformance/run.js --command "my-eyemind" # run the conformance suite against another implementation
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
The full suite needs a few GB of memory; on a small machine run it under a cap, such as `systemd-run --user --scope -q -p MemoryMax=3G -p MemorySwapMax=0 -- npm test`. Generated tests forge saved proofs at random and require the checker to reject every forgery that claims more than the program entails. The playground tests need Chrome (`CHROME` names it). When adding an example, register it in [examples/manifest.json](https://github.com/eyereasoner/eyemind/blob/main/examples/manifest.json), write its deck in `examples/deck/`, and generate its artifacts.
|
|
355
|
+
|
|
356
|
+
### Releases
|
|
357
|
+
|
|
358
|
+
`./release patch "Describe the changes"` (or `minor`, `major`) requires a clean tree, pulls `main`, runs the tests, bumps the version, and pushes `main` with an annotated tag. The tag creates the GitHub release, which Zenodo archives, and publishes to npm through trusted publishing, with no stored token. To publish an existing tag again, use **Actions → Publish to npm → Run workflow**.
|
|
359
|
+
|
|
360
|
+
## The name
|
|
361
|
+
|
|
362
|
+
**eyemind** joins *eye*, after the [EYE](https://github.com/eyereasoner/eye) family of reasoners, to *mind*: facts and rules lead to conclusions whose reasoning can be inspected and checked.
|
|
363
|
+
|
|
36
364
|
MIT licensed; see [LICENSE.md](LICENSE.md).
|
package/SPEC.md
CHANGED
package/package.json
CHANGED
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// The release this checkout is; ./release keeps it in step with package.json.
|
|
2
|
-
export const VERSION = '0.3.
|
|
2
|
+
export const VERSION = '0.3.8';
|