occam-verify-cli 1.0.862 → 1.0.866
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/literal.js +1 -9
- 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 +34 -34
- package/lib/element/substitution/reference.js +37 -36
- package/lib/element/substitution/statement.js +41 -38
- package/lib/element/substitution/term.js +35 -34
- package/lib/element/substitution.js +66 -29
- package/lib/element/variable.js +4 -4
- package/lib/process/unify.js +5 -5
- package/lib/utilities/context.js +52 -17
- 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/literal.js +0 -14
- 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 +42 -38
- package/src/element/substitution/reference.js +46 -39
- package/src/element/substitution/statement.js +51 -41
- package/src/element/substitution/term.js +44 -38
- package/src/element/substitution.js +84 -35
- package/src/element/variable.js +3 -3
- package/src/process/unify.js +3 -5
- package/src/utilities/context.js +61 -23
- 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, attempts, descend, 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,24 @@ 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
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}, generalContext, specificContext);
|
|
109
|
-
}, specificContext, context);
|
|
110
|
-
}, generalContext, context);
|
|
89
|
+
const generalContext = this.getGeneralContext(),
|
|
90
|
+
specificContext = this.getSpecificContext();
|
|
91
|
+
|
|
92
|
+
attempts((generalContext, specificContext) => {
|
|
93
|
+
const targetFrameValidates = this.validateTargetFrame(generalContext, specificContext);
|
|
94
|
+
|
|
95
|
+
if (targetFrameValidates) {
|
|
96
|
+
const replacementFrameValidates = this.validateReplacementFrame(generalContext, specificContext);
|
|
97
|
+
|
|
98
|
+
if (replacementFrameValidates) {
|
|
99
|
+
validates = true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (validates) {
|
|
104
|
+
this.commit(generalContext, specificContext);
|
|
105
|
+
}
|
|
106
|
+
}, generalContext, specificContext);
|
|
111
107
|
}
|
|
112
108
|
|
|
113
109
|
if (validates) {
|
|
@@ -189,17 +185,22 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
189
185
|
const { name } = json;
|
|
190
186
|
|
|
191
187
|
if (this.name === name) {
|
|
192
|
-
|
|
188
|
+
unserialises((json, generalContext, specificContext) => {
|
|
193
189
|
const context = specificContext; ///
|
|
194
190
|
|
|
195
191
|
instantiate((context) => {
|
|
196
192
|
const { string, lineIndex } = json,
|
|
193
|
+
specificContext = context, ///
|
|
194
|
+
contexts = [
|
|
195
|
+
generalContext,
|
|
196
|
+
specificContext
|
|
197
|
+
],
|
|
197
198
|
frameSubstitutionNode = instantiateFrameSubstitution(string, context),
|
|
198
199
|
node = frameSubstitutionNode, ///
|
|
199
200
|
targetFrame = targetFrameFromFrameSubstitutionNode(frameSubstitutionNode, context),
|
|
200
201
|
replacementFrame = replacementFrameFromFrameSubstitutionNode(frameSubstitutionNode, context);
|
|
201
202
|
|
|
202
|
-
frameSubstitutionn = new FrameSubstitution(
|
|
203
|
+
frameSubstitutionn = new FrameSubstitution(contexts, string, node, lineIndex, targetFrame, replacementFrame);
|
|
203
204
|
}, context);
|
|
204
205
|
}, json, context);
|
|
205
206
|
}
|
|
@@ -207,32 +208,35 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
207
208
|
return frameSubstitutionn;
|
|
208
209
|
}
|
|
209
210
|
|
|
210
|
-
static fromStatement(statement,
|
|
211
|
+
static fromStatement(statement, generalContext, specificContext) {
|
|
211
212
|
let frameSubstitution = null;
|
|
212
213
|
|
|
213
214
|
const frameSubstitutionNode = statement.getFrameSubstitutionNode();
|
|
214
215
|
|
|
215
216
|
if (frameSubstitutionNode !== null) {
|
|
216
|
-
|
|
217
|
-
frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode,
|
|
218
|
-
},
|
|
217
|
+
ablates((generalContext, specificContext) => {
|
|
218
|
+
frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, generalContext, specificContext);
|
|
219
|
+
}, generalContext, specificContext);
|
|
219
220
|
}
|
|
220
221
|
|
|
221
222
|
return frameSubstitution;
|
|
222
223
|
}
|
|
223
224
|
|
|
224
|
-
static fromFrameAndMetavariable(frame, metavariable,
|
|
225
|
+
static fromFrameAndMetavariable(frame, metavariable, generalContext, specificContext) {
|
|
225
226
|
let frameSubstitution
|
|
226
227
|
|
|
227
|
-
|
|
228
|
+
ablates((generalContext, specificContext) => {
|
|
229
|
+
const context = specificContext; ///
|
|
230
|
+
|
|
228
231
|
instantiate((context) => {
|
|
229
|
-
const
|
|
232
|
+
const specificContext = context, ///
|
|
233
|
+
frameSubstitutionString = frameSubstitutionStringFromFrameAndMetavariable(frame, metavariable),
|
|
230
234
|
string = frameSubstitutionString, ///
|
|
231
235
|
frameSubstitutionNode = instantiateFrameSubstitution(string, context);
|
|
232
236
|
|
|
233
|
-
frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode,
|
|
237
|
+
frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, generalContext, specificContext);
|
|
234
238
|
}, context);
|
|
235
|
-
},
|
|
239
|
+
}, generalContext, specificContext);
|
|
236
240
|
|
|
237
241
|
return frameSubstitution;
|
|
238
242
|
}
|
|
@@ -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 { ablates, attempts, descend, 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,24 @@ 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
|
-
}, generalContext, specificContext);
|
|
126
|
-
}, specificContext, context);
|
|
127
|
-
}, generalContext, context);
|
|
106
|
+
const generalContext = this.getGeneralContext(),
|
|
107
|
+
specificContext = this.getSpecificContext();
|
|
108
|
+
|
|
109
|
+
attempts((generalContext, 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
|
+
this.commit(generalContext, specificContext);
|
|
122
|
+
}
|
|
123
|
+
}, generalContext, specificContext);
|
|
128
124
|
}
|
|
129
125
|
|
|
130
126
|
if (validates) {
|
|
@@ -194,17 +190,22 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
194
190
|
const { name } = json;
|
|
195
191
|
|
|
196
192
|
if (this.name === name) {
|
|
197
|
-
|
|
193
|
+
unserialises((json, generalContext, specificContext) => {
|
|
198
194
|
const context = specificContext; ///
|
|
199
195
|
|
|
200
196
|
instantiate((context) => {
|
|
201
197
|
const { string, lineIndex } = json,
|
|
198
|
+
specificContext = context, ///
|
|
199
|
+
contexts = [
|
|
200
|
+
generalContext,
|
|
201
|
+
specificContext
|
|
202
|
+
],
|
|
202
203
|
referenceSubstitutionNode = instantiateReferenceSubstitution(string, context),
|
|
203
204
|
node = referenceSubstitutionNode, ///
|
|
204
205
|
targetReference = targetReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
|
|
205
206
|
replacementReference = replacementReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
|
|
206
207
|
|
|
207
|
-
referenceSubstitutionn = new ReferenceSubstitution(
|
|
208
|
+
referenceSubstitutionn = new ReferenceSubstitution(contexts, string, node, lineIndex, targetReference, replacementReference);
|
|
208
209
|
}, context);
|
|
209
210
|
}, json, context);
|
|
210
211
|
}
|
|
@@ -212,36 +213,42 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
212
213
|
return referenceSubstitutionn;
|
|
213
214
|
}
|
|
214
215
|
|
|
215
|
-
static fromReferenceAndMetavariable(reference, metavariable,
|
|
216
|
+
static fromReferenceAndMetavariable(reference, metavariable, generalContext, specificContext) {
|
|
216
217
|
let referenceSubstitution;
|
|
217
218
|
|
|
218
|
-
|
|
219
|
+
ablates((generalContext, specificContext) => {
|
|
220
|
+
const context = specificContext; ///
|
|
221
|
+
|
|
219
222
|
instantiate((context) => {
|
|
220
|
-
const
|
|
223
|
+
const specificContext = context, ///
|
|
224
|
+
referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
|
|
221
225
|
string = referenceSubstitutionString, ///
|
|
222
226
|
referenceSubstitutionNode = instantiateReferenceSubstitution(string, context);
|
|
223
227
|
|
|
224
|
-
referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode,
|
|
228
|
+
referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, generalContext, specificContext);
|
|
225
229
|
}, context);
|
|
226
|
-
},
|
|
230
|
+
}, generalContext, specificContext);
|
|
227
231
|
|
|
228
232
|
return referenceSubstitution;
|
|
229
233
|
}
|
|
230
234
|
|
|
231
|
-
static fromAssumptionAndMetaLevelAssumption(assumption, metaLevelAssumption,
|
|
235
|
+
static fromAssumptionAndMetaLevelAssumption(assumption, metaLevelAssumption, generalContext, specificContext) {
|
|
232
236
|
let referenceSubstitution;
|
|
233
237
|
|
|
234
|
-
|
|
238
|
+
ablates((generalContext, specificContext) => {
|
|
239
|
+
const context = specificContext; ///
|
|
240
|
+
|
|
235
241
|
instantiate((context) => {
|
|
236
|
-
const
|
|
242
|
+
const specificContext = context, ///
|
|
237
243
|
metavariable = assumption.getMetavariable(),
|
|
244
|
+
reference = metaLevelAssumption.getReference(),
|
|
238
245
|
referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
|
|
239
246
|
string = referenceSubstitutionString, ///
|
|
240
247
|
referenceSubstitutionNode = instantiateReferenceSubstitution(string, context);
|
|
241
248
|
|
|
242
|
-
referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode,
|
|
249
|
+
referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, generalContext, specificContext);
|
|
243
250
|
}, context);
|
|
244
|
-
},
|
|
251
|
+
}, generalContext, specificContext);
|
|
245
252
|
|
|
246
253
|
return referenceSubstitution;
|
|
247
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,
|
|
10
|
+
import { join, ablates, attempts, descend, reconcile, 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,28 @@ 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
|
+
attempts((generalContext, 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
|
-
}, specificContext, context);
|
|
127
|
-
}, generalContext, context);
|
|
120
|
+
if (validates) {
|
|
121
|
+
this.commit(generalContext, specificContext);
|
|
122
|
+
}
|
|
123
|
+
}, generalContext, specificContext);
|
|
128
124
|
}
|
|
129
125
|
|
|
130
126
|
if (validates) {
|
|
@@ -272,9 +268,8 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
272
268
|
replacementStatementUnifies = this.unifyReplacementStatement(replacementStatement, generalContext, specificContext);
|
|
273
269
|
|
|
274
270
|
if (replacementStatementUnifies) {
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
soleNonTrivialDerivedSubstitution = context.getSoleNonTrivialDerivedSubstitution(nested);
|
|
271
|
+
const context = specificContext, ///
|
|
272
|
+
soleNonTrivialDerivedSubstitution = context.getSoleNonTrivialDerivedSubstitution();
|
|
278
273
|
|
|
279
274
|
substitution = soleNonTrivialDerivedSubstitution; ///
|
|
280
275
|
}
|
|
@@ -353,19 +348,24 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
353
348
|
const { name } = json;
|
|
354
349
|
|
|
355
350
|
if (this.name === name) {
|
|
356
|
-
|
|
351
|
+
unserialises((json, generalContext, specificContext) => {
|
|
357
352
|
const context = specificContext; ///
|
|
358
353
|
|
|
359
354
|
instantiate((context) => {
|
|
360
355
|
const { string, lineIndex } = json,
|
|
356
|
+
specificContext = context, ///
|
|
357
|
+
contexts = [
|
|
358
|
+
generalContext,
|
|
359
|
+
specificContext
|
|
360
|
+
],
|
|
361
361
|
statementSubstitutionNode = instantiateStatementSubstitution(string, context),
|
|
362
362
|
node = statementSubstitutionNode, ///
|
|
363
363
|
resolved = resolvedFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
364
|
-
substitution = substitutionFromStatementSubstitutionNode(statementSubstitutionNode,
|
|
364
|
+
substitution = substitutionFromStatementSubstitutionNode(statementSubstitutionNode, generalContext, specificContext),
|
|
365
365
|
targetStatement = targetStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
366
366
|
replacementStatement = replacementStatementFromStatementSubstitutionNode(statementSubstitutionNode, context);
|
|
367
367
|
|
|
368
|
-
statementSubstitutionn = new StatementSubstitution(
|
|
368
|
+
statementSubstitutionn = new StatementSubstitution(contexts, string, node, lineIndex, resolved, substitution, targetStatement, replacementStatement);
|
|
369
369
|
}, context);
|
|
370
370
|
}, json, context);
|
|
371
371
|
}
|
|
@@ -373,38 +373,48 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
373
373
|
return statementSubstitutionn;
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
-
static fromStatementAndMetavariable(statement, metavariable,
|
|
376
|
+
static fromStatementAndMetavariable(statement, metavariable, generalContext, specificContext) {
|
|
377
|
+
const context = specificContext; ///
|
|
378
|
+
|
|
377
379
|
statement = stripBracketsFromStatement(statement, context); ///
|
|
378
380
|
|
|
379
381
|
let statementSubstitution;
|
|
380
382
|
|
|
381
|
-
|
|
383
|
+
ablates((generalContext, specificContext) => {
|
|
384
|
+
const context = specificContext; ///
|
|
385
|
+
|
|
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
|
+
}, generalContext, specificContext);
|
|
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
|
+
ablates((generalContext, specificContext) => {
|
|
407
|
+
const context = specificContext; ///
|
|
408
|
+
|
|
400
409
|
instantiate((context) => {
|
|
401
|
-
const
|
|
410
|
+
const specificContext = context, ///
|
|
411
|
+
statementSubstitutionString = statementSubstitutionStringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution),
|
|
402
412
|
string = statementSubstitutionString, ///
|
|
403
413
|
statementSubstitutionNode = instantiateStatementSubstitution(string, context);
|
|
404
414
|
|
|
405
|
-
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode,
|
|
415
|
+
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, generalContext, specificContext);
|
|
406
416
|
}, context);
|
|
407
|
-
},
|
|
417
|
+
}, generalContext, specificContext);
|
|
408
418
|
|
|
409
419
|
return statementSubstitution;
|
|
410
420
|
}
|
|
@@ -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 { ablates, attempts, descend, 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,24 @@ 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
|
-
}, generalContext, specificContext);
|
|
112
|
-
}, specificContext, context);
|
|
113
|
-
}, generalContext, context);
|
|
92
|
+
const generalContext = this.getGeneralContext(),
|
|
93
|
+
specificContext = this.getSpecificContext();
|
|
94
|
+
|
|
95
|
+
attempts((generalContext, 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
|
+
this.commit(generalContext, specificContext);
|
|
108
|
+
}
|
|
109
|
+
}, generalContext, specificContext);
|
|
114
110
|
}
|
|
115
111
|
|
|
116
112
|
if (validates) {
|
|
@@ -200,17 +196,22 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
200
196
|
const { name } = json;
|
|
201
197
|
|
|
202
198
|
if (this.name === name) {
|
|
203
|
-
|
|
199
|
+
unserialises((json, generalContext, specificContext) => {
|
|
204
200
|
const context = specificContext; ///
|
|
205
201
|
|
|
206
202
|
instantiate((context) => {
|
|
207
203
|
const { string, lineIndex } = json,
|
|
204
|
+
specificContext = context, ///
|
|
205
|
+
contexts = [
|
|
206
|
+
generalContext,
|
|
207
|
+
specificContext
|
|
208
|
+
],
|
|
208
209
|
termSubstitutionNode = instantiateTermSubstitution(string, context),
|
|
209
210
|
node = termSubstitutionNode, ///
|
|
210
211
|
targetTerm = targetTermFromTermSubstitutionNode(termSubstitutionNode, context),
|
|
211
212
|
replacementTerm = replacementTermFromTermSubstitutionNode(termSubstitutionNode, context);
|
|
212
213
|
|
|
213
|
-
termSubstitutionn = new TermSubstitution(
|
|
214
|
+
termSubstitutionn = new TermSubstitution(contexts, string, node, lineIndex, targetTerm, replacementTerm);
|
|
214
215
|
}, context);
|
|
215
216
|
}, json, context);
|
|
216
217
|
}
|
|
@@ -218,34 +219,39 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
218
219
|
return termSubstitutionn;
|
|
219
220
|
}
|
|
220
221
|
|
|
221
|
-
static fromStatement(statement,
|
|
222
|
+
static fromStatement(statement, generalContext, specificContext) {
|
|
222
223
|
let termSubstitution = null;
|
|
223
224
|
|
|
224
225
|
const termSubstitutionNode = statement.getTermSubstitutionNode();
|
|
225
226
|
|
|
226
227
|
if (termSubstitutionNode !== null) {
|
|
227
|
-
|
|
228
|
-
termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode,
|
|
229
|
-
},
|
|
228
|
+
ablates((generalContext, specificContext) => {
|
|
229
|
+
termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, generalContext, specificContext);
|
|
230
|
+
}, generalContext, specificContext);
|
|
230
231
|
}
|
|
231
232
|
|
|
232
233
|
return termSubstitution;
|
|
233
234
|
}
|
|
234
235
|
|
|
235
|
-
static fromTermAndVariable(term, variable,
|
|
236
|
+
static fromTermAndVariable(term, variable, generalContext, specificContext) {
|
|
237
|
+
const context = specificContext; ///
|
|
238
|
+
|
|
236
239
|
term = stripBracketsFromTerm(term, context); ///
|
|
237
240
|
|
|
238
241
|
let termSubstitution;
|
|
239
242
|
|
|
240
|
-
|
|
243
|
+
ablates((generalContext, specificContext) => {
|
|
244
|
+
const context = specificContext; ///
|
|
245
|
+
|
|
241
246
|
instantiate((context) => {
|
|
242
|
-
const
|
|
247
|
+
const specificContext = context, ///
|
|
248
|
+
termSubstitutionString = termSubstitutionStringFromTermAndVariable(term, variable),
|
|
243
249
|
string = termSubstitutionString, ///
|
|
244
250
|
termSubstitutionNode = instantiateTermSubstitution(string, context);
|
|
245
251
|
|
|
246
|
-
termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode,
|
|
252
|
+
termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, generalContext, specificContext);
|
|
247
253
|
}, context);
|
|
248
|
-
},
|
|
254
|
+
}, generalContext, specificContext);
|
|
249
255
|
|
|
250
256
|
return termSubstitution;
|
|
251
257
|
}
|