occam-verify-cli 1.0.764 → 1.0.776

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 (106) hide show
  1. package/lib/context/file/nominal.js +16 -47
  2. package/lib/context/illative.js +28 -0
  3. package/lib/context/nested.js +27 -0
  4. package/lib/context/nominal.js +2 -4
  5. package/lib/context/proof.js +232 -0
  6. package/lib/context/thetic.js +28 -0
  7. package/lib/context.js +37 -12
  8. package/lib/element/assertion/contained.js +24 -22
  9. package/lib/element/assertion/defined.js +20 -19
  10. package/lib/element/assertion/property.js +14 -13
  11. package/lib/element/assertion/satisfies.js +9 -10
  12. package/lib/element/assertion/subproof.js +23 -26
  13. package/lib/element/assertion/type.js +9 -11
  14. package/lib/element/assumption.js +46 -55
  15. package/lib/element/combinator/bracketed.js +3 -3
  16. package/lib/element/combinator.js +20 -20
  17. package/lib/element/conclusion.js +33 -29
  18. package/lib/element/constructor.js +19 -18
  19. package/lib/element/deduction.js +33 -29
  20. package/lib/element/equality.js +13 -15
  21. package/lib/element/equivalence.js +58 -49
  22. package/lib/element/frame.js +41 -34
  23. package/lib/element/hypothesis.js +7 -5
  24. package/lib/element/judgement.js +33 -73
  25. package/lib/element/label.js +22 -22
  26. package/lib/element/metavariable.js +23 -7
  27. package/lib/element/proofAssertion/premise.js +48 -35
  28. package/lib/element/proofAssertion/step.js +35 -20
  29. package/lib/element/proofAssertion/supposition.js +48 -34
  30. package/lib/element/proofAssertion.js +1 -14
  31. package/lib/element/reference.js +79 -52
  32. package/lib/element/signature.js +44 -3
  33. package/lib/element/statement.js +28 -28
  34. package/lib/element/substitution/frame.js +28 -23
  35. package/lib/element/substitution/metaLevel.js +34 -30
  36. package/lib/element/substitution/reference.js +12 -11
  37. package/lib/element/substitution/statement.js +44 -39
  38. package/lib/element/substitution/term.js +12 -11
  39. package/lib/element/term.js +24 -20
  40. package/lib/element/topLevelMetaAssertion.js +2 -2
  41. package/lib/element/variable.js +6 -2
  42. package/lib/process/assign.js +10 -4
  43. package/lib/process/unify.js +8 -8
  44. package/lib/process/validate.js +10 -8
  45. package/lib/utilities/context.js +68 -25
  46. package/lib/utilities/element.js +55 -27
  47. package/lib/utilities/json.js +8 -8
  48. package/lib/utilities/statement.js +1 -8
  49. package/lib/utilities/string.js +12 -1
  50. package/lib/utilities/unification.js +6 -4
  51. package/lib/utilities/validation.js +39 -31
  52. package/package.json +1 -1
  53. package/src/context/file/nominal.js +26 -74
  54. package/src/context/illative.js +17 -0
  55. package/src/context/nested.js +15 -0
  56. package/src/context/nominal.js +1 -5
  57. package/src/context/{scoped.js → proof.js} +73 -73
  58. package/src/context/thetic.js +17 -0
  59. package/src/context.js +58 -17
  60. package/src/element/assertion/contained.js +28 -28
  61. package/src/element/assertion/defined.js +23 -23
  62. package/src/element/assertion/property.js +15 -14
  63. package/src/element/assertion/satisfies.js +8 -10
  64. package/src/element/assertion/subproof.js +26 -31
  65. package/src/element/assertion/type.js +10 -12
  66. package/src/element/assumption.js +51 -74
  67. package/src/element/combinator/bracketed.js +2 -2
  68. package/src/element/combinator.js +23 -29
  69. package/src/element/conclusion.js +37 -40
  70. package/src/element/constructor.js +29 -34
  71. package/src/element/deduction.js +36 -39
  72. package/src/element/equality.js +16 -18
  73. package/src/element/equivalence.js +77 -64
  74. package/src/element/frame.js +43 -35
  75. package/src/element/hypothesis.js +7 -6
  76. package/src/element/judgement.js +37 -43
  77. package/src/element/label.js +25 -31
  78. package/src/element/metavariable.js +32 -12
  79. package/src/element/proofAssertion/premise.js +63 -49
  80. package/src/element/proofAssertion/step.js +43 -23
  81. package/src/element/proofAssertion/supposition.js +64 -50
  82. package/src/element/proofAssertion.js +0 -22
  83. package/src/element/reference.js +118 -79
  84. package/src/element/signature.js +5 -2
  85. package/src/element/statement.js +30 -33
  86. package/src/element/substitution/frame.js +32 -30
  87. package/src/element/substitution/metaLevel.js +43 -46
  88. package/src/element/substitution/reference.js +17 -17
  89. package/src/element/substitution/statement.js +58 -56
  90. package/src/element/substitution/term.js +17 -17
  91. package/src/element/term.js +42 -34
  92. package/src/element/topLevelMetaAssertion.js +1 -1
  93. package/src/element/variable.js +8 -1
  94. package/src/process/assign.js +9 -3
  95. package/src/process/unify.js +7 -7
  96. package/src/process/validate.js +9 -8
  97. package/src/utilities/context.js +79 -36
  98. package/src/utilities/element.js +68 -31
  99. package/src/utilities/json.js +13 -13
  100. package/src/utilities/statement.js +1 -9
  101. package/src/utilities/string.js +16 -2
  102. package/src/utilities/unification.js +7 -6
  103. package/src/utilities/validation.js +50 -38
  104. package/lib/context/scoped.js +0 -232
  105. package/lib/utilities/term.js +0 -17
  106. package/src/utilities/term.js +0 -10
