occam-verify-cli 0.0.455 → 0.0.457
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/axiom.js +26 -46
- package/lib/combinator.js +2 -3
- package/lib/conclusion.js +2 -3
- package/lib/constructor.js +2 -3
- package/lib/context/file.js +5 -1
- package/lib/context/release/file.js +17 -4
- package/lib/label.js +2 -3
- package/lib/lemma.js +26 -46
- package/lib/premise.js +2 -3
- package/lib/ruleNames.js +5 -1
- package/lib/theorem.js +26 -46
- package/lib/utilities/string.js +46 -1
- package/lib/verify/assertion/type.js +55 -0
- package/lib/verify/axiom.js +10 -15
- package/lib/verify/equality.js +7 -1
- package/lib/verify/lemma.js +13 -22
- package/lib/verify/metastatement/qualified.js +4 -3
- package/lib/verify/metastatement/unqualified.js +14 -9
- package/lib/verify/metastatement.js +19 -0
- package/lib/verify/statement/qualified.js +14 -11
- package/lib/verify/statement/unqualified.js +13 -9
- package/lib/verify/statement.js +5 -8
- package/lib/verify/statementAsCombinator.js +3 -2
- package/lib/verify/term.js +6 -1
- package/lib/verify/termAsConstructor.js +5 -5
- package/lib/verify/theorem.js +10 -15
- package/lib/verify/type.js +8 -7
- package/lib/verify/variable.js +4 -3
- package/package.json +3 -3
- package/src/axiom.js +27 -54
- package/src/combinator.js +3 -3
- package/src/conclusion.js +3 -3
- package/src/constructor.js +3 -3
- package/src/context/file.js +6 -0
- package/src/context/release/file.js +17 -4
- package/src/label.js +3 -3
- package/src/lemma.js +28 -55
- package/src/premise.js +3 -3
- package/src/ruleNames.js +1 -0
- package/src/theorem.js +32 -59
- package/src/utilities/string.js +67 -0
- package/src/verify/assertion/type.js +32 -56
- package/src/verify/axiom.js +10 -24
- package/src/verify/equality.js +9 -0
- package/src/verify/lemma.js +14 -37
- package/src/verify/metastatement/qualified.js +5 -3
- package/src/verify/metastatement/unqualified.js +17 -10
- package/src/verify/metastatement.js +15 -0
- package/src/verify/statement/qualified.js +20 -8
- package/src/verify/statement/unqualified.js +16 -10
- package/src/verify/statement.js +5 -8
- package/src/verify/statementAsCombinator.js +4 -2
- package/src/verify/term.js +8 -0
- package/src/verify/termAsConstructor.js +5 -5
- package/src/verify/theorem.js +11 -25
- package/src/verify/type.js +9 -7
- package/src/verify/variable.js +5 -3
- package/lib/utilities/node.js +0 -45
- package/src/utilities/node.js +0 -50
package/src/theorem.js
CHANGED
|
@@ -5,36 +5,31 @@ import Label from "./label";
|
|
|
5
5
|
import { THEOREM_KIND } from "./kinds";
|
|
6
6
|
import { nodeAsString } from "./utilities/string";
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { unqualifiedStatementNodeFromUnqualifiedStatementString, indicativeConditionalNodeFromIndicativeConditionalString } from "./utilities/string";
|
|
9
9
|
|
|
10
10
|
export default class Theorem {
|
|
11
|
-
constructor(labels,
|
|
11
|
+
constructor(labels, unqualifiedStatementNode, indicativeConditionalNode) {
|
|
12
12
|
this.labels = labels;
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.consequentStatementNode = consequentStatementNode;
|
|
13
|
+
this.unqualifiedStatementNode = unqualifiedStatementNode;
|
|
14
|
+
this.indicativeConditionalNode = indicativeConditionalNode;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
getLabels() {
|
|
19
18
|
return this.labels;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
return this.
|
|
21
|
+
getUnqualifiedStatementNode() {
|
|
22
|
+
return this.unqualifiedStatementNode;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
return this.
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
getConsequentStatementNode() {
|
|
31
|
-
return this.consequentStatementNode;
|
|
25
|
+
getIndicativeConditionalNode() {
|
|
26
|
+
return this.indicativeConditionalNode;
|
|
32
27
|
}
|
|
33
28
|
|
|
34
29
|
matchLabelName(labelName) {
|
|
35
30
|
const matchesLabelName = this.labels.some((label) => {
|
|
36
31
|
const name = labelName, ///
|
|
37
|
-
|
|
32
|
+
labelMatchesName = label.matchName(name);
|
|
38
33
|
|
|
39
34
|
if (labelMatchesName) {
|
|
40
35
|
return true;
|
|
@@ -50,24 +45,17 @@ export default class Theorem {
|
|
|
50
45
|
|
|
51
46
|
return labelJSON;
|
|
52
47
|
}),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
suppositionStatementStrings = this.suppositionStatementNodes.map((suppositionStatementNode) => {
|
|
56
|
-
const suppositionStatementString = nodeAsString(suppositionStatementNode);
|
|
57
|
-
|
|
58
|
-
return suppositionStatementString;
|
|
59
|
-
}),
|
|
48
|
+
unqualifiedStatementString = nodeAsString(this.unqalifiedStatementNode),
|
|
49
|
+
indicativeConditionalString = nodeAsString(this.indicativeConditionalNode),
|
|
60
50
|
kind = THEOREM_KIND,
|
|
61
51
|
labels = labelsJSON, ///
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
suppositions = suppositionStatementStrings, ///
|
|
52
|
+
unqualifiedStatement = unqualifiedStatementString, ///
|
|
53
|
+
indicativeConditional = indicativeConditionalString, ///
|
|
65
54
|
json = {
|
|
66
55
|
kind,
|
|
67
56
|
labels,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
suppositions
|
|
57
|
+
unqualifiedStatement,
|
|
58
|
+
indicativeConditional
|
|
71
59
|
};
|
|
72
60
|
|
|
73
61
|
return json;
|
|
@@ -79,51 +67,36 @@ export default class Theorem {
|
|
|
79
67
|
const labelsJSON = labels; ///
|
|
80
68
|
|
|
81
69
|
labels = labelsJSON.map((labelJSON) => {
|
|
82
|
-
|
|
83
|
-
|
|
70
|
+
const json = labelJSON, ///
|
|
71
|
+
label = Label.fromJSON(json, releaseContext);
|
|
84
72
|
|
|
85
|
-
|
|
86
|
-
|
|
73
|
+
return label;
|
|
74
|
+
});
|
|
87
75
|
|
|
88
|
-
|
|
76
|
+
let { unqualifiedStatement, indicativeConditional } = json;
|
|
89
77
|
|
|
90
|
-
let
|
|
78
|
+
let unqualifiedStatementNode = null,
|
|
79
|
+
indicativeConditionalNode = null;
|
|
91
80
|
|
|
92
|
-
if (
|
|
93
|
-
const
|
|
94
|
-
statementNode = statementNodeFromStatementJSON(statementJSON, releaseContext),
|
|
95
|
-
suppositionStatementNodes = null,
|
|
96
|
-
consequentStatementNode = null;
|
|
81
|
+
if (unqualifiedStatement !== null) {
|
|
82
|
+
const unqualifiedStatementString = unqualifiedStatement; ///
|
|
97
83
|
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
const statementNode = null,
|
|
101
|
-
suppositionStatementsJSON = suppositions, ///
|
|
102
|
-
suppositionStatementNodes = suppositionStatementsJSON.map((suppositionStatementJSON) => {
|
|
103
|
-
const suppositionStatementNode = statementNodeFromStatementJSON(suppositionStatementJSON, releaseContext);
|
|
84
|
+
unqualifiedStatementNode = unqualifiedStatementNodeFromUnqualifiedStatementString(unqualifiedStatementString, releaseContext);
|
|
85
|
+
}
|
|
104
86
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
consequentStatementJSON = consequent, ///
|
|
108
|
-
consequentStatementNode = statementNodeFromStatementJSON(consequentStatementJSON, releaseContext);
|
|
87
|
+
if (indicativeConditional !== null) {
|
|
88
|
+
const indicativeConditionalString = indicativeConditional; ///
|
|
109
89
|
|
|
110
|
-
|
|
90
|
+
indicativeConditionalNode = indicativeConditionalNodeFromIndicativeConditionalString(indicativeConditionalString, releaseContext);
|
|
111
91
|
}
|
|
112
92
|
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
static fromLabelsAndStatementNode(labels, statementNode) {
|
|
117
|
-
const suppositionStatementNodes = [],
|
|
118
|
-
consequentStatementNode = null,
|
|
119
|
-
theorem = new Theorem(labels, statementNode, suppositionStatementNodes, consequentStatementNode);
|
|
93
|
+
const theorem = new Theorem(labels, unqualifiedStatementNode, indicativeConditionalNode);
|
|
120
94
|
|
|
121
95
|
return theorem;
|
|
122
96
|
}
|
|
123
97
|
|
|
124
|
-
static
|
|
125
|
-
const
|
|
126
|
-
theorem = new Theorem(labels, statementNode, suppositionStatementNodes, consequentStatementNode);
|
|
98
|
+
static fromLabelsUnqualifiedStatementNodeAndIndicativeConditionalNode(labels, unqualifiedStatementNode, indicativeConditionalNode) {
|
|
99
|
+
const theorem = new Theorem(labels, unqualifiedStatementNode, indicativeConditionalNode);
|
|
127
100
|
|
|
128
101
|
return theorem;
|
|
129
102
|
}
|
package/src/utilities/string.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { COMMA } from "../constants";
|
|
4
|
+
import { nodeQuery } from "../utilities/query";
|
|
5
|
+
import { TERM_RULE_NAME,
|
|
6
|
+
LABEL_RULE_NAME,
|
|
7
|
+
UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
8
|
+
INDICATIVE_CONDITIONAL_RULE_NAME,
|
|
9
|
+
UNQUALIFIED_METASTATEMENT_RULE_NAME} from "../ruleNames";
|
|
10
|
+
|
|
11
|
+
const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement"),
|
|
12
|
+
metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatement");
|
|
4
13
|
|
|
5
14
|
export function nodeAsString(node) {
|
|
6
15
|
let string = null;
|
|
@@ -45,3 +54,61 @@ export function nodesAsString(nodes) {
|
|
|
45
54
|
|
|
46
55
|
return string;
|
|
47
56
|
}
|
|
57
|
+
|
|
58
|
+
export function termNodeFromTermString(termString, releaseContext) {
|
|
59
|
+
const ruleName = TERM_RULE_NAME,
|
|
60
|
+
content = termString, ///
|
|
61
|
+
node = releaseContext.nodeFromContentAndRuleName(content, ruleName),
|
|
62
|
+
termNode = node; ///
|
|
63
|
+
|
|
64
|
+
return termNode;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function labelNodeFromLabelString(labelString, releaseContext) {
|
|
68
|
+
const content = labelString, ///
|
|
69
|
+
ruleName = LABEL_RULE_NAME,
|
|
70
|
+
node = releaseContext.nodeFromContentAndRuleName(content, ruleName),
|
|
71
|
+
labelNode = node; ///
|
|
72
|
+
|
|
73
|
+
return labelNode;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function statementNodeFromStatementString(statementString, releaseContext) {
|
|
77
|
+
const ruleName = UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
78
|
+
content = `${statementString}
|
|
79
|
+
`,
|
|
80
|
+
node = releaseContext.nodeFromContentAndRuleName(content, ruleName),
|
|
81
|
+
unqualifiedStatementNode = node, ///
|
|
82
|
+
statementNode = statementNodeQuery(unqualifiedStatementNode);
|
|
83
|
+
|
|
84
|
+
return statementNode;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function metastatementNodeFromMetastatementString(metastatementString, releaseContext) {
|
|
88
|
+
const ruleName = UNQUALIFIED_METASTATEMENT_RULE_NAME,
|
|
89
|
+
content = `${metastatementString}
|
|
90
|
+
`,
|
|
91
|
+
node = releaseContext.nodeFromContentAndRuleName(content, ruleName),
|
|
92
|
+
unqualifiedMetastatementNode = node, ///
|
|
93
|
+
metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode);
|
|
94
|
+
|
|
95
|
+
return metastatementNode;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function unqualifiedStatementNodeFromUnqualifiedStatementString(unqualifiedStatementString, releaseContext) {
|
|
99
|
+
const ruleName = UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
100
|
+
content = unqualifiedStatementString, ///
|
|
101
|
+
node = releaseContext.nodeFromContentAndRuleName(content, ruleName),
|
|
102
|
+
unqualifiedStatementNode = node; ///
|
|
103
|
+
|
|
104
|
+
return unqualifiedStatementNode;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function indicativeConditionalNodeFromIndicativeConditionalString(indicativeConditionalString, releaseContext) {
|
|
108
|
+
const ruleName = INDICATIVE_CONDITIONAL_RULE_NAME,
|
|
109
|
+
content = indicativeConditionalString, ///
|
|
110
|
+
node = releaseContext.nodeFromContentAndRuleName(content, ruleName),
|
|
111
|
+
indicativeConditionalNode = node; ///
|
|
112
|
+
|
|
113
|
+
return indicativeConditionalNode;
|
|
114
|
+
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import Variable from "../../variable";
|
|
4
|
-
|
|
5
3
|
import { first } from "../../utilities/array";
|
|
6
4
|
import { nodeAsString } from "../../utilities/string";
|
|
7
5
|
import { nodeQuery, typeNameFromTypeNode } from "../../utilities/query";
|
|
@@ -10,11 +8,15 @@ import { verifyTermAsVariable, verifyTermAgainstConstructors } from "../../verif
|
|
|
10
8
|
const termNodeQuery = nodeQuery("/typeAssertion/term"),
|
|
11
9
|
typeNodeQuery = nodeQuery("/typeAssertion/type");
|
|
12
10
|
|
|
13
|
-
export default function verifyTypeAssertion(typeAssertionNode,
|
|
11
|
+
export default function verifyTypeAssertion(typeAssertionNode, proofContext) {
|
|
14
12
|
let typeAssertionVerified = false;
|
|
15
13
|
|
|
16
14
|
proofContext.begin(typeAssertionNode);
|
|
17
15
|
|
|
16
|
+
const typeAssertionString = nodeAsString(typeAssertionNode);
|
|
17
|
+
|
|
18
|
+
proofContext.debug(`Verifying the '${typeAssertionString}' type assertion...`);
|
|
19
|
+
|
|
18
20
|
const typeNode = typeNodeQuery(typeAssertionNode),
|
|
19
21
|
typeName = typeNameFromTypeNode(typeNode),
|
|
20
22
|
typePresent = proofContext.isTypePresentByTypeName(typeName);
|
|
@@ -22,76 +24,50 @@ export default function verifyTypeAssertion(typeAssertionNode, types, variables,
|
|
|
22
24
|
if (!typePresent) {
|
|
23
25
|
proofContext.error(`The ${typeName} type is not present.`);
|
|
24
26
|
} else {
|
|
27
|
+
let assertedType = null;
|
|
28
|
+
|
|
25
29
|
const type = proofContext.findTypeByTypeName(typeName),
|
|
26
30
|
context = proofContext, ///
|
|
27
|
-
termNode = termNodeQuery(typeAssertionNode)
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
termNode = termNodeQuery(typeAssertionNode);
|
|
32
|
+
|
|
33
|
+
const variables = [],
|
|
30
34
|
termVerifiedAsVariable = verifyTermAsVariable(termNode, variables, context);
|
|
31
35
|
|
|
32
36
|
if (termVerifiedAsVariable) {
|
|
33
|
-
|
|
37
|
+
const firstVariable = first(variables),
|
|
38
|
+
variable = firstVariable, ///
|
|
39
|
+
variableType = variable.getType();
|
|
34
40
|
|
|
35
|
-
|
|
41
|
+
assertedType = variableType; ///
|
|
36
42
|
} else {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
43
|
+
const types = [],
|
|
44
|
+
termVerifiedAgainstConstructors = verifyTermAgainstConstructors(termNode, types, context);
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
if (termVerifiedAgainstConstructors) {
|
|
47
|
+
const firstType = first(types),
|
|
48
|
+
termType = firstType; ///
|
|
43
49
|
|
|
50
|
+
assertedType = termType; ///
|
|
51
|
+
}
|
|
52
|
+
}
|
|
44
53
|
|
|
45
|
-
|
|
54
|
+
if (assertedType !== null) {
|
|
55
|
+
const typeEqualToOrSubTypeOfAssertedType = type.isEqualToOrSubTypeOf(assertedType);
|
|
46
56
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
} else {
|
|
57
|
+
if (!typeEqualToOrSubTypeOfAssertedType) {
|
|
58
|
+
const termString = nodeAsString(termNode);
|
|
50
59
|
|
|
51
|
-
|
|
52
|
-
const firstVariable = first(variables),
|
|
53
|
-
variable = firstVariable, ///
|
|
54
|
-
variableName = variable.getName(),
|
|
55
|
-
variableDefined = variable.isDefined();
|
|
56
|
-
|
|
57
|
-
if (value !== undefined) {
|
|
58
|
-
proofContext.error(`The value of the ${variableName} variable is not undefined.`);
|
|
59
|
-
} else {
|
|
60
|
-
const type = proofContext.findTypeByTypeName(typeName),
|
|
61
|
-
firstType = first(types),
|
|
62
|
-
variableType = firstType, ///
|
|
63
|
-
typeEqualToOrSubTypeOfVariableType = type.isEqualToOrSubTypeOf(variableType);
|
|
64
|
-
|
|
65
|
-
if (!typeEqualToOrSubTypeOfVariableType) {
|
|
66
|
-
proofContext.error(`The asserted type of the ${variableName} variable is not equal to or a sub-type of its declared type.`);
|
|
67
|
-
} else {
|
|
68
|
-
const name = variableName, ///
|
|
69
|
-
variable = Variable.fromTypeAndName(type, name);
|
|
70
|
-
|
|
71
|
-
proofContext.addVariable(variable);
|
|
72
|
-
|
|
73
|
-
typeAssertionVerified = true;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
60
|
+
proofContext.error(`The type of the '${termString}' term or variable is not equal to or a sub-type of the asserted type.`);
|
|
76
61
|
} else {
|
|
77
|
-
|
|
78
|
-
if (termVerifiedAgainstConstructors) {
|
|
79
|
-
const type = proofContext.findTypeByTypeName(typeName),
|
|
80
|
-
firstType = first(types),
|
|
81
|
-
termType = firstType, ///
|
|
82
|
-
typeEqualToOrSubTypeOfTermType = type.isEqualToOrSubTypeOf(termType);
|
|
83
|
-
|
|
84
|
-
if (!typeEqualToOrSubTypeOfTermType) {
|
|
85
|
-
proofContext.error(`The asserted type of the '${termString}' term is not equal to or a sub-type of its declared type.`);
|
|
86
|
-
} else {
|
|
87
|
-
|
|
88
|
-
typeAssertionVerified = true;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
62
|
+
typeAssertionVerified = true;
|
|
91
63
|
}
|
|
92
64
|
}
|
|
93
65
|
}
|
|
94
66
|
|
|
67
|
+
if (typeAssertionVerified) {
|
|
68
|
+
proofContext.info(`Verified the '${typeAssertionString}' type assertion.`);
|
|
69
|
+
}
|
|
70
|
+
|
|
95
71
|
typeAssertionVerified ?
|
|
96
72
|
proofContext.complete(typeAssertionNode) :
|
|
97
73
|
proofContext.halt(typeAssertionNode);
|
package/src/verify/axiom.js
CHANGED
|
@@ -6,13 +6,10 @@ import ProofContext from "../context/proof";
|
|
|
6
6
|
import verifyUnqualifiedStatement from "../verify/statement/unqualified";
|
|
7
7
|
import verifyIndicativeConditional from "../verify/indicativeConditional";
|
|
8
8
|
|
|
9
|
-
import { front, last } from "../utilities/array";
|
|
10
9
|
import { nodesAsString } from "../utilities/string";
|
|
11
10
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
12
11
|
|
|
13
12
|
const labelNodesQuery = nodesQuery("/axiom/label"),
|
|
14
|
-
statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
|
|
15
|
-
statementNodesQuery = nodesQuery("/indicativeConditional/unqualifiedStatement/statement!"),
|
|
16
13
|
unqualifiedStatementNodeQuery = nodeQuery("/axiom/unqualifiedStatement!"),
|
|
17
14
|
indicativeConditionalNodeQuery = nodeQuery("/axiom/indicativeConditional!");
|
|
18
15
|
|
|
@@ -34,34 +31,23 @@ export default function verifyAxiom(axiomNode, fileContext) {
|
|
|
34
31
|
const unqualifiedStatementNode = unqualifiedStatementNodeQuery(axiomNode),
|
|
35
32
|
indicativeConditionalNode = indicativeConditionalNodeQuery(axiomNode);
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (unqualifiedStatementVerified) {
|
|
41
|
-
const statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
42
|
-
axiom = Axiom.fromLabelsAndStatementNode(labels, statementNode);
|
|
43
|
-
|
|
44
|
-
fileContext.addAxiom(axiom);
|
|
34
|
+
let unqualifiedStatementVerified = false,
|
|
35
|
+
indicativeConditionalVerified = false;
|
|
45
36
|
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
if (unqualifiedStatementNode !== null) {
|
|
38
|
+
unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, proofContext);
|
|
48
39
|
}
|
|
49
40
|
|
|
50
41
|
if (indicativeConditionalNode !== null) {
|
|
51
|
-
|
|
42
|
+
indicativeConditionalVerified = verifyIndicativeConditional(indicativeConditionalNode, proofContext);
|
|
43
|
+
}
|
|
52
44
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
lastStatementNode = last(statementNodes),
|
|
56
|
-
frontStatementNodes = front(statementNodes),
|
|
57
|
-
consequentStatementNode = lastStatementNode, ///
|
|
58
|
-
suppositionStatementNodes = frontStatementNodes, ///
|
|
59
|
-
axiom = Axiom.fromLabelsSuppositionStatementNodesAndConsequentStatementNode(labels, suppositionStatementNodes, consequentStatementNode);
|
|
45
|
+
if (unqualifiedStatementVerified || indicativeConditionalVerified) {
|
|
46
|
+
const axiom = Axiom.fromLabelsUnqualifiedStatementNodeAndIndicativeConditionalNode(labels, unqualifiedStatementNode, indicativeConditionalNode);
|
|
60
47
|
|
|
61
|
-
|
|
48
|
+
fileContext.addAxiom(axiom);
|
|
62
49
|
|
|
63
|
-
|
|
64
|
-
}
|
|
50
|
+
axiomVerified = true;
|
|
65
51
|
}
|
|
66
52
|
}
|
|
67
53
|
|
package/src/verify/equality.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import verifyTerm from "../verify/term";
|
|
4
4
|
|
|
5
5
|
import { nodeQuery } from "../utilities/query";
|
|
6
|
+
import { nodeAsString } from "../utilities/string";
|
|
6
7
|
import { first, second } from "../utilities/array";
|
|
7
8
|
|
|
8
9
|
const firstTermNodeQuery = nodeQuery("/equality/term[0]"),
|
|
@@ -13,6 +14,10 @@ export default function verifyEquality(equalityNode, proofContext) {
|
|
|
13
14
|
|
|
14
15
|
proofContext.begin(equalityNode);
|
|
15
16
|
|
|
17
|
+
const equalityString = nodeAsString(equalityNode);
|
|
18
|
+
|
|
19
|
+
proofContext.debug(`Verifying the '${equalityString}' equality...`);
|
|
20
|
+
|
|
16
21
|
const types = [],
|
|
17
22
|
context = proofContext,
|
|
18
23
|
firstTermNode = firstTermNodeQuery(equalityNode),
|
|
@@ -30,6 +35,10 @@ export default function verifyEquality(equalityNode, proofContext) {
|
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
|
|
38
|
+
if (equalityVerified) {
|
|
39
|
+
proofContext.info(`Verified the '${equalityString}' equality.`);
|
|
40
|
+
}
|
|
41
|
+
|
|
33
42
|
equalityVerified ?
|
|
34
43
|
proofContext.complete(equalityNode) :
|
|
35
44
|
proofContext.halt(equalityNode);
|
package/src/verify/lemma.js
CHANGED
|
@@ -6,13 +6,10 @@ import ProofContext from "../context/proof";
|
|
|
6
6
|
import verifyUnqualifiedStatement from "../verify/statement/unqualified";
|
|
7
7
|
import verifyIndicativeConditional from "../verify/indicativeConditional";
|
|
8
8
|
|
|
9
|
-
import { front, last } from "../utilities/array";
|
|
10
9
|
import { nodesAsString } from "../utilities/string";
|
|
11
10
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
12
11
|
|
|
13
12
|
const labelNodesQuery = nodesQuery("/lemma/label"),
|
|
14
|
-
statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
|
|
15
|
-
statementNodesQuery = nodesQuery("/indicativeConditional/unqualifiedStatement/statement!"),
|
|
16
13
|
unqualifiedStatementNodeQuery = nodeQuery("/lemma/unqualifiedStatement!"),
|
|
17
14
|
indicativeConditionalNodeQuery = nodeQuery("/lemma/indicativeConditional!");
|
|
18
15
|
|
|
@@ -25,57 +22,37 @@ export default function verifyLemma(lemmaNode, fileContext) {
|
|
|
25
22
|
labelsString = nodesAsString(labelNodes),
|
|
26
23
|
proofContext = ProofContext.fromFileContext(fileContext);
|
|
27
24
|
|
|
28
|
-
(labelsString
|
|
29
|
-
fileContext.debug(`Verifying an anonymous lemma...`) :
|
|
30
|
-
fileContext.debug(`Verifying the '${labelsString}' lemma...`);
|
|
25
|
+
fileContext.debug(`Verifying the '${labelsString}' lemma...`);
|
|
31
26
|
|
|
32
27
|
const labels = [],
|
|
33
|
-
labelsLength = labels.length,
|
|
34
28
|
labelsVerified = verifyLabels(labelNodes, labels, fileContext);
|
|
35
29
|
|
|
36
30
|
if (labelsVerified) {
|
|
37
31
|
const unqualifiedStatementNode = unqualifiedStatementNodeQuery(lemmaNode),
|
|
38
32
|
indicativeConditionalNode = indicativeConditionalNodeQuery(lemmaNode);
|
|
39
33
|
|
|
34
|
+
let unqualifiedStatementVerified = false,
|
|
35
|
+
indicativeConditionalVerified = false;
|
|
36
|
+
|
|
40
37
|
if (unqualifiedStatementNode !== null) {
|
|
41
|
-
|
|
38
|
+
unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, proofContext);
|
|
39
|
+
}
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
lemma = Lemma.fromLabelsAndStatementNode(labels, statementNode);
|
|
41
|
+
if (indicativeConditionalNode !== null) {
|
|
42
|
+
indicativeConditionalVerified = verifyIndicativeConditional(indicativeConditionalNode, proofContext);
|
|
43
|
+
}
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
if (unqualifiedStatementVerified || indicativeConditionalVerified) {
|
|
46
|
+
const lemma = Lemma.fromLabelsUnqualifiedStatementNodeAndIndicativeConditionalNode(labels, unqualifiedStatementNode, indicativeConditionalNode);
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}
|
|
48
|
+
fileContext.addLemma(lemma);
|
|
54
49
|
|
|
55
|
-
|
|
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
|
-
}
|
|
50
|
+
lemmaVerified = true;
|
|
72
51
|
}
|
|
73
52
|
}
|
|
74
53
|
|
|
75
54
|
if (lemmaVerified) {
|
|
76
|
-
(labelsString
|
|
77
|
-
fileContext.info(`Verified an anonymous lemma.`) :
|
|
78
|
-
fileContext.info(`Verified the '${labelsString}' lemma.`);
|
|
55
|
+
fileContext.info(`Verified the '${labelsString}' lemma.`);
|
|
79
56
|
}
|
|
80
57
|
|
|
81
58
|
lemmaVerified ?
|
|
@@ -11,6 +11,10 @@ export default function verifyQualifiedMetastatement(qualifiedMetastatementNode,
|
|
|
11
11
|
|
|
12
12
|
metaproofContext.begin(qualifiedMetastatementNode);
|
|
13
13
|
|
|
14
|
+
const qualifiedMetastatementString = nodeAsString(qualifiedMetastatementNode);
|
|
15
|
+
|
|
16
|
+
metaproofContext.debug(`Verifying the '${qualifiedMetastatementString}' qualified metastatement...`);
|
|
17
|
+
|
|
14
18
|
const metastatementNode = metastatementNodeQuery(qualifiedMetastatementNode);
|
|
15
19
|
|
|
16
20
|
if (metastatementNode !== null) {
|
|
@@ -26,9 +30,7 @@ export default function verifyQualifiedMetastatement(qualifiedMetastatementNode,
|
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
if (qualifiedMetastatementVerified) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
metaproofContext.debug(`Verified the '${metastatementString}' qualified metastatement.`);
|
|
33
|
+
metaproofContext.info(`Verified the '${qualifiedMetastatementString}' qualified metastatement.`);
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
qualifiedMetastatementVerified ?
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import MetaAssertion from "../../metaAssertion";
|
|
4
|
+
import verifyMetastatement from "../../verify/metastatement";
|
|
4
5
|
|
|
5
6
|
import { nodeQuery } from "../../utilities/query";
|
|
6
7
|
import { nodeAsString } from "../../utilities/string";
|
|
@@ -12,25 +13,31 @@ export default function verifyUnqualifiedMetastatement(unqualifiedMetastatementN
|
|
|
12
13
|
|
|
13
14
|
metaproofContext.begin(unqualifiedMetastatementNode);
|
|
14
15
|
|
|
16
|
+
const unqualifiedMetastatementString = nodeAsString(unqualifiedMetastatementNode);
|
|
17
|
+
|
|
18
|
+
metaproofContext.info(`Verified the '${unqualifiedMetastatementString}' unqualified metastatement.`);
|
|
19
|
+
|
|
15
20
|
const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode);
|
|
16
21
|
|
|
17
22
|
if (metastatementNode !== null) {
|
|
18
|
-
const
|
|
23
|
+
const metastatementVerified = verifyMetastatement(metastatementNode, metaproofContext);
|
|
19
24
|
|
|
20
|
-
if (
|
|
21
|
-
const
|
|
22
|
-
metaAssertionMatches = metaproofContext.matchMetaAssertion(metaAssertion);
|
|
25
|
+
if (metastatementVerified) {
|
|
26
|
+
const derived = metaproofContext.isDerived();
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
if (derived) {
|
|
29
|
+
const metaAssertion = MetaAssertion.fromMetastatementNode(metastatementNode),
|
|
30
|
+
metaAssertionMatches = metaproofContext.matchMetaAssertion(metaAssertion);
|
|
31
|
+
|
|
32
|
+
unqualifiedMetastatementVerified = metaAssertionMatches; ///
|
|
33
|
+
} else {
|
|
34
|
+
unqualifiedMetastatementVerified = true;
|
|
35
|
+
}
|
|
27
36
|
}
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
if (unqualifiedMetastatementVerified) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
metaproofContext.debug(`Verified the '${metastatementString}' unqualified metastatement.`);
|
|
40
|
+
metaproofContext.info(`Verified the '${unqualifiedMetastatementString}' unqualified metastatement.`);
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
unqualifiedMetastatementVerified ?
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export default function verifyMetastatement(metastatementNode, metaproofContext) {
|
|
4
|
+
let statementVerified;
|
|
5
|
+
|
|
6
|
+
metaproofContext.begin(metastatementNode);
|
|
7
|
+
|
|
8
|
+
statementVerified = true; ///
|
|
9
|
+
|
|
10
|
+
statementVerified ?
|
|
11
|
+
metaproofContext.complete(metastatementNode) :
|
|
12
|
+
metaproofContext.halt(metastatementNode);
|
|
13
|
+
|
|
14
|
+
return statementVerified;
|
|
15
|
+
}
|
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { nodeAsString } from "../../utilities/string";
|
|
4
|
+
import { nodeQuery, referenceNameFromReferenceNode } from "../../utilities/query";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const statementNodeQuery = nodeQuery("/qualifiedStatement/statement!");
|
|
6
|
+
const referenceNodeQuery = nodeQuery("/qualifiedStatement/qualification!/reference!"),
|
|
7
|
+
statementNodeQuery = nodeQuery("/qualifiedStatement/statement!");
|
|
8
8
|
|
|
9
9
|
export default function verifyQualifiedStatement(qualifiedStatementNode, proofContext) {
|
|
10
|
-
let qualifiedStatementVerified;
|
|
10
|
+
let qualifiedStatementVerified = false;
|
|
11
11
|
|
|
12
12
|
proofContext.begin(qualifiedStatementNode);
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const qualifiedStatementString = nodeAsString(qualifiedStatementNode);
|
|
15
|
+
|
|
16
|
+
proofContext.debug(`Verifying the '${qualifiedStatementString}' qualified statement...`);
|
|
17
|
+
|
|
18
|
+
const statementNode = statementNodeQuery(qualifiedStatementNode);
|
|
19
|
+
|
|
20
|
+
if (statementNode !== null) {
|
|
21
|
+
const referenceNode = referenceNodeQuery(qualifiedStatementNode),
|
|
22
|
+
referenceName = referenceNameFromReferenceNode(referenceNode);
|
|
23
|
+
|
|
24
|
+
///
|
|
25
|
+
}
|
|
16
26
|
|
|
17
|
-
qualifiedStatementVerified
|
|
27
|
+
if (qualifiedStatementVerified) {
|
|
28
|
+
proofContext.info(`Verified the '${qualifiedStatementString}' qualified statement.`);
|
|
29
|
+
}
|
|
18
30
|
|
|
19
31
|
qualifiedStatementVerified ?
|
|
20
32
|
proofContext.complete(qualifiedStatementNode) :
|