occam-verify-cli 1.0.768 → 1.0.781

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 (108) hide show
  1. package/lib/context/file/nominal.js +11 -11
  2. package/lib/context/illative.js +28 -0
  3. package/lib/context/nested.js +31 -0
  4. package/lib/context/proof.js +242 -0
  5. package/lib/context/thetic.js +28 -0
  6. package/lib/context.js +19 -21
  7. package/lib/element/assertion/contained.js +32 -24
  8. package/lib/element/assertion/defined.js +47 -40
  9. package/lib/element/assertion/property.js +18 -13
  10. package/lib/element/assertion/satisfies.js +12 -9
  11. package/lib/element/assertion/subproof.js +28 -26
  12. package/lib/element/assertion/type.js +14 -12
  13. package/lib/element/assumption.js +40 -50
  14. package/lib/element/combinator/bracketed.js +3 -3
  15. package/lib/element/combinator.js +20 -20
  16. package/lib/element/conclusion.js +33 -29
  17. package/lib/element/constructor.js +19 -18
  18. package/lib/element/deduction.js +33 -29
  19. package/lib/element/equality.js +13 -15
  20. package/lib/element/equivalence.js +59 -52
  21. package/lib/element/equivalences.js +4 -2
  22. package/lib/element/frame.js +74 -53
  23. package/lib/element/hypothesis.js +7 -5
  24. package/lib/element/judgement.js +41 -74
  25. package/lib/element/label.js +22 -22
  26. package/lib/element/metavariable.js +31 -11
  27. package/lib/element/proofAssertion/premise.js +48 -35
  28. package/lib/element/proofAssertion/step.js +77 -22
  29. package/lib/element/proofAssertion/supposition.js +48 -34
  30. package/lib/element/proofAssertion.js +1 -14
  31. package/lib/element/reference.js +80 -53
  32. package/lib/element/signature.js +44 -3
  33. package/lib/element/statement.js +28 -29
  34. package/lib/element/subproof.js +2 -2
  35. package/lib/element/substitution/frame.js +24 -19
  36. package/lib/element/substitution/metaLevel.js +31 -27
  37. package/lib/element/substitution/reference.js +11 -10
  38. package/lib/element/substitution/statement.js +30 -23
  39. package/lib/element/substitution/term.js +11 -10
  40. package/lib/element/term.js +24 -20
  41. package/lib/element/topLevelMetaAssertion.js +2 -2
  42. package/lib/element/variable.js +6 -2
  43. package/lib/process/assign.js +10 -4
  44. package/lib/process/unify.js +8 -8
  45. package/lib/process/validate.js +10 -8
  46. package/lib/utilities/context.js +68 -23
  47. package/lib/utilities/element.js +55 -27
  48. package/lib/utilities/json.js +8 -8
  49. package/lib/utilities/string.js +12 -1
  50. package/lib/utilities/unification.js +14 -12
  51. package/lib/utilities/validation.js +55 -40
  52. package/package.json +4 -4
  53. package/src/context/file/nominal.js +14 -16
  54. package/src/context/illative.js +17 -0
  55. package/src/context/nested.js +21 -0
  56. package/src/context/{scoped.js → proof.js} +65 -51
  57. package/src/context/thetic.js +17 -0
  58. package/src/context.js +30 -36
  59. package/src/element/assertion/contained.js +44 -31
  60. package/src/element/assertion/defined.js +55 -46
  61. package/src/element/assertion/property.js +23 -15
  62. package/src/element/assertion/satisfies.js +15 -10
  63. package/src/element/assertion/subproof.js +34 -31
  64. package/src/element/assertion/type.js +18 -13
  65. package/src/element/assumption.js +40 -69
  66. package/src/element/combinator/bracketed.js +2 -2
  67. package/src/element/combinator.js +23 -29
  68. package/src/element/conclusion.js +37 -40
  69. package/src/element/constructor.js +29 -34
  70. package/src/element/deduction.js +36 -39
  71. package/src/element/equality.js +16 -18
  72. package/src/element/equivalence.js +76 -67
  73. package/src/element/equivalences.js +5 -2
  74. package/src/element/frame.js +96 -65
  75. package/src/element/hypothesis.js +7 -6
  76. package/src/element/judgement.js +45 -45
  77. package/src/element/label.js +25 -31
  78. package/src/element/metavariable.js +48 -21
  79. package/src/element/proofAssertion/premise.js +63 -49
  80. package/src/element/proofAssertion/step.js +47 -26
  81. package/src/element/proofAssertion/supposition.js +64 -50
  82. package/src/element/proofAssertion.js +0 -22
  83. package/src/element/reference.js +119 -80
  84. package/src/element/signature.js +5 -2
  85. package/src/element/statement.js +30 -35
  86. package/src/element/subproof.js +1 -1
  87. package/src/element/substitution/frame.js +27 -26
  88. package/src/element/substitution/metaLevel.js +38 -42
  89. package/src/element/substitution/reference.js +13 -14
  90. package/src/element/substitution/statement.js +35 -33
  91. package/src/element/substitution/term.js +13 -14
  92. package/src/element/term.js +42 -34
  93. package/src/element/topLevelMetaAssertion.js +1 -1
  94. package/src/element/variable.js +8 -1
  95. package/src/process/assign.js +9 -3
  96. package/src/process/unify.js +7 -7
  97. package/src/process/validate.js +9 -8
  98. package/src/utilities/context.js +82 -31
  99. package/src/utilities/element.js +68 -31
  100. package/src/utilities/json.js +13 -13
  101. package/src/utilities/string.js +16 -2
  102. package/src/utilities/unification.js +18 -16
  103. package/src/utilities/validation.js +73 -53
  104. package/lib/context/scoped.js +0 -232
  105. package/lib/utilities/statement.js +0 -78
  106. package/lib/utilities/term.js +0 -17
  107. package/src/utilities/statement.js +0 -74
  108. package/src/utilities/term.js +0 -10
