occam-verify-cli 0.0.700 → 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.
- package/lib/assignment/equality.js +2 -2
- package/lib/assignment/metavariable.js +2 -2
- package/lib/assignment/variable.js +2 -2
- package/lib/collection.js +44 -6
- package/lib/conclusion.js +6 -6
- package/lib/consequent.js +4 -4
- package/lib/context/file.js +9 -2
- package/lib/context/local.js +27 -64
- package/lib/context/localMeta.js +8 -1
- package/lib/equality.js +20 -4
- package/lib/premise.js +9 -9
- package/lib/supposition.js +4 -4
- package/lib/utilities/collection.js +27 -13
- package/lib/verifier/node/statementAsCombinator.js +4 -1
- package/lib/verifier/node/termAsConstructor.js +4 -20
- package/lib/verifier/nodes/equality.js +169 -0
- package/lib/verifier/nodes/metastatementForMetavariable.js +6 -7
- package/lib/verifier/nodes/statement.js +12 -4
- package/lib/verifier/nodes/statementForMetavariable.js +6 -7
- package/lib/verifier/nodes/termForVariable.js +19 -20
- package/lib/verify/consequent.js +3 -3
- package/lib/verify/derivation.js +28 -6
- package/lib/verify/equality.js +9 -4
- package/lib/verify/givenType.js +32 -0
- package/lib/verify/metastatement.js +3 -3
- package/lib/verify/statement/qualified.js +135 -37
- package/lib/verify/statement.js +34 -42
- package/lib/verify/supposition.js +13 -8
- package/lib/verify/suppositions.js +2 -11
- package/lib/verify/term.js +25 -59
- package/lib/verify/termAndGivenType.js +39 -0
- package/lib/verify/termAsGivenVariable.js +36 -0
- package/lib/verify/typeAssertion.js +35 -22
- package/package.json +1 -1
- package/src/assignment/equality.js +2 -2
- package/src/assignment/metavariable.js +2 -2
- package/src/assignment/variable.js +2 -2
- package/src/collection.js +55 -5
- package/src/conclusion.js +6 -6
- package/src/consequent.js +4 -4
- package/src/context/file.js +7 -1
- package/src/context/local.js +33 -78
- package/src/context/localMeta.js +6 -0
- package/src/equality.js +23 -2
- package/src/premise.js +10 -10
- package/src/supposition.js +3 -3
- package/src/utilities/collection.js +31 -11
- package/src/verifier/node/statementAsCombinator.js +6 -0
- package/src/verifier/node/termAsConstructor.js +5 -26
- package/src/verifier/nodes/equality.js +47 -0
- package/src/verifier/nodes/metastatementForMetavariable.js +10 -10
- package/src/verifier/nodes/statement.js +1 -1
- package/src/verifier/nodes/statementForMetavariable.js +10 -10
- package/src/verifier/nodes/termForVariable.js +30 -30
- package/src/verify/consequent.js +4 -4
- package/src/verify/derivation.js +37 -8
- package/src/verify/equality.js +12 -3
- package/src/verify/{standaloneType.js → givenType.js} +7 -7
- package/src/verify/metastatement.js +2 -2
- package/src/verify/statement/qualified.js +194 -39
- package/src/verify/statement.js +47 -47
- package/src/verify/supposition.js +15 -8
- package/src/verify/suppositions.js +1 -13
- package/src/verify/term.js +26 -62
- package/src/verify/termAndGivenType.js +37 -0
- package/src/verify/termAsGivenVariable.js +39 -0
- package/src/verify/typeAssertion.js +50 -28
- package/lib/verifier/nodes/metastatementForMetavariable/conclusion.js +0 -114
- package/lib/verifier/nodes/metastatementForMetavariable/premise.js +0 -114
- package/lib/verifier/nodes/statementForMetavariable/conclusion.js +0 -114
- package/lib/verifier/nodes/statementForMetavariable/premise.js +0 -114
- package/lib/verifier/nodes/termForVariable/consequent.js +0 -114
- package/lib/verifier/nodes/termForVariable/supposition.js +0 -114
- package/lib/verify/standaloneType.js +0 -32
- package/lib/verify/termAndStandaloneType.js +0 -39
- package/lib/verify/termAsVariableAndStandaloneType.js +0 -39
- package/src/verifier/nodes/metastatementForMetavariable/conclusion.js +0 -11
- package/src/verifier/nodes/metastatementForMetavariable/premise.js +0 -11
- package/src/verifier/nodes/statementForMetavariable/conclusion.js +0 -11
- package/src/verifier/nodes/statementForMetavariable/premise.js +0 -11
- package/src/verifier/nodes/termForVariable/consequent.js +0 -11
- package/src/verifier/nodes/termForVariable/supposition.js +0 -11
- package/src/verify/termAndStandaloneType.js +0 -37
- package/src/verify/termAsVariableAndStandaloneType.js +0 -38
package/src/context/local.js
CHANGED
|
@@ -5,7 +5,7 @@ import Collection from "../collection";
|
|
|
5
5
|
import contextMixins from "../mixins/context";
|
|
6
6
|
|
|
7
7
|
import { last } from "../utilities/array";
|
|
8
|
-
import { mergeCollections,
|
|
8
|
+
import { mergeCollections, findCollectionByTerm } from "../utilities/collection";
|
|
9
9
|
|
|
10
10
|
class LocalContext {
|
|
11
11
|
constructor(context, variables, proofSteps, collections) {
|
|
@@ -44,10 +44,11 @@ class LocalContext {
|
|
|
44
44
|
getCollections() {
|
|
45
45
|
let collections = this.context.getCollections();
|
|
46
46
|
|
|
47
|
-
const collectionsA = collections, ///
|
|
48
|
-
collectionsB =
|
|
47
|
+
const collectionsA = this.collections, ///
|
|
48
|
+
collectionsB = collections,
|
|
49
|
+
localContext = this; ///
|
|
49
50
|
|
|
50
|
-
collections = mergeCollections(collectionsA, collectionsB); ///
|
|
51
|
+
collections = mergeCollections(collectionsA, collectionsB, localContext); ///
|
|
51
52
|
|
|
52
53
|
return collections;
|
|
53
54
|
}
|
|
@@ -66,6 +67,24 @@ class LocalContext {
|
|
|
66
67
|
|
|
67
68
|
getMetavariables() { return this.context.getMetavariables(); }
|
|
68
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
|
+
|
|
69
88
|
addEquality(equality) {
|
|
70
89
|
let equalityAdded;
|
|
71
90
|
|
|
@@ -88,23 +107,24 @@ class LocalContext {
|
|
|
88
107
|
|
|
89
108
|
equalityAdded = true;
|
|
90
109
|
} else if ((leftCollection !== null) && (rightCollection === null)) {
|
|
91
|
-
|
|
92
|
-
collection = leftCollection; ///
|
|
93
|
-
|
|
94
|
-
collection.addTerm(term);
|
|
110
|
+
leftCollection.addTerm(rightTerm);
|
|
95
111
|
|
|
96
112
|
equalityAdded = true;
|
|
97
113
|
} else if ((leftCollection === null) && (rightCollection !== null)) {
|
|
98
|
-
|
|
99
|
-
collection = rightCollection; ///
|
|
100
|
-
|
|
101
|
-
collection.addTerm(term);
|
|
114
|
+
rightCollection.addTerm(leftTerm);
|
|
102
115
|
|
|
103
116
|
equalityAdded = true;
|
|
104
117
|
} else if ((leftCollection !== null) && (rightCollection !== null)) {
|
|
118
|
+
if (leftCollection === rightCollection) {
|
|
119
|
+
const collection = leftCollection; ///
|
|
105
120
|
|
|
106
|
-
|
|
121
|
+
collection.addTerm(leftTerm);
|
|
122
|
+
collection.addTerm(rightTerm);
|
|
107
123
|
|
|
124
|
+
equalityAdded = true;
|
|
125
|
+
} else {
|
|
126
|
+
debugger
|
|
127
|
+
}
|
|
108
128
|
}
|
|
109
129
|
}
|
|
110
130
|
|
|
@@ -162,27 +182,6 @@ class LocalContext {
|
|
|
162
182
|
return statementMatches;
|
|
163
183
|
}
|
|
164
184
|
|
|
165
|
-
findCollectionByType(type) {
|
|
166
|
-
const collections = this.getCollections(),
|
|
167
|
-
collection = findCollectionByType(collections, type);
|
|
168
|
-
|
|
169
|
-
return collection;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
findCollectionByTerm(term) {
|
|
173
|
-
const collections = this.getCollections(),
|
|
174
|
-
collection = findCollectionByTerm(collections, term);
|
|
175
|
-
|
|
176
|
-
return collection;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
findCollectionByTerms(terms) {
|
|
180
|
-
const collections = this.getCollections(),
|
|
181
|
-
collection = findCollectionByTerms(collections, terms);
|
|
182
|
-
|
|
183
|
-
return collection;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
185
|
findVariableByVariableNode(variableNode) {
|
|
187
186
|
const node = variableNode, ///
|
|
188
187
|
variables = this.getVariables(),
|
|
@@ -204,35 +203,6 @@ class LocalContext {
|
|
|
204
203
|
return variablePresent;
|
|
205
204
|
}
|
|
206
205
|
|
|
207
|
-
isEqualityEqual(equality) {
|
|
208
|
-
let equalityEqual;
|
|
209
|
-
|
|
210
|
-
const equalityReflexive = equality.isReflexive();
|
|
211
|
-
|
|
212
|
-
if (equalityReflexive) {
|
|
213
|
-
equalityEqual = true;
|
|
214
|
-
} else {
|
|
215
|
-
const leftTerm = equality.getLeftTerm(),
|
|
216
|
-
rightTerm = equality.getRightTerm(),
|
|
217
|
-
terms = [
|
|
218
|
-
leftTerm,
|
|
219
|
-
rightTerm
|
|
220
|
-
],
|
|
221
|
-
termsEqual = this.areTermsEqual(terms);
|
|
222
|
-
|
|
223
|
-
equalityEqual = termsEqual; ///
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return equalityEqual;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
areTermsEqual(terms) {
|
|
230
|
-
const collection = this.findCollectionByTerms(terms),
|
|
231
|
-
termsEqual = (collection !== null);
|
|
232
|
-
|
|
233
|
-
return termsEqual;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
206
|
toJSON(tokens) {
|
|
237
207
|
const variables = this.variables.map((variable) => {
|
|
238
208
|
const variableJSON = variable.toJSON(tokens);
|
|
@@ -288,21 +258,6 @@ class LocalContext {
|
|
|
288
258
|
|
|
289
259
|
return localContext;
|
|
290
260
|
}
|
|
291
|
-
|
|
292
|
-
static fromLocalContextAndAssignments(localContext, assignments) {
|
|
293
|
-
const context = localContext, ///
|
|
294
|
-
variables = assignments.map((assignment) => {
|
|
295
|
-
const variable = assignment.getVariable();
|
|
296
|
-
|
|
297
|
-
return variable;
|
|
298
|
-
}),
|
|
299
|
-
proofSteps = [],
|
|
300
|
-
collections = [];
|
|
301
|
-
|
|
302
|
-
localContext = new LocalContext(context, variables, proofSteps, collections);
|
|
303
|
-
|
|
304
|
-
return localContext;
|
|
305
|
-
}
|
|
306
261
|
}
|
|
307
262
|
|
|
308
263
|
Object.assign(LocalContext.prototype, contextMixins);
|
package/src/context/localMeta.js
CHANGED
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,12 +23,31 @@ 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
|
-
|
|
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(),
|
package/src/premise.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
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 { nodeQuery, nodesQuery } from "./utilities/query";
|
|
@@ -46,7 +46,7 @@ export default class Premise {
|
|
|
46
46
|
nonTerminalNodeB = subproofStatementNode, ///
|
|
47
47
|
fileContextA = fileContext, ///
|
|
48
48
|
localContextB = statementLocalContext, ///
|
|
49
|
-
nonTerminalNodeVerified =
|
|
49
|
+
nonTerminalNodeVerified = statementForMetavariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContextB, () => {
|
|
50
50
|
const verifiedAhead = true;
|
|
51
51
|
|
|
52
52
|
return verifiedAhead;
|
|
@@ -67,7 +67,7 @@ export default class Premise {
|
|
|
67
67
|
nonTerminalNodeB = statementNode, ///
|
|
68
68
|
fileContextA = fileContext, ///
|
|
69
69
|
localContextB = statementLocalContext, ///
|
|
70
|
-
nonTerminalNodeVerified =
|
|
70
|
+
nonTerminalNodeVerified = statementForMetavariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContextB, () => {
|
|
71
71
|
const verifiedAhead = true;
|
|
72
72
|
|
|
73
73
|
return verifiedAhead;
|
|
@@ -77,7 +77,7 @@ export default class Premise {
|
|
|
77
77
|
return statementNodeMatches;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext,
|
|
80
|
+
matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, metastatementLocalMetaContext) {
|
|
81
81
|
let ruleSubproofNodeMatches = false;
|
|
82
82
|
|
|
83
83
|
const ruleSubproofAssertionNode = ruleSubproofAssertionNodeQuery(this.metastatementNode);
|
|
@@ -99,8 +99,8 @@ export default class Premise {
|
|
|
99
99
|
nonTerminalNodeA = ruleSubproofAssertionMetastatementNode, ///
|
|
100
100
|
nonTerminalNodeB = ruleSubproofMetastatementNode, ///
|
|
101
101
|
fileContextA = fileContext, ///
|
|
102
|
-
|
|
103
|
-
nonTerminalNodeVerified =
|
|
102
|
+
localMetaContextB = metastatementLocalMetaContext, ///
|
|
103
|
+
nonTerminalNodeVerified = metastatementForMetavariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, () => {
|
|
104
104
|
const verifiedAhead = true;
|
|
105
105
|
|
|
106
106
|
return verifiedAhead;
|
|
@@ -116,12 +116,12 @@ export default class Premise {
|
|
|
116
116
|
return ruleSubproofNodeMatches;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
matchMetastatementNode(metastatementNode, substitutions, fileContext,
|
|
119
|
+
matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementLocalMetaContext) {
|
|
120
120
|
const nonTerminalNodeA = this.metastatementNode, ///
|
|
121
121
|
nonTerminalNodeB = metastatementNode, ///
|
|
122
122
|
fileContextA = fileContext, ///
|
|
123
|
-
|
|
124
|
-
nonTerminalNodeVerified =
|
|
123
|
+
localMetaContextB = metastatementLocalMetaContext, ///
|
|
124
|
+
nonTerminalNodeVerified = metastatementForMetavariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, () => {
|
|
125
125
|
const verifiedAhead = true;
|
|
126
126
|
|
|
127
127
|
return verifiedAhead;
|
package/src/supposition.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import termForVariableNodesVerifier from "./verifier/nodes/termForVariable";
|
|
4
4
|
|
|
5
5
|
import { nodeAsString } from "./utilities/string";
|
|
6
6
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
@@ -43,7 +43,7 @@ export default class Supposition {
|
|
|
43
43
|
nonTerminalNodeB = subproofStatementNode, ///
|
|
44
44
|
localContextA = localContext, ///
|
|
45
45
|
localContextB = statementLocalContext, ///
|
|
46
|
-
nonTerminalNodeVerified =
|
|
46
|
+
nonTerminalNodeVerified = termForVariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
47
47
|
const verifiedAhead = true;
|
|
48
48
|
|
|
49
49
|
return verifiedAhead;
|
|
@@ -64,7 +64,7 @@ export default class Supposition {
|
|
|
64
64
|
nonTerminalNodeB = statementNode, ///
|
|
65
65
|
localContextA = localContext, ///
|
|
66
66
|
localContextB = statementLocalContext, ///
|
|
67
|
-
nonTerminalNodeVerified =
|
|
67
|
+
nonTerminalNodeVerified = termForVariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
68
68
|
const verifiedAhead = true;
|
|
69
69
|
|
|
70
70
|
return verifiedAhead;
|
|
@@ -2,9 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
import { compress } from "../utilities/array";
|
|
4
4
|
|
|
5
|
-
export function
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export function areTermNodesEqual(leftTermNode, rightTermNode, collections) {
|
|
6
|
+
let termNodesEqual;
|
|
7
|
+
|
|
8
|
+
const leftTermNodeMatchesRightTermNode = leftTermNode.match(rightTermNode);
|
|
9
|
+
|
|
10
|
+
if (leftTermNodeMatchesRightTermNode) {
|
|
11
|
+
termNodesEqual = true;
|
|
12
|
+
} else {
|
|
13
|
+
const termNodes = [
|
|
14
|
+
leftTermNode,
|
|
15
|
+
rightTermNode
|
|
16
|
+
],
|
|
17
|
+
collection = findCollectionByTermNodes(collections, termNodes);
|
|
18
|
+
|
|
19
|
+
termNodesEqual = (collection !== null);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return termNodesEqual;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function mergeCollections(collectionsA, collectionsB, localContext) {
|
|
26
|
+
const typesA = typesFromCollections(collectionsA, localContext),
|
|
27
|
+
typesB = typesFromCollections(collectionsB, localContext),
|
|
8
28
|
types = [
|
|
9
29
|
...typesA,
|
|
10
30
|
...typesB
|
|
@@ -19,8 +39,8 @@ export function mergeCollections(collectionsA, collectionsB) {
|
|
|
19
39
|
const collections = types.map((type) => {
|
|
20
40
|
let collection;
|
|
21
41
|
|
|
22
|
-
const collectionA = findCollectionByType(collectionsA, type),
|
|
23
|
-
collectionB = findCollectionByType(collectionsB, type);
|
|
42
|
+
const collectionA = findCollectionByType(collectionsA, type, localContext),
|
|
43
|
+
collectionB = findCollectionByType(collectionsB, type, localContext);
|
|
24
44
|
|
|
25
45
|
if ((collectionA !== null) && (collectionB !== null)) {
|
|
26
46
|
collection = Collection.fromCollections(collectionA, collectionB);
|
|
@@ -36,9 +56,9 @@ export function mergeCollections(collectionsA, collectionsB) {
|
|
|
36
56
|
return collections;
|
|
37
57
|
}
|
|
38
58
|
|
|
39
|
-
export function findCollectionByType(collections, type) {
|
|
59
|
+
export function findCollectionByType(collections, type, localContext) {
|
|
40
60
|
const collection = collections.find((collection) => {
|
|
41
|
-
const collectionMatchesType = collection.matchType(type);
|
|
61
|
+
const collectionMatchesType = collection.matchType(type, localContext);
|
|
42
62
|
|
|
43
63
|
if (collectionMatchesType) {
|
|
44
64
|
return true;
|
|
@@ -60,9 +80,9 @@ export function findCollectionByTerm(collections, term) {
|
|
|
60
80
|
return collection;
|
|
61
81
|
}
|
|
62
82
|
|
|
63
|
-
|
|
83
|
+
function findCollectionByTermNodes(collections, termNodes) {
|
|
64
84
|
const collection = collections.find((collection) => {
|
|
65
|
-
const collectionMatchesTerms = collection.
|
|
85
|
+
const collectionMatchesTerms = collection.matchTermNodes(termNodes);
|
|
66
86
|
|
|
67
87
|
if (collectionMatchesTerms) {
|
|
68
88
|
return true;
|
|
@@ -72,9 +92,9 @@ export function findCollectionByTerms(collections, terms) {
|
|
|
72
92
|
return collection;
|
|
73
93
|
}
|
|
74
94
|
|
|
75
|
-
function typesFromCollections(collections) {
|
|
95
|
+
function typesFromCollections(collections, localContext) {
|
|
76
96
|
const types = collections.map((collection) => {
|
|
77
|
-
const type = collection.getType();
|
|
97
|
+
const type = collection.getType(localContext);
|
|
78
98
|
|
|
79
99
|
return type;
|
|
80
100
|
});
|
|
@@ -14,6 +14,8 @@ class StatementAsCombinatorNodeVerifier extends NodeVerifier {
|
|
|
14
14
|
|
|
15
15
|
switch (ruleName) {
|
|
16
16
|
case TYPE_RULE_NAME: {
|
|
17
|
+
debugger
|
|
18
|
+
|
|
17
19
|
const typeNode = nonTerminalNode, ///
|
|
18
20
|
typeVerified = verifyType(typeNode, fileContext, verifyAhead),
|
|
19
21
|
typeNodeVerified = typeVerified; ///
|
|
@@ -24,6 +26,8 @@ class StatementAsCombinatorNodeVerifier extends NodeVerifier {
|
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
case TERM_RULE_NAME: {
|
|
29
|
+
debugger
|
|
30
|
+
|
|
27
31
|
const termNode = nonTerminalNode, ///
|
|
28
32
|
standaloneTermVerified = verifyStandaloneTerm(termNode, fileContext, verifyAhead),
|
|
29
33
|
termNodeVerified = standaloneTermVerified; ///
|
|
@@ -34,6 +38,8 @@ class StatementAsCombinatorNodeVerifier extends NodeVerifier {
|
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
case STATEMENT_RULE_NAME: {
|
|
41
|
+
debugger
|
|
42
|
+
|
|
37
43
|
const statementNode = nonTerminalNode, ///
|
|
38
44
|
standaloneStatementVerified = verifyStandaloneStatement(statementNode, fileContext, verifyAhead),
|
|
39
45
|
statementNodeVerified = standaloneStatementVerified; ///
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import verifyTerm from "../../verify/term";
|
|
4
4
|
import NodeVerifier from "../../verifier/node";
|
|
5
|
+
import verifyGivenType from "../../verify/givenType";
|
|
5
6
|
|
|
6
|
-
import { nodeQuery
|
|
7
|
+
import { nodeQuery } from "../../utilities/query";
|
|
7
8
|
import { TERM_RULE_NAME, ARGUMENT_RULE_NAME } from "../../ruleNames";
|
|
8
9
|
|
|
9
10
|
const typeNodeQuery = nodeQuery("/argument/type"),
|
|
@@ -71,29 +72,6 @@ export function verifyStandaloneTerm(termNode, fileContext, verifyAhead) {
|
|
|
71
72
|
return standaloneTermVerified;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
export function verifyType(typeNode, fileContext, verifyAhead) {
|
|
75
|
-
let typeVerified = false;
|
|
76
|
-
|
|
77
|
-
const typeString = fileContext.nodeAsString(typeNode);
|
|
78
|
-
|
|
79
|
-
fileContext.trace(`Verifying the '${typeString}' type...`, typeNode);
|
|
80
|
-
|
|
81
|
-
const typeName = typeNameFromTypeNode(typeNode),
|
|
82
|
-
typePresent = fileContext.isTypePresentByTypeName(typeName);
|
|
83
|
-
|
|
84
|
-
if (!typePresent) {
|
|
85
|
-
fileContext.debug(`The type '${typeName}' is not present.`, typeNode);
|
|
86
|
-
} else {
|
|
87
|
-
fileContext.debug(`...verified the '${typeString}' type.`, typeNode);
|
|
88
|
-
|
|
89
|
-
const verifiedAhead = verifyAhead();
|
|
90
|
-
|
|
91
|
-
typeVerified = verifiedAhead; ///
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return typeVerified;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
75
|
function verifyArgument(argumentNode, fileContext, verifyAhead) {
|
|
98
76
|
let argumentVerified;
|
|
99
77
|
|
|
@@ -105,9 +83,10 @@ function verifyArgument(argumentNode, fileContext, verifyAhead) {
|
|
|
105
83
|
termNode = termNodeQuery(argumentNode);
|
|
106
84
|
|
|
107
85
|
if (typeNode !== null) {
|
|
108
|
-
const
|
|
86
|
+
const types = [], ///
|
|
87
|
+
givenTypeVerified = verifyGivenType(typeNode, types, fileContext, verifyAhead);
|
|
109
88
|
|
|
110
|
-
argumentVerified =
|
|
89
|
+
argumentVerified = givenTypeVerified; ///
|
|
111
90
|
}
|
|
112
91
|
|
|
113
92
|
if (termNode !== null) {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import NodesVerifier from "../../verifier/nodes";
|
|
4
|
+
|
|
5
|
+
import { TERM_RULE_NAME } from "../../ruleNames";
|
|
6
|
+
import { areTermNodesEqual } from "../../utilities/collection";
|
|
7
|
+
|
|
8
|
+
class EqualityNodesVerifier extends NodesVerifier {
|
|
9
|
+
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, collections, localContext, verifyAhead) {
|
|
10
|
+
let nonTerminalNodeVerified = false;
|
|
11
|
+
|
|
12
|
+
const ruleNameA = nonTerminalNodeA.getRuleName(), ///
|
|
13
|
+
ruleNameB = nonTerminalNodeB.getRuleName(); ///
|
|
14
|
+
|
|
15
|
+
if (ruleNameA === ruleNameB) {
|
|
16
|
+
switch (ruleNameA) {
|
|
17
|
+
case TERM_RULE_NAME: {
|
|
18
|
+
const leftTermNode = nonTerminalNodeA, ///
|
|
19
|
+
rightTermNode = nonTerminalNodeB, ///
|
|
20
|
+
termNodesEqual = areTermNodesEqual(leftTermNode, rightTermNode, collections);
|
|
21
|
+
|
|
22
|
+
if (termNodesEqual) {
|
|
23
|
+
const verifiedAhead = verifyAhead();
|
|
24
|
+
|
|
25
|
+
nonTerminalNodeVerified = verifiedAhead; ///
|
|
26
|
+
} else {
|
|
27
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, collections, localContext, verifyAhead);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
default: {
|
|
34
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, collections, localContext, verifyAhead);
|
|
35
|
+
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return nonTerminalNodeVerified;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const equalityNodesVerifier = new EqualityNodesVerifier();
|
|
46
|
+
|
|
47
|
+
export default equalityNodesVerifier;
|
|
@@ -8,7 +8,7 @@ import { METASTATEMENT_RULE_NAME } from "../../ruleNames";
|
|
|
8
8
|
|
|
9
9
|
const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!');
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
class MetastatementForMetavariableNodesVerifier extends NodesVerifier {
|
|
12
12
|
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead) {
|
|
13
13
|
let nonTerminalNodeVerified = false;
|
|
14
14
|
|
|
@@ -68,16 +68,12 @@ export default class MetastatementForMetavariableNodesVerifier extends NodesVeri
|
|
|
68
68
|
|
|
69
69
|
metavariableNodeVerified = metastatementNodeMatches; ///
|
|
70
70
|
} else {
|
|
71
|
-
const
|
|
71
|
+
const metavariableNode = metavariableNodeA, ///
|
|
72
|
+
metastatementNode = metastatementNodeB, ///
|
|
73
|
+
metastatementForMetavariableSubstitution = MetastatementForMetavariableSubstitution.fromMetavariableNodeAndMetastatementNode(metavariableNode, metastatementNode),
|
|
74
|
+
substitution = metastatementForMetavariableSubstitution; ///
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
const metavariableNode = metavariableNodeA, ///
|
|
75
|
-
metastatementNode = metastatementNodeB, ///
|
|
76
|
-
metastatementForMetavariableSubstitution = MetastatementForMetavariableSubstitution.fromMetavariableNodeAndMetastatementNode(metavariableNode, metastatementNode),
|
|
77
|
-
substitution = metastatementForMetavariableSubstitution; ///
|
|
78
|
-
|
|
79
|
-
substitutions.push(substitution);
|
|
80
|
-
}
|
|
76
|
+
substitutions.push(substitution);
|
|
81
77
|
|
|
82
78
|
metavariableNodeVerified = true;
|
|
83
79
|
}
|
|
@@ -85,3 +81,7 @@ export default class MetastatementForMetavariableNodesVerifier extends NodesVeri
|
|
|
85
81
|
return metavariableNodeVerified;
|
|
86
82
|
}
|
|
87
83
|
}
|
|
84
|
+
|
|
85
|
+
const metastatementForMetavariableNodesVerifier = new MetastatementForMetavariableNodesVerifier();
|
|
86
|
+
|
|
87
|
+
export default metastatementForMetavariableNodesVerifier;
|
|
@@ -60,7 +60,7 @@ const statementNodesVerifier = new StatementNodesVerifier();
|
|
|
60
60
|
|
|
61
61
|
export default statementNodesVerifier;
|
|
62
62
|
|
|
63
|
-
function verifyMetaargument(metaArgumentNode, combinatorMetaargumentNode, context, verifyAhead) {
|
|
63
|
+
export function verifyMetaargument(metaArgumentNode, combinatorMetaargumentNode, context, verifyAhead) {
|
|
64
64
|
let metaArgumentVerified = false;
|
|
65
65
|
|
|
66
66
|
const metaArgumentString = context.nodeAsString(metaArgumentNode);
|
|
@@ -9,7 +9,7 @@ import { STATEMENT_RULE_NAME, METASTATEMENT_RULE_NAME, META_ARGUMENT_RULE_NAME }
|
|
|
9
9
|
const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!'),
|
|
10
10
|
metaArgumentChildNodeNodeQuery = nodeQuery('/metaArgument/*!');
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
class StatementForMetavariableNodesVerifier extends NodesVerifier {
|
|
13
13
|
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContext) {
|
|
14
14
|
let nonTerminalNodeVerified = false;
|
|
15
15
|
|
|
@@ -84,16 +84,12 @@ export default class StatementForMetavariableNodesVerifier extends NodesVerifier
|
|
|
84
84
|
|
|
85
85
|
metavariableNodeVerified = statementNodeMatches; ///
|
|
86
86
|
} else {
|
|
87
|
-
const
|
|
87
|
+
const metavariableNode = metavariableNodeA, ///
|
|
88
|
+
statementNode = statementNodeB, ///
|
|
89
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromMetavariableNodeAndStatementNode(metavariableNode, statementNode),
|
|
90
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
88
91
|
|
|
89
|
-
|
|
90
|
-
const metavariableNode = metavariableNodeA, ///
|
|
91
|
-
statementNode = statementNodeB, ///
|
|
92
|
-
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromMetavariableNodeAndStatementNode(metavariableNode, statementNode),
|
|
93
|
-
substitution = statementForMetavariableSubstitution; ///
|
|
94
|
-
|
|
95
|
-
substitutions.push(substitution);
|
|
96
|
-
}
|
|
92
|
+
substitutions.push(substitution);
|
|
97
93
|
|
|
98
94
|
metavariableNodeVerified = true;
|
|
99
95
|
}
|
|
@@ -101,3 +97,7 @@ export default class StatementForMetavariableNodesVerifier extends NodesVerifier
|
|
|
101
97
|
return metavariableNodeVerified;
|
|
102
98
|
}
|
|
103
99
|
}
|
|
100
|
+
|
|
101
|
+
const statementForMetavariableNodesVerifier = new StatementForMetavariableNodesVerifier();
|
|
102
|
+
|
|
103
|
+
export default statementForMetavariableNodesVerifier;
|