occam-verify-cli 1.0.787 → 1.0.796

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 (65) hide show
  1. package/lib/context/ephemeral.js +3 -8
  2. package/lib/context/file/nominal.js +5 -1
  3. package/lib/context/liminal.js +39 -16
  4. package/lib/context/proof.js +35 -40
  5. package/lib/context.js +15 -3
  6. package/lib/element/assumption/metaLevel.js +181 -0
  7. package/lib/element/assumption.js +21 -42
  8. package/lib/element/judgement.js +11 -13
  9. package/lib/element/metavariable.js +28 -25
  10. package/lib/element/parameter.js +5 -5
  11. package/lib/element/procedureCall.js +2 -2
  12. package/lib/element/proofAssertion/step.js +2 -2
  13. package/lib/element/reference.js +41 -30
  14. package/lib/element/substitution/frame.js +23 -18
  15. package/lib/element/substitution/reference.js +44 -22
  16. package/lib/element/substitution/statement.js +41 -16
  17. package/lib/element/substitution/term.js +22 -17
  18. package/lib/element/substitution.js +4 -4
  19. package/lib/element/topLevelMetaAssertion.js +9 -9
  20. package/lib/node/assumption/metaLevel.js +27 -0
  21. package/lib/node/assumption.js +5 -5
  22. package/lib/nonTerminalNodeMap.js +3 -1
  23. package/lib/preamble.js +2 -1
  24. package/lib/process/instantiate.js +8 -2
  25. package/lib/process/unify.js +15 -28
  26. package/lib/ruleNames.js +5 -1
  27. package/lib/utilities/context.js +9 -5
  28. package/lib/utilities/element.js +33 -18
  29. package/lib/utilities/json.js +33 -3
  30. package/lib/utilities/string.js +25 -14
  31. package/lib/utilities/unification.js +3 -3
  32. package/lib/utilities/validation.js +9 -14
  33. package/package.json +4 -4
  34. package/src/context/ephemeral.js +2 -10
  35. package/src/context/file/nominal.js +6 -0
  36. package/src/context/liminal.js +54 -16
  37. package/src/context/proof.js +41 -47
  38. package/src/context.js +22 -2
  39. package/src/element/assumption/metaLevel.js +263 -0
  40. package/src/element/assumption.js +31 -61
  41. package/src/element/judgement.js +13 -21
  42. package/src/element/metavariable.js +29 -28
  43. package/src/element/parameter.js +4 -4
  44. package/src/element/procedureCall.js +1 -1
  45. package/src/element/proofAssertion/step.js +1 -1
  46. package/src/element/reference.js +53 -36
  47. package/src/element/substitution/frame.js +25 -18
  48. package/src/element/substitution/reference.js +61 -25
  49. package/src/element/substitution/statement.js +57 -18
  50. package/src/element/substitution/term.js +25 -18
  51. package/src/element/substitution.js +3 -4
  52. package/src/element/topLevelMetaAssertion.js +15 -15
  53. package/src/node/assumption/metaLevel.js +23 -0
  54. package/src/node/assumption.js +8 -8
  55. package/src/nonTerminalNodeMap.js +3 -0
  56. package/src/preamble.js +1 -0
  57. package/src/process/instantiate.js +4 -0
  58. package/src/process/unify.js +18 -39
  59. package/src/ruleNames.js +1 -0
  60. package/src/utilities/context.js +10 -4
  61. package/src/utilities/element.js +44 -25
  62. package/src/utilities/json.js +40 -5
  63. package/src/utilities/string.js +34 -19
  64. package/src/utilities/unification.js +3 -3
  65. package/src/utilities/validation.js +10 -16
