occam-verify-cli 0.0.1016 → 0.0.1020

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 (151) hide show
  1. package/lib/argument.js +12 -11
  2. package/lib/assignment/equality.js +3 -3
  3. package/lib/axiom.js +102 -6
  4. package/lib/combinator.js +12 -12
  5. package/lib/conclusion.js +3 -4
  6. package/lib/consequent.js +75 -14
  7. package/lib/constructor/bracketed.js +3 -3
  8. package/lib/constructor.js +68 -18
  9. package/lib/context/file.js +49 -89
  10. package/lib/context/local.js +34 -58
  11. package/lib/declaration/combinator.js +3 -3
  12. package/lib/declaration/metavariable.js +15 -4
  13. package/lib/declaration/type.js +3 -3
  14. package/lib/declaration/variable.js +146 -0
  15. package/lib/equality.js +95 -19
  16. package/lib/index.js +6 -1
  17. package/lib/label.js +9 -9
  18. package/lib/lemma.js +107 -6
  19. package/lib/metavariable.js +14 -21
  20. package/lib/mixins/statement/qualified/unify.js +3 -3
  21. package/lib/mixins/statement/verify.js +4 -5
  22. package/lib/mixins/term/unify.js +82 -0
  23. package/lib/mixins/term/verify.js +44 -0
  24. package/lib/node/term/constructor/bracketed.js +15 -11
  25. package/lib/premise.js +3 -5
  26. package/lib/proofStep.js +2 -2
  27. package/lib/reference.js +9 -9
  28. package/lib/rule.js +5 -5
  29. package/lib/ruleNames.js +5 -5
  30. package/lib/statement/qualified.js +6 -3
  31. package/lib/statement.js +22 -39
  32. package/lib/supposition.js +75 -50
  33. package/lib/term.js +62 -16
  34. package/lib/topLevelAssertion.js +98 -33
  35. package/lib/type.js +22 -31
  36. package/lib/unifier/equality.js +12 -4
  37. package/lib/unifier/intrinsicLevel.js +1 -4
  38. package/lib/unifier/metaLevel.js +1 -4
  39. package/lib/unifier/metavariable.js +10 -7
  40. package/lib/unifier/statementWithCombinator.js +18 -9
  41. package/lib/unifier/termWithConstructor.js +11 -4
  42. package/lib/unify/frameWithMetaType.js +2 -2
  43. package/lib/utilities/name.js +9 -2
  44. package/lib/utilities/node.js +14 -14
  45. package/lib/utilities/tokens.js +7 -7
  46. package/lib/utilities/unify.js +3 -3
  47. package/lib/variable.js +155 -20
  48. package/lib/verifier/statementAsCombinator.js +2 -2
  49. package/lib/verifier/termAsConstructor.js +2 -2
  50. package/lib/verifier/topLevel.js +7 -7
  51. package/lib/verify/assertion/type.js +3 -4
  52. package/lib/verify/conjecture.js +2 -3
  53. package/lib/verify/frame.js +2 -6
  54. package/lib/verify/lemma.js +2 -3
  55. package/lib/verify/metaLemma.js +2 -3
  56. package/lib/verify/metatheorem.js +2 -3
  57. package/lib/verify/metavariableGivenMetaType.js +3 -3
  58. package/lib/verify/theorem.js +2 -3
  59. package/package.json +1 -1
  60. package/src/argument.js +11 -9
  61. package/src/assignment/equality.js +3 -4
  62. package/src/axiom.js +78 -1
  63. package/src/combinator.js +10 -9
  64. package/src/conclusion.js +2 -4
  65. package/src/consequent.js +88 -13
  66. package/src/constructor/bracketed.js +4 -1
  67. package/src/constructor.js +18 -14
  68. package/src/context/file.js +50 -93
  69. package/src/context/local.js +13 -31
  70. package/src/declaration/combinator.js +2 -2
  71. package/src/declaration/metavariable.js +20 -6
  72. package/src/declaration/type.js +2 -2
  73. package/src/declaration/variable.js +78 -0
  74. package/src/equality.js +123 -22
  75. package/src/index.js +6 -0
  76. package/src/label.js +7 -7
  77. package/src/lemma.js +91 -1
  78. package/src/metavariable.js +13 -22
  79. package/src/mixins/statement/qualified/unify.js +2 -2
  80. package/src/mixins/statement/verify.js +5 -5
  81. package/src/mixins/term/unify.js +110 -0
  82. package/src/mixins/term/verify.js +47 -0
  83. package/src/node/term/constructor/bracketed.js +4 -3
  84. package/src/premise.js +2 -5
  85. package/src/proofStep.js +1 -1
  86. package/src/reference.js +7 -7
  87. package/src/rule.js +4 -4
  88. package/src/ruleNames.js +1 -1
  89. package/src/statement/qualified.js +7 -3
  90. package/src/statement.js +28 -60
  91. package/src/supposition.js +106 -53
  92. package/src/term.js +70 -14
  93. package/src/topLevelAssertion.js +120 -33
  94. package/src/type.js +39 -41
  95. package/src/unifier/equality.js +15 -3
  96. package/src/unifier/intrinsicLevel.js +0 -4
  97. package/src/unifier/metaLevel.js +0 -4
  98. package/src/unifier/metavariable.js +16 -8
  99. package/src/unifier/statementWithCombinator.js +33 -11
  100. package/src/unifier/termWithConstructor.js +17 -4
  101. package/src/unify/frameWithMetaType.js +1 -1
  102. package/src/utilities/name.js +9 -1
  103. package/src/utilities/node.js +14 -14
  104. package/src/utilities/tokens.js +4 -4
  105. package/src/utilities/unify.js +2 -2
  106. package/src/variable.js +158 -22
  107. package/src/verifier/statementAsCombinator.js +1 -1
  108. package/src/verifier/termAsConstructor.js +1 -1
  109. package/src/verifier/topLevel.js +9 -6
  110. package/src/verify/assertion/type.js +1 -1
  111. package/src/verify/conjecture.js +1 -1
  112. package/src/verify/frame.js +1 -7
  113. package/src/verify/lemma.js +1 -1
  114. package/src/verify/metaLemma.js +1 -1
  115. package/src/verify/metatheorem.js +1 -1
  116. package/src/verify/metavariableGivenMetaType.js +2 -2
  117. package/src/verify/theorem.js +1 -1
  118. package/lib/tokens/constructorTerm/bracketed.js +0 -17
  119. package/lib/unify/termWithBracketedConstructor.js +0 -39
  120. package/lib/unify/termWithConstructor.js +0 -37
  121. package/lib/unify/termWithConstructors.js +0 -34
  122. package/lib/unify/termWithTerm.js +0 -27
  123. package/lib/unify/termWithType.js +0 -24
  124. package/lib/verify/axiom.js +0 -45
  125. package/lib/verify/consequent.js +0 -38
  126. package/lib/verify/declaration/variable.js +0 -67
  127. package/lib/verify/equality.js +0 -92
  128. package/lib/verify/proofStep.js +0 -28
  129. package/lib/verify/term.js +0 -97
  130. package/lib/verify/termAsConstructor.js +0 -58
  131. package/lib/verify/termGivenType.js +0 -34
  132. package/lib/verify/terms.js +0 -38
  133. package/lib/verify/type.js +0 -23
  134. package/lib/verify/variable.js +0 -25
  135. package/src/tokens/constructorTerm/bracketed.js +0 -10
  136. package/src/unify/termWithBracketedConstructor.js +0 -39
  137. package/src/unify/termWithConstructor.js +0 -39
  138. package/src/unify/termWithConstructors.js +0 -27
  139. package/src/unify/termWithTerm.js +0 -24
  140. package/src/unify/termWithType.js +0 -14
  141. package/src/verify/axiom.js +0 -56
  142. package/src/verify/consequent.js +0 -40
  143. package/src/verify/declaration/variable.js +0 -85
  144. package/src/verify/equality.js +0 -118
  145. package/src/verify/proofStep.js +0 -21
  146. package/src/verify/term.js +0 -123
  147. package/src/verify/termAsConstructor.js +0 -66
  148. package/src/verify/termGivenType.js +0 -32
  149. package/src/verify/terms.js +0 -38
  150. package/src/verify/type.js +0 -19
  151. package/src/verify/variable.js +0 -21
