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.
Files changed (53) hide show
  1. package/lib/context/liminal.js +16 -24
  2. package/lib/context/mnemic.js +5 -51
  3. package/lib/context/synoptic.js +26 -12
  4. package/lib/context.js +1 -37
  5. package/lib/element/assumption/metaLevel.js +3 -3
  6. package/lib/element/combinator.js +2 -2
  7. package/lib/element/conclusion.js +2 -2
  8. package/lib/element/constructor.js +2 -2
  9. package/lib/element/deduction.js +2 -2
  10. package/lib/element/label.js +2 -2
  11. package/lib/element/metavariable.js +10 -10
  12. package/lib/element/proofAssertion/premise.js +2 -2
  13. package/lib/element/proofAssertion/step.js +2 -2
  14. package/lib/element/proofAssertion/supposition.js +2 -2
  15. package/lib/element/reference.js +2 -2
  16. package/lib/element/substitution/frame.js +35 -33
  17. package/lib/element/substitution/reference.js +34 -32
  18. package/lib/element/substitution/statement.js +36 -34
  19. package/lib/element/substitution/term.js +33 -31
  20. package/lib/element/substitution.js +63 -29
  21. package/lib/element/variable.js +4 -4
  22. package/lib/process/unify.js +5 -5
  23. package/lib/utilities/context.js +42 -18
  24. package/lib/utilities/element.js +27 -66
  25. package/lib/utilities/json.js +27 -8
  26. package/lib/utilities/validation.js +7 -7
  27. package/package.json +4 -4
  28. package/src/context/liminal.js +15 -26
  29. package/src/context/mnemic.js +8 -64
  30. package/src/context/synoptic.js +37 -11
  31. package/src/context.js +0 -54
  32. package/src/element/assumption/metaLevel.js +2 -2
  33. package/src/element/combinator.js +1 -1
  34. package/src/element/conclusion.js +1 -1
  35. package/src/element/constructor.js +1 -1
  36. package/src/element/deduction.js +1 -1
  37. package/src/element/label.js +1 -1
  38. package/src/element/metavariable.js +10 -10
  39. package/src/element/proofAssertion/premise.js +1 -1
  40. package/src/element/proofAssertion/step.js +1 -1
  41. package/src/element/proofAssertion/supposition.js +1 -1
  42. package/src/element/reference.js +1 -1
  43. package/src/element/substitution/frame.js +39 -33
  44. package/src/element/substitution/reference.js +44 -35
  45. package/src/element/substitution/statement.js +45 -37
  46. package/src/element/substitution/term.js +44 -35
  47. package/src/element/substitution.js +80 -35
  48. package/src/element/variable.js +3 -3
  49. package/src/process/unify.js +3 -5
  50. package/src/utilities/context.js +50 -24
  51. package/src/utilities/element.js +36 -70
  52. package/src/utilities/json.js +31 -12
  53. 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 { join, ablate, descend, attempt, unserialise, instantiate } from "../../utilities/context";
9
+ import { ablates, descend, attempt, instantiate, unserialises } from "../../utilities/context";
10
10
 
