occam-verify-cli 1.0.781 → 1.0.787

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 (59) hide show
  1. package/lib/context/branching.js +1 -1
  2. package/lib/context/ephemeral.js +22 -11
  3. package/lib/context/file/nominal.js +4 -4
  4. package/lib/context/proof.js +45 -40
  5. package/lib/context.js +16 -24
  6. package/lib/element/assumption.js +53 -17
  7. package/lib/element/frame.js +1 -39
  8. package/lib/element/judgement.js +33 -5
  9. package/lib/element/label.js +9 -1
  10. package/lib/element/metavariable.js +7 -7
  11. package/lib/element/proofAssertion/step.js +3 -3
  12. package/lib/element/reference.js +24 -22
  13. package/lib/element/substitution/frame.js +5 -7
  14. package/lib/element/substitution/reference.js +9 -9
  15. package/lib/element/substitution/statement.js +7 -11
  16. package/lib/element/substitution/term.js +4 -6
  17. package/lib/element/topLevelMetaAssertion.js +9 -9
  18. package/lib/nonTerminalNodeMap.js +1 -3
  19. package/lib/preamble.js +1 -2
  20. package/lib/process/instantiate.js +2 -8
  21. package/lib/process/unify.js +72 -5
  22. package/lib/ruleNames.js +1 -5
  23. package/lib/utilities/context.js +5 -22
  24. package/lib/utilities/element.js +25 -76
  25. package/lib/utilities/json.js +1 -23
  26. package/lib/utilities/string.js +8 -19
  27. package/lib/utilities/unification.js +8 -6
  28. package/package.json +4 -4
  29. package/src/context/branching.js +1 -1
  30. package/src/context/ephemeral.js +26 -10
  31. package/src/context/file/nominal.js +3 -3
  32. package/src/context/proof.js +52 -46
  33. package/src/context.js +21 -34
  34. package/src/element/assumption.js +82 -23
  35. package/src/element/frame.js +1 -61
  36. package/src/element/judgement.js +45 -5
  37. package/src/element/label.js +14 -0
  38. package/src/element/metavariable.js +6 -9
  39. package/src/element/proofAssertion/step.js +2 -2
  40. package/src/element/reference.js +32 -29
  41. package/src/element/substitution/frame.js +6 -8
  42. package/src/element/substitution/reference.js +13 -11
  43. package/src/element/substitution/statement.js +11 -15
  44. package/src/element/substitution/term.js +6 -8
  45. package/src/element/topLevelMetaAssertion.js +13 -13
  46. package/src/nonTerminalNodeMap.js +0 -3
  47. package/src/preamble.js +0 -1
  48. package/src/process/instantiate.js +2 -6
  49. package/src/process/unify.js +117 -7
  50. package/src/ruleNames.js +0 -1
  51. package/src/utilities/context.js +4 -33
  52. package/src/utilities/element.js +46 -101
  53. package/src/utilities/json.js +0 -26
  54. package/src/utilities/string.js +8 -22
  55. package/src/utilities/unification.js +8 -8
  56. package/lib/element/substitution/metaLevel.js +0 -148
  57. package/lib/node/substitution/metaLevel.js +0 -40
  58. package/src/element/substitution/metaLevel.js +0 -212
  59. package/src/node/substitution/metaLevel.js +0 -37
@@ -3,8 +3,11 @@
3
3
  import { Element } from "occam-languages";
4
4
 
5
5
  import { define } from "../elements";
6
- import { descend, instantiate } from "../utilities/context";
6
+ import { unifyAssumption } from "../process/unify";
7
7
  import { instantiateAssumption } from "../process/instantiate";
8
+ import { assumptionFromAssumptionNode } from "../utilities/element";
9
+ import { join, descend, reconcile, instantiate } from "../utilities/context";
10
+ import { assumptionStringFromStatementAndReference } from "../utilities/string";
8
11
 
