occam-verify-cli 0.0.892 → 0.0.894
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/axiomLemmaTheoremConjecture.js +5 -5
- package/lib/conclusion.js +4 -3
- package/lib/metaConsequent.js +4 -3
- package/lib/metaLemmaMetatheorem.js +16 -16
- package/lib/metaSupposition.js +19 -20
- package/lib/premise.js +63 -20
- package/lib/rule.js +43 -31
- package/lib/step/metaproof.js +19 -5
- package/lib/utilities/array.js +5 -2
- package/lib/verifier/nodes/metaLevel.js +7 -7
- package/lib/verify/derivation.js +10 -90
- package/lib/verify/metaDerivation.js +7 -87
- package/lib/verify/metaProofStep.js +76 -0
- package/lib/verify/metaSubDerivation.js +25 -0
- package/lib/verify/metaSubproof.js +34 -0
- package/lib/verify/metaproof.js +7 -8
- package/lib/verify/metastatement/qualified.js +71 -35
- package/lib/verify/metastatement/unqualified.js +16 -19
- package/lib/verify/proofStep.js +70 -0
- package/lib/verify/ruleDerivation.js +7 -85
- package/lib/verify/ruleProofStep.js +88 -0
- package/lib/verify/ruleSubDerivation.js +25 -0
- package/lib/verify/ruleSubproof.js +34 -0
- package/lib/verify/statement/qualified.js +74 -100
- package/lib/verify/statement/unqualified.js +16 -19
- package/lib/verify/statement.js +7 -1
- package/lib/verify/subDerivation.js +25 -0
- package/lib/verify/subproof.js +34 -0
- package/package.json +4 -4
- package/src/axiomLemmaTheoremConjecture.js +6 -5
- package/src/conclusion.js +6 -4
- package/src/metaConsequent.js +6 -4
- package/src/metaLemmaMetatheorem.js +16 -16
- package/src/metaSupposition.js +32 -33
- package/src/premise.js +106 -35
- package/src/rule.js +48 -30
- package/src/step/metaproof.js +24 -7
- package/src/utilities/array.js +1 -1
- package/src/verifier/nodes/metaLevel.js +6 -6
- package/src/verify/derivation.js +10 -138
- package/src/verify/metaDerivation.js +7 -135
- package/src/verify/metaProofStep.js +98 -0
- package/src/verify/metaSubDerivation.js +22 -0
- package/src/verify/metaSubproof.js +32 -0
- package/src/verify/metaproof.js +11 -11
- package/src/verify/metastatement/qualified.js +98 -32
- package/src/verify/metastatement/unqualified.js +16 -19
- package/src/verify/proofStep.js +88 -0
- package/src/verify/ruleDerivation.js +7 -133
- package/src/verify/ruleProofStep.js +121 -0
- package/src/verify/ruleSubDerivation.js +22 -0
- package/src/verify/ruleSubproof.js +32 -0
- package/src/verify/statement/qualified.js +83 -125
- package/src/verify/statement/unqualified.js +16 -19
- package/src/verify/statement.js +2 -2
- package/src/verify/subDerivation.js +22 -0
- package/src/verify/subproof.js +32 -0
package/src/rule.js
CHANGED
|
@@ -4,7 +4,7 @@ import Label from "./label";
|
|
|
4
4
|
import Premise from "./premise";
|
|
5
5
|
import Conclusion from "./conclusion";
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { extract } from "./utilities/array";
|
|
8
8
|
import { someSubArray } from "./utilities/array";
|
|
9
9
|
|
|
10
10
|
export default class Rule {
|
|
@@ -31,27 +31,27 @@ export default class Rule {
|
|
|
31
31
|
return this.fileContext;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
matchStatement(statementNode,
|
|
34
|
+
matchStatement(statementNode, localContext) {
|
|
35
35
|
let statementNatches;
|
|
36
36
|
|
|
37
37
|
const premisesLength = this.premises.length;
|
|
38
38
|
|
|
39
39
|
if (premisesLength === 0) {
|
|
40
40
|
const substitutions = [],
|
|
41
|
-
conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext,
|
|
41
|
+
conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, localContext);
|
|
42
42
|
|
|
43
43
|
statementNatches = conclusionMatches; ///
|
|
44
44
|
} else {
|
|
45
|
-
const proofSteps =
|
|
45
|
+
const proofSteps = localContext.getProofSteps();
|
|
46
46
|
|
|
47
47
|
statementNatches = someSubArray(proofSteps, premisesLength, (proofSteps) => {
|
|
48
48
|
let premisesMatchConclusion = false;
|
|
49
49
|
|
|
50
50
|
const substitutions = [],
|
|
51
|
-
premisesMatch = matchPremises(this.premises, proofSteps, substitutions, this.fileContext,
|
|
51
|
+
premisesMatch = matchPremises(this.premises, proofSteps, substitutions, this.fileContext, localContext);
|
|
52
52
|
|
|
53
53
|
if (premisesMatch) {
|
|
54
|
-
const conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext,
|
|
54
|
+
const conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, localContext);
|
|
55
55
|
|
|
56
56
|
premisesMatchConclusion = conclusionMatches; ///
|
|
57
57
|
}
|
|
@@ -65,27 +65,27 @@ export default class Rule {
|
|
|
65
65
|
return statementNatches;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
matchMetastatement(metastatementNode,
|
|
68
|
+
matchMetastatement(metastatementNode, localMetaContext) {
|
|
69
69
|
let metastatementNatches;
|
|
70
70
|
|
|
71
71
|
const premisesLength = this.premises.length;
|
|
72
72
|
|
|
73
73
|
if (premisesLength === 0) {
|
|
74
74
|
const substitutions = [],
|
|
75
|
-
conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext,
|
|
75
|
+
conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, localMetaContext);
|
|
76
76
|
|
|
77
77
|
metastatementNatches = conclusionMatches; ///
|
|
78
78
|
} else {
|
|
79
|
-
const metaproofSteps =
|
|
79
|
+
const metaproofSteps = localMetaContext.getMetaproofSteps();
|
|
80
80
|
|
|
81
81
|
metastatementNatches = someSubArray(metaproofSteps, premisesLength, (metaproofSteps) => {
|
|
82
82
|
let premisesMatchConclusion = false;
|
|
83
83
|
|
|
84
84
|
const substitutions = [],
|
|
85
|
-
premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions, this.fileContext,
|
|
85
|
+
premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions, this.fileContext, localMetaContext);
|
|
86
86
|
|
|
87
87
|
if (premisesMatch) {
|
|
88
|
-
const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext,
|
|
88
|
+
const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, localMetaContext);
|
|
89
89
|
|
|
90
90
|
premisesMatchConclusion = conclusionMatches; ///
|
|
91
91
|
}
|
|
@@ -180,14 +180,23 @@ export default class Rule {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
function matchPremise(premise, proofSteps, substitutions, fileContext,
|
|
184
|
-
const proofStep =
|
|
185
|
-
const
|
|
183
|
+
function matchPremise(premise, proofSteps, substitutions, fileContext, localContext) {
|
|
184
|
+
const proofStep = extract(proofSteps, (proofStep) => {
|
|
185
|
+
const subproofNode = proofStep.getSubproofNode(),
|
|
186
|
+
statementNode = proofStep.getStatementNode();
|
|
187
|
+
|
|
188
|
+
if (subproofNode !== null) {
|
|
189
|
+
const subproofNodeMatches = premise.matchSubproofNode(subproofNode, substitutions, fileContext, localContext);
|
|
190
|
+
|
|
191
|
+
if (subproofNodeMatches) {
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
186
195
|
|
|
187
196
|
if (statementNode !== null) {
|
|
188
|
-
const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions, fileContext,
|
|
197
|
+
const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions, fileContext, localContext);
|
|
189
198
|
|
|
190
|
-
if (
|
|
199
|
+
if (statementNodeMatches) {
|
|
191
200
|
return true;
|
|
192
201
|
}
|
|
193
202
|
}
|
|
@@ -198,9 +207,9 @@ function matchPremise(premise, proofSteps, substitutions, fileContext, statement
|
|
|
198
207
|
return premiseMatches;
|
|
199
208
|
}
|
|
200
209
|
|
|
201
|
-
function matchPremises(premise, proofSteps, substitutions, fileContext,
|
|
210
|
+
function matchPremises(premise, proofSteps, substitutions, fileContext, localContext) {
|
|
202
211
|
const premisesMatch = premise.every((premise) => {
|
|
203
|
-
const premiseMatches = matchPremise(premise, proofSteps, substitutions, fileContext,
|
|
212
|
+
const premiseMatches = matchPremise(premise, proofSteps, substitutions, fileContext, localContext);
|
|
204
213
|
|
|
205
214
|
if (premiseMatches) {
|
|
206
215
|
return true;
|
|
@@ -210,30 +219,39 @@ function matchPremises(premise, proofSteps, substitutions, fileContext, statemen
|
|
|
210
219
|
return premisesMatch;
|
|
211
220
|
}
|
|
212
221
|
|
|
213
|
-
function matchConclusion(conclusion, statementNode, substitutions, fileContext,
|
|
214
|
-
const statementNodeMatches = conclusion.matchStatementNode(statementNode, substitutions, fileContext,
|
|
222
|
+
function matchConclusion(conclusion, statementNode, substitutions, fileContext, localContext) {
|
|
223
|
+
const statementNodeMatches = conclusion.matchStatementNode(statementNode, substitutions, fileContext, localContext),
|
|
215
224
|
conclusionMatches = statementNodeMatches; ///
|
|
216
225
|
|
|
217
226
|
return conclusionMatches;
|
|
218
227
|
}
|
|
219
228
|
|
|
220
|
-
function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext,
|
|
221
|
-
const metaproofStep =
|
|
229
|
+
function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, localMetaContext) {
|
|
230
|
+
const metaproofStep = extract(metaproofSteps, (metaproofStep) => {
|
|
222
231
|
const ruleSubproofNode = metaproofStep.getRuleSubproofNode(),
|
|
232
|
+
metaSubproofNode = metaproofStep.getMetaSubproofNode(),
|
|
223
233
|
metastatementNode = metaproofStep.getMetastatementNode()
|
|
224
234
|
|
|
225
235
|
if (ruleSubproofNode !== null) {
|
|
226
|
-
const ruleSubProofNodeMatches = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext,
|
|
236
|
+
const ruleSubProofNodeMatches = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, localMetaContext);
|
|
237
|
+
|
|
238
|
+
if (ruleSubProofNodeMatches) {
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (metaSubproofNode !== null) {
|
|
244
|
+
const metaSubProofNodeMatches = premise.matchMetaSubproofNode(metaSubproofNode, substitutions, fileContext, localMetaContext);
|
|
227
245
|
|
|
228
|
-
if (
|
|
246
|
+
if (metaSubProofNodeMatches) {
|
|
229
247
|
return true;
|
|
230
248
|
}
|
|
231
249
|
}
|
|
232
250
|
|
|
233
251
|
if (metastatementNode !== null) {
|
|
234
|
-
const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode, substitutions, fileContext,
|
|
252
|
+
const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode, substitutions, fileContext, localMetaContext);
|
|
235
253
|
|
|
236
|
-
if (
|
|
254
|
+
if (metastatementNodeMatches) {
|
|
237
255
|
return true;
|
|
238
256
|
}
|
|
239
257
|
}
|
|
@@ -244,9 +262,9 @@ function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, m
|
|
|
244
262
|
return premiseMatches;
|
|
245
263
|
}
|
|
246
264
|
|
|
247
|
-
function metaMatchPremises(premise, metaproofSteps, substitutions, fileContext,
|
|
265
|
+
function metaMatchPremises(premise, metaproofSteps, substitutions, fileContext, localMetaContext) {
|
|
248
266
|
const premisesMatch = premise.every((premise) => {
|
|
249
|
-
const premiseMatches = metaMatchPremise(premise, metaproofSteps, substitutions, fileContext,
|
|
267
|
+
const premiseMatches = metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, localMetaContext);
|
|
250
268
|
|
|
251
269
|
if (premiseMatches) {
|
|
252
270
|
return true;
|
|
@@ -256,8 +274,8 @@ function metaMatchPremises(premise, metaproofSteps, substitutions, fileContext,
|
|
|
256
274
|
return premisesMatch;
|
|
257
275
|
}
|
|
258
276
|
|
|
259
|
-
function metaMatchConclusion(conclusion, metastatementNode, substitutions, fileContext,
|
|
260
|
-
const metastatementNodeMatches = conclusion.matchMetastatementNode(metastatementNode, substitutions, fileContext,
|
|
277
|
+
function metaMatchConclusion(conclusion, metastatementNode, substitutions, fileContext, localMetaContext) {
|
|
278
|
+
const metastatementNodeMatches = conclusion.matchMetastatementNode(metastatementNode, substitutions, fileContext, localMetaContext),
|
|
261
279
|
conclusionMatches = metastatementNodeMatches; ///
|
|
262
280
|
|
|
263
281
|
return conclusionMatches;
|
package/src/step/metaproof.js
CHANGED
|
@@ -9,12 +9,17 @@ const metastatementNodesQuery = nodesQuery("/subproofAssertion/metastatement"),
|
|
|
9
9
|
qualifiedOrUnqualifiedMetastatementMetastatementNodesQuery = nodesQuery("/ruleSubproof/qualifiedMetastatement|unqualifiedMetastatement/metastatement!");
|
|
10
10
|
|
|
11
11
|
export default class MetaproofStep {
|
|
12
|
-
constructor(ruleSubproofNode, metaSubproofNode, metastatementNode) {
|
|
12
|
+
constructor(statementNode, ruleSubproofNode, metaSubproofNode, metastatementNode) {
|
|
13
|
+
this.statementNode = statementNode;
|
|
13
14
|
this.ruleSubproofNode = ruleSubproofNode;
|
|
14
15
|
this.metaSubproofNode = metaSubproofNode;
|
|
15
16
|
this.metastatementNode = metastatementNode;
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
getStatementNode() {
|
|
20
|
+
return this.statementNode;
|
|
21
|
+
}
|
|
22
|
+
|
|
18
23
|
getRuleSubproofNode() {
|
|
19
24
|
return this.ruleSubproofNode;
|
|
20
25
|
}
|
|
@@ -90,27 +95,39 @@ export default class MetaproofStep {
|
|
|
90
95
|
return ruleSubproofAssertionMatches;
|
|
91
96
|
}
|
|
92
97
|
|
|
98
|
+
static fromStatementNode(statementNode) {
|
|
99
|
+
const ruleSubproofNode = null,
|
|
100
|
+
metaSubproofNode = null,
|
|
101
|
+
metastatementNode = null,
|
|
102
|
+
metaProofStep = new MetaproofStep(statementNode, ruleSubproofNode, metaSubproofNode, metastatementNode);
|
|
103
|
+
|
|
104
|
+
return metaProofStep;
|
|
105
|
+
}
|
|
106
|
+
|
|
93
107
|
static fromRuleSubproofNode(ruleSubproofNode) {
|
|
94
|
-
const
|
|
108
|
+
const statementNode = null,
|
|
109
|
+
metaSubproofNode = null,
|
|
95
110
|
metastatementNode = null,
|
|
96
|
-
metaProofStep = new MetaproofStep(ruleSubproofNode, metaSubproofNode, metastatementNode);
|
|
111
|
+
metaProofStep = new MetaproofStep(statementNode, ruleSubproofNode, metaSubproofNode, metastatementNode);
|
|
97
112
|
|
|
98
113
|
return metaProofStep;
|
|
99
114
|
}
|
|
100
115
|
|
|
101
116
|
static fromMetaSubproofNode(metaSubproofNode) {
|
|
102
|
-
const
|
|
117
|
+
const statementNode = null,
|
|
118
|
+
ruleSubproofNode = null,
|
|
103
119
|
metastatementNode = null,
|
|
104
|
-
metaProofStep = new MetaproofStep(ruleSubproofNode, metaSubproofNode, metastatementNode);
|
|
120
|
+
metaProofStep = new MetaproofStep(statementNode, ruleSubproofNode, metaSubproofNode, metastatementNode);
|
|
105
121
|
|
|
106
122
|
return metaProofStep;
|
|
107
123
|
|
|
108
124
|
}
|
|
109
125
|
|
|
110
126
|
static fromMetastatementNode(metastatementNode) {
|
|
111
|
-
const
|
|
127
|
+
const statementNode = null,
|
|
128
|
+
ruleSubproofNode = null,
|
|
112
129
|
metaSubproofNode = null,
|
|
113
|
-
metaProofStep = new MetaproofStep(ruleSubproofNode, metaSubproofNode, metastatementNode);
|
|
130
|
+
metaProofStep = new MetaproofStep(statementNode, ruleSubproofNode, metaSubproofNode, metastatementNode);
|
|
114
131
|
|
|
115
132
|
return metaProofStep;
|
|
116
133
|
}
|
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, match, filter, compress, separate } = arrayUtilities;
|
|
9
|
+
export const { first, second, last, push, prune, extract, match, filter, compress, separate } = arrayUtilities;
|
|
10
10
|
|
|
11
11
|
export function someSubArray(array, subArrayLength, callback) {
|
|
12
12
|
let found = false;
|
|
@@ -10,21 +10,21 @@ const metastatementNodeQuery = nodeQuery("/metastatement!"),
|
|
|
10
10
|
metastatementMetavariableNodeQuery = nodeQuery("/metastatement/metavariable!");
|
|
11
11
|
|
|
12
12
|
class MetaLevelNodesVerifier extends NodesVerifier {
|
|
13
|
-
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions,
|
|
13
|
+
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localMetaContextA, localMetaContextB, verifyAhead) {
|
|
14
14
|
let nonTerminalNodeVerified;
|
|
15
15
|
|
|
16
16
|
const nodeQueryMaps = [
|
|
17
17
|
{
|
|
18
18
|
nodeQueryA: metastatementMetavariableNodeQuery,
|
|
19
19
|
nodeQueryB: metastatementNodeQuery,
|
|
20
|
-
verifyNodes: (nodeA, nodeB, substitutions,
|
|
20
|
+
verifyNodes: (nodeA, nodeB, substitutions, localMetaContextA, localMetaContextB, verifyAhead) => {
|
|
21
21
|
let nonTerminalNodeVerified;
|
|
22
22
|
|
|
23
23
|
const metastatementNodeB = nodeB, ///
|
|
24
24
|
metastatementMetavariableNodeA = nodeA, ///
|
|
25
25
|
metastatementMetavariableNodeVerifiedAgainstMetastatementNode =
|
|
26
26
|
|
|
27
|
-
this.verifyMetastatementMetavariableNodeAgainstMetastatementNode(metastatementMetavariableNodeA, metastatementNodeB, substitutions,
|
|
27
|
+
this.verifyMetastatementMetavariableNodeAgainstMetastatementNode(metastatementMetavariableNodeA, metastatementNodeB, substitutions, localMetaContextA, localMetaContextB, verifyAhead);
|
|
28
28
|
|
|
29
29
|
nonTerminalNodeVerified = metastatementMetavariableNodeVerifiedAgainstMetastatementNode; ///
|
|
30
30
|
|
|
@@ -33,16 +33,16 @@ class MetaLevelNodesVerifier extends NodesVerifier {
|
|
|
33
33
|
}
|
|
34
34
|
];
|
|
35
35
|
|
|
36
|
-
const nodesVerified = verifyNodes(nodeQueryMaps, nonTerminalNodeA, nonTerminalNodeB, substitutions,
|
|
36
|
+
const nodesVerified = verifyNodes(nodeQueryMaps, nonTerminalNodeA, nonTerminalNodeB, substitutions, localMetaContextA, localMetaContextB, verifyAhead);
|
|
37
37
|
|
|
38
38
|
nonTerminalNodeVerified = nodesVerified ?
|
|
39
39
|
true :
|
|
40
|
-
super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions,
|
|
40
|
+
super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localMetaContextA, localMetaContextB, verifyAhead);
|
|
41
41
|
|
|
42
42
|
return nonTerminalNodeVerified;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
verifyMetastatementMetavariableNodeAgainstMetastatementNode(metastatementMetavariableNodeA, metastatementNodeB, substitutions,
|
|
45
|
+
verifyMetastatementMetavariableNodeAgainstMetastatementNode(metastatementMetavariableNodeA, metastatementNodeB, substitutions, localMetaContextA, localMetaContextB, verifyAhead) {
|
|
46
46
|
let metastatementMetavariableNodeVerifiedAgainstMetastatementNode;
|
|
47
47
|
|
|
48
48
|
const metavariableNode = metastatementMetavariableNodeA, ///
|
package/src/verify/derivation.js
CHANGED
|
@@ -1,151 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import LocalContext from "../context/local";
|
|
5
|
-
import verifySuppositions from "../verify/suppositions";
|
|
6
|
-
import verifyQualifiedStatement from "../verify/statement/qualified";
|
|
7
|
-
import verifyUnqualifiedStatement from "../verify/statement/unqualified";
|
|
3
|
+
import verifyProofStep from "../verify/proofStep";
|
|
8
4
|
|
|
9
|
-
import {
|
|
10
|
-
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
11
|
-
import { SUBPROOF_RULE_NAME, QUALIFIED_STATEMENT_RULE_NAME, UNQUALIFIED_STATEMENT_RULE_NAME } from "../ruleNames";
|
|
5
|
+
import { nodesQuery } from "../utilities/query";
|
|
12
6
|
|
|
13
|
-
const
|
|
14
|
-
statementNodeQuery = nodeQuery("/qualifiedStatement|unqualifiedStatement/statement!"),
|
|
15
|
-
suppositionNodesQuery = nodesQuery("/subproof/supposition"),
|
|
16
|
-
subDerivationNodeQuery = nodeQuery("/subproof/subDerivation");
|
|
7
|
+
const proofStepNodesQuery = nodesQuery("/derivation/proofStep|lastProofStep");
|
|
17
8
|
|
|
18
|
-
export default function verifyDerivation(
|
|
19
|
-
let
|
|
9
|
+
export default function verifyDerivation(ruleDerivationNode, localMetaContext) {
|
|
10
|
+
let ruleDerivationVerified;
|
|
20
11
|
|
|
21
|
-
const
|
|
12
|
+
const proofStepNodes = proofStepNodesQuery(ruleDerivationNode);
|
|
22
13
|
|
|
23
|
-
|
|
24
|
-
const
|
|
14
|
+
ruleDerivationVerified = proofStepNodes.every((proofStepNode) => {
|
|
15
|
+
const proofStepVerified = verifyProofStep(proofStepNode, localMetaContext);
|
|
25
16
|
|
|
26
|
-
if (
|
|
17
|
+
if (proofStepVerified) {
|
|
27
18
|
return true;
|
|
28
19
|
}
|
|
29
20
|
});
|
|
30
21
|
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function verifySubDerivation(subDerivationNode, localContext) {
|
|
35
|
-
let subDerivationVerified;
|
|
36
|
-
|
|
37
|
-
const childNodes = childNodesQuery(subDerivationNode);
|
|
38
|
-
|
|
39
|
-
subDerivationVerified = childNodes.every((childNode) => {
|
|
40
|
-
const childVerified = verifyChild(childNode, localContext);
|
|
41
|
-
|
|
42
|
-
if (childVerified) {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return subDerivationVerified;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function verifySubproof(subproofNode, localContext) {
|
|
51
|
-
let subproofVerified = false;
|
|
52
|
-
|
|
53
|
-
localContext = LocalContext.fromLocalContext(localContext); ///
|
|
54
|
-
|
|
55
|
-
const suppositions = [],
|
|
56
|
-
suppositionNodes = suppositionNodesQuery(subproofNode),
|
|
57
|
-
suppositionsVerified = verifySuppositions(suppositionNodes, suppositions, localContext);
|
|
58
|
-
|
|
59
|
-
if (suppositionsVerified) {
|
|
60
|
-
const subDerivationNode = subDerivationNodeQuery(subproofNode),
|
|
61
|
-
subDerivationVerified = verifySubDerivation(subDerivationNode, localContext);
|
|
62
|
-
|
|
63
|
-
if (subDerivationVerified) {
|
|
64
|
-
subproofVerified = true;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return subproofVerified;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function verifyChild(childNode, localContext) {
|
|
72
|
-
let childVerified = false;
|
|
73
|
-
|
|
74
|
-
const childNodeRuleName = childNode.getRuleName();
|
|
75
|
-
|
|
76
|
-
switch (childNodeRuleName) {
|
|
77
|
-
case SUBPROOF_RULE_NAME: {
|
|
78
|
-
let subproofVerified;
|
|
79
|
-
|
|
80
|
-
const subproofNode = childNode; ///
|
|
81
|
-
|
|
82
|
-
subproofVerified = verifySubproof(subproofNode, localContext);
|
|
83
|
-
|
|
84
|
-
if (subproofVerified) {
|
|
85
|
-
const proofStep = ProofStep.fromSubproofNode(subproofNode);
|
|
86
|
-
|
|
87
|
-
localContext.addProofStep(proofStep);
|
|
88
|
-
|
|
89
|
-
childVerified = true;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
case QUALIFIED_STATEMENT_RULE_NAME: {
|
|
96
|
-
let qualifiedStatementVerified;
|
|
97
|
-
|
|
98
|
-
const derived = true,
|
|
99
|
-
assignments = [],
|
|
100
|
-
qualifiedStatementNode = childNode; ///
|
|
101
|
-
|
|
102
|
-
qualifiedStatementVerified = verifyQualifiedStatement(qualifiedStatementNode, assignments, derived, localContext);
|
|
103
|
-
|
|
104
|
-
if (qualifiedStatementVerified) {
|
|
105
|
-
const assignmentAssigned = assignAssignment(assignments, localContext);
|
|
106
|
-
|
|
107
|
-
qualifiedStatementVerified = assignmentAssigned; ///
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (qualifiedStatementVerified) {
|
|
111
|
-
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
112
|
-
proofStep = ProofStep.fromStatementNode(statementNode);
|
|
113
|
-
|
|
114
|
-
localContext.addProofStep(proofStep);
|
|
115
|
-
|
|
116
|
-
childVerified = true; ///
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
case UNQUALIFIED_STATEMENT_RULE_NAME: {
|
|
123
|
-
let unqualifiedStatementVerified;
|
|
124
|
-
|
|
125
|
-
const derived = true,
|
|
126
|
-
assignments = [],
|
|
127
|
-
unqualifiedStatementNode = childNode; ///
|
|
128
|
-
|
|
129
|
-
unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, assignments, derived, localContext);
|
|
130
|
-
|
|
131
|
-
if (unqualifiedStatementVerified) {
|
|
132
|
-
const assignmentAssigned = assignAssignment(assignments, localContext);
|
|
133
|
-
|
|
134
|
-
unqualifiedStatementVerified = assignmentAssigned; ///
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (unqualifiedStatementVerified) {
|
|
138
|
-
const statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
139
|
-
proofStep = ProofStep.fromStatementNode(statementNode);
|
|
140
|
-
|
|
141
|
-
localContext.addProofStep(proofStep);
|
|
142
|
-
|
|
143
|
-
childVerified = true;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return childVerified;
|
|
22
|
+
return ruleDerivationVerified;
|
|
151
23
|
}
|
|
@@ -1,151 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import LocalMetaContext from "../context/localMeta";
|
|
5
|
-
import verifyMetaSuppositions from "../verify/metaSuppositions";
|
|
6
|
-
import verifyQualifiedMetastatement from "../verify/metastatement/qualified";
|
|
7
|
-
import verifyUnqualifiedMetastatement from "../verify/metastatement/unqualified";
|
|
3
|
+
import verifyMetaProofStep from "../verify/metaProofStep";
|
|
8
4
|
|
|
9
|
-
import {
|
|
10
|
-
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
11
|
-
import { META_SUBPROOF_RULE_NAME, QUALIFIED_METASTATEMENT_RULE_NAME, UNQUALIFIED_METASTATEMENT_RULE_NAME } from "../ruleNames";
|
|
5
|
+
import { nodesQuery } from "../utilities/query";
|
|
12
6
|
|
|
13
|
-
const
|
|
14
|
-
metastatementNodeQuery = nodeQuery("/qualifiedMetastatement|unqualifiedMetastatement/metastatement!"),
|
|
15
|
-
metaSuppositionNodesQuery = nodesQuery("/metaSubproof/metaSupposition"),
|
|
16
|
-
metaSubDerivationNodeQuery = nodeQuery("/metaSubproof/metaSubDerivation");
|
|
7
|
+
const metaProofStepNodesQuery = nodesQuery("/metaDerivation/metaProofStep|lastMetaProofStep");
|
|
17
8
|
|
|
18
9
|
export default function verifyMetaDerivation(metaDerivationNode, substitutions, localMetaContext) {
|
|
19
10
|
let metaDerivationVerified;
|
|
20
11
|
|
|
21
|
-
const
|
|
12
|
+
const metaProofStepNodes = metaProofStepNodesQuery(metaDerivationNode);
|
|
22
13
|
|
|
23
|
-
metaDerivationVerified =
|
|
24
|
-
const
|
|
14
|
+
metaDerivationVerified = metaProofStepNodes.every((metaProofStepNode) => {
|
|
15
|
+
const metaProofStepVerified = verifyMetaProofStep(metaProofStepNode, substitutions, localMetaContext);
|
|
25
16
|
|
|
26
|
-
if (
|
|
17
|
+
if (metaProofStepVerified) {
|
|
27
18
|
return true;
|
|
28
19
|
}
|
|
29
20
|
});
|
|
30
21
|
|
|
31
22
|
return metaDerivationVerified;
|
|
32
23
|
}
|
|
33
|
-
|
|
34
|
-
function verifyMetaSubDerivation(metaSubDerivationNode, substitutions, localMetaContext) {
|
|
35
|
-
let metaSubDerivationVerified;
|
|
36
|
-
|
|
37
|
-
const childNodes = childNodesQuery(metaSubDerivationNode);
|
|
38
|
-
|
|
39
|
-
metaSubDerivationVerified = childNodes.every((childNode) => {
|
|
40
|
-
const childVerified = verifyChild(childNode, substitutions, localMetaContext);
|
|
41
|
-
|
|
42
|
-
if (childVerified) {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return metaSubDerivationVerified;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function verifyMetaSubproof(metaSubproofNode, substitutions, localMetaContext) {
|
|
51
|
-
let metaSubproofVerified = false;
|
|
52
|
-
|
|
53
|
-
localMetaContext = LocalMetaContext.fromLocalMetaContext(localMetaContext); ///
|
|
54
|
-
|
|
55
|
-
const metaSuppositions = [],
|
|
56
|
-
metaSuppositionNodes = metaSuppositionNodesQuery(metaSubproofNode),
|
|
57
|
-
metaSuppositionsVerified = verifyMetaSuppositions(metaSuppositionNodes, metaSuppositions, substitutions, localMetaContext);
|
|
58
|
-
|
|
59
|
-
if (metaSuppositionsVerified) {
|
|
60
|
-
const metaSubDerivationNode = metaSubDerivationNodeQuery(metaSubproofNode),
|
|
61
|
-
metaSubDerivationVerified = verifyMetaSubDerivation(metaSubDerivationNode, substitutions, localMetaContext);
|
|
62
|
-
|
|
63
|
-
if (metaSubDerivationVerified) {
|
|
64
|
-
metaSubproofVerified = true;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return metaSubproofVerified;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function verifyChild(childNode, substitutions, localMetaContext) {
|
|
72
|
-
let childVerified = false;
|
|
73
|
-
|
|
74
|
-
const childNodeRuleName = childNode.getRuleName();
|
|
75
|
-
|
|
76
|
-
switch (childNodeRuleName) {
|
|
77
|
-
case META_SUBPROOF_RULE_NAME: {
|
|
78
|
-
let metaSubproofVerified;
|
|
79
|
-
|
|
80
|
-
const metaSubproofNode = childNode; ///
|
|
81
|
-
|
|
82
|
-
metaSubproofVerified = verifyMetaSubproof(metaSubproofNode, substitutions, localMetaContext);
|
|
83
|
-
|
|
84
|
-
if (metaSubproofVerified) {
|
|
85
|
-
const metaproofStep = MetaproofStep.fromMetaSubproofNode(metaSubproofNode);
|
|
86
|
-
|
|
87
|
-
localMetaContext.addMetaproofStep(metaproofStep);
|
|
88
|
-
|
|
89
|
-
childVerified = true;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
case QUALIFIED_METASTATEMENT_RULE_NAME: {
|
|
96
|
-
let qualifiedMetastatementVerified;
|
|
97
|
-
|
|
98
|
-
const derived = true,
|
|
99
|
-
assignments = [],
|
|
100
|
-
qualifiedMetastatementNode = childNode; ///
|
|
101
|
-
|
|
102
|
-
qualifiedMetastatementVerified = verifyQualifiedMetastatement(qualifiedMetastatementNode, substitutions, assignments, derived, localMetaContext);
|
|
103
|
-
|
|
104
|
-
if (qualifiedMetastatementVerified) {
|
|
105
|
-
const assignmentAssigned = assignAssignment(assignments, localMetaContext);
|
|
106
|
-
|
|
107
|
-
qualifiedMetastatementVerified = assignmentAssigned; ///
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (qualifiedMetastatementVerified) {
|
|
111
|
-
const metastatementNode = metastatementNodeQuery(qualifiedMetastatementNode),
|
|
112
|
-
metaproofStep = MetaproofStep.fromMetastatementNode(metastatementNode);
|
|
113
|
-
|
|
114
|
-
localMetaContext.addMetaproofStep(metaproofStep);
|
|
115
|
-
|
|
116
|
-
childVerified = true; ///
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
case UNQUALIFIED_METASTATEMENT_RULE_NAME: {
|
|
123
|
-
let unqualifiedMetastatementVerified;
|
|
124
|
-
|
|
125
|
-
const derived = true,
|
|
126
|
-
assignments = [],
|
|
127
|
-
unqualifiedMetastatementNode = childNode; ///
|
|
128
|
-
|
|
129
|
-
unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, assignments, derived, localMetaContext);
|
|
130
|
-
|
|
131
|
-
if (unqualifiedMetastatementVerified) {
|
|
132
|
-
const assignmentAssigned = assignAssignment(assignments, localMetaContext);
|
|
133
|
-
|
|
134
|
-
unqualifiedMetastatementVerified = assignmentAssigned; ///
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (unqualifiedMetastatementVerified) {
|
|
138
|
-
const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode),
|
|
139
|
-
metaproofStep = MetaproofStep.fromMetastatementNode(metastatementNode);
|
|
140
|
-
|
|
141
|
-
localMetaContext.addMetaproofStep(metaproofStep);
|
|
142
|
-
|
|
143
|
-
childVerified = true;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return childVerified;
|
|
151
|
-
}
|