11
11
  export default define(class FrameSubstitution extends Substitution {
12
- constructor(context, string, node, lineIndex, generalContext, targetFrame, replacementFrame) {
13
- super(context, string, node, lineIndex, generalContext);
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(generalContext, specificContext) {
73
+ validate(context) {
74
74
  let frameSubstitution = null;
75
75
 
76
- const context = specificContext, ///
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 context = this.getContext();
89
+ const generalContext = this.getGeneralContext(),
90
+ specificContext = this.getSpecificContext();
91
91
 
92
- join((generalContext) => {
93
- join((specificContext) => {
94
- attempt((generalContext, specificContext) => {
95
- const targetFrameValidates = this.validateTargetFrame(generalContext, specificContext);
92
+ attempt((generalContext) => {
93
+ attempt((specificContext) => {
94
+ const targetFrameValidates = this.validateTargetFrame(generalContext, specificContext);
96
95
 
97
- if (targetFrameValidates) {
98
- const replacementFrameValidates = this.validateReplacementFrame(generalContext, specificContext);
96
+ if (targetFrameValidates) {
97
+ const replacementFrameValidates = this.validateReplacementFrame(generalContext, specificContext);
99
98
 
100
- if (replacementFrameValidates) {
101
- validates = true;
102
- }
99
+ if (replacementFrameValidates) {
100
+ validates = true;
103
101
  }
102
+ }
104
103
 
105
- if (validates) {
106
- this.setContexts(generalContext, specificContext);
107
- }
108
- }, generalContext, specificContext);
109
- }, specificContext, context);
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
- unserialise((json, generalContext, specificContext) => {
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(context, string, node, lineIndex, generalContext, targetFrame, replacementFrame);
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, context) {
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
- ablate((context) => {
217
- frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context);
218
- }, context);
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, context) {
227
+ static fromFrameAndMetavariable(frame, metavariable, generalContext, specificContext) {
225
228
  let frameSubstitution
226
229
 
227
- ablate((context) => {
230
+ ablates((generalContext, specificContext) => {
231
+ const context = specificContext; ///
232
+
228
233
  instantiate((context) => {
229
- const frameSubstitutionString = frameSubstitutionStringFromFrameAndMetavariable(frame, metavariable),
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, context);
239
+ frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, generalContext, specificContext);
234
240
  }, context);
235
- }, context);
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, generalContext, targetReference, replacementReference) {
13
- super(context, string, node, lineIndex, generalContext);
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(generalContext, specificContext) {
90
+ validate(context) {
91
91
  let referenceSubstitution = null;
92
92
 
93
- const context = specificContext, ///
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 context = this.getContext();
108
-
109
- join((generalContext) => {
110
- join((specificContext) => {
111
- attempt((generalContext, specificContext) => {
112
- const targetReferenceValidates = this.validateTargetReference(generalContext, specificContext);
113
-
114
- if (targetReferenceValidates) {
115
- const replacementReferenceValidates = this.validateReplacementReference(generalContext, specificContext);
116
-
117
- if (replacementReferenceValidates) {
118
- validates = true;
119
- }
120
- }
121
-
122
- if (validates) {
123
- this.setContexts(generalContext, specificContext);
124
- }
125
- }, generalContext, specificContext);
126
- }, specificContext, context);
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
- unserialise((json, generalContext, specificContext) => {
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(context, string, node, lineIndex, generalContext, targetReference, replacementReference);
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, context) {
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 referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
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, context);
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, context) {
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 reference = metaLevelAssumption.getReference(),
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, context);
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, unserialise, instantiate } from "../../utilities/context";
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(context, string, node, lineIndex, generalContext, resolved, substitution, targetStatement, replacementStatement) {
15
- super(context, string, node, lineIndex, generalContext);
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, generalContext, specificContext) {
86
+ validate(substitution, context) {
87
87
  let statementSubstitution = null;
88
88
 
89
- const context = specificContext, ///
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 context = this.getContext();
102
+ const generalContext = this.getGeneralContext(),
103
+ specificContext = this.getSpecificContext();
104
104
 
105
- join((generalContext) => {
106
- join((specificContext) => {
107
- attempt((generalContext, specificContext) => {
108
- const targetStatementValidates = this.validateTargetStatement(generalContext, specificContext);
105
+ attempt((specificContext) => {
106
+ const targetStatementValidates = this.validateTargetStatement(generalContext, specificContext);
109
107
 
110
- if (targetStatementValidates) {
111
- const replacementStatementValidates = this.validateReplacementStatement(generalContext, specificContext);
108
+ if (targetStatementValidates) {
109
+ const replacementStatementValidates = this.validateReplacementStatement(generalContext, specificContext);
112
110
 
113
- if (replacementStatementValidates) {
114
- const substitutionValidates = this.validateSubstitution(substitution, generalContext, specificContext);
111
+ if (replacementStatementValidates) {
112
+ const substitutionValidates = this.validateSubstitution(substitution, generalContext, specificContext);
115
113
 
116
- if (substitutionValidates) {
117
- validates = true;
118
- }
119
- }
114
+ if (substitutionValidates) {
115
+ validates = true;
120
116
  }
117
+ }
118
+ }
121
119
 
122
- if (validates) {
123
- this.setContexts(generalContext, specificContext);
124
- }
125
- }, generalContext, specificContext);
126
- }, specificContext, context);
127
- }, generalContext, context);
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 nested = false,
276
- context = specificContext, ///
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
- unserialise((json, generalContext, specificContext) => {
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, context),
366
+ substitution = substitutionFromStatementSubstitutionNode(statementSubstitutionNode, generalContext, specificContext),
365
367
  targetStatement = targetStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
366
368
  replacementStatement = replacementStatementFromStatementSubstitutionNode(statementSubstitutionNode, context);
367
369
 
368
- statementSubstitutionn = new StatementSubstitution(context, string, node, lineIndex, generalContext, resolved, substitution, targetStatement, replacementStatement);
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, context) {
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 statementSubstitutionString = statementSubstitutionStringFromStatementAndMetavariable(statement, metavariable, context),
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, context);
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, context) {
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 statementSubstitutionString = statementSubstitutionStringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution),
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, context);
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 { join, ablate, descend, attempt, unserialise, instantiate } from "../../utilities/context";
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, generalContext, targetTerm, replacementTerm) {
14
- super(context, string, node, lineIndex, generalContext);
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(generalContext, specificContext) {
76
+ validate(context) {
77
77
  let termSubstitution = null;
78
78
 
79
- const context = specificContext, ///
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 context = this.getContext();
94
-
95
- join((generalContext) => {
96
- join((specificContext) => {
97
- attempt((generalContext, specificContext) => {
98
- const targetTermValidates = this.validateTargetTerm(generalContext, specificContext);
99
-
100
- if (targetTermValidates) {
101
- const replacementTermValidates = this.validateReplacementTerm(generalContext, specificContext);
102
-
103
- if (replacementTermValidates) {
104
- validates = true;
105
- }
106
- }
107
-
108
- if (validates) {
109
- this.setContexts(generalContext, specificContext);
110
- }
111
- }, generalContext, specificContext);
112
- }, specificContext, context);
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
- unserialise((json, generalContext, specificContext) => {
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(context, string, node, lineIndex, generalContext, targetTerm, replacementTerm);
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, context) {
224
+ static fromStatement(statement, generalContext, specificContext) {
222
225
  let termSubstitution = null;
223
226
 
224
- const termSubstitutionNode = statement.getTermSubstitutionNode();
227
+ const context = specificContext, ///
228
+ termSubstitutionNode = statement.getTermSubstitutionNode();
225
229
 
226
230
  if (termSubstitutionNode !== null) {
227
231
  ablate((context) => {
228
- termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, context);
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, context) {
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 termSubstitutionString = termSubstitutionStringFromTermAndVariable(term, variable),
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, context);
255
+ termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, generalContext, specificContext);
247
256
  }, context);
248
257
  }, context);
249
258