9
12
  export default define(class Assumption extends Element {
10
13
  constructor(context, string, node, reference, statement) {
@@ -33,34 +36,31 @@ export default define(class Assumption extends Element {
33
36
 
34
37
  getTopLevelMetaAssertion() { return this.reference.getTopLevelMetaAssertion(); }
35
38
 
36
- matchAssumptionNode(assumptionNode) {
37
- const node = assumptionNode, ///
38
- nodeMatches = this.matchNode(node),
39
- assumptionNodeMatches = nodeMatches; ///
39
+ isEqualTo(assumption) {
40
+ const assumptionNode = assumption.getNode(),
41
+ assumptionNodeMatches = this.matchAssumptionNode(assumptionNode),
42
+ equalTo = assumptionNodeMatches; ///
40
43
 
41
- return assumptionNodeMatches;
44
+ return equalTo;
42
45
  }
43
46
 
44
- compareMetaLevelSubstitution(metaLevelSubstitution, context) {
45
- let comparesToMetaLevelSubstitution = false;
47
+ isMetaLevel() {
48
+ const metaLevel = (this.context !== null);
46
49
 
47
- const assumptionString = this.getString(), ///
48
- metaLevelSubstitutionString = metaLevelSubstitution.getString();
49
-
50
- context.trace(`Comparing the '${assumptionString}' assumption to the '${metaLevelSubstitutionString}' meta-level substitution...`);
51
-
52
- debugger
50
+ return metaLevel;
51
+ }
53
52
 
54
- if (comparesToMetaLevelSubstitution) {
55
- context.debug(`...compared the '${assumptionString}' assumption to the '${metaLevelSubstitutionString}' meta-level substitution.`);
56
- }
53
+ matchAssumptionNode(assumptionNode) {
54
+ const node = assumptionNode, ///
55
+ nodeMatches = this.matchNode(node),
56
+ assumptionNodeMatches = nodeMatches; ///
57
57
 
58
- return comparesToMetaLevelSubstitution;
58
+ return assumptionNodeMatches;
59
59
  }
60
60
 
61
- findValidAssumption(context) {
61
+ findValidAssumption(context, metaLevel = false) {
62
62
  const assumptionNode = this.getAssumptionNode(),
63
- assumption = context.findAssumptionByAssumptionNode(assumptionNode),
63
+ assumption = context.findAssumptionByAssumptionNode(assumptionNode, metaLevel),
64
64
  validAssumption = assumption; ///
65
65
 
66
66
  return validAssumption;
@@ -69,11 +69,17 @@ export default define(class Assumption extends Element {
69
69
  validate(context) {
70
70
  let assumption = null;
71
71
 
72
+ const metaLevel = this.isMetaLevel();
73
+
74
+ if (metaLevel) {
75
+ context = this.getContext();
76
+ }
77
+
72
78
  const assumptionString = this.getString(); ///
73
79
 
74
80
  context.trace(`Validating the '${assumptionString}' assumption...`);
75
81
 
76
- const validAssumption = this.findValidAssumption(context);
82
+ const validAssumption = this.findValidAssumption(context, metaLevel);
77
83
 
78
84
  if (validAssumption) {
79
85
  assumption = validAssumption; ///
@@ -108,7 +114,7 @@ export default define(class Assumption extends Element {
108
114
  if (validates) {
109
115
  assumption = this; ///
110
116
 
111
- context.addAssumption(assumption);
117
+ context.addAssumption(assumption, metaLevel);
112
118
 
113
119
  context.debug(`...validated the '${assumptionString}' assumption.`);
114
120
  }
@@ -125,7 +131,7 @@ export default define(class Assumption extends Element {
125
131
 
126
132
  context.trace(`Validating the '${assumptionString}' assumption's '${referenceString}' reference...`);
127
133
 
128
- const reference = this.reference.validate(context);
134
+ const reference = this.reference.validate();
129
135
 
130
136
  if (reference !== null) {
131
137
  const metavariable = this.reference.getMetavariable(),
@@ -147,6 +153,10 @@ export default define(class Assumption extends Element {
147
153
  referenceValidates = true;
148
154
  }
149
155
  }
156
+
157
+ if (referenceValidates) {
158
+ context.addReference(reference);
159
+ }
150
160
  }
151
161
 
152
162
  if (referenceValidates) {
@@ -216,6 +226,39 @@ export default define(class Assumption extends Element {
216
226
  return validatesWhenDerived;
217
227
  }
218
228
 
229
+ unifyAssumption(assumption, generalContext, specificContext) {
230
+ let assumptionUnifies;
231
+
232
+ const context = specificContext, ///
233
+ generalAssumption = this, ///
234
+ specificAssumption = assumption, ///
235
+ generalAssumptionString = generalAssumption.getString(),
236
+ specificAssumptionString = specificAssumption.getString();
237
+
238
+ context.trace(`Unifying the '${specificAssumptionString}' assumption with the '${generalAssumptionString}' assumption...`);
239
+
240
+ const assumptionContext = assumption.getContext();
241
+
242
+ specificContext = assumptionContext; ///
243
+
244
+ join((specificContext) => {
245
+ reconcile((specificContext) => {
246
+ assumptionUnifies = unifyAssumption(generalAssumption, specificAssumption, generalContext, specificContext);
247
+
248
+ if (assumptionUnifies) {
249
+ specificContext.commit(context);
250
+ }
251
+
252
+ }, specificContext);
253
+ }, specificContext, context);
254
+
255
+ if (assumptionUnifies) {
256
+ context.debug(`...unified the '${specificAssumptionString}' assumption with the '${generalAssumptionString}' assumption.`);
257
+ }
258
+
259
+ return assumptionUnifies;
260
+ }
261
+
219
262
  unifyTopLevelMetaAssertion(topLevelMetaAssertion, context) {
220
263
  let topLevelMetaAssertionUnifies;
221
264
 
@@ -265,6 +308,22 @@ export default define(class Assumption extends Element {
265
308
 
266
309
  return assumption;
267
310
  }
311
+
312
+ static fromStatementAndReference(statement, reference, context) {
313
+ let assumption;
314
+
315
+ instantiate((context) => {
316
+ const assumptionString = assumptionStringFromStatementAndReference(statement, reference),
317
+ string = assumptionString, ///
318
+ assumptionNode = instantiateAssumption(string, context);
319
+
320
+ assumption = assumptionFromAssumptionNode(assumptionNode, context);
321
+
322
+ assumption.setContext(context);
323
+ }, context);
324
+
325
+ return assumption;
326
+ }
268
327
  });
269
328
 
270
329
  function referenceFromAssumptionNode(assumptionNode, context) {
@@ -7,7 +7,7 @@ import { instantiateFrame } from "../process/instantiate";
7
7
  import { FRAME_META_TYPE_NAME } from "../metaTypeNames";
8
8
  import { metavariableFromFrameNode } from "../utilities/element";
9
9
  import { descend, reconcile, instantiate } from "../utilities/context";
10
- import { assumptionsStringFromAssumptions, metaLevelSubstitutionsStringFromMetaLevelSubstitutions } from "../utilities/string";
10
+ import { assumptionsStringFromAssumptions } from "../utilities/string";
11
11
 
12
12
  export default define(class Frame extends Element {
13
13
  constructor(context, string, node, assumptions, metavariable) {
@@ -119,56 +119,6 @@ export default define(class Frame extends Element {
119
119
  return comparesToMetavariableName;
120
120
  }
121
121
 
122
- compareMetaLevelSubstitution(metaLevelSubstitution, context) {
123
- let comparesToMetaLevelSubstitution;
124
-
125
- const frameString = this.getString(), ///
126
- metaLevelSubstitutionString = metaLevelSubstitution.getString();
127
-
128
- context.trace(`Comparing the '${frameString}' frame to the '${metaLevelSubstitutionString}' meta-level substitution...`);
129
-
130
- const metavariableNode = this.metavariable.getNode(),
131
- judgements = context.findJudgementsByMetavariableNode(metavariableNode),
132
- assumptions = assumptionsFromJudgements(judgements);
133
-
134
- comparesToMetaLevelSubstitution = assumptions.some((assumption) => {
135
- const assumptionComparesToSubstitution = assumption.compareMetaLevelSubstitution(metaLevelSubstitution, context);
136
-
137
- if (assumptionComparesToSubstitution) {
138
- return true;
139
- }
140
- });
141
-
142
- if (comparesToMetaLevelSubstitution) {
143
- context.debug(`...compared the '${frameString}' frame to the '${metaLevelSubstitutionString}' meta-level substitution.`);
144
- }
145
-
146
- return comparesToMetaLevelSubstitution;
147
- }
148
-
149
- compareMetaLevelSubstitutions(metaLevelSubstitutions, context) {
150
- let comparesToMetaLevelSubstitutions;
151
-
152
- const frameString = this.getString(), ///
153
- metaLevelSubstitutionsString = metaLevelSubstitutionsStringFromMetaLevelSubstitutions(metaLevelSubstitutions);
154
-
155
- context.trace(`Comparing the '${frameString}' frame to the '${metaLevelSubstitutionsString}' meta-level substitution...`);
156
-
157
- comparesToMetaLevelSubstitutions = metaLevelSubstitutions.every((metaLevelSubstitution) => {
158
- const compaaresToMetaLevelSubstitution = this.compareMetaLevelSubstitution(metaLevelSubstitution, context);
159
-
160
- if (compaaresToMetaLevelSubstitution) {
161
- return true;
162
- }
163
- });
164
-
165
- if (comparesToMetaLevelSubstitutions) {
166
- context.debug(`...compared the '${frameString}' frame to the '${metaLevelSubstitutionsString}' metaLevelSubstitutions.`);
167
- }
168
-
169
- return comparesToMetaLevelSubstitutions;
170
- }
171
-
172
122
  findValidFrame(context) {
173
123
  const frameNode = this.getFrameNode(),
174
124
  frame = context.findFrameByFrameNode(frameNode),
@@ -391,13 +341,3 @@ function assumptionsFromFrameNode(frameNode, context) {
391
341
 
392
342
  return assumptions;
393
343
  }
394
-
395
- function assumptionsFromJudgements(judgements) {
396
- const assumptions = judgements.map((judgement) => {
397
- const assumption = judgement.getAssumption();
398
-
399
- return assumption;
400
- });
401
-
402
- return assumptions;
403
- }
@@ -40,6 +40,8 @@ export default define(class Judgement extends Element {
40
40
 
41
41
  getMetavariable() { return this.frame.getMetavariable(); }
42
42
 
43
+ getMetavariableNode() { return this.frame.getMetavariableNode(); }
44
+
43
45
  matchJudgementNode(judgementNode) {
44
46
  const node = judgementNode, ///
45
47
  nodeMatches = this.matchNode(node),
@@ -185,12 +187,40 @@ export default define(class Judgement extends Element {
185
187
  context.trace(`Validating the '${judgementString}' derived judgement...`);
186
188
 
187
189
  const topLevelMetaAssertion = this.assumption.getTopLevelMetaAssertion(),
188
- metaLevelSubstitutions = topLevelMetaAssertion.getMetaLevelSubstitutions(),
189
- frameComparesToSubstitutions = this.frame.compareMetaLevelSubstitutions(metaLevelSubstitutions, context);
190
+ metavariableNode = this.getMetavariableNode(),
191
+ judgements = context.findJudgementsByMetavariableNode(metavariableNode);
190
192
 
191
- if (frameComparesToSubstitutions) {
192
- validatesWhenDerived = true;
193
- }
193
+ let assumptions;
194
+
195
+ assumptions = topLevelMetaAssertion.getAssumptions();
196
+
197
+ const specificAssumptions = assumptions; ///
198
+
199
+ assumptions = assumptionsFromJudgements(judgements);
200
+
201
+ const generalAssumptions = assumptions; ///
202
+
203
+ reconcile((context) => {
204
+ const specificAssumptionsUnify = specificAssumptions.every((specificAssumption) => {
205
+ const specificAssumptionUnifies = generalAssumptions.some((generalAssumption) => {
206
+ const generalContext = context, ///
207
+ specificContext = context, ///
208
+ specificAssumptionUnifies = generalAssumption.unifyAssumption(specificAssumption, generalContext, specificContext);
209
+
210
+ if (specificAssumptionUnifies) {
211
+ return true;
212
+ }
213
+ });
214
+
215
+ if (specificAssumptionUnifies) {
216
+ return true;
217
+ }
218
+ });
219
+
220
+ if (specificAssumptionsUnify) {
221
+ validatesWhenDerived = true;
222
+ }
223
+ }, context);
194
224
 
195
225
  if (validatesWhenDerived) {
196
226
  context.debug(`...validated the '${judgementString}' derived judgement.`);
@@ -254,6 +284,16 @@ function frameFromJudgementNode(judgementNode, context) {
254
284
  return frame;
255
285
  }
256
286
 
287
+ function assumptionsFromJudgements(judgements) {
288
+ const assumptions = judgements.map((judgement) => {
289
+ const assumption = judgement.getAssumption();
290
+
291
+ return assumption;
292
+ });
293
+
294
+ return assumptions;
295
+ }
296
+
257
297
  function assumptionFromJudgementNode(judgementNode, context) {
258
298
  const assumptionNode = judgementNode.getAssumptionNode(),
259
299
  assumption = context.findAssumptionByAssumptionNode(assumptionNode);
@@ -4,6 +4,7 @@ import { Element } from "occam-languages";
4
4
 
5
5
  import { define } from "../elements";
6
6
  import { instantiateLabel } from "../process/instantiate";
7
+ import { labelFromLabelNode } from "../utilities/element";
7
8
  import { metavariableFromLabelNode } from "../utilities/element";
8
9
  import { attempt, serialise, unserialise, instantiate } from "../utilities/context";
9
10
 
@@ -157,4 +158,17 @@ export default define(class Label extends Element {
157
158
 
158
159
  return label;
159
160
  }
161
+
162
+ static fromLabelString(labelString, context) {
163
+ let label;
164
+
165
+ instantiate((context) => {
166
+ const string = labelString, ///
167
+ labelNode = instantiateLabel(string, context);
168
+
169
+ label = labelFromLabelNode(labelNode, context);
170
+ }, context);
171
+
172
+ return label;
173
+ }
160
174
  });
@@ -290,11 +290,10 @@ export default define(class Metavariable extends Element {
290
290
  frameUnifies = true;
291
291
  } else {
292
292
  const metavariableName = this.getMetavariableName(),
293
- simpleSubstitution = context.findSimpleSubstitutionByMetavariableName(metavariableName);
293
+ substitution = context.findSimpleSubstitutionByMetavariableName(metavariableName);
294
294
 
295
- if (simpleSubstitution !== null) {
296
- const substitution = simpleSubstitution, ///
297
- substitutionFrameComparesToFrame = substitution.compareFrame(frame, context);
295
+ if (substitution !== null) {
296
+ const substitutionFrameComparesToFrame = substitution.compareFrame(frame, context);
298
297
 
299
298
  if (substitutionFrameComparesToFrame) {
300
299
  const frameSubstitution = substitution, ///
@@ -402,12 +401,10 @@ export default define(class Metavariable extends Element {
402
401
  referenceUnifies = true;
403
402
  } else {
404
403
  const metavariableName = this.getMetavariableName(),
405
- simpleSubstitutionPresent = context.isSimpleSubstitutionPresentByMetavariableName(metavariableName);
404
+ substitution = context.findSubstitutionByMetavariableName(metavariableName);
406
405
 
407
- if (simpleSubstitutionPresent) {
408
- const simpleSubstitution = context.findSimpleSubstitutionByMetavariableName(metavariableName),
409
- substitution = simpleSubstitution, ///
410
- substitutionReferenceComparesToReference = substitution.compareReference(reference, context);
406
+ if (substitution !== null) {
407
+ const substitutionReferenceComparesToReference = substitution.compareReference(reference, context);
411
408
 
412
409
  if (substitutionReferenceComparesToReference) {
413
410
  const referenceSubstitution = substitution, ///
@@ -137,7 +137,7 @@ export default define(class Step extends ProofAssertion {
137
137
 
138
138
  context.trace(`Validating the '${stepString}' step's '${referenceString}' reference... `);
139
139
 
140
- const reference = this.reference.validate(context);
140
+ const reference = this.reference.validate();
141
141
 
142
142
  if (reference === null) {
143
143
  referenceValidates = false;
@@ -169,7 +169,7 @@ export default define(class Step extends ProofAssertion {
169
169
  }
170
170
 
171
171
  if (statementValidates) {
172
- context.debug(`...validated the '${stepString}' step statement. `);
172
+ context.debug(`...validated the '${stepString}' step's statement. `);
173
173
  }
174
174
 
175
175
  return statementValidates;
@@ -5,7 +5,8 @@ import { Element } from "occam-languages";
5
5
  import { define } from "../elements";
6
6
  import { instantiateReference } from "../process/instantiate";
7
7
  import { REFERENCE_META_TYPE_NAME } from "../metaTypeNames";
8
- import { serialise, reconcile, unserialise, instantiate } from "../utilities/context";
8
+ import { referenceFromReferenceNode } from "../utilities/element";
9
+ import { attempt, serialise, reconcile, unserialise, instantiate } from "../utilities/context";
9
10
  import { metavariableFromReferenceNode, topLevelMetaAssertionFromReferenceNode } from "../utilities/element";
10
11
 
11
12
  export default define(class Reference extends Element {
@@ -122,30 +123,17 @@ export default define(class Reference extends Element {
122
123
  return topLevelMetaAssertionCompares;
123
124
  }
124
125
 
125
- findValidRefernece(context) {
126
- const metavariableNode = this.getMetavariableNode(),
127
- reference = context.findReferenceByMetavariableNode(metavariableNode),
128
- validReference = reference; ///
126
+ validate() {
127
+ let referennce = null;
129
128
 
130
- return validReference;
131
- }
132
-
133
- validate(context) {
134
- let reference = null;
135
-
136
- const referenceString = this.getString(); ///
129
+ const context = this.getContext(),
130
+ referenceString = this.getString(); ///
137
131
 
138
132
  context.trace(`Validating the '${referenceString}' reference...`);
139
133
 
140
- const validReference = this.findValidRefernece(context);
141
-
142
- if (validReference !== null) {
143
- reference = validReference; ///
144
-
145
- context.debug(`...the '${referenceString}' reference is already valid.`);
146
- } else {
147
- let validates = false;
134
+ let validates;
148
135
 
136
+ attempt((context) => {
149
137
  const metavariableValidates = this.validateMetavariable(context);
150
138
 
151
139
  if (metavariableValidates) {
@@ -170,23 +158,25 @@ export default define(class Reference extends Element {
170
158
  } else {
171
159
  const metaTypeString = metaType.getString(),
172
160
  metavariableString = this.metavariable.getString(),
173
- reerenceMetaTypeString = referenceMetaType.getString();
161
+ referenceMetaTypeString = referenceMetaType.getString();
174
162
 
175
- context.debug(`The '${referenceString}' reference's '${metavariableString}' metavariable's '${metaTypeString}' meta-type should be the '${reerenceMetaTypeString}' meta-type.`);
163
+ context.debug(`The '${referenceString}' reference's '${metavariableString}' metavariable's '${metaTypeString}' meta-type should be the '${referenceMetaTypeString}' meta-type.`);
176
164
  }
177
165
  }
178
166
  }
179
167
 
180
168
  if (validates) {
181
- reference = this; ///
169
+ context.commit(this);
170
+ }
171
+ }, context);
182
172
 
183
- context.addReference(reference);
173
+ if (validates) {
174
+ referennce = this; ///
184
175
 
185
- context.debug(`...validated the '${referenceString}' reference.`);
186
- }
176
+ context.debug(`...validated the '${referenceString}' reference.`);
187
177
  }
188
178
 
189
- return reference;
179
+ return referennce;
190
180
  }
191
181
 
192
182
  validateMetavariable(context) {
@@ -195,8 +185,6 @@ export default define(class Reference extends Element {
195
185
  const referenceString = this.getString(), ///
196
186
  metavariableString = this.metavariable.getString();
197
187
 
198
- context = this.getContext();
199
-
200
188
  context.trace(`Validating the '${referenceString}' reference's '${metavariableString}' metavariable...'`);
201
189
 
202
190
  const metavariable = this.metavariable.validate(context);
@@ -336,4 +324,19 @@ export default define(class Reference extends Element {
336
324
 
337
325
  return reference;
338
326
  }
327
+
328
+ static fromReferenceString(referenceString, context) {
329
+ let reference;
330
+
331
+ instantiate((context) => {
332
+ const string = referenceString, ///
333
+ referenceNode = instantiateReference(string, context);
334
+
335
+ reference = referenceFromReferenceNode(referenceNode, context);
336
+ }, context);
337
+
338
+ return reference;
339
+ }
339
340
  });
341
+
342
+ let counter = 0;
@@ -3,8 +3,8 @@
3
3
  import Substitution from "../substitution";
4
4
 
5
5
  import { define } from "../../elements";
6
+ import { descend, instantiate } from "../../utilities/context";
6
7
  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
 
@@ -203,14 +203,12 @@ export default define(class FrameSubstitution extends Substitution {
203
203
  static fromFrameAndMetavariable(frame, metavariable, context) {
204
204
  let frameSubstitution
205
205
 
206
- simplify((context) => {
207
- instantiate((context) => {
208
- const frameSubstitutionString = frameSubstitutionStringFromFrameAndMetavariable(frame, metavariable),
209
- string = frameSubstitutionString, ///
210
- frameSubstitutionNode = instantiateFrameSubstitution(string, context);
206
+ instantiate((context) => {
207
+ const frameSubstitutionString = frameSubstitutionStringFromFrameAndMetavariable(frame, metavariable),
208
+ string = frameSubstitutionString, ///
209
+ frameSubstitutionNode = instantiateFrameSubstitution(string, context);
211
210
 
212
- frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context);
213
- }, context);
211
+ frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context);
214
212
  }, context);
215
213
 
216
214
  return frameSubstitution;
@@ -3,7 +3,7 @@
3
3
  import Substitution from "../substitution";
4
4
 
5
5
  import { define } from "../../elements";
6
- import { simplify, instantiate } from "../../utilities/context";
6
+ import { instantiate } from "../../utilities/context";
7
7
  import { instantiateReferenceSubstitution } from "../../process/instantiate";
8
8
  import { referenceSubstitutionFromReferenceSubstitutionNode } from "../../utilities/element";
9
9
  import { referenceSubstitutionStringFromReferenceAndMetavariable } from "../../utilities/string";
@@ -114,15 +114,17 @@ export default define(class ReferenceSubstitution extends Substitution {
114
114
  validateTargetReference(generalContext, specificContext) {
115
115
  let targetReferenceValidates = false;
116
116
 
117
- const context = generalContext, ///
117
+ const context = specificContext, ///
118
118
  targetReferenceString = this.targetReference.getString(),
119
119
  referenceSubstitutionString = this.getString(); ///
120
120
 
121
121
  context.trace(`Validating the '${referenceSubstitutionString}' reference substitution's '${targetReferenceString}' target reference...`);
122
122
 
123
- const targetReference = this.targetReference.validate(context);
123
+ const targetReference = this.targetReference.validate();
124
124
 
125
125
  if (targetReference !== null) {
126
+ context.addReference(targetReference);
127
+
126
128
  targetReferenceValidates = true;
127
129
  }
128
130
 
@@ -142,9 +144,11 @@ export default define(class ReferenceSubstitution extends Substitution {
142
144
 
143
145
  context.trace(`Validating the '${referenceSubstitutionString}' reference substitution's '${replacementReferenceString}' replacement reference...`);
144
146
 
145
- const replacementReference = this.replacementReference.validate(context);
147
+ const replacementReference = this.replacementReference.validate();
146
148
 
147
149
  if (replacementReference !== null) {
150
+ context.addReference(replacementReference);
151
+
148
152
  replacementReferenceValidates = true;
149
153
  }
150
154
 
@@ -182,14 +186,12 @@ export default define(class ReferenceSubstitution extends Substitution {
182
186
  static fromReferenceAndMetavariable(reference, metavariable, context) {
183
187
  let referenceSubstitution;
184
188
 
185
- simplify((context) => {
186
- instantiate((context) => {
187
- const referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
188
- string = referenceSubstitutionString, ///
189
- referenceSubstitutionNode = instantiateReferenceSubstitution(string, context);
189
+ instantiate((context) => {
190
+ const referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
191
+ string = referenceSubstitutionString, ///
192
+ referenceSubstitutionNode = instantiateReferenceSubstitution(string, context);
190
193
 
191
- referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
192
- }, context);
194
+ referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
193
195
  }, context);
194
196
 
195
197
  return referenceSubstitution;
@@ -6,7 +6,7 @@ import { define } from "../../elements";
6
6
  import { unifySubstitution } from "../../process/unify";
7
7
  import { stripBracketsFromStatement } from "../../utilities/brackets";
8
8
  import { instantiateStatementSubstitution } from "../../process/instantiate";
9
- import { join, simplify, descend, reconcile, instantiate } from "../../utilities/context";
9
+ import { join, descend, reconcile, instantiate } from "../../utilities/context";
10
10
  import { statementSubstitutionFromStatementSubstitutionNode } from "../../utilities/element";
11
11
  import { statementSubstitutionStringFromStatementAndMetavariable, statementSubstitutionStringFromStatementMetavariableAndSubstitution } from "../../utilities/string";
12
12
 
@@ -367,14 +367,12 @@ export default define(class StatementSubstitution extends Substitution {
367
367
 
368
368
  let statementSubstitution;
369
369
 
370
- simplify((context) => {
371
- instantiate((context) => {
372
- const statementSubstitutionString = statementSubstitutionStringFromStatementAndMetavariable(statement, metavariable, context),
373
- string = statementSubstitutionString, ///
374
- statementSubstitutionNode = instantiateStatementSubstitution(string, context);
370
+ instantiate((context) => {
371
+ const statementSubstitutionString = statementSubstitutionStringFromStatementAndMetavariable(statement, metavariable, context),
372
+ string = statementSubstitutionString, ///
373
+ statementSubstitutionNode = instantiateStatementSubstitution(string, context);
375
374
 
376
- statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
377
- }, context);
375
+ statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
378
376
  }, context);
379
377
 
380
378
  return statementSubstitution;
@@ -385,14 +383,12 @@ export default define(class StatementSubstitution extends Substitution {
385
383
 
386
384
  let statementSubstitution;
387
385
 
388
- simplify((context) => {
389
- instantiate((context) => {
390
- const statementSubstitutionString = statementSubstitutionStringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution),
391
- string = statementSubstitutionString, ///
392
- statementSubstitutionNode = instantiateStatementSubstitution(string, context);
386
+ instantiate((context) => {
387
+ const statementSubstitutionString = statementSubstitutionStringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution),
388
+ string = statementSubstitutionString, ///
389
+ statementSubstitutionNode = instantiateStatementSubstitution(string, context);
393
390
 
394
- statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
395
- }, context);
391
+ statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
396
392
  }, context);
397
393
 
398
394
  return statementSubstitution;