occam-verify-cli 0.0.682 → 0.0.684

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 (130) hide show
  1. package/lib/assignment/equality.js +60 -0
  2. package/lib/assignment/variable.js +60 -0
  3. package/lib/axiom.js +4 -4
  4. package/lib/axiomLemmaTheoremConjecture.js +29 -29
  5. package/lib/collection.js +154 -0
  6. package/lib/combinator.js +1 -1
  7. package/lib/conclusion.js +5 -5
  8. package/lib/conjecture.js +4 -4
  9. package/lib/consequent.js +3 -3
  10. package/lib/constructor.js +1 -1
  11. package/lib/context/file.js +9 -2
  12. package/lib/context/local.js +330 -0
  13. package/lib/context/localMeta.js +192 -0
  14. package/lib/context/release.js +1 -1
  15. package/lib/equality.js +19 -87
  16. package/lib/label.js +1 -1
  17. package/lib/lemma.js +4 -4
  18. package/lib/log.js +1 -1
  19. package/lib/metaType.js +1 -1
  20. package/lib/metavariable.js +1 -1
  21. package/lib/ocmbinator/bracketed.js +1 -1
  22. package/lib/premise.js +9 -9
  23. package/lib/rule.js +25 -25
  24. package/lib/step/metaproof.js +1 -1
  25. package/lib/step/proof.js +1 -1
  26. package/lib/substitution/metastatementForMetavariable.js +1 -1
  27. package/lib/substitution/statementForMetavariable.js +1 -1
  28. package/lib/substitution/termForVariable.js +1 -1
  29. package/lib/supposition.js +5 -5
  30. package/lib/term.js +68 -0
  31. package/lib/theorem.js +4 -4
  32. package/lib/type.js +5 -5
  33. package/lib/utilities/array.js +4 -4
  34. package/lib/utilities/collection.js +107 -0
  35. package/lib/variable.js +1 -1
  36. package/lib/verifier/node/metastatement.js +9 -9
  37. package/lib/verifier/node/statementAsCombinator.js +1 -1
  38. package/lib/verifier/node/termAsConstructor.js +2 -2
  39. package/lib/verifier/node.js +1 -1
  40. package/lib/verifier/nodes/metastatementForMetavariable/conclusion.js +1 -1
  41. package/lib/verifier/nodes/metastatementForMetavariable/premise.js +1 -1
  42. package/lib/verifier/nodes/metastatementForMetavariable.js +8 -8
  43. package/lib/verifier/nodes/statement.js +1 -1
  44. package/lib/verifier/nodes/statementForMetavariable/conclusion.js +1 -1
  45. package/lib/verifier/nodes/statementForMetavariable/premise.js +1 -1
  46. package/lib/verifier/nodes/statementForMetavariable.js +9 -9
  47. package/lib/verifier/nodes/term.js +3 -3
  48. package/lib/verifier/nodes/termForVariable/consequent.js +1 -1
  49. package/lib/verifier/nodes/termForVariable/supposition.js +1 -1
  50. package/lib/verifier/nodes/termForVariable.js +11 -11
  51. package/lib/verifier/nodes.js +1 -1
  52. package/lib/verify/axiom.js +6 -6
  53. package/lib/verify/conclusion.js +6 -6
  54. package/lib/verify/conjecture.js +7 -7
  55. package/lib/verify/consequent.js +6 -6
  56. package/lib/verify/derivation.js +17 -17
  57. package/lib/verify/equality.js +50 -18
  58. package/lib/verify/lemma.js +7 -7
  59. package/lib/verify/metastatement/qualified.js +7 -7
  60. package/lib/verify/metastatement/unqualified.js +7 -7
  61. package/lib/verify/metastatement.js +12 -12
  62. package/lib/verify/premise.js +7 -7
  63. package/lib/verify/proof.js +10 -7
  64. package/lib/verify/rule.js +6 -6
  65. package/lib/verify/ruleDerivation.js +17 -17
  66. package/lib/verify/ruleProof.js +6 -6
  67. package/lib/verify/statement/qualified.js +15 -15
  68. package/lib/verify/statement/unqualified.js +7 -7
  69. package/lib/verify/supposition.js +8 -8
  70. package/lib/verify/term.js +32 -31
  71. package/lib/verify/terms.js +11 -17
  72. package/lib/verify/theorem.js +7 -7
  73. package/lib/verify/typeAssertion.js +3 -3
  74. package/package.json +2 -2
  75. package/src/assignment/equality.js +21 -0
  76. package/src/assignment/variable.js +21 -0
  77. package/src/axiom.js +1 -1
  78. package/src/axiomLemmaTheoremConjecture.js +26 -26
  79. package/src/collection.js +101 -0
  80. package/src/conclusion.js +6 -6
  81. package/src/conjecture.js +1 -1
  82. package/src/consequent.js +4 -4
  83. package/src/context/file.js +9 -1
  84. package/src/context/local.js +311 -0
  85. package/src/context/{metaproof.js → localMeta.js} +16 -17
  86. package/src/equality.js +17 -111
  87. package/src/lemma.js +1 -1
  88. package/src/premise.js +12 -12
  89. package/src/rule.js +24 -24
  90. package/src/supposition.js +8 -8
  91. package/src/term.js +30 -0
  92. package/src/theorem.js +1 -1
  93. package/src/type.js +3 -3
  94. package/src/utilities/array.js +1 -1
  95. package/src/utilities/collection.js +83 -0
  96. package/src/verifier/node/metastatement.js +8 -8
  97. package/src/verifier/node/termAsConstructor.js +2 -2
  98. package/src/verifier/nodes/metastatementForMetavariable.js +7 -7
  99. package/src/verifier/nodes/statementForMetavariable.js +8 -8
  100. package/src/verifier/nodes/term.js +5 -4
  101. package/src/verifier/nodes/termForVariable.js +15 -14
  102. package/src/verify/axiom.js +5 -5
  103. package/src/verify/conclusion.js +5 -5
  104. package/src/verify/conjecture.js +6 -6
  105. package/src/verify/consequent.js +5 -5
  106. package/src/verify/derivation.js +16 -16
  107. package/src/verify/equality.js +81 -24
  108. package/src/verify/lemma.js +6 -6
  109. package/src/verify/metastatement/qualified.js +7 -7
  110. package/src/verify/metastatement/unqualified.js +6 -6
  111. package/src/verify/metastatement.js +11 -11
  112. package/src/verify/premise.js +6 -6
  113. package/src/verify/proof.js +13 -10
  114. package/src/verify/rule.js +5 -5
  115. package/src/verify/ruleDerivation.js +16 -16
  116. package/src/verify/ruleProof.js +5 -5
  117. package/src/verify/statement/qualified.js +15 -15
  118. package/src/verify/statement/unqualified.js +6 -6
  119. package/src/verify/supposition.js +7 -7
  120. package/src/verify/term.js +38 -35
  121. package/src/verify/terms.js +14 -28
  122. package/src/verify/theorem.js +6 -6
  123. package/src/verify/typeAssertion.js +3 -2
  124. package/lib/assignment.js +0 -74
  125. package/lib/context/metaproof.js +0 -192
  126. package/lib/context/proof.js +0 -245
  127. package/lib/verifier/nodes/equality.js +0 -155
  128. package/src/assignment.js +0 -36
  129. package/src/context/proof.js +0 -205
  130. package/src/verifier/nodes/equality.js +0 -68
