occam-verify-cli 0.0.682 → 0.0.684
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/assignment/equality.js +60 -0
- package/lib/assignment/variable.js +60 -0
- package/lib/axiom.js +4 -4
- package/lib/axiomLemmaTheoremConjecture.js +29 -29
- package/lib/collection.js +154 -0
- package/lib/combinator.js +1 -1
- package/lib/conclusion.js +5 -5
- package/lib/conjecture.js +4 -4
- package/lib/consequent.js +3 -3
- package/lib/constructor.js +1 -1
- package/lib/context/file.js +9 -2
- package/lib/context/local.js +330 -0
- package/lib/context/localMeta.js +192 -0
- package/lib/context/release.js +1 -1
- package/lib/equality.js +19 -87
- package/lib/label.js +1 -1
- package/lib/lemma.js +4 -4
- package/lib/log.js +1 -1
- package/lib/metaType.js +1 -1
- package/lib/metavariable.js +1 -1
- package/lib/ocmbinator/bracketed.js +1 -1
- package/lib/premise.js +9 -9
- package/lib/rule.js +25 -25
- package/lib/step/metaproof.js +1 -1
- package/lib/step/proof.js +1 -1
- package/lib/substitution/metastatementForMetavariable.js +1 -1
- package/lib/substitution/statementForMetavariable.js +1 -1
- package/lib/substitution/termForVariable.js +1 -1
- package/lib/supposition.js +5 -5
- package/lib/term.js +68 -0
- package/lib/theorem.js +4 -4
- package/lib/type.js +5 -5
- package/lib/utilities/array.js +4 -4
- package/lib/utilities/collection.js +107 -0
- package/lib/variable.js +1 -1
- package/lib/verifier/node/metastatement.js +9 -9
- package/lib/verifier/node/statementAsCombinator.js +1 -1
- package/lib/verifier/node/termAsConstructor.js +2 -2
- package/lib/verifier/node.js +1 -1
- package/lib/verifier/nodes/metastatementForMetavariable/conclusion.js +1 -1
- package/lib/verifier/nodes/metastatementForMetavariable/premise.js +1 -1
- package/lib/verifier/nodes/metastatementForMetavariable.js +8 -8
- package/lib/verifier/nodes/statement.js +1 -1
- package/lib/verifier/nodes/statementForMetavariable/conclusion.js +1 -1
- package/lib/verifier/nodes/statementForMetavariable/premise.js +1 -1
- package/lib/verifier/nodes/statementForMetavariable.js +9 -9
- package/lib/verifier/nodes/term.js +3 -3
- package/lib/verifier/nodes/termForVariable/consequent.js +1 -1
- package/lib/verifier/nodes/termForVariable/supposition.js +1 -1
- package/lib/verifier/nodes/termForVariable.js +11 -11
- package/lib/verifier/nodes.js +1 -1
- package/lib/verify/axiom.js +6 -6
- package/lib/verify/conclusion.js +6 -6
- package/lib/verify/conjecture.js +7 -7
- package/lib/verify/consequent.js +6 -6
- package/lib/verify/derivation.js +17 -17
- package/lib/verify/equality.js +50 -18
- package/lib/verify/lemma.js +7 -7
- package/lib/verify/metastatement/qualified.js +7 -7
- package/lib/verify/metastatement/unqualified.js +7 -7
- package/lib/verify/metastatement.js +12 -12
- package/lib/verify/premise.js +7 -7
- package/lib/verify/proof.js +10 -7
- package/lib/verify/rule.js +6 -6
- package/lib/verify/ruleDerivation.js +17 -17
- package/lib/verify/ruleProof.js +6 -6
- package/lib/verify/statement/qualified.js +15 -15
- package/lib/verify/statement/unqualified.js +7 -7
- package/lib/verify/supposition.js +8 -8
- package/lib/verify/term.js +32 -31
- package/lib/verify/terms.js +11 -17
- package/lib/verify/theorem.js +7 -7
- package/lib/verify/typeAssertion.js +3 -3
- package/package.json +2 -2
- package/src/assignment/equality.js +21 -0
- package/src/assignment/variable.js +21 -0
- package/src/axiom.js +1 -1
- package/src/axiomLemmaTheoremConjecture.js +26 -26
- package/src/collection.js +101 -0
- package/src/conclusion.js +6 -6
- package/src/conjecture.js +1 -1
- package/src/consequent.js +4 -4
- package/src/context/file.js +9 -1
- package/src/context/local.js +311 -0
- package/src/context/{metaproof.js → localMeta.js} +16 -17
- package/src/equality.js +17 -111
- package/src/lemma.js +1 -1
- package/src/premise.js +12 -12
- package/src/rule.js +24 -24
- package/src/supposition.js +8 -8
- package/src/term.js +30 -0
- package/src/theorem.js +1 -1
- package/src/type.js +3 -3
- package/src/utilities/array.js +1 -1
- package/src/utilities/collection.js +83 -0
- package/src/verifier/node/metastatement.js +8 -8
- package/src/verifier/node/termAsConstructor.js +2 -2
- package/src/verifier/nodes/metastatementForMetavariable.js +7 -7
- package/src/verifier/nodes/statementForMetavariable.js +8 -8
- package/src/verifier/nodes/term.js +5 -4
- package/src/verifier/nodes/termForVariable.js +15 -14
- package/src/verify/axiom.js +5 -5
- package/src/verify/conclusion.js +5 -5
- package/src/verify/conjecture.js +6 -6
- package/src/verify/consequent.js +5 -5
- package/src/verify/derivation.js +16 -16
- package/src/verify/equality.js +81 -24
- package/src/verify/lemma.js +6 -6
- package/src/verify/metastatement/qualified.js +7 -7
- package/src/verify/metastatement/unqualified.js +6 -6
- package/src/verify/metastatement.js +11 -11
- package/src/verify/premise.js +6 -6
- package/src/verify/proof.js +13 -10
- package/src/verify/rule.js +5 -5
- package/src/verify/ruleDerivation.js +16 -16
- package/src/verify/ruleProof.js +5 -5
- package/src/verify/statement/qualified.js +15 -15
- package/src/verify/statement/unqualified.js +6 -6
- package/src/verify/supposition.js +7 -7
- package/src/verify/term.js +38 -35
- package/src/verify/terms.js +14 -28
- package/src/verify/theorem.js +6 -6
- package/src/verify/typeAssertion.js +3 -2
- package/lib/assignment.js +0 -74
- package/lib/context/metaproof.js +0 -192
- package/lib/context/proof.js +0 -245
- package/lib/verifier/nodes/equality.js +0 -155
- package/src/assignment.js +0 -36
- package/src/context/proof.js +0 -205
- package/src/verifier/nodes/equality.js +0 -68
package/src/verify/axiom.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Axiom from "../axiom";
|
|
4
|
-
import
|
|
4
|
+
import LocalContext from "../context/local";
|
|
5
5
|
import verifyLabels from "../verify/labels";
|
|
6
6
|
import verifyConsequent from "../verify/consequent";
|
|
7
7
|
import verifySupposition from "../verify/supposition";
|
|
@@ -18,7 +18,7 @@ export default function verifyAxiom(axiomNode, fileContext) {
|
|
|
18
18
|
|
|
19
19
|
const labelNodes = labelNodesQuery(axiomNode),
|
|
20
20
|
labelsString = fileContext.nodesAsString(labelNodes),
|
|
21
|
-
|
|
21
|
+
localContext = LocalContext.fromFileContext(fileContext);
|
|
22
22
|
|
|
23
23
|
fileContext.trace(`Verifying the '${labelsString}' axiom...`, axiomNode);
|
|
24
24
|
|
|
@@ -29,7 +29,7 @@ export default function verifyAxiom(axiomNode, fileContext) {
|
|
|
29
29
|
const suppositions = [],
|
|
30
30
|
suppositionNodes = suppositionsNodeQuery(axiomNode),
|
|
31
31
|
suppositionsVerified = suppositionNodes.every((suppositionNode) => {
|
|
32
|
-
const suppositionVerified = verifySupposition(suppositionNode, suppositions,
|
|
32
|
+
const suppositionVerified = verifySupposition(suppositionNode, suppositions, localContext);
|
|
33
33
|
|
|
34
34
|
if (suppositionVerified) {
|
|
35
35
|
return true;
|
|
@@ -39,12 +39,12 @@ export default function verifyAxiom(axiomNode, fileContext) {
|
|
|
39
39
|
if (suppositionsVerified) {
|
|
40
40
|
const consequents = [],
|
|
41
41
|
consequentNode = consequentNodeQuery(axiomNode),
|
|
42
|
-
consequentVerified = verifyConsequent(consequentNode, consequents,
|
|
42
|
+
consequentVerified = verifyConsequent(consequentNode, consequents, localContext);
|
|
43
43
|
|
|
44
44
|
if (consequentVerified) {
|
|
45
45
|
const firstConsequent = first(consequents),
|
|
46
46
|
consequent = firstConsequent, ///
|
|
47
|
-
axiom = Axiom.
|
|
47
|
+
axiom = Axiom.fromLabelsSuppositionsConsequentAndLocalContext(labels, suppositions, consequent, localContext);
|
|
48
48
|
|
|
49
49
|
fileContext.addAxiom(axiom);
|
|
50
50
|
|
package/src/verify/conclusion.js
CHANGED
|
@@ -8,16 +8,16 @@ import { nodeQuery } from "../utilities/query";
|
|
|
8
8
|
const metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatement!"),
|
|
9
9
|
unqualifiedMetastatementNodeQuery = nodeQuery("/conclusion/unqualifiedMetastatement!");
|
|
10
10
|
|
|
11
|
-
export default function verifyConclusion(conclusionNode, conclusions,
|
|
11
|
+
export default function verifyConclusion(conclusionNode, conclusions, localMetaContext) {
|
|
12
12
|
let conclusionVerified = false;
|
|
13
13
|
|
|
14
|
-
const conclusionString =
|
|
14
|
+
const conclusionString = localMetaContext.nodeAsString(conclusionNode);
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
localMetaContext.trace(`Verifying the '${conclusionString}' conclusion...`, conclusionNode);
|
|
17
17
|
|
|
18
18
|
const derived = false,
|
|
19
19
|
unqualifiedMetastatementNode = unqualifiedMetastatementNodeQuery(conclusionNode),
|
|
20
|
-
unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, derived,
|
|
20
|
+
unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, derived, localMetaContext);
|
|
21
21
|
|
|
22
22
|
if (unqualifiedMetastatementVerified) {
|
|
23
23
|
const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode),
|
|
@@ -29,7 +29,7 @@ export default function verifyConclusion(conclusionNode, conclusions, metaproofC
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
if (conclusionVerified) {
|
|
32
|
-
|
|
32
|
+
localMetaContext.debug(`...verified the '${conclusionString}' conclusion.`, conclusionNode);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
return conclusionVerified;
|
package/src/verify/conjecture.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import Conjecture from "../conjecture";
|
|
4
4
|
import verifyProof from "../verify/proof";
|
|
5
|
-
import
|
|
5
|
+
import LocalContext from "../context/local";
|
|
6
6
|
import verifyLabels from "../verify/labels";
|
|
7
7
|
import verifyConsequent from "./consequent";
|
|
8
8
|
import verifySupposition from "./supposition";
|
|
@@ -20,7 +20,7 @@ export default function verifyConjecture(conjectureNode, fileContext) {
|
|
|
20
20
|
|
|
21
21
|
const labelNodes = labelNodesQuery(conjectureNode),
|
|
22
22
|
labelsString = fileContext.nodesAsString(labelNodes),
|
|
23
|
-
|
|
23
|
+
localContext = LocalContext.fromFileContext(fileContext);
|
|
24
24
|
|
|
25
25
|
fileContext.trace(`Verifying the '${labelsString}' conjecture...`, conjectureNode);
|
|
26
26
|
|
|
@@ -31,7 +31,7 @@ export default function verifyConjecture(conjectureNode, fileContext) {
|
|
|
31
31
|
const suppositions = [],
|
|
32
32
|
suppositionNodes = suppositionsNodeQuery(conjectureNode),
|
|
33
33
|
suppositionsVerified = suppositionNodes.every((suppositionNode) => {
|
|
34
|
-
const suppositionVerified = verifySupposition(suppositionNode, suppositions,
|
|
34
|
+
const suppositionVerified = verifySupposition(suppositionNode, suppositions, localContext);
|
|
35
35
|
|
|
36
36
|
if (suppositionVerified) {
|
|
37
37
|
return true;
|
|
@@ -41,16 +41,16 @@ export default function verifyConjecture(conjectureNode, fileContext) {
|
|
|
41
41
|
if (suppositionsVerified) {
|
|
42
42
|
const consequents = [],
|
|
43
43
|
consequentNode = consequentNodeQuery(conjectureNode),
|
|
44
|
-
consequentVerified = verifyConsequent(consequentNode, consequents,
|
|
44
|
+
consequentVerified = verifyConsequent(consequentNode, consequents, localContext);
|
|
45
45
|
|
|
46
46
|
if (consequentVerified) {
|
|
47
47
|
const proofNode = proofNodeQuery(conjectureNode),
|
|
48
48
|
firstConsequent = first(consequents),
|
|
49
49
|
consequent = firstConsequent; ///
|
|
50
50
|
|
|
51
|
-
verifyProof(proofNode, consequent,
|
|
51
|
+
verifyProof(proofNode, consequent, localContext);
|
|
52
52
|
|
|
53
|
-
const conjecture = Conjecture.
|
|
53
|
+
const conjecture = Conjecture.fromLabelsSuppositionsConsequentAndLocalContext(labels, suppositions, consequent, localContext);
|
|
54
54
|
|
|
55
55
|
fileContext.addConjecture(conjecture);
|
|
56
56
|
|
package/src/verify/consequent.js
CHANGED
|
@@ -8,17 +8,17 @@ import { nodeQuery } from "../utilities/query";
|
|
|
8
8
|
const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
|
|
9
9
|
unqualifiedStatementNodeQuery = nodeQuery("/consequent/unqualifiedStatement!");
|
|
10
10
|
|
|
11
|
-
export default function verifyConsequent(consequentNode, consequents,
|
|
11
|
+
export default function verifyConsequent(consequentNode, consequents, localContext) {
|
|
12
12
|
let consequentVerified = false;
|
|
13
13
|
|
|
14
|
-
const consequentString =
|
|
14
|
+
const consequentString = localContext.nodeAsString(consequentNode);
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
localContext.trace(`Verifying the '${consequentString}' consequent...`, consequentNode);
|
|
17
17
|
|
|
18
18
|
const derived = false,
|
|
19
19
|
assignments = [],
|
|
20
20
|
unqualifiedStatementNode = unqualifiedStatementNodeQuery(consequentNode),
|
|
21
|
-
unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, assignments, derived,
|
|
21
|
+
unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, assignments, derived, localContext);
|
|
22
22
|
|
|
23
23
|
if (unqualifiedStatementVerified) {
|
|
24
24
|
const statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
@@ -30,7 +30,7 @@ export default function verifyConsequent(consequentNode, consequents, proofConte
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
if (consequentVerified) {
|
|
33
|
-
|
|
33
|
+
localContext.debug(`...verified the '${consequentString}' consequent.`, consequentNode);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
return consequentVerified;
|
package/src/verify/derivation.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import ProofStep from "../step/proof";
|
|
4
|
-
import
|
|
4
|
+
import LocalContext from "../context/local";
|
|
5
5
|
import verifySupposition from "./supposition";
|
|
6
6
|
import verifyQualifiedStatement from "../verify/statement/qualified";
|
|
7
7
|
import verifyUnqualifiedStatement from "../verify/statement/unqualified";
|
|
@@ -14,13 +14,13 @@ const childNodesQuery = nodesQuery("/derivation|subDerivation/*"),
|
|
|
14
14
|
suppositionNodesQuery = nodesQuery("/subproof/supposition"),
|
|
15
15
|
subDerivationNodeQuery = nodeQuery("/subproof/subDerivation");
|
|
16
16
|
|
|
17
|
-
export default function verifyDerivation(derivationNode,
|
|
17
|
+
export default function verifyDerivation(derivationNode, localContext) {
|
|
18
18
|
let derivationVerified;
|
|
19
19
|
|
|
20
20
|
const childNodes = childNodesQuery(derivationNode);
|
|
21
21
|
|
|
22
22
|
derivationVerified = childNodes.every((childNode) => {
|
|
23
|
-
const childVerified = verifyChild(childNode,
|
|
23
|
+
const childVerified = verifyChild(childNode, localContext);
|
|
24
24
|
|
|
25
25
|
if (childVerified) {
|
|
26
26
|
return true;
|
|
@@ -30,13 +30,13 @@ export default function verifyDerivation(derivationNode, proofContext) {
|
|
|
30
30
|
return derivationVerified;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function verifySubDerivation(subDerivationNode,
|
|
33
|
+
function verifySubDerivation(subDerivationNode, localContext) {
|
|
34
34
|
let subDerivationVerified;
|
|
35
35
|
|
|
36
36
|
const childNodes = childNodesQuery(subDerivationNode);
|
|
37
37
|
|
|
38
38
|
subDerivationVerified = childNodes.every((childNode) => {
|
|
39
|
-
const childVerified = verifyChild(childNode,
|
|
39
|
+
const childVerified = verifyChild(childNode, localContext);
|
|
40
40
|
|
|
41
41
|
if (childVerified) {
|
|
42
42
|
return true;
|
|
@@ -46,15 +46,15 @@ function verifySubDerivation(subDerivationNode, proofContext) {
|
|
|
46
46
|
return subDerivationVerified;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
function verifySubproof(subproofNode,
|
|
49
|
+
function verifySubproof(subproofNode, localContext) {
|
|
50
50
|
let subproofVerified = false;
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
localContext = LocalContext.fromLocalContext(localContext); ///
|
|
53
53
|
|
|
54
54
|
const suppositions = [],
|
|
55
55
|
suppositionNodes = suppositionNodesQuery(subproofNode),
|
|
56
56
|
suppositionsVerified = suppositionNodes.every((suppositionNode) => {
|
|
57
|
-
const suppositionVerified = verifySupposition(suppositionNode, suppositions,
|
|
57
|
+
const suppositionVerified = verifySupposition(suppositionNode, suppositions, localContext);
|
|
58
58
|
|
|
59
59
|
if (suppositionVerified) {
|
|
60
60
|
return true;
|
|
@@ -63,7 +63,7 @@ function verifySubproof(subproofNode, proofContext) {
|
|
|
63
63
|
|
|
64
64
|
if (suppositionsVerified) {
|
|
65
65
|
const subDerivationNode = subDerivationNodeQuery(subproofNode),
|
|
66
|
-
subDerivationVerified = verifySubDerivation(subDerivationNode,
|
|
66
|
+
subDerivationVerified = verifySubDerivation(subDerivationNode, localContext);
|
|
67
67
|
|
|
68
68
|
if (subDerivationVerified) {
|
|
69
69
|
subproofVerified = true;
|
|
@@ -73,7 +73,7 @@ function verifySubproof(subproofNode, proofContext) {
|
|
|
73
73
|
return subproofVerified;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
function verifyChild(childNode,
|
|
76
|
+
function verifyChild(childNode, localContext) {
|
|
77
77
|
let childVerified;
|
|
78
78
|
|
|
79
79
|
const childNodeRuleName = childNode.getRuleName();
|
|
@@ -81,12 +81,12 @@ function verifyChild(childNode, proofContext) {
|
|
|
81
81
|
switch (childNodeRuleName) {
|
|
82
82
|
case SUBPROOF_RULE_NAME: {
|
|
83
83
|
const subproofNode = childNode, ///
|
|
84
|
-
subproofVerified = verifySubproof(subproofNode,
|
|
84
|
+
subproofVerified = verifySubproof(subproofNode, localContext);
|
|
85
85
|
|
|
86
86
|
if (subproofVerified) {
|
|
87
87
|
const proofStep = ProofStep.fromSubproofNode(subproofNode);
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
localContext.addProofStep(proofStep);
|
|
90
90
|
|
|
91
91
|
childVerified = true;
|
|
92
92
|
}
|
|
@@ -98,13 +98,13 @@ function verifyChild(childNode, proofContext) {
|
|
|
98
98
|
const derived = true,
|
|
99
99
|
assignments = [],
|
|
100
100
|
qualifiedStatementNode = childNode, ///
|
|
101
|
-
qualifiedStatementVerified = verifyQualifiedStatement(qualifiedStatementNode, assignments, derived,
|
|
101
|
+
qualifiedStatementVerified = verifyQualifiedStatement(qualifiedStatementNode, assignments, derived, localContext);
|
|
102
102
|
|
|
103
103
|
if (qualifiedStatementVerified) {
|
|
104
104
|
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
105
105
|
proofStep = ProofStep.fromStatementNode(statementNode);
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
localContext.addProofStep(proofStep);
|
|
108
108
|
|
|
109
109
|
childVerified = qualifiedStatementVerified; ///
|
|
110
110
|
}
|
|
@@ -116,13 +116,13 @@ function verifyChild(childNode, proofContext) {
|
|
|
116
116
|
const derived = true,
|
|
117
117
|
assignments = [],
|
|
118
118
|
unqualifiedStatementNode = childNode, ///
|
|
119
|
-
unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, assignments, derived,
|
|
119
|
+
unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, assignments, derived, localContext);
|
|
120
120
|
|
|
121
121
|
if (unqualifiedStatementVerified) {
|
|
122
122
|
const statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
123
123
|
proofStep = ProofStep.fromStatementNode(statementNode);
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
localContext.addProofStep(proofStep);
|
|
126
126
|
|
|
127
127
|
childVerified = true;
|
|
128
128
|
}
|
package/src/verify/equality.js
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import Equality from "../equality";
|
|
4
4
|
import verifyTerms from "../verify/terms";
|
|
5
|
+
import EqualityAssignment from "../assignment/equality";
|
|
6
|
+
|
|
7
|
+
import { nodeQuery } from "../utilities/query";
|
|
8
|
+
import { first, second } from "../utilities/array";
|
|
9
|
+
|
|
10
|
+
const leftTermNodeQuery = nodeQuery("/equality/argument[0]/term!"),
|
|
11
|
+
rightTermNodeQuery = nodeQuery("/equality/argument[1]/term!");
|
|
5
12
|
|
|
6
13
|
export default function verifyEquality(equalityNode, assignments, derived, context, verifyAhead) {
|
|
7
14
|
let equalityVerified;
|
|
@@ -10,15 +17,15 @@ export default function verifyEquality(equalityNode, assignments, derived, conte
|
|
|
10
17
|
|
|
11
18
|
context.trace(`Verifying the '${equalityString}' equality...`, equalityNode);
|
|
12
19
|
|
|
13
|
-
const
|
|
20
|
+
const verifyEqualityFunctions = [
|
|
14
21
|
verifyDerivedEquality,
|
|
15
22
|
verifyStandaloneEquality
|
|
16
23
|
];
|
|
17
24
|
|
|
18
|
-
equalityVerified =
|
|
19
|
-
const
|
|
25
|
+
equalityVerified = verifyEqualityFunctions.some((verifyEqualityFunction) => {
|
|
26
|
+
const equalityVerified = verifyEqualityFunction(equalityNode, assignments, derived, context, verifyAhead);
|
|
20
27
|
|
|
21
|
-
if (
|
|
28
|
+
if (equalityVerified) {
|
|
22
29
|
return true;
|
|
23
30
|
}
|
|
24
31
|
});
|
|
@@ -30,47 +37,97 @@ export default function verifyEquality(equalityNode, assignments, derived, conte
|
|
|
30
37
|
return equalityVerified;
|
|
31
38
|
}
|
|
32
39
|
|
|
33
|
-
function verifyDerivedEquality(equalityNode, derived, context, verifyAhead) {
|
|
34
|
-
let
|
|
40
|
+
function verifyDerivedEquality(equalityNode, assignments, derived, context, verifyAhead) {
|
|
41
|
+
let derivedEqualityVerified = false;
|
|
35
42
|
|
|
36
43
|
if (derived) {
|
|
37
44
|
const equalityString = context.nodeAsString(equalityNode);
|
|
38
45
|
|
|
39
46
|
context.trace(`Verifying the '${equalityString}' derived equality...`, equalityNode);
|
|
40
47
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
const terms = [],
|
|
49
|
+
leftTermNode = leftTermNodeQuery(equalityNode),
|
|
50
|
+
rightTermNode = rightTermNodeQuery(equalityNode),
|
|
51
|
+
termNodes = [
|
|
52
|
+
leftTermNode,
|
|
53
|
+
rightTermNode
|
|
54
|
+
],
|
|
55
|
+
termsVerified = verifyTerms(termNodes, terms, context, () => {
|
|
56
|
+
let verifiedAhead = false;
|
|
57
|
+
|
|
58
|
+
const firstTerm = first(terms),
|
|
59
|
+
secondTerm = second(terms),
|
|
60
|
+
leftTerm = firstTerm, ///
|
|
61
|
+
rightTerm = secondTerm, ///
|
|
62
|
+
equality = Equality.fromLeftTermAndRightTerm(leftTerm, rightTerm);
|
|
63
|
+
|
|
64
|
+
if (equality !== null) {
|
|
65
|
+
const equalityEqual = context.isEqualityEqual(equality);
|
|
66
|
+
|
|
67
|
+
if (equalityEqual) {
|
|
68
|
+
verifiedAhead = verifyAhead();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return verifiedAhead;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
derivedEqualityVerified = termsVerified; ///
|
|
76
|
+
|
|
77
|
+
if (derivedEqualityVerified) {
|
|
78
|
+
context.trace(`...verified the '${equalityString}' derived equality.`, equalityNode);
|
|
49
79
|
}
|
|
50
80
|
}
|
|
51
81
|
|
|
52
|
-
return
|
|
82
|
+
return derivedEqualityVerified;
|
|
53
83
|
}
|
|
54
84
|
|
|
55
|
-
function verifyStandaloneEquality(equalityNode, derived, context, verifyAhead) {
|
|
56
|
-
let
|
|
85
|
+
function verifyStandaloneEquality(equalityNode, assignments, derived, context, verifyAhead) {
|
|
86
|
+
let standaloneEqualityVerified = false;
|
|
57
87
|
|
|
58
88
|
if (!derived) {
|
|
59
89
|
const equalityString = context.nodeAsString(equalityNode);
|
|
60
90
|
|
|
61
91
|
context.trace(`Verifying the '${equalityString}' standalone equality...`, equalityNode);
|
|
62
92
|
|
|
63
|
-
const
|
|
64
|
-
leftTermNode =
|
|
65
|
-
rightTermNode =
|
|
66
|
-
|
|
93
|
+
const terms = [],
|
|
94
|
+
leftTermNode = leftTermNodeQuery(equalityNode),
|
|
95
|
+
rightTermNode = rightTermNodeQuery(equalityNode),
|
|
96
|
+
termNodes = [
|
|
97
|
+
leftTermNode,
|
|
98
|
+
rightTermNode
|
|
99
|
+
],
|
|
100
|
+
termsVerified = verifyTerms(termNodes, terms, context, () => {
|
|
101
|
+
let verifiedAhead = false;
|
|
102
|
+
|
|
103
|
+
const firstTerm = first(terms),
|
|
104
|
+
secondTerm = second(terms),
|
|
105
|
+
leftTerm = firstTerm, ///
|
|
106
|
+
rightTerm = secondTerm, ///
|
|
107
|
+
equality = Equality.fromLeftTermAndRightTerm(leftTerm, rightTerm);
|
|
108
|
+
|
|
109
|
+
if (equality !== null) {
|
|
110
|
+
const equalityAssignment = EqualityAssignment.fromEquality(equality),
|
|
111
|
+
assignment = equalityAssignment; ///
|
|
112
|
+
|
|
113
|
+
assignments.push(assignment);
|
|
114
|
+
|
|
115
|
+
verifiedAhead = verifyAhead();
|
|
116
|
+
|
|
117
|
+
if (!verifiedAhead) {
|
|
118
|
+
assignments.pop();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return verifiedAhead;
|
|
123
|
+
});
|
|
67
124
|
|
|
68
|
-
|
|
125
|
+
standaloneEqualityVerified = termsVerified; ///
|
|
69
126
|
|
|
70
|
-
if (
|
|
127
|
+
if (standaloneEqualityVerified) {
|
|
71
128
|
context.trace(`...verified the '${equalityString}' standalone equality.`, equalityNode);
|
|
72
129
|
}
|
|
73
130
|
}
|
|
74
131
|
|
|
75
|
-
return
|
|
132
|
+
return standaloneEqualityVerified;
|
|
76
133
|
}
|
package/src/verify/lemma.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import Lemma from "../lemma";
|
|
4
4
|
import verifyProof from "../verify/proof";
|
|
5
|
-
import
|
|
5
|
+
import LocalContext from "../context/local";
|
|
6
6
|
import verifyLabels from "../verify/labels";
|
|
7
7
|
import verifyConsequent from "./consequent";
|
|
8
8
|
import verifySupposition from "./supposition";
|
|
@@ -21,7 +21,7 @@ export default function verifyLemma(lemmaNode, fileContext) {
|
|
|
21
21
|
|
|
22
22
|
const labelNodes = labelNodesQuery(lemmaNode),
|
|
23
23
|
labelsString = fileContext.nodesAsString(labelNodes),
|
|
24
|
-
|
|
24
|
+
localContext = LocalContext.fromFileContext(fileContext);
|
|
25
25
|
|
|
26
26
|
(labelsString === EMPTY_STRING) ?
|
|
27
27
|
fileContext.trace(`Verifying a lemma...`, lemmaNode) :
|
|
@@ -34,7 +34,7 @@ export default function verifyLemma(lemmaNode, fileContext) {
|
|
|
34
34
|
const suppositions = [],
|
|
35
35
|
suppositionNodes = suppositionsNodeQuery(lemmaNode),
|
|
36
36
|
suppositionsVerified = suppositionNodes.every((suppositionNode) => {
|
|
37
|
-
const suppositionVerified = verifySupposition(suppositionNode, suppositions,
|
|
37
|
+
const suppositionVerified = verifySupposition(suppositionNode, suppositions, localContext);
|
|
38
38
|
|
|
39
39
|
if (suppositionVerified) {
|
|
40
40
|
return true;
|
|
@@ -44,16 +44,16 @@ export default function verifyLemma(lemmaNode, fileContext) {
|
|
|
44
44
|
if (suppositionsVerified) {
|
|
45
45
|
const consequents = [],
|
|
46
46
|
consequentNode = consequentNodeQuery(lemmaNode),
|
|
47
|
-
consequentVerified = verifyConsequent(consequentNode, consequents,
|
|
47
|
+
consequentVerified = verifyConsequent(consequentNode, consequents, localContext);
|
|
48
48
|
|
|
49
49
|
if (consequentVerified) {
|
|
50
50
|
const proofNode = proofNodeQuery(lemmaNode),
|
|
51
51
|
firstConsequent = first(consequents),
|
|
52
52
|
consequent = firstConsequent, ///
|
|
53
|
-
proofVerified = verifyProof(proofNode, consequent,
|
|
53
|
+
proofVerified = verifyProof(proofNode, consequent, localContext);
|
|
54
54
|
|
|
55
55
|
if (proofVerified) {
|
|
56
|
-
const lemma = Lemma.
|
|
56
|
+
const lemma = Lemma.fromLabelsSuppositionsConsequentAndLocalContext(labels, suppositions, consequent, localContext);
|
|
57
57
|
|
|
58
58
|
fileContext.addLemma(lemma);
|
|
59
59
|
|
|
@@ -5,29 +5,29 @@ import { nodeQuery, referenceNameFromReferenceNode } from "../../utilities/query
|
|
|
5
5
|
const referenceNodeQuery = nodeQuery("/qualifiedMetastatement/qualification!/reference!"),
|
|
6
6
|
metastatementNodeQuery = nodeQuery("/qualifiedMetastatement/metastatement!");
|
|
7
7
|
|
|
8
|
-
export default function verifyQualifiedMetastatement(qualifiedMetastatementNode, assignments, derived,
|
|
8
|
+
export default function verifyQualifiedMetastatement(qualifiedMetastatementNode, assignments, derived, localMetaContext) {
|
|
9
9
|
let qualifiedMetastatementVerified = false;
|
|
10
10
|
|
|
11
11
|
const metastatementNode = metastatementNodeQuery(qualifiedMetastatementNode);
|
|
12
12
|
|
|
13
13
|
if (metastatementNode !== null) {
|
|
14
|
-
const metastatementString =
|
|
15
|
-
|
|
14
|
+
const metastatementString = localMetaContext.nodeAsString(metastatementNode),
|
|
15
|
+
metastatementLocalMetaContext = localMetaContext; ///
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
localMetaContext.trace(`Verifying the '${metastatementString}' qualified metastatement...`, qualifiedMetastatementNode);
|
|
18
18
|
|
|
19
19
|
const referenceNode = referenceNodeQuery(qualifiedMetastatementNode),
|
|
20
20
|
referenceName = referenceNameFromReferenceNode(referenceNode),
|
|
21
|
-
rule =
|
|
21
|
+
rule = localMetaContext.findRuleByReferenceName(referenceName);
|
|
22
22
|
|
|
23
23
|
if (rule !== null) {
|
|
24
|
-
const ruleMatchesMetastatement = rule.matchMetastatement(metastatementNode,
|
|
24
|
+
const ruleMatchesMetastatement = rule.matchMetastatement(metastatementNode, metastatementLocalMetaContext);
|
|
25
25
|
|
|
26
26
|
qualifiedMetastatementVerified = ruleMatchesMetastatement; ///
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
if (qualifiedMetastatementVerified) {
|
|
30
|
-
|
|
30
|
+
localMetaContext.debug(`...verified the '${metastatementString}' qualified metastatement.`, qualifiedMetastatementNode);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -6,24 +6,24 @@ import { nodeQuery } from "../../utilities/query";
|
|
|
6
6
|
|
|
7
7
|
const metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatement!");
|
|
8
8
|
|
|
9
|
-
export default function verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, derived,
|
|
9
|
+
export default function verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, derived, localMetaContext) {
|
|
10
10
|
let unqualifiedMetastatementVerified = false;
|
|
11
11
|
|
|
12
12
|
const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode);
|
|
13
13
|
|
|
14
14
|
if (metastatementNode !== null) {
|
|
15
|
-
const metastatementString =
|
|
15
|
+
const metastatementString = localMetaContext.nodeAsString(metastatementNode);
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
localMetaContext.trace(`Verifying the '${metastatementString}' unqualified metastatement...`, unqualifiedMetastatementNode);
|
|
18
18
|
|
|
19
19
|
if (derived) {
|
|
20
|
-
const metastatementMatches =
|
|
20
|
+
const metastatementMatches = localMetaContext.matchMetastatement(metastatementNode);
|
|
21
21
|
|
|
22
22
|
unqualifiedMetastatementVerified = metastatementMatches; ///
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
if (!unqualifiedMetastatementVerified) {
|
|
26
|
-
const metastatementVerified = verifyMetastatement(metastatementNode, derived,
|
|
26
|
+
const metastatementVerified = verifyMetastatement(metastatementNode, derived, localMetaContext, () => {
|
|
27
27
|
const verifiedAhead = true;
|
|
28
28
|
|
|
29
29
|
return verifiedAhead;
|
|
@@ -33,7 +33,7 @@ export default function verifyUnqualifiedMetastatement(unqualifiedMetastatementN
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
if (unqualifiedMetastatementVerified) {
|
|
36
|
-
|
|
36
|
+
localMetaContext.debug(`...verified the '${metastatementString}' unqualified metastatement.`, unqualifiedMetastatementNode);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
import metastatementNodeVerifier from "../verifier/node/metastatement";
|
|
4
4
|
|
|
5
|
-
function verifyMetastatement(metastatementNode, derived,
|
|
5
|
+
function verifyMetastatement(metastatementNode, derived, localMetaContext) {
|
|
6
6
|
let metastatementVerified;
|
|
7
7
|
|
|
8
|
-
const metastatementString =
|
|
8
|
+
const metastatementString = localMetaContext.nodeAsString(metastatementNode);
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
localMetaContext.trace(`Verifying the '${metastatementString}' metastatement...`, metastatementNode);
|
|
11
11
|
|
|
12
12
|
const verifyMetastatementFunctions = [
|
|
13
13
|
verifyStandaloneMetastatement
|
|
14
14
|
];
|
|
15
15
|
|
|
16
|
-
metastatementVerified = verifyMetastatementFunctions.some((
|
|
17
|
-
const metastatementVerified =
|
|
16
|
+
metastatementVerified = verifyMetastatementFunctions.some((verifyMetastatementFunction) => {
|
|
17
|
+
const metastatementVerified = verifyMetastatementFunction(metastatementNode, derived, localMetaContext);
|
|
18
18
|
|
|
19
19
|
if (metastatementVerified) {
|
|
20
20
|
return true;
|
|
@@ -22,7 +22,7 @@ function verifyMetastatement(metastatementNode, derived, metaproofContext) {
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
if (metastatementVerified) {
|
|
25
|
-
|
|
25
|
+
localMetaContext.debug(`...verified the '${metastatementString}' metastatement.`, metastatementNode);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
return metastatementVerified;
|
|
@@ -34,15 +34,15 @@ Object.assign(verifyMetastatement, {
|
|
|
34
34
|
|
|
35
35
|
export default verifyMetastatement;
|
|
36
36
|
|
|
37
|
-
function verifyStandaloneMetastatement(metastatementNode, derived,
|
|
37
|
+
function verifyStandaloneMetastatement(metastatementNode, derived, localMetaContext) {
|
|
38
38
|
let standaloneMetastatementVerified;
|
|
39
39
|
|
|
40
|
-
const metastatementString =
|
|
40
|
+
const metastatementString = localMetaContext.nodeAsString(metastatementNode);
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
localMetaContext.trace(`Verifying the '${metastatementString}' standalone metastatement...`, metastatementNode);
|
|
43
43
|
|
|
44
44
|
const nonTerminalNode = metastatementNode, ///
|
|
45
|
-
nonTerminalNodeVerified = metastatementNodeVerifier.verifyNonTerminalNode(nonTerminalNode,
|
|
45
|
+
nonTerminalNodeVerified = metastatementNodeVerifier.verifyNonTerminalNode(nonTerminalNode, localMetaContext, () => {
|
|
46
46
|
const verifiedAhead = true;
|
|
47
47
|
|
|
48
48
|
return verifiedAhead;
|
|
@@ -51,7 +51,7 @@ function verifyStandaloneMetastatement(metastatementNode, derived, metaproofCont
|
|
|
51
51
|
standaloneMetastatementVerified = nonTerminalNodeVerified; ///
|
|
52
52
|
|
|
53
53
|
if (standaloneMetastatementVerified) {
|
|
54
|
-
|
|
54
|
+
localMetaContext.debug(`...verified the '${metastatementString}' standalone metastatement.`, metastatementNode);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
return standaloneMetastatementVerified;
|
package/src/verify/premise.js
CHANGED
|
@@ -9,16 +9,16 @@ import { nodeQuery } from "../utilities/query";
|
|
|
9
9
|
const metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatement!"),
|
|
10
10
|
unqualifiedMetastatementNodeQuery = nodeQuery("/premise/unqualifiedMetastatement!");
|
|
11
11
|
|
|
12
|
-
export default function verifyPremise(premiseNode, premises,
|
|
12
|
+
export default function verifyPremise(premiseNode, premises, localMetaContext) {
|
|
13
13
|
let premiseVerified;
|
|
14
14
|
|
|
15
|
-
const premiseString =
|
|
15
|
+
const premiseString = localMetaContext.nodeAsString(premiseNode);
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
localMetaContext.trace(`Verifying the '${premiseString}' premise...`, premiseNode);
|
|
18
18
|
|
|
19
19
|
const derived = false,
|
|
20
20
|
unqualifiedMetastatementNode = unqualifiedMetastatementNodeQuery(premiseNode),
|
|
21
|
-
unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, derived,
|
|
21
|
+
unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, derived, localMetaContext);
|
|
22
22
|
|
|
23
23
|
if (unqualifiedMetastatementVerified) {
|
|
24
24
|
const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode),
|
|
@@ -27,13 +27,13 @@ export default function verifyPremise(premiseNode, premises, metaproofContext) {
|
|
|
27
27
|
|
|
28
28
|
premises.push(premise);
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
localMetaContext.addMetaproofStep(metaproofStep);
|
|
31
31
|
|
|
32
32
|
premiseVerified = true;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
if (premiseVerified) {
|
|
36
|
-
|
|
36
|
+
localMetaContext.debug(`...verified the '${premiseString}' premise.`, premiseNode);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
return premiseVerified;
|