@@ -30,20 +30,20 @@ export default define(class Parameter extends Element {
30
30
  return parameterNode;
31
31
  }
32
32
 
33
- findPrimitive(substitutions) {
33
+ findPrimitive(substitutions, context) {
34
34
  let primitive = null;
35
35
 
36
36
  const parameter = this, ///
37
37
  substitution = substitutions.find((substitution) => {
38
- const substitutionComparesToParamter = substitution.compareParameter(parameter);
38
+ const substitutionComparesToParameter = substitution.compareParameter(parameter);
39
39
 
40
- if (substitutionComparesToParamter) {
40
+ if (substitutionComparesToParameter) {
41
41
  return true;
42
42
  }
43
43
  }) || null;
44
44
 
45
45
  if (substitution !== null) {
46
- primitive = substitution.getPrimitive();
46
+ primitive = substitution.getPrimitive(context);
47
47
  }
48
48
 
49
49
  return primitive;
@@ -38,7 +38,7 @@ export default define(class ProcedureCall extends Element {
38
38
  findPrimitives(context) {
39
39
  const substitutions = context.getSubstitutions(),
40
40
  primitives = this.parameters.map((parameter) => {
41
- const primitive = parameter.findPrimitive(substitutions);
41
+ const primitive = parameter.findPrimitive(substitutions, context);
42
42
 
43
43
  return primitive;
44
44
  });
@@ -137,7 +137,7 @@ export default define(class Step extends ProofAssertion {
137
137
 
138
138
  context.trace(`Validating the '${stepString}' step's '${referenceString}' reference... `);
139
139
 
140
- const reference = this.reference.validate();
140
+ const reference = this.reference.validate(context);
141
141
 
142
142
  if (reference === null) {
143
143
  referenceValidates = false;
@@ -123,60 +123,79 @@ export default define(class Reference extends Element {
123
123
  return topLevelMetaAssertionCompares;
124
124
  }
125
125
 
126
- validate() {
127
- let referennce = null;
126
+ findValidReference(context) {
127
+ const referenceNode = this.getReferenceNode(),
128
+ reference = context.findReferenceByReferenceNode(referenceNode),
129
+ validReference = reference; ///
128
130
 
129
- const context = this.getContext(),
130
- referenceString = this.getString(); ///
131
+ return validReference;
132
+ }
133
+
134
+ validate(context) {
135
+ let reference = null;
136
+
137
+ const referenceString = this.getString(); ///
131
138
 
132
139
  context.trace(`Validating the '${referenceString}' reference...`);
133
140
 
134
- let validates;
141
+ let validates = false;
135
142
 
136
- attempt((context) => {
137
- const metavariableValidates = this.validateMetavariable(context);
143
+ const validReference = this.findValidReference(context);
138
144
 
139
- if (metavariableValidates) {
140
- const referenceMetaTypeName = REFERENCE_META_TYPE_NAME,
141
- referenceMetaType = context.findMetaTypeByMetaTypeName(referenceMetaTypeName),
142
- metaType = this.metavariable.getMetaType();
145
+ if (validReference) {
146
+ reference = validReference; ///
143
147
 
144
- if (metaType === null) {
145
- const reference = this, ///
146
- labelPresent = context.isLabelPresentByReference(reference);
148
+ context.debug(`...the '${referenceString}' reference is already valid.`);
149
+ } else {
150
+ const context = this.getContext();
147
151
 
148
- if (labelPresent) {
149
- validates = true;
150
- } else {
151
- context.debug(`There is no label for the '${referenceString}' reference.`);
152
- }
153
- } else {
154
- const metavariableMetaTypeEqualToReferenceMetaType = this.metavariable.isMetaTypeEqualTo(referenceMetaType);
152
+ attempt((context) => {
153
+ const metavariableValidates = this.validateMetavariable(context);
154
+
155
+ if (metavariableValidates) {
156
+ const referenceMetaTypeName = REFERENCE_META_TYPE_NAME,
157
+ referenceMetaType = context.findMetaTypeByMetaTypeName(referenceMetaTypeName),
158
+ metaType = this.metavariable.getMetaType();
155
159
 
156
- if (metavariableMetaTypeEqualToReferenceMetaType) {
157
- validates = true;
160
+ if (metaType === null) {
161
+ const reference = this, ///
162
+ labelPresent = context.isLabelPresentByReference(reference);
163
+
164
+ if (labelPresent) {
165
+ validates = true;
166
+ } else {
167
+ context.debug(`There is no label for the '${referenceString}' reference.`);
168
+ }
158
169
  } else {
159
- const metaTypeString = metaType.getString(),
160
- metavariableString = this.metavariable.getString(),
161
- referenceMetaTypeString = referenceMetaType.getString();
170
+ const metavariableMetaTypeEqualToReferenceMetaType = this.metavariable.isMetaTypeEqualTo(referenceMetaType);
171
+
172
+ if (metavariableMetaTypeEqualToReferenceMetaType) {
173
+ validates = true;
174
+ } else {
175
+ const metaTypeString = metaType.getString(),
176
+ metavariableString = this.metavariable.getString(),
177
+ referenceMetaTypeString = referenceMetaType.getString();
162
178
 
163
- context.debug(`The '${referenceString}' reference's '${metavariableString}' metavariable's '${metaTypeString}' meta-type should be the '${referenceMetaTypeString}' meta-type.`);
179
+ context.debug(`The '${referenceString}' reference's '${metavariableString}' metavariable's '${metaTypeString}' meta-type should be the '${referenceMetaTypeString}' meta-type.`);
180
+ }
164
181
  }
165
182
  }
166
- }
167
183
 
168
- if (validates) {
169
- context.commit(this);
170
- }
171
- }, context);
184
+ if (validates) {
185
+ context.commit(this);
186
+ }
187
+ }, context);
188
+ }
172
189
 
173
190
  if (validates) {
174
- referennce = this; ///
191
+ reference = this; ///
192
+
193
+ context.addReference(reference);
175
194
 
176
195
  context.debug(`...validated the '${referenceString}' reference.`);
177
196
  }
178
197
 
179
- return referennce;
198
+ return reference;
180
199
  }
181
200
 
182
201
  validateMetavariable(context) {
@@ -338,5 +357,3 @@ export default define(class Reference extends Element {
338
357
  return reference;
339
358
  }
340
359
  });
341
-
342
- let counter = 0;
@@ -3,8 +3,8 @@
3
3
  import Substitution from "../substitution";
4
4
 
5
5
  import { define } from "../../elements";
6
- import { descend, instantiate } from "../../utilities/context";
7
6
  import { instantiateFrameSubstitution } from "../../process/instantiate";
7
+ import { attempt, descend, instantiate } from "../../utilities/context";
8
8
  import { frameSubstitutionStringFromFrameAndMetavariable } from "../../utilities/string";
9
9
  import { frameSubstitutionFromStatementNode, frameSubstitutionFromFrameSubstitutionNode } from "../../utilities/element";
10
10
 
@@ -78,34 +78,43 @@ export default define(class FrameSubstitution extends Substitution {
78
78
 
79
79
  context.trace(`Validating the '${frameSubstitutionString}' frame substitution...`);
80
80
 
81
- const validSubstitution = this.findValidSubstiution(context);
81
+ let validates = false;
82
+
83
+ const validSubstitution = this.findValidSubstitution(context);
82
84
 
83
85
  if (validSubstitution) {
84
86
  frameSubstitution = validSubstitution; ///
85
87
 
86
88
  context.debug(`...the '${frameSubstitutionString}' frame substitution is already valid.`);
87
89
  } else {
88
- let validates = false;
90
+ const context = this.getContext(),
91
+ specificContext = context; ///
89
92
 
90
- const targetFrameValidates = this.validateTargetFrame(generalContext, specificContext);
93
+ attempt((specificContext) => {
94
+ const targetFrameValidates = this.validateTargetFrame(generalContext, specificContext);
91
95
 
92
- if (targetFrameValidates) {
93
- const replacementFrameValidates = this.validateReplacementFrame(generalContext, specificContext);
96
+ if (targetFrameValidates) {
97
+ const replacementFrameValidates = this.validateReplacementFrame(generalContext, specificContext);
94
98
 
95
- if (replacementFrameValidates) {
96
- validates = true;
99
+ if (replacementFrameValidates) {
100
+ validates = true;
101
+ }
97
102
  }
98
- }
99
103
 
100
- if (validates) {
101
- const substitution = this; ///
104
+ if (validates) {
105
+ specificContext.commit(this);
106
+ }
107
+ }, specificContext);
108
+ }
109
+
110
+ if (validates) {
111
+ const substitution = this; ///
102
112
 
103
- frameSubstitution = substitution; ///
113
+ frameSubstitution = substitution; ///
104
114
 
105
- context.addSubstitution(substitution);
115
+ context.addSubstitution(substitution);
106
116
 
107
- context.debug(`...validated the '${frameSubstitutionString}' frame substitution.`);
108
- }
117
+ context.debug(`...validated the '${frameSubstitutionString}' frame substitution.`);
109
118
  }
110
119
 
111
120
  return frameSubstitution;
@@ -146,7 +155,7 @@ export default define(class FrameSubstitution extends Substitution {
146
155
  validateReplacementFrame(generalContext, specificContext) {
147
156
  let replacementFrameValidates = false;
148
157
 
149
- const context = this.getContext(),
158
+ const context = specificContext, ///
150
159
  replacementFrameString = this.replacementFrame.getString(),
151
160
  frameSubstitutionString = this.getString(); ///
152
161
 
@@ -184,8 +193,6 @@ export default define(class FrameSubstitution extends Substitution {
184
193
  targetFrame = targetFrameFromFrameSubstitutionNode(frameSubstitutionNode, context),
185
194
  replacementFrame = replacementFrameFromFrameSubstitutionNode(frameSubstitutionNode, context);
186
195
 
187
- context = null;
188
-
189
196
  frameSubstitutionn = new FrameSubstitution(context, string, node, targetFrame, replacementFrame);
190
197
  }, context);
191
198
  }
@@ -3,7 +3,7 @@
3
3
  import Substitution from "../substitution";
4
4
 
5
5
  import { define } from "../../elements";
6
- import { instantiate } from "../../utilities/context";
6
+ import { attempt, instantiate } from "../../utilities/context";
7
7
  import { instantiateReferenceSubstitution } from "../../process/instantiate";
8
8
  import { referenceSubstitutionFromReferenceSubstitutionNode } from "../../utilities/element";
9
9
  import { referenceSubstitutionStringFromReferenceAndMetavariable } from "../../utilities/string";
@@ -70,6 +70,23 @@ export default define(class ReferenceSubstitution extends Substitution {
70
70
  return comparesToParameter;
71
71
  }
72
72
 
73
+ compareSubstitution(substitution) {
74
+ let substitutionCompares = false;
75
+
76
+ const substitutionReferenceSubstitution = (substitution instanceof ReferenceSubstitution);
77
+
78
+ if (substitutionReferenceSubstitution) {
79
+ const substitutionNode = substitution.getNode(),
80
+ substitutionNodeMatches = this.matchNode(substitutionNode);
81
+
82
+ if (substitutionNodeMatches) {
83
+ substitutionCompares = true;
84
+ }
85
+ }
86
+
87
+ return substitutionCompares;
88
+ }
89
+
73
90
  validate(generalContext, specificContext) {
74
91
  let referenceSubstitution = null;
75
92
 
@@ -78,34 +95,43 @@ export default define(class ReferenceSubstitution extends Substitution {
78
95
 
79
96
  context.trace(`Validating the '${referenceSubstitutionString}' reference substitution...`);
80
97
 
81
- const validSubstitution = this.findValidSubstiution(context);
98
+ let validates = false;
99
+
100
+ const validSubstitution = this.findValidSubstitution(context);
82
101
 
83
102
  if (validSubstitution) {
84
103
  referenceSubstitution = validSubstitution; ///
85
104
 
86
105
  context.debug(`...the '${referenceSubstitutionString}' reference substitution is already valid.`);
87
106
  } else {
88
- let validates = false;
107
+ const context = this.getContext(),
108
+ specificContext = context; ///
89
109
 
90
- const targetReferenceValidates = this.validateTargetReference(generalContext, specificContext);
110
+ attempt((specificContext) => {
111
+ const targetReferenceValidates = this.validateTargetReference(generalContext, specificContext);
91
112
 
92
- if (targetReferenceValidates) {
93
- const replacementReferenceValidates = this.validateReplacementReference(generalContext, specificContext);
113
+ if (targetReferenceValidates) {
114
+ const replacementReferenceValidates = this.validateReplacementReference(generalContext, specificContext);
94
115
 
95
- if (replacementReferenceValidates) {
96
- validates = true;
116
+ if (replacementReferenceValidates) {
117
+ validates = true;
118
+ }
97
119
  }
98
- }
99
120
 
100
- if (validates) {
101
- const subsitution = this; ///
121
+ if (validates) {
122
+ specificContext.commit(this);
123
+ }
124
+ }, specificContext);
125
+ }
102
126
 
103
- referenceSubstitution = subsitution; ///
127
+ if (validates) {
128
+ const substitution = this; ///
104
129
 
105
- context.addSubstitution(subsitution);
130
+ referenceSubstitution = substitution; ///
106
131
 
107
- context.debug(`...validated the '${referenceSubstitutionString}' reference substitution.`);
108
- }
132
+ context.addSubstitution(substitution);
133
+
134
+ context.debug(`...validated the '${referenceSubstitutionString}' reference substitution.`);
109
135
  }
110
136
 
111
137
  return referenceSubstitution;
@@ -114,17 +140,15 @@ export default define(class ReferenceSubstitution extends Substitution {
114
140
  validateTargetReference(generalContext, specificContext) {
115
141
  let targetReferenceValidates = false;
116
142
 
117
- const context = specificContext, ///
143
+ const context = generalContext, ///
118
144
  targetReferenceString = this.targetReference.getString(),
119
145
  referenceSubstitutionString = this.getString(); ///
120
146
 
121
147
  context.trace(`Validating the '${referenceSubstitutionString}' reference substitution's '${targetReferenceString}' target reference...`);
122
148
 
123
- const targetReference = this.targetReference.validate();
149
+ const targetReference = this.targetReference.validate(context);
124
150
 
125
151
  if (targetReference !== null) {
126
- context.addReference(targetReference);
127
-
128
152
  targetReferenceValidates = true;
129
153
  }
130
154
 
@@ -138,17 +162,15 @@ export default define(class ReferenceSubstitution extends Substitution {
138
162
  validateReplacementReference(generalContext, specificContext) {
139
163
  let replacementReferenceValidates = false;
140
164
 
141
- const context = this.getContext(),
165
+ const context = specificContext, ///
142
166
  replacementReferenceString = this.replacementReference.getString(),
143
167
  referenceSubstitutionString = this.getString(); ///
144
168
 
145
169
  context.trace(`Validating the '${referenceSubstitutionString}' reference substitution's '${replacementReferenceString}' replacement reference...`);
146
170
 
147
- const replacementReference = this.replacementReference.validate();
171
+ const replacementReference = this.replacementReference.validate(context);
148
172
 
149
173
  if (replacementReference !== null) {
150
- context.addReference(replacementReference);
151
-
152
174
  replacementReferenceValidates = true;
153
175
  }
154
176
 
@@ -174,8 +196,6 @@ export default define(class ReferenceSubstitution extends Substitution {
174
196
  targetReference = targetReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
175
197
  replacementReference = replacementReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
176
198
 
177
- context = null;
178
-
179
199
  referenceSubstitutionn = new ReferenceSubstitution(context, string, node, targetReference, replacementReference);
180
200
  }, context);
181
201
  }
@@ -196,6 +216,22 @@ export default define(class ReferenceSubstitution extends Substitution {
196
216
 
197
217
  return referenceSubstitution;
198
218
  }
219
+
220
+ static fromAssumptionAndMetaLevelAssumption(assumption, metaLevelAssumption, context) {
221
+ let referenceSubstitution;
222
+
223
+ instantiate((context) => {
224
+ const reference = metaLevelAssumption.getReference(),
225
+ metavariable = assumption.getMetavariable(),
226
+ referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
227
+ string = referenceSubstitutionString, ///
228
+ referenceSubstitutionNode = instantiateReferenceSubstitution(string, context);
229
+
230
+ referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
231
+ }, context);
232
+
233
+ return referenceSubstitution;
234
+ }
199
235
  });
200
236
 
201
237
  function targetReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context) {
@@ -6,7 +6,7 @@ import { define } from "../../elements";
6
6
  import { unifySubstitution } from "../../process/unify";
7
7
  import { stripBracketsFromStatement } from "../../utilities/brackets";
8
8
  import { instantiateStatementSubstitution } from "../../process/instantiate";
9
- import { join, descend, reconcile, instantiate } from "../../utilities/context";
9
+ import { join, attempt, descend, reconcile, instantiate } from "../../utilities/context";
10
10
  import { statementSubstitutionFromStatementSubstitutionNode } from "../../utilities/element";
11
11
  import { statementSubstitutionStringFromStatementAndMetavariable, statementSubstitutionStringFromStatementMetavariableAndSubstitution } from "../../utilities/string";
12
12
 
@@ -113,39 +113,80 @@ export default define(class StatementSubstitution extends Substitution {
113
113
 
114
114
  context.trace(`Validating the '${statementSubstitutionString}' statement substitution...`);
115
115
 
116
- const validSubstitution = this.findValidSubstiution(context);
116
+ let validates = false;
117
+
118
+ const validSubstitution = this.findValidSubstitution(context);
117
119
 
118
120
  if (validSubstitution) {
119
121
  statementSubstitution = validSubstitution; ///
120
122
 
121
123
  context.debug(`...the '${statementSubstitutionString}' statement substitution is already valid.`);
122
124
  } else {
123
- let validates = false;
125
+ const context = this.getContext(),
126
+ specificContext = context; ///
127
+
128
+ attempt((specificContext) => {
129
+ const targetStatementValidates = this.validateTargetStatement(generalContext, specificContext);
130
+
131
+ if (targetStatementValidates) {
132
+ const replacementStatementValidates = this.validateReplacementStatement(generalContext, specificContext);
124
133
 
125
- const targetStatementValidates = this.validateTargetStatement(generalContext, specificContext);
134
+ if (replacementStatementValidates) {
135
+ const substitutionValidates = this.validateSubstitution(generalContext, specificContext);
126
136
 
127
- if (targetStatementValidates) {
128
- const replacementStatementValidates = this.validateReplacementStatement(generalContext, specificContext);
137
+ if (substitutionValidates) {
138
+ validates = true;
139
+ }
140
+ }
141
+ }
129
142
 
130
- if (replacementStatementValidates) {
131
- validates = true;
143
+ if (validates) {
144
+ specificContext.commit(this);
132
145
  }
133
- }
146
+ }, specificContext);
147
+ }
134
148
 
135
- if (validates) {
136
- const substitution = this; ///
149
+ if (validates) {
150
+ const substitution = this; ///
137
151
 
138
- statementSubstitution = substitution; ///
152
+ statementSubstitution = substitution; ///
139
153
 
140
- context.addSubstitution(substitution);
154
+ context.addSubstitution(substitution);
141
155
 
142
- context.debug(`...validated the '${statementSubstitutionString}' statement substitution.`);
143
- }
156
+ context.debug(`...validated the '${statementSubstitutionString}' statement substitution.`);
144
157
  }
145
158
 
146
159
  return statementSubstitution;
147
160
  }
148
161
 
162
+ validateSubstitution(generalContext, specificContext) {
163
+ let substitutionValidates = true;
164
+
165
+ if (this.substitution !== null) {
166
+ const context = specificContext, ///
167
+ substitutionString = this.substitution.getString(),
168
+ statementSubstitutionString = this.getString();
169
+
170
+ context.trace(`Validating the '${statementSubstitutionString}' statement substitution's '${substitutionString}' substitution...`);
171
+
172
+ specificContext = generalContext; ///
173
+
174
+ const substitution = this.substitution.validate(generalContext, specificContext);
175
+
176
+ if (substitution !== null) {
177
+ this.substitution = substitution;
178
+
179
+ substitutionValidates = true;
180
+ }
181
+
182
+ if (substitutionValidates) {
183
+ context.debug(`...validatewd the '${statementSubstitutionString}' statement substitution's '${substitutionString}' substitution.`);
184
+ }
185
+ }
186
+
187
+ return substitutionValidates;
188
+ }
189
+
149
190
  validateTargetStatement(generalContext, specificContext) {
150
191
  let targetStatementValidates = false;
151
192
 
@@ -179,7 +220,7 @@ export default define(class StatementSubstitution extends Substitution {
179
220
  validateReplacementStatement(generalContext, specificContext) {
180
221
  let replacementStatementValidates = false;
181
222
 
182
- const context = this.getContext(),
223
+ const context = specificContext, ///
183
224
  replacementStatementString = this.replacementStatement.getString(),
184
225
  statementSubstitutionString = this.getString(); ///
185
226
 
@@ -353,8 +394,6 @@ export default define(class StatementSubstitution extends Substitution {
353
394
  targetStatement = targetStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
354
395
  replacementStatement = replacementStatementFromStatementSubstitutionNode(statementSubstitutionNode, context);
355
396
 
356
- context = null;
357
-
358
397
  statementSubstitutionn = new StatementSubstitution(context, string, node, targetStatement, replacementStatement);
359
398
  }, context);
360
399
  }
@@ -3,7 +3,7 @@
3
3
  import Substitution from "../substitution";
4
4
 
5
5
  import { define } from "../../elements";
6
- import { instantiate } from "../../utilities/context";
6
+ import { attempt, instantiate } from "../../utilities/context";
7
7
  import { stripBracketsFromTerm } from "../../utilities/brackets";
8
8
  import { instantiateTermSubstitution } from "../../process/instantiate";
9
9
  import { termSubstitutionStringFromTermAndVariable } from "../../utilities/string";
@@ -81,34 +81,43 @@ export default define(class TermSubstitution extends Substitution {
81
81
 
82
82
  context.trace(`Validating the '${termSubstitutionString}' term substitution...`);
83
83
 
84
- const validSubstitution = this.findValidSubstiution(context);
84
+ let validates = false;
85
+
86
+ const validSubstitution = this.findValidSubstitution(context);
85
87
 
86
88
  if (validSubstitution) {
87
89
  termSubstitution = validSubstitution; ///
88
90
 
89
91
  context.debug(`...the '${termSubstitutionString}' term substitution is already valid.`);
90
92
  } else {
91
- let validates = false;
93
+ const context = this.getContext(),
94
+ specificContext = context; ///
92
95
 
93
- const targetTermValidates = this.validateTargetTerm(generalContext, specificContext);
96
+ attempt((specificContext) => {
97
+ const targetTermValidates = this.validateTargetTerm(generalContext, specificContext);
94
98
 
95
- if (targetTermValidates) {
96
- const replacementTermValidates = this.validateReplacementTerm(generalContext, specificContext);
99
+ if (targetTermValidates) {
100
+ const replacementTermValidates = this.validateReplacementTerm(generalContext, specificContext);
97
101
 
98
- if (replacementTermValidates) {
99
- validates = true;
102
+ if (replacementTermValidates) {
103
+ validates = true;
104
+ }
100
105
  }
101
- }
102
106
 
103
- if (validates) {
104
- const substitution = this; ///
107
+ if (validates) {
108
+ specificContext.commit(this);
109
+ }
110
+ }, specificContext);
111
+ }
112
+
113
+ if (validates) {
114
+ const substitution = this; ///
105
115
 
106
- termSubstitution = substitution; ///
116
+ termSubstitution = substitution; ///
107
117
 
108
- context.addSubstitution(substitution);
118
+ context.addSubstitution(substitution);
109
119
 
110
- context.debug(`...validated the '${termSubstitutionString}' term substitution.`);
111
- }
120
+ context.debug(`...validated the '${termSubstitutionString}' term substitution.`);
112
121
  }
113
122
 
114
123
  return termSubstitution;
@@ -151,7 +160,7 @@ export default define(class TermSubstitution extends Substitution {
151
160
  validateReplacementTerm(generalContext, specificContext) {
152
161
  let replacementTermValidates = false;
153
162
 
154
- const context = this.getContext(),
163
+ const context = specificContext, ///
155
164
  replacementTermString = this.replacementTerm.getString(),
156
165
  termSubstitutionString = this.getString(); ///
157
166
 
@@ -191,8 +200,6 @@ export default define(class TermSubstitution extends Substitution {
191
200
  targetTerm = targetTermFromTermSubstitutionNode(termSubstitutionNode, context),
192
201
  replacementTerm = replacementTermFromTermSubstitutionNode(termSubstitutionNode, context);
193
202
 
194
- context = null;
195
-
196
203
  termSubstitutionn = new TermSubstitution(context, string, node, targetTerm, replacementTerm);
197
204
  }, context);
198
205
  }
@@ -6,9 +6,8 @@ import { primitiveUtilities } from "occam-furtle";
6
6
  const { primitiveFromNode } =primitiveUtilities;
7
7
 
8
8
  export default class Substitution extends Element {
9
- getPrimitive() {
10
- const context = this.getContext(),
11
- replacementNode = this.getReplacementNode(),
9
+ getPrimitive(context) {
10
+ const replacementNode = this.getReplacementNode(),
12
11
  node = replacementNode, ///
13
12
  primitive = primitiveFromNode(node, context);
14
13
 
@@ -30,7 +29,7 @@ export default class Substitution extends Element {
30
29
  return substitutionNodeMatches;
31
30
  }
32
31
 
33
- findValidSubstiution(context) {
32
+ findValidSubstitution(context) {
34
33
  const substitutionNode = this.getSubstitutionNode(),
35
34
  substitution = context.findSubstitutionBySubstitutionNode(substitutionNode),
36
35
  validSubstitution = substitution; ///