occam-verify-cli 0.0.698 → 0.0.702

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 (123) hide show
  1. package/lib/assignment/equality.js +4 -4
  2. package/lib/assignment/metavariable.js +4 -4
  3. package/lib/assignment/variable.js +4 -4
  4. package/lib/collection.js +44 -6
  5. package/lib/conclusion.js +6 -6
  6. package/lib/consequent.js +4 -4
  7. package/lib/constructor.js +3 -10
  8. package/lib/context/file.js +12 -73
  9. package/lib/context/local.js +31 -70
  10. package/lib/context/localMeta.js +12 -9
  11. package/lib/context/release.js +2 -4
  12. package/lib/equality.js +22 -6
  13. package/lib/metaType.js +10 -10
  14. package/lib/metavariable.js +3 -10
  15. package/lib/mixins/context.js +107 -0
  16. package/lib/premise.js +9 -9
  17. package/lib/ruleNames.js +9 -1
  18. package/lib/supposition.js +4 -4
  19. package/lib/type.js +23 -27
  20. package/lib/utilities/collection.js +27 -13
  21. package/lib/utilities/node.js +3 -73
  22. package/lib/utilities/tokens.js +1 -8
  23. package/lib/variable.js +11 -10
  24. package/lib/verifier/node/statementAsCombinator.js +4 -1
  25. package/lib/verifier/node/termAsConstructor.js +4 -20
  26. package/lib/verifier/nodes/equality.js +169 -0
  27. package/lib/verifier/nodes/metastatementForMetavariable.js +6 -7
  28. package/lib/verifier/nodes/statement.js +12 -4
  29. package/lib/verifier/nodes/statementForMetavariable.js +6 -7
  30. package/lib/verifier/nodes/termForVariable.js +19 -20
  31. package/lib/verify/axiom.js +3 -8
  32. package/lib/verify/conclusion.js +2 -2
  33. package/lib/verify/conjecture.js +4 -9
  34. package/lib/verify/consequent.js +3 -3
  35. package/lib/verify/derivation.js +30 -13
  36. package/lib/verify/equality.js +17 -12
  37. package/lib/verify/givenType.js +32 -0
  38. package/lib/verify/lemma.js +4 -9
  39. package/lib/verify/metastatement.js +3 -3
  40. package/lib/verify/premises.js +28 -0
  41. package/lib/verify/rule.js +3 -8
  42. package/lib/verify/ruleDerivation.js +6 -8
  43. package/lib/verify/statement/qualified.js +135 -37
  44. package/lib/verify/statement.js +34 -42
  45. package/lib/verify/supposition.js +6 -7
  46. package/lib/verify/suppositions.js +28 -0
  47. package/lib/verify/term.js +25 -60
  48. package/lib/verify/termAndGivenType.js +39 -0
  49. package/lib/verify/termAsGivenVariable.js +36 -0
  50. package/lib/verify/theorem.js +3 -8
  51. package/lib/verify/typeAssertion.js +44 -27
  52. package/package.json +1 -1
  53. package/src/assignment/equality.js +5 -5
  54. package/src/assignment/metavariable.js +5 -5
  55. package/src/assignment/variable.js +7 -5
  56. package/src/collection.js +55 -5
  57. package/src/conclusion.js +6 -6
  58. package/src/consequent.js +4 -4
  59. package/src/constructor.js +2 -7
  60. package/src/context/file.js +16 -13
  61. package/src/context/local.js +39 -86
  62. package/src/context/localMeta.js +11 -7
  63. package/src/context/release.js +6 -9
  64. package/src/equality.js +25 -4
  65. package/src/metaType.js +10 -10
  66. package/src/metavariable.js +2 -7
  67. package/src/mixins/{file.js → context.js} +20 -2
  68. package/src/premise.js +10 -10
  69. package/src/ruleNames.js +2 -0
  70. package/src/supposition.js +3 -3
  71. package/src/type.js +27 -39
  72. package/src/utilities/collection.js +31 -11
  73. package/src/utilities/node.js +3 -81
  74. package/src/utilities/tokens.js +0 -8
  75. package/src/variable.js +9 -6
  76. package/src/verifier/node/statementAsCombinator.js +7 -1
  77. package/src/verifier/node/termAsConstructor.js +5 -26
  78. package/src/verifier/nodes/equality.js +47 -0
  79. package/src/verifier/nodes/metastatementForMetavariable.js +10 -10
  80. package/src/verifier/nodes/statement.js +1 -1
  81. package/src/verifier/nodes/statementForMetavariable.js +10 -10
  82. package/src/verifier/nodes/termForVariable.js +30 -30
  83. package/src/verify/axiom.js +2 -8
  84. package/src/verify/conclusion.js +1 -1
  85. package/src/verify/conjecture.js +3 -9
  86. package/src/verify/consequent.js +4 -4
  87. package/src/verify/derivation.js +39 -16
  88. package/src/verify/equality.js +20 -11
  89. package/src/verify/{standaloneType.js → givenType.js} +7 -7
  90. package/src/verify/lemma.js +3 -9
  91. package/src/verify/metastatement.js +2 -2
  92. package/src/verify/premises.js +17 -0
  93. package/src/verify/rule.js +2 -8
  94. package/src/verify/ruleDerivation.js +5 -7
  95. package/src/verify/statement/qualified.js +194 -39
  96. package/src/verify/statement.js +47 -47
  97. package/src/verify/supposition.js +10 -12
  98. package/src/verify/suppositions.js +17 -0
  99. package/src/verify/term.js +26 -64
  100. package/src/verify/termAndGivenType.js +37 -0
  101. package/src/verify/termAsGivenVariable.js +39 -0
  102. package/src/verify/theorem.js +2 -8
  103. package/src/verify/typeAssertion.js +59 -32
  104. package/lib/mixins/file.js +0 -83
  105. package/lib/mixins/logging.js +0 -39
  106. package/lib/verifier/nodes/metastatementForMetavariable/conclusion.js +0 -114
  107. package/lib/verifier/nodes/metastatementForMetavariable/premise.js +0 -114
  108. package/lib/verifier/nodes/statementForMetavariable/conclusion.js +0 -114
  109. package/lib/verifier/nodes/statementForMetavariable/premise.js +0 -114
  110. package/lib/verifier/nodes/termForVariable/consequent.js +0 -114
  111. package/lib/verifier/nodes/termForVariable/supposition.js +0 -114
  112. package/lib/verify/standaloneType.js +0 -32
  113. package/lib/verify/termAndStandaloneType.js +0 -39
  114. package/lib/verify/termAsVariableAndStandaloneType.js +0 -39
  115. package/src/mixins/logging.js +0 -24
  116. package/src/verifier/nodes/metastatementForMetavariable/conclusion.js +0 -11
  117. package/src/verifier/nodes/metastatementForMetavariable/premise.js +0 -11
  118. package/src/verifier/nodes/statementForMetavariable/conclusion.js +0 -11
  119. package/src/verifier/nodes/statementForMetavariable/premise.js +0 -11
  120. package/src/verifier/nodes/termForVariable/consequent.js +0 -11
  121. package/src/verifier/nodes/termForVariable/supposition.js +0 -11
  122. package/src/verify/termAndStandaloneType.js +0 -37
  123. package/src/verify/termAsVariableAndStandaloneType.js +0 -38
