occam-verify-cli 0.0.864 → 0.0.866
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 +7 -7
- package/lib/context/file.js +162 -60
- package/lib/context/local.js +4 -4
- package/lib/context/release.js +32 -1
- package/lib/label.js +6 -6
- package/lib/metaConsequent.js +88 -0
- package/lib/metaLemma.js +126 -0
- package/lib/metaLemmaMetatheorem.js +196 -0
- package/lib/metaSupposition.js +140 -0
- package/lib/metaType.js +33 -3
- package/lib/metaTypeNames.js +13 -4
- package/lib/metaTypes.js +9 -4
- package/lib/metatheorem.js +126 -0
- package/lib/mixins/context.js +30 -22
- package/lib/rule.js +7 -7
- package/lib/ruleNames.js +5 -1
- package/lib/step/metaproof.js +18 -4
- package/lib/type.js +9 -1
- package/lib/utilities/name.js +52 -0
- package/lib/utilities/query.js +1 -38
- package/lib/verifier/node/metastatement.js +3 -3
- package/lib/verifier/nodes/statementAgainstCombinator.js +4 -4
- package/lib/verifier/nodes/termAgainstConstructor.js +3 -3
- package/lib/verifier/nodes.js +10 -10
- package/lib/verify/declaration/metavariable.js +4 -4
- package/lib/verify/declaration/topLevel.js +11 -3
- package/lib/verify/givenMetavariable.js +31 -0
- package/lib/verify/givenType.js +2 -3
- package/lib/verify/label.js +3 -4
- package/lib/verify/metaConsequent.js +36 -0
- package/lib/verify/metaDerivation.js +111 -0
- package/lib/verify/metaLemma.js +51 -0
- package/lib/verify/metaSupposition.js +40 -0
- package/lib/verify/metaSuppositions.js +28 -0
- package/lib/verify/metaproof.js +34 -0
- package/lib/verify/metastatement/qualified.js +2 -2
- package/lib/verify/metatheorem.js +50 -0
- package/lib/verify/metavariable.js +30 -10
- package/lib/verify/proof.js +3 -3
- package/lib/verify/statement/qualified.js +28 -28
- package/lib/verify/termAsConstructor.js +4 -5
- package/lib/verify/type.js +18 -20
- package/lib/verify/variable.js +13 -16
- package/package.json +4 -4
- package/src/axiomLemmaTheoremConjecture.js +6 -6
- package/src/context/file.js +187 -73
- package/src/context/local.js +1 -1
- package/src/context/release.js +37 -0
- package/src/label.js +4 -6
- package/src/metaConsequent.js +58 -0
- package/src/metaLemma.js +9 -0
- package/src/metaLemmaMetatheorem.js +194 -0
- package/src/metaSupposition.js +103 -0
- package/src/metaType.js +23 -3
- package/src/metaTypeNames.js +1 -0
- package/src/metaTypes.js +8 -1
- package/src/metatheorem.js +9 -0
- package/src/mixins/context.js +20 -14
- package/src/rule.js +6 -6
- package/src/ruleNames.js +1 -0
- package/src/step/metaproof.js +20 -4
- package/src/type.js +10 -0
- package/src/utilities/name.js +50 -0
- package/src/utilities/query.js +0 -47
- package/src/verifier/node/metastatement.js +2 -1
- package/src/verifier/nodes/statementAgainstCombinator.js +3 -3
- package/src/verifier/nodes/termAgainstConstructor.js +3 -4
- package/src/verifier/nodes.js +9 -9
- package/src/verify/declaration/metavariable.js +4 -3
- package/src/verify/declaration/topLevel.js +14 -0
- package/src/verify/givenMetavariable.js +31 -0
- package/src/verify/givenType.js +1 -4
- package/src/verify/label.js +2 -5
- package/src/verify/metaConsequent.js +36 -0
- package/src/verify/metaDerivation.js +151 -0
- package/src/verify/metaLemma.js +67 -0
- package/src/verify/metaSupposition.js +44 -0
- package/src/verify/metaSuppositions.js +17 -0
- package/src/verify/metaproof.js +32 -0
- package/src/verify/metastatement/qualified.js +2 -3
- package/src/verify/metatheorem.js +62 -0
- package/src/verify/metavariable.js +46 -16
- package/src/verify/proof.js +2 -2
- package/src/verify/statement/qualified.js +27 -23
- package/src/verify/termAsConstructor.js +4 -6
- package/src/verify/type.js +20 -22
- package/src/verify/variable.js +14 -17
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Label from "./label";
|
|
4
|
+
import LocalContext from "./context/local";
|
|
5
|
+
import MetaConsequent from "./metaConsequent";
|
|
6
|
+
import MetaSupposition from "./metaSupposition";
|
|
7
|
+
|
|
8
|
+
import { prune } from "./utilities/array";
|
|
9
|
+
import { someSubArray } from "./utilities/array";
|
|
10
|
+
|
|
11
|
+
export default class MetaLemmaMetatheorem {
|
|
12
|
+
constructor(labels, metaSuppositions, metaConsequent, localContext) {
|
|
13
|
+
this.labels = labels;
|
|
14
|
+
this.metaSuppositions = metaSuppositions;
|
|
15
|
+
this.metaConsequent = metaConsequent;
|
|
16
|
+
this.localContext = localContext;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getLabels() {
|
|
20
|
+
return this.labels;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getMetaSuppositions() {
|
|
24
|
+
return this.metaSuppositions;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getMetaConsequent() {
|
|
28
|
+
return this.metaConsequent;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getLocalContext() {
|
|
32
|
+
return this.localContext;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
matchLabelNode(labelNode) {
|
|
36
|
+
const labelNodeMatches = this.labels.some((label) => {
|
|
37
|
+
const node = labelNode, ///
|
|
38
|
+
labelMatchesNode = label.matchNode(node);
|
|
39
|
+
|
|
40
|
+
if (labelMatchesNode) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return labelNodeMatches;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
matchMetastatement(metastatementNode, metastatementLocalContext) {
|
|
49
|
+
let metastatementNatches;
|
|
50
|
+
|
|
51
|
+
const metaSuppositionsLength = this.metaSuppositions.length;
|
|
52
|
+
|
|
53
|
+
if (metaSuppositionsLength === 0) {
|
|
54
|
+
const substitutions = [],
|
|
55
|
+
metaConsequentMatches = matchMetaConsequent(this.metaConsequent, metastatementNode, substitutions, this.localContext, metastatementLocalContext);
|
|
56
|
+
|
|
57
|
+
metastatementNatches = metaConsequentMatches; ///
|
|
58
|
+
} else {
|
|
59
|
+
const metaproofSteps = metastatementLocalContext.getProofSteps();
|
|
60
|
+
|
|
61
|
+
metastatementNatches = someSubArray(metaproofSteps, metaSuppositionsLength, (metaproofSteps) => {
|
|
62
|
+
let metaSuppositionsMatchMetaConsequent = false;
|
|
63
|
+
|
|
64
|
+
const substitutions = [],
|
|
65
|
+
metaSuppositionsMatch = matchMetaSuppositions(this.metaSuppositions, metaproofSteps, substitutions, this.localContext, metastatementLocalContext);
|
|
66
|
+
|
|
67
|
+
if (metaSuppositionsMatch) {
|
|
68
|
+
const metaConsequentMatches = matchMetaConsequent(this.metaConsequent, metastatementNode, substitutions, this.localContext, metastatementLocalContext);
|
|
69
|
+
|
|
70
|
+
metaSuppositionsMatchMetaConsequent = metaConsequentMatches; ///
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (metaSuppositionsMatchMetaConsequent) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return metastatementNatches;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
toJSON(tokens) {
|
|
83
|
+
const labelsJSON = this.labels.map((label) => {
|
|
84
|
+
const labelJSON = label.toJSON(tokens);
|
|
85
|
+
|
|
86
|
+
return labelJSON;
|
|
87
|
+
}),
|
|
88
|
+
metaSuppositionsJSON = this.metaSuppositions.map((metaSupposition) => {
|
|
89
|
+
const metaSuppositionJSON = metaSupposition.toJSON(tokens);
|
|
90
|
+
|
|
91
|
+
return metaSuppositionJSON;
|
|
92
|
+
}),
|
|
93
|
+
metaConsequentJSON = this.metaConsequent.toJSON(tokens),
|
|
94
|
+
localContextJSON = this.localContext.toJSON(tokens),
|
|
95
|
+
labels = labelsJSON, ///
|
|
96
|
+
metaSuppositions = metaSuppositionsJSON, ///
|
|
97
|
+
metaConsequent = metaConsequentJSON, ///
|
|
98
|
+
localContext = localContextJSON, ///
|
|
99
|
+
json = {
|
|
100
|
+
labels,
|
|
101
|
+
metaSuppositions,
|
|
102
|
+
metaConsequent,
|
|
103
|
+
localContext
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
return json;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static fromJSONAndFileContext(Class, json, fileContext) {
|
|
110
|
+
let { labels } = json;
|
|
111
|
+
|
|
112
|
+
const labelsJSON = labels; ///
|
|
113
|
+
|
|
114
|
+
labels = labelsJSON.map((labelJSON) => {
|
|
115
|
+
const json = labelJSON, ///
|
|
116
|
+
label = Label.fromJSONAndFileContext(json, fileContext);
|
|
117
|
+
|
|
118
|
+
return label;
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
let { metaSuppositions, metaConsequent, localContext } = json;
|
|
122
|
+
|
|
123
|
+
const metaSuppositionsJSON = metaSuppositions; ///
|
|
124
|
+
|
|
125
|
+
metaSuppositions = metaSuppositionsJSON.map((metaSuppositionJSON) => {
|
|
126
|
+
const json = metaSuppositionJSON, ///
|
|
127
|
+
metaSupposition = MetaSupposition.fromJSONAndFileContext(json, fileContext);
|
|
128
|
+
|
|
129
|
+
return metaSupposition;
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const metaConsequentJSON = metaConsequent; ///
|
|
133
|
+
|
|
134
|
+
json = metaConsequentJSON; ///
|
|
135
|
+
|
|
136
|
+
metaConsequent = MetaConsequent.fromJSONAndFileContext(json, fileContext);
|
|
137
|
+
|
|
138
|
+
const localContextJSON = localContext; ///
|
|
139
|
+
|
|
140
|
+
json = localContextJSON; ///
|
|
141
|
+
|
|
142
|
+
localContext = LocalContext.fromJSONAndFileContext(json, fileContext);
|
|
143
|
+
|
|
144
|
+
return new Class(labels, metaSuppositions, metaConsequent, localContext); ///
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
static fromLabelsMetaSuppositionsMetaConsequentAndLocalContext(Class, labels, metaSuppositions, metaConsequent, localContext) { return new Class(labels, metaSuppositions, metaConsequent, localContext); }
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function matchMetaSupposition(metaSupposition, metaproofSteps, substitutions, localContext, metastatementLocalContext) {
|
|
151
|
+
const metaproofStep = prune(metaproofSteps, (metaproofStep) => {
|
|
152
|
+
const metaSubproofNode = metaproofStep.getMetaSubproofNode(),
|
|
153
|
+
metastatementNode = metaproofStep.getMetastatementNode();
|
|
154
|
+
|
|
155
|
+
if (metaSubproofNode !== null) {
|
|
156
|
+
const metaSubProofMatches = metaSupposition.matchMetaSubproofNode(metaSubproofNode, substitutions, localContext, metastatementLocalContext);
|
|
157
|
+
|
|
158
|
+
if (!metaSubProofMatches) { ///
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (metastatementNode !== null) {
|
|
164
|
+
const metastatementMatches = metaSupposition.matchMetastatementNode(metastatementNode, substitutions, localContext, metastatementLocalContext);
|
|
165
|
+
|
|
166
|
+
if (!metastatementMatches) { ///
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}) || null;
|
|
171
|
+
|
|
172
|
+
const metaSuppositionMatches = (metaproofStep !== null);
|
|
173
|
+
|
|
174
|
+
return metaSuppositionMatches;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function matchMetaSuppositions(metaSuppositions, metaproofSteps, substitutions, localContext, metastatementLocalContext) {
|
|
178
|
+
const metaSuppositionsMatch = metaSuppositions.every((metaSupposition) => {
|
|
179
|
+
const metaSuppositionMatches = matchMetaSupposition(metaSupposition, metaproofSteps, substitutions, localContext, metastatementLocalContext);
|
|
180
|
+
|
|
181
|
+
if (metaSuppositionMatches) {
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
return metaSuppositionsMatch;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function matchMetaConsequent(metaConsequent, metastatementNode, substitutions, localContext, metastatementLocalContext) {
|
|
190
|
+
const nonTerminalNodeMatches = metaConsequent.matchMetastatementNode(metastatementNode, substitutions, localContext, metastatementLocalContext),
|
|
191
|
+
metaConsequentMatches = nonTerminalNodeMatches; ///
|
|
192
|
+
|
|
193
|
+
return metaConsequentMatches;
|
|
194
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import metaLevelNodesVerifier from "./verifier/nodes/metaLevel";
|
|
4
|
+
|
|
5
|
+
import { match } from "./utilities/array";
|
|
6
|
+
import { nodeAsString } from "./utilities/string";
|
|
7
|
+
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
8
|
+
import { metastatementNodeFromMetastatementString } from "./utilities/node";
|
|
9
|
+
|
|
10
|
+
const metaSubproofAssertionNodeQuery = nodeQuery("/metastatement/metaSubproofAssertion!"),
|
|
11
|
+
metaSubproofAssertionMetastatementNodesQuery = nodesQuery("/metaSubproofAssertion/metastatement"),
|
|
12
|
+
metaSubproofMetaSuppositionMetastatementNodesQuery = nodesQuery("/metaSubproof/metaSupposition/unqualifiedMetastatement/metastatement!"),
|
|
13
|
+
metaSubproofSubDerivationLastMetastatementNodeQuery = nodeQuery("/metaSubproof/metaSubDerivation/qualifiedMetastatement|unqualifiedMetastatement[-1]/metastatement!");
|
|
14
|
+
|
|
15
|
+
export default class MetaSupposition {
|
|
16
|
+
constructor(metastatementNode) {
|
|
17
|
+
this.metastatementNode = metastatementNode;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getMetastatementNode() {
|
|
21
|
+
return this.metastatementNode;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
matchMetaSubproofNode(metaSubproofNode, substitutions, localContext, metastatementLocalContext) {
|
|
25
|
+
let metaSubproofNodeMatches = false;
|
|
26
|
+
|
|
27
|
+
const metaSubproofAssertionNode = metaSubproofAssertionNodeQuery(this.metastatementNode);
|
|
28
|
+
|
|
29
|
+
if (metaSubproofAssertionNode !== null) {
|
|
30
|
+
const metaSubproofMetaSuppositionMetastatementNodes = metaSubproofMetaSuppositionMetastatementNodesQuery(metaSubproofNode),
|
|
31
|
+
metaSubproofSubDerivationLastMetastatementNode = metaSubproofSubDerivationLastMetastatementNodeQuery(metaSubproofNode),
|
|
32
|
+
metaSubproofMetastatementNodes = [
|
|
33
|
+
...metaSubproofMetaSuppositionMetastatementNodes,
|
|
34
|
+
metaSubproofSubDerivationLastMetastatementNode
|
|
35
|
+
],
|
|
36
|
+
metaSubproofAssertionMetastatementNodes = metaSubproofAssertionMetastatementNodesQuery(metaSubproofAssertionNode),
|
|
37
|
+
metaSubproofMetastatementNodesLength = metaSubproofMetastatementNodes.length,
|
|
38
|
+
metaSubproofAssertionMetastatementNodesLength = metaSubproofAssertionMetastatementNodes.length;
|
|
39
|
+
|
|
40
|
+
if (metaSubproofMetastatementNodesLength === metaSubproofAssertionMetastatementNodesLength) {
|
|
41
|
+
metaSubproofNodeMatches = match(metaSubproofAssertionMetastatementNodes, metaSubproofMetastatementNodes, (metaSubproofAssertionMetastatementNode, metaSubproofMetastatementNode) => {
|
|
42
|
+
const nonTerminalNodeA = metaSubproofAssertionMetastatementNode, ///
|
|
43
|
+
nonTerminalNodeB = metaSubproofMetastatementNode, ///
|
|
44
|
+
localContextA = localContext, ///
|
|
45
|
+
localContextB = metastatementLocalContext, ///
|
|
46
|
+
nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
47
|
+
const verifiedAhead = true;
|
|
48
|
+
|
|
49
|
+
return verifiedAhead;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (nonTerminalNodeVerified) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return metaSubproofNodeMatches;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
matchMetastatementNode(metastatementNode, substitutions, localContext, metastatementLocalContext) {
|
|
63
|
+
const nonTerminalNodeA = this.metastatementNode, ///
|
|
64
|
+
nonTerminalNodeB = metastatementNode, ///
|
|
65
|
+
localContextA = localContext, ///
|
|
66
|
+
localContextB = metastatementLocalContext, ///
|
|
67
|
+
nonTerminalNodeVerified = metaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
68
|
+
const verifiedAhead = true;
|
|
69
|
+
|
|
70
|
+
return verifiedAhead;
|
|
71
|
+
}),
|
|
72
|
+
metastatementNodeMatches = nonTerminalNodeVerified; ///
|
|
73
|
+
|
|
74
|
+
return metastatementNodeMatches;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
toJSON(tokens) {
|
|
78
|
+
const metastatementString = nodeAsString(this.metastatementNode, tokens),
|
|
79
|
+
metastatement = metastatementString, ///
|
|
80
|
+
json = {
|
|
81
|
+
metastatement
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return json;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static fromMetastatementNode(metastatementNode) {
|
|
88
|
+
const metaSupposition = new MetaSupposition(metastatementNode);
|
|
89
|
+
|
|
90
|
+
return metaSupposition;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static fromJSONAndFileContext(json, fileContext) {
|
|
94
|
+
const { metastatement } = json,
|
|
95
|
+
metastatementString = metastatement, ///
|
|
96
|
+
lexer = fileContext.getLexer(),
|
|
97
|
+
parser = fileContext.getParser(),
|
|
98
|
+
metastatementNode = metastatementNodeFromMetastatementString(metastatementString, lexer, parser),
|
|
99
|
+
metaSupposition = new MetaSupposition(metastatementNode);
|
|
100
|
+
|
|
101
|
+
return metaSupposition;
|
|
102
|
+
}
|
|
103
|
+
}
|
package/src/metaType.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { metaTypeNameFromMetaTypeNode } from "./utilities/name";
|
|
4
|
+
import { CONTEXT_META_TYPE_NAME, STATEMENT_META_TYPE_NAME } from "./metaTypeNames";
|
|
4
5
|
|
|
5
6
|
export default class MetaType {
|
|
6
7
|
constructor(name) {
|
|
@@ -36,6 +37,14 @@ export default class MetaType {
|
|
|
36
37
|
return metaTypeNameMatches;
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
matchMetaTypeNode(metaTypeNode) {
|
|
41
|
+
const metaTypeName = metaTypeNameFromMetaTypeNode(metaTypeNode),
|
|
42
|
+
metaTypeNameMatches = this.matchMetaTypeName(metaTypeName),
|
|
43
|
+
metaTypeNodeMatches = metaTypeNameMatches; ///
|
|
44
|
+
|
|
45
|
+
return metaTypeNodeMatches;
|
|
46
|
+
}
|
|
47
|
+
|
|
39
48
|
asString(tokens) {
|
|
40
49
|
const string = `${this.name}`;
|
|
41
50
|
|
|
@@ -59,15 +68,26 @@ export default class MetaType {
|
|
|
59
68
|
}
|
|
60
69
|
}
|
|
61
70
|
|
|
71
|
+
class ContextMetaType extends MetaType {
|
|
72
|
+
static fromNothing() {
|
|
73
|
+
const name = CONTEXT_META_TYPE_NAME,
|
|
74
|
+
contextMetaType = new ContextMetaType(name);
|
|
75
|
+
|
|
76
|
+
return contextMetaType;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
62
80
|
class StatementMetaType extends MetaType {
|
|
63
81
|
static fromNothing() {
|
|
64
82
|
const name = STATEMENT_META_TYPE_NAME,
|
|
65
|
-
|
|
83
|
+
statementMetaType = new StatementMetaType(name);
|
|
66
84
|
|
|
67
|
-
return
|
|
85
|
+
return statementMetaType;
|
|
68
86
|
}
|
|
69
87
|
}
|
|
70
88
|
|
|
89
|
+
export const contextMetaType = ContextMetaType.fromNothing();
|
|
90
|
+
|
|
71
91
|
export const statementMetaType = StatementMetaType.fromNothing();
|
|
72
92
|
|
|
73
93
|
export function metaTypeFromJSONAndFileContext(json, fileContext) {
|
package/src/metaTypeNames.js
CHANGED
package/src/metaTypes.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MetaLemmaMetatheorem from "./metaLemmaMetatheorem";
|
|
4
|
+
|
|
5
|
+
export default class Metatheorem extends MetaLemmaMetatheorem {
|
|
6
|
+
static fromJSONAndFileContext(json, fileContext) { return MetaLemmaMetatheorem.fromJSONAndFileContext(Metatheorem, json, fileContext); }
|
|
7
|
+
|
|
8
|
+
static fromLabelsMetaSuppositionsMetaConsequentAndLocalMetaContext(labels, suppositions, consequent, localMetaContext) { return MetaLemmaMetatheorem.fromLabelsMetaSuppositionsMetaConsequentAndLocalMetaContext(Metatheorem, labels, suppositions, consequent, localMetaContext); }
|
|
9
|
+
}
|
package/src/mixins/context.js
CHANGED
|
@@ -26,22 +26,26 @@ function getConstructors() { return this.context.getConstructors(); }
|
|
|
26
26
|
|
|
27
27
|
function findTypeByTypeName(typeName) { return this.context.findTypeByTypeName(typeName); }
|
|
28
28
|
|
|
29
|
-
function
|
|
29
|
+
function findTypeByTypeNode(labelNode) { return this.context.findTypeByTypeNode(labelNode); }
|
|
30
30
|
|
|
31
|
-
function
|
|
31
|
+
function findLabelByLabelNode(labelNode) { return this.context.findLabelByLabelNode(labelNode); }
|
|
32
32
|
|
|
33
|
-
function
|
|
33
|
+
function findRuleByReferenceNode(referenceNode) { return this.context.findRuleByReferenceNode(referenceNode); }
|
|
34
34
|
|
|
35
|
-
function
|
|
35
|
+
function findAxiomByReferenceNode(referenceNode) { return this.context.findAxiomByReferenceNode(referenceNode); }
|
|
36
36
|
|
|
37
|
-
function
|
|
37
|
+
function findLemmaByReferenceNode(referenceNode) { return this.context.findLemmaByReferenceNode(referenceNode); }
|
|
38
38
|
|
|
39
|
-
function
|
|
39
|
+
function findTheoremByReferenceNode(referenceNode) { return this.context.findTheoremByReferenceNode(referenceNode); }
|
|
40
40
|
|
|
41
|
-
function
|
|
41
|
+
function findConjectureByReferenceNode(referenceNode) { return this.context.findConjectureByReferenceNode(referenceNode); }
|
|
42
42
|
|
|
43
43
|
function isTypePresentByTypeName(typeName) { return this.context.isTypePresentByTypeName(typeName); }
|
|
44
44
|
|
|
45
|
+
function isTypePresentByTypeNode(typeNode) { return this.context.isTypePresentByTypeNode(typeNode); }
|
|
46
|
+
|
|
47
|
+
function isLabelPresentByLabelNode(labelNode) { return this.context.isLabelPresentByLabelNode(labelNode); }
|
|
48
|
+
|
|
45
49
|
function nodeAsString(node) { return this.context.nodeAsString(node); }
|
|
46
50
|
|
|
47
51
|
function nodesAsString(node) { return this.context.nodesAsString(node); }
|
|
@@ -60,14 +64,16 @@ const contextMixins = {
|
|
|
60
64
|
getCombinators,
|
|
61
65
|
getConstructors,
|
|
62
66
|
findTypeByTypeName,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
findTypeByTypeNode,
|
|
68
|
+
findLabelByLabelNode,
|
|
69
|
+
findRuleByReferenceNode,
|
|
70
|
+
findAxiomByReferenceNode,
|
|
71
|
+
findLemmaByReferenceNode,
|
|
72
|
+
findTheoremByReferenceNode,
|
|
73
|
+
findConjectureByReferenceNode,
|
|
70
74
|
isTypePresentByTypeName,
|
|
75
|
+
isTypePresentByTypeNode,
|
|
76
|
+
isLabelPresentByLabelNode,
|
|
71
77
|
nodeAsString,
|
|
72
78
|
nodesAsString
|
|
73
79
|
};
|
package/src/rule.js
CHANGED
|
@@ -31,17 +31,17 @@ export default class Rule {
|
|
|
31
31
|
return this.fileContext;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
34
|
+
matchLabelNode(labelNode) {
|
|
35
|
+
const labelNodeMatches = this.labels.some((label) => {
|
|
36
|
+
const node = labelNode, ///
|
|
37
|
+
labelMatchesNode = label.matchNode(node);
|
|
38
38
|
|
|
39
|
-
if (
|
|
39
|
+
if (labelMatchesNode) {
|
|
40
40
|
return true;
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
return
|
|
44
|
+
return labelNodeMatches;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
matchStatement(statementNode, statementLocalContext) {
|
package/src/ruleNames.js
CHANGED
|
@@ -10,6 +10,7 @@ export const STATEMENT_RULE_NAME = "statement";
|
|
|
10
10
|
export const METAVARIABLE_RULE_NAME = "metavariable";
|
|
11
11
|
export const METASTATEMENT_RULE_NAME = "metastatement";
|
|
12
12
|
export const RULE_SUBPROOF_RULE_NAME = "ruleSubproof";
|
|
13
|
+
export const META_SUBPROOF_RULE_NAME = "metaSubproof";
|
|
13
14
|
export const META_ARGUMENT_RULE_NAME = "metaArgument";
|
|
14
15
|
export const QUALIFIED_STATEMENT_RULE_NAME = "qualifiedStatement";
|
|
15
16
|
export const VARIABLE_DECLARATION_RULE_NAME = "variableDeclaration";
|
package/src/step/metaproof.js
CHANGED
|
@@ -9,8 +9,9 @@ const metastatementNodesQuery = nodesQuery("/ruleSubproofAssertion/metastatement
|
|
|
9
9
|
qualifiedOrUnqualifiedMetastatementMetastatementNodesQuery = nodesQuery("/ruleSubproof/qualifiedMetastatement|unqualifiedMetastatement/metastatement!");
|
|
10
10
|
|
|
11
11
|
export default class MetaproofStep {
|
|
12
|
-
constructor(ruleSubproofNode, metastatementNode) {
|
|
12
|
+
constructor(ruleSubproofNode, metaSubproofNode, metastatementNode) {
|
|
13
13
|
this.ruleSubproofNode = ruleSubproofNode;
|
|
14
|
+
this.metaSubproofNode = metaSubproofNode;
|
|
14
15
|
this.metastatementNode = metastatementNode;
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -18,6 +19,10 @@ export default class MetaproofStep {
|
|
|
18
19
|
return this.ruleSubproofNode;
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
getMetaSubproofNode() {
|
|
23
|
+
return this.metaSubproofNode;
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
getMetastatementNode() {
|
|
22
27
|
return this.metastatementNode;
|
|
23
28
|
}
|
|
@@ -87,15 +92,26 @@ export default class MetaproofStep {
|
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
static fromRuleSubproofNode(ruleSubproofNode) {
|
|
90
|
-
const
|
|
91
|
-
|
|
95
|
+
const metaSubproofNode = null,
|
|
96
|
+
metastatementNode = null,
|
|
97
|
+
metaProofStep = new MetaproofStep(ruleSubproofNode, metaSubproofNode, metastatementNode);
|
|
98
|
+
|
|
99
|
+
return metaProofStep;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static fromMetaSubproofNode(metaSubproofNode) {
|
|
103
|
+
const ruleSubproofNode = null,
|
|
104
|
+
metastatementNode = null,
|
|
105
|
+
metaProofStep = new MetaproofStep(ruleSubproofNode, metaSubproofNode, metastatementNode);
|
|
92
106
|
|
|
93
107
|
return metaProofStep;
|
|
108
|
+
|
|
94
109
|
}
|
|
95
110
|
|
|
96
111
|
static fromMetastatementNode(metastatementNode) {
|
|
97
112
|
const ruleSubproofNode = null,
|
|
98
|
-
|
|
113
|
+
metaSubproofNode = null,
|
|
114
|
+
metaProofStep = new MetaproofStep(ruleSubproofNode, metaSubproofNode, metastatementNode);
|
|
99
115
|
|
|
100
116
|
return metaProofStep;
|
|
101
117
|
}
|
package/src/type.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { OBJECT_TYPE_NAME } from "./typeNames";
|
|
4
4
|
|
|
5
|
+
import { typeNameFromTypeNode } from "./utilities/name";
|
|
6
|
+
|
|
5
7
|
export default class Type {
|
|
6
8
|
constructor(name, superType) {
|
|
7
9
|
this.name = name;
|
|
@@ -101,6 +103,14 @@ export default class Type {
|
|
|
101
103
|
return typeNameMatches;
|
|
102
104
|
}
|
|
103
105
|
|
|
106
|
+
matchTypeNode(typeNode) {
|
|
107
|
+
const typeName = typeNameFromTypeNode(typeNode),
|
|
108
|
+
typeNameMatches = this.matchTypeName(typeName),
|
|
109
|
+
typeNodeMatches = typeNameMatches; ///
|
|
110
|
+
|
|
111
|
+
return typeNodeMatches;
|
|
112
|
+
}
|
|
113
|
+
|
|
104
114
|
asString(tokens, noSuperType = false) {
|
|
105
115
|
let string;
|
|
106
116
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { nodeQuery } from "../utilities/query";
|
|
4
|
+
|
|
5
|
+
const typeTerminalNodeQuery = nodeQuery("/type/@type"),
|
|
6
|
+
metaTypeTerminalNodeQuery = nodeQuery("/metaType/@meta-type"),
|
|
7
|
+
labelNameTerminalNodeQuery = nodeQuery("/label/@name"),
|
|
8
|
+
referenceNameTerminalNodeQuery = nodeQuery("/reference/@name");
|
|
9
|
+
|
|
10
|
+
export function typeNameFromTypeNode(typeNode) {
|
|
11
|
+
let typeName = null;
|
|
12
|
+
|
|
13
|
+
if (typeNode !== null) {
|
|
14
|
+
const typeTerminalNode = typeTerminalNodeQuery(typeNode),
|
|
15
|
+
typeTerminalNodeContent = typeTerminalNode.getContent();
|
|
16
|
+
|
|
17
|
+
typeName = typeTerminalNodeContent; ///
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return typeName;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function labelNameFromLabelNode(labelNode) {
|
|
24
|
+
const labelNameTerminalNode = labelNameTerminalNodeQuery(labelNode),
|
|
25
|
+
labelNameTerminalNodeContent = labelNameTerminalNode.getContent(),
|
|
26
|
+
labelName = labelNameTerminalNodeContent; ///
|
|
27
|
+
|
|
28
|
+
return labelName;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function metaTypeNameFromMetaTypeNode(metaTypeNode) {
|
|
32
|
+
let metaTypeName = null;
|
|
33
|
+
|
|
34
|
+
if (metaTypeNode !== null) {
|
|
35
|
+
const metaTypeTerminalNode = metaTypeTerminalNodeQuery(metaTypeNode),
|
|
36
|
+
metaTypeTerminalNodeContent = metaTypeTerminalNode.getContent();
|
|
37
|
+
|
|
38
|
+
metaTypeName = metaTypeTerminalNodeContent; ///
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return metaTypeName;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function referenceNameFromReferenceNode(referenceNode) {
|
|
45
|
+
const referenceNameTerminalNode = referenceNameTerminalNodeQuery(referenceNode),
|
|
46
|
+
referenceNameTerminalNodeContent = referenceNameTerminalNode.getContent(),
|
|
47
|
+
referenceName = referenceNameTerminalNodeContent; ///
|
|
48
|
+
|
|
49
|
+
return referenceName;
|
|
50
|
+
}
|
package/src/utilities/query.js
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { Query } from "occam-query";
|
|
4
4
|
|
|
5
|
-
const typeTerminalNodeQuery = nodeQuery("/type/@type"),
|
|
6
|
-
metaTypeTerminalNodeQuery = nodeQuery("/metaType/@meta-type"),
|
|
7
|
-
labelNameTerminalNodeQuery = nodeQuery("/label/@name"),
|
|
8
|
-
referenceNameTerminalNodeQuery = nodeQuery("/reference/@name");
|
|
9
|
-
|
|
10
5
|
export function nodeQuery(expression) {
|
|
11
6
|
const query = Query.fromExpression(expression);
|
|
12
7
|
|
|
@@ -34,45 +29,3 @@ export function nodesQuery(expression) {
|
|
|
34
29
|
return nodes;
|
|
35
30
|
};
|
|
36
31
|
}
|
|
37
|
-
|
|
38
|
-
export function typeNameFromTypeNode(typeNode) {
|
|
39
|
-
let typeName = null;
|
|
40
|
-
|
|
41
|
-
if (typeNode !== null) {
|
|
42
|
-
const typeTerminalNode = typeTerminalNodeQuery(typeNode),
|
|
43
|
-
typeTerminalNodeContent = typeTerminalNode.getContent();
|
|
44
|
-
|
|
45
|
-
typeName = typeTerminalNodeContent; ///
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return typeName;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function labelNameFromLabelNode(labelNode) {
|
|
52
|
-
const labelNameTerminalNode = labelNameTerminalNodeQuery(labelNode),
|
|
53
|
-
labelNameTerminalNodeContent = labelNameTerminalNode.getContent(),
|
|
54
|
-
labelName = labelNameTerminalNodeContent; ///
|
|
55
|
-
|
|
56
|
-
return labelName;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function metaTypeNameFromMetaTypeNode(metaTypeNode) {
|
|
60
|
-
let metaTypeName = null;
|
|
61
|
-
|
|
62
|
-
if (metaTypeNode !== null) {
|
|
63
|
-
const metaTypeTerminalNode = metaTypeTerminalNodeQuery(metaTypeNode),
|
|
64
|
-
metaTypeTerminalNodeContent = metaTypeTerminalNode.getContent();
|
|
65
|
-
|
|
66
|
-
metaTypeName = metaTypeTerminalNodeContent; ///
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return metaTypeName;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function referenceNameFromReferenceNode(referenceNode) {
|
|
73
|
-
const referenceNameTerminalNode = referenceNameTerminalNodeQuery(referenceNode),
|
|
74
|
-
referenceNameTerminalNodeContent = referenceNameTerminalNode.getContent(),
|
|
75
|
-
referenceName = referenceNameTerminalNodeContent; ///
|
|
76
|
-
|
|
77
|
-
return referenceName;
|
|
78
|
-
}
|
|
@@ -27,7 +27,8 @@ class MetastatementNodeVerifier extends NodeVerifier {
|
|
|
27
27
|
|
|
28
28
|
case VARIABLE_RULE_NAME: {
|
|
29
29
|
const variableNode = nonTerminalNode, ///
|
|
30
|
-
|
|
30
|
+
localContext = LocalContext.fromLocalMetaContext(localMetaContext),
|
|
31
|
+
standaloneVariableVerified = verifyStandaloneVariable(variableNode, localContext, verifyAhead),
|
|
31
32
|
variableNodeVerified = standaloneVariableVerified; ///
|
|
32
33
|
|
|
33
34
|
nonTerminalNodeVerified = variableNodeVerified; ///
|