package/src/rule.js CHANGED
@@ -44,27 +44,27 @@ export default class Rule {
44
44
  return labelNameMatches;
45
45
  }
46
46
 
47
- matchStatement(statementNode, statementProofContext) {
47
+ matchStatement(statementNode, statementLocalContext) {
48
48
  let statementNatches;
49
49
 
50
50
  const premisesLength = this.premises.length;
51
51
 
52
52
  if (premisesLength === 0) {
53
53
  const substitutions = [],
54
- conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, statementProofContext);
54
+ conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, statementLocalContext);
55
55
 
56
56
  statementNatches = conclusionMatches; ///
57
57
  } else {
58
- const proofSteps = statementProofContext.getProofSteps();
58
+ const proofSteps = statementLocalContext.getProofSteps();
59
59
 
60
60
  statementNatches = someSubArray(proofSteps, premisesLength, (proofSteps) => {
61
61
  let premisesMatchConclusion = false;
62
62
 
63
63
  const substitutions = [],
64
- premisesMatch = matchPremises(this.premises, proofSteps, substitutions, this.fileContext, statementProofContext);
64
+ premisesMatch = matchPremises(this.premises, proofSteps, substitutions, this.fileContext, statementLocalContext);
65
65
 
66
66
  if (premisesMatch) {
67
- const conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, statementProofContext);
67
+ const conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, statementLocalContext);
68
68
 
69
69
  premisesMatchConclusion = conclusionMatches; ///
70
70
  }
@@ -78,27 +78,27 @@ export default class Rule {
78
78
  return statementNatches;
79
79
  }
80
80
 
81
- matchMetastatement(metastatementNode, metastatementMetaproofContext) {
81
+ matchMetastatement(metastatementNode, metastatementLocalMetaContext) {
82
82
  let metastatementNatches;
83
83
 
84
84
  const premisesLength = this.premises.length;
85
85
 
86
86
  if (premisesLength === 0) {
87
87
  const substitutions = [],
88
- conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, metastatementMetaproofContext);
88
+ conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, metastatementLocalMetaContext);
89
89
 
90
90
  metastatementNatches = conclusionMatches; ///
91
91
  } else {
92
- const metaproofSteps = metastatementMetaproofContext.getMetaproofSteps();
92
+ const metaproofSteps = metastatementLocalMetaContext.getMetaproofSteps();
93
93
 
94
94
  metastatementNatches = someSubArray(metaproofSteps, premisesLength, (metaproofSteps) => {
95
95
  let premisesMatchConclusion = false;
96
96
 
97
97
  const substitutions = [],
98
- premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions, this.fileContext, metastatementMetaproofContext);
98
+ premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions, this.fileContext, metastatementLocalMetaContext);
99
99
 
100
100
  if (premisesMatch) {
101
- const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, metastatementMetaproofContext);
101
+ const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, metastatementLocalMetaContext);
102
102
 
103
103
  premisesMatchConclusion = conclusionMatches; ///
104
104
  }
