eyemind 0.8.50 → 0.8.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LE-SPEC.md CHANGED
@@ -326,9 +326,7 @@ These programs use the grammar above without additional syntax:
326
326
  | --- | --- |
327
327
  | [Shortest paths](https://eyereasoner.github.io/eyemind/examples/deck/shortest-path-le) | Bounded recursive histories, exact costs and minimum selection by absence, retaining ties. |
328
328
  | [River crossing](https://eyereasoner.github.io/eyemind/examples/deck/river-crossing-le) | Compound states, repeated-variable matching, safety constraints and complete plans within a bound. |
329
- | [Pell equations](https://eyereasoner.github.io/eyemind/examples/deck/pell-equation-le) | Recursive arithmetic beyond binary64 integer precision and exact polynomial checks. |
330
329
  | [Course certificates](https://eyereasoner.github.io/eyemind/examples/deck/course-certificates-le) | Recursive requirements, absence of a counterexample, shared existential witnesses and witnesses containing earlier witnesses. |
331
- | [Symbolic differentiation](https://eyereasoner.github.io/eyemind/examples/deck/symbolic-derivative-le) | Structural recursion over expression trees, constructed derivatives and evaluation at separate points. |
332
330
  | [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. |
333
331
  | [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. |
334
332
  | [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. |
package/LS-SPEC.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ```text
4
4
  Title: The Logic Script (LS) Language and Proof Format
5
- Version: eyemind 0.8.50
5
+ Version: eyemind 0.8.52
6
6
  ```
7
7
 
8
8
  This document specifies Logic Script (LS): the syntax and meaning of its
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
- 170 runnable programs, each with a card deck and saved conclusions; all but
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.
@@ -261,7 +261,6 @@ hierarchy in category constraints. [Logical English specification](https://eyere
261
261
  For larger programs, try
262
262
  [shortest paths](https://eyereasoner.github.io/eyemind/examples/deck/shortest-path-le),
263
263
  [river-crossing plans](https://eyereasoner.github.io/eyemind/examples/deck/river-crossing-le),
264
- [Pell equations](https://eyereasoner.github.io/eyemind/examples/deck/pell-equation-le),
265
264
  [British citizenship](https://eyereasoner.github.io/eyemind/examples/deck/british-citizenship-le),
266
265
  [library fines](https://eyereasoner.github.io/eyemind/examples/deck/library-fines-le) or an
267
266
  [election tally](https://eyereasoner.github.io/eyemind/examples/deck/election-tally-le).
@@ -435,8 +434,9 @@ query(rdf(O, iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), sosa('Obser
435
434
  entailments, without integrity checks or SKOS-XL.
436
435
  - `--shacl` compiles shapes to LS and writes a standard `sh:ValidationReport`.
437
436
  It implements SHACL 1.2 Core, including list, reifier and targeting
438
- constraints, and SHACL 1.2 node expressions with the `sparql:` functions and
439
- custom functions. All 162 W3C Core and 284 node-expression tests pass with
437
+ constraints and `sh:condition`, and SHACL 1.2 node expressions with the
438
+ `sparql:` functions and custom functions. All 173 W3C Core and 284
439
+ node-expression tests pass with
440
440
  complete reports. Recursive shapes, SHACL-SPARQL and rules are not
441
441
  supported.
442
442
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyemind",
3
- "version": "0.8.50",
3
+ "version": "0.8.52",
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/shacl.js CHANGED
@@ -24,9 +24,9 @@ const CONSTRAINTS = ['class', 'datatype', 'nodeKind', 'minCount', 'maxCount', 'm
24
24
  'closed', 'hasValue', 'in', 'rootClass', 'uniqueValuesFor', 'expression', 'nodeByExpression'];
25
25
  const ANNOTATIONS = ['severity', 'message', 'deactivated', 'name', 'description', 'order', 'group', 'defaultValue', 'unit',
26
26
  'intent', 'agentInstruction', 'codeIdentifier', 'codeType', 'keyParameter', 'optional'];
27
- const ALLOWED = new Set([...TARGETS, ...CONSTRAINTS, ...ANNOTATIONS, 'path', 'values', 'flags', 'ignoredProperties']);
27
+ const ALLOWED = new Set([...TARGETS, ...CONSTRAINTS, ...ANNOTATIONS, 'path', 'values', 'flags', 'ignoredProperties', 'condition']);
28
28
  // Shape-expecting parameters, whose values are compiled as shapes and checked for recursion.
29
- const SHAPE_PARAMETERS = ['node', 'not', 'qualifiedValueShape', 'property', 'memberShape', 'reifierShape', 'someValue', 'targetWhere'];
29
+ const SHAPE_PARAMETERS = ['node', 'not', 'qualifiedValueShape', 'property', 'memberShape', 'reifierShape', 'someValue', 'targetWhere', 'condition'];
30
30
  const PATH_OPERATORS = ['inversePath', 'alternativePath', 'zeroOrMorePath', 'oneOrMorePath', 'zeroOrOnePath'];
31
31
  // The default conformance-disallow set of SHACL 1.2.
32
32
  export const SHACL_DISALLOWS = ['Violation', 'Warning', 'Info'].map((n) => SH + n);
@@ -110,6 +110,24 @@ export function compileShacl(quads, { disallows = SHACL_DISALLOWS, needs = new S
110
110
  const target = shape(child, depth + 1); node.refs.push(target);
111
111
  if (p === 'property') node.properties.push(target);
112
112
  }
113
+ // A focus node meets sh:condition when it conforms to every condition
114
+ // shape; one that is a class also brings the node shapes of its
115
+ // superclasses.
116
+ node.conditions = [];
117
+ for (const condition of values(s, 'condition')) {
118
+ const seen = new Set(), pending = [condition];
119
+ while (pending.length) {
120
+ const t = pending.pop();
121
+ if (seen.has(write(t))) continue;
122
+ seen.add(write(t));
123
+ if (write(t) === write(condition) || isNodeShape(t)) {
124
+ const target = shape(t, depth + 1);
125
+ node.conditions.push(target);
126
+ if (!node.refs.includes(target)) node.refs.push(target);
127
+ }
128
+ if (isClass(t)) pending.push(...values(t, RDFS + 'subClassOf'));
129
+ }
130
+ }
113
131
  for (const p of ['and', 'or', 'xone']) {
114
132
  const root = one(s, p);
115
133
  if (root) {
@@ -287,6 +305,7 @@ export function compileShacl(quads, { disallows = SHACL_DISALLOWS, needs = new S
287
305
  lines.push(`implied_by(sh_inactive_${id}(F), ${expression(deactivated)}(F, [], nodes([${TRUE_TERM}])));`);
288
306
  guard.push(`not(sh_inactive_${id}(F))`);
289
307
  }
308
+ for (const condition of node.conditions) guard.push(`sh_ok_${condition.id}(F)`);
290
309
  const all = (property, fn) => values(s, property).forEach(fn);
291
310
  all('targetNode', (t) => lines.push(t instanceof Struct && t.name === 'bnode' ?
292
311
  `implies([${expression(t)}('sh_none', [], nodes(L)), ent_member(T, L)], ${target}(T));` :
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.50';
2
+ export const VERSION = '0.8.52';