occam-verify-cli 0.0.922 → 0.0.923
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/conclusion.js +11 -41
- package/lib/constants.js +1 -5
- package/lib/context/local.js +15 -55
- package/lib/declaration.js +15 -15
- package/lib/metaLemmaMetatheorem.js +59 -59
- package/lib/mixins/nodesVerifier/metaLevel.js +6 -6
- package/lib/premise.js +14 -91
- package/lib/{step/proof.js → proofStep.js} +1 -1
- package/lib/rule.js +1 -45
- package/lib/ruleNames.js +1 -9
- package/lib/substitution/statementForMetavariable.js +9 -1
- package/lib/substitution.js +1 -8
- package/lib/supposition.js +55 -1
- package/lib/utilities/customGrammar.js +2 -2
- package/lib/utilities/match.js +13 -50
- package/lib/utilities/node.js +2 -27
- package/lib/utilities/tokens.js +1 -8
- package/lib/utilities/verify.js +8 -24
- package/lib/verifier/nodes/intrinsicLevelAgainstMetaLevel.js +29 -29
- package/lib/verifier/nodes/metaLevel.js +13 -13
- package/lib/verify/conclusion.js +10 -11
- package/lib/verify/declaration.js +6 -6
- package/lib/verify/metaLemma.js +12 -12
- package/lib/verify/metastatement.js +64 -64
- package/lib/verify/metatheorem.js +12 -12
- package/lib/verify/premise.js +11 -30
- package/lib/verify/proofStep.js +5 -5
- package/lib/verify/rule.js +9 -9
- package/lib/verify/statement/qualified.js +35 -9
- package/lib/verify/statement/unqualified.js +1 -1
- package/lib/verify/supposition.js +3 -3
- package/package.json +1 -1
- package/src/conclusion.js +13 -52
- package/src/constants.js +0 -1
- package/src/context/local.js +17 -64
- package/src/declaration.js +19 -19
- package/src/metaLemmaMetatheorem.js +58 -58
- package/src/mixins/nodesVerifier/metaLevel.js +8 -8
- package/src/premise.js +20 -137
- package/src/rule.js +0 -67
- package/src/ruleNames.js +0 -2
- package/src/substitution/statementForMetavariable.js +14 -0
- package/src/substitution.js +0 -6
- package/src/supposition.js +46 -0
- package/src/utilities/customGrammar.js +1 -2
- package/src/utilities/match.js +13 -60
- package/src/utilities/node.js +3 -32
- package/src/utilities/tokens.js +0 -8
- package/src/utilities/verify.js +4 -20
- package/src/verifier/nodes/intrinsicLevelAgainstMetaLevel.js +36 -37
- package/src/verifier/nodes/metaLevel.js +17 -17
- package/src/verify/conclusion.js +9 -13
- package/src/verify/declaration.js +7 -7
- package/src/verify/metaLemma.js +22 -22
- package/src/verify/metastatement.js +64 -64
- package/src/verify/metatheorem.js +21 -21
- package/src/verify/premise.js +14 -46
- package/src/verify/proofStep.js +1 -1
- package/src/verify/rule.js +8 -8
- package/src/verify/statement/qualified.js +43 -9
- package/src/verify/statement/unqualified.js +1 -1
- package/src/verify/supposition.js +1 -1
- package/lib/metaConsequent.js +0 -108
- package/lib/metaSupposition.js +0 -160
- package/lib/node/metastatement/bracketed.js +0 -16
- package/lib/step/metaproof.js +0 -106
- package/lib/substitution/metastatementForMetavariable.js +0 -173
- package/lib/verify/metaConsequent.js +0 -50
- package/lib/verify/metaDerivation.js +0 -31
- package/lib/verify/metaSubDerivation.js +0 -25
- package/lib/verify/metaSubproof.js +0 -34
- package/lib/verify/metaSupposition.js +0 -61
- package/lib/verify/metaSuppositions.js +0 -28
- package/lib/verify/metaproof.js +0 -31
- package/lib/verify/metaproofStep.js +0 -98
- package/lib/verify/metastatement/qualified.js +0 -95
- package/lib/verify/metastatement/unqualified.js +0 -37
- package/lib/verify/metastatementAsContainedAssertion.js +0 -109
- package/lib/verify/metastatementAsDefinedAssertion.js +0 -132
- package/lib/verify/metavariableAgainstMetastatement.js +0 -44
- package/src/metaConsequent.js +0 -83
- package/src/metaSupposition.js +0 -127
- package/src/node/metastatement/bracketed.js +0 -9
- package/src/step/metaproof.js +0 -73
- package/src/substitution/metastatementForMetavariable.js +0 -90
- package/src/verify/metaConsequent.js +0 -61
- package/src/verify/metaDerivation.js +0 -23
- package/src/verify/metaSubDerivation.js +0 -22
- package/src/verify/metaSubproof.js +0 -32
- package/src/verify/metaSupposition.js +0 -78
- package/src/verify/metaSuppositions.js +0 -17
- package/src/verify/metaproof.js +0 -28
- package/src/verify/metaproofStep.js +0 -137
- package/src/verify/metastatement/qualified.js +0 -130
- package/src/verify/metastatement/unqualified.js +0 -34
- package/src/verify/metastatementAsContainedAssertion.js +0 -127
- package/src/verify/metastatementAsDefinedAssertion.js +0 -156
- package/src/verify/metavariableAgainstMetastatement.js +0 -42
- /package/src/{step/proof.js → proofStep.js} +0 -0
package/src/premise.js
CHANGED
|
@@ -7,27 +7,18 @@ import intrinsicLevelAgainstMetaLevelNodesVerifier from "./verifier/nodes/intrin
|
|
|
7
7
|
import { match } from "./utilities/array";
|
|
8
8
|
import { nodeAsString } from "./utilities/string";
|
|
9
9
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
10
|
-
import { statementNodeFromStatementString
|
|
10
|
+
import { statementNodeFromStatementString } from "./utilities/node";
|
|
11
11
|
|
|
12
|
-
const subproofAssertionNodeQuery = nodeQuery("/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
ruleSubproofPremiseMetastatementNodesQuery = nodesQuery("/ruleSubproof/premise/unqualifiedMetastatement!/metastatement!"),
|
|
17
|
-
metaSubproofMetaSuppositionMetastatementNodesQuery = nodesQuery("/metaSubproof/metaSupposition/unqualifiedMetastatement!/metastatement!"),
|
|
18
|
-
ruleSubproofLastRuleProofStepMetastatementNodeQuery = nodeQuery("/ruleSubproof/ruleSubDerivation/lastRuleProofStep/unqualifiedMetastatement|qualifiedMetastatement/metastatement!"),
|
|
19
|
-
metaSubproofLastMetaproofStepMetastatementNodeQuery = nodeQuery("/metaSubproof/metaSubDerivation/lastMetaproofStep/unqualifiedMetastatement|qualifiedMetastatement/metastatement!");
|
|
12
|
+
const subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion!"),
|
|
13
|
+
subproofPremiseStatementNodesQuery = nodesQuery("/subproof/premise/unqualifiedStatement!/statement!"),
|
|
14
|
+
subproofAssertionStatementNodesQuery = nodesQuery("/subproofAssertion/statement"),
|
|
15
|
+
subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement!");
|
|
20
16
|
|
|
21
17
|
export default class Premise {
|
|
22
|
-
constructor(
|
|
23
|
-
this.metastatementNode = metastatementNode;
|
|
18
|
+
constructor(statementNode) {
|
|
24
19
|
this.statementnode = statementNode;
|
|
25
20
|
}
|
|
26
21
|
|
|
27
|
-
getMetastatementNode() {
|
|
28
|
-
return this.metastatementNode;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
22
|
getStatementNode() {
|
|
32
23
|
return this.statementnode;
|
|
33
24
|
}
|
|
@@ -35,9 +26,9 @@ export default class Premise {
|
|
|
35
26
|
matchStatementNode(statementNode, substitutions, fileContext, localContext) {
|
|
36
27
|
let matchesStatementNode = false;
|
|
37
28
|
|
|
38
|
-
if (this.
|
|
29
|
+
if (this.statementNode !== null) {
|
|
39
30
|
const fileContextA = fileContext, ///
|
|
40
|
-
nonTerminalNodeA = this.
|
|
31
|
+
nonTerminalNodeA = this.statementNode, ///
|
|
41
32
|
nonTerminalNodeB = statementNode, ///
|
|
42
33
|
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
43
34
|
localContextB = localContext, ///
|
|
@@ -56,98 +47,24 @@ export default class Premise {
|
|
|
56
47
|
matchSubproofNode(subproofNode, substitutions, fileContext, localContext) {
|
|
57
48
|
let matchesSubproofNode = false;
|
|
58
49
|
|
|
59
|
-
if (this.
|
|
60
|
-
const subproofAssertionNode = subproofAssertionNodeQuery(this.
|
|
50
|
+
if (this.statementNode !== null) {
|
|
51
|
+
const subproofAssertionNode = subproofAssertionNodeQuery(this.statementNode);
|
|
61
52
|
|
|
62
53
|
if (subproofAssertionNode !== null) {
|
|
63
|
-
const
|
|
54
|
+
const subproofPremiseStatementNodes = subproofPremiseStatementNodesQuery(subproofNode),
|
|
64
55
|
subproofLastProofStepStatementNode = subproofLastProofStepStatementNodeQuery(subproofNode),
|
|
65
56
|
subproofStatementNodes = [
|
|
66
|
-
...
|
|
57
|
+
...subproofPremiseStatementNodes,
|
|
67
58
|
subproofLastProofStepStatementNode
|
|
68
59
|
],
|
|
69
|
-
|
|
60
|
+
subproofAssertionStatementNodes = subproofAssertionStatementNodesQuery(subproofAssertionNode);
|
|
70
61
|
|
|
71
|
-
matchesSubproofNode = match(
|
|
62
|
+
matchesSubproofNode = match(subproofAssertionStatementNodes, subproofStatementNodes, (subproofAssertionStatementNode, subproofStatementNode) => {
|
|
72
63
|
const fileContextA = fileContext, ///
|
|
73
|
-
nonTerminalNodeA =
|
|
64
|
+
nonTerminalNodeA = subproofAssertionStatementNode, ///
|
|
74
65
|
nonTerminalNodeB = subproofStatementNode, ///
|
|
75
66
|
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
76
67
|
localContextB = localContext, ///
|
|
77
|
-
nonTerminalNodeVerified = intrinsicLevelAgainstMetaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
78
|
-
const verifiedAhead = true;
|
|
79
|
-
|
|
80
|
-
return verifiedAhead;
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
if (nonTerminalNodeVerified) {
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return matchesSubproofNode;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, localContext) {
|
|
94
|
-
let matchesRuleSubproofNode = false;
|
|
95
|
-
|
|
96
|
-
if (this.metastatementNode !== null) {
|
|
97
|
-
const subproofAssertionNode = subproofAssertionNodeQuery(this.metastatementNode);
|
|
98
|
-
|
|
99
|
-
if (subproofAssertionNode !== null) {
|
|
100
|
-
const ruleSubproofPremiseMetastatementNodes = ruleSubproofPremiseMetastatementNodesQuery(ruleSubproofNode),
|
|
101
|
-
ruleSubproofLastRuleProofStepMetastatementNode = ruleSubproofLastRuleProofStepMetastatementNodeQuery(ruleSubproofNode),
|
|
102
|
-
ruleSubproofMetastatementNodes = [
|
|
103
|
-
...ruleSubproofPremiseMetastatementNodes,
|
|
104
|
-
ruleSubproofLastRuleProofStepMetastatementNode
|
|
105
|
-
],
|
|
106
|
-
subproofAssertionMetastatementNodes = subproofAssertionMetastatementNodesQuery(subproofAssertionNode);
|
|
107
|
-
|
|
108
|
-
matchesRuleSubproofNode = match(subproofAssertionMetastatementNodes, ruleSubproofMetastatementNodes, (subproofAssertionMetastatementNode, ruleSubproofMetastatementNode) => {
|
|
109
|
-
const fileContextA = fileContext, ///
|
|
110
|
-
nonTerminalNodeA = subproofAssertionMetastatementNode, ///
|
|
111
|
-
nonTerminalNodeB = ruleSubproofMetastatementNode, ///
|
|
112
|
-
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
113
|
-
localContextB = localContext, ///
|
|
114
|
-
nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
115
|
-
const verifiedAhead = true;
|
|
116
|
-
|
|
117
|
-
return verifiedAhead;
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
if (nonTerminalNodeVerified) {
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return matchesRuleSubproofNode;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
matchMetaSubproofNode(metaSubproofNode, substitutions, fileContext, localContext) {
|
|
131
|
-
let matchesMetaSubproofNode = false;
|
|
132
|
-
|
|
133
|
-
if (this.metastatementNode !== null) {
|
|
134
|
-
const subproofAssertionNode = subproofAssertionNodeQuery(this.metastatementNode);
|
|
135
|
-
|
|
136
|
-
if (subproofAssertionNode !== null) {
|
|
137
|
-
const metaSubproofMetaSuppositionMetastatementNodes = metaSubproofMetaSuppositionMetastatementNodesQuery(metaSubproofNode),
|
|
138
|
-
metaSubproofLastMetaproofStepMetastatementNode = metaSubproofLastMetaproofStepMetastatementNodeQuery(metaSubproofNode),
|
|
139
|
-
metaSubproofMetastatementNodes = [
|
|
140
|
-
...metaSubproofMetaSuppositionMetastatementNodes,
|
|
141
|
-
metaSubproofLastMetaproofStepMetastatementNode
|
|
142
|
-
],
|
|
143
|
-
subproofAssertionMetastatementNodes = subproofAssertionMetastatementNodesQuery(subproofAssertionNode);
|
|
144
|
-
|
|
145
|
-
matchesMetaSubproofNode = match(subproofAssertionMetastatementNodes, metaSubproofMetastatementNodes, (subproofAssertionMetastatementNode, ruleSubproofMetastatementNode) => {
|
|
146
|
-
const fileContextA = fileContext, ///
|
|
147
|
-
nonTerminalNodeA = subproofAssertionMetastatementNode, ///
|
|
148
|
-
nonTerminalNodeB = ruleSubproofMetastatementNode, ///
|
|
149
|
-
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
150
|
-
localContextB = localContext, ///
|
|
151
68
|
nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
152
69
|
const verifiedAhead = true;
|
|
153
70
|
|
|
@@ -161,37 +78,13 @@ export default class Premise {
|
|
|
161
78
|
}
|
|
162
79
|
}
|
|
163
80
|
|
|
164
|
-
return
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
matchMetastatementNode(metastatementNode, substitutions, fileContext, localContext) {
|
|
168
|
-
let matchesMetastatementNode = false;
|
|
169
|
-
|
|
170
|
-
if (this.metastatementNode !== null) {
|
|
171
|
-
const fileContextA = fileContext, ///
|
|
172
|
-
nonTerminalNodeA = this.metastatementNode, ///
|
|
173
|
-
nonTerminalNodeB = metastatementNode, ///
|
|
174
|
-
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
175
|
-
localContextB = localContext, ///
|
|
176
|
-
nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
177
|
-
const verifiedAhead = true;
|
|
178
|
-
|
|
179
|
-
return verifiedAhead;
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
matchesMetastatementNode = nonTerminalNodeVerified; ///
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return matchesMetastatementNode;
|
|
81
|
+
return matchesSubproofNode;
|
|
186
82
|
}
|
|
187
83
|
|
|
188
84
|
toJSON(tokens) {
|
|
189
|
-
const
|
|
190
|
-
statementString = nodeAsString(this.statementnode, tokens),
|
|
191
|
-
metastatement = metastatementString, ///
|
|
85
|
+
const statementString = nodeAsString(this.statementnode, tokens),
|
|
192
86
|
statement = statementString, ///
|
|
193
87
|
json = {
|
|
194
|
-
metastatement,
|
|
195
88
|
statement
|
|
196
89
|
};
|
|
197
90
|
|
|
@@ -199,28 +92,18 @@ export default class Premise {
|
|
|
199
92
|
}
|
|
200
93
|
|
|
201
94
|
static fromStatementNode(statementNode) {
|
|
202
|
-
const
|
|
203
|
-
premise = new Premise(metastatementNode, statementNode);
|
|
204
|
-
|
|
205
|
-
return premise;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
static fromMetastatementNode(metastatementNode) {
|
|
209
|
-
const statementNode = null,
|
|
210
|
-
premise = new Premise(metastatementNode, statementNode);
|
|
95
|
+
const premise = new Premise(statementNode);
|
|
211
96
|
|
|
212
97
|
return premise;
|
|
213
98
|
}
|
|
214
99
|
|
|
215
100
|
static fromJSONAndFileContext(json, fileContext) {
|
|
216
|
-
const {
|
|
217
|
-
metastatementString = metastatement, ///
|
|
101
|
+
const { statement } = json,
|
|
218
102
|
statementString = statement, ///
|
|
219
103
|
lexer = fileContext.getLexer(),
|
|
220
104
|
parser = fileContext.getParser(),
|
|
221
|
-
metastatementNode = metastatementNodeFromMetastatementString(metastatementString, lexer, parser),
|
|
222
105
|
statementNode = statementNodeFromStatementString(statementString, lexer, parser),
|
|
223
|
-
premise = new Premise(
|
|
106
|
+
premise = new Premise(statementNode, statementNode);
|
|
224
107
|
|
|
225
108
|
return premise;
|
|
226
109
|
}
|
package/src/rule.js
CHANGED
|
@@ -46,22 +46,6 @@ export default class Rule {
|
|
|
46
46
|
return matchesStatement;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
matchMetastatement(metastatementNode, localContext) {
|
|
50
|
-
let matchesMetastatement = false;
|
|
51
|
-
|
|
52
|
-
const metaproofSteps = localContext.getMetaproofSteps(),
|
|
53
|
-
substitutions = [],
|
|
54
|
-
premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions, this.fileContext, localContext);
|
|
55
|
-
|
|
56
|
-
if (premisesMatch) {
|
|
57
|
-
const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, localContext);
|
|
58
|
-
|
|
59
|
-
matchesMetastatement = conclusionMatches; ///
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return matchesMetastatement;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
49
|
matchMetavariableNode(metavariableNode) {
|
|
66
50
|
const matchesMetavariableNode = this.labels.some((label) => {
|
|
67
51
|
const labelMatchesMetavariableNode = label.matchMetavariableNode(metavariableNode);
|
|
@@ -186,54 +170,3 @@ function matchConclusion(conclusion, statementNode, substitutions, fileContext,
|
|
|
186
170
|
|
|
187
171
|
return conclusionMatches;
|
|
188
172
|
}
|
|
189
|
-
|
|
190
|
-
function metaMatchPremise(premise, metaproofStep, substitutions, fileContext, localContext) {
|
|
191
|
-
let premiseMatches = false;
|
|
192
|
-
|
|
193
|
-
const ruleSubproofNode = metaproofStep.getRuleSubproofNode(),
|
|
194
|
-
metaSubproofNode = metaproofStep.getMetaSubproofNode(),
|
|
195
|
-
metastatementNode = metaproofStep.getMetastatementNode()
|
|
196
|
-
|
|
197
|
-
if (ruleSubproofNode !== null) {
|
|
198
|
-
const premiseMatchesRuleSubproofNode = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, localContext);
|
|
199
|
-
|
|
200
|
-
premiseMatches = premiseMatchesRuleSubproofNode; ///
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (metaSubproofNode !== null) {
|
|
204
|
-
const premiseMatchesMetaSubproofNode = premise.matchMetaSubproofNode(metaSubproofNode, substitutions, fileContext, localContext);
|
|
205
|
-
|
|
206
|
-
premiseMatches = premiseMatchesMetaSubproofNode; ///
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (metastatementNode !== null) {
|
|
210
|
-
const premiseMatchesMetastatementNode = premise.matchMetastatementNode(metastatementNode, substitutions, fileContext, localContext);
|
|
211
|
-
|
|
212
|
-
premiseMatches = premiseMatchesMetastatementNode; ///
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return premiseMatches;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function metaMatchPremises(premises, metaproofSteps, substitutions, fileContext, localContext) {
|
|
219
|
-
premises = reverse(premises); ///
|
|
220
|
-
|
|
221
|
-
metaproofSteps = reverse(metaproofSteps); ///
|
|
222
|
-
|
|
223
|
-
const premisesMatch = correlate(premises, metaproofSteps, (premise, metaproofStep) => {
|
|
224
|
-
const premiseMatches = metaMatchPremise(premise, metaproofStep, substitutions, fileContext, localContext);
|
|
225
|
-
|
|
226
|
-
if (premiseMatches) {
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
return premisesMatch;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function metaMatchConclusion(conclusion, metastatementNode, substitutions, fileContext, localContext) {
|
|
235
|
-
const conclusionMatchesMetastatementNode = conclusion.matchMetastatementNode(metastatementNode, substitutions, fileContext, localContext),
|
|
236
|
-
conclusionMatches = conclusionMatchesMetastatementNode; ///
|
|
237
|
-
|
|
238
|
-
return conclusionMatches;
|
|
239
|
-
}
|
package/src/ruleNames.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export const METAVARIABLE_RULE_NAME = "metavariable";
|
|
4
|
-
export const META_ARGUMENT_RULE_NAME = "metaArgument";
|
|
5
4
|
export const VARIABLE_DECLARATION_RULE_NAME = "variableDeclaration";
|
|
6
5
|
export const UNQUALIFIED_STATEMENT_RULE_NAME = "unqualifiedStatement";
|
|
7
6
|
export const CONSTRUCTOR_DECLARATION_RULE_NAME = "constructorDeclaration";
|
|
8
|
-
export const UNQUALIFIED_METASTATEMENT_RULE_NAME = "unqualifiedMetastatement";
|
|
@@ -5,6 +5,7 @@ import TermForVariableSubstitution from "./termForVariable";
|
|
|
5
5
|
import verifyStatementAgainstStatement from "../verify/statementAtainstStatement";
|
|
6
6
|
|
|
7
7
|
import { bracketedStatementChildNodeFromStatementNode } from "../utilities/match";
|
|
8
|
+
import { statementNodeFromStatementString, metavariableNodeFromMetavariableString } from "../utilities/node";
|
|
8
9
|
|
|
9
10
|
export default class StatementForMetavariableSubstitution extends Substitution {
|
|
10
11
|
constructor(metavariableNode, statementNode, substitution) {
|
|
@@ -55,6 +56,19 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
55
56
|
return matchesMetavariableNode;
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
static fromJSONAndFileContext(json, fileContext) {
|
|
60
|
+
const { metavariable, statement } = json,
|
|
61
|
+
metavariableString = metavariable, ///
|
|
62
|
+
statementString = statement, ///
|
|
63
|
+
lexer = fileContext.getLexer(),
|
|
64
|
+
parser = fileContext.getParser(),
|
|
65
|
+
statementNode = statementNodeFromStatementString(statementString, lexer, parser),
|
|
66
|
+
metavariableNode = metavariableNodeFromMetavariableString(metavariableString, lexer, parser),
|
|
67
|
+
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(statementNode, metavariableNode);
|
|
68
|
+
|
|
69
|
+
return statementForMetavariableSubstitution;
|
|
70
|
+
}
|
|
71
|
+
|
|
58
72
|
static fromMetavariableNodeAndStatementNode(metavariableNode, statementNode) {
|
|
59
73
|
let statementForMetavariableSubstitution;
|
|
60
74
|
|
package/src/substitution.js
CHANGED
package/src/supposition.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import LocalContext from "./context/local";
|
|
4
|
+
import metaLevelNodesVerifier from "./verifier/nodes/metaLevel";
|
|
3
5
|
import intrinsicLevelNodesVerifier from "./verifier/nodes/intrinsicLevel";
|
|
4
6
|
|
|
7
|
+
import { match } from "./utilities/array";
|
|
5
8
|
import { nodeAsString } from "./utilities/string";
|
|
6
9
|
import { statementNodeFromStatementString } from "./utilities/node";
|
|
10
|
+
import {nodeQuery, nodesQuery} from "./utilities/query";
|
|
11
|
+
|
|
12
|
+
const subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion!"),
|
|
13
|
+
subproofAssertionStatementNodesQuery = nodesQuery("/subproofAssertion/statement"),
|
|
14
|
+
subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement/statement!"),
|
|
15
|
+
subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement!");
|
|
7
16
|
|
|
8
17
|
export default class Supposition {
|
|
9
18
|
constructor(statementNode) {
|
|
@@ -29,6 +38,43 @@ export default class Supposition {
|
|
|
29
38
|
return matchesStatementNode;
|
|
30
39
|
}
|
|
31
40
|
|
|
41
|
+
matchSubproofNode(subproofNode, substitutions, fileContext, localContext) {
|
|
42
|
+
let matchesSubproofNode = false;
|
|
43
|
+
|
|
44
|
+
if (this.statementNode !== null) {
|
|
45
|
+
const subproofAssertionNode = subproofAssertionNodeQuery(this.statementNode);
|
|
46
|
+
|
|
47
|
+
if (subproofAssertionNode !== null) {
|
|
48
|
+
const subproofSuppositionStatementNodes = subproofSuppositionStatementNodesQuery(subproofNode),
|
|
49
|
+
subproofLastProofStepStatementNode = subproofLastProofStepStatementNodeQuery(subproofNode),
|
|
50
|
+
subproofStatementNodes = [
|
|
51
|
+
...subproofSuppositionStatementNodes,
|
|
52
|
+
subproofLastProofStepStatementNode
|
|
53
|
+
],
|
|
54
|
+
subproofAssertionStatementNodes = subproofAssertionStatementNodesQuery(subproofAssertionNode);
|
|
55
|
+
|
|
56
|
+
matchesSubproofNode = match(subproofAssertionStatementNodes, subproofStatementNodes, (subproofAssertionStatementNode, ruleSubproofStatementNode) => {
|
|
57
|
+
const fileContextA = fileContext, ///
|
|
58
|
+
nonTerminalNodeA = subproofAssertionStatementNode, ///
|
|
59
|
+
nonTerminalNodeB = ruleSubproofStatementNode, ///
|
|
60
|
+
localContextA = LocalContext.fromFileContext(fileContextA), ///
|
|
61
|
+
localContextB = localContext, ///
|
|
62
|
+
nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
63
|
+
const verifiedAhead = true;
|
|
64
|
+
|
|
65
|
+
return verifiedAhead;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (nonTerminalNodeVerified) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return matchesSubproofNode;
|
|
76
|
+
}
|
|
77
|
+
|
|
32
78
|
toJSON(tokens) {
|
|
33
79
|
const statementString = nodeAsString(this.statementNode, tokens),
|
|
34
80
|
statement = statementString, ///
|
|
@@ -5,11 +5,10 @@ import { CustomGrammar, CombinedCustomGrammar } from "occam-custom-grammars";
|
|
|
5
5
|
export function customGrammarFromNameAndEntries(name, entries) {
|
|
6
6
|
const termBNF = entries.getTermBNF(),
|
|
7
7
|
statementBNF = entries.getStatementBNF(),
|
|
8
|
-
metastatementBNF = entries.getMetastatementBNF(),
|
|
9
8
|
typePattern = entries.getTypePattern(),
|
|
10
9
|
symbolPattern = entries.getSymbolPattern(),
|
|
11
10
|
operatorPattern = entries.getOperatorPattern(),
|
|
12
|
-
customGrammar = CustomGrammar.
|
|
11
|
+
customGrammar = CustomGrammar.fromNameTermBNFStatementBNFTypePatternSymbolPatternAndOperatorPattern(name, termBNF, statementBNF, typePattern, symbolPattern, operatorPattern);
|
|
13
12
|
|
|
14
13
|
return customGrammar;
|
|
15
14
|
}
|
package/src/utilities/match.js
CHANGED
|
@@ -1,76 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import bracketedStatementNode from "../node/statement/bracketed";
|
|
4
|
-
import bracketedMetastatementNode from "../node/metastatement/bracketed";
|
|
5
4
|
|
|
6
5
|
import { nodeQuery } from "../utilities/query";
|
|
7
|
-
import { BRACKETED_STATEMENT_DEPTH
|
|
6
|
+
import { BRACKETED_STATEMENT_DEPTH } from "../constants";
|
|
8
7
|
|
|
9
|
-
const bracketedStatementChildNodeQuery = nodeQuery("/statement/
|
|
10
|
-
bracketedMetastatementChildNodeQuery = nodeQuery("/metastatement/metastatement!");
|
|
8
|
+
const bracketedStatementChildNodeQuery = nodeQuery("/statement/statement!");
|
|
11
9
|
|
|
12
10
|
export function matchStatementModuloBrackets(statementNodeA, statementNodeB) {
|
|
13
|
-
let
|
|
11
|
+
let statementMatches = false;
|
|
14
12
|
|
|
15
|
-
if (!
|
|
16
|
-
const
|
|
13
|
+
if (!statementMatches) {
|
|
14
|
+
const statementNodeMatches = statementNodeA.match(statementNodeB);
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
statementMatches = statementNodeMatches; ///
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
if (!
|
|
19
|
+
if (!statementMatches) {
|
|
22
20
|
const bracketedStatementChildNodeA = bracketedStatementChildNodeFromStatementNode(statementNodeA);
|
|
23
21
|
|
|
24
22
|
if (bracketedStatementChildNodeA !== null) {
|
|
25
|
-
const
|
|
23
|
+
const bracketedStatementChildNodeAMatchesStatementNodeB = bracketedStatementChildNodeA.match(statementNodeB);
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
statementMatches = bracketedStatementChildNodeAMatchesStatementNodeB; ///
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
if (!
|
|
29
|
+
if (!statementMatches) {
|
|
32
30
|
const bracketedStatementChildNodeB = bracketedStatementChildNodeFromStatementNode(statementNodeB);
|
|
33
31
|
|
|
34
32
|
if (bracketedStatementChildNodeB !== null) {
|
|
35
|
-
const
|
|
33
|
+
const statementNodeAMatchesBracketedStatementChildNodeB = statementNodeA.match(bracketedStatementChildNodeB);
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
statementMatches = statementNodeAMatchesBracketedStatementChildNodeB; ///
|
|
38
36
|
}
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function matchMetastatementModuloBrackets(metastatementNodeA, metastatementNodeB) {
|
|
45
|
-
let metastatementMatches = false;
|
|
46
|
-
|
|
47
|
-
if (!metastatementMatches) {
|
|
48
|
-
const metastatementNodeMatches = metastatementNodeA.match(metastatementNodeB);
|
|
49
|
-
|
|
50
|
-
metastatementMatches = metastatementNodeMatches; ///
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (!metastatementMatches) {
|
|
54
|
-
const bracketedMetastatementChildNodeA = bracketedMetastatementChildNodeFromMetastatementNode(metastatementNodeA);
|
|
55
|
-
|
|
56
|
-
if (bracketedMetastatementChildNodeA !== null) {
|
|
57
|
-
const bracketedMetastatementChildNodeAMatchesMetastatementNodeB = bracketedMetastatementChildNodeA.match(metastatementNodeB);
|
|
58
|
-
|
|
59
|
-
metastatementMatches = bracketedMetastatementChildNodeAMatchesMetastatementNodeB; ///
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (!metastatementMatches) {
|
|
64
|
-
const bracketedMetastatementChildNodeB = bracketedMetastatementChildNodeFromMetastatementNode(metastatementNodeB);
|
|
65
|
-
|
|
66
|
-
if (bracketedMetastatementChildNodeB !== null) {
|
|
67
|
-
const metastatementNodeAMatchesBracketedMetastatementChildNodeB = metastatementNodeA.match(bracketedMetastatementChildNodeB);
|
|
68
|
-
|
|
69
|
-
metastatementMatches = metastatementNodeAMatchesBracketedMetastatementChildNodeB; ///
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return metastatementMatches;
|
|
39
|
+
return statementMatches;
|
|
74
40
|
}
|
|
75
41
|
|
|
76
42
|
export function bracketedStatementChildNodeFromStatementNode(statementNode) {
|
|
@@ -85,16 +51,3 @@ export function bracketedStatementChildNodeFromStatementNode(statementNode) {
|
|
|
85
51
|
|
|
86
52
|
return bracketedStatementChildNode;
|
|
87
53
|
}
|
|
88
|
-
|
|
89
|
-
export function bracketedMetastatementChildNodeFromMetastatementNode(metastatementNode) {
|
|
90
|
-
let bracketedMetastatementChildNode = null;
|
|
91
|
-
|
|
92
|
-
const depth = BRACKETED_METASTATEMENT_DEPTH,
|
|
93
|
-
metastatementNodeMatchesBracketedMetastatementNode = metastatementNode.match(bracketedMetastatementNode, depth);
|
|
94
|
-
|
|
95
|
-
if (metastatementNodeMatchesBracketedMetastatementNode) {
|
|
96
|
-
bracketedMetastatementChildNode = bracketedMetastatementChildNodeQuery(metastatementNode);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return bracketedMetastatementChildNode;
|
|
100
|
-
}
|
package/src/utilities/node.js
CHANGED
|
@@ -7,12 +7,10 @@ import { combinedCustomGrammarFromNothing } from "./customGrammar";
|
|
|
7
7
|
import { METAVARIABLE_RULE_NAME,
|
|
8
8
|
VARIABLE_DECLARATION_RULE_NAME,
|
|
9
9
|
UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
10
|
-
CONSTRUCTOR_DECLARATION_RULE_NAME
|
|
11
|
-
UNQUALIFIED_METASTATEMENT_RULE_NAME } from "../ruleNames";
|
|
10
|
+
CONSTRUCTOR_DECLARATION_RULE_NAME } from "../ruleNames";
|
|
12
11
|
import { metavariableTokensFromMetavariableString,
|
|
13
12
|
variableDeclarationTokensFromVariableString,
|
|
14
|
-
unqualifiedStatementTokensFromStatementString
|
|
15
|
-
unqualifiedMetastatementTokensFromMetastatementString } from "../utilities/tokens";
|
|
13
|
+
unqualifiedStatementTokensFromStatementString } from "../utilities/tokens";
|
|
16
14
|
|
|
17
15
|
const { florenceParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
18
16
|
|
|
@@ -21,8 +19,7 @@ const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
|
|
|
21
19
|
|
|
22
20
|
const termNodeQuery = nodeQuery("/constructorDeclaration/term!"),
|
|
23
21
|
variableNodeQuery = nodeQuery("/variableDeclaration/variable!"),
|
|
24
|
-
statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!")
|
|
25
|
-
metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatement!");
|
|
22
|
+
statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!");
|
|
26
23
|
|
|
27
24
|
export function variableNodeFromVariableString(variableString, lexer, parser) {
|
|
28
25
|
const variableTDeclarationTokens = variableDeclarationTokensFromVariableString(variableString, lexer),
|
|
@@ -45,13 +42,6 @@ export function metavariableNodeFromMetavariableString(metavariableString, lexer
|
|
|
45
42
|
return metavariableNode;
|
|
46
43
|
}
|
|
47
44
|
|
|
48
|
-
export function metastatementNodeFromMetastatementString(metastatementString, lexer, parser) {
|
|
49
|
-
const unqualifiedMetastatementTokens = unqualifiedMetastatementTokensFromMetastatementString(metastatementString, lexer),
|
|
50
|
-
metastatementNode = metastatementNodeFromUnqualifiedMetastatementTokens(unqualifiedMetastatementTokens, parser);
|
|
51
|
-
|
|
52
|
-
return metastatementNode;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
45
|
export function termNodeFromConstructorDeclarationTokens(constructorDeclarationTokens, parser) {
|
|
56
46
|
let termNode = null;
|
|
57
47
|
|
|
@@ -88,18 +78,6 @@ export function variableNodeFromVariableVariableTDeclarationTokens(variableTDecl
|
|
|
88
78
|
return variableNode;
|
|
89
79
|
}
|
|
90
80
|
|
|
91
|
-
export function metastatementNodeFromUnqualifiedMetastatementTokens(unqualifiedMetastatementTokens, parser) {
|
|
92
|
-
let metastatementNode = null;
|
|
93
|
-
|
|
94
|
-
const unqualifiedMetastatementNode = unqualifiedMetastatementNodeFromUnqualifiedMetastatementTokens(unqualifiedMetastatementTokens, parser);
|
|
95
|
-
|
|
96
|
-
if (unqualifiedMetastatementNode !== null) {
|
|
97
|
-
metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return metastatementNode;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
81
|
export function metavariableNodeFromMetavariableTokens(metavariableTokens, parser) {
|
|
104
82
|
const ruleName = METAVARIABLE_RULE_NAME,
|
|
105
83
|
metavariableNode = nodeFromTokensRuleNameAndParser(metavariableTokens, ruleName, parser);
|
|
@@ -128,13 +106,6 @@ export function constructorDeclarationNodeFromConstructorDeclarationTokens(const
|
|
|
128
106
|
return constructorDeclarationNode;
|
|
129
107
|
}
|
|
130
108
|
|
|
131
|
-
export function unqualifiedMetastatementNodeFromUnqualifiedMetastatementTokens(unqualifiedMetastatementTokens, parser) {
|
|
132
|
-
const ruleName = UNQUALIFIED_METASTATEMENT_RULE_NAME,
|
|
133
|
-
unqualifiedMetastatementNode = nodeFromTokensRuleNameAndParser(unqualifiedMetastatementTokens, ruleName, parser);
|
|
134
|
-
|
|
135
|
-
return unqualifiedMetastatementNode;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
109
|
function nodeFromTokensRuleNameAndParser(tokens, ruleName, parser = florenceParser) {
|
|
139
110
|
const ruleMap = parser.getRuleMap(),
|
|
140
111
|
rule = ruleMap[ruleName],
|
package/src/utilities/tokens.js
CHANGED
|
@@ -40,14 +40,6 @@ export function unqualifiedStatementTokensFromStatementString(statementString, l
|
|
|
40
40
|
return unqualifiedStatementTokens;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export function unqualifiedMetastatementTokensFromMetastatementString(metastatementString, lexer) {
|
|
44
|
-
const unqualifiedMetastatementContent = `${metastatementString}
|
|
45
|
-
`,
|
|
46
|
-
unqualifiedMetastatementTokens = tokensFromContentAndLexer(unqualifiedMetastatementContent, lexer);
|
|
47
|
-
|
|
48
|
-
return unqualifiedMetastatementTokens;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
43
|
function tokensFromContentAndLexer(content, lexer = florenceLexer) {
|
|
52
44
|
const tokens = lexer.tokenise(content);
|
|
53
45
|
|
package/src/utilities/verify.js
CHANGED
|
@@ -5,26 +5,10 @@ import { nodeQuery } from "../utilities/query";
|
|
|
5
5
|
|
|
6
6
|
const secondOperatorTerminalNodeQuery = nodeQuery("/*/@operator[1]");
|
|
7
7
|
|
|
8
|
-
export function
|
|
9
|
-
const
|
|
10
|
-
negated = isNegated(node),
|
|
11
|
-
statementNegated = negated; ///
|
|
12
|
-
|
|
13
|
-
return statementNegated;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function isMetastatementNegated(metastatementNode) {
|
|
17
|
-
const node = metastatementNode, ///
|
|
18
|
-
negated = isNegated(node),
|
|
19
|
-
statementNegated = negated; ///
|
|
20
|
-
|
|
21
|
-
return statementNegated;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function isNegated(node) {
|
|
25
|
-
const secondOperatorTerminalNode = secondOperatorTerminalNodeQuery(node),
|
|
8
|
+
export function isAssertionNegated(assertionNode) {
|
|
9
|
+
const secondOperatorTerminalNode = secondOperatorTerminalNodeQuery(assertionNode),
|
|
26
10
|
content = secondOperatorTerminalNode.getContent(),
|
|
27
|
-
|
|
11
|
+
assertionNegated = (content === NOT);
|
|
28
12
|
|
|
29
|
-
return
|
|
13
|
+
return assertionNegated;
|
|
30
14
|
}
|