occam-nominal 1.0.310 → 1.0.317

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 (69) hide show
  1. package/lib/context/liminal.js +17 -15
  2. package/lib/context/phaneric.js +3 -3
  3. package/lib/context.js +3 -3
  4. package/lib/element/assertion/contained.js +19 -17
  5. package/lib/element/assertion/defined.js +16 -14
  6. package/lib/element/conclusion.js +10 -11
  7. package/lib/element/declaration/variable.js +2 -2
  8. package/lib/element/deduction.js +7 -7
  9. package/lib/element/equality.js +3 -3
  10. package/lib/element/frame.js +8 -3
  11. package/lib/element/goal.js +7 -8
  12. package/lib/element/judgement.js +8 -10
  13. package/lib/element/metavariable.js +44 -40
  14. package/lib/element/proof.js +2 -2
  15. package/lib/element/proofAssertion/premise.js +17 -21
  16. package/lib/element/proofAssertion/step.js +5 -5
  17. package/lib/element/proofAssertion/supposition.js +39 -35
  18. package/lib/element/rule.js +24 -22
  19. package/lib/element/statement.js +56 -32
  20. package/lib/element/substitution/frame.js +71 -62
  21. package/lib/element/substitution/reference.js +21 -21
  22. package/lib/element/substitution/statement.js +81 -98
  23. package/lib/element/substitution/term.js +76 -67
  24. package/lib/element/substitution.js +5 -5
  25. package/lib/element/term.js +2 -2
  26. package/lib/element/topLevelAssertion/axiom.js +4 -5
  27. package/lib/element/topLevelAssertion/conjecture.js +3 -3
  28. package/lib/element/topLevelAssertion/lemma.js +3 -3
  29. package/lib/element/topLevelAssertion/theorem.js +3 -3
  30. package/lib/element/topLevelAssertion.js +59 -69
  31. package/lib/node/metavariable.js +18 -1
  32. package/lib/process/unify.js +5 -7
  33. package/lib/process/validation.js +5 -2
  34. package/lib/utilities/element.js +34 -56
  35. package/package.json +2 -2
  36. package/src/context/liminal.js +18 -16
  37. package/src/context/phaneric.js +3 -3
  38. package/src/context.js +2 -2
  39. package/src/element/assertion/contained.js +19 -18
  40. package/src/element/assertion/defined.js +16 -16
  41. package/src/element/conclusion.js +9 -11
  42. package/src/element/declaration/variable.js +1 -1
  43. package/src/element/deduction.js +6 -6
  44. package/src/element/equality.js +2 -2
  45. package/src/element/frame.js +10 -2
  46. package/src/element/goal.js +6 -8
  47. package/src/element/judgement.js +7 -11
  48. package/src/element/metavariable.js +56 -52
  49. package/src/element/proof.js +1 -1
  50. package/src/element/proofAssertion/premise.js +17 -25
  51. package/src/element/proofAssertion/step.js +4 -4
  52. package/src/element/proofAssertion/supposition.js +44 -43
  53. package/src/element/rule.js +27 -25
  54. package/src/element/statement.js +71 -41
  55. package/src/element/substitution/frame.js +88 -82
  56. package/src/element/substitution/reference.js +30 -32
  57. package/src/element/substitution/statement.js +97 -132
  58. package/src/element/substitution/term.js +95 -89
  59. package/src/element/substitution.js +6 -6
  60. package/src/element/term.js +1 -1
  61. package/src/element/topLevelAssertion/axiom.js +3 -5
  62. package/src/element/topLevelAssertion/conjecture.js +2 -2
  63. package/src/element/topLevelAssertion/lemma.js +2 -2
  64. package/src/element/topLevelAssertion/theorem.js +2 -2
  65. package/src/element/topLevelAssertion.js +61 -80
  66. package/src/node/metavariable.js +28 -1
  67. package/src/process/unify.js +7 -16
  68. package/src/process/validation.js +5 -4
  69. package/src/utilities/element.js +49 -64
