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.
- package/bin/action/verify.js +13 -3
- package/lib/axiomLemmaTheoremConjecture.js +3 -3
- package/lib/conclusion.js +16 -5
- package/lib/consequent.js +11 -3
- package/lib/context/file.js +73 -3
- package/lib/context/release.js +7 -2
- package/lib/equality.js +13 -199
- package/lib/premise.js +24 -7
- package/lib/supposition.js +15 -4
- package/lib/type.js +3 -8
- package/lib/utilities/array.js +5 -2
- package/lib/utilities/string.js +26 -13
- package/lib/verifier/node/metastatement.js +176 -0
- package/lib/verifier/node/statementAsCombinator.js +186 -0
- package/lib/verifier/node/termAsConstructor.js +224 -0
- package/lib/verifier/node.js +158 -0
- package/lib/verifier/nodes/equality.js +155 -0
- package/lib/verifier/{metastatementForMetavariable → nodes/metastatementForMetavariable}/conclusion.js +13 -12
- package/lib/verifier/{metastatementForMetavariable → nodes/metastatementForMetavariable}/premise.js +13 -12
- package/lib/verifier/nodes/metastatementForMetavariable.js +198 -0
- package/lib/verifier/nodes/statement.js +200 -0
- package/lib/verifier/{statementForMetavariable → nodes/statementForMetavariable}/conclusion.js +13 -12
- package/lib/verifier/{statementForMetavariable → nodes/statementForMetavariable}/premise.js +13 -12
- package/lib/verifier/nodes/statementForMetavariable.js +203 -0
- package/lib/verifier/nodes/term.js +210 -0
- package/lib/verifier/{termForVariable/supposition.js → nodes/termForVariable/consequent.js} +13 -12
- package/lib/verifier/{termForVariable/consequent.js → nodes/termForVariable/supposition.js} +13 -12
- package/lib/verifier/nodes/termForVariable.js +217 -0
- package/lib/verifier/nodes.js +175 -0
- package/lib/verify/axiom.js +3 -3
- package/lib/verify/conclusion.js +3 -3
- package/lib/verify/conjecture.js +3 -3
- package/lib/verify/consequent.js +3 -3
- package/lib/verify/declaration/combinator.js +7 -2
- package/lib/verify/declaration/constructor.js +8 -2
- package/lib/verify/declaration/metavariable.js +7 -2
- package/lib/verify/declaration/type.js +7 -2
- package/lib/verify/declaration/variable.js +8 -2
- package/lib/verify/file.js +3 -3
- package/lib/verify/label.js +9 -4
- package/lib/verify/lemma.js +3 -3
- package/lib/verify/metastatement/qualified.js +5 -6
- package/lib/verify/metastatement/unqualified.js +9 -7
- package/lib/verify/metastatement.js +36 -156
- package/lib/verify/metavariable.js +6 -4
- package/lib/verify/premise.js +3 -3
- package/lib/verify/release.js +3 -3
- package/lib/verify/rule.js +3 -3
- package/lib/verify/statement/qualified.js +5 -6
- package/lib/verify/statement/unqualified.js +9 -7
- package/lib/verify/statement.js +86 -332
- package/lib/verify/statementAsCombinator.js +8 -82
- package/lib/verify/supposition.js +3 -3
- package/lib/verify/term.js +79 -215
- package/lib/verify/termAsConstructor.js +15 -89
- package/lib/verify/terms.js +45 -0
- package/lib/verify/theorem.js +3 -3
- package/lib/verify/type.js +7 -5
- package/lib/verify/typeAssertion.js +124 -0
- package/lib/verify/variable.js +7 -5
- package/package.json +5 -5
- package/src/axiomLemmaTheoremConjecture.js +2 -2
- package/src/conclusion.js +13 -4
- package/src/consequent.js +9 -2
- package/src/context/file.js +9 -2
- package/src/context/release.js +9 -2
- package/src/equality.js +17 -143
- package/src/premise.js +23 -6
- package/src/supposition.js +12 -3
- package/src/type.js +3 -8
- package/src/utilities/array.js +1 -1
- package/src/utilities/string.js +34 -23
- package/src/verifier/node/metastatement.js +61 -0
- package/src/verifier/node/statementAsCombinator.js +80 -0
- package/src/verifier/node/termAsConstructor.js +124 -0
- package/src/verifier/node.js +85 -0
- package/src/verifier/nodes/equality.js +68 -0
- package/src/verifier/nodes/metastatementForMetavariable/conclusion.js +11 -0
- package/src/verifier/nodes/metastatementForMetavariable/premise.js +11 -0
- package/src/verifier/{metastatementForMetavariable.js → nodes/metastatementForMetavariable.js} +13 -13
- package/src/verifier/nodes/statement.js +100 -0
- package/src/verifier/nodes/statementForMetavariable/conclusion.js +11 -0
- package/src/verifier/nodes/statementForMetavariable/premise.js +11 -0
- package/src/verifier/{statementForMetavariable.js → nodes/statementForMetavariable.js} +10 -10
- package/src/verifier/nodes/term.js +106 -0
- package/src/verifier/nodes/termForVariable/consequent.js +11 -0
- package/src/verifier/nodes/termForVariable/supposition.js +11 -0
- package/src/verifier/{termForVariable.js → nodes/termForVariable.js} +42 -30
- package/src/verifier/nodes.js +111 -0
- package/src/verify/axiom.js +2 -2
- package/src/verify/conclusion.js +2 -2
- package/src/verify/conjecture.js +2 -2
- package/src/verify/consequent.js +2 -2
- package/src/verify/declaration/combinator.js +9 -1
- package/src/verify/declaration/constructor.js +15 -1
- package/src/verify/declaration/metavariable.js +9 -1
- package/src/verify/declaration/type.js +14 -1
- package/src/verify/declaration/variable.js +15 -1
- package/src/verify/file.js +2 -2
- package/src/verify/label.js +10 -2
- package/src/verify/lemma.js +4 -4
- package/src/verify/metastatement/qualified.js +4 -6
- package/src/verify/metastatement/unqualified.js +9 -7
- package/src/verify/metastatement.js +35 -56
- package/src/verify/metavariable.js +6 -3
- package/src/verify/premise.js +2 -2
- package/src/verify/release.js +2 -2
- package/src/verify/rule.js +2 -2
- package/src/verify/statement/qualified.js +4 -6
- package/src/verify/statement/unqualified.js +9 -7
- package/src/verify/statement.js +109 -302
- package/src/verify/statementAsCombinator.js +9 -129
- package/src/verify/supposition.js +2 -2
- package/src/verify/term.js +99 -156
- package/src/verify/termAsConstructor.js +20 -135
- package/src/verify/terms.js +54 -0
- package/src/verify/theorem.js +2 -2
- package/src/verify/type.js +7 -4
- package/src/verify/typeAssertion.js +164 -0
- package/src/verify/variable.js +7 -4
- package/lib/node/statement/combinator/equality.js +0 -21
- package/lib/ocmbinator/equality.js +0 -126
- package/lib/tokens/statement/combinator/equality.js +0 -17
- package/lib/verifier/metastatementForMetavariable.js +0 -198
- package/lib/verifier/statementForMetavariable.js +0 -203
- package/lib/verifier/termForVariable.js +0 -209
- package/lib/verifier.js +0 -138
- package/lib/verify/assertion/type.js +0 -115
- package/lib/verify/typeInference.js +0 -132
- package/src/node/statement/combinator/equality.js +0 -9
- package/src/ocmbinator/equality.js +0 -23
- package/src/tokens/statement/combinator/equality.js +0 -10
- package/src/verifier/metastatementForMetavariable/conclusion.js +0 -9
- package/src/verifier/metastatementForMetavariable/premise.js +0 -9
- package/src/verifier/statementForMetavariable/conclusion.js +0 -9
- package/src/verifier/statementForMetavariable/premise.js +0 -9
- package/src/verifier/termForVariable/consequent.js +0 -9
- package/src/verifier/termForVariable/supposition.js +0 -9
- package/src/verifier.js +0 -74
- package/src/verify/assertion/type.js +0 -153
- package/src/verify/typeInference.js +0 -146
package/src/verify/term.js
CHANGED
|
@@ -1,222 +1,165 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import termNodesVerifier from "../verifier/nodes/term";
|
|
4
4
|
|
|
5
5
|
import { first } from "../utilities/array";
|
|
6
|
-
import {
|
|
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
|
|
12
|
-
typeNodeQuery = nodeQuery("/argument/type!"),
|
|
13
|
-
variableNodeQuery = nodeQuery("/term/variable!");
|
|
8
|
+
const variableNodeQuery = nodeQuery("/term/variable!");
|
|
14
9
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let terminalNodeVerified = false;
|
|
10
|
+
function verifyTerm(termNode, types, context, verifyAhead) {
|
|
11
|
+
let termVerified;
|
|
18
12
|
|
|
19
|
-
|
|
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
|
-
|
|
44
|
-
}
|
|
15
|
+
context.trace(`Verifying the '${termString}' term...`, termNode);
|
|
45
16
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
constructorNodes = constructorChildNodes, ///
|
|
51
|
-
nodesVerified = this.verifyNodes(nodes, constructorNodes, context);
|
|
17
|
+
const verifyTermFunctions = [
|
|
18
|
+
verifyTermAsStandaloneVariable,
|
|
19
|
+
verifyTermAgainstConstructors
|
|
20
|
+
];
|
|
52
21
|
|
|
53
|
-
|
|
22
|
+
termVerified = verifyTermFunctions.some((verifyTermFunction) => {
|
|
23
|
+
const termVerified = verifyTermFunction(termNode, types, context, verifyAhead);
|
|
54
24
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
25
|
+
if (termVerified) {
|
|
26
|
+
return true;
|
|
58
27
|
}
|
|
28
|
+
});
|
|
59
29
|
|
|
60
|
-
|
|
30
|
+
if (termVerified) {
|
|
31
|
+
context.debug(`...verified the '${termString}' term.`, termNode);
|
|
61
32
|
}
|
|
62
33
|
|
|
63
|
-
|
|
64
|
-
|
|
34
|
+
return termVerified;
|
|
35
|
+
}
|
|
65
36
|
|
|
66
|
-
|
|
37
|
+
Object.assign(termNodesVerifier, {
|
|
38
|
+
verifyTerm
|
|
39
|
+
});
|
|
67
40
|
|
|
68
|
-
|
|
69
|
-
const argumentString = context.nodeAsString(argumentNode);
|
|
41
|
+
export default verifyTerm;
|
|
70
42
|
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
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
|
-
|
|
85
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
100
|
-
|
|
56
|
+
return termVerifiedAgainstConstructors;
|
|
57
|
+
}
|
|
101
58
|
|
|
102
|
-
|
|
59
|
+
export function verifyTermAsVariable(termNode, variables, context, verifyAhead) {
|
|
60
|
+
let termVerifiedAsVariable = false;
|
|
103
61
|
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
62
|
+
const variableNode = variableNodeQuery(termNode);
|
|
109
63
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
64
|
+
if (variableNode !== null) {
|
|
65
|
+
const termString = context.nodeAsString(termNode);
|
|
113
66
|
|
|
114
|
-
|
|
67
|
+
context.trace(`Verifying the '${termString}' term as a variable...`, termNode);
|
|
115
68
|
|
|
116
|
-
|
|
117
|
-
|
|
69
|
+
const variableName = variableNameFromVariableNode(variableNode),
|
|
70
|
+
variablePresent = context.isVariablePresentByVariableName(variableName);
|
|
118
71
|
|
|
119
|
-
|
|
72
|
+
if (variablePresent) {
|
|
73
|
+
let verifiedAhead;
|
|
120
74
|
|
|
121
|
-
|
|
75
|
+
const variable = context.findVariableByVariableName(variableName);
|
|
122
76
|
|
|
123
|
-
|
|
124
|
-
const variables = [],
|
|
125
|
-
termVerifiedAsVariable = verifyTermAsVariable(termNode, variables, context);
|
|
77
|
+
variables.push(variable);
|
|
126
78
|
|
|
127
|
-
|
|
128
|
-
const firstVariable = first(variables),
|
|
129
|
-
variable = firstVariable, ///
|
|
130
|
-
type = variable.getType();
|
|
79
|
+
verifiedAhead = verifyAhead();
|
|
131
80
|
|
|
132
|
-
|
|
81
|
+
if (!verifiedAhead) {
|
|
82
|
+
variables.pop();
|
|
83
|
+
}
|
|
133
84
|
|
|
134
|
-
|
|
85
|
+
termVerifiedAsVariable = verifiedAhead; ///
|
|
135
86
|
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (!termVerified) {
|
|
139
|
-
const termVerifiedAgainstConstructors = verifyTermAgainstConstructors(termNode, types, context);
|
|
140
87
|
|
|
141
|
-
if (
|
|
142
|
-
|
|
88
|
+
if (termVerifiedAsVariable) {
|
|
89
|
+
context.debug(`...verified the '${termString}' term as a variable.`, termNode);
|
|
143
90
|
}
|
|
144
91
|
}
|
|
145
92
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
type = firstType, ///
|
|
149
|
-
typeName = type.getName();
|
|
93
|
+
return termVerifiedAsVariable;
|
|
94
|
+
}
|
|
150
95
|
|
|
151
|
-
|
|
152
|
-
|
|
96
|
+
function verifyTermAgainstConstructor(termNode, types, constructor, context, verifyAhead) {
|
|
97
|
+
let termVerifiedAgainstConstructor;
|
|
153
98
|
|
|
154
|
-
|
|
155
|
-
|
|
99
|
+
const termString = context.nodeAsString(termNode),
|
|
100
|
+
constructorString = constructor.getString();
|
|
156
101
|
|
|
157
|
-
|
|
158
|
-
let termVerifiedAgainstConstructors = false;
|
|
102
|
+
context.trace(`Verifying the '${termString}' term against the '${constructorString}' constructor...`, termNode);
|
|
159
103
|
|
|
160
|
-
const
|
|
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
|
-
|
|
112
|
+
types.push(type);
|
|
163
113
|
|
|
164
|
-
|
|
165
|
-
constructor = constructors.find((constructor) => {
|
|
166
|
-
const termVerifiedAgainstConstructor = verifyTermAgainstConstructor(termNode, constructor, context);
|
|
114
|
+
verifiedAhead = verifyAhead();
|
|
167
115
|
|
|
168
|
-
if (
|
|
169
|
-
|
|
116
|
+
if (!verifiedAhead) {
|
|
117
|
+
types.pop();
|
|
170
118
|
}
|
|
171
|
-
}) || null;
|
|
172
119
|
|
|
173
|
-
|
|
174
|
-
|
|
120
|
+
return verifiedAhead;
|
|
121
|
+
});
|
|
175
122
|
|
|
176
|
-
|
|
123
|
+
termVerifiedAgainstConstructor = nodeVerified; ///
|
|
177
124
|
|
|
178
|
-
|
|
125
|
+
if (termVerifiedAgainstConstructor) {
|
|
126
|
+
context.debug(`...verified the '${termString}' term against the '${constructorString}' constructor.`, termNode);
|
|
179
127
|
}
|
|
180
128
|
|
|
181
|
-
return
|
|
129
|
+
return termVerifiedAgainstConstructor;
|
|
182
130
|
}
|
|
183
131
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
constructorString = constructor.getString();
|
|
132
|
+
function verifyTermAsStandaloneVariable(termNode, types, context, verifyAhead) {
|
|
133
|
+
let termVerifiedAsStandaloneVariable;
|
|
187
134
|
|
|
188
|
-
|
|
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
|
-
|
|
197
|
-
}
|
|
137
|
+
context.trace(`Verifying the '${termString}' term as a standalone variable...`, termNode);
|
|
198
138
|
|
|
199
|
-
|
|
200
|
-
|
|
139
|
+
const variables = [],
|
|
140
|
+
termVerifiedAsVariable = verifyTermAsVariable(termNode, variables, context, () => {
|
|
141
|
+
let verifiedAhead;
|
|
201
142
|
|
|
202
|
-
|
|
143
|
+
const firstVariable = first(variables),
|
|
144
|
+
variable = firstVariable, ///
|
|
145
|
+
type = variable.getType();
|
|
203
146
|
|
|
204
|
-
|
|
147
|
+
types.push(type);
|
|
205
148
|
|
|
206
|
-
|
|
149
|
+
verifiedAhead = verifyAhead();
|
|
207
150
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
151
|
+
if (!verifiedAhead) {
|
|
152
|
+
types.pop();
|
|
153
|
+
}
|
|
211
154
|
|
|
212
|
-
|
|
213
|
-
|
|
155
|
+
return verifiedAhead;
|
|
156
|
+
});
|
|
214
157
|
|
|
215
|
-
|
|
158
|
+
termVerifiedAsStandaloneVariable = termVerifiedAsVariable; ///
|
|
216
159
|
|
|
217
|
-
|
|
218
|
-
}
|
|
160
|
+
if (termVerifiedAsStandaloneVariable) {
|
|
161
|
+
context.debug(`...verified the '${termString}' term as a standalone variable.`, termNode);
|
|
219
162
|
}
|
|
220
163
|
|
|
221
|
-
return
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
15
|
+
const nonTerminalNode = termNode, ///
|
|
16
|
+
childNodes = nonTerminalNode.getChildNodes(),
|
|
17
|
+
childNodesVerified = termAsConstructorNodeVerifier.verifyChildNodes(childNodes, fileContext, () => {
|
|
18
|
+
const verifiedAhead = true;
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
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.
|
|
36
|
+
fileContext.debug(`The '${termString}' constructor's '${typeName}' type is not present.`, termNode);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
if (termVerifiedAsConstructor) {
|
|
41
|
+
const tokens = fileContext.getTokens(),
|
|
42
|
+
constructor = Constructor.fromTermNodeTypeAndTokens(termNode, type, tokens);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
fileContext.addConstructor(constructor);
|
|
45
|
+
}
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
if (termVerifiedAsConstructor) {
|
|
48
|
-
fileContext.
|
|
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
|
+
}
|
package/src/verify/theorem.js
CHANGED
|
@@ -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.
|
|
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.
|
|
64
|
+
fileContext.debug(`...verified the '${labelsString}' theorem.`, theoremNode);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
return theoremVerified;
|
package/src/verify/type.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
44
|
+
fileContext.debug(`...verified the '${typeString}' type.`, typeNode);
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
return typeVerified;
|