occam-verify-cli 0.0.700 → 0.0.704
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 +7 -17
- package/lib/verifier/node/termAsConstructor.js +10 -45
- 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 +7 -25
- package/lib/verify/statement/qualified.js +135 -37
- package/lib/verify/statement.js +44 -33
- package/lib/verify/supposition.js +13 -8
- package/lib/verify/suppositions.js +2 -11
- package/lib/verify/term.js +35 -50
- package/lib/verify/termAndGivenType.js +39 -0
- package/lib/verify/termAsGivenVariable.js +36 -0
- package/lib/verify/type.js +28 -4
- 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 +5 -24
- package/src/verifier/node/termAsConstructor.js +6 -47
- 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 +8 -35
- package/src/verify/statement/qualified.js +194 -39
- package/src/verify/statement.js +65 -44
- package/src/verify/supposition.js +15 -8
- package/src/verify/suppositions.js +1 -13
- package/src/verify/term.js +42 -58
- package/src/verify/termAndGivenType.js +37 -0
- package/src/verify/termAsGivenVariable.js +39 -0
- package/src/verify/type.js +26 -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/conclusion.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 { metastatementNodeFromMetastatementString } from "./utilities/node";
|
|
@@ -20,7 +20,7 @@ export default class Conclusion {
|
|
|
20
20
|
nonTerminalNodeB = statementNode, ///
|
|
21
21
|
fileContextA = fileContext, ///
|
|
22
22
|
localContextB = statementLocalContext, ///
|
|
23
|
-
nonTerminalNodeVerified =
|
|
23
|
+
nonTerminalNodeVerified = statementForMetavariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContextB, () => {
|
|
24
24
|
const verifyAhead = true;
|
|
25
25
|
|
|
26
26
|
return verifyAhead;
|
|
@@ -30,12 +30,12 @@ export default class Conclusion {
|
|
|
30
30
|
return statementNodeMatches;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
matchMetastatementNode(metastatementNode, substitutions, fileContext,
|
|
33
|
+
matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementLocalMetaContext) {
|
|
34
34
|
const nonTerminalNodeA = this.metastatementNode, ///
|
|
35
35
|
nonTerminalNodeB = metastatementNode, ///
|
|
36
36
|
fileContextA = fileContext, ///
|
|
37
|
-
|
|
38
|
-
nonTerminalNodeVerified =
|
|
37
|
+
localMetaContextB = metastatementLocalMetaContext, ///
|
|
38
|
+
nonTerminalNodeVerified = metastatementForMetavariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, () => {
|
|
39
39
|
const verifiedAhead = true;
|
|
40
40
|
|
|
41
41
|
return verifiedAhead;
|
package/src/consequent.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import termForVariableNodesVerifier from "./verifier/nodes/termForVariable";
|
|
4
4
|
|
|
5
5
|
import { nodeAsString } from "./utilities/string";
|
|
6
6
|
import { statementNodeFromStatementString } from "./utilities/node";
|
|
@@ -14,12 +14,12 @@ export default class Consequent {
|
|
|
14
14
|
return this.statementNode;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
matchStatementNode(statementNode, substitutions, localContext) {
|
|
17
|
+
matchStatementNode(statementNode, substitutions, localContext, statementLocalContext) {
|
|
18
18
|
const nonTerminalNodeA = this.statementNode, ///
|
|
19
19
|
nonTerminalNodeB = statementNode, ///
|
|
20
20
|
localContextA = localContext, ///
|
|
21
|
-
localContextB =
|
|
22
|
-
nonTerminalNodeVerified =
|
|
21
|
+
localContextB = statementLocalContext, ///
|
|
22
|
+
nonTerminalNodeVerified = termForVariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
23
23
|
const verifiedAhead = true;
|
|
24
24
|
|
|
25
25
|
return verifiedAhead;
|
package/src/context/file.js
CHANGED
|
@@ -58,13 +58,19 @@ export default class FileContext {
|
|
|
58
58
|
|
|
59
59
|
getParser() { return this.releaseContext.getParser(); }
|
|
60
60
|
|
|
61
|
+
getTermType(term) {
|
|
62
|
+
const termType = term.getType();
|
|
63
|
+
|
|
64
|
+
return termType;
|
|
65
|
+
}
|
|
66
|
+
|
|
61
67
|
getProofSteps() {
|
|
62
68
|
const proofSteps = []; ///
|
|
63
69
|
|
|
64
70
|
return proofSteps;
|
|
65
71
|
}
|
|
66
72
|
|
|
67
|
-
getCollections() {
|
|
73
|
+
getCollections(localContext) {
|
|
68
74
|
const collections = []; ///
|
|
69
75
|
|
|
70
76
|
return collections;
|
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
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import NodeVerifier from "../../verifier/node";
|
|
4
|
-
import verifyStatement from "../../verify/statement";
|
|
5
4
|
|
|
6
|
-
import {
|
|
5
|
+
import { verifyStandaloneType } from "./../../verify/type";
|
|
6
|
+
import { verifyStandaloneTerm } from "./../../verify/term";
|
|
7
|
+
import { verifyStandaloneStatement } from "../../verify/statement";
|
|
7
8
|
import { TYPE_RULE_NAME, TERM_RULE_NAME, STATEMENT_RULE_NAME } from "../../ruleNames";
|
|
8
9
|
|
|
9
10
|
class StatementAsCombinatorNodeVerifier extends NodeVerifier {
|
|
@@ -15,8 +16,8 @@ class StatementAsCombinatorNodeVerifier extends NodeVerifier {
|
|
|
15
16
|
switch (ruleName) {
|
|
16
17
|
case TYPE_RULE_NAME: {
|
|
17
18
|
const typeNode = nonTerminalNode, ///
|
|
18
|
-
|
|
19
|
-
typeNodeVerified =
|
|
19
|
+
standaloneTypeVerified = verifyStandaloneType(typeNode, fileContext, verifyAhead),
|
|
20
|
+
typeNodeVerified = standaloneTypeVerified; ///
|
|
20
21
|
|
|
21
22
|
nonTerminalNodeVerified = typeNodeVerified; ///
|
|
22
23
|
|
|
@@ -58,23 +59,3 @@ const statementAsCombinatorNodeVerifier = new StatementAsCombinatorNodeVerifier(
|
|
|
58
59
|
|
|
59
60
|
export default statementAsCombinatorNodeVerifier;
|
|
60
61
|
|
|
61
|
-
function verifyStandaloneStatement(statementNode, fileContext, verifyAhead) {
|
|
62
|
-
let standaloneStatementVerified;
|
|
63
|
-
|
|
64
|
-
const statementString = fileContext.nodeAsString(statementNode);
|
|
65
|
-
|
|
66
|
-
fileContext.trace(`Verifying the '${statementString}' standalone statement...`, statementNode);
|
|
67
|
-
|
|
68
|
-
const context = fileContext, ///
|
|
69
|
-
derived = false,
|
|
70
|
-
assignments = [],
|
|
71
|
-
statementVerified = verifyStatement(statementNode, assignments, derived, context, verifyAhead);
|
|
72
|
-
|
|
73
|
-
standaloneStatementVerified = statementVerified; ///
|
|
74
|
-
|
|
75
|
-
if (standaloneStatementVerified) {
|
|
76
|
-
fileContext.debug(`...verified the '${statementString}' standalone statement.`, statementNode);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return standaloneStatementVerified;
|
|
80
|
-
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import verifyTerm from "../../verify/term";
|
|
4
3
|
import NodeVerifier from "../../verifier/node";
|
|
4
|
+
import verifyGivenType from "../../verify/givenType";
|
|
5
5
|
|
|
6
|
-
import { nodeQuery
|
|
6
|
+
import { nodeQuery } from "../../utilities/query";
|
|
7
|
+
import { verifyStandaloneTerm } from "../../verify/term";
|
|
7
8
|
import { TERM_RULE_NAME, ARGUMENT_RULE_NAME } from "../../ruleNames";
|
|
8
9
|
|
|
9
10
|
const typeNodeQuery = nodeQuery("/argument/type"),
|
|
@@ -51,49 +52,6 @@ const termAsConstructorNodeVerifier = new TermAsConstructorNodeVerifier();
|
|
|
51
52
|
|
|
52
53
|
export default termAsConstructorNodeVerifier;
|
|
53
54
|
|
|
54
|
-
export function verifyStandaloneTerm(termNode, fileContext, verifyAhead) {
|
|
55
|
-
let standaloneTermVerified;
|
|
56
|
-
|
|
57
|
-
const termString = fileContext.nodeAsString(termNode);
|
|
58
|
-
|
|
59
|
-
fileContext.trace(`Verifying the '${termString}' standalone term...`, termNode);
|
|
60
|
-
|
|
61
|
-
const terms = [],
|
|
62
|
-
context = fileContext, ///
|
|
63
|
-
termVerified = verifyTerm(termNode, terms, context, verifyAhead);
|
|
64
|
-
|
|
65
|
-
standaloneTermVerified = termVerified; ///
|
|
66
|
-
|
|
67
|
-
if (standaloneTermVerified) {
|
|
68
|
-
fileContext.debug(`...verified the '${termString}' standalone term.`, termNode);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return standaloneTermVerified;
|
|
72
|
-
}
|
|
73
|
-
|
|
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
55
|
function verifyArgument(argumentNode, fileContext, verifyAhead) {
|
|
98
56
|
let argumentVerified;
|
|
99
57
|
|
|
@@ -105,9 +63,10 @@ function verifyArgument(argumentNode, fileContext, verifyAhead) {
|
|
|
105
63
|
termNode = termNodeQuery(argumentNode);
|
|
106
64
|
|
|
107
65
|
if (typeNode !== null) {
|
|
108
|
-
const
|
|
66
|
+
const types = [], ///
|
|
67
|
+
givenTypeVerified = verifyGivenType(typeNode, types, fileContext, verifyAhead);
|
|
109
68
|
|
|
110
|
-
argumentVerified =
|
|
69
|
+
argumentVerified = givenTypeVerified; ///
|
|
111
70
|
}
|
|
112
71
|
|
|
113
72
|
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;
|