eyeling 1.7.12 → 1.7.14
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/eyeling.js +205 -35
- package/package.json +1 -1
package/eyeling.js
CHANGED
|
@@ -117,7 +117,8 @@ function __resolveBrowserUrl(ref) {
|
|
|
117
117
|
if (!ref) return ref;
|
|
118
118
|
// If already absolute, keep as-is.
|
|
119
119
|
if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(ref)) return ref;
|
|
120
|
-
const base =
|
|
120
|
+
const base =
|
|
121
|
+
(typeof document !== 'undefined' && document.baseURI) || (typeof location !== 'undefined' && location.href) || '';
|
|
121
122
|
try {
|
|
122
123
|
return new URL(ref, base).toString();
|
|
123
124
|
} catch {
|
|
@@ -131,7 +132,10 @@ function __fetchHttpTextSyncBrowser(url) {
|
|
|
131
132
|
const xhr = new XMLHttpRequest();
|
|
132
133
|
xhr.open('GET', url, false); // synchronous
|
|
133
134
|
try {
|
|
134
|
-
xhr.setRequestHeader(
|
|
135
|
+
xhr.setRequestHeader(
|
|
136
|
+
'Accept',
|
|
137
|
+
'text/n3, text/turtle, application/n-triples, application/n-quads, text/plain;q=0.1, */*;q=0.01',
|
|
138
|
+
);
|
|
135
139
|
} catch {
|
|
136
140
|
// Some environments restrict setting headers (ignore).
|
|
137
141
|
}
|
|
@@ -461,7 +465,21 @@ function utcIsoDateTimeStringFromEpochSeconds(sec) {
|
|
|
461
465
|
const s2 = d.getUTCSeconds();
|
|
462
466
|
const ms2 = d.getUTCMilliseconds();
|
|
463
467
|
const msPart = ms2 ? '.' + String(ms2).padStart(3, '0') : '';
|
|
464
|
-
return
|
|
468
|
+
return (
|
|
469
|
+
pad(year, 4) +
|
|
470
|
+
'-' +
|
|
471
|
+
pad(month) +
|
|
472
|
+
'-' +
|
|
473
|
+
pad(day) +
|
|
474
|
+
'T' +
|
|
475
|
+
pad(hour) +
|
|
476
|
+
':' +
|
|
477
|
+
pad(min) +
|
|
478
|
+
':' +
|
|
479
|
+
pad(s2) +
|
|
480
|
+
msPart +
|
|
481
|
+
'+00:00'
|
|
482
|
+
);
|
|
465
483
|
}
|
|
466
484
|
|
|
467
485
|
function getNowLex() {
|
|
@@ -499,7 +517,9 @@ function deterministicSkolemIdFromKey(key) {
|
|
|
499
517
|
const hex = [h1, h2, h3, h4].map((h) => h.toString(16).padStart(8, '0')).join(''); // 32 hex chars
|
|
500
518
|
|
|
501
519
|
// Format like a UUID: 8-4-4-4-12
|
|
502
|
-
return
|
|
520
|
+
return (
|
|
521
|
+
hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16) + '-' + hex.slice(16, 20) + '-' + hex.slice(20)
|
|
522
|
+
);
|
|
503
523
|
}
|
|
504
524
|
|
|
505
525
|
let runLocalTimeCache = null;
|
|
@@ -1904,7 +1924,12 @@ function liftBlankRuleVars(premise, conclusion) {
|
|
|
1904
1924
|
}
|
|
1905
1925
|
if (t instanceof GraphTerm) {
|
|
1906
1926
|
const triples = t.triples.map(
|
|
1907
|
-
(tr) =>
|
|
1927
|
+
(tr) =>
|
|
1928
|
+
new Triple(
|
|
1929
|
+
convertTerm(tr.s, mapping, counter),
|
|
1930
|
+
convertTerm(tr.p, mapping, counter),
|
|
1931
|
+
convertTerm(tr.o, mapping, counter),
|
|
1932
|
+
),
|
|
1908
1933
|
);
|
|
1909
1934
|
return new GraphTerm(triples);
|
|
1910
1935
|
}
|
|
@@ -1912,7 +1937,11 @@ function liftBlankRuleVars(premise, conclusion) {
|
|
|
1912
1937
|
}
|
|
1913
1938
|
|
|
1914
1939
|
function convertTriple(tr, mapping, counter) {
|
|
1915
|
-
return new Triple(
|
|
1940
|
+
return new Triple(
|
|
1941
|
+
convertTerm(tr.s, mapping, counter),
|
|
1942
|
+
convertTerm(tr.p, mapping, counter),
|
|
1943
|
+
convertTerm(tr.o, mapping, counter),
|
|
1944
|
+
);
|
|
1916
1945
|
}
|
|
1917
1946
|
|
|
1918
1947
|
const mapping = {};
|
|
@@ -1961,7 +1990,9 @@ function skolemizeTermForHeadBlanks(t, headBlankLabels, mapping, skCounter, firi
|
|
|
1961
1990
|
}
|
|
1962
1991
|
|
|
1963
1992
|
if (t instanceof ListTerm) {
|
|
1964
|
-
return new ListTerm(
|
|
1993
|
+
return new ListTerm(
|
|
1994
|
+
t.elems.map((e) => skolemizeTermForHeadBlanks(e, headBlankLabels, mapping, skCounter, firingKey, globalMap)),
|
|
1995
|
+
);
|
|
1965
1996
|
}
|
|
1966
1997
|
|
|
1967
1998
|
if (t instanceof OpenListTerm) {
|
|
@@ -1973,7 +2004,9 @@ function skolemizeTermForHeadBlanks(t, headBlankLabels, mapping, skCounter, firi
|
|
|
1973
2004
|
|
|
1974
2005
|
if (t instanceof GraphTerm) {
|
|
1975
2006
|
return new GraphTerm(
|
|
1976
|
-
t.triples.map((tr) =>
|
|
2007
|
+
t.triples.map((tr) =>
|
|
2008
|
+
skolemizeTripleForHeadBlanks(tr, headBlankLabels, mapping, skCounter, firingKey, globalMap),
|
|
2009
|
+
),
|
|
1977
2010
|
);
|
|
1978
2011
|
}
|
|
1979
2012
|
|
|
@@ -2182,7 +2215,11 @@ function alphaEqTermInGraph(a, b, vmap, bmap) {
|
|
|
2182
2215
|
}
|
|
2183
2216
|
|
|
2184
2217
|
function alphaEqTripleInGraph(a, b, vmap, bmap) {
|
|
2185
|
-
return
|
|
2218
|
+
return (
|
|
2219
|
+
alphaEqTermInGraph(a.s, b.s, vmap, bmap) &&
|
|
2220
|
+
alphaEqTermInGraph(a.p, b.p, vmap, bmap) &&
|
|
2221
|
+
alphaEqTermInGraph(a.o, b.o, vmap, bmap)
|
|
2222
|
+
);
|
|
2186
2223
|
}
|
|
2187
2224
|
|
|
2188
2225
|
function alphaEqGraphTriples(xs, ys) {
|
|
@@ -2504,7 +2541,12 @@ function isConstraintBuiltin(tr) {
|
|
|
2504
2541
|
}
|
|
2505
2542
|
|
|
2506
2543
|
// log: tests that are purely constraints (no new bindings)
|
|
2507
|
-
if (
|
|
2544
|
+
if (
|
|
2545
|
+
v === LOG_NS + 'forAllIn' ||
|
|
2546
|
+
v === LOG_NS + 'notEqualTo' ||
|
|
2547
|
+
v === LOG_NS + 'notIncludes' ||
|
|
2548
|
+
v === LOG_NS + 'outputString'
|
|
2549
|
+
) {
|
|
2508
2550
|
return true;
|
|
2509
2551
|
}
|
|
2510
2552
|
|
|
@@ -2717,13 +2759,19 @@ function unifyGraphTriples(xs, ys, subst) {
|
|
|
2717
2759
|
}
|
|
2718
2760
|
|
|
2719
2761
|
function unifyTerm(a, b, subst) {
|
|
2720
|
-
return unifyTermWithOptions(a, b, subst, {
|
|
2762
|
+
return unifyTermWithOptions(a, b, subst, {
|
|
2763
|
+
boolValueEq: true,
|
|
2764
|
+
intDecimalEq: false,
|
|
2765
|
+
});
|
|
2721
2766
|
}
|
|
2722
2767
|
|
|
2723
2768
|
function unifyTermListAppend(a, b, subst) {
|
|
2724
2769
|
// Keep list:append behavior: allow integer<->decimal exact equality,
|
|
2725
2770
|
// but do NOT add boolean-value equivalence (preserves current semantics).
|
|
2726
|
-
return unifyTermWithOptions(a, b, subst, {
|
|
2771
|
+
return unifyTermWithOptions(a, b, subst, {
|
|
2772
|
+
boolValueEq: false,
|
|
2773
|
+
intDecimalEq: true,
|
|
2774
|
+
});
|
|
2727
2775
|
}
|
|
2728
2776
|
|
|
2729
2777
|
function unifyTermWithOptions(a, b, subst, opts) {
|
|
@@ -3282,7 +3330,8 @@ function isQuotedLexical(lex) {
|
|
|
3282
3330
|
// long: """...""" or '''...'''
|
|
3283
3331
|
if (typeof lex !== 'string') return false;
|
|
3284
3332
|
const n = lex.length;
|
|
3285
|
-
if (n >= 6 && ((lex.startsWith('"""') && lex.endsWith('"""')) || (lex.startsWith("'''") && lex.endsWith("'''"))))
|
|
3333
|
+
if (n >= 6 && ((lex.startsWith('"""') && lex.endsWith('"""')) || (lex.startsWith("'''") && lex.endsWith("'''"))))
|
|
3334
|
+
return true;
|
|
3286
3335
|
if (n >= 2) {
|
|
3287
3336
|
const a = lex[0];
|
|
3288
3337
|
const b = lex[n - 1];
|
|
@@ -3493,7 +3542,7 @@ function parseXsdDatetimeTerm(t) {
|
|
|
3493
3542
|
|
|
3494
3543
|
function parseXsdDateTimeLexParts(t) {
|
|
3495
3544
|
// Parse *lexical* components of an xsd:dateTime literal without timezone normalization.
|
|
3496
|
-
// Returns { yearStr, month, day, minute, second, tz } or null.
|
|
3545
|
+
// Returns { yearStr, month, day, hour, minute, second, tz } or null.
|
|
3497
3546
|
if (!(t instanceof Literal)) return null;
|
|
3498
3547
|
const [lex, dt] = literalParts(t.value);
|
|
3499
3548
|
if (dt !== XSD_NS + 'dateTime') return null;
|
|
@@ -3506,16 +3555,18 @@ function parseXsdDateTimeLexParts(t) {
|
|
|
3506
3555
|
const yearStr = m[1];
|
|
3507
3556
|
const month = parseInt(m[2], 10);
|
|
3508
3557
|
const day = parseInt(m[3], 10);
|
|
3558
|
+
const hour = parseInt(m[4], 10);
|
|
3509
3559
|
const minute = parseInt(m[5], 10);
|
|
3510
3560
|
const second = parseInt(m[6], 10);
|
|
3511
3561
|
const tz = m[7] || null;
|
|
3512
3562
|
|
|
3513
3563
|
if (!(month >= 1 && month <= 12)) return null;
|
|
3514
3564
|
if (!(day >= 1 && day <= 31)) return null;
|
|
3565
|
+
if (!(hour >= 0 && hour <= 23)) return null;
|
|
3515
3566
|
if (!(minute >= 0 && minute <= 59)) return null;
|
|
3516
3567
|
if (!(second >= 0 && second <= 59)) return null;
|
|
3517
3568
|
|
|
3518
|
-
return { yearStr, month, day, minute, second, tz };
|
|
3569
|
+
return { yearStr, month, day, hour, minute, second, tz };
|
|
3519
3570
|
}
|
|
3520
3571
|
|
|
3521
3572
|
function parseDatetimeLike(t) {
|
|
@@ -3562,7 +3613,13 @@ function parseIso8601DurationToSeconds(s) {
|
|
|
3562
3613
|
}
|
|
3563
3614
|
|
|
3564
3615
|
const totalDays =
|
|
3565
|
-
years * 365.2425 +
|
|
3616
|
+
years * 365.2425 +
|
|
3617
|
+
months * 30.436875 +
|
|
3618
|
+
weeks * 7.0 +
|
|
3619
|
+
days +
|
|
3620
|
+
hours / 24.0 +
|
|
3621
|
+
minutes / (24.0 * 60.0) +
|
|
3622
|
+
seconds / (24.0 * 3600.0);
|
|
3566
3623
|
|
|
3567
3624
|
return totalDays * 86400.0;
|
|
3568
3625
|
}
|
|
@@ -4634,6 +4691,32 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
|
|
|
4634
4691
|
return s2 !== null ? [s2] : [];
|
|
4635
4692
|
}
|
|
4636
4693
|
|
|
4694
|
+
// time:hour
|
|
4695
|
+
// Gets as object the integer hour component of the subject xsd:dateTime.
|
|
4696
|
+
// Schema: $s+ time:hour $o-
|
|
4697
|
+
if (pv === TIME_NS + 'hour') {
|
|
4698
|
+
const parts = parseXsdDateTimeLexParts(g.s);
|
|
4699
|
+
if (!parts) return [];
|
|
4700
|
+
const out = internLiteral(String(parts.hour));
|
|
4701
|
+
|
|
4702
|
+
if (g.o instanceof Var) {
|
|
4703
|
+
const s2 = { ...subst };
|
|
4704
|
+
s2[g.o.name] = out;
|
|
4705
|
+
return [s2];
|
|
4706
|
+
}
|
|
4707
|
+
if (g.o instanceof Blank) return [{ ...subst }];
|
|
4708
|
+
|
|
4709
|
+
const oi = parseIntLiteral(g.o);
|
|
4710
|
+
if (oi !== null) {
|
|
4711
|
+
try {
|
|
4712
|
+
if (oi === BigInt(parts.hour)) return [{ ...subst }];
|
|
4713
|
+
} catch {}
|
|
4714
|
+
}
|
|
4715
|
+
|
|
4716
|
+
const s2 = unifyTerm(g.o, out, subst);
|
|
4717
|
+
return s2 !== null ? [s2] : [];
|
|
4718
|
+
}
|
|
4719
|
+
|
|
4637
4720
|
// time:minute
|
|
4638
4721
|
// Gets as object the integer minutes component of the subject xsd:dateTime.
|
|
4639
4722
|
// Schema: $s+ time:minute $o-
|
|
@@ -5557,7 +5640,11 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
|
|
|
5557
5640
|
|
|
5558
5641
|
const scopeFacts = g.s.triples.slice();
|
|
5559
5642
|
ensureFactIndexes(scopeFacts);
|
|
5560
|
-
Object.defineProperty(scopeFacts, '__scopedSnapshot', {
|
|
5643
|
+
Object.defineProperty(scopeFacts, '__scopedSnapshot', {
|
|
5644
|
+
value: scopeFacts,
|
|
5645
|
+
enumerable: false,
|
|
5646
|
+
writable: true,
|
|
5647
|
+
});
|
|
5561
5648
|
|
|
5562
5649
|
const visited2 = [];
|
|
5563
5650
|
// Start from the incoming substitution so bindings flow outward.
|
|
@@ -5575,7 +5662,11 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
|
|
|
5575
5662
|
|
|
5576
5663
|
const scopeFacts = g.s.triples.slice();
|
|
5577
5664
|
ensureFactIndexes(scopeFacts);
|
|
5578
|
-
Object.defineProperty(scopeFacts, '__scopedSnapshot', {
|
|
5665
|
+
Object.defineProperty(scopeFacts, '__scopedSnapshot', {
|
|
5666
|
+
value: scopeFacts,
|
|
5667
|
+
enumerable: false,
|
|
5668
|
+
writable: true,
|
|
5669
|
+
});
|
|
5579
5670
|
|
|
5580
5671
|
const visited2 = [];
|
|
5581
5672
|
const sols = proveGoals(Array.from(g.o.triples), { ...subst }, scopeFacts, [], depth + 1, visited2, varGen);
|
|
@@ -5608,7 +5699,11 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
|
|
|
5608
5699
|
if (g.o instanceof GraphTerm) {
|
|
5609
5700
|
scopeFacts = g.o.triples.slice();
|
|
5610
5701
|
ensureFactIndexes(scopeFacts);
|
|
5611
|
-
Object.defineProperty(scopeFacts, '__scopedSnapshot', {
|
|
5702
|
+
Object.defineProperty(scopeFacts, '__scopedSnapshot', {
|
|
5703
|
+
value: scopeFacts,
|
|
5704
|
+
enumerable: false,
|
|
5705
|
+
writable: true,
|
|
5706
|
+
});
|
|
5612
5707
|
scopeBackRules = [];
|
|
5613
5708
|
} else {
|
|
5614
5709
|
scopeFacts = facts.__scopedSnapshot || null;
|
|
@@ -5621,7 +5716,15 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
|
|
|
5621
5716
|
}
|
|
5622
5717
|
|
|
5623
5718
|
const visited2 = [];
|
|
5624
|
-
const sols = proveGoals(
|
|
5719
|
+
const sols = proveGoals(
|
|
5720
|
+
Array.from(clauseTerm.triples),
|
|
5721
|
+
{},
|
|
5722
|
+
scopeFacts,
|
|
5723
|
+
scopeBackRules,
|
|
5724
|
+
depth + 1,
|
|
5725
|
+
visited2,
|
|
5726
|
+
varGen,
|
|
5727
|
+
);
|
|
5625
5728
|
|
|
5626
5729
|
const collected = sols.map((sBody) => applySubstTerm(valueTempl, sBody));
|
|
5627
5730
|
const collectedList = new ListTerm(collected);
|
|
@@ -5642,7 +5745,11 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
|
|
|
5642
5745
|
if (g.o instanceof GraphTerm) {
|
|
5643
5746
|
scopeFacts = g.o.triples.slice();
|
|
5644
5747
|
ensureFactIndexes(scopeFacts);
|
|
5645
|
-
Object.defineProperty(scopeFacts, '__scopedSnapshot', {
|
|
5748
|
+
Object.defineProperty(scopeFacts, '__scopedSnapshot', {
|
|
5749
|
+
value: scopeFacts,
|
|
5750
|
+
enumerable: false,
|
|
5751
|
+
writable: true,
|
|
5752
|
+
});
|
|
5646
5753
|
scopeBackRules = [];
|
|
5647
5754
|
} else {
|
|
5648
5755
|
scopeFacts = facts.__scopedSnapshot || null;
|
|
@@ -5650,11 +5757,27 @@ function evalBuiltin(goal, subst, facts, backRules, depth, varGen) {
|
|
|
5650
5757
|
}
|
|
5651
5758
|
|
|
5652
5759
|
const visited1 = [];
|
|
5653
|
-
const sols1 = proveGoals(
|
|
5760
|
+
const sols1 = proveGoals(
|
|
5761
|
+
Array.from(whereClause.triples),
|
|
5762
|
+
{},
|
|
5763
|
+
scopeFacts,
|
|
5764
|
+
scopeBackRules,
|
|
5765
|
+
depth + 1,
|
|
5766
|
+
visited1,
|
|
5767
|
+
varGen,
|
|
5768
|
+
);
|
|
5654
5769
|
|
|
5655
5770
|
for (const s1 of sols1) {
|
|
5656
5771
|
const visited2 = [];
|
|
5657
|
-
const sols2 = proveGoals(
|
|
5772
|
+
const sols2 = proveGoals(
|
|
5773
|
+
Array.from(thenClause.triples),
|
|
5774
|
+
s1,
|
|
5775
|
+
scopeFacts,
|
|
5776
|
+
scopeBackRules,
|
|
5777
|
+
depth + 1,
|
|
5778
|
+
visited2,
|
|
5779
|
+
varGen,
|
|
5780
|
+
);
|
|
5658
5781
|
if (!sols2.length) return [];
|
|
5659
5782
|
}
|
|
5660
5783
|
return [{ ...subst }];
|
|
@@ -6170,7 +6293,12 @@ function proveGoals(goals, subst, facts, backRules, depth, visited, varGen) {
|
|
|
6170
6293
|
results.push(gcCompactForGoals(composed, [], answerVars));
|
|
6171
6294
|
} else {
|
|
6172
6295
|
const nextSubst = maybeCompactSubst(composed, restGoals, answerVars, state.depth + 1);
|
|
6173
|
-
nextStates.push({
|
|
6296
|
+
nextStates.push({
|
|
6297
|
+
goals: restGoals,
|
|
6298
|
+
subst: nextSubst,
|
|
6299
|
+
depth: state.depth + 1,
|
|
6300
|
+
visited: state.visited,
|
|
6301
|
+
});
|
|
6174
6302
|
}
|
|
6175
6303
|
}
|
|
6176
6304
|
// Push in reverse so the *first* generated alternative is explored first (LIFO stack).
|
|
@@ -6195,7 +6323,12 @@ function proveGoals(goals, subst, facts, backRules, depth, visited, varGen) {
|
|
|
6195
6323
|
results.push(gcCompactForGoals(composed, [], answerVars));
|
|
6196
6324
|
} else {
|
|
6197
6325
|
const nextSubst = maybeCompactSubst(composed, restGoals, answerVars, state.depth + 1);
|
|
6198
|
-
nextStates.push({
|
|
6326
|
+
nextStates.push({
|
|
6327
|
+
goals: restGoals,
|
|
6328
|
+
subst: nextSubst,
|
|
6329
|
+
depth: state.depth + 1,
|
|
6330
|
+
visited: state.visited,
|
|
6331
|
+
});
|
|
6199
6332
|
}
|
|
6200
6333
|
}
|
|
6201
6334
|
for (let i = nextStates.length - 1; i >= 0; i--) stack.push(nextStates[i]);
|
|
@@ -6211,7 +6344,12 @@ function proveGoals(goals, subst, facts, backRules, depth, visited, varGen) {
|
|
|
6211
6344
|
results.push(gcCompactForGoals(composed, [], answerVars));
|
|
6212
6345
|
} else {
|
|
6213
6346
|
const nextSubst = maybeCompactSubst(composed, restGoals, answerVars, state.depth + 1);
|
|
6214
|
-
nextStates.push({
|
|
6347
|
+
nextStates.push({
|
|
6348
|
+
goals: restGoals,
|
|
6349
|
+
subst: nextSubst,
|
|
6350
|
+
depth: state.depth + 1,
|
|
6351
|
+
visited: state.visited,
|
|
6352
|
+
});
|
|
6215
6353
|
}
|
|
6216
6354
|
}
|
|
6217
6355
|
for (let i = nextStates.length - 1; i >= 0; i--) stack.push(nextStates[i]);
|
|
@@ -6236,7 +6374,12 @@ function proveGoals(goals, subst, facts, backRules, depth, visited, varGen) {
|
|
|
6236
6374
|
if (composed === null) continue;
|
|
6237
6375
|
const newGoals = body.concat(restGoals);
|
|
6238
6376
|
const nextSubst = maybeCompactSubst(composed, newGoals, answerVars, state.depth + 1);
|
|
6239
|
-
nextStates.push({
|
|
6377
|
+
nextStates.push({
|
|
6378
|
+
goals: newGoals,
|
|
6379
|
+
subst: nextSubst,
|
|
6380
|
+
depth: state.depth + 1,
|
|
6381
|
+
visited: visitedForRules,
|
|
6382
|
+
});
|
|
6240
6383
|
}
|
|
6241
6384
|
for (let i = nextStates.length - 1; i >= 0; i--) stack.push(nextStates[i]);
|
|
6242
6385
|
}
|
|
@@ -6278,7 +6421,12 @@ function forwardChain(facts, forwardRules, backRules, onDerived /* optional */)
|
|
|
6278
6421
|
|
|
6279
6422
|
function setScopedSnapshot(snap) {
|
|
6280
6423
|
if (!Object.prototype.hasOwnProperty.call(facts, '__scopedSnapshot')) {
|
|
6281
|
-
Object.defineProperty(facts, '__scopedSnapshot', {
|
|
6424
|
+
Object.defineProperty(facts, '__scopedSnapshot', {
|
|
6425
|
+
value: snap,
|
|
6426
|
+
enumerable: false,
|
|
6427
|
+
writable: true,
|
|
6428
|
+
configurable: true,
|
|
6429
|
+
});
|
|
6282
6430
|
} else {
|
|
6283
6431
|
facts.__scopedSnapshot = snap;
|
|
6284
6432
|
}
|
|
@@ -6287,7 +6435,12 @@ function forwardChain(facts, forwardRules, backRules, onDerived /* optional */)
|
|
|
6287
6435
|
function makeScopedSnapshot() {
|
|
6288
6436
|
const snap = facts.slice();
|
|
6289
6437
|
ensureFactIndexes(snap);
|
|
6290
|
-
Object.defineProperty(snap, '__scopedSnapshot', {
|
|
6438
|
+
Object.defineProperty(snap, '__scopedSnapshot', {
|
|
6439
|
+
value: snap,
|
|
6440
|
+
enumerable: false,
|
|
6441
|
+
writable: true,
|
|
6442
|
+
configurable: true,
|
|
6443
|
+
});
|
|
6291
6444
|
return snap;
|
|
6292
6445
|
}
|
|
6293
6446
|
|
|
@@ -6321,14 +6474,22 @@ function forwardChain(facts, forwardRules, backRules, onDerived /* optional */)
|
|
|
6321
6474
|
const isFwRuleTriple =
|
|
6322
6475
|
isLogImplies(instantiated.p) &&
|
|
6323
6476
|
((instantiated.s instanceof GraphTerm && instantiated.o instanceof GraphTerm) ||
|
|
6324
|
-
(instantiated.s instanceof Literal &&
|
|
6325
|
-
|
|
6477
|
+
(instantiated.s instanceof Literal &&
|
|
6478
|
+
instantiated.s.value === 'true' &&
|
|
6479
|
+
instantiated.o instanceof GraphTerm) ||
|
|
6480
|
+
(instantiated.s instanceof GraphTerm &&
|
|
6481
|
+
instantiated.o instanceof Literal &&
|
|
6482
|
+
instantiated.o.value === 'true'));
|
|
6326
6483
|
|
|
6327
6484
|
const isBwRuleTriple =
|
|
6328
6485
|
isLogImpliedBy(instantiated.p) &&
|
|
6329
6486
|
((instantiated.s instanceof GraphTerm && instantiated.o instanceof GraphTerm) ||
|
|
6330
|
-
(instantiated.s instanceof GraphTerm &&
|
|
6331
|
-
|
|
6487
|
+
(instantiated.s instanceof GraphTerm &&
|
|
6488
|
+
instantiated.o instanceof Literal &&
|
|
6489
|
+
instantiated.o.value === 'true') ||
|
|
6490
|
+
(instantiated.s instanceof Literal &&
|
|
6491
|
+
instantiated.s.value === 'true' &&
|
|
6492
|
+
instantiated.o instanceof GraphTerm));
|
|
6332
6493
|
|
|
6333
6494
|
if (isFwRuleTriple || isBwRuleTriple) {
|
|
6334
6495
|
if (!hasFactIndexed(facts, instantiated)) {
|
|
@@ -6394,14 +6555,23 @@ function forwardChain(facts, forwardRules, backRules, onDerived /* optional */)
|
|
|
6394
6555
|
}
|
|
6395
6556
|
|
|
6396
6557
|
// Only skolemize blank nodes that occur explicitly in the rule head
|
|
6397
|
-
const inst = skolemizeTripleForHeadBlanks(
|
|
6558
|
+
const inst = skolemizeTripleForHeadBlanks(
|
|
6559
|
+
instantiated,
|
|
6560
|
+
r.headBlankLabels,
|
|
6561
|
+
skMap,
|
|
6562
|
+
skCounter,
|
|
6563
|
+
fireKey,
|
|
6564
|
+
headSkolemCache,
|
|
6565
|
+
);
|
|
6398
6566
|
|
|
6399
6567
|
if (!isGroundTriple(inst)) continue;
|
|
6400
6568
|
if (hasFactIndexed(facts, inst)) continue;
|
|
6401
6569
|
|
|
6402
6570
|
factList.push(inst);
|
|
6403
6571
|
pushFactIndexed(facts, inst);
|
|
6404
|
-
const df = new DerivedFact(inst, r, instantiatedPremises.slice(), {
|
|
6572
|
+
const df = new DerivedFact(inst, r, instantiatedPremises.slice(), {
|
|
6573
|
+
...s,
|
|
6574
|
+
});
|
|
6405
6575
|
derivedForward.push(df);
|
|
6406
6576
|
if (typeof onDerived === 'function') onDerived(df);
|
|
6407
6577
|
|