eyemind 0.8.5 → 0.8.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/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.5
5
+ Version: eyemind 0.8.6
6
6
  ```
7
7
 
8
8
  This document specifies Logic Script (LS): the syntax and meaning of its
package/README.md CHANGED
@@ -315,9 +315,13 @@ Four switches add standalone LS rules to RDF inputs; vocabulary alone never
315
315
  enables one. They combine, inference closes before validation, and the output
316
316
  is Turtle with the new triples and reports.
317
317
 
318
- - `--owl2rl` adds the RDFS and non-datatype [OWL 2 RL](https://www.w3.org/TR/owl2-profiles/#Reasoning_in_OWL_2_RL_and_RDF_Graphs)
319
- rules, with partial datatype reasoning, and reports contradictions as
320
- `ent:Conflict` records instead of inferring everything from them.
318
+ - `--owl2rl` adds the RDFS and [OWL 2 RL](https://www.w3.org/TR/owl2-profiles/#Reasoning_in_OWL_2_RL_and_RDF_Graphs)
319
+ rules, including the datatype map of its table 8: value equality and
320
+ difference, membership across lexical forms, and ill-typed literals for the
321
+ XSD numeric, string, temporal and binary types, `rdf:PlainLiteral` and
322
+ `rdf:XMLLiteral`. It reports contradictions as `ent:Conflict` records
323
+ instead of inferring everything from them, and passes all 273 cases of the
324
+ [MobiBench](https://github.com/william-vw/mobibench) OWL 2 RL suite.
321
325
  - `--qudt` normalizes QUDT quantity values and CDT literals to SI units from
322
326
  an offline catalog adapted from [QUDT.org](https://qudt.org/) (CC BY 4.0):
323
327
  `"36 km/h"^^cdt:speed` yields `"10.0 m/s"^^cdt:speed`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyemind",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "description": "A dependency-free Logic Script (LS) reasoner with forward and backward reasoning, checkable proofs, and RDF 1.2, Notation3 (N3), SPARQL 1.2 RL (SRL) and Logical English (LE) interoperability.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/engine.js CHANGED
@@ -103,6 +103,14 @@ class Point {
103
103
  }
104
104
 
105
105
  const NO_NODES = Object.freeze([]);
106
+
107
+ // Add a fact number to an index bucket: a single number, then an array of them.
108
+ function addToBucket(index, key, number) {
109
+ const bucket = index.get(key);
110
+ if (bucket === undefined) index.set(key, number);
111
+ else if (typeof bucket === 'number') index.set(key, [bucket, number]);
112
+ else bucket.push(number);
113
+ }
106
114
  const QUIET = new Pending(null, null, NO_NODES, null);
107
115
  const SPLICE = 'splice';
108
116
 
@@ -284,6 +292,10 @@ export class Solver {
284
292
  // per argument position from an atom or number to the indexes, in order,
285
293
  // of the facts with that value there.
286
294
  this.factIndex = new Map();
295
+ // Derived facts are also indexed on adjacent argument pairs, so a goal such
296
+ // as rdf(S, P, O, G) with a common subject and a given property finds its
297
+ // facts directly rather than among all the subject's facts.
298
+ this.pairIndex = new Map();
287
299
  this.factKeys = new Set(program.groundFactKeys);
288
300
  this.iriIds = new Map();
289
301
  for (const clause of program.clauses) {
@@ -549,15 +561,24 @@ export class Solver {
549
561
  positions = Array.from({ length: arity }, () => new Map());
550
562
  this.factIndex.set(goalKey, positions);
551
563
  }
552
- node.goal.args.forEach((arg, position) => {
553
- const argument = indexKey(arg);
554
- if (argument !== undefined) {
555
- const bucket = positions[position].get(argument);
556
- if (bucket === undefined) positions[position].set(argument, number);
557
- else if (typeof bucket === 'number') positions[position].set(argument, [bucket, number]);
558
- else bucket.push(number);
559
- }
564
+ const keys = node.goal.args.map((arg) => indexKey(arg));
565
+ keys.forEach((argument, position) => {
566
+ if (argument !== undefined) addToBucket(positions[position], argument, number);
560
567
  });
568
+ if (arity > 1) {
569
+ let pairs = this.pairIndex.get(goalKey);
570
+ if (pairs === undefined) {
571
+ pairs = Array.from({ length: arity - 1 }, () => new Map());
572
+ this.pairIndex.set(goalKey, pairs);
573
+ }
574
+ for (let position = 0; position + 1 < arity; position++) {
575
+ const [first, second] = [keys[position], keys[position + 1]];
576
+ if (first === undefined || second === undefined) continue;
577
+ let inner = pairs[position].get(first);
578
+ if (inner === undefined) pairs[position].set(first, inner = new Map());
579
+ addToBucket(inner, second, number);
580
+ }
581
+ }
561
582
  }
562
583
  }
563
584
 
@@ -583,17 +604,20 @@ export class Solver {
583
604
  if (positions === undefined) return null;
584
605
  let best = null;
585
606
  let size = this.facts.get(goalKey).length;
586
- for (let position = 0; position < goal.args.length; position++) {
587
- const arg = indexKey(goal.args[position], env);
588
- if (arg !== undefined) {
589
- const stored = positions[position].get(arg);
590
- const bucket = typeof stored === 'number' ? [stored] : stored ?? NO_NODES;
591
- if (bucket.length < size) {
592
- best = bucket;
593
- size = bucket.length;
594
- if (!size) break;
595
- }
607
+ const keys = goal.args.map((arg) => indexKey(arg, env));
608
+ const consider = (stored) => {
609
+ const bucket = typeof stored === 'number' ? [stored] : stored ?? NO_NODES;
610
+ if (bucket.length < size) {
611
+ best = bucket;
612
+ size = bucket.length;
596
613
  }
614
+ };
615
+ for (let position = 0; position < keys.length && size; position++) {
616
+ if (keys[position] !== undefined) consider(positions[position].get(keys[position]));
617
+ }
618
+ const pairs = this.pairIndex.get(goalKey);
619
+ for (let position = 0; pairs !== undefined && position + 1 < keys.length && size; position++) {
620
+ if (keys[position] !== undefined && keys[position + 1] !== undefined) consider(pairs[position].get(keys[position])?.get(keys[position + 1]));
597
621
  }
598
622
  return best;
599
623
  }
package/src/owl2rl.js CHANGED
@@ -163,15 +163,16 @@ implies([t(A, r('type'), o('AllDisjointProperties')), t(A, o('members'), L), ent
163
163
  implies([t(P, o('propertyDisjointWith'), Q), t(X, P, V), t(Y, Q, V)], t(X, o('differentFrom'), Y));
164
164
  implies([t(P, o('propertyDisjointWith'), Q), t(X, P, V), t(X, Q, W)], t(V, o('differentFrom'), W));
165
165
  implies([t(P, r('type'), o('FunctionalProperty')), t(X, P, V), t(Y, P, W), t(V, o('differentFrom'), W)], t(X, o('differentFrom'), Y));
166
- // Literal membership and exact numeric/boolean/string value comparisons.
167
- // Datatype declarations are scoped to the vocabulary actually used by a graph.
168
- implies([ent_node(iri(D), G), rv_supported(iri(D))], t(iri(D), r('type'), s('Datatype')));
166
+ // The datatype map (dt-type1): every supported datatype, and rdfs:Literal.
167
+ implies([ent_graph(G), rv_supported(D)], t(D, r('type'), s('Datatype')));
168
+ implies(ent_graph(G), t(s('Literal'), r('type'), s('Datatype')));
169
169
  implies([rdf(_, _, T, G), rv_literal(T)], ent_literal(T, G));
170
+ // A literal is an instance of its own datatype and of every supported
171
+ // datatype whose value space holds its value (dt-type2), and a literal typed
172
+ // with a supported datatype that does not hold its value is a conflict.
170
173
  implies([ent_literal(T, G), rv_datatype(T, D), rv_valid(T)], t(T, r('type'), D));
171
- implies([ent_literal(T, G), ent_node(D, G), rv_supported(D), rv_member(T, D)], t(T, r('type'), D));
172
- implies([ent_literal(T, G), rv_datatype(T, D), rv_supported(D), rdf(T, r('type'), D, G), not(rv_valid(T))],
173
- ent_conflict('dt-not-type', T, r('type'), D, G));
174
- implies([ent_literal(T, G), rv_exact(T), rdf(T, r('type'), D, G), rv_integer_datatype(D), not(rv_member(T, D))],
174
+ implies([ent_literal(T, G), rv_supported(D), rv_member(T, D)], t(T, r('type'), D));
175
+ implies([ent_literal(T, G), rdf(T, r('type'), D, G), rv_supported(D), not(rv_member(T, D))],
175
176
  ent_conflict('dt-not-type', T, r('type'), D, G));
176
177
  implies([ent_literal(A, G), ent_literal(B, G), not_identical(A, B), rv_same(A, B)], t(A, o('sameAs'), B));
177
178
  implies([ent_literal(A, G), ent_literal(B, G), rv_different(A, B)], t(A, o('differentFrom'), B));
package/src/rdf-values.js CHANGED
@@ -13,11 +13,12 @@ const bounds = [
13
13
  ['unsignedShort', '0', '65535'], ['unsignedByte', '0', '255'],
14
14
  ];
15
15
  export const RDF_DATATYPES = new Set([...bounds.map(([n]) => XSD + n), ...['decimal', 'float', 'double', 'boolean', 'string',
16
- 'normalizedString', 'token', 'language', 'anyURI', 'date', 'dateTime', 'dateTimeStamp', 'time',
17
- 'hexBinary', 'base64Binary'].map((n) => XSD + n), RDF + 'langString', RDF + 'dirLangString']);
16
+ 'normalizedString', 'token', 'language', 'Name', 'NCName', 'NMTOKEN', 'anyURI', 'date', 'dateTime', 'dateTimeStamp', 'time',
17
+ 'hexBinary', 'base64Binary'].map((n) => XSD + n), RDF + 'langString', RDF + 'dirLangString', RDF + 'PlainLiteral', RDF + 'XMLLiteral']);
18
18
 
19
19
  const integerRules = bounds.map(([name, min, max]) => {
20
- const facets = `${min === null ? '' : `, ge(N, ${min})`}${max === null ? '' : `, le(N, ${max})`}`;
20
+ // BigInt literals: as JavaScript numbers, bounds beyond 2^53 would round.
21
+ const facets = `${min === null ? '' : `, ge(N, ${min}n)`}${max === null ? '' : `, le(N, ${max}n)`}`;
21
22
  return `implied_by(rv_lexical('${XSD}${name}', L), [srl_read_number('integer', L, N)${facets}]);\n` +
22
23
  `implied_by(rv_member(T, iri('${XSD}${name}')), [rv_integer_value(T, N)${facets}]);\n` +
23
24
  `fact(rv_integer_datatype(iri('${XSD}${name}')));`;
@@ -72,12 +73,39 @@ implied_by(rv_valid_as(literal(L, datatype(D)), iri(D)), rv_lexical(D, L));
72
73
  fact(rv_valid_as(literal(_, lang(_)), iri(rvRdf + 'langString')));
73
74
  fact(rv_valid_as(literal(_, lang(_, _)), iri(rvRdf + 'dirLangString')));
74
75
  implied_by(rv_lexical(rvXsd + 'decimal', L), srl_decimal_text(L, _));
75
- implied_by(rv_lexical(D, L), [rv_binary_type(D), regex_match('^[ \\t\\r\\n]*(?:[+-]?(?:(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?|INF)|NaN)[ \\t\\r\\n]*$', L)]);
76
+ implied_by(rv_lexical(D, L), [rv_binary_type(D), regex_match('^[ \\t\\r\\n]*(?:[+-]?(?:(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?|INF)|NaN)[ \\t\\r\\n]*$', L), rv_binary_range(D, L)]);
77
+ // A finite lexical form whose value overflows the type, or is nonzero and
78
+ // rounds to zero in it, denotes no value of the type.
79
+ implied_by(rv_binary_range(D, L), or(regex_match('INF|NaN', L), [float64('parse', L, 0, V), is_float(V), float64('abs', V, 0, A),
80
+ rv_binary_limits(D, Max, Min), float64('compare', A, Max, O1), not_identical(O1, '>'), or(not(regex_match('^[^eE]*[1-9]', L)), [float64('compare', A, Min, O2), identical(O2, '>')])]));
81
+ fact(rv_binary_limits(rvXsd + 'double', float(1.7976931348623157e308), float(0)), rv_binary_limits(rvXsd + 'float', float(3.4028235677973366e38), float(7.006492321624085e-46)));
76
82
  fact(rv_binary_type(rvXsd + 'float'), rv_binary_type(rvXsd + 'double'));
77
83
  implied_by(rv_lexical(rvXsd + 'boolean', L), regex_match('^[ \\t\\r\\n]*(true|false|0|1)[ \\t\\r\\n]*$', L));
78
84
  implied_by(rv_lexical(D, L), [rv_text_type(D), is_atom(L)]);
79
- fact(rv_text_type(rvXsd + 'string'), rv_text_type(rvXsd + 'normalizedString'), rv_text_type(rvXsd + 'token'), rv_text_type(rvXsd + 'anyURI'));
80
- implied_by(rv_lexical(rvXsd + 'language', L), regex_match('^[ \\t\\r\\n]*[A-Za-z]{1,8}(?:-[A-Za-z0-9]{1,8})*[ \\t\\r\\n]*$', L));
85
+ fact(rv_text_type(rvXsd + 'string'));
86
+ // An IRI reference: a colon before any /, ? or # ends a scheme, which starts
87
+ // with a letter; spaces, <>"{}|\^ and the backquote are excluded.
88
+ implied_by(rv_lexical(rvXsd + 'anyURI', L), [not(regex_match('[\\s<>"{}|\\\\^\\x60]', L)),
89
+ or(not(regex_match('^[^/?#]*:', L)), regex_match('^[A-Za-z][A-Za-z0-9+.\\-]*:', L))]);
90
+ // The lexical spaces of the string types derived by restriction exclude what
91
+ // their whitespace facets would remove: a literal is not normalized first.
92
+ implied_by(rv_lexical(rvXsd + 'normalizedString', L), not(regex_match('[\\t\\r\\n]', L)));
93
+ implied_by(rv_lexical(rvXsd + 'token', L), not(regex_match('[\\t\\r\\n]|^ | $| ', L)));
94
+ implied_by(rv_lexical(rvXsd + 'language', L), regex_match('^[A-Za-z]{1,8}(?:-[A-Za-z0-9]{1,8})*$', L));
95
+ implied_by(rv_lexical(rvXsd + 'Name', L), regex_match('^[\\p{L}_:][\\p{L}\\p{N}._:\\-]*$', L));
96
+ implied_by(rv_lexical(rvXsd + 'NCName', L), regex_match('^[\\p{L}_][\\p{L}\\p{N}._\\-]*$', L));
97
+ implied_by(rv_lexical(rvXsd + 'NMTOKEN', L), regex_match('^[\\p{L}\\p{N}._:\\-]+$', L));
98
+ // rdf:PlainLiteral: text, then @ and an empty or well-formed language tag.
99
+ implied_by(rv_lexical(rvRdf + 'PlainLiteral', L), regex_match('@(?:[A-Za-z]{1,8}(?:-[A-Za-z0-9]{1,8})*)?$', L));
100
+ implied_by(rv_lexical(rvRdf + 'XMLLiteral', L), rv_xml(L));
101
+ // A well-formed XML fragment, as far as its tags: each opened tag closes in
102
+ // order, and no markup character is left outside a tag.
103
+ implied_by(rv_xml(L), [findall([C, N, E], regex_find('<(/?)([\\p{L}_:][\\p{L}\\p{N}._:\\-]*)(?:\\s[^<>]*?)?(/?)>', L, [_, C, N, E]), Tags),
104
+ regex_replace('<(/?)([\\p{L}_:][\\p{L}\\p{N}._:\\-]*)(?:\\s[^<>]*?)?(/?)>', L, '', Rest), not(regex_match('[<>]', Rest)), rv_xml_balanced(Tags, [])]);
105
+ fact(rv_xml_balanced([], []));
106
+ implied_by(rv_xml_balanced([['', _, '/'], ...T], S), rv_xml_balanced(T, S));
107
+ implied_by(rv_xml_balanced([['', N, ''], ...T], S), rv_xml_balanced(T, [N, ...S]));
108
+ implied_by(rv_xml_balanced([['/', N, ''], ...T], [N, ...S]), rv_xml_balanced(T, S));
81
109
  implied_by(rv_lexical(rvXsd + 'hexBinary', L), regex_match('^[ \\t\\r\\n]*(?:[0-9A-Fa-f]{2})*[ \\t\\r\\n]*$', L));
82
110
  implied_by(rv_lexical(rvXsd + 'base64Binary', L), [regex_replace('[ \\t\\r\\n]', L, '', S), regex_match('^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/][AQgw]==|[A-Za-z0-9+/]{2}[AEIMQUYcgkosw048]=)?$', S)]);
83
111
  implied_by(rv_exact(T), [rv_valid(T), srl_num(T, K, _), rv_exact_kind(K)]);
@@ -91,11 +119,39 @@ fact(rv_boolean_text('true', 'true'), rv_boolean_text('1', 'true'), rv_boolean_t
91
119
  implied_by(rv_same(A, B), [rv_text_value(A, S), rv_text_value(B, S)]);
92
120
  implied_by(rv_different(A, B), [rv_text_value(A, S), rv_text_value(B, T), not_identical(S, T)]);
93
121
  fact(rv_text_value(literal(L, datatype(rvXsd + 'string')), L));
94
- implied_by(rv_text_value(literal(L, datatype(rvXsd + 'normalizedString')), S), regex_replace('[\\t\\r\\n]', L, ' ', S));
95
- implied_by(rv_text_value(literal(L, datatype(rvXsd + 'token')), S), [regex_replace('[ \\t\\r\\n]+', L, ' ', A), regex_replace('^ | $', A, '', S)]);
122
+ // A valid literal of a string type derived by restriction is its own value.
123
+ implied_by(rv_text_value(literal(L, datatype(D)), L), [rv_string_type(D), rv_lexical(D, L)]);
124
+ fact(rv_string_type(rvXsd + 'normalizedString'), rv_string_type(rvXsd + 'token'), rv_string_type(rvXsd + 'language'),
125
+ rv_string_type(rvXsd + 'Name'), rv_string_type(rvXsd + 'NCName'), rv_string_type(rvXsd + 'NMTOKEN'));
126
+ implied_by(rv_text_value(literal(L, datatype(rvRdf + 'PlainLiteral')), S), regex_find('^([\\s\\S]*)@$', L, [_, S]));
127
+ // The other value spaces: binary floats and doubles, temporal values, binary
128
+ // data, URIs, language-tagged text and XML. Values of different spaces are
129
+ // neither the same nor, here, different.
130
+ implied_by(rv_value(T, Space, V), [rv_valid(T), rv_datatype(T, D), rv_value_of(D, T, Space, V)]);
131
+ implied_by(rv_value_of(iri(D), T, D, V), [rv_binary_type(D), srl_num(T, _, V), is_float(V)]);
132
+ implied_by(rv_value_of(_, T, temporal(Type, Kind), V), rv_temporal(T, Type, Kind, V));
133
+ implied_by(rv_value_of(iri(rvXsd + 'hexBinary'), literal(L, _), 'hexBinary', V), [regex_replace('[ \\t\\r\\n]', L, '', S), atom_upper(S, V)]);
134
+ implied_by(rv_value_of(iri(rvXsd + 'base64Binary'), literal(L, _), 'base64Binary', V), regex_replace('[ \\t\\r\\n]', L, '', V));
135
+ fact(rv_value_of(iri(rvXsd + 'anyURI'), literal(L, _), 'anyURI', L));
136
+ fact(rv_value_of(iri(rvRdf + 'XMLLiteral'), literal(L, _), 'XMLLiteral', L));
137
+ implied_by(rv_value_of(iri(rvRdf + 'langString'), literal(S, lang(L)), 'lang', [S, T]), atom_lower(L, T));
138
+ implied_by(rv_value_of(iri(rvRdf + 'PlainLiteral'), literal(L, _), 'lang', [S, T]), [regex_find('^([\\s\\S]*)@([^@]+)$', L, [_, S, Tag]), atom_lower(Tag, T)]);
139
+ implied_by(rv_same(A, B), [rv_value(A, Space, V), rv_value(B, Space, W), rv_value_compare(Space, V, W, '=')]);
140
+ implied_by(rv_different(A, B), [rv_value(A, Space, V), rv_value(B, Space, W), rv_value_compare(Space, V, W, O), not_identical(O, '='), not_identical(O, 'unordered')]);
141
+ implied_by(rv_value_compare(Space, V, W, O), [rv_binary_type(Space), float64('compare', V, W, O)]);
142
+ implied_by(rv_value_compare(temporal(_, _), V, W, O), [srl_decimal_value(V, A), srl_decimal_value(W, B), srl_value_compare(A, B, O)]);
143
+ implied_by(rv_value_compare(Space, V, W, O), [rv_identity_space(Space), or([identical(V, W), unify(O, '=')], [not_identical(V, W), unify(O, '<>')])]);
144
+ fact(rv_identity_space('hexBinary'), rv_identity_space('base64Binary'), rv_identity_space('anyURI'), rv_identity_space('XMLLiteral'), rv_identity_space('lang'));
96
145
  implied_by(rv_order(A, B, O), [rv_valid(A), rv_valid(B), srl_pair(A, B, _, X, Y), srl_value_compare(X, Y, O)]);
97
146
  implied_by(rv_order(A, B, O), [rv_text_value(A, S), rv_text_value(B, T), compare(O, S, T)]);
98
147
  implied_by(rv_integer_value(T, N), [rv_exact(T), srl_num(T, _, V), srl_decimal_value(V, decimal(C, S)), is(P, pow(10, S)), eq(mod(C, P), 0), is(N, floordiv(C, P))]);
99
148
  implied_by(rv_member(T, iri(rvXsd + 'decimal')), rv_exact(T));
149
+ // Every string-family value is a string, and strings and language-tagged
150
+ // strings are rdf:PlainLiteral values.
151
+ implied_by(rv_member(T, iri(rvXsd + 'string')), rv_text_value(T, _));
152
+ // A string value belongs to each string type derived by restriction whose
153
+ // lexical space holds it: an NCName is also a Name, a token and so on.
154
+ implied_by(rv_member(T, iri(D)), [rv_text_value(T, S), rv_string_type(D), rv_lexical(D, S)]);
155
+ implied_by(rv_member(T, iri(rvRdf + 'PlainLiteral')), or(rv_text_value(T, _), rv_value(T, 'lang', _)));
100
156
  implied_by(rv_member(T, D), rv_valid_as(T, D));
101
157
  ` + integerRules + '\n' + [...RDF_DATATYPES].map((d) => `fact(rv_supported(iri('${d}')));`).join('\n') + dateRules;
