occam-verify-cli 0.0.317 → 0.0.319
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/bin/callbacks.js +27 -0
- package/bin/main.js +2 -5
- package/bin/messages.js +11 -0
- package/bin/utilities/logging.js +2 -10
- package/bin/utilities/release.js +47 -46
- package/lib/callbacks.js +68 -0
- package/lib/context/file.js +58 -81
- package/lib/context/metaproof.js +30 -118
- package/lib/context/proof.js +73 -137
- package/lib/context/release.js +81 -15
- package/lib/index.js +9 -1
- package/lib/mixins/callbacks.js +27 -0
- package/lib/mixins/file.js +23 -0
- package/lib/mixins/logging.js +39 -0
- package/lib/rule.js +3 -3
- package/lib/utilities/verification.js +45 -0
- package/lib/verify/IndicativeConditional.js +9 -5
- package/lib/verify/assertion/type.js +12 -10
- package/lib/verify/axiom.js +10 -14
- package/lib/verify/conclusion.js +5 -3
- package/lib/verify/conditinalInference.js +7 -5
- package/lib/verify/declaration/combinator.js +7 -3
- package/lib/verify/declaration/constructor.js +7 -3
- package/lib/verify/declaration/topLevel.js +11 -9
- package/lib/verify/declaration/type.js +8 -3
- package/lib/verify/declaration/variable.js +7 -3
- package/lib/verify/equality.js +8 -6
- package/lib/verify/file.js +7 -9
- package/lib/verify/label.js +6 -4
- package/lib/verify/labels.js +5 -4
- package/lib/verify/metaDerivation.js +21 -18
- package/lib/verify/metaproof.js +6 -4
- package/lib/verify/metastatement/qualified.js +7 -5
- package/lib/verify/metastatement/unqualified.js +7 -5
- package/lib/verify/premiseOrPremises.js +11 -12
- package/lib/verify/release.js +28 -18
- package/lib/verify/rule.js +11 -14
- package/lib/verify/statement/qualified.js +7 -3
- package/lib/verify/statement/unqualified.js +6 -4
- package/lib/verify/statement.js +8 -10
- package/lib/verify/statementAsCombinator.js +33 -36
- package/lib/verify/term.js +4 -2
- package/lib/verify/termAsConstructor.js +38 -39
- package/lib/verify/termAsVariable.js +4 -2
- package/lib/verify/type.js +18 -14
- package/lib/verify/unconditionalInference.js +5 -3
- package/lib/verify/variable.js +13 -10
- package/package.json +1 -1
- package/src/callbacks.js +27 -0
- package/src/context/file.js +62 -61
- package/src/context/metaproof.js +29 -44
- package/src/context/proof.js +51 -64
- package/src/context/release.js +33 -11
- package/src/index.js +3 -0
- package/src/mixins/callbacks.js +15 -0
- package/src/mixins/file.js +12 -0
- package/src/mixins/logging.js +24 -0
- package/src/rule.js +2 -2
- package/src/utilities/verification.js +41 -0
- package/src/verify/IndicativeConditional.js +18 -9
- package/src/verify/assertion/type.js +15 -8
- package/src/verify/axiom.js +15 -17
- package/src/verify/conclusion.js +8 -2
- package/src/verify/conditinalInference.js +10 -4
- package/src/verify/declaration/combinator.js +12 -3
- package/src/verify/declaration/constructor.js +12 -3
- package/src/verify/declaration/topLevel.js +15 -9
- package/src/verify/declaration/type.js +14 -4
- package/src/verify/declaration/variable.js +12 -3
- package/src/verify/equality.js +11 -4
- package/src/verify/file.js +6 -8
- package/src/verify/label.js +9 -3
- package/src/verify/labels.js +5 -3
- package/src/verify/metaDerivation.js +26 -19
- package/src/verify/metaproof.js +9 -3
- package/src/verify/metastatement/qualified.js +10 -4
- package/src/verify/metastatement/unqualified.js +10 -4
- package/src/verify/premiseOrPremises.js +18 -14
- package/src/verify/release.js +45 -27
- package/src/verify/rule.js +15 -16
- package/src/verify/statement/qualified.js +12 -3
- package/src/verify/statement/unqualified.js +9 -3
- package/src/verify/statement.js +10 -9
- package/src/verify/statementAsCombinator.js +45 -46
- package/src/verify/term.js +7 -1
- package/src/verify/termAsConstructor.js +48 -45
- package/src/verify/termAsVariable.js +7 -1
- package/src/verify/type.js +25 -21
- package/src/verify/unconditionalInference.js +8 -2
- package/src/verify/variable.js +18 -11
- package/lib/mixins/log.js +0 -41
- package/lib/verify/supposition.js +0 -29
- package/src/mixins/log.js +0 -28
- package/src/verify/supposition.js +0 -22
package/src/context/proof.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import fileMixins from "../mixins/file";
|
|
4
|
+
import loggingMixins from "../mixins/logging";
|
|
5
|
+
import callbacksMixins from "../mixins/callbacks";
|
|
6
|
+
|
|
7
|
+
class ProofContext {
|
|
8
|
+
constructor(context, derived, assertions) {
|
|
5
9
|
this.context = context;
|
|
6
10
|
this.derived = derived;
|
|
7
|
-
this.
|
|
8
|
-
this.statementNodes = statementNodes;
|
|
11
|
+
this.assertions = assertions;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
getContext() {
|
|
@@ -16,50 +19,15 @@ export default class ProofContext {
|
|
|
16
19
|
return this.derived;
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
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(); }
|
|
22
|
+
getAssertions() {
|
|
23
|
+
let assertions = this.context.getAssertions();
|
|
32
24
|
|
|
33
|
-
|
|
25
|
+
assertions = [
|
|
26
|
+
...assertions,
|
|
27
|
+
...this.assertions
|
|
28
|
+
];
|
|
34
29
|
|
|
35
|
-
|
|
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;
|
|
30
|
+
return assertions;
|
|
63
31
|
}
|
|
64
32
|
|
|
65
33
|
setDerived(derived) {
|
|
@@ -70,34 +38,53 @@ export default class ProofContext {
|
|
|
70
38
|
this.derived = derived;
|
|
71
39
|
}
|
|
72
40
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
addVariable(variable) {
|
|
76
|
-
this.variables.push(variable);
|
|
41
|
+
addAssertion(assertion) {
|
|
42
|
+
this.assertions.push(assertion);
|
|
77
43
|
}
|
|
78
44
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
45
|
+
matchAssertion(assertion) {
|
|
46
|
+
let assertionMatches;
|
|
82
47
|
|
|
83
|
-
|
|
48
|
+
const assertionB = assertion; ///
|
|
84
49
|
|
|
85
|
-
|
|
50
|
+
assertionMatches = this.assertions.some((assertion) => {
|
|
51
|
+
const assertionA = assertion, ///
|
|
52
|
+
matches = assertionA.match(assertionB);
|
|
86
53
|
|
|
87
|
-
|
|
54
|
+
if (matches) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
88
58
|
|
|
89
|
-
|
|
59
|
+
if (!assertionMatches) {
|
|
60
|
+
assertionMatches = this.context.matchAssertion(assertion);
|
|
61
|
+
}
|
|
90
62
|
|
|
91
|
-
|
|
63
|
+
return assertionMatches;
|
|
64
|
+
}
|
|
92
65
|
|
|
93
|
-
|
|
66
|
+
static fromFileContext(fileContext) {
|
|
67
|
+
const context = fileContext, ///
|
|
68
|
+
derived = false,
|
|
69
|
+
assertions = [],
|
|
70
|
+
proofContext = new ProofContext(context, derived, assertions);
|
|
94
71
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
72
|
+
return proofContext;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static fromProofContext(proofContext) {
|
|
76
|
+
const context = proofContext, ///
|
|
77
|
+
derived = false,
|
|
78
|
+
assertions = [];
|
|
79
|
+
|
|
80
|
+
proofContext = new ProofContext(context, derived, assertions); ///
|
|
100
81
|
|
|
101
82
|
return proofContext;
|
|
102
83
|
}
|
|
103
84
|
}
|
|
85
|
+
|
|
86
|
+
Object.assign(ProofContext.prototype, fileMixins);
|
|
87
|
+
Object.assign(ProofContext.prototype, loggingMixins);
|
|
88
|
+
Object.assign(ProofContext.prototype, callbacksMixins);
|
|
89
|
+
|
|
90
|
+
export default ProofContext;
|
package/src/context/release.js
CHANGED
|
@@ -2,21 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
import { lexersUtilities, parsersUtilities } from "occam-custom-grammars";
|
|
4
4
|
|
|
5
|
-
import logMixins from "../mixins/log";
|
|
6
|
-
|
|
7
5
|
import { push } from "../utilities/array";
|
|
8
6
|
import { customGrammarFromRelease, combinedCustomGrammarFromReleaseContexts } from "../utilities/customGrammar";
|
|
9
7
|
|
|
10
8
|
const { florenceLexerFromCombinedCustomGrammar } = lexersUtilities,
|
|
11
9
|
{ florenceParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
12
10
|
|
|
13
|
-
class ReleaseContext {
|
|
14
|
-
constructor(log, release, verified, customGrammar, fileContexts, florenceLexer, florenceParser, releaseContexts) {
|
|
11
|
+
export default class ReleaseContext {
|
|
12
|
+
constructor(log, release, callbacks, verified, customGrammar, fileContexts, florenceLexer, florenceParser, releaseContexts) {
|
|
15
13
|
this.log = log;
|
|
16
14
|
this.release = release;
|
|
15
|
+
this.callbacks = callbacks;
|
|
17
16
|
this.verified = verified;
|
|
18
17
|
this.customGrammar = customGrammar;
|
|
19
|
-
|
|
20
18
|
this.fileContexts = fileContexts;
|
|
21
19
|
this.florenceLexer = florenceLexer;
|
|
22
20
|
this.florenceParser = florenceParser;
|
|
@@ -31,6 +29,10 @@ class ReleaseContext {
|
|
|
31
29
|
return this.release;
|
|
32
30
|
}
|
|
33
31
|
|
|
32
|
+
getCallbacks() {
|
|
33
|
+
return this.callbacks;
|
|
34
|
+
}
|
|
35
|
+
|
|
34
36
|
isVerified() {
|
|
35
37
|
return this.verified;
|
|
36
38
|
}
|
|
@@ -65,6 +67,8 @@ class ReleaseContext {
|
|
|
65
67
|
|
|
66
68
|
getDependencies() { return this.release.getDependencies(); }
|
|
67
69
|
|
|
70
|
+
matchShortenedVersion(shortenedVersion) { return this.release.matchShortenedVersion(shortenedVersion); }
|
|
71
|
+
|
|
68
72
|
getRules(releaseNames = []) {
|
|
69
73
|
const name = this.getName(),
|
|
70
74
|
rules = [],
|
|
@@ -204,10 +208,32 @@ class ReleaseContext {
|
|
|
204
208
|
this.fileContexts.push(fileContext);
|
|
205
209
|
}
|
|
206
210
|
|
|
211
|
+
setVerified(verified) {
|
|
212
|
+
this.verified = verified;
|
|
213
|
+
}
|
|
214
|
+
|
|
207
215
|
tokenise(content) { return this.florenceLexer.tokenise(content); }
|
|
208
216
|
|
|
209
217
|
parse(tokens) { return this.florenceParser.parse(tokens); }
|
|
210
218
|
|
|
219
|
+
trace(message) { this.log.trace(message); }
|
|
220
|
+
|
|
221
|
+
debug(message) { this.log.debug(message); }
|
|
222
|
+
|
|
223
|
+
info(message) { this.log.info(message); }
|
|
224
|
+
|
|
225
|
+
warning(message) { this.log.warning(message); }
|
|
226
|
+
|
|
227
|
+
error(message) { this.log.error(message); }
|
|
228
|
+
|
|
229
|
+
fatal(message) { this.log.fatal(message); }
|
|
230
|
+
|
|
231
|
+
halt(filePath, leastLineIndex, greatestLineIndex) { this.callbacks.halt(filePath, leastLineIndex, greatestLineIndex); }
|
|
232
|
+
|
|
233
|
+
begin(filePath, leastLineIndex, greatestLineIndex) { this.callbacks.begin(filePath, leastLineIndex, greatestLineIndex); }
|
|
234
|
+
|
|
235
|
+
complete(filePath, leastLineIndex, greatestLineIndex) { this.callbacks.complete(filePath, leastLineIndex, greatestLineIndex); }
|
|
236
|
+
|
|
211
237
|
initialise(releaseContexts, dependencyReleaseContexts) {
|
|
212
238
|
const releaseContext = this; ///
|
|
213
239
|
|
|
@@ -222,19 +248,15 @@ class ReleaseContext {
|
|
|
222
248
|
this.releaseContexts = releaseContexts;
|
|
223
249
|
}
|
|
224
250
|
|
|
225
|
-
static
|
|
251
|
+
static fromLogReleaseAndCallbacks(log, release, callbacks, ...remainingArguments) {
|
|
226
252
|
const verified = false,
|
|
227
253
|
customGrammar = customGrammarFromRelease(release),
|
|
228
254
|
fileContexts = [],
|
|
229
255
|
florenceLexer = null,
|
|
230
256
|
florenceParser = null,
|
|
231
257
|
releaseContexts = [],
|
|
232
|
-
releaseContext = new ReleaseContext(log, release, verified, customGrammar, fileContexts, florenceLexer, florenceParser, releaseContexts, ...remainingArguments);
|
|
258
|
+
releaseContext = new ReleaseContext(log, release, callbacks, verified, customGrammar, fileContexts, florenceLexer, florenceParser, releaseContexts, ...remainingArguments);
|
|
233
259
|
|
|
234
260
|
return releaseContext;
|
|
235
261
|
}
|
|
236
262
|
}
|
|
237
|
-
|
|
238
|
-
Object.assign(ReleaseContext.prototype, logMixins);
|
|
239
|
-
|
|
240
|
-
export default ReleaseContext;
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
export { default as Callbacks } from "./callbacks";
|
|
3
4
|
export { default as verifyRelease } from "./verify/release";
|
|
4
5
|
export { default as ReleaseContext } from "./context/release";
|
|
6
|
+
|
|
7
|
+
export { default as verificationUtilities } from "./utilities/verification";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function halt(node) { this.context.halt(node); }
|
|
4
|
+
|
|
5
|
+
function begin(node) { this.context.begin(node); }
|
|
6
|
+
|
|
7
|
+
function complete(node) { this.context.complete(node); }
|
|
8
|
+
|
|
9
|
+
const callbacksMixins = {
|
|
10
|
+
halt,
|
|
11
|
+
begin,
|
|
12
|
+
complete
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default callbacksMixins;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function findRuleByReferenceName(referenceName) { return this.context.findRuleByReferenceName(referenceName); }
|
|
4
|
+
|
|
5
|
+
function findAxiomByReferenceName(referenceName) { return this.context.findAxiomByReferenceName(referenceName); }
|
|
6
|
+
|
|
7
|
+
const fileMixins = {
|
|
8
|
+
findRuleByReferenceName,
|
|
9
|
+
findAxiomByReferenceName
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default fileMixins;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function trace(message) { this.context.trace(message); }
|
|
4
|
+
|
|
5
|
+
function debug(message) { this.context.debug(message); }
|
|
6
|
+
|
|
7
|
+
function info(message) { this.context.info(message); }
|
|
8
|
+
|
|
9
|
+
function warning(message) { this.context.warning(message); }
|
|
10
|
+
|
|
11
|
+
function error(message) { this.context.error(message); }
|
|
12
|
+
|
|
13
|
+
function fatal(message) { this.context.fatal(message); }
|
|
14
|
+
|
|
15
|
+
const loggingMixins = {
|
|
16
|
+
trace,
|
|
17
|
+
debug,
|
|
18
|
+
info,
|
|
19
|
+
warning,
|
|
20
|
+
error,
|
|
21
|
+
fatal
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default loggingMixins;
|
package/src/rule.js
CHANGED
|
@@ -23,7 +23,7 @@ export default class Rule {
|
|
|
23
23
|
return this.conclusion;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
matchMetastatement(metastatementNode,
|
|
26
|
+
matchMetastatement(metastatementNode, metaproofContext) {
|
|
27
27
|
let metastatementNatches;
|
|
28
28
|
|
|
29
29
|
const premisesLength = this.premises.length;
|
|
@@ -34,7 +34,7 @@ export default class Rule {
|
|
|
34
34
|
|
|
35
35
|
metastatementNatches = conclusionMatches; ///
|
|
36
36
|
} else {
|
|
37
|
-
const metaAssertions =
|
|
37
|
+
const metaAssertions = metaproofContext.getMetaAssertions();
|
|
38
38
|
|
|
39
39
|
metastatementNatches = someSubArray(metaAssertions, premisesLength, (metaAssertions) => {
|
|
40
40
|
const premisesMatchConclusion = matchPremisesAndConclusion(this.premises, this.conclusion, metaAssertions, metastatementNode);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
const { first } = arrayUtilities;
|
|
6
|
+
|
|
7
|
+
export function checkCyclicDependencyExists(name, dependentNames, releaseContext) {
|
|
8
|
+
const dependentNamesIncludesName = dependentNames.includes(name),
|
|
9
|
+
cyclicDependencyExists = dependentNamesIncludesName; ///
|
|
10
|
+
|
|
11
|
+
if (cyclicDependencyExists) {
|
|
12
|
+
const firstDependentName = first(dependentNames),
|
|
13
|
+
dependencyNames = dependentNames.concat(firstDependentName),
|
|
14
|
+
dependencyNamesString = dependencyNames.join(`' -> '`);
|
|
15
|
+
|
|
16
|
+
releaseContext.error(`There is a cyclic dependency: '${dependencyNamesString}'.`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return cyclicDependencyExists;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function checkReleaseMatchesShortenedVersion(releaseContext, shortenedVersion) {
|
|
23
|
+
const release = releaseContext.getRelease(),
|
|
24
|
+
releaseMatchesShortedVersion = release.matchShortenedVersion(shortenedVersion);
|
|
25
|
+
|
|
26
|
+
if (!releaseMatchesShortedVersion) {
|
|
27
|
+
const name = releaseContext.getName(),
|
|
28
|
+
version = releaseContext.getVersion(),
|
|
29
|
+
versionString = version.toString(),
|
|
30
|
+
shortenedVersionString = shortenedVersion.toString();
|
|
31
|
+
|
|
32
|
+
releaseContext.error(`The '${name}' package's version of ${versionString} does not match the dependency's shortened version of ${shortenedVersionString}.`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return releaseMatchesShortedVersion;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default {
|
|
39
|
+
checkCyclicDependencyExists,
|
|
40
|
+
checkReleaseMatchesShortenedVersion
|
|
41
|
+
};
|
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import verifyUnqualifiedStatement from "../verify/
|
|
3
|
+
import verifyUnqualifiedStatement from "../verify/statement/unqualified";
|
|
4
4
|
|
|
5
5
|
import { nodesQuery } from "../utilities/query";
|
|
6
6
|
|
|
7
7
|
const unqualifiedStatementNodesQuery = nodesQuery("/indicativeConditional/unqualifiedStatement");
|
|
8
8
|
|
|
9
|
-
export default function verifyIndicativeConditional(indicativeConditionalNode, statementNodes,
|
|
10
|
-
|
|
11
|
-
indicativeConditionalVerified = unqualifiedStatementNodes.every((unqualifiedStatementNode) => {
|
|
12
|
-
const unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, context);
|
|
9
|
+
export default function verifyIndicativeConditional(indicativeConditionalNode, statementNodes, proofContext) {
|
|
10
|
+
let indicativeConditionalVerified;
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
proofContext.begin(indicativeConditionalNode);
|
|
13
|
+
|
|
14
|
+
const unqualifiedStatementNodes = unqualifiedStatementNodesQuery(indicativeConditionalNode);
|
|
15
|
+
|
|
16
|
+
indicativeConditionalVerified = unqualifiedStatementNodes.every((unqualifiedStatementNode) => {
|
|
17
|
+
const unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, proofContext);
|
|
18
|
+
|
|
19
|
+
if (unqualifiedStatementVerified) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
indicativeConditionalVerified ?
|
|
25
|
+
proofContext.complete(indicativeConditionalNode) :
|
|
26
|
+
proofContext.halt(indicativeConditionalNode);
|
|
18
27
|
|
|
19
28
|
return indicativeConditionalVerified;
|
|
20
29
|
}
|
|
@@ -9,17 +9,19 @@ import { nodeQuery, typeNameFromTypeNode } from "../../utilities/query";
|
|
|
9
9
|
const termNodeQuery = nodeQuery("/typeAssertion/term"),
|
|
10
10
|
typeNodeQuery = nodeQuery("/typeAssertion/type");
|
|
11
11
|
|
|
12
|
-
export default function verifyTypeAssertion(typeAssertionNode,
|
|
12
|
+
export default function verifyTypeAssertion(typeAssertionNode, proofContext) {
|
|
13
13
|
let typeAssertionVerified = false;
|
|
14
14
|
|
|
15
|
+
proofContext.begin(typeAssertionNode);
|
|
16
|
+
|
|
15
17
|
const typeNode = typeNodeQuery(typeAssertionNode),
|
|
16
18
|
typeName = typeNameFromTypeNode(typeNode),
|
|
17
|
-
typePresent =
|
|
19
|
+
typePresent = proofContext.isTypePresentByTypeName(typeName);
|
|
18
20
|
|
|
19
21
|
if (!typePresent) {
|
|
20
|
-
|
|
22
|
+
proofContext.error(`The ${typeName} type is not present.`);
|
|
21
23
|
} else {
|
|
22
|
-
const derived =
|
|
24
|
+
const derived = proofContext.isDerived();
|
|
23
25
|
|
|
24
26
|
if (derived) {
|
|
25
27
|
debugger
|
|
@@ -27,6 +29,7 @@ export default function verifyTypeAssertion(typeAssertionNode, context) {
|
|
|
27
29
|
const types = [],
|
|
28
30
|
names = [],
|
|
29
31
|
values = [],
|
|
32
|
+
context = proofContext, ///
|
|
30
33
|
termNode = termNodeQuery(typeAssertionNode),
|
|
31
34
|
termVerified = verifyTermAsVariable(termNode, types, names, values, context);
|
|
32
35
|
|
|
@@ -37,20 +40,20 @@ export default function verifyTypeAssertion(typeAssertionNode, context) {
|
|
|
37
40
|
value = firstValue;
|
|
38
41
|
|
|
39
42
|
if (value !== undefined) {
|
|
40
|
-
|
|
43
|
+
proofContext.error(`The value of the ${variableName} variable is not undefined.`);
|
|
41
44
|
} else {
|
|
42
|
-
const type =
|
|
45
|
+
const type = proofContext.findTypeByTypeName(typeName),
|
|
43
46
|
firstType = first(types),
|
|
44
47
|
variableType = firstType, ///
|
|
45
48
|
typeSubTypeOfVariableType = type.isSubTypeOf(variableType);
|
|
46
49
|
|
|
47
50
|
if (!typeSubTypeOfVariableType) {
|
|
48
|
-
|
|
51
|
+
proofContext.error(`The asserted type of the ${variableName} variable is not a sub-type of its declared type.`);
|
|
49
52
|
} else {
|
|
50
53
|
const name = variableName, ///
|
|
51
54
|
variable = Variable.fromTypeAndName(type, name);
|
|
52
55
|
|
|
53
|
-
|
|
56
|
+
proofContext.addVariable(variable);
|
|
54
57
|
|
|
55
58
|
typeAssertionVerified = true;
|
|
56
59
|
}
|
|
@@ -59,5 +62,9 @@ export default function verifyTypeAssertion(typeAssertionNode, context) {
|
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
|
|
65
|
+
typeAssertionVerified ?
|
|
66
|
+
proofContext.complete(typeAssertionNode) :
|
|
67
|
+
proofContext.halt(typeAssertionNode);
|
|
68
|
+
|
|
62
69
|
return typeAssertionVerified;
|
|
63
70
|
}
|
package/src/verify/axiom.js
CHANGED
|
@@ -13,30 +13,28 @@ const labelNodesQuery = nodesQuery("/axiom/label"),
|
|
|
13
13
|
unqualifiedStatementNodeQuery = nodeQuery("/axiom/unqualifiedStatement!"),
|
|
14
14
|
indicativeConditionalNodeQuery = nodeQuery("/axiom/indicativeConditional!");
|
|
15
15
|
|
|
16
|
-
export default function verifyAxiom(axiomNode,
|
|
17
|
-
|
|
18
|
-
labelsString = nodesAsString(labelNodes);
|
|
19
|
-
|
|
20
|
-
context.debug(`Verifying the '${labelsString}' axiom...`, axiomNode);
|
|
21
|
-
|
|
22
|
-
const proofContext = ProofContext.fromContext(context);
|
|
16
|
+
export default function verifyAxiom(axiomNode, fileContext) {
|
|
17
|
+
let axiomVerified = false;
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
fileContext.begin(axiomNode);
|
|
25
20
|
|
|
26
|
-
const
|
|
21
|
+
const labelNodes = labelNodesQuery(axiomNode),
|
|
22
|
+
labelsString = nodesAsString(labelNodes),
|
|
23
|
+
proofContext = ProofContext.fromFileContext(fileContext),
|
|
24
|
+
unqualifiedStatementNode = unqualifiedStatementNodeQuery(axiomNode),
|
|
27
25
|
indicativeConditionalNode = indicativeConditionalNodeQuery(axiomNode);
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
fileContext.debug(`Verifying the '${labelsString}' axiom...`);
|
|
30
28
|
|
|
31
29
|
if (unqualifiedStatementNode !== null) {
|
|
32
|
-
const unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode,
|
|
30
|
+
const unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, proofContext);
|
|
33
31
|
|
|
34
32
|
if (unqualifiedStatementVerified) {
|
|
35
33
|
const statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
36
34
|
labels = labelsString, ///
|
|
37
35
|
axiom = Axiom.fromStatementNodeAndLabels(statementNode, labels);
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
fileContext.addAxiom(axiom);
|
|
40
38
|
|
|
41
39
|
axiomVerified = true;
|
|
42
40
|
}
|
|
@@ -44,7 +42,7 @@ export default function verifyAxiom(axiomNode, context) {
|
|
|
44
42
|
|
|
45
43
|
if (indicativeConditionalNode !== null) {
|
|
46
44
|
const statementNodes = [],
|
|
47
|
-
indicativeConditionalVerified = verifyIndicativeConditional(indicativeConditionalNode, statementNodes,
|
|
45
|
+
indicativeConditionalVerified = verifyIndicativeConditional(indicativeConditionalNode, statementNodes, proofContext);
|
|
48
46
|
|
|
49
47
|
if (indicativeConditionalVerified !== null) {
|
|
50
48
|
const labels = labelsString, ///
|
|
@@ -54,15 +52,15 @@ export default function verifyAxiom(axiomNode, context) {
|
|
|
54
52
|
consequentStatementNode = secondStatementNode, ///
|
|
55
53
|
axiom = Axiom.fromSuppositionStatementNodeConsequentStatementNodeAndLabels(suppositionStatementNode, consequentStatementNode, labels);
|
|
56
54
|
|
|
57
|
-
|
|
55
|
+
fileContext.addAxiom(axiom);
|
|
58
56
|
|
|
59
57
|
axiomVerified = true;
|
|
60
58
|
}
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
axiomVerified ?
|
|
62
|
+
fileContext.complete(axiomNode) :
|
|
63
|
+
fileContext.halt(axiomNode);
|
|
66
64
|
|
|
67
65
|
return axiomVerified;
|
|
68
66
|
}
|
package/src/verify/conclusion.js
CHANGED
|
@@ -8,13 +8,15 @@ import { nodeQuery } from "../utilities/query";
|
|
|
8
8
|
const metastatementNodeQuery = nodeQuery("/*/metastatement!"),
|
|
9
9
|
unqualifiedMetastatementNodeQuery = nodeQuery("/conclusion/unqualifiedMetastatement!");
|
|
10
10
|
|
|
11
|
-
export default function verifyConclusion(conclusionNode, conclusions,
|
|
11
|
+
export default function verifyConclusion(conclusionNode, conclusions, metaproofContext) {
|
|
12
12
|
let conclusionVerified = false;
|
|
13
13
|
|
|
14
|
+
metaproofContext.begin(conclusionNode);
|
|
15
|
+
|
|
14
16
|
const unqualifiedMetastatementNode = unqualifiedMetastatementNodeQuery(conclusionNode);
|
|
15
17
|
|
|
16
18
|
if (unqualifiedMetastatementNode !== null) {
|
|
17
|
-
const unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode,
|
|
19
|
+
const unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, metaproofContext);
|
|
18
20
|
|
|
19
21
|
if (unqualifiedMetastatementVerified) {
|
|
20
22
|
const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode),
|
|
@@ -26,5 +28,9 @@ export default function verifyConclusion(conclusionNode, conclusions, context) {
|
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
|
|
31
|
+
conclusionVerified ?
|
|
32
|
+
metaproofContext.complete(conclusionNode) :
|
|
33
|
+
metaproofContext.halt(conclusionNode);
|
|
34
|
+
|
|
29
35
|
return conclusionVerified;
|
|
30
36
|
}
|
|
@@ -8,18 +8,24 @@ import { nodeQuery } from "../utilities/query";
|
|
|
8
8
|
const conclusionNodeQuery = nodeQuery("/conditionalInference/conclusion!"),
|
|
9
9
|
premiseOrPremisesNodeQuery = nodeQuery("/conditionalInference/premise|premises!");
|
|
10
10
|
|
|
11
|
-
export default function verifyConditionalInference(conditionalInferenceNode, premises, conclusions,
|
|
11
|
+
export default function verifyConditionalInference(conditionalInferenceNode, premises, conclusions, metaproofContext) {
|
|
12
12
|
let conditionalInferenceVerified = false;
|
|
13
13
|
|
|
14
|
+
metaproofContext.begin(conditionalInferenceNode);
|
|
15
|
+
|
|
14
16
|
const conclusionNode = conclusionNodeQuery(conditionalInferenceNode),
|
|
15
17
|
premiseOrPremisesNode = premiseOrPremisesNodeQuery(conditionalInferenceNode),
|
|
16
|
-
premiseOrPremisesVerified = verifyPremiseOrPremises(premiseOrPremisesNode, premises,
|
|
18
|
+
premiseOrPremisesVerified = verifyPremiseOrPremises(premiseOrPremisesNode, premises, metaproofContext);
|
|
17
19
|
|
|
18
20
|
if (premiseOrPremisesVerified) {
|
|
19
|
-
const conclusionVerified = verifyConclusion(conclusionNode, conclusions,
|
|
21
|
+
const conclusionVerified = verifyConclusion(conclusionNode, conclusions, metaproofContext);
|
|
20
22
|
|
|
21
|
-
conditionalInferenceVerified = conclusionVerified;
|
|
23
|
+
conditionalInferenceVerified = conclusionVerified; ///
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
conditionalInferenceVerified ?
|
|
27
|
+
metaproofContext.complete(conditionalInferenceNode) :
|
|
28
|
+
metaproofContext.halt(conditionalInferenceNode);
|
|
29
|
+
|
|
24
30
|
return conditionalInferenceVerified;
|
|
25
31
|
}
|
|
@@ -6,10 +6,19 @@ import { nodeQuery } from "../../utilities/query";
|
|
|
6
6
|
|
|
7
7
|
const statementNodeQuery = nodeQuery("/combinatorDeclaration/statement");
|
|
8
8
|
|
|
9
|
-
export default function verifyCombinatorDeclaration(combinatorDeclarationNode,
|
|
9
|
+
export default function verifyCombinatorDeclaration(combinatorDeclarationNode, fileContext) {
|
|
10
|
+
let combinatorDeclarationVerified;
|
|
11
|
+
|
|
12
|
+
fileContext.begin(combinatorDeclarationNode);
|
|
13
|
+
|
|
10
14
|
const statementNode = statementNodeQuery(combinatorDeclarationNode),
|
|
11
|
-
statementVerifiedAsCombinator = verifyStatementAsCombinator(statementNode,
|
|
12
|
-
|
|
15
|
+
statementVerifiedAsCombinator = verifyStatementAsCombinator(statementNode, fileContext);
|
|
16
|
+
|
|
17
|
+
combinatorDeclarationVerified = statementVerifiedAsCombinator; ///
|
|
18
|
+
|
|
19
|
+
combinatorDeclarationVerified ?
|
|
20
|
+
fileContext.complete(combinatorDeclarationNode) :
|
|
21
|
+
fileContext.halt(combinatorDeclarationNode);
|
|
13
22
|
|
|
14
23
|
return combinatorDeclarationVerified;
|
|
15
24
|
}
|
|
@@ -7,11 +7,20 @@ import { nodeQuery } from "../../utilities/query";
|
|
|
7
7
|
const termNodeQuery = nodeQuery("/constructorDeclaration/term"),
|
|
8
8
|
typeNodeQuery = nodeQuery("/constructorDeclaration/type");
|
|
9
9
|
|
|
10
|
-
export default function verifyConstructorDeclaration(constructorDeclarationNode,
|
|
10
|
+
export default function verifyConstructorDeclaration(constructorDeclarationNode, fileContext) {
|
|
11
|
+
let constructorDeclarationVerified;
|
|
12
|
+
|
|
13
|
+
fileContext.begin(constructorDeclarationNode);
|
|
14
|
+
|
|
11
15
|
const termNode = termNodeQuery(constructorDeclarationNode),
|
|
12
16
|
typeNode = typeNodeQuery(constructorDeclarationNode),
|
|
13
|
-
termVerifiedAsConstructor = verifyTermAsConstructor(termNode, typeNode,
|
|
14
|
-
|
|
17
|
+
termVerifiedAsConstructor = verifyTermAsConstructor(termNode, typeNode, fileContext);
|
|
18
|
+
|
|
19
|
+
constructorDeclarationVerified = termVerifiedAsConstructor; ///
|
|
20
|
+
|
|
21
|
+
constructorDeclarationVerified ?
|
|
22
|
+
fileContext.complete(constructorDeclarationNode) :
|
|
23
|
+
fileContext.halt(constructorDeclarationNode);
|
|
15
24
|
|
|
16
25
|
return constructorDeclarationVerified;
|
|
17
26
|
}
|