occam-verify-cli 0.0.950 → 0.0.952
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/context/file.js +9 -128
- package/lib/context/release.js +174 -33
- package/lib/declaration.js +13 -13
- package/lib/frame.js +14 -14
- package/lib/judgement.js +4 -4
- package/lib/metavariable.js +10 -10
- package/lib/releaseContext/initialise.js +2 -2
- package/lib/substitution/statementForMetavariable.js +11 -11
- package/lib/unifier/equality.js +6 -6
- package/lib/unifier/metaLevel.js +5 -5
- package/lib/unify/statementAgainstMetaType.js +5 -5
- package/lib/utilities/array.js +5 -2
- package/lib/verify/declaration/variable.js +2 -2
- package/lib/verify/judgement.js +3 -3
- package/lib/verify/metavariable.js +3 -3
- package/lib/verify/statement/qualified.js +3 -3
- package/package.json +1 -1
- package/src/context/file.js +11 -212
- package/src/context/release.js +164 -33
- package/src/declaration.js +10 -10
- package/src/frame.js +12 -11
- package/src/judgement.js +1 -1
- package/src/metavariable.js +18 -17
- package/src/releaseContext/initialise.js +1 -1
- package/src/substitution/statementForMetavariable.js +9 -10
- package/src/unifier/equality.js +5 -5
- package/src/unifier/metaLevel.js +4 -4
- package/src/unify/statementAgainstMetaType.js +4 -4
- package/src/utilities/array.js +1 -1
- package/src/verify/declaration/variable.js +3 -1
- package/src/verify/judgement.js +3 -3
- package/src/verify/metavariable.js +3 -3
- package/src/verify/statement/qualified.js +2 -2
package/src/context/release.js
CHANGED
|
@@ -4,15 +4,15 @@ import { lexersUtilities, parsersUtilities } from "occam-custom-grammars";
|
|
|
4
4
|
|
|
5
5
|
import FileContext from "./file";
|
|
6
6
|
|
|
7
|
-
import { push } from "../utilities/array";
|
|
8
7
|
import { objectType } from "../type";
|
|
8
|
+
import { tail, push, leftDifference } from "../utilities/array";
|
|
9
9
|
import { customGrammarFromNameAndEntries, combinedCustomGrammarFromReleaseContexts } from "../utilities/customGrammar";
|
|
10
10
|
|
|
11
11
|
const { florenceLexerFromCombinedCustomGrammar } = lexersUtilities,
|
|
12
12
|
{ florenceParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
13
13
|
|
|
14
14
|
export default class ReleaseContext {
|
|
15
|
-
constructor(log, json, name, entries, lexer, parser, verified, customGrammar,
|
|
15
|
+
constructor(log, json, name, entries, lexer, parser, verified, fileContexts, customGrammar, loggingDisabled, dependencyReleaseContexts) {
|
|
16
16
|
this.log = log;
|
|
17
17
|
this.json = json;
|
|
18
18
|
this.name = name;
|
|
@@ -20,8 +20,9 @@ export default class ReleaseContext {
|
|
|
20
20
|
this.lexer = lexer;
|
|
21
21
|
this.parser = parser;
|
|
22
22
|
this.verified = verified;
|
|
23
|
-
this.customGrammar = customGrammar;
|
|
24
23
|
this.fileContexts = fileContexts;
|
|
24
|
+
this.customGrammar = customGrammar;
|
|
25
|
+
this.loggingDisabled = loggingDisabled;
|
|
25
26
|
this.dependencyReleaseContexts = dependencyReleaseContexts;
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -53,18 +54,66 @@ export default class ReleaseContext {
|
|
|
53
54
|
return this.verified;
|
|
54
55
|
}
|
|
55
56
|
|
|
57
|
+
getFileContexts() {
|
|
58
|
+
return this.fileContexts;
|
|
59
|
+
}
|
|
60
|
+
|
|
56
61
|
getCustomGrammar() {
|
|
57
62
|
return this.customGrammar;
|
|
58
63
|
}
|
|
59
64
|
|
|
60
|
-
|
|
61
|
-
return this.
|
|
65
|
+
isLoggingDisabled() {
|
|
66
|
+
return this.loggingDisabled;
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
getDependencyReleaseContexts() {
|
|
65
70
|
return this.dependencyReleaseContexts;
|
|
66
71
|
}
|
|
67
72
|
|
|
73
|
+
setLog(log) {
|
|
74
|
+
this.log = log;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
setJSON(json) {
|
|
78
|
+
this.json = json;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
setName(name) {
|
|
82
|
+
this.name = name;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
setEntries(entries) {
|
|
86
|
+
this.entries = entries;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
setLexer(lexer) {
|
|
90
|
+
this.lexer = lexer;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
setParser(parser) {
|
|
94
|
+
this.parser = parser;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
setVerified(verified) {
|
|
98
|
+
this.verified = verified;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
setFileContexts(fileContexts) {
|
|
102
|
+
this.fileContexts = fileContexts;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
setCustomGrammar(customGrammar) {
|
|
106
|
+
this.customGrammar = customGrammar;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
setLoggingDisabled(loggingDisabled) {
|
|
110
|
+
this.loggingDisabled = loggingDisabled;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
setDependencyReleaseContexts(dependencyReleaseContexts) {
|
|
114
|
+
this.dependencyReleaseContexts = dependencyReleaseContexts;
|
|
115
|
+
}
|
|
116
|
+
|
|
68
117
|
getLabels(includeDependencies = true) {
|
|
69
118
|
const labels = [];
|
|
70
119
|
|
|
@@ -356,53 +405,87 @@ export default class ReleaseContext {
|
|
|
356
405
|
|
|
357
406
|
matchShortenedVersion(shortenedVersion) { return this.entries.matchShortenedVersion(shortenedVersion); }
|
|
358
407
|
|
|
359
|
-
|
|
360
|
-
|
|
408
|
+
disableLogging() {
|
|
409
|
+
const loggingDisabled = true;
|
|
410
|
+
|
|
411
|
+
this.setLoggingDisabled(loggingDisabled);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
enableLogging() {
|
|
415
|
+
const loggingDisabled = false;
|
|
416
|
+
|
|
417
|
+
this.setLoggingDisabled(loggingDisabled);
|
|
361
418
|
}
|
|
362
419
|
|
|
363
|
-
|
|
420
|
+
trace(message, node = null, tokens = null, filePath = null) {
|
|
421
|
+
if (this.loggingDisabled) {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
this.log.trace(message, node, tokens, filePath);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
debug(message, node = null, tokens = null, filePath = null) {
|
|
429
|
+
if (this.loggingDisabled) {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
this.log.debug(message, node, tokens, filePath);
|
|
434
|
+
}
|
|
364
435
|
|
|
365
|
-
|
|
436
|
+
info(message, node = null, tokens = null, filePath = null) {
|
|
437
|
+
if (this.loggingDisabled) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
366
440
|
|
|
367
|
-
|
|
441
|
+
this.log.info(message, node, tokens, filePath);
|
|
442
|
+
}
|
|
368
443
|
|
|
369
|
-
|
|
444
|
+
warning(message, node = null, tokens = null, filePath = null) {
|
|
445
|
+
if (this.loggingDisabled) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
370
448
|
|
|
371
|
-
|
|
449
|
+
this.log.warning(message, node, tokens, filePath);
|
|
450
|
+
}
|
|
372
451
|
|
|
373
|
-
|
|
452
|
+
error(message, node = null, tokens = null, filePath = null) {
|
|
453
|
+
if (this.loggingDisabled) {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
374
456
|
|
|
375
|
-
|
|
457
|
+
this.log.error(message, node, tokens, filePath);
|
|
458
|
+
}
|
|
376
459
|
|
|
377
|
-
fatal(message, node = null, tokens = null, filePath = null) {
|
|
460
|
+
fatal(message, node = null, tokens = null, filePath = null) {
|
|
461
|
+
if (this.loggingDisabled) {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
378
464
|
|
|
379
|
-
|
|
380
|
-
|
|
465
|
+
this.log.fatal(message, node, tokens, filePath);
|
|
466
|
+
}
|
|
381
467
|
|
|
468
|
+
verify(releaseContexts) {
|
|
382
469
|
const combinedCustomGrammar = combinedCustomGrammarFromReleaseContexts(releaseContexts),
|
|
383
|
-
|
|
384
|
-
|
|
470
|
+
florenceParser = florenceParserFromCombinedCustomGrammar(combinedCustomGrammar),
|
|
471
|
+
florenceLexer = florenceLexerFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
385
472
|
|
|
386
473
|
this.lexer = florenceLexer; ///
|
|
387
474
|
|
|
388
475
|
this.parser = florenceParser; ///
|
|
389
476
|
|
|
390
|
-
|
|
391
|
-
dependencyReleaseContexts = releaseContexts; ///
|
|
392
|
-
|
|
393
|
-
this.dependencyReleaseContexts = dependencyReleaseContexts;
|
|
477
|
+
this.dependencyReleaseContexts = tail(releaseContexts)
|
|
394
478
|
|
|
395
479
|
if (this.json !== null) {
|
|
396
|
-
const
|
|
480
|
+
const releaseContext = this;
|
|
397
481
|
|
|
398
|
-
|
|
399
|
-
const json = fileContextJSON, ///
|
|
400
|
-
fileContext = FileContext.fromJSONAndReleaseContext(json, releaseContext);
|
|
482
|
+
releaseContext.disableLogging();
|
|
401
483
|
|
|
402
|
-
|
|
484
|
+
this.fileContexts = fileContextsFromJSON(this.json, releaseContext);
|
|
403
485
|
|
|
404
|
-
|
|
405
|
-
|
|
486
|
+
verifyFileContexts(this.fileContexts, releaseContext);
|
|
487
|
+
|
|
488
|
+
releaseContext.enableLogging();
|
|
406
489
|
|
|
407
490
|
this.verified = true;
|
|
408
491
|
}
|
|
@@ -423,11 +506,59 @@ export default class ReleaseContext {
|
|
|
423
506
|
const lexer = null,
|
|
424
507
|
parser = null,
|
|
425
508
|
verified = false,
|
|
426
|
-
customGrammar = customGrammarFromNameAndEntries(name, entries),
|
|
427
509
|
fileContexts = [],
|
|
510
|
+
customGrammar = customGrammarFromNameAndEntries(name, entries),
|
|
511
|
+
loggingDisabled = false,
|
|
428
512
|
dependencyReleaseContexts = null,
|
|
429
|
-
releaseContext = new ReleaseContext(log, json, name, entries, lexer, parser, verified, customGrammar,
|
|
513
|
+
releaseContext = new ReleaseContext(log, json, name, entries, lexer, parser, verified, fileContexts, customGrammar, loggingDisabled, dependencyReleaseContexts);
|
|
430
514
|
|
|
431
515
|
return releaseContext;
|
|
432
516
|
}
|
|
433
|
-
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function verifyFileContexts(fileContexts, releaseContext) {
|
|
520
|
+
fileContexts = [ ///
|
|
521
|
+
...fileContexts
|
|
522
|
+
];
|
|
523
|
+
|
|
524
|
+
for (;;) {
|
|
525
|
+
const fileContextsLength = fileContexts.length;
|
|
526
|
+
|
|
527
|
+
if (fileContextsLength === 0) {
|
|
528
|
+
break;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
const verifiedFileContexts = [];
|
|
532
|
+
|
|
533
|
+
fileContexts.forEach((fileContext) => {
|
|
534
|
+
const verified = fileContext.verify(releaseContext);
|
|
535
|
+
|
|
536
|
+
if (verified) {
|
|
537
|
+
const verifiedFileContext = fileContext; ///
|
|
538
|
+
|
|
539
|
+
verifiedFileContexts.push(verifiedFileContext);
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
const verifiedFileContextsLength = verifiedFileContexts.length,
|
|
544
|
+
fileVerified = (verifiedFileContextsLength > 0);
|
|
545
|
+
|
|
546
|
+
if (!fileVerified) {
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
leftDifference(fileContexts, verifiedFileContexts);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
function fileContextsFromJSON(json, releaseContext) {
|
|
555
|
+
const fileContextsJSON = json, ///
|
|
556
|
+
fileContexts = fileContextsJSON.map((fileContextJSON) => {
|
|
557
|
+
const json = fileContextJSON, ///
|
|
558
|
+
fileContext = FileContext.fromJSONAndReleaseContext(json, releaseContext);
|
|
559
|
+
|
|
560
|
+
return fileContext;
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
return fileContexts;
|
|
564
|
+
}
|
package/src/declaration.js
CHANGED
|
@@ -16,23 +16,23 @@ export default class Declaration {
|
|
|
16
16
|
return this.statementNode;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
unifySubstitution(substitution) {
|
|
20
20
|
const statementNode = substitution.getStatementNode(),
|
|
21
21
|
metavariableNode = substitution.getMetavariableNode(),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
statementUnified = this.unifyStatement(statementNode),
|
|
23
|
+
metavariableUnified = this.unifyMetavariable(metavariableNode),
|
|
24
|
+
substitutionUnified = (metavariableUnified && statementUnified);
|
|
25
25
|
|
|
26
|
-
return
|
|
26
|
+
return substitutionUnified;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
unifyMetavariable(metavariableNode) {
|
|
30
30
|
const matchesMetavariableNode = this.metavariableNode.match(metavariableNode);
|
|
31
31
|
|
|
32
32
|
return matchesMetavariableNode;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
unifyStatement(statementNode) {
|
|
36
36
|
const statementNodeA = statementNode, ///
|
|
37
37
|
statementNodeB = this.statementNode, ///
|
|
38
38
|
statementMatches = matchStatementModuloBrackets(statementNodeA, statementNodeB),
|
|
@@ -41,13 +41,13 @@ export default class Declaration {
|
|
|
41
41
|
return matchesStatementNode;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem) {
|
|
45
45
|
const consequent = metaLemmaMetatheorem.getConsequent(),
|
|
46
46
|
statementNode = consequent.getStatementNode(),
|
|
47
47
|
matches = this.statementNode.match(statementNode),
|
|
48
|
-
|
|
48
|
+
metaLemmaOrMetaTheoremUnified = matches; ///
|
|
49
49
|
|
|
50
|
-
return
|
|
50
|
+
return metaLemmaOrMetaTheoremUnified;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
static fromMetavariableNodeAndStatementNode(metavariableNode, statementNode) {
|
package/src/frame.js
CHANGED
|
@@ -36,29 +36,30 @@ export default class Frame {
|
|
|
36
36
|
push(this.declarations, declarations);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
const
|
|
39
|
+
unifySubstitution(substitution) {
|
|
40
|
+
const substitutionUnified = this.declarations.some((declaration) => {
|
|
41
|
+
const substitutionUnifiedAgainstDeclaration = declaration.unifySubstitution(substitution);
|
|
42
42
|
|
|
43
|
-
if (
|
|
43
|
+
if (substitutionUnifiedAgainstDeclaration) {
|
|
44
44
|
return true;
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
return
|
|
48
|
+
return substitutionUnified;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
unifyMetaLemmaOrMetaTheorem(metaLemmaMetatheorem) {
|
|
52
52
|
const substitutions = metaLemmaMetatheorem.getSubstitutions(),
|
|
53
|
-
|
|
54
|
-
const
|
|
53
|
+
substitutionsUnified = substitutions.everySubstitution((substitution) => {
|
|
54
|
+
const substitutionUnified = this.unifySubstitution(substitution);
|
|
55
55
|
|
|
56
|
-
if (
|
|
56
|
+
if (substitutionUnified) {
|
|
57
57
|
return true;
|
|
58
58
|
}
|
|
59
|
-
})
|
|
59
|
+
}),
|
|
60
|
+
metaLemmaOrMetaTheoremUnified = substitutionsUnified; ///
|
|
60
61
|
|
|
61
|
-
return
|
|
62
|
+
return metaLemmaOrMetaTheoremUnified;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
static fromDeclarations(declarations) {
|
package/src/judgement.js
CHANGED
|
@@ -27,7 +27,7 @@ export default class Judgement {
|
|
|
27
27
|
return matchesMetavariableNode;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
unifyMetaLemmaOrmetatheorem(metaLemmaMetatheorem) { return this.frame.unifyMetaLemmaOrmetatheorem(metaLemmaMetatheorem); }
|
|
31
31
|
|
|
32
32
|
static fromJudgementNodeFrameAndMetavariableNode(judgementNode, frame, metavariableNode) {
|
|
33
33
|
const node = judgementNode,
|
package/src/metavariable.js
CHANGED
|
@@ -65,9 +65,9 @@ export default class Metavariable {
|
|
|
65
65
|
} else if ((termNode === null) && (this.termType === null)) {
|
|
66
66
|
matchesNode = true;
|
|
67
67
|
} else if ((termNode !== null) && (this.termType !== null)) {
|
|
68
|
-
const
|
|
68
|
+
const termUnifiedAgainstTermType = unifyTermAgainstTermType(termNode, this.termType, localContext);
|
|
69
69
|
|
|
70
|
-
matchesNode =
|
|
70
|
+
matchesNode = termUnifiedAgainstTermType; ///
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -128,28 +128,29 @@ export default class Metavariable {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
export function
|
|
132
|
-
let
|
|
131
|
+
export function unifyTermAgainstTermType(termNode, termType, localContext) {
|
|
132
|
+
let termUnifiedAgainstTermType;
|
|
133
133
|
|
|
134
134
|
const type = termType, ///
|
|
135
|
-
terms = []
|
|
135
|
+
terms = [],
|
|
136
|
+
termVerified = verifyTerm(termNode, terms, localContext, () => {
|
|
137
|
+
let verifiedAhead = false;
|
|
136
138
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
+
const firstTerm = first(terms),
|
|
140
|
+
term = firstTerm, ///
|
|
141
|
+
termType = term.getType(),
|
|
142
|
+
termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(type);
|
|
139
143
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(type);
|
|
144
|
+
if (termTypeEqualToOrSubTypeOfType) {
|
|
145
|
+
verifiedAhead = true;
|
|
146
|
+
}
|
|
144
147
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
+
return verifiedAhead;
|
|
149
|
+
});
|
|
148
150
|
|
|
149
|
-
|
|
150
|
-
});
|
|
151
|
+
termUnifiedAgainstTermType = termVerified; ///
|
|
151
152
|
|
|
152
|
-
return
|
|
153
|
+
return termUnifiedAgainstTermType;
|
|
153
154
|
}
|
|
154
155
|
|
|
155
156
|
function termTypeFromMetavariableNode(metavariableNode, fileContext) {
|
|
@@ -42,7 +42,7 @@ export default function initialiseReleaseContext(dependency, dependentName, depe
|
|
|
42
42
|
if (releaseContextInitialised) {
|
|
43
43
|
const releaseContexts = retrieveReleaseContexts(releaseContext, releaseContextMap);
|
|
44
44
|
|
|
45
|
-
releaseContext.
|
|
45
|
+
releaseContext.verify(releaseContexts);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -38,14 +38,14 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
38
38
|
return node;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
unifyStatement(statementNode, substitutions, localContextA, localContextB) {
|
|
42
42
|
let statementNodeMatches;
|
|
43
43
|
|
|
44
44
|
const substitution = this.substitution, ///
|
|
45
45
|
statementNodeA = statementNode, ///
|
|
46
46
|
statementNodeB = this.statementNode; ///
|
|
47
47
|
|
|
48
|
-
statementNodeMatches =
|
|
48
|
+
statementNodeMatches = unifyStatement(statementNodeA, statementNodeB, substitution, substitutions, localContextA, localContextB);
|
|
49
49
|
|
|
50
50
|
if (!statementNodeMatches) {
|
|
51
51
|
const bracketedStatementChildNode = bracketedStatementChildNodeFromStatementNode(statementNode);
|
|
@@ -53,7 +53,7 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
53
53
|
if (bracketedStatementChildNode !== null) {
|
|
54
54
|
const statementNodeA = bracketedStatementChildNode; ///
|
|
55
55
|
|
|
56
|
-
statementNodeMatches =
|
|
56
|
+
statementNodeMatches = unifyStatement(statementNodeA, statementNodeB, substitution, substitutions, localContextA, localContextB);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -153,19 +153,18 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
function
|
|
157
|
-
let
|
|
156
|
+
function unifyStatement(statementNodeA, statementNodeB, substitution, substitutions, localContextA, localContextB) {
|
|
157
|
+
let statementUnified;
|
|
158
158
|
|
|
159
159
|
if (substitution === null) {
|
|
160
160
|
const statementNodeAMatchesStatementNodeB = statementNodeB.match(statementNodeA);
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
statementUnified = statementNodeAMatchesStatementNodeB; ///
|
|
163
163
|
} else {
|
|
164
|
-
const
|
|
164
|
+
const statementUnifiedAgainstStatement = unifyStatementAgainstStatement(statementNodeA, statementNodeB, substitution, substitutions, localContextA, localContextB);
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
statementUnified = statementUnifiedAgainstStatement; ///
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
return
|
|
170
|
-
|
|
169
|
+
return statementUnified;
|
|
171
170
|
}
|
package/src/unifier/equality.js
CHANGED
|
@@ -25,14 +25,14 @@ class EqualityUnifier extends Unifier {
|
|
|
25
25
|
nodeQueryA: termNodeQuery,
|
|
26
26
|
nodeQueryB: termNodeQuery,
|
|
27
27
|
unify: (termNodeA, termNodeB, localContext) => {
|
|
28
|
-
let
|
|
28
|
+
let termUnifiedAgainstTerm;
|
|
29
29
|
|
|
30
30
|
const leftTermNode = termNodeA, ///
|
|
31
31
|
rightTermNode = termNodeB; ///
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
termUnifiedAgainstTerm = unifyTermAgainstTerm(leftTermNode, rightTermNode, localContext);
|
|
34
34
|
|
|
35
|
-
if (!
|
|
35
|
+
if (!termUnifiedAgainstTerm) {
|
|
36
36
|
const nonTerminalNodeA = termNodeA, ///
|
|
37
37
|
nonTerminalNodeB = termNodeB, ///
|
|
38
38
|
nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
@@ -41,10 +41,10 @@ class EqualityUnifier extends Unifier {
|
|
|
41
41
|
childNodesB = nonTerminalNodeBChildNodes, ///
|
|
42
42
|
childNodesVerified = equalityUnifier.unifyChildNodes(childNodesA, childNodesB, localContext);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
termUnifiedAgainstTerm = childNodesVerified; ///
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
return
|
|
47
|
+
return termUnifiedAgainstTerm;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
];
|
package/src/unifier/metaLevel.js
CHANGED
|
@@ -31,7 +31,7 @@ class MetaLevelUnifier extends Unifier {
|
|
|
31
31
|
nodeQueryA: statementNodeQuery,
|
|
32
32
|
nodeQueryB: statementNodeQuery,
|
|
33
33
|
unify: (statementNodeA, statementNodeB, substitutions, localContextA, localContextB) => {
|
|
34
|
-
let
|
|
34
|
+
let statementUnifiedAgainstStatement;
|
|
35
35
|
|
|
36
36
|
const metavariableNodeA = metavariableNodeQuery(statementNodeA);
|
|
37
37
|
|
|
@@ -39,7 +39,7 @@ class MetaLevelUnifier extends Unifier {
|
|
|
39
39
|
const substitutionNodeA = substitutionNodeQuery(statementNodeA),
|
|
40
40
|
metavariableUnifiedAgainstStatement = unifyMetavariableAgainstStatement(metavariableNodeA, statementNodeB, substitutionNodeA, substitutions, localContextA, localContextB);
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
statementUnifiedAgainstStatement = metavariableUnifiedAgainstStatement; ///
|
|
43
43
|
} else {
|
|
44
44
|
const nonTerminalNodeA = statementNodeA, ///
|
|
45
45
|
nonTerminalNodeB = statementNodeB, ///
|
|
@@ -49,10 +49,10 @@ class MetaLevelUnifier extends Unifier {
|
|
|
49
49
|
childNodesB = nonTerminalNodeBChildNodes, ///
|
|
50
50
|
childNodesVerified = metaLevelUnifier.unifyChildNodes(childNodesA, childNodesB, substitutions, localContextA, localContextB);
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
statementUnifiedAgainstStatement = childNodesVerified; ///
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
return
|
|
55
|
+
return statementUnifiedAgainstStatement;
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
{
|
|
@@ -9,7 +9,7 @@ const metavariableNodeQuery = nodeQuery("/statement/metavariable"),
|
|
|
9
9
|
metaTypeTerminalNodeQuery = nodeQuery("/metaType/@meta-type!");
|
|
10
10
|
|
|
11
11
|
export default function unifyStatementAgainstMetaType(statementNode, metaTypeNode, localContext) {
|
|
12
|
-
let
|
|
12
|
+
let statementUnifiedAgainstMetaType = false;
|
|
13
13
|
|
|
14
14
|
const metaTypeTerminalNode = metaTypeTerminalNodeQuery(metaTypeNode),
|
|
15
15
|
metaTypeTerminalNodeContent = metaTypeTerminalNode.getContent(),
|
|
@@ -26,7 +26,7 @@ export default function unifyStatementAgainstMetaType(statementNode, metaTypeNod
|
|
|
26
26
|
const metavariableMetaTypeName = metavariable.getMetaTypeName();
|
|
27
27
|
|
|
28
28
|
if (metavariableMetaTypeName === metaTypeName) {
|
|
29
|
-
|
|
29
|
+
statementUnifiedAgainstMetaType = true;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -40,11 +40,11 @@ export default function unifyStatementAgainstMetaType(statementNode, metaTypeNod
|
|
|
40
40
|
assignments = [],
|
|
41
41
|
statementVerified = verifyStatement(statementNode, assignments, derived, localContext);
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
statementUnifiedAgainstMetaType = statementVerified;
|
|
44
44
|
|
|
45
45
|
break;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
return
|
|
49
|
+
return statementUnifiedAgainstMetaType;
|
|
50
50
|
}
|
package/src/utilities/array.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
-
export const { first, second, last, extract, push, match, prune, filter, compress, separate } = arrayUtilities;
|
|
5
|
+
export const { first, second, last, extract, tail, push, match, prune, filter, compress, separate } = arrayUtilities;
|
|
6
6
|
|
|
7
7
|
export function reverse(array) {
|
|
8
8
|
array = [ ///
|
|
@@ -15,7 +15,9 @@ export default function verifyVariableDeclaration(variableDeclarationNode, fileC
|
|
|
15
15
|
|
|
16
16
|
const typeNode = typeNodeQuery(variableDeclarationNode),
|
|
17
17
|
variableNode = variableNodeQuery(variableDeclarationNode),
|
|
18
|
-
typeString =
|
|
18
|
+
typeString = (typeNode === null) ?
|
|
19
|
+
EMPTY_STRING :
|
|
20
|
+
fileContext.nodeAsString(typeNode),
|
|
19
21
|
variableString = fileContext.nodeAsString(variableNode);
|
|
20
22
|
|
|
21
23
|
(typeString === EMPTY_STRING) ?
|
package/src/verify/judgement.js
CHANGED
|
@@ -70,10 +70,10 @@ function verifyDerivedJudgement(judgementNode, assignments, derived, localContex
|
|
|
70
70
|
metaLemmaMetatheorem = (metaLemma || metatheorem); ///
|
|
71
71
|
|
|
72
72
|
if (metaLemmaMetatheorem !== null) {
|
|
73
|
-
const
|
|
74
|
-
|
|
73
|
+
const metaLemmaMetatheoremUnifiedAgainstDeclaration = declaration.unifyMetaLemmaOrMetaTheorem(metaLemmaMetatheorem),
|
|
74
|
+
metaLemmaMetatheoremUnifiedAgainstJudgement = judgement.unifyMetaLemmaOrMetaTheorem(metaLemmaMetatheorem);
|
|
75
75
|
|
|
76
|
-
derivedJudgementVerified = (
|
|
76
|
+
derivedJudgementVerified = (metaLemmaMetatheoremUnifiedAgainstDeclaration && metaLemmaMetatheoremUnifiedAgainstJudgement);
|
|
77
77
|
} else {
|
|
78
78
|
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
79
79
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { nodeQuery } from "../utilities/query";
|
|
4
4
|
import { nameFromMetavariableNode } from "../utilities/name";
|
|
5
|
-
import {
|
|
5
|
+
import { unifyTermAgainstTermType } from "../metavariable";
|
|
6
6
|
|
|
7
7
|
const termNodeQuery = nodeQuery("/metavariable/argument/term"),
|
|
8
8
|
typeNodeQuery = nodeQuery("/metavariable/argument/type");
|
|
@@ -43,9 +43,9 @@ export default function verifyMetavariable(metavariableNode, localContext) {
|
|
|
43
43
|
|
|
44
44
|
localContext.debug(`No term was found when the metavariable's term type is '${termTypeName}'.`, termNode);
|
|
45
45
|
} else {
|
|
46
|
-
const
|
|
46
|
+
const termUnifiedAgainstTermType = unifyTermAgainstTermType(termNode, termType, localContext);
|
|
47
47
|
|
|
48
|
-
metavariableVerified =
|
|
48
|
+
metavariableVerified = termUnifiedAgainstTermType; ///
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -194,13 +194,13 @@ function unifyQualifiedStatementAAgainstReference(qualifiedStatementNode, substi
|
|
|
194
194
|
statementNodeB = statementNode, ///
|
|
195
195
|
substitutionNodeA = null,
|
|
196
196
|
metavariableNodeA = metavariableNode, ///
|
|
197
|
-
|
|
197
|
+
metavariableUnifiedAgainstStatement = unifyMetavariableAgainstStatement(metavariableNodeA, statementNodeB, substitutionNodeA, substitutions, localContextA, localContextB, () => {
|
|
198
198
|
const verifiedAhead = true;
|
|
199
199
|
|
|
200
200
|
return verifiedAhead;
|
|
201
201
|
});
|
|
202
202
|
|
|
203
|
-
qualifiedStatementUnifiedAgainstReference =
|
|
203
|
+
qualifiedStatementUnifiedAgainstReference = metavariableUnifiedAgainstStatement; ///
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
if (qualifiedStatementUnifiedAgainstReference) {
|