occam-verify-cli 0.0.450 → 0.0.451
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/lib/constructor.js +8 -6
- package/lib/context/file.js +43 -3
- package/lib/context/release/directory.js +20 -1
- package/lib/context/release/file.js +26 -3
- package/lib/kinds.js +5 -1
- package/lib/lemma.js +146 -0
- package/lib/verify/assertion/type.js +57 -7
- package/lib/verify/declaration/topLevel.js +7 -3
- package/lib/verify/lemma.js +61 -0
- package/lib/verify/release.js +5 -5
- package/lib/verify/term.js +55 -22
- package/package.json +1 -1
- package/src/constructor.js +7 -5
- package/src/context/file.js +48 -2
- package/src/context/release/directory.js +24 -0
- package/src/context/release/file.js +32 -3
- package/src/kinds.js +1 -0
- package/src/lemma.js +130 -0
- package/src/verify/assertion/type.js +26 -9
- package/src/verify/declaration/topLevel.js +7 -0
- package/src/verify/lemma.js +86 -0
- package/src/verify/release.js +5 -5
- package/src/verify/term.js +68 -19
- package/lib/verify/termAsVariable.js +0 -33
- package/src/verify/termAsVariable.js +0 -41
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Lemma from "../lemma";
|
|
4
|
+
import verifyLabels from "../verify/labels";
|
|
5
|
+
import ProofContext from "../context/proof";
|
|
6
|
+
import verifyUnqualifiedStatement from "../verify/statement/unqualified";
|
|
7
|
+
import verifyIndicativeConditional from "../verify/indicativeConditional";
|
|
8
|
+
|
|
9
|
+
import { front, last } from "../utilities/array";
|
|
10
|
+
import { nodesAsString } from "../utilities/string";
|
|
11
|
+
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
12
|
+
|
|
13
|
+
const labelNodesQuery = nodesQuery("/lemma/label"),
|
|
14
|
+
statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
|
|
15
|
+
statementNodesQuery = nodesQuery("/indicativeConditional/unqualifiedStatement/statement!"),
|
|
16
|
+
unqualifiedStatementNodeQuery = nodeQuery("/lemma/unqualifiedStatement!"),
|
|
17
|
+
indicativeConditionalNodeQuery = nodeQuery("/lemma/indicativeConditional!");
|
|
18
|
+
|
|
19
|
+
export default function verifyLemma(lemmaNode, fileContext) {
|
|
20
|
+
let lemmaVerified = false;
|
|
21
|
+
|
|
22
|
+
fileContext.begin(lemmaNode);
|
|
23
|
+
|
|
24
|
+
const labelNodes = labelNodesQuery(lemmaNode),
|
|
25
|
+
labelsString = nodesAsString(labelNodes),
|
|
26
|
+
proofContext = ProofContext.fromFileContext(fileContext);
|
|
27
|
+
|
|
28
|
+
(labelsString === null) ?
|
|
29
|
+
fileContext.debug(`Verifying an anonymous lemma...`) :
|
|
30
|
+
fileContext.debug(`Verifying the '${labelsString}' lemma...`);
|
|
31
|
+
|
|
32
|
+
const labels = [],
|
|
33
|
+
labelsLength = labels.length,
|
|
34
|
+
labelsVerified = verifyLabels(labelNodes, labels, fileContext);
|
|
35
|
+
|
|
36
|
+
if (labelsVerified) {
|
|
37
|
+
const unqualifiedStatementNode = unqualifiedStatementNodeQuery(lemmaNode),
|
|
38
|
+
indicativeConditionalNode = indicativeConditionalNodeQuery(lemmaNode);
|
|
39
|
+
|
|
40
|
+
if (unqualifiedStatementNode !== null) {
|
|
41
|
+
const unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, proofContext);
|
|
42
|
+
|
|
43
|
+
if (unqualifiedStatementVerified) {
|
|
44
|
+
if (labelsLength > 0) {
|
|
45
|
+
const statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
46
|
+
lemma = Lemma.fromLabelsAndStatementNode(labels, statementNode);
|
|
47
|
+
|
|
48
|
+
fileContext.addLemma(lemma);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
lemmaVerified = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (indicativeConditionalNode !== null) {
|
|
56
|
+
const indicativeConditionalVerified = verifyIndicativeConditional(indicativeConditionalNode, proofContext);
|
|
57
|
+
|
|
58
|
+
if (indicativeConditionalVerified !== null) {
|
|
59
|
+
if (labelsLength) {
|
|
60
|
+
const statementNodes = statementNodesQuery(indicativeConditionalNode),
|
|
61
|
+
lastStatementNode = last(statementNodes),
|
|
62
|
+
frontStatementNodes = front(statementNodes),
|
|
63
|
+
consequentStatementNode = lastStatementNode, ///
|
|
64
|
+
suppositionStatementNodes = frontStatementNodes, ///
|
|
65
|
+
lemma = Lemma.fromLabelsSuppositionStatementNodesAndConsequentStatementNode(labels, suppositionStatementNodes, consequentStatementNode);
|
|
66
|
+
|
|
67
|
+
fileContext.addLemma(lemma);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
lemmaVerified = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (lemmaVerified) {
|
|
76
|
+
(labelsString === null) ?
|
|
77
|
+
fileContext.info(`Verified an anonymous lemma.`) :
|
|
78
|
+
fileContext.info(`Verified the '${labelsString}' lemma.`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
lemmaVerified ?
|
|
82
|
+
fileContext.complete(lemmaNode) :
|
|
83
|
+
fileContext.halt(lemmaNode);
|
|
84
|
+
|
|
85
|
+
return lemmaVerified;
|
|
86
|
+
}
|
package/src/verify/release.js
CHANGED
|
@@ -16,7 +16,7 @@ export default function verifyRelease(releaseName, releaseContextMap) {
|
|
|
16
16
|
if (verified) {
|
|
17
17
|
releaseVerified = true;
|
|
18
18
|
} else {
|
|
19
|
-
releaseContext.debug(`Verifying
|
|
19
|
+
releaseContext.debug(`Verifying '${releaseName}'...`);
|
|
20
20
|
|
|
21
21
|
const releaseFilesVerified = verifyReleaseFiles(releaseContext);
|
|
22
22
|
|
|
@@ -27,11 +27,11 @@ export default function verifyRelease(releaseName, releaseContextMap) {
|
|
|
27
27
|
|
|
28
28
|
releaseVerified = verified; ///
|
|
29
29
|
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
if (releaseVerified) {
|
|
32
|
+
releaseContext.info(`Verified '${releaseName}'.`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
package/src/verify/term.js
CHANGED
|
@@ -1,52 +1,101 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import verifyTermAsVariable from "../verify/termAsVariable";
|
|
4
|
-
|
|
5
3
|
import { first } from "../utilities/array";
|
|
6
4
|
import { nodeAsString } from "../utilities/string";
|
|
7
5
|
import { ARGUMENT_RULE_NAME } from "../ruleNames";
|
|
8
|
-
import { nodeQuery, typeNameFromTypeNode } from "../utilities/query";
|
|
6
|
+
import { nodeQuery, typeNameFromTypeNode, variableNameFromVariableNode } from "../utilities/query";
|
|
9
7
|
|
|
10
8
|
const termNodeQuery = nodeQuery("/argument/term!"),
|
|
11
|
-
typeNodeQuery = nodeQuery("/argument/type!")
|
|
9
|
+
typeNodeQuery = nodeQuery("/argument/type!"),
|
|
10
|
+
variableNodeQuery = nodeQuery("/term/variable!");
|
|
12
11
|
|
|
13
12
|
export default function verifyTerm(termNode, types, values, context) {
|
|
14
13
|
let termVerified = false;
|
|
15
14
|
|
|
16
15
|
context.begin(termNode);
|
|
17
16
|
|
|
18
|
-
const
|
|
19
|
-
termVerifiedAsVariable = verifyTermAsVariable(termNode, types, names, values, context);
|
|
17
|
+
const termVerifiedAsVariable = verifyTermAsVariable(termNode, types, values, context);
|
|
20
18
|
|
|
21
19
|
if (termVerifiedAsVariable) {
|
|
22
20
|
termVerified = true;
|
|
23
21
|
} else {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const termVerifiedAgainstConstructors = verifyTermAgainstConstructors(termNode, types, values, context);
|
|
23
|
+
|
|
24
|
+
if (termVerifiedAgainstConstructors) {
|
|
25
|
+
termVerified = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
termVerified ?
|
|
30
|
+
context.complete(termNode) :
|
|
31
|
+
context.halt(termNode);
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
return termVerified;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function verifyTermAsVariable(termNode, types, values, context) {
|
|
37
|
+
let termVerifiedAsVariable = false;
|
|
38
|
+
|
|
39
|
+
context.begin(termNode);
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
const variableNode = variableNodeQuery(termNode);
|
|
42
|
+
|
|
43
|
+
if (variableNode !== null) {
|
|
44
|
+
const variableName = variableNameFromVariableNode(variableNode),
|
|
45
|
+
variablePresent = context.isVariablePresentByVariableName(variableName);
|
|
46
|
+
|
|
47
|
+
if (!variablePresent) {
|
|
48
|
+
context.error(`The ${variableName} variable is not present.`)
|
|
49
|
+
} else {
|
|
50
|
+
const variable = context.findVariableByVariableName(variableName),
|
|
51
|
+
type = variable.getType(),
|
|
52
|
+
value = variable.getValue();
|
|
36
53
|
|
|
37
54
|
types.push(type);
|
|
38
55
|
|
|
39
56
|
values.push(value);
|
|
40
57
|
|
|
41
|
-
|
|
58
|
+
termVerifiedAsVariable = true;
|
|
42
59
|
}
|
|
43
60
|
}
|
|
44
61
|
|
|
45
|
-
|
|
62
|
+
termVerifiedAsVariable ?
|
|
46
63
|
context.complete(termNode) :
|
|
47
64
|
context.halt(termNode);
|
|
48
65
|
|
|
49
|
-
return
|
|
66
|
+
return termVerifiedAsVariable;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function verifyTermAgainstConstructors(termNode, types, values, context) {
|
|
70
|
+
let termVerifiedAgainstConstructors = false;
|
|
71
|
+
|
|
72
|
+
context.begin(termNode);
|
|
73
|
+
|
|
74
|
+
const constructors = context.getConstructors(),
|
|
75
|
+
constructor = constructors.find((constructor) => {
|
|
76
|
+
const termVerifiedAgainstConstructor = verifyTermAgainstConstructor(termNode, constructor, context);
|
|
77
|
+
|
|
78
|
+
if (termVerifiedAgainstConstructor) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
}) || null;
|
|
82
|
+
|
|
83
|
+
if (constructor !== null) {
|
|
84
|
+
const type = constructor.getType(),
|
|
85
|
+
value = termNode; ///
|
|
86
|
+
|
|
87
|
+
types.push(type);
|
|
88
|
+
|
|
89
|
+
values.push(value);
|
|
90
|
+
|
|
91
|
+
termVerifiedAgainstConstructors = true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
termVerifiedAgainstConstructors ?
|
|
95
|
+
context.complete(termNode) :
|
|
96
|
+
context.halt(termNode);
|
|
97
|
+
|
|
98
|
+
return termVerifiedAgainstConstructors;
|
|
50
99
|
}
|
|
51
100
|
|
|
52
101
|
function verifyTermAgainstConstructor(termNode, constructor, context) {
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return verifyTermAsVariable;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
var _query = require("../utilities/query");
|
|
12
|
-
var variableNodeQuery = (0, _query.nodeQuery)("/term/variable!");
|
|
13
|
-
function verifyTermAsVariable(termNode, types, names, values, context) {
|
|
14
|
-
var termVerifiedAsVariable = false;
|
|
15
|
-
context.begin(termNode);
|
|
16
|
-
var variableNode = variableNodeQuery(termNode);
|
|
17
|
-
if (variableNode !== null) {
|
|
18
|
-
var variableName = (0, _query.variableNameFromVariableNode)(variableNode), variablePresent = context.isVariablePresentByVariableName(variableName);
|
|
19
|
-
if (!variablePresent) {
|
|
20
|
-
context.error("The ".concat(variableName, " variable is not present."));
|
|
21
|
-
} else {
|
|
22
|
-
var variable = context.findVariableByVariableName(variableName), type = variable.getType(), name = variableName, value = variable.getValue();
|
|
23
|
-
types.push(type);
|
|
24
|
-
names.push(name);
|
|
25
|
-
values.push(value);
|
|
26
|
-
termVerifiedAsVariable = true;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
termVerifiedAsVariable ? context.complete(termNode) : context.halt(termNode);
|
|
30
|
-
return termVerifiedAsVariable;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92ZXJpZnkvdGVybUFzVmFyaWFibGUuanMiXSwic291cmNlc0NvbnRlbnQiOlsiXCJ1c2Ugc3RyaWN0XCI7XG5cbmltcG9ydCB7IG5vZGVRdWVyeSwgdmFyaWFibGVOYW1lRnJvbVZhcmlhYmxlTm9kZX0gZnJvbSBcIi4uL3V0aWxpdGllcy9xdWVyeVwiO1xuXG5jb25zdCB2YXJpYWJsZU5vZGVRdWVyeSA9IG5vZGVRdWVyeShcIi90ZXJtL3ZhcmlhYmxlIVwiKTtcblxuZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gdmVyaWZ5VGVybUFzVmFyaWFibGUodGVybU5vZGUsIHR5cGVzLCBuYW1lcywgdmFsdWVzLCBjb250ZXh0KSB7XG4gIGxldCB0ZXJtVmVyaWZpZWRBc1ZhcmlhYmxlID0gZmFsc2U7XG5cbiAgY29udGV4dC5iZWdpbih0ZXJtTm9kZSk7XG5cbiAgY29uc3QgdmFyaWFibGVOb2RlID0gdmFyaWFibGVOb2RlUXVlcnkodGVybU5vZGUpO1xuXG4gIGlmICh2YXJpYWJsZU5vZGUgIT09IG51bGwpIHtcbiAgICBjb25zdCB2YXJpYWJsZU5hbWUgPSB2YXJpYWJsZU5hbWVGcm9tVmFyaWFibGVOb2RlKHZhcmlhYmxlTm9kZSksXG4gICAgICAgICAgdmFyaWFibGVQcmVzZW50ID0gY29udGV4dC5pc1ZhcmlhYmxlUHJlc2VudEJ5VmFyaWFibG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FRaUIsUUFBUSxDQUFDckIsWUFDZkksUUFBUWtCLElBQUksQ0FBQ3RCLFNBQVM7SUFFMUIsT0FBT0s7QUFDVCJ9
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { nodeQuery, variableNameFromVariableNode} from "../utilities/query";
|
|
4
|
-
|
|
5
|
-
const variableNodeQuery = nodeQuery("/term/variable!");
|
|
6
|
-
|
|
7
|
-
export default function verifyTermAsVariable(termNode, types, names, values, context) {
|
|
8
|
-
let termVerifiedAsVariable = false;
|
|
9
|
-
|
|
10
|
-
context.begin(termNode);
|
|
11
|
-
|
|
12
|
-
const variableNode = variableNodeQuery(termNode);
|
|
13
|
-
|
|
14
|
-
if (variableNode !== null) {
|
|
15
|
-
const variableName = variableNameFromVariableNode(variableNode),
|
|
16
|
-
variablePresent = context.isVariablePresentByVariableName(variableName);
|
|
17
|
-
|
|
18
|
-
if (!variablePresent) {
|
|
19
|
-
context.error(`The ${variableName} variable is not present.`)
|
|
20
|
-
} else {
|
|
21
|
-
const variable = context.findVariableByVariableName(variableName),
|
|
22
|
-
type = variable.getType(),
|
|
23
|
-
name = variableName, ///
|
|
24
|
-
value = variable.getValue();
|
|
25
|
-
|
|
26
|
-
types.push(type);
|
|
27
|
-
|
|
28
|
-
names.push(name);
|
|
29
|
-
|
|
30
|
-
values.push(value);
|
|
31
|
-
|
|
32
|
-
termVerifiedAsVariable = true;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
termVerifiedAsVariable ?
|
|
37
|
-
context.complete(termNode) :
|
|
38
|
-
context.halt(termNode);
|
|
39
|
-
|
|
40
|
-
return termVerifiedAsVariable;
|
|
41
|
-
}
|