occam-verify-cli 1.0.862 → 1.0.865
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/liminal.js +16 -24
- package/lib/context/mnemic.js +5 -51
- package/lib/context/synoptic.js +26 -12
- package/lib/context.js +1 -37
- package/lib/element/assumption/metaLevel.js +3 -3
- package/lib/element/combinator.js +2 -2
- package/lib/element/conclusion.js +2 -2
- package/lib/element/constructor.js +2 -2
- package/lib/element/deduction.js +2 -2
- package/lib/element/label.js +2 -2
- package/lib/element/metavariable.js +10 -10
- package/lib/element/proofAssertion/premise.js +2 -2
- package/lib/element/proofAssertion/step.js +2 -2
- package/lib/element/proofAssertion/supposition.js +2 -2
- package/lib/element/reference.js +2 -2
- package/lib/element/substitution/frame.js +35 -33
- package/lib/element/substitution/reference.js +34 -32
- package/lib/element/substitution/statement.js +36 -34
- package/lib/element/substitution/term.js +33 -31
- package/lib/element/substitution.js +63 -29
- package/lib/element/variable.js +4 -4
- package/lib/process/unify.js +5 -5
- package/lib/utilities/context.js +42 -18
- package/lib/utilities/element.js +27 -66
- package/lib/utilities/json.js +27 -8
- package/lib/utilities/validation.js +7 -7
- package/package.json +4 -4
- package/src/context/liminal.js +15 -26
- package/src/context/mnemic.js +8 -64
- package/src/context/synoptic.js +37 -11
- package/src/context.js +0 -54
- package/src/element/assumption/metaLevel.js +2 -2
- package/src/element/combinator.js +1 -1
- package/src/element/conclusion.js +1 -1
- package/src/element/constructor.js +1 -1
- package/src/element/deduction.js +1 -1
- package/src/element/label.js +1 -1
- package/src/element/metavariable.js +10 -10
- package/src/element/proofAssertion/premise.js +1 -1
- package/src/element/proofAssertion/step.js +1 -1
- package/src/element/proofAssertion/supposition.js +1 -1
- package/src/element/reference.js +1 -1
- package/src/element/substitution/frame.js +39 -33
- package/src/element/substitution/reference.js +44 -35
- package/src/element/substitution/statement.js +45 -37
- package/src/element/substitution/term.js +44 -35
- package/src/element/substitution.js +80 -35
- package/src/element/variable.js +3 -3
- package/src/process/unify.js +3 -5
- package/src/utilities/context.js +50 -24
- package/src/utilities/element.js +36 -70
- package/src/utilities/json.js +31 -12
- package/src/utilities/validation.js +9 -9
|
@@ -6,11 +6,11 @@ import { define } from "../../elements";
|
|
|
6
6
|
import { instantiateFrameSubstitution } from "../../process/instantiate";
|
|
7
7
|
import { frameSubstitutionFromFrameSubstitutionNode } from "../../utilities/element";
|
|
8
8
|
import { frameSubstitutionStringFromFrameAndMetavariable } from "../../utilities/string";
|
|
9
|
-
import {
|
|
9
|
+
import { ablates, descend, attempt, instantiate, unserialises } from "../../utilities/context";
|
|
10
10
|
|
|
11
11
|
export default define(class FrameSubstitution extends Substitution {
|
|
12
|
-
constructor(
|
|
13
|
-
super(
|
|
12
|
+
constructor(contexts, string, node, lineIndex, targetFrame, replacementFrame) {
|
|
13
|
+
super(contexts, string, node, lineIndex);
|
|
14
14
|
|
|
15
15
|
this.targetFrame = targetFrame;
|
|
16
16
|
this.replacementFrame = replacementFrame;
|
|
@@ -70,11 +70,10 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
70
70
|
return comparesToParameter;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
validate(
|
|
73
|
+
validate(context) {
|
|
74
74
|
let frameSubstitution = null;
|
|
75
75
|
|
|
76
|
-
const
|
|
77
|
-
frameSubstitutionString = this.getString(); ///
|
|
76
|
+
const frameSubstitutionString = this.getString(); ///
|
|
78
77
|
|
|
79
78
|
context.trace(`Validating the '${frameSubstitutionString}' frame substitution...`);
|
|
80
79
|
|
|
@@ -87,27 +86,26 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
87
86
|
|
|
88
87
|
context.debug(`...the '${frameSubstitutionString}' frame substitution is already valid.`);
|
|
89
88
|
} else {
|
|
90
|
-
const
|
|
89
|
+
const generalContext = this.getGeneralContext(),
|
|
90
|
+
specificContext = this.getSpecificContext();
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const targetFrameValidates = this.validateTargetFrame(generalContext, specificContext);
|
|
92
|
+
attempt((generalContext) => {
|
|
93
|
+
attempt((specificContext) => {
|
|
94
|
+
const targetFrameValidates = this.validateTargetFrame(generalContext, specificContext);
|
|
96
95
|
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
if (targetFrameValidates) {
|
|
97
|
+
const replacementFrameValidates = this.validateReplacementFrame(generalContext, specificContext);
|
|
99
98
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
99
|
+
if (replacementFrameValidates) {
|
|
100
|
+
validates = true;
|
|
103
101
|
}
|
|
102
|
+
}
|
|
104
103
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}, generalContext, context);
|
|
104
|
+
if (validates) {
|
|
105
|
+
this.commit(generalContext, specificContext);
|
|
106
|
+
}
|
|
107
|
+
}, specificContext);
|
|
108
|
+
}, generalContext);
|
|
111
109
|
}
|
|
112
110
|
|
|
113
111
|
if (validates) {
|
|
@@ -189,17 +187,22 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
189
187
|
const { name } = json;
|
|
190
188
|
|
|
191
189
|
if (this.name === name) {
|
|
192
|
-
|
|
190
|
+
unserialises((json, generalContext, specificContext) => {
|
|
193
191
|
const context = specificContext; ///
|
|
194
192
|
|
|
195
193
|
instantiate((context) => {
|
|
196
194
|
const { string, lineIndex } = json,
|
|
195
|
+
specificContext = context, ///
|
|
196
|
+
contexts = [
|
|
197
|
+
generalContext,
|
|
198
|
+
specificContext
|
|
199
|
+
],
|
|
197
200
|
frameSubstitutionNode = instantiateFrameSubstitution(string, context),
|
|
198
201
|
node = frameSubstitutionNode, ///
|
|
199
202
|
targetFrame = targetFrameFromFrameSubstitutionNode(frameSubstitutionNode, context),
|
|
200
203
|
replacementFrame = replacementFrameFromFrameSubstitutionNode(frameSubstitutionNode, context);
|
|
201
204
|
|
|
202
|
-
frameSubstitutionn = new FrameSubstitution(
|
|
205
|
+
frameSubstitutionn = new FrameSubstitution(contexts, string, node, lineIndex, targetFrame, replacementFrame);
|
|
203
206
|
}, context);
|
|
204
207
|
}, json, context);
|
|
205
208
|
}
|
|
@@ -207,32 +210,35 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
207
210
|
return frameSubstitutionn;
|
|
208
211
|
}
|
|
209
212
|
|
|
210
|
-
static fromStatement(statement,
|
|
213
|
+
static fromStatement(statement, generalContext, specificContext) {
|
|
211
214
|
let frameSubstitution = null;
|
|
212
215
|
|
|
213
216
|
const frameSubstitutionNode = statement.getFrameSubstitutionNode();
|
|
214
217
|
|
|
215
218
|
if (frameSubstitutionNode !== null) {
|
|
216
|
-
|
|
217
|
-
frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode,
|
|
218
|
-
},
|
|
219
|
+
ablates((generalContext, specificContext) => {
|
|
220
|
+
frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, generalContext, specificContext);
|
|
221
|
+
}, generalContext, specificContext);
|
|
219
222
|
}
|
|
220
223
|
|
|
221
224
|
return frameSubstitution;
|
|
222
225
|
}
|
|
223
226
|
|
|
224
|
-
static fromFrameAndMetavariable(frame, metavariable,
|
|
227
|
+
static fromFrameAndMetavariable(frame, metavariable, generalContext, specificContext) {
|
|
225
228
|
let frameSubstitution
|
|
226
229
|
|
|
227
|
-
|
|
230
|
+
ablates((generalContext, specificContext) => {
|
|
231
|
+
const context = specificContext; ///
|
|
232
|
+
|
|
228
233
|
instantiate((context) => {
|
|
229
|
-
const
|
|
234
|
+
const specificContext = context, ///
|
|
235
|
+
frameSubstitutionString = frameSubstitutionStringFromFrameAndMetavariable(frame, metavariable),
|
|
230
236
|
string = frameSubstitutionString, ///
|
|
231
237
|
frameSubstitutionNode = instantiateFrameSubstitution(string, context);
|
|
232
238
|
|
|
233
|
-
frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode,
|
|
239
|
+
frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, generalContext, specificContext);
|
|
234
240
|
}, context);
|
|
235
|
-
},
|
|
241
|
+
}, generalContext, specificContext);
|
|
236
242
|
|
|
237
243
|
return frameSubstitution;
|
|
238
244
|
}
|
|
@@ -5,12 +5,12 @@ import Substitution from "../substitution";
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
6
|
import { instantiateReferenceSubstitution } from "../../process/instantiate";
|
|
7
7
|
import { referenceSubstitutionFromReferenceSubstitutionNode } from "../../utilities/element";
|
|
8
|
+
import { ablate, descend, attempt, instantiate, unserialises } from "../../utilities/context";
|
|
8
9
|
import { referenceSubstitutionStringFromReferenceAndMetavariable } from "../../utilities/string";
|
|
9
|
-
import { join, ablate, descend, attempt, unserialise, instantiate } from "../../utilities/context";
|
|
10
10
|
|
|
11
11
|
export default define(class ReferenceSubstitution extends Substitution {
|
|
12
|
-
constructor(context, string, node, lineIndex,
|
|
13
|
-
super(context, string, node, lineIndex
|
|
12
|
+
constructor(context, string, node, lineIndex, targetReference, replacementReference) {
|
|
13
|
+
super(context, string, node, lineIndex);
|
|
14
14
|
|
|
15
15
|
this.targetReference = targetReference;
|
|
16
16
|
this.replacementReference = replacementReference;
|
|
@@ -87,11 +87,10 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
87
87
|
return substitutionCompares;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
validate(
|
|
90
|
+
validate(context) {
|
|
91
91
|
let referenceSubstitution = null;
|
|
92
92
|
|
|
93
|
-
const
|
|
94
|
-
referenceSubstitutionString = this.getString(); ///
|
|
93
|
+
const referenceSubstitutionString = this.getString(); ///
|
|
95
94
|
|
|
96
95
|
context.trace(`Validating the '${referenceSubstitutionString}' reference substitution...`);
|
|
97
96
|
|
|
@@ -104,27 +103,26 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
104
103
|
|
|
105
104
|
context.debug(`...the '${referenceSubstitutionString}' reference substitution is already valid.`);
|
|
106
105
|
} else {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}, generalContext, context);
|
|
106
|
+
const generalContext = this.getGeneralContext(),
|
|
107
|
+
specificContext = this.getSpecificContext();
|
|
108
|
+
|
|
109
|
+
attempt((specificContext) => {
|
|
110
|
+
const targetReferenceValidates = this.validateTargetReference(generalContext, specificContext);
|
|
111
|
+
|
|
112
|
+
if (targetReferenceValidates) {
|
|
113
|
+
const replacementReferenceValidates = this.validateReplacementReference(generalContext, specificContext);
|
|
114
|
+
|
|
115
|
+
if (replacementReferenceValidates) {
|
|
116
|
+
validates = true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (validates) {
|
|
121
|
+
context = specificContext; ///
|
|
122
|
+
|
|
123
|
+
this.commit(context);
|
|
124
|
+
}
|
|
125
|
+
}, specificContext);
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
if (validates) {
|
|
@@ -194,17 +192,22 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
194
192
|
const { name } = json;
|
|
195
193
|
|
|
196
194
|
if (this.name === name) {
|
|
197
|
-
|
|
195
|
+
unserialises((json, generalContext, specificContext) => {
|
|
198
196
|
const context = specificContext; ///
|
|
199
197
|
|
|
200
198
|
instantiate((context) => {
|
|
201
199
|
const { string, lineIndex } = json,
|
|
200
|
+
specificContext = context, ///
|
|
201
|
+
contexts = [
|
|
202
|
+
generalContext,
|
|
203
|
+
specificContext
|
|
204
|
+
],
|
|
202
205
|
referenceSubstitutionNode = instantiateReferenceSubstitution(string, context),
|
|
203
206
|
node = referenceSubstitutionNode, ///
|
|
204
207
|
targetReference = targetReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
|
|
205
208
|
replacementReference = replacementReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
|
|
206
209
|
|
|
207
|
-
referenceSubstitutionn = new ReferenceSubstitution(
|
|
210
|
+
referenceSubstitutionn = new ReferenceSubstitution(contexts, string, node, lineIndex, targetReference, replacementReference);
|
|
208
211
|
}, context);
|
|
209
212
|
}, json, context);
|
|
210
213
|
}
|
|
@@ -212,34 +215,40 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
212
215
|
return referenceSubstitutionn;
|
|
213
216
|
}
|
|
214
217
|
|
|
215
|
-
static fromReferenceAndMetavariable(reference, metavariable,
|
|
218
|
+
static fromReferenceAndMetavariable(reference, metavariable, generalContext, specificContext) {
|
|
216
219
|
let referenceSubstitution;
|
|
217
220
|
|
|
221
|
+
const context = specificContext; ///
|
|
222
|
+
|
|
218
223
|
ablate((context) => {
|
|
219
224
|
instantiate((context) => {
|
|
220
|
-
const
|
|
225
|
+
const specificContext = context, ///
|
|
226
|
+
referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
|
|
221
227
|
string = referenceSubstitutionString, ///
|
|
222
228
|
referenceSubstitutionNode = instantiateReferenceSubstitution(string, context);
|
|
223
229
|
|
|
224
|
-
referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode,
|
|
230
|
+
referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, generalContext, specificContext);
|
|
225
231
|
}, context);
|
|
226
232
|
}, context);
|
|
227
233
|
|
|
228
234
|
return referenceSubstitution;
|
|
229
235
|
}
|
|
230
236
|
|
|
231
|
-
static fromAssumptionAndMetaLevelAssumption(assumption, metaLevelAssumption,
|
|
237
|
+
static fromAssumptionAndMetaLevelAssumption(assumption, metaLevelAssumption, generalContext, specificContext) {
|
|
232
238
|
let referenceSubstitution;
|
|
233
239
|
|
|
240
|
+
const context = specificContext; ///
|
|
241
|
+
|
|
234
242
|
ablate((context) => {
|
|
235
243
|
instantiate((context) => {
|
|
236
|
-
const
|
|
244
|
+
const specificContext = context, ///
|
|
237
245
|
metavariable = assumption.getMetavariable(),
|
|
246
|
+
reference = metaLevelAssumption.getReference(),
|
|
238
247
|
referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
|
|
239
248
|
string = referenceSubstitutionString, ///
|
|
240
249
|
referenceSubstitutionNode = instantiateReferenceSubstitution(string, context);
|
|
241
250
|
|
|
242
|
-
referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode,
|
|
251
|
+
referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, generalContext, specificContext);
|
|
243
252
|
}, context);
|
|
244
253
|
}, context);
|
|
245
254
|
|
|
@@ -7,12 +7,12 @@ import { unifySubstitution } from "../../process/unify";
|
|
|
7
7
|
import { stripBracketsFromStatement } from "../../utilities/brackets";
|
|
8
8
|
import { instantiateStatementSubstitution } from "../../process/instantiate";
|
|
9
9
|
import { statementSubstitutionFromStatementSubstitutionNode } from "../../utilities/element";
|
|
10
|
-
import { join, ablate, descend, reconcile, attempt,
|
|
10
|
+
import { join, ablate, descend, reconcile, attempt, instantiate, unserialises } from "../../utilities/context";
|
|
11
11
|
import { statementSubstitutionStringFromStatementAndMetavariable, statementSubstitutionStringFromStatementMetavariableAndSubstitution } from "../../utilities/string";
|
|
12
12
|
|
|
13
13
|
export default define(class StatementSubstitution extends Substitution {
|
|
14
|
-
constructor(
|
|
15
|
-
super(
|
|
14
|
+
constructor(contexts, string, node, lineIndex, resolved, substitution, targetStatement, replacementStatement) {
|
|
15
|
+
super(contexts, string, node, lineIndex);
|
|
16
16
|
|
|
17
17
|
this.resolved = resolved;
|
|
18
18
|
this.substitution = substitution;
|
|
@@ -83,11 +83,10 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
83
83
|
return comparesToParameter;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
validate(substitution,
|
|
86
|
+
validate(substitution, context) {
|
|
87
87
|
let statementSubstitution = null;
|
|
88
88
|
|
|
89
|
-
const
|
|
90
|
-
statementSubstitutionString = this.getString(); ///
|
|
89
|
+
const statementSubstitutionString = this.getString(); ///
|
|
91
90
|
|
|
92
91
|
context.trace(`Validating the '${statementSubstitutionString}' statement substitution...`);
|
|
93
92
|
|
|
@@ -100,31 +99,30 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
100
99
|
|
|
101
100
|
context.debug(`...the '${statementSubstitutionString}' statement substitution is already valid.`);
|
|
102
101
|
} else {
|
|
103
|
-
const
|
|
102
|
+
const generalContext = this.getGeneralContext(),
|
|
103
|
+
specificContext = this.getSpecificContext();
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
attempt((generalContext, specificContext) => {
|
|
108
|
-
const targetStatementValidates = this.validateTargetStatement(generalContext, specificContext);
|
|
105
|
+
attempt((specificContext) => {
|
|
106
|
+
const targetStatementValidates = this.validateTargetStatement(generalContext, specificContext);
|
|
109
107
|
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
if (targetStatementValidates) {
|
|
109
|
+
const replacementStatementValidates = this.validateReplacementStatement(generalContext, specificContext);
|
|
112
110
|
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
if (replacementStatementValidates) {
|
|
112
|
+
const substitutionValidates = this.validateSubstitution(substitution, generalContext, specificContext);
|
|
115
113
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
}
|
|
114
|
+
if (substitutionValidates) {
|
|
115
|
+
validates = true;
|
|
120
116
|
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
121
119
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
},
|
|
120
|
+
if (validates) {
|
|
121
|
+
context = specificContext; ///
|
|
122
|
+
|
|
123
|
+
this.commit(context);
|
|
124
|
+
}
|
|
125
|
+
}, specificContext);
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
if (validates) {
|
|
@@ -272,9 +270,8 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
272
270
|
replacementStatementUnifies = this.unifyReplacementStatement(replacementStatement, generalContext, specificContext);
|
|
273
271
|
|
|
274
272
|
if (replacementStatementUnifies) {
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
soleNonTrivialDerivedSubstitution = context.getSoleNonTrivialDerivedSubstitution(nested);
|
|
273
|
+
const context = specificContext, ///
|
|
274
|
+
soleNonTrivialDerivedSubstitution = context.getSoleNonTrivialDerivedSubstitution();
|
|
278
275
|
|
|
279
276
|
substitution = soleNonTrivialDerivedSubstitution; ///
|
|
280
277
|
}
|
|
@@ -353,19 +350,24 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
353
350
|
const { name } = json;
|
|
354
351
|
|
|
355
352
|
if (this.name === name) {
|
|
356
|
-
|
|
353
|
+
unserialises((json, generalContext, specificContext) => {
|
|
357
354
|
const context = specificContext; ///
|
|
358
355
|
|
|
359
356
|
instantiate((context) => {
|
|
360
357
|
const { string, lineIndex } = json,
|
|
358
|
+
specificContext = context, ///
|
|
359
|
+
contexts = [
|
|
360
|
+
generalContext,
|
|
361
|
+
specificContext
|
|
362
|
+
],
|
|
361
363
|
statementSubstitutionNode = instantiateStatementSubstitution(string, context),
|
|
362
364
|
node = statementSubstitutionNode, ///
|
|
363
365
|
resolved = resolvedFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
364
|
-
substitution = substitutionFromStatementSubstitutionNode(statementSubstitutionNode,
|
|
366
|
+
substitution = substitutionFromStatementSubstitutionNode(statementSubstitutionNode, generalContext, specificContext),
|
|
365
367
|
targetStatement = targetStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
366
368
|
replacementStatement = replacementStatementFromStatementSubstitutionNode(statementSubstitutionNode, context);
|
|
367
369
|
|
|
368
|
-
statementSubstitutionn = new StatementSubstitution(
|
|
370
|
+
statementSubstitutionn = new StatementSubstitution(contexts, string, node, lineIndex, resolved, substitution, targetStatement, replacementStatement);
|
|
369
371
|
}, context);
|
|
370
372
|
}, json, context);
|
|
371
373
|
}
|
|
@@ -373,36 +375,42 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
373
375
|
return statementSubstitutionn;
|
|
374
376
|
}
|
|
375
377
|
|
|
376
|
-
static fromStatementAndMetavariable(statement, metavariable,
|
|
378
|
+
static fromStatementAndMetavariable(statement, metavariable, generalContext, specificContext) {
|
|
379
|
+
const context = specificContext; ///
|
|
380
|
+
|
|
377
381
|
statement = stripBracketsFromStatement(statement, context); ///
|
|
378
382
|
|
|
379
383
|
let statementSubstitution;
|
|
380
384
|
|
|
381
385
|
ablate((context) => {
|
|
382
386
|
instantiate((context) => {
|
|
383
|
-
const
|
|
387
|
+
const specificContext = context, ///
|
|
388
|
+
statementSubstitutionString = statementSubstitutionStringFromStatementAndMetavariable(statement, metavariable),
|
|
384
389
|
string = statementSubstitutionString, ///
|
|
385
390
|
statementSubstitutionNode = instantiateStatementSubstitution(string, context);
|
|
386
391
|
|
|
387
|
-
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode,
|
|
392
|
+
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, generalContext, specificContext);
|
|
388
393
|
}, context);
|
|
389
394
|
}, context);
|
|
390
395
|
|
|
391
396
|
return statementSubstitution;
|
|
392
397
|
}
|
|
393
398
|
|
|
394
|
-
static fromStatementMetavariableAndSubstitution(statement, metavariable, substitution,
|
|
399
|
+
static fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, generalContext, specificContext) {
|
|
400
|
+
const context = specificContext; ///
|
|
401
|
+
|
|
395
402
|
statement = stripBracketsFromStatement(statement, context); ///
|
|
396
403
|
|
|
397
404
|
let statementSubstitution;
|
|
398
405
|
|
|
399
406
|
ablate((context) => {
|
|
400
407
|
instantiate((context) => {
|
|
401
|
-
const
|
|
408
|
+
const specificContext = context, ///
|
|
409
|
+
statementSubstitutionString = statementSubstitutionStringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution),
|
|
402
410
|
string = statementSubstitutionString, ///
|
|
403
411
|
statementSubstitutionNode = instantiateStatementSubstitution(string, context);
|
|
404
412
|
|
|
405
|
-
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode,
|
|
413
|
+
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, generalContext, specificContext);
|
|
406
414
|
}, context);
|
|
407
415
|
}, context);
|
|
408
416
|
|
|
@@ -7,11 +7,11 @@ import { stripBracketsFromTerm } from "../../utilities/brackets";
|
|
|
7
7
|
import { instantiateTermSubstitution } from "../../process/instantiate";
|
|
8
8
|
import { termSubstitutionFromTermSubstitutionNode } from "../../utilities/element";
|
|
9
9
|
import { termSubstitutionStringFromTermAndVariable } from "../../utilities/string";
|
|
10
|
-
import {
|
|
10
|
+
import { ablate, descend, attempt, instantiate, unserialises } from "../../utilities/context";
|
|
11
11
|
|
|
12
12
|
export default define(class TermSubstitution extends Substitution {
|
|
13
|
-
constructor(context, string, node, lineIndex,
|
|
14
|
-
super(context, string, node, lineIndex
|
|
13
|
+
constructor(context, string, node, lineIndex, targetTerm, replacementTerm) {
|
|
14
|
+
super(context, string, node, lineIndex);
|
|
15
15
|
|
|
16
16
|
this.targetTerm = targetTerm;
|
|
17
17
|
this.replacementTerm = replacementTerm;
|
|
@@ -73,11 +73,10 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
73
73
|
return comparesToParameter;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
validate(
|
|
76
|
+
validate(context) {
|
|
77
77
|
let termSubstitution = null;
|
|
78
78
|
|
|
79
|
-
const
|
|
80
|
-
termSubstitutionString = this.getString(); ///
|
|
79
|
+
const termSubstitutionString = this.getString(); ///
|
|
81
80
|
|
|
82
81
|
context.trace(`Validating the '${termSubstitutionString}' term substitution...`);
|
|
83
82
|
|
|
@@ -90,27 +89,26 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
90
89
|
|
|
91
90
|
context.debug(`...the '${termSubstitutionString}' term substitution is already valid.`);
|
|
92
91
|
} else {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}, generalContext, context);
|
|
92
|
+
const generalContext = this.getGeneralContext(),
|
|
93
|
+
specificContext = this.getSpecificContext();
|
|
94
|
+
|
|
95
|
+
attempt((specificContext) => {
|
|
96
|
+
const targetTermValidates = this.validateTargetTerm(generalContext, specificContext);
|
|
97
|
+
|
|
98
|
+
if (targetTermValidates) {
|
|
99
|
+
const replacementTermValidates = this.validateReplacementTerm(generalContext, specificContext);
|
|
100
|
+
|
|
101
|
+
if (replacementTermValidates) {
|
|
102
|
+
validates = true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (validates) {
|
|
107
|
+
context = specificContext; ///
|
|
108
|
+
|
|
109
|
+
this.commit(context);
|
|
110
|
+
}
|
|
111
|
+
}, specificContext);
|
|
114
112
|
}
|
|
115
113
|
|
|
116
114
|
if (validates) {
|
|
@@ -200,17 +198,22 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
200
198
|
const { name } = json;
|
|
201
199
|
|
|
202
200
|
if (this.name === name) {
|
|
203
|
-
|
|
201
|
+
unserialises((json, generalContext, specificContext) => {
|
|
204
202
|
const context = specificContext; ///
|
|
205
203
|
|
|
206
204
|
instantiate((context) => {
|
|
207
205
|
const { string, lineIndex } = json,
|
|
206
|
+
specificContext = context, ///
|
|
207
|
+
contexts = [
|
|
208
|
+
generalContext,
|
|
209
|
+
specificContext
|
|
210
|
+
],
|
|
208
211
|
termSubstitutionNode = instantiateTermSubstitution(string, context),
|
|
209
212
|
node = termSubstitutionNode, ///
|
|
210
213
|
targetTerm = targetTermFromTermSubstitutionNode(termSubstitutionNode, context),
|
|
211
214
|
replacementTerm = replacementTermFromTermSubstitutionNode(termSubstitutionNode, context);
|
|
212
215
|
|
|
213
|
-
termSubstitutionn = new TermSubstitution(
|
|
216
|
+
termSubstitutionn = new TermSubstitution(contexts, string, node, lineIndex, targetTerm, replacementTerm);
|
|
214
217
|
}, context);
|
|
215
218
|
}, json, context);
|
|
216
219
|
}
|
|
@@ -218,32 +221,38 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
218
221
|
return termSubstitutionn;
|
|
219
222
|
}
|
|
220
223
|
|
|
221
|
-
static fromStatement(statement,
|
|
224
|
+
static fromStatement(statement, generalContext, specificContext) {
|
|
222
225
|
let termSubstitution = null;
|
|
223
226
|
|
|
224
|
-
const
|
|
227
|
+
const context = specificContext, ///
|
|
228
|
+
termSubstitutionNode = statement.getTermSubstitutionNode();
|
|
225
229
|
|
|
226
230
|
if (termSubstitutionNode !== null) {
|
|
227
231
|
ablate((context) => {
|
|
228
|
-
|
|
232
|
+
const specificContext = context; ///
|
|
233
|
+
|
|
234
|
+
termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, generalContext, specificContext);
|
|
229
235
|
}, context);
|
|
230
236
|
}
|
|
231
237
|
|
|
232
238
|
return termSubstitution;
|
|
233
239
|
}
|
|
234
240
|
|
|
235
|
-
static fromTermAndVariable(term, variable,
|
|
241
|
+
static fromTermAndVariable(term, variable, generalContext, specificContext) {
|
|
242
|
+
const context = specificContext; ///
|
|
243
|
+
|
|
236
244
|
term = stripBracketsFromTerm(term, context); ///
|
|
237
245
|
|
|
238
246
|
let termSubstitution;
|
|
239
247
|
|
|
240
248
|
ablate((context) => {
|
|
241
249
|
instantiate((context) => {
|
|
242
|
-
const
|
|
250
|
+
const specificContext = context, ///
|
|
251
|
+
termSubstitutionString = termSubstitutionStringFromTermAndVariable(term, variable),
|
|
243
252
|
string = termSubstitutionString, ///
|
|
244
253
|
termSubstitutionNode = instantiateTermSubstitution(string, context);
|
|
245
254
|
|
|
246
|
-
termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode,
|
|
255
|
+
termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, generalContext, specificContext);
|
|
247
256
|
}, context);
|
|
248
257
|
}, context);
|
|
249
258
|
|