occam-verify-cli 0.0.1036 → 0.0.1038
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/assertion/subproof.js +80 -49
- package/lib/assertion/type.js +5 -5
- package/lib/context/file.js +6 -20
- package/lib/context/release.js +24 -84
- package/lib/equality.js +5 -5
- package/lib/metavariable.js +92 -6
- package/lib/mixins/statement/verify.js +3 -3
- package/lib/premise.js +25 -34
- package/lib/ruleNames.js +5 -1
- package/lib/statement.js +17 -4
- package/lib/substitution/frameForMetavariable.js +4 -4
- package/lib/substitution/statement.js +139 -0
- package/lib/substitution/statementForMetavariable.js +39 -22
- package/lib/substitution/termForVariable.js +17 -16
- package/lib/supposition.js +48 -57
- package/lib/unifier/intrinsicLevel.js +4 -4
- package/lib/unifier/metaLevel.js +22 -20
- package/lib/unifier/statementWithCombinator.js +1 -2
- package/lib/utilities/node.js +15 -1
- package/lib/utilities/tokens.js +8 -1
- package/lib/variable.js +13 -6
- package/lib/verifier/intrinsicLevel.js +2 -2
- package/lib/verifier/metaLevel.js +2 -2
- package/lib/verify/assertion/subproof.js +1 -49
- package/package.json +1 -1
- package/src/assertion/subproof.js +102 -56
- package/src/assertion/type.js +4 -4
- package/src/context/file.js +2 -48
- package/src/context/release.js +27 -65
- package/src/equality.js +4 -4
- package/src/metavariable.js +115 -6
- package/src/mixins/statement/verify.js +3 -2
- package/src/premise.js +33 -47
- package/src/ruleNames.js +1 -0
- package/src/statement.js +21 -4
- package/src/substitution/frameForMetavariable.js +3 -2
- package/src/substitution/statement.js +52 -0
- package/src/substitution/statementForMetavariable.js +50 -22
- package/src/substitution/termForVariable.js +21 -19
- package/src/supposition.js +64 -78
- package/src/unifier/intrinsicLevel.js +6 -7
- package/src/unifier/metaLevel.js +33 -26
- package/src/unifier/statementWithCombinator.js +0 -1
- package/src/utilities/node.js +16 -0
- package/src/utilities/tokens.js +7 -0
- package/src/variable.js +12 -5
- package/src/verifier/intrinsicLevel.js +3 -3
- package/src/verifier/metaLevel.js +3 -3
- package/src/verify/assertion/subproof.js +0 -63
- package/lib/unify/conclusionWithStatement.js +0 -34
- package/lib/unify/consequentWithStatement.js +0 -34
- package/lib/unify/metavariableWithStatement.js +0 -40
- package/lib/unify/metavariableWithStatementGivenSubstitution.js +0 -40
- package/lib/unify/suppositionWithProffStep.js +0 -41
- package/lib/unify/suppositionsWithProofSteps.js +0 -31
- package/lib/unify/unqualifiedStatement.js +0 -25
- package/lib/verify/file.js +0 -35
- package/lib/verify/subDerivation.js +0 -31
- package/src/unify/conclusionWithStatement.js +0 -34
- package/src/unify/consequentWithStatement.js +0 -34
- package/src/unify/metavariableWithStatement.js +0 -40
- package/src/unify/metavariableWithStatementGivenSubstitution.js +0 -41
- package/src/unify/suppositionWithProffStep.js +0 -54
- package/src/unify/suppositionsWithProofSteps.js +0 -23
- package/src/unify/unqualifiedStatement.js +0 -24
- package/src/verify/file.js +0 -29
- package/src/verify/subDerivation.js +0 -24
package/src/context/release.js
CHANGED
|
@@ -15,7 +15,7 @@ const { isFilePathNominalFilePath } = filePathUtilities,
|
|
|
15
15
|
{ nominalParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
16
16
|
|
|
17
17
|
export default class ReleaseContext {
|
|
18
|
-
constructor(log, name, json, entries, lexer, parser, verified, initialised, fileContexts, customGrammar,
|
|
18
|
+
constructor(log, name, json, entries, lexer, parser, verified, initialised, fileContexts, customGrammar, dependencyReleaseContexts) {
|
|
19
19
|
this.log = log;
|
|
20
20
|
this.name = name;
|
|
21
21
|
this.json = json;
|
|
@@ -26,7 +26,6 @@ export default class ReleaseContext {
|
|
|
26
26
|
this.initialised = initialised;
|
|
27
27
|
this.fileContexts = fileContexts;
|
|
28
28
|
this.customGrammar = customGrammar;
|
|
29
|
-
this.verifiedFileContexts = verifiedFileContexts;
|
|
30
29
|
this.dependencyReleaseContexts = dependencyReleaseContexts;
|
|
31
30
|
}
|
|
32
31
|
|
|
@@ -70,52 +69,20 @@ export default class ReleaseContext {
|
|
|
70
69
|
return this.customGrammar;
|
|
71
70
|
}
|
|
72
71
|
|
|
73
|
-
getVerifiedFileContexts() {
|
|
74
|
-
return this.verifiedFileContexts;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
72
|
getDependencyReleaseContexts() {
|
|
78
73
|
return this.dependencyReleaseContexts;
|
|
79
74
|
}
|
|
80
75
|
|
|
81
|
-
|
|
82
|
-
this.
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
setName(name) {
|
|
86
|
-
this.name = name;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
setEntries(entries) {
|
|
90
|
-
this.entries = entries;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
setLexer(lexer) {
|
|
94
|
-
this.lexer = lexer;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
setParser(parser) {
|
|
98
|
-
this.parser = parser;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
setVerified(verified) {
|
|
102
|
-
this.verified = verified;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
setInitialised(initialised) {
|
|
106
|
-
return this.initialised = initialised;
|
|
107
|
-
}
|
|
76
|
+
isReleased() {
|
|
77
|
+
const released = (this.json !== null);
|
|
108
78
|
|
|
109
|
-
|
|
110
|
-
this.fileContexts = fileContexts;
|
|
79
|
+
return released;
|
|
111
80
|
}
|
|
112
81
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
82
|
+
findFile(filePath) {
|
|
83
|
+
const file = this.entries.getFile(filePath);
|
|
116
84
|
|
|
117
|
-
|
|
118
|
-
this.dependencyReleaseContexts = dependencyReleaseContexts;
|
|
85
|
+
return file;
|
|
119
86
|
}
|
|
120
87
|
|
|
121
88
|
findFileContext(filePath) {
|
|
@@ -130,12 +97,6 @@ export default class ReleaseContext {
|
|
|
130
97
|
return fileContext;
|
|
131
98
|
}
|
|
132
99
|
|
|
133
|
-
isReleased() {
|
|
134
|
-
const released = (this.json !== null);
|
|
135
|
-
|
|
136
|
-
return released;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
100
|
getLabels(includeDependencies = true) {
|
|
140
101
|
const labels = [];
|
|
141
102
|
|
|
@@ -438,9 +399,11 @@ export default class ReleaseContext {
|
|
|
438
399
|
|
|
439
400
|
this.parser = nominalParser; ///
|
|
440
401
|
|
|
402
|
+
clear(this.fileContexts);
|
|
403
|
+
|
|
441
404
|
released ?
|
|
442
|
-
|
|
443
|
-
|
|
405
|
+
fileContextsFromJSONAndEntries(this.json, this.entries, this.fileContexts, releaseContext) :
|
|
406
|
+
fileContextsFromEntries(this.entries, this.fileContexts, releaseContext);
|
|
444
407
|
|
|
445
408
|
this.initialised = true;
|
|
446
409
|
}
|
|
@@ -448,11 +411,12 @@ export default class ReleaseContext {
|
|
|
448
411
|
verify() {
|
|
449
412
|
let verified = false;
|
|
450
413
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
const fileContextsVerified = verifyFileContexts(this.fileContexts, this.verifiedFileContexts);
|
|
414
|
+
const verifiedFileContexts = [],
|
|
415
|
+
fileContextsVerified = verifyFileContexts(this.fileContexts, verifiedFileContexts);
|
|
454
416
|
|
|
455
417
|
if (fileContextsVerified) {
|
|
418
|
+
this.fileContexts = verifiedFileContexts; ///
|
|
419
|
+
|
|
456
420
|
this.verified = true;
|
|
457
421
|
|
|
458
422
|
verified = true;
|
|
@@ -462,12 +426,12 @@ export default class ReleaseContext {
|
|
|
462
426
|
}
|
|
463
427
|
|
|
464
428
|
toJSON() {
|
|
465
|
-
const
|
|
466
|
-
const
|
|
429
|
+
const fileContextsJSON = this.fileContexts.map((fileContext) => {
|
|
430
|
+
const fileContextJSON = fileContext.toJSON();
|
|
467
431
|
|
|
468
|
-
return
|
|
432
|
+
return fileContextJSON;
|
|
469
433
|
}),
|
|
470
|
-
json =
|
|
434
|
+
json = fileContextsJSON; ///
|
|
471
435
|
|
|
472
436
|
return json;
|
|
473
437
|
}
|
|
@@ -479,20 +443,20 @@ export default class ReleaseContext {
|
|
|
479
443
|
initialised = false,
|
|
480
444
|
fileContexts = [],
|
|
481
445
|
customGrammar = customGrammarFromNameAndEntries(name, entries),
|
|
482
|
-
verifiedFileContexts = [],
|
|
483
446
|
dependencyReleaseContexts = null,
|
|
484
|
-
releaseContext = new ReleaseContext(log, name, json, entries, lexer, parser, verified, initialised, fileContexts, customGrammar,
|
|
447
|
+
releaseContext = new ReleaseContext(log, name, json, entries, lexer, parser, verified, initialised, fileContexts, customGrammar, dependencyReleaseContexts);
|
|
485
448
|
|
|
486
449
|
return releaseContext;
|
|
487
450
|
}
|
|
488
451
|
}
|
|
489
452
|
|
|
490
|
-
function
|
|
453
|
+
function fileContextsFromJSONAndEntries(json, entries, fileContexts, releaseContext) {
|
|
491
454
|
const fileContextsJSON = json; ///
|
|
492
455
|
|
|
493
456
|
fileContextsJSON.forEach((fileContextJSON) => {
|
|
494
|
-
const
|
|
495
|
-
|
|
457
|
+
const { filePath } = fileContextJSON,
|
|
458
|
+
file = entries.getFile(filePath),
|
|
459
|
+
fileContext = FileContext.fromFile(file, releaseContext);
|
|
496
460
|
|
|
497
461
|
fileContext.initialise(fileContextJSON);
|
|
498
462
|
|
|
@@ -500,19 +464,17 @@ function fileContextsFromJSONAndReleaseContext(json, fileContexts, releaseContex
|
|
|
500
464
|
});
|
|
501
465
|
}
|
|
502
466
|
|
|
503
|
-
function
|
|
467
|
+
function fileContextsFromEntries(entries, fileContexts, releaseContext) {
|
|
504
468
|
entries.forEachFile((file) => {
|
|
505
469
|
const filePath = file.getPath(),
|
|
506
470
|
filePathNominalFilePath = isFilePathNominalFilePath(filePath);
|
|
507
471
|
|
|
508
472
|
if (filePathNominalFilePath) {
|
|
509
|
-
const fileContext = FileContext.
|
|
473
|
+
const fileContext = FileContext.fromFile(file, releaseContext);
|
|
510
474
|
|
|
511
475
|
fileContexts.push(fileContext);
|
|
512
476
|
}
|
|
513
477
|
});
|
|
514
|
-
|
|
515
|
-
return fileContexts;
|
|
516
478
|
}
|
|
517
479
|
|
|
518
480
|
function verifyFileContexts(fileContexts, verifiedFileContexts) {
|
|
@@ -562,7 +524,7 @@ function verifyFileContext(fileContext) {
|
|
|
562
524
|
|
|
563
525
|
if (tokens === null) {
|
|
564
526
|
const filePath = fileContext.getFilePath(),
|
|
565
|
-
file = fileContext.
|
|
527
|
+
file = fileContext.findFile(filePath),
|
|
566
528
|
lexer = fileContext.getLexer(),
|
|
567
529
|
parser = fileContext.getParser(),
|
|
568
530
|
content = file.getContent(),
|
package/src/equality.js
CHANGED
|
@@ -121,14 +121,14 @@ export default class Equality {
|
|
|
121
121
|
|
|
122
122
|
const equalityString = this.string; ///
|
|
123
123
|
|
|
124
|
-
localContext.trace(`Verifying the
|
|
124
|
+
localContext.trace(`Verifying the '${equalityString}' stated equality...`);
|
|
125
125
|
|
|
126
126
|
const termsVerified = this.verifyTerms(localContext);
|
|
127
127
|
|
|
128
128
|
verifiedWhenStated = termsVerified; ///
|
|
129
129
|
|
|
130
130
|
if (verifiedWhenStated) {
|
|
131
|
-
localContext.debug(`...verified the
|
|
131
|
+
localContext.debug(`...verified the '${equalityString}' stated equality.`);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
return verifiedWhenStated;
|
|
@@ -139,7 +139,7 @@ export default class Equality {
|
|
|
139
139
|
|
|
140
140
|
const equalityString = this.string; ///
|
|
141
141
|
|
|
142
|
-
localContext.trace(`Verifying the
|
|
142
|
+
localContext.trace(`Verifying the '${equalityString}' derived equality...`);
|
|
143
143
|
|
|
144
144
|
const termsVerified = this.verifyTerms(localContext);
|
|
145
145
|
|
|
@@ -150,7 +150,7 @@ export default class Equality {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
if (verifiedWhenDerived) {
|
|
153
|
-
localContext.debug(`...verified the
|
|
153
|
+
localContext.debug(`...verified the '${equalityString}' derived equality.`);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
return verifiedWhenDerived;
|
package/src/metavariable.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import shim from "./shim";
|
|
4
4
|
import Argument from "./argument";
|
|
5
5
|
import LocalContext from "./context/local";
|
|
6
|
+
import StatementForMetavariableSubstitution from "./substitution/statementForMetavariable";
|
|
6
7
|
|
|
7
8
|
import { nodeQuery } from "./utilities/query";
|
|
8
9
|
import { metavariableNameFromMetavariableNode } from "./utilities/name";
|
|
@@ -10,16 +11,22 @@ import { metavariableNodeFromMetavariableString } from "./utilities/node";
|
|
|
10
11
|
|
|
11
12
|
const argumentNodeQuery = nodeQuery("/metavariable/argument"),
|
|
12
13
|
metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType"),
|
|
13
|
-
metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable")
|
|
14
|
+
metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable"),
|
|
15
|
+
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable");
|
|
14
16
|
|
|
15
17
|
export default class Metavariable {
|
|
16
|
-
constructor(string, node, name, metaType) {
|
|
18
|
+
constructor(fileContext, string, node, name, metaType) {
|
|
19
|
+
this.fileContext = fileContext;
|
|
17
20
|
this.string = string;
|
|
18
21
|
this.node = node;
|
|
19
22
|
this.name = name;
|
|
20
23
|
this.metaType = metaType;
|
|
21
24
|
}
|
|
22
25
|
|
|
26
|
+
getFileContext() {
|
|
27
|
+
return this.fileContext;
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
getString() {
|
|
24
31
|
return this.string;
|
|
25
32
|
}
|
|
@@ -105,6 +112,94 @@ export default class Metavariable {
|
|
|
105
112
|
return verifiedAtTopLevel;
|
|
106
113
|
}
|
|
107
114
|
|
|
115
|
+
unifyStatement(statement, substitutions, localContext) {
|
|
116
|
+
let statementUnified = false;
|
|
117
|
+
|
|
118
|
+
const statementString = statement.getString(),
|
|
119
|
+
metavariableString = this.string;
|
|
120
|
+
|
|
121
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable...`);
|
|
122
|
+
|
|
123
|
+
const statementNode = statement.getNode(),
|
|
124
|
+
metavariableNode = this.node, ///
|
|
125
|
+
simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableNode(metavariableNode),
|
|
126
|
+
substitution = simpleSubstitution; ///
|
|
127
|
+
|
|
128
|
+
if (substitution !== null) {
|
|
129
|
+
const statementNodeMatches = substitution.matchStatementNode(statementNode);
|
|
130
|
+
|
|
131
|
+
if (statementNodeMatches) {
|
|
132
|
+
statementUnified = true;
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
const metavariable = this, ///
|
|
136
|
+
statementMetavariable = statementMetavariableFromStatementNode(statementNode, localContext);
|
|
137
|
+
|
|
138
|
+
if (metavariable === statementMetavariable) {
|
|
139
|
+
statementUnified = true;
|
|
140
|
+
} else {
|
|
141
|
+
const statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable, localContext),
|
|
142
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
143
|
+
|
|
144
|
+
substitutions.addSubstitution(substitution, localContext);
|
|
145
|
+
|
|
146
|
+
statementUnified = true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (statementUnified) {
|
|
151
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable.`);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return statementUnified;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
unifyStatementGivenSubstitution(statement, substitution, substitutions, localContext) {
|
|
158
|
+
let statementUnifiedGivenSubstitution = false;
|
|
159
|
+
|
|
160
|
+
const statementString = statement.getString(),
|
|
161
|
+
substitutionString = substitution.getString(),
|
|
162
|
+
metavariableString = this.string;
|
|
163
|
+
|
|
164
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable givne the '${substitutionString}' substitution...`);
|
|
165
|
+
|
|
166
|
+
// let metavariableUnifiedWithStatementGivenSubstitution = false;
|
|
167
|
+
//
|
|
168
|
+
// const metavariableNode = metavariable.getNode(),
|
|
169
|
+
// substitutionNode = substitution.getNode(),
|
|
170
|
+
// complexSubstitution = substitutions.findComplexSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode);
|
|
171
|
+
//
|
|
172
|
+
// if (complexSubstitution !== null) {
|
|
173
|
+
// const statementNode = statement.getNode(),
|
|
174
|
+
// statementNodeMatches = complexSubstitution.matchStatementNode(statementNode);
|
|
175
|
+
//
|
|
176
|
+
// if (statementNodeMatches) {
|
|
177
|
+
// metavariableUnifiedWithStatementGivenSubstitution = true;
|
|
178
|
+
// }
|
|
179
|
+
// } else {
|
|
180
|
+
// const metavariableNameA = metavariableNameFromMetavariableNode(metavariableNode),
|
|
181
|
+
// metavariableA = localContextA.findMetavariableByMetavariableName(metavariableNameA),
|
|
182
|
+
// metavariableB = metavariableFromStatementNode(statement, localContextB);
|
|
183
|
+
//
|
|
184
|
+
// if (metavariableA === metavariableB) {
|
|
185
|
+
// metavariableUnifiedWithStatementGivenSubstitution = false; ///
|
|
186
|
+
// } else {
|
|
187
|
+
// const statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContextA, localContextB),
|
|
188
|
+
// substitution = statementForMetavariableSubstitution; ///
|
|
189
|
+
//
|
|
190
|
+
// substitutions.addSubstitution(substitution, localContextA, localContextB);
|
|
191
|
+
//
|
|
192
|
+
// metavariableUnifiedWithStatementGivenSubstitution = true;
|
|
193
|
+
// }
|
|
194
|
+
// }
|
|
195
|
+
|
|
196
|
+
if (statementUnifiedGivenSubstitution) {
|
|
197
|
+
localContext.trace(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable givne the '${substitutionString}' substitution.`);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return statementUnifiedGivenSubstitution;
|
|
201
|
+
}
|
|
202
|
+
|
|
108
203
|
toJSON() {
|
|
109
204
|
const metaTypeJSON = (this.metaType !== null) ?
|
|
110
205
|
this.metaType.toJSON() :
|
|
@@ -129,7 +224,7 @@ export default class Metavariable {
|
|
|
129
224
|
node = metavariableNode, ///
|
|
130
225
|
name = metavariableName, ///
|
|
131
226
|
metaType = metaTypeFromJSON(json, fileContext),
|
|
132
|
-
metavariable = new Metavariable(string, node, name, metaType);
|
|
227
|
+
metavariable = new Metavariable(fileContext, string, node, name, metaType);
|
|
133
228
|
|
|
134
229
|
return metavariable;
|
|
135
230
|
}
|
|
@@ -140,7 +235,7 @@ export default class Metavariable {
|
|
|
140
235
|
name = metavariableName, ///
|
|
141
236
|
string = fileContext.nodeAsString(node),
|
|
142
237
|
metaType = null,
|
|
143
|
-
metavariable = new Metavariable(string, node, name, metaType);
|
|
238
|
+
metavariable = new Metavariable(fileContext, string, node, name, metaType);
|
|
144
239
|
|
|
145
240
|
return metavariable;
|
|
146
241
|
}
|
|
@@ -156,7 +251,7 @@ export default class Metavariable {
|
|
|
156
251
|
node = metavariableNode, ///
|
|
157
252
|
name = metavariableName, ///
|
|
158
253
|
metaType = MetaType.fromMetaTypeNode(metaTypeNode, localContext),
|
|
159
|
-
metavariable = new Metavariable(string, node, name, metaType);
|
|
254
|
+
metavariable = new Metavariable(fileContext, string, node, name, metaType);
|
|
160
255
|
|
|
161
256
|
return metavariable;
|
|
162
257
|
}
|
|
@@ -173,4 +268,18 @@ function metaTypeFromJSON(json, fileContext) {
|
|
|
173
268
|
}
|
|
174
269
|
|
|
175
270
|
return metaType;
|
|
176
|
-
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function statementMetavariableFromStatementNode(statementNode, localContext) {
|
|
274
|
+
let statementMetavariable = null;
|
|
275
|
+
|
|
276
|
+
const statementMetavariableNode = statementMetavariableNodeQuery(statementNode);
|
|
277
|
+
|
|
278
|
+
if (statementMetavariableNode !== null) {
|
|
279
|
+
const statementMetavariableName = metavariableNameFromMetavariableNode(statementMetavariableNode);
|
|
280
|
+
|
|
281
|
+
statementMetavariable = localContext.findMetavariableByMetavariableName(statementMetavariableName);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return statementMetavariable;
|
|
285
|
+
}
|
|
@@ -8,11 +8,11 @@ import verifyJudgement from "../../verify/judgement";
|
|
|
8
8
|
import verifyDeclaration from "../../verify/declaration";
|
|
9
9
|
import metavariableUnifier from "../../unifier/metavariable";
|
|
10
10
|
import verifyDefinedAssertion from "../../verify/assertion/defined";
|
|
11
|
-
import verifySubproofAssertion from "../../verify/assertion/subproof";
|
|
12
11
|
import verifyContainedAssertion from "../../verify/assertion/contained";
|
|
13
12
|
|
|
14
13
|
import { nodeQuery } from "../../utilities/query";
|
|
15
14
|
import { metavariableNameFromMetavariableNode } from "../../utilities/name";
|
|
15
|
+
import SubproofAssertion from "../../assertion/subproof";
|
|
16
16
|
|
|
17
17
|
const frameNodeQuery = nodeQuery("/statement/frame!"),
|
|
18
18
|
equalityNodeQuery = nodeQuery("/statement/equality!"),
|
|
@@ -198,7 +198,8 @@ function verifyAsSubproofAssertion(statement, assignments, stated, localContext)
|
|
|
198
198
|
|
|
199
199
|
localContext.trace(`Verifying the '${statementString}' statement as a subproof assertion...`);
|
|
200
200
|
|
|
201
|
-
const
|
|
201
|
+
const subproofAssertion = SubproofAssertion.fromSubproofAssertionNode(subproofAssertionNode, localContext),
|
|
202
|
+
subproofAssertionVerified = subproofAssertion.verify(assignments, stated, localContext);
|
|
202
203
|
|
|
203
204
|
verifiedAsSubproofAssertion = subproofAssertionVerified; ///
|
|
204
205
|
|
package/src/premise.js
CHANGED
|
@@ -12,9 +12,8 @@ import { assignAssignments } from "./utilities/assignments";
|
|
|
12
12
|
const unqualifiedStatementNodeQuery = nodeQuery("/premise/unqualifiedStatement");
|
|
13
13
|
|
|
14
14
|
export default class Premise {
|
|
15
|
-
constructor(fileContext,
|
|
15
|
+
constructor(fileContext, unqualifiedStatement) {
|
|
16
16
|
this.fileContext = fileContext;
|
|
17
|
-
this.subproofAssertion = subproofAssertion;
|
|
18
17
|
this.unqualifiedStatement = unqualifiedStatement;
|
|
19
18
|
}
|
|
20
19
|
|
|
@@ -22,10 +21,6 @@ export default class Premise {
|
|
|
22
21
|
return this.fileContext;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
getSubproofAssertion() {
|
|
26
|
-
return this.subproofAssertion;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
24
|
getUnqualifiedStatement() {
|
|
30
25
|
return this.unqualifiedStatement;
|
|
31
26
|
}
|
|
@@ -34,6 +29,30 @@ export default class Premise {
|
|
|
34
29
|
|
|
35
30
|
getStatement() { return this.unqualifiedStatement.getStatement(); }
|
|
36
31
|
|
|
32
|
+
unifySubproof(subproof, substitutions, localContext) {
|
|
33
|
+
let subproofUnified = false;
|
|
34
|
+
|
|
35
|
+
const premise = this, ///
|
|
36
|
+
subproofString = subproof.getString(),
|
|
37
|
+
premiseStatement = premise.getStatement(),
|
|
38
|
+
premiseStatementString = premiseStatement.getString();
|
|
39
|
+
|
|
40
|
+
localContext.trace(`Unifying the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement...`);
|
|
41
|
+
|
|
42
|
+
const statement = this.unqualifiedStatement.getStatement(),
|
|
43
|
+
subproofAssertion = SubproofAssertion.fromStatement(statement, this.fileContext);
|
|
44
|
+
|
|
45
|
+
if (subproofAssertion !== null) {
|
|
46
|
+
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, this.fileContext, localContext);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (subproofUnified) {
|
|
50
|
+
localContext.debug(`...unified the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement.`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return subproofUnified;
|
|
54
|
+
}
|
|
55
|
+
|
|
37
56
|
unifyProofStep(proofStep, substitutions, localContext) {
|
|
38
57
|
let proofStepUnified = false;
|
|
39
58
|
|
|
@@ -85,27 +104,6 @@ export default class Premise {
|
|
|
85
104
|
return statementUnified;
|
|
86
105
|
}
|
|
87
106
|
|
|
88
|
-
unifySubproof(subproof, substitutions, localContext) {
|
|
89
|
-
let subproofUnified = false;
|
|
90
|
-
|
|
91
|
-
const premise = this, ///
|
|
92
|
-
subproofString = subproof.getString(),
|
|
93
|
-
premiseStatement = premise.getStatement(),
|
|
94
|
-
premiseStatementString = premiseStatement.getString();
|
|
95
|
-
|
|
96
|
-
localContext.trace(`Unifying the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement...`);
|
|
97
|
-
|
|
98
|
-
if (this.subproofAssertion !== null) {
|
|
99
|
-
subproofUnified = this.subproofAssertion.unifySubproof(subproof, substitutions, localContext);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (subproofUnified) {
|
|
103
|
-
localContext.debug(`...unified the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement.`);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return subproofUnified;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
107
|
verify(localContext) {
|
|
110
108
|
let verified = false;
|
|
111
109
|
|
|
@@ -143,42 +141,30 @@ export default class Premise {
|
|
|
143
141
|
|
|
144
142
|
toJSON() {
|
|
145
143
|
const unqualifiedStatementJSON = this.unqualifiedStatement.toJSON(),
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
subproofAssertion = subproofAssertionJSON, ///
|
|
151
|
-
json = {
|
|
152
|
-
unqualifiedStatement,
|
|
153
|
-
subproofAssertion
|
|
154
|
-
};
|
|
144
|
+
unqualifiedStatement = unqualifiedStatementJSON, ///
|
|
145
|
+
json = {
|
|
146
|
+
unqualifiedStatement
|
|
147
|
+
};
|
|
155
148
|
|
|
156
149
|
return json;
|
|
157
150
|
}
|
|
158
151
|
|
|
159
152
|
static fromJSON(json, fileContext) {
|
|
160
|
-
let {
|
|
153
|
+
let { unqualifiedStatement } = json;
|
|
161
154
|
|
|
162
155
|
json = unqualifiedStatement; ///
|
|
163
156
|
|
|
164
157
|
unqualifiedStatement = UnqualifiedStatement.fromJSON(json, fileContext);
|
|
165
158
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
subproofAssertion = (json !== null) ?
|
|
169
|
-
SubproofAssertion.fromJSON(json, fileContext) :
|
|
170
|
-
null;
|
|
171
|
-
|
|
172
|
-
const premise = new Premise(fileContext, subproofAssertion, unqualifiedStatement);
|
|
159
|
+
const premise = new Premise(fileContext, unqualifiedStatement);
|
|
173
160
|
|
|
174
161
|
return premise;
|
|
175
162
|
}
|
|
176
163
|
|
|
177
|
-
static
|
|
164
|
+
static fromPremiseNode(suppositionNode, fileContext) {
|
|
178
165
|
const unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
|
|
179
166
|
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
|
180
|
-
|
|
181
|
-
premise = new Premise(fileContext, subproofAssertion, unqualifiedStatement);
|
|
167
|
+
premise = new Premise(fileContext, unqualifiedStatement);
|
|
182
168
|
|
|
183
169
|
return premise
|
|
184
170
|
}
|
package/src/ruleNames.js
CHANGED
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
export const VARIABLE_RULE_NAME = "variable";
|
|
4
4
|
export const METAVARIABLE_RULE_NAME = "metavariable";
|
|
5
|
+
export const SUBSTITUTION_RULE_NAME = "substitution";
|
|
5
6
|
export const UNQUALIFIED_STATEMENT_RULE_NAME = "unqualifiedStatement";
|
|
6
7
|
export const CONSTRUCTOR_DECLARATION_RULE_NAME = "constructorDeclaration";
|
package/src/statement.js
CHANGED
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
import shim from "./shim";
|
|
4
4
|
import unifyMixins from "./mixins/statement/unify";
|
|
5
5
|
import verifyMixins from "./mixins/statement/verify";
|
|
6
|
+
import StatementSubstitution from "./substitution/statement";
|
|
6
7
|
import statementAsCombinatorVerifier from "./verifier/statementAsCombinator";
|
|
7
8
|
|
|
8
9
|
import { STATEMENT_META_TYPE_NAME } from "./metaTypeNames";
|
|
9
10
|
import { statementNodeFromStatementString } from "./utilities/node";
|
|
10
11
|
|
|
11
12
|
class Statement {
|
|
12
|
-
constructor(string, node) {
|
|
13
|
+
constructor(string, node, substitution) {
|
|
13
14
|
this.string = string;
|
|
14
15
|
this.node = node;
|
|
16
|
+
this.substitution = substitution;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
getString() {
|
|
@@ -22,6 +24,10 @@ class Statement {
|
|
|
22
24
|
return this.node;
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
getSubstitution() {
|
|
28
|
+
return this.substitution;
|
|
29
|
+
}
|
|
30
|
+
|
|
25
31
|
isEqualTo(statement) {
|
|
26
32
|
const node = statement.getNode(),
|
|
27
33
|
matches = this.node.match(node),
|
|
@@ -122,8 +128,17 @@ class Statement {
|
|
|
122
128
|
lexer = fileContext.getLexer(),
|
|
123
129
|
parser = fileContext.getParser(),
|
|
124
130
|
statementNode = statementNodeFromStatementString(statementString, lexer, parser),
|
|
125
|
-
node = statementNode
|
|
126
|
-
|
|
131
|
+
node = statementNode; ///
|
|
132
|
+
|
|
133
|
+
let { substitution } = json;
|
|
134
|
+
|
|
135
|
+
json = substitution; ///
|
|
136
|
+
|
|
137
|
+
const statementSubstitution = StatementSubstitution.fromJSON(json, fileContext);
|
|
138
|
+
|
|
139
|
+
substitution = statementSubstitution; ///
|
|
140
|
+
|
|
141
|
+
const statement = new Statement(string, node, substitution);
|
|
127
142
|
|
|
128
143
|
return statement;
|
|
129
144
|
}
|
|
@@ -131,7 +146,9 @@ class Statement {
|
|
|
131
146
|
static fromStatementNode(statementNode, localContext) {
|
|
132
147
|
const node = statementNode, ///
|
|
133
148
|
string = localContext.nodeAsString(node),
|
|
134
|
-
|
|
149
|
+
statementSubstitution = StatementSubstitution.fromStatementNode(statementNode, localContext),
|
|
150
|
+
substitution = statementSubstitution, ///
|
|
151
|
+
statement = new Statement(string, node, substitution);
|
|
135
152
|
|
|
136
153
|
return statement;
|
|
137
154
|
}
|
|
@@ -69,10 +69,11 @@ export default class FrameForMetavariableSubstitution extends Substitution {
|
|
|
69
69
|
return metavariableNodeMatches;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
static
|
|
72
|
+
static fromSubstitution(substitution, localContextA, localContextB) {
|
|
73
73
|
let frameForMetavariableSubstitution = null;
|
|
74
74
|
|
|
75
|
-
const
|
|
75
|
+
const substitutionNode = substitution.getNode(),
|
|
76
|
+
substitutionFrameNode = substitutionFrameNodeQuery(substitutionNode);
|
|
76
77
|
|
|
77
78
|
if (substitutionFrameNode !== null) {
|
|
78
79
|
const substitutionMetavariableNode = substitutionMetavariableNodeQuery(substitutionNode),
|