@@ -1,17 +1,23 @@
1
1
  "use strict";
2
2
 
3
+ import Label from "./label";
4
+ import Consequent from "./consequent";
5
+ import Supposition from "./supposition";
3
6
  import Substitutions from "./substitutions";
4
- import resolveSubstitutions from "./resolve/substitutions";
5
- import unifyConsequentWithStatement from "./unify/consequentWithStatement";
6
- import unifySuppositionsWithProofSteps from "./unify/suppositionsWithProofSteps";
7
+
8
+ import { reverse, correlate } from "./utilities/array";
7
9
 
8
10
  export default class TopLevelAssertion {
9
- constructor(labels, suppositions, consequent, substitutions, fileContext) {
11
+ constructor(fileContext, labels, suppositions, consequent, proof) {
12
+ this.fileContext = fileContext;
10
13
  this.labels = labels;
11
14
  this.suppositions = suppositions;
12
15
  this.consequent = consequent;
13
- this.substitutions = substitutions;
14
- this.fileContext = fileContext;
16
+ this.proof = proof;
17
+ }
18
+
19
+ getFileContext() {
20
+ return this.fileContext;
15
21
  }
16
22
 
17
23
  getLabels() {
@@ -26,50 +32,131 @@ export default class TopLevelAssertion {
26
32
  return this.consequent;
27
33
  }
28
34
 
29
- getSubstitutions() {
30
- return this.substitutions;
35
+ getProof() {
36
+ return this.proof;
31
37
  }
32
38
 
33
- getFileContext() {
34
- return this.fileContext;
35
- }
39
+ matchMetavariableNode(metavariableNode) {
40
+ const metavariableNodeMatches = this.labels.some((label) => {
41
+ const metavariableNodeMatches = label.matchMetavariableNode(metavariableNode);
36
42
 
37
- unifyStatement(statementNode, localContext) {
38
- let statementUnified = false;
43
+ if (metavariableNodeMatches) {
44
+ return true;
45
+ }
46
+ });
39
47
 
40
- const substitutions = Substitutions.fromNothing(),
41
- proofSteps = localContext.getProofSteps(),
42
- proofStepsB = proofSteps, ///
43
- fileContextA = this.fileContext, ///
44
- suppositionsA = this.suppositions, ///
45
- localContextB = localContext, ///
46
- suppositionsUnified = unifySuppositionsWithProofSteps(suppositionsA, proofStepsB, substitutions, fileContextA, localContextB);
48
+ return metavariableNodeMatches;
49
+ }
47
50
 
48
- if (suppositionsUnified) {
49
- const consequentA = this.consequent, ///
50
- consequentUnified = unifyConsequentWithStatement(consequentA, statementNode, substitutions, fileContextA, localContext);
51
+ unifyStatement(statement, localContext) {
52
+ let statementUnified = false;
51
53
 
52
- if (consequentUnified) {
53
- const substitutionsResolved = resolveSubstitutions(substitutions, fileContextA, localContextB);
54
+ const proofSteps = localContext.getProofSteps(),
55
+ substitutions = Substitutions.fromNothing(),
56
+ proofStepsUnified = this.unifyProofSteps(proofSteps, substitutions, localContext);
54
57
 
55
- statementUnified = substitutionsResolved; ///
56
- }
58
+ if (proofStepsUnified) {
59
+ statementUnified = this.consequent.unifyStatement(statement, substitutions, localContext);
57
60
  }
58
61
 
59
62
  return statementUnified;
60
63
  }
61
64
 
62
- matchMetavariableNode(metavariableNode) {
63
- const metavariableNodeMatches = this.labels.some((label) => {
64
- const metavariableNodeMatches = label.matchMetavariableNode(metavariableNode);
65
+ unifyProofSteps(proofSteps, substitutions, localContext) {
66
+ let proofStepsUnified;
65
67
 
66
- if (metavariableNodeMatches) {
68
+ let suppositions = this.suppositions;
69
+
70
+ suppositions = reverse(suppositions); ///
71
+
72
+ proofSteps = reverse(proofSteps); ///
73
+
74
+ proofStepsUnified = correlate(suppositions, proofSteps, (supposition, proofStep) => {
75
+ const proofStepUnified = supposition.unifyProofStep(proofStep, substitutions, localContext);
76
+
77
+ if (proofStepUnified) {
67
78
  return true;
68
79
  }
69
80
  });
70
81
 
71
- return metavariableNodeMatches;
82
+ return proofStepsUnified;
72
83
  }
73
84
 
74
- static fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(Class, labels, suppositions, consequent, substitutions, fileContext) { return new Class(labels, suppositions, consequent, substitutions, fileContext); }
85
+ toJSON() {
86
+ const labelsJSON = this.labels.map((label) => {
87
+ const labelJSON = label.toJSON();
88
+
89
+ return labelJSON;
90
+ }),
91
+ suppositionsJSON = this.suppositions.map((supposition) => {
92
+ const suppositionJSON = supposition.toJSON();
93
+
94
+ return suppositionJSON;
95
+ }),
96
+ consequentJSON = this.consequent.toJSON(),
97
+ labels = labelsJSON, ///
98
+ suppositions = suppositionsJSON, ///
99
+ consequent = consequentJSON, ///
100
+ json = {
101
+ labels,
102
+ suppositions,
103
+ consequent
104
+ };
105
+
106
+ return json;
107
+ }
108
+
109
+ static fromJSON(Class, json, fileContext) {
110
+ let rule;
111
+
112
+ let { labels } = json;
113
+
114
+ const labelsJSON = labels; ///
115
+
116
+ labels = labelsJSON.map((labelJSON) => {
117
+ const json = labelJSON, ///
118
+ label = Label.fromJSON(json, fileContext);
119
+
120
+ return label;
121
+ });
122
+
123
+ let { suppositions } = json;
124
+
125
+ const suppositionsJSON = suppositions; ///
126
+
127
+ suppositions = suppositionsJSON.map((suppositionJSON) => {
128
+ const json = suppositionJSON, ///
129
+ supposition = Supposition.fromJSON(json, fileContext);
130
+
131
+ return supposition;
132
+ });
133
+
134
+ let { consequent } = json;
135
+
136
+ const consequentJSON = consequent; ///
137
+
138
+ json = consequentJSON; ///
139
+
140
+ consequent = Consequent.fromJSON(json, fileContext);
141
+
142
+ const proof = null;
143
+
144
+ rule = new Class(fileContext, labels, suppositions, consequent, proof);
145
+
146
+ return rule;
147
+ }
75
148
  }
149
+
150
+ export function labelsStringFromLabels(labels) {
151
+ const labelsString = labels.reduce((labelsString, label) => {
152
+ const labelString = label.getString();
153
+
154
+ labelsString = (labelsString === null) ?
155
+ labelString: ///
156
+ `${labelString}, ${labelString}`;
157
+
158
+ return labelsString;
159
+ }, null);
160
+
161
+ return labelsString;
162
+ }
package/src/type.js CHANGED
@@ -74,7 +74,7 @@ class Type {
74
74
  const equalTo = this.isEqualTo(type),
75
75
  subTypeOf = this.isSubTypeOf(type),
76
76
  superTypeOf = this.isSuperTypeOf(type),
77
- comparableTo = equalTo || subTypeOf || superTypeOf;
77
+ comparableTo = (equalTo || subTypeOf || superTypeOf);
78
78
 
79
79
  return comparableTo;
80
80
  }
@@ -82,7 +82,7 @@ class Type {
82
82
  isEqualToOrSubTypeOf(type) {
83
83
  const equalTo = this.isEqualTo(type),
84
84
  subTypeOf = this.isSubTypeOf(type),
85
- equalToOrSubTypeOf = equalTo || subTypeOf;
85
+ equalToOrSubTypeOf = (equalTo || subTypeOf);
86
86
 
87
87
  return equalToOrSubTypeOf;
88
88
  }
@@ -90,7 +90,7 @@ class Type {
90
90
  isEqualToOrSuperTypeOf(type) {
91
91
  const equalTo = this.isEqualTo(type),
92
92
  superTypeOf = this.isSuperTypeOf(type),
93
- equalToOrSuperTypeOf = equalTo || superTypeOf;
93
+ equalToOrSuperTypeOf = (equalTo || superTypeOf);
94
94
 
95
95
  return equalToOrSuperTypeOf;
96
96
  }
@@ -124,37 +124,31 @@ class Type {
124
124
  verify(fileContext) {
125
125
  let verified = false;
126
126
 
127
- const nameObjectTypeName = (this.name === OBJECT_TYPE_NAME);
128
-
129
- if (nameObjectTypeName) {
130
- verified = true;
131
- } else {
132
- const typeString = this.string; ///
127
+ const typeString = this.string; ///
133
128
 
134
- fileContext.trace(`Verifying the '${typeString}' type...`);
129
+ fileContext.trace(`Verifying the '${typeString}' type...`);
135
130
 
136
- const typePresent = fileContext.isTypePresentByTypeName(this.name);
131
+ const typePresent = fileContext.isTypePresentByTypeName(this.name);
137
132
 
138
- if (typePresent) {
139
- verified = true;
140
- } else {
141
- fileContext.debug(`The type '${typeString}' is not present.`);
142
- }
133
+ if (typePresent) {
134
+ verified = true;
135
+ } else {
136
+ fileContext.debug(`The type '${typeString}' is not present.`);
137
+ }
143
138
 
144
- if (verified) {
145
- fileContext.debug(`...verified the '${typeString}' type.`);
146
- }
139
+ if (verified) {
140
+ fileContext.debug(`...verified the '${typeString}' type.`);
147
141
  }
148
142
 
149
143
  return verified;
150
144
  }
151
145
 
152
- verifyWhenDeclared(fileContext) {
153
- let verifiedWhenDeclared = false;
146
+ verifyAtTopLevel(fileContext) {
147
+ let verifiedAtTopLevel = false;
154
148
 
155
149
  const typeString = this.string; ///
156
150
 
157
- fileContext.trace(`Verifying the '${typeString}' type when declared...`);
151
+ fileContext.trace(`Verifying the '${typeString}' type at top level...`);
158
152
 
159
153
  const typePresent = fileContext.isTypePresentByTypeName(this.name);
160
154
 
@@ -162,13 +156,13 @@ class Type {
162
156
  fileContext.debug(`The type '${typeString}' is already present.`);
163
157
  } else {
164
158
  if (this.superType === null) {
165
- verifiedWhenDeclared = true;
159
+ verifiedAtTopLevel = true;
166
160
  } else {
167
161
  const name = this.superType.getName(),
168
- superTypePresent = fileContext.isTypePresentByTypeName(name);
162
+ superTypePresent = fileContext.isTypePresentByTypeName(name);
169
163
 
170
164
  if (superTypePresent) {
171
- verifiedWhenDeclared = true;
165
+ verifiedAtTopLevel = true;
172
166
  } else {
173
167
  const superTypeString = this.superType.getString();
174
168
 
@@ -177,11 +171,11 @@ class Type {
177
171
  }
178
172
  }
179
173
 
180
- if (verifiedWhenDeclared) {
181
- fileContext.debug(`...verifiedWhenDeclared the '${typeString}' type when declared.`);
174
+ if (verifiedAtTopLevel) {
175
+ fileContext.debug(`...verified the '${typeString}' type at top level.`);
182
176
  }
183
177
 
184
- return verifiedWhenDeclared;
178
+ return verifiedAtTopLevel;
185
179
  }
186
180
 
187
181
  toJSON() {
@@ -213,22 +207,23 @@ class Type {
213
207
 
214
208
  const typeName = name, ///
215
209
  string = stringFromTypeNameAndSuperType(typeName, superType),
216
- type = new Type(string, name, superType);
210
+ typeNameObjectTypeName = (typeName === OBJECT_TYPE_NAME),
211
+ type = typeNameObjectTypeName ?
212
+ objectType :
213
+ new Type(string, name, superType);
217
214
 
218
215
  return type;
219
216
  }
220
217
 
221
218
  static fromTypeNode(typeNode) {
222
- let type = null;
223
-
224
- if (typeNode !== null) {
225
- const typeName = typeNameFromTypeNode(typeNode),
226
- name = typeName, ///
227
- string = name, ///
228
- superType = null;
229
-
230
- type = new Type(string, name, superType);
231
- }
219
+ const typeName = typeNameFromTypeNode(typeNode),
220
+ name = typeName, ///
221
+ string = name, ///
222
+ superType = null,
223
+ typeNameObjectTypeName = (typeName === OBJECT_TYPE_NAME),
224
+ type = typeNameObjectTypeName ?
225
+ objectType :
226
+ new Type(string, name, superType);
232
227
 
233
228
  return type;
234
229
  }
@@ -237,7 +232,9 @@ class Type {
237
232
  const typeNode = typeNodeQuery(typeDeclarationNode),
238
233
  superTypeNode = superTypeNodeQuery(typeDeclarationNode),
239
234
  typeName = typeNameFromTypeNode(typeNode),
240
- superType = Type.fromTypeNode(superTypeNode),
235
+ superType = (superTypeNode === null) ?
236
+ objectType :
237
+ Type.fromTypeNode(superTypeNode),
241
238
  string = stringFromTypeNameAndSuperType(typeName, superType),
242
239
  name = typeName, ///
243
240
  type = new Type(string, name, superType);
@@ -268,8 +265,9 @@ export default Type;
268
265
  class ObjectType extends Type {
269
266
  static fromNothing() {
270
267
  const name = OBJECT_TYPE_NAME,
268
+ string = name, //
271
269
  superType = null,
272
- objectType = new ObjectType(name, superType);
270
+ objectType = new ObjectType(string, name, superType);
273
271
 
274
272
  return objectType;
275
273
  }
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  import Unifier from "../unifier";
4
- import unifyTermWithTerm from "../unify/termWithTerm";
5
4
 
6
5
  import { nodeQuery } from "../utilities/query";
6
+ import { findEquivalenceByTermNodes } from "../utilities/equivalences";
7
7
 
8
8
  const termNodeQuery = nodeQuery("/term!");
9
9
 
@@ -28,9 +28,21 @@ class EqualityUnifier extends Unifier {
28
28
  let termUnifiedWithTerm;
29
29
 
30
30
  const leftTermNode = termNodeA, ///
31
- rightTermNode = termNodeB; ///
31
+ rightTermNode = termNodeB, ///
32
+ leftTermNodeMatchesRightTermNode = leftTermNode.match(rightTermNode);
32
33
 
33
- termUnifiedWithTerm = unifyTermWithTerm(leftTermNode, rightTermNode, localContext);
34
+ if (leftTermNodeMatchesRightTermNode) {
35
+ termUnifiedWithTerm = true;
36
+ } else {
37
+ const equivalences = localContext.getEquivalences(),
38
+ termNodes = [
39
+ leftTermNode,
40
+ rightTermNode
41
+ ],
42
+ equivalence = findEquivalenceByTermNodes(equivalences, termNodes);
43
+
44
+ termUnifiedWithTerm = (equivalence !== null);
45
+ }
34
46
 
35
47
  if (!termUnifiedWithTerm) {
36
48
  const nonTerminalNodeA = termNodeA, ///
@@ -38,8 +38,4 @@ class IntrinsicLevelUnifier extends Unifier {
38
38
 
39
39
  const intrinsicLevelUnifier = new IntrinsicLevelUnifier();
40
40
 
41
- Object.assign(shim, {
42
- intrinsicLevelUnifier
43
- });
44
-
45
41
  export default intrinsicLevelUnifier;
@@ -91,10 +91,6 @@ class MetaLevelUnifier extends Unifier {
91
91
 
92
92
  const metaLevelUnifier = new MetaLevelUnifier();
93
93
 
94
- Object.assign(shim, {
95
- metaLevelUnifier
96
- });
97
-
98
94
  export default metaLevelUnifier;
99
95
 
100
96
  function unifyStatementWithStatement(statementNodeA, statementNodeB, substitutions, localContextA, localContextB) {
@@ -4,7 +4,6 @@ import shim from "../shim";
4
4
  import Unifier from "../unifier";
5
5
 
6
6
  import { nodeQuery } from "../utilities/query";
7
- import unifyTermWithType from "../unify/termWithType";
8
7
 
9
8
  const typeNodeQuery = nodeQuery("/type!"),
10
9
  termNodeQuery = nodeQuery("/term!");
@@ -27,11 +26,24 @@ class MetavariableUnifier extends Unifier {
27
26
  nodeQueryA: termNodeQuery,
28
27
  nodeQueryB: typeNodeQuery,
29
28
  unify: (termNodeA, typeNodeB, localContext) => {
30
- const termNode = termNodeA, ///
29
+ let unified = false;
30
+
31
+ const { Term, Type } = shim,
31
32
  typeNode = typeNodeB, ///
32
- termUnifiedWithType = unifyTermWithType(termNode, typeNode, localContext);
33
+ type = Type.fromTypeNode(typeNode, localContext),
34
+ typeVerified = type.verify(localContext);
35
+
36
+ if (typeVerified) {
37
+ const termNode = termNodeA, ///
38
+ term = Term.fromTermNode(termNode, localContext),
39
+ termVerifiedGivenType = term.verifyGivenType(type, localContext);
33
40
 
34
- return termUnifiedWithType;
41
+ if (termVerifiedGivenType) {
42
+ unified = true;
43
+ }
44
+ }
45
+
46
+ return unified;
35
47
  }
36
48
  }
37
49
  ];
@@ -39,8 +51,4 @@ class MetavariableUnifier extends Unifier {
39
51
 
40
52
  const metavariableUnifier = new MetavariableUnifier();
41
53
 
42
- Object.assign(shim, {
43
- metavariableUnifier
44
- });
45
-
46
54
  export default metavariableUnifier;
@@ -2,8 +2,6 @@
2
2
 
3
3
  import shim from "../shim";
4
4
  import Unifier from "../unifier";
5
- import unifyTermWithType from "../unify/termWithType";
6
- import unifyFrameWithMetaType from "../unify/frameWithMetaType";
7
5
 
8
6
  import { nodeQuery } from "../utilities/query";
9
7
 
@@ -31,36 +29,60 @@ class StatementWithCombinatorUnifier extends Unifier {
31
29
  nodeQueryA: statementNodeQuery,
32
30
  nodeQueryB: metaTypeNodeQuery,
33
31
  unify: (statementNodeA, metaTypeNodeB, assignments, stated, localContext) => {
34
- const { MetaType, Statement } = shim,
32
+ let unified;
33
+
34
+ const { Statement, MetaType } = shim,
35
35
  metaTypeNode = metaTypeNodeB, ///
36
36
  statementNode = statementNodeA, ///
37
37
  metaType = MetaType.fromMetaTypeNode(metaTypeNode, localContext),
38
38
  statement = Statement.fromStatementNode(statementNode, localContext),
39
- statementUnifiedWithMetaType = statement.unifyWithMetaType(metaType, assignments, stated, localContext);
39
+ statementVerifiedGivenType = statement.verifyGivenMetaType(metaType, assignments, stated, localContext);
40
+
41
+ unified = statementVerifiedGivenType;
40
42
 
41
- return statementUnifiedWithMetaType;
43
+ return unified;
42
44
  }
43
45
  },
44
46
  {
45
47
  nodeQueryA: frameNodeQuery,
46
48
  nodeQueryB: metaTypeNodeQuery,
47
49
  unify: (frameNodeA, metaTypeNodeB, assignments, stated, localContext) => {
48
- const metaTypeNode = metaTypeNodeB, ///
50
+ let unified;
51
+
52
+ const { Frame, MetaType } = shim,
53
+ metaTypeNode = metaTypeNodeB, ///
49
54
  frameNode = frameNodeA, ///
50
- frameUnifiedWithMetaType = unifyFrameWithMetaType(frameNode, metaTypeNode, assignments, stated, localContext);
55
+ metaType = MetaType.fromMetaTypeNode(metaTypeNode, localContext),
56
+ frame = Frame.fromTermNode(frameNode, localContext),
57
+ frameVerifiedGivenType = frame.verifyGivenMetaType(metaType, localContext);
51
58
 
52
- return frameUnifiedWithMetaType;
59
+ unified = frameVerifiedGivenType;
60
+
61
+ return unified;
53
62
  }
54
63
  },
55
64
  {
56
65
  nodeQueryA: termNodeQuery,
57
66
  nodeQueryB: typeNodeQuery,
58
67
  unify: (termNodeA, typeNodeB, assignments, stated, localContext) => {
59
- const termNode = termNodeA, ///
68
+ let unified = false;
69
+
70
+ const { Term, Type } = shim,
60
71
  typeNode = typeNodeB, ///
61
- termUnifiedWithType = unifyTermWithType(termNode, typeNode, localContext);
72
+ type = Type.fromTypeNode(typeNode, localContext),
73
+ typeVerified = type.verify(localContext);
74
+
75
+ if (typeVerified) {
76
+ const termNode = termNodeA, ///
77
+ term = Term.fromTermNode(termNode, localContext),
78
+ termVerifiedGivenType = term.verifyGivenType(type, localContext);
79
+
80
+ if (termVerifiedGivenType) {
81
+ unified = true;
82
+ }
83
+ }
62
84
 
63
- return termUnifiedWithType;
85
+ return unified;
64
86
  }
65
87
  }
66
88
  ];
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ import shim from "../shim";
3
4
  import Unifier from "../unifier";
4
- import unifyTermWithType from "../unify/termWithType";
5
5
 
6
6
  import { nodeQuery } from "../utilities/query";
7
7
 
@@ -26,11 +26,24 @@ class TermWithConstructorUnifier extends Unifier {
26
26
  nodeQueryA: termNodeQuery,
27
27
  nodeQueryB: typeNodeQuery,
28
28
  unify: (termNodeA, typeNodeB, localContext) => {
29
- const termNode = termNodeA, ///
29
+ let unified = false;
30
+
31
+ const { Term, Type } = shim,
30
32
  typeNode = typeNodeB, ///
31
- termUnifiedWithType = unifyTermWithType(termNode, typeNode, localContext);
33
+ type = Type.fromTypeNode(typeNode, localContext),
34
+ typeVerified = type.verify(localContext);
35
+
36
+ if (typeVerified) {
37
+ const termNode = termNodeA, ///
38
+ term = Term.fromTermNode(termNode, localContext),
39
+ termVerifiedGivenType = term.verifyGivenType(type, localContext);
40
+
41
+ if (termVerifiedGivenType) {
42
+ unified = true;
43
+ }
44
+ }
32
45
 
33
- return termUnifiedWithType;
46
+ return unified;
34
47
  }
35
48
  }
36
49
  ];
@@ -5,7 +5,7 @@ import verifyFrameGivenMetaType from "../verify/frameGivenMetaType";
5
5
  export default function unifyFrameWithMetaType(frameNode, metaTypeNode, assignments, stated, localContext) {
6
6
  let frameUnifiedWithMetaType;
7
7
 
8
- const metaType = localContext.findMetaTypeByMetaTypeNode(metaTypeNode),
8
+ const metaType = localContext.findMetaTypeByMetaTypeName(metaTypeNode),
9
9
  frameVerifiedGivenMetaType = verifyFrameGivenMetaType(frameNode, metaType, assignments, stated, localContext);
10
10
 
11
11
  frameUnifiedWithMetaType = frameVerifiedGivenMetaType; ///
@@ -3,7 +3,7 @@
3
3
  import { nodeQuery } from "../utilities/query";
4
4
 
5
5
  const typeTerminalNodeQuery = nodeQuery("/type/@type"),
6
- nameTerminalNodeQuery = nodeQuery("/metavariable/@name"),
6
+ nameTerminalNodeQuery = nodeQuery("/variable|metavariable/@name"),
7
7
  metaTypeTerminalNodeQuery = nodeQuery("/metaType/@meta-type");
8
8
 
9
9
  export function typeNameFromTypeNode(typeNode) {
@@ -14,6 +14,14 @@ export function typeNameFromTypeNode(typeNode) {
14
14
  return typeName;
15
15
  }
16
16
 
17
+ export function variableNameFromVariableNode(variableNode) {
18
+ const nameTerminalNode = nameTerminalNodeQuery(variableNode),
19
+ nameTerminalNodeContent = nameTerminalNode.getContent(),
20
+ variableName = nameTerminalNodeContent; ///
21
+
22
+ return variableName;
23
+ }
24
+
17
25
  export function metaTypeNameFromMetaTypeNode(metaTypeNode) {
18
26
  const metaTypeTerminalNode = metaTypeTerminalNodeQuery(metaTypeNode),
19
27
  metaTypeTerminalNodeContent = metaTypeTerminalNode.getContent(),
@@ -4,11 +4,12 @@ import { parsersUtilities } from "occam-custom-grammars";
4
4
 
5
5
  import { nodeQuery } from "../utilities/query";
6
6
  import { combinedCustomGrammarFromNothing } from "./customGrammar";
7
- import { TERM_RULE_NAME,
7
+ import { VARIABLE_RULE_NAME,
8
8
  METAVARIABLE_RULE_NAME,
9
9
  UNQUALIFIED_STATEMENT_RULE_NAME,
10
10
  CONSTRUCTOR_DECLARATION_RULE_NAME } from "../ruleNames";
11
- import { metavariableTokensFromMetavariableString,
11
+ import { variableTokensFromVariableString,
12
+ metavariableTokensFromMetavariableString,
12
13
  unqualifiedStatementTokensFromUnqualifiedStatementString,
13
14
  constructorDeclarationTokensFromConstructorDeclarationString } from "../utilities/tokens";
14
15
 
@@ -30,6 +31,13 @@ export function termNodeFromTermString(termString, lexer, parser) {
30
31
  return termNode;
31
32
  }
32
33
 
34
+ export function variableNodeFromVariableString(variableString, lexer, parser) {
35
+ const variableTokens = variableTokensFromVariableString(variableString, lexer),
36
+ variableNode = variableNodeFromVariableTokens(variableTokens, parser);
37
+
38
+ return variableNode;
39
+ }
40
+
33
41
  export function statementNodeFromStatementString(statementString, lexer, parser) {
34
42
  const unqualifiedStatementString = `${statementString}
35
43
  `,
@@ -47,19 +55,11 @@ export function metavariableNodeFromMetavariableString(metavariableString, lexer
47
55
  return metavariableNode;
48
56
  }
49
57
 
50
- export function unqualifiedStatementNodeFromUnqualifiedStatementString(unqualifiedStatementString, lexer, parser) {
51
- const unqualifiedStatementTokens = unqualifiedStatementTokensFromUnqualifiedStatementString(unqualifiedStatementString, lexer),
52
- unqualifiedStatementNode = unqualifiedStatementNodeFromUnqualifiedStatementTokens(unqualifiedStatementTokens, parser);
53
-
54
- return unqualifiedStatementNode;
55
- }
56
-
57
- export function termNodeFromTermTokens(termTokens, parser) {
58
- const tokens = termTokens, ///
59
- ruleName = TERM_RULE_NAME,
60
- termNode = nodeFromTokensRuleNameAndParser(tokens, ruleName, parser);
58
+ export function variableNodeFromVariableTokens(variableTokens, parser) {
59
+ const ruleName = VARIABLE_RULE_NAME,
60
+ variableNode = nodeFromTokensRuleNameAndParser(variableTokens, ruleName, parser);
61
61
 
62
- return termNode;
62
+ return variableNode;
63
63
  }
64
64
 
65
65
  export function metavariableNodeFromMetavariableTokens(metavariableTokens, parser) {
@@ -9,11 +9,11 @@ const { nominalLexerFromCombinedCustomGrammar } = lexersUtilities;
9
9
  const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
10
10
  nominalLexer = nominalLexerFromCombinedCustomGrammar(combinedCustomGrammar);
11
11
 
12
- export function termTokensFromTermString(termString, lexer) {
13
- const content = termString, ///
14
- termTokens = tokensFromContentAndLexer(content, lexer);
12
+ export function variableTokensFromVariableString(variableString, lexer) {
13
+ const variableContent = `${variableString}`,
14
+ variableTokens = tokensFromContentAndLexer(variableContent, lexer);
15
15
 
16
- return termTokens;
16
+ return variableTokens;
17
17
  }
18
18
 
19
19
  export function metavariableTokensFromMetavariableString(metavariableString, lexer) {