eyemind 0.8.43 → 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 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
- [Research access example](https://eyereasoner.github.io/eyemind/examples/deck/research-access-le) · [ODRL Vocabulary](https://www.w3.org/TR/odrl-vocab/) · [Data Privacy Vocabulary 2.3](https://w3id.org/dpv/2.3/dpv/)
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. An if/then sentence compiles its premises and conclusions to one
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 `reportConstraint` distinguish the report's
419
- `eval:permission`, `eval:prohibition` and `eval:constraint` links from ODRL
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. [Research snapshot](https://eyereasoner.github.io/eyemind/examples/deck/research-snapshot-le)
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 normal
465
- `--odrl` switch continues to select the Turtle snapshot compiler.
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. `--goal` uses LS goal syntax and
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.43
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
@@ -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, `--to le` writes LS conclusions
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
@@ -450,14 +453,15 @@ properties with scalar or DPV category constraints and combines constraints
450
453
  with `odrl:and`, `odrl:or` or `odrl:xone`. Permissions can require duties,
451
454
  with fulfillment evidence attached to each request.
452
455
 
453
- `--odrl` combines with `--owl2rl`, `--skos`, `--qudt` and `--shacl`. The
456
+ `--odrl` combines with `--owl2rl`, `--skos`, `--qudt` and `--shacl`, though
457
+ not with `--stream-messages`, `--shacl-in` or `--shacl-out`. The
454
458
  snapshot then reads the given triples, what the profiles entail about each
455
459
  request's state, such as an observation a property chain derives, and entailed
456
460
  SKOS links between categories, such as a `skos:broadMatch` to DPV. Other
457
461
  entailments, such as an `rdfs:Resource` type for every node, stay out of the
458
462
  snapshot, whose validation would reject them. The output is the ODRL report
459
463
  with the profiles' own reports, such as a SHACL validation report.
460
- [Handicap-card example](https://eyereasoner.github.io/eyemind/examples/deck/handicap-card) · [Research snapshot](https://eyereasoner.github.io/eyemind/examples/deck/research-snapshot-le) · [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)
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)
461
465
 
462
466
  ## How eyemind reasons
463
467
 
@@ -604,9 +608,9 @@ A clause is listed when no conclusion's proof uses it; a clause only a negation
604
608
 
605
609
  ## Examples and the playground
606
610
 
607
- The [examples](https://eyereasoner.github.io/eyemind/examples/) range from classics (Ackermann, the zebra puzzle) to planning, policy reasoning, mathematics, RDF 1.2 data and a hundred-thousand-level taxonomy. Each has its conclusions, proof and check report saved in `examples/output/`, `examples/proof/` and `examples/check/`, and a card deck for a wide audience. Change a fact, run it, and compare with the saved output.
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.
608
612
 
609
- The [playground](https://eyereasoner.github.io/eyemind/playground/) runs eyemind in a worker in your browser, so **Stop** ends a long run. Choose an example, edit it, pick an output (conclusions, proof, check of a saved proof, or unused clauses) and press **Run** or Ctrl+Enter. A line an error names is marked red, the options panel shows the equivalent command, and **Share link** copies a link with the program and options.
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.
610
614
 
611
615
  ## Command line
612
616
 
@@ -628,10 +632,10 @@ eyemind [OPTION ...] [FILE ...]
628
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. |
629
633
  | `--stats` | Print reasoning statistics as JSON to standard error. |
630
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. |
631
- | `--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. |
632
636
  | `--all` | With RDF or N3 output, write the given data too. |
633
637
  | `--program` | Print the program the inputs compile to. |
634
- | `--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`. |
635
639
  | `--owl2rl` | Add the documented OWL 2 RL inference rules, including RDFS, and RDF conflict reports to RDF inputs. |
636
640
  | `--qudt` | Normalize supported QUDT/CDT quantities, with source provenance. |
637
641
  | `--skos` | Add positive SKOS Core entailments. |
@@ -727,7 +731,7 @@ not in the proof.
727
731
  | `negation requires a goal whose variables are bound` | Bind the variables before `not(...)`, or use `_`. |
728
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). |
729
733
  | `exceeded max_depth` or another bound | Usually a left-recursive backward rule; make it forward, or raise the bound. |
730
- | A goal with no arguments finds nothing | In goal text a bare name is a variable; write `p()` or `'p'`. |
734
+ | `the called variable p must be bound` | In goal text a bare name is a variable; write `p()` or `'p'`. |
731
735
  | `this is a proof document, not a program` | Check it with `--check-proof PROOF PROGRAM`. |
732
736
 
733
737
  ## JavaScript library
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyemind",
3
- "version": "0.8.43",
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.kind === 'le' ? loaded.prefixes : {} });
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
- const namespaces = odrl ? [] : Object.entries(prefixes).filter(([prefix]) => PREFIX.test(prefix))
582
- .sort((a, b) => b[1].length - a[1].length);
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/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.43';
2
+ export const VERSION = '0.8.44';