occam-verify-cli 0.0.1003 → 0.0.1006
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/README.md +0 -2
- package/bin/abbreviations.js +1 -3
- package/bin/action/help.js +0 -2
- package/bin/action/verify.js +4 -24
- package/bin/defaults.js +0 -2
- package/bin/main.js +3 -4
- package/bin/options.js +0 -2
- package/bin/utilities/releaseContext.js +9 -2
- package/lib/assertion/subproof.js +106 -0
- package/lib/assignment/metavariable.js +2 -2
- package/lib/combinator.js +50 -16
- package/lib/conclusion.js +74 -14
- package/lib/context/file.js +191 -31
- package/lib/context/local.js +37 -49
- package/lib/context/release.js +25 -81
- package/lib/declaration/combinator.js +83 -0
- package/lib/derivation.js +86 -0
- package/lib/equality.js +3 -11
- package/lib/index.js +1 -1
- package/lib/judgement.js +3 -10
- package/lib/label.js +58 -16
- package/lib/log.js +3 -11
- package/lib/metaType.js +31 -19
- package/lib/metavariable.js +39 -12
- package/lib/mixins/statement/qualified/unify.js +118 -0
- package/lib/mixins/statement/unify.js +57 -0
- package/lib/mixins/statement/verify.js +184 -0
- package/lib/node/statement/combinator/bracketed.js +15 -11
- package/lib/ocmbinator/bracketed.js +52 -8
- package/lib/premise.js +109 -55
- package/lib/proof.js +91 -0
- package/lib/proofStep.js +78 -25
- package/lib/reference.js +62 -16
- package/lib/rule.js +146 -26
- package/lib/ruleNames.js +5 -5
- package/lib/statement/qualified.js +127 -0
- package/lib/statement/unqualified.js +89 -0
- package/lib/statement.js +176 -0
- package/lib/subDerivation.js +86 -0
- package/lib/subproof.js +155 -0
- package/lib/substitution/frameForMetavariable.js +14 -15
- package/lib/substitution/statementForMetavariable.js +23 -24
- package/lib/substitution/termForVariable.js +11 -12
- package/lib/substitution.js +9 -2
- package/lib/substitutions.js +14 -14
- package/lib/supposition.js +92 -61
- package/lib/unifier/statementWithCombinator.js +3 -3
- package/lib/unify/metavariableWithFrame.js +2 -2
- package/lib/unify/metavariableWithStatement.js +2 -2
- package/lib/unify/metavariableWithStatementGivenSubstitution.js +2 -2
- package/lib/unify/variableWithTerm.js +2 -2
- package/lib/utilities/node.js +13 -11
- package/lib/utilities/releaseContext.js +5 -6
- package/lib/utilities/string.js +8 -2
- package/lib/utilities/subproof.js +5 -5
- package/lib/utilities/tokens.js +10 -10
- package/lib/variable.js +1 -10
- package/lib/verifier/metaLevel.js +2 -2
- package/lib/verifier/topLevel.js +5 -5
- package/lib/verify/axiom.js +3 -5
- package/lib/verify/conjecture.js +4 -7
- package/lib/verify/consequent.js +2 -3
- package/lib/verify/declaration/combinator.js +2 -14
- package/lib/verify/declaration/metavariable.js +9 -10
- package/lib/verify/files.js +4 -4
- package/lib/verify/frame.js +12 -12
- package/lib/verify/lemma.js +4 -7
- package/lib/verify/metaLemma.js +4 -7
- package/lib/verify/metatheorem.js +4 -7
- package/lib/verify/proofStep.js +2 -31
- package/lib/verify/theorem.js +4 -7
- package/package.json +1 -1
- package/src/assertion/subproof.js +84 -0
- package/src/assignment/metavariable.js +2 -2
- package/src/combinator.js +45 -15
- package/src/conclusion.js +85 -13
- package/src/context/file.js +223 -11
- package/src/context/local.js +12 -16
- package/src/context/release.js +31 -100
- package/src/declaration/combinator.js +44 -0
- package/src/derivation.js +50 -0
- package/src/equality.js +2 -9
- package/src/index.js +0 -1
- package/src/judgement.js +2 -8
- package/src/label.js +56 -13
- package/src/log.js +2 -9
- package/src/metaType.js +26 -14
- package/src/metavariable.js +57 -9
- package/src/mixins/statement/qualified/unify.js +186 -0
- package/src/mixins/statement/unify.js +70 -0
- package/src/mixins/statement/verify.js +274 -0
- package/src/node/statement/combinator/bracketed.js +4 -3
- package/src/ocmbinator/bracketed.js +15 -12
- package/src/premise.js +138 -44
- package/src/proof.js +58 -0
- package/src/proofStep.js +92 -22
- package/src/reference.js +58 -12
- package/src/rule.js +199 -30
- package/src/ruleNames.js +1 -1
- package/src/statement/qualified.js +104 -0
- package/src/statement/unqualified.js +60 -0
- package/src/statement.js +179 -0
- package/src/subDerivation.js +52 -0
- package/src/subproof.js +99 -0
- package/src/substitution/frameForMetavariable.js +20 -17
- package/src/substitution/statementForMetavariable.js +31 -29
- package/src/substitution/termForVariable.js +15 -14
- package/src/substitution.js +8 -0
- package/src/substitutions.js +12 -13
- package/src/supposition.js +96 -51
- package/src/unifier/statementWithCombinator.js +6 -3
- package/src/unify/metavariableWithFrame.js +1 -1
- package/src/unify/metavariableWithStatement.js +1 -1
- package/src/unify/metavariableWithStatementGivenSubstitution.js +1 -1
- package/src/unify/variableWithTerm.js +1 -1
- package/src/utilities/node.js +18 -12
- package/src/utilities/releaseContext.js +5 -8
- package/src/utilities/string.js +6 -2
- package/src/utilities/subproof.js +2 -2
- package/src/utilities/tokens.js +7 -7
- package/src/variable.js +0 -10
- package/src/verifier/metaLevel.js +3 -2
- package/src/verifier/topLevel.js +6 -4
- package/src/verify/axiom.js +1 -2
- package/src/verify/conjecture.js +2 -3
- package/src/verify/consequent.js +1 -1
- package/src/verify/declaration/combinator.js +0 -20
- package/src/verify/declaration/metavariable.js +8 -12
- package/src/verify/files.js +3 -3
- package/src/verify/frame.js +11 -11
- package/src/verify/lemma.js +2 -3
- package/src/verify/metaLemma.js +2 -3
- package/src/verify/metatheorem.js +2 -3
- package/src/verify/proofStep.js +0 -41
- package/src/verify/theorem.js +2 -3
- package/lib/tokens/combinatorStatement/bracketed.js +0 -17
- package/lib/unify/premiseWithProofStep.js +0 -41
- package/lib/unify/premisesWithProofSteps.js +0 -31
- package/lib/unify/qualifiedStatement.js +0 -136
- package/lib/unify/statementWithBracketedCombinator.js +0 -30
- package/lib/unify/statementWithCombinator.js +0 -29
- package/lib/unify/statementWithCombinators.js +0 -31
- package/lib/unify/statementWithMetaType.js +0 -24
- package/lib/verify/conclusion.js +0 -39
- package/lib/verify/derivation.js +0 -31
- package/lib/verify/label.js +0 -37
- package/lib/verify/labels.js +0 -28
- package/lib/verify/premise.js +0 -45
- package/lib/verify/premises.js +0 -28
- package/lib/verify/proof.js +0 -34
- package/lib/verify/rule.js +0 -56
- package/lib/verify/statement/qualified.js +0 -41
- package/lib/verify/statement/unqualified.js +0 -45
- package/lib/verify/statement.js +0 -219
- package/lib/verify/statementAsCombinator.js +0 -33
- package/lib/verify/statementGivenMetaType.js +0 -52
- package/lib/verify/subproof.js +0 -34
- package/lib/verify/supposition.js +0 -45
- package/lib/verify/suppositions.js +0 -28
- package/src/tokens/combinatorStatement/bracketed.js +0 -10
- package/src/unify/premiseWithProofStep.js +0 -54
- package/src/unify/premisesWithProofSteps.js +0 -23
- package/src/unify/qualifiedStatement.js +0 -208
- package/src/unify/statementWithBracketedCombinator.js +0 -22
- package/src/unify/statementWithCombinator.js +0 -22
- package/src/unify/statementWithCombinators.js +0 -23
- package/src/unify/statementWithMetaType.js +0 -14
- package/src/verify/conclusion.js +0 -40
- package/src/verify/derivation.js +0 -23
- package/src/verify/label.js +0 -34
- package/src/verify/labels.js +0 -17
- package/src/verify/premise.js +0 -49
- package/src/verify/premises.js +0 -17
- package/src/verify/proof.js +0 -31
- package/src/verify/rule.js +0 -71
- package/src/verify/statement/qualified.js +0 -40
- package/src/verify/statement/unqualified.js +0 -49
- package/src/verify/statement.js +0 -312
- package/src/verify/statementAsCombinator.js +0 -27
- package/src/verify/statementGivenMetaType.js +0 -52
- package/src/verify/subproof.js +0 -32
- package/src/verify/supposition.js +0 -49
- package/src/verify/suppositions.js +0 -17
package/src/context/local.js
CHANGED
|
@@ -88,8 +88,6 @@ class LocalContext {
|
|
|
88
88
|
return lastProofStep;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
getTokens() { return this.context.getTokens(); }
|
|
92
|
-
|
|
93
91
|
getAxioms() { return this.context.getAxioms(); }
|
|
94
92
|
|
|
95
93
|
getLemmas() { return this.context.getLemmas(); }
|
|
@@ -377,29 +375,29 @@ class LocalContext {
|
|
|
377
375
|
return metavariable;
|
|
378
376
|
}
|
|
379
377
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
findTypeByTypeNode(typeNode) { return this.context.findTypeByTypeNode(typeNode); }
|
|
378
|
+
findMetaTypeByMetaTypeNode(metaTypeNode) { return this.context.findMetaTypeByMetaTypeNode(metaTypeNode); }
|
|
383
379
|
|
|
384
380
|
findLabelByMetavariableNode(metavariableNode) { return this.context.findLabelByMetavariableNode(metavariableNode); }
|
|
385
381
|
|
|
386
|
-
|
|
382
|
+
findMetavariableByMetavariableName(metavariableName) { return this.context.findMetavariableByMetavariableName(metavariableName); }
|
|
383
|
+
|
|
384
|
+
findTypeByTypeName(typeName) { return this.context.findTypeByTypeName(typeName); }
|
|
387
385
|
|
|
388
|
-
|
|
386
|
+
findTypeByTypeNode(typeNode) { return this.context.findTypeByTypeNode(typeNode); }
|
|
389
387
|
|
|
390
|
-
|
|
388
|
+
findRuleByReference(reference) { return this.context.findRuleByReference(reference); }
|
|
391
389
|
|
|
392
|
-
|
|
390
|
+
findAxiomByReference(reference) { return this.context.findAxiomByReference(reference); }
|
|
393
391
|
|
|
394
|
-
|
|
392
|
+
findLemmaByReference(reference) { return this.context.findLemmaByReference(reference); }
|
|
395
393
|
|
|
396
|
-
|
|
394
|
+
findTheoremByReference(reference) { return this.context.findTheoremByReference(reference); }
|
|
397
395
|
|
|
398
|
-
|
|
396
|
+
findMetaLemmaByReference(reference) { return this.context.findMetaLemmaByReference(reference); }
|
|
399
397
|
|
|
400
|
-
|
|
398
|
+
findConjectureByReference(reference) { return this.context.findConjectureByReference(reference); }
|
|
401
399
|
|
|
402
|
-
|
|
400
|
+
findMetatheoremByReference(reference) { return this.context.findMetatheoremByReference(reference); }
|
|
403
401
|
|
|
404
402
|
nodeAsString(node) { return this.context.nodeAsString(node); }
|
|
405
403
|
|
|
@@ -415,8 +413,6 @@ class LocalContext {
|
|
|
415
413
|
|
|
416
414
|
error(message, node) { this.context.error(message, node); }
|
|
417
415
|
|
|
418
|
-
fatal(message, node) { this.context.fatal(node, message); }
|
|
419
|
-
|
|
420
416
|
static fromFileContext(fileContext) {
|
|
421
417
|
const context = fileContext, ///
|
|
422
418
|
variables = [],
|
package/src/context/release.js
CHANGED
|
@@ -10,13 +10,14 @@ import { tail, push, leftDifference } from "../utilities/array";
|
|
|
10
10
|
import { customGrammarFromNameAndEntries, combinedCustomGrammarFromReleaseContexts } from "../utilities/customGrammar";
|
|
11
11
|
|
|
12
12
|
const { isFilePathFlorenceFilePath } = filePathUtilities,
|
|
13
|
-
{
|
|
14
|
-
{
|
|
13
|
+
{ nominalLexerFromCombinedCustomGrammar } = lexersUtilities,
|
|
14
|
+
{ nominalParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
15
15
|
|
|
16
16
|
export default class ReleaseContext {
|
|
17
|
-
constructor(log, name, entries, released, lexer, parser, verified, initialised, fileContexts, customGrammar,
|
|
17
|
+
constructor(log, name, json, entries, released, lexer, parser, verified, initialised, fileContexts, customGrammar, dependencyReleaseContexts) {
|
|
18
18
|
this.log = log;
|
|
19
19
|
this.name = name;
|
|
20
|
+
this.json = json;
|
|
20
21
|
this.entries = entries;
|
|
21
22
|
this.released = released;
|
|
22
23
|
this.lexer = lexer;
|
|
@@ -25,7 +26,6 @@ export default class ReleaseContext {
|
|
|
25
26
|
this.initialised = initialised;
|
|
26
27
|
this.fileContexts = fileContexts;
|
|
27
28
|
this.customGrammar = customGrammar;
|
|
28
|
-
this.loggingDisabled = loggingDisabled;
|
|
29
29
|
this.dependencyReleaseContexts = dependencyReleaseContexts;
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -37,6 +37,10 @@ export default class ReleaseContext {
|
|
|
37
37
|
return this.name;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
getJSON() {
|
|
41
|
+
return this.json;
|
|
42
|
+
}
|
|
43
|
+
|
|
40
44
|
getEntries() {
|
|
41
45
|
return this.entries;
|
|
42
46
|
}
|
|
@@ -69,10 +73,6 @@ export default class ReleaseContext {
|
|
|
69
73
|
return this.customGrammar;
|
|
70
74
|
}
|
|
71
75
|
|
|
72
|
-
isLoggingDisabled() {
|
|
73
|
-
return this.loggingDisabled;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
76
|
getDependencyReleaseContexts() {
|
|
77
77
|
return this.dependencyReleaseContexts;
|
|
78
78
|
}
|
|
@@ -117,10 +117,6 @@ export default class ReleaseContext {
|
|
|
117
117
|
this.customGrammar = customGrammar;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
setLoggingDisabled(loggingDisabled) {
|
|
121
|
-
this.loggingDisabled = loggingDisabled;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
120
|
setDependencyReleaseContexts(dependencyReleaseContexts) {
|
|
125
121
|
this.dependencyReleaseContexts = dependencyReleaseContexts;
|
|
126
122
|
}
|
|
@@ -404,113 +400,49 @@ export default class ReleaseContext {
|
|
|
404
400
|
|
|
405
401
|
matchShortenedVersion(shortenedVersion) { return this.entries.matchShortenedVersion(shortenedVersion); }
|
|
406
402
|
|
|
407
|
-
|
|
408
|
-
const loggingDisabled = true;
|
|
409
|
-
|
|
410
|
-
this.setLoggingDisabled(loggingDisabled);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
enableLogging() {
|
|
414
|
-
const loggingDisabled = false;
|
|
415
|
-
|
|
416
|
-
this.setLoggingDisabled(loggingDisabled);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
trace(message, node = null, tokens = null, filePath = null) {
|
|
420
|
-
if (this.loggingDisabled) {
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
this.log.trace(message, node, tokens, filePath);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
debug(message, node = null, tokens = null, filePath = null) {
|
|
428
|
-
if (this.loggingDisabled) {
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
this.log.debug(message, node, tokens, filePath);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
info(message, node = null, tokens = null, filePath = null) {
|
|
436
|
-
if (this.loggingDisabled) {
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
this.log.info(message, node, tokens, filePath);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
warning(message, node = null, tokens = null, filePath = null) {
|
|
444
|
-
if (this.loggingDisabled) {
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
403
|
+
trace(message, node = null, tokens = null, filePath = null) { this.log.trace(message, node, tokens, filePath); }
|
|
447
404
|
|
|
448
|
-
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
error(message, node = null, tokens = null, filePath = null) {
|
|
452
|
-
if (this.loggingDisabled) {
|
|
453
|
-
return;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
this.log.error(message, node, tokens, filePath);
|
|
457
|
-
}
|
|
405
|
+
debug(message, node = null, tokens = null, filePath = null) { this.log.debug(message, node, tokens, filePath); }
|
|
458
406
|
|
|
459
|
-
|
|
460
|
-
if (this.loggingDisabled) {
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
407
|
+
info(message, node = null, tokens = null, filePath = null) { this.log.info(message, node, tokens, filePath); }
|
|
463
408
|
|
|
464
|
-
|
|
465
|
-
}
|
|
409
|
+
warning(message, node = null, tokens = null, filePath = null) { this.log.warning(message, node, tokens, filePath); }
|
|
466
410
|
|
|
467
|
-
|
|
468
|
-
let initialised;
|
|
411
|
+
error(message, node = null, tokens = null, filePath = null) { this.log.error(message, node, tokens, filePath); }
|
|
469
412
|
|
|
413
|
+
initialise(releaseContexts) {
|
|
470
414
|
const combinedCustomGrammar = combinedCustomGrammarFromReleaseContexts(releaseContexts),
|
|
471
|
-
|
|
472
|
-
|
|
415
|
+
nominalParser = nominalParserFromCombinedCustomGrammar(combinedCustomGrammar),
|
|
416
|
+
nominalLexer = nominalLexerFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
473
417
|
|
|
474
|
-
this.lexer =
|
|
418
|
+
this.lexer = nominalLexer; ///
|
|
475
419
|
|
|
476
|
-
this.parser =
|
|
420
|
+
this.parser = nominalParser; ///
|
|
477
421
|
|
|
478
422
|
this.dependencyReleaseContexts = tail(releaseContexts);
|
|
479
423
|
|
|
480
424
|
if (this.released) {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
initialised = verified; ///
|
|
484
|
-
} else {
|
|
485
|
-
initialised = true;
|
|
425
|
+
debugger
|
|
486
426
|
}
|
|
487
427
|
|
|
488
|
-
this.initialised =
|
|
489
|
-
|
|
490
|
-
return initialised;
|
|
428
|
+
this.initialised = true;
|
|
491
429
|
}
|
|
492
430
|
|
|
493
|
-
verify(
|
|
494
|
-
let verified;
|
|
431
|
+
verify() {
|
|
432
|
+
let verified = false;
|
|
495
433
|
|
|
496
|
-
const releaseContext = this
|
|
434
|
+
const releaseContext = this, ///
|
|
435
|
+
fileContexts = fileContextsFromEntries(this.entries, releaseContext),
|
|
436
|
+
fileContextsVerified = verifyFileContexts(fileContexts, releaseContext);
|
|
497
437
|
|
|
498
|
-
if (
|
|
499
|
-
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
this.fileContexts = fileContextsFromEntries(this.entries, releaseContext);
|
|
503
|
-
|
|
504
|
-
const fileContextsVerified = verifyFileContexts(this.fileContexts, releaseContext);
|
|
438
|
+
if (fileContextsVerified) {
|
|
439
|
+
this.fileContexts = fileContexts;
|
|
505
440
|
|
|
506
|
-
|
|
441
|
+
this.verified = true;
|
|
507
442
|
|
|
508
|
-
|
|
509
|
-
releaseContext.enableLogging();
|
|
443
|
+
verified = true;
|
|
510
444
|
}
|
|
511
445
|
|
|
512
|
-
this.verified = verified;
|
|
513
|
-
|
|
514
446
|
return verified;
|
|
515
447
|
}
|
|
516
448
|
|
|
@@ -525,16 +457,15 @@ export default class ReleaseContext {
|
|
|
525
457
|
return json;
|
|
526
458
|
}
|
|
527
459
|
|
|
528
|
-
static
|
|
460
|
+
static fromLogNameJSONEntriesAndReleased(log, name, json, entries, released) {
|
|
529
461
|
const lexer = null,
|
|
530
462
|
parser = null,
|
|
531
463
|
verified = false,
|
|
532
464
|
initialised = false,
|
|
533
465
|
fileContexts = [],
|
|
534
466
|
customGrammar = customGrammarFromNameAndEntries(name, entries),
|
|
535
|
-
loggingDisabled = false,
|
|
536
467
|
dependencyReleaseContexts = null,
|
|
537
|
-
releaseContext = new ReleaseContext(log, name, entries, released, lexer, parser, verified, initialised, fileContexts, customGrammar,
|
|
468
|
+
releaseContext = new ReleaseContext(log, name, json, entries, released, lexer, parser, verified, initialised, fileContexts, customGrammar, dependencyReleaseContexts);
|
|
538
469
|
|
|
539
470
|
return releaseContext;
|
|
540
471
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Combinator from "../combinator";
|
|
4
|
+
|
|
5
|
+
export default class CombinatorDeclaration {
|
|
6
|
+
constructor(combinator) {
|
|
7
|
+
this.combinator = combinator;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
getCombinator() {
|
|
11
|
+
return this.combinator;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getString() { return this.combinator.getString(); }
|
|
15
|
+
|
|
16
|
+
verify(fileContext) {
|
|
17
|
+
let verified;
|
|
18
|
+
|
|
19
|
+
const ocmbinatorDeclarationString = this.getString(); ///
|
|
20
|
+
|
|
21
|
+
fileContext.trace(`Verifying the '${ocmbinatorDeclarationString}' combinator declaration...`);
|
|
22
|
+
|
|
23
|
+
const combinatorVerified = this.combinator.verify(fileContext);
|
|
24
|
+
|
|
25
|
+
if (combinatorVerified) {
|
|
26
|
+
fileContext.addCombinator(this.combinator);
|
|
27
|
+
|
|
28
|
+
verified = true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (verified) {
|
|
32
|
+
fileContext.debug(`...verified the '${ocmbinatorDeclarationString}' combinator declaration.`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return verified;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static fromCombinatorDeclarationNode(combinatorDeclarationNode, fileContext) {
|
|
39
|
+
const combinator = Combinator.fromCombinatorDeclarationNode(combinatorDeclarationNode, fileContext),
|
|
40
|
+
combinatorDeclaration = new CombinatorDeclaration(combinator);
|
|
41
|
+
|
|
42
|
+
return combinatorDeclaration;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import ProofStep from "./proofStep";
|
|
4
|
+
|
|
5
|
+
import { last } from "./utilities/array";
|
|
6
|
+
import { nodesQuery } from "./utilities/query";
|
|
7
|
+
|
|
8
|
+
const proofStepNodesQuery = nodesQuery("/derivation/proofStep|lastProofStep");
|
|
9
|
+
|
|
10
|
+
export default class Derivation {
|
|
11
|
+
constructor(proofSteps) {
|
|
12
|
+
this.proofSteps = proofSteps;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getProofSteps() {
|
|
16
|
+
return this.proofSteps;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getLastProofStep() {
|
|
20
|
+
const lastProofStep = last(this.proofSteps);
|
|
21
|
+
|
|
22
|
+
return lastProofStep;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
verify(substitutions, localContext) {
|
|
26
|
+
let verified;
|
|
27
|
+
|
|
28
|
+
verified = this.proofSteps.every((proofStep) => { ///
|
|
29
|
+
const proofStepVerified = proofStep.verify(substitutions, localContext);
|
|
30
|
+
|
|
31
|
+
if (proofStepVerified) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return verified;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static fromDerivationNode(derivationNode, fileContext) {
|
|
40
|
+
const proofStepNodes = proofStepNodesQuery(derivationNode),
|
|
41
|
+
proofSteps = proofStepNodes.map((proofStepNode) => {
|
|
42
|
+
const proofStep = ProofStep.fromProofStepNode(proofStepNode, fileContext);
|
|
43
|
+
|
|
44
|
+
return proofStep;
|
|
45
|
+
}),
|
|
46
|
+
derivation = new Derivation(proofSteps);
|
|
47
|
+
|
|
48
|
+
return derivation;
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/equality.js
CHANGED
|
@@ -5,16 +5,11 @@ import equalityUnifier from "./unifier/equality";
|
|
|
5
5
|
import { first, second } from "./utilities/array";
|
|
6
6
|
|
|
7
7
|
export default class Equality {
|
|
8
|
-
constructor(
|
|
9
|
-
this.node = node;
|
|
8
|
+
constructor(leftTerm, rightTerm) {
|
|
10
9
|
this.leftTerm = leftTerm;
|
|
11
10
|
this.rightTerm = rightTerm;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
getNode() {
|
|
15
|
-
return this.node;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
13
|
getLeftTerm() {
|
|
19
14
|
return this.leftTerm;
|
|
20
15
|
}
|
|
@@ -67,9 +62,7 @@ export default class Equality {
|
|
|
67
62
|
leftTermTypeComparableToRightTermType = leftTermType.isComparableTo(rightTermType);
|
|
68
63
|
|
|
69
64
|
if (leftTermTypeComparableToRightTermType) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
equality = new Equality(node, leftTerm, rightTerm);
|
|
65
|
+
equality = new Equality(leftTerm, rightTerm);
|
|
73
66
|
}
|
|
74
67
|
|
|
75
68
|
return equality;
|
package/src/index.js
CHANGED
|
@@ -5,4 +5,3 @@ export { default as verifyRelease } from "./verify/release";
|
|
|
5
5
|
export { default as ReleaseContext } from "./context/release";
|
|
6
6
|
export { default as customGrammarUtilities } from "./utilities/customGrammar";
|
|
7
7
|
export { default as releaseContextUtilities } from "./utilities/releaseContext";
|
|
8
|
-
|
package/src/judgement.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export default class Judgement {
|
|
4
|
-
constructor(
|
|
5
|
-
this.node = node;
|
|
4
|
+
constructor(frame, declaration) {
|
|
6
5
|
this.frame = frame;
|
|
7
6
|
this.declaration = declaration;
|
|
8
7
|
}
|
|
9
8
|
|
|
10
|
-
getNode() {
|
|
11
|
-
return this.node;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
9
|
getFrame() {
|
|
15
10
|
return this.frame;
|
|
16
11
|
}
|
|
@@ -24,8 +19,7 @@ export default class Judgement {
|
|
|
24
19
|
matchMetavariableName(metavariableName) { return this.frame.matchMetavariableName(metavariableName); }
|
|
25
20
|
|
|
26
21
|
static fromJudgementNodeFrameAndDeclaration(judgementNode, frame, declaration) {
|
|
27
|
-
const
|
|
28
|
-
judgement = new Judgement(node, frame, declaration);
|
|
22
|
+
const judgement = new Judgement(frame, declaration);
|
|
29
23
|
|
|
30
24
|
return judgement;
|
|
31
25
|
}
|
package/src/label.js
CHANGED
|
@@ -1,30 +1,73 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import Metavariable from "./metavariable";
|
|
4
|
+
|
|
5
|
+
import { nodeQuery } from "./utilities/query";
|
|
6
|
+
|
|
7
|
+
const metavariableNodeQuery = nodeQuery("//label/metavariable");
|
|
4
8
|
|
|
5
9
|
export default class Label {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
10
|
+
constructor(metavariable) {
|
|
11
|
+
this.metavariable = metavariable;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getMetavariable() {
|
|
15
|
+
return this.metavariable;
|
|
8
16
|
}
|
|
9
17
|
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
getString() { return this.metavariable.getString(); }
|
|
19
|
+
|
|
20
|
+
matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
|
|
21
|
+
|
|
22
|
+
verify(fileContext) {
|
|
23
|
+
let verified = false;
|
|
24
|
+
|
|
25
|
+
const labelString = this.getString(); ///
|
|
26
|
+
|
|
27
|
+
fileContext.trace(`Verifying the '${labelString}' label...`);
|
|
28
|
+
|
|
29
|
+
const metavariableNode = this.metavariable.getNode(),
|
|
30
|
+
labelPresent = fileContext.isLabelPresentByMetavariableNode(metavariableNode);
|
|
31
|
+
|
|
32
|
+
if (labelPresent) {
|
|
33
|
+
fileContext.debug(`The '${labelString}' label is already present.`);
|
|
34
|
+
} else {
|
|
35
|
+
verified = true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (verified) {
|
|
39
|
+
fileContext.debug(`...verified the '${labelString}' label.`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return verified;
|
|
12
43
|
}
|
|
13
44
|
|
|
14
|
-
|
|
15
|
-
const
|
|
45
|
+
toJSON() {
|
|
46
|
+
const metavariableJSON = this.metavariable.toJSON(),
|
|
47
|
+
metavariable = metavariableJSON, ///
|
|
48
|
+
json = {
|
|
49
|
+
metavariable
|
|
50
|
+
};
|
|
16
51
|
|
|
17
|
-
return
|
|
52
|
+
return json;
|
|
18
53
|
}
|
|
19
54
|
|
|
20
|
-
|
|
21
|
-
|
|
55
|
+
static fromJSON(json, fileContext) {
|
|
56
|
+
let { metavariable } = json;
|
|
22
57
|
|
|
23
|
-
|
|
58
|
+
json = metavariable; ///
|
|
59
|
+
|
|
60
|
+
metavariable = Metavariable.fromJSON(json, fileContext);
|
|
61
|
+
|
|
62
|
+
const label = new Label(metavariable);
|
|
63
|
+
|
|
64
|
+
return label;
|
|
24
65
|
}
|
|
25
66
|
|
|
26
|
-
static
|
|
27
|
-
const
|
|
67
|
+
static fromLabelNode(labelNode, fileContext) {
|
|
68
|
+
const metavariableNode = metavariableNodeQuery(labelNode),
|
|
69
|
+
metavariable = Metavariable.fromMetavariableNode(metavariableNode, fileContext),
|
|
70
|
+
label = new Label(metavariable);
|
|
28
71
|
|
|
29
72
|
return label;
|
|
30
73
|
}
|
package/src/log.js
CHANGED
|
@@ -4,7 +4,7 @@ import { levels } from "necessary";
|
|
|
4
4
|
|
|
5
5
|
import { leastLineIndexFromNodeAndTokens, greatestLineIndexFromNodeAndTokens } from "./utilities/message";
|
|
6
6
|
|
|
7
|
-
const { TRACE_LEVEL, DEBUG_LEVEL, INFO_LEVEL, WARNING_LEVEL, ERROR_LEVEL
|
|
7
|
+
const { TRACE_LEVEL, DEBUG_LEVEL, INFO_LEVEL, WARNING_LEVEL, ERROR_LEVEL } = levels;
|
|
8
8
|
|
|
9
9
|
export default class Log {
|
|
10
10
|
constructor(messages, logLevel, follow) {
|
|
@@ -55,20 +55,13 @@ export default class Log {
|
|
|
55
55
|
this.write(level, message, node, tokens, filePath);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
fatal(message, node, tokens, filePath) {
|
|
59
|
-
const level = FATAL_LEVEL;
|
|
60
|
-
|
|
61
|
-
this.write(level, message, node, tokens, filePath);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
58
|
write(level, message, node, tokens, filePath) {
|
|
65
59
|
const levels = [
|
|
66
60
|
TRACE_LEVEL,
|
|
67
61
|
DEBUG_LEVEL,
|
|
68
62
|
INFO_LEVEL,
|
|
69
63
|
WARNING_LEVEL,
|
|
70
|
-
ERROR_LEVEL
|
|
71
|
-
FATAL_LEVEL,
|
|
64
|
+
ERROR_LEVEL
|
|
72
65
|
],
|
|
73
66
|
levelIndex = levels.indexOf(level),
|
|
74
67
|
logLevelIndex = levels.indexOf(this.logLevel);
|
package/src/metaType.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import shim from "./shim";
|
|
4
|
+
|
|
3
5
|
import { metaTypeNameFromMetaTypeNode } from "./utilities/name";
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
class MetaType {
|
|
6
8
|
constructor(name) {
|
|
7
9
|
this.name = name;
|
|
8
10
|
}
|
|
@@ -17,13 +19,6 @@ export default class MetaType {
|
|
|
17
19
|
return equalTo;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
match(metaType) {
|
|
21
|
-
const equalToMetaType = this.isEqualTo(metaType),
|
|
22
|
-
matches = equalToMetaType; ///
|
|
23
|
-
|
|
24
|
-
return matches;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
22
|
matchName(name) {
|
|
28
23
|
const nameMatches = (this.name === name);
|
|
29
24
|
|
|
@@ -44,21 +39,38 @@ export default class MetaType {
|
|
|
44
39
|
return metaTypeNodeMatches;
|
|
45
40
|
}
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
const
|
|
42
|
+
toJSON() {
|
|
43
|
+
const name = this.name,
|
|
44
|
+
json = {
|
|
45
|
+
name
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return json;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static fromJSON(json, fileContext) {
|
|
52
|
+
const { name } = json,
|
|
53
|
+
metaType = new MetaType(name);
|
|
49
54
|
|
|
50
|
-
return
|
|
55
|
+
return metaType;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
static
|
|
54
|
-
const
|
|
58
|
+
static fromMetaTypeNode(metaTypeNode, localContext) {
|
|
59
|
+
const metaTypeName = metaTypeNameFromMetaTypeNode(metaTypeNode),
|
|
60
|
+
name = metaTypeName, ///
|
|
55
61
|
metaType = new MetaType(name);
|
|
56
62
|
|
|
57
63
|
return metaType;
|
|
58
64
|
}
|
|
59
65
|
}
|
|
60
66
|
|
|
61
|
-
|
|
67
|
+
Object.assign(shim, {
|
|
68
|
+
MetaType
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export default MetaType;
|
|
72
|
+
|
|
73
|
+
export function metaTypeFromJSON(json, fileContext) {
|
|
62
74
|
let metaType;
|
|
63
75
|
|
|
64
76
|
const { name } = json;
|