occam-verify-cli 0.0.538 → 0.0.539
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/action/verify.js +3 -24
- package/bin/actions.js +20 -6
- package/lib/axiom.js +4 -4
- package/lib/axiomLemmaTheoremConjecture.js +28 -25
- package/lib/conclusion.js +5 -5
- package/lib/conjecture.js +4 -4
- package/lib/consequence.js +3 -3
- package/lib/context/file.js +90 -28
- package/lib/kinds.js +5 -1
- package/lib/lemma.js +4 -4
- package/lib/metaType.js +201 -0
- package/lib/metavariable.js +75 -0
- package/lib/premise.js +9 -9
- package/lib/rule.js +36 -29
- package/lib/supposition.js +5 -5
- package/lib/theorem.js +4 -4
- package/lib/utilities/query.js +13 -2
- package/lib/variable.js +12 -12
- package/lib/verifier/metastatementForMetavariable.js +8 -8
- package/lib/verifier/statementForMetavariable.js +9 -9
- package/lib/verifier/termForVariable.js +22 -11
- package/lib/verify/assertion/type.js +2 -2
- package/lib/verify/axiom.js +2 -2
- package/lib/verify/conjecture.js +2 -2
- package/lib/verify/declaration/metavariable.js +26 -0
- package/lib/verify/declaration/topLevel.js +7 -3
- package/lib/verify/lemma.js +2 -2
- package/lib/verify/metastatement/qualified.js +3 -3
- package/lib/verify/metavariable.js +34 -0
- package/lib/verify/rule.js +2 -2
- package/lib/verify/statement/qualified.js +7 -7
- package/lib/verify/statement.js +5 -5
- package/lib/verify/theorem.js +2 -2
- package/lib/verify/variable.js +4 -4
- package/package.json +3 -3
- package/src/axiom.js +1 -1
- package/src/axiomLemmaTheoremConjecture.js +27 -28
- package/src/conclusion.js +8 -4
- package/src/conjecture.js +1 -1
- package/src/consequence.js +2 -2
- package/src/context/file.js +97 -28
- package/src/kinds.js +1 -0
- package/src/lemma.js +1 -1
- package/src/metaType.js +81 -0
- package/src/metavariable.js +35 -0
- package/src/premise.js +16 -8
- package/src/rule.js +32 -27
- package/src/supposition.js +8 -4
- package/src/theorem.js +1 -1
- package/src/utilities/query.js +14 -0
- package/src/variable.js +8 -8
- package/src/verifier/metastatementForMetavariable.js +7 -7
- package/src/verifier/statementForMetavariable.js +8 -8
- package/src/verifier/termForVariable.js +33 -13
- package/src/verify/assertion/type.js +3 -3
- package/src/verify/axiom.js +1 -1
- package/src/verify/conjecture.js +2 -1
- package/src/verify/declaration/metavariable.js +20 -0
- package/src/verify/declaration/topLevel.js +9 -2
- package/src/verify/lemma.js +1 -1
- package/src/verify/metastatement/qualified.js +3 -2
- package/src/verify/metavariable.js +32 -0
- package/src/verify/rule.js +1 -1
- package/src/verify/statement/qualified.js +7 -6
- package/src/verify/statement.js +12 -12
- package/src/verify/theorem.js +2 -1
- package/src/verify/variable.js +4 -4
package/src/premise.js
CHANGED
|
@@ -22,7 +22,7 @@ export default class Premise {
|
|
|
22
22
|
return this.metastatementNode;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
matchSubproofNode(subproofNode, substitutions) {
|
|
25
|
+
matchSubproofNode(subproofNode, substitutions, fileContext, statementProofContext) {
|
|
26
26
|
let subproofNodeMatches = false;
|
|
27
27
|
|
|
28
28
|
const subproofAssertionNode = ruleSubproofAssertionNodeQuery(this.metastatementNode);
|
|
@@ -43,7 +43,9 @@ export default class Premise {
|
|
|
43
43
|
const subproofStatementNode = subproofStatementNodes[index],
|
|
44
44
|
nonTerminalNodeA = ruleSubproofAssertionMetastatementNode, ///
|
|
45
45
|
nonTerminalNodeB = subproofStatementNode, ///
|
|
46
|
-
|
|
46
|
+
fileContextA = fileContext, ///
|
|
47
|
+
proofContextB = statementProofContext, ///
|
|
48
|
+
nonTerminalNodeVerified = premiseStatementForMetavariableVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, proofContextB);
|
|
47
49
|
|
|
48
50
|
if (nonTerminalNodeVerified) {
|
|
49
51
|
return true;
|
|
@@ -55,16 +57,18 @@ export default class Premise {
|
|
|
55
57
|
return subproofNodeMatches;
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
matchStatementNode(statementNode, substitutions) {
|
|
60
|
+
matchStatementNode(statementNode, substitutions, fileContext, statementProofContext) {
|
|
59
61
|
const nonTerminalNodeA = this.metastatementNode, ///
|
|
60
62
|
nonTerminalNodeB = statementNode, ///
|
|
61
|
-
|
|
63
|
+
fileContextA = fileContext, ///
|
|
64
|
+
proofContextB = statementProofContext, ///
|
|
65
|
+
nonTerminalNodeVerified = premiseStatementForMetavariableVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, proofContextB),
|
|
62
66
|
statementNodeMatches = nonTerminalNodeVerified; ///
|
|
63
67
|
|
|
64
68
|
return statementNodeMatches;
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
matchRuleSubproofNode(ruleSubproofNode, substitutions) {
|
|
71
|
+
matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, metastatementMetaproofContext) {
|
|
68
72
|
let ruleSubproofNodeMatches = false;
|
|
69
73
|
|
|
70
74
|
const ruleSubproofAssertionNode = ruleSubproofAssertionNodeQuery(this.metastatementNode);
|
|
@@ -85,7 +89,9 @@ export default class Premise {
|
|
|
85
89
|
const ruleSubproofMetastatementNode = ruleSubproofMetastatementNodes[index],
|
|
86
90
|
nonTerminalNodeA = ruleSubproofAssertionMetastatementNode, ///
|
|
87
91
|
nonTerminalNodeB = ruleSubproofMetastatementNode, ///
|
|
88
|
-
|
|
92
|
+
fileContextA = fileContext, ///
|
|
93
|
+
metaproofContextB = metastatementMetaproofContext, ///
|
|
94
|
+
nonTerminalNodeVerified = premiseMetastatementForMetavariableVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, metaproofContextB);
|
|
89
95
|
|
|
90
96
|
if (nonTerminalNodeVerified) {
|
|
91
97
|
return true;
|
|
@@ -97,10 +103,12 @@ export default class Premise {
|
|
|
97
103
|
return ruleSubproofNodeMatches;
|
|
98
104
|
}
|
|
99
105
|
|
|
100
|
-
matchMetastatementNode(metastatementNode, substitutions) {
|
|
106
|
+
matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementMetaproofContext) {
|
|
101
107
|
const nonTerminalNodeA = this.metastatementNode, ///
|
|
102
108
|
nonTerminalNodeB = metastatementNode, ///
|
|
103
|
-
|
|
109
|
+
fileContextA = fileContext, ///
|
|
110
|
+
metaproofContextB = metastatementMetaproofContext, ///
|
|
111
|
+
nonTerminalNodeVerified = premiseMetastatementForMetavariableVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, metaproofContextB),
|
|
104
112
|
metastatementNodeMatches = nonTerminalNodeVerified; ///
|
|
105
113
|
|
|
106
114
|
return metastatementNodeMatches;
|
package/src/rule.js
CHANGED
|
@@ -9,10 +9,11 @@ import { RULE_KIND } from "./kinds";
|
|
|
9
9
|
import { someSubArray } from "./utilities/array";
|
|
10
10
|
|
|
11
11
|
export default class Rule {
|
|
12
|
-
constructor(labels, premises, conclusion) {
|
|
12
|
+
constructor(labels, premises, conclusion, fileContext) {
|
|
13
13
|
this.labels = labels;
|
|
14
14
|
this.premises = premises;
|
|
15
15
|
this.conclusion = conclusion;
|
|
16
|
+
this.fileContext = fileContext;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
getLabels() {
|
|
@@ -27,6 +28,10 @@ export default class Rule {
|
|
|
27
28
|
return this.conclusion;
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
getFileContext() {
|
|
32
|
+
return this.fileContext;
|
|
33
|
+
}
|
|
34
|
+
|
|
30
35
|
matchLabelName(labelName) {
|
|
31
36
|
const matchesLabelName = this.labels.some((label) => {
|
|
32
37
|
const name = labelName, ///
|
|
@@ -40,27 +45,27 @@ export default class Rule {
|
|
|
40
45
|
return matchesLabelName;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
matchStatement(statementNode,
|
|
48
|
+
matchStatement(statementNode, statementProofContext) {
|
|
44
49
|
let statementNatches;
|
|
45
50
|
|
|
46
51
|
const premisesLength = this.premises.length;
|
|
47
52
|
|
|
48
53
|
if (premisesLength === 0) {
|
|
49
54
|
const substitutions = [],
|
|
50
|
-
conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions);
|
|
55
|
+
conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, statementProofContext);
|
|
51
56
|
|
|
52
57
|
statementNatches = conclusionMatches; ///
|
|
53
58
|
} else {
|
|
54
|
-
const proofSteps =
|
|
59
|
+
const proofSteps = statementProofContext.getProofSteps();
|
|
55
60
|
|
|
56
61
|
statementNatches = someSubArray(proofSteps, premisesLength, (proofSteps) => {
|
|
57
62
|
let premisesMatchConclusion = false;
|
|
58
63
|
|
|
59
64
|
const substitutions = [],
|
|
60
|
-
premisesMatch = matchPremises(this.premises, proofSteps, substitutions);
|
|
65
|
+
premisesMatch = matchPremises(this.premises, proofSteps, substitutions, this.fileContext, statementProofContext);
|
|
61
66
|
|
|
62
67
|
if (premisesMatch) {
|
|
63
|
-
const conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions);
|
|
68
|
+
const conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, statementProofContext);
|
|
64
69
|
|
|
65
70
|
premisesMatchConclusion = conclusionMatches; ///
|
|
66
71
|
}
|
|
@@ -74,27 +79,27 @@ export default class Rule {
|
|
|
74
79
|
return statementNatches;
|
|
75
80
|
}
|
|
76
81
|
|
|
77
|
-
matchMetastatement(metastatementNode,
|
|
82
|
+
matchMetastatement(metastatementNode, metastatementMetaproofContext) {
|
|
78
83
|
let metastatementNatches;
|
|
79
84
|
|
|
80
85
|
const premisesLength = this.premises.length;
|
|
81
86
|
|
|
82
87
|
if (premisesLength === 0) {
|
|
83
88
|
const substitutions = [],
|
|
84
|
-
conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions);
|
|
89
|
+
conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, metastatementMetaproofContext);
|
|
85
90
|
|
|
86
91
|
metastatementNatches = conclusionMatches; ///
|
|
87
92
|
} else {
|
|
88
|
-
const metaproofSteps =
|
|
93
|
+
const metaproofSteps = metastatementMetaproofContext.getMetaproofSteps();
|
|
89
94
|
|
|
90
95
|
metastatementNatches = someSubArray(metaproofSteps, premisesLength, (metaproofSteps) => {
|
|
91
96
|
let premisesMatchConclusion = false;
|
|
92
97
|
|
|
93
98
|
const substitutions = [],
|
|
94
|
-
premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions);
|
|
99
|
+
premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions, this.fileContext, metastatementMetaproofContext);
|
|
95
100
|
|
|
96
101
|
if (premisesMatch) {
|
|
97
|
-
const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions);
|
|
102
|
+
const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, metastatementMetaproofContext);
|
|
98
103
|
|
|
99
104
|
premisesMatchConclusion = conclusionMatches; ///
|
|
100
105
|
}
|
|
@@ -172,20 +177,20 @@ export default class Rule {
|
|
|
172
177
|
return rule;
|
|
173
178
|
}
|
|
174
179
|
|
|
175
|
-
static
|
|
176
|
-
const rule = new Rule(labels, premises, conclusion);
|
|
180
|
+
static fromLabelsPremisesConclusionAndFileContext(labels, premises, conclusion, fileContext) {
|
|
181
|
+
const rule = new Rule(labels, premises, conclusion, fileContext);
|
|
177
182
|
|
|
178
183
|
return rule;
|
|
179
184
|
}
|
|
180
185
|
}
|
|
181
186
|
|
|
182
|
-
function matchPremise(premise, proofSteps, substitutions) {
|
|
187
|
+
function matchPremise(premise, proofSteps, substitutions, fileContext, statementProofContext) {
|
|
183
188
|
const proofStep = prune(proofSteps, (proofStep) => {
|
|
184
189
|
const subproofNode = proofStep.getSubproofNode(),
|
|
185
190
|
statementNode = proofStep.getStatementNode()
|
|
186
191
|
|
|
187
192
|
if (subproofNode !== null) {
|
|
188
|
-
const subProofNodeMatches = premise.matchSubproofNode(subproofNode, substitutions);
|
|
193
|
+
const subProofNodeMatches = premise.matchSubproofNode(subproofNode, substitutions, fileContext, statementProofContext);
|
|
189
194
|
|
|
190
195
|
if (!subProofNodeMatches) { ///
|
|
191
196
|
return true;
|
|
@@ -193,7 +198,7 @@ function matchPremise(premise, proofSteps, substitutions) {
|
|
|
193
198
|
}
|
|
194
199
|
|
|
195
200
|
if (statementNode !== null) {
|
|
196
|
-
const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions);
|
|
201
|
+
const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions, fileContext, statementProofContext);
|
|
197
202
|
|
|
198
203
|
if (!statementNodeMatches) { ///
|
|
199
204
|
return true;
|
|
@@ -206,9 +211,9 @@ function matchPremise(premise, proofSteps, substitutions) {
|
|
|
206
211
|
return premiseMatches;
|
|
207
212
|
}
|
|
208
213
|
|
|
209
|
-
function matchPremises(premise, proofSteps, substitutions) {
|
|
214
|
+
function matchPremises(premise, proofSteps, substitutions, fileContext, statementProofContext) {
|
|
210
215
|
const premisesMatch = premise.every((premise) => {
|
|
211
|
-
const premiseMatches = matchPremise(premise, proofSteps, substitutions);
|
|
216
|
+
const premiseMatches = matchPremise(premise, proofSteps, substitutions, fileContext, statementProofContext);
|
|
212
217
|
|
|
213
218
|
if (premiseMatches) {
|
|
214
219
|
return true;
|
|
@@ -218,20 +223,20 @@ function matchPremises(premise, proofSteps, substitutions) {
|
|
|
218
223
|
return premisesMatch;
|
|
219
224
|
}
|
|
220
225
|
|
|
221
|
-
function matchConclusion(conclusion, statementNode, substitutions) {
|
|
222
|
-
const statementNodeMatches = conclusion.matchStatementNode(statementNode, substitutions),
|
|
226
|
+
function matchConclusion(conclusion, statementNode, substitutions, fileContext, statementProofContext) {
|
|
227
|
+
const statementNodeMatches = conclusion.matchStatementNode(statementNode, substitutions, fileContext, statementProofContext),
|
|
223
228
|
conclusionMatches = statementNodeMatches; ///
|
|
224
229
|
|
|
225
230
|
return conclusionMatches;
|
|
226
231
|
}
|
|
227
232
|
|
|
228
|
-
function metaMatchPremise(premise, metaproofSteps, substitutions) {
|
|
233
|
+
function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, metastatementMetaproofContext) {
|
|
229
234
|
const metaproofStep = prune(metaproofSteps, (metaproofStep) => {
|
|
230
235
|
const ruleSubproofNode = metaproofStep.getRuleSubproofNode(),
|
|
231
236
|
metastatementNode = metaproofStep.getMetastatementNode()
|
|
232
237
|
|
|
233
238
|
if (ruleSubproofNode !== null) {
|
|
234
|
-
const ruleSubProofNodeMatches = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions);
|
|
239
|
+
const ruleSubProofNodeMatches = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, metastatementMetaproofContext);
|
|
235
240
|
|
|
236
241
|
if (!ruleSubProofNodeMatches) { ///
|
|
237
242
|
return true;
|
|
@@ -239,7 +244,7 @@ function metaMatchPremise(premise, metaproofSteps, substitutions) {
|
|
|
239
244
|
}
|
|
240
245
|
|
|
241
246
|
if (metastatementNode !== null) {
|
|
242
|
-
const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode, substitutions);
|
|
247
|
+
const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementMetaproofContext);
|
|
243
248
|
|
|
244
249
|
if (!metastatementNodeMatches) { ///
|
|
245
250
|
return true;
|
|
@@ -252,9 +257,9 @@ function metaMatchPremise(premise, metaproofSteps, substitutions) {
|
|
|
252
257
|
return premiseMatches;
|
|
253
258
|
}
|
|
254
259
|
|
|
255
|
-
function metaMatchPremises(premise, metaproofSteps, substitutions) {
|
|
260
|
+
function metaMatchPremises(premise, metaproofSteps, substitutions, fileContext, metastatementMetaproofContext) {
|
|
256
261
|
const premisesMatch = premise.every((premise) => {
|
|
257
|
-
const premiseMatches = metaMatchPremise(premise, metaproofSteps, substitutions);
|
|
262
|
+
const premiseMatches = metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, metastatementMetaproofContext);
|
|
258
263
|
|
|
259
264
|
if (premiseMatches) {
|
|
260
265
|
return true;
|
|
@@ -264,8 +269,8 @@ function metaMatchPremises(premise, metaproofSteps, substitutions) {
|
|
|
264
269
|
return premisesMatch;
|
|
265
270
|
}
|
|
266
271
|
|
|
267
|
-
function metaMatchConclusion(conclusion, metastatementNode, substitutions) {
|
|
268
|
-
const metastatementNodeMatches = conclusion.matchMetastatementNode(metastatementNode, substitutions),
|
|
272
|
+
function metaMatchConclusion(conclusion, metastatementNode, substitutions, fileContext, metastatementMetaproofContext) {
|
|
273
|
+
const metastatementNodeMatches = conclusion.matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementMetaproofContext),
|
|
269
274
|
conclusionMatches = metastatementNodeMatches; ///
|
|
270
275
|
|
|
271
276
|
return conclusionMatches;
|
package/src/supposition.js
CHANGED
|
@@ -19,7 +19,7 @@ export default class Supposition {
|
|
|
19
19
|
return this.statementNode;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
matchSubproofNode(subproofNode, substitutions) {
|
|
22
|
+
matchSubproofNode(subproofNode, substitutions, proofContext, statementProofContext) {
|
|
23
23
|
let subproofNodeMatches = false;
|
|
24
24
|
|
|
25
25
|
const subproofAssertionNode = subproofAssertionNodeQuery(this.statementNode);
|
|
@@ -40,7 +40,9 @@ export default class Supposition {
|
|
|
40
40
|
const subproofStatementNode = subproofStatementNodes[index],
|
|
41
41
|
nonTerminalNodeA = subproofAssertionStatementNode, ///
|
|
42
42
|
nonTerminalNodeB = subproofStatementNode, ///
|
|
43
|
-
|
|
43
|
+
proofContextA = proofContext, ///
|
|
44
|
+
proofContextB = statementProofContext, ///
|
|
45
|
+
nonTerminalNodeVerified = suppositionTermForVariableVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, proofContextA, proofContextB);
|
|
44
46
|
|
|
45
47
|
if (nonTerminalNodeVerified) {
|
|
46
48
|
return true;
|
|
@@ -52,10 +54,12 @@ export default class Supposition {
|
|
|
52
54
|
return subproofNodeMatches;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
matchStatementNode(statementNode, substitutions) {
|
|
57
|
+
matchStatementNode(statementNode, substitutions, proofContext, statementProofContext) {
|
|
56
58
|
const nonTerminalNodeA = this.statementNode, ///
|
|
57
59
|
nonTerminalNodeB = statementNode, ///
|
|
58
|
-
|
|
60
|
+
proofContextA = proofContext, ///
|
|
61
|
+
proofContextB = statementProofContext, ///
|
|
62
|
+
nonTerminalNodeVerified = suppositionTermForVariableVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, proofContextA, proofContextB),
|
|
59
63
|
statementNodeMatches = nonTerminalNodeVerified; ///
|
|
60
64
|
|
|
61
65
|
return statementNodeMatches;
|
package/src/theorem.js
CHANGED
|
@@ -9,5 +9,5 @@ export default class Theorem extends AxiomLemmaTheoremConjecture {
|
|
|
9
9
|
|
|
10
10
|
static fromJSON(json, context) { return AxiomLemmaTheoremConjecture.fromJSON(Theorem, json, context); }
|
|
11
11
|
|
|
12
|
-
static
|
|
12
|
+
static fromLabelsSuppositionsConsequenceAndProofContext(labels, suppositions, consequence, proofContext) { return AxiomLemmaTheoremConjecture.fromLabelsSuppositionsConsequenceAndProofContext(Theorem, labels, suppositions, consequence, proofContext); }
|
|
13
13
|
}
|
package/src/utilities/query.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Query } from "occam-dom";
|
|
4
4
|
|
|
5
5
|
const typeTerminalNodeQuery = nodeQuery("/type/@type"),
|
|
6
|
+
metaTypeTerminalNodeQuery = nodeQuery("/metaType/@meta-type"),
|
|
6
7
|
labelNameTerminalNodeQuery = nodeQuery("/label/@name"),
|
|
7
8
|
variableNameTerminalNodeQuery = nodeQuery("/variable/@name"),
|
|
8
9
|
referenceNameTerminalNodeQuery = nodeQuery("/reference/@name"),
|
|
@@ -57,6 +58,19 @@ export function labelNameFromLabelNode(labelNode) {
|
|
|
57
58
|
return labelName;
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
export function metaTypeNameFromMetaTypeNode(metaTypeNode) {
|
|
62
|
+
let metaTypeName = null;
|
|
63
|
+
|
|
64
|
+
if (metaTypeNode !== null) {
|
|
65
|
+
const metaTypeTerminalNode = metaTypeTerminalNodeQuery(metaTypeNode),
|
|
66
|
+
metaTypeTerminalNodeContent = metaTypeTerminalNode.getContent();
|
|
67
|
+
|
|
68
|
+
metaTypeName = metaTypeTerminalNodeContent; ///
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return metaTypeName;
|
|
72
|
+
}
|
|
73
|
+
|
|
60
74
|
export function variableNameFromVariableNode(variableNode) {
|
|
61
75
|
const variableNameTerminalNode = variableNameTerminalNodeQuery(variableNode),
|
|
62
76
|
variableNameTerminalNodeContent = variableNameTerminalNode.getContent(),
|
package/src/variable.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export default class Variable {
|
|
4
|
-
constructor(
|
|
5
|
-
this.type = type;
|
|
4
|
+
constructor(name, type) {
|
|
6
5
|
this.name = name;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
getType() {
|
|
10
|
-
return this.type;
|
|
6
|
+
this.type = type;
|
|
11
7
|
}
|
|
12
8
|
|
|
13
9
|
getName() {
|
|
14
10
|
return this.name;
|
|
15
11
|
}
|
|
16
12
|
|
|
13
|
+
getType() {
|
|
14
|
+
return this.type;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
17
|
matchName(name) {
|
|
18
18
|
const matchesName = (this.name === name);
|
|
19
19
|
|
|
@@ -27,8 +27,8 @@ export default class Variable {
|
|
|
27
27
|
return string;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
static
|
|
31
|
-
const variable = new Variable(
|
|
30
|
+
static fromNameAndType(name, type) {
|
|
31
|
+
const variable = new Variable(name, type);
|
|
32
32
|
|
|
33
33
|
return variable;
|
|
34
34
|
}
|
|
@@ -10,7 +10,7 @@ import { metavariableNameFromMetavariableNode } from "../utilities/query";
|
|
|
10
10
|
const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!');
|
|
11
11
|
|
|
12
12
|
export default class MetastatementForMetavariableVerifier extends Verifier {
|
|
13
|
-
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
|
|
13
|
+
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, metaproofContextB) {
|
|
14
14
|
let nonTerminalNodeVerified = false;
|
|
15
15
|
|
|
16
16
|
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
@@ -23,28 +23,28 @@ export default class MetastatementForMetavariableVerifier extends Verifier {
|
|
|
23
23
|
if (nonTerminalNodeARuleNameMetastatementRuleName && nonTerminalNodeBRuleNameMetastatementRuleName) {
|
|
24
24
|
const metastatementNodeA = nonTerminalNodeA, ///
|
|
25
25
|
metastatementNodeB = nonTerminalNodeB, ///
|
|
26
|
-
metastatementNodeVerified = this.verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions);
|
|
26
|
+
metastatementNodeVerified = this.verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions, fileContextA, metaproofContextB);
|
|
27
27
|
|
|
28
28
|
if (metastatementNodeVerified) {
|
|
29
29
|
nonTerminalNodeVerified = true; ///
|
|
30
30
|
} else {
|
|
31
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
31
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, metaproofContextB);
|
|
32
32
|
}
|
|
33
33
|
} else {
|
|
34
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
34
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, metaproofContextB);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
return nonTerminalNodeVerified;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions) {
|
|
41
|
+
verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions, fileContextA, metaproofContextB) {
|
|
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);
|
|
47
|
+
const metaVariableNodeVerified = this.verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions, fileContextA, metaproofContextB);
|
|
48
48
|
|
|
49
49
|
metastatementNodeVerified = metaVariableNodeVerified; ///
|
|
50
50
|
}
|
|
@@ -52,7 +52,7 @@ export default class MetastatementForMetavariableVerifier extends Verifier {
|
|
|
52
52
|
return metastatementNodeVerified;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions) {
|
|
55
|
+
verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions, fileContextA, metaproofContextB) {
|
|
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 StatementForMetavariableVerifier extends Verifier {
|
|
14
|
-
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
|
|
14
|
+
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, proofContextB) {
|
|
15
15
|
let nonTerminalNodeVerified = false;
|
|
16
16
|
|
|
17
17
|
const nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(),
|
|
@@ -23,7 +23,7 @@ export default class StatementForMetavariableVerifier extends Verifier {
|
|
|
23
23
|
|
|
24
24
|
nonTerminalNodeB = metaArgumentChildNodeB; ///
|
|
25
25
|
|
|
26
|
-
nonTerminalNodeVerified = this.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
26
|
+
nonTerminalNodeVerified = this.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, proofContextB);
|
|
27
27
|
} else {
|
|
28
28
|
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
29
29
|
nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(),
|
|
@@ -33,7 +33,7 @@ export default class StatementForMetavariableVerifier extends Verifier {
|
|
|
33
33
|
if (nonTerminalNodeARuleNameMetastatementRuleName && nonTerminalNodeBRuleNameStatementRuleName) {
|
|
34
34
|
const metastatementNodeA = nonTerminalNodeA, ///
|
|
35
35
|
statementNodeB = nonTerminalNodeB, ///
|
|
36
|
-
statementNodeVerified = this.verifyStatementNode(metastatementNodeA, statementNodeB, substitutions);
|
|
36
|
+
statementNodeVerified = this.verifyStatementNode(metastatementNodeA, statementNodeB, substitutions, fileContextA, proofContextB);
|
|
37
37
|
|
|
38
38
|
if (statementNodeVerified) {
|
|
39
39
|
nonTerminalNodeVerified = true; ///
|
|
@@ -42,25 +42,25 @@ export default class StatementForMetavariableVerifier extends Verifier {
|
|
|
42
42
|
nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
|
|
43
43
|
nodesA = nonTerminalNodeAChildNodes, ///
|
|
44
44
|
nodesB = nonTerminalNodeBChildNodes, ///
|
|
45
|
-
nodesMatch = this.verifyNodes(nodesA, nodesB, substitutions);
|
|
45
|
+
nodesMatch = this.verifyNodes(nodesA, nodesB, substitutions, fileContextA, proofContextB);
|
|
46
46
|
|
|
47
47
|
nonTerminalNodeVerified = nodesMatch; ///
|
|
48
48
|
}
|
|
49
49
|
} else if (nonTerminalNodeBRuleName === nonTerminalNodeARuleName) {
|
|
50
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
50
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, proofContextB);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
return nonTerminalNodeVerified;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
verifyStatementNode(metastatementNodeA, statementNodeB, substitutions) {
|
|
57
|
+
verifyStatementNode(metastatementNodeA, statementNodeB, substitutions, fileContextA, proofContextB) {
|
|
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);
|
|
63
|
+
const metavariableNodeVerified = this.verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions, fileContextA, proofContextB);
|
|
64
64
|
|
|
65
65
|
statementNodeVerified = metavariableNodeVerified; ///
|
|
66
66
|
}
|
|
@@ -68,7 +68,7 @@ export default class StatementForMetavariableVerifier extends Verifier {
|
|
|
68
68
|
return statementNodeVerified;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions) {
|
|
71
|
+
verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions, fileContextA, proofContextB) {
|
|
72
72
|
let metavariableNodeVerified;
|
|
73
73
|
|
|
74
74
|
const metavariableNameA = metavariableNameFromMetavariableNode(metavariableNodeA),
|
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
import Verifier from "../verifier";
|
|
4
4
|
import TermForVariableSubstitution from "../substitution/termForVariable";
|
|
5
5
|
|
|
6
|
+
import { first } from "../utilities/array";
|
|
6
7
|
import { nodeQuery } from "../utilities/query";
|
|
7
8
|
import { TERM_RULE_NAME } from "../ruleNames";
|
|
8
9
|
import { variableNameFromVariableNode } from "../utilities/query";
|
|
10
|
+
import { verifyTermAgainstConstructors } from "../verify/term";
|
|
9
11
|
|
|
10
12
|
const variableNodeQuery = nodeQuery('/term/variable!');
|
|
11
13
|
|
|
12
14
|
export default class TermForVariableVerifier extends Verifier {
|
|
13
|
-
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
|
|
15
|
+
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, proofContextA, proofContextB) {
|
|
14
16
|
let nonTerminalNodeVerified = false;
|
|
15
17
|
|
|
16
18
|
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
@@ -23,28 +25,28 @@ export default class TermForVariableVerifier extends Verifier {
|
|
|
23
25
|
if (nonTerminalNodeARuleNameTermRuleName && nonTerminalNodeBRuleNameTermRuleName) {
|
|
24
26
|
const termNodeA = nonTerminalNodeA, ///
|
|
25
27
|
termNodeB = nonTerminalNodeB, ///
|
|
26
|
-
termNodeVerified = this.verifyTermNode(termNodeA, termNodeB, substitutions);
|
|
28
|
+
termNodeVerified = this.verifyTermNode(termNodeA, termNodeB, substitutions, proofContextA, proofContextB);
|
|
27
29
|
|
|
28
30
|
if (termNodeVerified) {
|
|
29
31
|
nonTerminalNodeVerified = true; ///
|
|
30
32
|
} else {
|
|
31
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
33
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, proofContextA, proofContextB);
|
|
32
34
|
}
|
|
33
35
|
} else {
|
|
34
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
36
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, proofContextA, proofContextB);
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
return nonTerminalNodeVerified;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
verifyTermNode(termNodeA, termNodeB, substitutions) {
|
|
43
|
+
verifyTermNode(termNodeA, termNodeB, substitutions, proofContextA, proofContextB) {
|
|
42
44
|
let termNodeVerified = false;
|
|
43
45
|
|
|
44
46
|
const variableNodeA = variableNodeQuery(termNodeA);
|
|
45
47
|
|
|
46
48
|
if (variableNodeA !== null) {
|
|
47
|
-
const variableVerified = this.verifyVariableNode(variableNodeA, termNodeB, substitutions);
|
|
49
|
+
const variableVerified = this.verifyVariableNode(variableNodeA, termNodeB, substitutions, proofContextA, proofContextB);
|
|
48
50
|
|
|
49
51
|
termNodeVerified = variableVerified; ///
|
|
50
52
|
}
|
|
@@ -52,7 +54,7 @@ export default class TermForVariableVerifier extends Verifier {
|
|
|
52
54
|
return termNodeVerified;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
verifyVariableNode(variableNodeB, termNodeB, substitutions) {
|
|
57
|
+
verifyVariableNode(variableNodeB, termNodeB, substitutions, proofContextA, proofContextB) {
|
|
56
58
|
let variableVerified;
|
|
57
59
|
|
|
58
60
|
const variableNameA = variableNameFromVariableNode(variableNodeB),
|
|
@@ -74,14 +76,32 @@ export default class TermForVariableVerifier extends Verifier {
|
|
|
74
76
|
|
|
75
77
|
if (createSubstitutions) {
|
|
76
78
|
const variableName = variableNameA, ///
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
substitution = termForVariableSubstitution; ///
|
|
79
|
+
proofContext = proofContextA, ///
|
|
80
|
+
variable = proofContext.findVariableByVariableName(variableName);
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
if (variable !== null) {
|
|
83
|
+
const types = [],
|
|
84
|
+
context = proofContextB, ///
|
|
85
|
+
termNode = termNodeB, ///
|
|
86
|
+
termVerified = verifyTermAgainstConstructors(termNodeB, types, context);
|
|
87
|
+
|
|
88
|
+
if (termVerified) {
|
|
89
|
+
const firstType = first(types),
|
|
90
|
+
termType = firstType,
|
|
91
|
+
variableType = variable.getType(),
|
|
92
|
+
variableTypeEqualToOrSuperTypeOfTermType = variableType.isEqualToOrSuperTypeOf(termType);
|
|
93
|
+
|
|
94
|
+
if (variableTypeEqualToOrSuperTypeOfTermType) {
|
|
95
|
+
const termForVariableSubstitution = TermForVariableSubstitution.fromVariableNameAndTermNode(variableName, termNode),
|
|
96
|
+
substitution = termForVariableSubstitution; ///
|
|
97
|
+
|
|
98
|
+
substitutions.push(substitution);
|
|
83
99
|
|
|
84
|
-
|
|
100
|
+
variableVerified = true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
85
105
|
}
|
|
86
106
|
|
|
87
107
|
return variableVerified;
|
|
@@ -85,9 +85,9 @@ function verifyVariableTypeAssertion(typeAssertionNode, assignments, derived, co
|
|
|
85
85
|
|
|
86
86
|
context.error(`The '${assertedTypeName}' asserted type is not equal to or a sub-type of the '${variableName}' variable's '${variableTypeName}' type.`, typeAssertionNode);
|
|
87
87
|
} else {
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
variable = Variable.
|
|
88
|
+
const name = variableName, ///
|
|
89
|
+
type = assertedType, ///
|
|
90
|
+
variable = Variable.fromNameAndType(name, type),
|
|
91
91
|
assignment = Assignment.fromVariable(variable);
|
|
92
92
|
|
|
93
93
|
assignments.push(assignment);
|
package/src/verify/axiom.js
CHANGED
|
@@ -44,7 +44,7 @@ export default function verifyAxiom(axiomNode, fileContext) {
|
|
|
44
44
|
if (consequenceVerified) {
|
|
45
45
|
const firstConsequence = first(consequences),
|
|
46
46
|
consequence = firstConsequence, ///
|
|
47
|
-
axiom = Axiom.
|
|
47
|
+
axiom = Axiom.fromLabelsSuppositionsConsequenceAndProofContext(labels, suppositions, consequence, proofContext);
|
|
48
48
|
|
|
49
49
|
fileContext.addAxiom(axiom);
|
|
50
50
|
|
package/src/verify/conjecture.js
CHANGED
|
@@ -9,6 +9,7 @@ import verifyConsequence from "./consequence";
|
|
|
9
9
|
|
|
10
10
|
import { first } from "../utilities/array";
|
|
11
11
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
12
|
+
import proof from "../context/proof";
|
|
12
13
|
|
|
13
14
|
const proofNodeQuery = nodeQuery("/conjecture/proof!"),
|
|
14
15
|
labelNodesQuery = nodesQuery("/conjecture/label"),
|
|
@@ -50,7 +51,7 @@ export default function verifyConjecture(conjectureNode, fileContext) {
|
|
|
50
51
|
|
|
51
52
|
verifyProof(proofNode, consequence, proofContext);
|
|
52
53
|
|
|
53
|
-
const conjecture = Conjecture.
|
|
54
|
+
const conjecture = Conjecture.fromLabelsSuppositionsConsequenceAndProofContext(labels, suppositions, consequence, proofContext);
|
|
54
55
|
|
|
55
56
|
fileContext.addConjecture(conjecture);
|
|
56
57
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import verifyMetavariable from "../../verify/metavariable";
|
|
4
|
+
|
|
5
|
+
import { nodeQuery } from "../../utilities/query";
|
|
6
|
+
|
|
7
|
+
const metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType"),
|
|
8
|
+
metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable");
|
|
9
|
+
|
|
10
|
+
export default function verifyMetavariableDeclaration(metavariableDeclarationNode, fileContext) {
|
|
11
|
+
let metavariableDeclarationVerified;
|
|
12
|
+
|
|
13
|
+
const metaTypeNode = metaTypeNodeQuery(metavariableDeclarationNode),
|
|
14
|
+
metavariableNode = metavariableNodeQuery(metavariableDeclarationNode),
|
|
15
|
+
metavariableVVerified = verifyMetavariable(metavariableNode, metaTypeNode, fileContext);
|
|
16
|
+
|
|
17
|
+
metavariableDeclarationVerified = metavariableVVerified; ///
|
|
18
|
+
|
|
19
|
+
return metavariableDeclarationVerified;
|
|
20
|
+
}
|