occam-verify-cli 0.0.262
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 +7 -0
- package/bin/abbreviations.js +11 -0
- package/bin/antecedent.js +19 -0
- package/bin/axiom.js +52 -0
- package/bin/combinator.js +27 -0
- package/bin/conclusion.js +19 -0
- package/bin/consequent.js +19 -0
- package/bin/constants.js +9 -0
- package/bin/constructor.js +43 -0
- package/bin/context/file.js +257 -0
- package/bin/context/metaproof.js +90 -0
- package/bin/context/package/fileSystem.js +111 -0
- package/bin/context/package.js +221 -0
- package/bin/context/proof.js +93 -0
- package/bin/fileNames.js +17 -0
- package/bin/loadPackageContexts.js +53 -0
- package/bin/main.js +25 -0
- package/bin/metaAntecedent.js +19 -0
- package/bin/metaConsequent.js +19 -0
- package/bin/metaSubstitution.js +24 -0
- package/bin/options.js +9 -0
- package/bin/premise.js +19 -0
- package/bin/rule.js +64 -0
- package/bin/ruleNames.js +19 -0
- package/bin/type.js +120 -0
- package/bin/utilities/array.js +97 -0
- package/bin/utilities/fileSystem.js +97 -0
- package/bin/utilities/query.js +92 -0
- package/bin/utilities/rule.js +279 -0
- package/bin/utilities/string.js +51 -0
- package/bin/variable.js +54 -0
- package/bin/verify/antecedent.js +35 -0
- package/bin/verify/axiom/IndicativeConditional.js +54 -0
- package/bin/verify/axiom/unqualifiedStatement.js +40 -0
- package/bin/verify/axiom.js +37 -0
- package/bin/verify/conclusion.js +32 -0
- package/bin/verify/consequent.js +32 -0
- package/bin/verify/declaration/combinator.js +17 -0
- package/bin/verify/declaration/constructor.js +19 -0
- package/bin/verify/declaration/topLevel.js +61 -0
- package/bin/verify/declaration/type.js +21 -0
- package/bin/verify/declaration/variable.js +19 -0
- package/bin/verify/equality.js +52 -0
- package/bin/verify/file.js +43 -0
- package/bin/verify/files.js +46 -0
- package/bin/verify/label.js +27 -0
- package/bin/verify/labels.js +17 -0
- package/bin/verify/metaAntecedent.js +35 -0
- package/bin/verify/metaConsequent.js +32 -0
- package/bin/verify/metaDerivation.js +105 -0
- package/bin/verify/metaproof.js +46 -0
- package/bin/verify/metastatement/qualified.js +43 -0
- package/bin/verify/metastatement/unqualified.js +40 -0
- package/bin/verify/package.js +81 -0
- package/bin/verify/premise.js +35 -0
- package/bin/verify/rule/inferenceConditional.js +54 -0
- package/bin/verify/rule/unqualifiedMetastatement.js +40 -0
- package/bin/verify/rule.js +61 -0
- package/bin/verify/statement/qualified.js +17 -0
- package/bin/verify/statement/unqualified.js +27 -0
- package/bin/verify/statement.js +47 -0
- package/bin/verify/statementAsCombinator.js +140 -0
- package/bin/verify/term.js +183 -0
- package/bin/verify/termAsConstructor.js +173 -0
- package/bin/verify/termAsVariable.js +41 -0
- package/bin/verify/type.js +53 -0
- package/bin/verify/typeAssertion.js +69 -0
- package/bin/verify/variable.js +55 -0
- package/index.js +9 -0
- package/license.txt +48 -0
- package/package.json +24 -0
- package/verify.js +13 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { CustomGrammar, lexersUtilities, parsersUtilities, CombinedCustomGrammar } = require("occam-custom-grammars");
|
|
4
|
+
|
|
5
|
+
const { push } = require("../utilities/array");
|
|
6
|
+
|
|
7
|
+
const { florenceLexerFromCombinedCustomGrammar } = lexersUtilities,
|
|
8
|
+
{ florenceParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
9
|
+
|
|
10
|
+
class PackageContext {
|
|
11
|
+
constructor(packageName, fileContexts, florenceLexer, florenceParser, packageContexts, packageVerified) {
|
|
12
|
+
this.packageName = packageName;
|
|
13
|
+
this.fileContexts = fileContexts;
|
|
14
|
+
this.florenceLexer = florenceLexer;
|
|
15
|
+
this.florenceParser = florenceParser;
|
|
16
|
+
this.packageContexts = packageContexts;
|
|
17
|
+
this.packageVerified = packageVerified;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getPackageName() {
|
|
21
|
+
return this.packageName;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getFileContexts() {
|
|
25
|
+
return this.fileContexts;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getFlorenceLexer() {
|
|
29
|
+
return this.florenceLexer;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getFlorenceParser() {
|
|
33
|
+
return this.florenceParser;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getPackageContexts() {
|
|
37
|
+
return this.packageContexts;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
isPackageVerified() {
|
|
41
|
+
return this.packageVerified;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getRules(packageNames = []) {
|
|
45
|
+
const rules = [],
|
|
46
|
+
packageNamesIncludesPackageName = packageNames.includes(this.packageName);
|
|
47
|
+
|
|
48
|
+
if (!packageNamesIncludesPackageName) {
|
|
49
|
+
packageNames.push(this.packageName);
|
|
50
|
+
|
|
51
|
+
const bubble = false;
|
|
52
|
+
|
|
53
|
+
this.fileContexts.forEach((fileContext) => {
|
|
54
|
+
const fileContextRules = fileContext.getRules(bubble);
|
|
55
|
+
|
|
56
|
+
push(rules, fileContextRules);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
this.packageContexts.forEach((packageContext) => {
|
|
60
|
+
const packageContextRules = packageContext.getRules(packageNames);
|
|
61
|
+
|
|
62
|
+
push(rules, packageContextRules);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return rules;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
getTypes(packageNames = []) {
|
|
70
|
+
const types = [],
|
|
71
|
+
packageNamesIncludesPackageName = packageNames.includes(this.packageName);
|
|
72
|
+
|
|
73
|
+
if (!packageNamesIncludesPackageName) {
|
|
74
|
+
packageNames.push(this.packageName);
|
|
75
|
+
|
|
76
|
+
const bubble = false;
|
|
77
|
+
|
|
78
|
+
this.fileContexts.forEach((fileContext) => {
|
|
79
|
+
const fileContextTypes = fileContext.getTypes(bubble);
|
|
80
|
+
|
|
81
|
+
push(types, fileContextTypes);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
this.packageContexts.forEach((packageContext) => {
|
|
85
|
+
const packageContextTypes = packageContext.getTypes(packageNames);
|
|
86
|
+
|
|
87
|
+
push(types, packageContextTypes);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return types;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
getAxioms(packageNames = []) {
|
|
95
|
+
const axioms = [],
|
|
96
|
+
packageNamesIncludesPackageName = packageNames.includes(this.packageName);
|
|
97
|
+
|
|
98
|
+
if (!packageNamesIncludesPackageName) {
|
|
99
|
+
packageNames.push(this.packageName);
|
|
100
|
+
|
|
101
|
+
const bubble = false;
|
|
102
|
+
|
|
103
|
+
this.fileContexts.forEach((fileContext) => {
|
|
104
|
+
const fileContextAxioms = fileContext.getAxioms(bubble);
|
|
105
|
+
|
|
106
|
+
push(axioms, fileContextAxioms);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
this.packageContexts.forEach((packageContext) => {
|
|
110
|
+
const packageContextAxioms = packageContext.getAxioms(packageNames);
|
|
111
|
+
|
|
112
|
+
push(axioms, packageContextAxioms);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return axioms;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
getCombinators(packageNames = []) {
|
|
120
|
+
const combinators = [],
|
|
121
|
+
packageNamesIncludesPackageName = packageNames.includes(this.packageName);
|
|
122
|
+
|
|
123
|
+
if (!packageNamesIncludesPackageName) {
|
|
124
|
+
packageNames.push(this.packageName);
|
|
125
|
+
|
|
126
|
+
const bubble = false;
|
|
127
|
+
|
|
128
|
+
this.fileContexts.forEach((fileContext) => {
|
|
129
|
+
const fileContextCombinators = fileContext.getCombinators(bubble);
|
|
130
|
+
|
|
131
|
+
push(combinators, fileContextCombinators);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
this.packageContexts.forEach((packageContext) => {
|
|
135
|
+
const packageContextCombinators = packageContext.getCombinators(packageNames);
|
|
136
|
+
|
|
137
|
+
push(combinators, packageContextCombinators);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return combinators;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
getConstructors(packageNames = []) {
|
|
145
|
+
const constructors = [],
|
|
146
|
+
packageNamesIncludesPackageName = packageNames.includes(this.packageName);
|
|
147
|
+
|
|
148
|
+
if (!packageNamesIncludesPackageName) {
|
|
149
|
+
packageNames.push(this.packageName);
|
|
150
|
+
|
|
151
|
+
const bubble = false;
|
|
152
|
+
|
|
153
|
+
this.fileContexts.forEach((fileContext) => {
|
|
154
|
+
const fileContextConstructors = fileContext.getConstructors(bubble);
|
|
155
|
+
|
|
156
|
+
push(constructors, fileContextConstructors);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
this.packageContexts.forEach((packageContext) => {
|
|
160
|
+
const packageContextConstructors = packageContext.getConstructors(packageNames);
|
|
161
|
+
|
|
162
|
+
push(constructors, packageContextConstructors);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return constructors;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
getCustomGrammar() {
|
|
170
|
+
const name = this.packageName, ///
|
|
171
|
+
termBNF = this.getTermBNF(),
|
|
172
|
+
statementBNF = this.getStatementBNF(),
|
|
173
|
+
metastatementBNF = this.getMetastatementBNF(),
|
|
174
|
+
typePattern = this.getTypePattern(),
|
|
175
|
+
symbolPattern = this.getSymbolPattern(),
|
|
176
|
+
operatorPattern = this.getOperatorPattern(),
|
|
177
|
+
customGrammar = new CustomGrammar(name, termBNF, statementBNF, metastatementBNF, typePattern, symbolPattern, operatorPattern);
|
|
178
|
+
|
|
179
|
+
return customGrammar;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
addFileContext(fileContext) {
|
|
183
|
+
this.fileContexts.push(fileContext);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
tokenise(content) { return this.florenceLexer.tokenise(content); }
|
|
187
|
+
|
|
188
|
+
parse(tokens) { return this.florenceParser.parse(tokens); }
|
|
189
|
+
|
|
190
|
+
initialise(packageContexts, dependencyPackageContexts) {
|
|
191
|
+
this.packageContexts = packageContexts;
|
|
192
|
+
|
|
193
|
+
const packageContext = this; ///
|
|
194
|
+
|
|
195
|
+
packageContexts = [ packageContext, ...dependencyPackageContexts ]; ///
|
|
196
|
+
|
|
197
|
+
const customGrammars = packageContexts.map((packageContext) => {
|
|
198
|
+
const customGrammar = packageContext.getCustomGrammar();
|
|
199
|
+
|
|
200
|
+
return customGrammar;
|
|
201
|
+
}),
|
|
202
|
+
combinedCustomGrammar = CombinedCustomGrammar.fromCustomGrammars(customGrammars);
|
|
203
|
+
|
|
204
|
+
this.florenceLexer = florenceLexerFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
205
|
+
|
|
206
|
+
this.florenceParser = florenceParserFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
static fromPackageName(Class, packageName, ...remainingArguments) {
|
|
210
|
+
const fileContexts = [],
|
|
211
|
+
florenceLexer = null,
|
|
212
|
+
florenceParser = null,
|
|
213
|
+
packageContexts = [],
|
|
214
|
+
packageVerified = false,
|
|
215
|
+
packageContext = new Class(packageName, fileContexts, florenceLexer, florenceParser, packageContexts, packageVerified, ...remainingArguments);
|
|
216
|
+
|
|
217
|
+
return packageContext;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
module.exports = PackageContext;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class ProofContext {
|
|
4
|
+
constructor(context, derived, variables, statementNodes) {
|
|
5
|
+
this.context = context;
|
|
6
|
+
this.derived = derived;
|
|
7
|
+
this.variables = variables;
|
|
8
|
+
this.statementNodes = statementNodes;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
getContext() {
|
|
12
|
+
return this.context;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
isDerived() {
|
|
16
|
+
return this.derived;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getVariables() {
|
|
20
|
+
return this.variables;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getStatementNodes() {
|
|
24
|
+
return this.statementNodes;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getRules() { return this.context.getRules(); }
|
|
28
|
+
|
|
29
|
+
getTypes() { return this.context.getTypes(); }
|
|
30
|
+
|
|
31
|
+
getAxioms() { return this.context.getAxioms(); }
|
|
32
|
+
|
|
33
|
+
getCombinators() { return this.context.getCombinators(); }
|
|
34
|
+
|
|
35
|
+
getConstructors() { return this.context.getConstructors(); }
|
|
36
|
+
|
|
37
|
+
findTypeByTypeName(typeName) { return this.context.findTypeByTypeName(typeName); }
|
|
38
|
+
|
|
39
|
+
findRuleByReferenceName(referenceName) { return this.context.findRuleByReferenceName(referenceName); }
|
|
40
|
+
|
|
41
|
+
findVariableByVariableName(variableName) {
|
|
42
|
+
const name = variableName, ///
|
|
43
|
+
variable = this.variables.find((variable) => {
|
|
44
|
+
const matches = variable.matchName(name);
|
|
45
|
+
|
|
46
|
+
if (matches) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
}) || this.context.findVariableByVariableName(variableName); ///
|
|
50
|
+
|
|
51
|
+
return variable;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
isLabelPresent(label) { return this.context.isLabelPresent(label); }
|
|
55
|
+
|
|
56
|
+
isTypePresentByTypeName(typeName) { return this.context.isTypePresentByTypeName(typeName); }
|
|
57
|
+
|
|
58
|
+
isVariablePresentByVariableName(variableName) {
|
|
59
|
+
const variable = this.findVariableByVariableName(variableName),
|
|
60
|
+
variablePresent = (variable !== null);
|
|
61
|
+
|
|
62
|
+
return variablePresent;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
setDerived(derived) {
|
|
66
|
+
if (derived) {
|
|
67
|
+
this.statementNodes.pop();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this.derived = derived;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
addAxiom(axiom) { this.context.addAxiom(axiom); }
|
|
74
|
+
|
|
75
|
+
addVariable(variable) {
|
|
76
|
+
this.variables.push(variable);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
addStatementNode(statementNode) {
|
|
80
|
+
this.statementNodes.push(statementNode);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static fromContext(context) {
|
|
84
|
+
const derived = false,
|
|
85
|
+
variables = [],
|
|
86
|
+
statementNodes = [],
|
|
87
|
+
proofContext = new ProofContext(context, derived, variables, statementNodes);
|
|
88
|
+
|
|
89
|
+
return proofContext;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
module.exports = ProofContext;
|
package/bin/fileNames.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const TERM_BNF_FILE_NAME = "term.bnf";
|
|
4
|
+
const STATEMENT_BNF_FILE_NAME = "statement.bnf";
|
|
5
|
+
const METASTATEMENT_BNF_FILE_NAME = "metastatement.bnf";
|
|
6
|
+
const TYPE_PATTERN_FILE_NAME = "type.ptn";
|
|
7
|
+
const SYMBOL_PATTERN_FILE_NAME = "symbol.ptn";
|
|
8
|
+
const OPERATOR_PATTERN_FILE_NAME = "operator.ptn";
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
TERM_BNF_FILE_NAME,
|
|
12
|
+
STATEMENT_BNF_FILE_NAME,
|
|
13
|
+
METASTATEMENT_BNF_FILE_NAME,
|
|
14
|
+
TYPE_PATTERN_FILE_NAME,
|
|
15
|
+
SYMBOL_PATTERN_FILE_NAME,
|
|
16
|
+
OPERATOR_PATTERN_FILE_NAME
|
|
17
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { loggingUtilities } = require("necessary");
|
|
4
|
+
|
|
5
|
+
const FileSystemPackageContext = require("./context/package/fileSystem");
|
|
6
|
+
|
|
7
|
+
const { first } = require("./utilities/array");
|
|
8
|
+
|
|
9
|
+
const { log } = loggingUtilities;
|
|
10
|
+
|
|
11
|
+
function loadPackageContexts(packageName, packageContextMap = {}, dependentPackageNames = []) {
|
|
12
|
+
const cyclicDependencyExists = checkCyclicDependencyExists(packageName, dependentPackageNames);
|
|
13
|
+
|
|
14
|
+
if (!cyclicDependencyExists) {
|
|
15
|
+
const packageContext = packageContextMap[packageName] || null;
|
|
16
|
+
|
|
17
|
+
if (packageContext === null) {
|
|
18
|
+
const fileSystemPackageContext = FileSystemPackageContext.fromPackageName(packageName),
|
|
19
|
+
packageContext = fileSystemPackageContext; ///
|
|
20
|
+
|
|
21
|
+
packageContextMap[packageName] = packageContext;
|
|
22
|
+
|
|
23
|
+
const dependencyPackageNames = packageContext.getDependencyPackageNames(packageName);
|
|
24
|
+
|
|
25
|
+
dependentPackageNames = [ ...dependentPackageNames, packageName ]; ///
|
|
26
|
+
|
|
27
|
+
dependencyPackageNames.forEach((dependencyPackageName) => {
|
|
28
|
+
const packageName = dependencyPackageName; ///
|
|
29
|
+
|
|
30
|
+
loadPackageContexts(packageName, packageContextMap, dependentPackageNames);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return packageContextMap;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = loadPackageContexts;
|
|
39
|
+
|
|
40
|
+
function checkCyclicDependencyExists(packageName, dependentPackageNames) {
|
|
41
|
+
const dependentPackageNamesIncludesPackageName = dependentPackageNames.includes(packageName),
|
|
42
|
+
cyclicDependencyExists = dependentPackageNamesIncludesPackageName; ///
|
|
43
|
+
|
|
44
|
+
if (cyclicDependencyExists) {
|
|
45
|
+
const firstDependentPackageName = first(dependentPackageNames),
|
|
46
|
+
packageNames = dependentPackageNames.concat(firstDependentPackageName),
|
|
47
|
+
packageNamesString = packageNames.join(`' -> '`);
|
|
48
|
+
|
|
49
|
+
log.error(`There is a cyclic dependency: '${packageNamesString}'.`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return cyclicDependencyExists;
|
|
53
|
+
}
|
package/bin/main.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { loggingUtilities } = require("necessary");
|
|
4
|
+
|
|
5
|
+
const verifyPackage = require("./verify/package"),
|
|
6
|
+
loadPackageContexts = require("./loadPackageContexts");
|
|
7
|
+
|
|
8
|
+
const { first } = require("./utilities/array");
|
|
9
|
+
|
|
10
|
+
const { log } = loggingUtilities;
|
|
11
|
+
|
|
12
|
+
function main(commands, options) {
|
|
13
|
+
const firstCommand = first(commands),
|
|
14
|
+
{ logLevel = null, packageName = firstCommand } = options; ///
|
|
15
|
+
|
|
16
|
+
if (logLevel !== null) {
|
|
17
|
+
log.setLogLevel(logLevel);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const packageContextMap = loadPackageContexts(packageName);
|
|
21
|
+
|
|
22
|
+
verifyPackage(packageName, packageContextMap);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = main;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class MetaAntecedent {
|
|
4
|
+
constructor(metastatementNodes) {
|
|
5
|
+
this.metastatementNodes = metastatementNodes;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
getMetastatementNodes() {
|
|
9
|
+
return this.metastatementNodes;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static fromMetastatementNodes(metastatementNodes) {
|
|
13
|
+
const metaAntecedent = new MetaAntecedent(metastatementNodes);
|
|
14
|
+
|
|
15
|
+
return metaAntecedent;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = MetaAntecedent;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class MetaConsequent {
|
|
4
|
+
constructor(metastatementNode) {
|
|
5
|
+
this.metastatementNode = metastatementNode;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
getMetastatementNode() {
|
|
9
|
+
return this.metastatementNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static fromStatementNode(metastatementNode) {
|
|
13
|
+
const metaConsequent = new MetaConsequent(metastatementNode);
|
|
14
|
+
|
|
15
|
+
return metaConsequent;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = MetaConsequent;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class MetaSubstitution {
|
|
4
|
+
constructor(metavariableName, nonTerminalNode) {
|
|
5
|
+
this.metavariableName = metavariableName;
|
|
6
|
+
this.nonTerminalNode = nonTerminalNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
getMetavariableName() {
|
|
10
|
+
return this.metavariableName;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getNonTerminalNode() {
|
|
14
|
+
return this.nonTerminalNode;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static fromMetavariableNameAndNonTerminalNode(metavariableName, nonTerminalNode) {
|
|
18
|
+
const metaSubstitution = new MetaSubstitution(metavariableName, nonTerminalNode);
|
|
19
|
+
|
|
20
|
+
return metaSubstitution;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = MetaSubstitution;
|
package/bin/options.js
ADDED
package/bin/premise.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class Premise {
|
|
4
|
+
constructor(metastatementNodes) {
|
|
5
|
+
this.metastatementNodes = metastatementNodes;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
getMetastatementNodes() {
|
|
9
|
+
return this.metastatementNodes;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static fromMetastatementNodes(metastatementNodes) {
|
|
13
|
+
const premise = new Premise(metastatementNodes);
|
|
14
|
+
|
|
15
|
+
return premise;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = Premise;
|
package/bin/rule.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { labelsAsString } = require("./utilities/string");
|
|
4
|
+
|
|
5
|
+
class Rule {
|
|
6
|
+
constructor(labels, premise, conclusion, metastatementNode) {
|
|
7
|
+
this.labels = labels;
|
|
8
|
+
this.premise = premise;
|
|
9
|
+
this.conclusion = conclusion;
|
|
10
|
+
this.metastatementNode = metastatementNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getLabels() {
|
|
14
|
+
return this.labels;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getPremise() {
|
|
18
|
+
return this.premise;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getConclusion() {
|
|
22
|
+
return this.conclusion;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getPremiseMetastatementNodes() {
|
|
26
|
+
const metastatementNodes = (this.premise !== null) ?
|
|
27
|
+
this.premise.getMetastatementNodes() :
|
|
28
|
+
[];
|
|
29
|
+
|
|
30
|
+
return metastatementNodes;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getConclusionMetastatementNode() {
|
|
34
|
+
const metastatementNode = (this.conclusion !== null) ?
|
|
35
|
+
this.conclusion.getMetastatementNode() :
|
|
36
|
+
this.metastatementNode;
|
|
37
|
+
|
|
38
|
+
return metastatementNode;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
asString() {
|
|
42
|
+
const string = labelsAsString(this.labels);
|
|
43
|
+
|
|
44
|
+
return string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static fromMetastatementNodeAndLabels(metastatementNode, labels) {
|
|
48
|
+
const premise = null,
|
|
49
|
+
conclusion = null,
|
|
50
|
+
rule = new Rule(labels, premise, conclusion, metastatementNode);
|
|
51
|
+
|
|
52
|
+
return rule;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static fromPremiseConclusionAndLabels(premise, conclusion, labels) {
|
|
56
|
+
const metastatementNode = null,
|
|
57
|
+
rule = new Rule(labels, premise, conclusion, metastatementNode);
|
|
58
|
+
|
|
59
|
+
return rule;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = Rule;
|
|
64
|
+
|
package/bin/ruleNames.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const TERM_RULE_NAME = "term",
|
|
4
|
+
TYPE_RULE_NAME = "type",
|
|
5
|
+
ARGUMENT_RULE_NAME = "argument",
|
|
6
|
+
METAVARIABLE_RULE_NAME = "metavariable",
|
|
7
|
+
META_SUBLEMMA_RULE_NAME = "metaSublemma",
|
|
8
|
+
QUALIFIED_METASTATEMENT_RULE_NAME = "qualifiedMetastatement",
|
|
9
|
+
UNQUALIFIED_METASTATEMENT_RULE_NAME = "unqualifiedMetastatement";
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
TERM_RULE_NAME,
|
|
13
|
+
TYPE_RULE_NAME,
|
|
14
|
+
ARGUMENT_RULE_NAME,
|
|
15
|
+
METAVARIABLE_RULE_NAME,
|
|
16
|
+
META_SUBLEMMA_RULE_NAME,
|
|
17
|
+
QUALIFIED_METASTATEMENT_RULE_NAME,
|
|
18
|
+
UNQUALIFIED_METASTATEMENT_RULE_NAME
|
|
19
|
+
};
|