occam-verify-cli 0.0.272 → 0.0.274
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/.swcrc +5 -0
- package/bin/abbreviations.js +4 -2
- package/bin/context/{package → release}/fileSystem.js +38 -25
- package/bin/fileNames.js +7 -7
- package/bin/loadReleaseContexts.js +52 -0
- package/bin/main.js +8 -9
- package/bin/options.js +2 -2
- package/bin/utilities/fileSystem.js +13 -15
- package/lib/assertion.js +140 -0
- package/lib/axiom.js +90 -0
- package/lib/browser.js +27 -0
- package/lib/combinator.js +58 -0
- package/lib/conclusion.js +140 -0
- package/lib/constants.js +42 -0
- package/lib/constructor.js +76 -0
- package/lib/context/file.js +342 -0
- package/lib/context/metaproof.js +232 -0
- package/lib/context/proof.js +211 -0
- package/lib/context/release.js +303 -0
- package/lib/main.js +27 -0
- package/lib/metaAssertion.js +200 -0
- package/lib/metaSubstitution.js +123 -0
- package/lib/permutationsMatrix.js +466136 -0
- package/lib/premise.js +168 -0
- package/lib/rule.js +139 -0
- package/lib/ruleNames.js +46 -0
- package/lib/type.js +153 -0
- package/lib/utilities/array.js +99 -0
- package/lib/utilities/metastatement.js +45 -0
- package/lib/utilities/permutations.js +114 -0
- package/lib/utilities/query.js +81 -0
- package/lib/utilities/string.js +54 -0
- package/lib/variable.js +94 -0
- package/lib/verify/IndicativeConditional.js +29 -0
- package/lib/verify/assertion/type.js +52 -0
- package/lib/verify/axiom.js +52 -0
- package/lib/verify/conclusion.js +34 -0
- package/lib/verify/conditinalInference.js +30 -0
- package/lib/verify/declaration/combinator.js +24 -0
- package/lib/verify/declaration/constructor.js +24 -0
- package/lib/verify/declaration/topLevel.js +51 -0
- package/lib/verify/declaration/type.js +24 -0
- package/lib/verify/declaration/variable.js +24 -0
- package/lib/verify/equality.js +45 -0
- package/lib/verify/file.js +39 -0
- package/lib/verify/files.js +48 -0
- package/lib/verify/label.js +24 -0
- package/lib/verify/labels.js +27 -0
- package/lib/verify/metaDerivation.js +94 -0
- package/lib/verify/metaproof.js +81 -0
- package/lib/verify/metastatement/qualified.js +31 -0
- package/lib/verify/metastatement/unqualified.js +39 -0
- package/lib/verify/premiseOrPremises.js +39 -0
- package/lib/verify/release.js +61 -0
- package/lib/verify/rule.js +61 -0
- package/lib/verify/statement/qualified.js +24 -0
- package/lib/verify/statement/unqualified.js +32 -0
- package/lib/verify/statement.js +43 -0
- package/lib/verify/statementAsCombinator.js +102 -0
- package/lib/verify/supposition.js +29 -0
- package/lib/verify/term.js +121 -0
- package/lib/verify/termAsConstructor.js +126 -0
- package/lib/verify/termAsVariable.js +31 -0
- package/lib/verify/type.js +45 -0
- package/lib/verify/unconditionalInference.js +31 -0
- package/lib/verify/variable.js +48 -0
- package/package.json +21 -5
- package/{bin → src}/assertion.js +2 -4
- package/src/axiom.js +49 -0
- package/src/browser.js +4 -0
- package/{bin → src}/combinator.js +2 -4
- package/{bin → src}/conclusion.js +4 -6
- package/src/constants.js +9 -0
- package/{bin → src}/constructor.js +2 -4
- package/{bin → src}/context/file.js +34 -24
- package/{bin → src}/context/metaproof.js +13 -3
- package/{bin → src}/context/proof.js +13 -3
- package/src/context/release.js +219 -0
- package/src/main.js +4 -0
- package/{bin → src}/metaAssertion.js +4 -6
- package/{bin → src}/metaSubstitution.js +11 -4
- package/{bin → src}/permutationsMatrix.js +1 -1
- package/{bin → src}/premise.js +6 -8
- package/{bin → src}/rule.js +24 -15
- package/src/ruleNames.js +10 -0
- package/{bin → src}/type.js +1 -3
- package/{bin → src}/utilities/array.js +19 -24
- package/{bin → src}/utilities/metastatement.js +18 -12
- package/{bin → src}/utilities/permutations.js +4 -4
- package/{bin → src}/utilities/query.js +8 -18
- package/{bin → src}/utilities/string.js +4 -10
- package/{bin → src}/variable.js +1 -3
- package/src/verify/IndicativeConditional.js +20 -0
- package/{bin → src}/verify/assertion/type.js +8 -14
- package/src/verify/axiom.js +68 -0
- package/{bin → src}/verify/conclusion.js +4 -6
- package/src/verify/conditinalInference.js +25 -0
- package/{bin → src}/verify/declaration/combinator.js +3 -5
- package/{bin → src}/verify/declaration/constructor.js +3 -5
- package/{bin → src}/verify/declaration/topLevel.js +8 -10
- package/{bin → src}/verify/declaration/type.js +3 -5
- package/{bin → src}/verify/declaration/variable.js +3 -5
- package/{bin → src}/verify/equality.js +4 -6
- package/{bin → src}/verify/file.js +9 -15
- package/{bin → src}/verify/files.js +5 -7
- package/{bin → src}/verify/label.js +3 -9
- package/{bin → src}/verify/labels.js +2 -4
- package/{bin → src}/verify/metaDerivation.js +25 -19
- package/{bin → src}/verify/metaproof.js +6 -7
- package/{bin → src}/verify/metastatement/qualified.js +4 -10
- package/{bin → src}/verify/metastatement/unqualified.js +5 -11
- package/{bin → src}/verify/premiseOrPremises.js +9 -10
- package/src/verify/release.js +70 -0
- package/{bin → src}/verify/rule.js +17 -20
- package/{bin → src}/verify/statement/qualified.js +3 -5
- package/{bin → src}/verify/statement/unqualified.js +3 -5
- package/{bin → src}/verify/statement.js +7 -13
- package/{bin → src}/verify/statementAsCombinator.js +8 -14
- package/{bin → src}/verify/supposition.js +4 -6
- package/{bin → src}/verify/term.js +7 -13
- package/{bin → src}/verify/termAsConstructor.js +13 -19
- package/{bin → src}/verify/termAsVariable.js +3 -9
- package/{bin → src}/verify/type.js +7 -13
- package/{bin → src}/verify/unconditionalInference.js +4 -11
- package/{bin → src}/verify/variable.js +6 -12
- package/bin/axiom.js +0 -52
- package/bin/consequent.js +0 -19
- package/bin/constants.js +0 -19
- package/bin/context/package.js +0 -221
- package/bin/loadPackageContexts.js +0 -53
- package/bin/permutations.js +0 -3
- package/bin/ruleNames.js +0 -23
- package/bin/verify/axiom/IndicativeConditional.js +0 -54
- package/bin/verify/axiom/unqualifiedStatement.js +0 -40
- package/bin/verify/axiom.js +0 -37
- package/bin/verify/conditinalInference.js +0 -42
- package/bin/verify/consequent.js +0 -32
- package/bin/verify/metaConsequent.js +0 -23
- package/bin/verify/metaSupposition.js +0 -24
- package/bin/verify/package.js +0 -81
- package/index.js +0 -9
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "occam-verify-cli",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.274",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/occam-verify-cli",
|
|
7
7
|
"description": "Occam's Verifier",
|
|
@@ -12,13 +12,29 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"argumentative": "^2.0.15",
|
|
14
14
|
"necessary": "^11.0.40",
|
|
15
|
-
"occam-custom-grammars": "^5.0.
|
|
15
|
+
"occam-custom-grammars": "^5.0.355",
|
|
16
16
|
"occam-dom": "^3.0.171",
|
|
17
17
|
"occam-grammar-utilities": "^7.0.66",
|
|
18
|
-
"occam-grammars": "^1.0.
|
|
18
|
+
"occam-grammars": "^1.0.322",
|
|
19
19
|
"occam-open-cli": "^5.0.37",
|
|
20
20
|
"occam-parsers": "^16.0.122"
|
|
21
21
|
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@swc/core": "^1.2.51",
|
|
24
|
+
"watchful-cli": "^1.7.13"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"clean": "rm -rf ./lib",
|
|
28
|
+
"watchful": "watchful -m --transpiler=swc --source-directory=./src --lib-directory=./lib --pause=100",
|
|
29
|
+
"batch": "npm run watchful batch --",
|
|
30
|
+
"batch-debug": "npm run watchful batch -- --debug",
|
|
31
|
+
"incremental": "npm run watchful incremental --",
|
|
32
|
+
"incremental-debug": "npm run watchful incremental -- --debug",
|
|
33
|
+
"build": "npm run clean && npm run batch",
|
|
34
|
+
"build-debug": "npm run clean && npm run batch-debug",
|
|
35
|
+
"watch": "npm run clean && npm run batch && npm run incremental",
|
|
36
|
+
"watch-debug": "npm run clean && npm run batch-debug && npm run incremental-debug"
|
|
37
|
+
},
|
|
38
|
+
"browser": "./lib/browser.js",
|
|
39
|
+
"main": "./lib/main.js"
|
|
24
40
|
}
|
package/{bin → src}/assertion.js
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { nodeQuery } from "./utilities/query";
|
|
4
4
|
|
|
5
5
|
const statementNodeQuery = nodeQuery("/*/statement!");
|
|
6
6
|
|
|
7
|
-
class Assertion {
|
|
7
|
+
export default class Assertion {
|
|
8
8
|
constructor(subproofNode, statementNode) {
|
|
9
9
|
this.subproofNode = subproofNode;
|
|
10
10
|
this.statementNode = statementNode;
|
|
@@ -66,8 +66,6 @@ class Assertion {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
module.exports = Assertion;
|
|
70
|
-
|
|
71
69
|
function matchAssertionNode(assertionNode, node) {
|
|
72
70
|
let assertionNodeMatches = false;
|
|
73
71
|
|
package/src/axiom.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { labelsAsString } from "./utilities/string";
|
|
4
|
+
|
|
5
|
+
export default class Axiom {
|
|
6
|
+
constructor(labels, statementNode, suppositionStatementNode, consequentStatementNode) {
|
|
7
|
+
this.labels = labels;
|
|
8
|
+
this.statementNode = statementNode;
|
|
9
|
+
this.suppositionStatementNode = suppositionStatementNode;
|
|
10
|
+
this.consequentStatementNode = consequentStatementNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getLabels() {
|
|
14
|
+
return this.labels;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getStatementNode() {
|
|
18
|
+
return this.statementNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getSuppositionStatementNode() {
|
|
22
|
+
return this.suppositionStatementNode;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getConsequentStatementNode() {
|
|
26
|
+
return this.consequentStatementNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
asString() {
|
|
30
|
+
const string = labelsAsString(this.labels);
|
|
31
|
+
|
|
32
|
+
return string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static fromStatementNodeAndLabels(statementNode, labels) {
|
|
36
|
+
const suppositionStatementNode = null,
|
|
37
|
+
consequentStatementNode = null,
|
|
38
|
+
axiom = new Axiom(labels, statementNode, suppositionStatementNode, consequentStatementNode);
|
|
39
|
+
|
|
40
|
+
return axiom;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static fromSuppositionStatementNodeConsequentStatementNodeAndLabels(suppositionStatementNode, consequentStatementNode, labels) {
|
|
44
|
+
const statementNode = null,
|
|
45
|
+
axiom = new Axiom(labels, statementNode, suppositionStatementNode, consequentStatementNode);
|
|
46
|
+
|
|
47
|
+
return axiom;
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/browser.js
ADDED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { nodeAsString } from "./utilities/string";
|
|
4
4
|
|
|
5
|
-
class Combinator {
|
|
5
|
+
export default class Combinator {
|
|
6
6
|
constructor(statementNode) {
|
|
7
7
|
this.statementNode = statementNode;
|
|
8
8
|
}
|
|
@@ -23,5 +23,3 @@ class Combinator {
|
|
|
23
23
|
return combinator;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
module.exports = Combinator;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { first } from "./utilities/array";
|
|
4
|
+
import { metavariableNameFromMetavariableNode } from "./utilities/query";
|
|
5
|
+
import { METAVARIABLE_RULE_NAME, METASTATEMENT_RULE_NAME } from "./ruleNames";
|
|
6
6
|
|
|
7
|
-
class Conclusion {
|
|
7
|
+
export default class Conclusion {
|
|
8
8
|
constructor(metastatementNode) {
|
|
9
9
|
this.metastatementNode = metastatementNode;
|
|
10
10
|
}
|
|
@@ -29,8 +29,6 @@ class Conclusion {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
module.exports = Conclusion;
|
|
33
|
-
|
|
34
32
|
function matchConclusionNode(conclusionNode, node, metaSubstitutions) {
|
|
35
33
|
let conclusionNodeMatches = false;
|
|
36
34
|
|
package/src/constants.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const COMMA = ',';
|
|
4
|
+
export const EMPTY_STRING = "";
|
|
5
|
+
export const LEFT_BRACKET = "(";
|
|
6
|
+
export const RIGHT_BRACKET = ")";
|
|
7
|
+
export const MAXIMUM_INDEXES_LENGTH = 10;
|
|
8
|
+
export const MAXIMUM_PERMUTATION_LENGTH = 5;
|
|
9
|
+
export const BRACKETED_METASTATEMENT_CHILD_NODES_LENGTH = 3;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { nodeAsString } from "./utilities/string";
|
|
4
4
|
|
|
5
|
-
class Constructor {
|
|
5
|
+
export default class Constructor {
|
|
6
6
|
constructor(termNode, type) {
|
|
7
7
|
this.termNode = termNode;
|
|
8
8
|
this.type = type;
|
|
@@ -39,5 +39,3 @@ class Constructor {
|
|
|
39
39
|
return constructor;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
module.exports = Constructor;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { rewriteNodes } from "occam-grammar-utilities";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { push } from "../utilities/array";
|
|
6
6
|
|
|
7
|
-
class FileContext {
|
|
8
|
-
constructor(tokens, node, rules, types, axioms, variables, combinators, constructors,
|
|
7
|
+
export default class FileContext {
|
|
8
|
+
constructor(tokens, node, rules, types, axioms, variables, combinators, constructors, releaseContext) {
|
|
9
9
|
this.tokens = tokens;
|
|
10
10
|
this.node = node;
|
|
11
11
|
this.rules = rules;
|
|
@@ -14,7 +14,7 @@ class FileContext {
|
|
|
14
14
|
this.variables = variables;
|
|
15
15
|
this.combinators = combinators;
|
|
16
16
|
this.constructors = constructors;
|
|
17
|
-
this.
|
|
17
|
+
this.releaseContext = releaseContext;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
getTokens() {
|
|
@@ -31,9 +31,9 @@ class FileContext {
|
|
|
31
31
|
];
|
|
32
32
|
|
|
33
33
|
if (bubble) {
|
|
34
|
-
const
|
|
34
|
+
const releaseContextRules = this.releaseContext.getRules();
|
|
35
35
|
|
|
36
|
-
push(rules,
|
|
36
|
+
push(rules, releaseContextRules);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
return rules;
|
|
@@ -45,9 +45,9 @@ class FileContext {
|
|
|
45
45
|
];
|
|
46
46
|
|
|
47
47
|
if (bubble) {
|
|
48
|
-
const
|
|
48
|
+
const releaseContextTypes = this.releaseContext.getTypes();
|
|
49
49
|
|
|
50
|
-
push(types,
|
|
50
|
+
push(types, releaseContextTypes);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
return types;
|
|
@@ -59,9 +59,9 @@ class FileContext {
|
|
|
59
59
|
];
|
|
60
60
|
|
|
61
61
|
if (bubble) {
|
|
62
|
-
const
|
|
62
|
+
const releaseContextAxioms = this.releaseContext.getAxioms();
|
|
63
63
|
|
|
64
|
-
push(axioms,
|
|
64
|
+
push(axioms, releaseContextAxioms);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
return axioms;
|
|
@@ -90,9 +90,9 @@ class FileContext {
|
|
|
90
90
|
];
|
|
91
91
|
|
|
92
92
|
if (bubble) {
|
|
93
|
-
const
|
|
93
|
+
const releaseContextCombinators = this.releaseContext.getCombinators();
|
|
94
94
|
|
|
95
|
-
push(combinators,
|
|
95
|
+
push(combinators, releaseContextCombinators);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
return combinators;
|
|
@@ -104,16 +104,16 @@ class FileContext {
|
|
|
104
104
|
];
|
|
105
105
|
|
|
106
106
|
if (bubble) {
|
|
107
|
-
const
|
|
107
|
+
const releaseContextConstructors = this.releaseContext.getConstructors();
|
|
108
108
|
|
|
109
|
-
push(constructors,
|
|
109
|
+
push(constructors, releaseContextConstructors);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
return constructors;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
return this.
|
|
115
|
+
getReleaseContext() {
|
|
116
|
+
return this.releaseContext;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
getMetaAssertions() {
|
|
@@ -236,11 +236,23 @@ class FileContext {
|
|
|
236
236
|
this.constructors.push(constructor);
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
|
|
240
|
-
|
|
239
|
+
trace(message) { this.releaseContext.trace(message); }
|
|
240
|
+
|
|
241
|
+
debug(message) { this.releaseContext.debug(message); }
|
|
242
|
+
|
|
243
|
+
info(message) { this.releaseContext.info(message); }
|
|
244
|
+
|
|
245
|
+
warning(message) { this.releaseContext.warning(message); }
|
|
246
|
+
|
|
247
|
+
error(message) { this.releaseContext.error(message); }
|
|
248
|
+
|
|
249
|
+
fatal(message) { this.releaseContext.fatal(message); }
|
|
250
|
+
|
|
251
|
+
static fromReleaseContextAndFilePath(releaseContext, filePath) {
|
|
252
|
+
const fileContent = releaseContext.getFileContent(filePath),
|
|
241
253
|
content = fileContent, ///
|
|
242
|
-
tokens =
|
|
243
|
-
node =
|
|
254
|
+
tokens = releaseContext.tokenise(content),
|
|
255
|
+
node = releaseContext.parse(tokens);
|
|
244
256
|
|
|
245
257
|
rewriteNodes(node);
|
|
246
258
|
|
|
@@ -250,10 +262,8 @@ class FileContext {
|
|
|
250
262
|
variables = [],
|
|
251
263
|
combinators = [],
|
|
252
264
|
constructors = [],
|
|
253
|
-
fileContext = new FileContext(tokens, node, rules, types, axioms, variables, combinators, constructors,
|
|
265
|
+
fileContext = new FileContext(tokens, node, rules, types, axioms, variables, combinators, constructors, releaseContext);
|
|
254
266
|
|
|
255
267
|
return fileContext;
|
|
256
268
|
}
|
|
257
269
|
}
|
|
258
|
-
|
|
259
|
-
module.exports = FileContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
class MetaproofContext {
|
|
3
|
+
export default class MetaproofContext {
|
|
4
4
|
constructor(context, derived, metaAssertions) {
|
|
5
5
|
this.context = context;
|
|
6
6
|
this.derived = derived;
|
|
@@ -79,6 +79,18 @@ class MetaproofContext {
|
|
|
79
79
|
this.metaAssertions.push(metaAssertion);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
trace(message) { this.context.trace(message); }
|
|
83
|
+
|
|
84
|
+
debug(message) { this.context.debug(message); }
|
|
85
|
+
|
|
86
|
+
info(message) { this.context.info(message); }
|
|
87
|
+
|
|
88
|
+
warning(message) { this.context.warning(message); }
|
|
89
|
+
|
|
90
|
+
error(message) { this.context.error(message); }
|
|
91
|
+
|
|
92
|
+
fatal(message) { this.context.fatal(message); }
|
|
93
|
+
|
|
82
94
|
static fromContext(context) {
|
|
83
95
|
const derived = false,
|
|
84
96
|
metaAssertions = [],
|
|
@@ -87,5 +99,3 @@ class MetaproofContext {
|
|
|
87
99
|
return metaproofContext;
|
|
88
100
|
}
|
|
89
101
|
}
|
|
90
|
-
|
|
91
|
-
module.exports = MetaproofContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
class ProofContext {
|
|
3
|
+
export default class ProofContext {
|
|
4
4
|
constructor(context, derived, variables, statementNodes) {
|
|
5
5
|
this.context = context;
|
|
6
6
|
this.derived = derived;
|
|
@@ -80,6 +80,18 @@ class ProofContext {
|
|
|
80
80
|
this.statementNodes.push(statementNode);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
trace(message) { this.context.trace(message); }
|
|
84
|
+
|
|
85
|
+
debug(message) { this.context.debug(message); }
|
|
86
|
+
|
|
87
|
+
info(message) { this.context.info(message); }
|
|
88
|
+
|
|
89
|
+
warning(message) { this.context.warning(message); }
|
|
90
|
+
|
|
91
|
+
error(message) { this.context.error(message); }
|
|
92
|
+
|
|
93
|
+
fatal(message) { this.context.fatal(message); }
|
|
94
|
+
|
|
83
95
|
static fromContext(context) {
|
|
84
96
|
const derived = false,
|
|
85
97
|
variables = [],
|
|
@@ -89,5 +101,3 @@ class ProofContext {
|
|
|
89
101
|
return proofContext;
|
|
90
102
|
}
|
|
91
103
|
}
|
|
92
|
-
|
|
93
|
-
module.exports = ProofContext;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { CustomGrammar, lexersUtilities, parsersUtilities, CombinedCustomGrammar } from "occam-custom-grammars";
|
|
4
|
+
|
|
5
|
+
import { push } from "../utilities/array";
|
|
6
|
+
|
|
7
|
+
const { florenceLexerFromCombinedCustomGrammar } = lexersUtilities,
|
|
8
|
+
{ florenceParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
9
|
+
|
|
10
|
+
export default class ReleaseContext {
|
|
11
|
+
constructor(releaseName, fileContexts, florenceLexer, florenceParser, releaseContexts, releaseVerified) {
|
|
12
|
+
this.releaseName = releaseName;
|
|
13
|
+
this.fileContexts = fileContexts;
|
|
14
|
+
this.florenceLexer = florenceLexer;
|
|
15
|
+
this.florenceParser = florenceParser;
|
|
16
|
+
this.releaseContexts = releaseContexts;
|
|
17
|
+
this.releaseVerified = releaseVerified;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getReleaseName() {
|
|
21
|
+
return this.releaseName;
|
|
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
|
+
getReleaseContexts() {
|
|
37
|
+
return this.releaseContexts;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
isReleaseVerified() {
|
|
41
|
+
return this.releaseVerified;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getRules(releaseNames = []) {
|
|
45
|
+
const rules = [],
|
|
46
|
+
releaseNamesIncludesReleaseName = releaseNames.includes(this.releaseName);
|
|
47
|
+
|
|
48
|
+
if (!releaseNamesIncludesReleaseName) {
|
|
49
|
+
releaseNames.push(this.releaseName);
|
|
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.releaseContexts.forEach((releaseContext) => {
|
|
60
|
+
const releaseContextRules = releaseContext.getRules(releaseNames);
|
|
61
|
+
|
|
62
|
+
push(rules, releaseContextRules);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return rules;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
getTypes(releaseNames = []) {
|
|
70
|
+
const types = [],
|
|
71
|
+
releaseNamesIncludesReleaseName = releaseNames.includes(this.releaseName);
|
|
72
|
+
|
|
73
|
+
if (!releaseNamesIncludesReleaseName) {
|
|
74
|
+
releaseNames.push(this.releaseName);
|
|
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.releaseContexts.forEach((releaseContext) => {
|
|
85
|
+
const releaseContextTypes = releaseContext.getTypes(releaseNames);
|
|
86
|
+
|
|
87
|
+
push(types, releaseContextTypes);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return types;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
getAxioms(releaseNames = []) {
|
|
95
|
+
const axioms = [],
|
|
96
|
+
releaseNamesIncludesReleaseName = releaseNames.includes(this.releaseName);
|
|
97
|
+
|
|
98
|
+
if (!releaseNamesIncludesReleaseName) {
|
|
99
|
+
releaseNames.push(this.releaseName);
|
|
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.releaseContexts.forEach((releaseContext) => {
|
|
110
|
+
const releaseContextAxioms = releaseContext.getAxioms(releaseNames);
|
|
111
|
+
|
|
112
|
+
push(axioms, releaseContextAxioms);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return axioms;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
getCombinators(releaseNames = []) {
|
|
120
|
+
const combinators = [],
|
|
121
|
+
releaseNamesIncludesReleaseName = releaseNames.includes(this.releaseName);
|
|
122
|
+
|
|
123
|
+
if (!releaseNamesIncludesReleaseName) {
|
|
124
|
+
releaseNames.push(this.releaseName);
|
|
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.releaseContexts.forEach((releaseContext) => {
|
|
135
|
+
const releaseContextCombinators = releaseContext.getCombinators(releaseNames);
|
|
136
|
+
|
|
137
|
+
push(combinators, releaseContextCombinators);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return combinators;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
getConstructors(releaseNames = []) {
|
|
145
|
+
const constructors = [],
|
|
146
|
+
releaseNamesIncludesReleaseName = releaseNames.includes(this.releaseName);
|
|
147
|
+
|
|
148
|
+
if (!releaseNamesIncludesReleaseName) {
|
|
149
|
+
releaseNames.push(this.releaseName);
|
|
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.releaseContexts.forEach((releaseContext) => {
|
|
160
|
+
const releaseContextConstructors = releaseContext.getConstructors(releaseNames);
|
|
161
|
+
|
|
162
|
+
push(constructors, releaseContextConstructors);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return constructors;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
getCustomGrammar() {
|
|
170
|
+
const name = this.releaseName, ///
|
|
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(releaseContexts, dependencyReleaseContexts) {
|
|
191
|
+
this.releaseContexts = releaseContexts;
|
|
192
|
+
|
|
193
|
+
const releaseContext = this; ///
|
|
194
|
+
|
|
195
|
+
releaseContexts = [ releaseContext, ...dependencyReleaseContexts ]; ///
|
|
196
|
+
|
|
197
|
+
const customGrammars = releaseContexts.map((releaseContext) => {
|
|
198
|
+
const customGrammar = releaseContext.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 fromReleaseName(Class, releaseName, ...remainingArguments) {
|
|
210
|
+
const fileContexts = [],
|
|
211
|
+
florenceLexer = null,
|
|
212
|
+
florenceParser = null,
|
|
213
|
+
releaseContexts = [],
|
|
214
|
+
releaseVerified = false,
|
|
215
|
+
releaseContext = new Class(releaseName, fileContexts, florenceLexer, florenceParser, releaseContexts, releaseVerified, ...remainingArguments);
|
|
216
|
+
|
|
217
|
+
return releaseContext;
|
|
218
|
+
}
|
|
219
|
+
}
|
package/src/main.js
ADDED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { first, second } from "./utilities/array";
|
|
4
|
+
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
5
|
+
import { matchBracketedMetastatementChildNode } from "./utilities/metastatement";
|
|
6
6
|
|
|
7
7
|
const metastatementNodeQuery = nodeQuery("/*/metastatement!"),
|
|
8
8
|
metastatementNodesQuery = nodesQuery("/metaSubproofAssertion/metastatement"),
|
|
9
9
|
metaSubproofAssertionNodeQuery = nodeQuery("/metastatement/metaSubproofAssertion"),
|
|
10
10
|
qualifiedOrUnqualifiedMetastatementMetastatementNodesQuery = nodesQuery("/metaSubproof/qualifiedMetastatement|unqualifiedMetastatement/metastatement!");
|
|
11
11
|
|
|
12
|
-
class MetaAssertion {
|
|
12
|
+
export default class MetaAssertion {
|
|
13
13
|
constructor(metaSubproofNode, metastatementNode) {
|
|
14
14
|
this.metaSubproofNode = metaSubproofNode;
|
|
15
15
|
this.metastatementNode = metastatementNode;
|
|
@@ -118,8 +118,6 @@ class MetaAssertion {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
module.exports = MetaAssertion;
|
|
122
|
-
|
|
123
121
|
function matchMetaAssertionNode(metaAssertionNode, node) {
|
|
124
122
|
let metaAssertionNodeMatches = false;
|
|
125
123
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { matchBracketedMetastatementChildNode, bracketedMetastatementChildNodeFromChildNodes } from "./utilities/metastatement";
|
|
4
4
|
|
|
5
|
-
class MetaSubstitution {
|
|
5
|
+
export default class MetaSubstitution {
|
|
6
6
|
constructor(metavariableName, nodes) {
|
|
7
7
|
this.metavariableName = metavariableName;
|
|
8
8
|
this.nodes = nodes;
|
|
@@ -43,14 +43,21 @@ class MetaSubstitution {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
static fromMetavariableNameAndNodes(metavariableName, nodes) {
|
|
46
|
+
const bracketedMetastatementChildNode = bracketedMetastatementChildNodeFromChildNodes(nodes);
|
|
47
|
+
|
|
48
|
+
if (bracketedMetastatementChildNode !== null) {
|
|
49
|
+
const nonTerminalNode = bracketedMetastatementChildNode, ///
|
|
50
|
+
childNodes = nonTerminalNode.getChildNodes();
|
|
51
|
+
|
|
52
|
+
nodes = childNodes; ///
|
|
53
|
+
}
|
|
54
|
+
|
|
46
55
|
const metaSubstitution = new MetaSubstitution(metavariableName, nodes);
|
|
47
56
|
|
|
48
57
|
return metaSubstitution;
|
|
49
58
|
}
|
|
50
59
|
}
|
|
51
60
|
|
|
52
|
-
module.exports = MetaSubstitution;
|
|
53
|
-
|
|
54
61
|
function matchMetaSubstitutionNode(metaSubstitutionNode, node) {
|
|
55
62
|
let metaSubstitutionNodeMatches = false;
|
|
56
63
|
|