eyemind 0.8.42 → 0.8.44
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/LE-SPEC.md +17 -10
- package/LS-SPEC.md +4 -2
- package/README.md +18 -11
- package/package.json +1 -1
- package/src/engine.js +2 -0
- package/src/formats.js +1 -1
- package/src/le.js +12 -2
- package/src/qudt.js +5 -0
- package/src/version.js +1 -1
package/LE-SPEC.md
CHANGED
|
@@ -128,8 +128,9 @@ writes the RDF graph and `--all` adds the stated RDF facts.
|
|
|
128
128
|
Prefix declarations specify names. The facts and rules supply their
|
|
129
129
|
meaning for a run. The research access example uses ODRL permissions,
|
|
130
130
|
prohibitions, constraints and a duty with DPV purpose and consent
|
|
131
|
-
evidence. Its ordinary LE rules specify the scenario's policy decisions
|
|
132
|
-
|
|
131
|
+
evidence. Its ordinary LE rules specify the scenario's policy decisions; a
|
|
132
|
+
Turtle companion decides similar requests with the ODRL snapshot evaluator.
|
|
133
|
+
[Research access example](https://eyereasoner.github.io/eyemind/examples/deck/research-access-le) · [Turtle companion](https://eyereasoner.github.io/eyemind/examples/deck/research-access-odrl) · [ODRL Vocabulary](https://www.w3.org/TR/odrl-vocab/) · [Data Privacy Vocabulary 2.3](https://w3id.org/dpv/2.3/dpv/)
|
|
133
134
|
|
|
134
135
|
## Rules and calculations
|
|
135
136
|
|
|
@@ -141,7 +142,8 @@ If Alice is a person then Alice is a participant.
|
|
|
141
142
|
```
|
|
142
143
|
|
|
143
144
|
`Every A is B.` compiles to `implies(A(X), B(X))`, with a fresh clause-local
|
|
144
|
-
variable
|
|
145
|
+
variable; `a` or `an` may precede each class after `is`, as in
|
|
146
|
+
`Every human is a mortal.`. An if/then sentence compiles its premises and conclusions to one
|
|
145
147
|
forward LS rule. Both sides may contain conjunctions. A conclusion variable
|
|
146
148
|
must be supplied by a premise or explicitly declared existentially. The
|
|
147
149
|
compiler checks the stated order of premises for calculations and absence tests;
|
|
@@ -415,9 +417,9 @@ use `has`; for example `issueAlice has decision allowed.`. Status values
|
|
|
415
417
|
`invalidReport` name the corresponding `eval:` IRIs. Report classes include
|
|
416
418
|
`evaluationReport`, `conflict`, `validationError` and `uncertainty`.
|
|
417
419
|
`conflict` as a property means `eval:conflict`; `applicablePermission`,
|
|
418
|
-
`applicableProhibition` and `
|
|
419
|
-
`eval:permission`, `eval:prohibition
|
|
420
|
-
input properties. Other report fields retain their `eval:` names. An IRI with
|
|
420
|
+
`applicableProhibition`, `reportConstraint` and `reportDuty` distinguish the
|
|
421
|
+
report's `eval:permission`, `eval:prohibition`, `eval:constraint` and
|
|
422
|
+
`eval:duty` links from ODRL input properties. Other report fields retain their `eval:` names. An IRI with
|
|
421
423
|
no unambiguous abbreviation stays explicit, including IRIs inside witness keys.
|
|
422
424
|
|
|
423
425
|
Prefix declarations can follow either ODRL directive. A qualified state
|
|
@@ -458,11 +460,14 @@ An exact match or a supplied broader path satisfies the constraint. With
|
|
|
458
460
|
a known observation and no such path the constraint is unmet. The snapshot
|
|
459
461
|
reports missing, ambiguous or mistyped observations as unknown.
|
|
460
462
|
The research snapshot demonstrates compound scope, two DPV hierarchies and
|
|
461
|
-
request-local duty evidence
|
|
463
|
+
request-local duty evidence; its Turtle twin, run with `--odrl`, reaches the
|
|
464
|
+
same decisions. [Research snapshot](https://eyereasoner.github.io/eyemind/examples/deck/research-snapshot-le) · [Turtle twin](https://eyereasoner.github.io/eyemind/examples/deck/research-snapshot-odrl)
|
|
462
465
|
|
|
463
466
|
Both ODRL directives take a single LE file and reject mixed-in ordinary LE
|
|
464
|
-
rules or questions. `--goal` can query their compiled LS program. The
|
|
465
|
-
`--odrl` switch
|
|
467
|
+
rules or questions. `--goal` can query their compiled LS program. The
|
|
468
|
+
`--odrl` switch selects the Turtle snapshot compiler, which can also combine
|
|
469
|
+
with `--owl2rl`, `--skos`, `--qudt` and `--shacl`; an LE run takes none of these
|
|
470
|
+
switches, so an LE snapshot reads only the facts it states.
|
|
466
471
|
|
|
467
472
|
## Output, compilation and checking
|
|
468
473
|
|
|
@@ -500,7 +505,9 @@ eyemind --check-proof /tmp/socrates-le-proof.js examples/socrates-le.le
|
|
|
500
505
|
|
|
501
506
|
Multiple `.le` files form one program in file order; they do not mix with other
|
|
502
507
|
input formats or the RDF logic switches. Standard input remains LS; `--to le`
|
|
503
|
-
can write supported LS conclusions as LE.
|
|
508
|
+
can write supported LS conclusions as LE. For an N3, SRL or RDF run, IRIs are
|
|
509
|
+
abbreviated with that run's prefixes; a prefix LE cannot spell, such as
|
|
510
|
+
Turtle's empty one, is declared as `ns`, or `ns2` and so on when taken. `--goal` uses LS goal syntax and
|
|
504
511
|
defaults to LS output; add `--to le` for LE output. `--all` applies to RDF and N3
|
|
505
512
|
output, without changing LE's selected conclusions.
|
|
506
513
|
|
package/LS-SPEC.md
CHANGED
|
@@ -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.
|
|
5
|
+
Version: eyemind 0.8.44
|
|
6
6
|
```
|
|
7
7
|
|
|
8
8
|
This document specifies Logic Script (LS): the syntax and meaning of its
|
|
@@ -1214,7 +1214,9 @@ depth, goals started or forward rounds are provided, they count as follows:
|
|
|
1214
1214
|
allows exceeds it. A goal solved by a fact adds no level.
|
|
1215
1215
|
- Every goal the search starts counts once toward the inference bound,
|
|
1216
1216
|
including each conjunction, control and primitive, in forward premises as
|
|
1217
|
-
in goals: `[p(X), p(Y)]` against one fact starts three goals.
|
|
1217
|
+
in goals: the goal `[p(X), p(Y)]` against one fact starts three goals. A
|
|
1218
|
+
rule body is flattened to its goals ([Section 3.5](#35-clause-constraints-and-numbering)), so the same
|
|
1219
|
+
array as a forward premise starts two.
|
|
1218
1220
|
- Every forward round of a stratum counts toward the round bound,
|
|
1219
1221
|
including the final round that adds nothing; a stratum without forward
|
|
1220
1222
|
rules has no rounds.
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ program, a JavaScript library and a browser application.
|
|
|
13
13
|
- [Playground](https://eyereasoner.github.io/eyemind/playground/): run any
|
|
14
14
|
example or your own program in the browser, with its proof and check report.
|
|
15
15
|
- [Examples](https://eyereasoner.github.io/eyemind/examples/): the
|
|
16
|
-
|
|
16
|
+
165 runnable programs, each with a card deck and saved conclusions; all but
|
|
17
17
|
the two streamed examples also save proofs and check reports.
|
|
18
18
|
- [Specification](https://eyereasoner.github.io/eyemind/LS-SPEC): the
|
|
19
19
|
language, the proof format and how a proof is checked.
|
|
@@ -84,6 +84,7 @@ eyemind examples/socrates.js
|
|
|
84
84
|
prints
|
|
85
85
|
|
|
86
86
|
```js
|
|
87
|
+
// Answers: each instance of a query() that holds.
|
|
87
88
|
type('socrates', 'mortal')
|
|
88
89
|
type('socrates', 'human')
|
|
89
90
|
```
|
|
@@ -236,7 +237,8 @@ premises; an aggregate's own variables stay inside it, and a conjunction in its
|
|
|
236
237
|
condition is put in parentheses. Arithmetic follows LS: integers stay exact,
|
|
237
238
|
division gives a float. An answer becomes a sentence such as `16 is a square of 4.`; a witness is written
|
|
238
239
|
`witness(rule 4, Y, Alice)`, and conclusions read back as facts of another LE
|
|
239
|
-
program. Several `.le` files form one program,
|
|
240
|
+
program. Several `.le` files form one program, without other input formats
|
|
241
|
+
or RDF logic switches; `--to le` writes LS conclusions
|
|
240
242
|
as LE, and proofs check the compiled LS, not the English-to-LS translation.
|
|
241
243
|
There are no pronouns, disjunctive conclusions or implicit assumptions.
|
|
242
244
|
|
|
@@ -288,7 +290,8 @@ and P.-A. Champin, ["Notation3: Graph Terms for RDF"](https://arxiv.org/abs/2610
|
|
|
288
290
|
a rule with existentials in its conclusion is restricted, making Skolem
|
|
289
291
|
witnesses only where none is known. RDF named graphs join N3 as
|
|
290
292
|
`graph:content` formulas, and `log:semantics` documents are read before
|
|
291
|
-
compiling.
|
|
293
|
+
compiling. All 1163 cases of the
|
|
294
|
+
[Notation3 test suite](https://codeberg.org/phochste/notation3tests) pass.
|
|
292
295
|
|
|
293
296
|
```sh
|
|
294
297
|
eyemind examples/family-n3.n3 # the derived triples as N3
|
|
@@ -407,7 +410,10 @@ query(rdf(O, iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), sosa('Obser
|
|
|
407
410
|
units: with `qudt:conversionMultiplier` and `qudt:hasDimensionVector`,
|
|
408
411
|
composed from QUDT units with `qudt:hasFactorUnit` and an optional
|
|
409
412
|
`qudt:factorUnitScalar`, derived from `qudt:prefix` and `qudt:scalingOf`,
|
|
410
|
-
or aligned with `owl:sameAs` or `skos:exactMatch
|
|
413
|
+
or aligned with `owl:sameAs` or `skos:exactMatch`, which are symmetric and
|
|
414
|
+
read in either direction, or with `qconv:alignedQudtUnit` from the local
|
|
415
|
+
unit to the QUDT one; a local `qudt:symbol` or `qudt:ucumCode` then names
|
|
416
|
+
the unit in a CDT literal. The
|
|
411
417
|
other units of the QUDT unit vocabulary with a fixed conversion, such as
|
|
412
418
|
`unit:W-PER-M2`, come from an offline catalog that `tools/qudt-catalog.js`
|
|
413
419
|
generates from a QUDT release, also by the UCUM code of a CDT literal. A
|
|
@@ -447,14 +453,15 @@ properties with scalar or DPV category constraints and combines constraints
|
|
|
447
453
|
with `odrl:and`, `odrl:or` or `odrl:xone`. Permissions can require duties,
|
|
448
454
|
with fulfillment evidence attached to each request.
|
|
449
455
|
|
|
450
|
-
`--odrl` combines with `--owl2rl`, `--skos`, `--qudt` and `--shacl
|
|
456
|
+
`--odrl` combines with `--owl2rl`, `--skos`, `--qudt` and `--shacl`, though
|
|
457
|
+
not with `--stream-messages`, `--shacl-in` or `--shacl-out`. The
|
|
451
458
|
snapshot then reads the given triples, what the profiles entail about each
|
|
452
459
|
request's state, such as an observation a property chain derives, and entailed
|
|
453
460
|
SKOS links between categories, such as a `skos:broadMatch` to DPV. Other
|
|
454
461
|
entailments, such as an `rdfs:Resource` type for every node, stay out of the
|
|
455
462
|
snapshot, whose validation would reject them. The output is the ODRL report
|
|
456
463
|
with the profiles' own reports, such as a SHACL validation report.
|
|
457
|
-
[Handicap-card example](https://eyereasoner.github.io/eyemind/examples/deck/handicap-card) · [Research snapshot](https://eyereasoner.github.io/eyemind/examples/deck/research-snapshot-
|
|
464
|
+
[Handicap-card example](https://eyereasoner.github.io/eyemind/examples/deck/handicap-card) · [Research snapshot](https://eyereasoner.github.io/eyemind/examples/deck/research-snapshot-odrl) · [Research access with OWL 2 RL and SKOS](https://eyereasoner.github.io/eyemind/examples/deck/research-access-odrl) · [Research portal with OWL 2 RL](https://eyereasoner.github.io/eyemind/examples/deck/research-portal-odrl) · [Package holiday with SHACL](https://eyereasoner.github.io/eyemind/examples/deck/package-holiday-odrl)
|
|
458
465
|
|
|
459
466
|
## How eyemind reasons
|
|
460
467
|
|
|
@@ -601,9 +608,9 @@ A clause is listed when no conclusion's proof uses it; a clause only a negation
|
|
|
601
608
|
|
|
602
609
|
## Examples and the playground
|
|
603
610
|
|
|
604
|
-
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
|
|
611
|
+
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 saved in `examples/output/`, all but the two streamed examples their proof and check report in `examples/proof/` and `examples/check/`, and each a card deck for a wide audience. Change a fact, run it, and compare with the saved output.
|
|
605
612
|
|
|
606
|
-
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
|
|
613
|
+
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, checked answers, check of a saved proof, unused clauses, or independent RDF Messages) 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.
|
|
607
614
|
|
|
608
615
|
## Command line
|
|
609
616
|
|
|
@@ -625,10 +632,10 @@ eyemind [OPTION ...] [FILE ...]
|
|
|
625
632
|
| `--shacl-out FILE` | With an RDF logic profile, plan only the rules that conclude triples the SHACL shapes in `FILE` describe, or what those rules read, and write only those triples. |
|
|
626
633
|
| `--stats` | Print reasoning statistics as JSON to standard error. |
|
|
627
634
|
| `--max-depth N`, `--max-iterations N`, `--max-inferences N` | Bound backward depth (1000000), forward rounds per stratum (1000) and goals started (1000000); a compiled N3, SRL, ODRL or RDF profile program has 1000000, 100000 and 1000000000. |
|
|
628
|
-
| `--to FORMAT` | Write the conclusions as `turtle`, `trig`, `n-triples`, `n-quads`, `n3`, `le` or `eyemind`; by default LE for LE, N3 for N3, Turtle for SRL, ODRL and RDF profiles, eyemind otherwise. |
|
|
635
|
+
| `--to FORMAT` | Write the conclusions as `turtle`, `trig`, `n-triples`, `n-quads`, `n3`, `le` or `eyemind`; `n3` only for an N3 run; by default LE for LE, N3 for N3, Turtle for SRL, ODRL and RDF profiles, eyemind otherwise. |
|
|
629
636
|
| `--all` | With RDF or N3 output, write the given data too. |
|
|
630
637
|
| `--program` | Print the program the inputs compile to. |
|
|
631
|
-
| `--odrl` | Add the ODRL snapshot profile's validation and evaluation LS to one Turtle input; with RDF logic profiles, the snapshot also reads what they entail about its states. |
|
|
638
|
+
| `--odrl` | Add the ODRL snapshot profile's validation and evaluation LS to one Turtle input; with RDF logic profiles, the snapshot also reads what they entail about its states. Not with `--stream-messages`, `--shacl-in` or `--shacl-out`. |
|
|
632
639
|
| `--owl2rl` | Add the documented OWL 2 RL inference rules, including RDFS, and RDF conflict reports to RDF inputs. |
|
|
633
640
|
| `--qudt` | Normalize supported QUDT/CDT quantities, with source provenance. |
|
|
634
641
|
| `--skos` | Add positive SKOS Core entailments. |
|
|
@@ -724,7 +731,7 @@ not in the proof.
|
|
|
724
731
|
| `negation requires a goal whose variables are bound` | Bind the variables before `not(...)`, or use `_`. |
|
|
725
732
|
| `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). |
|
|
726
733
|
| `exceeded max_depth` or another bound | Usually a left-recursive backward rule; make it forward, or raise the bound. |
|
|
727
|
-
|
|
|
734
|
+
| `the called variable p must be bound` | In goal text a bare name is a variable; write `p()` or `'p'`. |
|
|
728
735
|
| `this is a proof document, not a program` | Check it with `--check-proof PROOF PROGRAM`. |
|
|
729
736
|
|
|
730
737
|
## JavaScript library
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eyemind",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.44",
|
|
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",
|
package/src/engine.js
CHANGED
|
@@ -409,6 +409,8 @@ export class Solver {
|
|
|
409
409
|
stats.inferences++;
|
|
410
410
|
if (stats.inferences > this.maxInferences) throw new EyemindError('reasoning exceeded max_inferences');
|
|
411
411
|
const goal = deref(frame.goals[frame.index], env);
|
|
412
|
+
// A renamed-apart variable is named by what its clause or goal wrote.
|
|
413
|
+
if (goal instanceof Var) throw new EyemindError(`the called variable ${goal.name.split('#')[0]} must be bound`);
|
|
412
414
|
if (!isCallable(goal)) throw new EyemindError(`expected a callable goal, got ${text(goal)}`);
|
|
413
415
|
const next = this.step(goal, frame, env, choices);
|
|
414
416
|
if (next === null) {
|
package/src/formats.js
CHANGED
|
@@ -217,7 +217,7 @@ export const defaultFormat = (kind) => RDF_PROFILES.includes(kind) ? 'turtle' :
|
|
|
217
217
|
export function writeConclusions(loaded, result, { format, all = false, blankNodePrefix = '' } = {}) {
|
|
218
218
|
if (format === 'eyemind') return null;
|
|
219
219
|
if (format === 'le') return writeLe(result, { odrl: loaded.compiled?.odrl ?? null,
|
|
220
|
-
prefixes: loaded.
|
|
220
|
+
prefixes: loaded.prefixes instanceof Map ? Object.fromEntries(loaded.prefixes) : loaded.prefixes ?? {} });
|
|
221
221
|
if (format === 'n3') {
|
|
222
222
|
if (loaded.kind !== 'n3') throw new EyemindError('--to n3 writes the conclusions of an N3 run');
|
|
223
223
|
return resultToN3(loaded.compiled.doc, result, { mode: all ? 'all' : 'new', blankNodePrefix }).n3;
|
package/src/le.js
CHANGED
|
@@ -578,8 +578,18 @@ function leGoal(term, render, properties, compact) {
|
|
|
578
578
|
|
|
579
579
|
export function writeLe(result, { odrl = null, prefixes = {} } = {}) {
|
|
580
580
|
if (odrl) result = odrlLeReport(result, odrl.namespace);
|
|
581
|
-
|
|
582
|
-
|
|
581
|
+
// A prefix LE cannot spell, such as Turtle's empty one, gets the first free
|
|
582
|
+
// name of ns, ns2, ...; the output declares each prefix it uses.
|
|
583
|
+
const valid = Object.entries(prefixes).filter(([prefix, namespace]) => PREFIX.test(prefix) && typeof namespace === 'string');
|
|
584
|
+
const taken = new Set(valid.map(([prefix]) => prefix)), stated = new Set(valid.map(([, namespace]) => namespace));
|
|
585
|
+
for (const [prefix, namespace] of Object.entries(prefixes)) {
|
|
586
|
+
if (PREFIX.test(prefix) || typeof namespace !== 'string' || stated.has(namespace)) continue;
|
|
587
|
+
let name = 'ns';
|
|
588
|
+
for (let n = 2; taken.has(name); n++) name = `ns${n}`;
|
|
589
|
+
taken.add(name); stated.add(namespace);
|
|
590
|
+
valid.push([name, namespace]);
|
|
591
|
+
}
|
|
592
|
+
const namespaces = odrl ? [] : valid.sort((a, b) => b[1].length - a[1].length);
|
|
583
593
|
const used = new Map();
|
|
584
594
|
const compact = (term) => {
|
|
585
595
|
if (!(term instanceof Struct) || term.name !== 'iri' || term.args.length !== 1 || typeof term.args[0] !== 'string') return null;
|
package/src/qudt.js
CHANGED
|
@@ -97,6 +97,11 @@ implied_by(qu_align(U, U, G), qu_dimension(U, G, _));
|
|
|
97
97
|
for (const p of [iri('${SAME_AS}'), iri('${EXACT_MATCH}'), qc('alignedQudtUnit')]) {
|
|
98
98
|
implied_by(qu_align(Local, U, G), [rdf(Local, p, U, G), qu_dimension(U, G, _)]);
|
|
99
99
|
}
|
|
100
|
+
// owl:sameAs and skos:exactMatch are symmetric, so a known unit can name its
|
|
101
|
+
// local alias without --owl2rl or --skos; qconv:alignedQudtUnit is directed.
|
|
102
|
+
for (const p of [iri('${SAME_AS}'), iri('${EXACT_MATCH}')]) {
|
|
103
|
+
implied_by(qu_align(Local, U, G), [rdf(U, p, Local, G), qu_dimension(U, G, _)]);
|
|
104
|
+
}
|
|
100
105
|
implied_by(qu_custom_profile(P, G), ent_base(P, qc('targetUnit'), _, G));
|
|
101
106
|
implied_by(qu_profile(P, DT, U, Code, G), [qu_builtin_profile(P, DT, U, Code), not(qu_custom_profile(P, G))]);
|
|
102
107
|
implied_by(qu_profile(P, DT, U, Code, G), [ent_base(P, qc('targetUnit'), U, G), ent_base(P, qc('datatype'), iri(DT), G), ent_base(P, qc('targetUcumCode'), L, G), srl_str(L, literal(Code, datatype(quString)))]);
|
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
|
+
export const VERSION = '0.8.44';
|