occam-verify-cli 1.0.587 → 1.0.603

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 (105) hide show
  1. package/lib/context/ephemeral.js +74 -2
  2. package/lib/context/file/nominal.js +11 -9
  3. package/lib/context/liminal.js +161 -24
  4. package/lib/context/literal.js +8 -2
  5. package/lib/context/scoped.js +4 -28
  6. package/lib/context/synthetic.js +146 -0
  7. package/lib/context.js +170 -1
  8. package/lib/element/assertion/contained.js +21 -15
  9. package/lib/element/assertion/defined.js +45 -65
  10. package/lib/element/assertion/property.js +25 -19
  11. package/lib/element/assertion/satisfies.js +14 -8
  12. package/lib/element/assertion/subproof.js +12 -6
  13. package/lib/element/assertion.js +47 -1
  14. package/lib/element/assumption.js +12 -12
  15. package/lib/element/conclusion.js +2 -2
  16. package/lib/element/deduction.js +2 -2
  17. package/lib/element/frame.js +61 -29
  18. package/lib/element/judgement.js +7 -1
  19. package/lib/element/label.js +8 -8
  20. package/lib/element/metavariable.js +71 -59
  21. package/lib/element/procedureCall.js +24 -8
  22. package/lib/element/proof.js +43 -35
  23. package/lib/element/proofAssertion/premise.js +122 -97
  24. package/lib/element/proofAssertion/step.js +161 -115
  25. package/lib/element/proofAssertion/supposition.js +157 -118
  26. package/lib/element/proofAssertion.js +3 -3
  27. package/lib/element/reference.js +40 -7
  28. package/lib/element/rule.js +227 -95
  29. package/lib/element/signature.js +2 -1
  30. package/lib/element/statement.js +67 -34
  31. package/lib/element/substitution/frame.js +36 -16
  32. package/lib/element/substitution/reference.js +36 -16
  33. package/lib/element/substitution/statement.js +94 -55
  34. package/lib/element/substitution/term.js +36 -16
  35. package/lib/element/substitution.js +54 -17
  36. package/lib/element/substitutions.js +4 -276
  37. package/lib/element/term.js +60 -31
  38. package/lib/element/topLevelAssertion/axiom.js +13 -4
  39. package/lib/element/topLevelAssertion/conjecture.js +7 -2
  40. package/lib/element/topLevelAssertion/theorem.js +7 -2
  41. package/lib/element/topLevelAssertion.js +201 -134
  42. package/lib/element/topLevelMetaAssertion.js +310 -51
  43. package/lib/element/variable.js +15 -6
  44. package/lib/node/substitution/statement.js +33 -1
  45. package/lib/process/unify.js +6 -6
  46. package/lib/utilities/context.js +10 -25
  47. package/lib/utilities/element.js +34 -9
  48. package/lib/utilities/statement.js +1 -8
  49. package/lib/utilities/string.js +12 -1
  50. package/lib/utilities/substitutions.js +42 -16
  51. package/lib/utilities/unification.js +3 -1
  52. package/lib/utilities/validation.js +2 -2
  53. package/package.json +4 -4
  54. package/src/context/ephemeral.js +73 -1
  55. package/src/context/file/nominal.js +14 -11
  56. package/src/context/liminal.js +180 -25
  57. package/src/context/literal.js +3 -1
  58. package/src/context/scoped.js +3 -35
  59. package/src/context/synthetic.js +49 -0
  60. package/src/context.js +163 -1
  61. package/src/element/assertion/contained.js +28 -20
  62. package/src/element/assertion/defined.js +62 -34
  63. package/src/element/assertion/property.js +27 -19
  64. package/src/element/assertion/satisfies.js +15 -7
  65. package/src/element/assertion/subproof.js +13 -5
  66. package/src/element/assertion.js +35 -0
  67. package/src/element/assumption.js +5 -5
  68. package/src/element/conclusion.js +2 -4
  69. package/src/element/deduction.js +2 -4
  70. package/src/element/frame.js +71 -39
  71. package/src/element/judgement.js +2 -0
  72. package/src/element/label.js +4 -4
  73. package/src/element/metavariable.js +94 -75
  74. package/src/element/procedureCall.js +6 -6
  75. package/src/element/proof.js +6 -6
  76. package/src/element/proofAssertion/premise.js +101 -69
  77. package/src/element/proofAssertion/step.js +78 -39
  78. package/src/element/proofAssertion/supposition.js +141 -115
  79. package/src/element/proofAssertion.js +3 -2
  80. package/src/element/reference.js +52 -10
  81. package/src/element/rule.js +138 -76
  82. package/src/element/signature.js +2 -0
  83. package/src/element/statement.js +76 -45
  84. package/src/element/substitution/frame.js +44 -15
  85. package/src/element/substitution/reference.js +44 -15
  86. package/src/element/substitution/statement.js +124 -72
  87. package/src/element/substitution/term.js +43 -15
  88. package/src/element/substitution.js +55 -18
  89. package/src/element/substitutions.js +1 -258
  90. package/src/element/term.js +65 -34
  91. package/src/element/topLevelAssertion/axiom.js +1 -1
  92. package/src/element/topLevelAssertion/conjecture.js +1 -1
  93. package/src/element/topLevelAssertion/theorem.js +1 -1
  94. package/src/element/topLevelAssertion.js +128 -48
  95. package/src/element/topLevelMetaAssertion.js +86 -32
  96. package/src/element/variable.js +15 -5
  97. package/src/node/substitution/statement.js +33 -0
  98. package/src/process/unify.js +6 -8
  99. package/src/utilities/context.js +9 -8
  100. package/src/utilities/element.js +37 -10
  101. package/src/utilities/statement.js +0 -7
  102. package/src/utilities/string.js +14 -0
  103. package/src/utilities/substitutions.js +59 -17
  104. package/src/utilities/unification.js +4 -0
  105. package/src/utilities/validation.js +3 -1