package/src/skos.js CHANGED
@@ -7,12 +7,18 @@ const RDFS = 'http://www.w3.org/2000/01/rdf-schema#';
7
7
  const OWL = 'http://www.w3.org/2002/07/owl#';
8
8
  const iri = (s) => `iri(${JSON.stringify(s)})`;
9
9
  const k = (s) => iri(SKOS + s);
10
- const schema = [], facts = [];
10
+ // Each entailment is its own rule with the property as a constant, so the
11
+ // engine's argument index gives a rule only the triples of that property.
12
+ const schema = [], rules = [];
13
+ const TYPE = iri(RDF + 'type');
11
14
  const axiom = (s, p, o) => schema.push(`fact(sk_schema(${s}, ${p}, ${o}));`);
12
- const sub = (p, q) => { facts.push(`fact(sk_sub(${k(p)}, ${q}));`); axiom(k(p), iri(RDFS + 'subPropertyOf'), q); };
13
- const domain = (p, c) => { facts.push(`fact(sk_domain(${k(p)}, ${k(c)}));`); axiom(k(p), iri(RDFS + 'domain'), k(c)); };
14
- const range = (p, c) => { facts.push(`fact(sk_range(${k(p)}, ${k(c)}));`); axiom(k(p), iri(RDFS + 'range'), k(c)); };
15
- const inverse = (p, q) => { facts.push(`fact(sk_inverse(${k(p)}, ${k(q)}));`); axiom(k(p), iri(OWL + 'inverseOf'), k(q)); };
15
+ const sub = (p, q) => { rules.push(`implies(rdf(S, ${k(p)}, O, G), rdf(S, ${q}, O, G));`); axiom(k(p), iri(RDFS + 'subPropertyOf'), q); };
16
+ const domain = (p, c) => { rules.push(`implies(rdf(S, ${k(p)}, O, G), rdf(S, ${TYPE}, ${k(c)}, G));`); axiom(k(p), iri(RDFS + 'domain'), k(c)); };
17
+ const range = (p, c) => { rules.push(`implies(rdf(S, ${k(p)}, O, G), rdf(O, ${TYPE}, ${k(c)}, G));`); axiom(k(p), iri(RDFS + 'range'), k(c)); };
18
+ const inverse = (p, q) => {
19
+ rules.push(`implies(rdf(S, ${k(p)}, O, G), rdf(O, ${k(q)}, S, G));`, `implies(rdf(S, ${k(q)}, O, G), rdf(O, ${k(p)}, S, G));`);
20
+ axiom(k(p), iri(OWL + 'inverseOf'), k(q));
21
+ };
16
22
  for (const c of ['Concept', 'ConceptScheme', 'Collection', 'OrderedCollection']) axiom(k(c), iri(RDF + 'type'), iri(OWL + 'Class'));
