eyeling 1.6.32 → 1.6.33

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.
Files changed (2) hide show
  1. package/eyeling.js +76 -78
  2. package/package.json +1 -1
package/eyeling.js CHANGED
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  /*
5
- * eyeling.js — a minimal Notation3 (N3) reasoner in JavaScript
5
+ * eyeling.js — A Notation3 (N3) reasoner in JavaScript
6
6
  *
7
7
  * High-level pipeline:
8
8
  * 1) Read an N3 file from disk.
@@ -273,7 +273,7 @@ class OpenListTerm extends Term {
273
273
  }
274
274
  }
275
275
 
276
- class FormulaTerm extends Term {
276
+ class GraphTerm extends Term {
277
277
  constructor(triples) {
278
278
  super();
279
279
  this.triples = triples; // Triple[]
@@ -891,7 +891,7 @@ function collectIrisInTerm(t) {
891
891
  for (const x of t.elems) out.push(...collectIrisInTerm(x));
892
892
  } else if (t instanceof OpenListTerm) {
893
893
  for (const x of t.prefix) out.push(...collectIrisInTerm(x));
894
- } else if (t instanceof FormulaTerm) {
894
+ } else if (t instanceof GraphTerm) {
895
895
  for (const tr of t.triples) {
896
896
  out.push(...collectIrisInTerm(tr.s));
897
897
  out.push(...collectIrisInTerm(tr.p));
@@ -909,7 +909,7 @@ function collectVarsInTerm(t, acc) {
909
909
  } else if (t instanceof OpenListTerm) {
910
910
  for (const x of t.prefix) collectVarsInTerm(x, acc);
911
911
  acc.add(t.tailVar);
912
- } else if (t instanceof FormulaTerm) {
912
+ } else if (t instanceof GraphTerm) {
913
913
  for (const tr of t.triples) {
914
914
  collectVarsInTerm(tr.s, acc);
915
915
  collectVarsInTerm(tr.p, acc);
@@ -940,7 +940,7 @@ function collectBlankLabelsInTerm(t, acc) {
940
940
  for (const x of t.elems) collectBlankLabelsInTerm(x, acc);
941
941
  } else if (t instanceof OpenListTerm) {
942
942
  for (const x of t.prefix) collectBlankLabelsInTerm(x, acc);
943
- } else if (t instanceof FormulaTerm) {
943
+ } else if (t instanceof GraphTerm) {
944
944
  for (const tr of t.triples) {
945
945
  collectBlankLabelsInTerm(tr.s, acc);
946
946
  collectBlankLabelsInTerm(tr.p, acc);
@@ -1059,9 +1059,9 @@ class Parser {
1059
1059
 
1060
1060
  // normalize explicit log:implies / log:impliedBy at top-level
1061
1061
  for (const tr of more) {
1062
- if (isLogImplies(tr.p) && tr.s instanceof FormulaTerm && tr.o instanceof FormulaTerm) {
1062
+ if (isLogImplies(tr.p) && tr.s instanceof GraphTerm && tr.o instanceof GraphTerm) {
1063
1063
  forwardRules.push(this.makeRule(tr.s, tr.o, true));
1064
- } else if (isLogImpliedBy(tr.p) && tr.s instanceof FormulaTerm && tr.o instanceof FormulaTerm) {
1064
+ } else if (isLogImpliedBy(tr.p) && tr.s instanceof GraphTerm && tr.o instanceof GraphTerm) {
1065
1065
  backwardRules.push(this.makeRule(tr.s, tr.o, false));
1066
1066
  } else {
1067
1067
  triples.push(tr);
@@ -1244,7 +1244,7 @@ class Parser {
1244
1244
  if (typ === 'Var') return new Var(val || '');
1245
1245
  if (typ === 'LParen') return this.parseList();
1246
1246
  if (typ === 'LBracket') return this.parseBlank();
1247
- if (typ === 'LBrace') return this.parseFormula();
1247
+ if (typ === 'LBrace') return this.parseGraph();
1248
1248
 
1249
1249
  throw new Error(`Unexpected term token: ${tok.toString()}`);
1250
1250
  }
@@ -1374,7 +1374,7 @@ class Parser {
1374
1374
  return new Blank(id);
1375
1375
  }
1376
1376
 
1377
- parseFormula() {
1377
+ parseGraph() {
1378
1378
  const triples = [];
1379
1379
  while (this.peek().typ !== 'RBrace') {
1380
1380
  const left = this.parseTerm();
@@ -1422,7 +1422,7 @@ class Parser {
1422
1422
  }
1423
1423
  }
1424
1424
  this.next(); // consume '}'
1425
- return new FormulaTerm(triples);
1425
+ return new GraphTerm(triples);
1426
1426
  }
1427
1427
 
1428
1428
  parsePredicateObjectList(subject) {
@@ -1514,7 +1514,7 @@ class Parser {
1514
1514
  }
1515
1515
 
1516
1516
  let rawPremise;
1517
- if (premiseTerm instanceof FormulaTerm) {
1517
+ if (premiseTerm instanceof GraphTerm) {
1518
1518
  rawPremise = premiseTerm.triples;
1519
1519
  } else if (premiseTerm instanceof Literal && premiseTerm.value === 'true') {
1520
1520
  rawPremise = [];
@@ -1523,7 +1523,7 @@ class Parser {
1523
1523
  }
1524
1524
 
1525
1525
  let rawConclusion;
1526
- if (conclTerm instanceof FormulaTerm) {
1526
+ if (conclTerm instanceof GraphTerm) {
1527
1527
  rawConclusion = conclTerm.triples;
1528
1528
  } else if (conclTerm instanceof Literal && conclTerm.value === 'false') {
1529
1529
  rawConclusion = [];
@@ -1566,11 +1566,11 @@ function liftBlankRuleVars(premise, conclusion) {
1566
1566
  t.tailVar,
1567
1567
  );
1568
1568
  }
1569
- if (t instanceof FormulaTerm) {
1569
+ if (t instanceof GraphTerm) {
1570
1570
  const triples = t.triples.map(
1571
1571
  (tr) => new Triple(convertTerm(tr.s, mapping, counter), convertTerm(tr.p, mapping, counter), convertTerm(tr.o, mapping, counter)),
1572
1572
  );
1573
- return new FormulaTerm(triples);
1573
+ return new GraphTerm(triples);
1574
1574
  }
1575
1575
  return t;
1576
1576
  }
@@ -1635,8 +1635,8 @@ function skolemizeTermForHeadBlanks(t, headBlankLabels, mapping, skCounter, firi
1635
1635
  );
1636
1636
  }
1637
1637
 
1638
- if (t instanceof FormulaTerm) {
1639
- return new FormulaTerm(
1638
+ if (t instanceof GraphTerm) {
1639
+ return new GraphTerm(
1640
1640
  t.triples.map((tr) => skolemizeTripleForHeadBlanks(tr, headBlankLabels, mapping, skCounter, firingKey, globalMap)),
1641
1641
  );
1642
1642
  }
@@ -1707,8 +1707,8 @@ function termsEqual(a, b) {
1707
1707
  return true;
1708
1708
  }
1709
1709
 
1710
- if (a instanceof FormulaTerm) {
1711
- return alphaEqFormulaTriples(a.triples, b.triples);
1710
+ if (a instanceof GraphTerm) {
1711
+ return alphaEqGraphTriples(a.triples, b.triples);
1712
1712
  }
1713
1713
 
1714
1714
  return false;
@@ -1775,8 +1775,8 @@ function termsEqualNoIntDecimal(a, b) {
1775
1775
  return true;
1776
1776
  }
1777
1777
 
1778
- if (a instanceof FormulaTerm) {
1779
- return alphaEqFormulaTriples(a.triples, b.triples);
1778
+ if (a instanceof GraphTerm) {
1779
+ return alphaEqGraphTriples(a.triples, b.triples);
1780
1780
  }
1781
1781
 
1782
1782
  return false;
@@ -1802,7 +1802,7 @@ function alphaEqVarName(x, y, vmap) {
1802
1802
  return true;
1803
1803
  }
1804
1804
 
1805
- function alphaEqTermInFormula(a, b, vmap, bmap) {
1805
+ function alphaEqTermInGraph(a, b, vmap, bmap) {
1806
1806
  // Blank nodes: renamable
1807
1807
  if (a instanceof Blank && b instanceof Blank) {
1808
1808
  const x = a.label;
@@ -1823,7 +1823,7 @@ function alphaEqTermInFormula(a, b, vmap, bmap) {
1823
1823
  if (a instanceof ListTerm && b instanceof ListTerm) {
1824
1824
  if (a.elems.length !== b.elems.length) return false;
1825
1825
  for (let i = 0; i < a.elems.length; i++) {
1826
- if (!alphaEqTermInFormula(a.elems[i], b.elems[i], vmap, bmap)) return false;
1826
+ if (!alphaEqTermInGraph(a.elems[i], b.elems[i], vmap, bmap)) return false;
1827
1827
  }
1828
1828
  return true;
1829
1829
  }
@@ -1831,27 +1831,25 @@ function alphaEqTermInFormula(a, b, vmap, bmap) {
1831
1831
  if (a instanceof OpenListTerm && b instanceof OpenListTerm) {
1832
1832
  if (a.prefix.length !== b.prefix.length) return false;
1833
1833
  for (let i = 0; i < a.prefix.length; i++) {
1834
- if (!alphaEqTermInFormula(a.prefix[i], b.prefix[i], vmap, bmap)) return false;
1834
+ if (!alphaEqTermInGraph(a.prefix[i], b.prefix[i], vmap, bmap)) return false;
1835
1835
  }
1836
1836
  // tailVar is a var-name string, so treat it as renamable too
1837
1837
  return alphaEqVarName(a.tailVar, b.tailVar, vmap);
1838
1838
  }
1839
1839
 
1840
1840
  // Nested formulas: compare with fresh maps (separate scope)
1841
- if (a instanceof FormulaTerm && b instanceof FormulaTerm) {
1842
- return alphaEqFormulaTriples(a.triples, b.triples);
1841
+ if (a instanceof GraphTerm && b instanceof GraphTerm) {
1842
+ return alphaEqGraphTriples(a.triples, b.triples);
1843
1843
  }
1844
1844
 
1845
1845
  return false;
1846
1846
  }
1847
1847
 
1848
- function alphaEqTripleInFormula(a, b, vmap, bmap) {
1849
- return (
1850
- alphaEqTermInFormula(a.s, b.s, vmap, bmap) && alphaEqTermInFormula(a.p, b.p, vmap, bmap) && alphaEqTermInFormula(a.o, b.o, vmap, bmap)
1851
- );
1848
+ function alphaEqTripleInGraph(a, b, vmap, bmap) {
1849
+ return alphaEqTermInGraph(a.s, b.s, vmap, bmap) && alphaEqTermInGraph(a.p, b.p, vmap, bmap) && alphaEqTermInGraph(a.o, b.o, vmap, bmap);
1852
1850
  }
1853
1851
 
1854
- function alphaEqFormulaTriples(xs, ys) {
1852
+ function alphaEqGraphTriples(xs, ys) {
1855
1853
  if (xs.length !== ys.length) return false;
1856
1854
  // Fast path: exact same sequence.
1857
1855
  if (triplesListEqual(xs, ys)) return true;
@@ -1870,7 +1868,7 @@ function alphaEqFormulaTriples(xs, ys) {
1870
1868
 
1871
1869
  const v2 = { ...vmap };
1872
1870
  const b2 = { ...bmap };
1873
- if (!alphaEqTripleInFormula(x, y, v2, b2)) continue;
1871
+ if (!alphaEqTripleInGraph(x, y, v2, b2)) continue;
1874
1872
 
1875
1873
  used[j] = true;
1876
1874
  if (step(i + 1, v2, b2)) return true;
@@ -1910,9 +1908,9 @@ function alphaEqTerm(a, b, bmap) {
1910
1908
  }
1911
1909
  return true;
1912
1910
  }
1913
- if (a instanceof FormulaTerm && b instanceof FormulaTerm) {
1911
+ if (a instanceof GraphTerm && b instanceof GraphTerm) {
1914
1912
  // formulas are alpha-equivalent up to var/blank renaming
1915
- return alphaEqFormulaTriples(a.triples, b.triples);
1913
+ return alphaEqGraphTriples(a.triples, b.triples);
1916
1914
  }
1917
1915
  return false;
1918
1916
  }
@@ -2220,30 +2218,30 @@ function containsVarTerm(t, v) {
2220
2218
  if (t instanceof Var) return t.name === v;
2221
2219
  if (t instanceof ListTerm) return t.elems.some((e) => containsVarTerm(e, v));
2222
2220
  if (t instanceof OpenListTerm) return t.prefix.some((e) => containsVarTerm(e, v)) || t.tailVar === v;
2223
- if (t instanceof FormulaTerm)
2221
+ if (t instanceof GraphTerm)
2224
2222
  return t.triples.some((tr) => containsVarTerm(tr.s, v) || containsVarTerm(tr.p, v) || containsVarTerm(tr.o, v));
2225
2223
  return false;
2226
2224
  }
2227
2225
 
2228
- function isGroundTermInFormula(t) {
2229
- // EYE-style: variables inside formula terms are treated as local placeholders,
2226
+ function isGroundTermInGraph(t) {
2227
+ // variables inside graph terms are treated as local placeholders,
2230
2228
  // so they don't make the *surrounding triple* non-ground.
2231
2229
  if (t instanceof OpenListTerm) return false;
2232
- if (t instanceof ListTerm) return t.elems.every((e) => isGroundTermInFormula(e));
2233
- if (t instanceof FormulaTerm) return t.triples.every((tr) => isGroundTripleInFormula(tr));
2230
+ if (t instanceof ListTerm) return t.elems.every((e) => isGroundTermInGraph(e));
2231
+ if (t instanceof GraphTerm) return t.triples.every((tr) => isGroundTripleInGraph(tr));
2234
2232
  // Iri/Literal/Blank/Var are all OK inside formulas
2235
2233
  return true;
2236
2234
  }
2237
2235
 
2238
- function isGroundTripleInFormula(tr) {
2239
- return isGroundTermInFormula(tr.s) && isGroundTermInFormula(tr.p) && isGroundTermInFormula(tr.o);
2236
+ function isGroundTripleInGraph(tr) {
2237
+ return isGroundTermInGraph(tr.s) && isGroundTermInGraph(tr.p) && isGroundTermInGraph(tr.o);
2240
2238
  }
2241
2239
 
2242
2240
  function isGroundTerm(t) {
2243
2241
  if (t instanceof Var) return false;
2244
2242
  if (t instanceof ListTerm) return t.elems.every((e) => isGroundTerm(e));
2245
2243
  if (t instanceof OpenListTerm) return false;
2246
- if (t instanceof FormulaTerm) return t.triples.every((tr) => isGroundTripleInFormula(tr));
2244
+ if (t instanceof GraphTerm) return t.triples.every((tr) => isGroundTripleInGraph(tr));
2247
2245
  return true;
2248
2246
  }
2249
2247
 
@@ -2262,7 +2260,7 @@ function skolemKeyFromTerm(t) {
2262
2260
  if (u instanceof Var) return ['V', u.name];
2263
2261
  if (u instanceof ListTerm) return ['List', u.elems.map(enc)];
2264
2262
  if (u instanceof OpenListTerm) return ['OpenList', u.prefix.map(enc), u.tailVar];
2265
- if (u instanceof FormulaTerm) return ['Formula', u.triples.map((tr) => [enc(tr.s), enc(tr.p), enc(tr.o)])];
2263
+ if (u instanceof GraphTerm) return ['Graph', u.triples.map((tr) => [enc(tr.s), enc(tr.p), enc(tr.o)])];
2266
2264
  return ['Other', String(u)];
2267
2265
  }
2268
2266
  return JSON.stringify(enc(t));
@@ -2320,8 +2318,8 @@ function applySubstTerm(t, s) {
2320
2318
  }
2321
2319
  }
2322
2320
 
2323
- if (t instanceof FormulaTerm) {
2324
- return new FormulaTerm(t.triples.map((tr) => applySubstTriple(tr, s)));
2321
+ if (t instanceof GraphTerm) {
2322
+ return new GraphTerm(t.triples.map((tr) => applySubstTriple(tr, s)));
2325
2323
  }
2326
2324
 
2327
2325
  return t;
@@ -2348,7 +2346,7 @@ function unifyOpenWithList(prefix, tailv, ys, subst) {
2348
2346
  return s2;
2349
2347
  }
2350
2348
 
2351
- function unifyFormulaTriples(xs, ys, subst) {
2349
+ function unifyGraphTriples(xs, ys, subst) {
2352
2350
  if (xs.length !== ys.length) return null;
2353
2351
 
2354
2352
  // Fast path: exact same sequence.
@@ -2490,10 +2488,10 @@ function unifyTermWithOptions(a, b, subst, opts) {
2490
2488
  return s2;
2491
2489
  }
2492
2490
 
2493
- // Formulas
2494
- if (a instanceof FormulaTerm && b instanceof FormulaTerm) {
2495
- if (alphaEqFormulaTriples(a.triples, b.triples)) return { ...subst };
2496
- return unifyFormulaTriples(a.triples, b.triples, subst);
2491
+ // Graphs
2492
+ if (a instanceof GraphTerm && b instanceof GraphTerm) {
2493
+ if (alphaEqGraphTriples(a.triples, b.triples)) return { ...subst };
2494
+ return unifyGraphTriples(a.triples, b.triples, subst);
2497
2495
  }
2498
2496
 
2499
2497
  return null;
@@ -3635,7 +3633,7 @@ function materializeRdfLists(triples, forwardRules, backwardRules) {
3635
3633
  });
3636
3634
  return changed ? new OpenListTerm(prefix, t.tailVar) : t;
3637
3635
  }
3638
- if (t instanceof FormulaTerm) {
3636
+ if (t instanceof GraphTerm) {
3639
3637
  for (const tr of t.triples) rewriteTriple(tr);
3640
3638
  return t;
3641
3639
  }
@@ -4726,8 +4724,8 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
4726
4724
  // fresh copy of the rule with fresh variable names
4727
4725
  const r = standardizeRule(r0, varGen);
4728
4726
 
4729
- const premF = new FormulaTerm(r.premise);
4730
- const concTerm = r0.isFuse ? internLiteral('false') : new FormulaTerm(r.conclusion);
4727
+ const premF = new GraphTerm(r.premise);
4728
+ const concTerm = r0.isFuse ? internLiteral('false') : new GraphTerm(r.conclusion);
4731
4729
 
4732
4730
  // unify subject with the premise formula
4733
4731
  let s2 = unifyTerm(goal.s, premF, subst);
@@ -4755,8 +4753,8 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
4755
4753
  const r = standardizeRule(r0, varGen);
4756
4754
 
4757
4755
  // For backward rules, r.conclusion is the head, r.premise is the body
4758
- const headF = new FormulaTerm(r.conclusion);
4759
- const bodyF = new FormulaTerm(r.premise);
4756
+ const headF = new GraphTerm(r.conclusion);
4757
+ const bodyF = new GraphTerm(r.premise);
4760
4758
 
4761
4759
  // unify subject with the head formula
4762
4760
  let s2 = unifyTerm(goal.s, headF, subst);
@@ -4772,16 +4770,16 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
4772
4770
  return results;
4773
4771
  }
4774
4772
 
4775
- // log:notIncludes (EYE-style: "not provable in scope")
4773
+ // log:notIncludes (not provable in scope)
4776
4774
  // Delay until we have a frozen scope snapshot to avoid early success.
4777
4775
  if (pv === LOG_NS + 'notIncludes') {
4778
- if (!(g.o instanceof FormulaTerm)) return [];
4776
+ if (!(g.o instanceof GraphTerm)) return [];
4779
4777
 
4780
4778
  let scopeFacts = null;
4781
4779
  let scopeBackRules = backRules;
4782
4780
 
4783
4781
  // If the subject is a formula, treat it as the concrete scope graph
4784
- if (g.s instanceof FormulaTerm) {
4782
+ if (g.s instanceof GraphTerm) {
4785
4783
  scopeFacts = g.s.triples.slice();
4786
4784
  ensureFactIndexes(scopeFacts);
4787
4785
  Object.defineProperty(scopeFacts, '__scopedSnapshot', { value: scopeFacts, enumerable: false, writable: true });
@@ -4800,12 +4798,12 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
4800
4798
  if (pv === LOG_NS + 'collectAllIn') {
4801
4799
  if (!(g.s instanceof ListTerm) || g.s.elems.length !== 3) return [];
4802
4800
  const [valueTempl, clauseTerm, listTerm] = g.s.elems;
4803
- if (!(clauseTerm instanceof FormulaTerm)) return [];
4801
+ if (!(clauseTerm instanceof GraphTerm)) return [];
4804
4802
 
4805
4803
  let scopeFacts = null;
4806
4804
  let scopeBackRules = backRules;
4807
4805
 
4808
- if (g.o instanceof FormulaTerm) {
4806
+ if (g.o instanceof GraphTerm) {
4809
4807
  scopeFacts = g.o.triples.slice();
4810
4808
  ensureFactIndexes(scopeFacts);
4811
4809
  Object.defineProperty(scopeFacts, '__scopedSnapshot', { value: scopeFacts, enumerable: false, writable: true });
@@ -4829,12 +4827,12 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
4829
4827
  if (pv === LOG_NS + 'forAllIn') {
4830
4828
  if (!(g.s instanceof ListTerm) || g.s.elems.length !== 2) return [];
4831
4829
  const [whereClause, thenClause] = g.s.elems;
4832
- if (!(whereClause instanceof FormulaTerm) || !(thenClause instanceof FormulaTerm)) return [];
4830
+ if (!(whereClause instanceof GraphTerm) || !(thenClause instanceof GraphTerm)) return [];
4833
4831
 
4834
4832
  let scopeFacts = null;
4835
4833
  let scopeBackRules = backRules;
4836
4834
 
4837
- if (g.o instanceof FormulaTerm) {
4835
+ if (g.o instanceof GraphTerm) {
4838
4836
  scopeFacts = g.o.triples.slice();
4839
4837
  ensureFactIndexes(scopeFacts);
4840
4838
  Object.defineProperty(scopeFacts, '__scopedSnapshot', { value: scopeFacts, enumerable: false, writable: true });
@@ -5174,7 +5172,7 @@ function standardizeRule(rule, gen) {
5174
5172
  if (newTail !== t.tailVar) changed = true;
5175
5173
  return changed ? new OpenListTerm(newXs, newTail) : t;
5176
5174
  }
5177
- if (t instanceof FormulaTerm) {
5175
+ if (t instanceof GraphTerm) {
5178
5176
  let changed = false;
5179
5177
  const triples2 = t.triples.map((tr) => {
5180
5178
  const s2 = renameTerm(tr.s, vmap, genArr);
@@ -5183,7 +5181,7 @@ function standardizeRule(rule, gen) {
5183
5181
  if (s2 !== tr.s || p2 !== tr.p || o2 !== tr.o) changed = true;
5184
5182
  return s2 === tr.s && p2 === tr.p && o2 === tr.o ? tr : new Triple(s2, p2, o2);
5185
5183
  });
5186
- return changed ? new FormulaTerm(triples2) : t;
5184
+ return changed ? new GraphTerm(triples2) : t;
5187
5185
  }
5188
5186
  return t;
5189
5187
  }
@@ -5238,7 +5236,7 @@ function gcCollectVarsInTerm(t, out) {
5238
5236
  out.add(t.tailVar);
5239
5237
  return;
5240
5238
  }
5241
- if (t instanceof FormulaTerm) {
5239
+ if (t instanceof GraphTerm) {
5242
5240
  for (const tr of t.triples) gcCollectVarsInTriple(tr, out);
5243
5241
  return;
5244
5242
  }
@@ -5500,15 +5498,15 @@ function forwardChain(facts, forwardRules, backRules) {
5500
5498
 
5501
5499
  const isFwRuleTriple =
5502
5500
  isLogImplies(instantiated.p) &&
5503
- ((instantiated.s instanceof FormulaTerm && instantiated.o instanceof FormulaTerm) ||
5504
- (instantiated.s instanceof Literal && instantiated.s.value === 'true' && instantiated.o instanceof FormulaTerm) ||
5505
- (instantiated.s instanceof FormulaTerm && instantiated.o instanceof Literal && instantiated.o.value === 'true'));
5501
+ ((instantiated.s instanceof GraphTerm && instantiated.o instanceof GraphTerm) ||
5502
+ (instantiated.s instanceof Literal && instantiated.s.value === 'true' && instantiated.o instanceof GraphTerm) ||
5503
+ (instantiated.s instanceof GraphTerm && instantiated.o instanceof Literal && instantiated.o.value === 'true'));
5506
5504
 
5507
5505
  const isBwRuleTriple =
5508
5506
  isLogImpliedBy(instantiated.p) &&
5509
- ((instantiated.s instanceof FormulaTerm && instantiated.o instanceof FormulaTerm) ||
5510
- (instantiated.s instanceof FormulaTerm && instantiated.o instanceof Literal && instantiated.o.value === 'true') ||
5511
- (instantiated.s instanceof Literal && instantiated.s.value === 'true' && instantiated.o instanceof FormulaTerm));
5507
+ ((instantiated.s instanceof GraphTerm && instantiated.o instanceof GraphTerm) ||
5508
+ (instantiated.s instanceof GraphTerm && instantiated.o instanceof Literal && instantiated.o.value === 'true') ||
5509
+ (instantiated.s instanceof Literal && instantiated.s.value === 'true' && instantiated.o instanceof GraphTerm));
5512
5510
 
5513
5511
  if (isFwRuleTriple || isBwRuleTriple) {
5514
5512
  if (!hasFactIndexed(facts, instantiated)) {
@@ -5520,14 +5518,14 @@ function forwardChain(facts, forwardRules, backRules) {
5520
5518
 
5521
5519
  // Promote rule-producing triples to live rules, treating literal true as {}.
5522
5520
  const left =
5523
- instantiated.s instanceof FormulaTerm
5521
+ instantiated.s instanceof GraphTerm
5524
5522
  ? instantiated.s.triples
5525
5523
  : instantiated.s instanceof Literal && instantiated.s.value === 'true'
5526
5524
  ? []
5527
5525
  : null;
5528
5526
 
5529
5527
  const right =
5530
- instantiated.o instanceof FormulaTerm
5528
+ instantiated.o instanceof GraphTerm
5531
5529
  ? instantiated.o.triples
5532
5530
  : instantiated.o instanceof Literal && instantiated.o.value === 'true'
5533
5531
  ? []
@@ -5651,7 +5649,7 @@ function termToN3(t, pref) {
5651
5649
  inside.push('?' + t.tailVar);
5652
5650
  return '(' + inside.join(' ') + ')';
5653
5651
  }
5654
- if (t instanceof FormulaTerm) {
5652
+ if (t instanceof GraphTerm) {
5655
5653
  let s = '{\n';
5656
5654
  for (const tr of t.triples) {
5657
5655
  let line = tripleToN3(tr, pref).trimEnd();
@@ -5786,7 +5784,9 @@ function printExplanation(df, prefixes) {
5786
5784
  function main() {
5787
5785
  // Drop "node" and script name; keep only user-provided args
5788
5786
  const argv = process.argv.slice(2);
5789
- const prog = String(process.argv[1] || 'eyeling').split(/[\/]/).pop();
5787
+ const prog = String(process.argv[1] || 'eyeling')
5788
+ .split(/[\/]/)
5789
+ .pop();
5790
5790
 
5791
5791
  function printHelp(toStderr = false) {
5792
5792
  const msg =
@@ -5800,12 +5800,11 @@ function main() {
5800
5800
  (toStderr ? console.error : console.log)(msg);
5801
5801
  }
5802
5802
 
5803
-
5804
5803
  // --------------------------------------------------------------------------
5805
5804
  // Global options
5806
5805
  // --------------------------------------------------------------------------
5807
5806
  // --help / -h: print help and exit
5808
- if (argv.includes('--help') || argv.includes('-h')) {
5807
+ if (argv.includes('--help') || argv.includes('-h')) {
5809
5808
  printHelp(false);
5810
5809
  process.exit(0);
5811
5810
  }
@@ -5818,7 +5817,6 @@ function main() {
5818
5817
 
5819
5818
  const showAst = argv.includes('--ast') || argv.includes('-a');
5820
5819
 
5821
-
5822
5820
  // --proof-comments / -p: enable proof explanations
5823
5821
  if (argv.includes('--proof-comments') || argv.includes('-p')) {
5824
5822
  proofCommentsEnabled = true;
@@ -5833,7 +5831,7 @@ function main() {
5833
5831
  // --------------------------------------------------------------------------
5834
5832
  // Positional args (the N3 file)
5835
5833
  // --------------------------------------------------------------------------
5836
- const positional = argv.filter((a) => !a.startsWith('-'));
5834
+ const positional = argv.filter((a) => !a.startsWith('-'));
5837
5835
  if (positional.length === 0) {
5838
5836
  // No args: show help like many CLI tools do.
5839
5837
  printHelp(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyeling",
3
- "version": "1.6.32",
3
+ "version": "1.6.33",
4
4
  "description": "A minimal Notation3 (N3) reasoner in JavaScript.",
5
5
  "main": "./index.js",
6
6
  "keywords": [