occam-verify-cli 0.0.1089 → 0.0.1091

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 (126) hide show
  1. package/bin/action/verify.js +2 -2
  2. package/lib/assertion/contained.js +35 -41
  3. package/lib/assertion/defined.js +24 -24
  4. package/lib/assertion/subproof.js +24 -24
  5. package/lib/assertion/type.js +23 -23
  6. package/lib/assignment/equality.js +4 -10
  7. package/lib/assignment/judgement.js +4 -4
  8. package/lib/assignment/variable.js +4 -4
  9. package/lib/combinator/bracketed.js +3 -3
  10. package/lib/conclusion.js +11 -13
  11. package/lib/consequent.js +11 -13
  12. package/lib/constructor/bracketed.js +3 -3
  13. package/lib/constructor.js +2 -2
  14. package/lib/context/file.js +28 -27
  15. package/lib/context/local.js +31 -32
  16. package/lib/context/release.js +6 -3
  17. package/lib/declaration.js +18 -18
  18. package/lib/derivation.js +3 -3
  19. package/lib/equality.js +24 -24
  20. package/lib/equivalence.js +13 -13
  21. package/lib/frame.js +43 -43
  22. package/lib/index.js +2 -1
  23. package/lib/judgement.js +20 -20
  24. package/lib/label.js +9 -1
  25. package/lib/metaType.js +2 -2
  26. package/lib/metavariable.js +40 -39
  27. package/lib/mixins/statement/qualified/unify.js +19 -19
  28. package/lib/mixins/statement/resolve.js +11 -11
  29. package/lib/mixins/statement/unify.js +12 -12
  30. package/lib/mixins/statement/verify.js +36 -36
  31. package/lib/mixins/term/verify.js +2 -2
  32. package/lib/premise.js +31 -40
  33. package/lib/proof.js +6 -5
  34. package/lib/proofStep.js +17 -17
  35. package/lib/reference.js +8 -8
  36. package/lib/rule.js +21 -21
  37. package/lib/statement/qualified.js +17 -17
  38. package/lib/statement/unqualified.js +19 -19
  39. package/lib/statement.js +52 -54
  40. package/lib/subDerivation.js +3 -3
  41. package/lib/subproof.js +6 -5
  42. package/lib/substitution/frameForMetavariable.js +16 -39
  43. package/lib/substitution/statementForMetavariable.js +88 -74
  44. package/lib/substitution/termForVariable.js +15 -41
  45. package/lib/substitution.js +20 -6
  46. package/lib/substitutions.js +13 -13
  47. package/lib/supposition.js +31 -40
  48. package/lib/term.js +28 -28
  49. package/lib/topLevelAssertion.js +33 -21
  50. package/lib/unifier/equality.js +8 -8
  51. package/lib/unifier/intrinsicLevel.js +149 -0
  52. package/lib/unifier/metaLevel.js +41 -31
  53. package/lib/unifier/metavariable.js +14 -8
  54. package/lib/unifier/statementWithCombinator.js +16 -16
  55. package/lib/unifier/termWithConstructor.js +6 -6
  56. package/lib/unifier.js +47 -47
  57. package/lib/utilities/assignments.js +3 -3
  58. package/lib/utilities/equivalences.js +14 -14
  59. package/lib/utilities/json.js +22 -21
  60. package/lib/utilities/unifier.js +7 -8
  61. package/lib/variable.js +33 -33
  62. package/lib/verifier/statementAsCombinator.js +2 -2
  63. package/lib/verifier/termAsConstructor.js +2 -2
  64. package/package.json +2 -2
  65. package/src/assertion/contained.js +37 -45
  66. package/src/assertion/defined.js +25 -25
  67. package/src/assertion/subproof.js +25 -28
  68. package/src/assertion/type.js +23 -23
  69. package/src/assignment/equality.js +4 -6
  70. package/src/assignment/judgement.js +4 -4
  71. package/src/assignment/variable.js +4 -4
  72. package/src/combinator/bracketed.js +2 -2
  73. package/src/conclusion.js +14 -15
  74. package/src/consequent.js +14 -15
  75. package/src/constructor/bracketed.js +2 -2
  76. package/src/constructor.js +3 -2
  77. package/src/context/file.js +26 -25
  78. package/src/context/local.js +21 -23
  79. package/src/context/release.js +5 -3
  80. package/src/declaration.js +20 -20
  81. package/src/derivation.js +2 -2
  82. package/src/equality.js +26 -26
  83. package/src/equivalence.js +12 -12
  84. package/src/frame.js +42 -42
  85. package/src/index.js +1 -0
  86. package/src/judgement.js +25 -25
  87. package/src/label.js +14 -0
  88. package/src/metaType.js +1 -1
  89. package/src/metavariable.js +51 -43
  90. package/src/mixins/statement/qualified/unify.js +21 -21
  91. package/src/mixins/statement/resolve.js +12 -12
  92. package/src/mixins/statement/unify.js +11 -11
  93. package/src/mixins/statement/verify.js +35 -35
  94. package/src/mixins/term/verify.js +1 -1
  95. package/src/premise.js +42 -53
  96. package/src/proof.js +6 -4
  97. package/src/proofStep.js +21 -21
  98. package/src/reference.js +12 -11
  99. package/src/rule.js +20 -20
  100. package/src/statement/qualified.js +18 -17
  101. package/src/statement/unqualified.js +19 -18
  102. package/src/statement.js +63 -66
  103. package/src/subDerivation.js +2 -3
  104. package/src/subproof.js +6 -4
  105. package/src/substitution/frameForMetavariable.js +29 -45
  106. package/src/substitution/statementForMetavariable.js +136 -86
  107. package/src/substitution/termForVariable.js +28 -49
  108. package/src/substitution.js +15 -5
  109. package/src/substitutions.js +12 -12
  110. package/src/supposition.js +41 -53
  111. package/src/term.js +27 -27
  112. package/src/topLevelAssertion.js +32 -19
  113. package/src/unifier/equality.js +7 -7
  114. package/src/unifier/intrinsicLevel.js +61 -0
  115. package/src/unifier/metaLevel.js +60 -46
  116. package/src/unifier/metavariable.js +22 -13
  117. package/src/unifier/statementWithCombinator.js +28 -28
  118. package/src/unifier/termWithConstructor.js +8 -8
  119. package/src/unifier.js +55 -55
  120. package/src/utilities/assignments.js +2 -2
  121. package/src/utilities/equivalences.js +13 -13
  122. package/src/utilities/json.js +76 -66
  123. package/src/utilities/unifier.js +10 -12
  124. package/src/variable.js +43 -40
  125. package/src/verifier/statementAsCombinator.js +2 -1
  126. package/src/verifier/termAsConstructor.js +2 -1
