eyemind 0.5.2 → 0.5.3

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
@@ -174,7 +174,7 @@ The answer is `test(a(A), c(A))`, with the shared variable preserved. Inspection
174
174
 
175
175
  ### RDF 1.2
176
176
 
177
- eyemind reads RDF 1.2 itself, with no dependency: a file ending in `.ttl`, `.trig`, `.nt` or `.nq` is Turtle, TriG, N-Triples or N-Quads, read by [eyeling](https://github.com/eyereasoner/eyeling)'s parser with the formats' own grammars, and given with a program its quads become `rdf(Subject, Predicate, Object, Graph)` facts, read as data through `facts_from` and never run. `--to turtle`, `trig`, `n-triples` or `n-quads` writes a run's `rdf` and `result_rdf` conclusions back as RDF:
177
+ eyemind reads RDF 1.2 itself, with no dependency: a file ending in `.ttl`, `.trig`, `.nt` or `.nq` is Turtle, TriG, N-Triples or N-Quads, read with the formats' own grammars, and given with a program its quads become `rdf(Subject, Predicate, Object, Graph)` facts, read as data through `facts_from` and never run. `--to turtle`, `trig`, `n-triples` or `n-quads` writes a run's `rdf` and `result_rdf` conclusions back as RDF:
178
178
 
179
179
  ```sh
180
180
  eyemind rules.js data.ttl # rdf/4 facts for the rules
@@ -203,7 +203,11 @@ eyemind --program examples/n3-family.n3 > /tmp/family.js # the compiled program
203
203
  eyemind -c examples/n3-family.n3 # a proof of it, checked
204
204
  ```
205
205
 
206
- Triples are `rdf(Subject, Predicate, Object)`, with IRIs, blank nodes and literals written as in the RDF table above and N3 numbers as eyemind numbers. `=>` becomes `implies`, `<=` becomes `implied_by`, `{ ... } => false` becomes `contradiction`, and scoped negation and collection become `not` and `findall`, so an N3 run has a proof that eyemind checks like any other. The documents `log:semantics` and `log:content` name are read before compiling, from local files only.
206
+ Triples are `rdf(Subject, Predicate, Object)`, with IRIs, blank nodes and literals written as in the RDF table above. N3 integers and decimals become eyemind numbers; float and double literals retain their RDF datatype, including numbers written with an exponent. Decimals use binary64 storage; `math:sum` adds their canonical decimal values before rounding its result. `=>` becomes `implies`, `<=` becomes `implied_by`, `{ ... } => false` becomes `contradiction`, and scoped negation and collection become `not` and `findall`, so an N3 run has a proof that eyemind checks like any other. Derived rules can trigger inference fuses too.
207
+
208
+ Scoped calls can use formulas supplied by the document's stated lists, including RDF collections written with `rdf:first` and `rdf:rest`. These calls are specialized before reasoning so their dependencies remain available for stratification and proof checking; formulas constructed only during reasoning are not supported by this compilation.
209
+
210
+ The documents `log:semantics`, `log:semanticsOrError` and `log:content` name are read before compiling. The command reads local files and HTTP(S) documents, with a ten-second fetch timeout and a 16 MiB response limit. The library uses the host callbacks `readFile(path)` and `readDocument(iri)`; without them it does not read external documents. Their contents become facts of the compiled program, which can be saved with `--program` for later proof checking.
207
211
 
208
212
  Five examples pair the original N3 with a compiled JavaScript program:
209
213
  [family queries](https://eyereasoner.github.io/eyemind/examples/deck/n3-family),
@@ -217,7 +221,7 @@ any remaining obligations.
217
221
 
218
222
  ### SPARQL 1.2 RL
219
223
 
220
- A file ending in `.srl` is a [SPARQL 1.2 RL](https://www.w3.org/TR/sparql12-rl/) rule set, read with [eyeleng](https://github.com/eyereasoner/eyeleng)'s parser and analysis: eyemind compiles it into a program, with the SPARQL functions and aggregates it uses written as eyemind rules, and RDF data files given with it are its base graph. The result is the inference graph, as Turtle:
224
+ A file ending in `.srl` is a [SPARQL 1.2 RL](https://www.w3.org/TR/sparql12-rl/) rule set: eyemind parses and analyzes it, then compiles it into a program, with the SPARQL functions and aggregates it uses written as eyemind rules, and RDF data files given with it are its base graph. The result is the inference graph, as Turtle:
221
225
 
222
226
  ```sh
223
227
  eyemind rules.srl facts.ttl # the inference graph as Turtle
@@ -397,17 +401,21 @@ npm test -- -k skolem # only tests whose line co
397
401
  EYEMIND_PROPERTY_SCALE=20 npm test -- -k properties # deeper generated tests
398
402
  node tools/update-examples.js # regenerate example artifacts after an intended change
399
403
  node tools/report.js # the table npm test ends with, into REPORT.md
404
+ node tools/notation3tests.js # the saved Notation3 suite, without network access
405
+ node tools/sync-notation3tests.js # refresh its tests and document fixtures from upstream
400
406
  node conformance/run.js --command "my-eyemind" # run the conformance suite against another implementation
401
407
  ```
402
408
 
403
409
  The full suite needs a few GB of memory; on a small machine run it under a cap, such as `systemd-run --user --scope -q -p MemoryMax=3G -p MemorySwapMax=0 -- npm test`. Generated tests forge saved proofs at random and require the checker to reject every forgery that claims more than the program entails. The playground tests need Chrome (`CHROME` names it). When adding an example, register it in [examples/manifest.json](https://github.com/eyereasoner/eyemind/blob/main/examples/manifest.json), write its deck in `examples/deck/`, and generate its artifacts.
404
410
 
411
+ The [Notation3 mirror](test/notation3tests/README.md) pins the upstream tests and their remote document inputs. Ordinary runs use those fixtures, with no network fallback. The sync command refreshes them for review; the scorer's `--live` option checks the current remote resources instead.
412
+
405
413
  ### Releases
406
414
 
407
415
  `./release patch "Describe the changes"` (or `minor`, `major`) requires a clean tree, pulls `main`, runs the tests, bumps the version, and pushes `main` with an annotated tag. The tag creates the GitHub release, which Zenodo archives, and publishes to npm through trusted publishing, with no stored token. To publish an existing tag again, use **Actions → Publish to npm → Run workflow**.
408
416
 
409
417
  ## The name
410
418
 
411
- **eyemind** joins *eye*, after the [EYE](https://github.com/eyereasoner/eye) family of reasoners, to *mind*: facts and rules lead to conclusions whose reasoning can be inspected and checked.
419
+ **eyemind** joins *eye* and *mind*: facts and rules lead to conclusions whose reasoning can be inspected and checked.
412
420
 
413
421
  MIT licensed; see [LICENSE.md](LICENSE.md).
package/SPEC.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ```text
4
4
  Title: The eyemind Rule Language and Proof Format
5
- Version: eyemind 0.5.2
5
+ Version: eyemind 0.5.3
6
6
  ```
7
7
 
8
8
  This document specifies the syntax and meaning of eyemind programs and data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyemind",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "A dependency-free JavaScript rule language with forward and backward reasoning and checkable proofs.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/formats.js CHANGED
@@ -64,7 +64,7 @@ function load(inputs, io, { base = null }) {
64
64
  if (kinds.includes('n3')) {
65
65
  if (kinds.includes('js')) throw new EyemindError('an N3 run takes .n3 documents and RDF data, not JavaScript programs');
66
66
  const sources = inputs.map(([t, n], k) => (kinds[k] === 'rdf' ? rdf(t, n, k) : [t, n]));
67
- const compiled = compileSources(sources, { base: base ?? '', baseOf: (n) => baseOf(n) ?? '', readFile: io?.readFile ?? null,
67
+ const compiled = compileSources(sources, { base: base ?? '', baseOf: (n) => baseOf(n) ?? '', readFile: io?.readFile ?? null, readDocument: io?.readDocument ?? null,
68
68
  source: inputs.map(([, n]) => n).join(', ') });
69
69
  return { kind: 'n3', program: loadSources([[compiled.program, inputs[kinds.indexOf('n3')][1]]], io), text: compiled.program, prefixes: compiled.doc.prefixes, compiled };
70
70
  }
@@ -20,11 +20,17 @@ const NUMERIC_TYPES = ['integer', 'decimal', 'double', 'float', 'int', 'long', '
20
20
 
21
21
  // Helpers shared by the built-ins.
22
22
  export const HELPERS = {
23
+ n3_fuse: {
24
+ text: `contradiction(n3_fuse(literal('false', datatype('${XSD}boolean'))))`,
25
+ },
23
26
  n3_num: {
24
27
  text: `
25
28
  // n3_num(T, N): N is the numeric value of the term T.
26
29
  implied_by(n3_num(T, N), [is_number(T), unify(N, T)])
27
- implied_by(n3_num(T, N), [is_compound(T), unify(T, literal(L, datatype(D))), n3_numeric_type(D), atom_chars(L, Cs), number_chars(N, Cs)])
30
+ implied_by(n3_num(T, N), [is_compound(T), unify(T, literal(L, datatype(D))), n3_numeric_type(D), atom_chars(L, Cs), number_chars(V, Cs), n3_numeric_value(D, V, N)])
31
+ implied_by(n3_numeric_value(D, V, N), [n3_floating_type(D), is(N, float(V))])
32
+ implied_by(n3_numeric_value(D, V, V), not(n3_floating_type(D)))
33
+ fact(n3_floating_type('${XSD}decimal'), n3_floating_type('${XSD}double'), n3_floating_type('${XSD}float'))
28
34
  ${NUMERIC_TYPES.map((t) => `fact(n3_numeric_type('${XSD}${t}'))`).join('\n')}`,
29
35
  },
30
36
  n3_nums: {
@@ -34,6 +40,15 @@ ${NUMERIC_TYPES.map((t) => `fact(n3_numeric_type('${XSD}${t}'))`).join('\n')}`,
34
40
  implied_by(n3_nums(L, Ns), [is_nonvar(L), n3_nums_(L, Ns)])
35
41
  fact(n3_nums_([], []))
36
42
  implied_by(n3_nums_([T, ...R], [N, ...Ns]), [n3_num(T, N), n3_nums_(R, Ns)])`,
43
+ },
44
+ n3_decimal: {
45
+ text: `
46
+ // A decimal's canonical text as an integer coefficient and a power of ten.
47
+ implied_by(n3_decimal(N, I, E), [number_chars(N, Cs), atom_chars(A, Cs), regex_find('^([+-]?)([0-9]+)(?:[.]([0-9]+))?(?:e([+-]?[0-9]+))?$', A, [_, Sign, Whole, Frac, Exp]), atom_concat(Sign, Whole, W), atom_concat(W, Frac, Digits), atom_chars(Digits, Ds), number_chars(I, Ds), atom_length(Frac, D), n3_decimal_exp(Exp, X), is(E, sub(X, D))])
48
+ fact(n3_decimal_exp('', 0))
49
+ implied_by(n3_decimal_exp(A, E), [not_identical(A, ''), atom_chars(A, Cs), number_chars(E, Cs)])
50
+ implied_by(n3_decimal_add(I, E, J, F, K, G), [is(G, min(E, F)), is(K, add(mul(I, pow(10, sub(E, G))), mul(J, pow(10, sub(F, G)))))])
51
+ implied_by(n3_decimal_value(I, E, N), [number_chars(I, Cs), atom_chars(A, Cs), number_chars(E, Es), atom_chars(B, Es), atom_concat(A, 'e', P), atom_concat(P, B, T), atom_chars(T, Ts), number_chars(N, Ts)])`,
37
52
  },
38
53
  n3_result: {
39
54
  needs: ['n3_num'],
@@ -72,6 +87,10 @@ implied_by(n3_float_text('no', T, A), [number_chars(T, Cs), atom_chars(A, Cs)])`
72
87
  implied_by(n3_strs(L, As), [is_nonvar(L), n3_strs_(L, As)])
73
88
  fact(n3_strs_([], []))
74
89
  implied_by(n3_strs_([T, ...R], [A, ...As]), [n3_str(T, A), n3_strs_(R, As)])`,
90
+ },
91
+ n3_pattern: {
92
+ text: `
93
+ implied_by(n3_regex_pattern(A, P), once(or(n3_pattern(A, P), unify(A, P))))`,
75
94
  },
76
95
  n3_str_result: {
77
96
  needs: ['n3_str'],
@@ -283,19 +302,27 @@ BUILTINS.get(`${MATH}exponentiation`).text = BUILTINS.get(`${MATH}exponentiation
283
302
  '[n3_num(A, X), n3_num(B, Y)', '[is_nonvar(B), n3_num(A, X), n3_num(B, Y)');
284
303
 
285
304
  def(`${MATH}sum`, 'n3_math_sum', `
286
- implied_by(n3_math_sum(L, O), [n3_nums(L, Ns), n3_sum(Ns, 0, V), n3_result(V, O)])
287
- // From the left, so floats round as they do written out: ((a + b) + c).
305
+ implied_by(n3_math_sum(L, O), [n3_nums(L, Ns), n3_sum_kind(L, K), n3_sum_value(K, Ns, V), n3_result(V, O)])
306
+ // Decimal inputs add integer coefficients; float and double use binary64.
307
+ implied_by(n3_sum_kind(L, K), once(or(and(n3_member(literal(_, datatype(D)), L), or(unify(D, '${XSD}float'), unify(D, '${XSD}double')), unify(K, 'binary')), unify(K, 'decimal'))))
308
+ implied_by(n3_sum_value('binary', Ns, V), n3_sum(Ns, 0, V))
309
+ implied_by(n3_sum_value('decimal', Ns, V), [n3_decimal_sum(Ns, 0, 0, I, E), n3_sum_result(Ns, I, E, V)])
310
+ fact(n3_decimal_sum([], I, E, I, E))
311
+ implied_by(n3_decimal_sum([N, ...Ns], I, E, J, F), [n3_decimal(N, K, G), n3_decimal_add(I, E, K, G, A, B), n3_decimal_sum(Ns, A, B, J, F)])
312
+ implied_by(n3_sum_result(Ns, I, E, V), [once(or(and(n3_member(N, Ns), is_float(N), unify(K, 'float')), unify(K, 'int'))), n3_sum_number(K, I, E, V)])
313
+ implied_by(n3_sum_number('int', I, E, V), is(V, mul(I, pow(10, E))))
314
+ implied_by(n3_sum_number('float', I, E, V), n3_decimal_value(I, E, V))
288
315
  fact(n3_sum([], V, V))
289
316
  implied_by(n3_sum([N], 0, N), 'true')
290
317
  implied_by(n3_sum([N, M, ...R], 0, V), [is(A, add(N, M)), n3_sum(R, A, V)])
291
- implied_by(n3_sum([N, ...R], A, V), [not_identical(A, 0), is(B, add(A, N)), n3_sum(R, B, V)])`, ['n3_nums', 'n3_result']);
318
+ implied_by(n3_sum([N, ...R], A, V), [not_identical(A, 0), is(B, add(A, N)), n3_sum(R, B, V)])`, ['n3_nums', 'n3_result', 'n3_member', 'n3_decimal']);
292
319
  def(`${MATH}product`, 'n3_math_product', `
293
320
  implied_by(n3_math_product(L, O), [n3_nums(L, [N, ...Ns]), n3_product(Ns, N, V), n3_result(V, O)])
294
321
  implied_by(n3_math_product([], O), n3_result(1, O))
295
322
  fact(n3_product([], V, V))
296
323
  implied_by(n3_product([N, ...R], A, V), [is(B, mul(A, N)), n3_product(R, B, V)])`, ['n3_nums', 'n3_result']);
297
324
  def(`${MATH}quotient`, 'n3_math_quotient', `
298
- // Integers that divide exactly give an integer, as in EYE.
325
+ // Integers that divide exactly give an integer.
299
326
  implied_by(n3_math_quotient([A, B], O), [n3_num(A, X), n3_num(B, Y), ne(Y, 0), n3_quotient(X, Y, V), n3_result(V, O)])
300
327
  implied_by(n3_quotient(X, Y, V), [is_int(X), is_int(Y), eq(mod(X, Y), 0), is(V, floordiv(X, Y))])
301
328
  implied_by(n3_quotient(X, Y, V), [not(and(is_int(X), is_int(Y), eq(mod(X, Y), 0))), is(V, div(X, Y))])`, ['n3_num', 'n3_result']);
@@ -359,13 +386,13 @@ def(`${STRING}notMatches`, 'n3_string_notMatches', `
359
386
  implied_by(n3_string_notMatches(S, O), [n3_str(S, A), n3_str(O, P), not(regex_match(P, A))])`, ['n3_str']);
360
387
  def(`${STRING}replace`, 'n3_string_replace', `
361
388
  // (Text Pattern Replacement) string:replace Result, every match replaced.
362
- implied_by(n3_string_replace([S, P0, R0], O), [n3_str(S, A), n3_str(P0, P), n3_str(R0, R), atom_chars(R, Cs), n3_replacement(Cs, Ds), atom_chars(D, Ds), regex_replace(P, A, D, B), n3_str_result(B, O)])
389
+ implied_by(n3_string_replace([S, P0, R0], O), [n3_str(S, A), n3_str(P0, Raw), n3_regex_pattern(Raw, P), n3_str(R0, R), atom_chars(R, Cs), n3_replacement(Cs, Ds), atom_chars(D, Ds), regex_replace(P, A, D, B), n3_str_result(B, O)])
363
390
  // A backslash escapes a dollar sign or backslash in N3 replacements;
364
391
  // ECMAScript spells a literal dollar sign as $$.
365
392
  fact(n3_replacement([], []))
366
393
  implied_by(n3_replacement([${JSON.stringify('\\')}, '$', ...R], ['$', '$', ...U]), n3_replacement(R, U))
367
394
  implied_by(n3_replacement([${JSON.stringify('\\')}, ${JSON.stringify('\\')}, ...R], [${JSON.stringify('\\')}, ...U]), n3_replacement(R, U))
368
- implied_by(n3_replacement([C, ...R], [C, ...U]), [not_unify([C, ...R], [${JSON.stringify('\\')}, '$', ..._]), not_unify([C, ...R], [${JSON.stringify('\\')}, ${JSON.stringify('\\')}, ..._]), n3_replacement(R, U)])`, ['n3_str', 'n3_str_result']);
395
+ implied_by(n3_replacement([C, ...R], [C, ...U]), [not_unify([C, ...R], [${JSON.stringify('\\')}, '$', ..._]), not_unify([C, ...R], [${JSON.stringify('\\')}, ${JSON.stringify('\\')}, ..._]), n3_replacement(R, U)])`, ['n3_str', 'n3_str_result', 'n3_pattern']);
369
396
  def(`${STRING}scrape`, 'n3_string_scrape', `
370
397
  // (Text Pattern) string:scrape Group: the first group of the first match.
371
398
  implied_by(n3_string_scrape([S, P0], O), [n3_str(S, A), n3_str(P0, P), once(regex_find(P, A, [_, G, ..._])), n3_str_result(G, O)])`, ['n3_str', 'n3_str_result']);
@@ -568,16 +595,21 @@ implied_by(n3_log_dtlit([S, iri(D)], O), [is_nonvar(S), n3_str(S, A), n3_typed(A
568
595
  implied_by(n3_log_dtlit([L, D], O), [is_nonvar(O), n3_lit_parts(O, A, U), unify(L, literal(A, datatype('${XSD}string'))), unify(D, iri(U))])
569
596
  // xsd:integer, xsd:decimal and xsd:double with a valid lexical form are
570
597
  // numbers, as when they are read.
571
- implied_by(n3_typed(A, D, N), [n3_number_type(D, K), atom_chars(A, Cs), number_chars(N, Cs), n3_number_kind(N, K)])
598
+ implied_by(n3_typed(A, D, O), [n3_number_type(D, K), atom_chars(A, Cs), number_chars(N, Cs), n3_number_kind(N, K), n3_typed_number(K, A, D, N, O)])
572
599
  implied_by(n3_typed(A, D, literal(A, datatype(D))), not(and(n3_number_type(D, _1), atom_chars(A, _2), number_chars(_3, _2), n3_number_kind(_3, _1))))
573
- fact(n3_number_type('${XSD}integer', 'int'), n3_number_type('${XSD}decimal', 'float'), n3_number_type('${XSD}double', 'float'))
600
+ fact(n3_number_type('${XSD}integer', 'int'), n3_number_type('${XSD}decimal', 'float'), n3_number_type('${XSD}double', 'typed'), n3_number_type('${XSD}float', 'typed'))
574
601
  implied_by(n3_number_kind(N, 'int'), is_int(N))
575
602
  implied_by(n3_number_kind(N, 'float'), is_number(N))
603
+ implied_by(n3_number_kind(N, 'typed'), is_number(N))
604
+ implied_by(n3_typed_number('int', _, _, N, O), unify(N, O))
605
+ implied_by(n3_typed_number('float', _, _, N, O), [is(V, float(N)), unify(V, O)])
606
+ implied_by(n3_typed_number('typed', A, D, _, O), [is_var(O), unify(O, literal(A, datatype(D)))])
607
+ implied_by(n3_typed_number('typed', _, D, N, O), [is_nonvar(O), unify(O, literal(_, datatype(D))), n3_num(O, V), eq(N, V)])
576
608
  implied_by(n3_lit_parts(literal(A, datatype(U)), A, U), 'true')
577
609
  implied_by(n3_lit_parts(literal(A, lang(_)), A, '${RDF}langString'), 'true')
578
610
  implied_by(n3_lit_parts(literal(A, lang(_, _)), A, '${RDF}dirLangString'), 'true')
579
611
  implied_by(n3_lit_parts(N, A, '${XSD}integer'), [is_int(N), number_chars(N, Cs), atom_chars(A, Cs)])
580
- implied_by(n3_lit_parts(N, A, '${XSD}decimal'), [is_float(N), number_chars(N, Cs), atom_chars(A, Cs)])`, ['n3_str']);
612
+ implied_by(n3_lit_parts(N, A, '${XSD}decimal'), [is_float(N), number_chars(N, Cs), atom_chars(A, Cs)])`, ['n3_str', 'n3_num']);
581
613
  def(`${LOG}langlit`, 'n3_log_langlit', `
582
614
  // (Lexical Language) log:langlit Literal.
583
615
  implied_by(n3_log_langlit([S, T], O), [is_nonvar(S), n3_str(S, A), n3_str(T, L), unify(O, literal(A, lang(L)))])
@@ -4,7 +4,7 @@
4
4
  // a program names are read before compiling: every IRI written as the
5
5
  // subject of one of those built-ins. The compiled program states each one's
6
6
  // text, formula or error as facts, and reasoning stays a function of them.
7
- // Only local files are read, through the host's readFile.
7
+ // The host supplies file access and, optionally, HTTP document access.
8
8
  import { LOG } from './n3-parser.js';
9
9
 
10
10
  export const DOCUMENT_PREDICATES = new Set([`${LOG}semantics`, `${LOG}semanticsOrError`, `${LOG}content`]);
@@ -49,18 +49,27 @@ function named(triples, found) {
49
49
  }
50
50
 
51
51
  // Read the documents: a Map from IRI to { text } or { error }. readFile
52
- // reads a local path; without it, or for another IRI, the document is an
53
- // error, and the built-ins find nothing.
54
- export function readDocuments(iris, readFile = null) {
52
+ // reads a local path, readDocument an HTTP(S) IRI; a missing reader or a
53
+ // failed read becomes a dereference error for log:semanticsOrError.
54
+ export function readDocuments(iris, readFile = null, readDocument = null) {
55
55
  const documents = new Map();
56
+ const locations = new Map();
56
57
  for (const iri of iris) {
57
58
  const location = iri.replace(/#.*$/, '');
59
+ if (locations.has(location)) {
60
+ documents.set(iri, locations.get(location));
61
+ continue;
62
+ }
58
63
  try {
59
- if (!location.startsWith('file:') || !readFile) throw new Error('only local files are read');
60
- documents.set(iri, { text: readFile(decodeURIComponent(new URL(location).pathname)) });
64
+ let text;
65
+ if (location.startsWith('file:') && readFile) text = readFile(decodeURIComponent(new URL(location).pathname));
66
+ else if (/^https?:/.test(location) && readDocument) text = readDocument(location);
67
+ else throw new Error('no reader for this document');
68
+ documents.set(iri, { text });
61
69
  } catch (error) {
62
70
  documents.set(iri, { error: `${location}: ${error.message}` });
63
71
  }
72
+ locations.set(location, documents.get(iri));
64
73
  }
65
74
  return documents;
66
75
  }
package/src/n3-parser.js CHANGED
@@ -445,19 +445,21 @@ export function parseN3(src, { base = '' } = {}) {
445
445
 
446
446
  function numberTerm(text) {
447
447
  if (/^[+-]?[0-9]+$/.test(text)) return { t: 'int', v: BigInt(text) };
448
+ if (/[eE]/.test(text)) return { t: 'literal', v: String(Number(text)), dt: `${XSD}double` };
448
449
  return { t: 'float', v: Number(text) };
449
450
  }
450
451
 
451
452
  const INTEGER_TYPES = new Set(['integer']);
452
- const FLOAT_TYPES = new Set(['decimal', 'double', 'float']);
453
+ const FLOAT_TYPES = new Set(['decimal']);
453
454
 
454
- // A typed literal; xsd:integer, xsd:decimal and xsd:double with a valid
455
- // lexical form become numbers, as the N3 shorthands 1, 1.5 and 1.5e0 do.
455
+ // Native numbers represent integer and decimal. Float and double retain
456
+ // their datatype so triple matching and log:equalTo distinguish them.
456
457
  export function typedLiteral(text, dt) {
457
458
  if (dt.startsWith(XSD)) {
458
459
  const local = dt.slice(XSD.length);
459
460
  if (INTEGER_TYPES.has(local) && /^[+-]?[0-9]+$/.test(text)) return { t: 'int', v: BigInt(text) };
460
461
  if (FLOAT_TYPES.has(local) && /^[+-]?([0-9]+(\.[0-9]*)?|\.[0-9]+)([eE][+-]?[0-9]+)?$/.test(text)) return { t: 'float', v: Number(text) };
462
+ if ((local === 'double' || local === 'float') && Number.isFinite(Number(text)) && /^[+-]?([0-9]+(\.[0-9]*)?|\.[0-9]+)([eE][+-]?[0-9]+)?$/.test(text)) return { t: 'literal', v: String(Number(text)), dt };
461
463
  }
462
464
  return { t: 'literal', v: text, dt };
463
465
  }
package/src/n3-writer.js CHANGED
@@ -167,6 +167,10 @@ class Writer {
167
167
  const dt = annotation.args[0];
168
168
  if (dt === `${XSD}string`) return lex;
169
169
  if (dt === `${XSD}boolean` && (text === 'true' || text === 'false')) return text;
170
+ if (dt === `${XSD}double` && /^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/.test(text) && Number.isFinite(Number(text))) {
171
+ const number = floatText(Number(text));
172
+ return /e/.test(number) ? number : `${number}e0`;
173
+ }
170
174
  return `${lex}^^${this.iri(dt)}`;
171
175
  }
172
176
  throw new N3WriteError('a literal needs datatype(IRI) or lang(Tag)');
package/src/n3.js CHANGED
@@ -46,6 +46,7 @@ export function compileN3Document(doc, { source = 'input', documents = new Map()
46
46
  const rules = [];
47
47
  const needed = new Set();
48
48
  let queries = 0;
49
+ const values = [...SCOPED_OBJECT].some((p) => usesPredicate(doc.triples, p)) ? statedValues(doc.triples) : [];
49
50
  // Only a document that mentions rdf:first, rdf:rest or rdf:nil can write a
50
51
  // list out as triples, so only its built-ins read lists that way.
51
52
  const views = ['first', 'rest', 'nil'].some((name) => mentions(doc.triples, `${RDF_NS}${name}`));
@@ -60,17 +61,29 @@ export function compileN3Document(doc, { source = 'input', documents = new Map()
60
61
  // a rule predicate or a variable predicate can find.
61
62
  if (rulesAsTriples && RULE_PREDICATES.has(p) && isFormulaLike(triple.s) && isFormulaLike(triple.o)) facts.push(`fact(${new Context(false).rdf(triple)})`);
62
63
  if (p === `${LOG}implies` && isFormulaLike(triple.s) && isFormulaLike(triple.o)) {
63
- rules.push(compileRule(triple.s, triple.o, 'forward', needed, views));
64
+ rules.push(compileRule(triple.s, triple.o, 'forward', needed, views, values));
64
65
  } else if (p === `${LOG}impliedBy` && isFormulaLike(triple.s) && isFormulaLike(triple.o)) {
65
- rules.push(compileRule(triple.o, triple.s, 'backward', needed, views));
66
+ rules.push(compileRule(triple.o, triple.s, 'backward', needed, views, values));
66
67
  } else if (p === `${LOG}query` && isFormulaLike(triple.s) && isFormulaLike(triple.o)) {
67
68
  queries++;
68
- rules.push(compileRule(triple.s, triple.o, 'query', needed, views));
69
+ rules.push(compileRule(triple.s, triple.o, 'query', needed, views, values));
69
70
  } else {
70
71
  const ctx = new Context(false);
71
72
  facts.push(`fact(${ctx.rdf(triple)})`);
72
73
  }
73
74
  }
75
+ if (views) rules.push([
76
+ `implied_by(rdf([H, ..._], iri('${RDF_NS}first'), H), 'true')`,
77
+ `implied_by(rdf([_, ...T], iri('${RDF_NS}rest'), R), n3_list_rest(T, R))`,
78
+ `fact(n3_list_rest([], iri('${RDF_NS}nil')))`,
79
+ `implied_by(n3_list_rest([H, ...T], [H, ...T]), 'true')`,
80
+ ]);
81
+ // Patterns read from data need the same Unicode adaptation as patterns
82
+ // written directly in a premise. Keep the data itself unchanged.
83
+ for (const literal of [...REGEX_PATTERN.keys()].some((p) => needed.has(p)) ? allStrings(doc.triples) : []) {
84
+ const pattern = unicodePattern(literal.v);
85
+ if (pattern !== literal.v) facts.push(`fact(n3_pattern(${q(literal.v)}, ${q(pattern)}))`);
86
+ }
74
87
  // The documents log:semantics and log:content read, fetched beforehand.
75
88
  let documentNumber = 0;
76
89
  const fetchedFormulas = [];
@@ -217,6 +230,42 @@ function statedStrings(triples) {
217
230
  return [...found.values()];
218
231
  }
219
232
 
233
+ function allStrings(triples) {
234
+ const found = statedStrings(triples);
235
+ for (const x of triples) for (const t of [x.s, x.o]) {
236
+ if (t.t === 'graph') found.push(...allStrings(t.triples));
237
+ }
238
+ return found;
239
+ }
240
+
241
+ // Values stated as data, including RDF collections. Specializing a scoped
242
+ // call to these formulas keeps its calls visible to dependency analysis.
243
+ function statedValues(triples) {
244
+ const values = [];
245
+ const expand = (t, seen = new Set()) => {
246
+ if (t.t === 'list') return { ...t, items: t.items.map((x) => expand(x, seen)) };
247
+ if (t.t === 'iri' && t.v === `${RDF_NS}nil`) return { t: 'list', items: [] };
248
+ if (t.t !== 'bnode') return t;
249
+ const key = bnodeKey(t);
250
+ if (seen.has(key)) return t;
251
+ const same = (x) => x.s.t === 'bnode' && bnodeKey(x.s) === key && x.p.t === 'iri';
252
+ const first = triples.find((x) => same(x) && x.p.v === `${RDF_NS}first`);
253
+ const rest = triples.find((x) => same(x) && x.p.v === `${RDF_NS}rest`);
254
+ if (!first || !rest) return t;
255
+ const next = new Set([...seen, key]);
256
+ const tail = expand(rest.o, next);
257
+ return tail.t === 'list' ? { t: 'list', items: [expand(first.o, next), ...tail.items] } : t;
258
+ };
259
+ for (const x of triples) {
260
+ if (x.p.t === 'iri' && RULE_PREDICATES.has(x.p.v)) continue;
261
+ for (const t of [x.s, x.o]) {
262
+ const value = expand(t);
263
+ if (value.t === 'list') values.push({ term: t, value });
264
+ }
265
+ }
266
+ return values;
267
+ }
268
+
220
269
  // The formulas the document's own facts state, each once, outermost first.
221
270
  function statedFormulas(triples) {
222
271
  const found = [];
@@ -405,14 +454,14 @@ function takesList(p, position) {
405
454
  }
406
455
  const SCOPED_OBJECT = new Set([`${LOG}collectAllIn`, `${LOG}forAllIn`]);
407
456
 
408
- function compileRule(body, head, kind, needed, views = true) {
457
+ function compileRule(body, head, kind, needed, views = true, values = []) {
409
458
  const ctx = new Context(true);
410
459
  if (!isFormulaLike(body)) throw new N3CompileError('a rule premise must be a formula');
411
460
  const bodyTriples = triplesOf(body);
412
461
  const headKeys = keysOf(head);
413
462
  // A ?variable or blank node that stands only as the scope of a scoped
414
463
  // built-in means the whole store, as in ?SCOPE log:notIncludes { ... }.
415
- const scopes = scopeTerms(bodyTriples, headKeys);
464
+ const scopes = scopeTerms(bodyTriples, kind === 'backward' ? headKeys : new Set());
416
465
  const outside = (skip) => {
417
466
  const keys = new Set(headKeys);
418
467
  for (const x of bodyTriples) if (x !== skip) keysOfTriple(x, keys);
@@ -465,9 +514,21 @@ function compileRule(body, head, kind, needed, views = true) {
465
514
  return [`${neg ? 'n3_not_includes' : 'n3_includes'}(${ctx.term(x.s)}, graph([${x.o.triples.map((y) => ctx.rdf(y)).join(', ')}]))`];
466
515
  }
467
516
  if (SCOPED_OBJECT.has(p)) {
468
- // The formulas must be written in the rule: eyemind cannot call a
469
- // formula only known when the rule runs, so such a goal fails.
517
+ // A call supplied as data is specialized to the stated values. Its
518
+ // formulas then compile like formulas written directly in the rule.
470
519
  const count = p === `${LOG}forAllIn` ? 2 : 3;
520
+ if (x.s.t === 'var' || x.s.t === 'bnode') {
521
+ const call = ++listViews;
522
+ const branches = values.filter(({ value }) => value.items.length === count).map(({ term, value }, i) => {
523
+ // A quoted formula's blank nodes are local pattern variables.
524
+ const own = (t) => t.t === 'bnode' ? { ...t, scope: `call${call}.${i}.${t.scope}` }
525
+ : t.t === 'var' ? { ...t, v: `call${call}.${i}.${t.v}` }
526
+ : t.t === 'list' ? { ...t, items: t.items.map(own) }
527
+ : t.t === 'graph' ? { ...t, triples: t.triples.map((y) => ({ s: own(y.s), p: own(y.p), o: own(y.o) })) } : t;
528
+ return conj([`unify(${ctx.term(x.s)}, ${new Context(false).term(term)})`, ...goal({ ...x, s: own(value) }, negated)]);
529
+ });
530
+ return branches.length ? [`or(${branches.join(', ')})`] : ["'fail'"];
531
+ }
471
532
  if (x.s.t !== 'list' || x.s.items.length !== count || x.s.items[count === 2 ? 0 : 1].t !== 'graph' ||
472
533
  x.s.items[1].t !== 'graph') return ["'fail'"];
473
534
  closed++;
@@ -577,20 +638,26 @@ function compileRule(body, head, kind, needed, views = true) {
577
638
  // state rules in turn.
578
639
  function headTerm(h, k, captured = null) {
579
640
  const p = h.p.t === 'iri' ? h.p.v : null;
580
- if (k === 'forward' && (p === `${LOG}implies` || p === `${LOG}impliedBy`) && isFormulaLike(h.s) && isFormulaLike(h.o)) {
641
+ if (k === 'forward' && (p === `${LOG}implies` || p === `${LOG}impliedBy`) && isFormulaLike(h.s) &&
642
+ (isFormulaLike(h.o) || (p === `${LOG}implies` && h.o.t === 'var'))) {
581
643
  const [b, c] = p === `${LOG}implies` ? [h.s, h.o] : [h.o, h.s];
582
644
  const inner = conj(goals(triplesOf(b), false));
583
645
  const cs = triplesOf(c);
584
- if (cs.length === 0) throw new N3CompileError('a derived rule needs a conclusion');
585
646
  if (captured === null) {
586
647
  captured = new Set();
587
648
  for (const x of bodyTriples) if (!(BUILTINS.has(x.p.v) && unconstrained(x))) keysOfTriple(x, captured);
649
+ for (const key of scopes) captured.delete(key);
588
650
  }
589
651
  // The firing also concludes the rule as a triple, its own variables
590
652
  // quoted as qvar(Name) and qbnode(Label), as N3 reasoners report derived rules.
591
653
  ctx.quoted = new Set([...keysOfTriple(h)].filter((key) => !captured.has(key)));
592
654
  const asTriple = ctx.rdf(h);
593
655
  ctx.quoted = null;
656
+ if (p === `${LOG}implies` && (isFalse(c) || c.t === 'var')) {
657
+ needed.add('n3_fuse');
658
+ return [`implies(${inner}, n3_fuse(${ctx.term(c)}))`, asTriple];
659
+ }
660
+ if (cs.length === 0) return [asTriple];
594
661
  if (p === `${LOG}impliedBy`) return [...cs.map((y) => `implied_by(${ctx.rdf(y)}, ${inner})`), asTriple];
595
662
  const within = new Set(captured);
596
663
  keysOf(b, within);
@@ -697,9 +764,9 @@ function reorder(triples, outside, given) {
697
764
  return [...order, ...pending];
698
765
  }
699
766
 
700
- function scopeTerms(triples, headKeys) {
767
+ function scopeTerms(triples, given) {
701
768
  const candidates = new Map();
702
- const elsewhere = new Set(headKeys);
769
+ const elsewhere = new Set(given);
703
770
  for (const x of triples) {
704
771
  const p = x.p.t === 'iri' ? x.p.v : null;
705
772
  let scope = null;
@@ -746,9 +813,9 @@ export function readSources(sources, { base = '', baseOf = () => '' } = {}) {
746
813
 
747
814
  // A document's program: { program, documents }; readFile reads the
748
815
  // documents it names for log:semantics and log:content.
749
- export function compileSources(sources, { base = '', baseOf, readFile = null, source } = {}) {
816
+ export function compileSources(sources, { base = '', baseOf, readFile = null, readDocument = null, source } = {}) {
750
817
  const doc = readSources(sources, { base, baseOf });
751
- const documents = readDocuments(documentIris(doc.triples), readFile);
818
+ const documents = readDocuments(documentIris(doc.triples), readFile, readDocument);
752
819
  const { program } = compileN3Document(doc, { source: source ?? sourceNames(sources), documents });
753
820
  return { doc, program };
754
821
  }
@@ -772,8 +839,8 @@ export const N3_LIMITS = { maxDepth: 1000000, maxIterations: 100000, maxInferenc
772
839
  // Reason over N3 sources. Returns { n3, triples, contradiction, program,
773
840
  // result }; with proof, result.proof is eyemind's checked proof of the
774
841
  // compiled program.
775
- export function reasonN3(sources, { base = '', mode = 'new', strings = 'auto', limits = {}, proof = false, goals = [], readFile = null } = {}) {
776
- const { doc, program } = compileSources(sources, { base, readFile });
842
+ export function reasonN3(sources, { base = '', mode = 'new', strings = 'auto', limits = {}, proof = false, goals = [], readFile = null, readDocument = null } = {}) {
843
+ const { doc, program } = compileSources(sources, { base, readFile, readDocument });
777
844
  const result = run(loadText(program, 'compiled.js'), { ...N3_LIMITS, ...limits, proof, goals });
778
845
  return { ...answersToN3(doc, result.answers, { mode, strings }), program, result };
779
846
  }
package/src/node.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // What the program loader and the command line need from Node: files, and
2
2
  // syntax errors with their line.
3
3
  import { readFileSync } from 'node:fs';
4
+ import { spawnSync } from 'node:child_process';
4
5
  import { resolve } from 'node:path';
5
6
  import { pathToFileURL } from 'node:url';
6
7
  import vm from 'node:vm';
@@ -8,6 +9,38 @@ import { EyemindError } from './terms.js';
8
9
 
9
10
  export const nodeIO = {
10
11
  readFile: (path) => readFileSync(path, 'utf8'),
12
+ // The loader is synchronous. Fetch in a child before compilation, with
13
+ // bounds on its time and output; no I/O happens during proof checking.
14
+ readDocument(iri) {
15
+ if (!/^https?:/.test(iri)) throw new EyemindError('a remote document needs an HTTP or HTTPS IRI');
16
+ // The test suite pins remote inputs. A missing fixture is an error,
17
+ // so an offline run can never silently fall back to the network.
18
+ if (process.env.EYEMIND_N3_DOCUMENTS) {
19
+ const fixtures = JSON.parse(readFileSync(process.env.EYEMIND_N3_DOCUMENTS, 'utf8'));
20
+ const document = fixtures[iri.replace(/#.*$/, '')];
21
+ if (!document) throw new EyemindError(`no saved N3 document for ${iri}`);
22
+ if (document.error !== undefined) throw new EyemindError(document.error);
23
+ if (typeof document.text !== 'string') throw new EyemindError(`invalid saved N3 document for ${iri}`);
24
+ return document.text;
25
+ }
26
+ const child = spawnSync(process.execPath, ['--input-type=module', '-e', `
27
+ try {
28
+ const response = await fetch(process.argv[1], { signal: AbortSignal.timeout(10000) });
29
+ if (!response.ok) throw new Error('HTTP ' + response.status);
30
+ let size = 0;
31
+ for await (const chunk of response.body) {
32
+ size += chunk.byteLength;
33
+ if (size > 16 * 1024 * 1024) throw new Error('document exceeds 16 MiB');
34
+ process.stdout.write(chunk);
35
+ }
36
+ } catch (error) {
37
+ process.stderr.write(error.message);
38
+ process.exitCode = 1;
39
+ }
40
+ `, iri], { encoding: 'utf8', timeout: 11000, maxBuffer: 16 * 1024 * 1024 });
41
+ if (child.error || child.status !== 0) throw new EyemindError(child.error?.message ?? child.stderr.trim());
42
+ return child.stdout;
43
+ },
11
44
  // The base IRI of a file, against which its relative IRIs resolve.
12
45
  fileIri: (path) => (path === '<stdin>' ? null : pathToFileURL(resolve(path)).href),
13
46
  checkSyntax(source, filename) {
package/src/rdf-lexer.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Eyeling Reasoner — lexer
2
+ * eyemind: RDF lexer
3
3
  *
4
4
  * Tokenizer for the supported N3/Turtle-like syntax. Produces a token stream
5
- * consumed by lib/parser.js.
5
+ * consumed by rdf-parser.js.
6
6
  */
7
7
 
8
8
 
@@ -359,8 +359,7 @@ function stripQuotes(lex) {
359
359
  }
360
360
 
361
361
 
362
- // RDF/TriG compatibility is an opt-in syntax-normalization layer, not a new
363
- // reasoning model. Eyeling remains strict N3 by default and N3 internally:
362
+ // eyemind: RDF/TriG syntax is normalized to the parser's N3 representation:
364
363
  // - RDF 1.2 triple terms <<( s p o )>> become singleton graph terms { s p o }.
365
364
  // - TriG named graph blocks g { ... } become g log:nameOf { ... } .
366
365
  // - A top-level default graph block { ... } is unwrapped into ordinary triples.
@@ -389,7 +388,7 @@ const EYMSG = Object.freeze({
389
388
  function normalizeRdfCompatibility(inputText, { trig = false } = {}) {
390
389
  let text = String(inputText ?? '');
391
390
 
392
- // Fast path: most Eyeling inputs are ordinary N3 and do not need RDF/TriG
391
+ // eyemind: ordinary N3 input does not need RDF/TriG
393
392
  // surface-syntax normalization. Avoid scanning large files character-by-character
394
393
  // unless they actually contain RDF 1.2 triple terms, VERSION directives, or a
395
394
  // plausible top-level TriG named graph block.
package/src/rdf-parser.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Eyeling Reasoner — parser
2
+ * eyemind: RDF parser
3
3
  *
4
4
  * Parser for the supported N3 syntax. Turns tokens into the internal term and
5
5
  * formula representation used by the engine.
@@ -219,7 +219,7 @@ class Parser {
219
219
  backwardRules.push(this.annotateSourceOffset(this.makeRule(tr.s, tr.o, false), statementOffset));
220
220
  } else if (isLogQuery(tr.p) && tr.s instanceof GraphTerm && tr.o instanceof GraphTerm) {
221
221
  // Output-selection directive: { premise } log:query { conclusion }.
222
- // When present at top-level, eyeling prints only the instantiated conclusion
222
+ // eyemind: select only the instantiated conclusion
223
223
  // triples (unique) instead of all newly derived facts.
224
224
  logQueries.push(this.annotateSourceOffset(this.makeRule(tr.s, tr.o, true), statementOffset));
225
225
  } else {
@@ -772,7 +772,7 @@ class Parser {
772
772
  }
773
773
 
774
774
  // In standard N3, the right-hand side of a rule is a formula term.
775
- // Eyeling primarily supports an explicit quoted formula `{ ... }` (GraphTerm)
775
+ // eyemind: a conclusion can be an explicit quoted formula `{ ... }` (GraphTerm)
776
776
  // or the special literals true/false.
777
777
  //
778
778
  // However, some programs use a *variable* in rule head position to mean:
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Eyeling Reasoner — prelude
2
+ * eyemind: RDF terms and shared utilities
3
3
  *
4
4
  * Core data model and shared utilities: Term/Triple/Formula types, namespaces,
5
5
  * and prefix environment helpers used throughout the project.
@@ -73,8 +73,8 @@ function removeLastPathSegment(path) {
73
73
  }
74
74
 
75
75
  function removeDotSegments(path) {
76
- // RFC 3986 section 5.2.4. This deliberately avoids WHATWG URL parsing so
77
- // Eyeling preserves IRI spelling (for example, it does not add a trailing
76
+ // eyemind: use RFC 3986 section 5.2.4 instead of WHATWG URL parsing to
77
+ // preserve IRI spelling (for example, do not add a trailing
78
78
  // slash to `http://example.org`) while still normalizing `.` and `..` path
79
79
  // segments as required by section 5.2.2.
80
80
  let input = String(path || '');
@@ -400,7 +400,7 @@ class Blank extends Term {
400
400
  constructor(label, blankNodeKind = 'labeled') {
401
401
  super();
402
402
  this.label = label; // _:b1, etc.
403
- // EYE's log:rawType distinguishes source-labeled blank nodes (_:name)
403
+ // eyemind: log:rawType distinguishes source-labeled blank nodes (_:name)
404
404
  // from unlabeled blank nodes introduced by N3 syntax such as [] / [...].
405
405
  this.blankNodeKind = blankNodeKind === 'unlabeled' ? 'unlabeled' : 'labeled';
406
406
  Object.defineProperty(this, '__tid', {
package/src/rdf-rules.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Eyeling Reasoner — rules
2
+ * eyemind: RDF rule helpers
3
3
  *
4
4
  * Built-in rule helpers and utilities used by the engine. This is not the
5
5
  * inference engine itself, but shared rule-related machinery.
package/src/rdf-syntax.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // The RDF 1.2 grammars of Turtle, TriG, N-Triples and N-Quads, checked token
2
- // by token before eyeling's parser reads a document.
2
+ // by token before the parser reads a document.
3
3
  //
4
- // eyeling's parser reads N3, a superset of these formats, so on its own it
4
+ // The parser also reads N3, a superset of these formats, so on its own it
5
5
  // would accept what they forbid: N3 operators and formulas, ?variables,
6
6
  // keywords, unknown escapes, malformed names. This pass reads the document
7
7
  // with the formats' own token rules and the statement shapes the parser
package/src/rdf.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // RDF 1.2 in and out of eyemind: Turtle, TriG, N-Triples and N-Quads.
2
2
  //
3
- // Documents are read by eyeling's lexer and parser (rdf-lexer.js,
4
- // rdf-parser.js, rdf-prelude.js and rdf-rules.js) in its RDF mode, with the
5
- // surface checks eyeling applies for RDF 1.2 below. Each quad becomes the
6
- // eyemind term rdf(Subject, Predicate, Object, Graph):
3
+ // Documents are read by the RDF lexer and parser (rdf-lexer.js,
4
+ // rdf-parser.js, rdf-prelude.js and rdf-rules.js), with the RDF 1.2
5
+ // surface checks below. Each quad becomes an eyemind term
6
+ // rdf(Subject, Predicate, Object, Graph):
7
7
  //
8
8
  // IRI iri('https://example.org/a')
9
9
  // blank node bnode(Scope, Label), Scope naming the document
@@ -126,7 +126,7 @@ function convert(term, position, graph, state, list = true) {
126
126
  throw new SyntaxError(`${term?.constructor?.name ?? typeof term} is no RDF term`);
127
127
  }
128
128
 
129
- // A literal of eyeling's parser: its raw form is a quoted lexical form with a
129
+ // A parsed literal: its raw form is a quoted lexical form with a
130
130
  // language tag or datatype, or a bare number or boolean.
131
131
  function literalTerm(raw) {
132
132
  const text = String(raw);
@@ -169,7 +169,7 @@ export function rdfDocument(quads, name = 'rdf') {
169
169
  return quads.map(([s, p, o, g]) => write(st(name, s, p, o, g))).join('\n');
170
170
  }
171
171
 
172
- // eyeling's RDF 1.2 surface checks, which its parser leaves to a separate
172
+ // RDF 1.2 surface checks, which the parser leaves to a separate
173
173
  // pass: escaped surrogates, triple terms as subjects, and the stricter line
174
174
  // syntax of N-Triples and N-Quads.
175
175
  function assertRdf12SurfaceSyntax(text, format) {
@@ -1,5 +1,5 @@
1
1
 
2
- // The SPARQL 1.2 RL BuiltInCall names and arities, from eyeleng's src/builtins.js.
2
+ // eyemind: the SPARQL 1.2 RL BuiltInCall names and arities.
3
3
  // This table is intentionally shaped by the SPARQL 1.2 RL grammar production BuiltInCall.
4
4
  // Keys are the canonical spellings used by the draft; lookup is case-insensitive so examples
5
5
  // may use SPARQL-style uppercase or lowercase spellings while still being checked against the
package/src/srl.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // SPARQL 1.2 RL rule sets compiled to eyemind programs.
2
2
  //
3
- // Rule sets are read by eyeleng's tokenizer, parser and analysis (the
3
+ // Rule sets are read by the SRL tokenizer, parser and analysis (the
4
4
  // srl-*.js files): parsing gives the rule set's data blocks and rules, and the
5
5
  // analysis checks sequential variable scope and stratification by the
6
6
  // specification's open and closed dependencies.
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.5.2';
2
+ export const VERSION = '0.5.3';