17
23
  const relations = ['inScheme', 'hasTopConcept', 'topConceptOf', 'semanticRelation', 'broader', 'narrower', 'related',
18
24
  'broaderTransitive', 'narrowerTransitive', 'member', 'memberList', 'mappingRelation', 'closeMatch', 'exactMatch', 'broadMatch', 'narrowMatch', 'relatedMatch'];
@@ -43,21 +49,14 @@ for (const [p, q] of [['broadMatch', 'broader'], ['narrowMatch', 'narrower'], ['
43
49
  }
44
50
  inverse('broadMatch', 'narrowMatch');
45
51
  for (const p of ['related', 'relatedMatch', 'closeMatch', 'exactMatch']) {
46
- facts.push(`fact(sk_symmetric(${k(p)}));`); axiom(k(p), iri(RDF + 'type'), iri(OWL + 'SymmetricProperty'));
52
+ rules.push(`implies(rdf(S, ${k(p)}, O, G), rdf(O, ${k(p)}, S, G));`); axiom(k(p), iri(RDF + 'type'), iri(OWL + 'SymmetricProperty'));
47
53
  }
48
54
  for (const p of ['broaderTransitive', 'narrowerTransitive', 'exactMatch']) {
49
- facts.push(`fact(sk_transitive(${k(p)}));`); axiom(k(p), iri(RDF + 'type'), iri(OWL + 'TransitiveProperty'));
55
+ rules.push(`implies([rdf(S, ${k(p)}, M, G), rdf(M, ${k(p)}, O, G)], rdf(S, ${k(p)}, O, G));`); axiom(k(p), iri(RDF + 'type'), iri(OWL + 'TransitiveProperty'));
50
56
  }
51
57
 
52
- export const skosRules = '\n' + [...schema, ...facts].join('\n') + String.raw`
58
+ export const skosRules = '\n' + [...schema, ...rules].join('\n') + String.raw`
53
59
  implies([ent_graph(G), sk_schema(S, P, O)], rdf(S, P, O, G));
54
- implies([rdf(S, P, O, G), sk_sub(P, Q)], rdf(S, Q, O, G));
55
- implies([rdf(S, P, O, G), sk_domain(P, C)], rdf(S, iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), C, G));
56
- implies([rdf(S, P, O, G), sk_range(P, C)], rdf(O, iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), C, G));
57
- implies([rdf(S, P, O, G), sk_inverse(P, Q)], rdf(O, Q, S, G));
58
- implies([rdf(S, Q, O, G), sk_inverse(P, Q)], rdf(O, P, S, G));
59
- implies([rdf(S, P, O, G), sk_symmetric(P)], rdf(O, P, S, G));
60
- implies([rdf(S, P, M, G), sk_transitive(P), rdf(M, P, O, G)], rdf(S, P, O, G));
61
60
  implies(rdf(S, iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), iri('http://www.w3.org/2004/02/skos/core#OrderedCollection'), G), rdf(S, iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), iri('http://www.w3.org/2004/02/skos/core#Collection'), G));
62
61
  implies([ent_graph(G)], sk_list(iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'), G));
63
62
  implies([rdf(L, iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#first'), X, G), rdf(L, iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#rest'), T, G), sk_list(T, G)], sk_list(L, G));
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.5';
2
+ export const VERSION = '0.8.6';