eyemind 0.8.45 → 0.8.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LE-SPEC.md +17 -5
- package/LS-SPEC.md +1 -1
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/le-odrl.js +5 -1
- package/src/le.js +15 -6
- package/src/odrl.js +1 -1
- package/src/version.js +1 -1
package/LE-SPEC.md
CHANGED
|
@@ -317,6 +317,8 @@ These programs use the grammar above without additional syntax:
|
|
|
317
317
|
| [British citizenship](https://eyereasoner.github.io/eyemind/examples/deck/british-citizenship-le) | Section 1 of the British Nationality Act 1981: alternative premises, a presumption that holds unless the contrary is shown, date comparisons and citizenship through a derived parent. |
|
|
318
318
|
| [Library fines](https://eyereasoner.github.io/eyemind/examples/deck/library-fines-le) | Charges from alternative rules, then the sum, number and maximum per member over distinct combinations. |
|
|
319
319
|
| [Election tally](https://eyereasoner.github.io/eyemind/examples/deck/election-tally-le) | Eligibility by alternatives, distinct choices, an absence test inside a count, winners by maximum with ties, and a quorum. |
|
|
320
|
+
| [International data transfers](https://eyereasoner.github.io/eyemind/examples/deck/data-transfers-le) | GDPR Chapter V over ODRL, DPV, location and GDPR-extension names: alternative premises, a duty read from a policy, and a prohibition that wins. |
|
|
321
|
+
| [Breach notification](https://eyereasoner.github.io/eyemind/examples/deck/breach-notification-le) | GDPR Articles 33 and 34 over DPV risk terms: deadlines in hours, an encryption exemption, a processor's ODRL duty and a sum. |
|
|
320
322
|
|
|
321
323
|
Their decks state the modeled assumptions and what the checked proofs establish.
|
|
322
324
|
Bounds and finite expression domains are explicit in the programs.
|
|
@@ -419,14 +421,24 @@ use `has`; for example `issueAlice has decision allowed.`. Status values
|
|
|
419
421
|
`conflict` as a property means `eval:conflict`; `applicablePermission`,
|
|
420
422
|
`applicableProhibition`, `reportConstraint` and `reportDuty` distinguish the
|
|
421
423
|
report's `eval:permission`, `eval:prohibition`, `eval:constraint` and
|
|
422
|
-
`eval:duty` links from ODRL input properties. Other report fields retain their `eval:` names.
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
424
|
+
`eval:duty` links from ODRL input properties. Other report fields retain their `eval:` names. Other IRIs
|
|
425
|
+
are written with the run's prefixes, declared after the directive: those the
|
|
426
|
+
file declares, `odrl:` and `eval:`. Inside a witness key, where a bare name
|
|
427
|
+
would read back as a name rather than an IRI, the snapshot namespace also
|
|
428
|
+
needs a prefix: the file's own, or `ns` when it declares none. An IRI that no
|
|
429
|
+
prefix abbreviates stays explicit.
|
|
430
|
+
|
|
431
|
+
Prefix declarations can follow either ODRL directive, and the whole snapshot
|
|
432
|
+
can be written with qualified names, as `ex:mayErase has odrl:action
|
|
433
|
+
odrl:delete.` or `ex:evaluation is a eval:Evaluation.`. After an ODRL
|
|
434
|
+
directive a qualified statement takes the subjects and values the short forms
|
|
435
|
+
take: an ordinary name in the declared namespace, `true` and `false`, and an
|
|
436
|
+
operand list, as `ex:scope has odrl:and [ex:purpose, ex:consent].`. A state
|
|
426
437
|
property or value can use a DPV IRI, for example
|
|
427
|
-
`
|
|
438
|
+
`state has dpv:hasPurpose dpv:AcademicResearch.`. An equality constraint
|
|
428
439
|
can read `dpv:hasPurpose` as its left operand and use
|
|
429
440
|
`dpv:AcademicResearch` as its right operand.
|
|
441
|
+
[Right to erasure example](https://eyereasoner.github.io/eyemind/examples/deck/right-to-erasure-le)
|
|
430
442
|
|
|
431
443
|
```text
|
|
432
444
|
scope is a logicalConstraint and scope has andOperands [purpose, dataCategory].
|
package/LS-SPEC.md
CHANGED
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ program, a JavaScript library and a browser application.
|
|
|
13
13
|
- [Playground](https://eyereasoner.github.io/eyemind/playground/): run any
|
|
14
14
|
example or your own program in the browser, with its proof and check report.
|
|
15
15
|
- [Examples](https://eyereasoner.github.io/eyemind/examples/): the
|
|
16
|
-
|
|
16
|
+
168 runnable programs, each with a card deck and saved conclusions; all but
|
|
17
17
|
the two streamed examples also save proofs and check reports.
|
|
18
18
|
- [Specification](https://eyereasoner.github.io/eyemind/LS-SPEC): the
|
|
19
19
|
language, the proof format and how a proof is checked.
|
|
@@ -461,7 +461,7 @@ SKOS links between categories, such as a `skos:broadMatch` to DPV. Other
|
|
|
461
461
|
entailments, such as an `rdfs:Resource` type for every node, stay out of the
|
|
462
462
|
snapshot, whose validation would reject them. The output is the ODRL report
|
|
463
463
|
with the profiles' own reports, such as a SHACL validation report.
|
|
464
|
-
[Handicap-card example](https://eyereasoner.github.io/eyemind/examples/deck/handicap-card) · [Research snapshot](https://eyereasoner.github.io/eyemind/examples/deck/research-snapshot-odrl) · [Research access with OWL 2 RL and SKOS](https://eyereasoner.github.io/eyemind/examples/deck/research-access-odrl) · [Research portal with OWL 2 RL](https://eyereasoner.github.io/eyemind/examples/deck/research-portal-odrl) · [Package holiday with SHACL](https://eyereasoner.github.io/eyemind/examples/deck/package-holiday-odrl)
|
|
464
|
+
[Handicap-card example](https://eyereasoner.github.io/eyemind/examples/deck/handicap-card) · [Research snapshot](https://eyereasoner.github.io/eyemind/examples/deck/research-snapshot-odrl) · [Research access with OWL 2 RL and SKOS](https://eyereasoner.github.io/eyemind/examples/deck/research-access-odrl) · [Research portal with OWL 2 RL](https://eyereasoner.github.io/eyemind/examples/deck/research-portal-odrl) · [Package holiday with SHACL](https://eyereasoner.github.io/eyemind/examples/deck/package-holiday-odrl) · [Right to erasure in qualified LE](https://eyereasoner.github.io/eyemind/examples/deck/right-to-erasure-le)
|
|
465
465
|
|
|
466
466
|
## How eyemind reasons
|
|
467
467
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eyemind",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.46",
|
|
4
4
|
"description": "A dependency-free Logic Script (LS) reasoner with forward and backward reasoning, checkable proofs, and RDF 1.2, Notation3 (N3), SPARQL 1.2 RL (SRL) and Logical English (LE) interoperability.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/le-odrl.js
CHANGED
|
@@ -106,7 +106,11 @@ export function compileOdrlLe(statements, profile, source) {
|
|
|
106
106
|
for (const head of statement.heads) {
|
|
107
107
|
if (!(head instanceof Struct) || !isGround(head)) throw new EyemindError(`${statement.file}: line ${statement.line}: an LE ODRL fact needs a ground class or property statement`);
|
|
108
108
|
let s, p, o;
|
|
109
|
-
if (head.name === 'rdf' && head.args.length === 3)
|
|
109
|
+
if (head.name === 'rdf' && head.args.length === 3) {
|
|
110
|
+
[s, p, o] = head.args;
|
|
111
|
+
s = rdfValue(s, namespace);
|
|
112
|
+
o = LIST_OPERANDS.has(p.args?.[0]) && properListItems(o) !== null ? o : rdfValue(o, namespace);
|
|
113
|
+
}
|
|
110
114
|
else if (head.args.length === 1) {
|
|
111
115
|
s = rdfValue(head.args[0], namespace); p = iri(RDF + 'type');
|
|
112
116
|
o = iri(TYPES.get(head.name) ?? namespace + head.name);
|
package/src/le.js
CHANGED
|
@@ -136,10 +136,16 @@ class Parser {
|
|
|
136
136
|
|
|
137
137
|
statement(name, subject, ...objects) {
|
|
138
138
|
if (typeof name === 'string') return st(name, subject, ...objects);
|
|
139
|
-
|
|
139
|
+
// After an ODRL directive, qualified statements take the names, true,
|
|
140
|
+
// false and operand lists the short forms take; le-odrl.js maps them.
|
|
141
|
+
const name_ = (term) => this.odrl && typeof term === 'string';
|
|
142
|
+
if (!rdfResource(subject) && !name_(subject)) this.error('a qualified RDF statement needs a resource subject such as ex:item, iri(...) or a variable');
|
|
140
143
|
if (!objects.length) return st('rdf', subject, st('iri', RDF_TYPE), name);
|
|
141
|
-
|
|
142
|
-
|
|
144
|
+
const [object] = objects, items = this.odrl ? listItems(object) : null;
|
|
145
|
+
if (!rdfValue(object) && !name_(object) && !(items?.length && items.every((item) => rdfValue(item) || name_(item)))) {
|
|
146
|
+
this.error('a qualified RDF property needs an RDF value such as a qualified name, number or literal(...)');
|
|
147
|
+
}
|
|
148
|
+
return st('rdf', subject, name, object);
|
|
143
149
|
}
|
|
144
150
|
|
|
145
151
|
declarations() {
|
|
@@ -386,6 +392,7 @@ class Parser {
|
|
|
386
392
|
if (this.take('snapshot')) { this.need('logic'); evaluate = true; }
|
|
387
393
|
else this.need('vocabulary');
|
|
388
394
|
const namespace = this.namespace('an ODRL');
|
|
395
|
+
this.odrl = true;
|
|
389
396
|
return { kind: 'odrl', namespace, evaluate, line };
|
|
390
397
|
}
|
|
391
398
|
if (this.take('every')) {
|
|
@@ -580,6 +587,8 @@ export function writeLe(result, { odrl = null, prefixes = {} } = {}) {
|
|
|
580
587
|
if (odrl) result = odrlLeReport(result, odrl.namespace);
|
|
581
588
|
// A prefix LE cannot spell, such as Turtle's empty one, gets the first free
|
|
582
589
|
// name of ns, ns2, ...; the output declares each prefix it uses.
|
|
590
|
+
// An ODRL report names its own namespace's resources bare where a name
|
|
591
|
+
// reads back as that IRI; inside a witness key a prefix keeps it an IRI.
|
|
583
592
|
const valid = Object.entries(prefixes).filter(([prefix, namespace]) => PREFIX.test(prefix) && typeof namespace === 'string');
|
|
584
593
|
const taken = new Set(valid.map(([prefix]) => prefix)), stated = new Set(valid.map(([, namespace]) => namespace));
|
|
585
594
|
for (const [prefix, namespace] of Object.entries(prefixes)) {
|
|
@@ -589,7 +598,7 @@ export function writeLe(result, { odrl = null, prefixes = {} } = {}) {
|
|
|
589
598
|
taken.add(name); stated.add(namespace);
|
|
590
599
|
valid.push([name, namespace]);
|
|
591
600
|
}
|
|
592
|
-
const namespaces =
|
|
601
|
+
const namespaces = valid.sort((a, b) => b[1].length - a[1].length);
|
|
593
602
|
const used = new Map();
|
|
594
603
|
const compact = (term) => {
|
|
595
604
|
if (!(term instanceof Struct) || term.name !== 'iri' || term.args.length !== 1 || typeof term.args[0] !== 'string') return null;
|
|
@@ -611,7 +620,7 @@ export function writeLe(result, { odrl = null, prefixes = {} } = {}) {
|
|
|
611
620
|
lines.push(quantifier + flattenConjunction(term).map((goal) => leGoal(goal, render, odrl !== null, compact)).join(' and ') + '.');
|
|
612
621
|
}
|
|
613
622
|
const declarations = [...used].sort().map(([prefix, namespace]) => `Use prefix ${prefix} with namespace ${JSON.stringify(namespace)}.`);
|
|
614
|
-
const header = odrl ? `Use ODRL vocabulary with namespace ${JSON.stringify(odrl.namespace)}.\n
|
|
615
|
-
|
|
623
|
+
const header = (odrl ? `Use ODRL vocabulary with namespace ${JSON.stringify(odrl.namespace)}.\n` : '') +
|
|
624
|
+
(declarations.length ? `${declarations.join('\n')}\n` : '') + (odrl || declarations.length ? '\n' : '');
|
|
616
625
|
return header + (lines.length ? lines.join('\n') + '\n' : '# No conclusions.\n');
|
|
617
626
|
}
|
package/src/odrl.js
CHANGED
|
@@ -18,7 +18,7 @@ export function isOdrlEvaluation(quads) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export function checkOdrlInput(quads) {
|
|
21
|
-
if (!isOdrlEvaluation(quads)) throw new EyemindError('
|
|
21
|
+
if (!isOdrlEvaluation(quads)) throw new EyemindError('an ODRL snapshot needs an eval:Evaluation resource selecting the policies and requests');
|
|
22
22
|
if (quads.some(([, , , graph]) => graph !== DEFAULT_GRAPH)) throw new EyemindError('an ODRL snapshot needs one default graph');
|
|
23
23
|
}
|
|
24
24
|
|
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// The release this checkout is; ./release keeps it in step with package.json.
|
|
2
|
-
export const VERSION = '0.8.
|
|
2
|
+
export const VERSION = '0.8.46';
|