occam-verify-cli 0.0.893 → 0.0.895
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 +3 -3
- package/lib/conclusion.js +37 -14
- package/lib/metaConsequent.js +29 -10
- package/lib/metaLemmaMetatheorem.js +4 -4
- package/lib/metaSupposition.js +38 -19
- package/lib/premise.js +93 -22
- package/lib/rule.js +31 -20
- package/lib/step/metaproof.js +19 -5
- package/lib/utilities/array.js +5 -2
- package/lib/verifier/nodes/intrinsicLevelAgainstMetaLevel.js +2 -40
- package/lib/verify/metaProofStep.js +2 -2
- package/lib/verify/metaSubDerivation.js +3 -3
- package/lib/verify/metaSubproof.js +3 -3
- package/lib/verify/metastatement/qualified.js +32 -15
- package/lib/verify/ruleProofStep.js +27 -15
- package/lib/verify/statement/qualified.js +39 -23
- package/lib/verify/statement.js +7 -1
- package/package.json +4 -4
- package/src/axiomLemmaTheoremConjecture.js +3 -4
- package/src/conclusion.js +54 -26
- package/src/metaConsequent.js +40 -17
- package/src/metaLemmaMetatheorem.js +4 -4
- package/src/metaSupposition.js +58 -37
- package/src/premise.js +145 -41
- package/src/rule.js +36 -20
- package/src/step/metaproof.js +24 -7
- package/src/utilities/array.js +1 -1
- package/src/verifier/nodes/intrinsicLevelAgainstMetaLevel.js +0 -61
- package/src/verify/metaProofStep.js +1 -1
- package/src/verify/metaSubDerivation.js +2 -2
- package/src/verify/metaSubproof.js +2 -2
- package/src/verify/metastatement/qualified.js +51 -21
- package/src/verify/ruleProofStep.js +24 -2
- package/src/verify/statement/qualified.js +55 -25
- package/src/verify/statement.js +2 -2
package/src/metaSupposition.js
CHANGED
|
@@ -6,42 +6,45 @@ import metaLevelNodesVerifier from "./verifier/nodes/metaLevel";
|
|
|
6
6
|
import { match } from "./utilities/array";
|
|
7
7
|
import { nodeAsString } from "./utilities/string";
|
|
8
8
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
9
|
-
import { metastatementNodeFromMetastatementString } from "./utilities/node";
|
|
9
|
+
import { statementNodeFromStatementString, metastatementNodeFromMetastatementString } from "./utilities/node";
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const subproofAssertionNodeQuery = nodeQuery("/metastatement/subproofAssertion!"),
|
|
12
|
+
subproofAssertionMetastatementNodesQuery = nodesQuery("/subproofAssertion/metastatement"),
|
|
13
13
|
metaSubproofMetaSuppositionMetastatementNodesQuery = nodesQuery("/metaSubproof/metaSupposition/unqualifiedMetastatement/metastatement!"),
|
|
14
|
-
|
|
14
|
+
metaSubproofLastMetaProofStepMetastatementNodeQuery = nodeQuery("/metaSubproof/metaSubDerivation/lastMetaProofStep/unqualifiedMetastatement|qualifiedMetastatement/metastatement!");
|
|
15
15
|
|
|
16
16
|
export default class MetaSupposition {
|
|
17
|
-
constructor(metastatementNode) {
|
|
17
|
+
constructor(metastatementNode, statementNode) {
|
|
18
18
|
this.metastatementNode = metastatementNode;
|
|
19
|
+
this.statementNode = statementNode;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
getMetastatementNode() {
|
|
22
23
|
return this.metastatementNode;
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
getStatementNode() {
|
|
27
|
+
return this.statementNode;
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
matchMetaSubproofNode(metaSubproofNode, substitutions, fileContext, localMetaContext) {
|
|
26
31
|
let metaSubproofNodeMatches = false;
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const nonTerminalNodeA = metaSubproofAssertionMetastatementNode, ///
|
|
44
|
-
nonTerminalNodeB = metaSubproofMetastatementNode, ///
|
|
33
|
+
if (this.metastatementNode !== null) {
|
|
34
|
+
const subproofAssertionNode = subproofAssertionNodeQuery(this.metastatementNode);
|
|
35
|
+
|
|
36
|
+
if (subproofAssertionNode !== null) {
|
|
37
|
+
const metaSubproofMetaSuppositionMetastatementNodes = metaSubproofMetaSuppositionMetastatementNodesQuery(metaSubproofNode),
|
|
38
|
+
metaSubproofLastMetaProofStepMetastatementNode = metaSubproofLastMetaProofStepMetastatementNodeQuery(metaSubproofNode),
|
|
39
|
+
metaSubproofMetastatementNodes = [
|
|
40
|
+
...metaSubproofMetaSuppositionMetastatementNodes,
|
|
41
|
+
metaSubproofLastMetaProofStepMetastatementNode
|
|
42
|
+
],
|
|
43
|
+
subproofAssertionMetastatementNodes = subproofAssertionMetastatementNodesQuery(subproofAssertionNode);
|
|
44
|
+
|
|
45
|
+
metaSubproofNodeMatches = match(subproofAssertionMetastatementNodes, metaSubproofMetastatementNodes, (subproofAssertionMetastatementNode, ruleSubproofMetastatementNode) => {
|
|
46
|
+
const nonTerminalNodeA = subproofAssertionMetastatementNode, ///
|
|
47
|
+
nonTerminalNodeB = ruleSubproofMetastatementNode, ///
|
|
45
48
|
fileContextA = fileContext, ///
|
|
46
49
|
localMetaContextA = LocalMetaContext.fromFileContext(fileContextA),
|
|
47
50
|
localMetaContextB = localMetaContext, ///
|
|
@@ -62,44 +65,62 @@ export default class MetaSupposition {
|
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
matchMetastatementNode(metastatementNode, substitutions, fileContext, localMetaContext) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
let metastatementNodeMatches = false;
|
|
69
|
+
|
|
70
|
+
if (this.metastatementNode !== null) {
|
|
71
|
+
const nonTerminalNodeA = this.metastatementNode, ///
|
|
72
|
+
nonTerminalNodeB = metastatementNode, ///
|
|
73
|
+
fileContextA = fileContext, ///
|
|
74
|
+
localMetaContextA = LocalMetaContext.fromFileContext(fileContextA),
|
|
75
|
+
localMetaContextB = localMetaContext, ///
|
|
76
|
+
nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localMetaContextA, localMetaContextB, () => {
|
|
77
|
+
const verifiedAhead = true;
|
|
78
|
+
|
|
79
|
+
return verifiedAhead;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
metastatementNodeMatches = nonTerminalNodeVerified; ///
|
|
83
|
+
}
|
|
76
84
|
|
|
77
85
|
return metastatementNodeMatches;
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
toJSON(tokens) {
|
|
81
89
|
const metastatementString = nodeAsString(this.metastatementNode, tokens),
|
|
90
|
+
statementString = nodeAsString(this.statementNode, tokens),
|
|
82
91
|
metastatement = metastatementString, ///
|
|
92
|
+
statement = statementString, ///
|
|
83
93
|
json = {
|
|
84
|
-
metastatement
|
|
94
|
+
metastatement,
|
|
95
|
+
statement
|
|
85
96
|
};
|
|
86
97
|
|
|
87
98
|
return json;
|
|
88
99
|
}
|
|
89
100
|
|
|
90
101
|
static fromMetastatementNode(metastatementNode) {
|
|
91
|
-
const
|
|
102
|
+
const statementNode = null,
|
|
103
|
+
metaSupposition = new MetaSupposition(metastatementNode, statementNode);
|
|
104
|
+
|
|
105
|
+
return metaSupposition;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static fromStatementNode(statementNode) {
|
|
109
|
+
const metastatementNode = null,
|
|
110
|
+
metaSupposition = new MetaSupposition(metastatementNode, statementNode);
|
|
92
111
|
|
|
93
112
|
return metaSupposition;
|
|
94
113
|
}
|
|
95
114
|
|
|
96
115
|
static fromJSONAndFileContext(json, fileContext) {
|
|
97
|
-
const { metastatement } = json,
|
|
116
|
+
const { metastatement, statement } = json,
|
|
98
117
|
metastatementString = metastatement, ///
|
|
118
|
+
statementString = statement, ///
|
|
99
119
|
lexer = fileContext.getLexer(),
|
|
100
120
|
parser = fileContext.getParser(),
|
|
101
121
|
metastatementNode = metastatementNodeFromMetastatementString(metastatementString, lexer, parser),
|
|
102
|
-
|
|
122
|
+
statementNode = statementNodeFromStatementString(statementString, lexer, parser),
|
|
123
|
+
metaSupposition = new MetaSupposition(metastatementNode, statementNode);
|
|
103
124
|
|
|
104
125
|
return metaSupposition;
|
|
105
126
|
}
|
package/src/premise.js
CHANGED
|
@@ -8,55 +8,104 @@ import intrinsicLevelAgainstMetaLevelNodesVerifier from "./verifier/nodes/intrin
|
|
|
8
8
|
import { match } from "./utilities/array";
|
|
9
9
|
import { nodeAsString } from "./utilities/string";
|
|
10
10
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
11
|
-
import { metastatementNodeFromMetastatementString } from "./utilities/node";
|
|
11
|
+
import { statementNodeFromStatementString, metastatementNodeFromMetastatementString } from "./utilities/node";
|
|
12
12
|
|
|
13
13
|
const subproofAssertionNodeQuery = nodeQuery("/metastatement/subproofAssertion!"),
|
|
14
|
+
subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement!/statement!"),
|
|
15
|
+
subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement!"),
|
|
14
16
|
subproofAssertionMetastatementNodesQuery = nodesQuery("/subproofAssertion/metastatement"),
|
|
15
17
|
ruleSubproofPremiseMetastatementNodesQuery = nodesQuery("/ruleSubproof/premise/unqualifiedMetastatement!/metastatement!"),
|
|
16
|
-
|
|
18
|
+
metaSubproofMetaSuppositionMetastatementNodesQuery = nodesQuery("/metaSubproof/metaSupposition/unqualifiedMetastatement!/metastatement!"),
|
|
19
|
+
ruleSubproofLastRuleProofStepMetastatementNodeQuery = nodeQuery("/ruleSubproof/ruleSubDerivation/lastRuleProofStep/unqualifiedMetastatement|qualifiedMetastatement/metastatement!"),
|
|
20
|
+
metaSubproofLastMetaProofStepMetastatementNodeQuery = nodeQuery("/metaSubproof/metaSubDerivation/lastMetaProofStep/unqualifiedMetastatement|qualifiedMetastatement/metastatement!");
|
|
17
21
|
|
|
18
22
|
export default class Premise {
|
|
19
|
-
constructor(metastatementNode) {
|
|
23
|
+
constructor(metastatementNode, statementNode) {
|
|
20
24
|
this.metastatementNode = metastatementNode;
|
|
25
|
+
this.statementnode = statementNode;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
getMetastatementNode() {
|
|
24
29
|
return this.metastatementNode;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
nonTerminalNodeVerified = intrinsicLevelAgainstMetaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
34
|
-
const verifiedAhead = true;
|
|
32
|
+
getStatementNode() {
|
|
33
|
+
return this.statementnode;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
matchStatementNode(statementNode, substitutions, fileContext, localContext) {
|
|
37
|
+
let statementNodeMatches = false;
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
if (this.metastatementNode !== null) {
|
|
40
|
+
const nonTerminalNodeA = this.metastatementNode, ///
|
|
41
|
+
nonTerminalNodeB = statementNode, ///
|
|
42
|
+
fileContextA = fileContext, ///
|
|
43
|
+
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
44
|
+
localContextB = localContext, ///
|
|
45
|
+
nonTerminalNodeVerified = intrinsicLevelAgainstMetaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
46
|
+
const verifiedAhead = true;
|
|
47
|
+
|
|
48
|
+
return verifiedAhead;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
statementNodeMatches = nonTerminalNodeVerified; ///
|
|
52
|
+
}
|
|
39
53
|
|
|
40
54
|
return statementNodeMatches;
|
|
41
55
|
}
|
|
42
56
|
|
|
57
|
+
matchSubproofNode(subproofNode, substitutions, fileContext, localContext) {
|
|
58
|
+
let subproofNodeMatches = false;
|
|
59
|
+
|
|
60
|
+
if (this.metastatementNode !== null) {
|
|
61
|
+
const subproofAssertionNode = subproofAssertionNodeQuery(this.metastatementNode);
|
|
62
|
+
|
|
63
|
+
if (subproofAssertionNode !== null) {
|
|
64
|
+
const subproofSuppositionStatementNodes = subproofSuppositionStatementNodesQuery(subproofNode),
|
|
65
|
+
subproofLastProofStepStatementNode = subproofLastProofStepStatementNodeQuery(subproofNode),
|
|
66
|
+
subproofStatementNodes = [
|
|
67
|
+
...subproofSuppositionStatementNodes,
|
|
68
|
+
subproofLastProofStepStatementNode
|
|
69
|
+
],
|
|
70
|
+
subproofAssertionMetastatementNodes = subproofAssertionMetastatementNodesQuery(subproofAssertionNode);
|
|
71
|
+
|
|
72
|
+
subproofNodeMatches = match(subproofAssertionMetastatementNodes, subproofStatementNodes, (subproofAssertionMetastatementNode, subproofStatementNode) => {
|
|
73
|
+
const nonTerminalNodeA = subproofAssertionMetastatementNode, ///
|
|
74
|
+
nonTerminalNodeB = subproofStatementNode, ///
|
|
75
|
+
fileContextA = fileContext, ///
|
|
76
|
+
localContextA = LocalMetaContext.fromFileContext(fileContextA),
|
|
77
|
+
localContextB = localContext, ///
|
|
78
|
+
nonTerminalNodeVerified = intrinsicLevelAgainstMetaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
79
|
+
const verifiedAhead = true;
|
|
80
|
+
|
|
81
|
+
return verifiedAhead;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
if (nonTerminalNodeVerified) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return subproofNodeMatches;
|
|
92
|
+
}
|
|
93
|
+
|
|
43
94
|
matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, localMetaContext) {
|
|
44
95
|
let ruleSubproofNodeMatches = false;
|
|
45
96
|
|
|
46
|
-
|
|
97
|
+
if (this.metastatementNode !== null) {
|
|
98
|
+
const subproofAssertionNode = subproofAssertionNodeQuery(this.metastatementNode);
|
|
47
99
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
subproofAssertionMetastatementNodes = subproofAssertionMetastatementNodesQuery(subproofAssertionNode),
|
|
57
|
-
subproofAssertionMetastatementNodesLength = subproofAssertionMetastatementNodes.length;
|
|
100
|
+
if (subproofAssertionNode !== null) {
|
|
101
|
+
const ruleSubproofPremiseMetastatementNodes = ruleSubproofPremiseMetastatementNodesQuery(ruleSubproofNode),
|
|
102
|
+
ruleSubproofLastRuleProofStepMetastatementNode = ruleSubproofLastRuleProofStepMetastatementNodeQuery(ruleSubproofNode),
|
|
103
|
+
ruleSubproofMetastatementNodes = [
|
|
104
|
+
...ruleSubproofPremiseMetastatementNodes,
|
|
105
|
+
ruleSubproofLastRuleProofStepMetastatementNode
|
|
106
|
+
],
|
|
107
|
+
subproofAssertionMetastatementNodes = subproofAssertionMetastatementNodesQuery(subproofAssertionNode);
|
|
58
108
|
|
|
59
|
-
if (ruleSubproofMetastatementNodesLength === subproofAssertionMetastatementNodesLength) {
|
|
60
109
|
ruleSubproofNodeMatches = match(subproofAssertionMetastatementNodes, ruleSubproofMetastatementNodes, (subproofAssertionMetastatementNode, ruleSubproofMetastatementNode) => {
|
|
61
110
|
const nonTerminalNodeA = subproofAssertionMetastatementNode, ///
|
|
62
111
|
nonTerminalNodeB = ruleSubproofMetastatementNode, ///
|
|
@@ -79,45 +128,100 @@ export default class Premise {
|
|
|
79
128
|
return ruleSubproofNodeMatches;
|
|
80
129
|
}
|
|
81
130
|
|
|
131
|
+
matchMetaSubproofNode(metaSubproofNode, substitutions, fileContext, localMetaContext) {
|
|
132
|
+
let metaSubproofNodeMatches = false;
|
|
133
|
+
|
|
134
|
+
if (this.metastatementNode !== null) {
|
|
135
|
+
const subproofAssertionNode = subproofAssertionNodeQuery(this.metastatementNode);
|
|
136
|
+
|
|
137
|
+
if (subproofAssertionNode !== null) {
|
|
138
|
+
const metaSubproofMetaSuppositionMetastatementNodes = metaSubproofMetaSuppositionMetastatementNodesQuery(metaSubproofNode),
|
|
139
|
+
metaSubproofLastMetaProofStepMetastatementNode = metaSubproofLastMetaProofStepMetastatementNodeQuery(metaSubproofNode),
|
|
140
|
+
metaSubproofMetastatementNodes = [
|
|
141
|
+
...metaSubproofMetaSuppositionMetastatementNodes,
|
|
142
|
+
metaSubproofLastMetaProofStepMetastatementNode
|
|
143
|
+
],
|
|
144
|
+
subproofAssertionMetastatementNodes = subproofAssertionMetastatementNodesQuery(subproofAssertionNode);
|
|
145
|
+
|
|
146
|
+
metaSubproofNodeMatches = match(subproofAssertionMetastatementNodes, metaSubproofMetastatementNodes, (subproofAssertionMetastatementNode, ruleSubproofMetastatementNode) => {
|
|
147
|
+
const nonTerminalNodeA = subproofAssertionMetastatementNode, ///
|
|
148
|
+
nonTerminalNodeB = ruleSubproofMetastatementNode, ///
|
|
149
|
+
fileContextA = fileContext, ///
|
|
150
|
+
localMetaContextA = LocalMetaContext.fromFileContext(fileContextA),
|
|
151
|
+
localMetaContextB = localMetaContext, ///
|
|
152
|
+
nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localMetaContextA, localMetaContextB, () => {
|
|
153
|
+
const verifiedAhead = true;
|
|
154
|
+
|
|
155
|
+
return verifiedAhead;
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
if (nonTerminalNodeVerified) {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return metaSubproofNodeMatches;
|
|
166
|
+
}
|
|
167
|
+
|
|
82
168
|
matchMetastatementNode(metastatementNode, substitutions, fileContext, localMetaContext) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
169
|
+
let metastatementNodeMatches = false;
|
|
170
|
+
|
|
171
|
+
if (this.metastatementNode !== null) {
|
|
172
|
+
const nonTerminalNodeA = this.metastatementNode, ///
|
|
173
|
+
nonTerminalNodeB = metastatementNode, ///
|
|
174
|
+
fileContextA = fileContext, ///
|
|
175
|
+
localMetaContextA = LocalMetaContext.fromFileContext(fileContextA),
|
|
176
|
+
localMetaContextB = localMetaContext, ///
|
|
177
|
+
nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localMetaContextA, localMetaContextB, () => {
|
|
178
|
+
const verifiedAhead = true;
|
|
179
|
+
|
|
180
|
+
return verifiedAhead;
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
metastatementNodeMatches = nonTerminalNodeVerified; ///
|
|
184
|
+
}
|
|
94
185
|
|
|
95
186
|
return metastatementNodeMatches;
|
|
96
187
|
}
|
|
97
188
|
|
|
98
189
|
toJSON(tokens) {
|
|
99
190
|
const metastatementString = nodeAsString(this.metastatementNode, tokens),
|
|
191
|
+
statementString = nodeAsString(this.statementnode, tokens),
|
|
100
192
|
metastatement = metastatementString, ///
|
|
193
|
+
statement = metastatement, ///
|
|
101
194
|
json = {
|
|
102
|
-
metastatement
|
|
195
|
+
metastatement,
|
|
196
|
+
statement
|
|
103
197
|
};
|
|
104
198
|
|
|
105
199
|
return json;
|
|
106
200
|
}
|
|
107
201
|
|
|
108
202
|
static fromJSONAndFileContext(json, fileContext) {
|
|
109
|
-
const { metastatement } = json,
|
|
203
|
+
const { metastatement, statement } = json,
|
|
110
204
|
metastatementString = metastatement, ///
|
|
205
|
+
statementString = statement, ///
|
|
111
206
|
lexer = fileContext.getLexer(),
|
|
112
207
|
parser = fileContext.getParser(),
|
|
113
208
|
metastatementNode = metastatementNodeFromMetastatementString(metastatementString, lexer, parser),
|
|
114
|
-
|
|
209
|
+
statementNode = statementNodeFromStatementString(statementString, lexer, parser),
|
|
210
|
+
premise = new Premise(metastatementNode, statementNode);
|
|
115
211
|
|
|
116
212
|
return premise;
|
|
117
213
|
}
|
|
118
214
|
|
|
119
215
|
static fromMetastatementNode(metastatementNode) {
|
|
120
|
-
const
|
|
216
|
+
const statementNode = null,
|
|
217
|
+
premise = new Premise(metastatementNode, statementNode);
|
|
218
|
+
|
|
219
|
+
return premise;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
static fromStatementNode(statementNode) {
|
|
223
|
+
const metastatementNode = null,
|
|
224
|
+
premise = new Premise(metastatementNode, statementNode);
|
|
121
225
|
|
|
122
226
|
return premise;
|
|
123
227
|
}
|
package/src/rule.js
CHANGED
|
@@ -4,9 +4,8 @@ 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
|
-
import local from "./context/local";
|
|
10
9
|
|
|
11
10
|
export default class Rule {
|
|
12
11
|
constructor(labels, premises, conclusion, fileContext) {
|
|
@@ -35,25 +34,24 @@ export default class Rule {
|
|
|
35
34
|
matchStatement(statementNode, localContext) {
|
|
36
35
|
let statementNatches;
|
|
37
36
|
|
|
38
|
-
const premisesLength = this.premises.length
|
|
39
|
-
statementLocalContext = localContext; ///
|
|
37
|
+
const premisesLength = this.premises.length;
|
|
40
38
|
|
|
41
39
|
if (premisesLength === 0) {
|
|
42
40
|
const substitutions = [],
|
|
43
|
-
conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext,
|
|
41
|
+
conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, localContext);
|
|
44
42
|
|
|
45
43
|
statementNatches = conclusionMatches; ///
|
|
46
44
|
} else {
|
|
47
|
-
const proofSteps =
|
|
45
|
+
const proofSteps = localContext.getProofSteps();
|
|
48
46
|
|
|
49
47
|
statementNatches = someSubArray(proofSteps, premisesLength, (proofSteps) => {
|
|
50
48
|
let premisesMatchConclusion = false;
|
|
51
49
|
|
|
52
50
|
const substitutions = [],
|
|
53
|
-
premisesMatch = matchPremises(this.premises, proofSteps, substitutions, this.fileContext,
|
|
51
|
+
premisesMatch = matchPremises(this.premises, proofSteps, substitutions, this.fileContext, localContext);
|
|
54
52
|
|
|
55
53
|
if (premisesMatch) {
|
|
56
|
-
const conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext,
|
|
54
|
+
const conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, localContext);
|
|
57
55
|
|
|
58
56
|
premisesMatchConclusion = conclusionMatches; ///
|
|
59
57
|
}
|
|
@@ -182,14 +180,23 @@ export default class Rule {
|
|
|
182
180
|
}
|
|
183
181
|
}
|
|
184
182
|
|
|
185
|
-
function matchPremise(premise, proofSteps, substitutions, fileContext,
|
|
186
|
-
const proofStep =
|
|
187
|
-
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
|
+
}
|
|
188
195
|
|
|
189
196
|
if (statementNode !== null) {
|
|
190
|
-
const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions, fileContext,
|
|
197
|
+
const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions, fileContext, localContext);
|
|
191
198
|
|
|
192
|
-
if (
|
|
199
|
+
if (statementNodeMatches) {
|
|
193
200
|
return true;
|
|
194
201
|
}
|
|
195
202
|
}
|
|
@@ -200,9 +207,9 @@ function matchPremise(premise, proofSteps, substitutions, fileContext, statement
|
|
|
200
207
|
return premiseMatches;
|
|
201
208
|
}
|
|
202
209
|
|
|
203
|
-
function matchPremises(premise, proofSteps, substitutions, fileContext,
|
|
210
|
+
function matchPremises(premise, proofSteps, substitutions, fileContext, localContext) {
|
|
204
211
|
const premisesMatch = premise.every((premise) => {
|
|
205
|
-
const premiseMatches = matchPremise(premise, proofSteps, substitutions, fileContext,
|
|
212
|
+
const premiseMatches = matchPremise(premise, proofSteps, substitutions, fileContext, localContext);
|
|
206
213
|
|
|
207
214
|
if (premiseMatches) {
|
|
208
215
|
return true;
|
|
@@ -212,22 +219,31 @@ function matchPremises(premise, proofSteps, substitutions, fileContext, statemen
|
|
|
212
219
|
return premisesMatch;
|
|
213
220
|
}
|
|
214
221
|
|
|
215
|
-
function matchConclusion(conclusion, statementNode, substitutions, fileContext,
|
|
216
|
-
const statementNodeMatches = conclusion.matchStatementNode(statementNode, substitutions, fileContext,
|
|
222
|
+
function matchConclusion(conclusion, statementNode, substitutions, fileContext, localContext) {
|
|
223
|
+
const statementNodeMatches = conclusion.matchStatementNode(statementNode, substitutions, fileContext, localContext),
|
|
217
224
|
conclusionMatches = statementNodeMatches; ///
|
|
218
225
|
|
|
219
226
|
return conclusionMatches;
|
|
220
227
|
}
|
|
221
228
|
|
|
222
229
|
function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, localMetaContext) {
|
|
223
|
-
const metaproofStep =
|
|
230
|
+
const metaproofStep = extract(metaproofSteps, (metaproofStep) => {
|
|
224
231
|
const ruleSubproofNode = metaproofStep.getRuleSubproofNode(),
|
|
232
|
+
metaSubproofNode = metaproofStep.getMetaSubproofNode(),
|
|
225
233
|
metastatementNode = metaproofStep.getMetastatementNode()
|
|
226
234
|
|
|
227
235
|
if (ruleSubproofNode !== null) {
|
|
228
236
|
const ruleSubProofNodeMatches = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, localMetaContext);
|
|
229
237
|
|
|
230
|
-
if (
|
|
238
|
+
if (ruleSubProofNodeMatches) {
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (metaSubproofNode !== null) {
|
|
244
|
+
const metaSubProofNodeMatches = premise.matchMetaSubproofNode(metaSubproofNode, substitutions, fileContext, localMetaContext);
|
|
245
|
+
|
|
246
|
+
if (metaSubProofNodeMatches) {
|
|
231
247
|
return true;
|
|
232
248
|
}
|
|
233
249
|
}
|
|
@@ -235,7 +251,7 @@ function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, l
|
|
|
235
251
|
if (metastatementNode !== null) {
|
|
236
252
|
const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode, substitutions, fileContext, localMetaContext);
|
|
237
253
|
|
|
238
|
-
if (
|
|
254
|
+
if (metastatementNodeMatches) {
|
|
239
255
|
return true;
|
|
240
256
|
}
|
|
241
257
|
}
|
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;
|