occam-verify-cli 0.0.881 → 0.0.882
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 +4 -10
- package/lib/context/file.js +40 -41
- package/lib/context/localMeta.js +27 -2
- package/lib/declaration.js +90 -0
- package/lib/frame.js +52 -13
- package/lib/judgement.js +28 -9
- package/lib/label.js +3 -3
- package/lib/metaLemmaMetatheorem.js +4 -4
- package/lib/mixins/context.js +32 -24
- package/lib/premise.js +2 -26
- package/lib/rule.js +4 -10
- package/lib/supposition.js +1 -53
- package/lib/verify/declaration.js +34 -16
- package/lib/verify/frame.js +47 -6
- package/lib/verify/judgement.js +63 -47
- package/lib/verify/label.js +8 -8
- package/lib/verify/labels.js +4 -4
- package/lib/verify/metastatement/qualified.js +12 -8
- package/lib/verify/statement/qualified.js +6 -6
- package/package.json +2 -2
- package/src/axiomLemmaTheoremConjecture.js +3 -12
- package/src/context/file.js +32 -33
- package/src/context/localMeta.js +32 -1
- package/src/declaration.js +58 -0
- package/src/frame.js +52 -10
- package/src/judgement.js +16 -6
- package/src/label.js +2 -2
- package/src/metaLemmaMetatheorem.js +3 -3
- package/src/mixins/context.js +21 -15
- package/src/premise.js +0 -41
- package/src/rule.js +3 -12
- package/src/supposition.js +0 -45
- package/src/verify/declaration.js +47 -20
- package/src/verify/frame.js +66 -5
- package/src/verify/judgement.js +101 -50
- package/src/verify/label.js +7 -8
- package/src/verify/labels.js +4 -3
- package/src/verify/metastatement/qualified.js +14 -11
- package/src/verify/statement/qualified.js +10 -10
|
@@ -66,9 +66,9 @@ export default class AxiomLemmaTheoremConjecture {
|
|
|
66
66
|
return statementNatches;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
matchLabelMetavariableNode(
|
|
69
|
+
matchLabelMetavariableNode(metavariableNode) {
|
|
70
70
|
const labelMetavariableNodeMatches = this.labels.some((label) => {
|
|
71
|
-
const node =
|
|
71
|
+
const node = metavariableNode, ///
|
|
72
72
|
labelMatchesNode = label.matchNode(node);
|
|
73
73
|
|
|
74
74
|
if (labelMatchesNode) {
|
|
@@ -149,16 +149,7 @@ export default class AxiomLemmaTheoremConjecture {
|
|
|
149
149
|
|
|
150
150
|
function matchSupposition(supposition, proofSteps, substitutions, localContext, statementLocalContext) {
|
|
151
151
|
const proofStep = prune(proofSteps, (proofStep) => {
|
|
152
|
-
const
|
|
153
|
-
statementNode = proofStep.getStatementNode();
|
|
154
|
-
|
|
155
|
-
if (subproofNode !== null) {
|
|
156
|
-
const subProofMatches = supposition.matchSubproofNode(subproofNode, substitutions, localContext, statementLocalContext);
|
|
157
|
-
|
|
158
|
-
if (!subProofMatches) { ///
|
|
159
|
-
return true;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
152
|
+
const statementNode = proofStep.getStatementNode();
|
|
162
153
|
|
|
163
154
|
if (statementNode !== null) {
|
|
164
155
|
const statementMatches = supposition.matchStatementNode(statementNode, substitutions, localContext, statementLocalContext);
|
package/src/context/file.js
CHANGED
|
@@ -17,7 +17,6 @@ import { push } from "../utilities/array";
|
|
|
17
17
|
import { objectType } from "../type";
|
|
18
18
|
import { typeFromJSONAndFileContext } from "../type";
|
|
19
19
|
import { nodeAsString, nodesAsString } from "../utilities/string";
|
|
20
|
-
import localMeta from "./localMeta";
|
|
21
20
|
|
|
22
21
|
export default class FileContext {
|
|
23
22
|
constructor(releaseContext, filePath, tokens, node, types, rules, axioms, lemmas, theorems, variables, metaLemmas, conjectures, combinators, constructors, metatheorems, metavariables) {
|
|
@@ -361,22 +360,8 @@ export default class FileContext {
|
|
|
361
360
|
return metaType;
|
|
362
361
|
}
|
|
363
362
|
|
|
364
|
-
|
|
365
|
-
const
|
|
366
|
-
metavariables = this.getMetavariables(),
|
|
367
|
-
metavariable = metavariables.find((metavariable) => {
|
|
368
|
-
const matches = metavariable.matchNode(node);
|
|
369
|
-
|
|
370
|
-
if (matches) {
|
|
371
|
-
return true;
|
|
372
|
-
}
|
|
373
|
-
}) || null;
|
|
374
|
-
|
|
375
|
-
return metavariable;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
findLabelByLabelMetavariableNode(labelMetavariableNode) {
|
|
379
|
-
const name = labelMetavariableNode, ///
|
|
363
|
+
findLabelByMetavariableNode(metavariableNode) {
|
|
364
|
+
const name = metavariableNode, ///
|
|
380
365
|
labels = this.getLabels(),
|
|
381
366
|
label = labels.find((label) => {
|
|
382
367
|
const matches = label.matchNode(name);
|
|
@@ -389,10 +374,10 @@ export default class FileContext {
|
|
|
389
374
|
return label;
|
|
390
375
|
}
|
|
391
376
|
|
|
392
|
-
|
|
377
|
+
findRuleByMetavariableNode(metavariableNode) {
|
|
393
378
|
const rules = this.getRules(),
|
|
394
379
|
rule = rules.find((rule) => {
|
|
395
|
-
const ruleMatchesLabelMetavariableNode = rule.matchLabelMetavariableNode(
|
|
380
|
+
const ruleMatchesLabelMetavariableNode = rule.matchLabelMetavariableNode(metavariableNode);
|
|
396
381
|
|
|
397
382
|
if (ruleMatchesLabelMetavariableNode) {
|
|
398
383
|
return true;
|
|
@@ -402,10 +387,10 @@ export default class FileContext {
|
|
|
402
387
|
return rule;
|
|
403
388
|
}
|
|
404
389
|
|
|
405
|
-
|
|
390
|
+
findAxiomByMetavariableNode(metavariableNode) {
|
|
406
391
|
const axioms = this.getAxioms(),
|
|
407
392
|
axiom = axioms.find((axiom) => {
|
|
408
|
-
const axiomMatchesLabelMetavariableNode = axiom.matchLabelMetavariableNode(
|
|
393
|
+
const axiomMatchesLabelMetavariableNode = axiom.matchLabelMetavariableNode(metavariableNode);
|
|
409
394
|
|
|
410
395
|
if (axiomMatchesLabelMetavariableNode) {
|
|
411
396
|
return true;
|
|
@@ -415,10 +400,10 @@ export default class FileContext {
|
|
|
415
400
|
return axiom;
|
|
416
401
|
}
|
|
417
402
|
|
|
418
|
-
|
|
403
|
+
findLemmaByMetavariableNode(metavariableNode) {
|
|
419
404
|
const lemmas = this.getLemmas(),
|
|
420
405
|
lemma = lemmas.find((lemma) => {
|
|
421
|
-
const lemmaMatchesLabelMetavariableNode = lemma.matchLabelMetavariableNode(
|
|
406
|
+
const lemmaMatchesLabelMetavariableNode = lemma.matchLabelMetavariableNode(metavariableNode);
|
|
422
407
|
|
|
423
408
|
if (lemmaMatchesLabelMetavariableNode) {
|
|
424
409
|
return true;
|
|
@@ -428,10 +413,10 @@ export default class FileContext {
|
|
|
428
413
|
return lemma;
|
|
429
414
|
}
|
|
430
415
|
|
|
431
|
-
|
|
416
|
+
findTheoremByMetavariableNode(metavariableNode) {
|
|
432
417
|
const theorems = this.getTheorems(),
|
|
433
418
|
theorem = theorems.find((theorem) => {
|
|
434
|
-
const theoremMatchesLabelMetavariableNode = theorem.matchLabelMetavariableNode(
|
|
419
|
+
const theoremMatchesLabelMetavariableNode = theorem.matchLabelMetavariableNode(metavariableNode);
|
|
435
420
|
|
|
436
421
|
if (theoremMatchesLabelMetavariableNode) {
|
|
437
422
|
return true;
|
|
@@ -441,10 +426,10 @@ export default class FileContext {
|
|
|
441
426
|
return theorem;
|
|
442
427
|
}
|
|
443
428
|
|
|
444
|
-
|
|
429
|
+
findMetaLemmaByMetavariableNode(metavariableNode) {
|
|
445
430
|
const metaLemmas = this.getMetaLemmas(),
|
|
446
431
|
metaLemma = metaLemmas.find((metaLemma) => {
|
|
447
|
-
const metaLemmaMatchesLabelMetavariableNode = metaLemma.matchLabelMetavariableNode(
|
|
432
|
+
const metaLemmaMatchesLabelMetavariableNode = metaLemma.matchLabelMetavariableNode(metavariableNode);
|
|
448
433
|
|
|
449
434
|
if (metaLemmaMatchesLabelMetavariableNode) {
|
|
450
435
|
return true;
|
|
@@ -454,10 +439,10 @@ export default class FileContext {
|
|
|
454
439
|
return metaLemma;
|
|
455
440
|
}
|
|
456
441
|
|
|
457
|
-
|
|
442
|
+
findConjectureByMetavariableNode(metavariableNode) {
|
|
458
443
|
const conjectures = this.getConjectures(),
|
|
459
444
|
conjecture = conjectures.find((conjecture) => {
|
|
460
|
-
const conjectureMatchesLabelMetavariableNode = conjecture.matchLabelMetavariableNode(
|
|
445
|
+
const conjectureMatchesLabelMetavariableNode = conjecture.matchLabelMetavariableNode(metavariableNode);
|
|
461
446
|
|
|
462
447
|
if (conjectureMatchesLabelMetavariableNode) {
|
|
463
448
|
return true;
|
|
@@ -467,10 +452,10 @@ export default class FileContext {
|
|
|
467
452
|
return conjecture;
|
|
468
453
|
}
|
|
469
454
|
|
|
470
|
-
|
|
455
|
+
findMetatheoremByMetavariableNode(metavariableNode) {
|
|
471
456
|
const metatheorems = this.getMetatheorems(),
|
|
472
457
|
metatheorem = metatheorems.find((metatheorem) => {
|
|
473
|
-
const metatheoremMatchesLabelMetavariableNode = metatheorem.matchLabelMetavariableNode(
|
|
458
|
+
const metatheoremMatchesLabelMetavariableNode = metatheorem.matchLabelMetavariableNode(metavariableNode);
|
|
474
459
|
|
|
475
460
|
if (metatheoremMatchesLabelMetavariableNode) {
|
|
476
461
|
return true;
|
|
@@ -480,6 +465,20 @@ export default class FileContext {
|
|
|
480
465
|
return metatheorem;
|
|
481
466
|
}
|
|
482
467
|
|
|
468
|
+
findMetavariableByMetavariableNode(metavariableNode) {
|
|
469
|
+
const node = metavariableNode, ///
|
|
470
|
+
metavariables = this.getMetavariables(),
|
|
471
|
+
metavariable = metavariables.find((metavariable) => {
|
|
472
|
+
const matches = metavariable.matchNode(node);
|
|
473
|
+
|
|
474
|
+
if (matches) {
|
|
475
|
+
return true;
|
|
476
|
+
}
|
|
477
|
+
}) || null;
|
|
478
|
+
|
|
479
|
+
return metavariable;
|
|
480
|
+
}
|
|
481
|
+
|
|
483
482
|
isTypePresentByTypeName(typeName) {
|
|
484
483
|
const type = this.findTypeByTypeName(typeName),
|
|
485
484
|
typePresent = (type !== null);
|
|
@@ -508,8 +507,8 @@ export default class FileContext {
|
|
|
508
507
|
return variablePresent;
|
|
509
508
|
}
|
|
510
509
|
|
|
511
|
-
|
|
512
|
-
const label = this.
|
|
510
|
+
isLabelPresentByMetavariableNode(metavariableNode) {
|
|
511
|
+
const label = this.findLabelByMetavariableNode(metavariableNode),
|
|
513
512
|
labelPresent = (label !== null);
|
|
514
513
|
|
|
515
514
|
return labelPresent;
|
package/src/context/localMeta.js
CHANGED
|
@@ -74,7 +74,18 @@ class LocalMetaContext {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
addJudgement(judgement) {
|
|
77
|
-
|
|
77
|
+
let judgementAdded = false;
|
|
78
|
+
|
|
79
|
+
const metavariableNode = judgement.getMetavariableNode(),
|
|
80
|
+
judgementPresent = this.isJudgementPresentByMetavariableNode(metavariableNode);
|
|
81
|
+
|
|
82
|
+
if (!judgementPresent) {
|
|
83
|
+
this.judgements.push(judgement);
|
|
84
|
+
|
|
85
|
+
judgementAdded = true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return judgementAdded;
|
|
78
89
|
}
|
|
79
90
|
|
|
80
91
|
addMetavariable(metavariable) {
|
|
@@ -138,6 +149,19 @@ class LocalMetaContext {
|
|
|
138
149
|
return variable;
|
|
139
150
|
}
|
|
140
151
|
|
|
152
|
+
findJudgementByMetavariableNode(metavariableNode) {
|
|
153
|
+
const judgements = this.getJudgements(),
|
|
154
|
+
judgement = judgements.find((judgement) => {
|
|
155
|
+
const metavariableMatches = judgement.matchMetavariableNode(metavariableNode);
|
|
156
|
+
|
|
157
|
+
if (metavariableMatches) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
}) || null;
|
|
161
|
+
|
|
162
|
+
return judgement;
|
|
163
|
+
}
|
|
164
|
+
|
|
141
165
|
isVariablePresentByVariableNode(variableNode) {
|
|
142
166
|
const variable = this.findVariableByVariableNode(variableNode),
|
|
143
167
|
variablePresent = (variable !== null);
|
|
@@ -145,6 +169,13 @@ class LocalMetaContext {
|
|
|
145
169
|
return variablePresent;
|
|
146
170
|
}
|
|
147
171
|
|
|
172
|
+
isJudgementPresentByMetavariableNode(metavariableNode) {
|
|
173
|
+
const judgement = this.findJudgementByMetavariableNode(metavariableNode),
|
|
174
|
+
judgementPresent = (judgement !== null);
|
|
175
|
+
|
|
176
|
+
return judgementPresent;
|
|
177
|
+
}
|
|
178
|
+
|
|
148
179
|
findMetavariableByMetavariableNode(metavariableNode, localMetaContext) {
|
|
149
180
|
const node = metavariableNode, ///
|
|
150
181
|
metavariables = this.getMetavariables(),
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { matchMetastatement } from "./utilities/metaproof";
|
|
4
|
+
|
|
5
|
+
export default class Declaration {
|
|
6
|
+
constructor(metavariableNode, metastatementNode) {
|
|
7
|
+
this.metavariableNode = metavariableNode;
|
|
8
|
+
this.metastatementNode = metastatementNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
getMetavariableNode() {
|
|
12
|
+
return this.metavariableNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getMetastatementNode() {
|
|
16
|
+
return this.metastatementNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
matchSubstitution(substitution) {
|
|
20
|
+
const metavariableNode = substitution.getMetavariableNode(),
|
|
21
|
+
metastatementNode = substitution.getMetastatementNode(),
|
|
22
|
+
metavariableNodeMatches = this.matchMetavariableNode(metavariableNode),
|
|
23
|
+
metastatementNodeMatches = this.matchMetastatementNode(metastatementNode),
|
|
24
|
+
substitutionMatches = (metavariableNodeMatches && metastatementNodeMatches);
|
|
25
|
+
|
|
26
|
+
return substitutionMatches;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
matchMetavariableNode(metavariableNode) {
|
|
30
|
+
const metavariableNodeMatches = this.metavariableNode.match(metavariableNode);
|
|
31
|
+
|
|
32
|
+
return metavariableNodeMatches;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
matchMetastatementNode(metastatementNode) {
|
|
36
|
+
const metastatementNodeA = metastatementNode, ///
|
|
37
|
+
metastatementNodeB = this.metastatementNode, ///
|
|
38
|
+
metastatementMatches = matchMetastatement(metastatementNodeA, metastatementNodeB),
|
|
39
|
+
metastatementNodeMatches = metastatementMatches; ///
|
|
40
|
+
|
|
41
|
+
return metastatementNodeMatches;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
matchMetaLemmaOrMetaTheorem(metaLemmaMetatheorem) {
|
|
45
|
+
const metaConsequent = metaLemmaMetatheorem.getMetaConsequent(),
|
|
46
|
+
metastatementNode = metaConsequent.getMetastatementNode(),
|
|
47
|
+
matches = this.metastatementNode.match(metastatementNode),
|
|
48
|
+
metaLemmaOrMetaTheoremMatches = matches; ///
|
|
49
|
+
|
|
50
|
+
return metaLemmaOrMetaTheoremMatches;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static fromMetavariableNodeAndMetastatementNode(metavariableNode, metastatementNode) {
|
|
54
|
+
const declaration = new Declaration(metavariableNode, metastatementNode);
|
|
55
|
+
|
|
56
|
+
return declaration;
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/frame.js
CHANGED
|
@@ -1,27 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { push, first } from "./utilities/array";
|
|
4
|
+
|
|
3
5
|
export default class Frame {
|
|
4
|
-
constructor(
|
|
5
|
-
this.node = node;
|
|
6
|
+
constructor(declarations) {
|
|
6
7
|
this.declarations = declarations;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
getNode() {
|
|
10
|
-
return this.node;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
10
|
getDeclarations() {
|
|
14
11
|
return this.declarations;
|
|
15
12
|
}
|
|
16
13
|
|
|
14
|
+
getDeclaration() {
|
|
15
|
+
let declaration = null;
|
|
16
|
+
|
|
17
|
+
const singular = this.isSingular();
|
|
18
|
+
|
|
19
|
+
if (singular) {
|
|
20
|
+
const firstDeclaration = first(this.declarations);
|
|
21
|
+
|
|
22
|
+
declaration = firstDeclaration; ///
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return declaration;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
isSingular() {
|
|
29
|
+
const declarationsLength = this.declarations.length,
|
|
30
|
+
singular = (declarationsLength === 1);
|
|
31
|
+
|
|
32
|
+
return singular;
|
|
33
|
+
}
|
|
34
|
+
|
|
17
35
|
addDeclarations(declarations) {
|
|
18
36
|
push(this.declarations, declarations);
|
|
19
37
|
}
|
|
20
38
|
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
39
|
+
matchSubstitution(substitution) {
|
|
40
|
+
const substitutionMatches = this.declarations.some((declaration) => {
|
|
41
|
+
const declarationMatchesSubstitution = declaration.matchSubstitution(substitution);
|
|
42
|
+
|
|
43
|
+
if (declarationMatchesSubstitution) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return substitutionMatches;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
matchMetaLemmaOrMetaTheorem(metaLemmaMetatheorem) {
|
|
52
|
+
const substitutions = metaLemmaMetatheorem.getSubstitutions(),
|
|
53
|
+
metaLemmaOrMetaTheoremMatches = substitutions.every((substitution) => {
|
|
54
|
+
const frameMatchesSubstitution = this.matchSubstitution(substitution);
|
|
55
|
+
|
|
56
|
+
if (frameMatchesSubstitution) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return metaLemmaOrMetaTheoremMatches;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static fromDeclarations(declarations) {
|
|
65
|
+
const frame = new Frame(declarations);
|
|
24
66
|
|
|
25
67
|
return frame;
|
|
26
68
|
}
|
|
27
|
-
}
|
|
69
|
+
}
|
package/src/judgement.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export default class Judgement {
|
|
4
|
-
constructor(node, frame,
|
|
4
|
+
constructor(node, frame, metavariableNode) {
|
|
5
5
|
this.node = node;
|
|
6
6
|
this.frame = frame;
|
|
7
|
-
this.
|
|
7
|
+
this.metavariableNode = metavariableNode;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
getNode() {
|
|
@@ -15,13 +15,23 @@ export default class Judgement {
|
|
|
15
15
|
return this.frame;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
return this.
|
|
18
|
+
getMetavariableNode() {
|
|
19
|
+
return this.metavariableNode;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
getDeclarations() { return this.frame.getDeclarations(); }
|
|
23
|
+
|
|
24
|
+
matchMetavariableNode(metavariableNode) {
|
|
25
|
+
const metavariableNodeMatches = this.metavariableNode.match(metavariableNode);
|
|
26
|
+
|
|
27
|
+
return metavariableNodeMatches;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
matchMetaLemmaOrMetaTheorem(metaLemmaMetatheorem) { return this.frame.matchMetaLemmaOrMetaTheorem(metaLemmaMetatheorem); }
|
|
31
|
+
|
|
32
|
+
static fromJudgementNodeFrameAndMetavariableNode(judgementNode, frame, metavariableNode) {
|
|
23
33
|
const node = judgementNode,
|
|
24
|
-
judgement = new Judgement(node, frame,
|
|
34
|
+
judgement = new Judgement(node, frame, metavariableNode);
|
|
25
35
|
|
|
26
36
|
return judgement;
|
|
27
37
|
}
|
package/src/label.js
CHANGED
|
@@ -33,9 +33,9 @@ export default class Label {
|
|
|
33
33
|
|
|
34
34
|
static fromMetavariableNode(metavariableNode) {
|
|
35
35
|
const node = metavariableNode, ///
|
|
36
|
-
|
|
36
|
+
label = new Label(node);
|
|
37
37
|
|
|
38
|
-
return
|
|
38
|
+
return label;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
static fromJSONAndFileContext(json, fileContext) {
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import Label from "./label";
|
|
4
4
|
import MetaConsequent from "./metaConsequent";
|
|
5
5
|
import MetaSupposition from "./metaSupposition";
|
|
6
|
+
import MetastatementForMetavariableSubstitution from "./substitution/metastatementForMetavariable";
|
|
6
7
|
|
|
7
8
|
import { prune } from "./utilities/array";
|
|
8
9
|
import { someSubArray } from "./utilities/array";
|
|
9
|
-
import MetastatementForMetavariableSubstitution from "./substitution/metastatementForMetavariable";
|
|
10
10
|
|
|
11
11
|
export default class MetaLemmaMetatheorem {
|
|
12
12
|
constructor(labels, metaSuppositions, metaConsequent, substitutions, fileContext) {
|
|
@@ -71,9 +71,9 @@ export default class MetaLemmaMetatheorem {
|
|
|
71
71
|
return metastatementNatches;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
matchLabelMetavariableNode(
|
|
74
|
+
matchLabelMetavariableNode(metavariableNode) {
|
|
75
75
|
const labelMetavariableNodeMatches = this.labels.some((label) => {
|
|
76
|
-
const node =
|
|
76
|
+
const node = metavariableNode, ///
|
|
77
77
|
labelMatchesNode = label.matchNode(node);
|
|
78
78
|
|
|
79
79
|
if (labelMatchesNode) {
|
package/src/mixins/context.js
CHANGED
|
@@ -26,7 +26,7 @@ function getConstructors() { return this.context.getConstructors(); }
|
|
|
26
26
|
|
|
27
27
|
function findTypeByTypeName(typeName) { return this.context.findTypeByTypeName(typeName); }
|
|
28
28
|
|
|
29
|
-
function findTypeByTypeNode(
|
|
29
|
+
function findTypeByTypeNode(typeNode) { return this.context.findTypeByTypeNode(typeNode); }
|
|
30
30
|
|
|
31
31
|
function findMetavariableByName(name) { return this.context.findMetavariableByName(name); }
|
|
32
32
|
|
|
@@ -36,19 +36,23 @@ function isTypePresentByTypeNode(typeNode) { return this.context.isTypePresentBy
|
|
|
36
36
|
|
|
37
37
|
function isMetavariablePresentByName(name) { return this.context.isMetavariablePresentByName(name); }
|
|
38
38
|
|
|
39
|
-
function
|
|
39
|
+
function isLabelPresentByMetavariableNode(metavariableNode) { return this.context.isLabelPresentByMetavariableNode(metavariableNode); }
|
|
40
40
|
|
|
41
|
-
function
|
|
41
|
+
function findLabelByMetavariableNode(metavariableNode) { return this.context.findLabelByMetavariableNode(metavariableNode); }
|
|
42
42
|
|
|
43
|
-
function
|
|
43
|
+
function findRuleByMetavariableNode(metavariableNode) { return this.context.findRuleByMetavariableNode(metavariableNode); }
|
|
44
44
|
|
|
45
|
-
function
|
|
45
|
+
function findAxiomByMetavariableNode(metavariableNode) { return this.context.findAxiomByMetavariableNode(metavariableNode); }
|
|
46
46
|
|
|
47
|
-
function
|
|
47
|
+
function findLemmaByMetavariableNode(metavariableNode) { return this.context.findLemmaByMetavariableNode(metavariableNode); }
|
|
48
48
|
|
|
49
|
-
function
|
|
49
|
+
function findTheoremByMetavariableNode(metavariableNode) { return this.context.findTheoremByMetavariableNode(metavariableNode); }
|
|
50
50
|
|
|
51
|
-
function
|
|
51
|
+
function findMetaLemmaByMetavariableNode(metavariableNode) { return this.context.findMetaLemmaByMetavariableNode(metavariableNode); }
|
|
52
|
+
|
|
53
|
+
function findConjectureByMetavariableNode(metavariableNode) { return this.context.findConjectureByMetavariableNode(metavariableNode); }
|
|
54
|
+
|
|
55
|
+
function findMetatheoremByMetavariableNode(metavariableNode) { return this.context.findMetatheoremByMetavariableNode(metavariableNode); }
|
|
52
56
|
|
|
53
57
|
function nodeAsString(node) { return this.context.nodeAsString(node); }
|
|
54
58
|
|
|
@@ -73,13 +77,15 @@ const contextMixins = {
|
|
|
73
77
|
isTypePresentByTypeName,
|
|
74
78
|
isTypePresentByTypeNode,
|
|
75
79
|
isMetavariablePresentByName,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
isLabelPresentByMetavariableNode,
|
|
81
|
+
findLabelByMetavariableNode,
|
|
82
|
+
findRuleByMetavariableNode,
|
|
83
|
+
findAxiomByMetavariableNode,
|
|
84
|
+
findLemmaByMetavariableNode,
|
|
85
|
+
findTheoremByMetavariableNode,
|
|
86
|
+
findMetaLemmaByMetavariableNode,
|
|
87
|
+
findConjectureByMetavariableNode,
|
|
88
|
+
findMetatheoremByMetavariableNode,
|
|
83
89
|
nodeAsString,
|
|
84
90
|
nodesAsString
|
|
85
91
|
};
|
package/src/premise.js
CHANGED
|
@@ -11,8 +11,6 @@ import { metastatementNodeFromMetastatementString } from "./utilities/node";
|
|
|
11
11
|
|
|
12
12
|
const ruleSubproofAssertionNodeQuery = nodeQuery("/metastatement/ruleSubproofAssertion!"),
|
|
13
13
|
ruleSubproofPremiseMetastatementQuery = nodesQuery("/ruleSubproof/premise/unqualifiedMetastatement!/metastatement!"),
|
|
14
|
-
subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement!/statement!"),
|
|
15
|
-
subproofSubDerivationLastStatementNodeQuery = nodeQuery("/subproof/subDerivation/qualifiedStatement|unqualifiedStatement[-1]/statement!"),
|
|
16
14
|
ruleSubproofAssertionMetastatementNodesQuery = nodesQuery("/ruleSubproofAssertion/metastatement"),
|
|
17
15
|
ruleSubproofSubDerivationLastMetastatementQuery = nodeQuery("/ruleSubproof/ruleSubDerivation/qualifiedMetastatement|unqualifiedMetastatement[-1]/metastatement!");
|
|
18
16
|
|
|
@@ -25,45 +23,6 @@ export default class Premise {
|
|
|
25
23
|
return this.metastatementNode;
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
matchSubproofNode(subproofNode, substitutions, fileContext, statementLocalContext) {
|
|
29
|
-
let subproofNodeMatches = false;
|
|
30
|
-
|
|
31
|
-
const subproofAssertionNode = ruleSubproofAssertionNodeQuery(this.metastatementNode);
|
|
32
|
-
|
|
33
|
-
if (subproofAssertionNode !== null) {
|
|
34
|
-
const subproofSuppositionStatementNodes = subproofSuppositionStatementNodesQuery(subproofNode),
|
|
35
|
-
subproofSubDerivationLastStatementNode = subproofSubDerivationLastStatementNodeQuery(subproofNode),
|
|
36
|
-
subproofStatementNodes = [
|
|
37
|
-
...subproofSuppositionStatementNodes,
|
|
38
|
-
subproofSubDerivationLastStatementNode
|
|
39
|
-
],
|
|
40
|
-
ruleSubproofAssertionMetastatementNodes = ruleSubproofAssertionMetastatementNodesQuery(subproofAssertionNode),
|
|
41
|
-
subproofStatementNodesLength = subproofStatementNodes.length,
|
|
42
|
-
ruleSubproofAssertionMetastatementNodesLength = ruleSubproofAssertionMetastatementNodes.length;
|
|
43
|
-
|
|
44
|
-
if (subproofStatementNodesLength === ruleSubproofAssertionMetastatementNodesLength) {
|
|
45
|
-
subproofNodeMatches = match(ruleSubproofAssertionMetastatementNodes, subproofStatementNodes, (ruleSubproofAssertionMetastatementNode, subproofStatementNode) => {
|
|
46
|
-
const nonTerminalNodeA = ruleSubproofAssertionMetastatementNode, ///
|
|
47
|
-
nonTerminalNodeB = subproofStatementNode, ///
|
|
48
|
-
fileContextA = fileContext, ///
|
|
49
|
-
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
50
|
-
localContextB = statementLocalContext, ///
|
|
51
|
-
nonTerminalNodeVerified = intrinsicLevelAgainstMetaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
52
|
-
const verifiedAhead = true;
|
|
53
|
-
|
|
54
|
-
return verifiedAhead;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
if (nonTerminalNodeVerified) {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return subproofNodeMatches;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
26
|
matchStatementNode(statementNode, substitutions, fileContext, statementLocalContext) {
|
|
68
27
|
const nonTerminalNodeA = this.metastatementNode, ///
|
|
69
28
|
nonTerminalNodeB = statementNode, ///
|
package/src/rule.js
CHANGED
|
@@ -99,9 +99,9 @@ export default class Rule {
|
|
|
99
99
|
return metastatementNatches;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
matchLabelMetavariableNode(
|
|
102
|
+
matchLabelMetavariableNode(metavariableNode) {
|
|
103
103
|
const labelMetavariableNodeMatches = this.labels.some((label) => {
|
|
104
|
-
const node =
|
|
104
|
+
const node = metavariableNode, ///
|
|
105
105
|
labelMatchesNode = label.matchNode(node);
|
|
106
106
|
|
|
107
107
|
if (labelMatchesNode) {
|
|
@@ -183,16 +183,7 @@ export default class Rule {
|
|
|
183
183
|
|
|
184
184
|
function matchPremise(premise, proofSteps, substitutions, fileContext, statementLocalContext) {
|
|
185
185
|
const proofStep = prune(proofSteps, (proofStep) => {
|
|
186
|
-
const
|
|
187
|
-
statementNode = proofStep.getStatementNode()
|
|
188
|
-
|
|
189
|
-
if (subproofNode !== null) {
|
|
190
|
-
const subProofNodeMatches = premise.matchSubproofNode(subproofNode, substitutions, fileContext, statementLocalContext);
|
|
191
|
-
|
|
192
|
-
if (!subProofNodeMatches) { ///
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
186
|
+
const statementNode = proofStep.getStatementNode()
|
|
196
187
|
|
|
197
188
|
if (statementNode !== null) {
|
|
198
189
|
const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions, fileContext, statementLocalContext);
|
package/src/supposition.js
CHANGED
|
@@ -2,16 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import intrinsicLevelNodesVerifier from "./verifier/nodes/intrinsicLevel";
|
|
4
4
|
|
|
5
|
-
import { match } from "./utilities/array";
|
|
6
5
|
import { nodeAsString } from "./utilities/string";
|
|
7
|
-
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
8
6
|
import { statementNodeFromStatementString } from "./utilities/node";
|
|
9
7
|
|
|
10
|
-
const subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion!"),
|
|
11
|
-
subproofAssertionStatementNodesQuery = nodesQuery("/subproofAssertion/statement"),
|
|
12
|
-
subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement/statement!"),
|
|
13
|
-
subproofSubDerivationLastStatementNodeQuery = nodeQuery("/subproof/subDerivation/qualifiedStatement|unqualifiedStatement[-1]/statement!");
|
|
14
|
-
|
|
15
8
|
export default class Supposition {
|
|
16
9
|
constructor(statementNode) {
|
|
17
10
|
this.statementNode = statementNode;
|
|
@@ -21,44 +14,6 @@ export default class Supposition {
|
|
|
21
14
|
return this.statementNode;
|
|
22
15
|
}
|
|
23
16
|
|
|
24
|
-
matchSubproofNode(subproofNode, substitutions, localContext, statementLocalContext) {
|
|
25
|
-
let subproofNodeMatches = false;
|
|
26
|
-
|
|
27
|
-
const subproofAssertionNode = subproofAssertionNodeQuery(this.statementNode);
|
|
28
|
-
|
|
29
|
-
if (subproofAssertionNode !== null) {
|
|
30
|
-
const subproofSuppositionStatementNodes = subproofSuppositionStatementNodesQuery(subproofNode),
|
|
31
|
-
subproofSubDerivationLastStatementNode = subproofSubDerivationLastStatementNodeQuery(subproofNode),
|
|
32
|
-
subproofStatementNodes = [
|
|
33
|
-
...subproofSuppositionStatementNodes,
|
|
34
|
-
subproofSubDerivationLastStatementNode
|
|
35
|
-
],
|
|
36
|
-
subproofAssertionStatementNodes = subproofAssertionStatementNodesQuery(subproofAssertionNode),
|
|
37
|
-
subproofStatementNodesLength = subproofStatementNodes.length,
|
|
38
|
-
subproofAssertionStatementNodesLength = subproofAssertionStatementNodes.length;
|
|
39
|
-
|
|
40
|
-
if (subproofStatementNodesLength === subproofAssertionStatementNodesLength) {
|
|
41
|
-
subproofNodeMatches = match(subproofAssertionStatementNodes, subproofStatementNodes, (subproofAssertionStatementNode, subproofStatementNode) => {
|
|
42
|
-
const nonTerminalNodeA = subproofAssertionStatementNode, ///
|
|
43
|
-
nonTerminalNodeB = subproofStatementNode, ///
|
|
44
|
-
localContextA = localContext, ///
|
|
45
|
-
localContextB = statementLocalContext, ///
|
|
46
|
-
nonTerminalNodeVerified = intrinsicLevelNodesVerifier.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 subproofNodeMatches;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
17
|
matchStatementNode(statementNode, substitutions, localContext, statementLocalContext) {
|
|
63
18
|
const nonTerminalNodeA = this.statementNode, ///
|
|
64
19
|
nonTerminalNodeB = statementNode, ///
|