occam-verify-cli 0.0.922 → 0.0.924
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/axiom.js +9 -9
- package/lib/conclusion.js +11 -41
- package/lib/conjecture.js +9 -9
- package/lib/constants.js +1 -13
- package/lib/context/file.js +3 -3
- package/lib/context/local.js +19 -59
- package/lib/declaration.js +15 -15
- package/lib/lemma.js +9 -9
- package/lib/metaLemma.js +7 -7
- package/lib/metatheorem.js +7 -7
- package/lib/metavariable.js +8 -1
- 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/theorem.js +9 -9
- package/lib/topLevelAssertion.js +186 -0
- 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/axiom.js +4 -4
- package/lib/verify/conclusion.js +10 -11
- package/lib/verify/conjecture.js +4 -4
- package/lib/verify/containedAssertion.js +91 -0
- package/lib/verify/declaration.js +7 -7
- package/lib/verify/definedAssertion.js +115 -0
- package/lib/verify/derivation.js +7 -7
- package/lib/verify/frame.js +2 -2
- package/lib/verify/judgement.js +2 -2
- package/lib/verify/lemma.js +5 -5
- package/lib/verify/metaLemma.js +12 -12
- package/lib/verify/metastatement.js +48 -67
- package/lib/verify/metatheorem.js +12 -12
- package/lib/verify/metavariable.js +2 -2
- package/lib/verify/premise.js +11 -30
- package/lib/verify/proof.js +3 -3
- package/lib/verify/proofStep.js +8 -8
- package/lib/verify/rule.js +10 -10
- package/lib/verify/statement/qualified.js +38 -15
- package/lib/verify/statement/unqualified.js +38 -10
- package/lib/verify/statement.js +85 -92
- package/lib/verify/subDerivation.js +3 -3
- package/lib/verify/subproof.js +3 -3
- package/lib/verify/supposition.js +3 -3
- package/lib/verify/termAsConstructor.js +2 -2
- package/lib/verify/theorem.js +4 -4
- package/package.json +2 -2
- package/src/axiom.js +4 -4
- package/src/conclusion.js +13 -52
- package/src/conjecture.js +4 -4
- package/src/constants.js +0 -3
- package/src/context/file.js +2 -2
- package/src/context/local.js +21 -67
- package/src/declaration.js +19 -19
- package/src/lemma.js +4 -4
- package/src/metaLemma.js +4 -4
- package/src/metatheorem.js +4 -4
- package/src/metavariable.js +6 -0
- 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/theorem.js +4 -4
- package/src/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +36 -23
- 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/axiom.js +5 -4
- package/src/verify/conclusion.js +9 -13
- package/src/verify/conjecture.js +5 -4
- package/src/verify/{statementAsContainedAssertion.js → containedAssertion.js} +20 -36
- package/src/verify/declaration.js +8 -8
- package/src/verify/{statementAsDefinedAssertion.js → definedAssertion.js} +22 -37
- package/src/verify/derivation.js +6 -6
- package/src/verify/frame.js +1 -1
- package/src/verify/judgement.js +1 -1
- package/src/verify/lemma.js +8 -5
- package/src/verify/metaLemma.js +24 -24
- package/src/verify/metastatement.js +48 -76
- package/src/verify/metatheorem.js +23 -23
- package/src/verify/metavariable.js +1 -1
- package/src/verify/premise.js +14 -46
- package/src/verify/proof.js +2 -2
- package/src/verify/proofStep.js +4 -4
- package/src/verify/rule.js +11 -11
- package/src/verify/statement/qualified.js +56 -21
- package/src/verify/statement/unqualified.js +52 -10
- package/src/verify/statement.js +133 -39
- package/src/verify/subDerivation.js +2 -2
- package/src/verify/subproof.js +2 -2
- package/src/verify/supposition.js +1 -1
- package/src/verify/termAsConstructor.js +2 -2
- package/src/verify/theorem.js +7 -4
- package/lib/axiomLemmaTheoremConjecture.js +0 -174
- package/lib/metaConsequent.js +0 -108
- package/lib/metaLemmaMetatheorem.js +0 -191
- 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/lib/verify/statementAsContainedAssertion.js +0 -109
- package/lib/verify/statementAsDefinedAssertion.js +0 -132
- package/src/metaConsequent.js +0 -83
- package/src/metaLemmaMetatheorem.js +0 -188
- 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, ///
|
package/src/theorem.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import TopLevelAssertion from "./topLevelAssertion";
|
|
4
4
|
|
|
5
|
-
export default class Theorem extends
|
|
6
|
-
static fromJSONAndFileContext(json, fileContext) { return
|
|
5
|
+
export default class Theorem extends TopLevelAssertion {
|
|
6
|
+
static fromJSONAndFileContext(json, fileContext) { return TopLevelAssertion.fromJSONAndFileContext(Theorem, json, fileContext); }
|
|
7
7
|
|
|
8
|
-
static
|
|
8
|
+
static fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(labels, suppositions, consequent, substitutions, fileContext) { return TopLevelAssertion.fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(Theorem, labels, suppositions, consequent, substitutions, fileContext); }
|
|
9
9
|
}
|
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
import Label from "./label";
|
|
4
4
|
import Consequent from "./consequent";
|
|
5
5
|
import Supposition from "./supposition";
|
|
6
|
-
import
|
|
6
|
+
import StatementForMetavariableSubstitution from "./substitution/statementForMetavariable";
|
|
7
7
|
|
|
8
8
|
import { reverse, correlate } from "./utilities/array";
|
|
9
9
|
|
|
10
|
-
export default class
|
|
11
|
-
constructor(labels, suppositions, consequent,
|
|
10
|
+
export default class TopLevelAssertion {
|
|
11
|
+
constructor(labels, suppositions, consequent, substitutions, fileContext) {
|
|
12
12
|
this.labels = labels;
|
|
13
13
|
this.suppositions = suppositions;
|
|
14
14
|
this.consequent = consequent;
|
|
15
|
-
this.
|
|
15
|
+
this.substitutions = substitutions;
|
|
16
|
+
this.fileContext = fileContext;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
getLabels() {
|
|
@@ -27,8 +28,12 @@ export default class AxiomLemmaTheoremConjecture {
|
|
|
27
28
|
return this.consequent;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
return this.
|
|
31
|
+
getSubstitutions() {
|
|
32
|
+
return this.substitutions;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getFileContext() {
|
|
36
|
+
return this.fileContext;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
matchStatement(statementNode, localContext) {
|
|
@@ -36,10 +41,10 @@ export default class AxiomLemmaTheoremConjecture {
|
|
|
36
41
|
|
|
37
42
|
const proofSteps = localContext.getProofSteps(),
|
|
38
43
|
substitutions = [],
|
|
39
|
-
suppositionsMatch = matchSuppositions(this.suppositions, proofSteps, substitutions, this.
|
|
44
|
+
suppositionsMatch = matchSuppositions(this.suppositions, proofSteps, substitutions, this.fileContext, localContext);
|
|
40
45
|
|
|
41
46
|
if (suppositionsMatch) {
|
|
42
|
-
const consequentMatches = matchConsequent(this.consequent, statementNode, substitutions, this.
|
|
47
|
+
const consequentMatches = matchConsequent(this.consequent, statementNode, substitutions, this.fileContext, localContext);
|
|
43
48
|
|
|
44
49
|
statementNatches = consequentMatches; ///
|
|
45
50
|
}
|
|
@@ -71,16 +76,20 @@ export default class AxiomLemmaTheoremConjecture {
|
|
|
71
76
|
return suppositionJSON;
|
|
72
77
|
}),
|
|
73
78
|
consequentJSON = this.consequent.toJSON(tokens),
|
|
74
|
-
|
|
79
|
+
substitutionsJSON = this.substitutions.map((substitution) => {
|
|
80
|
+
const substitutionJSON = substitution.toJSON();
|
|
81
|
+
|
|
82
|
+
return substitutionJSON;
|
|
83
|
+
}),
|
|
75
84
|
labels = labelsJSON, ///
|
|
76
85
|
suppositions = suppositionsJSON, ///
|
|
77
86
|
consequent = consequentJSON, ///
|
|
78
|
-
|
|
87
|
+
substitutions = substitutionsJSON, ///
|
|
79
88
|
json = {
|
|
80
89
|
labels,
|
|
81
90
|
suppositions,
|
|
82
91
|
consequent,
|
|
83
|
-
|
|
92
|
+
substitutions
|
|
84
93
|
};
|
|
85
94
|
|
|
86
95
|
return json;
|
|
@@ -98,7 +107,7 @@ export default class AxiomLemmaTheoremConjecture {
|
|
|
98
107
|
return label;
|
|
99
108
|
});
|
|
100
109
|
|
|
101
|
-
let { suppositions, consequent,
|
|
110
|
+
let { suppositions, consequent, substitutions } = json;
|
|
102
111
|
|
|
103
112
|
const suppositionsJSON = suppositions; ///
|
|
104
113
|
|
|
@@ -115,25 +124,29 @@ export default class AxiomLemmaTheoremConjecture {
|
|
|
115
124
|
|
|
116
125
|
consequent = Consequent.fromJSONAndFileContext(json, fileContext);
|
|
117
126
|
|
|
118
|
-
const
|
|
127
|
+
const substitutionsJSON = substitutions; ///
|
|
119
128
|
|
|
120
|
-
|
|
129
|
+
substitutions = substitutionsJSON.map((substitutionJSON) => {
|
|
130
|
+
const json = substitutionJSON, ///
|
|
131
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromJSONAndFileContext(json, fileContext),
|
|
132
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
121
133
|
|
|
122
|
-
|
|
134
|
+
return substitution;
|
|
135
|
+
});
|
|
123
136
|
|
|
124
|
-
return new Class(labels, suppositions, consequent,
|
|
137
|
+
return new Class(labels, suppositions, consequent, substitutions, fileContext); ///
|
|
125
138
|
}
|
|
126
139
|
|
|
127
|
-
static
|
|
140
|
+
static fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(Class, labels, suppositions, consequent, substitutions, fileContext) { return new Class(labels, suppositions, consequent, substitutions, fileContext); }
|
|
128
141
|
}
|
|
129
142
|
|
|
130
|
-
function matchSuppositions(suppositions, proofSteps, substitutions,
|
|
143
|
+
function matchSuppositions(suppositions, proofSteps, substitutions, fileContext, localContext) {
|
|
131
144
|
suppositions = reverse(suppositions); ///
|
|
132
145
|
|
|
133
146
|
proofSteps = reverse(proofSteps); ///
|
|
134
147
|
|
|
135
148
|
const suppositionsMatch = correlate(suppositions, proofSteps, (supposition, proofStep) => {
|
|
136
|
-
const suppositionMatches = matchSupposition(supposition, proofStep, substitutions,
|
|
149
|
+
const suppositionMatches = matchSupposition(supposition, proofStep, substitutions, fileContext, localContext);
|
|
137
150
|
|
|
138
151
|
if (suppositionMatches) {
|
|
139
152
|
return true;
|
|
@@ -143,13 +156,13 @@ function matchSuppositions(suppositions, proofSteps, substitutions, localContext
|
|
|
143
156
|
return suppositionsMatch;
|
|
144
157
|
}
|
|
145
158
|
|
|
146
|
-
function matchSupposition(supposition, proofStep, substitutions,
|
|
159
|
+
function matchSupposition(supposition, proofStep, substitutions, fileContext, localContext) {
|
|
147
160
|
let suppositionMatches = false;
|
|
148
161
|
|
|
149
162
|
const statementNode = proofStep.getStatementNode();
|
|
150
163
|
|
|
151
164
|
if (statementNode !== null) {
|
|
152
|
-
const suppositionMatchesStatementNode = supposition.matchStatementNode(statementNode, substitutions,
|
|
165
|
+
const suppositionMatchesStatementNode = supposition.matchStatementNode(statementNode, substitutions, fileContext, localContext);
|
|
153
166
|
|
|
154
167
|
suppositionMatches = suppositionMatchesStatementNode; ///
|
|
155
168
|
}
|
|
@@ -157,8 +170,8 @@ function matchSupposition(supposition, proofStep, substitutions, localContext, s
|
|
|
157
170
|
return suppositionMatches;
|
|
158
171
|
}
|
|
159
172
|
|
|
160
|
-
function matchConsequent(consequent, statementNode, substitutions,
|
|
161
|
-
const consequentMatchesStatementNode = consequent.matchStatementNode(statementNode, substitutions,
|
|
173
|
+
function matchConsequent(consequent, statementNode, substitutions, fileContext, localContext) {
|
|
174
|
+
const consequentMatchesStatementNode = consequent.matchStatementNode(statementNode, substitutions, fileContext, localContext),
|
|
162
175
|
consequentMatches = consequentMatchesStatementNode; ///
|
|
163
176
|
|
|
164
177
|
return consequentMatches;
|
|
@@ -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
|
}
|