occam-verify-cli 1.0.806 → 1.0.814
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 +242 -0
- package/lib/context/branching.js +3 -3
- package/lib/context/ephemeral.js +3 -3
- package/lib/context/file/nominal.js +16 -16
- package/lib/context/liminal.js +26 -30
- package/lib/context/synoptic.js +272 -0
- package/lib/context.js +66 -54
- package/lib/element/assertion/defined.js +8 -8
- 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/derivation.js +1 -7
- 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/proof.js +2 -2
- package/lib/element/proofAssertion/premise.js +27 -27
- package/lib/element/proofAssertion/step.js +26 -6
- 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 +42 -44
- package/lib/element/signature.js +4 -4
- package/lib/element/statement.js +35 -45
- package/lib/element/subproof.js +5 -5
- package/lib/element/substitution/frame.js +16 -11
- package/lib/element/substitution/reference.js +15 -10
- package/lib/element/substitution/statement.js +62 -56
- package/lib/element/substitution/term.js +15 -10
- package/lib/element/substitution.js +29 -31
- package/lib/element/term.js +1 -16
- package/lib/element/topLevelAssertion/axiom.js +5 -3
- package/lib/element/topLevelAssertion.js +37 -39
- package/lib/element/topLevelMetaAssertion.js +2 -2
- package/lib/element/variable.js +6 -6
- package/lib/node/frame.js +1 -9
- package/lib/node/statement.js +1 -9
- package/lib/node/term.js +1 -19
- package/lib/process/assign.js +23 -31
- package/lib/utilities/context.js +41 -42
- package/lib/utilities/element.js +33 -5
- package/lib/utilities/equivalence.js +4 -4
- package/lib/utilities/equivalences.js +28 -13
- package/lib/utilities/instance.js +3 -3
- package/lib/utilities/string.js +2 -2
- package/lib/utilities/substitutions.js +16 -15
- package/lib/utilities/unification.js +133 -124
- package/package.json +4 -4
- package/src/context/{proof.js → bounded.js} +9 -9
- package/src/context/branching.js +2 -2
- package/src/context/ephemeral.js +2 -2
- package/src/context/file/nominal.js +15 -15
- package/src/context/liminal.js +29 -35
- package/src/context/{synthetic.js → synoptic.js} +84 -4
- package/src/context.js +88 -69
- package/src/element/assertion/defined.js +8 -8
- 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/derivation.js +0 -2
- 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 +15 -10
- package/src/element/proof.js +2 -2
- package/src/element/proofAssertion/premise.js +41 -41
- package/src/element/proofAssertion/step.js +39 -9
- 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 +59 -63
- package/src/element/signature.js +3 -3
- package/src/element/statement.js +54 -68
- package/src/element/subproof.js +5 -5
- package/src/element/substitution/frame.js +18 -8
- package/src/element/substitution/reference.js +16 -7
- package/src/element/substitution/statement.js +87 -74
- package/src/element/substitution/term.js +15 -6
- package/src/element/substitution.js +38 -41
- package/src/element/term.js +0 -26
- package/src/element/topLevelAssertion/axiom.js +5 -2
- package/src/element/topLevelAssertion.js +51 -55
- package/src/element/topLevelMetaAssertion.js +2 -2
- package/src/element/variable.js +5 -5
- package/src/node/frame.js +0 -12
- package/src/node/statement.js +0 -12
- package/src/node/term.js +0 -28
- package/src/process/assign.js +35 -46
- package/src/utilities/context.js +41 -43
- package/src/utilities/element.js +32 -4
- package/src/utilities/equivalence.js +3 -4
- package/src/utilities/equivalences.js +29 -17
- package/src/utilities/instance.js +3 -3
- package/src/utilities/string.js +2 -2
- package/src/utilities/substitutions.js +17 -15
- package/src/utilities/unification.js +145 -119
- package/lib/context/proof.js +0 -242
- package/lib/context/synthetic.js +0 -212
package/src/element/subproof.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { Element, asynchronousUtilities } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import {
|
|
6
|
+
import { enclose } from "../utilities/context";
|
|
7
7
|
|
|
8
8
|
const { asyncEvery } = asynchronousUtilities;
|
|
9
9
|
|
|
@@ -54,16 +54,16 @@ export default define(class Subproof extends Element {
|
|
|
54
54
|
return proofAssertion;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
const
|
|
57
|
+
compareStep(step, context) {
|
|
58
|
+
const comparesToStep = false;
|
|
59
59
|
|
|
60
|
-
return
|
|
60
|
+
return comparesToStep;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
async verify(context) {
|
|
64
64
|
let verifies = false;
|
|
65
65
|
|
|
66
|
-
await
|
|
66
|
+
await enclose(async (context) => {
|
|
67
67
|
const suppositionsVerify = await this.verifySuppositions(context);
|
|
68
68
|
|
|
69
69
|
if (suppositionsVerify) {
|
|
@@ -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,21 +163,23 @@ 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
|
|
|
172
170
|
context.trace(`Validating the '${statementSubstitutionString}' statement substitution's '${substitutionString}' substitution...`);
|
|
173
171
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
172
|
+
descend((context) => {
|
|
173
|
+
const generalContext = context, ///
|
|
174
|
+
specificContext = context, ///
|
|
175
|
+
substitution = this.substitution.validate(generalContext, specificContext);
|
|
177
176
|
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
if (substitution !== null) {
|
|
178
|
+
this.substitution = substitution;
|
|
180
179
|
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
substitutionValidates = true;
|
|
181
|
+
}
|
|
182
|
+
}, context);
|
|
183
183
|
|
|
184
184
|
if (substitutionValidates) {
|
|
185
185
|
context.debug(`...validatewd the '${statementSubstitutionString}' statement substitution's '${substitutionString}' substitution.`);
|
|
@@ -243,41 +243,58 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
243
243
|
return replacementStatementValidates;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
|
|
247
|
-
let
|
|
246
|
+
unifySimpleSubstitution(simpleSubstitution, context) {
|
|
247
|
+
let simpleSubstitutionUnifies;
|
|
248
248
|
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
specificSubstitution = substitution, ///
|
|
252
|
-
generalSubstitutionString = generalSubstitution.getString(),
|
|
253
|
-
specificSubstitutionString = specificSubstitution.getString();
|
|
249
|
+
const substitutionString = this.substitution.getString(),
|
|
250
|
+
simpleSubstitutionString = simpleSubstitution.getString();
|
|
254
251
|
|
|
255
|
-
context.trace(`Unifying the '${
|
|
252
|
+
context.trace(`Unifying the '${simpleSubstitutionString}' simple substitution with the '${substitutionString}' substitution...`);
|
|
256
253
|
|
|
257
|
-
|
|
258
|
-
|
|
254
|
+
const generalSubstitution = this.substitution, ///
|
|
255
|
+
specificSubstitution = simpleSubstitution, ///
|
|
256
|
+
generalSubstitutionGeneralContext = generalSubstitution.getGeneralContext(),
|
|
257
|
+
generalSubstitutionSpecificContext = generalSubstitution.getSpecificContext(),
|
|
258
|
+
specificSubstitutionGeneralContext = specificSubstitution.getGeneralContext(),
|
|
259
|
+
specificSubstitutionSpecificContext = specificSubstitution.getSpecificContext();
|
|
259
260
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
join((specificContext) => {
|
|
262
|
+
join((generalContext) => {
|
|
263
|
+
reconcile((specificContext) => {
|
|
264
|
+
simpleSubstitutionUnifies = unifySubstitution(generalSubstitution, specificSubstitution, generalContext, specificContext);
|
|
265
|
+
|
|
266
|
+
if (simpleSubstitutionUnifies) {
|
|
267
|
+
specificContext.commit(context);
|
|
268
|
+
}
|
|
269
|
+
}, specificContext)
|
|
270
|
+
}, generalSubstitutionSpecificContext, generalSubstitutionGeneralContext);
|
|
271
|
+
}, specificSubstitutionSpecificContext, specificSubstitutionGeneralContext, context);
|
|
264
272
|
|
|
265
|
-
if (
|
|
266
|
-
context.trace(`...unified the '${
|
|
273
|
+
if (simpleSubstitutionUnifies) {
|
|
274
|
+
context.trace(`...unified the '${simpleSubstitutionString}' simple substitution with the '${substitutionString}' substitution.`);
|
|
267
275
|
}
|
|
268
276
|
|
|
269
|
-
return
|
|
277
|
+
return simpleSubstitutionUnifies;
|
|
270
278
|
}
|
|
271
279
|
|
|
272
|
-
unifyComplexSubstitution(complexSubstitution,
|
|
280
|
+
unifyComplexSubstitution(complexSubstitution, context) {
|
|
273
281
|
let substitution = null;
|
|
274
282
|
|
|
275
|
-
const
|
|
276
|
-
simpleSubstitutionString = this.getString(), ///
|
|
283
|
+
const simpleSubstitutionString = this.getString(), ///
|
|
277
284
|
complexSubstitutionString = complexSubstitution.getString(); ///
|
|
278
285
|
|
|
279
286
|
context.trace(`Unifying the '${complexSubstitutionString}' complex substitution with the '${simpleSubstitutionString}' simple substitution...`);
|
|
280
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
|
+
|
|
281
298
|
let simpleSubstitutionUnifies = false;
|
|
282
299
|
|
|
283
300
|
reconcile((specificContext) => {
|
|
@@ -294,6 +311,8 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
294
311
|
}, specificContext);
|
|
295
312
|
|
|
296
313
|
if (substitution !== null) {
|
|
314
|
+
substitution = substitution.validate(generalContext, specificContext);
|
|
315
|
+
|
|
297
316
|
simpleSubstitutionUnifies = true;
|
|
298
317
|
}
|
|
299
318
|
|
|
@@ -326,52 +345,24 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
326
345
|
return replacementStatemnentUnifies;
|
|
327
346
|
}
|
|
328
347
|
|
|
329
|
-
|
|
330
|
-
let substitution;
|
|
331
|
-
|
|
332
|
-
const complexSubstitution = this, ///
|
|
333
|
-
simpleSubstitutionContext = simpleSubstitution.getContext(),
|
|
334
|
-
complexSubstitutionContext = complexSubstitution.getContext();
|
|
335
|
-
|
|
336
|
-
generalContext = simpleSubstitutionContext; ///
|
|
337
|
-
|
|
338
|
-
specificContext = complexSubstitutionContext; ///
|
|
339
|
-
|
|
340
|
-
substitution = simpleSubstitution.unifyComplexSubstitution(complexSubstitution, generalContext, specificContext);
|
|
341
|
-
|
|
342
|
-
return substitution;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
resolve(generalContext, specificContext) {
|
|
348
|
+
resolve(context) {
|
|
346
349
|
let resolved = false;
|
|
347
350
|
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
|
|
351
|
+
const metavariableNode = this.getMetavariableNode(),
|
|
352
|
+
simpleSubstitution = context.findSimpleSubstitutionByMetavariableNode(metavariableNode),
|
|
353
|
+
complexSubstitution = this; ///
|
|
351
354
|
|
|
352
355
|
if (simpleSubstitution !== null) {
|
|
353
356
|
const substitutionString = this.getString(); ///
|
|
354
357
|
|
|
355
358
|
context.trace(`Resolving the ${substitutionString} substitution...`);
|
|
356
359
|
|
|
357
|
-
const substitution =
|
|
360
|
+
const substitution = simpleSubstitution.unifyComplexSubstitution(complexSubstitution, context);
|
|
358
361
|
|
|
359
362
|
if (substitution !== null) {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
context = substitution.getContext();
|
|
363
|
-
|
|
364
|
-
const specificContext = context; ///
|
|
365
|
-
|
|
366
|
-
context = this.substitution.getContext();
|
|
367
|
-
|
|
368
|
-
const generalContext = context; ///
|
|
363
|
+
const simpleSubstitutionUnifies = complexSubstitution.unifySimpleSubstitution(substitution, context);
|
|
369
364
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
const substitutionUnifies = this.unifySubstitution(substitution, generalContext, specificContext);
|
|
373
|
-
|
|
374
|
-
if (substitutionUnifies) {
|
|
365
|
+
if (simpleSubstitutionUnifies) {
|
|
375
366
|
resolved = true;
|
|
376
367
|
}
|
|
377
368
|
|
|
@@ -395,11 +386,14 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
395
386
|
instantiate((context) => {
|
|
396
387
|
const { string } = json,
|
|
397
388
|
statementSubstitutionNode = instantiateStatementSubstitution(string, context),
|
|
398
|
-
node = statementSubstitutionNode,
|
|
389
|
+
node = statementSubstitutionNode, ///
|
|
390
|
+
generalContext = generalContextFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
391
|
+
resolved = resolvedFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
392
|
+
substitution = substitutionFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
399
393
|
targetStatement = targetStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
400
394
|
replacementStatement = replacementStatementFromStatementSubstitutionNode(statementSubstitutionNode, context);
|
|
401
395
|
|
|
402
|
-
statementSubstitutionn = new StatementSubstitution(context, string, node, targetStatement, replacementStatement);
|
|
396
|
+
statementSubstitutionn = new StatementSubstitution(context, string, node, generalContext, resolved, substitution, targetStatement, replacementStatement);
|
|
403
397
|
}, context);
|
|
404
398
|
}
|
|
405
399
|
|
|
@@ -456,3 +450,22 @@ function replacementStatementFromStatementSubstitutionNode(statementSubstitution
|
|
|
456
450
|
|
|
457
451
|
return replacementStatement;
|
|
458
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,9 +46,7 @@ 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
52
|
const targetTermEqualToReplacementTerm = this.targetTerm.isEqualTo(this.replacementTerm),
|
|
@@ -57,6 +55,8 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
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
|
|
|
@@ -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,58 +70,50 @@ 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;
|
|
82
81
|
|
|
83
|
-
return
|
|
82
|
+
return substitution;
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
|
|
87
|
-
const
|
|
85
|
+
getVariableNode() {
|
|
86
|
+
const variableNode = null;
|
|
88
87
|
|
|
89
|
-
return
|
|
88
|
+
return variableNode;
|
|
90
89
|
}
|
|
91
90
|
|
|
92
|
-
|
|
93
|
-
const
|
|
91
|
+
getMetavariableNode() {
|
|
92
|
+
const metavariableNode = null;
|
|
94
93
|
|
|
95
|
-
return
|
|
94
|
+
return metavariableNode;
|
|
96
95
|
}
|
|
97
96
|
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
return comparesToParameter;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
compareMetavariable(metavariable) {
|
|
105
|
-
const compaaresToMetavariable = false;
|
|
97
|
+
isSimple() {
|
|
98
|
+
const simple = true;
|
|
106
99
|
|
|
107
|
-
return
|
|
100
|
+
return simple;
|
|
108
101
|
}
|
|
109
102
|
|
|
110
|
-
|
|
111
|
-
const
|
|
103
|
+
matchSubstitutionNode(substitutionNode) {
|
|
104
|
+
const node = substitutionNode, ///
|
|
105
|
+
nodeMatches = this.matchNode(node),
|
|
106
|
+
substitutionNodeMatches = nodeMatches; ///
|
|
112
107
|
|
|
113
|
-
return
|
|
108
|
+
return substitutionNodeMatches;
|
|
114
109
|
}
|
|
115
110
|
|
|
116
|
-
|
|
117
|
-
const
|
|
111
|
+
findValidSubstitution(context) {
|
|
112
|
+
const substitutionNode = this.getSubstitutionNode(),
|
|
113
|
+
substitution = context.findSubstitutionBySubstitutionNode(substitutionNode),
|
|
114
|
+
validSubstitution = substitution; ///
|
|
118
115
|
|
|
119
|
-
return
|
|
116
|
+
return validSubstitution;
|
|
120
117
|
}
|
|
121
118
|
|
|
122
119
|
resolve(substitutions, generalContext, specificContext) {
|
package/src/element/term.js
CHANGED
|
@@ -41,14 +41,6 @@ export default define(class Term extends Element {
|
|
|
41
41
|
return variableIdentifier;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
isEqualTo(term) {
|
|
45
|
-
const termNode = term.getNode(),
|
|
46
|
-
termNodeMatches = this.matchTermNode(termNode),
|
|
47
|
-
equalTo = termNodeMatches; ///
|
|
48
|
-
|
|
49
|
-
return equalTo;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
44
|
isGrounded(definedVariables, context) {
|
|
53
45
|
const term = this, ///
|
|
54
46
|
variables = variablesFromTerm(term, context);
|
|
@@ -129,24 +121,6 @@ export default define(class Term extends Element {
|
|
|
129
121
|
return comparesToParamter;
|
|
130
122
|
}
|
|
131
123
|
|
|
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
124
|
findValidTerm(context) {
|
|
151
125
|
const termNode = this.getTermNode(),
|
|
152
126
|
term = context.findTermByTermNode(termNode),
|