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/proof.js
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import LocalContext from "../context/local";
|
|
4
4
|
import verifyDerivation from "../verify/derivation";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
7
|
|
|
8
8
|
const derivationNodeQuery = nodeQuery("/proof/derivation!");
|
|
9
9
|
|
|
10
|
-
export default function verifyProof(proofNode, conclusion,
|
|
10
|
+
export default function verifyProof(proofNode, conclusion, localContext) {
|
|
11
11
|
let proofVerified = false;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
localContext = LocalContext.fromLocalContext(localContext); ///
|
|
14
14
|
|
|
15
15
|
const derivationNode = derivationNodeQuery(proofNode),
|
|
16
|
-
derivationVerified = verifyDerivation(derivationNode,
|
|
16
|
+
derivationVerified = verifyDerivation(derivationNode, localContext);
|
|
17
17
|
|
|
18
18
|
if (derivationVerified) {
|
|
19
|
-
const lastProofStep =
|
|
20
|
-
proofStep = lastProofStep, ///
|
|
21
|
-
statementNode = proofStep.getStatementNode(),
|
|
22
|
-
conclusionStatementNode = conclusion.getStatementNode(),
|
|
23
|
-
statementNodeMatchConclusionStatementNode = statementNode.match(conclusionStatementNode);
|
|
19
|
+
const lastProofStep = localContext.getLastProofStep();
|
|
24
20
|
|
|
25
|
-
|
|
21
|
+
if (lastProofStep !== null) {
|
|
22
|
+
const proofStep = lastProofStep, ///
|
|
23
|
+
statementNode = proofStep.getStatementNode(),
|
|
24
|
+
conclusionStatementNode = conclusion.getStatementNode(),
|
|
25
|
+
statementNodeMatchConclusionStatementNode = statementNode.match(conclusionStatementNode);
|
|
26
|
+
|
|
27
|
+
proofVerified = statementNodeMatchConclusionStatementNode; ///
|
|
28
|
+
}
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
return proofVerified;
|
package/src/verify/rule.js
CHANGED
|
@@ -4,7 +4,7 @@ import Rule from "../rule";
|
|
|
4
4
|
import verifyLabels from "../verify/labels";
|
|
5
5
|
import verifyPremise from "../verify/premise";
|
|
6
6
|
import verifyRuleProof from "../verify/ruleProof";
|
|
7
|
-
import
|
|
7
|
+
import LocalMetaContext from "../context/localMeta";
|
|
8
8
|
import verifyConclusion from "../verify/conclusion";
|
|
9
9
|
|
|
10
10
|
import { first } from "../utilities/array";
|
|
@@ -20,7 +20,7 @@ export default function verifyRule(ruleNode, fileContext) {
|
|
|
20
20
|
|
|
21
21
|
const labelNodes = labelNodesQuery(ruleNode),
|
|
22
22
|
labelsString = fileContext.nodesAsString(labelNodes),
|
|
23
|
-
|
|
23
|
+
localMetaContext = LocalMetaContext.fromFileContext(fileContext);
|
|
24
24
|
|
|
25
25
|
fileContext.trace(`Verifying the '${labelsString}' rule...`, ruleNode);
|
|
26
26
|
|
|
@@ -31,7 +31,7 @@ export default function verifyRule(ruleNode, fileContext) {
|
|
|
31
31
|
const premises = [],
|
|
32
32
|
premiseNodes = premisesNodeQuery(ruleNode),
|
|
33
33
|
premisesVerified = premiseNodes.every((premiseNode) => {
|
|
34
|
-
const premiseVerified = verifyPremise(premiseNode, premises,
|
|
34
|
+
const premiseVerified = verifyPremise(premiseNode, premises, localMetaContext);
|
|
35
35
|
|
|
36
36
|
if (premiseVerified) {
|
|
37
37
|
return true;
|
|
@@ -41,7 +41,7 @@ export default function verifyRule(ruleNode, fileContext) {
|
|
|
41
41
|
if (premisesVerified) {
|
|
42
42
|
const conclusions = [],
|
|
43
43
|
conclusionNode = conclusionNodeQuery(ruleNode),
|
|
44
|
-
conclusionVerified = verifyConclusion(conclusionNode, conclusions,
|
|
44
|
+
conclusionVerified = verifyConclusion(conclusionNode, conclusions, localMetaContext);
|
|
45
45
|
|
|
46
46
|
if (conclusionVerified) {
|
|
47
47
|
const ruleProofNode = ruleProofNodeQuery(ruleNode),
|
|
@@ -51,7 +51,7 @@ export default function verifyRule(ruleNode, fileContext) {
|
|
|
51
51
|
let ruleProofVerified = true; ///
|
|
52
52
|
|
|
53
53
|
if (ruleProofNode !== null) {
|
|
54
|
-
ruleProofVerified = verifyRuleProof(ruleProofNode, conclusion,
|
|
54
|
+
ruleProofVerified = verifyRuleProof(ruleProofNode, conclusion, localMetaContext);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
if (ruleProofVerified) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import MetaproofStep from "../step/metaproof";
|
|
4
4
|
import verifyPremise from "../verify/premise";
|
|
5
|
-
import
|
|
5
|
+
import LocalMetaContext from "../context/localMeta";
|
|
6
6
|
import verifyQualifiedMetastatement from "../verify/metastatement/qualified";
|
|
7
7
|
import verifyUnqualifiedMetastatement from "../verify/metastatement/unqualified";
|
|
8
8
|
|
|
@@ -14,13 +14,13 @@ const childNodesQuery = nodesQuery("/ruleDerivation|ruleSubDerivation/*"),
|
|
|
14
14
|
metastatementNodeQuery = nodeQuery("/qualifiedMetastatement|unqualifiedMetastatement/metastatement!"),
|
|
15
15
|
ruleSubDerivationNodeQuery = nodeQuery("/ruleSubproof/ruleSubDerivation");
|
|
16
16
|
|
|
17
|
-
export default function verifyRuleDerivation(ruleDerivationNode,
|
|
17
|
+
export default function verifyRuleDerivation(ruleDerivationNode, localMetaContext) {
|
|
18
18
|
let ruleDerivationVerified;
|
|
19
19
|
|
|
20
20
|
const childNodes = childNodesQuery(ruleDerivationNode);
|
|
21
21
|
|
|
22
22
|
ruleDerivationVerified = childNodes.every((childNode) => {
|
|
23
|
-
const childVerified = verifyChild(childNode,
|
|
23
|
+
const childVerified = verifyChild(childNode, localMetaContext);
|
|
24
24
|
|
|
25
25
|
if (childVerified) {
|
|
26
26
|
return true;
|
|
@@ -30,13 +30,13 @@ export default function verifyRuleDerivation(ruleDerivationNode, metaproofContex
|
|
|
30
30
|
return ruleDerivationVerified;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function verifyRuleSubDerivation(ruleSubDerivationNode,
|
|
33
|
+
function verifyRuleSubDerivation(ruleSubDerivationNode, localMetaContext) {
|
|
34
34
|
let ruleSubDerivationVerified;
|
|
35
35
|
|
|
36
36
|
const childNodes = childNodesQuery(ruleSubDerivationNode);
|
|
37
37
|
|
|
38
38
|
ruleSubDerivationVerified = childNodes.every((childNode) => {
|
|
39
|
-
const childVerified = verifyChild(childNode,
|
|
39
|
+
const childVerified = verifyChild(childNode, localMetaContext);
|
|
40
40
|
|
|
41
41
|
if (childVerified) {
|
|
42
42
|
return true;
|
|
@@ -46,15 +46,15 @@ function verifyRuleSubDerivation(ruleSubDerivationNode, metaproofContext) {
|
|
|
46
46
|
return ruleSubDerivationVerified;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
function verifyRuleSubproof(ruleSubproofNode,
|
|
49
|
+
function verifyRuleSubproof(ruleSubproofNode, localMetaContext) {
|
|
50
50
|
let ruleSubproofVerified = false;
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
localMetaContext = LocalMetaContext.fromLocalMetaContext(localMetaContext); ///
|
|
53
53
|
|
|
54
54
|
const premises = [],
|
|
55
55
|
premiseNodes = premiseNodesQuery(ruleSubproofNode),
|
|
56
56
|
premisesVerified = premiseNodes.every((premiseNode) => {
|
|
57
|
-
const premiseVerified = verifyPremise(premiseNode, premises,
|
|
57
|
+
const premiseVerified = verifyPremise(premiseNode, premises, localMetaContext);
|
|
58
58
|
|
|
59
59
|
if (premiseVerified) {
|
|
60
60
|
return true;
|
|
@@ -63,7 +63,7 @@ function verifyRuleSubproof(ruleSubproofNode, metaproofContext) {
|
|
|
63
63
|
|
|
64
64
|
if (premisesVerified) {
|
|
65
65
|
const ruleSubDerivationNode = ruleSubDerivationNodeQuery(ruleSubproofNode),
|
|
66
|
-
ruleSubDerivationVerified = verifyRuleSubDerivation(ruleSubDerivationNode,
|
|
66
|
+
ruleSubDerivationVerified = verifyRuleSubDerivation(ruleSubDerivationNode, localMetaContext);
|
|
67
67
|
|
|
68
68
|
if (ruleSubDerivationVerified) {
|
|
69
69
|
ruleSubproofVerified = true;
|
|
@@ -73,7 +73,7 @@ function verifyRuleSubproof(ruleSubproofNode, metaproofContext) {
|
|
|
73
73
|
return ruleSubproofVerified;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
function verifyChild(childNode,
|
|
76
|
+
function verifyChild(childNode, localMetaContext) {
|
|
77
77
|
let childVerified;
|
|
78
78
|
|
|
79
79
|
const childNodeRuleName = childNode.getRuleName();
|
|
@@ -81,12 +81,12 @@ function verifyChild(childNode, metaproofContext) {
|
|
|
81
81
|
switch (childNodeRuleName) {
|
|
82
82
|
case RULE_SUBPROOF_RULE_NAME: {
|
|
83
83
|
const ruleSubproofNode = childNode, ///
|
|
84
|
-
ruleSubproofVerified = verifyRuleSubproof(ruleSubproofNode,
|
|
84
|
+
ruleSubproofVerified = verifyRuleSubproof(ruleSubproofNode, localMetaContext);
|
|
85
85
|
|
|
86
86
|
if (ruleSubproofVerified) {
|
|
87
87
|
const metaproofStep = MetaproofStep.fromRuleSubproofNode(ruleSubproofNode);
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
localMetaContext.addMetaproofStep(metaproofStep);
|
|
90
90
|
|
|
91
91
|
childVerified = true;
|
|
92
92
|
}
|
|
@@ -98,13 +98,13 @@ function verifyChild(childNode, metaproofContext) {
|
|
|
98
98
|
const derived = true,
|
|
99
99
|
assignments = [],
|
|
100
100
|
qualifiedMetastatementNode = childNode, ///
|
|
101
|
-
qualifiedMetastatementVerified = verifyQualifiedMetastatement(qualifiedMetastatementNode, assignments, derived,
|
|
101
|
+
qualifiedMetastatementVerified = verifyQualifiedMetastatement(qualifiedMetastatementNode, assignments, derived, localMetaContext);
|
|
102
102
|
|
|
103
103
|
if (qualifiedMetastatementVerified) {
|
|
104
104
|
const metastatementNode = metastatementNodeQuery(qualifiedMetastatementNode),
|
|
105
105
|
metaproofStep = MetaproofStep.fromMetastatementNode(metastatementNode);
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
localMetaContext.addMetaproofStep(metaproofStep);
|
|
108
108
|
|
|
109
109
|
childVerified = qualifiedMetastatementVerified; ///
|
|
110
110
|
}
|
|
@@ -115,13 +115,13 @@ function verifyChild(childNode, metaproofContext) {
|
|
|
115
115
|
case UNQUALIFIED_METASTATEMENT_RULE_NAME: {
|
|
116
116
|
const derived = true,
|
|
117
117
|
unqualifiedMetastatementNode = childNode, ///
|
|
118
|
-
unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, derived,
|
|
118
|
+
unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, derived, localMetaContext);
|
|
119
119
|
|
|
120
120
|
if (unqualifiedMetastatementVerified) {
|
|
121
121
|
const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode),
|
|
122
122
|
metaproofStep = MetaproofStep.fromMetastatementNode(metastatementNode);
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
localMetaContext.addMetaproofStep(metaproofStep);
|
|
125
125
|
|
|
126
126
|
childVerified = true;
|
|
127
127
|
}
|
package/src/verify/ruleProof.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import LocalMetaContext from "../context/localMeta";
|
|
4
4
|
import verifyRuleDerivation from "../verify/ruleDerivation";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
7
|
|
|
8
8
|
const ruleDerivationNodeQuery = nodeQuery("/ruleProof/ruleDerivation!");
|
|
9
9
|
|
|
10
|
-
export default function verifyRuleProof(ruleProofNode, conclusion,
|
|
10
|
+
export default function verifyRuleProof(ruleProofNode, conclusion, localMetaContext) {
|
|
11
11
|
let ruleProofVerified = false;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
localMetaContext = LocalMetaContext.fromLocalMetaContext(localMetaContext); ///
|
|
14
14
|
|
|
15
15
|
const ruleDerivationNode = ruleDerivationNodeQuery(ruleProofNode),
|
|
16
|
-
ruleDerivationVerified = verifyRuleDerivation(ruleDerivationNode,
|
|
16
|
+
ruleDerivationVerified = verifyRuleDerivation(ruleDerivationNode, localMetaContext);
|
|
17
17
|
|
|
18
18
|
if (ruleDerivationVerified) {
|
|
19
|
-
const lastMetaproofStep =
|
|
19
|
+
const lastMetaproofStep = localMetaContext.getLastMetaproofStep(),
|
|
20
20
|
metaproofStep = lastMetaproofStep, ///
|
|
21
21
|
metastatementNode = metaproofStep.getMetastatementNode(),
|
|
22
22
|
conclusionMetastatementNode = conclusion.getMetastatementNode(),
|
|
@@ -5,72 +5,72 @@ import { nodeQuery, referenceNameFromReferenceNode } from "../../utilities/query
|
|
|
5
5
|
const referenceNodeQuery = nodeQuery("/qualifiedStatement/qualification!/reference!"),
|
|
6
6
|
statementNodeQuery = nodeQuery("/qualifiedStatement/statement!");
|
|
7
7
|
|
|
8
|
-
export default function verifyQualifiedStatement(qualifiedStatementNode, assignments, derived,
|
|
8
|
+
export default function verifyQualifiedStatement(qualifiedStatementNode, assignments, derived, localContext) {
|
|
9
9
|
let qualifiedStatementVerified = false;
|
|
10
10
|
|
|
11
11
|
const statementNode = statementNodeQuery(qualifiedStatementNode);
|
|
12
12
|
|
|
13
13
|
if (statementNode !== null) {
|
|
14
|
-
const statementString =
|
|
15
|
-
|
|
14
|
+
const statementString = localContext.nodeAsString(statementNode),
|
|
15
|
+
statementLocalContext = localContext; ///
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
localContext.trace(`Verifying the '${statementString}' qualified statement...`, qualifiedStatementNode);
|
|
18
18
|
|
|
19
19
|
const referenceNode = referenceNodeQuery(qualifiedStatementNode),
|
|
20
20
|
referenceName = referenceNameFromReferenceNode(referenceNode);
|
|
21
21
|
|
|
22
22
|
if (!qualifiedStatementVerified) {
|
|
23
|
-
const rule =
|
|
23
|
+
const rule = localContext.findRuleByReferenceName(referenceName);
|
|
24
24
|
|
|
25
25
|
if (rule !== null) {
|
|
26
|
-
const ruleMatchesStatement = rule.matchStatement(statementNode,
|
|
26
|
+
const ruleMatchesStatement = rule.matchStatement(statementNode, statementLocalContext);
|
|
27
27
|
|
|
28
28
|
qualifiedStatementVerified = ruleMatchesStatement; ///
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
if (!qualifiedStatementVerified) {
|
|
33
|
-
const axiom =
|
|
33
|
+
const axiom = localContext.findAxiomByReferenceName(referenceName);
|
|
34
34
|
|
|
35
35
|
if (axiom !== null) {
|
|
36
|
-
const axiomMatchesStatement = axiom.matchStatement(statementNode,
|
|
36
|
+
const axiomMatchesStatement = axiom.matchStatement(statementNode, statementLocalContext);
|
|
37
37
|
|
|
38
38
|
qualifiedStatementVerified = axiomMatchesStatement; ///
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
if (!qualifiedStatementVerified) {
|
|
43
|
-
const lemma =
|
|
43
|
+
const lemma = localContext.findLemmaByReferenceName(referenceName);
|
|
44
44
|
|
|
45
45
|
if (lemma !== null) {
|
|
46
|
-
const lemmaMatchesStatement = lemma.matchStatement(statementNode,
|
|
46
|
+
const lemmaMatchesStatement = lemma.matchStatement(statementNode, statementLocalContext);
|
|
47
47
|
|
|
48
48
|
qualifiedStatementVerified = lemmaMatchesStatement; ///
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
if (!qualifiedStatementVerified) {
|
|
53
|
-
const theorem =
|
|
53
|
+
const theorem = localContext.findTheoremByReferenceName(referenceName);
|
|
54
54
|
|
|
55
55
|
if (theorem !== null) {
|
|
56
|
-
const theoremMatchesStatement = theorem.matchStatement(statementNode,
|
|
56
|
+
const theoremMatchesStatement = theorem.matchStatement(statementNode, statementLocalContext);
|
|
57
57
|
|
|
58
58
|
qualifiedStatementVerified = theoremMatchesStatement; ///
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
if (!qualifiedStatementVerified) {
|
|
63
|
-
const conjecture =
|
|
63
|
+
const conjecture = localContext.findConjectureByReferenceName(referenceName);
|
|
64
64
|
|
|
65
65
|
if (conjecture !== null) {
|
|
66
|
-
const conjectureMatchesStatement = conjecture.matchStatement(statementNode,
|
|
66
|
+
const conjectureMatchesStatement = conjecture.matchStatement(statementNode, statementLocalContext);
|
|
67
67
|
|
|
68
68
|
qualifiedStatementVerified = conjectureMatchesStatement; ///
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
if (qualifiedStatementVerified) {
|
|
73
|
-
|
|
73
|
+
localContext.debug(`...verified the '${statementString}' qualified statement.`, qualifiedStatementNode);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -6,24 +6,24 @@ import { nodeQuery } from "../../utilities/query";
|
|
|
6
6
|
|
|
7
7
|
const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!");
|
|
8
8
|
|
|
9
|
-
export default function verifyUnqualifiedStatement(unqualifiedStatementNode, assignments, derived,
|
|
9
|
+
export default function verifyUnqualifiedStatement(unqualifiedStatementNode, assignments, derived, localContext) {
|
|
10
10
|
let unqualifiedStatementVerified = false;
|
|
11
11
|
|
|
12
12
|
const statementNode = statementNodeQuery(unqualifiedStatementNode);
|
|
13
13
|
|
|
14
14
|
if (statementNode !== null) {
|
|
15
|
-
const statementString =
|
|
15
|
+
const statementString = localContext.nodeAsString(statementNode);
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
localContext.trace(`Verifying the '${statementString}' unqualified statement...`, unqualifiedStatementNode);
|
|
18
18
|
|
|
19
19
|
if (derived) {
|
|
20
|
-
const statementMatches =
|
|
20
|
+
const statementMatches = localContext.matchStatement(statementNode);
|
|
21
21
|
|
|
22
22
|
unqualifiedStatementVerified = statementMatches; ///
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
if (!unqualifiedStatementVerified) {
|
|
26
|
-
const context =
|
|
26
|
+
const context = localContext, ///
|
|
27
27
|
statementVerified = verifyStatement(statementNode, assignments, derived, context, () => {
|
|
28
28
|
const verifiedAhead = true;
|
|
29
29
|
|
|
@@ -34,7 +34,7 @@ export default function verifyUnqualifiedStatement(unqualifiedStatementNode, ass
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
if (unqualifiedStatementVerified) {
|
|
37
|
-
|
|
37
|
+
localContext.debug(`...verified the '${statementString}' unqualified statement.`, unqualifiedStatementNode);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -9,17 +9,17 @@ import { nodeQuery } from "../utilities/query";
|
|
|
9
9
|
const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
|
|
10
10
|
unqualifiedStatementNodeQuery = nodeQuery("/supposition/unqualifiedStatement!");
|
|
11
11
|
|
|
12
|
-
export default function verifySupposition(suppositionNode, suppositions,
|
|
12
|
+
export default function verifySupposition(suppositionNode, suppositions, localContext) {
|
|
13
13
|
let suppositionVerified;
|
|
14
14
|
|
|
15
|
-
const suppositionString =
|
|
15
|
+
const suppositionString = localContext.nodeAsString(suppositionNode);
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
localContext.trace(`Verifying the '${suppositionString}' supposition...`, suppositionNode);
|
|
18
18
|
|
|
19
19
|
const derived = false,
|
|
20
20
|
assignments = [],
|
|
21
21
|
unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
|
|
22
|
-
unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, assignments, derived,
|
|
22
|
+
unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, assignments, derived, localContext);
|
|
23
23
|
|
|
24
24
|
if (unqualifiedStatementVerified) {
|
|
25
25
|
const statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
@@ -28,17 +28,17 @@ export default function verifySupposition(suppositionNode, suppositions, proofCo
|
|
|
28
28
|
|
|
29
29
|
suppositions.push(supposition);
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
localContext.addProofStep(proofStep);
|
|
32
32
|
|
|
33
33
|
assignments.forEach((assignment) => {
|
|
34
|
-
assignment.assign(
|
|
34
|
+
assignment.assign(localContext);
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
suppositionVerified = true;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
if (suppositionVerified) {
|
|
41
|
-
|
|
41
|
+
localContext.debug(`...verified the '${suppositionString}' supposition.`, suppositionNode);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
return suppositionVerified;
|
package/src/verify/term.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Term from "../term";
|
|
3
4
|
import termNodesVerifier from "../verifier/nodes/term";
|
|
4
5
|
|
|
5
6
|
import { first } from "../utilities/array";
|
|
@@ -7,7 +8,7 @@ import { nodeQuery, variableNameFromVariableNode } from "../utilities/query";
|
|
|
7
8
|
|
|
8
9
|
const variableNodeQuery = nodeQuery("/term/variable!");
|
|
9
10
|
|
|
10
|
-
function verifyTerm(termNode,
|
|
11
|
+
function verifyTerm(termNode, terms, context, verifyAhead) {
|
|
11
12
|
let termVerified;
|
|
12
13
|
|
|
13
14
|
const termString = context.nodeAsString(termNode);
|
|
@@ -20,7 +21,7 @@ function verifyTerm(termNode, types, context, verifyAhead) {
|
|
|
20
21
|
];
|
|
21
22
|
|
|
22
23
|
termVerified = verifyTermFunctions.some((verifyTermFunction) => {
|
|
23
|
-
const termVerified = verifyTermFunction(termNode,
|
|
24
|
+
const termVerified = verifyTermFunction(termNode, terms, context, verifyAhead);
|
|
24
25
|
|
|
25
26
|
if (termVerified) {
|
|
26
27
|
return true;
|
|
@@ -40,13 +41,13 @@ Object.assign(termNodesVerifier, {
|
|
|
40
41
|
|
|
41
42
|
export default verifyTerm;
|
|
42
43
|
|
|
43
|
-
export function verifyTermAgainstConstructors(termNode,
|
|
44
|
+
export function verifyTermAgainstConstructors(termNode, terms, context, verifyAhead) {
|
|
44
45
|
let termVerifiedAgainstConstructors;
|
|
45
46
|
|
|
46
47
|
const constructors = context.getConstructors();
|
|
47
48
|
|
|
48
49
|
termVerifiedAgainstConstructors = constructors.some((constructor) => {
|
|
49
|
-
const termVerifiedAgainstConstructor = verifyTermAgainstConstructor(termNode,
|
|
50
|
+
const termVerifiedAgainstConstructor = verifyTermAgainstConstructor(termNode, terms, constructor, context, verifyAhead);
|
|
50
51
|
|
|
51
52
|
if (termVerifiedAgainstConstructor) {
|
|
52
53
|
return true;
|
|
@@ -93,73 +94,75 @@ export function verifyTermAsVariable(termNode, variables, context, verifyAhead)
|
|
|
93
94
|
return termVerifiedAsVariable;
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
function
|
|
97
|
-
let
|
|
97
|
+
function verifyTermAsStandaloneVariable(termNode, terms, context, verifyAhead) {
|
|
98
|
+
let termVerifiedAsStandaloneVariable;
|
|
98
99
|
|
|
99
|
-
const termString = context.nodeAsString(termNode)
|
|
100
|
-
constructorString = constructor.getString();
|
|
100
|
+
const termString = context.nodeAsString(termNode);
|
|
101
101
|
|
|
102
|
-
context.trace(`Verifying the '${termString}' term
|
|
102
|
+
context.trace(`Verifying the '${termString}' term as a standalone variable...`, termNode);
|
|
103
103
|
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
nonTerminalNodeB = constructorTermNode, ///
|
|
107
|
-
nodeVerified = termNodesVerifier.verifyNonTerminalNode(nonTerminalNNdeA, nonTerminalNodeB, context, () => {
|
|
104
|
+
const variables = [],
|
|
105
|
+
termVerifiedAsVariable = verifyTermAsVariable(termNode, variables, context, () => {
|
|
108
106
|
let verifiedAhead;
|
|
109
107
|
|
|
110
|
-
const
|
|
108
|
+
const firstVariable = first(variables),
|
|
109
|
+
variable = firstVariable, ///
|
|
110
|
+
type = variable.getType(),
|
|
111
|
+
term = Term.fromTermNodeAndType(termNode, type);
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
terms.push(term);
|
|
113
114
|
|
|
114
115
|
verifiedAhead = verifyAhead();
|
|
115
116
|
|
|
116
117
|
if (!verifiedAhead) {
|
|
117
|
-
|
|
118
|
+
terms.pop();
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
return verifiedAhead;
|
|
121
122
|
});
|
|
122
123
|
|
|
123
|
-
|
|
124
|
+
termVerifiedAsStandaloneVariable = termVerifiedAsVariable; ///
|
|
124
125
|
|
|
125
|
-
if (
|
|
126
|
-
context.debug(`...verified the '${termString}' term
|
|
126
|
+
if (termVerifiedAsStandaloneVariable) {
|
|
127
|
+
context.debug(`...verified the '${termString}' term as a standalone variable.`, termNode);
|
|
127
128
|
}
|
|
128
129
|
|
|
129
|
-
return
|
|
130
|
+
return termVerifiedAsStandaloneVariable;
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
function
|
|
133
|
-
let
|
|
133
|
+
function verifyTermAgainstConstructor(termNode, terms, constructor, context, verifyAhead) {
|
|
134
|
+
let termVerifiedAgainstConstructor;
|
|
134
135
|
|
|
135
|
-
const termString = context.nodeAsString(termNode)
|
|
136
|
+
const termString = context.nodeAsString(termNode),
|
|
137
|
+
constructorString = constructor.getString();
|
|
136
138
|
|
|
137
|
-
context.trace(`Verifying the '${termString}' term
|
|
139
|
+
context.trace(`Verifying the '${termString}' term against the '${constructorString}' constructor...`, termNode);
|
|
138
140
|
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
+
const constructorTermNode = constructor.getTermNode(),
|
|
142
|
+
nonTerminalNNdeA = termNode, ///
|
|
143
|
+
nonTerminalNodeB = constructorTermNode, ///
|
|
144
|
+
nodeVerified = termNodesVerifier.verifyNonTerminalNode(nonTerminalNNdeA, nonTerminalNodeB, context, () => {
|
|
141
145
|
let verifiedAhead;
|
|
142
146
|
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
type = variable.getType();
|
|
147
|
+
const type = constructor.getType(),
|
|
148
|
+
term = Term.fromTermNodeAndType(termNode, type);
|
|
146
149
|
|
|
147
|
-
|
|
150
|
+
terms.push(term);
|
|
148
151
|
|
|
149
152
|
verifiedAhead = verifyAhead();
|
|
150
153
|
|
|
151
154
|
if (!verifiedAhead) {
|
|
152
|
-
|
|
155
|
+
terms.pop();
|
|
153
156
|
}
|
|
154
157
|
|
|
155
158
|
return verifiedAhead;
|
|
156
159
|
});
|
|
157
160
|
|
|
158
|
-
|
|
161
|
+
termVerifiedAgainstConstructor = nodeVerified; ///
|
|
159
162
|
|
|
160
|
-
if (
|
|
161
|
-
context.debug(`...verified the '${termString}' term
|
|
163
|
+
if (termVerifiedAgainstConstructor) {
|
|
164
|
+
context.debug(`...verified the '${termString}' term against the '${constructorString}' constructor.`, termNode);
|
|
162
165
|
}
|
|
163
166
|
|
|
164
|
-
return
|
|
167
|
+
return termVerifiedAgainstConstructor;
|
|
165
168
|
}
|
package/src/verify/terms.js
CHANGED
|
@@ -4,51 +4,37 @@ import verifyTerm from "../verify/term";
|
|
|
4
4
|
|
|
5
5
|
import { first, second } from "../utilities/array";
|
|
6
6
|
|
|
7
|
-
export default function verifyTerms(
|
|
7
|
+
export default function verifyTerms(termNodes, terms, context, verifyAhead) {
|
|
8
8
|
let termsVerified;
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const firstTermNode = first(termNodes),
|
|
11
|
+
secondTermNode = second(termNodes),
|
|
12
|
+
firstTermString = context.nodeAsString(firstTermNode),
|
|
13
|
+
secondTermString = context.nodeAsString(secondTermNode);
|
|
12
14
|
|
|
13
|
-
context.trace(`Verifying the '${
|
|
15
|
+
context.trace(`Verifying the '${firstTermString}' and '${secondTermString}' terms...`, firstTermNode);
|
|
14
16
|
|
|
15
|
-
const
|
|
16
|
-
leftTermVerified = verifyTerm(leftTermNode, types, context, () => {
|
|
17
|
+
const firstTermVerified = verifyTerm(firstTermNode, terms, context, () => {
|
|
17
18
|
let verifiedAhead;
|
|
18
19
|
|
|
19
|
-
const
|
|
20
|
-
let verifiedAhead
|
|
20
|
+
const secondTermVerified = verifyTerm(secondTermNode, terms, context, () => {
|
|
21
|
+
let verifiedAhead;
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
secondType = second(types),
|
|
24
|
-
leftType = firstType, ///
|
|
25
|
-
rightType = secondType, ///
|
|
26
|
-
leftTypeEqualToOrSubTypeOfOfSuperTypeOfRightType = leftType.isEqualToOrSubTypeOfOfSuperTypeOf(rightType);
|
|
27
|
-
|
|
28
|
-
if (!leftTypeEqualToOrSubTypeOfOfSuperTypeOfRightType) {
|
|
29
|
-
const leftTypeName = leftType.getName(),
|
|
30
|
-
rightTypeName = rightType.getName(),
|
|
31
|
-
leftTermString = context.nodeAsString(leftTermNode),
|
|
32
|
-
rightTermString = context.nodeAsString(rightTermNode);
|
|
33
|
-
|
|
34
|
-
context.debug(`The left '${leftTermString}' term's '${leftTypeName}' type is not equal to, a sub-type of nor a super-type of the right '${rightTermString}' term's '${rightTypeName}' type.`, statementNode);
|
|
35
|
-
} else {
|
|
36
|
-
verifiedAhead = verifyAhead();
|
|
37
|
-
}
|
|
23
|
+
verifiedAhead = verifyAhead();
|
|
38
24
|
|
|
39
25
|
return verifiedAhead;
|
|
40
26
|
});
|
|
41
27
|
|
|
42
|
-
verifiedAhead =
|
|
28
|
+
verifiedAhead = secondTermVerified; ///
|
|
43
29
|
|
|
44
30
|
return verifiedAhead;
|
|
45
31
|
});
|
|
46
32
|
|
|
33
|
+
termsVerified = firstTermVerified; ///
|
|
34
|
+
|
|
47
35
|
if (termsVerified) {
|
|
48
|
-
context.debug(`...verified the '${
|
|
36
|
+
context.debug(`...verified the '${firstTermString}' and '${secondTermString}' terms.`, firstTermNode);
|
|
49
37
|
}
|
|
50
38
|
|
|
51
|
-
termsVerified = leftTermVerified; ///
|
|
52
|
-
|
|
53
39
|
return termsVerified
|
|
54
40
|
}
|