eyemind 0.8.2 → 0.8.4

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  eyemind reads `.le` files as the language defined here and compiles
4
4
  them to ordinary Logic Script (LS). This is an input extension; the meaning of
5
- the compiled program is defined by the [LS specification](https://eyereasoner.github.io/eyemind/SPEC).
5
+ the compiled program is defined by the [LS specification](https://eyereasoner.github.io/eyemind/LS-SPEC).
6
6
  It supports statements and computations in a fixed grammar. It does not parse
7
7
  arbitrary mathematical prose or check textbook proof arguments.
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  ```text
4
4
  Title: The Logic Script (LS) Language and Proof Format
5
- Version: eyemind 0.8.2
5
+ Version: eyemind 0.8.4
6
6
  ```
7
7
 
8
8
  This document specifies Logic Script (LS): the syntax and meaning of its
package/README.md CHANGED
@@ -3,11 +3,20 @@
3
3
  [![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.23824021-blue.svg)](https://doi.org/10.5281/zenodo.23824021)
4
4
  [![npm](https://img.shields.io/npm/v/eyemind.svg)](https://www.npmjs.com/package/eyemind)
5
5
 
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. **Logical English (LE)** also compiles to LS and writes `.le` conclusions. It runs as a command-line program, a JavaScript library, and a browser application.
6
+ A dependency-free Logic Script (LS) reasoner with forward and backward reasoning, checkable proofs, and RDF 1.2, Notation3 (N3), SPARQL 1.2 RL (SRL) and Logical English (LE) interoperability.
7
7
 
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/)
8
+ LS is a rule language with JavaScript syntax. eyemind draws conclusions from
9
+ facts, rules and queries, and every conclusion can come with a proof that a
10
+ separate checker verifies against your program. It runs as a command-line
11
+ program, a JavaScript library and a browser application.
9
12
 
10
- The playground runs programs in your browser; the specification defines the language, its canonical text, the proof format and how a proof is checked. The examples are 152 runnable programs, each with a card deck and saved conclusions, proofs and check reports. The conformance suite has 1246 cases that test language and proof behavior through a command adapter, together with implementation interface checks; run it [in your browser](https://eyereasoner.github.io/eyemind/playground/conformance).
13
+ [Playground](https://eyereasoner.github.io/eyemind/playground/) · [Examples](https://eyereasoner.github.io/eyemind/examples/) · [Specification](https://eyereasoner.github.io/eyemind/LS-SPEC) · [Conformance](https://eyereasoner.github.io/eyemind/conformance/)
14
+
15
+ The examples are 152 runnable programs, each with a card deck and saved
16
+ conclusions, proofs and check reports. The specification defines the language,
17
+ the proof format and how a proof is checked; its conformance suite has
18
+ 1246 cases that test language and proof behavior, and runs
19
+ [in your browser](https://eyereasoner.github.io/eyemind/playground/conformance).
11
20
 
12
21
  ## Contents
13
22
 
@@ -18,16 +27,13 @@ The playground runs programs in your browser; the specification defines the lang
18
27
  - [Terms and names](#terms-and-names)
19
28
  - [Deriving rules](#deriving-rules)
20
29
  - [Inspecting rules](#inspecting-rules)
30
+ - [Other formats](#other-formats)
21
31
  - [Logical English](#logical-english)
22
32
  - [RDF 1.2](#rdf-12)
23
33
  - [Notation3](#notation3)
24
34
  - [RDF Messages](#rdf-messages)
25
35
  - [SPARQL 1.2 RL](#sparql-12-rl)
26
- - [OWL 2 RL](#owl-2-rl)
27
- - [Combining RDF logic profiles](#combining-rdf-logic-profiles)
28
- - [QUDT quantities](#qudt-quantities)
29
- - [SKOS entailment](#skos-entailment)
30
- - [SHACL validation](#shacl-validation)
36
+ - [RDF logic profiles](#rdf-logic-profiles)
31
37
  - [ODRL snapshots](#odrl-snapshots)
32
38
  - [How eyemind reasons](#how-eyemind-reasons)
33
39
  - [Proofs, and what checking one means](#proofs-and-what-checking-one-means)
@@ -42,7 +48,6 @@ The playground runs programs in your browser; the specification defines the lang
42
48
  - [JavaScript library](#javascript-library)
43
49
  - [What is deliberately absent](#what-is-deliberately-absent)
44
50
  - [Development](#development)
45
- - [Releases](#releases)
46
51
  - [The name](#the-name)
47
52
 
48
53
  ## Why eyemind?
@@ -71,7 +76,7 @@ Prolog, Datalog, N3 and SRL already exist, and eyemind adds no new logic: rules
71
76
  When eyemind is not the right tool:
72
77
 
73
78
  - If you do not need proofs, use the mature tools: SWI-Prolog and XSB have tabling, and Soufflé is fast at scale.
74
- - 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)).
79
+ - N3 and SRL are designed around RDF and Web data. eyemind does not compete there: it reads them, and compiles them to LS (see [Other formats](#other-formats)).
75
80
  - 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.
76
81
 
77
82
  ## Install and run
@@ -151,7 +156,7 @@ for (let level = 1; level <= 10; level++) {
151
156
  }
152
157
  ```
153
158
 
154
- - **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).
159
+ - **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/LS-SPEC#4-goals-and-primitives) and the arithmetic functions in [SPEC §5](https://eyereasoner.github.io/eyemind/LS-SPEC#5-arithmetic).
155
160
  - **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.
156
161
  - **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']))`.
157
162
  - **Data is not a program.** eyemind's term documents are 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.
@@ -169,7 +174,7 @@ implies(enabled(Name), [
169
174
  query([known('demo', X), available('demo', X)])
170
175
  ```
171
176
 
172
- 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).
177
+ 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/LS-SPEC#62-inline-rule-templates).
173
178
 
174
179
  ### Inspecting rules
175
180
 
@@ -182,14 +187,21 @@ implies(implies(X, Y), test(X, Y))
182
187
  query(test(X, Y))
183
188
  ```
184
189
 
185
- 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).
190
+ 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/LS-SPEC#63-source-rule-inspection).
191
+
192
+ ## Other formats
193
+
194
+ Every other input compiles to an ordinary LS program, so its conclusions get
195
+ the same checked proofs, and `--program` prints that program as standalone LS.
196
+ The file extension selects the format; proofs and check reports are always `.js`.
186
197
 
187
198
  ### Logical English
188
199
 
189
- A `.le` file is [Logical English](https://eyereasoner.github.io/eyemind/LOGICAL-ENGLISH),
190
- compiled deterministically into LS. Facts, class rules, quantified if/then rules,
191
- calculations, explicit absence tests, existential conclusions, questions and
192
- contradictions have a fixed grammar. Unsupported prose is an error.
200
+ A `.le` file is Logical English (LE): sentences in a fixed English grammar,
201
+ each ending in `.`, compiled deterministically to LS, as the
202
+ [LE specification](https://eyereasoner.github.io/eyemind/LE-SPEC) defines. Unsupported prose is an
203
+ error, never an approximate translation, and the conclusions are written back
204
+ as sentences.
193
205
 
194
206
  ```text
195
207
  Socrates is a human.
@@ -197,577 +209,141 @@ Every human is mortal.
197
209
  Find every X such that X is mortal.
198
210
  ```
199
211
 
200
- ```sh
201
- eyemind examples/socrates-le.le > /tmp/socrates-le.le
202
- eyemind --program examples/socrates-le.le > /tmp/socrates-le.js
203
- eyemind --to le /tmp/socrates-le.js
204
- eyemind --proof examples/socrates-le.le > /tmp/socrates-le-proof.js
205
- eyemind --check-proof /tmp/socrates-le-proof.js examples/socrates-le.le
206
- ```
212
+ `eyemind examples/socrates-le.le` prints `Socrates is a mortal.`
213
+
214
+ **Names.** Keywords are case-insensitive, names case-sensitive. A class or
215
+ relation name starts with a lowercase letter; an individual is a name such as
216
+ `Socrates` or a JSON-quoted `"René Descartes"`. A variable is a capital letter
217
+ with optional digits (`X`, `Y1`) and must be declared in its sentence, which is
218
+ its scope. Terms also include exact integers, floats (`1.0`, `1e3`), lists
219
+ `[a, b]` and compounds `pair(A, B)`. `#` starts a comment.
207
220
 
208
- Conclusions default to `.le`: `Socrates is a mortal.`. They can supply facts to
209
- another LE program. `--to le` also writes supported LS conclusions in this
210
- format. Proofs and check reports remain `.js`, and the standalone compilation
211
- contains all its LS clauses with source sentence locations. The existing checker
212
- checks the compiled LS; the documented grammar and compiler tests define the
213
- English translation.
214
-
215
- Multiple `.le` files form one program. Names are case-sensitive, variables such
216
- as `X` and `Y1` are explicitly declared within each sentence, and integers stay
217
- exact. Arithmetic and absence tests require their inputs from earlier premises;
218
- absence is written `it is not known that`, with LS's stratified meaning. A rule
219
- can introduce witnesses with `there exists`. LE uses the ordinary LS resource
220
- bounds; recursive and existential rules can still have an infinite closure.
221
-
222
- The playground loads LE examples and downloads conclusions as `output.le`.
223
- Try [Socrates](https://eyereasoner.github.io/eyemind/examples/deck/socrates-le),
224
- [exact squares](https://eyereasoner.github.io/eyemind/examples/deck/squares-le)
225
- and [record creation](https://eyereasoner.github.io/eyemind/examples/deck/records-le).
226
- For examples combining more features, try
221
+ | LE | LS |
222
+ | --- | --- |
223
+ | `T is a class`, `T is an class` | `class(T)` |
224
+ | `T is a relation of U`, `T has relation U` | `relation(T, U)` |
225
+ | `relation(T, U, ...)` | that goal |
226
+ | `A and B` | a conjunction; on its own, facts |
227
+ | `For every X, ...` | a universally quantified fact |
228
+ | `Every A is B.` | `implies(A(X), B(X))` |
229
+ | `For every X and Y, if ... then ...` | a forward rule |
230
+ | `Y is the value of E` | `is(Y, E)`, with `+ - * /` and parentheses |
231
+ | `X is greater than`, `less than`, `at least`, `at most`, `equal to`, `different from E` | `gt`, `lt`, `ge`, `le`, `eq`, `ne` |
232
+ | `it is not known that S` | `not(S)`, with LS's stratified meaning |
233
+ | `then there exists Y such that ...` | a Skolem witness of the firing |
234
+ | `Find every X such that ...`, `Find whether ...` | `query(...)` |
235
+ | `It is impossible that ...`, `Contradiction.` | `contradiction(...)` |
236
+
237
+ Arithmetic and absence tests need their inputs from earlier premises, and
238
+ arithmetic follows LS: integers stay exact, division gives a float. An
239
+ answer becomes a sentence such as `16 is a square of 4.`; a witness is written
240
+ `witness(rule 4, Y, Alice)`, and conclusions read back as facts of another LE
241
+ program. Several `.le` files form one program, `--to le` writes LS conclusions
242
+ as LE, and proofs check the compiled LS, not the English-to-LS translation.
243
+ There are no pronouns, disjunctive conclusions or implicit assumptions.
244
+
245
+ A first sentence `Use ODRL snapshot logic with namespace "..."` turns a file of
246
+ ground facts into an [ODRL snapshot](#odrl-snapshots) evaluation, with LE names
247
+ mapped to the `eval:` and `odrl:` vocabularies; see the
248
+ [handicap-card LE deck](https://eyereasoner.github.io/eyemind/examples/deck/handicap-card-le).
249
+ For larger programs, try
227
250
  [shortest paths](https://eyereasoner.github.io/eyemind/examples/deck/shortest-path-le),
228
- [river-crossing plans](https://eyereasoner.github.io/eyemind/examples/deck/river-crossing-le),
229
- [large Pell solutions](https://eyereasoner.github.io/eyemind/examples/deck/pell-equation-le),
230
- [symbolic differentiation](https://eyereasoner.github.io/eyemind/examples/deck/symbolic-derivative-le),
231
- or [course certificates](https://eyereasoner.github.io/eyemind/examples/deck/course-certificates-le).
232
- The [handicap-card LE snapshot](https://eyereasoner.github.io/eyemind/examples/deck/handicap-card-le)
233
- explicitly selects the shared ODRL evaluator with `Use ODRL snapshot logic with
234
- namespace ...`. It expresses the Turtle example's policies and SOTW as English
235
- property facts and writes the same decisions and conflicts as an LE report.
251
+ [river-crossing plans](https://eyereasoner.github.io/eyemind/examples/deck/river-crossing-le) or
252
+ [Pell equations](https://eyereasoner.github.io/eyemind/examples/deck/pell-equation-le).
236
253
 
237
254
  ### RDF 1.2
238
255
 
239
- eyemind reads RDF 1.2 itself, with no dependency: a file ending in `.ttl`, `.trig`, `.nt` or `.nq` is Turtle, TriG, N-Triples or N-Quads, read with the formats' own grammars, and given with a program its quads become `rdf(Subject, Predicate, Object, Graph)` facts, read as data through `facts_from` and never run. `--to turtle`, `trig`, `n-triples` or `n-quads` writes a run's `rdf` and `result_rdf` conclusions back as RDF:
240
-
241
- ```sh
242
- eyemind rules.js data.ttl # rdf/4 facts for the rules
243
- eyemind --to trig rules.js data.trig # the conclusions as TriG
244
- ```
256
+ `.ttl`, `.trig`, `.nt` and `.nq` files are read with the formats' own grammars,
257
+ as data: their quads become `rdf(Subject, Predicate, Object, Graph)` facts.
258
+ `--to turtle`, `trig`, `n-triples` or `n-quads` writes the conclusions back.
245
259
 
246
260
  | RDF 1.2 | eyemind term |
247
261
  | --- | --- |
248
262
  | IRI | `iri('https://example.org/bob')` |
249
263
  | Blank node | `bnode(Scope, Label)`, the scope naming the file |
250
264
  | `xsd:integer` with a canonical lexical form | an integer, `42`, exact at any size |
251
- | Other typed literal | `literal('1.50', datatype('http://www.w3.org/2001/XMLSchema#decimal'))`, its lexical form kept |
252
- | Language string | `literal('chat', lang('fr'))`, or `lang('ar', 'rtl')` with a direction |
253
- | Triple term | `triple(S, P, O)`, which may nest |
265
+ | Other literal | `literal('1.50', datatype(Iri))`, or `literal('chat', lang('fr'))`, with an optional direction |
266
+ | Triple term | `triple(S, P, O)` |
254
267
  | Default graph, named graph | `'default_graph'`, `iri(Name)` |
255
268
 
256
- A reified triple `<< s p o >>` and an annotation `{| ... |}` become their reifier and its `rdf:reifies` triple, as RDF 1.2 defines. A Skolem term is written as a blank node, the same one for the same rule firing. The RDF examples load Turtle or TriG files from `examples/data/` alongside companion rules in `examples/`. They show triple terms, annotations, directional strings, typed numbers and named graphs. The W3C RDF test suites run in `npm test` from `.cache/w3c/rdf-tests`: all 1065 tests of N-Triples, N-Quads, Turtle and TriG, in RDF 1.1 and 1.2, pass.
269
+ All 1065 W3C RDF 1.1 and 1.2 syntax tests pass.
257
270
 
258
271
  ### Notation3
259
272
 
260
- 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:
273
+ A `.n3` file compiles to LS with the N3 built-ins it uses written as LS rules,
274
+ and its conclusions are written as N3: `=>` becomes `implies`, `<=`
275
+ `implied_by`, `{ ... } => false` a `contradiction`, and scoped negation and
276
+ collection `not` and `findall`. Quoted formulas are graph terms, as in D. Arndt
277
+ and P.-A. Champin, ["Notation3: Graph Terms for RDF"](https://arxiv.org/abs/2610.31266);
278
+ a rule with existentials in its conclusion is restricted, making Skolem
279
+ witnesses only where none is known. RDF named graphs join N3 as
280
+ `graph:content` formulas, and `log:semantics` documents are read before
281
+ compiling.
261
282
 
262
283
  ```sh
263
284
  eyemind examples/family-n3.n3 # the derived triples as N3
264
- eyemind --program examples/family-n3.n3 > /tmp/family.js # the compiled program, to inspect
265
- eyemind -c examples/family-n3.n3 # a proof of it, checked
285
+ eyemind -c examples/family-n3.n3 # with a checked proof
266
286
  ```
267
287
 
268
- Triples are `rdf(Subject, Predicate, Object)`, with IRIs, blank nodes and literals written as in the RDF table above. N3 integers and decimals become eyemind numbers; float and double literals retain their RDF datatype, including numbers written with an exponent. Decimals use binary64 storage; `math:sum` adds their canonical decimal values before rounding its result. `=>` becomes `implies`, or `restricted` when the conclusion has blank nodes of its own, `<=` becomes `implied_by`, `{ ... } => false` becomes `contradiction`, and scoped negation and collection become `not` and `findall` (`findall_sorted` when the collected list is only counted with `list:length` or added with `math:sum`), so an N3 run has a proof that eyemind checks like any other. Derived rules can trigger inference fuses too.
269
-
270
- Quoted formulas are graph terms, read as in D. Arndt and P.-A. Champin,
271
- ["Notation3: Graph Terms for RDF"](https://arxiv.org/abs/2610.31266).
272
- `@forAll` and `@forSome` declare IRIs as universal and existential variables
273
- of the formula they open, before its first statement and with `@forAll`
274
- first. A declaration reaches the formulas inside it unless one declares the
275
- same IRI again. A `?x` belongs to the whole document, and a blank node to the
276
- innermost formula that holds it. So `@forAll :x . :x :p :o .` and
277
- `?x :says { ?x :is :wise } .` are facts about everything. A document
278
- existential is one individual, in rules and quoted formulas alike. Within the
279
- scope of universals it becomes a witness of them, so
280
- `?x :loves _:y .` gives each individual its own beloved. A rule whose
281
- conclusion has existentials is restricted: a firing makes Skolem witnesses
282
- only where no known individuals satisfy the conclusion. A
283
- conclusion that declares universals of its own becomes backward rules, which
284
- state it for every individual, and `{ ... } => ?g .` asserts the formula bound
285
- to `?g`.
286
-
287
- A graph term is opaque: `owl:sameAs` does not rewrite it. It is closed and
288
- compared as a set, up to a one-to-one renaming of its own variables, each
289
- kind to its own kind. A rule's graph pattern therefore matches only formulas
290
- with the same triples, and its own blank nodes match only the formula's own
291
- blank nodes. A rule variable never stands for one of them, but it can stand
292
- for a quoted universal, as rules stated as data quote their variables.
293
- `log:includes` never instantiates the universals of its subject. Matching in
294
- nested graph terms below the first level is by unification, so it depends on
295
- the order of their triples. See
296
- [universal instances](https://eyereasoner.github.io/eyemind/examples/deck/universal-instances-n3),
297
- [a shared existential](https://eyereasoner.github.io/eyemind/examples/deck/shared-existential-n3),
298
- [a Skolem IRI rule with explicit universals](https://eyereasoner.github.io/eyemind/examples/deck/explicit-existential-rule-n3),
299
- [quantifier scopes](https://eyereasoner.github.io/eyemind/examples/deck/quantifier-scopes-n3) and
300
- [graph terms](https://eyereasoner.github.io/eyemind/examples/deck/graph-terms-n3).
301
-
302
- The Notation3 test suite case `static/success-literal-22.n3` expects the
303
- pattern `{ _:X :B :C }` to match `{ :A :B :C }`. eyemind's scorer checks
304
- instead that the conclusion is absent, because a quoted blank node is the
305
- formula's own variable.
306
-
307
- N3 has no named-graph syntax. When RDF data joins an N3 run, eyemind represents
308
- each named graph as a quoted formula through `graph:content`, where `graph:`
309
- is `https://eyereasoner.github.io/eyemind/graph#`:
310
-
311
- ```n3
312
- @prefix : <https://example.org/> .
313
- @prefix graph: <https://eyereasoner.github.io/eyemind/graph#> .
314
-
315
- :family graph:content { :alice :parent :bob . :bob :parent :carol } .
316
- ```
317
-
318
- Default-graph triples remain ordinary assertions. Named-graph triples stay
319
- inside their formulas; `?g graph:content ?data` and
320
- `?data log:includes { ... }` inspect them. Contents with the same graph name
321
- from several RDF inputs are combined, while blank nodes keep their source
322
- scopes. Conclusions can attach further formulas to that name; the output
323
- writes these as N3 formulas. See the [named graph example](https://eyereasoner.github.io/eyemind/examples/deck/trig-named-graph-n3).
324
-
325
- Scoped calls can use formulas supplied by the document's stated lists, including RDF collections written with `rdf:first` and `rdf:rest`, and the named-graph formulas loaded from RDF. These calls are specialized before reasoning so their dependencies remain available for stratification and proof checking; formulas constructed only during reasoning are not supported by this compilation.
326
-
327
- The documents `log:semantics`, `log:semanticsOrError` and `log:content` name are read before compiling. The command reads local files and HTTP(S) documents, with a ten-second fetch timeout and a 16 MiB response limit. The library uses the host callbacks `readFile(path)` and `readDocument(iri)`; without them it does not read external documents. Their contents become facts of the compiled program, which can be saved with `--program` for later proof checking.
328
-
329
- Examples run directly from their N3 source in the playground and on the command line:
330
- [family queries](https://eyereasoner.github.io/eyemind/examples/deck/family-n3),
331
- [scoped negation](https://eyereasoner.github.io/eyemind/examples/deck/scoped-negation-n3),
332
- [invoice collection](https://eyereasoner.github.io/eyemind/examples/deck/invoice-n3),
333
- [French cities](https://eyereasoner.github.io/eyemind/examples/deck/french-cities-n3), and
334
- [Skolem IRI witnesses](https://eyereasoner.github.io/eyemind/examples/deck/witnesses-n3).
335
- Each deck shows the N3 result and what its saved proof establishes.
336
-
337
288
  ### RDF Messages
338
289
 
339
- eyemind reads the [RDF Messages living draft](https://w3c-cg.github.io/rsp/spec/messages)
340
- in Turtle, TriG, N-Triples and N-Quads. A version such as
341
- `VERSION "1.2-messages"` enables `MESSAGE` boundaries; Turtle and TriG also
342
- accept `@version "1.2-messages" .` and `@message .`. Empty messages are
343
- preserved, a final delimiter adds no extra message, and blank nodes belong
344
- to their message. Prefix and base changes apply to subsequent data.
345
-
346
- Whole-log replay gives N3 or JavaScript rules an ordered view of the messages:
347
-
348
- ```sh
349
- eyemind examples/message-boundaries-n3.n3 examples/data/message-boundaries-n3.trig
350
- eyemind --proof examples/message-boundaries-n3.n3 examples/data/message-boundaries-n3.trig
351
- eyemind --check-proof examples/proof/message-boundaries-n3.js examples/message-boundaries-n3.n3 examples/data/message-boundaries-n3.trig
352
- ```
353
-
354
- The replay vocabulary is `eymsg:`, with namespace
355
- `https://eyereasoner.github.io/eyeling/vocab/message#`. A stream has
356
- `messageCount`, `orderedEnvelopes`, `firstEnvelope`, `lastEnvelope` and
357
- `envelope` links. Each envelope has a one-based `offset`, a `payloadKind`
358
- of `empty` or `nonEmpty`, and, when nonempty, a `payloadGraph` link.
359
- `nextEnvelope` preserves order. Stream and envelope IRIs are deterministic
360
- from the input's scope; they are application replay identifiers, not syntax
361
- from the draft.
362
-
363
- `?payload log:nameOf ?data` exposes a quoted payload formula, inspected with
364
- `?data log:includes { ... }`. A named graph inside a message is another
365
- `log:nameOf` formula inside that payload. Message triples stay inside their
366
- contexts; rules can deliberately join envelopes when replaying a whole log.
367
- JavaScript rules see the replay facts as `rdf(S, P, O, 'default_graph')`
368
- with `graph(...)` terms for payload formulas.
369
-
370
- For independent processing, run the rules once per message:
371
-
372
- ```sh
373
- eyemind --stream-messages examples/message-alerts-n3.n3 examples/data/message-alerts-n3.nt
374
- ```
375
-
376
- The Node command incrementally reads files, standard input (`-`) or HTTP(S)
377
- message logs and writes each result when its message closes. It reads static
378
- inputs once and discards each run's derived facts before the next message.
379
- Memory retains the current message, active prefix/base context and static
380
- inputs. An inference fuse stops the stream with exit code 65. Output uses
381
- the ordinary N3, RDF or term format selected for the run.
382
-
383
- The playground's **Independent RDF Messages** mode processes its loaded
384
- text with the same boundaries. Whole-log replay supports proofs;
385
- `--stream-messages` rejects proof, proof-checking, compiled-program and
386
- unused-clause modes. The [message-boundaries](https://eyereasoner.github.io/eyemind/examples/deck/message-boundaries-n3),
387
- [message-alerts](https://eyereasoner.github.io/eyemind/examples/deck/message-alerts-n3)
388
- and [message-provenance](https://eyereasoner.github.io/eyemind/examples/deck/message-provenance-n3)
389
- decks show the outputs and what their proofs establish.
390
-
391
- Library hosts can import `RdfMessageReader` and `parseRdfMessages` from
392
- `eyemind`. The former accepts text chunks through `write(text)` and
393
- `finish()`, calling `onMessage({ index, quads, prefixes, base })` for each
394
- dataset; returning `false` stops it. The latter reads a complete string and
395
- returns `messages` plus its replay representation. Both take `format`,
396
- `base` and `scope` options. `parseRdf` reads ordinary RDF documents; use
397
- `parseRdfMessages` to retain message boundaries.
290
+ eyemind reads [RDF Message](https://w3c-cg.github.io/rsp/spec/messages) logs
291
+ in all four RDF syntaxes. By default rules see the whole log replayed as
292
+ ordered envelopes in the `eymsg:` vocabulary, with proofs;
293
+ `--stream-messages` instead runs the rules once per message, reading files,
294
+ standard input or HTTP(S) incrementally. See the
295
+ [message-boundaries](https://eyereasoner.github.io/eyemind/examples/deck/message-boundaries-n3)
296
+ and [message-alerts](https://eyereasoner.github.io/eyemind/examples/deck/message-alerts-n3) decks.
398
297
 
399
298
  ### SPARQL 1.2 RL
400
299
 
401
- 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:
300
+ A `.srl` file is a [SPARQL 1.2 RL](https://www.w3.org/TR/sparql12-rl/) rule
301
+ set over the RDF data given with it; the result is the inference graph, as
302
+ Turtle (`--all` adds the base graph). Rules become `implies`, `NOT` becomes
303
+ `not`, `GROUP` becomes `findall_sorted`, and a SPARQL error is a goal that
304
+ fails. Decimals are exact (`0.1 + 0.2` is `0.3`) and floats are binary64.
305
+ `NOW()` and `UUID()` use a clock and seed captured at compilation, which a
306
+ saved proof retains. All 342 W3C SPARQL 1.2 RL tests pass.
402
307
 
403
308
  ```sh
404
- eyemind rules.srl facts.ttl # the inference graph as Turtle
405
- eyemind --all rules.srl facts.ttl # the base graph too
406
- eyemind -c rules.srl facts.ttl # a proof of it, checked
309
+ eyemind -c rules.srl facts.ttl # the inference graph, with a checked proof
407
310
  ```
408
311
 
409
- Triples are `rdf(Subject, Predicate, Object)`, with `base/3` marking the base graph and `inf/3` the inference graph. A rule becomes `implies`, `NOT` becomes `not` of a helper, `GROUP` becomes `findall_sorted`, which leaves aggregates independent of derivation order, a blank node in a rule head becomes the Skolem term of its firing, and a SPARQL error is a goal that fails, so `FILTER` rejects the solution and `SET` drops it. The W3C SPARQL 1.2 RL test suite runs in `npm test` from `.cache/w3c/sparql-rl`: all 342 tests pass.
410
-
411
- SRL integers and decimals use exact integer arithmetic. Decimal addition,
412
- subtraction, multiplication, comparison, rounding and terminating division
413
- preserve decimal values, including values beyond the exact integer range of
414
- a double: `0.1 + 0.2` is `0.3`. Nonterminating division retains at least 34
415
- significant digits and rounds to nearest with ties to even. Floats and doubles
416
- use binary64 arithmetic: `0.1e0 + 0.2e0` is
417
- `"0.30000000000000004"^^xsd:double`. Floating-point overflow and division by
418
- zero follow IEEE-754, including `INF`, `-INF`, `NaN` and signed zero; decimal
419
- division by zero is an expression error. Mixed numeric expressions use
420
- SPARQL type promotion. The [exact decimals example](https://eyereasoner.github.io/eyemind/examples/deck/exact-decimals-srl)
421
- shows both arithmetic models.
422
-
423
- `NOW()` returns one UTC `xsd:dateTime` throughout a rule set evaluation.
424
- `UUID()` produces a `urn:uuid:` IRI and `STRUUID()` a UUID string, distinct
425
- for each expression occurrence and incoming solution. Compilation captures
426
- the clock and a fresh random seed once; UUIDs are derived from that seed,
427
- the rule, the expression and the solution, so later reasoning rounds keep
428
- the same identifiers. A new compilation captures a new execution context.
429
- The compiled program states this context as one `srl_execution` fact.
430
- Saved proofs retain it, and `--check-proof` restores only that validated
431
- context before recompiling the source. Checking proves consequences of the
432
- recorded context; it does not attest the wall-clock time or the randomness
433
- of the seed. Library calls to `compileSrl` and `reasonSrl` accept
434
- `context: { now, seed }`, with an ISO UTC timestamp including milliseconds
435
- and 64 lowercase hexadecimal seed digits, to reproduce an execution.
436
- The [execution identifiers example](https://eyereasoner.github.io/eyemind/examples/deck/execution-identifiers-srl)
437
- has a fixed context in the example manifest for its saved artifacts;
438
- ordinary command-line and playground runs capture fresh values.
439
-
440
- The [example catalog](https://eyereasoner.github.io/eyemind/examples/) includes
441
- SRL programs for deployment dependencies, route distances, ancestry, inventory,
442
- invoices, provenance and Unicode strings. Each has saved Turtle output, a
443
- proof, a check report and a deck, and runs in the playground.
444
-
445
- ### OWL 2 RL
446
-
447
- `--owl2rl` adds inference rules, including RDFS, to RDF inputs. The files still
448
- use their usual RDF extensions; standard input is Turtle. A graph's use of
449
- RDFS or OWL vocabulary alone does not enable the extension. The playground
450
- has the same switch and preserves it in saved sessions and shared links.
451
-
452
- ```sh
453
- eyemind --owl2rl examples/people-owl2rl.ttl
454
- eyemind --owl2rl examples/family-owl2rl.ttl > /tmp/family-report.ttl
455
- eyemind --owl2rl --program examples/family-owl2rl.ttl > /tmp/family.js
456
- eyemind --to turtle /tmp/family.js
457
- eyemind --owl2rl --proof examples/family-owl2rl.ttl > /tmp/family-proof.js
458
- eyemind --owl2rl --check-proof /tmp/family-proof.js examples/family-owl2rl.ttl
459
- ```
460
-
461
- The generated `.js` contains the data, inference rules and reporting rules;
462
- it runs as standalone LS. Proofs and check reports remain `.js`. Conclusions
463
- default to Turtle, with `--all` adding the input triples. Multiple RDF files
464
- join their default graphs; named graphs are reasoned over independently and
465
- need `--to trig` or `--to n-quads` to retain their graph names.
466
-
467
- The implemented rules are:
468
-
469
- | Rule family | Coverage |
470
- | --- | --- |
471
- | RDFS | Class and property hierarchy transitivity, type and property propagation, domain and range inference and inheritance, resource/class/property typing, reflexive hierarchies, container membership and datatype-to-literal subclassing. |
472
- | OWL | Equality and substitution; equivalent classes and properties; inverse, symmetric, transitive, functional and inverse-functional properties; property chains and keys; intersections, unions, enumerations, value restrictions and maximum cardinalities 0 and 1; class/property disjointness, AllDifferent, negative property assertions and schema propagation. |
473
-
474
- The OWL rules cover the non-datatype families of
475
- [OWL 2 RL/RDF tables 4–7 and 9](https://www.w3.org/TR/owl2-profiles/#Reasoning_in_OWL_2_RL_and_RDF_Graphs),
476
- inspired by [EYE's RDF plus OWL rules](https://github.com/eyereasoner/eye/tree/master/reasoning/rpo)
477
- and the [rdfjs-inference-engine rule sets](https://github.com/pietercolpaert/rdfjs-inference-engine/tree/main/rules).
478
- Disjoint lists also infer pairwise differences or disjointness, and reflexive
479
- properties apply to resources present in the graph.
480
-
481
- Datatype reasoning is partial: integer and decimal comparisons are exact,
482
- integer subtype bounds are checked, and boolean and string values are
483
- compared across supported lexical spellings. Supported datatype IRIs present
484
- in a graph are recognized as datatypes. Maximum qualified cardinalities can
485
- use `owl:onDataRange`. This does not implement all of OWL table 8: full
486
- datatype inclusion/disjointness, facets, binary floating-point value equality
487
- and temporal value equality are outside the profile. RDFS axiomatic triples,
488
- ontology imports and constructs beyond these rule families are also outside
489
- it. The switch does not validate OWL profile membership or certify
490
- completeness for arbitrary ontologies.
491
-
492
- OWL contradictions appear as RDF records of type `ent:Conflict`, where
493
- `ent:` is `https://eyereasoner.github.io/eyemind/entailment#`. Each records its
494
- rule name with `ent:rule` and arguments with `ent:focus`, `ent:left` and
495
- `ent:right`; the proof supplies the supporting assertions. Reporting continues
496
- after a conflict and does not infer arbitrary triples from inconsistency.
497
- Exit code 0 means the report completed, including any conflicts. An empty
498
- conflict set only means these rules detected none; it is not a full consistency
499
- guarantee. RDFS domain and range infer types rather than checking required
500
- fields, and missing facts alone do not establish a conflict.
501
-
502
- Try the [people directory](https://eyereasoner.github.io/eyemind/examples/deck/people-owl2rl)
503
- [family ontology](https://eyereasoner.github.io/eyemind/examples/deck/family-owl2rl)
504
- and [datatype catalog](https://eyereasoner.github.io/eyemind/examples/deck/datatypes-owl2rl).
505
-
506
- ### Combining RDF logic profiles
507
-
508
- `--owl2rl`, `--qudt`, `--skos` and `--shacl` can be combined. Each explicitly
509
- adds its logic to RDF inputs; vocabulary alone never enables a profile.
510
- Multiple inputs merge their default graphs. Named graphs remain independent:
511
- put each graph's data and shapes together, and use `--to trig` to retain graph
512
- names in the output. These switches cannot be combined with `--odrl` or
513
- `--stream-messages`.
514
-
515
- All four compile to standalone `.js` containing the data and ordinary LS
516
- rules. Inference closes before validation, whose reports cannot affect
517
- inference. Output defaults to Turtle containing new triples and reports;
518
- `--all` includes the input. Proofs and check reports remain `.js`, including
519
- proofs of validation failures. Exit code 0 means evaluation completed;
520
- inspect `sh:conforms` and any `ent:Conflict` records to assess the graph.
521
- The playground exposes the same switches and preserves combinations in
522
- saved sessions and shared links.
312
+ ### RDF logic profiles
313
+
314
+ Four switches add standalone LS rules to RDF inputs; vocabulary alone never
315
+ enables one. They combine, inference closes before validation, and the output
316
+ is Turtle with the new triples and reports.
317
+
318
+ - `--owl2rl` adds the RDFS and non-datatype [OWL 2 RL](https://www.w3.org/TR/owl2-profiles/#Reasoning_in_OWL_2_RL_and_RDF_Graphs)
319
+ rules, with partial datatype reasoning, and reports contradictions as
320
+ `ent:Conflict` records instead of inferring everything from them.
321
+ - `--qudt` normalizes QUDT quantity values and CDT literals to SI units from
322
+ an offline catalog adapted from [QUDT.org](https://qudt.org/) (CC BY 4.0):
323
+ `"36 km/h"^^cdt:speed` yields `"10.0 m/s"^^cdt:speed`.
324
+ - `--skos` adds positive [SKOS Core](https://www.w3.org/TR/skos-reference/)
325
+ entailments, without integrity checks or SKOS-XL.
326
+ - `--shacl` compiles shapes to LS and writes a standard `sh:ValidationReport`.
327
+ It implements SHACL 1.2 Core, including list, reifier and targeting
328
+ constraints, and SHACL 1.2 node expressions with the `sparql:` functions and
329
+ custom functions. All 162 W3C Core and 284 node-expression tests pass with
330
+ complete reports. Recursive shapes, SHACL-SPARQL and rules are not
331
+ supported.
523
332
 
524
333
  ```sh
525
334
  eyemind --qudt --shacl examples/measurement-shacl.ttl
526
- eyemind --qudt --shacl --program examples/measurement-shacl.ttl > /tmp/measurement.js
527
- eyemind --to turtle /tmp/measurement.js
528
- eyemind --qudt --shacl --proof examples/measurement-shacl.ttl > /tmp/measurement-proof.js
529
- eyemind --qudt --shacl --check-proof /tmp/measurement-proof.js examples/measurement-shacl.ttl
335
+ eyemind --owl2rl -c examples/family-owl2rl.ttl
530
336
  ```
531
337
 
532
- ### QUDT quantities
533
-
534
- `--qudt` normalizes linked `qudt:QuantityValue` objects and quantity literals
535
- using current `https://w3id.org/cdt/` or legacy
536
- `http://w3id.org/lindt/custom_datatypes#` datatypes. For example,
537
- `"36 km/h"^^cdt:speed` yields `"10.0 m/s"^^cdt:speed`. The object form needs
538
- an incoming `subject property quantity` link, a `qudt:QuantityValue` type,
539
- `qudt:numericValue` and `qudt:unit`. Only input measurements are normalized;
540
- generated quantities do not create another generation of measurements.
541
-
542
- The offline catalog contains common length, area, volume, time, mass, speed,
543
- acceleration, temperature, pressure, energy, power, dimensionless, electric
544
- current and amount-of-substance units. Defaults are SI units. Unit tokens
545
- include registered symbols and UCUM spellings; this is a finite catalog,
546
- not a general UCUM expression parser or the complete QUDT ontology.
547
- Affine conversion uses `(value + offset) * multiplier`, including Fahrenheit.
548
- Selected logarithmic conventions are power-ratio bel/decibel, neper,
549
- octave, decade and pH. Conversions use binary64 arithmetic; logarithmic
550
- results can depend on the host math library's last-place rounding.
551
-
552
- Input unit metadata extends or overrides the catalog with
553
- `qudt:hasDimensionVector`, `qudt:conversionMultiplier`, optional
554
- `qudt:conversionOffset` (zero by default), and `qudt:symbol`, `qudt:ucumCode`
555
- or `qudt:expression` tokens. A custom affine definition needs both its
556
- dimension vector and multiplier. Local unit IRIs can align to a known unit
557
- through `owl:sameAs`, `skos:exactMatch` or `qconv:alignedQudtUnit`; enabling
558
- OWL or SKOS also supplies their inferred alignments.
559
-
560
- Here `qconv:` is `https://eyereasoner.github.io/eyemind/qudt#`. A property
561
- can select a `qconv:normalizationProfile`; built-in profiles include
562
- `qconv:LengthProfile`, `qconv:SpeedProfile` and `qconv:TemperatureProfile`.
563
- A custom profile supplies `qconv:targetUnit`, `qconv:datatype` (an IRI) and
564
- `qconv:targetUcumCode` (a string). Generic `cdt:ucum` literals and quantity
565
- objects otherwise select an unambiguous profile by dimension. Specific CDT
566
- literals select their datatype's profile and must agree with any property
567
- contract. Source and target dimension vectors must match. Unknown tokens,
568
- incompatible dimensions, ambiguous profiles and unsupported conversions
569
- produce no normalization; use SHACL required-value constraints when missing
570
- normalization must be reported.
571
-
572
- Each result attaches `qconv:normalizedQuantity`,
573
- `qconv:normalizedUcumLiteral` and `qconv:normalizedCdtLiteral` to the original
574
- subject. The generated quantity records its unit and numeric value, plus
575
- `qconv:sourceProperty`, `qconv:sourceUnit` and `qconv:sourceLiteral` or
576
- `qconv:sourceQuantity`. Legacy literals normalize to current CDT datatypes.
577
- The small catalog is adapted from [QUDT.org](https://qudt.org/), licensed
578
- [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), and can be inspected
579
- in `src/qudt.js`. No ontology is downloaded during compilation.
580
- Try [quantities](https://eyereasoner.github.io/eyemind/examples/deck/quantities-qudt).
581
-
582
- ### SKOS entailment
583
-
584
- `--skos` adds positive [SKOS Core entailments](https://www.w3.org/TR/skos-reference/):
585
- concept and scheme typing, labels and notes, top concepts, hierarchical and
586
- associative relations, mapping relations and ordered collection membership.
587
- `skos:broader` and `skos:closeMatch` are not transitive;
588
- `skos:broaderTransitive`, `skos:narrowerTransitive` and `skos:exactMatch` are.
589
- A collection member is not arbitrarily typed as either a concept or a
590
- collection, and related concepts do not acquire a shared scheme without
591
- supporting assertions. Cyclic lists do not invent collection members.
592
-
593
- The profile emits its vocabulary axioms and resulting triples. It does not
594
- check SKOS integrity conditions or implement SKOS-XL. Add `--owl2rl` for
595
- general RDFS/OWL consequences of the vocabulary.
596
- Try the [transport thesaurus](https://eyereasoner.github.io/eyemind/examples/deck/thesaurus-skos).
597
-
598
- ### SHACL validation
599
-
600
- `--shacl` compiles the supplied shapes into LS predicates with explicit
601
- conformance dependencies. Validation inspects the completed graph, including
602
- consequences from the other selected profiles. It writes a standard
603
- `sh:ValidationReport` with `sh:conforms` and linked `sh:ValidationResult`
604
- records carrying focus node, source shape, constraint component and severity,
605
- plus path, value and supplied messages where applicable. Complex result
606
- paths retain their RDF definitions in the report.
607
-
608
- SHACL 1.2 Core is implemented: node, class, subjects-of, objects-of and where
609
- targets, `sh:shape` links in the data, and implicit class targets including
610
- `sh:ShapeClass`; class, datatype, node-kind and root-class constraints, each
611
- also with a list of alternatives; counts, bounds, lengths, patterns, single
612
- lines and language constraints; SHACL list members, lengths and uniqueness;
613
- sets, unique values for targets, property pairs over any path, and closed
614
- shapes, also `sh:ByTypes`; nested properties, node/not/and/or/xone,
615
- `sh:someValue`, reifier shapes and qualified counts with disjoint siblings.
616
- Node expressions in `sh:values`, `sh:defaultValue`, `sh:targetNode` and
617
- `sh:deactivated` compute value nodes, targets and deactivation. Predicate,
618
- inverse, sequence, alternative and repeated paths compute distinct values and
619
- terminate on data cycles. Repeated `xone` members count separately.
620
-
621
- A reifier of a constraint triple can deactivate that constraint or give it its
622
- own `sh:severity` and `sh:message`. Each validation of a focus node is a
623
- separate result, so a nested shape reached by two routes reports twice, and
624
- `sh:lessThan` reports each incomparable pair. Results whose severity is outside
625
- the conformance-disallow set (`sh:Violation`, `sh:Warning` and `sh:Info` by
626
- default) are reported but do not make a node or the report nonconforming; a
627
- library caller can pass another set as `disallows`, which the report then
628
- lists as `sh:conformanceDisallows`. Only the boolean `true` activates a
629
- boolean parameter. Deactivated shapes conform without validation.
630
-
631
- SHACL 1.2 node expressions compile to LS as well: constants, lists, variables,
632
- paths, `exists`, `if`, distinct, intersection, concat, remove, filter,
633
- limit, offset, order, flat map, find-first and match-all, counts and other
634
- aggregates, `instancesOf`, `nodesMatching` and `conformsToShape`, the
635
- `sparql:` functions, and custom named and list parameter functions. An
636
- expression gives its output nodes in order, or an evaluation failure that the
637
- enclosing expression propagates. `sh:expression` and `sh:nodeByExpression`
638
- constrain value nodes with them, and report the expression or shape as
639
- `sh:sourceConstraint`. A library caller can evaluate one expression with
640
- `compileRdfLogic(graph, { profiles: ['shacl'], evaluate: { expression, focus,
641
- scope } })`, which answers `sh_evaluation(nodes(List))` or
642
- `sh_evaluation('failure')`. `sparql:now`, `rand`, `uuid` and `struuid` read a
643
- captured clock and seed, so checking such a proof from its source recompiles
644
- another context and fails.
645
-
646
- Shapes and path definitions must be present in the input; inference may add
647
- data and targets, but cannot dynamically define new constraints. A shape
648
- selected at evaluation time, by `sh:nodeByExpression` or `conformsToShape`,
649
- cannot itself use `sh:expression`, `sh:nodeByExpression` or expression-valued
650
- parameters. Recursive shape dependencies, SHACL-SPARQL, JavaScript
651
- constraints and rules are outside the implementation. An evaluation failure
652
- in validation is not reported separately. Active shapes with unsupported
653
- constraint predicates are rejected.
654
-
655
- Datatype checks support XSD integer subtypes, decimal, float/double, boolean,
656
- string/normalizedString/token/language/anyURI, hex/base64 binary,
657
- date/dateTime/dateTimeStamp/time and RDF language strings; a literal of
658
- another datatype matches that datatype's IRI. Numeric bounds use exact integers/decimals with
659
- SPARQL promotion for binary floats; string and same-kind temporal bounds
660
- are also supported. Temporal fractions remain exact. Timezones compare
661
- when both values have one or both omit one; a mixed pair is incomparable.
662
- Unsupported comparisons fail their constraint.
663
-
664
- Patterns use the LS Unicode ECMAScript regex primitive. Flag `s` and the
665
- whitespace-removing flag `x` are translated; `i` supports ASCII literal and
666
- character-class folding. Flag `m`, non-ASCII case folding and richer escaped
667
- case-insensitive patterns raise errors. XPath-specific regex syntax is not
668
- implemented. Malformed shapes and unsupported features produce specific
669
- errors instead of a conforming report.
670
- Try the [directory](https://eyereasoner.github.io/eyemind/examples/deck/people-shacl)
671
- and [normalized speed readings](https://eyereasoner.github.io/eyemind/examples/deck/measurement-shacl).
672
-
673
- The [W3C SHACL 1.2 manifest](https://w3c.github.io/data-shapes/shacl12-test-suite/tests/manifest.ttl)
674
- is scored on every `npm test`, including filtered runs. eyemind targets its
675
- Core and node-expression groups; SHACL-SPARQL and inference rules are out of
676
- scope and not scored. At upstream revision
677
- `0ed3f9b4273c2debba0125a7ed5c9dc3cd4b741c`, **all 162 Core tests pass
678
- complete-report comparison**, as do all 284 node-expression tests.
679
-
680
- The two groups are reported separately in
681
- [REPORT.md](REPORT.md) and [SHACL EARL](reports/w3c-shacl-earl.ttl). The runner
682
- preserves separate data and shapes graphs, follows manifest includes and
683
- compares complete top-level results, their multiplicity, messages and paths.
684
- A matching conformance boolean alone is not a pass. Unimplemented processor
685
- families are explicitly untested in EARL; attempted validation cases that
686
- reject unsupported constraints or produce wrong reports are failed.
687
-
688
- ```sh
689
- node tools/shacltests.js
690
- node tools/shacltests.js --json > /tmp/shacl-coverage.json
691
- node tools/shacltests.js --strict
692
- ```
693
-
694
- The default scorer and `npm test` report SHACL coverage without making missing
695
- support fail the release checks, as with the Notation3 scorer. `--strict` exits
696
- with code 1 for any non-passing SHACL case. Broken manifests and missing test
697
- resources always fail the run. These commands reuse the cached suite; an
698
- optional suite directory can select a different copy.
699
-
700
338
  ### ODRL snapshots
701
339
 
702
- Use `--odrl` to add ODRL validation and evaluation to one Turtle file
703
- containing policies, candidate requests and their state of the world (SOTW).
704
- A resource of type `eval:Evaluation`, using
705
- `eval: <https://eyereasoner.github.io/eyemind/odrl#>`, selects the policies
706
- with `eval:policy`, the requests with `eval:request`, and a cross-policy
707
- `eval:conflictStrategy`: `odrl:perm`, `odrl:prohibit` or `odrl:invalid`.
708
- The switch enables the snapshot compiler; without it Turtle remains RDF
709
- data, even when it contains an `eval:Evaluation` resource. The playground
710
- has the same `--odrl` checkbox, enabled for the handicap-card example and
711
- preserved in saved state and shared links.
712
-
713
- ```sh
714
- eyemind --odrl examples/handicap-card.ttl > /tmp/handicap-card-report.ttl
715
- eyemind --odrl --program examples/handicap-card.ttl > /tmp/handicap-card.js
716
- eyemind --to turtle /tmp/handicap-card.js > /tmp/handicap-card-report.ttl
717
- eyemind --odrl --proof examples/handicap-card.ttl > /tmp/handicap-card-proof.js
718
- eyemind --odrl --check-proof /tmp/handicap-card-proof.js examples/handicap-card.ttl
719
- ```
720
-
721
- The compiled `.js` includes the input facts and all validation and evaluation
722
- LS; running it needs no policy file or external evaluator. The Turtle report
723
- lists each request's `eval:decision` (`Allowed`, `Prohibited`,
724
- `NotApplicable` or `Undetermined`), the `eval:canHappen` requests, validation
725
- errors, uncertainties and conflicts. Each conflict identifies its request,
726
- permission policy/rule and prohibition policy/rule. `eval:conflictCount`
727
- explicitly records zero when none is detected. This evaluates the listed
728
- requests at the supplied snapshot; it neither issues a card nor predicts
729
- future changes to the world.
730
- `eval:validationStatus` records whether the input fits the profile's shape
731
- and vocabulary. Conflicts are reported and resolved separately.
732
-
733
- The supported profile is declared on each policy with
734
- `odrl:profile eval:SnapshotProfile`. Policies are `odrl:Set` or
735
- `odrl:Agreement`; each rule states exactly one assignee, action and target.
736
- A request is an `eval:Request` with those same three ODRL properties, an
737
- `eval:subject` and an `eval:state`. Its `eval:State` names the same subject.
738
- Assignees, actions and targets match by RDF term identity. Each constraint's
739
- `odrl:leftOperand` is an IRI naming a property of that state, with exactly one
740
- `odrl:operator` and `odrl:rightOperand`. All constraints of a rule must hold.
741
- Equality and inequality (`eq`, `neq`) support IRIs, strings, booleans and
742
- exact integers; ordering (`gt`, `gteq`, `lt`, `lteq`) supports exact integers.
743
- Boolean lexical forms `true`/`1` and `false`/`0` denote the same values.
744
-
745
- An absent, multiply valued, unsupported or differently typed observation
746
- leaves a constraint unknown. A definitely false constraint makes its rule
747
- inapplicable; otherwise an unknown constraint makes the request
748
- `Undetermined`. Missing facts never establish a negative observation.
749
- The caller supplies the applicable policy set, trusted state and candidate
750
- actions. The compiler does not establish agreement acceptance or evidence
751
- authenticity. Unsupported policy properties, profiles, duties, inheritance,
752
- action hierarchies, collections and refinements are validation errors and
753
- block authorization for the evaluation. This is a bounded profile, not a
754
- general ODRL evaluator.
755
-
756
- ODRL's per-policy `odrl:conflict` strategies are applied first; an omitted
757
- strategy defaults to `odrl:invalid`. A detected internal conflict then voids
758
- that policy and leaves the evaluation undetermined. The explicit
759
- `eval:conflictStrategy` combines the remaining policy decisions; `invalid`
760
- voids the evaluation if both a permission and a prohibition remain for any
761
- request. Conflicts stay in the report after resolution. These are
762
- permission/prohibition overlaps for the listed requests, not an exhaustive
763
- search for conflicts in every possible state. The rules follow the
764
- [ODRL Information Model](https://www.w3.org/TR/odrl-model/) for the supported
765
- features; the snapshot vocabulary and cross-policy composition are this
766
- profile's conventions.
767
-
768
- The [handicap-card example](https://eyereasoner.github.io/eyemind/examples/deck/handicap-card)
769
- allows Alice's request and reports the conflict that blocks Bob's, under
770
- explicitly fictional criteria.
340
+ `--odrl` evaluates one Turtle file holding ODRL policies, candidate requests
341
+ and their state of the world, selected by an `eval:Evaluation` resource. The
342
+ report gives each request's decision (`Allowed`, `Prohibited`,
343
+ `NotApplicable` or `Undetermined`) and the permission/prohibition conflicts.
344
+ It is a bounded profile, not a general ODRL evaluator: each rule has one
345
+ assignee, action and target, and constraints compare state properties. See
346
+ the [handicap-card example](https://eyereasoner.github.io/eyemind/examples/deck/handicap-card).
771
347
 
772
348
  ## How eyemind reasons
773
349
 
@@ -780,7 +356,7 @@ The statement chooses the direction:
780
356
 
781
357
  Forward rules suit closures and classifications: `implies([path(X, Y), edge(Y, Z)], path(X, Z))` terminates on a cyclic graph. A variable only a forward rule's conclusion mentions gets a fresh value, a Skolem term, for each firing. `restricted` makes one only where none is known: `restricted(human(X), [father(X, F), man(F)])` gives no new father to a human whose known father is a man. Its other rules run first in each stratum, a restricted rule whose conclusion can satisfy another's runs before it, a run whose new value later facts make unneeded stops with an error, and its proof shows each new value is needed, as the restricted chase of N. Küchenmeister, A. Ivliev, D. Arndt and M. Krötzsch, ["Stratified Negation in RDF Rules"](https://arxiv.org/abs/2607.28778), requires. Which firings it makes can depend on the order of rule applications, so call fidelity stays an obligation. 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.
782
358
 
783
- 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 collection waits until everything it inspects is final. A rule with a variable in every position, such as `implies([rdf(P, 'spo', Q), rdf(X, P, Y)], rdf(X, Q, Y))`, reaches every negation of its relation, and a cycle through it has no strata. Such a program is still accepted when it is chain-stratified, as Küchenmeister, Ivliev, Arndt and Krötzsch define it: no chain of rule applications from a rule with a negation can make one of its negated goals true without also satisfying a `contradiction`. Its rules then run in ranks, the Datalog rules first, and a rule fires only while no lower-ranked rule has a firing left ([SPEC §6.4](https://eyereasoner.github.io/eyemind/SPEC#64-chain-stratification)). `--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.
359
+ 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 collection waits until everything it inspects is final. A rule with a variable in every position, such as `implies([rdf(P, 'spo', Q), rdf(X, P, Y)], rdf(X, Q, Y))`, reaches every negation of its relation, and a cycle through it has no strata. Such a program is still accepted when it is chain-stratified, as Küchenmeister, Ivliev, Arndt and Krötzsch define it: no chain of rule applications from a rule with a negation can make one of its negated goals true without also satisfying a `contradiction`. Its rules then run in ranks, the Datalog rules first, and a rule fires only while no lower-ranked rule has a firing left ([SPEC §6.4](https://eyereasoner.github.io/eyemind/LS-SPEC#64-chain-stratification)). `--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/LS-SPEC#8-evaluation-and-conclusions) defines the details.
784
360
 
785
361
  ## Proofs, and what checking one means
786
362
 
@@ -858,7 +434,7 @@ type('socrates', 'human')
858
434
  verdict('checked')
859
435
  ```
860
436
 
861
- A `checked` verdict establishes that every claim follows from the program and every required answer of the original questions is claimed. When the run reports only derived facts, source facts and backward-only answers are not required conclusions. A failed check lists `failure(Detail)` facts, ends with `verdict(failed(N))` and exits with code 2. A halted run's proof establishes that its claims follow, without establishing answer completeness. To check answers to `--goal` questions, pass the same goals when checking. [SPEC §11](https://eyereasoner.github.io/eyemind/SPEC#11-proof-checking) defines the check.
437
+ A `checked` verdict establishes that every claim follows from the program and every required answer of the original questions is claimed. When the run reports only derived facts, source facts and backward-only answers are not required conclusions. A failed check lists `failure(Detail)` facts, ends with `verdict(failed(N))` and exits with code 2. A halted run's proof establishes that its claims follow, without establishing answer completeness. To check answers to `--goal` questions, pass the same goals when checking. [SPEC §11](https://eyereasoner.github.io/eyemind/LS-SPEC#11-proof-checking) defines the check.
862
438
 
863
439
  The report's comments explain which checks succeeded, with references to
864
440
  SPEC Sections 11.2–11.6. They distinguish complete answers from a halted
@@ -1003,12 +579,12 @@ unless a negation or collection in the proof could consult it and its
1003
579
  omission changes the conclusions or halt code, or causes an error. The clauses a
1004
580
  negation or collection could consult are those whose heads have the name and
1005
581
  arity of a goal it reaches through the program's bodies. Running the program
1006
- without a clause leaves every other clause its number ([Section 3.5](https://eyereasoner.github.io/eyemind/SPEC#35-clause-constraints-and-numbering)), so the
1007
- Skolem terms of the other rules ([Section 8.2](https://eyereasoner.github.io/eyemind/SPEC#82-forward-evaluation-and-witnesses)) do not change.
582
+ without a clause leaves every other clause its number ([Section 3.5](https://eyereasoner.github.io/eyemind/LS-SPEC#35-clause-constraints-and-numbering)), so the
583
+ Skolem terms of the other rules ([Section 8.2](https://eyereasoner.github.io/eyemind/LS-SPEC#82-forward-evaluation-and-witnesses)) do not change.
1008
584
 
1009
585
  Unused clauses are reported one per line, in clause order, as
1010
586
  `unused(line(L), Display)`, where `L` is the source line where the statement call begins; facts read
1011
- by `facts_from` use that call's line. `Display` is as in [Section 10.2](https://eyereasoner.github.io/eyemind/SPEC#102-clause-displays); with several
587
+ by `facts_from` use that call's line. `Display` is as in [Section 10.2](https://eyereasoner.github.io/eyemind/LS-SPEC#102-clause-displays); with several
1012
588
  scripts, clause order tells which script a line belongs to. The listing is
1013
589
  the result whether or not the program halts with `'false'`, and the command
1014
590
  exits with code 0 after it.
@@ -1016,7 +592,7 @@ exits with code 0 after it.
1016
592
  A clause compiled from a template inherits its generator's source line.
1017
593
 
1018
594
  "Unused" is relative to the recorded derivations, which are the first ones
1019
- found ([Section 8.7](https://eyereasoner.github.io/eyemind/SPEC#87-proof-generation)). A clause that only offers a second derivation of a
595
+ found ([Section 8.7](https://eyereasoner.github.io/eyemind/LS-SPEC#87-proof-generation)). A clause that only offers a second derivation of a
1020
596
  conclusion, such as a duplicate rule, is unused, though leaving out the
1021
597
  clause that offers the first one would make it used; leaving out several
1022
598
  unused clauses together can therefore change the conclusions. A
@@ -1067,57 +643,19 @@ development tools used by the author.
1067
643
 
1068
644
  ```sh
1069
645
  npm test # unit, examples, conformance, command line, playground
1070
- npm test -- unit examples # these sections, plus W3C EARL
1071
646
  npm test -- -k skolem # only tests whose line contains "skolem"
1072
647
  EYEMIND_PROPERTY_SCALE=20 npm test -- -k properties # deeper generated tests
1073
648
  node tools/update-examples.js # regenerate example artifacts after an intended change
1074
- node tools/report.js # run the full suite and write REPORT.md
1075
- node tools/notation3tests.js # the cached Notation3 suite
1076
- node tools/shacltests.js # SHACL 1.2 coverage; --strict fails for missing support
1077
- npm run sync # refresh all four upstream test suites
649
+ npm run sync # refresh the cached upstream test suites
1078
650
  node conformance/run.js --command "my-eyemind" # run the conformance suite against another implementation
651
+ ./release patch "Describe the changes" # test, tag and publish a release
1079
652
  ```
1080
653
 
1081
- 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.
1082
-
1083
- A full `npm test` writes `REPORT.md` from the summary table it prints.
1084
-
1085
- Every `npm test` invocation, including a filtered run, also runs both cached
1086
- W3C format suites and rewrites [reports/w3c-rdf-earl.ttl](reports/w3c-rdf-earl.ttl)
1087
- and [reports/w3c-sparql-rl-earl.ttl](reports/w3c-sparql-rl-earl.ttl). It also scores
1088
- the Core and node-expression groups of the SHACL 1.2 manifest and writes
1089
- [reports/w3c-shacl-earl.ttl](reports/w3c-shacl-earl.ttl).
1090
- These [EARL](https://www.w3.org/TR/EARL10-Schema/) reports contain one
1091
- assertion per manifest case, its actual outcome and diagnostic, the eyemind
1092
- version and the run date. An RDF or SRL failure makes the command fail; SHACL is reported as coverage. A negative
1093
- syntax test passes when the parser rejects its input as required.
1094
-
1095
- The [upstream suites](test/UPSTREAM.md) live in Git-ignored `.cache/`.
1096
- `npm test` reuses them without fetching. If the cache is missing or incomplete,
1097
- it downloads the suites first; that first run needs Git and network access.
1098
- `npm run sync` explicitly refreshes all four suites and the Notation3 document
1099
- fixtures. Downloads and manifest resource checks finish before the cached
1100
- suites are replaced; a failed refresh retains the old set. Upstream licensing
1101
- and documentation stay with the cached files. The small tracked
1102
- [test/upstream.json](test/upstream.json) records their revisions and case counts.
1103
- Run `npm test` after a sync to verify the suites and refresh EARL.
1104
-
1105
- Local Git checkouts can supply any of the sources:
1106
-
1107
- ```sh
1108
- npm run sync -- --notation3tests /path/to/notation3tests --w3c-rdf /path/to/rdf-tests --w3c-sparql-rl /path/to/data-shapes
1109
- ```
1110
-
1111
- The data-shapes checkout supplies both SRL and SHACL; `--w3c-shacl PATH` can
1112
- select a separate checkout for SHACL.
1113
-
1114
- `node tools/sync-notation3tests.js [UPSTREAM_CHECKOUT]` still refreshes only
1115
- Notation3 in `.cache/`. Once cached, tests use saved documents with no network fallback;
1116
- the scorer's `--live` option checks the current remote resources instead.
1117
-
1118
- ### Releases
1119
-
1120
- `./release patch "Describe the changes"` (or `minor`, `major`) requires a clean tree, pulls `main`, runs the tests, bumps the version, refreshes and checks EARL with that 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**.
654
+ The full suite needs a few GB of memory; on a small machine run it under a
655
+ cap, such as `systemd-run --user --scope -q -p MemoryMax=3G -p MemorySwapMax=0 -- npm test`.
656
+ The playground tests need Chrome (`CHROME` names it). A full run writes
657
+ [REPORT.md](REPORT.md) and the [W3C EARL reports](reports/README.md); the
658
+ [upstream suites](test/UPSTREAM.md) are cached in Git-ignored `.cache/`.
1121
659
 
1122
660
  ## The name
1123
661
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eyemind",
3
- "version": "0.8.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.",
3
+ "version": "0.8.4",
4
+ "description": "A dependency-free Logic Script (LS) reasoner with forward and backward reasoning, checkable proofs, and RDF 1.2, Notation3 (N3), SPARQL 1.2 RL (SRL) and Logical English (LE) interoperability.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
7
  "exports": {
@@ -16,8 +16,8 @@
16
16
  "bin/",
17
17
  "src/",
18
18
  "README.md",
19
- "SPEC.md",
20
- "LOGICAL-ENGLISH.md",
19
+ "LS-SPEC.md",
20
+ "LE-SPEC.md",
21
21
  "LICENSE.md"
22
22
  ],
23
23
  "scripts": {
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.8.2';
2
+ export const VERSION = '0.8.4';