@@ -3,23 +3,27 @@
3
3
  import { Element } from "occam-languages";
4
4
 
5
5
  import { define } from "../elements";
6
- import { instantiate } from "../utilities/context";
7
6
  import { instantiateReference } from "../process/instantiate";
8
7
  import { REFERENCE_META_TYPE_NAME } from "../metaTypeNames";
9
- import { metavariableFromReferenceNode } from "../utilities/element";
10
- import { unifyMetavariableIntrinsically } from "../process/unify";
8
+ import { serialise, reconcile, unserialise, instantiate } from "../utilities/context";
9
+ import { metavariableFromReferenceNode, topLevelMetaAssertionFromReferenceNode } from "../utilities/element";
11
10
 
12
11
  export default define(class Reference extends Element {
13
- constructor(context, string, node, metavariable) {
12
+ constructor(context, string, node, metavariable, topLevelMetaAssertion) {
14
13
  super(context, string, node);
15
14
 
16
15
  this.metavariable = metavariable;
16
+ this.topLevelMetaAssertion = topLevelMetaAssertion;
17
17
  }
18
18
 
19
19
  getMetavariable() {
20
20
  return this.metavariable;
21
21
  }
22
22
 
23
+ getTopLevelMetaAssertion() {
24
+ return this.topLevelMetaAssertion;
25
+ }
26
+
23
27
  getReferenceNode() {
24
28
  const node = this.getNode(),
25
29
  referenceNode = node; ///
@@ -27,8 +31,6 @@ export default define(class Reference extends Element {
27
31
  return referenceNode;
28
32
  }
29
33
 
30
- getName() { return this.metavariable.getName(); }
31
-
32
34
  getMetavariableName() {
33
35
  const metavariableName = this.metavariable.getName();
34
36
 
@@ -41,6 +43,14 @@ export default define(class Reference extends Element {
41
43
  return metavariableNode;
42
44
  }
43
45
 
46
+ isEqualTo(reference) {
47
+ const referenceNode = reference.getNode(),
48
+ referenceNodeMatches = this.matchReferenceNode(referenceNode),
49
+ equalTo = referenceNodeMatches; ///
50
+
51
+ return equalTo;
52
+ }
53
+
44
54
  matchReferenceNode(referenceNode) {
45
55
  const node = referenceNode, ///
46
56
  nodeMatches = this.matchNode(node),
@@ -49,21 +59,7 @@ export default define(class Reference extends Element {
49
59
  return referenceNodeMatches;
50
60
  }
51
61
 
52
- findValidRefernece(context) {
53
- const metavariableNode = this.getMetavariableNode(),
54
- reference = context.findReferenceByMetavariableNode(metavariableNode),
55
- validReference = reference; ///
56
-
57
- return validReference;
58
- }
59
-
60
- isEqualTo(reference) {
61
- const referenceNode = reference.getNode(),
62
- referenceNodeMatches = this.matchReferenceNode(referenceNode),
63
- equalTo = referenceNodeMatches; ///
64
-
65
- return equalTo;
66
- }
62
+ matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
67
63
 
68
64
  compareParameter(parameter) {
69
65
  let comparesToParamter = false;
@@ -103,7 +99,36 @@ export default define(class Reference extends Element {
103
99
 
104
100
  compareMetavariableName(metavariableName) { return this.metavariable.compareMetavariableName(metavariableName); }
105
101
 
106
- matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
102
+ compareTopLevelMetaAssertion(topLevelMetaAssertion) {
103
+ let topLevelMetaAssertionCompares = false;
104
+
105
+ const context = this.getContext(),
106
+ referenceString = this.getString(), ///
107
+ topLevelMetaAssertionString = topLevelMetaAssertion.getString();
108
+
109
+ context.trace(`Comparing the '${topLevelMetaAssertionString}' top level meta-assertion to the '${referenceString}' reference...`);
110
+
111
+ const label = topLevelMetaAssertion.getLabel(),
112
+ labelUnifies = this.unifyLabel(label);
113
+
114
+ if (labelUnifies) {
115
+ topLevelMetaAssertionCompares = true;
116
+ }
117
+
118
+ if (topLevelMetaAssertionCompares) {
119
+ context.trace(`...compared the '${topLevelMetaAssertionString}' top level meta-assertion to the '${referenceString}' reference.`);
120
+ }
121
+
122
+ return topLevelMetaAssertionCompares;
123
+ }
124
+
125
+ findValidRefernece(context) {
126
+ const metavariableNode = this.getMetavariableNode(),
127
+ reference = context.findReferenceByMetavariableNode(metavariableNode),
128
+ validReference = reference; ///
129
+
130
+ return validReference;
131
+ }
107
132
 
108
133
  validate(context) {
109
134
  let reference = null;
@@ -112,10 +137,10 @@ export default define(class Reference extends Element {
112
137
 
113
138
  context.trace(`Validating the '${referenceString}' reference...`);
114
139
 
115
- const validRefernece = this.findValidRefernece(context);
140
+ const validReference = this.findValidRefernece(context);
116
141
 
117
- if (validRefernece !== null) {
118
- reference = validRefernece; ///
142
+ if (validReference !== null) {
143
+ reference = validReference; ///
119
144
 
120
145
  context.debug(`...the '${referenceString}' reference is already valid.`);
121
146
  } else {
@@ -170,6 +195,8 @@ export default define(class Reference extends Element {
170
195
  const referenceString = this.getString(), ///
171
196
  metavariableString = this.metavariable.getString();
172
197
 
198
+ context = this.getContext();
199
+
173
200
  context.trace(`Validating the '${referenceString}' reference's '${metavariableString}' metavariable...'`);
174
201
 
175
202
  const metavariable = this.metavariable.validate(context);
@@ -187,29 +214,23 @@ export default define(class Reference extends Element {
187
214
  return metavariableValidates;
188
215
  }
189
216
 
190
- unifyLabel(label, context) {
191
- let labelUnifies;
192
-
193
- const specificContext = context; ///
194
-
195
- context = this.getContext();
196
-
197
- const generalContext = context; ///
217
+ unifyLabel(label) {
218
+ let labelUnifies = false;
198
219
 
199
- context = specificContext; ///
200
-
201
- const reference = this, ///
220
+ const context = label.getContext(),
202
221
  labelString = label.getString(),
203
- referenceString = reference.getString();
222
+ referenceString = this.getString(); ///
204
223
 
205
224
  context.trace(`Unifying the '${labelString}' label with the '${referenceString}' reference...`);
206
225
 
207
- const labelMetavariable = label.getMetavariable(),
208
- generalMetavariable = this.metavariable, ///
209
- specificMetavariable = labelMetavariable, ///
210
- metavariableUnifiesIntrinsically = unifyMetavariableIntrinsically(generalMetavariable, specificMetavariable, generalContext, specificContext);
226
+ reconcile((context) => {
227
+ const metavariable = label.getMetavariable(),
228
+ metavariableUnifies = this.unifyMetavariable(metavariable, context);
211
229
 
212
- labelUnifies = metavariableUnifiesIntrinsically; ///
230
+ if (metavariableUnifies) {
231
+ labelUnifies = true;
232
+ }
233
+ }, context);
213
234
 
214
235
  if (labelUnifies) {
215
236
  context.debug(`...unified the '${labelString}' label with the '${referenceString}' reference.`);
@@ -221,22 +242,20 @@ export default define(class Reference extends Element {
221
242
  unifyMetavariable(metavariable, context) {
222
243
  let metavariableUnifies = false;
223
244
 
224
- const specificContext = context; ///
245
+ const referenceString = this.getString(), ///
246
+ metavariableString = metavariable.getString();
225
247
 
226
- context = this.getContext();
248
+ context.trace(`Unifying the '${metavariableString}' metavariable with the '${referenceString}' reference...`);
227
249
 
228
- const generalContext = context; ///
250
+ const specificContext = context; ///
229
251
 
230
- context = specificContext; ///
252
+ context = this.getContext();
231
253
 
232
- const referenceString = this.getString(), ///
233
- metavariableString = metavariable.getString();
254
+ const generalContext = context; ///
234
255
 
235
- context.trace(`Unifying the '${metavariableString}' metavariable with the '${referenceString}' reference...`);
256
+ context = specificContext; ///
236
257
 
237
- const generalMetavariable = this.metavariable, ///
238
- specificMetavariable = metavariable, ///
239
- metavariableUnifiesIntrinsically = unifyMetavariableIntrinsically(generalMetavariable, specificMetavariable, generalContext, specificContext);
258
+ const metavariableUnifiesIntrinsically = this.metavariable.unifyMetavariableIntrinsically(metavariable, generalContext, specificContext);
240
259
 
241
260
  if (metavariableUnifiesIntrinsically) {
242
261
  metavariableUnifies = true;
@@ -249,52 +268,72 @@ export default define(class Reference extends Element {
249
268
  return metavariableUnifies;
250
269
  }
251
270
 
252
- compareTopLevelMetaAssertion(topLevelMetaAssertion, context) {
253
- let topLevelMetaAssertionCompares = false;
271
+ unifyTopLevelMetaAssertion(topLevelMetaAssertion, context) {
272
+ let topLevelMetaAssertionUUnifies = false;
254
273
 
255
- const reference = this, ///
256
- referenceString = reference.getString(),
274
+ const label = topLevelMetaAssertion.getLabel(),
275
+ referenceString = this.getString(), ///
257
276
  topLevelMetaAssertionString = topLevelMetaAssertion.getString();
258
277
 
259
- context.trace(`Comparing the '${topLevelMetaAssertionString}' top level meta-assertion to the '${referenceString}' reference...`);
278
+ context.trace(`Unifying the '${topLevelMetaAssertionString}' top level meta-assertion with the '${referenceString}' reference...`);
260
279
 
261
- const label = topLevelMetaAssertion.getLabel(),
262
- labelUnifies = this.unifyLabel(label, context);
280
+ const specificContext = context; ///
263
281
 
264
- if (labelUnifies) {
265
- topLevelMetaAssertionCompares = true;
266
- }
282
+ context = label.getContext();
267
283
 
268
- if (topLevelMetaAssertionCompares) {
269
- context.trace(`...compared the '${topLevelMetaAssertionString}' top level meta-assertion to the '${referenceString}' reference.`);
284
+ reconcile((context) => {
285
+ const metavariable = label.getMetavariable(),
286
+ metavariableUnifies = this.unifyMetavariable(metavariable, context);
287
+
288
+ if (metavariableUnifies) {
289
+ this.topLevelMetaAssertion = topLevelMetaAssertion;
290
+
291
+ context.commit(specificContext);
292
+
293
+ topLevelMetaAssertionUUnifies = true;
294
+ }
295
+ }, context);
296
+
297
+ context = specificContext; ///
298
+
299
+ if (topLevelMetaAssertionUUnifies) {
300
+ context.debug(`...unified the '${topLevelMetaAssertionString}' top level meta-assertion with the '${referenceString}' reference.`);
270
301
  }
271
302
 
272
- return topLevelMetaAssertionCompares;
303
+ return topLevelMetaAssertionUUnifies;
273
304
  }
274
305
 
275
306
  toJSON() {
276
- const string = this.getString(),
277
- json = {
278
- string
279
- };
307
+ const context = this.getContext();
308
+
309
+ return serialise((context) => {
310
+ const string = this.getString(),
311
+ json = {
312
+ context,
313
+ string
314
+ };
280
315
 
281
- return json;
316
+ return json;
317
+ }, context);
282
318
  }
283
319
 
284
320
  static name = "Reference";
285
321
 
286
322
  static fromJSON(json, context) {
287
- return instantiate((context) => {
288
- const { string } = json,
289
- referenceNode = instantiateReference(string, context),
290
- node = referenceNode, ///
291
- metavariable = metavariableFromReferenceNode(referenceNode, context);
323
+ let reference;
292
324
 
293
- context = null;
325
+ unserialise((json, context) => {
326
+ instantiate((context) => {
327
+ const { string } = json,
328
+ referenceNode = instantiateReference(string, context),
329
+ node = referenceNode, ///
330
+ metavariable = metavariableFromReferenceNode(referenceNode, context),
331
+ topLevelMetaAssertion = topLevelMetaAssertionFromReferenceNode(referenceNode, context);
294
332
 
295
- const reference = new Reference(context, string, node, metavariable);
333
+ reference = new Reference(context, string, node, metavariable, topLevelMetaAssertion);
334
+ }, context);
335
+ }, json, context);
296
336
 
297
- return reference;
298
- }, context);
337
+ return reference;
299
338
  }
300
339
  });
@@ -3,6 +3,8 @@
3
3
  import { Element } from "occam-languages";
4
4
  import { arrayUtilities } from "necessary";
5
5
 
6
+ import elements from "../elements";
7
+
6
8
  import { define } from "../elements";
7
9
  import { instantiate } from "../utilities/context";
8
10
  import { instantiateSignature } from "../process/instantiate";
@@ -125,9 +127,10 @@ export default define(class Signature extends Element {
125
127
  termsA = this.terms, ///
126
128
  termsB = terms, ///
127
129
  matches = match(termsA, termsB, (termA, termB) => {
128
- const term = termB, ///
130
+ const { Variable } = elements,
131
+ term = termB, ///
129
132
  context = generalContext, ///
130
- variable = variableFromTerm(term, context);
133
+ variable = Variable.fromTerm(term, context);
131
134
 
132
135
  if (variable !== null) {
133
136
  const term = termA, ///
@@ -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,34 +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
- deductionUnifies = true;
270
- }
271
- }, specificContext);
267
+ deductionUnifies = true;
268
+ }
269
+ }, specificContext);
270
+ }, specificContext, context);
272
271
 
273
272
  if (deductionUnifies) {
274
- context.debug(`...unified the '${deductionString}' deduction's '${deductionStatementString}' statement with the '${statementString}' statement.`);
273
+ context.debug(`...unified the '${deductionString}' deduction with the '${statementString}' statement.`);
275
274
  }
276
275
 
277
276
  return deductionUnifies;
@@ -336,41 +335,39 @@ export default define(class Statement extends Element {
336
335
  return unifiesIndependently;
337
336
  }
338
337
 
339
- unifyTopLevelMetaAssertion(topLevelMetaAssertion, generalContext, specificContext) {
340
- let topLevelMetaAssertionUnifies = false;
338
+ unifyTopLevelMetaAssertion(topLevelMetaAssertion, context) {
339
+ let topLevelAssertionUnifies = false;
341
340
 
342
- const context = specificContext, ///
343
- statementString = this.getString(), ///
341
+ const statementString = this.getString(), ///
344
342
  topLevelMetaAssertionString = topLevelMetaAssertion.getString();
345
343
 
346
344
  context.trace(`Unifying the '${topLevelMetaAssertionString}' top level meta-assertion with the '${statementString}' statement...`);
347
345
 
348
- const topLevelMetaAssertionUnconditional = topLevelMetaAssertion.isUnconditional();
346
+ const unconditional = topLevelMetaAssertion.isUnconditional();
349
347
 
350
- if (topLevelMetaAssertionUnconditional) {
348
+ if (unconditional) {
351
349
  const deduction = topLevelMetaAssertion.getDeduction(),
352
- deductionUnifies = this.unifyDeduction(deduction, generalContext, specificContext);
350
+ deductionUnifies = this.unifyDeduction(deduction, context);
353
351
 
354
352
  if (deductionUnifies) {
355
- topLevelMetaAssertionUnifies = true;
353
+ topLevelAssertionUnifies = true;
356
354
  }
357
355
  } else {
358
356
  const statementNode = this.getStatementNode(),
359
357
  subproofAssertionNode = statementNode.getSubproofAssertionNode();
360
358
 
361
359
  if (subproofAssertionNode !== null) {
362
- const context = generalContext, ///
363
- subproofAssertion = context.findAssertionByAssertionNode(subproofAssertionNode);
360
+ const subproofAssertion = context.findAssertionByAssertionNode(subproofAssertionNode);
364
361
 
365
- topLevelMetaAssertionUnifies = subproofAssertion.unifyTopLevelMetaAssertion(topLevelMetaAssertion, generalContext, specificContext);
362
+ topLevelAssertionUnifies = subproofAssertion.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
366
363
  }
367
364
  }
368
365
 
369
- if (topLevelMetaAssertionUnifies) {
366
+ if (topLevelAssertionUnifies) {
370
367
  context.debug(`...unified the '${topLevelMetaAssertionString}' top level meta-assertion with the '${statementString}' statement.`);
371
368
  }
372
369
 
373
- return topLevelMetaAssertionUnifies;
370
+ return topLevelAssertionUnifies;
374
371
  }
375
372
 
376
373
  toJSON() {
@@ -3,8 +3,8 @@
3
3
  import Substitution from "../substitution";
4
4
 
5
5
  import { define } from "../../elements";
6
- import { instantiate } from "../../utilities/context";
7
6
  import { instantiateFrameSubstitution } from "../../process/instantiate";
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
 
@@ -73,11 +73,8 @@ export default define(class FrameSubstitution extends Substitution {
73
73
  validate(generalContext, specificContext) {
74
74
  let frameSubstitution = null;
75
75
 
76
- const context = this.getContext();
77
-
78
- specificContext = context; ///
79
-
80
- const frameSubstitutionString = this.getString(); ///
76
+ const context = specificContext, ///
77
+ frameSubstitutionString = this.getString(); ///
81
78
 
82
79
  context.trace(`Validating the '${frameSubstitutionString}' frame substitution...`);
83
80
 
@@ -126,14 +123,15 @@ export default define(class FrameSubstitution extends Substitution {
126
123
  const targetFrameSingular = this.targetFrame.isSingular();
127
124
 
128
125
  if (targetFrameSingular) {
129
- const stated = true,
130
- tragetFrame = this.targetFrame.validate(stated, context);
126
+ descend((context) => {
127
+ const tragetFrame = this.targetFrame.validate(context);
131
128
 
132
- if (tragetFrame !== null) {
133
- this.targetFrame = tragetFrame;
129
+ if (tragetFrame !== null) {
130
+ this.targetFrame = tragetFrame;
134
131
 
135
- targetFrameValidates = true;
136
- }
132
+ targetFrameValidates = true;
133
+ }
134
+ }, context);
137
135
  } else {
138
136
  context.debug(`The '${frameSubstitutionString}' frame substitution's '${targetFrameString}' target frame is not singular.`);
139
137
  }
@@ -146,22 +144,23 @@ export default define(class FrameSubstitution extends Substitution {
146
144
  }
147
145
 
148
146
  validateReplacementFrame(generalContext, specificContext) {
149
- let replacementFrameValidates;
147
+ let replacementFrameValidates = false;
150
148
 
151
- const context = specificContext, ///
149
+ const context = this.getContext(),
152
150
  replacementFrameString = this.replacementFrame.getString(),
153
151
  frameSubstitutionString = this.getString(); ///
154
152
 
155
153
  context.trace(`Validating the '${frameSubstitutionString}' frame substitution's '${replacementFrameString}' replacement frame...`);
156
154
 
157
- const stated = true,
158
- replacementFrame = this.replacementFrame.validate(stated, context);
155
+ descend((context) => {
156
+ const replacementFrame = this.replacementFrame.validate(context);
159
157
 
160
- if (replacementFrame !== null) {
161
- this.replacementFrame = replacementFrame;
158
+ if (replacementFrame !== null) {
159
+ this.replacementFrame = replacementFrame;
162
160
 
163
- replacementFrameValidates = true;
164
- }
161
+ replacementFrameValidates = true;
162
+ }
163
+ }, context);
165
164
 
166
165
  if (replacementFrameValidates) {
167
166
  context.debug(`...validated the '${frameSubstitutionString}' frame substitution's '${replacementFrameString}' replacement frame.`);
@@ -178,7 +177,7 @@ export default define(class FrameSubstitution extends Substitution {
178
177
  const { name } = json;
179
178
 
180
179
  if (this.name === name) {
181
- frameSubstitutionn = instantiate((context) => {
180
+ instantiate((context) => {
182
181
  const { string } = json,
183
182
  frameSubstitutionNode = instantiateFrameSubstitution(string, context),
184
183
  node = frameSubstitutionNode, ///
@@ -187,9 +186,7 @@ export default define(class FrameSubstitution extends Substitution {
187
186
 
188
187
  context = null;
189
188
 
190
- const frameSubstitutionn = new FrameSubstitution(context, string, node, targetFrame, replacementFrame);
191
-
192
- return frameSubstitutionn;
189
+ frameSubstitutionn = new FrameSubstitution(context, string, node, targetFrame, replacementFrame);
193
190
  }, context);
194
191
  }
195
192
 
@@ -204,14 +201,19 @@ export default define(class FrameSubstitution extends Substitution {
204
201
  }
205
202
 
206
203
  static fromFrameAndMetavariable(frame, metavariable, context) {
207
- return instantiate((context) => {
208
- const frameSubstitutionString = frameSubstitutionStringFromFrameAndMetavariable(frame, metavariable),
209
- string = frameSubstitutionString, ///
210
- frameSubstitutionNode = instantiateFrameSubstitution(string, context),
211
- frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context);
204
+ let frameSubstitution
205
+
206
+ simplify((context) => {
207
+ instantiate((context) => {
208
+ const frameSubstitutionString = frameSubstitutionStringFromFrameAndMetavariable(frame, metavariable),
209
+ string = frameSubstitutionString, ///
210
+ frameSubstitutionNode = instantiateFrameSubstitution(string, context);
212
211
 
213
- return frameSubstitution;
212
+ frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context);
213
+ }, context);
214
214
  }, context);
215
+
216
+ return frameSubstitution;
215
217
  }
216
218
  });
217
219