@@ -181,13 +181,13 @@ export default class Rule {
181
181
  }
182
182
  }
183
183
 
184
- function matchPremise(premise, proofSteps, substitutions, fileContext, statementProofContext) {
184
+ function matchPremise(premise, proofSteps, substitutions, fileContext, statementLocalContext) {
185
185
  const proofStep = prune(proofSteps, (proofStep) => {
186
186
  const subproofNode = proofStep.getSubproofNode(),
187
187
  statementNode = proofStep.getStatementNode()
188
188
 
189
189
  if (subproofNode !== null) {
190
- const subProofNodeMatches = premise.matchSubproofNode(subproofNode, substitutions, fileContext, statementProofContext);
190
+ const subProofNodeMatches = premise.matchSubproofNode(subproofNode, substitutions, fileContext, statementLocalContext);
191
191
 
192
192
  if (!subProofNodeMatches) { ///
193
193
  return true;
@@ -195,7 +195,7 @@ function matchPremise(premise, proofSteps, substitutions, fileContext, statement
195
195
  }
196
196
 
197
197
  if (statementNode !== null) {
198
- const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions, fileContext, statementProofContext);
198
+ const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions, fileContext, statementLocalContext);
199
199
 
200
200
  if (!statementNodeMatches) { ///
201
201
  return true;
@@ -208,9 +208,9 @@ function matchPremise(premise, proofSteps, substitutions, fileContext, statement
208
208
  return premiseMatches;
209
209
  }
210
210
 
211
- function matchPremises(premise, proofSteps, substitutions, fileContext, statementProofContext) {
211
+ function matchPremises(premise, proofSteps, substitutions, fileContext, statementLocalContext) {
212
212
  const premisesMatch = premise.every((premise) => {
213
- const premiseMatches = matchPremise(premise, proofSteps, substitutions, fileContext, statementProofContext);
213
+ const premiseMatches = matchPremise(premise, proofSteps, substitutions, fileContext, statementLocalContext);
214
214
 
215
215
  if (premiseMatches) {
216
216
  return true;
@@ -220,20 +220,20 @@ function matchPremises(premise, proofSteps, substitutions, fileContext, statemen
220
220
  return premisesMatch;
221
221
  }
222
222
 
223
- function matchConclusion(conclusion, statementNode, substitutions, fileContext, statementProofContext) {
224
- const statementNodeMatches = conclusion.matchStatementNode(statementNode, substitutions, fileContext, statementProofContext),
223
+ function matchConclusion(conclusion, statementNode, substitutions, fileContext, statementLocalContext) {
224
+ const statementNodeMatches = conclusion.matchStatementNode(statementNode, substitutions, fileContext, statementLocalContext),
225
225
  conclusionMatches = statementNodeMatches; ///
226
226
 
227
227
  return conclusionMatches;
228
228
  }
229
229
 
230
- function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, metastatementMetaproofContext) {
230
+ function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, metastatementLocalMetaContext) {
231
231
  const metaproofStep = prune(metaproofSteps, (metaproofStep) => {
232
232
  const ruleSubproofNode = metaproofStep.getRuleSubproofNode(),
233
233
  metastatementNode = metaproofStep.getMetastatementNode()
234
234
 
235
235
  if (ruleSubproofNode !== null) {
236
- const ruleSubProofNodeMatches = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, metastatementMetaproofContext);
236
+ const ruleSubProofNodeMatches = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, metastatementLocalMetaContext);
237
237
 
238
238
  if (!ruleSubProofNodeMatches) { ///
239
239
  return true;
@@ -241,7 +241,7 @@ function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, m
241
241
  }
242
242
 
243
243
  if (metastatementNode !== null) {
244
- const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementMetaproofContext);
244
+ const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementLocalMetaContext);
245
245
 
246
246
  if (!metastatementNodeMatches) { ///
247
247
  return true;
@@ -254,9 +254,9 @@ function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, m
254
254
  return premiseMatches;
255
255
  }
256
256
 
257
- function metaMatchPremises(premise, metaproofSteps, substitutions, fileContext, metastatementMetaproofContext) {
257
+ function metaMatchPremises(premise, metaproofSteps, substitutions, fileContext, metastatementLocalMetaContext) {
258
258
  const premisesMatch = premise.every((premise) => {
259
- const premiseMatches = metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, metastatementMetaproofContext);
259
+ const premiseMatches = metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, metastatementLocalMetaContext);
260
260
 
261
261
  if (premiseMatches) {
262
262
  return true;
@@ -266,8 +266,8 @@ function metaMatchPremises(premise, metaproofSteps, substitutions, fileContext,
266
266
  return premisesMatch;
267
267
  }
268
268
 
269
- function metaMatchConclusion(conclusion, metastatementNode, substitutions, fileContext, metastatementMetaproofContext) {
270
- const metastatementNodeMatches = conclusion.matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementMetaproofContext),
269
+ function metaMatchConclusion(conclusion, metastatementNode, substitutions, fileContext, metastatementLocalMetaContext) {
270
+ const metastatementNodeMatches = conclusion.matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementLocalMetaContext),
271
271
  conclusionMatches = metastatementNodeMatches; ///
272
272
 
273
273
  return conclusionMatches;
@@ -20,7 +20,7 @@ export default class Supposition {
20
20
  return this.statementNode;
21
21
  }
22
22
 
23
- matchSubproofNode(subproofNode, substitutions, proofContext, statementProofContext) {
23
+ matchSubproofNode(subproofNode, substitutions, localContext, statementLocalContext) {
24
24
  let subproofNodeMatches = false;
25
25
 
26
26
  const subproofAssertionNode = subproofAssertionNodeQuery(this.statementNode);
@@ -41,9 +41,9 @@ export default class Supposition {
41
41
  const subproofStatementNode = subproofStatementNodes[index],
42
42
  nonTerminalNodeA = subproofAssertionStatementNode, ///
43
43
  nonTerminalNodeB = subproofStatementNode, ///
44
- proofContextA = proofContext, ///
45
- proofContextB = statementProofContext, ///
46
- nonTerminalNodeVerified = suppositionTermForVariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, proofContextA, proofContextB, () => {
44
+ localContextA = localContext, ///
45
+ localContextB = statementLocalContext, ///
46
+ nonTerminalNodeVerified = suppositionTermForVariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
47
47
  const verifiedAhead = true;
48
48
 
49
49
  return verifiedAhead;
@@ -59,12 +59,12 @@ export default class Supposition {
59
59
  return subproofNodeMatches;
60
60
  }
61
61
 
62
- matchStatementNode(statementNode, substitutions, proofContext, statementProofContext) {
62
+ matchStatementNode(statementNode, substitutions, localContext, statementLocalContext) {
63
63
  const nonTerminalNodeA = this.statementNode, ///
64
64
  nonTerminalNodeB = statementNode, ///
65
- proofContextA = proofContext, ///
66
- proofContextB = statementProofContext, ///
67
- nonTerminalNodeVerified = suppositionTermForVariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, proofContextA, proofContextB, () => {
65
+ localContextA = localContext, ///
66
+ localContextB = statementLocalContext, ///
67
+ nonTerminalNodeVerified = suppositionTermForVariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
68
68
  const verifiedAhead = true;
69
69
 
70
70
  return verifiedAhead;
package/src/term.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ export default class Term {
4
+ constructor(node, type) {
5
+ this.node = node;
6
+ this.type = type;
7
+ }
8
+
9
+ getNode() {
10
+ return this.node;
11
+ }
12
+
13
+ getType() {
14
+ return this.type;
15
+ }
16
+
17
+ match(term) {
18
+ const node = term.getNode(),
19
+ matches = this.node.match(node);
20
+
21
+ return matches;
22
+ }
23
+
24
+ static fromTermNodeAndType(termNode, type) {
25
+ const node = termNode, ///
26
+ term = new Term(node, type);
27
+
28
+ return term;
29
+ }
30
+ }
package/src/theorem.js CHANGED
@@ -5,5 +5,5 @@ import AxiomLemmaTheoremConjecture from "./axiomLemmaTheoremConjecture";
5
5
  export default class Theorem extends AxiomLemmaTheoremConjecture {
6
6
  static fromJSONAndFileContext(json, fileContext) { return AxiomLemmaTheoremConjecture.fromJSONAndFileContext(Theorem, json, fileContext); }
7
7
 
8
- static fromLabelsSuppositionsConsequentAndProofContext(labels, suppositions, consequent, proofContext) { return AxiomLemmaTheoremConjecture.fromLabelsSuppositionsConsequentAndProofContext(Theorem, labels, suppositions, consequent, proofContext); }
8
+ static fromLabelsSuppositionsConsequentAndLocalContext(labels, suppositions, consequent, localContext) { return AxiomLemmaTheoremConjecture.fromLabelsSuppositionsConsequentAndLocalContext(Theorem, labels, suppositions, consequent, localContext); }
9
9
  }
package/src/type.js CHANGED
@@ -74,13 +74,13 @@ export default class Type {
74
74
  return equalToOrSuperTypeOf;
75
75
  }
76
76
 
77
- isEqualToOrSubTypeOfOfSuperTypeOf(type) {
77
+ isEqualToSubTypeOfOrSuperTypeOf(type) {
78
78
  const equalTo = this.isEqualTo(type),
79
79
  subTypeOf = this.isSubTypeOf(type),
80
80
  superTypeOf = this.isSuperTypeOf(type),
81
- equalToOrSubTypeOfOfSuperTypeOf = (equalTo || subTypeOf || superTypeOf);
81
+ equalToOrSubTypeOfSuperTypeOf = (equalTo || subTypeOf || superTypeOf);
82
82
 
83
- return equalToOrSubTypeOfOfSuperTypeOf;
83
+ return equalToOrSubTypeOfSuperTypeOf;
84
84
  }
85
85
 
86
86
  match(type) {
@@ -6,7 +6,7 @@ import permutationsMatrix from "../permutationsMatrix";
6
6
 
7
7
  import { MAXIMUM_INDEXES_LENGTH, MAXIMUM_PERMUTATION_LENGTH } from "../constants";
8
8
 
9
- export const { first, second, last, push, prune, filter, clear } = arrayUtilities;
9
+ export const { first, second, last, push, prune, filter, compress } = arrayUtilities;
10
10
 
11
11
  export function someSubArray(array, subArrayLength, callback) {
12
12
  let found = false;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ import { compress } from "../utilities/array";
4
+
5
+ export function mergeCollections(collectionsA, collectionsB) {
6
+ const typesA = typesFromCollections(collectionsA),
7
+ typesB = typesFromCollections(collectionsB),
8
+ types = [
9
+ ...typesA,
10
+ ...typesB
11
+ ];
12
+
13
+ compress(types, (typeA, typeB) => {
14
+ if (typeA === typeB) {
15
+ return true;
16
+ }
17
+ });
18
+
19
+ const collections = types.map((type) => {
20
+ let collection;
21
+
22
+ const collectionA = findCollectionByType(collectionsA, type),
23
+ collectionB = findCollectionByType(collectionsB, type);
24
+
25
+ if ((collectionA !== null) && (collectionB !== null)) {
26
+ collection = Collection.fromCollections(collectionA, collectionB);
27
+ } else if (collectionA !== null) {
28
+ collection = collectionA; ///
29
+ } else if (collectionB !== null) {
30
+ collection = collectionB; ///
31
+ }
32
+
33
+ return collection;
34
+ });
35
+
36
+ return collections;
37
+ }
38
+
39
+ export function findCollectionByType(collections, type) {
40
+ const collection = collections.find((collection) => {
41
+ const collectionMatchesType = collection.matchType(type);
42
+
43
+ if (collectionMatchesType) {
44
+ return true;
45
+ }
46
+ }) || null;
47
+
48
+ return collection;
49
+ }
50
+
51
+ export function findCollectionByTerm(collections, term) {
52
+ const collection = collections.find((collection) => {
53
+ const collectionMatchesTerm = collection.matchTerm(term);
54
+
55
+ if (collectionMatchesTerm) {
56
+ return true;
57
+ }
58
+ }) || null;
59
+
60
+ return collection;
61
+ }
62
+
63
+ export function findCollectionByTerms(collections, terms) {
64
+ const collection = collections.find((collection) => {
65
+ const collectionMatchesTerms = collection.matchTerms(terms);
66
+
67
+ if (collectionMatchesTerms) {
68
+ return true;
69
+ }
70
+ }) || null;
71
+
72
+ return collection;
73
+ }
74
+
75
+ function typesFromCollections(collections) {
76
+ const types = collections.map((collection) => {
77
+ const type = collection.getType();
78
+
79
+ return type;
80
+ });
81
+
82
+ return types;
83
+ }
@@ -6,7 +6,7 @@ import { METAVARIABLE_RULE_NAME } from "../../ruleNames";
6
6
  import { metavariableNameFromMetavariableNode } from "../../utilities/query";
7
7
 
8
8
  class MetastatementNodeVerifier extends NodeVerifier {
9
- verifyNonTerminalNode(nonTerminalNode, metaproofContext, verifyAhead) {
9
+ verifyNonTerminalNode(nonTerminalNode, localMetaContext, verifyAhead) {
10
10
  let nonTerminalNodeVerified;
11
11
 
12
12
  const ruleName = nonTerminalNode.getRuleName(); ///
@@ -14,7 +14,7 @@ class MetastatementNodeVerifier extends NodeVerifier {
14
14
  switch (ruleName) {
15
15
  case METAVARIABLE_RULE_NAME: {
16
16
  const metavariableNode = nonTerminalNode, ///
17
- metavariableVerified = verifyMetavariable(metavariableNode, metaproofContext, verifyAhead),
17
+ metavariableVerified = verifyMetavariable(metavariableNode, localMetaContext, verifyAhead),
18
18
  metavariableNodeVerified = metavariableVerified; ///
19
19
 
20
20
  nonTerminalNodeVerified = metavariableNodeVerified; ///
@@ -23,7 +23,7 @@ class MetastatementNodeVerifier extends NodeVerifier {
23
23
  }
24
24
 
25
25
  default: {
26
- nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNode, metaproofContext, verifyAhead);
26
+ nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNode, localMetaContext, verifyAhead);
27
27
 
28
28
  break;
29
29
  }
@@ -37,15 +37,15 @@ const metastatementNodeVerifier = new MetastatementNodeVerifier();
37
37
 
38
38
  export default metastatementNodeVerifier;
39
39
 
40
- function verifyMetavariable(metavariableNode, metaproofContext, verifyAhead) {
40
+ function verifyMetavariable(metavariableNode, localMetaContext, verifyAhead) {
41
41
  let metavariableVerified;
42
42
 
43
- const metavariableString = metaproofContext.nodeAsString(metavariableNode);
43
+ const metavariableString = localMetaContext.nodeAsString(metavariableNode);
44
44
 
45
- metaproofContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
45
+ localMetaContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
46
46
 
47
47
  const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
48
- metavariablePresent = metaproofContext.isMetavariablePresentByMetavariableName(metavariableName);
48
+ metavariablePresent = localMetaContext.isMetavariablePresentByMetavariableName(metavariableName);
49
49
 
50
50
  if (metavariablePresent) {
51
51
  const verifiedAhead = verifyAhead();
@@ -54,7 +54,7 @@ function verifyMetavariable(metavariableNode, metaproofContext, verifyAhead) {
54
54
  }
55
55
 
56
56
  if (metavariableVerified) {
57
- metaproofContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
57
+ localMetaContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
58
58
  }
59
59
 
60
60
  return metavariableVerified;
@@ -58,9 +58,9 @@ export function verifyStandaloneTerm(termNode, fileContext, verifyAhead) {
58
58
 
59
59
  fileContext.trace(`Verifying the '${termString}' standalone term...`, termNode);
60
60
 
61
- const types = [],
61
+ const terms = [],
62
62
  context = fileContext, ///
63
- termVerified = verifyTerm(termNode, types, context, verifyAhead);
63
+ termVerified = verifyTerm(termNode, terms, context, verifyAhead);
64
64
 
65
65
  standaloneTermVerified = termVerified; ///
66
66
 
@@ -10,7 +10,7 @@ import { metavariableNameFromMetavariableNode } from "../../utilities/query";
10
10
  const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!');
11
11
 
12
12
  export default class MetastatementForMetavariableNodesVerifier extends NodesVerifier {
13
- verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, metaproofContextB, verifyAhead) {
13
+ verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead) {
14
14
  let nonTerminalNodeVerified = false;
15
15
 
16
16
  const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
@@ -23,28 +23,28 @@ export default class MetastatementForMetavariableNodesVerifier extends NodesVeri
23
23
  if (nonTerminalNodeARuleNameMetastatementRuleName && nonTerminalNodeBRuleNameMetastatementRuleName) {
24
24
  const metastatementNodeA = nonTerminalNodeA, ///
25
25
  metastatementNodeB = nonTerminalNodeB, ///
26
- metastatementNodeVerified = this.verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions, fileContextA, metaproofContextB, verifyAhead);
26
+ metastatementNodeVerified = this.verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead);
27
27
 
28
28
  if (metastatementNodeVerified) {
29
29
  nonTerminalNodeVerified = true; ///
30
30
  } else {
31
- nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, metaproofContextB, verifyAhead);
31
+ nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead);
32
32
  }
33
33
  } else {
34
- nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, metaproofContextB, verifyAhead);
34
+ nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead);
35
35
  }
36
36
  }
37
37
 
38
38
  return nonTerminalNodeVerified;
39
39
  }
40
40
 
41
- verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions, fileContextA, metaproofContextB, verifyAhead) {
41
+ verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead) {
42
42
  let metastatementNodeVerified = false;
43
43
 
44
44
  const metavariableNodeA = metavariableNodeQuery(metastatementNodeA);
45
45
 
46
46
  if (metavariableNodeA !== null) {
47
- const metaVariableNodeVerified = this.verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions, fileContextA, metaproofContextB, verifyAhead);
47
+ const metaVariableNodeVerified = this.verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead);
48
48
 
49
49
  metastatementNodeVerified = metaVariableNodeVerified; ///
50
50
  }
@@ -52,7 +52,7 @@ export default class MetastatementForMetavariableNodesVerifier extends NodesVeri
52
52
  return metastatementNodeVerified;
53
53
  }
54
54
 
55
- verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions, fileContextA, metaproofContextB, verifyAhead) {
55
+ verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead) {
56
56
  let metavariableNodeVerified;
57
57
 
58
58
  const metavariableNameA = metavariableNameFromMetavariableNode(metavariableNodeA),
@@ -11,7 +11,7 @@ const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!'),
11
11
  metaArgumentChildNodeNodeQuery = nodeQuery('/metaArgument/*!');
12
12
 
13
13
  export default class StatementForMetavariableNodesVerifier extends NodesVerifier {
14
- verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, proofContextB) {
14
+ verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContext) {
15
15
  let nonTerminalNodeVerified = false;
16
16
 
17
17
  const nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(),
@@ -23,7 +23,7 @@ export default class StatementForMetavariableNodesVerifier extends NodesVerifier
23
23
 
24
24
  nonTerminalNodeB = metaArgumentChildNodeB; ///
25
25
 
26
- nonTerminalNodeVerified = this.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, proofContextB);
26
+ nonTerminalNodeVerified = this.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContext);
27
27
  } else {
28
28
  const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
29
29
  nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(),
@@ -33,7 +33,7 @@ export default class StatementForMetavariableNodesVerifier extends NodesVerifier
33
33
  if (nonTerminalNodeARuleNameMetastatementRuleName && nonTerminalNodeBRuleNameStatementRuleName) {
34
34
  const metastatementNodeA = nonTerminalNodeA, ///
35
35
  statementNodeB = nonTerminalNodeB, ///
36
- statementNodeVerified = this.verifyStatementNode(metastatementNodeA, statementNodeB, substitutions, fileContextA, proofContextB);
36
+ statementNodeVerified = this.verifyStatementNode(metastatementNodeA, statementNodeB, substitutions, fileContextA, localContext);
37
37
 
38
38
  if (statementNodeVerified) {
39
39
  nonTerminalNodeVerified = true; ///
@@ -42,25 +42,25 @@ export default class StatementForMetavariableNodesVerifier extends NodesVerifier
42
42
  nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
43
43
  childNodesA = nonTerminalNodeAChildNodes, ///
44
44
  childNodesB = nonTerminalNodeBChildNodes, ///
45
- childNodesVerified = this.verifyChildNodes(childNodesA, childNodesB, substitutions, fileContextA, proofContextB);
45
+ childNodesVerified = this.verifyChildNodes(childNodesA, childNodesB, substitutions, fileContextA, localContext);
46
46
 
47
47
  nonTerminalNodeVerified = childNodesVerified; ///
48
48
  }
49
49
  } else if (nonTerminalNodeBRuleName === nonTerminalNodeARuleName) {
50
- nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, proofContextB);
50
+ nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContext);
51
51
  }
52
52
  }
53
53
 
54
54
  return nonTerminalNodeVerified;
55
55
  }
56
56
 
57
- verifyStatementNode(metastatementNodeA, statementNodeB, substitutions, fileContextA, proofContextB) {
57
+ verifyStatementNode(metastatementNodeA, statementNodeB, substitutions, fileContextA, localContext) {
58
58
  let statementNodeVerified = false;
59
59
 
60
60
  const metavariableNodeA = metavariableNodeQuery(metastatementNodeA);
61
61
 
62
62
  if (metavariableNodeA !== null) {
63
- const metavariableNodeVerified = this.verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions, fileContextA, proofContextB);
63
+ const metavariableNodeVerified = this.verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions, fileContextA, localContext);
64
64
 
65
65
  statementNodeVerified = metavariableNodeVerified; ///
66
66
  }
@@ -68,7 +68,7 @@ export default class StatementForMetavariableNodesVerifier extends NodesVerifier
68
68
  return statementNodeVerified;
69
69
  }
70
70
 
71
- verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions, fileContextA, proofContextB) {
71
+ verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions, fileContextA, localContext) {
72
72
  let metavariableNodeVerified;
73
73
 
74
74
  const metavariableNameA = metavariableNameFromMetavariableNode(metavariableNodeA),
@@ -76,13 +76,14 @@ export function verifyArgument(argumentNode, constructorArgumentNode, context, v
76
76
 
77
77
  if (constructorTypeNode !== null) {
78
78
  const { verifyTerm } = termNodesVerifier,
79
- types = [],
80
- termVerified = verifyTerm(termNode, types, context, () => {
79
+ terms = [],
80
+ termVerified = verifyTerm(termNode, terms, context, () => {
81
81
  let verifiedAhead = false;
82
82
 
83
83
  const constructorTypeName = typeNameFromTypeNode(constructorTypeNode),
84
- firstType = first(types),
85
- termType = firstType, ///
84
+ firstTerm = first(terms),
85
+ term = firstTerm, ///
86
+ termType = term.getType(),
86
87
  constructorType = context.findTypeByTypeName(constructorTypeName),
87
88
  termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(constructorType);
88
89
 
@@ -12,7 +12,7 @@ import { variableNameFromVariableNode } from "../../utilities/query";
12
12
  const variableNodeQuery = nodeQuery('/term/variable!');
13
13
 
14
14
  export default class TermForVariableNodesVerifier extends NodesVerifier {
15
- verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, proofContextA, proofContextB, verifyAhead) {
15
+ verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, verifyAhead) {
16
16
  let nonTerminalNodeVerified = false;
17
17
 
18
18
  const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
@@ -25,28 +25,28 @@ export default class TermForVariableNodesVerifier extends NodesVerifier {
25
25
  if (nonTerminalNodeARuleNameTermRuleName && nonTerminalNodeBRuleNameTermRuleName) {
26
26
  const termNodeA = nonTerminalNodeA, ///
27
27
  termNodeB = nonTerminalNodeB, ///
28
- termNodeVerified = this.verifyTermNode(termNodeA, termNodeB, substitutions, proofContextA, proofContextB, verifyAhead);
28
+ termNodeVerified = this.verifyTermNode(termNodeA, termNodeB, substitutions, localContextA, localContextB, verifyAhead);
29
29
 
30
30
  if (termNodeVerified) {
31
31
  nonTerminalNodeVerified = true; ///
32
32
  } else {
33
- nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, proofContextA, proofContextB, verifyAhead);
33
+ nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, verifyAhead);
34
34
  }
35
35
  } else {
36
- nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, proofContextA, proofContextB, verifyAhead);
36
+ nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, verifyAhead);
37
37
  }
38
38
  }
39
39
 
40
40
  return nonTerminalNodeVerified;
41
41
  }
42
42
 
43
- verifyTermNode(termNodeA, termNodeB, substitutions, proofContextA, proofContextB, verifyAhead) {
43
+ verifyTermNode(termNodeA, termNodeB, substitutions, localContextA, localContextB, verifyAhead) {
44
44
  let termNodeVerified = false;
45
45
 
46
46
  const variableNodeA = variableNodeQuery(termNodeA);
47
47
 
48
48
  if (variableNodeA !== null) {
49
- const variableVerified = this.verifyVariableNode(variableNodeA, termNodeB, substitutions, proofContextA, proofContextB, verifyAhead);
49
+ const variableVerified = this.verifyVariableNode(variableNodeA, termNodeB, substitutions, localContextA, localContextB, verifyAhead);
50
50
 
51
51
  termNodeVerified = variableVerified; ///
52
52
  }
@@ -54,7 +54,7 @@ export default class TermForVariableNodesVerifier extends NodesVerifier {
54
54
  return termNodeVerified;
55
55
  }
56
56
 
57
- verifyVariableNode(variableNodeA, termNodeB, substitutions, proofContextA, proofContextB, verifyAhead) {
57
+ verifyVariableNode(variableNodeA, termNodeB, substitutions, localContextA, localContextB, verifyAhead) {
58
58
  let variableVerified = false;
59
59
 
60
60
  const variableNameA = variableNameFromVariableNode(variableNodeA),
@@ -80,18 +80,19 @@ export default class TermForVariableNodesVerifier extends NodesVerifier {
80
80
 
81
81
  if (createSubstitutions) {
82
82
  const variableName = variableNameA, ///
83
- proofContext = proofContextA, ///
84
- variable = proofContext.findVariableByVariableName(variableName);
83
+ localContext = localContextA, ///
84
+ variable = localContext.findVariableByVariableName(variableName);
85
85
 
86
86
  if (variable !== null) {
87
- const types = [],
88
- context = proofContextB, ///
87
+ const terms = [],
88
+ context = localContextB, ///
89
89
  termNode = termNodeB, ///
90
- termVerified = verifyTerm(termNode, types, context, () => {
90
+ termVerified = verifyTerm(termNode, terms, context, () => {
91
91
  let verifiedAhead = false;
92
92
 
93
- const firstType = first(types),
94
- termType = firstType,
93
+ const firstTerm = first(terms),
94
+ term = firstTerm, ///
95
+ termType = term.getType(),
95
96
  variableType = variable.getType(),
96
97
  variableTypeEqualToOrSuperTypeOfTermType = variableType.isEqualToOrSuperTypeOf(termType);
97
98