occam-verify-cli 0.0.678 → 0.0.680

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 (141) hide show
  1. package/bin/action/verify.js +13 -3
  2. package/lib/axiomLemmaTheoremConjecture.js +3 -3
  3. package/lib/conclusion.js +16 -5
  4. package/lib/consequent.js +11 -3
  5. package/lib/context/file.js +73 -3
  6. package/lib/context/release.js +7 -2
  7. package/lib/equality.js +13 -199
  8. package/lib/premise.js +24 -7
  9. package/lib/supposition.js +15 -4
  10. package/lib/type.js +3 -8
  11. package/lib/utilities/array.js +5 -2
  12. package/lib/utilities/string.js +26 -13
  13. package/lib/verifier/node/metastatement.js +176 -0
  14. package/lib/verifier/node/statementAsCombinator.js +186 -0
  15. package/lib/verifier/node/termAsConstructor.js +224 -0
  16. package/lib/verifier/node.js +158 -0
  17. package/lib/verifier/nodes/equality.js +155 -0
  18. package/lib/verifier/{metastatementForMetavariable → nodes/metastatementForMetavariable}/conclusion.js +13 -12
  19. package/lib/verifier/{metastatementForMetavariable → nodes/metastatementForMetavariable}/premise.js +13 -12
  20. package/lib/verifier/nodes/metastatementForMetavariable.js +198 -0
  21. package/lib/verifier/nodes/statement.js +200 -0
  22. package/lib/verifier/{statementForMetavariable → nodes/statementForMetavariable}/conclusion.js +13 -12
  23. package/lib/verifier/{statementForMetavariable → nodes/statementForMetavariable}/premise.js +13 -12
  24. package/lib/verifier/nodes/statementForMetavariable.js +203 -0
  25. package/lib/verifier/nodes/term.js +210 -0
  26. package/lib/verifier/{termForVariable/supposition.js → nodes/termForVariable/consequent.js} +13 -12
  27. package/lib/verifier/{termForVariable/consequent.js → nodes/termForVariable/supposition.js} +13 -12
  28. package/lib/verifier/nodes/termForVariable.js +217 -0
  29. package/lib/verifier/nodes.js +175 -0
  30. package/lib/verify/axiom.js +3 -3
  31. package/lib/verify/conclusion.js +3 -3
  32. package/lib/verify/conjecture.js +3 -3
  33. package/lib/verify/consequent.js +3 -3
  34. package/lib/verify/declaration/combinator.js +7 -2
  35. package/lib/verify/declaration/constructor.js +8 -2
  36. package/lib/verify/declaration/metavariable.js +7 -2
  37. package/lib/verify/declaration/type.js +7 -2
  38. package/lib/verify/declaration/variable.js +8 -2
  39. package/lib/verify/file.js +3 -3
  40. package/lib/verify/label.js +9 -4
  41. package/lib/verify/lemma.js +3 -3
  42. package/lib/verify/metastatement/qualified.js +5 -6
  43. package/lib/verify/metastatement/unqualified.js +9 -7
  44. package/lib/verify/metastatement.js +36 -156
  45. package/lib/verify/metavariable.js +6 -4
  46. package/lib/verify/premise.js +3 -3
  47. package/lib/verify/release.js +3 -3
  48. package/lib/verify/rule.js +3 -3
  49. package/lib/verify/statement/qualified.js +5 -6
  50. package/lib/verify/statement/unqualified.js +9 -7
  51. package/lib/verify/statement.js +86 -332
  52. package/lib/verify/statementAsCombinator.js +8 -82
  53. package/lib/verify/supposition.js +3 -3
  54. package/lib/verify/term.js +79 -215
  55. package/lib/verify/termAsConstructor.js +15 -89
  56. package/lib/verify/terms.js +45 -0
  57. package/lib/verify/theorem.js +3 -3
  58. package/lib/verify/type.js +7 -5
  59. package/lib/verify/typeAssertion.js +124 -0
  60. package/lib/verify/variable.js +7 -5
  61. package/package.json +5 -5
  62. package/src/axiomLemmaTheoremConjecture.js +2 -2
  63. package/src/conclusion.js +13 -4
  64. package/src/consequent.js +9 -2
  65. package/src/context/file.js +9 -2
  66. package/src/context/release.js +9 -2
  67. package/src/equality.js +17 -143
  68. package/src/premise.js +23 -6
  69. package/src/supposition.js +12 -3
  70. package/src/type.js +3 -8
  71. package/src/utilities/array.js +1 -1
  72. package/src/utilities/string.js +34 -23
  73. package/src/verifier/node/metastatement.js +61 -0
  74. package/src/verifier/node/statementAsCombinator.js +80 -0
  75. package/src/verifier/node/termAsConstructor.js +124 -0
  76. package/src/verifier/node.js +85 -0
  77. package/src/verifier/nodes/equality.js +68 -0
  78. package/src/verifier/nodes/metastatementForMetavariable/conclusion.js +11 -0
  79. package/src/verifier/nodes/metastatementForMetavariable/premise.js +11 -0
  80. package/src/verifier/{metastatementForMetavariable.js → nodes/metastatementForMetavariable.js} +13 -13
  81. package/src/verifier/nodes/statement.js +100 -0
  82. package/src/verifier/nodes/statementForMetavariable/conclusion.js +11 -0
  83. package/src/verifier/nodes/statementForMetavariable/premise.js +11 -0
  84. package/src/verifier/{statementForMetavariable.js → nodes/statementForMetavariable.js} +10 -10
  85. package/src/verifier/nodes/term.js +106 -0
  86. package/src/verifier/nodes/termForVariable/consequent.js +11 -0
  87. package/src/verifier/nodes/termForVariable/supposition.js +11 -0
  88. package/src/verifier/{termForVariable.js → nodes/termForVariable.js} +42 -30
  89. package/src/verifier/nodes.js +111 -0
  90. package/src/verify/axiom.js +2 -2
  91. package/src/verify/conclusion.js +2 -2
  92. package/src/verify/conjecture.js +2 -2
  93. package/src/verify/consequent.js +2 -2
  94. package/src/verify/declaration/combinator.js +9 -1
  95. package/src/verify/declaration/constructor.js +15 -1
  96. package/src/verify/declaration/metavariable.js +9 -1
  97. package/src/verify/declaration/type.js +14 -1
  98. package/src/verify/declaration/variable.js +15 -1
  99. package/src/verify/file.js +2 -2
  100. package/src/verify/label.js +10 -2
  101. package/src/verify/lemma.js +4 -4
  102. package/src/verify/metastatement/qualified.js +4 -6
  103. package/src/verify/metastatement/unqualified.js +9 -7
  104. package/src/verify/metastatement.js +35 -56
  105. package/src/verify/metavariable.js +6 -3
  106. package/src/verify/premise.js +2 -2
  107. package/src/verify/release.js +2 -2
  108. package/src/verify/rule.js +2 -2
  109. package/src/verify/statement/qualified.js +4 -6
  110. package/src/verify/statement/unqualified.js +9 -7
  111. package/src/verify/statement.js +109 -302
  112. package/src/verify/statementAsCombinator.js +9 -129
  113. package/src/verify/supposition.js +2 -2
  114. package/src/verify/term.js +99 -156
  115. package/src/verify/termAsConstructor.js +20 -135
  116. package/src/verify/terms.js +54 -0
  117. package/src/verify/theorem.js +2 -2
  118. package/src/verify/type.js +7 -4
  119. package/src/verify/typeAssertion.js +164 -0
  120. package/src/verify/variable.js +7 -4
  121. package/lib/node/statement/combinator/equality.js +0 -21
  122. package/lib/ocmbinator/equality.js +0 -126
  123. package/lib/tokens/statement/combinator/equality.js +0 -17
  124. package/lib/verifier/metastatementForMetavariable.js +0 -198
  125. package/lib/verifier/statementForMetavariable.js +0 -203
  126. package/lib/verifier/termForVariable.js +0 -209
  127. package/lib/verifier.js +0 -138
  128. package/lib/verify/assertion/type.js +0 -115
  129. package/lib/verify/typeInference.js +0 -132
  130. package/src/node/statement/combinator/equality.js +0 -9
  131. package/src/ocmbinator/equality.js +0 -23
  132. package/src/tokens/statement/combinator/equality.js +0 -10
  133. package/src/verifier/metastatementForMetavariable/conclusion.js +0 -9
  134. package/src/verifier/metastatementForMetavariable/premise.js +0 -9
  135. package/src/verifier/statementForMetavariable/conclusion.js +0 -9
  136. package/src/verifier/statementForMetavariable/premise.js +0 -9
  137. package/src/verifier/termForVariable/consequent.js +0 -9
  138. package/src/verifier/termForVariable/supposition.js +0 -9
  139. package/src/verifier.js +0 -74
  140. package/src/verify/assertion/type.js +0 -153
  141. package/src/verify/typeInference.js +0 -146
