occam-verify-cli 0.0.464 → 0.0.466
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/antecedent.js +214 -0
- package/lib/axiom.js +93 -78
- package/lib/axiomLemmaTheorem.js +190 -0
- package/lib/consequent.js +157 -0
- package/lib/constants.js +9 -1
- package/lib/lemma.js +93 -78
- package/lib/ruleNames.js +4 -4
- package/lib/substitution.js +123 -0
- package/lib/theorem.js +93 -78
- package/lib/utilities/statement.js +45 -0
- package/lib/utilities/string.js +6 -6
- package/lib/verify/antecedentOrAntecedents.js +38 -0
- package/lib/verify/axiom.js +15 -14
- package/lib/verify/conditinalIndicative.js +32 -0
- package/lib/verify/{indicativeConditional.js → conditionalIndicative.js} +10 -10
- package/lib/verify/consequent.js +36 -0
- package/lib/verify/derivation.js +1 -1
- package/lib/verify/lemma.js +25 -19
- package/lib/verify/proof.js +26 -11
- package/lib/verify/statement/qualified.js +16 -4
- package/lib/verify/theorem.js +22 -17
- package/lib/verify/unconditionalIndicative.js +28 -0
- package/package.json +3 -3
- package/src/antecedent.js +235 -0
- package/src/axiom.js +5 -95
- package/src/axiomLemmaTheorem.js +190 -0
- package/src/consequent.js +187 -0
- package/src/constants.js +2 -0
- package/src/lemma.js +5 -95
- package/src/ruleNames.js +1 -1
- package/src/substitution.js +130 -0
- package/src/theorem.js +5 -95
- package/src/utilities/statement.js +50 -0
- package/src/utilities/string.js +6 -6
- package/src/verify/antecedentOrAntecedents.js +40 -0
- package/src/verify/axiom.js +21 -16
- package/src/verify/conditinalIndicative.js +31 -0
- package/src/verify/conditionalIndicative.js +29 -0
- package/src/verify/consequent.js +36 -0
- package/src/verify/derivation.js +1 -1
- package/src/verify/lemma.js +38 -21
- package/src/verify/proof.js +32 -14
- package/src/verify/statement/qualified.js +15 -6
- package/src/verify/theorem.js +32 -20
- package/src/verify/unconditionalIndicative.js +24 -0
- package/src/verify/indicativeConditional.js +0 -29
package/src/theorem.js
CHANGED
|
@@ -1,103 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import AxiomLemmaTheorem from "./axiomLemmaTheorem";
|
|
4
4
|
|
|
5
5
|
import { THEOREM_KIND } from "./kinds";
|
|
6
|
-
import { nodeAsString } from "./utilities/string";
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
export default class Theorem extends AxiomLemmaTheorem {
|
|
8
|
+
static kind = THEOREM_KIND;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
constructor(labels, unqualifiedStatementNode, indicativeConditionalNode) {
|
|
12
|
-
this.labels = labels;
|
|
13
|
-
this.unqualifiedStatementNode = unqualifiedStatementNode;
|
|
14
|
-
this.indicativeConditionalNode = indicativeConditionalNode;
|
|
15
|
-
}
|
|
10
|
+
static fromJSON(json, releaseContext) { return AxiomLemmaTheorem.fromJSON(Theorem, json); }
|
|
16
11
|
|
|
17
|
-
|
|
18
|
-
return this.labels;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
getUnqualifiedStatementNode() {
|
|
22
|
-
return this.unqualifiedStatementNode;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
getIndicativeConditionalNode() {
|
|
26
|
-
return this.indicativeConditionalNode;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
matchLabelName(labelName) {
|
|
30
|
-
const matchesLabelName = this.labels.some((label) => {
|
|
31
|
-
const name = labelName, ///
|
|
32
|
-
labelMatchesName = label.matchName(name);
|
|
33
|
-
|
|
34
|
-
if (labelMatchesName) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return matchesLabelName;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
toJSON() {
|
|
43
|
-
const labelsJSON = this.labels.map((label) => {
|
|
44
|
-
const labelJSON = label.toJSON();
|
|
45
|
-
|
|
46
|
-
return labelJSON;
|
|
47
|
-
}),
|
|
48
|
-
unqualifiedStatementString = nodeAsString(this.unqalifiedStatementNode),
|
|
49
|
-
indicativeConditionalString = nodeAsString(this.indicativeConditionalNode),
|
|
50
|
-
kind = THEOREM_KIND,
|
|
51
|
-
labels = labelsJSON, ///
|
|
52
|
-
unqualifiedStatement = unqualifiedStatementString, ///
|
|
53
|
-
indicativeConditional = indicativeConditionalString, ///
|
|
54
|
-
json = {
|
|
55
|
-
kind,
|
|
56
|
-
labels,
|
|
57
|
-
unqualifiedStatement,
|
|
58
|
-
indicativeConditional
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
return json;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
static fromJSON(json, releaseContext) {
|
|
65
|
-
let { labels } = json;
|
|
66
|
-
|
|
67
|
-
const labelsJSON = labels; ///
|
|
68
|
-
|
|
69
|
-
labels = labelsJSON.map((labelJSON) => {
|
|
70
|
-
const json = labelJSON, ///
|
|
71
|
-
label = Label.fromJSON(json, releaseContext);
|
|
72
|
-
|
|
73
|
-
return label;
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
let { unqualifiedStatement, indicativeConditional } = json;
|
|
77
|
-
|
|
78
|
-
let unqualifiedStatementNode = null,
|
|
79
|
-
indicativeConditionalNode = null;
|
|
80
|
-
|
|
81
|
-
if (unqualifiedStatement !== null) {
|
|
82
|
-
const unqualifiedStatementString = unqualifiedStatement; ///
|
|
83
|
-
|
|
84
|
-
unqualifiedStatementNode = unqualifiedStatementNodeFromUnqualifiedStatementString(unqualifiedStatementString, releaseContext);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (indicativeConditional !== null) {
|
|
88
|
-
const indicativeConditionalString = indicativeConditional; ///
|
|
89
|
-
|
|
90
|
-
indicativeConditionalNode = indicativeConditionalNodeFromIndicativeConditionalString(indicativeConditionalString, releaseContext);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const theorem = new Theorem(labels, unqualifiedStatementNode, indicativeConditionalNode);
|
|
94
|
-
|
|
95
|
-
return theorem;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
static fromLabelsUnqualifiedStatementNodeAndIndicativeConditionalNode(labels, unqualifiedStatementNode, indicativeConditionalNode) {
|
|
99
|
-
const theorem = new Theorem(labels, unqualifiedStatementNode, indicativeConditionalNode);
|
|
100
|
-
|
|
101
|
-
return theorem;
|
|
102
|
-
}
|
|
12
|
+
static fromLabelsAntecedentsAndConsequent(labels, antecedents, consequent) { return AxiomLemmaTheorem.fromLabelsAntecedentsAndConsequent(Theorem, labels, antecedents, consequent); }
|
|
103
13
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { first, second, third } from "../utilities/array";
|
|
4
|
+
import { STATEMENT_RULE_NAME } from "../ruleNames";
|
|
5
|
+
import { LEFT_BRACKET, RIGHT_BRACKET, BRACKETED_STATEMENT_CHILD_NODES_LENGTH } from "../constants";
|
|
6
|
+
|
|
7
|
+
export function bracketedStatementChildNodeFromChildNodes(childNodes) {
|
|
8
|
+
let bracketedStatementChildNode = null;
|
|
9
|
+
|
|
10
|
+
const childNodesLength = childNodes.length;
|
|
11
|
+
|
|
12
|
+
if (childNodesLength === BRACKETED_STATEMENT_CHILD_NODES_LENGTH) {
|
|
13
|
+
const firstChildNode = first(childNodes),
|
|
14
|
+
thirdChildNode = third(childNodes),
|
|
15
|
+
secondChildNode = second(childNodes),
|
|
16
|
+
firstChildNodeTerminalNode = firstChildNode.isTerminalNode(),
|
|
17
|
+
thirdChildNodeTerminalNode = thirdChildNode.isTerminalNode(),
|
|
18
|
+
secondChildNodeNonTerminalNode = secondChildNode.isNonTerminalNode();
|
|
19
|
+
|
|
20
|
+
if (firstChildNodeTerminalNode && secondChildNodeNonTerminalNode && thirdChildNodeTerminalNode) {
|
|
21
|
+
const nonTerminalNode = secondChildNode, ///
|
|
22
|
+
firstTerminalNode = firstChildNode, ///
|
|
23
|
+
secondTerminalNode = thirdChildNode, ///
|
|
24
|
+
nonTerminalNodeRuleName = nonTerminalNode.getRuleName(),
|
|
25
|
+
firstTerminalNodeContent = firstTerminalNode.getContent(),
|
|
26
|
+
secondTerminalNodeContent = secondTerminalNode.getContent(),
|
|
27
|
+
firstTerminalNodeContentLeftBracket = (firstTerminalNodeContent === LEFT_BRACKET),
|
|
28
|
+
secondTerminalNodeContentRightBracket = (secondTerminalNodeContent === RIGHT_BRACKET),
|
|
29
|
+
nonTerminalNodeRuleNameStatementRuleName = (nonTerminalNodeRuleName === STATEMENT_RULE_NAME);
|
|
30
|
+
|
|
31
|
+
if (firstTerminalNodeContentLeftBracket && nonTerminalNodeRuleNameStatementRuleName && secondTerminalNodeContentRightBracket) {
|
|
32
|
+
bracketedStatementChildNode = nonTerminalNode; ///
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return bracketedStatementChildNode;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function matchBracketedStatementChildNode(childNodes, callback) {
|
|
41
|
+
let bracketedStatementChildNodeMatches = false;
|
|
42
|
+
|
|
43
|
+
const bracketedStatementChildNode = bracketedStatementChildNodeFromChildNodes(childNodes);
|
|
44
|
+
|
|
45
|
+
if (bracketedStatementChildNode !== null) {
|
|
46
|
+
bracketedStatementChildNodeMatches = callback(bracketedStatementChildNode);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return bracketedStatementChildNodeMatches;
|
|
50
|
+
}
|
package/src/utilities/string.js
CHANGED
|
@@ -5,7 +5,7 @@ import { nodeQuery } from "../utilities/query";
|
|
|
5
5
|
import { TERM_RULE_NAME,
|
|
6
6
|
LABEL_RULE_NAME,
|
|
7
7
|
UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
8
|
-
|
|
8
|
+
CONDITIONAL_INDICATIVE_RULE_NAME,
|
|
9
9
|
UNQUALIFIED_METASTATEMENT_RULE_NAME} from "../ruleNames";
|
|
10
10
|
|
|
11
11
|
const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement"),
|
|
@@ -104,11 +104,11 @@ export function unqualifiedStatementNodeFromUnqualifiedStatementString(unqualifi
|
|
|
104
104
|
return unqualifiedStatementNode;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
export function
|
|
108
|
-
const ruleName =
|
|
109
|
-
content =
|
|
107
|
+
export function conditionalIndicativeNodeFromConditionalIndicativeString(conditionalIndicativeString, releaseContext) {
|
|
108
|
+
const ruleName = CONDITIONAL_INDICATIVE_RULE_NAME,
|
|
109
|
+
content = conditionalIndicativeString, ///
|
|
110
110
|
node = releaseContext.nodeFromContentAndRuleName(content, ruleName),
|
|
111
|
-
|
|
111
|
+
conditionalIndicativeNode = node; ///
|
|
112
112
|
|
|
113
|
-
return
|
|
113
|
+
return conditionalIndicativeNode;
|
|
114
114
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Assertion from "../assertion";
|
|
4
|
+
import Antecedent from "../antecedent";
|
|
5
|
+
import verifyUnqualifiedStatement from "../verify/statement/unqualified";
|
|
6
|
+
|
|
7
|
+
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
8
|
+
|
|
9
|
+
const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement"),
|
|
10
|
+
unqualifiedStatementNodesQuery = nodesQuery("/antecedent|antecedents/unqualifiedStatement");
|
|
11
|
+
|
|
12
|
+
export default function verifyAntecedentOrAntecedents(antecedentOrAntecedentsNode, antecedents, proofContext) {
|
|
13
|
+
let antecedentOrAntecedentsVerified;
|
|
14
|
+
|
|
15
|
+
proofContext.begin(antecedentOrAntecedentsNode);
|
|
16
|
+
|
|
17
|
+
const unqualifiedStatementNodes = unqualifiedStatementNodesQuery(antecedentOrAntecedentsNode);
|
|
18
|
+
|
|
19
|
+
antecedentOrAntecedentsVerified = unqualifiedStatementNodes.every((unqualifiedStatementNode) => {
|
|
20
|
+
const unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, proofContext);
|
|
21
|
+
|
|
22
|
+
if (unqualifiedStatementVerified) {
|
|
23
|
+
const statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
24
|
+
assertion = Assertion.fromUnqualifiedStatementNode(unqualifiedStatementNode),
|
|
25
|
+
antecedent = Antecedent.fromStatementNode(statementNode);
|
|
26
|
+
|
|
27
|
+
antecedents.push(antecedent);
|
|
28
|
+
|
|
29
|
+
proofContext.addAssertion(assertion);
|
|
30
|
+
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
antecedentOrAntecedentsVerified ?
|
|
36
|
+
proofContext.complete(antecedentOrAntecedentsNode) :
|
|
37
|
+
proofContext.halt(antecedentOrAntecedentsNode);
|
|
38
|
+
|
|
39
|
+
return antecedentOrAntecedentsVerified;
|
|
40
|
+
}
|
package/src/verify/axiom.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Axiom from "../axiom";
|
|
4
|
-
import verifyLabels from "../verify/labels";
|
|
5
4
|
import ProofContext from "../context/proof";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
5
|
+
import verifyLabels from "../verify/labels";
|
|
6
|
+
import verifyConditionalIndicative from "../verify/conditinalIndicative";
|
|
7
|
+
import verifyUnconditionalIndicative from "../verify/unconditionalIndicative";
|
|
8
8
|
|
|
9
|
+
import { first } from "../utilities/array";
|
|
9
10
|
import { nodesAsString } from "../utilities/string";
|
|
10
11
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
11
12
|
|
|
12
13
|
const labelNodesQuery = nodesQuery("/axiom/label"),
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
conditionalIndicativeNodeQuery = nodeQuery("/axiom/conditionalIndicative!"),
|
|
15
|
+
unconditionalIndicativeNodeQuery = nodeQuery("/axiom/unconditionalIndicative!");
|
|
15
16
|
|
|
16
17
|
export default function verifyAxiom(axiomNode, fileContext) {
|
|
17
18
|
let axiomVerified = false;
|
|
@@ -28,22 +29,26 @@ export default function verifyAxiom(axiomNode, fileContext) {
|
|
|
28
29
|
labelsVerified = verifyLabels(labelNodes, labels, fileContext);
|
|
29
30
|
|
|
30
31
|
if (labelsVerified) {
|
|
31
|
-
const
|
|
32
|
-
|
|
32
|
+
const antecedents = [],
|
|
33
|
+
consequents = [],
|
|
34
|
+
conditionalIndicativeNode = conditionalIndicativeNodeQuery(axiomNode),
|
|
35
|
+
unconditionalIndicativeNode = unconditionalIndicativeNodeQuery(axiomNode);
|
|
33
36
|
|
|
34
|
-
let
|
|
35
|
-
|
|
37
|
+
let conditionalIndicativeVerified = false,
|
|
38
|
+
unconditionalIndicativeVerified = false;
|
|
36
39
|
|
|
37
|
-
if (
|
|
38
|
-
|
|
40
|
+
if (conditionalIndicativeNode !== null) {
|
|
41
|
+
conditionalIndicativeVerified = verifyConditionalIndicative(conditionalIndicativeNode, antecedents, consequents, proofContext);
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
if (
|
|
42
|
-
|
|
44
|
+
if (unconditionalIndicativeNode !== null) {
|
|
45
|
+
unconditionalIndicativeVerified = verifyUnconditionalIndicative(unconditionalIndicativeNode, consequents, proofContext);
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
if (
|
|
46
|
-
const
|
|
48
|
+
if (conditionalIndicativeVerified || unconditionalIndicativeVerified) {
|
|
49
|
+
const firstConsequent = first(consequents),
|
|
50
|
+
consequent = firstConsequent, ///
|
|
51
|
+
axiom = Axiom.fromLabelsAntecedentsAndConsequent(labels, antecedents, consequent);
|
|
47
52
|
|
|
48
53
|
fileContext.addAxiom(axiom);
|
|
49
54
|
|
|
@@ -57,7 +62,7 @@ export default function verifyAxiom(axiomNode, fileContext) {
|
|
|
57
62
|
|
|
58
63
|
axiomVerified ?
|
|
59
64
|
fileContext.complete(axiomNode) :
|
|
60
|
-
fileContext.
|
|
65
|
+
fileContext.complete(axiomNode);
|
|
61
66
|
|
|
62
67
|
return axiomVerified;
|
|
63
68
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import verifyConsequent from "../verify/consequent";
|
|
4
|
+
import verifyAntecedentOrAntecedents from "../verify/antecedentOrAntecedents";
|
|
5
|
+
|
|
6
|
+
import { nodeQuery } from "../utilities/query";
|
|
7
|
+
|
|
8
|
+
const consequentNodeQuery = nodeQuery("/conditionalIndicative/consequent!"),
|
|
9
|
+
antecedentOrAntecedentsNodeQuery = nodeQuery("/conditionalIndicative/antecedent|antecedents!");
|
|
10
|
+
|
|
11
|
+
export default function verifyConditionalIndicative(conditionalIndicativeNode, antecedents, consequents, proofContext) {
|
|
12
|
+
let conditionalIndicativeVerified = false;
|
|
13
|
+
|
|
14
|
+
proofContext.begin(conditionalIndicativeNode);
|
|
15
|
+
|
|
16
|
+
const consequentNode = consequentNodeQuery(conditionalIndicativeNode),
|
|
17
|
+
antecedentOrAntecedentsNode = antecedentOrAntecedentsNodeQuery(conditionalIndicativeNode),
|
|
18
|
+
antecedentOrAntecedentsVerified = verifyAntecedentOrAntecedents(antecedentOrAntecedentsNode, antecedents, proofContext);
|
|
19
|
+
|
|
20
|
+
if (antecedentOrAntecedentsVerified) {
|
|
21
|
+
const consequentVerified = verifyConsequent(consequentNode, consequents, proofContext);
|
|
22
|
+
|
|
23
|
+
conditionalIndicativeVerified = consequentVerified; ///
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
conditionalIndicativeVerified ?
|
|
27
|
+
proofContext.complete(conditionalIndicativeNode) :
|
|
28
|
+
proofContext.halt(conditionalIndicativeNode);
|
|
29
|
+
|
|
30
|
+
return conditionalIndicativeVerified;
|
|
31
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import verifyUnqualifiedStatement from "../verify/statement/unqualified";
|
|
4
|
+
|
|
5
|
+
import { nodesQuery } from "../utilities/query";
|
|
6
|
+
|
|
7
|
+
const unqualifiedStatementNodesQuery = nodesQuery("/conditionalIndicative/unqualifiedStatement");
|
|
8
|
+
|
|
9
|
+
export default function verifyConditionalIndicative(conditionalIndicativeNode, proofContext) {
|
|
10
|
+
let conditionalIndicativeVerified;
|
|
11
|
+
|
|
12
|
+
proofContext.begin(conditionalIndicativeNode);
|
|
13
|
+
|
|
14
|
+
const unqualifiedStatementNodes = unqualifiedStatementNodesQuery(conditionalIndicativeNode);
|
|
15
|
+
|
|
16
|
+
conditionalIndicativeVerified = unqualifiedStatementNodes.every((unqualifiedStatementNode) => {
|
|
17
|
+
const unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, proofContext);
|
|
18
|
+
|
|
19
|
+
if (unqualifiedStatementVerified) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
conditionalIndicativeVerified ?
|
|
25
|
+
proofContext.complete(conditionalIndicativeNode) :
|
|
26
|
+
proofContext.halt(conditionalIndicativeNode);
|
|
27
|
+
|
|
28
|
+
return conditionalIndicativeVerified;
|
|
29
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Consequent from "../consequent";
|
|
4
|
+
import verifyUnqualifiedStatement from "../verify/statement/unqualified";
|
|
5
|
+
|
|
6
|
+
import { nodeQuery } from "../utilities/query";
|
|
7
|
+
|
|
8
|
+
const statementNodeQuery = nodeQuery("/*/statement!"),
|
|
9
|
+
unqualifiedStatementNodeQuery = nodeQuery("/consequent/unqualifiedStatement!");
|
|
10
|
+
|
|
11
|
+
export default function verifyConsequent(consequentNode, consequents, proofContext) {
|
|
12
|
+
let consequentVerified = false;
|
|
13
|
+
|
|
14
|
+
proofContext.begin(consequentNode);
|
|
15
|
+
|
|
16
|
+
const unqualifiedStatementNode = unqualifiedStatementNodeQuery(consequentNode);
|
|
17
|
+
|
|
18
|
+
if (unqualifiedStatementNode !== null) {
|
|
19
|
+
const unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, proofContext);
|
|
20
|
+
|
|
21
|
+
if (unqualifiedStatementVerified) {
|
|
22
|
+
const statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
23
|
+
consequent = Consequent.fromStatementNode(statementNode);
|
|
24
|
+
|
|
25
|
+
consequents.push(consequent);
|
|
26
|
+
|
|
27
|
+
consequentVerified = true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
consequentVerified ?
|
|
32
|
+
proofContext.complete(consequentNode) :
|
|
33
|
+
proofContext.halt(consequentNode);
|
|
34
|
+
|
|
35
|
+
return consequentVerified;
|
|
36
|
+
}
|
package/src/verify/derivation.js
CHANGED
package/src/verify/lemma.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Lemma from "../lemma";
|
|
4
|
-
import
|
|
4
|
+
import verifyProof from "../verify/proof";
|
|
5
5
|
import ProofContext from "../context/proof";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import verifyLabels from "../verify/labels";
|
|
7
|
+
import verifyConditionalIndicative from "../verify/conditinalIndicative";
|
|
8
|
+
import verifyUnconditionalIndicative from "../verify/unconditionalIndicative";
|
|
8
9
|
|
|
10
|
+
import { first } from "../utilities/array";
|
|
11
|
+
import { EMPTY_STRING } from "../constants";
|
|
9
12
|
import { nodesAsString } from "../utilities/string";
|
|
10
13
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
11
14
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
const proofNodeQuery = nodeQuery("/lemma/proof!"),
|
|
16
|
+
labelNodesQuery = nodesQuery("/lemma/label"),
|
|
17
|
+
conditionalIndicativeNodeQuery = nodeQuery("/lemma/conditionalIndicative!"),
|
|
18
|
+
unconditionalIndicativeNodeQuery = nodeQuery("/lemma/unconditionalIndicative!");
|
|
15
19
|
|
|
16
20
|
export default function verifyLemma(lemmaNode, fileContext) {
|
|
17
21
|
let lemmaVerified = false;
|
|
@@ -22,42 +26,55 @@ export default function verifyLemma(lemmaNode, fileContext) {
|
|
|
22
26
|
labelsString = nodesAsString(labelNodes),
|
|
23
27
|
proofContext = ProofContext.fromFileContext(fileContext);
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
(labelsString === EMPTY_STRING) ?
|
|
30
|
+
fileContext.debug(`Verifying a lemma...`) :
|
|
31
|
+
fileContext.debug(`Verifying the '${labelsString}' lemma...`);
|
|
26
32
|
|
|
27
33
|
const labels = [],
|
|
28
34
|
labelsVerified = verifyLabels(labelNodes, labels, fileContext);
|
|
29
35
|
|
|
30
36
|
if (labelsVerified) {
|
|
31
|
-
const
|
|
32
|
-
|
|
37
|
+
const antecedents = [],
|
|
38
|
+
consequents = [],
|
|
39
|
+
conditionalIndicativeNode = conditionalIndicativeNodeQuery(lemmaNode),
|
|
40
|
+
unconditionalIndicativeNode = unconditionalIndicativeNodeQuery(lemmaNode);
|
|
33
41
|
|
|
34
|
-
let
|
|
35
|
-
|
|
42
|
+
let conditionalIndicativeVerified = false,
|
|
43
|
+
unconditionalIndicativeVerified = false;
|
|
36
44
|
|
|
37
|
-
if (
|
|
38
|
-
|
|
45
|
+
if (conditionalIndicativeNode !== null) {
|
|
46
|
+
conditionalIndicativeVerified = verifyConditionalIndicative(conditionalIndicativeNode, antecedents, consequents, proofContext);
|
|
39
47
|
}
|
|
40
48
|
|
|
41
|
-
if (
|
|
42
|
-
|
|
49
|
+
if (unconditionalIndicativeNode !== null) {
|
|
50
|
+
unconditionalIndicativeVerified = verifyUnconditionalIndicative(unconditionalIndicativeNode, consequents, proofContext);
|
|
43
51
|
}
|
|
44
52
|
|
|
45
|
-
if (
|
|
46
|
-
const
|
|
53
|
+
if (conditionalIndicativeVerified || unconditionalIndicativeVerified) {
|
|
54
|
+
const proofNode = proofNodeQuery(lemmaNode),
|
|
55
|
+
firstConsequent = first(consequents),
|
|
56
|
+
consequent = firstConsequent, ///
|
|
57
|
+
proofVerified = verifyProof(proofNode, consequent, proofContext);
|
|
58
|
+
|
|
59
|
+
if (proofVerified) {
|
|
60
|
+
const lemma = Lemma.fromLabelsAntecedentsAndConsequent(labels, antecedents, consequent);
|
|
47
61
|
|
|
48
|
-
|
|
62
|
+
fileContext.addLemma(lemma);
|
|
49
63
|
|
|
50
|
-
|
|
64
|
+
lemmaVerified = true;
|
|
65
|
+
}
|
|
51
66
|
}
|
|
52
67
|
}
|
|
53
68
|
|
|
54
69
|
if (lemmaVerified) {
|
|
55
|
-
|
|
70
|
+
(labelsString === EMPTY_STRING) ?
|
|
71
|
+
fileContext.info(`Verified the lemma.`) :
|
|
72
|
+
fileContext.info(`Verified the '${labelsString}' lemma.`);
|
|
56
73
|
}
|
|
57
74
|
|
|
58
75
|
lemmaVerified ?
|
|
59
76
|
fileContext.complete(lemmaNode) :
|
|
60
|
-
fileContext.
|
|
77
|
+
fileContext.complete(lemmaNode);
|
|
61
78
|
|
|
62
79
|
return lemmaVerified;
|
|
63
80
|
}
|
package/src/verify/proof.js
CHANGED
|
@@ -1,40 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import ProofContext from "../context/proof";
|
|
3
4
|
import verifyDerivation from "../verify/derivation";
|
|
4
5
|
import verifyQualifiedStatement from "../verify/statement/qualified";
|
|
5
6
|
|
|
6
7
|
import { nodeQuery } from "../utilities/query";
|
|
7
8
|
|
|
8
9
|
const derivationNodeQuery = nodeQuery("/proof/derivation!"),
|
|
9
|
-
qualifiedStatementNodeQuery = nodeQuery("/proof/qualifiedStatement!")
|
|
10
|
-
proofStatementNodeQuery = nodeQuery("/proof/qualifiedStatement/statement!");
|
|
10
|
+
qualifiedStatementNodeQuery = nodeQuery("/proof/qualifiedStatement!");
|
|
11
11
|
|
|
12
|
-
export default function verifyProof(proofNode,
|
|
12
|
+
export default function verifyProof(proofNode, fileContext) {
|
|
13
13
|
let proofVerified = false;
|
|
14
14
|
|
|
15
|
+
const proofContext = ProofContext.fromFileContext(fileContext);
|
|
16
|
+
|
|
15
17
|
proofContext.begin(proofNode);
|
|
16
18
|
|
|
17
|
-
const derivationNode = derivationNodeQuery(proofNode)
|
|
19
|
+
const derivationNode = derivationNodeQuery(proofNode),
|
|
20
|
+
qualifiedStatementNode = qualifiedStatementNodeQuery(proofNode);
|
|
18
21
|
|
|
19
|
-
let derivationVerified =
|
|
22
|
+
let derivationVerified = false,
|
|
23
|
+
qualifiedStatementVerified = false;
|
|
20
24
|
|
|
21
25
|
if (derivationNode !== null) {
|
|
22
26
|
derivationVerified = verifyDerivation(derivationNode, proofContext);
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
qualifiedStatementVerified = verifyQualifiedStatement(qualifiedStatementNode, proofContext);
|
|
29
|
+
if (qualifiedStatementNode !== null) {
|
|
30
|
+
let derived;
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
const statementNode = conclusion.getStatementNode(),
|
|
31
|
-
proofStatementNode = proofStatementNodeQuery(proofNode),
|
|
32
|
-
proofStatementNodeMatches = matchProofStatementNode(proofStatementNode, statementNode);
|
|
32
|
+
derived = true;
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
proofContext.setDerived(derived);
|
|
35
|
+
|
|
36
|
+
qualifiedStatementVerified = verifyQualifiedStatement(qualifiedStatementNode, proofContext);
|
|
37
|
+
|
|
38
|
+
derived = false;
|
|
39
|
+
|
|
40
|
+
proofContext.setDerived(derived);
|
|
36
41
|
}
|
|
37
42
|
|
|
43
|
+
// if (derivationVerified) {
|
|
44
|
+
// const qualifiedStatementNode = qualifiedStatementNodeQuery(proofNode),
|
|
45
|
+
// qualifiedStatementVerified = verifyQualifiedStatement(qualifiedStatementNode, proofContext);
|
|
46
|
+
//
|
|
47
|
+
// if (qualifiedStatementVerified) {
|
|
48
|
+
// const statementNode = conclusion.getStatementNode(),
|
|
49
|
+
// proofStatementNode = proofStatementNodeQuery(proofNode),
|
|
50
|
+
// proofStatementNodeMatches = matchProofStatementNode(proofStatementNode, statementNode);
|
|
51
|
+
//
|
|
52
|
+
// proofVerified = proofStatementNodeMatches; ///
|
|
53
|
+
// }
|
|
54
|
+
// }
|
|
55
|
+
|
|
38
56
|
proofVerified ?
|
|
39
57
|
proofContext.complete(proofNode) :
|
|
40
58
|
proofContext.complete(proofNode);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import verifyStatement from "../../verify/statement";
|
|
4
|
+
|
|
3
5
|
import { nodeAsString } from "../../utilities/string";
|
|
4
6
|
import { nodeQuery, referenceNameFromReferenceNode } from "../../utilities/query";
|
|
5
7
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
+
const statementNodeQuery = nodeQuery("/qualifiedStatement/statement!"),
|
|
9
|
+
referenceNodeQuery = nodeQuery("/qualifiedStatement/qualification!/reference!");
|
|
8
10
|
|
|
9
11
|
export default function verifyQualifiedStatement(qualifiedStatementNode, proofContext) {
|
|
10
12
|
let qualifiedStatementVerified = false;
|
|
@@ -17,11 +19,18 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, proofCo
|
|
|
17
19
|
|
|
18
20
|
const statementNode = statementNodeQuery(qualifiedStatementNode);
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
const referenceNode = referenceNodeQuery(qualifiedStatementNode)
|
|
22
|
-
|
|
22
|
+
if (statementNode !== null) {
|
|
23
|
+
const referenceNode = referenceNodeQuery(qualifiedStatementNode);
|
|
24
|
+
|
|
25
|
+
if (referenceNode === null) {
|
|
26
|
+
const statementVerified = verifyStatement(statementNode, proofContext);
|
|
27
|
+
|
|
28
|
+
qualifiedStatementVerified = statementVerified; ///
|
|
29
|
+
} else {
|
|
30
|
+
const referenceName = referenceNameFromReferenceNode(referenceNode);
|
|
23
31
|
|
|
24
|
-
|
|
32
|
+
debugger
|
|
33
|
+
}
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
if (qualifiedStatementVerified) {
|