occam-verify-cli 1.0.809 → 1.0.816
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/lib/context/bounded.js +6 -6
- package/lib/context/branching.js +3 -3
- package/lib/context/ephemeral.js +7 -3
- package/lib/context/file/nominal.js +16 -16
- package/lib/context/liminal.js +26 -30
- package/lib/context/synoptic.js +62 -2
- package/lib/context.js +66 -54
- package/lib/element/assertion/defined.js +12 -11
- package/lib/element/assertion/satisfies.js +15 -11
- package/lib/element/assertion.js +5 -5
- package/lib/element/assumption/metaLevel.js +3 -3
- package/lib/element/conclusion.js +11 -8
- package/lib/element/deduction.js +11 -8
- package/lib/element/frame.js +6 -14
- package/lib/element/label.js +5 -8
- package/lib/element/metavariable.js +17 -17
- package/lib/element/procedureCall.js +10 -6
- package/lib/element/proofAssertion/premise.js +27 -27
- package/lib/element/proofAssertion/step.js +25 -5
- package/lib/element/proofAssertion/supposition.js +27 -27
- package/lib/element/proofAssertion.js +10 -10
- package/lib/element/reference.js +9 -13
- package/lib/element/rule.js +41 -43
- package/lib/element/signature.js +8 -8
- package/lib/element/statement.js +35 -45
- package/lib/element/subproof.js +4 -4
- package/lib/element/substitution/frame.js +16 -11
- package/lib/element/substitution/reference.js +15 -10
- package/lib/element/substitution/statement.js +55 -51
- package/lib/element/substitution/term.js +17 -12
- package/lib/element/substitution.js +35 -29
- package/lib/element/term.js +18 -16
- package/lib/element/topLevelAssertion/axiom.js +5 -3
- package/lib/element/topLevelAssertion.js +36 -38
- package/lib/element/variable.js +7 -7
- package/lib/node/frame.js +1 -9
- package/lib/node/statement.js +1 -9
- package/lib/node/term.js +10 -19
- package/lib/process/assign.js +23 -31
- package/lib/utilities/element.js +33 -5
- package/lib/utilities/equivalence.js +4 -4
- package/lib/utilities/equivalences.js +30 -15
- package/lib/utilities/string.js +2 -2
- package/lib/utilities/substitutions.js +16 -15
- package/lib/utilities/unification.js +133 -124
- package/package.json +1 -1
- package/src/context/bounded.js +5 -5
- package/src/context/branching.js +2 -2
- package/src/context/ephemeral.js +10 -2
- package/src/context/file/nominal.js +15 -15
- package/src/context/liminal.js +29 -35
- package/src/context/synoptic.js +81 -1
- package/src/context.js +88 -69
- package/src/element/assertion/defined.js +17 -16
- package/src/element/assertion/satisfies.js +17 -10
- package/src/element/assertion.js +8 -8
- package/src/element/assumption/metaLevel.js +4 -2
- package/src/element/conclusion.js +12 -7
- package/src/element/deduction.js +12 -7
- package/src/element/frame.js +7 -20
- package/src/element/label.js +3 -5
- package/src/element/metavariable.js +27 -27
- package/src/element/procedureCall.js +14 -9
- package/src/element/proofAssertion/premise.js +41 -41
- package/src/element/proofAssertion/step.js +37 -7
- package/src/element/proofAssertion/supposition.js +41 -41
- package/src/element/proofAssertion.js +10 -9
- package/src/element/reference.js +9 -13
- package/src/element/rule.js +57 -61
- package/src/element/signature.js +7 -7
- package/src/element/statement.js +54 -68
- package/src/element/subproof.js +3 -3
- package/src/element/substitution/frame.js +18 -8
- package/src/element/substitution/reference.js +16 -7
- package/src/element/substitution/statement.js +78 -67
- package/src/element/substitution/term.js +19 -10
- package/src/element/substitution.js +45 -35
- package/src/element/term.js +28 -26
- package/src/element/topLevelAssertion/axiom.js +5 -2
- package/src/element/topLevelAssertion.js +49 -53
- package/src/element/variable.js +6 -6
- package/src/node/frame.js +0 -12
- package/src/node/statement.js +0 -12
- package/src/node/term.js +14 -28
- package/src/process/assign.js +35 -46
- package/src/utilities/element.js +32 -4
- package/src/utilities/equivalence.js +3 -4
- package/src/utilities/equivalences.js +31 -19
- package/src/utilities/string.js +2 -2
- package/src/utilities/substitutions.js +17 -15
- package/src/utilities/unification.js +145 -119
|
@@ -9,8 +9,8 @@ import { join, ablate, descend, attempt, instantiate } from "../../utilities/con
|
|
|
9
9
|
import { frameSubstitutionStringFromFrameAndMetavariable } from "../../utilities/string";
|
|
10
10
|
|
|
11
11
|
export default define(class FrameSubstitution extends Substitution {
|
|
12
|
-
constructor(context, string, node, targetFrame, replacementFrame) {
|
|
13
|
-
super(context, string, node);
|
|
12
|
+
constructor(context, string, node, generalContext, targetFrame, replacementFrame) {
|
|
13
|
+
super(context, string, node, generalContext);
|
|
14
14
|
|
|
15
15
|
this.targetFrame = targetFrame;
|
|
16
16
|
this.replacementFrame = replacementFrame;
|
|
@@ -31,6 +31,8 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
31
31
|
return frameSubstitutionNode;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
getMetavariableNode() { return this.targetFrame.getMetavariableNode(); }
|
|
35
|
+
|
|
34
36
|
getTargetNode() {
|
|
35
37
|
const targetFrameNode = this.targetFrame.getNode(),
|
|
36
38
|
tergetNode = targetFrameNode; ///
|
|
@@ -45,10 +47,6 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
45
47
|
return replacementNode;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
compareMetavariableName(metavariableName) { return this.targetFrame.compareMetavariableName(metavariableName); }
|
|
49
|
-
|
|
50
|
-
getMetavariableName() { return this.targetFrame.getMetavariableName(); }
|
|
51
|
-
|
|
52
50
|
isTrivial() {
|
|
53
51
|
const targetFrameEqualToReplacementFrame = this.targetFrame.isEqualTo(this.replacementFrame),
|
|
54
52
|
trivial = targetFrameEqualToReplacementFrame; ///
|
|
@@ -56,6 +54,8 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
56
54
|
return trivial;
|
|
57
55
|
}
|
|
58
56
|
|
|
57
|
+
matchMetavariableNode(metavariableNode) { return this.targetFrame.matchMetavariableNode(metavariableNode); }
|
|
58
|
+
|
|
59
59
|
compareFrame(frame, context) {
|
|
60
60
|
const frameEqualToReplacementFrame = this.replacementFrame.isEqualTo(frame),
|
|
61
61
|
comparedToFrame = frameEqualToReplacementFrame; ///
|
|
@@ -116,6 +116,8 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
116
116
|
|
|
117
117
|
context.addSubstitution(substitution);
|
|
118
118
|
|
|
119
|
+
this.setGeneralContext(generalContext);
|
|
120
|
+
|
|
119
121
|
context.debug(`...validated the '${frameSubstitutionString}' frame substitution.`);
|
|
120
122
|
}
|
|
121
123
|
|
|
@@ -191,11 +193,12 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
191
193
|
instantiate((context) => {
|
|
192
194
|
const { string } = json,
|
|
193
195
|
frameSubstitutionNode = instantiateFrameSubstitution(string, context),
|
|
194
|
-
node = frameSubstitutionNode,
|
|
196
|
+
node = frameSubstitutionNode, ///
|
|
197
|
+
generalContext = generalContextFromFrameSubstitutionNode(frameSubstitutionNode, context),
|
|
195
198
|
targetFrame = targetFrameFromFrameSubstitutionNode(frameSubstitutionNode, context),
|
|
196
199
|
replacementFrame = replacementFrameFromFrameSubstitutionNode(frameSubstitutionNode, context);
|
|
197
200
|
|
|
198
|
-
frameSubstitutionn = new FrameSubstitution(context, string, node, targetFrame, replacementFrame);
|
|
201
|
+
frameSubstitutionn = new FrameSubstitution(context, string, node, generalContext, targetFrame, replacementFrame);
|
|
199
202
|
}, context);
|
|
200
203
|
}
|
|
201
204
|
|
|
@@ -246,3 +249,10 @@ function replacementFrameFromFrameSubstitutionNode(frameSubstitutionNode, contex
|
|
|
246
249
|
|
|
247
250
|
return replacementFrame;
|
|
248
251
|
}
|
|
252
|
+
|
|
253
|
+
function generalContextFromFrameSubstitutionNode(frameSubstitutionNode, context) {
|
|
254
|
+
const generalContext = context; ///
|
|
255
|
+
|
|
256
|
+
return generalContext;
|
|
257
|
+
}
|
|
258
|
+
|
|
@@ -9,8 +9,8 @@ import { referenceSubstitutionFromReferenceSubstitutionNode } from "../../utilit
|
|
|
9
9
|
import { referenceSubstitutionStringFromReferenceAndMetavariable } from "../../utilities/string";
|
|
10
10
|
|
|
11
11
|
export default define(class ReferenceSubstitution extends Substitution {
|
|
12
|
-
constructor(context, string, node, targetReference, replacementReference) {
|
|
13
|
-
super(context, string, node);
|
|
12
|
+
constructor(context, string, node, generalContext, targetReference, replacementReference) {
|
|
13
|
+
super(context, string, node, generalContext);
|
|
14
14
|
|
|
15
15
|
this.targetReference = targetReference;
|
|
16
16
|
this.replacementReference = replacementReference;
|
|
@@ -45,9 +45,7 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
45
45
|
return replacementNode;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
compareMetavariableName(metavariableName) { return this.targetReference.compareMetavariableName(metavariableName); }
|
|
48
|
+
getMetavariableNode() { return this.targetReference.getMetavariableNode(); }
|
|
51
49
|
|
|
52
50
|
isTrivial() {
|
|
53
51
|
const targetReferenceEqualToReplacementReference = this.targetReference.isEqualTo(this.replacementReference),
|
|
@@ -56,6 +54,8 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
56
54
|
return trivial;
|
|
57
55
|
}
|
|
58
56
|
|
|
57
|
+
matchMetavariableNode(metavariableNode) { return this.targetReference.matchMetavariableNode(metavariableNode); }
|
|
58
|
+
|
|
59
59
|
compareReference(reference, context) {
|
|
60
60
|
const referenceEqualToReplacementReference = this.replacementReference.isEqualTo(reference),
|
|
61
61
|
comparedToReference = referenceEqualToReplacementReference; ///
|
|
@@ -133,6 +133,8 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
133
133
|
|
|
134
134
|
context.addSubstitution(substitution);
|
|
135
135
|
|
|
136
|
+
this.setGeneralContext(generalContext);
|
|
137
|
+
|
|
136
138
|
context.debug(`...validated the '${referenceSubstitutionString}' reference substitution.`);
|
|
137
139
|
}
|
|
138
140
|
|
|
@@ -198,11 +200,12 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
198
200
|
instantiate((context) => {
|
|
199
201
|
const { string } = json,
|
|
200
202
|
referenceSubstitutionNode = instantiateReferenceSubstitution(string, context),
|
|
201
|
-
node = referenceSubstitutionNode,
|
|
203
|
+
node = referenceSubstitutionNode, ///
|
|
204
|
+
generalContext = generalContextFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
|
|
202
205
|
targetReference = targetReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
|
|
203
206
|
replacementReference = replacementReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
|
|
204
207
|
|
|
205
|
-
referenceSubstitutionn = new ReferenceSubstitution(context, string, node, targetReference, replacementReference);
|
|
208
|
+
referenceSubstitutionn = new ReferenceSubstitution(context, string, node, generalContext, targetReference, replacementReference);
|
|
206
209
|
}, context);
|
|
207
210
|
}
|
|
208
211
|
|
|
@@ -257,3 +260,9 @@ function replacementReferenceFromReferenceSubstitutionNode(referenceSubstitution
|
|
|
257
260
|
|
|
258
261
|
return replacementReference;
|
|
259
262
|
}
|
|
263
|
+
|
|
264
|
+
function generalContextFromReferenceSubstitutionNode(referenceSubstitutionNode, context) {
|
|
265
|
+
const generalContext = context; ///
|
|
266
|
+
|
|
267
|
+
return generalContext;
|
|
268
|
+
}
|
|
@@ -11,8 +11,8 @@ import { join, ablate, attempt, descend, reconcile, instantiate } from "../../ut
|
|
|
11
11
|
import { statementSubstitutionStringFromStatementAndMetavariable, statementSubstitutionStringFromStatementMetavariableAndSubstitution } from "../../utilities/string";
|
|
12
12
|
|
|
13
13
|
export default define(class StatementSubstitution extends Substitution {
|
|
14
|
-
constructor(context, string, node, resolved, substitution, targetStatement, replacementStatement) {
|
|
15
|
-
super(context, string, node);
|
|
14
|
+
constructor(context, string, node, generalContext, resolved, substitution, targetStatement, replacementStatement) {
|
|
15
|
+
super(context, string, node, generalContext);
|
|
16
16
|
|
|
17
17
|
this.resolved = resolved;
|
|
18
18
|
this.substitution = substitution;
|
|
@@ -43,8 +43,6 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
43
43
|
return statementSubstitutionNode;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
getMtavariableName() { return this.targetStatement.getMtavariableName(); }
|
|
47
|
-
|
|
48
46
|
getTargetNode() {
|
|
49
47
|
const targetStatementNode = this.targetStatement.getNode(),
|
|
50
48
|
targetNode = targetStatementNode; ///
|
|
@@ -59,15 +57,15 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
59
57
|
return replacementNode;
|
|
60
58
|
}
|
|
61
59
|
|
|
60
|
+
getMetavariableNode() { return this.targetStatement.getMetavariableNode(); }
|
|
61
|
+
|
|
62
62
|
isSimple() {
|
|
63
63
|
const simple = (this.substitution === null);
|
|
64
64
|
|
|
65
65
|
return simple;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
compareMetavariableName(metavariableName) { return this.targetStatement.compareMetavariableName(metavariableName); }
|
|
68
|
+
matchMetavariableNode(metavariableNode) { return this.targetStatement.matchMetavariableNode(metavariableNode); }
|
|
71
69
|
|
|
72
70
|
compareStatement(statement, context) {
|
|
73
71
|
statement = stripBracketsFromStatement(statement, context); ///
|
|
@@ -103,8 +101,6 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
103
101
|
return comparesToSubstitution;
|
|
104
102
|
}
|
|
105
103
|
|
|
106
|
-
compareMetavariable(metavariable) { return this.targetStatement.compareMetavariable(metavariable); }
|
|
107
|
-
|
|
108
104
|
validate(generalContext, specificContext) {
|
|
109
105
|
let statementSubstitution = null;
|
|
110
106
|
|
|
@@ -155,6 +151,8 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
155
151
|
|
|
156
152
|
context.addSubstitution(substitution);
|
|
157
153
|
|
|
154
|
+
this.setGeneralContext(generalContext);
|
|
155
|
+
|
|
158
156
|
context.debug(`...validated the '${statementSubstitutionString}' statement substitution.`);
|
|
159
157
|
}
|
|
160
158
|
|
|
@@ -165,7 +163,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
165
163
|
let substitutionValidates = true;
|
|
166
164
|
|
|
167
165
|
if (this.substitution !== null) {
|
|
168
|
-
const context =
|
|
166
|
+
const context = generalContext, ///
|
|
169
167
|
substitutionString = this.substitution.getString(),
|
|
170
168
|
statementSubstitutionString = this.getString();
|
|
171
169
|
|
|
@@ -245,41 +243,58 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
245
243
|
return replacementStatementValidates;
|
|
246
244
|
}
|
|
247
245
|
|
|
248
|
-
|
|
249
|
-
let
|
|
246
|
+
unifySimpleSubstitution(simpleSubstitution, context) {
|
|
247
|
+
let simpleSubstitutionUnifies;
|
|
250
248
|
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
specificSubstitution = substitution, ///
|
|
254
|
-
generalSubstitutionString = generalSubstitution.getString(),
|
|
255
|
-
specificSubstitutionString = specificSubstitution.getString();
|
|
249
|
+
const substitutionString = this.substitution.getString(),
|
|
250
|
+
simpleSubstitutionString = simpleSubstitution.getString();
|
|
256
251
|
|
|
257
|
-
context.trace(`Unifying the '${
|
|
252
|
+
context.trace(`Unifying the '${simpleSubstitutionString}' simple substitution with the '${substitutionString}' substitution...`);
|
|
258
253
|
|
|
259
|
-
|
|
260
|
-
|
|
254
|
+
const generalSubstitution = this.substitution, ///
|
|
255
|
+
specificSubstitution = simpleSubstitution, ///
|
|
256
|
+
generalSubstitutionGeneralContext = generalSubstitution.getGeneralContext(),
|
|
257
|
+
generalSubstitutionSpecificContext = generalSubstitution.getSpecificContext(),
|
|
258
|
+
specificSubstitutionGeneralContext = specificSubstitution.getGeneralContext(),
|
|
259
|
+
specificSubstitutionSpecificContext = specificSubstitution.getSpecificContext();
|
|
261
260
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
261
|
+
join((specificContext) => {
|
|
262
|
+
join((generalContext) => {
|
|
263
|
+
reconcile((specificContext) => {
|
|
264
|
+
simpleSubstitutionUnifies = unifySubstitution(generalSubstitution, specificSubstitution, generalContext, specificContext);
|
|
266
265
|
|
|
267
|
-
|
|
268
|
-
|
|
266
|
+
if (simpleSubstitutionUnifies) {
|
|
267
|
+
specificContext.commit(context);
|
|
268
|
+
}
|
|
269
|
+
}, specificContext)
|
|
270
|
+
}, generalSubstitutionSpecificContext, generalSubstitutionGeneralContext);
|
|
271
|
+
}, specificSubstitutionSpecificContext, specificSubstitutionGeneralContext, context);
|
|
272
|
+
|
|
273
|
+
if (simpleSubstitutionUnifies) {
|
|
274
|
+
context.trace(`...unified the '${simpleSubstitutionString}' simple substitution with the '${substitutionString}' substitution.`);
|
|
269
275
|
}
|
|
270
276
|
|
|
271
|
-
return
|
|
277
|
+
return simpleSubstitutionUnifies;
|
|
272
278
|
}
|
|
273
279
|
|
|
274
|
-
unifyComplexSubstitution(complexSubstitution,
|
|
280
|
+
unifyComplexSubstitution(complexSubstitution, context) {
|
|
275
281
|
let substitution = null;
|
|
276
282
|
|
|
277
|
-
const
|
|
278
|
-
simpleSubstitutionString = this.getString(), ///
|
|
283
|
+
const simpleSubstitutionString = this.getString(), ///
|
|
279
284
|
complexSubstitutionString = complexSubstitution.getString(); ///
|
|
280
285
|
|
|
281
286
|
context.trace(`Unifying the '${complexSubstitutionString}' complex substitution with the '${simpleSubstitutionString}' simple substitution...`);
|
|
282
287
|
|
|
288
|
+
context = complexSubstitution.getContext();
|
|
289
|
+
|
|
290
|
+
const specificContext = context; ///
|
|
291
|
+
|
|
292
|
+
context = this.getContext();
|
|
293
|
+
|
|
294
|
+
const generalContext = context; ///
|
|
295
|
+
|
|
296
|
+
context = specificContext; ///
|
|
297
|
+
|
|
283
298
|
let simpleSubstitutionUnifies = false;
|
|
284
299
|
|
|
285
300
|
reconcile((specificContext) => {
|
|
@@ -296,6 +311,8 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
296
311
|
}, specificContext);
|
|
297
312
|
|
|
298
313
|
if (substitution !== null) {
|
|
314
|
+
substitution = substitution.validate(generalContext, specificContext);
|
|
315
|
+
|
|
299
316
|
simpleSubstitutionUnifies = true;
|
|
300
317
|
}
|
|
301
318
|
|
|
@@ -328,52 +345,24 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
328
345
|
return replacementStatemnentUnifies;
|
|
329
346
|
}
|
|
330
347
|
|
|
331
|
-
|
|
332
|
-
let substitution;
|
|
333
|
-
|
|
334
|
-
const complexSubstitution = this, ///
|
|
335
|
-
simpleSubstitutionContext = simpleSubstitution.getContext(),
|
|
336
|
-
complexSubstitutionContext = complexSubstitution.getContext();
|
|
337
|
-
|
|
338
|
-
generalContext = simpleSubstitutionContext; ///
|
|
339
|
-
|
|
340
|
-
specificContext = complexSubstitutionContext; ///
|
|
341
|
-
|
|
342
|
-
substitution = simpleSubstitution.unifyComplexSubstitution(complexSubstitution, generalContext, specificContext);
|
|
343
|
-
|
|
344
|
-
return substitution;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
resolve(generalContext, specificContext) {
|
|
348
|
+
resolve(context) {
|
|
348
349
|
let resolved = false;
|
|
349
350
|
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
351
|
+
const metavariableNode = this.getMetavariableNode(),
|
|
352
|
+
simpleSubstitution = context.findSimpleSubstitutionByMetavariableNode(metavariableNode),
|
|
353
|
+
complexSubstitution = this; ///
|
|
353
354
|
|
|
354
355
|
if (simpleSubstitution !== null) {
|
|
355
356
|
const substitutionString = this.getString(); ///
|
|
356
357
|
|
|
357
358
|
context.trace(`Resolving the ${substitutionString} substitution...`);
|
|
358
359
|
|
|
359
|
-
const substitution =
|
|
360
|
+
const substitution = simpleSubstitution.unifyComplexSubstitution(complexSubstitution, context);
|
|
360
361
|
|
|
361
362
|
if (substitution !== null) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
context = substitution.getContext();
|
|
365
|
-
|
|
366
|
-
const specificContext = context; ///
|
|
367
|
-
|
|
368
|
-
context = this.substitution.getContext();
|
|
369
|
-
|
|
370
|
-
const generalContext = context; ///
|
|
371
|
-
|
|
372
|
-
context = specificContext; ///
|
|
363
|
+
const simpleSubstitutionUnifies = complexSubstitution.unifySimpleSubstitution(substitution, context);
|
|
373
364
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
if (substitutionUnifies) {
|
|
365
|
+
if (simpleSubstitutionUnifies) {
|
|
377
366
|
resolved = true;
|
|
378
367
|
}
|
|
379
368
|
|
|
@@ -397,11 +386,14 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
397
386
|
instantiate((context) => {
|
|
398
387
|
const { string } = json,
|
|
399
388
|
statementSubstitutionNode = instantiateStatementSubstitution(string, context),
|
|
400
|
-
node = statementSubstitutionNode,
|
|
389
|
+
node = statementSubstitutionNode, ///
|
|
390
|
+
generalContext = generalContextFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
391
|
+
resolved = resolvedFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
392
|
+
substitution = substitutionFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
401
393
|
targetStatement = targetStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
402
394
|
replacementStatement = replacementStatementFromStatementSubstitutionNode(statementSubstitutionNode, context);
|
|
403
395
|
|
|
404
|
-
statementSubstitutionn = new StatementSubstitution(context, string, node, targetStatement, replacementStatement);
|
|
396
|
+
statementSubstitutionn = new StatementSubstitution(context, string, node, generalContext, resolved, substitution, targetStatement, replacementStatement);
|
|
405
397
|
}, context);
|
|
406
398
|
}
|
|
407
399
|
|
|
@@ -458,3 +450,22 @@ function replacementStatementFromStatementSubstitutionNode(statementSubstitution
|
|
|
458
450
|
|
|
459
451
|
return replacementStatement;
|
|
460
452
|
}
|
|
453
|
+
|
|
454
|
+
function resolvedFromStatementSubstitutionNode(statementSubstitutionNode, context) {
|
|
455
|
+
const resolved = true;
|
|
456
|
+
|
|
457
|
+
return resolved;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function substitutionFromStatementSubstitutionNode(statementSubstitutionNode, context) {
|
|
461
|
+
const substitutionNode = statementSubstitutionNode.getSubstitutionNode(),
|
|
462
|
+
substitution = context.findStatementByStatementNode(substitutionNode);
|
|
463
|
+
|
|
464
|
+
return substitution;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function generalContextFromStatementSubstitutionNode(statementSubstitutionNode, context) {
|
|
468
|
+
const generalContext = context; ///
|
|
469
|
+
|
|
470
|
+
return generalContext;
|
|
471
|
+
}
|
|
@@ -10,8 +10,8 @@ import { termSubstitutionStringFromTermAndVariable } from "../../utilities/strin
|
|
|
10
10
|
import { join, ablate, descend, attempt, instantiate } from "../../utilities/context";
|
|
11
11
|
|
|
12
12
|
export default define(class TermSubstitution extends Substitution {
|
|
13
|
-
constructor(context, string, node, targetTerm, replacementTerm) {
|
|
14
|
-
super(context, string, node);
|
|
13
|
+
constructor(context, string, node, generalContext, targetTerm, replacementTerm) {
|
|
14
|
+
super(context, string, node, generalContext);
|
|
15
15
|
|
|
16
16
|
this.targetTerm = targetTerm;
|
|
17
17
|
this.replacementTerm = replacementTerm;
|
|
@@ -46,22 +46,22 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
46
46
|
return replacementNode;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
compareVariableIdentifier(variableIdentifier) { return this.targetTerm.compareVariableIdentifier(variableIdentifier); }
|
|
49
|
+
getVariableNode() { return this.targetTerm.getVariableNode(); }
|
|
52
50
|
|
|
53
51
|
isTrivial() {
|
|
54
|
-
const
|
|
55
|
-
trivial =
|
|
52
|
+
const targetTermComparesToReplacementTerm = this.targetTerm.compareTerm(this.replacementTerm),
|
|
53
|
+
trivial = targetTermComparesToReplacementTerm; ///
|
|
56
54
|
|
|
57
55
|
return trivial;
|
|
58
56
|
}
|
|
59
57
|
|
|
58
|
+
matchVariableNode(variableNode) { return this.targetTerm.matchVariableNode(variableNode); }
|
|
59
|
+
|
|
60
60
|
compareTerm(term, context) {
|
|
61
61
|
term = stripBracketsFromTerm(term, context); ///
|
|
62
62
|
|
|
63
|
-
const
|
|
64
|
-
comparedToTerm =
|
|
63
|
+
const replacementTermComparesToTerm = this.replacementTerm.compareTerm(term),
|
|
64
|
+
comparedToTerm = replacementTermComparesToTerm; ///
|
|
65
65
|
|
|
66
66
|
return comparedToTerm;
|
|
67
67
|
}
|
|
@@ -119,6 +119,8 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
119
119
|
|
|
120
120
|
context.addSubstitution(substitution);
|
|
121
121
|
|
|
122
|
+
this.setGeneralContext(generalContext);
|
|
123
|
+
|
|
122
124
|
context.debug(`...validated the '${termSubstitutionString}' term substitution.`);
|
|
123
125
|
}
|
|
124
126
|
|
|
@@ -203,10 +205,11 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
203
205
|
const { string } = json,
|
|
204
206
|
termSubstitutionNode = instantiateTermSubstitution(string, context),
|
|
205
207
|
node = termSubstitutionNode, ///
|
|
208
|
+
generalContext = generalContextFromTermSubstitutionNode(termSubstitutionNode, context),
|
|
206
209
|
targetTerm = targetTermFromTermSubstitutionNode(termSubstitutionNode, context),
|
|
207
210
|
replacementTerm = replacementTermFromTermSubstitutionNode(termSubstitutionNode, context);
|
|
208
211
|
|
|
209
|
-
termSubstitutionn = new TermSubstitution(context, string, node, targetTerm, replacementTerm);
|
|
212
|
+
termSubstitutionn = new TermSubstitution(context, string, node, generalContext, targetTerm, replacementTerm);
|
|
210
213
|
}, context);
|
|
211
214
|
}
|
|
212
215
|
|
|
@@ -259,3 +262,9 @@ function replacementTermFromTermSubstitutionNode(termSubstitutionNode, context)
|
|
|
259
262
|
|
|
260
263
|
return replacementTerm;
|
|
261
264
|
}
|
|
265
|
+
|
|
266
|
+
function generalContextFromTermSubstitutionNode(termSubstitutionNode, context) {
|
|
267
|
+
const generalContext = context; ///
|
|
268
|
+
|
|
269
|
+
return generalContext;
|
|
270
|
+
}
|
|
@@ -6,6 +6,16 @@ import { primitiveUtilities } from "occam-furtle";
|
|
|
6
6
|
const { primitiveFromNode } =primitiveUtilities;
|
|
7
7
|
|
|
8
8
|
export default class Substitution extends Element {
|
|
9
|
+
constructor(context, string, node, generalContext) {
|
|
10
|
+
super(context, string, node);
|
|
11
|
+
|
|
12
|
+
this.generalContext = generalContext;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getGeneralContext() {
|
|
16
|
+
return this.generalContext;
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
getPrimitive(context) {
|
|
10
20
|
const replacementNode = this.getReplacementNode(),
|
|
11
21
|
node = replacementNode, ///
|
|
@@ -21,20 +31,15 @@ export default class Substitution extends Element {
|
|
|
21
31
|
return substitutionNode;
|
|
22
32
|
}
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
substitutionNodeMatches = nodeMatches; ///
|
|
34
|
+
getSpecificContext() {
|
|
35
|
+
const context = this.getContext(),
|
|
36
|
+
specificContext = context; ///
|
|
28
37
|
|
|
29
|
-
return
|
|
38
|
+
return specificContext;
|
|
30
39
|
}
|
|
31
40
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
substitution = context.findSubstitutionBySubstitutionNode(substitutionNode),
|
|
35
|
-
validSubstitution = substitution; ///
|
|
36
|
-
|
|
37
|
-
return validSubstitution;
|
|
41
|
+
setGeneralContext(generalContext) {
|
|
42
|
+
this.generalContext = generalContext;
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
isEqualTo(substitution) {
|
|
@@ -65,28 +70,28 @@ export default class Substitution extends Element {
|
|
|
65
70
|
return variable;
|
|
66
71
|
}
|
|
67
72
|
|
|
68
|
-
getSubstitution() {
|
|
69
|
-
const substitution = null;
|
|
70
|
-
|
|
71
|
-
return substitution;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
73
|
getMetavariable() {
|
|
75
74
|
const metavariable = null;
|
|
76
75
|
|
|
77
76
|
return metavariable;
|
|
78
77
|
}
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
const
|
|
79
|
+
getSubstitution() {
|
|
80
|
+
const substitution = null;
|
|
81
|
+
|
|
82
|
+
return substitution;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getVariableNode() {
|
|
86
|
+
const variableNode = null;
|
|
82
87
|
|
|
83
|
-
return
|
|
88
|
+
return variableNode;
|
|
84
89
|
}
|
|
85
90
|
|
|
86
|
-
|
|
87
|
-
const
|
|
91
|
+
getMetavariableNode() {
|
|
92
|
+
const metavariableNode = null;
|
|
88
93
|
|
|
89
|
-
return
|
|
94
|
+
return metavariableNode;
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
isSimple() {
|
|
@@ -95,28 +100,33 @@ export default class Substitution extends Element {
|
|
|
95
100
|
return simple;
|
|
96
101
|
}
|
|
97
102
|
|
|
98
|
-
|
|
99
|
-
const
|
|
103
|
+
matchVariableNode(variableNode) {
|
|
104
|
+
const variableNodeMatches = false;
|
|
100
105
|
|
|
101
|
-
return
|
|
106
|
+
return variableNodeMatches;
|
|
102
107
|
}
|
|
103
108
|
|
|
104
|
-
|
|
105
|
-
const
|
|
109
|
+
matchMetavariableNode(metavariableNode) {
|
|
110
|
+
const metavariableNodeMatches = false;
|
|
106
111
|
|
|
107
|
-
return
|
|
112
|
+
return metavariableNodeMatches;
|
|
108
113
|
}
|
|
109
114
|
|
|
110
|
-
|
|
111
|
-
const
|
|
115
|
+
matchSubstitutionNode(substitutionNode) {
|
|
116
|
+
const node = substitutionNode, ///
|
|
117
|
+
nodeMatches = this.matchNode(node),
|
|
118
|
+
substitutionNodeMatches = nodeMatches; ///
|
|
112
119
|
|
|
113
|
-
return
|
|
120
|
+
return substitutionNodeMatches;
|
|
114
121
|
}
|
|
115
122
|
|
|
116
|
-
compareVariableIdentifier(variableIdentifier) {
|
|
117
|
-
const comparesToVariableIdentifier = false;
|
|
118
123
|
|
|
119
|
-
|
|
124
|
+
findValidSubstitution(context) {
|
|
125
|
+
const substitutionNode = this.getSubstitutionNode(),
|
|
126
|
+
substitution = context.findSubstitutionBySubstitutionNode(substitutionNode),
|
|
127
|
+
validSubstitution = substitution; ///
|
|
128
|
+
|
|
129
|
+
return validSubstitution;
|
|
120
130
|
}
|
|
121
131
|
|
|
122
132
|
resolve(substitutions, generalContext, specificContext) {
|
package/src/element/term.js
CHANGED
|
@@ -34,19 +34,18 @@ export default define(class Term extends Element {
|
|
|
34
34
|
return termNode;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
getVariableNode() {
|
|
38
38
|
const termNode = this.getTermNode(),
|
|
39
|
-
|
|
39
|
+
variableNode = termNode.getVariableNode();
|
|
40
40
|
|
|
41
|
-
return
|
|
41
|
+
return variableNode;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
const termNode =
|
|
46
|
-
|
|
47
|
-
equalTo = termNodeMatches; ///
|
|
44
|
+
getVariableIdentifier() {
|
|
45
|
+
const termNode = this.getTermNode(),
|
|
46
|
+
variableIdentifier = termNode.getVariableIdentifier();
|
|
48
47
|
|
|
49
|
-
return
|
|
48
|
+
return variableIdentifier;
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
isGrounded(definedVariables, context) {
|
|
@@ -101,6 +100,27 @@ export default define(class Term extends Element {
|
|
|
101
100
|
return termNodeMatches;
|
|
102
101
|
}
|
|
103
102
|
|
|
103
|
+
matchVariableNode(variableNode) {
|
|
104
|
+
let varialbeNodeMatches = false;
|
|
105
|
+
|
|
106
|
+
const singular = this.isSingular();
|
|
107
|
+
|
|
108
|
+
if (singular) {
|
|
109
|
+
const variableNodeA = variableNode; ///
|
|
110
|
+
|
|
111
|
+
variableNode = this.getVariableNode();
|
|
112
|
+
|
|
113
|
+
const variableNodeB = variableNode, ///
|
|
114
|
+
variableNodeAMatchesVariableNodeB = variableNodeA.match(variableNodeB);
|
|
115
|
+
|
|
116
|
+
if (variableNodeAMatchesVariableNodeB) {
|
|
117
|
+
varialbeNodeMatches = true; ///
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return varialbeNodeMatches;
|
|
122
|
+
}
|
|
123
|
+
|
|
104
124
|
compareTerm(term) {
|
|
105
125
|
const termNode = term.getNode(),
|
|
106
126
|
termNodeMatches = this.matchNode(termNode),
|
|
@@ -129,24 +149,6 @@ export default define(class Term extends Element {
|
|
|
129
149
|
return comparesToParamter;
|
|
130
150
|
}
|
|
131
151
|
|
|
132
|
-
compareVariableIdentifier(variableIdentifier) {
|
|
133
|
-
let comparesToVariableIdentifier = false;
|
|
134
|
-
|
|
135
|
-
const singular = this.isSingular();
|
|
136
|
-
|
|
137
|
-
if (singular) {
|
|
138
|
-
const variableIdentifierA = variableIdentifier; ///
|
|
139
|
-
|
|
140
|
-
variableIdentifier = this.getVariableIdentifier();
|
|
141
|
-
|
|
142
|
-
const variableIdentifierB = variableIdentifier;
|
|
143
|
-
|
|
144
|
-
comparesToVariableIdentifier = (variableIdentifierA === variableIdentifierB);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return comparesToVariableIdentifier;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
152
|
findValidTerm(context) {
|
|
151
153
|
const termNode = this.getTermNode(),
|
|
152
154
|
term = context.findTermByTermNode(termNode),
|