@@ -3,8 +3,10 @@
3
3
  import { arrayUtilities } from "necessary";
4
4
  import { Element, asynchronousUtilities } from "occam-languages";
5
5
 
6
- import { scope } from "../utilities/context";
6
+ import assignAssignments from "../process/assign";
7
+
7
8
  import { define } from "../elements";
9
+ import { asyncScope } from "../utilities/context";
8
10
  import { labelsFromJSON,
9
11
  premisesFromJSON,
10
12
  conclusionFromJSON,
@@ -13,7 +15,7 @@ import { labelsFromJSON,
13
15
  conclusionToConclusionJSON } from "../utilities/json";
14
16
 
15
17
  const { reverse, extract } = arrayUtilities,
16
- { asyncBackwardsEvery } = asynchronousUtilities;
18
+ { asyncForwardsEvery, asyncBackwardsEvery } = asynchronousUtilities;
17
19
 
18
20
  export default define(class Rule extends Element {
19
21
  constructor(context, string, node, proof, labels, premises, conclusion) {
@@ -54,7 +56,14 @@ export default define(class Rule extends Element {
54
56
  }
55
57
 
56
58
  verifyLabels() {
57
- const labelsVerify = this.labels.every((label) => {
59
+ let labelsVerify;
60
+
61
+ const context = this.getContext(),
62
+ ruleString = this.getString(); ///
63
+
64
+ context.trace(`Verifying the '${ruleString}' rule's labels...`);
65
+
66
+ labelsVerify = this.labels.every((label) => {
58
67
  const nameOnly = true,
59
68
  labelVerifies = label.verify(nameOnly);
60
69
 
@@ -63,67 +72,144 @@ export default define(class Rule extends Element {
63
72
  }
64
73
  });
65
74
 
75
+ if (labelsVerify) {
76
+ context.trace(`...verified the '${ruleString}' rule's labels.`);
77
+ }
78
+
66
79
  return labelsVerify;
67
80
  }
68
81
 
69
- verifyPremises(context) {
70
- const premisesVerify = this.premises.every((premise) => {
71
- const premiseVerifies = this.verifyPremise(premise, context);
82
+ unifyStatementWithConclusion(statement, context) {
83
+ let statementUnifiesWithConclusion = false;
72
84
 
73
- if (premiseVerifies) {
74
- return true;
75
- }
76
- });
85
+ const ruleString = this.getString(),
86
+ statementString = statement.getString(),
87
+ conclusionString = this.conclusion.getString();
77
88
 
78
- return premisesVerify;
79
- }
89
+ context.trace(`Unifying the '${statementString}' statement with the '${ruleString}' rule's '${conclusionString}' conclusion...`);
80
90
 
81
- verifyPremise(premise, context) {
82
- const premiseVerifies = premise.verify(context);
91
+ const statementUnifies = this.conclusion.unifyStatement(statement, context);
92
+
93
+ if (statementUnifies) {
94
+ statementUnifiesWithConclusion = true;
95
+ }
96
+
97
+ if (statementUnifiesWithConclusion) {
98
+ context.debug(`...unified the '${statementString}' statement with the '${ruleString}' rule's '${conclusionString}' conclusion.`);
99
+ }
83
100
 
84
- return premiseVerifies;
101
+ return statementUnifiesWithConclusion;
85
102
  }
86
103
 
87
- verifyConclusion(context) {
88
- const conclusionVerifies = this.conclusion.verify(context);
104
+ async verify() {
105
+ let verifies = false;
89
106
 
90
- return conclusionVerifies;
107
+ const context = this.getContext();
108
+
109
+ await this.break(context);
110
+
111
+ const ruleString = this.getString(); ///
112
+
113
+ context.trace(`Verifying the '${ruleString}' rule...`);
114
+
115
+ await asyncScope(async (context) => {
116
+ const labelsVerify = this.verifyLabels();
117
+
118
+ if (labelsVerify) {
119
+ const premisesVerify = await this.verifyPremises(context);
120
+
121
+ if (premisesVerify) {
122
+ const conclusionVerifies = await this.verifyConclusion(context);
123
+
124
+ if (conclusionVerifies) {
125
+ const proofVerifies = await this.verifyProof(context);
126
+
127
+ if (proofVerifies) {
128
+ const rule = this; ///
129
+
130
+ context.addRule(rule);
131
+
132
+ verifies = true;
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }, context);
138
+
139
+ if (verifies) {
140
+ context.debug(`...verified the '${ruleString}' rule.`);
141
+ }
142
+
143
+ return verifies;
91
144
  }
92
145
 
93
- verifyProof(context) {
146
+ async verifyProof(context) {
94
147
  let proofVerifies;
95
148
 
96
149
  if (this.proof === null) {
97
150
  proofVerifies = true;
98
151
  } else {
99
- const substitutions = [];
152
+ const ruleString = this.getString(); ///
100
153
 
101
- proofVerifies = this.proof.verify(substitutions, this.conclusion, context);
154
+ context.trace(`Verifying the '${ruleString}' rule's proof...`);
155
+
156
+ const statement = this.conclusion.getStatement();
157
+
158
+ proofVerifies = this.proof.verify(statement, context);
159
+
160
+ if (proofVerifies) {
161
+ context.debug(`...verified the '${ruleString}' rule's proof.`);
162
+ }
102
163
  }
103
164
 
104
165
  return proofVerifies;
105
166
  }
106
167
 
107
- unifyStatementWithConclusion(statement, context) {
108
- let statementUnifiesWithConclusion = false;
168
+ async verifyPremises(context) {
169
+ let premisesVerify;
109
170
 
110
- const ruleString = this.getString(),
111
- statementString = statement.getString(),
112
- conclusionString = this.conclusion.getString();
171
+ const ruleString = this.getString(); ///
113
172
 
114
- context.trace(`Unifying the '${statementString}' statement with the '${ruleString}' rule's '${conclusionString}' conclusion...`);
173
+ context.trace(`Verifying the '${ruleString}' rule's premises...`);
115
174
 
116
- const statementUnifies = this.conclusion.unifyStatement(statement, context);
175
+ premisesVerify = await asyncForwardsEvery(this.premises, async (premise) => {
176
+ const assignments = [],
177
+ premiseVerifies = await premise.verify(assignments, context)
117
178
 
118
- if (statementUnifies) {
119
- statementUnifiesWithConclusion = true;
179
+ if (premiseVerifies) {
180
+ const assignmentsAssigned = assignAssignments(assignments, context);
181
+
182
+ if (assignmentsAssigned) {
183
+ const subproofOrProofAssertion = premise; ////
184
+
185
+ context.addSubproofOrProofAssertion(subproofOrProofAssertion);
186
+
187
+ return true;
188
+ }
189
+ }
190
+ });
191
+
192
+ if (premisesVerify) {
193
+ context.debug(`...verified the '${ruleString}' rule's premises.`);
120
194
  }
121
195
 
122
- if (statementUnifiesWithConclusion) {
123
- context.debug(`...unified the '${statementString}' statement with the '${ruleString}' rule's '${conclusionString}' conclusion.`);
196
+ return premisesVerify;
197
+ }
198
+
199
+ async verifyConclusion(context) {
200
+ let conclusionVerifies;
201
+
202
+ const ruleString = this.getString(); ///
203
+
204
+ context.trace(`Verifying the '${ruleString}' rule's conclusion...`);
205
+
206
+ conclusionVerifies = await this.conclusion.verify(context);
207
+
208
+ if (conclusionVerifies) {
209
+ context.debug(`...verified the '${ruleString}' rule's conclusion.`);
124
210
  }
125
211
 
126
- return statementUnifiesWithConclusion;
212
+ return conclusionVerifies;
127
213
  }
128
214
 
129
215
  async unifyStatementAndSubproofOrProofAssertions(statement, subproofOrProofAssertions, context) {
@@ -135,7 +221,15 @@ export default define(class Rule extends Element {
135
221
  const subproofOrProofAssertionsUnifiesWithPremises = await this.unifySubproofOrProofAssertionsWithPremises(subproofOrProofAssertions, context);
136
222
 
137
223
  if (subproofOrProofAssertionsUnifiesWithPremises) {
138
- const substitutionsResolved = context.areSubstitutionsResolved();
224
+ const specificContext = context; ///
225
+
226
+ context = this.getContext();
227
+
228
+ const generalContext = context; ///
229
+
230
+ context = specificContext; ///
231
+
232
+ const substitutionsResolved = context.areSubstitutionsResolved(generalContext, specificContext);
139
233
 
140
234
  if (substitutionsResolved) {
141
235
  statementAndSubproofOrProofAssertionsUnify = true;
@@ -170,6 +264,16 @@ export default define(class Rule extends Element {
170
264
  const subproofOrProofAssertionUnifies = premise.unifySubproofOrProofAssertion(subproofOrProofAssertion, context);
171
265
 
172
266
  if (subproofOrProofAssertionUnifies) {
267
+ const specificContext = context; ///
268
+
269
+ context = this.getContext();
270
+
271
+ const generalContext = context; ///
272
+
273
+ context = specificContext; ///
274
+
275
+ context.resolveSubstitutions(generalContext, specificContext);
276
+
173
277
  return true;
174
278
  }
175
279
  }) || null;
@@ -190,48 +294,6 @@ export default define(class Rule extends Element {
190
294
  return subproofOrProofAssertionsUnifiesWithPremise;
191
295
  }
192
296
 
193
- async verify() {
194
- let verifies = false;
195
-
196
- const context = this.getContext();
197
-
198
- await this.break(context);
199
-
200
- const ruleString = this.getString(); ///
201
-
202
- context.trace(`Verifying the '${ruleString}' rule...`);
203
-
204
- scope((context) => {
205
- const labelsVerify = this.verifyLabels();
206
-
207
- if (labelsVerify) {
208
- const premisesVerify = this.verifyPremises(context);
209
-
210
- if (premisesVerify) {
211
- const conclusionVerifies = this.verifyConclusion(context);
212
-
213
- if (conclusionVerifies) {
214
- const proofVerifies = this.verifyProof(context);
215
-
216
- if (proofVerifies) {
217
- verifies = true;
218
- }
219
- }
220
- }
221
- }
222
- }, context);
223
-
224
- if (verifies) {
225
- const rule = this; ///
226
-
227
- context.addRule(rule);
228
-
229
- context.debug(`...verified the '${ruleString}' rule.`);
230
- }
231
-
232
- return verifies;
233
- }
234
-
235
297
  toJSON() {
236
298
  const labelsJSON = labelsToLabelsJSON(this.labels),
237
299
  premisesJSON = premisesToPremisesJSON(this.premises),
@@ -68,6 +68,8 @@ export default define(class Signature extends Element {
68
68
  // const { TermSubstitution } = elements;
69
69
  //
70
70
  // TermSubstitution.fromTermAndVariable(term, variable, context);
71
+
72
+ // validates...
71
73
  // });
72
74
 
73
75
  return true;
@@ -30,16 +30,50 @@ export default define(class Statement extends Element {
30
30
  return metavariableName;
31
31
  }
32
32
 
33
+ getStatementNode() {
34
+ const node = this.getNode(),
35
+ statementNode = node; ///
36
+
37
+ return statementNode;
38
+ }
39
+
40
+ matchStatementNode(statementNode) {
41
+ const statementNodeA = statementNode; ///
42
+
43
+ statementNode = this.getStatementNode();
44
+
45
+ const statementNodeB = statementNode, ///
46
+ statementNodeAAMatchesStatementBNodeB = statementNodeA.match(statementNodeB),
47
+ equalTo = statementNodeAAMatchesStatementBNodeB; ///
48
+
49
+ return equalTo;
50
+ }
51
+
52
+ isValid(context) {
53
+ const statementNode = this.getStatementNode(),
54
+ statementPresent = context.isStatementPresentByStatementNode(statementNode),
55
+ valid = statementPresent; ///
56
+
57
+ return valid;
58
+ }
59
+
60
+ isEqualTo(statement) {
61
+ const statementNode = statement.getNode(),
62
+ statementNodeMatches = this.matchStatementNode(statementNode),
63
+ equalTo = statementNodeMatches; ///
64
+
65
+ return equalTo;
66
+ }
67
+
33
68
  isTermContained(term, context) {
34
69
  let termContained;
35
70
 
36
- const node = this.getNode(),
37
- termString = term.getString(),
71
+ const termString = term.getString(),
38
72
  statementString = this.getString(); ///
39
73
 
40
74
  context.trace(`Is the '${termString}' term contained in the '${statementString}' statement...`);
41
75
 
42
- const statementNode = node, ///
76
+ const statementNode = this.getStatementNode(),
43
77
  statementNodeTermNodes = statementNode.getTermNodes();
44
78
 
45
79
  termContained = statementNodeTermNodes.some((statementNodeTermNode) => { ///
@@ -65,8 +99,7 @@ export default define(class Statement extends Element {
65
99
 
66
100
  context.trace(`Is the '${frameString}' frame contained in the '${statementString}' statement...`);
67
101
 
68
- const node = this.getNode(),
69
- statementNode = node, ///
102
+ const statementNode = this.getStatementNode(),
70
103
  statementNodeFrameNodes = statementNode.getFrameNodes();
71
104
 
72
105
  frameContained = statementNodeFrameNodes.some((statementNodeFrameNode) => { ///
@@ -84,37 +117,29 @@ export default define(class Statement extends Element {
84
117
  return frameContained;
85
118
  }
86
119
 
87
- isMetavariableEqualToMetavariable(metavariable, context) {
88
- let metavariableEqualToMetavariable;
120
+ compareMetavariable(metavariable) {
121
+ let metavaraibleComparseTo;
89
122
 
90
123
  const singular = this.isSingular();
91
124
 
92
125
  if (singular) {
93
- const node = this.getNode(),
94
- metavariableA = metavariable, ///
95
- singularMetavariableNode = node.getSingularMetavariableNode(),
96
- metavariableName = singularMetavariableNode.getMetavariableName();
126
+ let metavariableName;
97
127
 
98
- metavariable = context.findMetavariableByMetavariableName(metavariableName)
128
+ const statementNode = this.getStatementNode(),
129
+ singularMetavariableNode = statementNode.getSingularMetavariableNode();
99
130
 
100
- const metavariableB = metavariable,
101
- equalTo = metavariableA.isEqualTo(metavariableB);
131
+ metavariableName = singularMetavariableNode.getMetavariableName();
102
132
 
103
- metavariableEqualToMetavariable = equalTo; ///
104
- }
133
+ const metavariableNameA = metavariableName ///
105
134
 
106
- return metavariableEqualToMetavariable;
107
- }
135
+ metavariableName = metavariable.getName();
108
136
 
109
- isEqualTo(statement) {
110
- const statementA = this, ///
111
- statementB = statement, ///
112
- statementANode = statementA.getNode(),
113
- statementBNode = statementB.getNode(),
114
- statementANodeMatchesStatementBNode = statementANode.match(statementBNode),
115
- equalTo = statementANodeMatchesStatementBNode; ///
137
+ const metavariableNameB = metavariableName; ///
116
138
 
117
- return equalTo;
139
+ metavaraibleComparseTo = (metavariableNameA === metavariableNameB);
140
+ }
141
+
142
+ return metavaraibleComparseTo;
118
143
  }
119
144
 
120
145
  compareParameter(parameter) {
@@ -144,21 +169,29 @@ export default define(class Statement extends Element {
144
169
 
145
170
  context.trace(`Validating the '${statementString}' statement...`);
146
171
 
147
- validates = validateStatements.some((validateStatement) => {
148
- const statement = this, ///
149
- statementValidates = validateStatement(statement, assignments, stated, context);
172
+ const valid = this.isValid(context);
150
173
 
151
- if (statementValidates) {
152
- return true;
153
- }
154
- });
174
+ if (valid) {
175
+ validates = true;
155
176
 
156
- if (validates) {
157
- const statement = this; ///
177
+ context.debug(`...the '${statementString}' statement is alrady valid.`);
178
+ } else {
179
+ validates = validateStatements.some((validateStatement) => {
180
+ const statement = this, ///
181
+ statementValidates = validateStatement(statement, assignments, stated, context);
158
182
 
159
- context.addStatement(statement);
183
+ if (statementValidates) {
184
+ return true;
185
+ }
186
+ });
187
+
188
+ if (validates) {
189
+ const statement = this; ///
190
+
191
+ context.addStatement(statement);
160
192
 
161
- context.debug(`...validated the '${statementString}' statement.`);
193
+ context.debug(`...validated the '${statementString}' statement.`);
194
+ }
162
195
  }
163
196
 
164
197
  return validates;
@@ -187,11 +220,10 @@ export default define(class Statement extends Element {
187
220
  return validatesGivenMetaType;
188
221
  }
189
222
 
190
- unifySubproof(subproof, substitutions, generalContext, specificContext) {
223
+ unifySubproof(subproof, generalContext, specificContext) {
191
224
  let subproofUnifies = false;
192
225
 
193
- const node = this.getNode(),
194
- statementNode = node, ///
226
+ const statementNode = this.getStatementNode(),
195
227
  subproofAssertionNode = statementNode.getSubproofAssertionNode(),
196
228
  assertionNode = subproofAssertionNode; ///
197
229
 
@@ -211,7 +243,7 @@ export default define(class Statement extends Element {
211
243
  subproofUnifies = match(subproofAssertionStatements, subproofStatements, (subproofAssertionStatement, subproofStatement) => {
212
244
  const generalStatement = subproofAssertionStatement, ///
213
245
  specificStatement = subproofStatement, ///
214
- statementUnifies = unifyStatement(generalStatement, specificStatement, substitutions, generalContext, specificContext);
246
+ statementUnifies = unifyStatement(generalStatement, specificStatement, generalContext, specificContext);
215
247
 
216
248
  if (statementUnifies) {
217
249
  return true;
@@ -246,7 +278,7 @@ export default define(class Statement extends Element {
246
278
  return statementUnifies;
247
279
  }
248
280
 
249
- unifyIndependently(substitutions, generalContext, specificContext) {
281
+ unifyIndependently(generalContext, specificContext) {
250
282
  let unifiesIndependently = false;
251
283
 
252
284
  const context = specificContext, ///
@@ -254,8 +286,7 @@ export default define(class Statement extends Element {
254
286
 
255
287
  context.trace(`Unifying the '${statementString}' statement independently...`);
256
288
 
257
- const node = this.getNode(),
258
- statementNode = node, ///
289
+ const statementNode = this.getStatementNode(),
259
290
  definedAssertionNode = statementNode.getDefinedAssertionNode(),
260
291
  containedAssertionNode = statementNode.getContainedAssertionNode();
261
292
 
@@ -263,7 +294,7 @@ export default define(class Statement extends Element {
263
294
  const context = generalContext, ///
264
295
  assertionNode = (definedAssertionNode || containedAssertionNode),
265
296
  assertion = context.findAssertionByAssertionNode(assertionNode),
266
- assertionUnifiesIndependently = assertion.unifyIndependently(substitutions, generalContext, specificContext);
297
+ assertionUnifiesIndependently = assertion.unifyIndependently(generalContext, specificContext);
267
298
 
268
299
  if (assertionUnifiesIndependently) {
269
300
  unifiesIndependently = true;
@@ -38,6 +38,21 @@ export default define(class FrameSubstitution extends Substitution {
38
38
  return replacementNode;
39
39
  }
40
40
 
41
+ getMetavariable(generalContext, specificContext) {
42
+ let metavariable = null;
43
+
44
+ const targetFrameNode = this.targetFrame.getNode(),
45
+ metavariableName = targetFrameNode.getMetavariableName();
46
+
47
+ if (metavariableName !== null) {
48
+ const context = generalContext; ///
49
+
50
+ metavariable = context.findMetavariableByMetavariableName(metavariableName);
51
+ }
52
+
53
+ return metavariable;
54
+ }
55
+
41
56
  isTrivial() {
42
57
  const targetFrameEqualToReplacementFrame = this.targetFrame.isEqualTo(this.replacementFrame),
43
58
  trivial = targetFrameEqualToReplacementFrame; ///
@@ -59,38 +74,51 @@ export default define(class FrameSubstitution extends Substitution {
59
74
  return comparesToParameter;
60
75
  }
61
76
 
62
- validate(context) {
77
+ validate(generalContext, specificContext) {
63
78
  let validates = false;
64
79
 
80
+ const context = this.getContext();
81
+
82
+ specificContext = context; ///
83
+
65
84
  const frameSubstitutionString = this.getString(); ///
66
85
 
67
86
  context.trace(`Validating the '${frameSubstitutionString}' frame substitution...`);
68
87
 
69
- const targetFrameValidates = this.validateTargetFrame(context);
88
+ const valid = this.isValid(context);
70
89
 
71
- if (targetFrameValidates) {
72
- const replacementFrameValidates = this.validateReplacementFrame(context);
90
+ if (valid) {
91
+ validates = true;
92
+
93
+ context.debug(`...the '${frameSubstitutionString}' frame substitution is already valid.`);
94
+ } else {
95
+ const targetFrameValidates = this.validateTargetFrame(generalContext, specificContext);
96
+
97
+ if (targetFrameValidates) {
98
+ const replacementFrameValidates = this.validateReplacementFrame(generalContext, specificContext);
73
99
 
74
- if (replacementFrameValidates) {
75
- validates = true;
100
+ if (replacementFrameValidates) {
101
+ validates = true;
102
+ }
76
103
  }
77
- }
78
104
 
79
- if (validates) {
80
- const substititoin = this; ///
105
+ if (validates) {
106
+ const substititoin = this; ///
81
107
 
82
- context.addSubstitution(substititoin);
108
+ context.addSubstitution(substititoin);
83
109
 
84
- context.debug(`...validated the '${frameSubstitutionString}' frame substitution.`);
110
+ context.debug(`...validated the '${frameSubstitutionString}' frame substitution.`);
111
+ }
85
112
  }
86
113
 
87
114
  return validates;
88
115
  }
89
116
 
90
- validateTargetFrame(context) {
117
+ validateTargetFrame(generalContext, specificContext) {
91
118
  let targetFrameValidates = false;
92
119
 
93
- const targetFrameString = this.targetFrame.getString(),
120
+ const context = generalContext, ///
121
+ targetFrameString = this.targetFrame.getString(),
94
122
  frameSubstitutionString = this.getString(); ///
95
123
 
96
124
  context.trace(`Validating the '${frameSubstitutionString}' frame subtitution's '${targetFrameString}' target frame...`);
@@ -113,10 +141,11 @@ export default define(class FrameSubstitution extends Substitution {
113
141
  return targetFrameValidates;
114
142
  }
115
143
 
116
- validateReplacementFrame(context) {
144
+ validateReplacementFrame(generalContext, specificContext) {
117
145
  let replacementFrameValidates;
118
146
 
119
- const replacementFrameString = this.replacementFrame.getString(),
147
+ const context = specificContext, ///
148
+ replacementFrameString = this.replacementFrame.getString(),
120
149
  frameSubstitutionString = this.getString(); ///
121
150
 
122
151
  context.trace(`Validating the '${frameSubstitutionString}' frame subtitution's '${replacementFrameString}' replacement frame...`);