occam-verify-cli 0.0.527 → 0.0.529
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 +4 -0
- package/bin/abbreviations.js +5 -1
- package/bin/action/help.js +4 -0
- package/bin/action/verify.js +35 -13
- package/bin/actions.js +11 -6
- package/bin/defaults.js +4 -0
- package/bin/options.js +4 -0
- package/bin/utilities/releaseContext.js +5 -7
- package/lib/axiom.js +3 -3
- package/lib/axiomLemmaTheoremConjecture.js +5 -5
- package/lib/combinator.js +4 -3
- package/lib/conclusion.js +8 -7
- package/lib/conjecture.js +3 -3
- package/lib/consequence.js +6 -5
- package/lib/constants.js +8 -12
- package/lib/constructor.js +5 -4
- package/lib/context/file.js +13 -35
- package/lib/context/metaproof.js +12 -11
- package/lib/context/proof.js +11 -10
- package/lib/context/release/directory.js +6 -6
- package/lib/context/release/file.js +15 -26
- package/lib/context/release.js +32 -51
- package/lib/equality.js +5 -4
- package/lib/index.js +4 -4
- package/lib/label.js +4 -3
- package/lib/lemma.js +3 -3
- package/lib/log.js +146 -0
- package/lib/matcher.js +14 -23
- package/lib/metaTypeNames.js +13 -0
- package/lib/mixins/logging.js +13 -13
- package/lib/node/metastatement/bracketed.js +16 -0
- package/lib/node/statement/bracketed.js +16 -0
- package/lib/node/statement/combinator/bracketed.js +17 -0
- package/lib/node/statement/combinator/equality.js +17 -0
- package/lib/node/statement/equality.js +16 -0
- package/lib/ocmbinator/bracketed.js +3 -4
- package/lib/ocmbinator/equality.js +3 -4
- package/lib/premise.js +10 -9
- package/lib/rule.js +5 -5
- package/lib/step/metaproof.js +28 -25
- package/lib/step/proof.js +15 -14
- package/lib/substitution/metastatementForMetavariable.js +16 -13
- package/lib/substitution/statementForMetavariable.js +17 -18
- package/lib/substitution/termForVariable.js +8 -18
- package/lib/supposition.js +7 -6
- package/lib/theorem.js +3 -3
- package/lib/type.js +5 -5
- package/lib/utilities/metaproof.js +60 -0
- package/lib/utilities/node.js +56 -0
- package/lib/utilities/proof.js +60 -0
- package/lib/utilities/releaseContext.js +24 -12
- package/lib/utilities/string.js +1 -32
- package/lib/{matcher → verifier}/metastatementForMetavariable/conclusion.js +12 -12
- package/lib/{matcher → verifier}/metastatementForMetavariable/premise.js +12 -12
- package/lib/verifier/metastatementForMetavariable.js +198 -0
- package/lib/{matcher → verifier}/statementForMetavariable/conclusion.js +12 -12
- package/lib/{matcher → verifier}/statementForMetavariable/premise.js +12 -12
- package/lib/verifier/statementForMetavariable.js +203 -0
- package/lib/{matcher → verifier}/termForVariable/consequence.js +12 -12
- package/lib/{matcher → verifier}/termForVariable/supposition.js +12 -12
- package/lib/verifier/termForVariable.js +198 -0
- package/lib/verifier.js +92 -0
- package/lib/verify/assertion/type.js +6 -8
- package/lib/verify/axiom.js +3 -5
- package/lib/verify/conclusion.js +2 -4
- package/lib/verify/conjecture.js +3 -5
- package/lib/verify/consequence.js +2 -4
- package/lib/verify/declaration/combinator.js +1 -3
- package/lib/verify/declaration/constructor.js +1 -3
- package/lib/verify/declaration/topLevel.js +1 -3
- package/lib/verify/declaration/type.js +1 -3
- package/lib/verify/declaration/variable.js +1 -3
- package/lib/verify/derivation.js +1 -5
- package/lib/verify/label.js +1 -3
- package/lib/verify/lemma.js +3 -5
- package/lib/verify/metastatement/qualified.js +2 -4
- package/lib/verify/metastatement/unqualified.js +2 -4
- package/lib/verify/metastatement.js +1 -3
- package/lib/verify/premise.js +2 -4
- package/lib/verify/proof.js +3 -5
- package/lib/verify/rule.js +3 -5
- package/lib/verify/ruleDerivation.js +1 -5
- package/lib/verify/ruleProof.js +3 -5
- package/lib/verify/statement/qualified.js +2 -4
- package/lib/verify/statement/unqualified.js +2 -4
- package/lib/verify/statement.js +14 -17
- package/lib/verify/statementAsCombinator.js +4 -6
- package/lib/verify/supposition.js +2 -4
- package/lib/verify/term.js +4 -10
- package/lib/verify/termAsConstructor.js +6 -9
- package/lib/verify/theorem.js +3 -5
- package/lib/verify/type.js +5 -9
- package/lib/verify/variable.js +5 -9
- package/package.json +1 -1
- package/src/axiom.js +1 -1
- package/src/axiomLemmaTheoremConjecture.js +4 -4
- package/src/combinator.js +3 -3
- package/src/conclusion.js +7 -7
- package/src/conjecture.js +1 -1
- package/src/consequence.js +5 -5
- package/src/constants.js +2 -3
- package/src/constructor.js +4 -4
- package/src/context/file.js +6 -30
- package/src/context/metaproof.js +13 -10
- package/src/context/proof.js +11 -9
- package/src/context/release/directory.js +7 -7
- package/src/context/release/file.js +17 -32
- package/src/context/release.js +23 -32
- package/src/equality.js +6 -8
- package/src/index.js +2 -1
- package/src/label.js +3 -3
- package/src/lemma.js +1 -1
- package/src/log.js +116 -0
- package/src/matcher.js +11 -9
- package/src/metaTypeNames.js +3 -0
- package/src/mixins/logging.js +6 -6
- package/src/node/metastatement/bracketed.js +9 -0
- package/src/node/statement/bracketed.js +9 -0
- package/src/node/statement/combinator/bracketed.js +10 -0
- package/src/node/statement/combinator/equality.js +11 -0
- package/src/node/statement/equality.js +10 -0
- package/src/ocmbinator/bracketed.js +2 -5
- package/src/ocmbinator/equality.js +2 -5
- package/src/premise.js +9 -9
- package/src/rule.js +4 -4
- package/src/step/metaproof.js +32 -29
- package/src/step/proof.js +15 -14
- package/src/substitution/metastatementForMetavariable.js +10 -15
- package/src/substitution/statementForMetavariable.js +12 -24
- package/src/substitution/termForVariable.js +2 -30
- package/src/supposition.js +6 -6
- package/src/theorem.js +1 -1
- package/src/type.js +4 -4
- package/src/utilities/metaproof.js +62 -0
- package/src/utilities/node.js +73 -0
- package/src/utilities/proof.js +62 -0
- package/src/utilities/releaseContext.js +30 -12
- package/src/utilities/string.js +0 -47
- package/src/verifier/metastatementForMetavariable/conclusion.js +9 -0
- package/src/verifier/metastatementForMetavariable/premise.js +9 -0
- package/src/{matcher → verifier}/metastatementForMetavariable.js +2 -2
- package/src/verifier/statementForMetavariable/conclusion.js +9 -0
- package/src/verifier/statementForMetavariable/premise.js +9 -0
- package/src/{matcher → verifier}/statementForMetavariable.js +2 -2
- package/src/verifier/termForVariable/consequence.js +9 -0
- package/src/verifier/termForVariable/supposition.js +9 -0
- package/src/{matcher → verifier}/termForVariable.js +2 -2
- package/src/verifier.js +74 -0
- package/src/verify/assertion/type.js +5 -11
- package/src/verify/axiom.js +2 -8
- package/src/verify/conclusion.js +1 -7
- package/src/verify/conjecture.js +2 -8
- package/src/verify/consequence.js +1 -7
- package/src/verify/declaration/combinator.js +0 -6
- package/src/verify/declaration/constructor.js +0 -6
- package/src/verify/declaration/topLevel.js +0 -6
- package/src/verify/declaration/type.js +0 -6
- package/src/verify/declaration/variable.js +0 -6
- package/src/verify/derivation.js +0 -12
- package/src/verify/label.js +0 -6
- package/src/verify/lemma.js +4 -10
- package/src/verify/metastatement/qualified.js +1 -7
- package/src/verify/metastatement/unqualified.js +1 -7
- package/src/verify/metastatement.js +0 -6
- package/src/verify/premise.js +1 -7
- package/src/verify/proof.js +1 -7
- package/src/verify/rule.js +2 -8
- package/src/verify/ruleDerivation.js +0 -12
- package/src/verify/ruleProof.js +1 -7
- package/src/verify/statement/qualified.js +1 -7
- package/src/verify/statement/unqualified.js +1 -7
- package/src/verify/statement.js +24 -34
- package/src/verify/statementAsCombinator.js +3 -9
- package/src/verify/supposition.js +1 -7
- package/src/verify/term.js +3 -21
- package/src/verify/termAsConstructor.js +5 -13
- package/src/verify/theorem.js +2 -8
- package/src/verify/type.js +4 -13
- package/src/verify/variable.js +4 -13
- package/bin/callbacks.js +0 -48
- package/lib/callbacks.js +0 -75
- package/lib/context/release/combinator.js +0 -64
- package/lib/matcher/metastatementForMetavariable.js +0 -198
- package/lib/matcher/statementForMetavariable.js +0 -203
- package/lib/matcher/termForVariable.js +0 -198
- package/lib/mixins/callbacks.js +0 -27
- package/lib/utilities/substitution.js +0 -60
- package/src/callbacks.js +0 -39
- package/src/context/release/combinator.js +0 -39
- package/src/matcher/metastatementForMetavariable/conclusion.js +0 -9
- package/src/matcher/metastatementForMetavariable/premise.js +0 -9
- package/src/matcher/statementForMetavariable/conclusion.js +0 -9
- package/src/matcher/statementForMetavariable/premise.js +0 -9
- package/src/matcher/termForVariable/consequence.js +0 -9
- package/src/matcher/termForVariable/supposition.js +0 -9
- package/src/mixins/callbacks.js +0 -15
- package/src/utilities/substitution.js +0 -81
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import matcher from "../matcher";
|
|
4
|
+
import bracketedStatementNode from "../node/statement/bracketed";
|
|
5
|
+
|
|
6
|
+
import { nodeQuery } from "../utilities/query";
|
|
7
|
+
import { BRACKETED_STATEMENT_DEPTH } from "../constants";
|
|
8
|
+
|
|
9
|
+
const bracketedStatementChildNodeQuery = nodeQuery('/statement/metaArgument!/statement!');
|
|
10
|
+
|
|
11
|
+
export function matchStatementModuloBrackets(statementNodeA, statementNodeB) {
|
|
12
|
+
let statementMatchesModuloBrackets = false;
|
|
13
|
+
|
|
14
|
+
if (!statementMatchesModuloBrackets) {
|
|
15
|
+
const nodeA = statementNodeA, ///
|
|
16
|
+
nodeB = statementNodeB, ///
|
|
17
|
+
nonTerminalNodeMatches = matcher.matchNode(nodeA, nodeB);
|
|
18
|
+
|
|
19
|
+
statementMatchesModuloBrackets = nonTerminalNodeMatches; ///
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!statementMatchesModuloBrackets) {
|
|
23
|
+
const bracketedStatementChildNodeA = bracketedStatementChildNodeFromStatementNode(statementNodeA);
|
|
24
|
+
|
|
25
|
+
if (bracketedStatementChildNodeA !== null) {
|
|
26
|
+
const nodeA = bracketedStatementChildNodeA, ///
|
|
27
|
+
nodeB = statementNodeB, ///
|
|
28
|
+
nodeMatches = matcher.matchNode(nodeA, nodeB);
|
|
29
|
+
|
|
30
|
+
statementMatchesModuloBrackets = nodeMatches; ///
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!statementMatchesModuloBrackets) {
|
|
35
|
+
const bracketedStatementChildNodeB = bracketedStatementChildNodeFromStatementNode(statementNodeB);
|
|
36
|
+
|
|
37
|
+
if (bracketedStatementChildNodeB !== null) {
|
|
38
|
+
const nodeA = statementNodeA, ///
|
|
39
|
+
nodeB = bracketedStatementChildNodeB, ///
|
|
40
|
+
nodeMatches = matcher.matchNode(nodeA, nodeB);
|
|
41
|
+
|
|
42
|
+
statementMatchesModuloBrackets = nodeMatches; ///
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return statementMatchesModuloBrackets;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function bracketedStatementChildNodeFromStatementNode(statementNode) {
|
|
50
|
+
let bracketedStatementChildNode = null;
|
|
51
|
+
|
|
52
|
+
const nodeA = statementNode, ///
|
|
53
|
+
nodeB = bracketedStatementNode, ///
|
|
54
|
+
depth = BRACKETED_STATEMENT_DEPTH,
|
|
55
|
+
nonTerminalNodeMatches = matcher.matchNode(nodeA, nodeB, depth);
|
|
56
|
+
|
|
57
|
+
if (nonTerminalNodeMatches) {
|
|
58
|
+
bracketedStatementChildNode = bracketedStatementChildNodeQuery(statementNode);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return bracketedStatementChildNode;
|
|
62
|
+
}
|
|
@@ -35,7 +35,7 @@ export function createReleaseContext(dependency, dependentNames, context, callba
|
|
|
35
35
|
|
|
36
36
|
error = checkReleaseMatchesDependency(dependency, dependentNames, releaseContext);
|
|
37
37
|
|
|
38
|
-
if (error
|
|
38
|
+
if (error) {
|
|
39
39
|
callback(error);
|
|
40
40
|
|
|
41
41
|
return;
|
|
@@ -47,19 +47,25 @@ export function createReleaseContext(dependency, dependentNames, context, callba
|
|
|
47
47
|
}, context);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export function initialiseReleaseContext(dependency, dependentName, verified, context) {
|
|
50
|
+
export function initialiseReleaseContext(dependency, dependentName, verified, context, callback) {
|
|
51
|
+
let error = null;
|
|
52
|
+
|
|
51
53
|
const { releaseContextMap } = context,
|
|
52
54
|
dependencyName = dependency.getName(),
|
|
53
55
|
releaseName = dependencyName, ///
|
|
54
56
|
releaseContext = releaseContextMap[releaseName] || null;
|
|
55
57
|
|
|
56
58
|
if (releaseContext === null) {
|
|
59
|
+
callback(error);
|
|
60
|
+
|
|
57
61
|
return;
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
const initialised = releaseContext.isInitialised();
|
|
61
65
|
|
|
62
66
|
if (initialised) {
|
|
67
|
+
callback(error);
|
|
68
|
+
|
|
63
69
|
return;
|
|
64
70
|
}
|
|
65
71
|
|
|
@@ -67,27 +73,39 @@ export function initialiseReleaseContext(dependency, dependentName, verified, co
|
|
|
67
73
|
|
|
68
74
|
if (verified) {
|
|
69
75
|
if (!releaseContextVerified) {
|
|
70
|
-
|
|
76
|
+
error = `Unable to initialise the '${releaseName}' dependency's context because its '${dependentName}' dependent is a package.`;
|
|
71
77
|
|
|
72
|
-
|
|
78
|
+
callback(error);
|
|
73
79
|
|
|
74
80
|
return;
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
|
|
78
|
-
verified = releaseContextVerified; ///
|
|
79
|
-
|
|
80
84
|
dependentName = releaseName; ///
|
|
81
85
|
|
|
86
|
+
verified = releaseContextVerified; ///
|
|
87
|
+
|
|
82
88
|
const dependencies = releaseContext.getDependencies();
|
|
83
89
|
|
|
84
|
-
dependencies.
|
|
85
|
-
initialiseReleaseContext(dependency, dependentName, verified, context)
|
|
86
|
-
|
|
90
|
+
dependencies.asynchronousForEachDependency((dependency, next, done) => {
|
|
91
|
+
initialiseReleaseContext(dependency, dependentName, verified, context, (error) => {
|
|
92
|
+
if (error) {
|
|
93
|
+
callback(error);
|
|
87
94
|
|
|
88
|
-
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
89
97
|
|
|
90
|
-
|
|
98
|
+
next();
|
|
99
|
+
});
|
|
100
|
+
}, done);
|
|
101
|
+
|
|
102
|
+
function done() {
|
|
103
|
+
const dependencyReleaseContexts = retrieveDependencyReleaseContexts(dependency, context);
|
|
104
|
+
|
|
105
|
+
releaseContext.initialise(dependencyReleaseContexts);
|
|
106
|
+
|
|
107
|
+
callback(error);
|
|
108
|
+
}
|
|
91
109
|
}
|
|
92
110
|
|
|
93
111
|
export default {
|
|
@@ -153,7 +171,7 @@ function createDependencyReleaseContexts(dependency, dependentNames, context, ca
|
|
|
153
171
|
dependencies.asynchronousForEachDependency((dependency, next, done) => {
|
|
154
172
|
const error = checkCyclicDependencyExists(dependency, dependentNames);
|
|
155
173
|
|
|
156
|
-
if (error
|
|
174
|
+
if (error) {
|
|
157
175
|
callback(error);
|
|
158
176
|
|
|
159
177
|
return;
|
package/src/utilities/string.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { nodeQuery } from "../utilities/query";
|
|
4
3
|
import { COMMA, EMPTY_STRING } from "../constants";
|
|
5
|
-
import { LABEL_RULE_NAME, UNQUALIFIED_STATEMENT_RULE_NAME, CONSTRUCTOR_DECLARATIONRULE_NAME, UNQUALIFIED_METASTATEMENT_RULE_NAME } from "../ruleNames";
|
|
6
|
-
|
|
7
|
-
const termNodeQuery = nodeQuery("/constructorDeclaration/term!"),
|
|
8
|
-
statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
|
|
9
|
-
metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatement!");
|
|
10
4
|
|
|
11
5
|
export function nodeAsString(node, tokens) {
|
|
12
6
|
let string = null;
|
|
@@ -61,44 +55,3 @@ export function nodesAsString(nodes, tokens) {
|
|
|
61
55
|
return string;
|
|
62
56
|
}
|
|
63
57
|
|
|
64
|
-
export function termNodeFromTermString(termString, releaseContext) {
|
|
65
|
-
const ruleName = CONSTRUCTOR_DECLARATIONRULE_NAME,
|
|
66
|
-
content = `Constructor ${termString}
|
|
67
|
-
`,
|
|
68
|
-
node = releaseContext.nodeFromContentAndRuleName(content, ruleName),
|
|
69
|
-
constructorDeclarationNode = node, ///
|
|
70
|
-
termNode = termNodeQuery(constructorDeclarationNode);
|
|
71
|
-
|
|
72
|
-
return termNode;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function labelNodeFromLabelString(labelString, releaseContext) {
|
|
76
|
-
const content = labelString, ///
|
|
77
|
-
ruleName = LABEL_RULE_NAME,
|
|
78
|
-
node = releaseContext.nodeFromContentAndRuleName(content, ruleName),
|
|
79
|
-
labelNode = node; ///
|
|
80
|
-
|
|
81
|
-
return labelNode;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function statementNodeFromStatementString(statementString, releaseContext) {
|
|
85
|
-
const ruleName = UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
86
|
-
content = `${statementString}
|
|
87
|
-
`,
|
|
88
|
-
node = releaseContext.nodeFromContentAndRuleName(content, ruleName),
|
|
89
|
-
unqualifiedStatementNode = node, ///
|
|
90
|
-
statementNode = statementNodeQuery(unqualifiedStatementNode);
|
|
91
|
-
|
|
92
|
-
return statementNode;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function metastatementNodeFromMetastatementString(metastatementString, releaseContext) {
|
|
96
|
-
const ruleName = UNQUALIFIED_METASTATEMENT_RULE_NAME,
|
|
97
|
-
content = `${metastatementString}
|
|
98
|
-
`,
|
|
99
|
-
node = releaseContext.nodeFromContentAndRuleName(content, ruleName),
|
|
100
|
-
unqualifiedMetastatementNode = node, ///
|
|
101
|
-
metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode);
|
|
102
|
-
|
|
103
|
-
return metastatementNode;
|
|
104
|
-
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MetastatementForMetavariableVerifier from "../../verifier/metastatementForMetavariable";
|
|
4
|
+
|
|
5
|
+
class ConclusionMetastatementForMetavariableVerifier extends MetastatementForMetavariableVerifier {
|
|
6
|
+
static createSubstitutions = false;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const conclusionMetastatementForMetavariableVerifier = new ConclusionMetastatementForMetavariableVerifier();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MetastatementForMetavariableVerifier from "../../verifier/metastatementForMetavariable";
|
|
4
|
+
|
|
5
|
+
class PremiseMetastatementForMetavariableVerifier extends MetastatementForMetavariableVerifier {
|
|
6
|
+
static createSubstitutions = true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const premiseMetastatementForMetavariableVerifier = new PremiseMetastatementForMetavariableVerifier();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import Verifier from "../verifier";
|
|
4
4
|
import MetastatementForMetavariableSubstitution from "../substitution/metastatementForMetavariable";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
@@ -9,7 +9,7 @@ import { metavariableNameFromMetavariableNode } from "../utilities/query";
|
|
|
9
9
|
|
|
10
10
|
const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!');
|
|
11
11
|
|
|
12
|
-
export default class
|
|
12
|
+
export default class MetastatementForMetavariableVerifier extends Verifier {
|
|
13
13
|
matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
|
|
14
14
|
let nonTerminalNodeMatches = false;
|
|
15
15
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import StatementForMetavariableVerifier from "../../verifier/statementForMetavariable";
|
|
4
|
+
|
|
5
|
+
class ConclusionStatementForMetavariableVerifier extends StatementForMetavariableVerifier {
|
|
6
|
+
static createSubstitutions = false;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const conclusionStatementForMetavariableVerifier = new ConclusionStatementForMetavariableVerifier();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import StatementForMetavariableVerifier from "../../verifier/statementForMetavariable";
|
|
4
|
+
|
|
5
|
+
class PremiseStatementForMetavariableVerifier extends StatementForMetavariableVerifier {
|
|
6
|
+
static createSubstitutions = true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const premiseStatementForMetavariableVerifier = new PremiseStatementForMetavariableVerifier();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import Verifier from "../verifier";
|
|
4
4
|
import StatementForMetavariableSubstitution from "../substitution/statementForMetavariable";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
@@ -10,7 +10,7 @@ import { STATEMENT_RULE_NAME, METASTATEMENT_RULE_NAME, META_ARGUMENT_RULE_NAME }
|
|
|
10
10
|
const metavariableNodeQuery = nodeQuery('/metastatement/metavariable!'),
|
|
11
11
|
metaArgumentChildNodeNodeQuery = nodeQuery('/metaArgument/*!');
|
|
12
12
|
|
|
13
|
-
export default class
|
|
13
|
+
export default class StatementForMetavariableVerifier extends Verifier {
|
|
14
14
|
matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
|
|
15
15
|
let nonTerminalNodeMatches = false;
|
|
16
16
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import TermForVariableVerifier from "../../verifier/termForVariable";
|
|
4
|
+
|
|
5
|
+
class ConsequenceTermForVariableVerifier extends TermForVariableVerifier {
|
|
6
|
+
static createSubstitutions = false;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const consequenceTermForVariableVerifier = new ConsequenceTermForVariableVerifier();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import TermForVariableVerifier from "../../verifier/termForVariable";
|
|
4
|
+
|
|
5
|
+
class SuppositionTermForVariableVerifier extends TermForVariableVerifier {
|
|
6
|
+
static createSubstitutions = true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const suppositionTermForVariableVerifier = new SuppositionTermForVariableVerifier();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import Verifier from "../verifier";
|
|
4
4
|
import TermForVariableSubstitution from "../substitution/termForVariable";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
@@ -9,7 +9,7 @@ import { variableNameFromVariableNode } from "../utilities/query";
|
|
|
9
9
|
|
|
10
10
|
const variableNodeQuery = nodeQuery('/term/variable!');
|
|
11
11
|
|
|
12
|
-
export default class
|
|
12
|
+
export default class TermForVariableVerifier extends Verifier {
|
|
13
13
|
matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
|
|
14
14
|
let nonTerminalNodeMatches = false;
|
|
15
15
|
|
package/src/verifier.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export default class Verifier {
|
|
4
|
+
matchNode(nodeA, nodeB, substitutions) {
|
|
5
|
+
let nodeMatches = false;
|
|
6
|
+
|
|
7
|
+
const nodeATerminalNode = nodeA.isTerminalNode(),
|
|
8
|
+
nodeBTerminalNode = nodeB.isTerminalNode();
|
|
9
|
+
|
|
10
|
+
if (nodeATerminalNode === nodeBTerminalNode) {
|
|
11
|
+
if (nodeATerminalNode) {
|
|
12
|
+
const terminalNodeA = nodeA, ///
|
|
13
|
+
terminalNodeB = nodeB, ///
|
|
14
|
+
terminalNodeMatches = this.matchTerminalNode(terminalNodeA, terminalNodeB);
|
|
15
|
+
|
|
16
|
+
nodeMatches = terminalNodeMatches; ///
|
|
17
|
+
} else {
|
|
18
|
+
const nonTerminalNodeA = nodeA, ///
|
|
19
|
+
nonTerminalNodeB = nodeB, ///
|
|
20
|
+
nonTerminalNodeMatches = this.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
|
|
21
|
+
|
|
22
|
+
nodeMatches = nonTerminalNodeMatches; ///
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return nodeMatches;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
matchNodes(nodesA, nodesB, substitutions) {
|
|
30
|
+
let nodesMatch = false;
|
|
31
|
+
|
|
32
|
+
const nodesALength = nodesA.length,
|
|
33
|
+
nodesBLength = nodesB.length;
|
|
34
|
+
|
|
35
|
+
if (nodesALength === nodesBLength) {
|
|
36
|
+
nodesMatch = nodesA.every((nodeA, index) => {
|
|
37
|
+
const nodeB = nodesB[index],
|
|
38
|
+
nodeMatches = this.matchNode(nodeA, nodeB, substitutions);
|
|
39
|
+
|
|
40
|
+
if (nodeMatches) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return nodesMatch;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
matchTerminalNode(terminalNodeA, terminalNodeB, substitutions) {
|
|
50
|
+
const matches = terminalNodeA.match(terminalNodeB),
|
|
51
|
+
terminalNodeMatches = matches; ///
|
|
52
|
+
|
|
53
|
+
return terminalNodeMatches;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
|
|
57
|
+
let nonTerminalNodeMatches = false;
|
|
58
|
+
|
|
59
|
+
const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(), ///
|
|
60
|
+
nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(); ///
|
|
61
|
+
|
|
62
|
+
if (nonTerminalNodeARuleName === nonTerminalNodeBRuleName) {
|
|
63
|
+
const nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
64
|
+
nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
|
|
65
|
+
nodesA = nonTerminalNodeAChildNodes, ///
|
|
66
|
+
nodesB = nonTerminalNodeBChildNodes, ///
|
|
67
|
+
nodesMatch = this.matchNodes(nodesA, nodesB, substitutions);
|
|
68
|
+
|
|
69
|
+
nonTerminalNodeMatches = nodesMatch; ///
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return nonTerminalNodeMatches;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -13,18 +13,16 @@ const termNodeQuery = nodeQuery("/typeAssertion/term"),
|
|
|
13
13
|
export default function verifyTypeAssertion(typeAssertionNode, assertions, derived, proofContext) {
|
|
14
14
|
let typeAssertionVerified = false;
|
|
15
15
|
|
|
16
|
-
proofContext.begin(typeAssertionNode);
|
|
17
|
-
|
|
18
16
|
const typeAssertionString = proofContext.nodeAsString(typeAssertionNode);
|
|
19
17
|
|
|
20
|
-
proofContext.debug(`Verifying the '${typeAssertionString}' type assertion
|
|
18
|
+
proofContext.debug(`Verifying the '${typeAssertionString}' type assertion...`, typeAssertionNode);
|
|
21
19
|
|
|
22
20
|
const typeNode = typeNodeQuery(typeAssertionNode),
|
|
23
21
|
typeName = typeNameFromTypeNode(typeNode),
|
|
24
22
|
typePresent = proofContext.isTypePresentByTypeName(typeName);
|
|
25
23
|
|
|
26
24
|
if (!typePresent) {
|
|
27
|
-
proofContext.error(`The ${typeName} type is not present
|
|
25
|
+
proofContext.error(`The ${typeName} type is not present.`, typeAssertionNode);
|
|
28
26
|
} else {
|
|
29
27
|
if (!typeAssertionVerified) {
|
|
30
28
|
const variableTypeAssertionVerified = verifyVariableTypeAssertion(typeAssertionNode, assertions, derived, proofContext);
|
|
@@ -40,13 +38,9 @@ export default function verifyTypeAssertion(typeAssertionNode, assertions, deriv
|
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
if (typeAssertionVerified) {
|
|
43
|
-
proofContext.info(`Verified the '${typeAssertionString}' statement type assertion
|
|
41
|
+
proofContext.info(`Verified the '${typeAssertionString}' statement type assertion.`, typeAssertionNode);
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
typeAssertionVerified ?
|
|
47
|
-
proofContext.complete(typeAssertionNode) :
|
|
48
|
-
proofContext.halt(typeAssertionNode);
|
|
49
|
-
|
|
50
44
|
return typeAssertionVerified;
|
|
51
45
|
}
|
|
52
46
|
|
|
@@ -75,7 +69,7 @@ function verifyVariableTypeAssertion(typeAssertionNode, assertions, derived, pro
|
|
|
75
69
|
const assertedTypeName = assertedType.getName(),
|
|
76
70
|
variableTypeName = variableType.getName();
|
|
77
71
|
|
|
78
|
-
proofContext.error(`The '${variableName}' variable's '${variableTypeName}' type is not equal to or a sub-type of the '${assertedTypeName}' asserted type
|
|
72
|
+
proofContext.error(`The '${variableName}' variable's '${variableTypeName}' type is not equal to or a sub-type of the '${assertedTypeName}' asserted type.`, typeAssertionNode);
|
|
79
73
|
} else {
|
|
80
74
|
variableTypeAssertionVerified = true;
|
|
81
75
|
}
|
|
@@ -86,7 +80,7 @@ function verifyVariableTypeAssertion(typeAssertionNode, assertions, derived, pro
|
|
|
86
80
|
const assertedTypeName = assertedType.getName(),
|
|
87
81
|
variableTypeName = variableType.getName();
|
|
88
82
|
|
|
89
|
-
proofContext.error(`The '${assertedTypeName}' asserted type is not equal to or a sub-type of the '${variableName}' variable's '${variableTypeName}' type
|
|
83
|
+
proofContext.error(`The '${assertedTypeName}' asserted type is not equal to or a sub-type of the '${variableName}' variable's '${variableTypeName}' type.`, typeAssertionNode);
|
|
90
84
|
} else {
|
|
91
85
|
const type = assertedType, ///
|
|
92
86
|
name = variableName, ///
|
package/src/verify/axiom.js
CHANGED
|
@@ -16,13 +16,11 @@ const labelNodesQuery = nodesQuery("/axiom/label"),
|
|
|
16
16
|
export default function verifyAxiom(axiomNode, fileContext) {
|
|
17
17
|
let axiomVerified = false;
|
|
18
18
|
|
|
19
|
-
fileContext.begin(axiomNode);
|
|
20
|
-
|
|
21
19
|
const labelNodes = labelNodesQuery(axiomNode),
|
|
22
20
|
labelsString = fileContext.nodesAsString(labelNodes),
|
|
23
21
|
proofContext = ProofContext.fromFileContext(fileContext);
|
|
24
22
|
|
|
25
|
-
fileContext.debug(`Verifying the '${labelsString}' axiom
|
|
23
|
+
fileContext.debug(`Verifying the '${labelsString}' axiom...`, axiomNode);
|
|
26
24
|
|
|
27
25
|
const labels = [],
|
|
28
26
|
labelsVerified = verifyLabels(labelNodes, labels, fileContext);
|
|
@@ -56,12 +54,8 @@ export default function verifyAxiom(axiomNode, fileContext) {
|
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
if (axiomVerified) {
|
|
59
|
-
fileContext.info(`Verified the '${labelsString}' axiom
|
|
57
|
+
fileContext.info(`Verified the '${labelsString}' axiom.`, axiomNode);
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
axiomVerified ?
|
|
63
|
-
fileContext.complete(axiomNode) :
|
|
64
|
-
fileContext.complete(axiomNode);
|
|
65
|
-
|
|
66
60
|
return axiomVerified;
|
|
67
61
|
}
|
package/src/verify/conclusion.js
CHANGED
|
@@ -11,11 +11,9 @@ const metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatemen
|
|
|
11
11
|
export default function verifyConclusion(conclusionNode, conclusions, metaproofContext) {
|
|
12
12
|
let conclusionVerified = false;
|
|
13
13
|
|
|
14
|
-
metaproofContext.begin(conclusionNode);
|
|
15
|
-
|
|
16
14
|
const conclusionString = metaproofContext.nodeAsString(conclusionNode);
|
|
17
15
|
|
|
18
|
-
metaproofContext.debug(`Verifying the '${conclusionString}' conclusion
|
|
16
|
+
metaproofContext.debug(`Verifying the '${conclusionString}' conclusion...`, conclusionNode);
|
|
19
17
|
|
|
20
18
|
const derived = false,
|
|
21
19
|
assertions = [],
|
|
@@ -31,9 +29,5 @@ export default function verifyConclusion(conclusionNode, conclusions, metaproofC
|
|
|
31
29
|
conclusionVerified = true;
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
conclusionVerified ?
|
|
35
|
-
metaproofContext.complete(conclusionNode) :
|
|
36
|
-
metaproofContext.halt(conclusionNode);
|
|
37
|
-
|
|
38
32
|
return conclusionVerified;
|
|
39
33
|
}
|
package/src/verify/conjecture.js
CHANGED
|
@@ -18,13 +18,11 @@ const proofNodeQuery = nodeQuery("/conjecture/proof!"),
|
|
|
18
18
|
export default function verifyConjecture(conjectureNode, fileContext) {
|
|
19
19
|
let conjectureVerified = false;
|
|
20
20
|
|
|
21
|
-
fileContext.begin(conjectureNode);
|
|
22
|
-
|
|
23
21
|
const labelNodes = labelNodesQuery(conjectureNode),
|
|
24
22
|
labelsString = fileContext.nodesAsString(labelNodes),
|
|
25
23
|
proofContext = ProofContext.fromFileContext(fileContext);
|
|
26
24
|
|
|
27
|
-
fileContext.debug(`Verifying the '${labelsString}' conjecture
|
|
25
|
+
fileContext.debug(`Verifying the '${labelsString}' conjecture...`, conjectureNode);
|
|
28
26
|
|
|
29
27
|
const labels = [],
|
|
30
28
|
labelsVerified = verifyLabels(labelNodes, labels, fileContext);
|
|
@@ -62,12 +60,8 @@ export default function verifyConjecture(conjectureNode, fileContext) {
|
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
if (conjectureVerified) {
|
|
65
|
-
fileContext.info(`Verified the '${labelsString}' conjecture
|
|
63
|
+
fileContext.info(`Verified the '${labelsString}' conjecture.`, conjectureNode);
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
conjectureVerified ?
|
|
69
|
-
fileContext.complete(conjectureNode) :
|
|
70
|
-
fileContext.complete(conjectureNode);
|
|
71
|
-
|
|
72
66
|
return conjectureVerified;
|
|
73
67
|
}
|
|
@@ -11,11 +11,9 @@ const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
|
|
|
11
11
|
export default function verifyConsequence(consequenceNode, consequences, proofContext) {
|
|
12
12
|
let consequenceVerified = false;
|
|
13
13
|
|
|
14
|
-
proofContext.begin(consequenceNode);
|
|
15
|
-
|
|
16
14
|
const consequenceString = proofContext.nodeAsString(consequenceNode);
|
|
17
15
|
|
|
18
|
-
proofContext.debug(`Verifying the '${consequenceString}' consequence
|
|
16
|
+
proofContext.debug(`Verifying the '${consequenceString}' consequence...`, consequenceNode);
|
|
19
17
|
|
|
20
18
|
const derived = false,
|
|
21
19
|
assertions = [],
|
|
@@ -31,9 +29,5 @@ export default function verifyConsequence(consequenceNode, consequences, proofCo
|
|
|
31
29
|
consequenceVerified = true;
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
consequenceVerified ?
|
|
35
|
-
proofContext.complete(consequenceNode) :
|
|
36
|
-
proofContext.halt(consequenceNode);
|
|
37
|
-
|
|
38
32
|
return consequenceVerified;
|
|
39
33
|
}
|
|
@@ -9,16 +9,10 @@ const statementNodeQuery = nodeQuery("/combinatorDeclaration/statement");
|
|
|
9
9
|
export default function verifyCombinatorDeclaration(combinatorDeclarationNode, fileContext) {
|
|
10
10
|
let combinatorDeclarationVerified;
|
|
11
11
|
|
|
12
|
-
fileContext.begin(combinatorDeclarationNode);
|
|
13
|
-
|
|
14
12
|
const statementNode = statementNodeQuery(combinatorDeclarationNode),
|
|
15
13
|
statementVerifiedAsCombinator = verifyStatementAsCombinator(statementNode, fileContext);
|
|
16
14
|
|
|
17
15
|
combinatorDeclarationVerified = statementVerifiedAsCombinator; ///
|
|
18
16
|
|
|
19
|
-
combinatorDeclarationVerified ?
|
|
20
|
-
fileContext.complete(combinatorDeclarationNode) :
|
|
21
|
-
fileContext.halt(combinatorDeclarationNode);
|
|
22
|
-
|
|
23
17
|
return combinatorDeclarationVerified;
|
|
24
18
|
}
|
|
@@ -10,17 +10,11 @@ const termNodeQuery = nodeQuery("/constructorDeclaration/term"),
|
|
|
10
10
|
export default function verifyConstructorDeclaration(constructorDeclarationNode, fileContext) {
|
|
11
11
|
let constructorDeclarationVerified;
|
|
12
12
|
|
|
13
|
-
fileContext.begin(constructorDeclarationNode);
|
|
14
|
-
|
|
15
13
|
const termNode = termNodeQuery(constructorDeclarationNode),
|
|
16
14
|
typeNode = typeNodeQuery(constructorDeclarationNode),
|
|
17
15
|
termVerifiedAsConstructor = verifyTermAsConstructor(termNode, typeNode, fileContext);
|
|
18
16
|
|
|
19
17
|
constructorDeclarationVerified = termVerifiedAsConstructor; ///
|
|
20
18
|
|
|
21
|
-
constructorDeclarationVerified ?
|
|
22
|
-
fileContext.complete(constructorDeclarationNode) :
|
|
23
|
-
fileContext.halt(constructorDeclarationNode);
|
|
24
|
-
|
|
25
19
|
return constructorDeclarationVerified;
|
|
26
20
|
}
|
|
@@ -25,8 +25,6 @@ const ruleNodeQuery = nodeQuery("/topLevelDeclaration/rule!"),
|
|
|
25
25
|
export default function verifyTopLevelDeclaration(topLevelDeclarationNode, fileContext) {
|
|
26
26
|
let topLevelDeclarationVerified = false;
|
|
27
27
|
|
|
28
|
-
fileContext.begin(topLevelDeclarationNode);
|
|
29
|
-
|
|
30
28
|
const node = topLevelDeclarationNode, ///
|
|
31
29
|
ruleNode = ruleNodeQuery(node),
|
|
32
30
|
axiomNode = axiomNodeQuery(node),
|
|
@@ -78,9 +76,5 @@ export default function verifyTopLevelDeclaration(topLevelDeclarationNode, fileC
|
|
|
78
76
|
topLevelDeclarationVerified = constructorDeclarationVerified; ///
|
|
79
77
|
}
|
|
80
78
|
|
|
81
|
-
topLevelDeclarationVerified ?
|
|
82
|
-
fileContext.complete(topLevelDeclarationNode) :
|
|
83
|
-
fileContext.halt(topLevelDeclarationNode);
|
|
84
|
-
|
|
85
79
|
return topLevelDeclarationVerified;
|
|
86
80
|
}
|
|
@@ -10,8 +10,6 @@ const firstTypeNodeQuery = nodeQuery("/typeDeclaration/type[0]"),
|
|
|
10
10
|
export default function verifyTypeDeclaration(typeDeclarationNode, fileContext) {
|
|
11
11
|
let typeDeclarationVerified;
|
|
12
12
|
|
|
13
|
-
fileContext.begin(typeDeclarationNode);
|
|
14
|
-
|
|
15
13
|
const firstTypeNode = firstTypeNodeQuery(typeDeclarationNode),
|
|
16
14
|
secondTypeNode = secondTypeNodeQuery(typeDeclarationNode),
|
|
17
15
|
typeNode = firstTypeNode, ///
|
|
@@ -21,9 +19,5 @@ export default function verifyTypeDeclaration(typeDeclarationNode, fileContext)
|
|
|
21
19
|
|
|
22
20
|
typeDeclarationVerified = typeVerified; ///
|
|
23
21
|
|
|
24
|
-
typeDeclarationVerified ?
|
|
25
|
-
fileContext.complete(typeDeclarationNode) :
|
|
26
|
-
fileContext.halt(typeDeclarationNode);
|
|
27
|
-
|
|
28
22
|
return typeDeclarationVerified;
|
|
29
23
|
}
|
|
@@ -10,17 +10,11 @@ const typeNodeQuery = nodeQuery("/variableDeclaration/type"),
|
|
|
10
10
|
export default function verifyVariableDeclaration(variableDeclarationNode, fileContext) {
|
|
11
11
|
let variableDeclarationVerified;
|
|
12
12
|
|
|
13
|
-
fileContext.begin(variableDeclarationNode);
|
|
14
|
-
|
|
15
13
|
const typeNode = typeNodeQuery(variableDeclarationNode),
|
|
16
14
|
variableNode = variableNodeQuery(variableDeclarationNode),
|
|
17
15
|
variableVVerified = verifyVariable(variableNode, typeNode, fileContext);
|
|
18
16
|
|
|
19
17
|
variableDeclarationVerified = variableVVerified; ///
|
|
20
18
|
|
|
21
|
-
variableDeclarationVerified ?
|
|
22
|
-
fileContext.complete(variableDeclarationNode) :
|
|
23
|
-
fileContext.halt(variableDeclarationNode);
|
|
24
|
-
|
|
25
19
|
return variableDeclarationVerified;
|
|
26
20
|
}
|