@@ -68,7 +68,7 @@ export default define(class Rule extends Element {
68
68
  verifyPremises = this.verifyPremises.bind(this),
69
69
  verifyConclusion = this.verifyConclusion.bind(this);
70
70
 
71
- all([
71
+ return all([
72
72
  verifyLabels,
73
73
  verifyPremises,
74
74
  verifyConclusion,
@@ -87,13 +87,29 @@ export default define(class Rule extends Element {
87
87
  }, context);
88
88
  });
89
89
 
90
+ verifyLabels(context, conntinuation) {
91
+ const ruleString = this.getString(); ///
92
+
93
+ context.trace(`Verifying the '${ruleString}' rule's labels...`);
94
+
95
+ return every(this.labels, (label, continuation) => {
96
+ return this.verifyLabel(label, context, continuation);
97
+ }, (labelsVerify) => {
98
+ if (labelsVerify) {
99
+ context.debug(`...verified the '${ruleString}' rule's labels.`);
100
+ }
101
+
102
+ return conntinuation(labelsVerify);
103
+ });
104
+ }
105
+
90
106
  verifyLabel(label, context, continuation) {
91
107
  const ruleString = this.getString(), ///
92
108
  labelString = label.getString();
93
109
 
94
110
  context.trace(`Verifying the '${ruleString}' rule's '${labelString}' label...`);
95
111
 
96
- label.verify((labelVerifies) => {
112
+ return label.verify((labelVerifies) => {
97
113
  if (labelVerifies) {
98
114
  context.debug(`...verified the '${ruleString}' rule's '${labelString}' label.`);
99
115
  }
@@ -115,7 +131,7 @@ export default define(class Rule extends Element {
115
131
 
116
132
  const statement = this.conclusion.getStatement();
117
133
 
118
- this.proof.verify(statement, context, (proofVerifies) => {
134
+ return this.proof.verify(statement, context, (proofVerifies) => {
119
135
  if (proofVerifies) {
120
136
  context.debug(`...verified the '${ruleString}' rule's proof.`);
121
137
  }
@@ -124,29 +140,13 @@ export default define(class Rule extends Element {
124
140
  });
125
141
  }
126
142
 
127
- verifyLabels(context, conntinuation) {
128
- const ruleString = this.getString(); ///
129
-
130
- context.trace(`Verifying the '${ruleString}' rule's labels...`);
131
-
132
- return every(this.labels, (label, continuation) => {
133
- return this.verifyLabel(label, context, continuation);
134
- }, (labelsVerify) => {
135
- if (labelsVerify) {
136
- context.debug(`...verified the '${ruleString}' rule's labels.`);
137
- }
138
-
139
- return conntinuation(labelsVerify);
140
- });
141
- }
142
-
143
143
  verifyPremise(premise, context, continuation) {
144
144
  const ruleString = this.getString(), ///
145
145
  premiseString = premise.getString();
146
146
 
147
147
  context.trace(`Verifying the '${ruleString}' rule's '${premiseString}' premise...`);
148
148
 
149
- premise.verify(context, (premiseVerifies) => {
149
+ return premise.verify(context, (premiseVerifies) => {
150
150
  if (premiseVerifies) {
151
151
  const subproofOrProofAssertion = premise; ////
152
152
 
@@ -185,7 +185,7 @@ export default define(class Rule extends Element {
185
185
 
186
186
  context.trace(`Verifying the '${ruleString}' rule's '${conclusionString}' conclusion...`);
187
187
 
188
- this.conclusion.verify(context, (conclusionVerifies) => {
188
+ return this.conclusion.verify(context, (conclusionVerifies) => {
189
189
  if (conclusionVerifies) {
190
190
  context.debug(`...verified the '${ruleString}' rule's '${conclusionString}' conclusion.`);
191
191
  }
@@ -201,7 +201,7 @@ export default define(class Rule extends Element {
201
201
 
202
202
  context.trace(`Unifying the '${stepString}' step with the '${ruleString}' rule's '${conclusionString}' conclusion...`);
203
203
 
204
- this.conclusion.unifyStep(step, context, (stepUnifies) => {
204
+ return this.conclusion.unifyStep(step, context, (stepUnifies) => {
205
205
  let stepUnifiesWithConclusion = false;
206
206
 
207
207
  if (stepUnifies) {
@@ -217,7 +217,7 @@ export default define(class Rule extends Element {
217
217
  }
218
218
 
219
219
  unifyStepAndSubproofOrProofAssertions(step, subproofOrProofAssertions, context, continuation) {
220
- this.unifyStepWithConclusion(step, context, (statementUnifiesWithConclusion) => {
220
+ return this.unifyStepWithConclusion(step, context, (statementUnifiesWithConclusion) => {
221
221
  if (!statementUnifiesWithConclusion) {
222
222
  const stepAndSubproofOrProofAssertionsUnify = false;
223
223
 
@@ -242,12 +242,14 @@ export default define(class Rule extends Element {
242
242
 
243
243
  unifySubproofOrProofAssertionsWithPremise(subproofOrProofAssertions, premise, context, continuation) {
244
244
  return extract(subproofOrProofAssertions, (subproofOrProofAssertion, continuation) => {
245
- premise.unifySubproofOrProofAssertion(subproofOrProofAssertion, context, continuation);
245
+ return premise.unifySubproofOrProofAssertion(subproofOrProofAssertion, context, continuation);
246
246
  }, (subproofOrProofAssertion = null) => {
247
247
  if (subproofOrProofAssertion !== null) {
248
248
  const subproofOrProofAssertionsUnifiesWithPremise = true;
249
249
 
250
- return continuation(subproofOrProofAssertionsUnifiesWithPremise);
250
+ return context.resolveDerivedSubstitutions(() => {
251
+ return continuation(subproofOrProofAssertionsUnifiesWithPremise);
252
+ });
251
253
  }
252
254
 
253
255
  return premise.unifyIndependently(context, continuation);
@@ -9,29 +9,26 @@ import { unifyStatement } from "../process/unify";
9
9
  import { validateStatements } from "../process/validation";
10
10
  import { dischargeStatements } from "../process/discharge";
11
11
  import { instantiateStatement } from "../process/instantiate";
12
+ import { substitutionFromStatementNode } from "../utilities/element";
12
13
 
13
14
  const { breakPointFromJSON, breakPointToBreakPointJSON } = breakPointUtilities;
14
15
 
15
16
  export default define(class Statement extends Element {
16
- getStatementNode() {
17
- const node = this.getNode(),
18
- statementNode = node; ///
17
+ constructor(context, string, node, breakPoint, substitution) {
18
+ super(context, string, node, breakPoint);
19
19
 
20
- return statementNode;
20
+ this.substitution = substitution;
21
21
  }
22
22
 
23
- getTermSubstitutionNode() {
24
- const statementNode = this.getNode(),
25
- termSubstitutionNode = statementNode.getTermSubstitutionNode();
26
-
27
- return termSubstitutionNode;
23
+ getSubstitution() {
24
+ return this.substitution;
28
25
  }
29
26
 
30
- getFrameSubstitutionNode() {
31
- const statementNode = this.getNode(),
32
- frameSubstitutionNode = statementNode.getFrameSubstitutionNode();
27
+ getStatementNode() {
28
+ const node = this.getNode(),
29
+ statementNode = node; ///
33
30
 
34
- return frameSubstitutionNode;
31
+ return statementNode;
35
32
  }
36
33
 
37
34
  getMetavariableNode() {
@@ -71,6 +68,19 @@ export default define(class Statement extends Element {
71
68
  return equalTo;
72
69
  }
73
70
 
71
+ isSimple() {
72
+ const simple = (this.substitution === null);
73
+
74
+ return simple;
75
+ }
76
+
77
+ isComplex() {
78
+ const simple = this.isSimple(),
79
+ complex = !simple;
80
+
81
+ return complex;
82
+ }
83
+
74
84
  isSingular() {
75
85
  const statementNode = this.getStatementNode(),
76
86
  singular = statementNode.isSingular();
@@ -207,7 +217,7 @@ export default define(class Statement extends Element {
207
217
 
208
218
  const statement = this;
209
219
 
210
- exists(validateStatements, statement, context, (statementValidates) => {
220
+ return exists(validateStatements, statement, context, (statementValidates) => {
211
221
  let statement = null;
212
222
 
213
223
  if (statementValidates) {
@@ -218,7 +228,7 @@ export default define(class Statement extends Element {
218
228
  context.debug(`...validated the '${statementString}' statement.`);
219
229
  }
220
230
 
221
- continuation(statement);
231
+ return continuation(statement);
222
232
  });
223
233
  }
224
234
 
@@ -254,7 +264,7 @@ export default define(class Statement extends Element {
254
264
 
255
265
  context.trace(`Unifying the '${specificStatementString}' statement with the '${generalStatementString}' statement...`);
256
266
 
257
- unifyStatement(generalStatement, specificStatement, generalContext, specificContext, (statementUnifies) => {
267
+ return unifyStatement(generalStatement, specificStatement, generalContext, specificContext, (statementUnifies) => {
258
268
  if (statementUnifies) {
259
269
  context.debug(`...unified the '${specificStatementString}' statement with the '${generalStatementString}' statement.`);
260
270
  }
@@ -263,9 +273,7 @@ export default define(class Statement extends Element {
263
273
  });
264
274
  }
265
275
 
266
- unifyIndependently(generalContext, specificContext) {
267
- let unifiesIndependently = false;
268
-
276
+ unifyIndependently(generalContext, specificContext, continuation) {
269
277
  const context = specificContext, ///
270
278
  statementString = this.getString(); ///
271
279
 
@@ -278,39 +286,60 @@ export default define(class Statement extends Element {
278
286
 
279
287
  if (typeAssertionNode !== null) {
280
288
  const context = generalContext, ///
281
- typeAssertion = context.findAssertionByAssertionNode(typeAssertionNode),
282
- typeAssertionUnifiesIndependently = typeAssertion.unifyIndependently(generalContext, specificContext);
289
+ typeAssertion = context.findAssertionByAssertionNode(typeAssertionNode);
283
290
 
284
- if (typeAssertionUnifiesIndependently) {
285
- unifiesIndependently = true;
286
- }
291
+ typeAssertion.unifyIndependently(generalContext, specificContext, (typeAssertionUnifiesIndependently) => {
292
+ let unifiesIndependently = false;
293
+
294
+ if (typeAssertionUnifiesIndependently) {
295
+ unifiesIndependently = true;
296
+ }
297
+
298
+ if (unifiesIndependently) {
299
+ context.debug(`...unified the '${statementString}' statement independently.`);
300
+ }
301
+
302
+ return continuation(unifiesIndependently);
303
+ });
287
304
  }
288
305
 
289
306
  if (definedAssertionNode !== null) {
290
307
  const context = generalContext, ///
291
- definedAssertion = context.findAssertionByAssertionNode(definedAssertionNode),
292
- definedAssertionUnifiesIndependently = definedAssertion.unifyIndependently(generalContext, specificContext);
308
+ definedAssertion = context.findAssertionByAssertionNode(definedAssertionNode);
293
309
 
294
- if (definedAssertionUnifiesIndependently) {
295
- unifiesIndependently = true;
296
- }
310
+ definedAssertion.unifyIndependently(generalContext, specificContext, (definedAssertionUnifiesIndependently) => {
311
+ let unifiesIndependently = false;
312
+
313
+ if (definedAssertionUnifiesIndependently) {
314
+ unifiesIndependently = true;
315
+ }
316
+
317
+ if (unifiesIndependently) {
318
+ context.debug(`...unified the '${statementString}' statement independently.`);
319
+ }
320
+
321
+ return continuation(unifiesIndependently);
322
+ });
297
323
  }
298
324
 
299
325
  if (containedAssertionNode !== null) {
300
326
  const context = generalContext, ///
301
- containedAssertion = context.findAssertionByAssertionNode(containedAssertionNode),
302
- containedAssertionUnifiesIndependently = containedAssertion.unifyIndependently(generalContext, specificContext);
327
+ containedAssertion = context.findAssertionByAssertionNode(containedAssertionNode);
303
328
 
304
- if (containedAssertionUnifiesIndependently) {
305
- unifiesIndependently = true;
306
- }
307
- }
329
+ containedAssertion.unifyIndependently(generalContext, specificContext, (containedAssertionUnifiesIndependently) => {
330
+ let unifiesIndependently = false;
308
331
 
309
- if (unifiesIndependently) {
310
- context.debug(`...unified the '${statementString}' statement independently.`);
311
- }
332
+ if (containedAssertionUnifiesIndependently) {
333
+ unifiesIndependently = true;
334
+ }
335
+
336
+ if (unifiesIndependently) {
337
+ context.debug(`...unified the '${statementString}' statement independently.`);
338
+ }
312
339
 
313
- return unifiesIndependently;
340
+ return continuation(unifiesIndependently);
341
+ });
342
+ }
314
343
  }
315
344
 
316
345
  static name = "Statement";
@@ -339,11 +368,12 @@ export default define(class Statement extends Element {
339
368
  const { string } = json,
340
369
  statementNode = instantiateStatement(string, context),
341
370
  node = statementNode, ///
342
- breakPoint = breakPointFromJSON(json);
371
+ breakPoint = breakPointFromJSON(json),
372
+ substitution = substitutionFromStatementNode(statementNode, context);
343
373
 
344
374
  context = null;
345
375
 
346
- const statement = new Statement(context, string, node, breakPoint);
376
+ const statement = new Statement(context, string, node, breakPoint, substitution);
347
377
 
348
378
  return statement;
349
379
  }, context);
@@ -9,7 +9,7 @@ import { define } from "../../elements";
9
9
  import { instantiateFrameSubstitution } from "../../process/instantiate";
10
10
  import { frameSubstitutionFromFrameSubstitutionNode } from "../../utilities/element";
11
11
  import { frameSubstitutionStringFromFrameAndMetavariable } from "../../utilities/string";
12
- import { elide, ablates, manifest, attempts, reconcile, instantiate, unserialises } from "../../utilities/context";
12
+ import { elide, ablate, ablates, descend, manifest, attempts, reconcile, instantiate, unserialises } from "../../utilities/context";
13
13
 
14
14
  const { breakPointFromJSON } = breakPointUtilities;
15
15
 
@@ -70,7 +70,7 @@ export default define(class FrameSubstitution extends Substitution {
70
70
 
71
71
  compareFrame(frame, context) {
72
72
  const frameEqualToReplacementFrame = this.replacementFrame.isEqualTo(frame),
73
- comparedToFrame = frameEqualToReplacementFrame; ///
73
+ comparedToFrame = frameEqualToReplacementFrame; ///
74
74
 
75
75
  return comparedToFrame;
76
76
  }
@@ -87,9 +87,7 @@ export default define(class FrameSubstitution extends Substitution {
87
87
 
88
88
  context.debug(`...the '${frameSubstitutionString}' frame substitution is already valid.`);
89
89
 
90
- continuatino(frameSubstitution);
91
-
92
- return;
90
+ return continuatino(frameSubstitution);
93
91
  }
94
92
 
95
93
  const generalContext = this.getGeneralContext(),
@@ -99,7 +97,7 @@ export default define(class FrameSubstitution extends Substitution {
99
97
  const validateTargetFrame = this.validateTargetFrame.bind(this),
100
98
  validateReplacementFrame = this.validateReplacementFrame.bind(this);
101
99
 
102
- all([
100
+ return all([
103
101
  validateTargetFrame,
104
102
  validateReplacementFrame
105
103
  ], generalContext, specificContext, (validates) => {
@@ -121,7 +119,7 @@ export default define(class FrameSubstitution extends Substitution {
121
119
  context.debug(`...validated the '${frameSubstitutionString}' frame substitution.`);
122
120
  }
123
121
 
124
- continuatino(frameSubstitution);
122
+ return continuatino(frameSubstitution);
125
123
  });
126
124
  }, generalContext, specificContext);
127
125
  }
@@ -140,28 +138,24 @@ export default define(class FrameSubstitution extends Substitution {
140
138
 
141
139
  context.debug(`The '${targetFrameString}' target frame is not singular.`);
142
140
 
143
- continuatino(targetFrameValidates);
144
-
145
- return;
141
+ return continuatino(targetFrameValidates);
146
142
  }
147
143
 
148
- manifest((context) => {
149
- elide((context) => {
150
- this.targetFrame.validate(context, (targetFrame) => {
151
- let targetFrameValidates = false;
144
+ elide((context) => {
145
+ return this.targetFrame.validate(context, (targetFrame) => {
146
+ let targetFrameValidates = false;
152
147
 
153
- if (targetFrame !== null) {
154
- targetFrameValidates = true;
155
- }
148
+ if (targetFrame !== null) {
149
+ targetFrameValidates = true;
150
+ }
156
151
 
157
- if (targetFrameValidates) {
158
- context.debug(`...validated the '${frameSubstitutionString}' frame substitution's target frame...`);
159
- }
152
+ if (targetFrameValidates) {
153
+ context.debug(`...validated the '${frameSubstitutionString}' frame substitution's target frame...`);
154
+ }
160
155
 
161
- continuatino(targetFrameValidates);
162
- });
163
- }, context);
164
- }, specificContext, context);
156
+ return continuatino(targetFrameValidates);
157
+ });
158
+ }, context);
165
159
  }
166
160
 
167
161
  validateReplacementFrame(generalContext, specificContext, continuatino) {
@@ -171,7 +165,7 @@ export default define(class FrameSubstitution extends Substitution {
171
165
  context.trace(`Validating the '${frameSubstitutionString}' frame substitution's replacement frame...`);
172
166
 
173
167
  elide((context) => {
174
- this.replacementFrame.validate(context, (replacementFrame) => {
168
+ return this.replacementFrame.validate(context, (replacementFrame) => {
175
169
  let replacementFrameValidates = false;
176
170
 
177
171
  if (replacementFrame !== null) {
@@ -182,14 +176,12 @@ export default define(class FrameSubstitution extends Substitution {
182
176
  context.debug(`...validated the '${frameSubstitutionString}' frame substitution's replacement frame.`);
183
177
  }
184
178
 
185
- continuatino(replacementFrameValidates);
179
+ return continuatino(replacementFrameValidates);
186
180
  });
187
181
  }, context);
188
182
  }
189
183
 
190
- unifySubstitution(substitution, context) {
191
- let substitutionUnifies = false;
192
-
184
+ unifySubstitution(substitution, context, continuation) {
193
185
  const generalSubstitution = this, ///
194
186
  specificSubstitution = substitution,
195
187
  generalSubstitutionString = generalSubstitution.getString(),
@@ -198,29 +190,27 @@ export default define(class FrameSubstitution extends Substitution {
198
190
  context.trace(`Unifying the '${specificSubstitutionString}' substitution with the '${generalSubstitutionString}' substitution...`);
199
191
 
200
192
  reconcile((context) => {
201
- const replacementFrameUnifies = this.unifyReplacementFrame(substitution, context);
202
-
203
- if (replacementFrameUnifies) {
204
- const targetFrameUnifies = this.unifyTargetFrame(substitution, context);
205
-
206
- if (targetFrameUnifies) {
193
+ const unifyTargetFrame = this.unifyTargetFrame.bind(this),
194
+ unifyReplacementFrame = this.unifyReplacementFrame.bind(this);
195
+
196
+ return all([
197
+ unifyReplacementFrame,
198
+ unifyTargetFrame
199
+ ], substitution, context, (substitutionUnifies) => {
200
+ if (substitutionUnifies) {
207
201
  context.commit();
208
-
209
- substitutionUnifies = true;
210
202
  }
211
- }
212
- }, context);
213
203
 
214
- if (substitutionUnifies) {
215
- context.debug(`...unified the '${specificSubstitutionString}' substitution with the '${generalSubstitutionString}' substitution.`);
216
- }
204
+ if (substitutionUnifies) {
205
+ context.debug(`...unified the '${specificSubstitutionString}' substitution with the '${generalSubstitutionString}' substitution.`);
206
+ }
217
207
 
218
- return substitutionUnifies;
208
+ return continuation(substitutionUnifies);
209
+ });
210
+ }, context);
219
211
  }
220
212
 
221
- unifyTargetFrame(substitution, context) {
222
- let targetFrameUnifies = false;
223
-
213
+ unifyTargetFrame(substitution, context, continuation) {
224
214
  const generalSubstitution = this, ///
225
215
  specificSubstitution = substitution,
226
216
  generalSubstitutionString = generalSubstitution.getString(),
@@ -241,28 +231,33 @@ export default define(class FrameSubstitution extends Substitution {
241
231
  const frameNode = generalFrame.getFrameNode(),
242
232
  metavariable = metavariableFromFrameNode(frameNode, generalContext);
243
233
 
244
- if (metavariable !== null) {
245
- const frame = specificFrame, ///
246
- frameUnifies = metavariable.unifyFrame(frame, generalContext, specificContext);
234
+ if (metavariable === null) {
235
+ const targetFrameUnifies = false;
236
+
237
+ return continuation(targetFrameUnifies);
238
+ }
239
+
240
+ const frame = specificFrame; ///
241
+
242
+ return metavariable.unifyFrame(frame, generalContext, specificContext, (frameUnifies) => {
243
+ let targetFrameUnifies = false;
247
244
 
248
245
  if (frameUnifies) {
249
246
  specificContext.commit(context);
250
247
 
251
248
  targetFrameUnifies = true;
252
249
  }
253
- }
254
- }, specificContext);
255
250
 
256
- if (targetFrameUnifies) {
257
- context.trace(`...unified the '${specificSubstitutionString}' substitution's target frame with the '${generalSubstitutionString}' substitution's target frame.`);
258
- }
251
+ if (targetFrameUnifies) {
252
+ context.trace(`...unified the '${specificSubstitutionString}' substitution's target frame with the '${generalSubstitutionString}' substitution's target frame.`);
253
+ }
259
254
 
260
- return targetFrameUnifies;
255
+ return continuation(targetFrameUnifies);
256
+ });
257
+ }, specificContext);
261
258
  }
262
259
 
263
- unifyReplacementFrame(substitution, context) {
264
- let replacementFrameUnifies = false;
265
-
260
+ unifyReplacementFrame(substitution, context, continuation) {
266
261
  const generalSubstitution = this, ///
267
262
  specificSubstitution = substitution,
268
263
  generalSubstitutionString = generalSubstitution.getString(),
@@ -283,23 +278,30 @@ export default define(class FrameSubstitution extends Substitution {
283
278
  const frameNode = generalFrame.getNode(),
284
279
  metavariable = metavariableFromFrameNode(frameNode, generalContext);
285
280
 
286
- if (metavariable !== null) {
287
- const frame = specificFrame, ///
288
- frameUnifies = metavariable.unifyFrame(frame, generalContext, specificContext);
281
+ if (metavariable === null) {
282
+ const replacementFrameUnifies = false;
283
+
284
+ return continuation(replacementFrameUnifies);
285
+ }
286
+
287
+ const frame = specificFrame; ///
288
+
289
+ return metavariable.unifyFrame(frame, generalContext, specificContext, (frameUnifies) => {
290
+ let replacementFrameUnifies = false;
289
291
 
290
292
  if (frameUnifies) {
291
293
  specificContext.commit(context);
292
294
 
293
295
  replacementFrameUnifies = true;
294
296
  }
295
- }
296
- }, specificContext);
297
297
 
298
- if (replacementFrameUnifies) {
299
- context.trace(`...unified the '${specificSubstitutionString}' substitution's replacement frame with the '${generalSubstitutionString}' substitution's replacement frame.`);
300
- }
298
+ if (replacementFrameUnifies) {
299
+ context.trace(`...unified the '${specificSubstitutionString}' substitution's replacement frame with the '${generalSubstitutionString}' substitution's replacement frame.`);
300
+ }
301
301
 
302
- return replacementFrameUnifies;
302
+ return continuation(replacementFrameUnifies);
303
+ });
304
+ }, specificContext);
303
305
  }
304
306
 
305
307
  static name = "FrameSubstitution";
@@ -331,16 +333,20 @@ export default define(class FrameSubstitution extends Substitution {
331
333
  return frameSubstitutionn;
332
334
  }
333
335
 
334
- static fromStatement(statement, context) {
336
+ static fromStatementNode(statementNode, context) {
335
337
  let frameSubstitution = null;
336
338
 
337
- const frameSubstitutionNode = statement.getFrameSubstitutionNode();
339
+ const frameSubstitutionNode = statementNode.getFrameSubstitutionNode();
338
340
 
339
341
  if (frameSubstitutionNode !== null) {
340
- const generalContext = context, ///
341
- specificContext = context; ///
342
+ ablate((context) => {
343
+ descend((context) => {
344
+ const generalContext = context, ///
345
+ specificContext = context; ///
342
346
 
343
- frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, generalContext, specificContext);
347
+ frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, generalContext, specificContext);
348
+ }, context);
349
+ }, context);
344
350
  }
345
351
 
346
352
  return frameSubstitution;
@@ -350,16 +356,16 @@ export default define(class FrameSubstitution extends Substitution {
350
356
  let frameSubstitution
351
357
 
352
358
  ablates((generalContext, specificContext) => {
353
- const context = specificContext; ///
354
-
355
- instantiate((context) => {
356
- const specificContext = context, ///
357
- frameSubstitutionString = frameSubstitutionStringFromFrameAndMetavariable(frame, metavariable),
358
- string = frameSubstitutionString, ///
359
- frameSubstitutionNode = instantiateFrameSubstitution(string, context);
360
-
361
- frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, generalContext, specificContext);
362
- }, context);
359
+ instantiate((specificContext) => {
360
+ manifest((generalContext) => {
361
+ const frameSubstitutionString = frameSubstitutionStringFromFrameAndMetavariable(frame, metavariable),
362
+ string = frameSubstitutionString, ///
363
+ context = specificContext, ///
364
+ frameSubstitutionNode = instantiateFrameSubstitution(string, context);
365
+
366
+ frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, generalContext, specificContext);
367
+ }, generalContext, specificContext);
368
+ }, specificContext);
363
369
  }, generalContext, specificContext);
364
370
 
365
371
  return frameSubstitution;