package/src/judgement.js CHANGED
@@ -31,26 +31,26 @@ class Judgement {
31
31
 
32
32
  matchMetavariableNode(metavariableNode) { return this.frame.matchMetavariableNode(metavariableNode); }
33
33
 
34
- verify(assignments, stated, localContext) {
34
+ verify(assignments, stated, context) {
35
35
  let verified;
36
36
 
37
37
  const judgementString = this.string; ///
38
38
 
39
- localContext.trace(`Verifying the '${judgementString}' judgement...`);
39
+ context.trace(`Verifying the '${judgementString}' judgement...`);
40
40
 
41
- const frameVerified = this.frame.verify(assignments, stated, localContext);
41
+ const frameVerified = this.frame.verify(assignments, stated, context);
42
42
 
43
43
  if (frameVerified) {
44
- const declarationVerified = this.declaration.verify(assignments, stated, localContext);
44
+ const declarationVerified = this.declaration.verify(assignments, stated, context);
45
45
 
46
46
  if (declarationVerified) {
47
47
  let verifiedWhenStated = false,
48
48
  verifiedWhenDerived = false;
49
49
 
50
50
  if (stated) {
51
- verifiedWhenStated = this.verifyWhenStated(assignments, localContext);
51
+ verifiedWhenStated = this.verifyWhenStated(assignments, context);
52
52
  } else {
53
- verifiedWhenDerived = this.verifyWhenDerived(assignments, localContext);
53
+ verifiedWhenDerived = this.verifyWhenDerived(assignments, context);
54
54
  }
55
55
 
56
56
  if (verifiedWhenStated || verifiedWhenDerived) {
@@ -60,18 +60,18 @@ class Judgement {
60
60
  }
61
61
 
62
62
  if (verified) {
63
- localContext.debug(`...verified the '${judgementString}' judgement.`);
63
+ context.debug(`...verified the '${judgementString}' judgement.`);
64
64
  }
65
65
 
66
66
  return verified;
67
67
  }
68
68
 
69
- verifyWhenStated(assignments, localContext) {
69
+ verifyWhenStated(assignments, context) {
70
70
  let verifiedWhenStated;
71
71
 
72
72
  const judgementString = this.string; ///
73
73
 
74
- localContext.trace(`Verifying the '${judgementString}' judgement when stated...`);
74
+ context.trace(`Verifying the '${judgementString}' judgement when stated...`);
75
75
 
76
76
  if (assignments !== null) {
77
77
  const judgement = this, ///
@@ -84,27 +84,27 @@ class Judgement {
84
84
  verifiedWhenStated = true;
85
85
 
86
86
  if (verifiedWhenStated) {
87
- localContext.debug(`...verified the '${judgementString}' judgement when stated.`);
87
+ context.debug(`...verified the '${judgementString}' judgement when stated.`);
88
88
  }
89
89
 
90
90
  return verifiedWhenStated;
91
91
  }
92
92
 
93
- verifyWhenDerived(assignments, localContext) {
93
+ verifyWhenDerived(assignments, context) {
94
94
  let verifiedWhenDerived = false;
95
95
 
96
96
  const judgementString = this.string; ///
97
97
 
98
- localContext.trace(`Verifying the '${judgementString}' judgement when derived...`);
98
+ context.trace(`Verifying the '${judgementString}' judgement when derived...`);
99
99
 
100
100
  if (!verifiedWhenDerived) {
101
101
  const reference = this.declaration.getReference(),
102
- metaLemma = localContext.findMetaLemmaByReference(reference),
103
- metatheorem = localContext.findMetatheoremByReference(reference),
102
+ metaLemma = context.findMetaLemmaByReference(reference),
103
+ metatheorem = context.findMetatheoremByReference(reference),
104
104
  metaLemmaMetatheorem = (metaLemma || metatheorem); ///
105
105
 
106
106
  if (metaLemmaMetatheorem !== null) {
107
- const metaLemmaMetatheoremUnified = this.frame.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem, localContext);
107
+ const metaLemmaMetatheoremUnified = this.frame.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem, context);
108
108
 
109
109
  verifiedWhenDerived = metaLemmaMetatheoremUnified; ///
110
110
  }
@@ -112,27 +112,27 @@ class Judgement {
112
112
 
113
113
  if (!verifiedWhenDerived) {
114
114
  const reference = this.declaration.getReference(),
115
- axiom = localContext.findAxiomByReference(reference),
116
- lemma = localContext.findLemmaByReference(reference),
117
- theorem = localContext.findTheoremByReference(reference),
118
- conjecture = localContext.findConjectureByReference(reference),
115
+ axiom = context.findAxiomByReference(reference),
116
+ lemma = context.findLemmaByReference(reference),
117
+ theorem = context.findTheoremByReference(reference),
118
+ conjecture = context.findConjectureByReference(reference),
119
119
  axiomLemmaTheoremOrConjecture = (axiom || lemma || theorem || conjecture);
120
120
 
121
121
  if (axiomLemmaTheoremOrConjecture !== null) {
122
- const axiomLemmaTheoremOrConjectureUnified = this.frame.unifyAxiomLemmaTheoremOrConjecture(axiomLemmaTheoremOrConjecture, localContext);
122
+ const axiomLemmaTheoremOrConjectureUnified = this.frame.unifyAxiomLemmaTheoremOrConjecture(axiomLemmaTheoremOrConjecture, context);
123
123
 
124
124
  verifiedWhenDerived = axiomLemmaTheoremOrConjectureUnified; ///
125
125
  }
126
126
  }
127
127
 
128
128
  if (verifiedWhenDerived) {
129
- localContext.debug(`...verified the '${judgementString}' judgement when derived.`);
129
+ context.debug(`...verified the '${judgementString}' judgement when derived.`);
130
130
  }
131
131
 
132
132
  return verifiedWhenDerived;
133
133
  }
134
134
 
135
- static fromJudgementNode(judgementNode, localContext) {
135
+ static fromJudgementNode(judgementNode, context) {
136
136
  let judgement = null;
137
137
 
138
138
  if (judgementNode !== null) {
@@ -140,9 +140,9 @@ class Judgement {
140
140
  frameNode = frameNodeQuery(judgementNode),
141
141
  declarationNode = declarationNodeQuery(judgementNode),
142
142
  node = judgementNode, ///
143
- string = localContext.nodeAsString(node),
144
- frame = Frame.fromFrameNode(frameNode, localContext),
145
- declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
143
+ frame = Frame.fromFrameNode(frameNode, context),
144
+ string = context.nodeAsString(node),
145
+ declaration = Declaration.fromDeclarationNode(declarationNode, context);
146
146
 
147
147
  judgement = new Judgement(string, frame, declaration);
148
148
  }
package/src/label.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import shim from "./shim";
4
4
  import LocalContext from "./context/local";
5
+ import intrinsicLevelUnifier from "./unifier/intrinsicLevel";
5
6
 
6
7
  import { nodeQuery } from "./utilities/query";
7
8
  import { metavariableFromJSON, metavariableToMetavariableJSON } from "./utilities/json";
@@ -21,6 +22,19 @@ class Label {
21
22
 
22
23
  matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
23
24
 
25
+ unifyReference(reference, generalContext, specificContext) {
26
+ const { Substitutions } = shim,
27
+ metavariableNode = this.metavariable.getNode(),
28
+ referenceMetavariable = reference.getMetavariable(),
29
+ referenceMetavariableNode = referenceMetavariable.getNode(),
30
+ metavariableNodeA = referenceMetavariableNode, ///
31
+ metavariableNodeB = metavariableNode, ///
32
+ substitutions = Substitutions.fromNothing(),
33
+ metavariableUnified = intrinsicLevelUnifier.unify(metavariableNodeA, metavariableNodeB, substitutions, generalContext, specificContext);
34
+
35
+ return metavariableUnified;
36
+ }
37
+
24
38
  verifyWhenDeclared(fileContext) {
25
39
  let verifiedAtTopLevel = false;
26
40
 
package/src/metaType.js CHANGED
@@ -63,7 +63,7 @@ class MetaType {
63
63
  return metaType;
64
64
  }
65
65
 
66
- static fromMetaTypeNode(metaTypeNode, localContext) {
66
+ static fromMetaTypeNode(metaTypeNode, context) {
67
67
  const metaTypeName = metaTypeNameFromMetaTypeNode(metaTypeNode),
68
68
  metaType = metaTypeFromMetaTypeName(metaTypeName);
69
69
 
@@ -71,14 +71,14 @@ class Metavariable {
71
71
  return metavariableNodeMatches;
72
72
  }
73
73
 
74
- unifyFrame(frame, substitutions, localContext) {
74
+ unifyFrame(frame, substitutions, generalContext, specificContext) {
75
75
  let frameUnified = false;
76
76
 
77
77
  const frameNode = frame.getNode(),
78
78
  frameString = frame.getString(),
79
79
  metavariableString = this.string; ///
80
80
 
81
- localContext.trace(`Unifying the '${frameString}' frame with the '${metavariableString}' metavariable...`);
81
+ specificContext.trace(`Unifying the '${frameString}' frame with the '${metavariableString}' metavariable...`);
82
82
 
83
83
  const metavariableNode = this.node, ///
84
84
  simpleSubstitutionPresent = substitutions.isSimpleSubstitutionPresentByMetavariableNode(metavariableNode);
@@ -93,30 +93,31 @@ class Metavariable {
93
93
  }
94
94
  } else {
95
95
  const metavariableNode = this.node, ///
96
- metavariable = metavariableFromMetavariableNode(metavariableNode, localContext),
97
- frameMetavariable = frameMetavariableFromStatementNode(frameNode, localContext);
96
+ metavariable = metavariableFromMetavariableNode(metavariableNode, generalContext, specificContext),
97
+ frameMetavariable = frameMetavariableFromStatementNode(frameNode, generalContext, specificContext);
98
98
 
99
- if (metavariable === frameMetavariable) {
99
+ if ((metavariable !== null) && (metavariable === frameMetavariable)) {
100
100
  frameUnified = true;
101
101
  } else {
102
102
  const metavariable = this, ///
103
- frameForMetavariableSubstitution = FrameForMetavariableSubstitution.fromFrameAndMetavariable(frame, metavariable, localContext),
103
+ context = specificContext, ///
104
+ frameForMetavariableSubstitution = FrameForMetavariableSubstitution.fromFrameAndMetavariable(frame, metavariable, context),
104
105
  substitution = frameForMetavariableSubstitution; ///
105
106
 
106
- substitutions.addSubstitution(substitution, localContext);
107
+ substitutions.addSubstitution(substitution, context);
107
108
 
108
109
  frameUnified = true;
109
110
  }
110
111
  }
111
112
 
112
113
  if (frameUnified) {
113
- localContext.debug(`...unified the '${frameString}' frame with the '${metavariableString}' metavariable.`);
114
+ specificContext.debug(`...unified the '${frameString}' frame with the '${metavariableString}' metavariable.`);
114
115
  }
115
116
 
116
117
  return frameUnified;
117
118
  }
118
119
 
119
- unifyStatement(statement, substitution, substitutions, localContext) {
120
+ unifyStatement(statement, substitution, substitutions, generalContext, specificContext) {
120
121
  let statementUnified = false;
121
122
 
122
123
  const statementString = statement.getString(),
@@ -125,7 +126,7 @@ class Metavariable {
125
126
  substitution.getString() :
126
127
  EMPTY_STRING;
127
128
 
128
- localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable...`);
129
+ specificContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable...`);
129
130
 
130
131
  const statementNode = statement.getNode(),
131
132
  metavariableNode = this.node, ///
@@ -143,68 +144,69 @@ class Metavariable {
143
144
  }
144
145
  } else {
145
146
  const metavariableNode = this.node, ///
146
- metavariable = metavariableFromMetavariableNode(metavariableNode, localContext),
147
- statementMetavariable = statementMetavariableFromStatementNode(statementNode, localContext);
147
+ metavariable = metavariableFromMetavariableNode(metavariableNode, generalContext, specificContext),
148
+ statementMetavariable = statementMetavariableFromStatementNode(statementNode, generalContext, specificContext);
148
149
 
149
150
  if ((metavariable !== null) && (metavariable === statementMetavariable)) {
150
151
  statementUnified = true;
151
152
  } else {
152
- const metavariable = this, ///
153
- statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext);
153
+ const context = specificContext, ///
154
+ metavariable = this, ///
155
+ statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context);
154
156
 
155
157
  substitution = statementForMetavariableSubstitution; ///
156
158
 
157
- substitutions.addSubstitution(substitution, localContext);
159
+ substitutions.addSubstitution(substitution, context);
158
160
 
159
161
  statementUnified = true;
160
162
  }
161
163
  }
162
164
 
163
165
  if (statementUnified) {
164
- localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable.`);
166
+ specificContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable.`);
165
167
  }
166
168
 
167
169
  return statementUnified;
168
170
  }
169
171
 
170
- unifySubstitution(substitution, localContext) {
172
+ unifySubstitution(substitution, context) {
171
173
  let substitutionUnified = false;
172
174
 
173
175
  const metavariableString = this.string, ///
174
176
  substitutionString = substitution.getString();
175
177
 
176
- localContext.trace(`Unifying the '${substitutionString}' substitution with the '${metavariableString}' metavariable...`);
178
+ context.trace(`Unifying the '${substitutionString}' substitution with the '${metavariableString}' metavariable...`);
177
179
 
178
180
  const metavariableNode = this.node, ///
179
- judgement = localContext.findJudgementByMetavariableNode(metavariableNode);
181
+ judgement = context.findJudgementByMetavariableNode(metavariableNode);
180
182
 
181
183
  if (judgement !== null){
182
184
  const declaration = judgement.getDeclaration();
183
185
 
184
- substitutionUnified = declaration.unifySubstitution(substitution, localContext);
186
+ substitutionUnified = declaration.unifySubstitution(substitution, context);
185
187
  }
186
188
 
187
189
  if (substitutionUnified) {
188
- localContext.debug(`...unified the '${substitutionString}' substitution with the '${metavariableString}' metavariable.`);
190
+ context.debug(`...unified the '${substitutionString}' substitution with the '${metavariableString}' metavariable.`);
189
191
  }
190
192
 
191
193
  return substitutionUnified;
192
194
  }
193
195
 
194
- verify(localContext) {
196
+ verify(context) {
195
197
  let verified;
196
198
 
197
199
  const metavariableString = this.string; ///
198
200
 
199
- localContext.trace(`Verifying the '${metavariableString}' metavariable...`);
201
+ context.trace(`Verifying the '${metavariableString}' metavariable...`);
200
202
 
201
203
  const metavariableNode = this.node,
202
- metavariablePresent = localContext.isMetavariablePresentByMetavariableNode(metavariableNode, localContext);
204
+ metavariablePresent = context.isMetavariablePresentByMetavariableNode(metavariableNode);
203
205
 
204
206
  verified = metavariablePresent; ///
205
207
 
206
208
  if (verified) {
207
- localContext.debug(`...verified the '${metavariableString}' metavariable.`);
209
+ context.debug(`...verified the '${metavariableString}' metavariable.`);
208
210
  }
209
211
 
210
212
  return verified;
@@ -227,9 +229,7 @@ class Metavariable {
227
229
  const termNode = termNodeQuery(this.node);
228
230
 
229
231
  if (termNode !== null) {
230
- const termString = this.fileContext.nodeAsString(termNode);
231
-
232
- this.fileContext.debug(`The '${termString}' term was found when a type should have been present.`);
232
+ this.fileContext.debug(`A term was found in the '${metavariableString}' metavariable when a type should have been present.`);
233
233
  } else {
234
234
  const typeNode = typeNodeQuery(this.node);
235
235
 
@@ -255,16 +255,18 @@ class Metavariable {
255
255
  return verifiedAtTopLevel;
256
256
  }
257
257
 
258
- verifyGivenMetaType(metaType, localContext) {
258
+ verifyGivenMetaType(metaType, context) {
259
259
  let verifiedGivenMetaType = false;
260
260
 
261
261
  const metavariableString = this.string, ///
262
262
  metaTypeString = metaType.getString();
263
263
 
264
- localContext.trace(`Verifying the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type...`);
264
+ context.trace(`Verifying the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type...`);
265
265
 
266
266
  const metavariableNode = this.node, ///
267
- metavariable = localContext.findMetavariableByMetavariableNode(metavariableNode, localContext);
267
+ specificContext = context, ///
268
+ generalContext = context, ///
269
+ metavariable = generalContext.findMetavariableByMetavariableNode(metavariableNode, specificContext);
268
270
 
269
271
  if (metavariable !== null) {
270
272
  const metaTypeMatches = metavariable.matchMetaType(metaType);
@@ -273,7 +275,7 @@ class Metavariable {
273
275
  }
274
276
 
275
277
  if (verifiedGivenMetaType) {
276
- localContext.debug(`...verified the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type.`);
278
+ context.debug(`...verified the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type.`);
277
279
  }
278
280
 
279
281
  return verifiedGivenMetaType;
@@ -306,17 +308,17 @@ class Metavariable {
306
308
  return metavariable;
307
309
  }
308
310
 
309
- static fromMetavariableNode(metavariableNode, localContext) {
311
+ static fromMetavariableNode(metavariableNode, context) {
310
312
  let metavariable = null;
311
313
 
312
314
  if (metavariableNode !== null) {
313
315
  const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
314
316
  node = metavariableNode, ///
315
317
  name = metavariableName, ///
316
- string = localContext.nodeAsString(node),
318
+ string = context.nodeAsString(node),
317
319
  metaType = null;
318
320
 
319
- metavariable = new Metavariable(localContext, string, node, name, metaType);
321
+ metavariable = new Metavariable(context, string, node, name, metaType);
320
322
  }
321
323
 
322
324
  return metavariable;
@@ -327,12 +329,13 @@ class Metavariable {
327
329
  metaTypeNode = metaTypeNodeQuery(metavariableDeclarationNode),
328
330
  metavariableNode = metavariableNodeQuery(metavariableDeclarationNode),
329
331
  metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
330
- localContext = LocalContext.fromFileContext(fileContext),
331
332
  metavariableString = fileContext.nodeAsString(metavariableNode),
333
+ localContext = LocalContext.fromFileContext(fileContext),
334
+ context = localContext, ///
332
335
  string = metavariableString, ///
333
336
  node = metavariableNode, ///
334
337
  name = metavariableName, ///
335
- metaType = MetaType.fromMetaTypeNode(metaTypeNode, localContext),
338
+ metaType = MetaType.fromMetaTypeNode(metaTypeNode, context),
336
339
  metavariable = new Metavariable(fileContext, string, node, name, metaType);
337
340
 
338
341
  return metavariable;
@@ -345,31 +348,36 @@ Object.assign(shim, {
345
348
 
346
349
  export default Metavariable;
347
350
 
348
- function metavariableFromMetavariableNode(metavariableNode, localContext) {
349
- const metavariable = localContext.findMetavariableByMetavariableNode(metavariableNode, localContext);
351
+ function metavariableFromMetavariableNode(metavariableNode, generalContext, specificContext) {
352
+ const context = generalContext, ///
353
+ metavariable = context.findMetavariableByMetavariableNode(metavariableNode, specificContext);
350
354
 
351
355
  return metavariable;
352
356
  }
353
357
 
354
- function frameMetavariableFromStatementNode(frameNode, localContext) {
358
+ function frameMetavariableFromStatementNode(frameNode, generalContext, specificContext) {
355
359
  let frameMetavariable = null;
356
360
 
357
361
  const frameMetavariableNode = frameMetavariableNodeQuery(frameNode);
358
362
 
359
363
  if (frameMetavariableNode !== null) {
360
- frameMetavariable = localContext.findMetavariableByMetavariableNode(frameMetavariableNode, localContext);
364
+ const context = generalContext; ///
365
+
366
+ frameMetavariable = context.findMetavariableByMetavariableNode(frameMetavariableNode, specificContext);
361
367
  }
362
368
 
363
369
  return frameMetavariable;
364
370
  }
365
371
 
366
- function statementMetavariableFromStatementNode(statementNode, localContext) {
372
+ function statementMetavariableFromStatementNode(statementNode, generalContext, specificContext) {
367
373
  let statementMetavariable = null;
368
374
 
369
375
  const statementMetavariableNode = statementMetavariableNodeQuery(statementNode);
370
376
 
371
377
  if (statementMetavariableNode !== null) {
372
- statementMetavariable = localContext.findMetavariableByMetavariableNode(statementMetavariableNode, localContext);
378
+ const context = generalContext;
379
+
380
+ statementMetavariable = context.findMetavariableByMetavariableNode(statementMetavariableNode, specificContext);
373
381
  }
374
382
 
375
383
  return statementMetavariable;
@@ -4,92 +4,92 @@ import StatementForMetavariableSubstitution from "../../../substitution/statemen
4
4
 
5
5
  import { trim } from "../../../utilities/string";
6
6
 
7
- function unifyAWithRule(qualifiedStatement, substitutions, localContext) {
7
+ function unifyAWithRule(qualifiedStatement, substitutions, context) {
8
8
  let unifiedWithRule = false;
9
9
 
10
10
  const reference = qualifiedStatement.getReference(),
11
- rule = localContext.findRuleByReference(reference);
11
+ rule = context.findRuleByReference(reference);
12
12
 
13
13
  if (rule !== null) {
14
14
  const referenceString = reference.getString(),
15
15
  qualifiedStatementString = trim(qualifiedStatement.getString()); ///
16
16
 
17
- localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${referenceString}' rule...`);
17
+ context.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${referenceString}' rule...`);
18
18
 
19
19
  const statement = qualifiedStatement.getStatement(),
20
- statementUnified = rule.unifyStatement(statement, localContext);
20
+ statementUnified = rule.unifyStatement(statement, context);
21
21
 
22
22
  unifiedWithRule = statementUnified; ///
23
23
 
24
24
  if (unifiedWithRule) {
25
- localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${referenceString}' rule.`);
25
+ context.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${referenceString}' rule.`);
26
26
  }
27
27
  }
28
28
 
29
29
  return unifiedWithRule;
30
30
  }
31
31
 
32
- function unifyAWithReference(qualifiedStatement, substitutions, localContext) {
32
+ function unifyAWithReference(qualifiedStatement, substitutions, context) {
33
33
  let unifiedWithReference = false;
34
34
 
35
35
  const reference = qualifiedStatement.getReference(),
36
36
  metavariableNode = reference.getMetavariableNode(),
37
- metavariablePresent = localContext.isMetavariablePresentByMetavariableNode(metavariableNode, localContext);
37
+ metavariablePresent = context.isMetavariablePresentByMetavariableNode(metavariableNode);
38
38
 
39
39
  if (metavariablePresent) {
40
40
  const statement = qualifiedStatement.getStatement(),
41
41
  statementString = statement.getString(),
42
42
  referenceString = reference.getString();
43
43
 
44
- localContext.trace(`Unifying the '${statementString}' qualified statement with the '${referenceString}' reference...`);
44
+ context.trace(`Unifying the '${statementString}' qualified statement with the '${referenceString}' reference...`);
45
45
 
46
46
  const metavariable = reference.getMetavariable(),
47
- statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable, localContext),
47
+ statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable, context),
48
48
  substitution = statementForMetavariableSubstitution; ///
49
49
 
50
- substitutions.addSubstitution(substitution, localContext);
50
+ substitutions.addSubstitution(substitution, context);
51
51
 
52
52
  unifiedWithReference = true;
53
53
 
54
54
  if (unifiedWithReference) {
55
- localContext.debug(`...unified the '${statementString}' qualified statement with the '${referenceString}' reference.`);
55
+ context.debug(`...unified the '${statementString}' qualified statement with the '${referenceString}' reference.`);
56
56
  }
57
57
  }
58
58
 
59
59
  return unifiedWithReference;
60
60
  }
61
61
 
62
- function unifyAWithAxiomLemmaTheoremOrConjecture(qualifiedStatement, substitutions, localContext) {
62
+ function unifyAWithAxiomLemmaTheoremOrConjecture(qualifiedStatement, substitutions, context) {
63
63
  let unifiedWithAxiomLemmaTheoremOrConjecture = false;
64
64
 
65
65
  const reference = qualifiedStatement.getReference(),
66
- axiom = localContext.findAxiomByReference(reference),
67
- lemma = localContext.findLemmaByReference(reference),
68
- theorem = localContext.findTheoremByReference(reference),
69
- conjecture = localContext.findConjectureByReference(reference),
66
+ axiom = context.findAxiomByReference(reference),
67
+ lemma = context.findLemmaByReference(reference),
68
+ theorem = context.findTheoremByReference(reference),
69
+ conjecture = context.findConjectureByReference(reference),
70
70
  axiomLemmaTheoremConjecture = (axiom || lemma || theorem || conjecture);
71
71
 
72
72
  if (axiomLemmaTheoremConjecture !== null) {
73
73
  const referenceString = reference.getString(),
74
74
  qualifiedStatementString = trim(qualifiedStatement.getString()); ///
75
75
 
76
- localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${referenceString}' axiom, lemma, theorem or conjecture...`);
76
+ context.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${referenceString}' axiom, lemma, theorem or conjecture...`);
77
77
 
78
78
  const statement = qualifiedStatement.getStatement(),
79
- statementUnified = axiomLemmaTheoremConjecture.unifyStatement(statement, localContext);
79
+ statementUnified = axiomLemmaTheoremConjecture.unifyStatement(statement, context);
80
80
 
81
81
  if (statementUnified) {
82
82
  const metavariable = reference.getMetavariable(),
83
- statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable, localContext),
83
+ statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable, context),
84
84
  substitution = statementForMetavariableSubstitution; ///
85
85
 
86
- substitutions.addSubstitution(substitution, localContext);
86
+ substitutions.addSubstitution(substitution, context);
87
87
 
88
88
  unifiedWithAxiomLemmaTheoremOrConjecture = true;
89
89
  }
90
90
 
91
91
  if (unifiedWithAxiomLemmaTheoremOrConjecture) {
92
- localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${referenceString}' axiom, lemma, theorem or conjecture.`);
92
+ context.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${referenceString}' axiom, lemma, theorem or conjecture.`);
93
93
  }
94
94
  }
95
95
 
@@ -8,52 +8,52 @@ import { nodeQuery } from "../../utilities/query";
8
8
  const definedAssertionNodeQuery = nodeQuery("/statement/definedAssertion"),
9
9
  containedAssertionNodeQuery = nodeQuery("/statement/containedAssertion");
10
10
 
11
- function resolveAsDefinedAssertion(statement, substitutions, localContextA, localContextB) {
11
+ function resolveAsDefinedAssertion(statement, substitutions, generalContext, specificContext) {
12
12
  let resolvedAsDefinedAssertion = false;
13
13
 
14
- const localContext = localContextA, ///
14
+ const context = generalContext, ///
15
15
  statementNode = statement.getNode(),
16
16
  definedAssertionNode = definedAssertionNodeQuery(statementNode),
17
- definedAssertion = DefinedAssertion.fromDefinedAssertionNode(definedAssertionNode, localContext);
17
+ definedAssertion = DefinedAssertion.fromDefinedAssertionNode(definedAssertionNode, context);
18
18
 
19
19
  if (definedAssertion !== null) {
20
20
  const statementString = statement.getString();
21
21
 
22
- localContextB.trace(`Resolving the '${statementString}' statement as a defined assertion...`);
22
+ specificContext.trace(`Resolving the '${statementString}' statement as a defined assertion...`);
23
23
 
24
- const localContext = localContextB, ///
24
+ const localContext = specificContext, ///
25
25
  definedAssertionVerified = definedAssertion.resolve(substitutions, localContext);
26
26
 
27
27
  resolvedAsDefinedAssertion = definedAssertionVerified; ///
28
28
 
29
29
  if (resolvedAsDefinedAssertion) {
30
- localContextB.debug(`...resolved the '${statementString}' statement as a defined assertion.`);
30
+ specificContext.debug(`...resolved the '${statementString}' statement as a defined assertion.`);
31
31
  }
32
32
  }
33
33
 
34
34
  return resolvedAsDefinedAssertion;
35
35
  }
36
36
 
37
- function resolveAsContainedAssertion(statement, substitutions, localContextA, localContextB) {
37
+ function resolveAsContainedAssertion(statement, substitutions, generalContext, specificContext) {
38
38
  let resolvedAsContainedAssertion = false;
39
39
 
40
- const localContext = localContextA, ///
40
+ const context = generalContext, ///
41
41
  statementNode = statement.getNode(),
42
42
  containedAssertionNode = containedAssertionNodeQuery(statementNode),
43
- containedAssertion = ContainedAssertion.fromContainedAssertionNode(containedAssertionNode, localContext);
43
+ containedAssertion = ContainedAssertion.fromContainedAssertionNode(containedAssertionNode, context);
44
44
 
45
45
  if (containedAssertion !== null) {
46
46
  const statementString = statement.getString();
47
47
 
48
- localContextB.trace(`Resolving the '${statementString}' statement as a contained assertion...`);
48
+ specificContext.trace(`Resolving the '${statementString}' statement as a contained assertion...`);
49
49
 
50
- const localContext = localContextB, ///
50
+ const localContext = specificContext, ///
51
51
  containedAssertionVerified = containedAssertion.resolve(substitutions, localContext);
52
52
 
53
53
  resolvedAsContainedAssertion = containedAssertionVerified; ///
54
54
 
55
55
  if (resolvedAsContainedAssertion) {
56
- localContextB.debug(`...resolved the '${statementString}' statement as a contained assertion.`);
56
+ specificContext.debug(`...resolved the '${statementString}' statement as a contained assertion.`);
57
57
  }
58
58
  }
59
59