eyemind 0.6.4 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -6
- package/SPEC.md +1 -1
- package/package.json +1 -1
- package/src/cli.js +16 -2
- package/src/entailment.js +180 -0
- package/src/formats.js +31 -5
- package/src/odrl.js +252 -0
- package/src/version.js +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ eyemind is a dependency-free reasoner for **Logic Script (LS)**, a rule language
|
|
|
7
7
|
|
|
8
8
|
[Playground](https://eyereasoner.github.io/eyemind/playground/) · [Specification](https://eyereasoner.github.io/eyemind/SPEC) · [Conformance](https://eyereasoner.github.io/eyemind/conformance/) · [Examples](https://eyereasoner.github.io/eyemind/examples/)
|
|
9
9
|
|
|
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
|
|
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 138 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).
|
|
11
11
|
|
|
12
12
|
## Contents
|
|
13
13
|
|
|
@@ -22,6 +22,8 @@ The playground runs programs in your browser; the specification defines the lang
|
|
|
22
22
|
- [Notation3](#notation3)
|
|
23
23
|
- [RDF Messages](#rdf-messages)
|
|
24
24
|
- [SPARQL 1.2 RL](#sparql-12-rl)
|
|
25
|
+
- [RDFS and OWL-RL](#rdfs-and-owl-rl)
|
|
26
|
+
- [ODRL snapshots](#odrl-snapshots)
|
|
25
27
|
- [How eyemind reasons](#how-eyemind-reasons)
|
|
26
28
|
- [Proofs, and what checking one means](#proofs-and-what-checking-one-means)
|
|
27
29
|
- [JSON check reports](#json-check-reports)
|
|
@@ -349,7 +351,7 @@ eyemind --all rules.srl facts.ttl # the base graph too
|
|
|
349
351
|
eyemind -c rules.srl facts.ttl # a proof of it, checked
|
|
350
352
|
```
|
|
351
353
|
|
|
352
|
-
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
|
|
354
|
+
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.
|
|
353
355
|
|
|
354
356
|
SRL integers and decimals use exact integer arithmetic. Decimal addition,
|
|
355
357
|
subtraction, multiplication, comparison, rounding and terminating division
|
|
@@ -385,6 +387,132 @@ SRL programs for deployment dependencies, route distances, ancestry, inventory,
|
|
|
385
387
|
invoices, provenance and Unicode strings. Each has saved Turtle output, a
|
|
386
388
|
proof, a check report and a deck, and runs in the playground.
|
|
387
389
|
|
|
390
|
+
### RDFS and OWL-RL
|
|
391
|
+
|
|
392
|
+
`--rdfs` and `--owl-rl` add inference rules to RDF inputs. The files still
|
|
393
|
+
use their usual RDF extensions; standard input is Turtle. A graph's use of
|
|
394
|
+
RDFS or OWL vocabulary alone does not enable either extension. The playground
|
|
395
|
+
has both switches and preserves them in saved sessions and shared links.
|
|
396
|
+
|
|
397
|
+
```sh
|
|
398
|
+
eyemind --rdfs examples/people-rdfs.ttl
|
|
399
|
+
eyemind --owl-rl examples/family-owl-rl.ttl > /tmp/family-report.ttl
|
|
400
|
+
eyemind --owl-rl --program examples/family-owl-rl.ttl > /tmp/family.js
|
|
401
|
+
eyemind --to turtle /tmp/family.js
|
|
402
|
+
eyemind --owl-rl --proof examples/family-owl-rl.ttl > /tmp/family-proof.js
|
|
403
|
+
eyemind --owl-rl --check-proof /tmp/family-proof.js examples/family-owl-rl.ttl
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
The generated `.js` contains the data, inference rules and reporting rules;
|
|
407
|
+
it runs as standalone LS. Proofs and check reports remain `.js`. Conclusions
|
|
408
|
+
default to Turtle, with `--all` adding the input triples. Multiple RDF files
|
|
409
|
+
join their default graphs; named graphs are reasoned over independently and
|
|
410
|
+
need `--to trig` or `--to n-quads` to retain their graph names.
|
|
411
|
+
|
|
412
|
+
The implemented rules are:
|
|
413
|
+
|
|
414
|
+
| Switch | Coverage |
|
|
415
|
+
| --- | --- |
|
|
416
|
+
| `--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. |
|
|
417
|
+
| `--owl-rl` | The RDFS rules above plus 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. |
|
|
418
|
+
|
|
419
|
+
The OWL rules implement the non-datatype rule families of
|
|
420
|
+
[OWL 2 RL/RDF tables 4–7 and 9](https://www.w3.org/TR/owl2-profiles/#Reasoning_in_OWL_2_RL_and_RDF_Graphs),
|
|
421
|
+
inspired by [EYE's RDF plus OWL rules](https://github.com/eyereasoner/eye/tree/master/reasoning/rpo).
|
|
422
|
+
They operate on the terms present in each graph. RDFS axiomatic triples,
|
|
423
|
+
datatype value-space reasoning (OWL table 8), ontology imports and OWL
|
|
424
|
+
constructs outside these rule families are not implemented. Literal equality
|
|
425
|
+
uses the RDF-to-LS representation, without general datatype normalization.
|
|
426
|
+
These switches do not validate profile membership or certify completeness
|
|
427
|
+
for arbitrary RDFS or OWL ontologies. `--owl-rl` already includes `--rdfs`;
|
|
428
|
+
enabling both adds the rules once. They take RDF inputs and cannot be combined
|
|
429
|
+
with `--odrl` or `--stream-messages`.
|
|
430
|
+
|
|
431
|
+
OWL contradictions appear as RDF records of type `ent:Conflict`, where
|
|
432
|
+
`ent:` is `https://eyereasoner.github.io/eyemind/entailment#`. Each records its
|
|
433
|
+
rule name with `ent:rule` and arguments with `ent:focus`, `ent:left` and
|
|
434
|
+
`ent:right`; the proof supplies the supporting assertions. Reporting continues
|
|
435
|
+
after a conflict and does not infer arbitrary triples from inconsistency.
|
|
436
|
+
Exit code 0 means the report completed, including any conflicts. An empty
|
|
437
|
+
conflict set only means these rules detected none; it is not a full consistency
|
|
438
|
+
guarantee. RDFS domain and range infer types rather than checking required
|
|
439
|
+
fields, and missing facts alone do not establish a conflict.
|
|
440
|
+
|
|
441
|
+
Try the [people directory](https://eyereasoner.github.io/eyemind/examples/deck/people-rdfs)
|
|
442
|
+
and [family ontology](https://eyereasoner.github.io/eyemind/examples/deck/family-owl-rl).
|
|
443
|
+
|
|
444
|
+
### ODRL snapshots
|
|
445
|
+
|
|
446
|
+
Use `--odrl` to add ODRL validation and evaluation to one Turtle file
|
|
447
|
+
containing policies, candidate requests and their state of the world (SOTW).
|
|
448
|
+
A resource of type `eval:Evaluation`, using
|
|
449
|
+
`eval: <https://eyereasoner.github.io/eyemind/odrl#>`, selects the policies
|
|
450
|
+
with `eval:policy`, the requests with `eval:request`, and a cross-policy
|
|
451
|
+
`eval:conflictStrategy`: `odrl:perm`, `odrl:prohibit` or `odrl:invalid`.
|
|
452
|
+
The switch enables the snapshot compiler; without it Turtle remains RDF
|
|
453
|
+
data, even when it contains an `eval:Evaluation` resource. The playground
|
|
454
|
+
has the same `--odrl` checkbox, enabled for the handicap-card example and
|
|
455
|
+
preserved in saved state and shared links.
|
|
456
|
+
|
|
457
|
+
```sh
|
|
458
|
+
eyemind --odrl examples/handicap-card.ttl > /tmp/handicap-card-report.ttl
|
|
459
|
+
eyemind --odrl --program examples/handicap-card.ttl > /tmp/handicap-card.js
|
|
460
|
+
eyemind --to turtle /tmp/handicap-card.js > /tmp/handicap-card-report.ttl
|
|
461
|
+
eyemind --odrl --proof examples/handicap-card.ttl > /tmp/handicap-card-proof.js
|
|
462
|
+
eyemind --odrl --check-proof /tmp/handicap-card-proof.js examples/handicap-card.ttl
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
The compiled `.js` includes the input facts and all validation and evaluation
|
|
466
|
+
LS; running it needs no policy file or external evaluator. The Turtle report
|
|
467
|
+
lists each request's `eval:decision` (`Allowed`, `Prohibited`,
|
|
468
|
+
`NotApplicable` or `Undetermined`), the `eval:canHappen` requests, validation
|
|
469
|
+
errors, uncertainties and conflicts. Each conflict identifies its request,
|
|
470
|
+
permission policy/rule and prohibition policy/rule. `eval:conflictCount`
|
|
471
|
+
explicitly records zero when none is detected. This evaluates the listed
|
|
472
|
+
requests at the supplied snapshot; it neither issues a card nor predicts
|
|
473
|
+
future changes to the world.
|
|
474
|
+
`eval:validationStatus` records whether the input fits the profile's shape
|
|
475
|
+
and vocabulary. Conflicts are reported and resolved separately.
|
|
476
|
+
|
|
477
|
+
The supported profile is declared on each policy with
|
|
478
|
+
`odrl:profile eval:SnapshotProfile`. Policies are `odrl:Set` or
|
|
479
|
+
`odrl:Agreement`; each rule states exactly one assignee, action and target.
|
|
480
|
+
A request is an `eval:Request` with those same three ODRL properties, an
|
|
481
|
+
`eval:subject` and an `eval:state`. Its `eval:State` names the same subject.
|
|
482
|
+
Assignees, actions and targets match by RDF term identity. Each constraint's
|
|
483
|
+
`odrl:leftOperand` is an IRI naming a property of that state, with exactly one
|
|
484
|
+
`odrl:operator` and `odrl:rightOperand`. All constraints of a rule must hold.
|
|
485
|
+
Equality and inequality (`eq`, `neq`) support IRIs, strings, booleans and
|
|
486
|
+
exact integers; ordering (`gt`, `gteq`, `lt`, `lteq`) supports exact integers.
|
|
487
|
+
Boolean lexical forms `true`/`1` and `false`/`0` denote the same values.
|
|
488
|
+
|
|
489
|
+
An absent, multiply valued, unsupported or differently typed observation
|
|
490
|
+
leaves a constraint unknown. A definitely false constraint makes its rule
|
|
491
|
+
inapplicable; otherwise an unknown constraint makes the request
|
|
492
|
+
`Undetermined`. Missing facts never establish a negative observation.
|
|
493
|
+
The caller supplies the applicable policy set, trusted state and candidate
|
|
494
|
+
actions. The compiler does not establish agreement acceptance or evidence
|
|
495
|
+
authenticity. Unsupported policy properties, profiles, duties, inheritance,
|
|
496
|
+
action hierarchies, collections and refinements are validation errors and
|
|
497
|
+
block authorization for the evaluation. This is a bounded profile, not a
|
|
498
|
+
general ODRL evaluator.
|
|
499
|
+
|
|
500
|
+
ODRL's per-policy `odrl:conflict` strategies are applied first; an omitted
|
|
501
|
+
strategy defaults to `odrl:invalid`. A detected internal conflict then voids
|
|
502
|
+
that policy and leaves the evaluation undetermined. The explicit
|
|
503
|
+
`eval:conflictStrategy` combines the remaining policy decisions; `invalid`
|
|
504
|
+
voids the evaluation if both a permission and a prohibition remain for any
|
|
505
|
+
request. Conflicts stay in the report after resolution. These are
|
|
506
|
+
permission/prohibition overlaps for the listed requests, not an exhaustive
|
|
507
|
+
search for conflicts in every possible state. The rules follow the
|
|
508
|
+
[ODRL Information Model](https://www.w3.org/TR/odrl-model/) for the supported
|
|
509
|
+
features; the snapshot vocabulary and cross-policy composition are this
|
|
510
|
+
profile's conventions.
|
|
511
|
+
|
|
512
|
+
The [handicap-card example](https://eyereasoner.github.io/eyemind/examples/deck/handicap-card)
|
|
513
|
+
allows Alice's request and reports the conflict that blocks Bob's, under
|
|
514
|
+
explicitly fictional criteria.
|
|
515
|
+
|
|
388
516
|
## How eyemind reasons
|
|
389
517
|
|
|
390
518
|
The statement chooses the direction:
|
|
@@ -551,10 +679,13 @@ eyemind [OPTION ...] [FILE ...]
|
|
|
551
679
|
| `--unused` | List the clauses that make no difference to the conclusions. |
|
|
552
680
|
| `--stream-messages` | Read an RDF Message Log and run the rules independently per message; Node reads files, stdin and HTTP(S) incrementally. |
|
|
553
681
|
| `--stats` | Print reasoning statistics as JSON to standard error. |
|
|
554
|
-
| `--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 or
|
|
555
|
-
| `--to FORMAT` | Write the conclusions as `turtle`, `trig`, `n-triples`, `n-quads`, `n3` or `eyemind`; by default N3 for N3, Turtle for SRL, eyemind otherwise. |
|
|
682
|
+
| `--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, RDFS or OWL-RL program has 1000000, 100000 and 1000000000. |
|
|
683
|
+
| `--to FORMAT` | Write the conclusions as `turtle`, `trig`, `n-triples`, `n-quads`, `n3` or `eyemind`; by default N3 for N3, Turtle for SRL, ODRL, RDFS and OWL-RL, eyemind otherwise. |
|
|
556
684
|
| `--all` | With RDF or N3 output, write the given data too. |
|
|
557
685
|
| `--program` | Print the program the inputs compile to. |
|
|
686
|
+
| `--odrl` | Add the ODRL snapshot profile's validation and evaluation LS to one Turtle input. |
|
|
687
|
+
| `--rdfs` | Add the documented RDFS inference rules to RDF inputs. |
|
|
688
|
+
| `--owl-rl` | Add the documented OWL-RL inference rules and RDF conflict reports to RDF inputs; includes `--rdfs`. |
|
|
558
689
|
| `--base IRI` | Resolve relative IRIs of the inputs against `IRI` instead of each file's location. |
|
|
559
690
|
| `-v`, `--version`, `-h`, `--help` | Print the version or the usage. |
|
|
560
691
|
|
|
@@ -564,7 +695,7 @@ each goal as a data document, with an array denoting conjunction. With
|
|
|
564
695
|
`--check-proof`, supply the original goals the proof answers.
|
|
565
696
|
An option that takes a value requires it immediately afterward; another
|
|
566
697
|
option, including a short alias such as `-v`, is reported as a missing value.
|
|
567
|
-
With `--goal`, answers default to eyemind terms even for N3 and
|
|
698
|
+
With `--goal`, answers default to eyemind terms even for N3, SRL, ODRL, RDFS and OWL-RL inputs;
|
|
568
699
|
use `--to` to request another output format.
|
|
569
700
|
|
|
570
701
|
With `--prove-and-check`, reasoning bounds and `--stats` apply to proof
|
|
@@ -593,7 +724,7 @@ They are outside the language and proof specification.
|
|
|
593
724
|
|
|
594
725
|
The JavaScript implementation defaults to a depth limit of 1000000, an
|
|
595
726
|
inference limit of 1000000 and a limit of 1000 forward rounds per stratum.
|
|
596
|
-
Compiled N3 and
|
|
727
|
+
Compiled N3, SRL, ODRL, RDFS and OWL-RL programs use 1000000, 1000000000 and 100000 respectively.
|
|
597
728
|
Each supplied bound must be a positive integer no greater than
|
|
598
729
|
9007199254740991.
|
|
599
730
|
|
package/SPEC.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eyemind",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "A dependency-free Logic Script (LS) reasoner with forward and backward reasoning, checkable proofs, and RDF 1.2, Notation3 (N3) and SPARQL 1.2 RL (SRL) interoperability.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/cli.js
CHANGED
|
@@ -24,9 +24,12 @@ Files are read by extension: .js as LS, .ttl, .trig, .nt and .nq as RDF 1.2 data
|
|
|
24
24
|
--max-inferences N Bound reasoning work (default 1000000)
|
|
25
25
|
--to FORMAT Write the conclusions as turtle, trig, n-triples,
|
|
26
26
|
n-quads, n3 or eyemind (default: n3 for N3, turtle
|
|
27
|
-
for
|
|
27
|
+
for SRL, ODRL, RDFS or OWL-RL, eyemind otherwise or with --goal)
|
|
28
28
|
--all With RDF or N3 output, write the given data too
|
|
29
29
|
--program Print the program the inputs compile to
|
|
30
|
+
--odrl Add ODRL validation and evaluation to one Turtle snapshot
|
|
31
|
+
--rdfs Add RDFS inference rules to RDF inputs
|
|
32
|
+
--owl-rl Add OWL-RL inference and conflict rules to RDF inputs
|
|
30
33
|
--base IRI Resolve relative IRIs of the inputs against IRI
|
|
31
34
|
--stream-messages Run the rules independently for each RDF Message
|
|
32
35
|
-v, --version Print the version
|
|
@@ -65,6 +68,9 @@ export function main(argv, io) {
|
|
|
65
68
|
let printProgram = false;
|
|
66
69
|
let base = null;
|
|
67
70
|
let streamMessages = false;
|
|
71
|
+
let odrl = false;
|
|
72
|
+
let rdfs = false;
|
|
73
|
+
let owlRl = false;
|
|
68
74
|
const filePositions = new Set();
|
|
69
75
|
for (let i = 0; i < argv.length; i++) {
|
|
70
76
|
const arg = ALIASES.get(argv[i]) ?? argv[i];
|
|
@@ -90,6 +96,12 @@ export function main(argv, io) {
|
|
|
90
96
|
all = true;
|
|
91
97
|
} else if (arg === '--program') {
|
|
92
98
|
printProgram = true;
|
|
99
|
+
} else if (arg === '--odrl') {
|
|
100
|
+
odrl = true;
|
|
101
|
+
} else if (arg === '--rdfs') {
|
|
102
|
+
rdfs = true;
|
|
103
|
+
} else if (arg === '--owl-rl') {
|
|
104
|
+
owlRl = true;
|
|
93
105
|
} else if (arg === '--stream-messages') {
|
|
94
106
|
streamMessages = true;
|
|
95
107
|
} else if (arg === '--check-proof' || arg === '--goal' || arg === '--to' || arg === '--base' || Object.hasOwn(LIMITS, arg)) {
|
|
@@ -137,6 +149,8 @@ export function main(argv, io) {
|
|
|
137
149
|
if (!files.length) files.push('-');
|
|
138
150
|
if (files.filter((file) => file === '-').length > 1) throw new UsageError('stdin can only be read once');
|
|
139
151
|
if (streamMessages) {
|
|
152
|
+
if (odrl) throw new UsageError('--odrl cannot be combined with --stream-messages');
|
|
153
|
+
if (rdfs || owlRl) throw new UsageError('--rdfs and --owl-rl cannot be combined with --stream-messages');
|
|
140
154
|
if (proofFile !== null || options.proof || proveAndCheck || printProgram || unused) {
|
|
141
155
|
throw new UsageError('--stream-messages cannot be combined with --proof, --check-proof, --prove-and-check, --program or --unused; replay the whole log to prove its conclusions');
|
|
142
156
|
}
|
|
@@ -177,7 +191,7 @@ export function main(argv, io) {
|
|
|
177
191
|
}
|
|
178
192
|
const document = proofFile === null ? null : readSource(proofFile, io);
|
|
179
193
|
const loaded = loadInputs(files.map((file) => [readSource(file, io), file === '-' ? '<stdin>' : file]), io,
|
|
180
|
-
{ base, messageInputs: io.messageInputs,
|
|
194
|
+
{ base, messageInputs: io.messageInputs, odrl, rdfs, owlRl,
|
|
181
195
|
srlContext: document !== null && files.some((file) => inputKind(file) === 'srl') ? srlContextFromProof(document) : null });
|
|
182
196
|
const program = loaded.program;
|
|
183
197
|
if (printProgram) {
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// Explicit RDF entailment extensions, compiled to standalone Logic Script.
|
|
2
|
+
// Rule names follow W3C OWL 2 RL/RDF tables 4–7 and 9:
|
|
3
|
+
// https://www.w3.org/TR/owl2-profiles/#Reasoning_in_OWL_2_RL_and_RDF_Graphs
|
|
4
|
+
import { loadText } from './lang.js';
|
|
5
|
+
import { rdfDocument } from './rdf.js';
|
|
6
|
+
|
|
7
|
+
export const ENTAILMENT = 'https://eyereasoner.github.io/eyemind/entailment#';
|
|
8
|
+
|
|
9
|
+
export function compileEntailment({ quads, prefixes }, { owl = false, source = '<input>' } = {}) {
|
|
10
|
+
const kind = owl ? 'owl-rl' : 'rdfs';
|
|
11
|
+
const text = `// Generated by eyemind from ${String(source).replace(/[\r\n\u2028\u2029]/g, ' ')}, with --${kind}.\n` +
|
|
12
|
+
'// rdf(S, P, O, G) is the working graph; result_rdf contains new RDF conclusions.\n' +
|
|
13
|
+
`facts_from({ text: ${JSON.stringify(rdfDocument(quads))} })\n` +
|
|
14
|
+
`facts_from({ text: ${JSON.stringify(rdfDocument(quads, 'ent_base'))} })\n` +
|
|
15
|
+
COMMON + RDFS + (owl ? OWL : '') + OUTPUT;
|
|
16
|
+
return { kind, text, program: loadText(text, source), prefixes: { ...prefixes, ent: ENTAILMENT }, compiled: null };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const COMMON = String.raw`
|
|
20
|
+
const r = (name) => iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#' + name);
|
|
21
|
+
const s = (name) => iri('http://www.w3.org/2000/01/rdf-schema#' + name);
|
|
22
|
+
const o = (name) => iri('http://www.w3.org/2002/07/owl#' + name);
|
|
23
|
+
const e = (name) => iri('https://eyereasoner.github.io/eyemind/entailment#' + name);
|
|
24
|
+
const t = (a, p, b) => rdf(a, p, b, G);
|
|
25
|
+
implied_by(ent_resource(iri(A)), is_atom(A));
|
|
26
|
+
implied_by(ent_resource(bnode(A, B)), [is_atom(A), is_atom(B)]);
|
|
27
|
+
implied_by(ent_resource(triple(A, B, C)), 'true');
|
|
28
|
+
implies(rdf(S, P, O, G), ent_graph(G));
|
|
29
|
+
implies(rdf(S, P, O, G), [ent_node(S, G), ent_node(P, G), ent_node(O, G)]);
|
|
30
|
+
|
|
31
|
+
// RDFS class/property propagation, shared with OWL-RL.
|
|
32
|
+
implies([t(P, s('domain'), C), t(X, P, Y)], t(X, r('type'), C));
|
|
33
|
+
implies([t(P, s('range'), C), t(X, P, Y)], t(Y, r('type'), C));
|
|
34
|
+
implies([t(C, s('subClassOf'), D), t(X, r('type'), C)], t(X, r('type'), D));
|
|
35
|
+
implies([t(C, s('subClassOf'), D), t(D, s('subClassOf'), E)], t(C, s('subClassOf'), E));
|
|
36
|
+
implies([t(P, s('subPropertyOf'), Q), t(X, P, Y)], t(X, Q, Y));
|
|
37
|
+
implies([t(P, s('subPropertyOf'), Q), t(Q, s('subPropertyOf'), R)], t(P, s('subPropertyOf'), R));
|
|
38
|
+
for (const property of ['domain', 'range']) {
|
|
39
|
+
implies([t(P, s(property), C), t(C, s('subClassOf'), D)], t(P, s(property), D));
|
|
40
|
+
implies([t(Q, s(property), C), t(P, s('subPropertyOf'), Q)], t(P, s(property), C));
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
const RDFS = String.raw`
|
|
45
|
+
// RDFS rules over the terms present in the input; no infinite vocabulary
|
|
46
|
+
// axioms or datatype value-space reasoning are added.
|
|
47
|
+
implies(rdf(S, P, O, G), t(P, r('type'), r('Property')));
|
|
48
|
+
implies(rdf(S, P, O, G), [t(S, r('type'), s('Resource')), t(O, r('type'), s('Resource'))]);
|
|
49
|
+
implies(t(X, r('type'), C), t(C, r('type'), s('Class')));
|
|
50
|
+
for (const property of ['subClassOf', 'domain', 'range']) {
|
|
51
|
+
implies(t(X, s(property), C), t(C, r('type'), s('Class')));
|
|
52
|
+
}
|
|
53
|
+
for (const property of ['domain', 'range']) implies(t(P, s(property), C), t(P, r('type'), r('Property')));
|
|
54
|
+
implies(t(C, s('subClassOf'), D), t(C, r('type'), s('Class')));
|
|
55
|
+
implies(t(P, s('subPropertyOf'), Q), [t(P, r('type'), r('Property')), t(Q, r('type'), r('Property'))]);
|
|
56
|
+
implies(t(P, r('type'), r('Property')), t(P, s('subPropertyOf'), P));
|
|
57
|
+
implies(t(C, r('type'), s('Class')), [t(C, s('subClassOf'), C), t(C, s('subClassOf'), s('Resource'))]);
|
|
58
|
+
implies(t(P, r('type'), s('ContainerMembershipProperty')), t(P, s('subPropertyOf'), s('member')));
|
|
59
|
+
implies(t(D, r('type'), s('Datatype')), t(D, s('subClassOf'), s('Literal')));
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
const OWL = String.raw`
|
|
63
|
+
// Equality (table 4). Generalized triples stay internal when their subject
|
|
64
|
+
// or predicate is a literal; RDF output only contains legal RDF triples.
|
|
65
|
+
implies(ent_node(X, G), t(X, o('sameAs'), X));
|
|
66
|
+
implies(t(X, o('sameAs'), Y), t(Y, o('sameAs'), X));
|
|
67
|
+
implies([t(X, o('sameAs'), Y), t(Y, o('sameAs'), Z)], t(X, o('sameAs'), Z));
|
|
68
|
+
implies([t(X, o('sameAs'), Y), t(X, P, Z)], t(Y, P, Z));
|
|
69
|
+
implies([t(P, o('sameAs'), Q), t(X, P, Y)], t(X, Q, Y));
|
|
70
|
+
implies([t(X, o('sameAs'), Y), t(Z, P, X)], t(Z, P, Y));
|
|
71
|
+
implies([t(X, o('sameAs'), Y), t(X, o('differentFrom'), Y)], ent_conflict('eq-diff1', X, o('differentFrom'), Y, G));
|
|
72
|
+
|
|
73
|
+
// Finite, positive list relations also terminate on cyclic rdf:rest data.
|
|
74
|
+
implies(ent_graph(G), ent_list(r('nil'), G));
|
|
75
|
+
implies([t(L, r('first'), X), t(L, r('rest'), R), ent_list(R, G)], ent_list(L, G));
|
|
76
|
+
implies([ent_list(L, G), t(L, r('first'), X)], ent_member(L, X, G));
|
|
77
|
+
implies([ent_list(L, G), t(L, r('rest'), R), ent_member(R, X, G)], ent_member(L, X, G));
|
|
78
|
+
implies([ent_list(L, G), t(L, r('first'), X), t(L, r('rest'), R), ent_member(R, Y, G)], ent_pair(L, X, Y, G));
|
|
79
|
+
implies([ent_list(L, G), t(L, r('rest'), R), ent_pair(R, X, Y, G)], ent_pair(L, X, Y, G));
|
|
80
|
+
for (const property of ['members', 'distinctMembers']) {
|
|
81
|
+
implies([t(A, r('type'), o('AllDifferent')), t(A, o(property), L), ent_pair(L, X, Y, G), t(X, o('sameAs'), Y)],
|
|
82
|
+
ent_conflict(property === 'members' ? 'eq-diff2' : 'eq-diff3', A, X, Y, G));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Property axioms (table 5).
|
|
86
|
+
for (const property of [s('label'), s('comment'), s('seeAlso'), s('isDefinedBy'),
|
|
87
|
+
o('deprecated'), o('versionInfo'), o('priorVersion'), o('backwardCompatibleWith'), o('incompatibleWith')]) {
|
|
88
|
+
implies(ent_graph(G), t(property, r('type'), o('AnnotationProperty')));
|
|
89
|
+
}
|
|
90
|
+
implies([t(P, r('type'), o('FunctionalProperty')), t(X, P, Y), t(X, P, Z)], t(Y, o('sameAs'), Z));
|
|
91
|
+
implies([t(P, r('type'), o('InverseFunctionalProperty')), t(X, P, Z), t(Y, P, Z)], t(X, o('sameAs'), Y));
|
|
92
|
+
implies([t(P, r('type'), o('SymmetricProperty')), t(X, P, Y)], t(Y, P, X));
|
|
93
|
+
implies([t(P, r('type'), o('TransitiveProperty')), t(X, P, Y), t(Y, P, Z)], t(X, P, Z));
|
|
94
|
+
implies([t(P, r('type'), o('IrreflexiveProperty')), t(X, P, X)], ent_conflict('prp-irp', X, P, X, G));
|
|
95
|
+
implies([t(P, r('type'), o('AsymmetricProperty')), t(X, P, Y), t(Y, P, X)], ent_conflict('prp-asyp', X, P, Y, G));
|
|
96
|
+
implies([t(P, o('propertyDisjointWith'), Q), t(X, P, Y), t(X, Q, Y)], ent_conflict('prp-pdw', X, P, Q, G));
|
|
97
|
+
implies([t(A, r('type'), o('AllDisjointProperties')), t(A, o('members'), L), ent_pair(L, P, Q, G), t(X, P, Y), t(X, Q, Y)],
|
|
98
|
+
ent_conflict('prp-adp', A, P, Q, G));
|
|
99
|
+
implies([t(P, o('inverseOf'), Q), t(X, P, Y)], t(Y, Q, X));
|
|
100
|
+
implies([t(P, o('inverseOf'), Q), t(X, Q, Y)], t(Y, P, X));
|
|
101
|
+
implies([t(L, r('first'), P), t(L, r('rest'), r('nil')), t(X, P, Y)], ent_chain(L, X, Y, G));
|
|
102
|
+
implies([t(L, r('first'), P), t(L, r('rest'), R), t(X, P, Y), ent_chain(R, Y, Z, G)], ent_chain(L, X, Z, G));
|
|
103
|
+
implies([t(P, o('propertyChainAxiom'), L), ent_chain(L, X, Y, G)], t(X, P, Y));
|
|
104
|
+
implies([t(C, o('hasKey'), L), t(X, r('type'), C), t(Y, r('type'), C)], ent_key_candidate(L, X, Y, G));
|
|
105
|
+
implies([ent_key_candidate(L, X, Y, G), t(L, r('rest'), R)], ent_key_candidate(R, X, Y, G));
|
|
106
|
+
implies(ent_key_candidate(r('nil'), X, Y, G), ent_key(r('nil'), X, Y, G));
|
|
107
|
+
implies([ent_key_candidate(L, X, Y, G), t(L, r('first'), P), t(L, r('rest'), R), t(X, P, V), t(Y, P, V), ent_key(R, X, Y, G)],
|
|
108
|
+
ent_key(L, X, Y, G));
|
|
109
|
+
implies([t(C, o('hasKey'), L), t(X, r('type'), C), t(Y, r('type'), C), ent_key(L, X, Y, G)], t(X, o('sameAs'), Y));
|
|
110
|
+
for (const property of ['targetIndividual', 'targetValue']) {
|
|
111
|
+
implies([t(A, o('sourceIndividual'), X), t(A, o('assertionProperty'), P), t(A, o(property), Y), t(X, P, Y)],
|
|
112
|
+
ent_conflict(property === 'targetIndividual' ? 'prp-npa1' : 'prp-npa2', A, P, Y, G));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Class expressions and class axioms (tables 6–7).
|
|
116
|
+
implies(ent_graph(G), [t(o('Thing'), r('type'), o('Class')), t(o('Nothing'), r('type'), o('Class'))]);
|
|
117
|
+
implies(t(X, r('type'), o('Nothing')), ent_conflict('cls-nothing2', X, r('type'), o('Nothing'), G));
|
|
118
|
+
implies(ent_node(X, G), ent_all(r('nil'), X, G));
|
|
119
|
+
implies([t(L, r('first'), C), t(L, r('rest'), R), t(X, r('type'), C), ent_all(R, X, G)], ent_all(L, X, G));
|
|
120
|
+
implies([t(C, o('intersectionOf'), L), ent_list(L, G), ent_all(L, X, G)], t(X, r('type'), C));
|
|
121
|
+
implies([t(C, o('intersectionOf'), L), ent_member(L, D, G)], t(C, s('subClassOf'), D));
|
|
122
|
+
implies([t(C, o('unionOf'), L), ent_member(L, D, G)], t(D, s('subClassOf'), C));
|
|
123
|
+
implies([t(C, o('oneOf'), L), ent_member(L, X, G)], t(X, r('type'), C));
|
|
124
|
+
for (const property of ['complementOf', 'disjointWith']) {
|
|
125
|
+
implies([t(C, o(property), D), t(X, r('type'), C), t(X, r('type'), D)],
|
|
126
|
+
ent_conflict(property === 'complementOf' ? 'cls-com' : 'cax-dw', X, C, D, G));
|
|
127
|
+
}
|
|
128
|
+
implies([t(A, r('type'), o('AllDisjointClasses')), t(A, o('members'), L), ent_pair(L, C, D, G), t(X, r('type'), C), t(X, r('type'), D)],
|
|
129
|
+
ent_conflict('cax-adc', X, C, D, G));
|
|
130
|
+
implies([t(C, o('someValuesFrom'), D), t(C, o('onProperty'), P), t(X, P, Y), t(Y, r('type'), D)], t(X, r('type'), C));
|
|
131
|
+
implies([t(C, o('someValuesFrom'), o('Thing')), t(C, o('onProperty'), P), t(X, P, Y)], t(X, r('type'), C));
|
|
132
|
+
implies([t(C, o('allValuesFrom'), D), t(C, o('onProperty'), P), t(X, r('type'), C), t(X, P, Y)], t(Y, r('type'), D));
|
|
133
|
+
implies([t(C, o('hasValue'), Y), t(C, o('onProperty'), P), t(X, r('type'), C)], t(X, P, Y));
|
|
134
|
+
implies([t(C, o('hasValue'), Y), t(C, o('onProperty'), P), t(X, P, Y)], t(X, r('type'), C));
|
|
135
|
+
for (const n of [0, 1]) {
|
|
136
|
+
fact(ent_cardinality(n, n));
|
|
137
|
+
implied_by(ent_cardinality(literal(V, datatype('http://www.w3.org/2001/XMLSchema#nonNegativeInteger')), n),
|
|
138
|
+
regex_match('^[ \\t\\r\\n]*' + (n === 0 ? '[+-]?0+' : '[+]?0*1') + '[ \\t\\r\\n]*$', V));
|
|
139
|
+
}
|
|
140
|
+
implies([t(C, o('maxCardinality'), N), ent_cardinality(N, 0), t(C, o('onProperty'), P), t(X, r('type'), C), t(X, P, Y)],
|
|
141
|
+
ent_conflict('cls-maxc1', X, C, P, G));
|
|
142
|
+
implies([t(C, o('maxCardinality'), N), ent_cardinality(N, 1), t(C, o('onProperty'), P), t(X, r('type'), C), t(X, P, Y), t(X, P, Z)],
|
|
143
|
+
t(Y, o('sameAs'), Z));
|
|
144
|
+
implies([t(C, o('maxQualifiedCardinality'), N), ent_cardinality(N, K), t(C, o('onProperty'), P), t(C, o('onClass'), D),
|
|
145
|
+
t(X, r('type'), C), t(X, P, Y), t(Y, r('type'), D)], ent_qualified(C, K, X, P, Y, G));
|
|
146
|
+
implies([t(C, o('maxQualifiedCardinality'), N), ent_cardinality(N, K), t(C, o('onProperty'), P), t(C, o('onClass'), o('Thing')),
|
|
147
|
+
t(X, r('type'), C), t(X, P, Y)], ent_qualified(C, K, X, P, Y, G));
|
|
148
|
+
implies(ent_qualified(C, 0, X, P, Y, G), ent_conflict('cls-maxqc1', X, C, P, G));
|
|
149
|
+
implies([ent_qualified(C, 1, X, P, Y, G), ent_qualified(C, 1, X, P, Z, G)], t(Y, o('sameAs'), Z));
|
|
150
|
+
|
|
151
|
+
// Schema vocabulary (table 9).
|
|
152
|
+
implies(t(C, r('type'), o('Class')), [t(C, s('subClassOf'), C), t(C, o('equivalentClass'), C),
|
|
153
|
+
t(C, s('subClassOf'), o('Thing')), t(o('Nothing'), s('subClassOf'), C)]);
|
|
154
|
+
for (const [equivalent, sub] of [['equivalentClass', 'subClassOf'], ['equivalentProperty', 'subPropertyOf']]) {
|
|
155
|
+
implies(t(C, o(equivalent), D), [t(C, s(sub), D), t(D, s(sub), C)]);
|
|
156
|
+
implies([t(C, s(sub), D), t(D, s(sub), C)], t(C, o(equivalent), D));
|
|
157
|
+
}
|
|
158
|
+
for (const kind of ['ObjectProperty', 'DatatypeProperty']) {
|
|
159
|
+
implies(t(P, r('type'), o(kind)), [t(P, s('subPropertyOf'), P), t(P, o('equivalentProperty'), P)]);
|
|
160
|
+
}
|
|
161
|
+
for (const kind of ['hasValue', 'someValuesFrom', 'allValuesFrom']) {
|
|
162
|
+
if (kind !== 'hasValue') implies([t(C, o(kind), Y), t(C, o('onProperty'), P), t(D, o(kind), Z),
|
|
163
|
+
t(D, o('onProperty'), P), t(Y, s('subClassOf'), Z)], t(C, s('subClassOf'), D));
|
|
164
|
+
implies([t(C, o(kind), Y), t(C, o('onProperty'), P), t(D, o(kind), Y), t(D, o('onProperty'), Q), t(P, s('subPropertyOf'), Q)],
|
|
165
|
+
kind === 'allValuesFrom' ? t(D, s('subClassOf'), C) : t(C, s('subClassOf'), D));
|
|
166
|
+
}
|
|
167
|
+
`;
|
|
168
|
+
|
|
169
|
+
const OUTPUT = String.raw`
|
|
170
|
+
// Separate report triples from the ontology so a conflict report does not
|
|
171
|
+
// create more ontology consequences. All conflicts are retained, without
|
|
172
|
+
// stopping at the first contradiction or concluding arbitrary triples.
|
|
173
|
+
implies([ent_conflict(R, X, P, Y, G)], [
|
|
174
|
+
ent_report(B, r('type'), e('Conflict'), G), ent_report(B, e('rule'), literal(R, datatype('http://www.w3.org/2001/XMLSchema#string')), G),
|
|
175
|
+
ent_report(B, e('focus'), X, G), ent_report(B, e('left'), P, G), ent_report(B, e('right'), Y, G),
|
|
176
|
+
]);
|
|
177
|
+
implies([rdf(S, iri(P), O, G), ent_resource(S), not(ent_base(S, iri(P), O, G))], result_rdf(S, iri(P), O, G));
|
|
178
|
+
implies(ent_report(S, P, O, G), result_rdf(S, P, O, G));
|
|
179
|
+
query(result_rdf(S, P, O, G));
|
|
180
|
+
`;
|
package/src/formats.js
CHANGED
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
// .n3 Notation3, compiled to an LS program
|
|
12
12
|
// .srl a SPARQL 1.2 RL rule set, compiled to one
|
|
13
13
|
//
|
|
14
|
+
// The odrl option adds the snapshot profile's validation and evaluation LS
|
|
15
|
+
// to one Turtle input. Its vocabulary alone never enables the evaluator.
|
|
16
|
+
// rdfs and owlRl add the documented entailment rules to RDF inputs.
|
|
17
|
+
//
|
|
14
18
|
// The compiled program is ordinary LS: proofs, checking and --unused
|
|
15
19
|
// apply to it. SRL execution functions capture a context that a saved proof
|
|
16
20
|
// retains; compiling with that context reproduces the same program later.
|
|
@@ -20,6 +24,8 @@ import { readTerms } from './reader.js';
|
|
|
20
24
|
import { DEFAULT_GRAPH, parseRdf, rdfDocument, rdfFormat, writeRdf } from './rdf.js';
|
|
21
25
|
import { resultToN3, compileSources } from './n3.js';
|
|
22
26
|
import { compileSrl, srlAnswers, srlQuads } from './srl.js';
|
|
27
|
+
import { compileOdrl } from './odrl.js';
|
|
28
|
+
import { compileEntailment } from './entailment.js';
|
|
23
29
|
import { write } from './writer.js';
|
|
24
30
|
import { isRdfMessageLog, parseRdfMessages } from './messages.js';
|
|
25
31
|
|
|
@@ -41,7 +47,7 @@ export function rdfMessageFormat(name) {
|
|
|
41
47
|
// Load inputs, given as [text, name] pairs, as one program. io may supply
|
|
42
48
|
// readFile, for the documents N3 and IMPORTS name, and fileIri(name), the
|
|
43
49
|
// base IRI of a file. Returns { kind, program, text, prefixes, compiled }:
|
|
44
|
-
// kind is 'js', 'n3' or '
|
|
50
|
+
// kind is 'js', 'n3', 'srl', 'odrl', 'rdfs' or 'owl-rl', text the compiled program,
|
|
45
51
|
// and compiled what writing the conclusions needs.
|
|
46
52
|
export function loadInputs(inputs, io = null, options = {}) {
|
|
47
53
|
try {
|
|
@@ -53,7 +59,7 @@ export function loadInputs(inputs, io = null, options = {}) {
|
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
|
|
56
|
-
function load(inputs, io, { base = null, messageInputs = null, srlContext = null }) {
|
|
62
|
+
function load(inputs, io, { base = null, messageInputs = null, srlContext = null, odrl = false, rdfs = false, owlRl = false }) {
|
|
57
63
|
const kinds = inputs.map(([text, name]) => messageInputs?.has(name) ||
|
|
58
64
|
(inputKind(name) === 'n3' && isRdfMessageLog(text)) ? 'rdf' : inputKind(name));
|
|
59
65
|
const baseOf = (name) => base ?? io?.fileIri?.(name) ?? null;
|
|
@@ -61,6 +67,26 @@ function load(inputs, io, { base = null, messageInputs = null, srlContext = null
|
|
|
61
67
|
(isRdfMessageLog(text) ? parseRdfMessages : parseRdf)(text, {
|
|
62
68
|
format: rdfFormat(name) ?? 'trig', base: baseOf(name), scope: scopeOf(inputs, name, k),
|
|
63
69
|
});
|
|
70
|
+
// These rule sets are added only when requested, never from vocabulary.
|
|
71
|
+
if ((rdfs || owlRl) && odrl) throw new EyemindError('--odrl cannot be combined with --rdfs or --owl-rl');
|
|
72
|
+
if (rdfs || owlRl) {
|
|
73
|
+
if (inputs.some(([, name], k) => kinds[k] !== 'rdf' && name !== '<stdin>')) {
|
|
74
|
+
throw new EyemindError('--rdfs and --owl-rl take RDF inputs; standard input is Turtle');
|
|
75
|
+
}
|
|
76
|
+
const prefixes = {}, quads = [];
|
|
77
|
+
inputs.forEach(([text, name], k) => {
|
|
78
|
+
const parsed = name === '<stdin>' ? parseRdf(text, { format: 'turtle', base: baseOf(name), scope: scopeOf(inputs, name, k) }) : rdf(text, name, k);
|
|
79
|
+
if (parsed.triples) throw new EyemindError('--rdfs and --owl-rl take RDF graphs, not RDF Message Logs');
|
|
80
|
+
Object.assign(prefixes, parsed.prefixes);
|
|
81
|
+
quads.push(...parsed.quads);
|
|
82
|
+
});
|
|
83
|
+
return compileEntailment({ quads, prefixes }, { owl: owlRl, source: inputs.map(([, n]) => n).join(', ') });
|
|
84
|
+
}
|
|
85
|
+
if (odrl) {
|
|
86
|
+
if (inputs.length !== 1) throw new EyemindError('--odrl takes one Turtle snapshot containing policies, requests and SOTW');
|
|
87
|
+
const [text, name] = inputs[0];
|
|
88
|
+
return compileOdrl(parseRdf(text, { format: 'turtle', base: baseOf(name), scope: scopeOf(inputs, name, 0) }), { source: name });
|
|
89
|
+
}
|
|
64
90
|
if (kinds.includes('srl')) {
|
|
65
91
|
const others = kinds.filter((k) => k !== 'srl' && k !== 'rdf');
|
|
66
92
|
if (kinds.filter((k) => k === 'srl').length > 1 || others.length) {
|
|
@@ -118,9 +144,9 @@ function importResolver(io) {
|
|
|
118
144
|
};
|
|
119
145
|
}
|
|
120
146
|
|
|
121
|
-
// The default output format
|
|
122
|
-
// eyemind's own text for a program.
|
|
123
|
-
export const defaultFormat = (kind) => ({ n3: 'n3', srl: 'turtle' })[kind] ?? 'eyemind';
|
|
147
|
+
// The default output format: N3 for N3, Turtle for SRL and the RDF logic
|
|
148
|
+
// extensions, and eyemind's own text for a program.
|
|
149
|
+
export const defaultFormat = (kind) => ({ n3: 'n3', srl: 'turtle', odrl: 'turtle', rdfs: 'turtle', 'owl-rl': 'turtle' })[kind] ?? 'eyemind';
|
|
124
150
|
|
|
125
151
|
// The conclusions of a run in an output format; null for eyemind's own text.
|
|
126
152
|
// all also writes the given data. Throws when a conclusion is no triple.
|
package/src/odrl.js
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// A bounded ODRL snapshot profile: one Turtle document supplies the policies,
|
|
2
|
+
// candidate requests and their state of the world. Both validation and
|
|
3
|
+
// evaluation are ordinary LS, included in the standalone compiled program.
|
|
4
|
+
// ODRL semantics: https://www.w3.org/TR/odrl-model/
|
|
5
|
+
import { EyemindError, Struct } from './terms.js';
|
|
6
|
+
import { DEFAULT_GRAPH } from './rdf.js';
|
|
7
|
+
import { loadText } from './lang.js';
|
|
8
|
+
import { write } from './writer.js';
|
|
9
|
+
|
|
10
|
+
export const ODRL_EVAL = 'https://eyereasoner.github.io/eyemind/odrl#';
|
|
11
|
+
const RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
|
|
12
|
+
|
|
13
|
+
export function isOdrlEvaluation(quads) {
|
|
14
|
+
return quads.some(([, predicate, object]) => predicate instanceof Struct && predicate.name === 'iri' &&
|
|
15
|
+
predicate.args[0] === `${RDF}type` && object instanceof Struct && object.name === 'iri' &&
|
|
16
|
+
object.args[0] === `${ODRL_EVAL}Evaluation`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function compileOdrl({ quads, prefixes }, { source = '<input>' } = {}) {
|
|
20
|
+
if (!isOdrlEvaluation(quads)) throw new EyemindError('--odrl needs an eval:Evaluation resource selecting the policies and requests');
|
|
21
|
+
if (quads.some(([, , , graph]) => graph !== DEFAULT_GRAPH)) throw new EyemindError('an ODRL snapshot needs one default graph');
|
|
22
|
+
// RDF graphs are sets; repeated statements must not violate cardinalities.
|
|
23
|
+
const facts = [...new Set(quads.map(([s, p, o]) => write(new Struct('odrl_input', [s, p, o]))))].join('\n');
|
|
24
|
+
const text = `// Generated by eyemind from ${String(source).replace(/[\r\n\u2028\u2029]/g, ' ')}, an ODRL snapshot.\n` +
|
|
25
|
+
'// Input triples are odrl_input(S, P, O); report triples are rdf(S, P, O).\n' +
|
|
26
|
+
`facts_from({ text: ${JSON.stringify(facts)} })\n${RULES}`;
|
|
27
|
+
return { kind: 'odrl', text, program: loadText(text, source), prefixes: { ...prefixes, eval: ODRL_EVAL }, compiled: null };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const RULES = String.raw`
|
|
31
|
+
// Validation: the supported snapshot profile. Unknown policy features fail
|
|
32
|
+
// validation, so they cannot disappear while a permission is being decided.
|
|
33
|
+
const odrlNS = 'http://www.w3.org/ns/odrl/2/';
|
|
34
|
+
const evalNS = 'https://eyereasoner.github.io/eyemind/odrl#';
|
|
35
|
+
const xsdNS = 'http://www.w3.org/2001/XMLSchema#';
|
|
36
|
+
const o = (name) => iri(odrlNS + name);
|
|
37
|
+
const e = (name) => iri(evalNS + name);
|
|
38
|
+
const rdfType = iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#type');
|
|
39
|
+
|
|
40
|
+
implies(odrl_input(E, rdfType, e('Evaluation')), odrl_evaluation(E));
|
|
41
|
+
implies(odrl_evaluation(E), odrl_node(E, E, 'evaluation'));
|
|
42
|
+
implies([odrl_evaluation(E), odrl_input(E, e('policy'), P)], odrl_node(E, P, 'policy'));
|
|
43
|
+
implies([odrl_evaluation(E), odrl_input(E, e('request'), Q)], odrl_node(E, Q, 'request'));
|
|
44
|
+
implies([odrl_node(E, P, 'policy'), odrl_input(P, o('permission'), R)], odrl_rule(E, P, R, 'permission'));
|
|
45
|
+
implies([odrl_node(E, P, 'policy'), odrl_input(P, o('prohibition'), R)], odrl_rule(E, P, R, 'prohibition'));
|
|
46
|
+
implies(odrl_rule(E, P, R, K), odrl_node(E, R, K));
|
|
47
|
+
implies([odrl_rule(E, P, R, K), odrl_input(R, o('constraint'), C)], odrl_node(E, C, 'constraint'));
|
|
48
|
+
implies([odrl_node(E, Q, 'request'), odrl_input(Q, e('state'), S)], odrl_node(E, S, 'state'));
|
|
49
|
+
implies([odrl_rule(E, P, R, K), odrl_input(R, o('action'), A)], odrl_node(E, A, 'action'));
|
|
50
|
+
implies([odrl_node(E, Q, 'request'), odrl_input(Q, o('action'), A)], odrl_node(E, A, 'action'));
|
|
51
|
+
for (const name of ['assignee', 'target']) {
|
|
52
|
+
implies([odrl_rule(E, P, R, K), odrl_input(R, o(name), S)], odrl_entity(E, S));
|
|
53
|
+
implies([odrl_node(E, Q, 'request'), odrl_input(Q, o(name), S)], odrl_entity(E, S));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
for (const [kind, predicate, min, max, valueKind] of [
|
|
57
|
+
['evaluation', rdfType, 1, 1, 'type'],
|
|
58
|
+
['evaluation', e('policy'), 1, -1, 'resource'],
|
|
59
|
+
['evaluation', e('request'), 1, -1, 'resource'],
|
|
60
|
+
['evaluation', e('conflictStrategy'), 1, 1, 'strategy'],
|
|
61
|
+
['policy', rdfType, 1, 1, 'type'],
|
|
62
|
+
['policy', o('profile'), 1, 1, 'profile'],
|
|
63
|
+
['policy', o('permission'), 0, -1, 'resource'],
|
|
64
|
+
['policy', o('prohibition'), 0, -1, 'resource'],
|
|
65
|
+
['policy', o('assigner'), 0, 1, 'resource'],
|
|
66
|
+
['policy', o('conflict'), 0, 1, 'strategy'],
|
|
67
|
+
['request', rdfType, 1, 1, 'type'],
|
|
68
|
+
['request', o('assignee'), 1, 1, 'resource'],
|
|
69
|
+
['request', o('action'), 1, 1, 'iri'],
|
|
70
|
+
['request', o('target'), 1, 1, 'resource'],
|
|
71
|
+
['request', e('subject'), 1, 1, 'resource'],
|
|
72
|
+
['request', e('state'), 1, 1, 'resource'],
|
|
73
|
+
['state', rdfType, 1, 1, 'type'],
|
|
74
|
+
['state', e('subject'), 1, 1, 'resource'],
|
|
75
|
+
['constraint', rdfType, 0, 1, 'type'],
|
|
76
|
+
['constraint', o('leftOperand'), 1, 1, 'iri'],
|
|
77
|
+
['constraint', o('operator'), 1, 1, 'operator'],
|
|
78
|
+
['constraint', o('rightOperand'), 1, 1, 'scalar'],
|
|
79
|
+
['action', rdfType, 0, 1, 'type'],
|
|
80
|
+
]) fact(odrl_field(kind, predicate, min, max, valueKind));
|
|
81
|
+
for (const kind of ['permission', 'prohibition']) {
|
|
82
|
+
fact(odrl_field(kind, rdfType, 0, 1, 'type'));
|
|
83
|
+
for (const name of ['assignee', 'action', 'target']) fact(odrl_field(kind, o(name), 1, 1, name === 'action' ? 'iri' : 'resource'));
|
|
84
|
+
fact(odrl_field(kind, o('assigner'), 0, 1, 'resource'), odrl_field(kind, o('constraint'), 0, -1, 'resource'));
|
|
85
|
+
}
|
|
86
|
+
for (const [kind, type] of [
|
|
87
|
+
['evaluation', e('Evaluation')], ['request', e('Request')], ['state', e('State')],
|
|
88
|
+
['policy', o('Set')], ['policy', o('Agreement')],
|
|
89
|
+
['permission', o('Permission')], ['prohibition', o('Prohibition')], ['constraint', o('Constraint')],
|
|
90
|
+
['action', o('Action')],
|
|
91
|
+
]) fact(odrl_type(kind, type));
|
|
92
|
+
for (const predicate of [
|
|
93
|
+
'http://www.w3.org/2000/01/rdf-schema#label', 'http://www.w3.org/2000/01/rdf-schema#comment',
|
|
94
|
+
'http://purl.org/dc/terms/title', 'http://purl.org/dc/terms/description',
|
|
95
|
+
]) fact(odrl_metadata(iri(predicate)));
|
|
96
|
+
for (const name of ['perm', 'prohibit', 'invalid']) fact(odrl_strategy_value(o(name)));
|
|
97
|
+
for (const name of ['eq', 'neq', 'gt', 'gteq', 'lt', 'lteq']) fact(odrl_operator(o(name)));
|
|
98
|
+
|
|
99
|
+
fact(odrl_count([], 0));
|
|
100
|
+
implied_by(odrl_count([_, ...T], N), [odrl_count(T, M), is(N, add(M, 1))]);
|
|
101
|
+
implied_by(odrl_resource(iri(V)), is_atom(V));
|
|
102
|
+
implied_by(odrl_resource(bnode(S, V)), [is_atom(S), is_atom(V)]);
|
|
103
|
+
implied_by(odrl_scalar(V, 'integer', V), is_int(V));
|
|
104
|
+
implied_by(odrl_scalar(iri(V), 'iri', V), is_atom(V));
|
|
105
|
+
implied_by(odrl_scalar(literal(V, datatype(xsdNS + 'string')), 'string', V), is_atom(V));
|
|
106
|
+
for (const [lexical, value] of [['true', 'true'], ['1', 'true'], ['false', 'false'], ['0', 'false']]) {
|
|
107
|
+
fact(odrl_scalar(literal(lexical, datatype(xsdNS + 'boolean')), 'boolean', value));
|
|
108
|
+
}
|
|
109
|
+
implied_by(odrl_value('resource', V), odrl_resource(V));
|
|
110
|
+
implied_by(odrl_value('iri', iri(V)), is_atom(V));
|
|
111
|
+
implied_by(odrl_value('type', iri(V)), is_atom(V));
|
|
112
|
+
implied_by(odrl_value('scalar', V), odrl_scalar(V, _, _));
|
|
113
|
+
implied_by(odrl_value('strategy', V), odrl_strategy_value(V));
|
|
114
|
+
implied_by(odrl_value('operator', V), odrl_operator(V));
|
|
115
|
+
fact(odrl_value('profile', e('SnapshotProfile')));
|
|
116
|
+
implied_by(odrl_known_field(K, P), odrl_field(K, P, _, _, _));
|
|
117
|
+
implied_by(odrl_known_field(K, P), odrl_metadata(P));
|
|
118
|
+
fact(odrl_known_field('state', P));
|
|
119
|
+
implied_by(odrl_has_rule(P), odrl_input(P, o('permission'), _));
|
|
120
|
+
implied_by(odrl_has_rule(P), odrl_input(P, o('prohibition'), _));
|
|
121
|
+
|
|
122
|
+
implies([odrl_node(E, S, K), odrl_field(K, P, Min, Max, T),
|
|
123
|
+
findall_sorted(V, odrl_input(S, P, V), Values), odrl_count(Values, N), lt(N, Min)],
|
|
124
|
+
odrl_problem(E, S, P, e('MissingValue')));
|
|
125
|
+
implies([odrl_node(E, S, K), odrl_field(K, P, Min, Max, T), ge(Max, 0),
|
|
126
|
+
findall_sorted(V, odrl_input(S, P, V), Values), odrl_count(Values, N), gt(N, Max)],
|
|
127
|
+
odrl_problem(E, S, P, e('TooManyValues')));
|
|
128
|
+
implies([odrl_node(E, S, K), odrl_field(K, P, Min, Max, T), odrl_input(S, P, V), not(odrl_value(T, V))],
|
|
129
|
+
odrl_problem(E, S, P, e('UnsupportedValue')));
|
|
130
|
+
implies([odrl_node(E, S, K), odrl_input(S, P, V), not(odrl_known_field(K, P))],
|
|
131
|
+
odrl_problem(E, S, P, e('UnsupportedProperty')));
|
|
132
|
+
implies([odrl_node(E, S, K), odrl_input(S, rdfType, T), not(odrl_type(K, T))],
|
|
133
|
+
odrl_problem(E, S, rdfType, e('UnsupportedType')));
|
|
134
|
+
implies([odrl_node(E, P, 'policy'), not(odrl_has_rule(P))], odrl_problem(E, P, rdfType, e('MissingRule')));
|
|
135
|
+
implies([odrl_evaluation(E), findall_sorted(X, odrl_evaluation(X), Es), odrl_count(Es, N), ne(N, 1)],
|
|
136
|
+
odrl_problem(E, E, rdfType, e('MultipleEvaluations')));
|
|
137
|
+
implies([odrl_node(E, Q, 'request'), odrl_input(Q, e('state'), S),
|
|
138
|
+
odrl_input(Q, e('subject'), Person), odrl_input(S, e('subject'), Other), not_identical(Person, Other)],
|
|
139
|
+
odrl_problem(E, Q, e('state'), e('SubjectMismatch')));
|
|
140
|
+
implies([odrl_rule(E, P, R, 'permission'), odrl_rule(E, P2, R, 'prohibition')],
|
|
141
|
+
odrl_problem(E, R, rdfType, e('AmbiguousRule')));
|
|
142
|
+
implies([odrl_entity(E, S), odrl_input(S, iri(P), V), atom_concat(odrlNS, _, P)],
|
|
143
|
+
odrl_problem(E, S, iri(P), e('UnsupportedProperty')));
|
|
144
|
+
for (const name of ['AssetCollection', 'PartyCollection']) {
|
|
145
|
+
implies([odrl_entity(E, S), odrl_input(S, rdfType, o(name))], odrl_problem(E, S, rdfType, e('UnsupportedType')));
|
|
146
|
+
}
|
|
147
|
+
implied_by(odrl_syntax_error(E), odrl_problem(E, _, _, _));
|
|
148
|
+
|
|
149
|
+
// Constraints read exactly one observation from the request's state.
|
|
150
|
+
// Missing, ambiguous or unsupported observations stay unknown.
|
|
151
|
+
implied_by(odrl_order_kind(o('eq'), K), 'true');
|
|
152
|
+
implied_by(odrl_order_kind(o('neq'), K), 'true');
|
|
153
|
+
for (const name of ['gt', 'gteq', 'lt', 'lteq']) fact(odrl_order_kind(o(name), 'integer'));
|
|
154
|
+
implies([odrl_node(E, C, 'constraint'), odrl_input(C, o('operator'), Op),
|
|
155
|
+
odrl_input(C, o('rightOperand'), V), odrl_scalar(V, K, N), not(odrl_order_kind(Op, K))],
|
|
156
|
+
odrl_problem(E, C, o('rightOperand'), e('OperatorTypeMismatch')));
|
|
157
|
+
fact(odrl_compare(o('eq'), K, V, V));
|
|
158
|
+
implied_by(odrl_compare(o('neq'), K, V, W), not_identical(V, W));
|
|
159
|
+
implied_by(odrl_compare(o('gt'), 'integer', V, W), gt(V, W));
|
|
160
|
+
implied_by(odrl_compare(o('gteq'), 'integer', V, W), ge(V, W));
|
|
161
|
+
implied_by(odrl_compare(o('lt'), 'integer', V, W), lt(V, W));
|
|
162
|
+
implied_by(odrl_compare(o('lteq'), 'integer', V, W), le(V, W));
|
|
163
|
+
implies([odrl_rule(E, P, R, K), odrl_node(E, Q, 'request'), not(odrl_syntax_error(E)),
|
|
164
|
+
odrl_input(R, o('assignee'), Who), odrl_input(Q, o('assignee'), Who),
|
|
165
|
+
odrl_input(R, o('action'), Act), odrl_input(Q, o('action'), Act),
|
|
166
|
+
odrl_input(R, o('target'), Target), odrl_input(Q, o('target'), Target)], odrl_candidate(E, Q, P, R, K));
|
|
167
|
+
implies([odrl_candidate(E, Q, P, R, K), odrl_input(R, o('constraint'), C),
|
|
168
|
+
odrl_input(C, o('leftOperand'), Left), odrl_input(Q, e('state'), S),
|
|
169
|
+
findall_sorted(V, odrl_input(S, Left, V), Values)], odrl_observation(E, Q, R, C, Values));
|
|
170
|
+
implies(odrl_observation(E, Q, R, C, []), odrl_condition(E, Q, R, C, 'unknown', e('MissingObservation')));
|
|
171
|
+
implies(odrl_observation(E, Q, R, C, [A, B, ...Rest]), odrl_condition(E, Q, R, C, 'unknown', e('AmbiguousObservation')));
|
|
172
|
+
implies([odrl_observation(E, Q, R, C, [V]), not(odrl_scalar(V, _, _))],
|
|
173
|
+
odrl_condition(E, Q, R, C, 'unknown', e('UnsupportedObservation')));
|
|
174
|
+
implies([odrl_observation(E, Q, R, C, [V]), odrl_scalar(V, VK, VN),
|
|
175
|
+
odrl_input(C, o('rightOperand'), W), odrl_scalar(W, WK, WN), not_identical(VK, WK)],
|
|
176
|
+
odrl_condition(E, Q, R, C, 'unknown', e('ObservationTypeMismatch')));
|
|
177
|
+
implies([odrl_observation(E, Q, R, C, [V]), odrl_scalar(V, K, VN),
|
|
178
|
+
odrl_input(C, o('rightOperand'), W), odrl_scalar(W, K, WN), odrl_input(C, o('operator'), Op),
|
|
179
|
+
odrl_compare(Op, K, VN, WN)], odrl_condition(E, Q, R, C, 'met', e('Satisfied')));
|
|
180
|
+
implies([odrl_observation(E, Q, R, C, [V]), odrl_scalar(V, K, VN),
|
|
181
|
+
odrl_input(C, o('rightOperand'), W), odrl_scalar(W, K, WN), odrl_input(C, o('operator'), Op),
|
|
182
|
+
not(odrl_compare(Op, K, VN, WN))], odrl_condition(E, Q, R, C, 'unmet', e('Unsatisfied')));
|
|
183
|
+
implied_by(odrl_failed(E, Q, R), odrl_condition(E, Q, R, _, 'unmet', _));
|
|
184
|
+
implied_by(odrl_unknown(E, Q, R), odrl_condition(E, Q, R, _, 'unknown', _));
|
|
185
|
+
implies([odrl_candidate(E, Q, P, R, K), not(odrl_failed(E, Q, R)), not(odrl_unknown(E, Q, R))],
|
|
186
|
+
odrl_applies(E, Q, P, R, K));
|
|
187
|
+
implied_by(odrl_uncertain(E, Q), [odrl_candidate(E, Q, P, R, K), not(odrl_failed(E, Q, R)), odrl_unknown(E, Q, R)]);
|
|
188
|
+
|
|
189
|
+
// Keep every permission/prohibition overlap as evidence, even when a
|
|
190
|
+
// strategy resolves it. An invalid policy voids the whole evaluation.
|
|
191
|
+
implies([odrl_applies(E, Q, PP, PR, 'permission'), odrl_applies(E, Q, NP, NR, 'prohibition')],
|
|
192
|
+
odrl_conflict(E, Q, PP, PR, NP, NR));
|
|
193
|
+
implied_by(odrl_policy_strategy(P, Strategy), odrl_input(P, o('conflict'), Strategy));
|
|
194
|
+
implied_by(odrl_policy_strategy(P, o('invalid')), not(odrl_input(P, o('conflict'), _)));
|
|
195
|
+
implied_by(odrl_void_policy(E, P), [odrl_conflict(E, Q, P, PR, P, NR), odrl_policy_strategy(P, o('invalid'))]);
|
|
196
|
+
implied_by(odrl_has(E, Q, P, K), odrl_applies(E, Q, P, _, K));
|
|
197
|
+
implies([odrl_applies(E, Q, P, R, 'permission'), not(odrl_void_policy(E, P)),
|
|
198
|
+
or(odrl_policy_strategy(P, o('perm')), not(odrl_has(E, Q, P, 'prohibition')))], odrl_retained(E, Q, P, R, 'permission'));
|
|
199
|
+
implies([odrl_applies(E, Q, P, R, 'prohibition'), not(odrl_void_policy(E, P)),
|
|
200
|
+
or(odrl_policy_strategy(P, o('prohibit')), not(odrl_has(E, Q, P, 'permission')))], odrl_retained(E, Q, P, R, 'prohibition'));
|
|
201
|
+
implied_by(odrl_retained_kind(E, Q, K), odrl_retained(E, Q, _, _, K));
|
|
202
|
+
implied_by(odrl_cross_conflict(E), [odrl_retained_kind(E, Q, 'permission'), odrl_retained_kind(E, Q, 'prohibition')]);
|
|
203
|
+
implied_by(odrl_blocked(E), odrl_syntax_error(E));
|
|
204
|
+
implied_by(odrl_blocked(E), odrl_void_policy(E, _));
|
|
205
|
+
implied_by(odrl_blocked(E), [odrl_input(E, e('conflictStrategy'), o('invalid')), odrl_cross_conflict(E)]);
|
|
206
|
+
implies([odrl_node(E, Q, 'request'), odrl_blocked(E)], odrl_decision(E, Q, e('Undetermined')));
|
|
207
|
+
implies([odrl_node(E, Q, 'request'), not(odrl_blocked(E)), odrl_uncertain(E, Q)], odrl_decision(E, Q, e('Undetermined')));
|
|
208
|
+
implies([odrl_node(E, Q, 'request'), not(odrl_blocked(E)), not(odrl_uncertain(E, Q)),
|
|
209
|
+
odrl_retained_kind(E, Q, 'permission'),
|
|
210
|
+
or(odrl_input(E, e('conflictStrategy'), o('perm')), not(odrl_retained_kind(E, Q, 'prohibition')))],
|
|
211
|
+
odrl_decision(E, Q, e('Allowed')));
|
|
212
|
+
implies([odrl_node(E, Q, 'request'), not(odrl_blocked(E)), not(odrl_uncertain(E, Q)),
|
|
213
|
+
odrl_retained_kind(E, Q, 'prohibition'),
|
|
214
|
+
or(odrl_input(E, e('conflictStrategy'), o('prohibit')), not(odrl_retained_kind(E, Q, 'permission')))],
|
|
215
|
+
odrl_decision(E, Q, e('Prohibited')));
|
|
216
|
+
implies([odrl_node(E, Q, 'request'), not(odrl_blocked(E)), not(odrl_uncertain(E, Q)),
|
|
217
|
+
not(odrl_retained_kind(E, Q, 'permission')), not(odrl_retained_kind(E, Q, 'prohibition'))],
|
|
218
|
+
odrl_decision(E, Q, e('NotApplicable')));
|
|
219
|
+
|
|
220
|
+
// One RDF report, including an explicit conflict count and links back to
|
|
221
|
+
// the requests, policies, rules and constraints that explain each result.
|
|
222
|
+
implies(odrl_evaluation(E), rdf(E, rdfType, e('EvaluationReport')));
|
|
223
|
+
implies([odrl_evaluation(E), odrl_input(E, e('policy'), P)], rdf(E, e('policy'), P));
|
|
224
|
+
implies([odrl_evaluation(E), odrl_input(E, e('conflictStrategy'), S)], rdf(E, e('conflictStrategy'), S));
|
|
225
|
+
implies([odrl_evaluation(E), not(odrl_syntax_error(E))], rdf(E, e('validationStatus'), e('Valid')));
|
|
226
|
+
implies(odrl_syntax_error(E), rdf(E, e('validationStatus'), e('Invalid')));
|
|
227
|
+
implies([odrl_decision(E, Q, Status), odrl_resource(Q)], [rdf(E, e('request'), Q), rdf(Q, e('decision'), Status)]);
|
|
228
|
+
implies(odrl_decision(E, Q, e('Allowed')), rdf(E, e('canHappen'), Q));
|
|
229
|
+
implies([odrl_node(E, Q, 'request'), odrl_resource(Q), odrl_input(Q, P, V)], rdf(Q, P, V));
|
|
230
|
+
implies(odrl_applies(E, Q, P, R, 'permission'), rdf(Q, e('permission'), R));
|
|
231
|
+
implies(odrl_applies(E, Q, P, R, 'prohibition'), rdf(Q, e('prohibition'), R));
|
|
232
|
+
implies(odrl_void_policy(E, P), rdf(E, e('invalidPolicy'), P));
|
|
233
|
+
implies([odrl_input(E, e('conflictStrategy'), o('invalid')), odrl_cross_conflict(E)], rdf(E, e('reason'), e('ConflictingPolicies')));
|
|
234
|
+
implies(odrl_condition(E, Q, R, C, 'unmet', Why), rdf(Q, e('unmetConstraint'), C));
|
|
235
|
+
implies([odrl_condition(E, Q, R, C, 'unknown', Why), odrl_input(C, o('leftOperand'), Left)], [
|
|
236
|
+
rdf(Q, e('uncertainty'), Issue), rdf(Issue, rdfType, e('Uncertainty')),
|
|
237
|
+
rdf(Issue, e('constraint'), C), rdf(Issue, e('rule'), R),
|
|
238
|
+
rdf(Issue, e('property'), Left), rdf(Issue, e('reason'), Why),
|
|
239
|
+
]);
|
|
240
|
+
implies(odrl_problem(E, S, P, Code), [
|
|
241
|
+
rdf(E, e('validationError'), Issue), rdf(Issue, rdfType, e('ValidationError')),
|
|
242
|
+
rdf(Issue, e('focus'), S), rdf(Issue, e('property'), P), rdf(Issue, e('code'), Code),
|
|
243
|
+
]);
|
|
244
|
+
implies(odrl_conflict(E, Q, PP, PR, NP, NR), [
|
|
245
|
+
rdf(E, e('conflict'), Conflict), rdf(Conflict, rdfType, e('Conflict')),
|
|
246
|
+
rdf(Conflict, e('request'), Q), rdf(Conflict, e('permissionPolicy'), PP), rdf(Conflict, e('permissionRule'), PR),
|
|
247
|
+
rdf(Conflict, e('prohibitionPolicy'), NP), rdf(Conflict, e('prohibitionRule'), NR),
|
|
248
|
+
]);
|
|
249
|
+
implies([odrl_evaluation(E), findall_sorted(conflict(Q, PP, PR, NP, NR), odrl_conflict(E, Q, PP, PR, NP, NR), Cs),
|
|
250
|
+
odrl_count(Cs, N)], rdf(E, e('conflictCount'), N));
|
|
251
|
+
query(rdf(S, P, O));
|
|
252
|
+
`;
|
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// The release this checkout is; ./release keeps it in step with package.json.
|
|
2
|
-
export const VERSION = '0.6.
|
|
2
|
+
export const VERSION = '0.6.6';
|