occam-verify-cli 0.0.683 → 0.0.685
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 +60 -0
- package/lib/assignment/variable.js +60 -0
- package/lib/axiom.js +4 -4
- package/lib/axiomLemmaTheoremConjecture.js +29 -29
- package/lib/collection.js +154 -0
- package/lib/combinator.js +1 -1
- package/lib/conclusion.js +5 -5
- package/lib/conjecture.js +4 -4
- package/lib/consequent.js +3 -3
- package/lib/constructor.js +1 -1
- package/lib/context/file.js +9 -2
- package/lib/context/local.js +330 -0
- package/lib/context/localMeta.js +192 -0
- package/lib/context/release.js +1 -1
- package/lib/equality.js +19 -87
- package/lib/label.js +1 -1
- package/lib/lemma.js +4 -4
- package/lib/log.js +1 -1
- package/lib/metaType.js +1 -1
- package/lib/metavariable.js +1 -1
- package/lib/ocmbinator/bracketed.js +1 -1
- package/lib/premise.js +9 -9
- package/lib/rule.js +25 -25
- package/lib/step/metaproof.js +1 -1
- package/lib/step/proof.js +1 -1
- package/lib/substitution/metastatementForMetavariable.js +1 -1
- package/lib/substitution/statementForMetavariable.js +1 -1
- package/lib/substitution/termForVariable.js +1 -1
- package/lib/supposition.js +5 -5
- package/lib/term.js +68 -0
- package/lib/theorem.js +4 -4
- package/lib/type.js +5 -5
- package/lib/utilities/array.js +4 -4
- package/lib/utilities/collection.js +107 -0
- package/lib/variable.js +1 -1
- package/lib/verifier/node/metastatement.js +9 -9
- package/lib/verifier/node/statementAsCombinator.js +1 -1
- package/lib/verifier/node/termAsConstructor.js +2 -2
- package/lib/verifier/node.js +1 -1
- package/lib/verifier/nodes/metastatementForMetavariable/conclusion.js +1 -1
- package/lib/verifier/nodes/metastatementForMetavariable/premise.js +1 -1
- package/lib/verifier/nodes/metastatementForMetavariable.js +8 -8
- package/lib/verifier/nodes/statement.js +1 -1
- package/lib/verifier/nodes/statementForMetavariable/conclusion.js +1 -1
- package/lib/verifier/nodes/statementForMetavariable/premise.js +1 -1
- package/lib/verifier/nodes/statementForMetavariable.js +9 -9
- package/lib/verifier/nodes/term.js +3 -3
- package/lib/verifier/nodes/termForVariable/consequent.js +1 -1
- package/lib/verifier/nodes/termForVariable/supposition.js +1 -1
- package/lib/verifier/nodes/termForVariable.js +11 -11
- package/lib/verifier/nodes.js +1 -1
- package/lib/verify/axiom.js +6 -6
- package/lib/verify/conclusion.js +6 -6
- package/lib/verify/conjecture.js +7 -7
- package/lib/verify/consequent.js +6 -6
- package/lib/verify/derivation.js +17 -17
- package/lib/verify/equality.js +50 -18
- package/lib/verify/lemma.js +7 -7
- package/lib/verify/metastatement/qualified.js +7 -7
- package/lib/verify/metastatement/unqualified.js +7 -7
- package/lib/verify/metastatement.js +12 -12
- package/lib/verify/premise.js +7 -7
- package/lib/verify/proof.js +10 -7
- package/lib/verify/rule.js +6 -6
- package/lib/verify/ruleDerivation.js +17 -17
- package/lib/verify/ruleProof.js +6 -6
- package/lib/verify/statement/qualified.js +15 -15
- package/lib/verify/statement/unqualified.js +7 -7
- package/lib/verify/supposition.js +8 -8
- package/lib/verify/term.js +32 -31
- package/lib/verify/terms.js +11 -17
- package/lib/verify/theorem.js +7 -7
- package/lib/verify/typeAssertion.js +3 -3
- package/package.json +5 -5
- package/src/assignment/equality.js +21 -0
- package/src/assignment/variable.js +21 -0
- package/src/axiom.js +1 -1
- package/src/axiomLemmaTheoremConjecture.js +26 -26
- package/src/collection.js +101 -0
- package/src/conclusion.js +6 -6
- package/src/conjecture.js +1 -1
- package/src/consequent.js +4 -4
- package/src/context/file.js +9 -1
- package/src/context/local.js +311 -0
- package/src/context/{metaproof.js → localMeta.js} +16 -17
- package/src/equality.js +17 -111
- package/src/lemma.js +1 -1
- package/src/premise.js +12 -12
- package/src/rule.js +24 -24
- package/src/supposition.js +8 -8
- package/src/term.js +30 -0
- package/src/theorem.js +1 -1
- package/src/type.js +3 -3
- package/src/utilities/array.js +1 -1
- package/src/utilities/collection.js +83 -0
- package/src/verifier/node/metastatement.js +8 -8
- package/src/verifier/node/termAsConstructor.js +2 -2
- package/src/verifier/nodes/metastatementForMetavariable.js +7 -7
- package/src/verifier/nodes/statementForMetavariable.js +8 -8
- package/src/verifier/nodes/term.js +5 -4
- package/src/verifier/nodes/termForVariable.js +15 -14
- package/src/verify/axiom.js +5 -5
- package/src/verify/conclusion.js +5 -5
- package/src/verify/conjecture.js +6 -6
- package/src/verify/consequent.js +5 -5
- package/src/verify/derivation.js +16 -16
- package/src/verify/equality.js +81 -24
- package/src/verify/lemma.js +6 -6
- package/src/verify/metastatement/qualified.js +7 -7
- package/src/verify/metastatement/unqualified.js +6 -6
- package/src/verify/metastatement.js +11 -11
- package/src/verify/premise.js +6 -6
- package/src/verify/proof.js +13 -10
- package/src/verify/rule.js +5 -5
- package/src/verify/ruleDerivation.js +16 -16
- package/src/verify/ruleProof.js +5 -5
- package/src/verify/statement/qualified.js +15 -15
- package/src/verify/statement/unqualified.js +6 -6
- package/src/verify/supposition.js +7 -7
- package/src/verify/term.js +38 -35
- package/src/verify/terms.js +14 -28
- package/src/verify/theorem.js +6 -6
- package/src/verify/typeAssertion.js +3 -2
- package/lib/assignment.js +0 -74
- package/lib/context/metaproof.js +0 -192
- package/lib/context/proof.js +0 -245
- package/lib/verifier/nodes/equality.js +0 -155
- package/src/assignment.js +0 -36
- package/src/context/proof.js +0 -205
- package/src/verifier/nodes/equality.js +0 -68
package/src/rule.js
CHANGED
|
@@ -44,27 +44,27 @@ export default class Rule {
|
|
|
44
44
|
return labelNameMatches;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
matchStatement(statementNode,
|
|
47
|
+
matchStatement(statementNode, statementLocalContext) {
|
|
48
48
|
let statementNatches;
|
|
49
49
|
|
|
50
50
|
const premisesLength = this.premises.length;
|
|
51
51
|
|
|
52
52
|
if (premisesLength === 0) {
|
|
53
53
|
const substitutions = [],
|
|
54
|
-
conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext,
|
|
54
|
+
conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, statementLocalContext);
|
|
55
55
|
|
|
56
56
|
statementNatches = conclusionMatches; ///
|
|
57
57
|
} else {
|
|
58
|
-
const proofSteps =
|
|
58
|
+
const proofSteps = statementLocalContext.getProofSteps();
|
|
59
59
|
|
|
60
60
|
statementNatches = someSubArray(proofSteps, premisesLength, (proofSteps) => {
|
|
61
61
|
let premisesMatchConclusion = false;
|
|
62
62
|
|
|
63
63
|
const substitutions = [],
|
|
64
|
-
premisesMatch = matchPremises(this.premises, proofSteps, substitutions, this.fileContext,
|
|
64
|
+
premisesMatch = matchPremises(this.premises, proofSteps, substitutions, this.fileContext, statementLocalContext);
|
|
65
65
|
|
|
66
66
|
if (premisesMatch) {
|
|
67
|
-
const conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext,
|
|
67
|
+
const conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, statementLocalContext);
|
|
68
68
|
|
|
69
69
|
premisesMatchConclusion = conclusionMatches; ///
|
|
70
70
|
}
|
|
@@ -78,27 +78,27 @@ export default class Rule {
|
|
|
78
78
|
return statementNatches;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
matchMetastatement(metastatementNode,
|
|
81
|
+
matchMetastatement(metastatementNode, metastatementLocalMetaContext) {
|
|
82
82
|
let metastatementNatches;
|
|
83
83
|
|
|
84
84
|
const premisesLength = this.premises.length;
|
|
85
85
|
|
|
86
86
|
if (premisesLength === 0) {
|
|
87
87
|
const substitutions = [],
|
|
88
|
-
conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext,
|
|
88
|
+
conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, metastatementLocalMetaContext);
|
|
89
89
|
|
|
90
90
|
metastatementNatches = conclusionMatches; ///
|
|
91
91
|
} else {
|
|
92
|
-
const metaproofSteps =
|
|
92
|
+
const metaproofSteps = metastatementLocalMetaContext.getMetaproofSteps();
|
|
93
93
|
|
|
94
94
|
metastatementNatches = someSubArray(metaproofSteps, premisesLength, (metaproofSteps) => {
|
|
95
95
|
let premisesMatchConclusion = false;
|
|
96
96
|
|
|
97
97
|
const substitutions = [],
|
|
98
|
-
premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions, this.fileContext,
|
|
98
|
+
premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions, this.fileContext, metastatementLocalMetaContext);
|
|
99
99
|
|
|
100
100
|
if (premisesMatch) {
|
|
101
|
-
const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext,
|
|
101
|
+
const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, metastatementLocalMetaContext);
|
|
102
102
|
|
|
103
103
|
premisesMatchConclusion = conclusionMatches; ///
|
|
104
104
|
}
|
|
@@ -181,13 +181,13 @@ export default class Rule {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
function matchPremise(premise, proofSteps, substitutions, fileContext,
|
|
184
|
+
function matchPremise(premise, proofSteps, substitutions, fileContext, statementLocalContext) {
|
|
185
185
|
const proofStep = prune(proofSteps, (proofStep) => {
|
|
186
186
|
const subproofNode = proofStep.getSubproofNode(),
|
|
187
187
|
statementNode = proofStep.getStatementNode()
|
|
188
188
|
|
|
189
189
|
if (subproofNode !== null) {
|
|
190
|
-
const subProofNodeMatches = premise.matchSubproofNode(subproofNode, substitutions, fileContext,
|
|
190
|
+
const subProofNodeMatches = premise.matchSubproofNode(subproofNode, substitutions, fileContext, statementLocalContext);
|
|
191
191
|
|
|
192
192
|
if (!subProofNodeMatches) { ///
|
|
193
193
|
return true;
|
|
@@ -195,7 +195,7 @@ function matchPremise(premise, proofSteps, substitutions, fileContext, statement
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
if (statementNode !== null) {
|
|
198
|
-
const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions, fileContext,
|
|
198
|
+
const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions, fileContext, statementLocalContext);
|
|
199
199
|
|
|
200
200
|
if (!statementNodeMatches) { ///
|
|
201
201
|
return true;
|
|
@@ -208,9 +208,9 @@ function matchPremise(premise, proofSteps, substitutions, fileContext, statement
|
|
|
208
208
|
return premiseMatches;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
function matchPremises(premise, proofSteps, substitutions, fileContext,
|
|
211
|
+
function matchPremises(premise, proofSteps, substitutions, fileContext, statementLocalContext) {
|
|
212
212
|
const premisesMatch = premise.every((premise) => {
|
|
213
|
-
const premiseMatches = matchPremise(premise, proofSteps, substitutions, fileContext,
|
|
213
|
+
const premiseMatches = matchPremise(premise, proofSteps, substitutions, fileContext, statementLocalContext);
|
|
214
214
|
|
|
215
215
|
if (premiseMatches) {
|
|
216
216
|
return true;
|
|
@@ -220,20 +220,20 @@ function matchPremises(premise, proofSteps, substitutions, fileContext, statemen
|
|
|
220
220
|
return premisesMatch;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
function matchConclusion(conclusion, statementNode, substitutions, fileContext,
|
|
224
|
-
const statementNodeMatches = conclusion.matchStatementNode(statementNode, substitutions, fileContext,
|
|
223
|
+
function matchConclusion(conclusion, statementNode, substitutions, fileContext, statementLocalContext) {
|
|
224
|
+
const statementNodeMatches = conclusion.matchStatementNode(statementNode, substitutions, fileContext, statementLocalContext),
|
|
225
225
|
conclusionMatches = statementNodeMatches; ///
|
|
226
226
|
|
|
227
227
|
return conclusionMatches;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext,
|
|
230
|
+
function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, metastatementLocalMetaContext) {
|
|
231
231
|
const metaproofStep = prune(metaproofSteps, (metaproofStep) => {
|
|
232
232
|
const ruleSubproofNode = metaproofStep.getRuleSubproofNode(),
|
|
233
233
|
metastatementNode = metaproofStep.getMetastatementNode()
|
|
234
234
|
|
|
235
235
|
if (ruleSubproofNode !== null) {
|
|
236
|
-
const ruleSubProofNodeMatches = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext,
|
|
236
|
+
const ruleSubProofNodeMatches = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, metastatementLocalMetaContext);
|
|
237
237
|
|
|
238
238
|
if (!ruleSubProofNodeMatches) { ///
|
|
239
239
|
return true;
|
|
@@ -241,7 +241,7 @@ function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, m
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
if (metastatementNode !== null) {
|
|
244
|
-
const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode, substitutions, fileContext,
|
|
244
|
+
const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementLocalMetaContext);
|
|
245
245
|
|
|
246
246
|
if (!metastatementNodeMatches) { ///
|
|
247
247
|
return true;
|
|
@@ -254,9 +254,9 @@ function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, m
|
|
|
254
254
|
return premiseMatches;
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
function metaMatchPremises(premise, metaproofSteps, substitutions, fileContext,
|
|
257
|
+
function metaMatchPremises(premise, metaproofSteps, substitutions, fileContext, metastatementLocalMetaContext) {
|
|
258
258
|
const premisesMatch = premise.every((premise) => {
|
|
259
|
-
const premiseMatches = metaMatchPremise(premise, metaproofSteps, substitutions, fileContext,
|
|
259
|
+
const premiseMatches = metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, metastatementLocalMetaContext);
|
|
260
260
|
|
|
261
261
|
if (premiseMatches) {
|
|
262
262
|
return true;
|
|
@@ -266,8 +266,8 @@ function metaMatchPremises(premise, metaproofSteps, substitutions, fileContext,
|
|
|
266
266
|
return premisesMatch;
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
-
function metaMatchConclusion(conclusion, metastatementNode, substitutions, fileContext,
|
|
270
|
-
const metastatementNodeMatches = conclusion.matchMetastatementNode(metastatementNode, substitutions, fileContext,
|
|
269
|
+
function metaMatchConclusion(conclusion, metastatementNode, substitutions, fileContext, metastatementLocalMetaContext) {
|
|
270
|
+
const metastatementNodeMatches = conclusion.matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementLocalMetaContext),
|
|
271
271
|
conclusionMatches = metastatementNodeMatches; ///
|
|
272
272
|
|
|
273
273
|
return conclusionMatches;
|
package/src/supposition.js
CHANGED
|
@@ -20,7 +20,7 @@ export default class Supposition {
|
|
|
20
20
|
return this.statementNode;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
matchSubproofNode(subproofNode, substitutions,
|
|
23
|
+
matchSubproofNode(subproofNode, substitutions, localContext, statementLocalContext) {
|
|
24
24
|
let subproofNodeMatches = false;
|
|
25
25
|
|
|
26
26
|
const subproofAssertionNode = subproofAssertionNodeQuery(this.statementNode);
|
|
@@ -41,9 +41,9 @@ export default class Supposition {
|
|
|
41
41
|
const subproofStatementNode = subproofStatementNodes[index],
|
|
42
42
|
nonTerminalNodeA = subproofAssertionStatementNode, ///
|
|
43
43
|
nonTerminalNodeB = subproofStatementNode, ///
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
nonTerminalNodeVerified = suppositionTermForVariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions,
|
|
44
|
+
localContextA = localContext, ///
|
|
45
|
+
localContextB = statementLocalContext, ///
|
|
46
|
+
nonTerminalNodeVerified = suppositionTermForVariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
47
47
|
const verifiedAhead = true;
|
|
48
48
|
|
|
49
49
|
return verifiedAhead;
|
|
@@ -59,12 +59,12 @@ export default class Supposition {
|
|
|
59
59
|
return subproofNodeMatches;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
matchStatementNode(statementNode, substitutions,
|
|
62
|
+
matchStatementNode(statementNode, substitutions, localContext, statementLocalContext) {
|
|
63
63
|
const nonTerminalNodeA = this.statementNode, ///
|
|
64
64
|
nonTerminalNodeB = statementNode, ///
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
nonTerminalNodeVerified = suppositionTermForVariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions,
|
|
65
|
+
localContextA = localContext, ///
|
|
66
|
+
localContextB = statementLocalContext, ///
|
|
67
|
+
nonTerminalNodeVerified = suppositionTermForVariableNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
68
68
|
const verifiedAhead = true;
|
|
69
69
|
|
|
70
70
|
return verifiedAhead;
|
package/src/term.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export default class Term {
|
|
4
|
+
constructor(node, type) {
|
|
5
|
+
this.node = node;
|
|
6
|
+
this.type = type;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
getNode() {
|
|
10
|
+
return this.node;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getType() {
|
|
14
|
+
return this.type;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
match(term) {
|
|
18
|
+
const node = term.getNode(),
|
|
19
|
+
matches = this.node.match(node);
|
|
20
|
+
|
|
21
|
+
return matches;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static fromTermNodeAndType(termNode, type) {
|
|
25
|
+
const node = termNode, ///
|
|
26
|
+
term = new Term(node, type);
|
|
27
|
+
|
|
28
|
+
return term;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/theorem.js
CHANGED
|
@@ -5,5 +5,5 @@ import AxiomLemmaTheoremConjecture from "./axiomLemmaTheoremConjecture";
|
|
|
5
5
|
export default class Theorem extends AxiomLemmaTheoremConjecture {
|
|
6
6
|
static fromJSONAndFileContext(json, fileContext) { return AxiomLemmaTheoremConjecture.fromJSONAndFileContext(Theorem, json, fileContext); }
|
|
7
7
|
|
|
8
|
-
static
|
|
8
|
+
static fromLabelsSuppositionsConsequentAndLocalContext(labels, suppositions, consequent, localContext) { return AxiomLemmaTheoremConjecture.fromLabelsSuppositionsConsequentAndLocalContext(Theorem, labels, suppositions, consequent, localContext); }
|
|
9
9
|
}
|
package/src/type.js
CHANGED
|
@@ -74,13 +74,13 @@ export default class Type {
|
|
|
74
74
|
return equalToOrSuperTypeOf;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
isEqualToSubTypeOfOrSuperTypeOf(type) {
|
|
78
78
|
const equalTo = this.isEqualTo(type),
|
|
79
79
|
subTypeOf = this.isSubTypeOf(type),
|
|
80
80
|
superTypeOf = this.isSuperTypeOf(type),
|
|
81
|
-
|
|
81
|
+
equalToOrSubTypeOfSuperTypeOf = (equalTo || subTypeOf || superTypeOf);
|
|
82
82
|
|
|
83
|
-
return
|
|
83
|
+
return equalToOrSubTypeOfSuperTypeOf;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
match(type) {
|
package/src/utilities/array.js
CHANGED
|
@@ -6,7 +6,7 @@ import permutationsMatrix from "../permutationsMatrix";
|
|
|
6
6
|
|
|
7
7
|
import { MAXIMUM_INDEXES_LENGTH, MAXIMUM_PERMUTATION_LENGTH } from "../constants";
|
|
8
8
|
|
|
9
|
-
export const { first, second, last, push, prune, filter,
|
|
9
|
+
export const { first, second, last, push, prune, filter, compress } = arrayUtilities;
|
|
10
10
|
|
|
11
11
|
export function someSubArray(array, subArrayLength, callback) {
|
|
12
12
|
let found = false;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { compress } from "../utilities/array";
|
|
4
|
+
|
|
5
|
+
export function mergeCollections(collectionsA, collectionsB) {
|
|
6
|
+
const typesA = typesFromCollections(collectionsA),
|
|
7
|
+
typesB = typesFromCollections(collectionsB),
|
|
8
|
+
types = [
|
|
9
|
+
...typesA,
|
|
10
|
+
...typesB
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
compress(types, (typeA, typeB) => {
|
|
14
|
+
if (typeA === typeB) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const collections = types.map((type) => {
|
|
20
|
+
let collection;
|
|
21
|
+
|
|
22
|
+
const collectionA = findCollectionByType(collectionsA, type),
|
|
23
|
+
collectionB = findCollectionByType(collectionsB, type);
|
|
24
|
+
|
|
25
|
+
if ((collectionA !== null) && (collectionB !== null)) {
|
|
26
|
+
collection = Collection.fromCollections(collectionA, collectionB);
|
|
27
|
+
} else if (collectionA !== null) {
|
|
28
|
+
collection = collectionA; ///
|
|
29
|
+
} else if (collectionB !== null) {
|
|
30
|
+
collection = collectionB; ///
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return collection;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return collections;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function findCollectionByType(collections, type) {
|
|
40
|
+
const collection = collections.find((collection) => {
|
|
41
|
+
const collectionMatchesType = collection.matchType(type);
|
|
42
|
+
|
|
43
|
+
if (collectionMatchesType) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}) || null;
|
|
47
|
+
|
|
48
|
+
return collection;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function findCollectionByTerm(collections, term) {
|
|
52
|
+
const collection = collections.find((collection) => {
|
|
53
|
+
const collectionMatchesTerm = collection.matchTerm(term);
|
|
54
|
+
|
|
55
|
+
if (collectionMatchesTerm) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}) || null;
|
|
59
|
+
|
|
60
|
+
return collection;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function findCollectionByTerms(collections, terms) {
|
|
64
|
+
const collection = collections.find((collection) => {
|
|
65
|
+
const collectionMatchesTerms = collection.matchTerms(terms);
|
|
66
|
+
|
|
67
|
+
if (collectionMatchesTerms) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
}) || null;
|
|
71
|
+
|
|
72
|
+
return collection;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function typesFromCollections(collections) {
|
|
76
|
+
const types = collections.map((collection) => {
|
|
77
|
+
const type = collection.getType();
|
|
78
|
+
|
|
79
|
+
return type;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return types;
|
|
83
|
+
}
|
|
@@ -6,7 +6,7 @@ import { METAVARIABLE_RULE_NAME } from "../../ruleNames";
|
|
|
6
6
|
import { metavariableNameFromMetavariableNode } from "../../utilities/query";
|
|
7
7
|
|
|
8
8
|
class MetastatementNodeVerifier extends NodeVerifier {
|
|
9
|
-
verifyNonTerminalNode(nonTerminalNode,
|
|
9
|
+
verifyNonTerminalNode(nonTerminalNode, localMetaContext, verifyAhead) {
|
|
10
10
|
let nonTerminalNodeVerified;
|
|
11
11
|
|
|
12
12
|
const ruleName = nonTerminalNode.getRuleName(); ///
|
|
@@ -14,7 +14,7 @@ class MetastatementNodeVerifier extends NodeVerifier {
|
|
|
14
14
|
switch (ruleName) {
|
|
15
15
|
case METAVARIABLE_RULE_NAME: {
|
|
16
16
|
const metavariableNode = nonTerminalNode, ///
|
|
17
|
-
metavariableVerified = verifyMetavariable(metavariableNode,
|
|
17
|
+
metavariableVerified = verifyMetavariable(metavariableNode, localMetaContext, verifyAhead),
|
|
18
18
|
metavariableNodeVerified = metavariableVerified; ///
|
|
19
19
|
|
|
20
20
|
nonTerminalNodeVerified = metavariableNodeVerified; ///
|
|
@@ -23,7 +23,7 @@ class MetastatementNodeVerifier extends NodeVerifier {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
default: {
|
|
26
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNode,
|
|
26
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNode, localMetaContext, verifyAhead);
|
|
27
27
|
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
@@ -37,15 +37,15 @@ const metastatementNodeVerifier = new MetastatementNodeVerifier();
|
|
|
37
37
|
|
|
38
38
|
export default metastatementNodeVerifier;
|
|
39
39
|
|
|
40
|
-
function verifyMetavariable(metavariableNode,
|
|
40
|
+
function verifyMetavariable(metavariableNode, localMetaContext, verifyAhead) {
|
|
41
41
|
let metavariableVerified;
|
|
42
42
|
|
|
43
|
-
const metavariableString =
|
|
43
|
+
const metavariableString = localMetaContext.nodeAsString(metavariableNode);
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
localMetaContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
46
46
|
|
|
47
47
|
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
48
|
-
metavariablePresent =
|
|
48
|
+
metavariablePresent = localMetaContext.isMetavariablePresentByMetavariableName(metavariableName);
|
|
49
49
|
|
|
50
50
|
if (metavariablePresent) {
|
|
51
51
|
const verifiedAhead = verifyAhead();
|
|
@@ -54,7 +54,7 @@ function verifyMetavariable(metavariableNode, metaproofContext, verifyAhead) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
if (metavariableVerified) {
|
|
57
|
-
|
|
57
|
+
localMetaContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
return metavariableVerified;
|
|
@@ -58,9 +58,9 @@ export function verifyStandaloneTerm(termNode, fileContext, verifyAhead) {
|
|
|
58
58
|
|
|
59
59
|
fileContext.trace(`Verifying the '${termString}' standalone term...`, termNode);
|
|
60
60
|
|
|
61
|
-
const
|
|
61
|
+
const terms = [],
|
|
62
62
|
context = fileContext, ///
|
|
63
|
-
termVerified = verifyTerm(termNode,
|
|
63
|
+
termVerified = verifyTerm(termNode, terms, context, verifyAhead);
|
|
64
64
|
|
|
65
65
|
standaloneTermVerified = termVerified; ///
|
|
66
66
|
|
|
@@ -10,7 +10,7 @@ import { metavariableNameFromMetavariableNode } from "../../utilities/query";
|
|
|
10
10
|
const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!');
|
|
11
11
|
|
|
12
12
|
export default class MetastatementForMetavariableNodesVerifier extends NodesVerifier {
|
|
13
|
-
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA,
|
|
13
|
+
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead) {
|
|
14
14
|
let nonTerminalNodeVerified = false;
|
|
15
15
|
|
|
16
16
|
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
@@ -23,28 +23,28 @@ export default class MetastatementForMetavariableNodesVerifier extends NodesVeri
|
|
|
23
23
|
if (nonTerminalNodeARuleNameMetastatementRuleName && nonTerminalNodeBRuleNameMetastatementRuleName) {
|
|
24
24
|
const metastatementNodeA = nonTerminalNodeA, ///
|
|
25
25
|
metastatementNodeB = nonTerminalNodeB, ///
|
|
26
|
-
metastatementNodeVerified = this.verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions, fileContextA,
|
|
26
|
+
metastatementNodeVerified = this.verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead);
|
|
27
27
|
|
|
28
28
|
if (metastatementNodeVerified) {
|
|
29
29
|
nonTerminalNodeVerified = true; ///
|
|
30
30
|
} else {
|
|
31
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA,
|
|
31
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead);
|
|
32
32
|
}
|
|
33
33
|
} else {
|
|
34
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA,
|
|
34
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
return nonTerminalNodeVerified;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions, fileContextA,
|
|
41
|
+
verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead) {
|
|
42
42
|
let metastatementNodeVerified = false;
|
|
43
43
|
|
|
44
44
|
const metavariableNodeA = metavariableNodeQuery(metastatementNodeA);
|
|
45
45
|
|
|
46
46
|
if (metavariableNodeA !== null) {
|
|
47
|
-
const metaVariableNodeVerified = this.verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions, fileContextA,
|
|
47
|
+
const metaVariableNodeVerified = this.verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead);
|
|
48
48
|
|
|
49
49
|
metastatementNodeVerified = metaVariableNodeVerified; ///
|
|
50
50
|
}
|
|
@@ -52,7 +52,7 @@ export default class MetastatementForMetavariableNodesVerifier extends NodesVeri
|
|
|
52
52
|
return metastatementNodeVerified;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions, fileContextA,
|
|
55
|
+
verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions, fileContextA, localMetaContextB, verifyAhead) {
|
|
56
56
|
let metavariableNodeVerified;
|
|
57
57
|
|
|
58
58
|
const metavariableNameA = metavariableNameFromMetavariableNode(metavariableNodeA),
|
|
@@ -11,7 +11,7 @@ const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!'),
|
|
|
11
11
|
metaArgumentChildNodeNodeQuery = nodeQuery('/metaArgument/*!');
|
|
12
12
|
|
|
13
13
|
export default class StatementForMetavariableNodesVerifier extends NodesVerifier {
|
|
14
|
-
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA,
|
|
14
|
+
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContext) {
|
|
15
15
|
let nonTerminalNodeVerified = false;
|
|
16
16
|
|
|
17
17
|
const nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(),
|
|
@@ -23,7 +23,7 @@ export default class StatementForMetavariableNodesVerifier extends NodesVerifier
|
|
|
23
23
|
|
|
24
24
|
nonTerminalNodeB = metaArgumentChildNodeB; ///
|
|
25
25
|
|
|
26
|
-
nonTerminalNodeVerified = this.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA,
|
|
26
|
+
nonTerminalNodeVerified = this.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContext);
|
|
27
27
|
} else {
|
|
28
28
|
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
29
29
|
nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(),
|
|
@@ -33,7 +33,7 @@ export default class StatementForMetavariableNodesVerifier extends NodesVerifier
|
|
|
33
33
|
if (nonTerminalNodeARuleNameMetastatementRuleName && nonTerminalNodeBRuleNameStatementRuleName) {
|
|
34
34
|
const metastatementNodeA = nonTerminalNodeA, ///
|
|
35
35
|
statementNodeB = nonTerminalNodeB, ///
|
|
36
|
-
statementNodeVerified = this.verifyStatementNode(metastatementNodeA, statementNodeB, substitutions, fileContextA,
|
|
36
|
+
statementNodeVerified = this.verifyStatementNode(metastatementNodeA, statementNodeB, substitutions, fileContextA, localContext);
|
|
37
37
|
|
|
38
38
|
if (statementNodeVerified) {
|
|
39
39
|
nonTerminalNodeVerified = true; ///
|
|
@@ -42,25 +42,25 @@ export default class StatementForMetavariableNodesVerifier extends NodesVerifier
|
|
|
42
42
|
nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
|
|
43
43
|
childNodesA = nonTerminalNodeAChildNodes, ///
|
|
44
44
|
childNodesB = nonTerminalNodeBChildNodes, ///
|
|
45
|
-
childNodesVerified = this.verifyChildNodes(childNodesA, childNodesB, substitutions, fileContextA,
|
|
45
|
+
childNodesVerified = this.verifyChildNodes(childNodesA, childNodesB, substitutions, fileContextA, localContext);
|
|
46
46
|
|
|
47
47
|
nonTerminalNodeVerified = childNodesVerified; ///
|
|
48
48
|
}
|
|
49
49
|
} else if (nonTerminalNodeBRuleName === nonTerminalNodeARuleName) {
|
|
50
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA,
|
|
50
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, localContext);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
return nonTerminalNodeVerified;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
verifyStatementNode(metastatementNodeA, statementNodeB, substitutions, fileContextA,
|
|
57
|
+
verifyStatementNode(metastatementNodeA, statementNodeB, substitutions, fileContextA, localContext) {
|
|
58
58
|
let statementNodeVerified = false;
|
|
59
59
|
|
|
60
60
|
const metavariableNodeA = metavariableNodeQuery(metastatementNodeA);
|
|
61
61
|
|
|
62
62
|
if (metavariableNodeA !== null) {
|
|
63
|
-
const metavariableNodeVerified = this.verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions, fileContextA,
|
|
63
|
+
const metavariableNodeVerified = this.verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions, fileContextA, localContext);
|
|
64
64
|
|
|
65
65
|
statementNodeVerified = metavariableNodeVerified; ///
|
|
66
66
|
}
|
|
@@ -68,7 +68,7 @@ export default class StatementForMetavariableNodesVerifier extends NodesVerifier
|
|
|
68
68
|
return statementNodeVerified;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions, fileContextA,
|
|
71
|
+
verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions, fileContextA, localContext) {
|
|
72
72
|
let metavariableNodeVerified;
|
|
73
73
|
|
|
74
74
|
const metavariableNameA = metavariableNameFromMetavariableNode(metavariableNodeA),
|
|
@@ -76,13 +76,14 @@ export function verifyArgument(argumentNode, constructorArgumentNode, context, v
|
|
|
76
76
|
|
|
77
77
|
if (constructorTypeNode !== null) {
|
|
78
78
|
const { verifyTerm } = termNodesVerifier,
|
|
79
|
-
|
|
80
|
-
termVerified = verifyTerm(termNode,
|
|
79
|
+
terms = [],
|
|
80
|
+
termVerified = verifyTerm(termNode, terms, context, () => {
|
|
81
81
|
let verifiedAhead = false;
|
|
82
82
|
|
|
83
83
|
const constructorTypeName = typeNameFromTypeNode(constructorTypeNode),
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
firstTerm = first(terms),
|
|
85
|
+
term = firstTerm, ///
|
|
86
|
+
termType = term.getType(),
|
|
86
87
|
constructorType = context.findTypeByTypeName(constructorTypeName),
|
|
87
88
|
termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(constructorType);
|
|
88
89
|
|
|
@@ -12,7 +12,7 @@ import { variableNameFromVariableNode } from "../../utilities/query";
|
|
|
12
12
|
const variableNodeQuery = nodeQuery('/term/variable!');
|
|
13
13
|
|
|
14
14
|
export default class TermForVariableNodesVerifier extends NodesVerifier {
|
|
15
|
-
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions,
|
|
15
|
+
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, verifyAhead) {
|
|
16
16
|
let nonTerminalNodeVerified = false;
|
|
17
17
|
|
|
18
18
|
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
@@ -25,28 +25,28 @@ export default class TermForVariableNodesVerifier extends NodesVerifier {
|
|
|
25
25
|
if (nonTerminalNodeARuleNameTermRuleName && nonTerminalNodeBRuleNameTermRuleName) {
|
|
26
26
|
const termNodeA = nonTerminalNodeA, ///
|
|
27
27
|
termNodeB = nonTerminalNodeB, ///
|
|
28
|
-
termNodeVerified = this.verifyTermNode(termNodeA, termNodeB, substitutions,
|
|
28
|
+
termNodeVerified = this.verifyTermNode(termNodeA, termNodeB, substitutions, localContextA, localContextB, verifyAhead);
|
|
29
29
|
|
|
30
30
|
if (termNodeVerified) {
|
|
31
31
|
nonTerminalNodeVerified = true; ///
|
|
32
32
|
} else {
|
|
33
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions,
|
|
33
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, verifyAhead);
|
|
34
34
|
}
|
|
35
35
|
} else {
|
|
36
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions,
|
|
36
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, verifyAhead);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
return nonTerminalNodeVerified;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
verifyTermNode(termNodeA, termNodeB, substitutions,
|
|
43
|
+
verifyTermNode(termNodeA, termNodeB, substitutions, localContextA, localContextB, verifyAhead) {
|
|
44
44
|
let termNodeVerified = false;
|
|
45
45
|
|
|
46
46
|
const variableNodeA = variableNodeQuery(termNodeA);
|
|
47
47
|
|
|
48
48
|
if (variableNodeA !== null) {
|
|
49
|
-
const variableVerified = this.verifyVariableNode(variableNodeA, termNodeB, substitutions,
|
|
49
|
+
const variableVerified = this.verifyVariableNode(variableNodeA, termNodeB, substitutions, localContextA, localContextB, verifyAhead);
|
|
50
50
|
|
|
51
51
|
termNodeVerified = variableVerified; ///
|
|
52
52
|
}
|
|
@@ -54,7 +54,7 @@ export default class TermForVariableNodesVerifier extends NodesVerifier {
|
|
|
54
54
|
return termNodeVerified;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
verifyVariableNode(variableNodeA, termNodeB, substitutions,
|
|
57
|
+
verifyVariableNode(variableNodeA, termNodeB, substitutions, localContextA, localContextB, verifyAhead) {
|
|
58
58
|
let variableVerified = false;
|
|
59
59
|
|
|
60
60
|
const variableNameA = variableNameFromVariableNode(variableNodeA),
|
|
@@ -80,18 +80,19 @@ export default class TermForVariableNodesVerifier extends NodesVerifier {
|
|
|
80
80
|
|
|
81
81
|
if (createSubstitutions) {
|
|
82
82
|
const variableName = variableNameA, ///
|
|
83
|
-
|
|
84
|
-
variable =
|
|
83
|
+
localContext = localContextA, ///
|
|
84
|
+
variable = localContext.findVariableByVariableName(variableName);
|
|
85
85
|
|
|
86
86
|
if (variable !== null) {
|
|
87
|
-
const
|
|
88
|
-
context =
|
|
87
|
+
const terms = [],
|
|
88
|
+
context = localContextB, ///
|
|
89
89
|
termNode = termNodeB, ///
|
|
90
|
-
termVerified = verifyTerm(termNode,
|
|
90
|
+
termVerified = verifyTerm(termNode, terms, context, () => {
|
|
91
91
|
let verifiedAhead = false;
|
|
92
92
|
|
|
93
|
-
const
|
|
94
|
-
|
|
93
|
+
const firstTerm = first(terms),
|
|
94
|
+
term = firstTerm, ///
|
|
95
|
+
termType = term.getType(),
|
|
95
96
|
variableType = variable.getType(),
|
|
96
97
|
variableTypeEqualToOrSuperTypeOfTermType = variableType.isEqualToOrSuperTypeOf(termType);
|
|
97
98
|
|