@@ -7,7 +7,7 @@ import { define } from "../elements";
7
7
  import { unifyStatement } from "../process/unify";
8
8
  import { validateStatements } from "../utilities/validation";
9
9
  import { instantiateStatement } from "../process/instantiate";
10
- import { reconcile, instantiate } from "../utilities/context";
10
+ import { join, reconcile, instantiate } from "../utilities/context";
11
11
 
12
12
  const { backwardsSome } = arrayUtilities;
13
13
 
@@ -184,7 +184,7 @@ export default define(class Statement extends Element {
184
184
  return frameContained;
185
185
  }
186
186
 
187
- validate(stated, context) {
187
+ validate(context) {
188
188
  let statement = null;
189
189
 
190
190
  const statementString = this.getString(); ///
@@ -200,7 +200,7 @@ export default define(class Statement extends Element {
200
200
  } else {
201
201
  const validates = validateStatements.some((validateStatement) => {
202
202
  const statement = this, ///
203
- statementValidates = validateStatement(statement, stated, context);
203
+ statementValidates = validateStatement(statement, context);
204
204
 
205
205
  if (statementValidates) {
206
206
  return true;
@@ -244,36 +244,33 @@ export default define(class Statement extends Element {
244
244
  return subproofUnifies;
245
245
  }
246
246
 
247
- unifyDeduction(deduction, generalContext, specificContext) {
247
+ unifyDeduction(deduction, context) {
248
248
  let deductionUnifies = false;
249
249
 
250
250
  const statementString = this.getString(), ///
251
251
  deductionString = deduction.getString(),
252
- deductionStatement = deduction.getStatement(),
253
- deductionStatementString = deductionStatement.getString();
252
+ deductionContext = deduction.getContext(),
253
+ deductionStatement = deduction.getStatement();
254
254
 
255
- let context;
255
+ context.trace(`Unifying the '${deductionString}' deduction with the '${statementString}' statement...`);
256
256
 
257
- context = specificContext; ///
257
+ const generalContext = context, ///
258
+ specificContext = deductionContext; ///
258
259
 
259
- context.trace(`Unifying the '${deductionString}' deduction's '${deductionStatementString}' statement with the '${statementString}' statement...`);
260
+ join((specificContext) => {
261
+ reconcile((specificContext) => {
262
+ const deductionStatementUnifies = this.unifyStatement(deductionStatement, generalContext, specificContext);
260
263
 
261
- context = deduction.getContext();
264
+ if (deductionStatementUnifies) {
265
+ specificContext.commit(context);
262
266
 
263
- specificContext = context; ///
264
-
265
- reconcile((specificContext) => {
266
- const deductionStatementUnfies = this.unifyStatement(deductionStatement, generalContext, specificContext);
267
-
268
- if (deductionStatementUnfies) {
269
- specificContext.commit();
270
-
271
- deductionUnifies = true;
272
- }
273
- }, specificContext);
267
+ deductionUnifies = true;
268
+ }
269
+ }, specificContext);
270
+ }, specificContext, context);
274
271
 
275
272
  if (deductionUnifies) {
276
- context.debug(`...unified the '${deductionString}' deduction's '${deductionStatementString}' statement with the '${statementString}' statement.`);
273
+ context.debug(`...unified the '${deductionString}' deduction with the '${statementString}' statement.`);
277
274
  }
278
275
 
279
276
  return deductionUnifies;
@@ -338,41 +335,39 @@ export default define(class Statement extends Element {
338
335
  return unifiesIndependently;
339
336
  }
340
337
 
341
- unifyTopLevelMetaAssertion(topLevelMetaAssertion, generalContext, specificContext) {
342
- let topLevelMetaAssertionUnifies = false;
338
+ unifyTopLevelMetaAssertion(topLevelMetaAssertion, context) {
339
+ let topLevelAssertionUnifies = false;
343
340
 
344
- const context = specificContext, ///
345
- statementString = this.getString(), ///
341
+ const statementString = this.getString(), ///
346
342
  topLevelMetaAssertionString = topLevelMetaAssertion.getString();
347
343
 
348
344
  context.trace(`Unifying the '${topLevelMetaAssertionString}' top level meta-assertion with the '${statementString}' statement...`);
349
345
 
350
- const topLevelMetaAssertionUnconditional = topLevelMetaAssertion.isUnconditional();
346
+ const unconditional = topLevelMetaAssertion.isUnconditional();
351
347
 
352
- if (topLevelMetaAssertionUnconditional) {
348
+ if (unconditional) {
353
349
  const deduction = topLevelMetaAssertion.getDeduction(),
354
- deductionUnifies = this.unifyDeduction(deduction, generalContext, specificContext);
350
+ deductionUnifies = this.unifyDeduction(deduction, context);
355
351
 
356
352
  if (deductionUnifies) {
357
- topLevelMetaAssertionUnifies = true;
353
+ topLevelAssertionUnifies = true;
358
354
  }
359
355
  } else {
360
356
  const statementNode = this.getStatementNode(),
361
357
  subproofAssertionNode = statementNode.getSubproofAssertionNode();
362
358
 
363
359
  if (subproofAssertionNode !== null) {
364
- const context = generalContext, ///
365
- subproofAssertion = context.findAssertionByAssertionNode(subproofAssertionNode);
360
+ const subproofAssertion = context.findAssertionByAssertionNode(subproofAssertionNode);
366
361
 
367
- topLevelMetaAssertionUnifies = subproofAssertion.unifyTopLevelMetaAssertion(topLevelMetaAssertion, generalContext, specificContext);
362
+ topLevelAssertionUnifies = subproofAssertion.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
368
363
  }
369
364
  }
370
365
 
371
- if (topLevelMetaAssertionUnifies) {
366
+ if (topLevelAssertionUnifies) {
372
367
  context.debug(`...unified the '${topLevelMetaAssertionString}' top level meta-assertion with the '${statementString}' statement.`);
373
368
  }
374
369
 
375
- return topLevelMetaAssertionUnifies;
370
+ return topLevelAssertionUnifies;
376
371
  }
377
372
 
378
373
  toJSON() {
@@ -121,7 +121,7 @@ export default define(class Subproof extends Element {
121
121
  context.trace(`Unifying the '${subproofString}' subproof with the '${satisfiesAssertionString}' satisfies assertion...`)
122
122
 
123
123
  const reference = satisfiesAssertion.getReference(),
124
- axiom = context.findAxiomByReference(reference, context);
124
+ axiom = context.findAxiomByReference(reference);
125
125
 
126
126
  if (axiom !== null) {
127
127
  const axiomSatisfiable = axiom.isSatisfiable();
@@ -4,7 +4,7 @@ import Substitution from "../substitution";
4
4
 
5
5
  import { define } from "../../elements";
6
6
  import { instantiateFrameSubstitution } from "../../process/instantiate";
7
- import { instantiate, sanitisedContextFromContext } from "../../utilities/context";
7
+ import { descend, simplify, instantiate } from "../../utilities/context";
8
8
  import { frameSubstitutionStringFromFrameAndMetavariable } from "../../utilities/string";
9
9
  import { frameSubstitutionFromStatementNode, frameSubstitutionFromFrameSubstitutionNode } from "../../utilities/element";
10
10
 
@@ -123,14 +123,15 @@ export default define(class FrameSubstitution extends Substitution {
123
123
  const targetFrameSingular = this.targetFrame.isSingular();
124
124
 
125
125
  if (targetFrameSingular) {
126
- const stated = true,
127
- tragetFrame = this.targetFrame.validate(stated, context);
126
+ descend((context) => {
127
+ const tragetFrame = this.targetFrame.validate(context);
128
128
 
129
- if (tragetFrame !== null) {
130
- this.targetFrame = tragetFrame;
129
+ if (tragetFrame !== null) {
130
+ this.targetFrame = tragetFrame;
131
131
 
132
- targetFrameValidates = true;
133
- }
132
+ targetFrameValidates = true;
133
+ }
134
+ }, context);
134
135
  } else {
135
136
  context.debug(`The '${frameSubstitutionString}' frame substitution's '${targetFrameString}' target frame is not singular.`);
136
137
  }
@@ -151,14 +152,15 @@ export default define(class FrameSubstitution extends Substitution {
151
152
 
152
153
  context.trace(`Validating the '${frameSubstitutionString}' frame substitution's '${replacementFrameString}' replacement frame...`);
153
154
 
154
- const stated = true,
155
- replacementFrame = this.replacementFrame.validate(stated, context);
155
+ descend((context) => {
156
+ const replacementFrame = this.replacementFrame.validate(context);
156
157
 
157
- if (replacementFrame !== null) {
158
- this.replacementFrame = replacementFrame;
158
+ if (replacementFrame !== null) {
159
+ this.replacementFrame = replacementFrame;
159
160
 
160
- replacementFrameValidates = true;
161
- }
161
+ replacementFrameValidates = true;
162
+ }
163
+ }, context);
162
164
 
163
165
  if (replacementFrameValidates) {
164
166
  context.debug(`...validated the '${frameSubstitutionString}' frame substitution's '${replacementFrameString}' replacement frame.`);
@@ -175,7 +177,7 @@ export default define(class FrameSubstitution extends Substitution {
175
177
  const { name } = json;
176
178
 
177
179
  if (this.name === name) {
178
- frameSubstitutionn = instantiate((context) => {
180
+ instantiate((context) => {
179
181
  const { string } = json,
180
182
  frameSubstitutionNode = instantiateFrameSubstitution(string, context),
181
183
  node = frameSubstitutionNode, ///
@@ -184,9 +186,7 @@ export default define(class FrameSubstitution extends Substitution {
184
186
 
185
187
  context = null;
186
188
 
187
- const frameSubstitutionn = new FrameSubstitution(context, string, node, targetFrame, replacementFrame);
188
-
189
- return frameSubstitutionn;
189
+ frameSubstitutionn = new FrameSubstitution(context, string, node, targetFrame, replacementFrame);
190
190
  }, context);
191
191
  }
192
192
 
@@ -201,18 +201,19 @@ export default define(class FrameSubstitution extends Substitution {
201
201
  }
202
202
 
203
203
  static fromFrameAndMetavariable(frame, metavariable, context) {
204
- const santisedContext = sanitisedContextFromContext(context);
205
-
206
- context = santisedContext; ///
204
+ let frameSubstitution
207
205
 
208
- return instantiate((context) => {
209
- const frameSubstitutionString = frameSubstitutionStringFromFrameAndMetavariable(frame, metavariable),
210
- string = frameSubstitutionString, ///
211
- frameSubstitutionNode = instantiateFrameSubstitution(string, context),
212
- frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context);
206
+ simplify((context) => {
207
+ instantiate((context) => {
208
+ const frameSubstitutionString = frameSubstitutionStringFromFrameAndMetavariable(frame, metavariable),
209
+ string = frameSubstitutionString, ///
210
+ frameSubstitutionNode = instantiateFrameSubstitution(string, context);
213
211
 
214
- return frameSubstitution;
212
+ frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context);
213
+ }, context);
215
214
  }, context);
215
+
216
+ return frameSubstitution;
216
217
  }
217
218
  });
218
219
 
@@ -4,10 +4,9 @@ import Substitution from "../substitution";
4
4
 
5
5
  import { define } from "../../elements";
6
6
  import { instantiateMetaLevelSubstitution } from "../../process/instantiate";
7
- import { instantiate, sanitisedContextFromContext } from "../../utilities/context";
8
7
  import { metaLevelSubstitutionFromMetaLevelSubstitutionNode } from "../../utilities/element";
9
8
  import { metaLevelSubstitutionStringFromStatementAndReference } from "../../utilities/string";
10
- import { ephemeralContextFromJSON, ephemeralContextToEphemeralContextJSON } from "../../utilities/json";
9
+ import { descend, simplify, serialise, unserialise, instantiate } from "../../utilities/context";
11
10
 
12
11
  export default define(class MetaLevelSubstitution extends Substitution {
13
12
  constructor(context, string, node, targetReference, replacementStatement) {
@@ -132,12 +131,13 @@ export default define(class MetaLevelSubstitution extends Substitution {
132
131
 
133
132
  context.trace(`Validating the '${metaLevelSubstitutionString}' meta-level substitution's '${replacementStatementString}' replacement statement...`);
134
133
 
135
- const stated = true,
136
- replacementStatement = this.replacementStatement.validate(stated, context);
134
+ descend((context) => {
135
+ const replacementStatement = this.replacementStatement.validate(context);
137
136
 
138
- if (replacementStatement !== null) {
139
- replacementStatementValidates = true;
140
- }
137
+ if (replacementStatement !== null) {
138
+ replacementStatementValidates = true;
139
+ }
140
+ }, context);
141
141
 
142
142
  if (replacementStatementValidates) {
143
143
  context.debug(`...validated the '${metaLevelSubstitutionString}' meta-level substitution's '${replacementStatementString}' replacement statement.`);
@@ -147,57 +147,53 @@ export default define(class MetaLevelSubstitution extends Substitution {
147
147
  }
148
148
 
149
149
  toJSON() {
150
- let context;
151
-
152
- context = this.getContext();
153
-
154
- const ephemeralContext = context, ///
155
- ephemeralContextJSON = ephemeralContextToEphemeralContextJSON(ephemeralContext),
156
- contextJSON = ephemeralContextJSON; ///
157
-
158
- context = contextJSON; ///
150
+ const context = this.getContext();
159
151
 
160
- const string = this.getString(),
161
- json = {
162
- context,
163
- string
164
- };
152
+ return serialise((context) => {
153
+ const string = this.getString(),
154
+ json = {
155
+ context,
156
+ string
157
+ };
165
158
 
166
- return json;
159
+ return json;
160
+ }, context);
167
161
  }
168
162
 
169
163
  static name = "MetaLevelSubstitution";
170
164
 
171
165
  static fromJSON(json, context) {
172
- const ephemeralContext = ephemeralContextFromJSON(json, context);
166
+ let metaLevelSubstitution;
173
167
 
174
- context = ephemeralContext; ///
168
+ unserialise((json, context) => {
169
+ instantiate((context) => {
170
+ const { string } = json,
171
+ metaLevelSubstitutionNode = instantiateMetaLevelSubstitution(string, context),
172
+ node = metaLevelSubstitutionNode, ///
173
+ targetReference = targetReferenceFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context),
174
+ replacementStatement = replacementStatementFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context);
175
175
 
176
- return instantiate((context) => {
177
- const { string } = json,
178
- metaLevelSubstitutionNode = instantiateMetaLevelSubstitution(string, context),
179
- node = metaLevelSubstitutionNode, ///
180
- targetReference = targetReferenceFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context),
181
- replacementStatement = replacementStatementFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context),
182
- metaLevelSubstitution = new MetaLevelSubstitution(context, string, node, targetReference, replacementStatement);
176
+ metaLevelSubstitution = new MetaLevelSubstitution(context, string, node, targetReference, replacementStatement);
177
+ }, context);
178
+ }, json, context);
183
179
 
184
- return metaLevelSubstitution;
185
- }, context);
180
+ return metaLevelSubstitution;
186
181
  }
187
182
 
188
183
  static fromStatementAndReference(statement, reference, context) {
189
- const santisedContext = sanitisedContextFromContext(context);
184
+ let metaLevelSubstitution;
190
185
 
191
- context = santisedContext; ///
186
+ simplify((context) => {
187
+ instantiate((context) => {
188
+ const metaLevelSubstitutionString = metaLevelSubstitutionStringFromStatementAndReference(statement, reference),
189
+ string = metaLevelSubstitutionString, ///
190
+ metaLevelSubstitutionNode = instantiateMetaLevelSubstitution(string, context);
192
191
 
193
- return instantiate((context) => {
194
- const metaLevelSubstitutionString = metaLevelSubstitutionStringFromStatementAndReference(statement, reference),
195
- string = metaLevelSubstitutionString, ///
196
- metaLevelSubstitutionNode = instantiateMetaLevelSubstitution(string, context),
197
- metaLevelSubstitution = metaLevelSubstitutionFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context);
198
-
199
- return metaLevelSubstitution;
192
+ metaLevelSubstitution = metaLevelSubstitutionFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context);
193
+ }, context);
200
194
  }, context);
195
+
196
+ return metaLevelSubstitution;
201
197
  }
202
198
  });
203
199
 
@@ -3,8 +3,8 @@
3
3
  import Substitution from "../substitution";
4
4
 
5
5
  import { define } from "../../elements";
6
+ import { simplify, instantiate } from "../../utilities/context";
6
7
  import { instantiateReferenceSubstitution } from "../../process/instantiate";
7
- import { instantiate, sanitisedContextFromContext } from "../../utilities/context";
8
8
  import { referenceSubstitutionFromReferenceSubstitutionNode } from "../../utilities/element";
9
9
  import { referenceSubstitutionStringFromReferenceAndMetavariable } from "../../utilities/string";
10
10
 
@@ -163,7 +163,7 @@ export default define(class ReferenceSubstitution extends Substitution {
163
163
  const { name } = json;
164
164
 
165
165
  if (this.name === name) {
166
- referenceSubstitutionn = instantiate((context) => {
166
+ instantiate((context) => {
167
167
  const { string } = json,
168
168
  referenceSubstitutionNode = instantiateReferenceSubstitution(string, context),
169
169
  node = referenceSubstitutionNode, ///
@@ -172,9 +172,7 @@ export default define(class ReferenceSubstitution extends Substitution {
172
172
 
173
173
  context = null;
174
174
 
175
- const referenceSubstitutionn = new ReferenceSubstitution(context, string, node, targetReference, replacementReference);
176
-
177
- return referenceSubstitutionn;
175
+ referenceSubstitutionn = new ReferenceSubstitution(context, string, node, targetReference, replacementReference);
178
176
  }, context);
179
177
  }
180
178
 
@@ -182,18 +180,19 @@ export default define(class ReferenceSubstitution extends Substitution {
182
180
  }
183
181
 
184
182
  static fromReferenceAndMetavariable(reference, metavariable, context) {
185
- const santisedContext = sanitisedContextFromContext(context);
186
-
187
- context = santisedContext; ///
183
+ let referenceSubstitution;
188
184
 
189
- return instantiate((context) => {
190
- const referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
191
- string = referenceSubstitutionString, ///
192
- referenceSubstitutionNode = instantiateReferenceSubstitution(string, context),
193
- referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
185
+ simplify((context) => {
186
+ instantiate((context) => {
187
+ const referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
188
+ string = referenceSubstitutionString, ///
189
+ referenceSubstitutionNode = instantiateReferenceSubstitution(string, context);
194
190
 
195
- return referenceSubstitution;
191
+ referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
192
+ }, context);
196
193
  }, context);
194
+
195
+ return referenceSubstitution;
197
196
  }
198
197
  });
199
198
 
@@ -6,8 +6,8 @@ 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, simplify, descend, reconcile, instantiate } from "../../utilities/context";
9
10
  import { statementSubstitutionFromStatementSubstitutionNode } from "../../utilities/element";
10
- import { join, reconcile, instantiate, sanitisedContextFromContext } from "../../utilities/context";
11
11
  import { statementSubstitutionStringFromStatementAndMetavariable, statementSubstitutionStringFromStatementMetavariableAndSubstitution } from "../../utilities/string";
12
12
 
13
13
  export default define(class StatementSubstitution extends Substitution {
@@ -158,12 +158,13 @@ export default define(class StatementSubstitution extends Substitution {
158
158
  const targetStatementSingular = this.targetStatement.isSingular();
159
159
 
160
160
  if (targetStatementSingular) {
161
- const stated = true,
162
- targetStatement = this.targetStatement.validate(stated, context);
161
+ descend((context) => {
162
+ const targetStatement = this.targetStatement.validate(context);
163
163
 
164
- if (targetStatement !== null) {
165
- targetStatementValidates = true;
166
- }
164
+ if (targetStatement !== null) {
165
+ targetStatementValidates = true;
166
+ }
167
+ }, context);
167
168
  } else {
168
169
  context.debug(`The '${statementSubstitutionString}' statement substitution's '${targetStatementString}' target statement is not singular.`);
169
170
  }
@@ -184,12 +185,13 @@ export default define(class StatementSubstitution extends Substitution {
184
185
 
185
186
  context.trace(`Validating the '${statementSubstitutionString}' statement substitution's '${replacementStatementString}' replacement statement...`);
186
187
 
187
- const stated = true,
188
- replacementStatement = this.replacementStatement.validate(stated, context);
188
+ descend((context) => {
189
+ const replacementStatement = this.replacementStatement.validate(context);
189
190
 
190
- if (replacementStatement !== null) {
191
- replacementStatementValidates = true;
192
- }
191
+ if (replacementStatement !== null) {
192
+ replacementStatementValidates = true;
193
+ }
194
+ }, context);
193
195
 
194
196
  if (replacementStatementValidates) {
195
197
  context.debug(`...validated the '${statementSubstitutionString}' statement substitution's '${replacementStatementString}' replacement statement.`);
@@ -344,7 +346,7 @@ export default define(class StatementSubstitution extends Substitution {
344
346
  const { name } = json;
345
347
 
346
348
  if (this.name === name) {
347
- statementSubstitutionn = instantiate((context) => {
349
+ instantiate((context) => {
348
350
  const { string } = json,
349
351
  statementSubstitutionNode = instantiateStatementSubstitution(string, context),
350
352
  node = statementSubstitutionNode, ///
@@ -353,9 +355,7 @@ export default define(class StatementSubstitution extends Substitution {
353
355
 
354
356
  context = null;
355
357
 
356
- const statementSubstitutionn = new StatementSubstitution(context, string, node, targetStatement, replacementStatement);
357
-
358
- return statementSubstitutionn;
358
+ statementSubstitutionn = new StatementSubstitution(context, string, node, targetStatement, replacementStatement);
359
359
  }, context);
360
360
  }
361
361
 
@@ -365,35 +365,37 @@ export default define(class StatementSubstitution extends Substitution {
365
365
  static fromStatementAndMetavariable(statement, metavariable, context) {
366
366
  statement = stripBracketsFromStatement(statement, context); ///
367
367
 
368
- const santisedContext = sanitisedContextFromContext(context);
369
-
370
- context = santisedContext; ///
368
+ let statementSubstitution;
371
369
 
372
- return instantiate((context) => {
373
- const statementSubstitutionString = statementSubstitutionStringFromStatementAndMetavariable(statement, metavariable, context),
374
- string = statementSubstitutionString, ///
375
- statementSubstitutionNode = instantiateStatementSubstitution(string, context),
376
- statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
370
+ simplify((context) => {
371
+ instantiate((context) => {
372
+ const statementSubstitutionString = statementSubstitutionStringFromStatementAndMetavariable(statement, metavariable, context),
373
+ string = statementSubstitutionString, ///
374
+ statementSubstitutionNode = instantiateStatementSubstitution(string, context);
377
375
 
378
- return statementSubstitution;
376
+ statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
377
+ }, context);
379
378
  }, context);
379
+
380
+ return statementSubstitution;
380
381
  }
381
382
 
382
383
  static fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context) {
383
384
  statement = stripBracketsFromStatement(statement, context); ///
384
385
 
385
- const santisedContext = sanitisedContextFromContext(context);
386
-
387
- context = santisedContext; ///
386
+ let statementSubstitution;
388
387
 
389
- return instantiate((context) => {
390
- const statementSubstitutionString = statementSubstitutionStringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution),
391
- string = statementSubstitutionString, ///
392
- statementSubstitutionNode = instantiateStatementSubstitution(string, context),
393
- statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
388
+ simplify((context) => {
389
+ instantiate((context) => {
390
+ const statementSubstitutionString = statementSubstitutionStringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution),
391
+ string = statementSubstitutionString, ///
392
+ statementSubstitutionNode = instantiateStatementSubstitution(string, context);
394
393
 
395
- return statementSubstitution;
394
+ statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
395
+ }, context);
396
396
  }, context);
397
+
398
+ return statementSubstitution;
397
399
  }
398
400
  });
399
401
 
@@ -3,9 +3,9 @@
3
3
  import Substitution from "../substitution";
4
4
 
5
5
  import { define } from "../../elements";
6
+ import { simplify, instantiate } from "../../utilities/context";
6
7
  import { stripBracketsFromTerm } from "../../utilities/brackets";
7
8
  import { instantiateTermSubstitution } from "../../process/instantiate";
8
- import { instantiate, sanitisedContextFromContext } from "../../utilities/context";
9
9
  import { termSubstitutionStringFromTermAndVariable } from "../../utilities/string";
10
10
  import { termSubstitutionFromStatementNode, termSubstitutionFromTermSubstitutionNode } from "../../utilities/element";
11
11
 
@@ -184,7 +184,7 @@ export default define(class TermSubstitution extends Substitution {
184
184
  const { name } = json;
185
185
 
186
186
  if (this.name === name) {
187
- termSubstitutionn = instantiate((context) => {
187
+ instantiate((context) => {
188
188
  const { string } = json,
189
189
  termSubstitutionNode = instantiateTermSubstitution(string, context),
190
190
  node = termSubstitutionNode, ///
@@ -193,9 +193,7 @@ export default define(class TermSubstitution extends Substitution {
193
193
 
194
194
  context = null;
195
195
 
196
- const termSubstitutionn = new TermSubstitution(context, string, node, targetTerm, replacementTerm);
197
-
198
- return termSubstitutionn;
196
+ termSubstitutionn = new TermSubstitution(context, string, node, targetTerm, replacementTerm);
199
197
  }, context);
200
198
  }
201
199
 
@@ -212,18 +210,19 @@ export default define(class TermSubstitution extends Substitution {
212
210
  static fromTermAndVariable(term, variable, context) {
213
211
  term = stripBracketsFromTerm(term, context); ///
214
212
 
215
- const santisedContext = sanitisedContextFromContext(context);
216
-
217
- context = santisedContext; ///
213
+ let termSubstitution;
218
214
 
219
- return instantiate((context) => {
220
- const termSubstitutionString = termSubstitutionStringFromTermAndVariable(term, variable),
221
- string = termSubstitutionString, ///
222
- termSubstitutionNode = instantiateTermSubstitution(string, context),
223
- termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, context);
215
+ simplify((context) => {
216
+ instantiate((context) => {
217
+ const termSubstitutionString = termSubstitutionStringFromTermAndVariable(term, variable),
218
+ string = termSubstitutionString, ///
219
+ termSubstitutionNode = instantiateTermSubstitution(string, context);
224
220
 
225
- return termSubstitution;
221
+ termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, context);
222
+ }, context);
226
223
  }, context);
224
+
225
+ return termSubstitution;
227
226
  }
228
227
  });
229
228