occam-verify-cli 0.0.538 → 0.0.540
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/bin/action/verify.js +7 -24
- package/bin/actions.js +20 -6
- package/lib/axiom.js +7 -7
- package/lib/axiomLemmaTheoremConjecture.js +33 -30
- package/lib/combinator.js +4 -4
- package/lib/conclusion.js +8 -8
- package/lib/conjecture.js +7 -7
- package/lib/consequence.js +3 -3
- package/lib/constructor.js +6 -6
- package/lib/context/file.js +215 -45
- package/lib/context/metaproof.js +3 -3
- package/lib/context/release.js +215 -2
- package/lib/kinds.js +13 -1
- package/lib/label.js +4 -4
- package/lib/lemma.js +7 -7
- package/lib/metaType.js +201 -0
- package/lib/metavariable.js +81 -0
- package/lib/premise.js +12 -12
- package/lib/rule.js +42 -35
- package/lib/ruleNames.js +16 -4
- package/lib/supposition.js +8 -8
- package/lib/theorem.js +7 -7
- package/lib/type.js +7 -7
- package/lib/utilities/node.js +17 -3
- package/lib/utilities/query.js +13 -2
- package/lib/variable.js +18 -12
- package/lib/verifier/metastatementForMetavariable.js +8 -8
- package/lib/verifier/statementForMetavariable.js +9 -9
- package/lib/verifier/termForVariable.js +22 -11
- package/lib/verifier.js +1 -1
- package/lib/verify/assertion/type.js +2 -2
- package/lib/verify/axiom.js +2 -2
- package/lib/verify/conjecture.js +2 -2
- package/lib/verify/declaration/metavariable.js +26 -0
- package/lib/verify/declaration/topLevel.js +7 -3
- package/lib/verify/lemma.js +2 -2
- package/lib/verify/metastatement/qualified.js +3 -3
- package/lib/verify/metastatement.js +147 -3
- package/lib/verify/metavariable.js +34 -0
- package/lib/verify/rule.js +2 -2
- package/lib/verify/statement/qualified.js +7 -7
- package/lib/verify/statement.js +6 -6
- package/lib/verify/theorem.js +2 -2
- package/lib/verify/variable.js +4 -4
- package/package.json +3 -3
- package/src/axiom.js +2 -2
- package/src/axiomLemmaTheoremConjecture.js +31 -32
- package/src/combinator.js +3 -3
- package/src/conclusion.js +11 -7
- package/src/conjecture.js +2 -2
- package/src/consequence.js +2 -2
- package/src/constructor.js +5 -5
- package/src/context/file.js +248 -45
- package/src/context/metaproof.js +1 -1
- package/src/context/release.js +254 -2
- package/src/kinds.js +3 -0
- package/src/label.js +3 -3
- package/src/lemma.js +2 -2
- package/src/metaType.js +81 -0
- package/src/metavariable.js +39 -0
- package/src/premise.js +19 -11
- package/src/rule.js +37 -32
- package/src/ruleNames.js +4 -1
- package/src/supposition.js +11 -7
- package/src/theorem.js +2 -2
- package/src/type.js +5 -5
- package/src/utilities/node.js +32 -2
- package/src/utilities/query.js +14 -0
- package/src/variable.js +12 -8
- package/src/verifier/metastatementForMetavariable.js +7 -7
- package/src/verifier/statementForMetavariable.js +8 -8
- package/src/verifier/termForVariable.js +33 -13
- package/src/verifier.js +1 -1
- package/src/verify/assertion/type.js +3 -3
- package/src/verify/axiom.js +1 -1
- package/src/verify/conjecture.js +2 -1
- package/src/verify/declaration/metavariable.js +20 -0
- package/src/verify/declaration/topLevel.js +9 -2
- package/src/verify/lemma.js +1 -1
- package/src/verify/metastatement/qualified.js +3 -2
- package/src/verify/metastatement.js +65 -2
- package/src/verify/metavariable.js +32 -0
- package/src/verify/rule.js +1 -1
- package/src/verify/statement/qualified.js +7 -6
- package/src/verify/statement.js +14 -14
- package/src/verify/theorem.js +2 -1
- package/src/verify/variable.js +4 -4
- package/lib/context/release/directory.js +0 -313
- package/lib/context/release/file.js +0 -387
- package/src/context/release/directory.js +0 -251
- package/src/context/release/file.js +0 -312
package/src/rule.js
CHANGED
|
@@ -9,10 +9,11 @@ import { RULE_KIND } from "./kinds";
|
|
|
9
9
|
import { someSubArray } from "./utilities/array";
|
|
10
10
|
|
|
11
11
|
export default class Rule {
|
|
12
|
-
constructor(labels, premises, conclusion) {
|
|
12
|
+
constructor(labels, premises, conclusion, fileContext) {
|
|
13
13
|
this.labels = labels;
|
|
14
14
|
this.premises = premises;
|
|
15
15
|
this.conclusion = conclusion;
|
|
16
|
+
this.fileContext = fileContext;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
getLabels() {
|
|
@@ -27,6 +28,10 @@ export default class Rule {
|
|
|
27
28
|
return this.conclusion;
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
getFileContext() {
|
|
32
|
+
return this.fileContext;
|
|
33
|
+
}
|
|
34
|
+
|
|
30
35
|
matchLabelName(labelName) {
|
|
31
36
|
const matchesLabelName = this.labels.some((label) => {
|
|
32
37
|
const name = labelName, ///
|
|
@@ -40,27 +45,27 @@ export default class Rule {
|
|
|
40
45
|
return matchesLabelName;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
matchStatement(statementNode,
|
|
48
|
+
matchStatement(statementNode, statementProofContext) {
|
|
44
49
|
let statementNatches;
|
|
45
50
|
|
|
46
51
|
const premisesLength = this.premises.length;
|
|
47
52
|
|
|
48
53
|
if (premisesLength === 0) {
|
|
49
54
|
const substitutions = [],
|
|
50
|
-
conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions);
|
|
55
|
+
conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, statementProofContext);
|
|
51
56
|
|
|
52
57
|
statementNatches = conclusionMatches; ///
|
|
53
58
|
} else {
|
|
54
|
-
const proofSteps =
|
|
59
|
+
const proofSteps = statementProofContext.getProofSteps();
|
|
55
60
|
|
|
56
61
|
statementNatches = someSubArray(proofSteps, premisesLength, (proofSteps) => {
|
|
57
62
|
let premisesMatchConclusion = false;
|
|
58
63
|
|
|
59
64
|
const substitutions = [],
|
|
60
|
-
premisesMatch = matchPremises(this.premises, proofSteps, substitutions);
|
|
65
|
+
premisesMatch = matchPremises(this.premises, proofSteps, substitutions, this.fileContext, statementProofContext);
|
|
61
66
|
|
|
62
67
|
if (premisesMatch) {
|
|
63
|
-
const conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions);
|
|
68
|
+
const conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, statementProofContext);
|
|
64
69
|
|
|
65
70
|
premisesMatchConclusion = conclusionMatches; ///
|
|
66
71
|
}
|
|
@@ -74,27 +79,27 @@ export default class Rule {
|
|
|
74
79
|
return statementNatches;
|
|
75
80
|
}
|
|
76
81
|
|
|
77
|
-
matchMetastatement(metastatementNode,
|
|
82
|
+
matchMetastatement(metastatementNode, metastatementMetaproofContext) {
|
|
78
83
|
let metastatementNatches;
|
|
79
84
|
|
|
80
85
|
const premisesLength = this.premises.length;
|
|
81
86
|
|
|
82
87
|
if (premisesLength === 0) {
|
|
83
88
|
const substitutions = [],
|
|
84
|
-
conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions);
|
|
89
|
+
conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, metastatementMetaproofContext);
|
|
85
90
|
|
|
86
91
|
metastatementNatches = conclusionMatches; ///
|
|
87
92
|
} else {
|
|
88
|
-
const metaproofSteps =
|
|
93
|
+
const metaproofSteps = metastatementMetaproofContext.getMetaproofSteps();
|
|
89
94
|
|
|
90
95
|
metastatementNatches = someSubArray(metaproofSteps, premisesLength, (metaproofSteps) => {
|
|
91
96
|
let premisesMatchConclusion = false;
|
|
92
97
|
|
|
93
98
|
const substitutions = [],
|
|
94
|
-
premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions);
|
|
99
|
+
premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions, this.fileContext, metastatementMetaproofContext);
|
|
95
100
|
|
|
96
101
|
if (premisesMatch) {
|
|
97
|
-
const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions);
|
|
102
|
+
const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, metastatementMetaproofContext);
|
|
98
103
|
|
|
99
104
|
premisesMatchConclusion = conclusionMatches; ///
|
|
100
105
|
}
|
|
@@ -134,7 +139,7 @@ export default class Rule {
|
|
|
134
139
|
return json;
|
|
135
140
|
}
|
|
136
141
|
|
|
137
|
-
static
|
|
142
|
+
static fromJSONAndFileContext(json, fileContext) {
|
|
138
143
|
let rule;
|
|
139
144
|
|
|
140
145
|
let { labels } = json;
|
|
@@ -143,7 +148,7 @@ export default class Rule {
|
|
|
143
148
|
|
|
144
149
|
labels = labelsJSON.map((labelJSON) => {
|
|
145
150
|
const json = labelJSON, ///
|
|
146
|
-
label = Label.
|
|
151
|
+
label = Label.fromJSONAndFileContext(json, fileContext);
|
|
147
152
|
|
|
148
153
|
return label;
|
|
149
154
|
});
|
|
@@ -154,7 +159,7 @@ export default class Rule {
|
|
|
154
159
|
|
|
155
160
|
premises = premisesJSON.map((premiseJSON) => {
|
|
156
161
|
const json = premiseJSON, ///
|
|
157
|
-
premise = Premise.
|
|
162
|
+
premise = Premise.fromJSONAndFileContext(json, fileContext);
|
|
158
163
|
|
|
159
164
|
return premise;
|
|
160
165
|
});
|
|
@@ -165,27 +170,27 @@ export default class Rule {
|
|
|
165
170
|
|
|
166
171
|
json = conclusionJSON; ///
|
|
167
172
|
|
|
168
|
-
conclusion = Conclusion.
|
|
173
|
+
conclusion = Conclusion.fromJSONAndFileContext(json, fileContext);
|
|
169
174
|
|
|
170
|
-
rule = new Rule(labels, premises, conclusion);
|
|
175
|
+
rule = new Rule(labels, premises, conclusion, fileContext);
|
|
171
176
|
|
|
172
177
|
return rule;
|
|
173
178
|
}
|
|
174
179
|
|
|
175
|
-
static
|
|
176
|
-
const rule = new Rule(labels, premises, conclusion);
|
|
180
|
+
static fromLabelsPremisesConclusionAndFileContext(labels, premises, conclusion, fileContext) {
|
|
181
|
+
const rule = new Rule(labels, premises, conclusion, fileContext);
|
|
177
182
|
|
|
178
183
|
return rule;
|
|
179
184
|
}
|
|
180
185
|
}
|
|
181
186
|
|
|
182
|
-
function matchPremise(premise, proofSteps, substitutions) {
|
|
187
|
+
function matchPremise(premise, proofSteps, substitutions, fileContext, statementProofContext) {
|
|
183
188
|
const proofStep = prune(proofSteps, (proofStep) => {
|
|
184
189
|
const subproofNode = proofStep.getSubproofNode(),
|
|
185
190
|
statementNode = proofStep.getStatementNode()
|
|
186
191
|
|
|
187
192
|
if (subproofNode !== null) {
|
|
188
|
-
const subProofNodeMatches = premise.matchSubproofNode(subproofNode, substitutions);
|
|
193
|
+
const subProofNodeMatches = premise.matchSubproofNode(subproofNode, substitutions, fileContext, statementProofContext);
|
|
189
194
|
|
|
190
195
|
if (!subProofNodeMatches) { ///
|
|
191
196
|
return true;
|
|
@@ -193,7 +198,7 @@ function matchPremise(premise, proofSteps, substitutions) {
|
|
|
193
198
|
}
|
|
194
199
|
|
|
195
200
|
if (statementNode !== null) {
|
|
196
|
-
const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions);
|
|
201
|
+
const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions, fileContext, statementProofContext);
|
|
197
202
|
|
|
198
203
|
if (!statementNodeMatches) { ///
|
|
199
204
|
return true;
|
|
@@ -206,9 +211,9 @@ function matchPremise(premise, proofSteps, substitutions) {
|
|
|
206
211
|
return premiseMatches;
|
|
207
212
|
}
|
|
208
213
|
|
|
209
|
-
function matchPremises(premise, proofSteps, substitutions) {
|
|
214
|
+
function matchPremises(premise, proofSteps, substitutions, fileContext, statementProofContext) {
|
|
210
215
|
const premisesMatch = premise.every((premise) => {
|
|
211
|
-
const premiseMatches = matchPremise(premise, proofSteps, substitutions);
|
|
216
|
+
const premiseMatches = matchPremise(premise, proofSteps, substitutions, fileContext, statementProofContext);
|
|
212
217
|
|
|
213
218
|
if (premiseMatches) {
|
|
214
219
|
return true;
|
|
@@ -218,20 +223,20 @@ function matchPremises(premise, proofSteps, substitutions) {
|
|
|
218
223
|
return premisesMatch;
|
|
219
224
|
}
|
|
220
225
|
|
|
221
|
-
function matchConclusion(conclusion, statementNode, substitutions) {
|
|
222
|
-
const statementNodeMatches = conclusion.matchStatementNode(statementNode, substitutions),
|
|
226
|
+
function matchConclusion(conclusion, statementNode, substitutions, fileContext, statementProofContext) {
|
|
227
|
+
const statementNodeMatches = conclusion.matchStatementNode(statementNode, substitutions, fileContext, statementProofContext),
|
|
223
228
|
conclusionMatches = statementNodeMatches; ///
|
|
224
229
|
|
|
225
230
|
return conclusionMatches;
|
|
226
231
|
}
|
|
227
232
|
|
|
228
|
-
function metaMatchPremise(premise, metaproofSteps, substitutions) {
|
|
233
|
+
function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, metastatementMetaproofContext) {
|
|
229
234
|
const metaproofStep = prune(metaproofSteps, (metaproofStep) => {
|
|
230
235
|
const ruleSubproofNode = metaproofStep.getRuleSubproofNode(),
|
|
231
236
|
metastatementNode = metaproofStep.getMetastatementNode()
|
|
232
237
|
|
|
233
238
|
if (ruleSubproofNode !== null) {
|
|
234
|
-
const ruleSubProofNodeMatches = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions);
|
|
239
|
+
const ruleSubProofNodeMatches = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, metastatementMetaproofContext);
|
|
235
240
|
|
|
236
241
|
if (!ruleSubProofNodeMatches) { ///
|
|
237
242
|
return true;
|
|
@@ -239,7 +244,7 @@ function metaMatchPremise(premise, metaproofSteps, substitutions) {
|
|
|
239
244
|
}
|
|
240
245
|
|
|
241
246
|
if (metastatementNode !== null) {
|
|
242
|
-
const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode, substitutions);
|
|
247
|
+
const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementMetaproofContext);
|
|
243
248
|
|
|
244
249
|
if (!metastatementNodeMatches) { ///
|
|
245
250
|
return true;
|
|
@@ -252,9 +257,9 @@ function metaMatchPremise(premise, metaproofSteps, substitutions) {
|
|
|
252
257
|
return premiseMatches;
|
|
253
258
|
}
|
|
254
259
|
|
|
255
|
-
function metaMatchPremises(premise, metaproofSteps, substitutions) {
|
|
260
|
+
function metaMatchPremises(premise, metaproofSteps, substitutions, fileContext, metastatementMetaproofContext) {
|
|
256
261
|
const premisesMatch = premise.every((premise) => {
|
|
257
|
-
const premiseMatches = metaMatchPremise(premise, metaproofSteps, substitutions);
|
|
262
|
+
const premiseMatches = metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, metastatementMetaproofContext);
|
|
258
263
|
|
|
259
264
|
if (premiseMatches) {
|
|
260
265
|
return true;
|
|
@@ -264,8 +269,8 @@ function metaMatchPremises(premise, metaproofSteps, substitutions) {
|
|
|
264
269
|
return premisesMatch;
|
|
265
270
|
}
|
|
266
271
|
|
|
267
|
-
function metaMatchConclusion(conclusion, metastatementNode, substitutions) {
|
|
268
|
-
const metastatementNodeMatches = conclusion.matchMetastatementNode(metastatementNode, substitutions),
|
|
272
|
+
function metaMatchConclusion(conclusion, metastatementNode, substitutions, fileContext, metastatementMetaproofContext) {
|
|
273
|
+
const metastatementNodeMatches = conclusion.matchMetastatementNode(metastatementNode, substitutions, fileContext, metastatementMetaproofContext),
|
|
269
274
|
conclusionMatches = metastatementNodeMatches; ///
|
|
270
275
|
|
|
271
276
|
return conclusionMatches;
|
package/src/ruleNames.js
CHANGED
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
export const TERM_RULE_NAME = "term";
|
|
4
4
|
export const TYPE_RULE_NAME = "type";
|
|
5
5
|
export const LABEL_RULE_NAME = "label";
|
|
6
|
+
export const VARIABLE_RULE_NAME = "variable";
|
|
6
7
|
export const ARGUMENT_RULE_NAME = "argument";
|
|
7
8
|
export const SUBPROOF_RULE_NAME = "subproof";
|
|
8
9
|
export const STATEMENT_RULE_NAME = "statement";
|
|
10
|
+
export const META_TYPE_RULE_NAME = "meta-type";
|
|
11
|
+
export const METAVARIABLE_RULE_NAME = "metavariable";
|
|
9
12
|
export const METASTATEMENT_RULE_NAME = "metastatement";
|
|
10
13
|
export const RULE_SUBPROOF_RULE_NAME = "ruleSubproof";
|
|
11
14
|
export const META_ARGUMENT_RULE_NAME = "metaArgument";
|
|
12
15
|
export const QUALIFIED_STATEMENT_RULE_NAME = "qualifiedStatement";
|
|
13
16
|
export const UNQUALIFIED_STATEMENT_RULE_NAME = "unqualifiedStatement";
|
|
14
|
-
export const
|
|
17
|
+
export const CONSTRUCTOR_DECLARATION_RULE_NAME = "constructorDeclaration";
|
|
15
18
|
export const QUALIFIED_METASTATEMENT_RULE_NAME = "qualifiedMetastatement";
|
|
16
19
|
export const UNQUALIFIED_METASTATEMENT_RULE_NAME = "unqualifiedMetastatement";
|
package/src/supposition.js
CHANGED
|
@@ -19,7 +19,7 @@ export default class Supposition {
|
|
|
19
19
|
return this.statementNode;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
matchSubproofNode(subproofNode, substitutions) {
|
|
22
|
+
matchSubproofNode(subproofNode, substitutions, proofContext, statementProofContext) {
|
|
23
23
|
let subproofNodeMatches = false;
|
|
24
24
|
|
|
25
25
|
const subproofAssertionNode = subproofAssertionNodeQuery(this.statementNode);
|
|
@@ -40,7 +40,9 @@ export default class Supposition {
|
|
|
40
40
|
const subproofStatementNode = subproofStatementNodes[index],
|
|
41
41
|
nonTerminalNodeA = subproofAssertionStatementNode, ///
|
|
42
42
|
nonTerminalNodeB = subproofStatementNode, ///
|
|
43
|
-
|
|
43
|
+
proofContextA = proofContext, ///
|
|
44
|
+
proofContextB = statementProofContext, ///
|
|
45
|
+
nonTerminalNodeVerified = suppositionTermForVariableVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, proofContextA, proofContextB);
|
|
44
46
|
|
|
45
47
|
if (nonTerminalNodeVerified) {
|
|
46
48
|
return true;
|
|
@@ -52,10 +54,12 @@ export default class Supposition {
|
|
|
52
54
|
return subproofNodeMatches;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
matchStatementNode(statementNode, substitutions) {
|
|
57
|
+
matchStatementNode(statementNode, substitutions, proofContext, statementProofContext) {
|
|
56
58
|
const nonTerminalNodeA = this.statementNode, ///
|
|
57
59
|
nonTerminalNodeB = statementNode, ///
|
|
58
|
-
|
|
60
|
+
proofContextA = proofContext, ///
|
|
61
|
+
proofContextB = statementProofContext, ///
|
|
62
|
+
nonTerminalNodeVerified = suppositionTermForVariableVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, proofContextA, proofContextB),
|
|
59
63
|
statementNodeMatches = nonTerminalNodeVerified; ///
|
|
60
64
|
|
|
61
65
|
return statementNodeMatches;
|
|
@@ -71,11 +75,11 @@ export default class Supposition {
|
|
|
71
75
|
return json;
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
static
|
|
78
|
+
static fromJSONAndFileContext(json, fileContext) {
|
|
75
79
|
const { statement } = json,
|
|
76
80
|
statementString = statement, ///
|
|
77
|
-
lexer =
|
|
78
|
-
parser =
|
|
81
|
+
lexer = fileContext.getLexer(),
|
|
82
|
+
parser = fileContext.getParser(),
|
|
79
83
|
statementNode = statementNodeFromStatementString(statementString, lexer, parser),
|
|
80
84
|
supposition = new Supposition(statementNode);
|
|
81
85
|
|
package/src/theorem.js
CHANGED
|
@@ -7,7 +7,7 @@ import { THEOREM_KIND } from "./kinds";
|
|
|
7
7
|
export default class Theorem extends AxiomLemmaTheoremConjecture {
|
|
8
8
|
static kind = THEOREM_KIND;
|
|
9
9
|
|
|
10
|
-
static
|
|
10
|
+
static fromJSONAndFileContext(json, fileContext) { return AxiomLemmaTheoremConjecture.fromJSONAndFileContext(Theorem, json, fileContext); }
|
|
11
11
|
|
|
12
|
-
static
|
|
12
|
+
static fromLabelsSuppositionsConsequenceAndProofContext(labels, suppositions, consequence, proofContext) { return AxiomLemmaTheoremConjecture.fromLabelsSuppositionsConsequenceAndProofContext(Theorem, labels, suppositions, consequence, proofContext); }
|
|
13
13
|
}
|
package/src/type.js
CHANGED
|
@@ -133,14 +133,14 @@ export default class Type {
|
|
|
133
133
|
return json;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
static
|
|
136
|
+
static fromJSONAndFileContext(json, fileContext) {
|
|
137
137
|
let type;
|
|
138
138
|
|
|
139
139
|
let { superType } = json;
|
|
140
140
|
|
|
141
141
|
const superTypeJSON = superType; ///
|
|
142
142
|
|
|
143
|
-
superType =
|
|
143
|
+
superType = superTypeFromSuperTypeJSONAndFileContext(superTypeJSON, fileContext);
|
|
144
144
|
|
|
145
145
|
const { name } = json;
|
|
146
146
|
|
|
@@ -190,7 +190,7 @@ class ObjectType extends Type {
|
|
|
190
190
|
|
|
191
191
|
export const objectType = ObjectType.fromNothing();
|
|
192
192
|
|
|
193
|
-
function
|
|
193
|
+
function superTypeFromSuperTypeJSONAndFileContext(superTypeJSON, fileContext) {
|
|
194
194
|
let superType;
|
|
195
195
|
|
|
196
196
|
const json = superTypeJSON, ///
|
|
@@ -200,11 +200,11 @@ function superTypeFromSuperTypeJSON(superTypeJSON, context) {
|
|
|
200
200
|
superType = objectType; ///
|
|
201
201
|
} else {
|
|
202
202
|
const typeName = name, ///
|
|
203
|
-
type =
|
|
203
|
+
type = fileContext.findTypeByTypeName(typeName);
|
|
204
204
|
|
|
205
205
|
superType = (type !== null) ?
|
|
206
206
|
type : ///
|
|
207
|
-
Type.
|
|
207
|
+
Type.fromJSONAndFileContext(json, fileContext); ///
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
return superType;
|
package/src/utilities/node.js
CHANGED
|
@@ -4,7 +4,13 @@ import { rewriteNodes } from "occam-grammar-utilities";
|
|
|
4
4
|
import { lexersUtilities, parsersUtilities } from "occam-custom-grammars";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
|
-
import {
|
|
7
|
+
import { TYPE_RULE_NAME,
|
|
8
|
+
LABEL_RULE_NAME,
|
|
9
|
+
VARIABLE_RULE_NAME,
|
|
10
|
+
METAVARIABLE_RULE_NAME,
|
|
11
|
+
UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
12
|
+
CONSTRUCTOR_DECLARATION_RULE_NAME,
|
|
13
|
+
UNQUALIFIED_METASTATEMENT_RULE_NAME } from "../ruleNames";
|
|
8
14
|
|
|
9
15
|
import { combinedCustomGrammarFromNothing } from "./customGrammar";
|
|
10
16
|
|
|
@@ -16,11 +22,13 @@ const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
|
|
|
16
22
|
florenceParser = florenceParserFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
17
23
|
|
|
18
24
|
const termNodeQuery = nodeQuery("/constructorDeclaration/term!"),
|
|
25
|
+
typeNodeQuery = nodeQuery("/variableDeclaration/type!"),
|
|
26
|
+
variableNodeQuery = nodeQuery("/variableDeclaration/variable!"),
|
|
19
27
|
statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
|
|
20
28
|
metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatement!");
|
|
21
29
|
|
|
22
30
|
export function termNodeFromTermString(termString, lexer, parser) {
|
|
23
|
-
const ruleName =
|
|
31
|
+
const ruleName = CONSTRUCTOR_DECLARATION_RULE_NAME,
|
|
24
32
|
content = `Constructor ${termString}
|
|
25
33
|
`,
|
|
26
34
|
node = nodeFromContentAndRuleName(content, ruleName, lexer, parser),
|
|
@@ -39,6 +47,28 @@ export function labelNodeFromLabelString(labelString, lexer, parser) {
|
|
|
39
47
|
return labelNode;
|
|
40
48
|
}
|
|
41
49
|
|
|
50
|
+
export function typeNodeFromVariableString(variableString, lexer, parser) {
|
|
51
|
+
const ruleName = TYPE_RULE_NAME,
|
|
52
|
+
content = `Variable ${variableString}
|
|
53
|
+
`,
|
|
54
|
+
node = nodeFromContentAndRuleName(content, ruleName, lexer, parser),
|
|
55
|
+
typeDeclarationNode = node, ///
|
|
56
|
+
typeNode = typeNodeQuery(typeDeclarationNode);
|
|
57
|
+
|
|
58
|
+
return typeNode;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function variableNodeFromVariableString(variableString, lexer, parser) {
|
|
62
|
+
const ruleName = VARIABLE_RULE_NAME,
|
|
63
|
+
content = `Variable ${variableString}
|
|
64
|
+
`,
|
|
65
|
+
node = nodeFromContentAndRuleName(content, ruleName, lexer, parser),
|
|
66
|
+
variableDeclarationNode = node, ///
|
|
67
|
+
variableNode = variableNodeQuery(variableDeclarationNode);
|
|
68
|
+
|
|
69
|
+
return variableNode;
|
|
70
|
+
}
|
|
71
|
+
|
|
42
72
|
export function statementNodeFromStatementString(statementString, lexer, parser) {
|
|
43
73
|
const ruleName = UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
44
74
|
content = `${statementString}
|
package/src/utilities/query.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Query } from "occam-dom";
|
|
4
4
|
|
|
5
5
|
const typeTerminalNodeQuery = nodeQuery("/type/@type"),
|
|
6
|
+
metaTypeTerminalNodeQuery = nodeQuery("/metaType/@meta-type"),
|
|
6
7
|
labelNameTerminalNodeQuery = nodeQuery("/label/@name"),
|
|
7
8
|
variableNameTerminalNodeQuery = nodeQuery("/variable/@name"),
|
|
8
9
|
referenceNameTerminalNodeQuery = nodeQuery("/reference/@name"),
|
|
@@ -57,6 +58,19 @@ export function labelNameFromLabelNode(labelNode) {
|
|
|
57
58
|
return labelName;
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
export function metaTypeNameFromMetaTypeNode(metaTypeNode) {
|
|
62
|
+
let metaTypeName = null;
|
|
63
|
+
|
|
64
|
+
if (metaTypeNode !== null) {
|
|
65
|
+
const metaTypeTerminalNode = metaTypeTerminalNodeQuery(metaTypeNode),
|
|
66
|
+
metaTypeTerminalNodeContent = metaTypeTerminalNode.getContent();
|
|
67
|
+
|
|
68
|
+
metaTypeName = metaTypeTerminalNodeContent; ///
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return metaTypeName;
|
|
72
|
+
}
|
|
73
|
+
|
|
60
74
|
export function variableNameFromVariableNode(variableNode) {
|
|
61
75
|
const variableNameTerminalNode = variableNameTerminalNodeQuery(variableNode),
|
|
62
76
|
variableNameTerminalNodeContent = variableNameTerminalNode.getContent(),
|
package/src/variable.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export default class Variable {
|
|
4
|
-
constructor(
|
|
5
|
-
this.type = type;
|
|
4
|
+
constructor(name, type) {
|
|
6
5
|
this.name = name;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
getType() {
|
|
10
|
-
return this.type;
|
|
6
|
+
this.type = type;
|
|
11
7
|
}
|
|
12
8
|
|
|
13
9
|
getName() {
|
|
14
10
|
return this.name;
|
|
15
11
|
}
|
|
16
12
|
|
|
13
|
+
getType() {
|
|
14
|
+
return this.type;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
17
|
matchName(name) {
|
|
18
18
|
const matchesName = (this.name === name);
|
|
19
19
|
|
|
@@ -27,8 +27,12 @@ export default class Variable {
|
|
|
27
27
|
return string;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
static
|
|
31
|
-
|
|
30
|
+
static fromJSONAndFileContext(json, fileContext) {
|
|
31
|
+
debugger
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static fromNameAndType(name, type) {
|
|
35
|
+
const variable = new Variable(name, type);
|
|
32
36
|
|
|
33
37
|
return variable;
|
|
34
38
|
}
|
|
@@ -10,7 +10,7 @@ import { metavariableNameFromMetavariableNode } from "../utilities/query";
|
|
|
10
10
|
const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!');
|
|
11
11
|
|
|
12
12
|
export default class MetastatementForMetavariableVerifier extends Verifier {
|
|
13
|
-
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
|
|
13
|
+
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, metaproofContextB) {
|
|
14
14
|
let nonTerminalNodeVerified = false;
|
|
15
15
|
|
|
16
16
|
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
@@ -23,28 +23,28 @@ export default class MetastatementForMetavariableVerifier extends Verifier {
|
|
|
23
23
|
if (nonTerminalNodeARuleNameMetastatementRuleName && nonTerminalNodeBRuleNameMetastatementRuleName) {
|
|
24
24
|
const metastatementNodeA = nonTerminalNodeA, ///
|
|
25
25
|
metastatementNodeB = nonTerminalNodeB, ///
|
|
26
|
-
metastatementNodeVerified = this.verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions);
|
|
26
|
+
metastatementNodeVerified = this.verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions, fileContextA, metaproofContextB);
|
|
27
27
|
|
|
28
28
|
if (metastatementNodeVerified) {
|
|
29
29
|
nonTerminalNodeVerified = true; ///
|
|
30
30
|
} else {
|
|
31
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
31
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, metaproofContextB);
|
|
32
32
|
}
|
|
33
33
|
} else {
|
|
34
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
34
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, metaproofContextB);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
return nonTerminalNodeVerified;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions) {
|
|
41
|
+
verifyMetastatementNode(metastatementNodeA, metastatementNodeB, substitutions, fileContextA, metaproofContextB) {
|
|
42
42
|
let metastatementNodeVerified = false;
|
|
43
43
|
|
|
44
44
|
const metavariableNodeA = metavariableNodeQuery(metastatementNodeA);
|
|
45
45
|
|
|
46
46
|
if (metavariableNodeA !== null) {
|
|
47
|
-
const metaVariableNodeVerified = this.verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions);
|
|
47
|
+
const metaVariableNodeVerified = this.verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions, fileContextA, metaproofContextB);
|
|
48
48
|
|
|
49
49
|
metastatementNodeVerified = metaVariableNodeVerified; ///
|
|
50
50
|
}
|
|
@@ -52,7 +52,7 @@ export default class MetastatementForMetavariableVerifier extends Verifier {
|
|
|
52
52
|
return metastatementNodeVerified;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions) {
|
|
55
|
+
verifyMetavariableNode(metavariableNodeA, metastatementNodeB, substitutions, fileContextA, metaproofContextB) {
|
|
56
56
|
let metavariableNodeVerified;
|
|
57
57
|
|
|
58
58
|
const metavariableNameA = metavariableNameFromMetavariableNode(metavariableNodeA),
|
|
@@ -11,7 +11,7 @@ const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!'),
|
|
|
11
11
|
metaArgumentChildNodeNodeQuery = nodeQuery('/metaArgument/*!');
|
|
12
12
|
|
|
13
13
|
export default class StatementForMetavariableVerifier extends Verifier {
|
|
14
|
-
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
|
|
14
|
+
verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, proofContextB) {
|
|
15
15
|
let nonTerminalNodeVerified = false;
|
|
16
16
|
|
|
17
17
|
const nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(),
|
|
@@ -23,7 +23,7 @@ export default class StatementForMetavariableVerifier extends Verifier {
|
|
|
23
23
|
|
|
24
24
|
nonTerminalNodeB = metaArgumentChildNodeB; ///
|
|
25
25
|
|
|
26
|
-
nonTerminalNodeVerified = this.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
26
|
+
nonTerminalNodeVerified = this.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, proofContextB);
|
|
27
27
|
} else {
|
|
28
28
|
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
|
|
29
29
|
nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(),
|
|
@@ -33,7 +33,7 @@ export default class StatementForMetavariableVerifier extends Verifier {
|
|
|
33
33
|
if (nonTerminalNodeARuleNameMetastatementRuleName && nonTerminalNodeBRuleNameStatementRuleName) {
|
|
34
34
|
const metastatementNodeA = nonTerminalNodeA, ///
|
|
35
35
|
statementNodeB = nonTerminalNodeB, ///
|
|
36
|
-
statementNodeVerified = this.verifyStatementNode(metastatementNodeA, statementNodeB, substitutions);
|
|
36
|
+
statementNodeVerified = this.verifyStatementNode(metastatementNodeA, statementNodeB, substitutions, fileContextA, proofContextB);
|
|
37
37
|
|
|
38
38
|
if (statementNodeVerified) {
|
|
39
39
|
nonTerminalNodeVerified = true; ///
|
|
@@ -42,25 +42,25 @@ export default class StatementForMetavariableVerifier extends Verifier {
|
|
|
42
42
|
nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
|
|
43
43
|
nodesA = nonTerminalNodeAChildNodes, ///
|
|
44
44
|
nodesB = nonTerminalNodeBChildNodes, ///
|
|
45
|
-
nodesMatch = this.verifyNodes(nodesA, nodesB, substitutions);
|
|
45
|
+
nodesMatch = this.verifyNodes(nodesA, nodesB, substitutions, fileContextA, proofContextB);
|
|
46
46
|
|
|
47
47
|
nonTerminalNodeVerified = nodesMatch; ///
|
|
48
48
|
}
|
|
49
49
|
} else if (nonTerminalNodeBRuleName === nonTerminalNodeARuleName) {
|
|
50
|
-
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
50
|
+
nonTerminalNodeVerified = super.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, fileContextA, proofContextB);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
return nonTerminalNodeVerified;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
verifyStatementNode(metastatementNodeA, statementNodeB, substitutions) {
|
|
57
|
+
verifyStatementNode(metastatementNodeA, statementNodeB, substitutions, fileContextA, proofContextB) {
|
|
58
58
|
let statementNodeVerified = false;
|
|
59
59
|
|
|
60
60
|
const metavariableNodeA = metavariableNodeQuery(metastatementNodeA);
|
|
61
61
|
|
|
62
62
|
if (metavariableNodeA !== null) {
|
|
63
|
-
const metavariableNodeVerified = this.verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions);
|
|
63
|
+
const metavariableNodeVerified = this.verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions, fileContextA, proofContextB);
|
|
64
64
|
|
|
65
65
|
statementNodeVerified = metavariableNodeVerified; ///
|
|
66
66
|
}
|
|
@@ -68,7 +68,7 @@ export default class StatementForMetavariableVerifier extends Verifier {
|
|
|
68
68
|
return statementNodeVerified;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions) {
|
|
71
|
+
verifyMetavariableNode(metavariableNodeA, statementNodeB, substitutions, fileContextA, proofContextB) {
|
|
72
72
|
let metavariableNodeVerified;
|
|
73
73
|
|
|
74
74
|
const metavariableNameA = metavariableNameFromMetavariableNode(metavariableNodeA),
|