@@ -1,222 +1,165 @@
1
1
  "use strict";
2
2
 
3
- import Verifier from "../verifier";
3
+ import termNodesVerifier from "../verifier/nodes/term";
4
4
 
5
5
  import { first } from "../utilities/array";
6
- import { objectType } from "../type";
7
- import { OBJECT_TYPE_NAME } from "../typeNames";
8
- import { ARGUMENT_RULE_NAME } from "../ruleNames";
9
- import { nodeQuery, typeNameFromTypeNode, variableNameFromVariableNode } from "../utilities/query";
6
+ import { nodeQuery, variableNameFromVariableNode } from "../utilities/query";
10
7
 
11
- const termNodeQuery = nodeQuery("/argument/term!"),
12
- typeNodeQuery = nodeQuery("/argument/type!"),
13
- variableNodeQuery = nodeQuery("/term/variable!");
8
+ const variableNodeQuery = nodeQuery("/term/variable!");
14
9
 
15
- class TermVerifier extends Verifier {
16
- verifyTerminalNode(terminalNode, constructorTerminalNode, context) {
17
- let terminalNodeVerified = false;
10
+ function verifyTerm(termNode, types, context, verifyAhead) {
11
+ let termVerified;
18
12
 
19
- const matches = terminalNode.match(constructorTerminalNode);
20
-
21
- if (matches) {
22
- terminalNodeVerified = true;
23
- }
24
-
25
- return terminalNodeVerified;
26
- }
27
-
28
- verifyNonTerminalNode(nonTerminalNode, constructorNonTerminalNode, context) {
29
- let nonTerminalNodeVerified = false;
30
-
31
- const ruleName = nonTerminalNode.getRuleName(), ///
32
- constructorRuleName = constructorNonTerminalNode.getRuleName(); ///
33
-
34
- if (ruleName === constructorRuleName) {
35
- switch (ruleName) {
36
- case ARGUMENT_RULE_NAME: {
37
- const argumentNode = nonTerminalNode, ///
38
- constructorArgumentNode = constructorNonTerminalNode, ///
39
- argumentNodeVerified = this.verifyArgumentNode(argumentNode, constructorArgumentNode, context);
40
-
41
- nonTerminalNodeVerified = argumentNodeVerified; ///
13
+ const termString = context.nodeAsString(termNode);
42
14
 
43
- break;
44
- }
15
+ context.trace(`Verifying the '${termString}' term...`, termNode);
45
16
 
46
- default: {
47
- const childNodes = nonTerminalNode.getChildNodes(),
48
- constructorChildNodes = constructorNonTerminalNode.getChildNodes(),
49
- nodes = childNodes, ///
50
- constructorNodes = constructorChildNodes, ///
51
- nodesVerified = this.verifyNodes(nodes, constructorNodes, context);
17
+ const verifyTermFunctions = [
18
+ verifyTermAsStandaloneVariable,
19
+ verifyTermAgainstConstructors
20
+ ];
52
21
 
53
- nonTerminalNodeVerified = nodesVerified; ///
22
+ termVerified = verifyTermFunctions.some((verifyTermFunction) => {
23
+ const termVerified = verifyTermFunction(termNode, types, context, verifyAhead);
54
24
 
55
- break;
56
- }
57
- }
25
+ if (termVerified) {
26
+ return true;
58
27
  }
28
+ });
59
29
 
60
- return nonTerminalNodeVerified;
30
+ if (termVerified) {
31
+ context.debug(`...verified the '${termString}' term.`, termNode);
61
32
  }
62
33
 
63
- verifyArgumentNode(argumentNode, constructorArgumentNode, context) {
64
- let argumentNodeVerified = false;
34
+ return termVerified;
35
+ }
65
36
 
66
- const typeNode = typeNodeQuery(argumentNode);
37
+ Object.assign(termNodesVerifier, {
38
+ verifyTerm
39
+ });
67
40
 
68
- if (typeNode !== null) {
69
- const argumentString = context.nodeAsString(argumentNode);
41
+ export default verifyTerm;
70
42
 
71
- context.error(`The '${argumentString}' argument should be a term, not a type`, argumentNode);
72
- } else {
73
- const termNode = termNodeQuery(argumentNode),
74
- constructorTermNode = termNodeQuery(constructorArgumentNode),
75
- constructorTypeNode = typeNodeQuery(constructorArgumentNode);
43
+ export function verifyTermAgainstConstructors(termNode, types, context, verifyAhead) {
44
+ let termVerifiedAgainstConstructors;
76
45
 
77
- if (false) {
78
- ///
79
- } else if (constructorTermNode !== null) {
80
- const node = termNode, ///
81
- constructorNode = constructorTermNode, ///
82
- nodeVerified = this.verifyNode(node, constructorNode, context);
46
+ const constructors = context.getConstructors();
83
47
 
84
- argumentNodeVerified = nodeVerified; ///
85
- } else if (constructorTypeNode !== null) {
86
- const types = [],
87
- termVerified = verifyTerm(termNode, types, context);
48
+ termVerifiedAgainstConstructors = constructors.some((constructor) => {
49
+ const termVerifiedAgainstConstructor = verifyTermAgainstConstructor(termNode, types, constructor, context, verifyAhead);
88
50
 
89
- if (termVerified) {
90
- const constructorTypeName = typeNameFromTypeNode(constructorTypeNode),
91
- firstType = first(types),
92
- termType = firstType, ///
93
- termTypeName = termType.getName(),
94
- constructorType = (constructorTypeName === OBJECT_TYPE_NAME) ?
95
- objectType :
96
- context.findTypeByTypeName(constructorTypeName),
97
- termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(constructorType);
51
+ if (termVerifiedAgainstConstructor) {
52
+ return true;
53
+ }
54
+ });
98
55
 
99
- if (termTypeEqualToOrSubTypeOfType) {
100
- const termString = context.nodeAsString(termNode);
56
+ return termVerifiedAgainstConstructors;
57
+ }
101
58
 
102
- context.trace(`The '${termTypeName}' type of the '${termString}' term is equal to or a sub-type of the '${constructorTypeName}' type in the constructor.`, argumentNode);
59
+ export function verifyTermAsVariable(termNode, variables, context, verifyAhead) {
60
+ let termVerifiedAsVariable = false;
103
61
 
104
- argumentNodeVerified = true;
105
- }
106
- }
107
- }
108
- }
62
+ const variableNode = variableNodeQuery(termNode);
109
63
 
110
- return argumentNodeVerified;
111
- }
112
- }
64
+ if (variableNode !== null) {
65
+ const termString = context.nodeAsString(termNode);
113
66
 
114
- export const termVerifier = new TermVerifier();
67
+ context.trace(`Verifying the '${termString}' term as a variable...`, termNode);
115
68
 
116
- export default function verifyTerm(termNode, types, context) {
117
- let termVerified = false;
69
+ const variableName = variableNameFromVariableNode(variableNode),
70
+ variablePresent = context.isVariablePresentByVariableName(variableName);
118
71
 
119
- const termString = context.nodeAsString(termNode);
72
+ if (variablePresent) {
73
+ let verifiedAhead;
120
74
 
121
- context.debug(`Verifying the '${termString}' term...`, termNode);
75
+ const variable = context.findVariableByVariableName(variableName);
122
76
 
123
- if (!termVerified) {
124
- const variables = [],
125
- termVerifiedAsVariable = verifyTermAsVariable(termNode, variables, context);
77
+ variables.push(variable);
126
78
 
127
- if (termVerifiedAsVariable) {
128
- const firstVariable = first(variables),
129
- variable = firstVariable, ///
130
- type = variable.getType();
79
+ verifiedAhead = verifyAhead();
131
80
 
132
- types.push(type);
81
+ if (!verifiedAhead) {
82
+ variables.pop();
83
+ }
133
84
 
134
- termVerified = true;
85
+ termVerifiedAsVariable = verifiedAhead; ///
135
86
  }
136
- }
137
-
138
- if (!termVerified) {
139
- const termVerifiedAgainstConstructors = verifyTermAgainstConstructors(termNode, types, context);
140
87
 
141
- if (termVerifiedAgainstConstructors) {
142
- termVerified = true;
88
+ if (termVerifiedAsVariable) {
89
+ context.debug(`...verified the '${termString}' term as a variable.`, termNode);
143
90
  }
144
91
  }
145
92
 
146
- if (termVerified) {
147
- const firstType = first(types),
148
- type = firstType, ///
149
- typeName = type.getName();
93
+ return termVerifiedAsVariable;
94
+ }
150
95
 
151
- context.debug(`Verified the '${termString}' term, which has type '${typeName}'.`, termNode);
152
- }
96
+ function verifyTermAgainstConstructor(termNode, types, constructor, context, verifyAhead) {
97
+ let termVerifiedAgainstConstructor;
153
98
 
154
- return termVerified;
155
- }
99
+ const termString = context.nodeAsString(termNode),
100
+ constructorString = constructor.getString();
156
101
 
157
- export function verifyTermAgainstConstructors(termNode, types, context) {
158
- let termVerifiedAgainstConstructors = false;
102
+ context.trace(`Verifying the '${termString}' term against the '${constructorString}' constructor...`, termNode);
159
103
 
160
- const termString = context.nodeAsString(termNode);
104
+ const constructorTermNode = constructor.getTermNode(),
105
+ nonTerminalNNdeA = termNode, ///
106
+ nonTerminalNodeB = constructorTermNode, ///
107
+ nodeVerified = termNodesVerifier.verifyNonTerminalNode(nonTerminalNNdeA, nonTerminalNodeB, context, () => {
108
+ let verifiedAhead;
109
+
110
+ const type = constructor.getType();
161
111
 
162
- context.trace(`Verifying the '${termString}' term against constructors...`, termNode);
112
+ types.push(type);
163
113
 
164
- const constructors = context.getConstructors(),
165
- constructor = constructors.find((constructor) => {
166
- const termVerifiedAgainstConstructor = verifyTermAgainstConstructor(termNode, constructor, context);
114
+ verifiedAhead = verifyAhead();
167
115
 
168
- if (termVerifiedAgainstConstructor) {
169
- return true;
116
+ if (!verifiedAhead) {
117
+ types.pop();
170
118
  }
171
- }) || null;
172
119
 
173
- if (constructor !== null) {
174
- const type = constructor.getType();
120
+ return verifiedAhead;
121
+ });
175
122
 
176
- types.push(type);
123
+ termVerifiedAgainstConstructor = nodeVerified; ///
177
124
 
178
- termVerifiedAgainstConstructors = true;
125
+ if (termVerifiedAgainstConstructor) {
126
+ context.debug(`...verified the '${termString}' term against the '${constructorString}' constructor.`, termNode);
179
127
  }
180
128
 
181
- return termVerifiedAgainstConstructors;
129
+ return termVerifiedAgainstConstructor;
182
130
  }
183
131
 
184
- export function verifyTermAgainstConstructor(termNode, constructor, context) {
185
- const termString = context.nodeAsString(termNode),
186
- constructorString = constructor.getString();
132
+ function verifyTermAsStandaloneVariable(termNode, types, context, verifyAhead) {
133
+ let termVerifiedAsStandaloneVariable;
187
134
 
188
- context.trace(`Verifying the '${termString}' term against the '${constructorString}' constructor.`, termNode);
189
-
190
- const constructorTermNode = constructor.getTermNode(),
191
- nonTerminalNNdeA = termNode, ///
192
- nonTerminalNodeB = constructorTermNode, ///
193
- nodeVerified = termVerifier.verifyNonTerminalNode(nonTerminalNNdeA, nonTerminalNodeB, context),
194
- termVerifiedAgainstConstructor = nodeVerified; ///
135
+ const termString = context.nodeAsString(termNode);
195
136
 
196
- return termVerifiedAgainstConstructor;
197
- }
137
+ context.trace(`Verifying the '${termString}' term as a standalone variable...`, termNode);
198
138
 
199
- export function verifyTermAsVariable(termNode, variables, context) {
200
- let termVerifiedAsVariable = false;
139
+ const variables = [],
140
+ termVerifiedAsVariable = verifyTermAsVariable(termNode, variables, context, () => {
141
+ let verifiedAhead;
201
142
 
202
- const termString = context.nodeAsString(termNode);
143
+ const firstVariable = first(variables),
144
+ variable = firstVariable, ///
145
+ type = variable.getType();
203
146
 
204
- context.trace(`Verifying the '${termString}' term as a variable...`, termNode);
147
+ types.push(type);
205
148
 
206
- const variableNode = variableNodeQuery(termNode);
149
+ verifiedAhead = verifyAhead();
207
150
 
208
- if (variableNode !== null) {
209
- const variableName = variableNameFromVariableNode(variableNode),
210
- variablePresent = context.isVariablePresentByVariableName(variableName);
151
+ if (!verifiedAhead) {
152
+ types.pop();
153
+ }
211
154
 
212
- if (variablePresent) {
213
- const variable = context.findVariableByVariableName(variableName);
155
+ return verifiedAhead;
156
+ });
214
157
 
215
- variables.push(variable);
158
+ termVerifiedAsStandaloneVariable = termVerifiedAsVariable; ///
216
159
 
217
- termVerifiedAsVariable = true;
218
- }
160
+ if (termVerifiedAsStandaloneVariable) {
161
+ context.debug(`...verified the '${termString}' term as a standalone variable.`, termNode);
219
162
  }
220
163
 
221
- return termVerifiedAsVariable;
164
+ return termVerifiedAsStandaloneVariable;
222
165
  }
@@ -1,27 +1,28 @@
1
1
  "use strict";
2
2
 
3
- import verifyTerm from "../verify/term";
4
3
  import Constructor from "../constructor";
4
+ import termAsConstructorNodeVerifier from "../verifier/node/termAsConstructor";
5
5
 
6
- import { first } from "../utilities/array";
7
- import { nodeQuery, typeNameFromTypeNode } from "../utilities/query";
8
- import { TERM_RULE_NAME, ARGUMENT_RULE_NAME } from "../ruleNames";
9
-
10
- const typeNodeQuery = nodeQuery("/argument/type"),
11
- termNodeQuery = nodeQuery("/argument/term");
6
+ import { typeNameFromTypeNode } from "../utilities/query";
12
7
 
13
8
  export default function verifyTermAsConstructor(termNode, typeNode, fileContext) {
14
9
  let termVerifiedAsConstructor = false;
15
10
 
16
- let type = null;
11
+ const termString = fileContext.nodeAsString(termNode);
12
+
13
+ fileContext.debug(`Verifying the '${termString}' term as a constructor...`, termNode);
17
14
 
18
- const nonTerminalNode = termNode, ///
19
- termString = fileContext.nodeAsString(termNode);
15
+ const nonTerminalNode = termNode, ///
16
+ childNodes = nonTerminalNode.getChildNodes(),
17
+ childNodesVerified = termAsConstructorNodeVerifier.verifyChildNodes(childNodes, fileContext, () => {
18
+ const verifiedAhead = true;
20
19
 
21
- const childNodes = nonTerminalNode.getChildNodes(),
22
- childNodesVerified = verifyChildNodes(childNodes, fileContext);
20
+ return verifiedAhead;
21
+ });
23
22
 
24
23
  if (childNodesVerified) {
24
+ let type = null;
25
+
25
26
  if (typeNode === null) {
26
27
  termVerifiedAsConstructor = true;
27
28
  } else {
@@ -32,137 +33,21 @@ export default function verifyTermAsConstructor(termNode, typeNode, fileContext)
32
33
  if (type !== null) {
33
34
  termVerifiedAsConstructor = true;
34
35
  } else {
35
- fileContext.error(`The '${termString}' constructor's '${typeName}' type is not present.`, termNode);
36
+ fileContext.debug(`The '${termString}' constructor's '${typeName}' type is not present.`, termNode);
36
37
  }
37
38
  }
38
- }
39
39
 
40
- if (termVerifiedAsConstructor) {
41
- const tokens = fileContext.getTokens(),
42
- constructor = Constructor.fromTermNodeTypeAndTokens(termNode, type, tokens);
40
+ if (termVerifiedAsConstructor) {
41
+ const tokens = fileContext.getTokens(),
42
+ constructor = Constructor.fromTermNodeTypeAndTokens(termNode, type, tokens);
43
43
 
44
- fileContext.addConstructor(constructor);
44
+ fileContext.addConstructor(constructor);
45
+ }
45
46
  }
46
47
 
47
48
  if (termVerifiedAsConstructor) {
48
- fileContext.info(`Verified the '${termString}' constructor.`, termNode);
49
+ fileContext.debug(`...verified the '${termString}' term as a constructor.`, termNode);
49
50
  }
50
51
 
51
52
  return termVerifiedAsConstructor;
52
53
  }
53
-
54
- function verifyNode(node, fileContext) {
55
- let nodeVerified;
56
-
57
- const nodeTerminalNode = node.isTerminalNode();
58
-
59
- if (nodeTerminalNode) {
60
- const terminalNode = node, ///
61
- terminalNodeVerified = verifyTerminalNode(terminalNode, fileContext);
62
-
63
- nodeVerified = terminalNodeVerified; ///
64
- } else {
65
- const nonTerminalNode = node, ///
66
- nonTerminalNodeVerified = verifyNonTerminalNode(nonTerminalNode, fileContext);
67
-
68
- nodeVerified = nonTerminalNodeVerified; ///
69
- }
70
-
71
- return nodeVerified;
72
- }
73
-
74
- function verifyChildNodes(childNodes, fileContext) {
75
- const childNodesVerified = childNodes.every((childNode) => {
76
- const node = childNode, ///
77
- nodeVerified = verifyNode(node, fileContext);
78
-
79
- if (nodeVerified) {
80
- return true;
81
- }
82
- });
83
-
84
- return childNodesVerified;
85
- }
86
-
87
- function verifyTerminalNode(terminalNode, fileContext) {
88
- const terminalNodeVerified = true;
89
-
90
- return terminalNodeVerified;
91
- }
92
-
93
- function verifyNonTerminalNode(nonTerminalNode, fileContext) {
94
- let nonTerminalNodeVerified;
95
-
96
- const ruleName = nonTerminalNode.getRuleName();
97
-
98
- switch (ruleName) {
99
- case ARGUMENT_RULE_NAME: {
100
- const argumentNode = nonTerminalNode, ///
101
- argumentNodeVerified = verifyArgumentNode(argumentNode, fileContext);
102
-
103
- nonTerminalNodeVerified = argumentNodeVerified; ///
104
-
105
- break;
106
- }
107
-
108
- case TERM_RULE_NAME: {
109
- const termNode = nonTerminalNode, ///
110
- types = [],
111
- context = fileContext, ///
112
- termVerified = verifyTerm(termNode, types, context);
113
-
114
- if (termVerified) {
115
- const firstType = first(types),
116
- type = firstType; ///
117
-
118
- if (type !== null) {
119
- const termString = fileContext.nodeAsString(termNode);
120
-
121
- fileContext.error(`The type of the constructor's compound '${termString}' term node is not null.`, termNode);
122
- } else {
123
- nonTerminalNodeVerified = true; ///
124
- }
125
- }
126
-
127
- break;
128
- }
129
-
130
- default: {
131
- const childNodes = nonTerminalNode.getChildNodes(),
132
- childNodesVerified = verifyChildNodes(childNodes, fileContext);
133
-
134
- nonTerminalNodeVerified = childNodesVerified; ///
135
-
136
- break;
137
- }
138
- }
139
-
140
- return nonTerminalNodeVerified;
141
- }
142
-
143
- function verifyArgumentNode(argumentNode, fileContext) {
144
- let argumentNodeVerified = false;
145
-
146
- const typeNode = typeNodeQuery(argumentNode),
147
- termNode = termNodeQuery(argumentNode);
148
-
149
- if (false) {
150
- ///
151
- } else if (typeNode !== null) {
152
- const typeName = typeNameFromTypeNode(typeNode),
153
- typePresent = fileContext.isTypePresentByTypeName(typeName);
154
-
155
- if (!typePresent) {
156
- fileContext.error(`The type '${typeName}' is not present.`, argumentNode);
157
- }
158
-
159
- argumentNodeVerified = typePresent; ///
160
- } else if (termNode !== null) {
161
- const node = termNode, ///
162
- nodeVerified = verifyNode(node, fileContext);
163
-
164
- argumentNodeVerified = nodeVerified; ///
165
- }
166
-
167
- return argumentNodeVerified;
168
- }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ import verifyTerm from "../verify/term";
4
+
5
+ import { first, second } from "../utilities/array";
6
+
7
+ export default function verifyTerms(leftTermNode, rightTermNode, context, verifyAhead) {
8
+ let termsVerified;
9
+
10
+ const leftTermString = context.nodeAsString(leftTermNode),
11
+ rightTermString = context.nodeAsString(rightTermNode);
12
+
13
+ context.trace(`Verifying the '${leftTermString}' and '${rightTermString}' terms...`, leftTermNode);
14
+
15
+ const types = [],
16
+ leftTermVerified = verifyTerm(leftTermNode, types, context, () => {
17
+ let verifiedAhead;
18
+
19
+ const rightTermVerified = verifyTerm(rightTermNode, types, context, () => {
20
+ let verifiedAhead = false;
21
+
22
+ const firstType = first(types),
23
+ secondType = second(types),
24
+ leftType = firstType, ///
25
+ rightType = secondType, ///
26
+ leftTypeEqualToOrSubTypeOfOfSuperTypeOfRightType = leftType.isEqualToOrSubTypeOfOfSuperTypeOf(rightType);
27
+
28
+ if (!leftTypeEqualToOrSubTypeOfOfSuperTypeOfRightType) {
29
+ const leftTypeName = leftType.getName(),
30
+ rightTypeName = rightType.getName(),
31
+ leftTermString = context.nodeAsString(leftTermNode),
32
+ rightTermString = context.nodeAsString(rightTermNode);
33
+
34
+ context.debug(`The left '${leftTermString}' term's '${leftTypeName}' type is not equal to, a sub-type of nor a super-type of the right '${rightTermString}' term's '${rightTypeName}' type.`, statementNode);
35
+ } else {
36
+ verifiedAhead = verifyAhead();
37
+ }
38
+
39
+ return verifiedAhead;
40
+ });
41
+
42
+ verifiedAhead = rightTermVerified; ///
43
+
44
+ return verifiedAhead;
45
+ });
46
+
47
+ if (termsVerified) {
48
+ context.debug(`...verified the '${leftTermString}' and '${rightTermString}' terms.`, leftTermNode);
49
+ }
50
+
51
+ termsVerified = leftTermVerified; ///
52
+
53
+ return termsVerified
54
+ }
@@ -22,7 +22,7 @@ export default function verifyTheorem(theoremNode, fileContext) {
22
22
  labelsString = fileContext.nodesAsString(labelNodes),
23
23
  proofContext = ProofContext.fromFileContext(fileContext);
24
24
 
25
- fileContext.debug(`Verifying the '${labelsString}' theorem...`, theoremNode);
25
+ fileContext.trace(`Verifying the '${labelsString}' theorem...`, theoremNode);
26
26
 
27
27
  const labels = [],
28
28
  labelsVerified = verifyLabels(labelNodes, labels, fileContext);
@@ -61,7 +61,7 @@ export default function verifyTheorem(theoremNode, fileContext) {
61
61
  }
62
62
 
63
63
  if (theoremVerified) {
64
- fileContext.info(`Verified the '${labelsString}' theorem.`, theoremNode);
64
+ fileContext.debug(`...verified the '${labelsString}' theorem.`, theoremNode);
65
65
  }
66
66
 
67
67
  return theoremVerified;
@@ -7,12 +7,15 @@ import { typeNameFromTypeNode } from "../utilities/query";
7
7
  export default function verifyType(typeNode, superTypeNode, fileContext) {
8
8
  let typeVerified = false;
9
9
 
10
+ const typeString = fileContext.nodeAsString(typeNode);
11
+
12
+ fileContext.trace(`Verifying the '${typeString}' type.`);
13
+
10
14
  const typeName = typeNameFromTypeNode(typeNode),
11
- typeString = fileContext.nodeAsString(typeNode),
12
15
  typePresent = fileContext.isTypePresentByTypeName(typeName);
13
16
 
14
17
  if (typePresent) {
15
- fileContext.error(`The type '${typeName}' is already present.`, typeNode);
18
+ fileContext.debug(`The type '${typeName}' is already present.`, typeNode);
16
19
  } else {
17
20
  let type;
18
21
 
@@ -24,7 +27,7 @@ export default function verifyType(typeNode, superTypeNode, fileContext) {
24
27
  const superType = fileContext.findTypeByTypeName(superTypeName);
25
28
 
26
29
  if (superType === null) {
27
- fileContext.error(`The super-type '${superTypeName}' is not present.`, typeNode);
30
+ fileContext.debug(`The super-type '${superTypeName}' is not present.`, typeNode);
28
31
  } else {
29
32
  type = Type.fromTypeNameAndSuperType(typeName, superType);
30
33
  }
@@ -38,7 +41,7 @@ export default function verifyType(typeNode, superTypeNode, fileContext) {
38
41
  }
39
42
 
40
43
  if (typeVerified) {
41
- fileContext.info(`Verified the '${typeString}' type.`, typeNode);
44
+ fileContext.debug(`...verified the '${typeString}' type.`, typeNode);
42
45
  }
43
46
 
44
47
  return typeVerified;