eyemind 0.6.3 → 0.6.5

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 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 135 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).
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 136 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,7 @@ 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
+ - [ODRL snapshots](#odrl-snapshots)
25
26
  - [How eyemind reasons](#how-eyemind-reasons)
26
27
  - [Proofs, and what checking one means](#proofs-and-what-checking-one-means)
27
28
  - [JSON check reports](#json-check-reports)
@@ -349,7 +350,7 @@ eyemind --all rules.srl facts.ttl # the base graph too
349
350
  eyemind -c rules.srl facts.ttl # a proof of it, checked
350
351
  ```
351
352
 
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 241 tests pass.
353
+ 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
354
 
354
355
  SRL integers and decimals use exact integer arithmetic. Decimal addition,
355
356
  subtraction, multiplication, comparison, rounding and terminating division
@@ -385,6 +386,78 @@ SRL programs for deployment dependencies, route distances, ancestry, inventory,
385
386
  invoices, provenance and Unicode strings. Each has saved Turtle output, a
386
387
  proof, a check report and a deck, and runs in the playground.
387
388
 
389
+ ### ODRL snapshots
390
+
391
+ Use `--odrl` to add ODRL validation and evaluation to one Turtle file
392
+ containing policies, candidate requests and their state of the world (SOTW).
393
+ A resource of type `eval:Evaluation`, using
394
+ `eval: <https://eyereasoner.github.io/eyemind/odrl#>`, selects the policies
395
+ with `eval:policy`, the requests with `eval:request`, and a cross-policy
396
+ `eval:conflictStrategy`: `odrl:perm`, `odrl:prohibit` or `odrl:invalid`.
397
+ The switch enables the snapshot compiler; without it Turtle remains RDF
398
+ data, even when it contains an `eval:Evaluation` resource. The playground
399
+ has the same `--odrl` checkbox, enabled for the handicap-card example and
400
+ preserved in saved state and shared links.
401
+
402
+ ```sh
403
+ eyemind --odrl examples/handicap-card.ttl > /tmp/handicap-card-report.ttl
404
+ eyemind --odrl --program examples/handicap-card.ttl > /tmp/handicap-card.js
405
+ eyemind --to turtle /tmp/handicap-card.js > /tmp/handicap-card-report.ttl
406
+ eyemind --odrl --proof examples/handicap-card.ttl > /tmp/handicap-card-proof.js
407
+ eyemind --odrl --check-proof /tmp/handicap-card-proof.js examples/handicap-card.ttl
408
+ ```
409
+
410
+ The compiled `.js` includes the input facts and all validation and evaluation
411
+ LS; running it needs no policy file or external evaluator. The Turtle report
412
+ lists each request's `eval:decision` (`Allowed`, `Prohibited`,
413
+ `NotApplicable` or `Undetermined`), the `eval:canHappen` requests, validation
414
+ errors, uncertainties and conflicts. Each conflict identifies its request,
415
+ permission policy/rule and prohibition policy/rule. `eval:conflictCount`
416
+ explicitly records zero when none is detected. This evaluates the listed
417
+ requests at the supplied snapshot; it neither issues a card nor predicts
418
+ future changes to the world.
419
+ `eval:validationStatus` records whether the input fits the profile's shape
420
+ and vocabulary. Conflicts are reported and resolved separately.
421
+
422
+ The supported profile is declared on each policy with
423
+ `odrl:profile eval:SnapshotProfile`. Policies are `odrl:Set` or
424
+ `odrl:Agreement`; each rule states exactly one assignee, action and target.
425
+ A request is an `eval:Request` with those same three ODRL properties, an
426
+ `eval:subject` and an `eval:state`. Its `eval:State` names the same subject.
427
+ Assignees, actions and targets match by RDF term identity. Each constraint's
428
+ `odrl:leftOperand` is an IRI naming a property of that state, with exactly one
429
+ `odrl:operator` and `odrl:rightOperand`. All constraints of a rule must hold.
430
+ Equality and inequality (`eq`, `neq`) support IRIs, strings, booleans and
431
+ exact integers; ordering (`gt`, `gteq`, `lt`, `lteq`) supports exact integers.
432
+ Boolean lexical forms `true`/`1` and `false`/`0` denote the same values.
433
+
434
+ An absent, multiply valued, unsupported or differently typed observation
435
+ leaves a constraint unknown. A definitely false constraint makes its rule
436
+ inapplicable; otherwise an unknown constraint makes the request
437
+ `Undetermined`. Missing facts never establish a negative observation.
438
+ The caller supplies the applicable policy set, trusted state and candidate
439
+ actions. The compiler does not establish agreement acceptance or evidence
440
+ authenticity. Unsupported policy properties, profiles, duties, inheritance,
441
+ action hierarchies, collections and refinements are validation errors and
442
+ block authorization for the evaluation. This is a bounded profile, not a
443
+ general ODRL evaluator.
444
+
445
+ ODRL's per-policy `odrl:conflict` strategies are applied first; an omitted
446
+ strategy defaults to `odrl:invalid`. A detected internal conflict then voids
447
+ that policy and leaves the evaluation undetermined. The explicit
448
+ `eval:conflictStrategy` combines the remaining policy decisions; `invalid`
449
+ voids the evaluation if both a permission and a prohibition remain for any
450
+ request. Conflicts stay in the report after resolution. These are
451
+ permission/prohibition overlaps for the listed requests, not an exhaustive
452
+ search for conflicts in every possible state. The rules follow the
453
+ [ODRL Information Model](https://www.w3.org/TR/odrl-model/) for the supported
454
+ features; the snapshot vocabulary and cross-policy composition are this
455
+ profile's conventions.
456
+
457
+ The [handicap-card example](https://eyereasoner.github.io/eyemind/examples/deck/handicap-card)
458
+ allows Alice's request and reports the conflict that blocks Bob's, under
459
+ explicitly fictional criteria.
460
+
388
461
  ## How eyemind reasons
389
462
 
390
463
  The statement chooses the direction:
@@ -474,7 +547,7 @@ type('socrates', 'human')
474
547
  verdict('checked')
475
548
  ```
476
549
 
477
- A `checked` verdict thus establishes two things: every claim follows from the program, and the claims are every answer of the original questions. A question with no claims is shown to have no answers by its table. A failed check lists `failure(Detail)` facts, ends with `verdict(failed(N))` and exits with code 2. A halted run's proof establishes that its claims follow, not that they are every answer. To check answers to `--goal` questions, pass the same goals when checking. [SPEC §11](https://eyereasoner.github.io/eyemind/SPEC#11-proof-checking) defines the check.
550
+ A `checked` verdict establishes that every claim follows from the program and every required answer of the original questions is claimed. When the run reports only derived facts, source facts and backward-only answers are not required conclusions. A failed check lists `failure(Detail)` facts, ends with `verdict(failed(N))` and exits with code 2. A halted run's proof establishes that its claims follow, without establishing answer completeness. To check answers to `--goal` questions, pass the same goals when checking. [SPEC §11](https://eyereasoner.github.io/eyemind/SPEC#11-proof-checking) defines the check.
478
551
 
479
552
  The report's comments explain which checks succeeded, with references to
480
553
  SPEC Sections 11.2–11.6. They distinguish complete answers from a halted
@@ -551,10 +624,11 @@ eyemind [OPTION ...] [FILE ...]
551
624
  | `--unused` | List the clauses that make no difference to the conclusions. |
552
625
  | `--stream-messages` | Read an RDF Message Log and run the rules independently per message; Node reads files, stdin and HTTP(S) incrementally. |
553
626
  | `--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 SRL program has 1000000, 100000 and 1000000000. |
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. |
627
+ | `--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 or ODRL program has 1000000, 100000 and 1000000000. |
628
+ | `--to FORMAT` | Write the conclusions as `turtle`, `trig`, `n-triples`, `n-quads`, `n3` or `eyemind`; by default N3 for N3, Turtle for SRL and ODRL, eyemind otherwise. |
556
629
  | `--all` | With RDF or N3 output, write the given data too. |
557
630
  | `--program` | Print the program the inputs compile to. |
631
+ | `--odrl` | Add the ODRL snapshot profile's validation and evaluation LS to one Turtle input. |
558
632
  | `--base IRI` | Resolve relative IRIs of the inputs against `IRI` instead of each file's location. |
559
633
  | `-v`, `--version`, `-h`, `--help` | Print the version or the usage. |
560
634
 
@@ -564,7 +638,7 @@ each goal as a data document, with an array denoting conjunction. With
564
638
  `--check-proof`, supply the original goals the proof answers.
565
639
  An option that takes a value requires it immediately afterward; another
566
640
  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 SRL inputs;
641
+ With `--goal`, answers default to eyemind terms even for N3, SRL and ODRL inputs;
568
642
  use `--to` to request another output format.
569
643
 
570
644
  With `--prove-and-check`, reasoning bounds and `--stats` apply to proof
@@ -593,7 +667,7 @@ They are outside the language and proof specification.
593
667
 
594
668
  The JavaScript implementation defaults to a depth limit of 1000000, an
595
669
  inference limit of 1000000 and a limit of 1000 forward rounds per stratum.
596
- Compiled N3 and SRL programs use 1000000, 1000000000 and 100000 respectively.
670
+ Compiled N3, SRL and ODRL programs use 1000000, 1000000000 and 100000 respectively.
597
671
  Each supplied bound must be a positive integer no greater than
598
672
  9007199254740991.
599
673
 
package/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.6.3
5
+ Version: eyemind 0.6.5
6
6
  ```
7
7
 
8
8
  This document specifies Logic Script (LS): the syntax and meaning of its
@@ -202,9 +202,8 @@ Proofs:
202
202
  ([Section 11.2](#112-original-questions)).
203
203
  - **Replay**: re-executing the firing a step records, from its source rule,
204
204
  with the bindings of each point of the search ([Section 11.4](#114-replaying-derived-facts)).
205
- - **Checks**: of a proof, that the checker finds no failure; its claims are
206
- then exactly the answers of the original questions, or for a halted run
207
- follow from the program ([Section 11.1](#111-what-a-checked-proof-establishes)).
205
+ - **Checks**: of a proof, that the checker finds no failure
206
+ ([Section 11.1](#111-what-a-checked-proof-establishes)).
208
207
  - **Check report**: what a checker writes: the claims, any failures and a
209
208
  verdict ([Section 12](#12-check-reports)).
210
209
 
@@ -227,6 +226,7 @@ An atom used as a predicate has arity 0. A compound's name and arity identify
227
226
  its constructor. Integers and floats are distinct: `1` and `1.0` MUST NOT
228
227
  unify. Booleans, `null`, `undefined`, infinities and NaN are not terms.
229
228
  Nonfinite numeric values MUST be rejected.
229
+ Atoms and numbers are **atomic** terms.
230
230
 
231
231
  ### 2.2 Lists
232
232
 
@@ -295,7 +295,7 @@ another script, resolved as [Section 3.2](#32-names) specifies, so scripts share
295
295
  declarations.
296
296
 
297
297
  The supplied names are the statements of [Section 3.4](#34-statements), `forward`, `backward`,
298
- `preds`, `vars`, `struct`, the controls and primitives of [Section 4](#4-goals-and-primitives), the
298
+ `preds`, `vars`, `struct`, `float`, the controls and primitives of [Section 4](#4-goals-and-primitives), the
299
299
  atom `fail`. Other names are resolved as [Section 3.2](#32-names) specifies.
300
300
 
301
301
  An embedding MAY supply additional library names. Their operations and
@@ -696,9 +696,10 @@ an incorrect or partial value. The bounds are implementation-defined.
696
696
  A body goal depends on a clause when the goal, renamed apart, unifies with
697
697
  one of the clause's heads. The dependency is **closed** when the goal occurs
698
698
  inside a negation or as the goal of a collection ([Section 4.2](#42-controls)), and **open**
699
- otherwise. Each clause has a rank: the least assignment such that a clause's
700
- rank is at least the rank of every clause it depends on, plus one for a closed
701
- dependency. Forward rules run in order of rank ([Section 8.2](#82-forward-evaluation-and-witnesses)).
699
+ otherwise. Each clause has a nonnegative integer rank: the least assignment
700
+ such that its rank is at least the rank of every clause it depends on, plus
701
+ one for a closed dependency. Forward rules run in order of rank
702
+ ([Section 8.2](#82-forward-evaluation-and-witnesses)).
702
703
 
703
704
  A program MUST be rejected when:
704
705
 
@@ -1073,9 +1074,8 @@ infinite closure. A finite model does not ensure search termination:
1073
1074
  `implied_by(p(X), p(X))` has an empty least model, but searching `p('a')`
1074
1075
  recurs indefinitely. Exceeding a resource bound raises an error ([Section
1075
1076
  8.3](#83-resource-bounds)). Contradictions halt without completing the closure ([Section 8.5](#85-contradictions)).
1076
- A proof that checks establishes that its claims are every answer of the
1077
- original questions ([Section 11.1](#111-what-a-checked-proof-establishes)); it does not establish termination of the
1078
- whole program.
1077
+ The guarantees and limits of a checked proof are defined in
1078
+ [Section 11.1](#111-what-a-checked-proof-establishes).
1079
1079
 
1080
1080
  ## 8. Evaluation and Conclusions
1081
1081
 
@@ -1115,15 +1115,12 @@ and `p(2)` publishes `a(1)`, `b(1)`, `a(2)`, `b(2)`. For each head:
1115
1115
  program writes it (an anonymous one as `_0`, `_1`, ..., [Section 3.3](#33-term-construction)), and
1116
1116
  `Arguments` the list of
1117
1117
  the ground values the solution gives the heads' other variables, in order
1118
- of their first occurrence in the heads. A Skolem term is thus a function of
1119
- the firing: the rule and the instance of its heads. The same firing
1120
- gives the same terms, in any round and in any run, and different
1121
- firings give different terms; variables shared between heads stay
1122
- shared. When several head variables stand for one term, the first of them
1123
- in the heads names it, whichever way unification bound them. A variable
1124
- that a value of the solution brought in, which no head variable stands
1125
- for, keeps its own name when no other term of the firing has it; the
1126
- others take that name followed by the first of `1`, `2`, ... that is
1118
+ of their first occurrence in the heads. When several head variables stand
1119
+ for one term, the first of them in the heads names it, whichever way
1120
+ unification bound them. A variable that a value of the solution brought
1121
+ in, which no head variable stands for, keeps its own name when no other
1122
+ term of the firing has it; the others take that name followed by the first
1123
+ of `1`, `2`, ... that is
1127
1124
  free, in order of first occurrence in the heads. A rule that keeps meeting new firings does
1128
1125
  not terminate ([Section 8.3](#83-resource-bounds)). Derived facts other than scoped inspection
1129
1126
  patterns ([Section 6.3](#63-source-rule-inspection)) are therefore ground. A
@@ -1212,9 +1209,6 @@ depth, goals started or forward rounds are provided, they count as follows:
1212
1209
  including the final round that adds nothing; a stratum without forward
1213
1210
  rules has no rounds.
1214
1211
 
1215
- A run that exceeds a bound MUST report resource exhaustion. Answers found
1216
- before exhaustion MUST NOT be presented as the complete result of that run.
1217
-
1218
1212
  ### 8.4 External goals
1219
1213
 
1220
1214
  A run MAY be given goals. Each goal is read on its own, so goals share no
@@ -1265,8 +1259,8 @@ rather than return a proof that does not check, as for results the format
1265
1259
  cannot establish ([Section 11.1](#111-what-a-checked-proof-establishes)) or a table that would meet an error. It
1266
1260
  MAY bound the work of making tables; exceeding the bound is such an error
1267
1261
  and MUST NOT change the run's answers. A run without conclusions has a proof
1268
- without claims, whose call tables show that the original questions have no
1269
- answers.
1262
+ without claims, whose certificate establishes that there are no required
1263
+ answers ([Section 11.5](#115-deciding-the-claims)).
1270
1264
 
1271
1265
  ## 9. Document Syntax and Canonical Text
1272
1266
 
@@ -1326,8 +1320,8 @@ conjunction rules of [Section 4.1](#41-goal-syntax).
1326
1320
  String escapes are `\\`, `\'`, `\"`, `\n`, `\r`, `\t`, `\b`, `\f`,
1327
1321
  `\v`, `\0` (not followed by a decimal digit), `\xHH`, `\uHHHH` and
1328
1322
  `\u{H...}` with one to six hexadecimal digits denoting a Unicode code point.
1329
- Other escapes and raw line breaks in strings MUST be rejected; a raw line
1330
- break is a line feed or a carriage return, while the characters U+2028 and
1323
+ Other escapes and unescaped characters U+0000–U+001F except tab MUST be
1324
+ rejected. This includes raw line feeds and carriage returns; U+2028 and
1331
1325
  U+2029 are allowed in a string as themselves. Outside
1332
1326
  strings, layout consists of spaces, tabs, carriage returns, line feeds and
1333
1327
  the byte-order-mark character, plus comments. A line feed outside brackets
@@ -1368,7 +1362,7 @@ Object keys may also use these reserved names, since keys denote atom text.
1368
1362
  `hex` is the lowercase hexadecimal code point of `c`. The variable name `A-B`
1369
1363
  is thus written `VAR_A_2d_B`. A reader decodes such a name back
1370
1364
  ([Section 9.1](#91-accepted-document-syntax)).
1371
- - A list is written `[I1, I2, ...]`; an open list ends with `, ...Tail`.
1365
+ - A list is written `[I1, I2, ...]`; an open or improper list ends with `, ...Tail`.
1372
1366
 
1373
1367
  ### 9.3 Canonical compounds
1374
1368
 
@@ -1484,10 +1478,9 @@ called(p(A), [p(_1)])
1484
1478
 
1485
1479
  ## 11. Proof Checking
1486
1480
 
1487
- A checker establishes whether the claims of a proof are exactly the answers
1488
- of the original questions of the source program. Its inputs are the program,
1489
- the proof document and, when the proof answers goals asked from outside the
1490
- program, those goals. The source program is the authority for clauses and
1481
+ A checker verifies a proof's claims against its source program. Its inputs
1482
+ are the program, the proof document and, when the proof answers external
1483
+ goals, those goals. The source program is the authority for clauses and
1491
1484
  questions; the proof supplies evidence to check. The outcome is `checked`
1492
1485
  or a list of failures.
1493
1486
 
@@ -1524,11 +1517,12 @@ two listings coincide ([Section 10.3](#103-certificate)), and when a variable's
1524
1517
 
1525
1518
  ### 11.1 What a checked proof establishes
1526
1519
 
1527
- A proof **checks** when the checker finds no failure. Then its claims follow
1528
- from the source program, and, unless the run halted, they are exactly the
1529
- answers of its original questions, up to the renaming of their variables:
1530
- every claim is an answer and every answer is claimed. A proof without claims
1531
- then establishes that the original questions have none.
1520
+ A proof **checks** when the checker finds no failure. Its claims then follow
1521
+ from the source program. Unless the proof is halted, every claim is an
1522
+ answer of an original question, and every required answer
1523
+ ([Section 11.5](#115-deciding-the-claims)) is claimed, up to variable
1524
+ renaming. A checked proof without claims establishes that there are no
1525
+ required answers.
1532
1526
 
1533
1527
  For a program with negation, "follows" is relative to the facts the
1534
1528
  listings hold: the check establishes that they are supported by replayed
@@ -1546,12 +1540,11 @@ A checked proof does not establish:
1546
1540
  - that the supplied program expresses the author's intended model.
1547
1541
 
1548
1542
  Some results cannot be established by this proof format, and their proofs
1549
- do not check: a first answer or a collection whose order rests on several
1550
- derived facts, whose publication order the format does not show; a firing of a
1551
- restricted rule, whose guard held before the firing but not in the final
1552
- facts ([Section 7.2](#72-variables-and-witnesses)); a comparison `compare/3` of terms that are not ground,
1553
- since renaming a table need not preserve the order of variable names; and a
1554
- search whose table would not close.
1543
+ do not check: a first answer or collection requiring uncertified answer
1544
+ order ([Section 11.3](#113-answering-calls)); a firing of a restricted rule
1545
+ with a guard ([Section 7.2](#72-variables-and-witnesses)); a comparison
1546
+ `compare/3` of terms that are not ground, since renaming a table need not
1547
+ preserve the order of variable names; and a search whose table would not close.
1555
1548
 
1556
1549
  ### 11.2 Original questions
1557
1550
 
@@ -1655,12 +1648,11 @@ starting with no bindings, against the step's corresponding use:
1655
1648
  - A primitive runs on the bindings of that point. Its first solution under
1656
1649
  which the goal can still unify with the use is taken. `compare/3` with a
1657
1650
  compared term that is not ground does not replay.
1658
- - `once/1`, `not/1`, `findall/3` and `findall_sorted/3` take the answers of
1659
- the goal, as it stands at that point, from the certificate, as in
1660
- [Section 11.3](#113-answering-calls). A negation with an unbound named variable does not replay,
1661
- and neither does a first answer or a collection whose order rests on a
1662
- listing. The first answer is taken, and the goal MUST still unify with the
1663
- use.
1651
+ - `once/1`, `not/1`, `findall/3` and `findall_sorted/3` are evaluated from
1652
+ the certificate on the bindings of that point, with the binding and
1653
+ certified-order requirements of [Section 11.3](#113-answering-calls).
1654
+ The control MUST succeed and its resulting goal MUST still unify with
1655
+ the use.
1664
1656
  - Any other goal, as it stands at that point, is answered from the
1665
1657
  certificate as in [Section 11.3](#113-answering-calls), when that search consults no listing:
1666
1658
  the answer identical to the use up to renaming is taken, or else the first
@@ -1689,10 +1681,6 @@ derived pattern's variables are all supplied by an inspection or a listed
1689
1681
  pattern. Each step's bindings MUST name distinct variables of its rule,
1690
1682
  whose values unify with what the replay gave them.
1691
1683
 
1692
- Replay re-executes each recorded firing, so a test of whether a variable is
1693
- bound sees what a search sees, a first answer is the search's first answer,
1694
- and arithmetic is computed rather than accepted.
1695
-
1696
1684
  ### 11.5 Deciding the claims
1697
1685
 
1698
1686
  For a proof that is not halted:
@@ -1748,19 +1736,15 @@ A check report is a document ([Section 9.1](#91-accepted-document-syntax)) holdi
1748
1736
  The comment MUST identify the claims as checked answers only when the proof
1749
1737
  checks, as following from a halted program when it checks and is halted, and
1750
1738
  as unverified claims when it fails; a proof without claims that checks MUST
1751
- be said to establish that the original questions have no answers. Comments
1752
- are informative and MAY be worded differently. The wording of `Detail`, and
1739
+ be said to establish that there are no required answers
1740
+ ([Section 11.1](#111-what-a-checked-proof-establishes)). Comments MAY explain
1741
+ the checks of Sections [11.2](#112-original-questions)–[11.6](#116-nothing-unused),
1742
+ but MUST NOT assert guarantees beyond those of the verdict. Their wording
1743
+ is informative and MAY differ. The wording of `Detail`, and
1753
1744
  the number and order of failures, are informative: a conforming checker
1754
1745
  agrees on the verdict `checked` or failed. A report is ordinary data:
1755
1746
  `facts_from` ([Section 3.4](#34-statements)) states it as facts.
1756
1747
 
1757
- Explanatory comments can describe the checks of Sections
1758
- [11.2](#112-original-questions)–[11.6](#116-nothing-unused). They do not add
1759
- evidence or change the verdict. A failed report must not describe those
1760
- checks as having succeeded; a checked halted proof establishes the replay
1761
- of its claims, without establishing answer completeness
1762
- ([Section 11.1](#111-what-a-checked-proof-establishes)).
1763
-
1764
1748
  ## 13. Conformance
1765
1749
 
1766
1750
  A conforming reasoner MUST implement the program syntax, semantics and
@@ -1817,8 +1801,8 @@ object = "{", [ pair, { ",", pair }, [ "," ] ], "}" ;
1817
1801
  pair = ( identifier | string ), ":", expression ;
1818
1802
  number = integer, [ "n" ] | float ;
1819
1803
  integer = "0" | nonzero, { digit } ;
1820
- float = ( digits, ".", { digit } | ".", digits ), [ exponent ]
1821
- | digits, exponent ;
1804
+ float = ( integer, ".", { digit } | ".", digits ), [ exponent ]
1805
+ | integer, exponent ;
1822
1806
  exponent = ( "e" | "E" ), [ "+" | "-" ], digits ;
1823
1807
  digits = digit, { digit } ;
1824
1808
  digit = "0" | nonzero ;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyemind",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
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,10 @@ 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 a rule set, eyemind otherwise or with --goal)
27
+ for SRL or ODRL, 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
30
31
  --base IRI Resolve relative IRIs of the inputs against IRI
31
32
  --stream-messages Run the rules independently for each RDF Message
32
33
  -v, --version Print the version
@@ -65,6 +66,7 @@ export function main(argv, io) {
65
66
  let printProgram = false;
66
67
  let base = null;
67
68
  let streamMessages = false;
69
+ let odrl = false;
68
70
  const filePositions = new Set();
69
71
  for (let i = 0; i < argv.length; i++) {
70
72
  const arg = ALIASES.get(argv[i]) ?? argv[i];
@@ -90,6 +92,8 @@ export function main(argv, io) {
90
92
  all = true;
91
93
  } else if (arg === '--program') {
92
94
  printProgram = true;
95
+ } else if (arg === '--odrl') {
96
+ odrl = true;
93
97
  } else if (arg === '--stream-messages') {
94
98
  streamMessages = true;
95
99
  } else if (arg === '--check-proof' || arg === '--goal' || arg === '--to' || arg === '--base' || Object.hasOwn(LIMITS, arg)) {
@@ -137,6 +141,7 @@ export function main(argv, io) {
137
141
  if (!files.length) files.push('-');
138
142
  if (files.filter((file) => file === '-').length > 1) throw new UsageError('stdin can only be read once');
139
143
  if (streamMessages) {
144
+ if (odrl) throw new UsageError('--odrl cannot be combined with --stream-messages');
140
145
  if (proofFile !== null || options.proof || proveAndCheck || printProgram || unused) {
141
146
  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
147
  }
@@ -177,7 +182,7 @@ export function main(argv, io) {
177
182
  }
178
183
  const document = proofFile === null ? null : readSource(proofFile, io);
179
184
  const loaded = loadInputs(files.map((file) => [readSource(file, io), file === '-' ? '<stdin>' : file]), io,
180
- { base, messageInputs: io.messageInputs,
185
+ { base, messageInputs: io.messageInputs, odrl,
181
186
  srlContext: document !== null && files.some((file) => inputKind(file) === 'srl') ? srlContextFromProof(document) : null });
182
187
  const program = loaded.program;
183
188
  if (printProgram) {
package/src/formats.js CHANGED
@@ -11,6 +11,9 @@
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
+ //
14
17
  // The compiled program is ordinary LS: proofs, checking and --unused
15
18
  // apply to it. SRL execution functions capture a context that a saved proof
16
19
  // retains; compiling with that context reproduces the same program later.
@@ -20,6 +23,7 @@ import { readTerms } from './reader.js';
20
23
  import { DEFAULT_GRAPH, parseRdf, rdfDocument, rdfFormat, writeRdf } from './rdf.js';
21
24
  import { resultToN3, compileSources } from './n3.js';
22
25
  import { compileSrl, srlAnswers, srlQuads } from './srl.js';
26
+ import { compileOdrl } from './odrl.js';
23
27
  import { write } from './writer.js';
24
28
  import { isRdfMessageLog, parseRdfMessages } from './messages.js';
25
29
 
@@ -41,7 +45,7 @@ export function rdfMessageFormat(name) {
41
45
  // Load inputs, given as [text, name] pairs, as one program. io may supply
42
46
  // readFile, for the documents N3 and IMPORTS name, and fileIri(name), the
43
47
  // base IRI of a file. Returns { kind, program, text, prefixes, compiled }:
44
- // kind is 'js', 'n3' or 'srl', text the compiled program for N3 and SRL,
48
+ // kind is 'js', 'n3', 'srl' or 'odrl', text the compiled program,
45
49
  // and compiled what writing the conclusions needs.
46
50
  export function loadInputs(inputs, io = null, options = {}) {
47
51
  try {
@@ -53,7 +57,7 @@ export function loadInputs(inputs, io = null, options = {}) {
53
57
  }
54
58
  }
55
59
 
56
- function load(inputs, io, { base = null, messageInputs = null, srlContext = null }) {
60
+ function load(inputs, io, { base = null, messageInputs = null, srlContext = null, odrl = false }) {
57
61
  const kinds = inputs.map(([text, name]) => messageInputs?.has(name) ||
58
62
  (inputKind(name) === 'n3' && isRdfMessageLog(text)) ? 'rdf' : inputKind(name));
59
63
  const baseOf = (name) => base ?? io?.fileIri?.(name) ?? null;
@@ -61,6 +65,12 @@ function load(inputs, io, { base = null, messageInputs = null, srlContext = null
61
65
  (isRdfMessageLog(text) ? parseRdfMessages : parseRdf)(text, {
62
66
  format: rdfFormat(name) ?? 'trig', base: baseOf(name), scope: scopeOf(inputs, name, k),
63
67
  });
68
+ // ODRL logic is added only when requested, never from a document's terms.
69
+ if (odrl) {
70
+ if (inputs.length !== 1) throw new EyemindError('--odrl takes one Turtle snapshot containing policies, requests and SOTW');
71
+ const [text, name] = inputs[0];
72
+ return compileOdrl(parseRdf(text, { format: 'turtle', base: baseOf(name), scope: scopeOf(inputs, name, 0) }), { source: name });
73
+ }
64
74
  if (kinds.includes('srl')) {
65
75
  const others = kinds.filter((k) => k !== 'srl' && k !== 'rdf');
66
76
  if (kinds.filter((k) => k === 'srl').length > 1 || others.length) {
@@ -118,9 +128,9 @@ function importResolver(io) {
118
128
  };
119
129
  }
120
130
 
121
- // The default output format of a run: N3 for N3, Turtle for SRL, and
131
+ // The default output format of a run: N3 for N3, Turtle for SRL and ODRL, and
122
132
  // eyemind's own text for a program.
123
- export const defaultFormat = (kind) => ({ n3: 'n3', srl: 'turtle' })[kind] ?? 'eyemind';
133
+ export const defaultFormat = (kind) => ({ n3: 'n3', srl: 'turtle', odrl: 'turtle' })[kind] ?? 'eyemind';
124
134
 
125
135
  // The conclusions of a run in an output format; null for eyemind's own text.
126
136
  // 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.3';
2
+ export const VERSION = '0.6.5';