package/src/collection.js CHANGED
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
 
3
+ import { nodeQuery } from "./utilities/query";
4
+
5
+ const variableNodeQuery = nodeQuery("/term/variable!");
6
+
3
7
  export default class Collection {
4
8
  constructor(terms) {
5
9
  this.terms = terms;
@@ -17,9 +21,9 @@ export default class Collection {
17
21
  this.terms.push(term);
18
22
  }
19
23
 
20
- getType() {
24
+ getType(context) {
21
25
  const type = this.terms.reduce((type, term) => {
22
- const termType = term.getType();
26
+ const termType = termTypeFromTerm(term, context);
23
27
 
24
28
  if (type === null) {
25
29
  type = termType; ///
@@ -37,14 +41,15 @@ export default class Collection {
37
41
  return type;
38
42
  }
39
43
 
40
- matchType(type) {
44
+ matchType(type, context) {
41
45
  const typeA = type; ///
42
46
 
43
- type = this.getType();
47
+ type = this.getType(context);
44
48
 
45
49
  const typeB = type; ///
46
50
 
47
- const typeMatches = (typeA === typeB); ///
51
+ const typeAEqualToTypeB = typeA.isEqualTo(typeB),
52
+ typeMatches = typeAEqualToTypeB; ///
48
53
 
49
54
  return typeMatches;
50
55
  }
@@ -63,6 +68,21 @@ export default class Collection {
63
68
  return termMatches;
64
69
  }
65
70
 
71
+ matchTermNode(termNode) {
72
+ const termNodeA = termNode, ///
73
+ termNodeMatches = this.terms.some((term) => {
74
+ const termNode = term.getNode(),
75
+ termNodeB = termNode, ///
76
+ termNodeAMatchesTermB = termNodeA.match(termNodeB);
77
+
78
+ if (termNodeAMatchesTermB) {
79
+ return true;
80
+ }
81
+ });
82
+
83
+ return termNodeMatches;
84
+ }
85
+
66
86
  matchTerms(terms) {
67
87
  const termsMatch = terms.every((term) => {
68
88
  const termMatches = this.matchTerm(term);
@@ -75,6 +95,18 @@ export default class Collection {
75
95
  return termsMatch;
76
96
  }
77
97
 
98
+ matchTermNodes(termNodes) {
99
+ const termNodesMatch = termNodes.every((termNode) => {
100
+ const termNodeMatches = this.matchTermNode(termNode);
101
+
102
+ if (termNodeMatches) {
103
+ return true;
104
+ }
105
+ })
106
+
107
+ return termNodesMatch;
108
+ }
109
+
78
110
  static fromEquality(equality) {
79
111
  const leftTerm = equality.getLeftTerm(),
80
112
  rightTerm = equality.getRightTerm(),
@@ -99,3 +131,21 @@ export default class Collection {
99
131
  return collection;
100
132
  }
101
133
  }
134
+
135
+ function termTypeFromTerm(term, context) {
136
+ let termType;
137
+
138
+ const termNode = term.getNode(),
139
+ variableNode = variableNodeQuery(termNode);
140
+
141
+ if (variableNode !== null) {
142
+ const variable = context.findVariableByVariableNode(variableNode),
143
+ variableType = variable.getType();
144
+
145
+ termType = variableType; ///
146
+ } else {
147
+ termType = term.getType();
148
+ }
149
+
150
+ return termType;
151
+ }
package/src/conclusion.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
- import conclusionStatementForMetavariableNodesVerifier from "./verifier/nodes/statementForMetavariable/conclusion";
4
- import conclusionMetastatementForMetavariableNodesVerifier from "./verifier/nodes/metastatementForMetavariable/conclusion";
3
+ import statementForMetavariableNodesVerifier from "./verifier/nodes/statementForMetavariable";
4
+ import metastatementForMetavariableNodesVerifier from "./verifier/nodes/metastatementForMetavariable";
5
5
 
6
6
  import { nodeAsString } from "./utilities/string";
7
7
  import { metastatementNodeFromMetastatementString } from "./utilities/node";
@@ -20,7 +20,7 @@ export default class Conclusion {
20
20
  nonTerminalNodeB = statementNode, ///
21
21
  fileContextA = fileContext, ///
22
22
  localContextB = statementLocalContext, ///
23
- nonTerminalNodeVerified = conclusionStatementForMetavariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContextB, () => {
23
+ nonTerminalNodeVerified = statementForMetavariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContextB, () => {
24
24
  const verifyAhead = true;
25
25
 
26
26
  return verifyAhead;
@@ -30,12 +30,12 @@ export default class Conclusion {
30
30
  return statementNodeMatches;
31
31
  }
32
32
 
33
- matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementMetalocalContext) {
33
+ matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementLocalMetaContext) {
34
34
  const nonTerminalNodeA = this.metastatementNode, ///
35
35
  nonTerminalNodeB = metastatementNode, ///
36
36
  fileContextA = fileContext, ///
37
- metalocalContextB = metastatementMetalocalContext, ///
38
- nonTerminalNodeVerified = conclusionMetastatementForMetavariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, metalocalContextB, () => {
37
+ localMetaContextB = metastatementLocalMetaContext, ///
38
+ nonTerminalNodeVerified = metastatementForMetavariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, () => {
39
39
  const verifiedAhead = true;
40
40
 
41
41
  return verifiedAhead;
package/src/consequent.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import consequentTermForVariableNodesVerifier from "./verifier/nodes/termForVariable/consequent";
3
+ import termForVariableNodesVerifier from "./verifier/nodes/termForVariable";
4
4
 
5
5
  import { nodeAsString } from "./utilities/string";
6
6
  import { statementNodeFromStatementString } from "./utilities/node";
@@ -14,12 +14,12 @@ export default class Consequent {
14
14
  return this.statementNode;
15
15
  }
16
16
 
17
- matchStatementNode(statementNode, substitutions, localContext) {
17
+ matchStatementNode(statementNode, substitutions, localContext, statementLocalContext) {
18
18
  const nonTerminalNodeA = this.statementNode, ///
19
19
  nonTerminalNodeB = statementNode, ///
20
20
  localContextA = localContext, ///
21
- localContextB = null, ///
22
- nonTerminalNodeVerified = consequentTermForVariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
21
+ localContextB = statementLocalContext, ///
22
+ nonTerminalNodeVerified = termForVariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
23
23
  const verifiedAhead = true;
24
24
 
25
25
  return verifiedAhead;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
 
3
- import Type from "./type";
4
-
5
3
  import { nodeAsString } from "./utilities/string";
4
+ import { typeFromJSONAndFileContext } from "./type";
6
5
  import { termNodeFromConstructorDeclarationTokens } from "./utilities/node";
7
6
  import { constructorDeclarationTokensFromTermString } from "./utilities/tokens";
8
7
 
@@ -62,11 +61,7 @@ export default class Constructor {
62
61
 
63
62
  json = typeJSON; ///
64
63
 
65
- type = Type.fromJSONAndFileContext(json, fileContext);
66
-
67
- const typeName = type.getName();
68
-
69
- type = fileContext.findTypeByTypeName(typeName); ///
64
+ type = typeFromJSONAndFileContext(json, fileContext);
70
65
  }
71
66
 
72
67
  const tokens = constructorDeclarationTokens, ///
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- import Type from "../type";
4
3
  import Rule from "../rule";
5
4
  import Axiom from "../axiom";
6
5
  import Lemma from "../lemma";
@@ -11,9 +10,10 @@ import Combinator from "../combinator";
11
10
  import Constructor from "../constructor";
12
11
  import Metavariable from "../metavariable";
13
12
 
13
+ import { push } from "../utilities/array";
14
14
  import { objectType } from "../type";
15
- import { push, filter } from "../utilities/array";
16
15
  import { statementMetaType } from "../metaType";
16
+ import { typeFromJSONAndFileContext } from "../type";
17
17
  import { nodeAsString, nodesAsString } from "../utilities/string";
18
18
 
19
19
  const metaTypes = [
@@ -58,13 +58,19 @@ export default class FileContext {
58
58
 
59
59
  getParser() { return this.releaseContext.getParser(); }
60
60
 
61
+ getTermType(term) {
62
+ const termType = term.getType();
63
+
64
+ return termType;
65
+ }
66
+
61
67
  getProofSteps() {
62
68
  const proofSteps = []; ///
63
69
 
64
70
  return proofSteps;
65
71
  }
66
72
 
67
- getCollections() {
73
+ getCollections(localContext) {
68
74
  const collections = []; ///
69
75
 
70
76
  return collections;
@@ -259,18 +265,15 @@ export default class FileContext {
259
265
  findTypeByTypeName(typeName) {
260
266
  let types = this.getTypes();
261
267
 
262
- types = [ ///
263
- ...types,
264
- objectType
265
- ];
268
+ types.push(objectType);
266
269
 
267
270
  const type = types.find((type) => {
268
- const matches = type.matchTypeName(typeName);
271
+ const matches = type.matchTypeName(typeName);
269
272
 
270
- if (matches) {
271
- return true;
272
- }
273
- }) || null;
273
+ if (matches) {
274
+ return true;
275
+ }
276
+ }) || null;
274
277
 
275
278
  return type;
276
279
  }
@@ -632,7 +635,7 @@ export default class FileContext {
632
635
 
633
636
  typesJSON.forEach((typeJSON) => {
634
637
  const json = typeJSON, ///
635
- type = Type.fromJSONAndFileContext(json, fileContext);
638
+ type = typeFromJSONAndFileContext(json, fileContext);
636
639
 
637
640
  this.types.push(type);
638
641
  });
@@ -2,11 +2,10 @@
2
2
 
3
3
  import Variable from "../variable";
4
4
  import Collection from "../collection";
5
- import fileMixins from "../mixins/file";
6
- import loggingMixins from "../mixins/logging";
5
+ import contextMixins from "../mixins/context";
7
6
 
8
7
  import { last } from "../utilities/array";
9
- import { mergeCollections, findCollectionByType, findCollectionByTerm, findCollectionByTerms } from "../utilities/collection";
8
+ import { mergeCollections, findCollectionByTerm } from "../utilities/collection";
10
9
 
11
10
  class LocalContext {
12
11
  constructor(context, variables, proofSteps, collections) {
@@ -24,8 +23,8 @@ class LocalContext {
24
23
  let variables = this.context.getVariables();
25
24
 
26
25
  variables = [ ///
27
- ...variables,
28
- ...this.variables
26
+ ...this.variables,
27
+ ...variables
29
28
  ];
30
29
 
31
30
  return variables;
@@ -35,8 +34,8 @@ class LocalContext {
35
34
  let proofSteps = this.context.getProofSteps();
36
35
 
37
36
  proofSteps = [ ///
38
- ...proofSteps,
39
- ...this.proofSteps
37
+ ...this.proofSteps,
38
+ ...proofSteps
40
39
  ];
41
40
 
42
41
  return proofSteps;
@@ -45,10 +44,11 @@ class LocalContext {
45
44
  getCollections() {
46
45
  let collections = this.context.getCollections();
47
46
 
48
- const collectionsA = collections, ///
49
- collectionsB = this.collections;
47
+ const collectionsA = this.collections, ///
48
+ collectionsB = collections,
49
+ localContext = this; ///
50
50
 
51
- collections = mergeCollections(collectionsA, collectionsB); ///
51
+ collections = mergeCollections(collectionsA, collectionsB, localContext); ///
52
52
 
53
53
  return collections;
54
54
  }
@@ -67,6 +67,24 @@ class LocalContext {
67
67
 
68
68
  getMetavariables() { return this.context.getMetavariables(); }
69
69
 
70
+ getTermType(term) {
71
+ let termType;
72
+
73
+ const collections = this.getCollections(),
74
+ collection = findCollectionByTerm(collections, term);
75
+
76
+ if (collection !== null) {
77
+ const localContext = this, ///
78
+ collectionType = collection.getType(localContext);
79
+
80
+ termType = collectionType; ///
81
+ } else {
82
+ termType = term.getType();
83
+ }
84
+
85
+ return termType;
86
+ }
87
+
70
88
  addEquality(equality) {
71
89
  let equalityAdded;
72
90
 
@@ -89,23 +107,24 @@ class LocalContext {
89
107
 
90
108
  equalityAdded = true;
91
109
  } else if ((leftCollection !== null) && (rightCollection === null)) {
92
- const term = rightTerm, ///
93
- collection = leftCollection; ///
94
-
95
- collection.addTerm(term);
110
+ leftCollection.addTerm(rightTerm);
96
111
 
97
112
  equalityAdded = true;
98
113
  } else if ((leftCollection === null) && (rightCollection !== null)) {
99
- const term = leftTerm, ///
100
- collection = rightCollection; ///
101
-
102
- collection.addTerm(term);
114
+ rightCollection.addTerm(leftTerm);
103
115
 
104
116
  equalityAdded = true;
105
117
  } else if ((leftCollection !== null) && (rightCollection !== null)) {
118
+ if (leftCollection === rightCollection) {
119
+ const collection = leftCollection; ///
106
120
 
107
- debugger
121
+ collection.addTerm(leftTerm);
122
+ collection.addTerm(rightTerm);
108
123
 
124
+ equalityAdded = true;
125
+ } else {
126
+ debugger
127
+ }
109
128
  }
110
129
  }
111
130
 
@@ -163,27 +182,6 @@ class LocalContext {
163
182
  return statementMatches;
164
183
  }
165
184
 
166
- findCollectionByType(type) {
167
- const collections = this.getCollections(),
168
- collection = findCollectionByType(collections, type);
169
-
170
- return collection;
171
- }
172
-
173
- findCollectionByTerm(term) {
174
- const collections = this.getCollections(),
175
- collection = findCollectionByTerm(collections, term);
176
-
177
- return collection;
178
- }
179
-
180
- findCollectionByTerms(terms) {
181
- const collections = this.getCollections(),
182
- collection = findCollectionByTerms(collections, terms);
183
-
184
- return collection;
185
- }
186
-
187
185
  findVariableByVariableNode(variableNode) {
188
186
  const node = variableNode, ///
189
187
  variables = this.getVariables(),
@@ -205,35 +203,6 @@ class LocalContext {
205
203
  return variablePresent;
206
204
  }
207
205
 
208
- isEqualityEqual(equality) {
209
- let equalityEqual;
210
-
211
- const equalityReflexive = equality.isReflexive();
212
-
213
- if (equalityReflexive) {
214
- equalityEqual = true;
215
- } else {
216
- const leftTerm = equality.getLeftTerm(),
217
- rightTerm = equality.getRightTerm(),
218
- terms = [
219
- leftTerm,
220
- rightTerm
221
- ],
222
- termsEqual = this.areTermsEqual(terms);
223
-
224
- equalityEqual = termsEqual; ///
225
- }
226
-
227
- return equalityEqual;
228
- }
229
-
230
- areTermsEqual(terms) {
231
- const collection = this.findCollectionByTerms(terms),
232
- termsEqual = (collection !== null);
233
-
234
- return termsEqual;
235
- }
236
-
237
206
  toJSON(tokens) {
238
207
  const variables = this.variables.map((variable) => {
239
208
  const variableJSON = variable.toJSON(tokens);
@@ -289,24 +258,8 @@ class LocalContext {
289
258
 
290
259
  return localContext;
291
260
  }
292
-
293
- static fromLocalContextAndAssignments(localContext, assignments) {
294
- const context = localContext, ///
295
- variables = assignments.map((assignment) => {
296
- const variable = assignment.getVariable();
297
-
298
- return variable;
299
- }),
300
- proofSteps = [],
301
- collections = [];
302
-
303
- localContext = new LocalContext(context, variables, proofSteps, collections);
304
-
305
- return localContext;
306
- }
307
261
  }
308
262
 
309
- Object.assign(LocalContext.prototype, fileMixins);
310
- Object.assign(LocalContext.prototype, loggingMixins);
263
+ Object.assign(LocalContext.prototype, contextMixins);
311
264
 
312
265
  export default LocalContext;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import fileMixins from "../mixins/file";
4
- import loggingMixins from "../mixins/logging";
3
+ import contextMixins from "../mixins/context";
5
4
 
6
5
  import { last } from "../utilities/array";
7
6
 
@@ -16,12 +15,18 @@ class LocalMetaContext {
16
15
  return this.context;
17
16
  }
18
17
 
18
+ getTermType(term) {
19
+ const termType = term.getType();
20
+
21
+ return termType;
22
+ }
23
+
19
24
  getMetavariables() {
20
25
  let metavariables = this.context.getMetavariables();
21
26
 
22
27
  metavariables = [ ///
28
+ ...this.metavariables,
23
29
  ...metavariables,
24
- this.metavariables
25
30
  ]
26
31
 
27
32
  return metavariables;
@@ -31,8 +36,8 @@ class LocalMetaContext {
31
36
  let metaproofSteps = this.context.getMetaproofSteps();
32
37
 
33
38
  metaproofSteps = [ ///
34
- ...metaproofSteps,
35
- ...this.metaproofSteps
39
+ ...this.metaproofSteps,
40
+ ...metaproofSteps
36
41
  ];
37
42
 
38
43
  return metaproofSteps;
@@ -140,7 +145,6 @@ class LocalMetaContext {
140
145
  }
141
146
  }
142
147
 
143
- Object.assign(LocalMetaContext.prototype, fileMixins);
144
- Object.assign(LocalMetaContext.prototype, loggingMixins);
148
+ Object.assign(LocalMetaContext.prototype, contextMixins);
145
149
 
146
150
  export default LocalMetaContext;
@@ -277,18 +277,15 @@ export default class ReleaseContext {
277
277
  findTypeByTypeName(typeName) {
278
278
  let types = this.getTypes();
279
279
 
280
- types = [ ///
281
- ...types,
282
- objectType
283
- ];
280
+ types.push(objectType);
284
281
 
285
282
  const type = types.find((type) => {
286
- const matches = type.matchTypeName(typeName);
283
+ const matches = type.matchTypeName(typeName);
287
284
 
288
- if (matches) {
289
- return true;
290
- }
291
- }) || null;
285
+ if (matches) {
286
+ return true;
287
+ }
288
+ }) || null;
292
289
 
293
290
  return type;
294
291
  }
package/src/equality.js CHANGED
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ import equalityNodesVerifier from "./verifier/nodes/equality";
4
+
3
5
  export default class Equality {
4
6
  constructor(node, leftTerm, rightTerm) {
5
7
  this.node = node;
@@ -21,19 +23,38 @@ export default class Equality {
21
23
 
22
24
  isReflexive() {
23
25
  const leftTermMatchesRightTerm = this.leftTerm.match(this.rightTerm),
24
- reflexive = leftTermMatchesRightTerm;
26
+ reflexive = leftTermMatchesRightTerm; ///
25
27
 
26
28
  return reflexive;
27
29
  }
28
30
 
29
- static fromEqualityNodeLeftTermAndRightTerm(equalityNode, leftTerm, rightTerm) {
31
+ isEqual(context) {
32
+ const leftTerm = this.getLeftTerm(),
33
+ rightTerm = this.getRightTerm(),
34
+ leftTermNode = leftTerm.getNode(),
35
+ rightTermNode = rightTerm.getNode(),
36
+ nonTerminalNodeA = leftTermNode, ///
37
+ nonTerminalNodeB = rightTermNode, ///
38
+ collections = context.getCollections(),
39
+ localContext = this, ///
40
+ nonTerminalNodeVerified = equalityNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, collections, localContext, () => {
41
+ const verifiedAhead = true;
42
+
43
+ return verifiedAhead;
44
+ }),
45
+ equal = nonTerminalNodeVerified; ///
46
+
47
+ return equal;
48
+ }
49
+
50
+ static fromLeftTermRightTermAndEqualityNode(leftTerm, rightTerm, equalityNode) {
30
51
  let equality = null;
31
52
 
32
53
  const leftTermType = leftTerm.getType(),
33
54
  rightTermType = rightTerm.getType(),
34
- leftTermTypeEqualToSubTypeOfOrSuperTypeOfRightTermType = leftTermType.isEqualToSubTypeOfOrSuperTypeOf(rightTermType);
55
+ leftTermTypeComparableToRightTermType = leftTermType.isComparableTo(rightTermType);
35
56
 
36
- if (leftTermTypeEqualToSubTypeOfOrSuperTypeOfRightTermType) {
57
+ if (leftTermTypeComparableToRightTermType) {
37
58
  const node = equalityNode; ///
38
59
 
39
60
  equality = new Equality(node, leftTerm, rightTerm);
package/src/metaType.js CHANGED
@@ -57,16 +57,6 @@ export default class MetaType {
57
57
 
58
58
  return metaType;
59
59
  }
60
-
61
- static fromJSONAndFileContext(json, fileContext) {
62
- let metaType;
63
-
64
- const { name } = json;
65
-
66
- metaType = new MetaType(name);
67
-
68
- return metaType;
69
- }
70
60
  }
71
61
 
72
62
  class StatementMetaType extends MetaType {
@@ -79,3 +69,13 @@ class StatementMetaType extends MetaType {
79
69
  }
80
70
 
81
71
  export const statementMetaType = StatementMetaType.fromNothing();
72
+
73
+ export function metaTypeFromJSONAndFileContext(json, fileContext) {
74
+ let metaType;
75
+
76
+ const { name } = json;
77
+
78
+ metaType = new MetaType(name);
79
+
80
+ return metaType;
81
+ }
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
 
3
- import MetaType from "./metaType";
4
-
5
3
  import { nodeAsString } from "./utilities/string";
4
+ import { metaTypeFromJSONAndFileContext } from "./metaType";
6
5
 
7
6
  export default class Metavariable {
8
7
  constructor(node, metaType) {
@@ -54,11 +53,7 @@ export default class Metavariable {
54
53
 
55
54
  json = metaType; ///
56
55
 
57
- metaType = MetaType.fromJSONAndFileContext(json, fileContext);
58
-
59
- const metaTypeName = metaType.getName();
60
-
61
- metaType = fileContext.findMetaTypeByMetaTypeName(metaTypeName); ///
56
+ metaType = metaTypeFromJSONAndFileContext(json, fileContext);
62
57
 
63
58
  const metavariable = new Metavariable(node, metaType);
64
59
 
@@ -1,5 +1,17 @@
1
1
  "use strict";
2
2
 
3
+ function trace(node, message) { this.context.trace(node, message); }
4
+
5
+ function debug(node, message) { this.context.debug(node, message); }
6
+
7
+ function info(node, message) { this.context.info(node, message); }
8
+
9
+ function warning(node, message) { this.context.warning(node, message); }
10
+
11
+ function error(node, message) { this.context.error(node, message); }
12
+
13
+ function fatal(node, message) { this.context.fatal(node, message); }
14
+
3
15
  function getAxioms() { return this.context.getAxioms(); }
4
16
 
5
17
  function getLemmas() { return this.context.getLemmas(); }
@@ -34,7 +46,13 @@ function nodeAsString(node) { return this.context.nodeAsString(node); }
34
46
 
35
47
  function nodesAsString(node) { return this.context.nodesAsString(node); }
36
48
 
37
- const fileMixins = {
49
+ const contextMixins = {
50
+ trace,
51
+ debug,
52
+ info,
53
+ warning,
54
+ error,
55
+ fatal,
38
56
  getAxioms,
39
57
  getLemmas,
40
58
  getTheorems,
@@ -54,4 +72,4 @@ const fileMixins = {
54
72
  nodesAsString
55
73
  };
56
74
 
57
- export default fileMixins;
75
+ export default contextMixins;