eyemind 0.6.1 → 0.6.2
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 +11 -9
- package/SPEC.md +10 -10
- package/package.json +4 -2
- package/src/cli.js +3 -3
- package/src/formats.js +4 -4
- package/src/index.js +4 -4
- package/src/lang.js +2 -2
- package/src/n3-builtins.js +2 -2
- package/src/n3.js +3 -3
- package/src/srl-functions.js +2 -2
- package/src/srl.js +1 -1
- package/src/version.js +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://doi.org/10.5281/zenodo.23824021)
|
|
4
4
|
[](https://www.npmjs.com/package/eyemind)
|
|
5
5
|
|
|
6
|
-
eyemind is a
|
|
6
|
+
eyemind is a dependency-free reasoner for **Logic Script (LS)**, a rule language with JavaScript syntax. LS programs state facts, rules, and queries; eyemind draws conclusions using forward and backward reasoning, and can produce proofs that a separate checker verifies against your program. It interoperates with **RDF 1.2**, **Notation3 (N3)** and **SPARQL 1.2 RL (SRL)**: RDF supplies data, and N3 and SRL compile to LS programs whose proofs use the same checker. It runs as a command-line program, a JavaScript library, and a browser application.
|
|
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
|
|
|
@@ -49,7 +49,7 @@ Prolog, Datalog, N3 and SRL already exist, and eyemind adds no new logic: rules
|
|
|
49
49
|
- what a rule says exists, as the Skolem term of that rule firing;
|
|
50
50
|
- whether each answer really answers the question asked, and whether every answer of the question is there.
|
|
51
51
|
- A forged proof must never pass the check, so a result is something you can hand to someone who does not trust your engine.
|
|
52
|
-
2. **
|
|
52
|
+
2. **Logic Script programs are JavaScript scripts.**
|
|
53
53
|
- There is no syntax to learn, no parser to install and no dependency.
|
|
54
54
|
- The same program runs on the command line, as a library and in a browser tab.
|
|
55
55
|
- Conclusions and proofs are data that is read back into terms without being run.
|
|
@@ -57,14 +57,14 @@ Prolog, Datalog, N3 and SRL already exist, and eyemind adds no new logic: rules
|
|
|
57
57
|
- Classic Datalog is forward-only and has no function terms; Prolog is backward-only.
|
|
58
58
|
- 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.
|
|
59
59
|
4. **A specification written for other implementers.**
|
|
60
|
-
- The specification and its black-box [conformance suite](https://eyereasoner.github.io/eyemind/conformance/) let someone else build an independent
|
|
60
|
+
- The specification and its black-box [conformance suite](https://eyereasoner.github.io/eyemind/conformance/) let someone else build an independent LS implementation and test it.
|
|
61
61
|
- Agreement between independent implementations is what makes a proof worth more than "trust our code".
|
|
62
62
|
5. **Exact numbers.** Integers are BigInts and are never silently turned into floats.
|
|
63
63
|
|
|
64
64
|
When eyemind is not the right tool:
|
|
65
65
|
|
|
66
66
|
- If you do not need proofs, use the mature tools: SWI-Prolog and XSB have tabling, and Soufflé is fast at scale.
|
|
67
|
-
- N3 and SRL are designed around RDF and Web data. eyemind does not compete there: RDF is read as data (see [RDF 1.2](#rdf-12)), and N3 programs and SRL rule sets compile to
|
|
67
|
+
- N3 and SRL are designed around RDF and Web data. eyemind does not compete there: RDF is read as data (see [RDF 1.2](#rdf-12)), and N3 programs and SRL rule sets compile to LS (see [Notation3](#notation3) and [SPARQL 1.2 RL](#sparql-12-rl)).
|
|
68
68
|
- 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.
|
|
69
69
|
|
|
70
70
|
## Install and run
|
|
@@ -93,7 +93,7 @@ The report ends with `verdict('checked')`. `eyemind -c examples/socrates.js` doe
|
|
|
93
93
|
|
|
94
94
|
## Your first program
|
|
95
95
|
|
|
96
|
-
Save this as `/tmp/family.js`, or paste it into the [playground](https://eyereasoner.github.io/eyemind/playground/):
|
|
96
|
+
Logic Script sources use the `.js` extension. Save this LS program as `/tmp/family.js`, or paste it into the [playground](https://eyereasoner.github.io/eyemind/playground/):
|
|
97
97
|
|
|
98
98
|
```js
|
|
99
99
|
fact(parent('alice', 'bob'))
|
|
@@ -200,7 +200,7 @@ A reified triple `<< s p o >>` and an annotation `{| ... |}` become their reifie
|
|
|
200
200
|
|
|
201
201
|
### Notation3
|
|
202
202
|
|
|
203
|
-
A file ending in `.n3` is Notation3: eyemind compiles its facts and rules into
|
|
203
|
+
A file ending in `.n3` is Notation3: eyemind compiles its facts and rules into an LS program, with the N3 built-ins it uses written as LS rules, and writes the conclusions back as N3. RDF default-graph data joins the N3 document as triples:
|
|
204
204
|
|
|
205
205
|
```sh
|
|
206
206
|
eyemind examples/family-n3.n3 # the derived triples as N3
|
|
@@ -341,7 +341,7 @@ returns `messages` plus its replay representation. Both take `format`,
|
|
|
341
341
|
|
|
342
342
|
### SPARQL 1.2 RL
|
|
343
343
|
|
|
344
|
-
A file ending in `.srl` is a [SPARQL 1.2 RL](https://www.w3.org/TR/sparql12-rl/) rule set: eyemind parses and analyzes it, then compiles it into
|
|
344
|
+
A file ending in `.srl` is a [SPARQL 1.2 RL](https://www.w3.org/TR/sparql12-rl/) rule set: eyemind parses and analyzes it, then compiles it into an LS program, with the SPARQL functions and aggregates it uses written as LS rules, and RDF data files given with it are its base graph. The result is the inference graph, as Turtle:
|
|
345
345
|
|
|
346
346
|
```sh
|
|
347
347
|
eyemind rules.srl facts.ttl # the inference graph as Turtle
|
|
@@ -402,7 +402,7 @@ The two work together: a forward rule's premise can call a backward definition,
|
|
|
402
402
|
|
|
403
403
|
A proof holds the claims, the certificate that answers the program's
|
|
404
404
|
questions, and the recorded firings behind derived facts as `step(...)`
|
|
405
|
-
records. Every input writes the same JavaScript proof: an N3 document or SRL rule set is compiled to an
|
|
405
|
+
records. Every input writes the same JavaScript proof: an N3 document or SRL rule set is compiled to an LS program, and
|
|
406
406
|
its proof cites that program's clauses, with triples as `rdf(S, P, O)` (an
|
|
407
407
|
SRL inference as `inf(S, P, O)`) over `iri(...)` and `literal(...)` terms:
|
|
408
408
|
|
|
@@ -528,7 +528,7 @@ eyemind [OPTION ...] [FILE ...]
|
|
|
528
528
|
|
|
529
529
|
| Option | Meaning |
|
|
530
530
|
| --- | --- |
|
|
531
|
-
| (none) | Load the files, or standard input, as one program and print its conclusions. `.ttl`, `.trig`, `.nt` and `.nq` files
|
|
531
|
+
| (none) | Load the files, or standard input, as one program and print its conclusions. `.js` files and standard input are Logic Script, `.ttl`, `.trig`, `.nt` and `.nq` files RDF data, `.n3` Notation3 and `.srl` a SPARQL 1.2 RL rule set. |
|
|
532
532
|
| `-p`, `--proof` | Print the proof instead. |
|
|
533
533
|
| `-c`, `--prove-and-check` | Generate a proof, check it, and print the checked answers with the report. |
|
|
534
534
|
| `--check-proof FILE` | Check a saved proof (`-` for standard input) against the program. |
|
|
@@ -714,4 +714,6 @@ the scorer's `--live` option checks the current remote resources instead.
|
|
|
714
714
|
|
|
715
715
|
**eyemind** joins *eye* and *mind*: facts and rules lead to conclusions whose reasoning can be inspected and checked.
|
|
716
716
|
|
|
717
|
+
**Logic Script (LS)** names the language: facts, rules, and queries written in JavaScript syntax. eyemind is the reasoner that runs LS programs and checks their proofs.
|
|
718
|
+
|
|
717
719
|
MIT licensed; see [LICENSE.md](LICENSE.md).
|
package/SPEC.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# <img src="assets/eye.png" alt="" width="48" height="48" align="absmiddle">
|
|
1
|
+
# <img src="assets/eye.png" alt="" width="48" height="48" align="absmiddle"> Logic Script (LS) specification
|
|
2
2
|
|
|
3
3
|
```text
|
|
4
|
-
Title: The
|
|
5
|
-
Version: eyemind 0.6.
|
|
4
|
+
Title: The Logic Script (LS) Language and Proof Format
|
|
5
|
+
Version: eyemind 0.6.2
|
|
6
6
|
```
|
|
7
7
|
|
|
8
|
-
This document specifies the syntax and meaning of
|
|
9
|
-
documents, their observable evaluation, their proofs, and
|
|
10
|
-
checked.
|
|
8
|
+
This document specifies Logic Script (LS): the syntax and meaning of its
|
|
9
|
+
programs and data documents, their observable evaluation, their proofs, and
|
|
10
|
+
how a proof is checked. eyemind is an implementation of LS.
|
|
11
11
|
|
|
12
12
|
## Table of Contents
|
|
13
13
|
|
|
@@ -83,9 +83,9 @@ checked.
|
|
|
83
83
|
|
|
84
84
|
### 1.1 Scope
|
|
85
85
|
|
|
86
|
-
This specification defines
|
|
86
|
+
This specification defines Logic Script's terms, program syntax, semantics,
|
|
87
87
|
evaluation, data documents, proof documents and proof checking.
|
|
88
|
-
|
|
88
|
+
LS programs are JavaScript scripts. Conclusions, proofs and check reports are
|
|
89
89
|
data documents whose expressions MUST be read without execution.
|
|
90
90
|
|
|
91
91
|
The requirements apply to any conforming implementation. JavaScript is the
|
|
@@ -285,8 +285,8 @@ own code point; a valid surrogate pair denotes one supplementary code point.
|
|
|
285
285
|
|
|
286
286
|
### 3.1 Scripts
|
|
287
287
|
|
|
288
|
-
A program consists of one or more non-strict JavaScript scripts.
|
|
289
|
-
may use JavaScript declarations, expressions, functions and control flow to
|
|
288
|
+
A Logic Script program consists of one or more non-strict JavaScript scripts.
|
|
289
|
+
Each script may use JavaScript declarations, expressions, functions and control flow to
|
|
290
290
|
construct its clauses. No import is required for the statements and term
|
|
291
291
|
constructors defined here. Clauses are stated in the order their statement
|
|
292
292
|
calls occur; multiple input scripts are processed in input order. Each
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eyemind",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "A dependency-free
|
|
3
|
+
"version": "0.6.2",
|
|
4
|
+
"description": "A dependency-free Logic Script (LS) reasoner with forward and backward reasoning, checkable proofs, and RDF 1.2, Notation3 (N3) and SPARQL 1.2 RL (SRL) interoperability.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
"reasoner",
|
|
31
31
|
"rules",
|
|
32
32
|
"logic",
|
|
33
|
+
"logic-script",
|
|
34
|
+
"javascript",
|
|
33
35
|
"proof",
|
|
34
36
|
"datalog"
|
|
35
37
|
],
|
package/src/cli.js
CHANGED
|
@@ -8,9 +8,9 @@ import { VERSION } from './version.js';
|
|
|
8
8
|
import { srlContextFromProof } from './srl.js';
|
|
9
9
|
|
|
10
10
|
export const HELP = `Usage: eyemind [OPTION ...] [FILE ...]
|
|
11
|
-
|
|
12
|
-
by
|
|
13
|
-
and .srl as a SPARQL 1.2 RL rule set, both compiled to
|
|
11
|
+
Logic Script (LS) programs use JavaScript syntax. Forward rules run to a fixpoint.
|
|
12
|
+
Files are read by extension: .js as LS, .ttl, .trig, .nt and .nq as RDF 1.2 data,
|
|
13
|
+
.n3 as Notation3 and .srl as a SPARQL 1.2 RL rule set, both compiled to LS.
|
|
14
14
|
-p, --proof Print a proof of the conclusions
|
|
15
15
|
-c, --prove-and-check Generate a proof and check it against the input program
|
|
16
16
|
--check-proof FILE Check a proof and print its answers and verdict (- for stdin)
|
package/src/formats.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
// The inputs of a run in other formats than
|
|
1
|
+
// The inputs of a run in other formats than Logic Script, and its output as
|
|
2
2
|
// RDF or N3.
|
|
3
3
|
//
|
|
4
4
|
// A file's extension says what it holds:
|
|
5
5
|
//
|
|
6
|
-
// .js and standard input
|
|
6
|
+
// .js and standard input a Logic Script (LS) program
|
|
7
7
|
// .ttl .trig .nt .nq RDF 1.2 data: with a program, rdf(S, P, O, G)
|
|
8
8
|
// facts; with an N3 document, default triples and
|
|
9
9
|
// graph:content formulas for named graphs; with a
|
|
10
10
|
// rule set, its base graph
|
|
11
|
-
// .n3 Notation3, compiled to an
|
|
11
|
+
// .n3 Notation3, compiled to an LS program
|
|
12
12
|
// .srl a SPARQL 1.2 RL rule set, compiled to one
|
|
13
13
|
//
|
|
14
|
-
// The compiled program is ordinary
|
|
14
|
+
// The compiled program is ordinary LS: proofs, checking and --unused
|
|
15
15
|
// apply to it. SRL execution functions capture a context that a saved proof
|
|
16
16
|
// retains; compiling with that context reproduces the same program later.
|
|
17
17
|
import { EyemindError, Struct } from './terms.js';
|
package/src/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// eyemind: reasoning you can see, in JavaScript.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// against the program, using
|
|
3
|
+
// Logic Script (LS) states facts, rules and queries in JavaScript syntax.
|
|
4
|
+
// Forward rules materialize conclusions until a fixpoint; backward rules are
|
|
5
|
+
// decided when a goal asks for them. A separate checker verifies proofs
|
|
6
|
+
// against the program, using their call tables and recorded firings.
|
|
7
7
|
export { VERSION } from './version.js';
|
|
8
8
|
export { Result, run, unusedClauses } from './engine.js';
|
|
9
9
|
export { readGoal } from './goals.js';
|
package/src/lang.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// Writing programs in JavaScript.
|
|
1
|
+
// Writing Logic Script (LS) programs in JavaScript.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// An LS program is a JavaScript script that states facts, rules and queries:
|
|
4
4
|
//
|
|
5
5
|
// fact(type('socrates', 'human'))
|
|
6
6
|
// fact(subclass_of('human', 'mortal'))
|
package/src/n3-builtins.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// N3 built-ins as
|
|
1
|
+
// N3 built-ins as Logic Script backward rules.
|
|
2
2
|
//
|
|
3
3
|
// Each built-in predicate of a rule body becomes a goal n3_<ns>_<name>(S, O)
|
|
4
|
-
// whose definition is written here in
|
|
4
|
+
// whose definition is written here in Logic Script, so the compiled program
|
|
5
5
|
// is self-contained and every built-in step is an ordinary, checkable
|
|
6
6
|
// derivation. A definition lists the helpers it needs; the compiler copies
|
|
7
7
|
// the definitions a program uses, and their helpers, into the program.
|
package/src/n3.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// N3 documents compiled to
|
|
1
|
+
// N3 documents compiled to Logic Script (LS) programs.
|
|
2
2
|
//
|
|
3
3
|
// Every N3 statement becomes rdf(Subject, Predicate, Object): the document's
|
|
4
4
|
// own triples are facts, and a run concludes the triples its forward rules
|
|
5
|
-
// derive that were not already facts. Rules become
|
|
5
|
+
// derive that were not already facts. Rules become LS rules:
|
|
6
6
|
//
|
|
7
7
|
// { B } => { H }. implies(B, H) forward; restricted(B, H)
|
|
8
8
|
// when H has blank nodes
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
// backward rules. A quoted formula is a graph term: its own blank nodes and
|
|
21
21
|
// universals are qbnode(Label) and qvar(Name), and a rule's graph pattern
|
|
22
22
|
// matches it as a set, up to a one-to-one renaming of those. Built-in
|
|
23
|
-
// predicates of a body become goals defined in
|
|
23
|
+
// predicates of a body become goals defined in LS (n3-builtins.js).
|
|
24
24
|
import { run } from './engine.js';
|
|
25
25
|
import { loadText } from './lang.js';
|
|
26
26
|
import { Program, Source } from './program.js';
|
package/src/srl-functions.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// SPARQL expressions and aggregates as
|
|
1
|
+
// SPARQL expressions and aggregates as Logic Script backward rules.
|
|
2
2
|
//
|
|
3
3
|
// An expression compiles to goals that bind its value; a function is a goal
|
|
4
4
|
// srl_<name>(Arguments..., Result) whose definition is written here in
|
|
5
|
-
//
|
|
5
|
+
// Logic Script, so the compiled program is self-contained and every
|
|
6
6
|
// function step is an ordinary, checkable derivation. A SPARQL error is a
|
|
7
7
|
// goal that fails: FILTER then rejects the solution and SET drops it, as
|
|
8
8
|
// SPARQL 1.2 RL evaluates them. A definition lists the definitions it needs;
|
package/src/srl.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPARQL 1.2 RL rule sets compiled to
|
|
1
|
+
// SPARQL 1.2 RL rule sets compiled to Logic Script (LS) programs.
|
|
2
2
|
//
|
|
3
3
|
// Rule sets are read by the SRL tokenizer, parser and analysis (the
|
|
4
4
|
// srl-*.js files): parsing gives the rule set's data blocks and rules, and the
|
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.6.
|
|
2
|
+
export const VERSION = '0.6.2';
|