occam-verify-cli 0.0.524 → 0.0.526
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/axiomLemmaTheorem.js +5 -5
- package/lib/combinator.js +5 -5
- package/lib/conclusion.js +3 -3
- package/lib/consequence.js +3 -3
- package/lib/constructor.js +6 -6
- package/lib/context/file.js +24 -8
- package/lib/context/metaproof.js +13 -1
- package/lib/context/proof.js +13 -1
- package/lib/equality.js +130 -7
- package/lib/label.js +5 -5
- package/lib/premise.js +3 -3
- package/lib/rule.js +5 -5
- package/lib/supposition.js +3 -3
- package/lib/type.js +5 -5
- package/lib/utilities/string.js +15 -10
- package/lib/variable.js +2 -2
- package/lib/verify/assertion/type.js +3 -3
- package/lib/verify/axiom.js +2 -2
- package/lib/verify/conclusion.js +2 -3
- package/lib/verify/consequence.js +3 -4
- package/lib/verify/derivation.js +3 -3
- package/lib/verify/label.js +2 -3
- package/lib/verify/lemma.js +2 -2
- package/lib/verify/metastatement/qualified.js +8 -9
- package/lib/verify/metastatement/unqualified.js +4 -4
- package/lib/verify/metastatement.js +2 -2
- package/lib/verify/premise.js +3 -4
- package/lib/verify/rule.js +2 -2
- package/lib/verify/ruleDerivation.js +3 -3
- package/lib/verify/statement/qualified.js +5 -5
- package/lib/verify/statement/unqualified.js +4 -4
- package/lib/verify/statement.js +56 -39
- package/lib/verify/statementAsCombinator.js +28 -18
- package/lib/verify/supposition.js +3 -4
- package/lib/verify/term.js +3 -4
- package/lib/verify/termAsConstructor.js +19 -20
- package/lib/verify/theorem.js +2 -2
- package/lib/verify/type.js +2 -3
- package/lib/verify/variable.js +2 -3
- package/package.json +1 -1
- package/src/axiomLemmaTheorem.js +4 -4
- package/src/combinator.js +4 -4
- package/src/conclusion.js +2 -2
- package/src/consequence.js +2 -2
- package/src/constructor.js +6 -6
- package/src/context/file.js +20 -7
- package/src/context/metaproof.js +4 -0
- package/src/context/proof.js +4 -0
- package/src/equality.js +202 -5
- package/src/label.js +4 -4
- package/src/premise.js +2 -2
- package/src/rule.js +4 -4
- package/src/supposition.js +2 -2
- package/src/type.js +4 -4
- package/src/utilities/string.js +23 -15
- package/src/variable.js +1 -1
- package/src/verify/assertion/type.js +2 -2
- package/src/verify/axiom.js +1 -1
- package/src/verify/conclusion.js +1 -2
- package/src/verify/consequence.js +2 -3
- package/src/verify/derivation.js +4 -2
- package/src/verify/label.js +1 -2
- package/src/verify/lemma.js +1 -1
- package/src/verify/metastatement/qualified.js +7 -10
- package/src/verify/metastatement/unqualified.js +3 -3
- package/src/verify/metastatement.js +1 -1
- package/src/verify/premise.js +2 -3
- package/src/verify/rule.js +1 -1
- package/src/verify/ruleDerivation.js +4 -2
- package/src/verify/statement/qualified.js +5 -5
- package/src/verify/statement/unqualified.js +4 -3
- package/src/verify/statement.js +67 -39
- package/src/verify/statementAsCombinator.js +48 -26
- package/src/verify/supposition.js +2 -3
- package/src/verify/term.js +2 -3
- package/src/verify/termAsConstructor.js +24 -26
- package/src/verify/theorem.js +1 -1
- package/src/verify/type.js +1 -2
- package/src/verify/variable.js +1 -2
|
@@ -8,7 +8,7 @@ import { nodeQuery, referenceNameFromReferenceNode } from "../../utilities/query
|
|
|
8
8
|
const referenceNodeQuery = nodeQuery("/qualifiedMetastatement/qualification!/reference!"),
|
|
9
9
|
metastatementNodeQuery = nodeQuery("/qualifiedMetastatement/metastatement!");
|
|
10
10
|
|
|
11
|
-
export default function verifyQualifiedMetastatement(qualifiedMetastatementNode, metaproofContext) {
|
|
11
|
+
export default function verifyQualifiedMetastatement(qualifiedMetastatementNode, assertions, derived, metaproofContext) {
|
|
12
12
|
let qualifiedMetastatementVerified = false;
|
|
13
13
|
|
|
14
14
|
metaproofContext.begin(qualifiedMetastatementNode);
|
|
@@ -16,11 +16,11 @@ export default function verifyQualifiedMetastatement(qualifiedMetastatementNode,
|
|
|
16
16
|
const metastatementNode = metastatementNodeQuery(qualifiedMetastatementNode);
|
|
17
17
|
|
|
18
18
|
if (metastatementNode !== null) {
|
|
19
|
-
const metastatementString = nodeAsString(metastatementNode);
|
|
19
|
+
const metastatementString = metaproofContext.nodeAsString(metastatementNode);
|
|
20
20
|
|
|
21
|
-
metaproofContext.debug(`Verifying the ${metastatementString} qualified metastatement...`);
|
|
21
|
+
metaproofContext.debug(`Verifying the '${metastatementString}' qualified metastatement...`);
|
|
22
22
|
|
|
23
|
-
let
|
|
23
|
+
let ruleMatchesMetastatement = true;
|
|
24
24
|
|
|
25
25
|
const referenceNode = referenceNodeQuery(qualifiedMetastatementNode);
|
|
26
26
|
|
|
@@ -29,15 +29,12 @@ export default function verifyQualifiedMetastatement(qualifiedMetastatementNode,
|
|
|
29
29
|
rule = metaproofContext.findRuleByReferenceName(referenceName);
|
|
30
30
|
|
|
31
31
|
if (rule !== null) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
qualifiedMetastatementVerified = ruleMatchesStatement; ///
|
|
32
|
+
ruleMatchesMetastatement = rule.matchMetastatement(metastatementNode, metaproofContext);
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
40
|
-
metastatementVerified = verifyMetastatement(metastatementNode, assertions, metaproofContext);
|
|
36
|
+
if (ruleMatchesMetastatement) {
|
|
37
|
+
const metastatementVerified = verifyMetastatement(metastatementNode, assertions, derived, metaproofContext);
|
|
41
38
|
|
|
42
39
|
qualifiedMetastatementVerified = metastatementVerified; ///
|
|
43
40
|
}
|
|
@@ -15,9 +15,9 @@ export default function verifyUnqualifiedMetastatement(unqualifiedMetastatementN
|
|
|
15
15
|
const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode);
|
|
16
16
|
|
|
17
17
|
if (metastatementNode !== null) {
|
|
18
|
-
const metastatementString = nodeAsString(metastatementNode);
|
|
18
|
+
const metastatementString = metaproofContext.nodeAsString(metastatementNode);
|
|
19
19
|
|
|
20
|
-
metaproofContext.debug(`Verifying the ${metastatementString} unqualified metastatement...`);
|
|
20
|
+
metaproofContext.debug(`Verifying the '${metastatementString}' unqualified metastatement...`);
|
|
21
21
|
|
|
22
22
|
let metastatementMatches = true;
|
|
23
23
|
|
|
@@ -26,7 +26,7 @@ export default function verifyUnqualifiedMetastatement(unqualifiedMetastatementN
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
if (metastatementMatches) {
|
|
29
|
-
const metastatementVerified = verifyMetastatement(metastatementNode, assertions, metaproofContext);
|
|
29
|
+
const metastatementVerified = verifyMetastatement(metastatementNode, assertions, derived, metaproofContext);
|
|
30
30
|
|
|
31
31
|
unqualifiedMetastatementVerified = metastatementVerified; ///
|
|
32
32
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
export default function verifyMetastatement(metastatementNode, assertions, metaproofContext) {
|
|
3
|
+
export default function verifyMetastatement(metastatementNode, assertions, derived, metaproofContext) {
|
|
4
4
|
let metastatementVerified = true; ///
|
|
5
5
|
|
|
6
6
|
metaproofContext.begin(metastatementNode);
|
package/src/verify/premise.js
CHANGED
|
@@ -5,7 +5,6 @@ import MetaproofStep from "../step/metaproof";
|
|
|
5
5
|
import verifyUnqualifiedMetastatement from "../verify/metastatement/unqualified";
|
|
6
6
|
|
|
7
7
|
import { nodeQuery } from "../utilities/query";
|
|
8
|
-
import { nodeAsString } from "../utilities/string";
|
|
9
8
|
|
|
10
9
|
const metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatement!"),
|
|
11
10
|
unqualifiedMetastatementNodeQuery = nodeQuery("/premise/unqualifiedMetastatement!");
|
|
@@ -15,9 +14,9 @@ export default function verifyPremise(premiseNode, premises, metaproofContext) {
|
|
|
15
14
|
|
|
16
15
|
metaproofContext.begin(premiseNode);
|
|
17
16
|
|
|
18
|
-
const premiseString = nodeAsString(premiseNode);
|
|
17
|
+
const premiseString = metaproofContext.nodeAsString(premiseNode);
|
|
19
18
|
|
|
20
|
-
metaproofContext.debug(`Verifying the ${premiseString} premise...`);
|
|
19
|
+
metaproofContext.debug(`Verifying the '${premiseString}' premise...`);
|
|
21
20
|
|
|
22
21
|
const derived = false,
|
|
23
22
|
assertions = [],
|
package/src/verify/rule.js
CHANGED
|
@@ -22,7 +22,7 @@ export default function verifyRule(ruleNode, fileContext) {
|
|
|
22
22
|
fileContext.begin(ruleNode);
|
|
23
23
|
|
|
24
24
|
const labelNodes = labelNodesQuery(ruleNode),
|
|
25
|
-
labelsString = nodesAsString(labelNodes),
|
|
25
|
+
labelsString = fileContext.nodesAsString(labelNodes),
|
|
26
26
|
metaProofContext = MetaproofContext.fromFileContext(fileContext);
|
|
27
27
|
|
|
28
28
|
fileContext.debug(`Verifying the '${labelsString}' rule...`);
|
|
@@ -107,8 +107,10 @@ function verifyChild(childNode, metaproofContext) {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
case QUALIFIED_METASTATEMENT_RULE_NAME: {
|
|
110
|
-
const
|
|
111
|
-
|
|
110
|
+
const derived = true,
|
|
111
|
+
assertions = [],
|
|
112
|
+
qualifiedMetastatementNode = childNode, ///
|
|
113
|
+
qualifiedMetastatementVerified = verifyQualifiedMetastatement(qualifiedMetastatementNode, assertions, derived, metaproofContext);
|
|
112
114
|
|
|
113
115
|
if (qualifiedMetastatementVerified) {
|
|
114
116
|
const metastatementNode = metastatementNodeQuery(qualifiedMetastatementNode),
|
|
@@ -8,7 +8,7 @@ import { nodeQuery, referenceNameFromReferenceNode } from "../../utilities/query
|
|
|
8
8
|
const referenceNodeQuery = nodeQuery("/qualifiedStatement/qualification!/reference!"),
|
|
9
9
|
statementNodeQuery = nodeQuery("/qualifiedStatement/statement!");
|
|
10
10
|
|
|
11
|
-
export default function verifyQualifiedStatement(qualifiedStatementNode, proofContext) {
|
|
11
|
+
export default function verifyQualifiedStatement(qualifiedStatementNode, assertions, derived, proofContext) {
|
|
12
12
|
let qualifiedStatementVerified = false;
|
|
13
13
|
|
|
14
14
|
proofContext.begin(qualifiedStatementNode);
|
|
@@ -16,9 +16,9 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, proofCo
|
|
|
16
16
|
const statementNode = statementNodeQuery(qualifiedStatementNode);
|
|
17
17
|
|
|
18
18
|
if (statementNode !== null) {
|
|
19
|
-
const statementString = nodeAsString(statementNode);
|
|
19
|
+
const statementString = proofContext.nodeAsString(statementNode);
|
|
20
20
|
|
|
21
|
-
proofContext.debug(`Verifying the ${statementString} qualified statement...`);
|
|
21
|
+
proofContext.debug(`Verifying the '${statementString}' qualified statement...`);
|
|
22
22
|
|
|
23
23
|
let ruleMatchesStatement = true;
|
|
24
24
|
|
|
@@ -34,8 +34,8 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, proofCo
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
if (ruleMatchesStatement) {
|
|
37
|
-
const
|
|
38
|
-
statementVerified = verifyStatement(statementNode, assertions,
|
|
37
|
+
const context = proofContext,
|
|
38
|
+
statementVerified = verifyStatement(statementNode, assertions, derived, context);
|
|
39
39
|
|
|
40
40
|
qualifiedStatementVerified = statementVerified; ///
|
|
41
41
|
}
|
|
@@ -15,9 +15,9 @@ export default function verifyUnqualifiedStatement(unqualifiedStatementNode, ass
|
|
|
15
15
|
const statementNode = statementNodeQuery(unqualifiedStatementNode);
|
|
16
16
|
|
|
17
17
|
if (statementNode !== null) {
|
|
18
|
-
const statementString = nodeAsString(statementNode);
|
|
18
|
+
const statementString = proofContext.nodeAsString(statementNode);
|
|
19
19
|
|
|
20
|
-
proofContext.debug(`Verifying the ${statementString} unqualified statement...`);
|
|
20
|
+
proofContext.debug(`Verifying the '${statementString}' unqualified statement...`);
|
|
21
21
|
|
|
22
22
|
let statementMatches = true;
|
|
23
23
|
|
|
@@ -26,7 +26,8 @@ export default function verifyUnqualifiedStatement(unqualifiedStatementNode, ass
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
if (statementMatches) {
|
|
29
|
-
const
|
|
29
|
+
const context = proofContext, ///
|
|
30
|
+
statementVerified = verifyStatement(statementNode, assertions, derived, context);
|
|
30
31
|
|
|
31
32
|
unqualifiedStatementVerified = statementVerified; ///
|
|
32
33
|
}
|
package/src/verify/statement.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Equality from "../equality";
|
|
3
4
|
import verifyTerm from "../verify/term";
|
|
4
5
|
import equalityCombinator from "../ocmbinator/equality";
|
|
5
6
|
import bracketedCombinator from "../ocmbinator/bracketed";
|
|
@@ -7,9 +8,9 @@ import verifyTypeAssertion from "../verify/assertion/type";
|
|
|
7
8
|
|
|
8
9
|
import { first } from "../utilities/array";
|
|
9
10
|
import { objectType } from "../type";
|
|
10
|
-
import { nodeAsString } from "../utilities/string";
|
|
11
11
|
import { OBJECT_TYPE_NAME } from "../typeNames";
|
|
12
12
|
import { STATEMENT_META_TYPE } from "../metaTypes";
|
|
13
|
+
import { MAXIMUM_INDEXES_LENGTH } from "../constants";
|
|
13
14
|
import { nodeQuery, typeNameFromTypeNode } from "../utilities/query";
|
|
14
15
|
import { ARGUMENT_RULE_NAME, META_ARGUMENT_RULE_NAME } from "../ruleNames";
|
|
15
16
|
|
|
@@ -19,56 +20,65 @@ const termNodeQuery = nodeQuery("/argument/term!"),
|
|
|
19
20
|
statementNodeQuery = nodeQuery("/metaArgument/statement!"),
|
|
20
21
|
typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion!");
|
|
21
22
|
|
|
22
|
-
export default function verifyStatement(statementNode, assertions,
|
|
23
|
+
export default function verifyStatement(statementNode, assertions, derived, context) {
|
|
23
24
|
let statementVerified = false;
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
context.begin(statementNode);
|
|
26
27
|
|
|
27
28
|
if (!statementVerified) {
|
|
28
|
-
const statementVerifiedAsEquality = verifyStatementAsEquality(statementNode,
|
|
29
|
+
const statementVerifiedAsEquality = verifyStatementAsEquality(statementNode, derived, context);
|
|
29
30
|
|
|
30
31
|
statementVerified = statementVerifiedAsEquality; //
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
if (!statementVerified) {
|
|
34
|
-
const statementVerifiedAsTypeAssertion = verifyStatementAsTypeAssertion(statementNode, assertions,
|
|
35
|
+
const statementVerifiedAsTypeAssertion = verifyStatementAsTypeAssertion(statementNode, assertions, context);
|
|
35
36
|
|
|
36
37
|
statementVerified = statementVerifiedAsTypeAssertion; ///
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
if (!statementVerified) {
|
|
40
|
-
const statementVerifiedAgainstCombinators = verifyStatementAgainstCombinators(statementNode,
|
|
41
|
+
const statementVerifiedAgainstCombinators = verifyStatementAgainstCombinators(statementNode, context);
|
|
41
42
|
|
|
42
43
|
statementVerified = statementVerifiedAgainstCombinators; ///
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
statementVerified ?
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
context.complete(statementNode) :
|
|
48
|
+
context.halt(statementNode);
|
|
48
49
|
|
|
49
50
|
return statementVerified;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
function verifyStatementAsEquality(statementNode,
|
|
53
|
+
function verifyStatementAsEquality(statementNode, derived, context) {
|
|
53
54
|
let statementVerifiedAsEquality = false;
|
|
54
55
|
|
|
55
56
|
const combinator = equalityCombinator, ///
|
|
56
|
-
statementVerifiedAgainstCombinator = verifyStatementAgainstCombinator(statementNode, combinator,
|
|
57
|
+
statementVerifiedAgainstCombinator = verifyStatementAgainstCombinator(statementNode, combinator, context);
|
|
57
58
|
|
|
58
59
|
if (statementVerifiedAgainstCombinator) {
|
|
59
60
|
statementVerifiedAsEquality = true;
|
|
61
|
+
|
|
62
|
+
if (derived) {
|
|
63
|
+
const equality = Equality.fromStatementNode(statementNode),
|
|
64
|
+
proofSteps = context.getProofSteps(),
|
|
65
|
+
equalities = equalitiesFromProofSteps(proofSteps),
|
|
66
|
+
equalityEquates = equality.equate(equalities);
|
|
67
|
+
|
|
68
|
+
statementVerifiedAsEquality = equalityEquates; ///
|
|
69
|
+
}
|
|
60
70
|
}
|
|
61
71
|
|
|
62
72
|
return statementVerifiedAsEquality;
|
|
63
73
|
}
|
|
64
74
|
|
|
65
|
-
function verifyStatementAsTypeAssertion(statementNode, assertions,
|
|
75
|
+
function verifyStatementAsTypeAssertion(statementNode, assertions, context) {
|
|
66
76
|
let statementVerifiedAsTypeAssertion = false;
|
|
67
77
|
|
|
68
78
|
const typeAssertionNode = typeAssertionNodeQuery(statementNode);
|
|
69
79
|
|
|
70
80
|
if (typeAssertionNode !== null) {
|
|
71
|
-
const typeAssertionVerified = verifyTypeAssertion(typeAssertionNode, assertions,
|
|
81
|
+
const typeAssertionVerified = verifyTypeAssertion(typeAssertionNode, assertions, context);
|
|
72
82
|
|
|
73
83
|
statementVerifiedAsTypeAssertion = typeAssertionVerified; ///
|
|
74
84
|
}
|
|
@@ -76,10 +86,10 @@ function verifyStatementAsTypeAssertion(statementNode, assertions, proofContext)
|
|
|
76
86
|
return statementVerifiedAsTypeAssertion;
|
|
77
87
|
}
|
|
78
88
|
|
|
79
|
-
function verifyStatementAgainstCombinators(statementNode,
|
|
89
|
+
function verifyStatementAgainstCombinators(statementNode, context) {
|
|
80
90
|
let statementVerifiedAgainstCombinators = false;
|
|
81
91
|
|
|
82
|
-
let combinators =
|
|
92
|
+
let combinators = context.getCombinators();
|
|
83
93
|
|
|
84
94
|
combinators = [ ///
|
|
85
95
|
bracketedCombinator,
|
|
@@ -87,7 +97,7 @@ function verifyStatementAgainstCombinators(statementNode, proofContext) {
|
|
|
87
97
|
];
|
|
88
98
|
|
|
89
99
|
const combinator = combinators.find((combinator) => {
|
|
90
|
-
const statementVerifiedAgainstCombinator = verifyStatementAgainstCombinator(statementNode, combinator,
|
|
100
|
+
const statementVerifiedAgainstCombinator = verifyStatementAgainstCombinator(statementNode, combinator, context);
|
|
91
101
|
|
|
92
102
|
if (statementVerifiedAgainstCombinator) {
|
|
93
103
|
return true;
|
|
@@ -101,17 +111,17 @@ function verifyStatementAgainstCombinators(statementNode, proofContext) {
|
|
|
101
111
|
return statementVerifiedAgainstCombinators;
|
|
102
112
|
}
|
|
103
113
|
|
|
104
|
-
function verifyStatementAgainstCombinator(statementNode, combinator,
|
|
114
|
+
function verifyStatementAgainstCombinator(statementNode, combinator, context) {
|
|
105
115
|
const combinatorStatementNode = combinator.getStatementNode(),
|
|
106
116
|
node = statementNode, ///
|
|
107
117
|
combinatorNode = combinatorStatementNode, ///
|
|
108
|
-
nodeVerified = verifyNode(node, combinatorNode,
|
|
118
|
+
nodeVerified = verifyNode(node, combinatorNode, context),
|
|
109
119
|
statementVerifiedAgainstCombinator = nodeVerified; ///
|
|
110
120
|
|
|
111
121
|
return statementVerifiedAgainstCombinator;
|
|
112
122
|
}
|
|
113
123
|
|
|
114
|
-
function verifyNode(node, combinatorNode,
|
|
124
|
+
function verifyNode(node, combinatorNode, context) {
|
|
115
125
|
let nodeVerified;
|
|
116
126
|
|
|
117
127
|
const nodeTerminalNode = node.isTerminalNode(),
|
|
@@ -121,13 +131,13 @@ function verifyNode(node, combinatorNode, proofContext) {
|
|
|
121
131
|
if (nodeTerminalNode) {
|
|
122
132
|
const terminalNode = node, ///
|
|
123
133
|
combinatorTerminalNode = combinatorNode, ///
|
|
124
|
-
terminalNodeVerified = verifyTerminalNode(terminalNode, combinatorTerminalNode,
|
|
134
|
+
terminalNodeVerified = verifyTerminalNode(terminalNode, combinatorTerminalNode, context);
|
|
125
135
|
|
|
126
136
|
nodeVerified = terminalNodeVerified; ///
|
|
127
137
|
} else {
|
|
128
138
|
const nonTerminalNode = node, ///
|
|
129
139
|
combinatorNonTerminalNode = combinatorNode, ///
|
|
130
|
-
nonTerminalNodeVerified = verifyNonTerminalNode(nonTerminalNode, combinatorNonTerminalNode,
|
|
140
|
+
nonTerminalNodeVerified = verifyNonTerminalNode(nonTerminalNode, combinatorNonTerminalNode, context);
|
|
131
141
|
|
|
132
142
|
nodeVerified = nonTerminalNodeVerified; ///
|
|
133
143
|
}
|
|
@@ -136,7 +146,7 @@ function verifyNode(node, combinatorNode, proofContext) {
|
|
|
136
146
|
return nodeVerified;
|
|
137
147
|
}
|
|
138
148
|
|
|
139
|
-
function verifyNodes(nodes, combinatorNodes,
|
|
149
|
+
function verifyNodes(nodes, combinatorNodes, context) {
|
|
140
150
|
let nodesVerified = false;
|
|
141
151
|
|
|
142
152
|
const nodesLength = nodes.length,
|
|
@@ -145,7 +155,7 @@ function verifyNodes(nodes, combinatorNodes, proofContext) {
|
|
|
145
155
|
if (nodesLength === combinatorNodesLength) {
|
|
146
156
|
nodesVerified = nodes.every((node, index) => {
|
|
147
157
|
const combinatorNode = combinatorNodes[index],
|
|
148
|
-
nodeVerified = verifyNode(node, combinatorNode,
|
|
158
|
+
nodeVerified = verifyNode(node, combinatorNode, context);
|
|
149
159
|
|
|
150
160
|
if (nodeVerified) {
|
|
151
161
|
return true;
|
|
@@ -156,7 +166,7 @@ function verifyNodes(nodes, combinatorNodes, proofContext) {
|
|
|
156
166
|
return nodesVerified;
|
|
157
167
|
}
|
|
158
168
|
|
|
159
|
-
function verifyTerminalNode(terminalNode, combinatorTerminalNode,
|
|
169
|
+
function verifyTerminalNode(terminalNode, combinatorTerminalNode, context) {
|
|
160
170
|
let terminalNodeVerified = false;
|
|
161
171
|
|
|
162
172
|
const matches = terminalNode.match(combinatorTerminalNode);
|
|
@@ -168,7 +178,7 @@ function verifyTerminalNode(terminalNode, combinatorTerminalNode, proofContext)
|
|
|
168
178
|
return terminalNodeVerified;
|
|
169
179
|
}
|
|
170
180
|
|
|
171
|
-
function verifyNonTerminalNode(nonTerminalNode, combinatorNonTerminalNode,
|
|
181
|
+
function verifyNonTerminalNode(nonTerminalNode, combinatorNonTerminalNode, context) {
|
|
172
182
|
let nonTerminalNodeVerified = false;
|
|
173
183
|
|
|
174
184
|
const ruleName = nonTerminalNode.getRuleName(), ///
|
|
@@ -179,7 +189,7 @@ function verifyNonTerminalNode(nonTerminalNode, combinatorNonTerminalNode, proof
|
|
|
179
189
|
case ARGUMENT_RULE_NAME: {
|
|
180
190
|
const argumentNode = nonTerminalNode, ///
|
|
181
191
|
combinatorArgumentNode = combinatorNonTerminalNode, ///
|
|
182
|
-
argumentNodeVerified = verifyArgumentNode(argumentNode, combinatorArgumentNode,
|
|
192
|
+
argumentNodeVerified = verifyArgumentNode(argumentNode, combinatorArgumentNode, context);
|
|
183
193
|
|
|
184
194
|
nonTerminalNodeVerified = argumentNodeVerified; ///
|
|
185
195
|
|
|
@@ -189,7 +199,7 @@ function verifyNonTerminalNode(nonTerminalNode, combinatorNonTerminalNode, proof
|
|
|
189
199
|
case META_ARGUMENT_RULE_NAME: {
|
|
190
200
|
const metaArgumentNode = nonTerminalNode, ///
|
|
191
201
|
combinatorMetaargumentNode = combinatorNonTerminalNode, ///
|
|
192
|
-
metaArgumentNodeVerified = verifyMetaargumentNode(metaArgumentNode, combinatorMetaargumentNode,
|
|
202
|
+
metaArgumentNodeVerified = verifyMetaargumentNode(metaArgumentNode, combinatorMetaargumentNode, context);
|
|
193
203
|
|
|
194
204
|
nonTerminalNodeVerified = metaArgumentNodeVerified; ///
|
|
195
205
|
|
|
@@ -201,7 +211,7 @@ function verifyNonTerminalNode(nonTerminalNode, combinatorNonTerminalNode, proof
|
|
|
201
211
|
combinatorChildNodes = combinatorNonTerminalNode.getChildNodes(),
|
|
202
212
|
nodes = childNodes, ///
|
|
203
213
|
combinatorNodes = combinatorChildNodes, ///
|
|
204
|
-
nodesVerified = verifyNodes(nodes, combinatorNodes,
|
|
214
|
+
nodesVerified = verifyNodes(nodes, combinatorNodes, context);
|
|
205
215
|
|
|
206
216
|
nonTerminalNodeVerified = nodesVerified; ///
|
|
207
217
|
|
|
@@ -213,18 +223,17 @@ function verifyNonTerminalNode(nonTerminalNode, combinatorNonTerminalNode, proof
|
|
|
213
223
|
return nonTerminalNodeVerified;
|
|
214
224
|
}
|
|
215
225
|
|
|
216
|
-
function verifyArgumentNode(argumentNode, combinatorArgumentNode,
|
|
226
|
+
function verifyArgumentNode(argumentNode, combinatorArgumentNode, context) {
|
|
217
227
|
let argumentNodeVerified = false;
|
|
218
228
|
|
|
219
229
|
const termNode = termNodeQuery(argumentNode);
|
|
220
230
|
|
|
221
231
|
if (termNode === null) {
|
|
222
|
-
const argumentString = nodeAsString(argumentNode);
|
|
232
|
+
const argumentString = context.nodeAsString(argumentNode);
|
|
223
233
|
|
|
224
|
-
|
|
234
|
+
context.error(`The ${argumentString} argument should be a term, not a type`);
|
|
225
235
|
} else {
|
|
226
236
|
const types = [],
|
|
227
|
-
context = proofContext, ///
|
|
228
237
|
termVerified = verifyTerm(termNode, types, context);
|
|
229
238
|
|
|
230
239
|
if (termVerified) {
|
|
@@ -234,7 +243,7 @@ function verifyArgumentNode(argumentNode, combinatorArgumentNode, proofContext)
|
|
|
234
243
|
typeName = typeNameFromTypeNode(typeNode),
|
|
235
244
|
type = (typeName === OBJECT_TYPE_NAME) ?
|
|
236
245
|
objectType : ///
|
|
237
|
-
|
|
246
|
+
context.findTypeByTypeName(typeName),
|
|
238
247
|
statementTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(type);
|
|
239
248
|
|
|
240
249
|
if (statementTypeEqualToOrSubTypeOfType) {
|
|
@@ -246,18 +255,19 @@ function verifyArgumentNode(argumentNode, combinatorArgumentNode, proofContext)
|
|
|
246
255
|
return argumentNodeVerified;
|
|
247
256
|
}
|
|
248
257
|
|
|
249
|
-
function verifyMetaargumentNode(metaArgumentNode, combinatorMetaargumentNode,
|
|
258
|
+
function verifyMetaargumentNode(metaArgumentNode, combinatorMetaargumentNode, context) {
|
|
250
259
|
let metaArgumentNodeVerified = false;
|
|
251
260
|
|
|
252
261
|
const statementNode = statementNodeQuery(metaArgumentNode);
|
|
253
262
|
|
|
254
263
|
if (statementNode === null) {
|
|
255
|
-
const metaArgumentString = nodeAsString(metaArgumentNode);
|
|
264
|
+
const metaArgumentString = context.nodeAsString(metaArgumentNode);
|
|
256
265
|
|
|
257
|
-
|
|
266
|
+
context.error(`The '${metaArgumentString}' meta-argument should be a statement, not a meta-type.`);
|
|
258
267
|
} else {
|
|
259
|
-
const
|
|
260
|
-
|
|
268
|
+
const derived = false,
|
|
269
|
+
assertions = null,
|
|
270
|
+
statementVerified = verifyStatement(statementNode, assertions, derived, context);
|
|
261
271
|
|
|
262
272
|
if (statementVerified) {
|
|
263
273
|
const combinatorMetaTYpeNode = metaTypeNodeQuery(combinatorMetaargumentNode);
|
|
@@ -271,12 +281,30 @@ function verifyMetaargumentNode(metaArgumentNode, combinatorMetaargumentNode, pr
|
|
|
271
281
|
}
|
|
272
282
|
|
|
273
283
|
if (!metaArgumentNodeVerified) {
|
|
274
|
-
const combinatorMetaargumentString = nodeAsString(combinatorMetaargumentNode);
|
|
284
|
+
const combinatorMetaargumentString = context.nodeAsString(combinatorMetaargumentNode);
|
|
275
285
|
|
|
276
|
-
|
|
286
|
+
context.error(`The '${combinatorMetaargumentString}' combinator meta-argument should be the 'Statement' meta-type.`);
|
|
277
287
|
}
|
|
278
288
|
}
|
|
279
289
|
}
|
|
280
290
|
|
|
281
291
|
return metaArgumentNodeVerified;
|
|
282
292
|
}
|
|
293
|
+
|
|
294
|
+
function equalitiesFromProofSteps(proofSteps) {
|
|
295
|
+
const start = -MAXIMUM_INDEXES_LENGTH; ///
|
|
296
|
+
|
|
297
|
+
proofSteps = proofSteps.slice(start); ///
|
|
298
|
+
|
|
299
|
+
const equalities = proofSteps.reduce((equalities, proofStep, index) => {
|
|
300
|
+
const equality = Equality.fromProofStep(proofStep);
|
|
301
|
+
|
|
302
|
+
if (equality !== null) {
|
|
303
|
+
equalities.push(equality);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return equalities;
|
|
307
|
+
}, []);
|
|
308
|
+
|
|
309
|
+
return equalities;
|
|
310
|
+
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Combinator from "../combinator";
|
|
4
|
+
import verifyTerm from "../verify/term";
|
|
5
|
+
import verifyStatement from "../verify/statement";
|
|
4
6
|
|
|
5
|
-
import { nodeAsString } from "../utilities/string";
|
|
6
7
|
import { typeNameFromTypeNode } from "../utilities/query";
|
|
7
|
-
import { TERM_RULE_NAME,
|
|
8
|
+
import { TYPE_RULE_NAME, TERM_RULE_NAME, STATEMENT_RULE_NAME } from "../ruleNames";
|
|
8
9
|
|
|
9
10
|
export default function verifyStatementAsCombinator(statementNode, fileContext) {
|
|
10
11
|
let statementVerifiedAsCombinator = false;
|
|
11
12
|
|
|
12
13
|
fileContext.begin(statementNode);
|
|
13
14
|
|
|
14
|
-
const statementString = nodeAsString(statementNode);
|
|
15
|
+
const statementString = fileContext.nodeAsString(statementNode);
|
|
15
16
|
|
|
16
17
|
fileContext.debug(`Verifying the '${statementString}' combinator....`);
|
|
17
18
|
|
|
@@ -58,29 +59,6 @@ function verifyNode(node, fileContext) {
|
|
|
58
59
|
return nodeVerified;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
function verifyTypeNode(typeNode, fileContext) {
|
|
62
|
-
let typeNodeVerified = false;
|
|
63
|
-
|
|
64
|
-
const typeName = typeNameFromTypeNode(typeNode),
|
|
65
|
-
typePresent = fileContext.isTypePresentByTypeName(typeName);
|
|
66
|
-
|
|
67
|
-
if (!typePresent) {
|
|
68
|
-
fileContext.error(`The type '${typeName}' is missing.`);
|
|
69
|
-
} else {
|
|
70
|
-
typeNodeVerified = true;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return typeNodeVerified;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function verifyTermNode(termNode, fileContext) {
|
|
77
|
-
let termNodeVerified = false;
|
|
78
|
-
|
|
79
|
-
debugger
|
|
80
|
-
|
|
81
|
-
return termNodeVerified;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
62
|
function verifyChildNodes(childNodes, fileContext) {
|
|
85
63
|
const childNodesVerified = childNodes.every((childNode) => {
|
|
86
64
|
const node = childNode, ///
|
|
@@ -124,6 +102,15 @@ function verifyNonTerminalNode(nonTerminalNode, fileContext) {
|
|
|
124
102
|
break;
|
|
125
103
|
}
|
|
126
104
|
|
|
105
|
+
case STATEMENT_RULE_NAME: {
|
|
106
|
+
const statmentNode = nonTerminalNode, ///
|
|
107
|
+
statmentNodeVerified = verifyStatementNode(statmentNode, fileContext);
|
|
108
|
+
|
|
109
|
+
nonTerminalNodeVerified = statmentNodeVerified; ///
|
|
110
|
+
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
|
|
127
114
|
default: {
|
|
128
115
|
const childNodes = nonTerminalNode.getChildNodes(),
|
|
129
116
|
childNodesVerified = verifyChildNodes(childNodes, fileContext);
|
|
@@ -136,3 +123,38 @@ function verifyNonTerminalNode(nonTerminalNode, fileContext) {
|
|
|
136
123
|
|
|
137
124
|
return nonTerminalNodeVerified;
|
|
138
125
|
}
|
|
126
|
+
|
|
127
|
+
function verifyTypeNode(typeNode, fileContext) {
|
|
128
|
+
let typeNodeVerified = false;
|
|
129
|
+
|
|
130
|
+
const typeName = typeNameFromTypeNode(typeNode),
|
|
131
|
+
typePresent = fileContext.isTypePresentByTypeName(typeName);
|
|
132
|
+
|
|
133
|
+
if (!typePresent) {
|
|
134
|
+
fileContext.error(`The type '${typeName}' is missing.`);
|
|
135
|
+
} else {
|
|
136
|
+
typeNodeVerified = true;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return typeNodeVerified;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function verifyTermNode(termNode, fileContext) {
|
|
143
|
+
const types = [],
|
|
144
|
+
context = fileContext, ///
|
|
145
|
+
termVerified = verifyTerm(termNode, types, context),
|
|
146
|
+
termNodeVerified = termVerified; ///
|
|
147
|
+
|
|
148
|
+
return termNodeVerified;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function verifyStatementNode(statementNode, fileContext) {
|
|
152
|
+
const context = fileContext, ///
|
|
153
|
+
derived = false,
|
|
154
|
+
assertions = [],
|
|
155
|
+
statementVerified = verifyStatement(statementNode, assertions, derived, context),
|
|
156
|
+
statementNodeVerified = statementVerified; ///
|
|
157
|
+
|
|
158
|
+
return statementNodeVerified;
|
|
159
|
+
}
|
|
160
|
+
|
|
@@ -5,7 +5,6 @@ import Supposition from "../supposition";
|
|
|
5
5
|
import verifyUnqualifiedStatement from "./statement/unqualified";
|
|
6
6
|
|
|
7
7
|
import { nodeQuery } from "../utilities/query";
|
|
8
|
-
import { nodeAsString } from "../utilities/string";
|
|
9
8
|
|
|
10
9
|
const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
|
|
11
10
|
unqualifiedStatementNodeQuery = nodeQuery("/supposition/unqualifiedStatement!");
|
|
@@ -15,9 +14,9 @@ export default function verifySupposition(suppositionNode, suppositions, proofCo
|
|
|
15
14
|
|
|
16
15
|
proofContext.begin(suppositionNode);
|
|
17
16
|
|
|
18
|
-
const suppositionString = nodeAsString(suppositionNode);
|
|
17
|
+
const suppositionString = proofContext.nodeAsString(suppositionNode);
|
|
19
18
|
|
|
20
|
-
proofContext.debug(`Verifying the ${suppositionString} supposition...`);
|
|
19
|
+
proofContext.debug(`Verifying the '${suppositionString}' supposition...`);
|
|
21
20
|
|
|
22
21
|
const derived = false,
|
|
23
22
|
assertions = [],
|
package/src/verify/term.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { first } from "../utilities/array";
|
|
4
4
|
import { objectType } from "../type";
|
|
5
|
-
import { nodeAsString } from "../utilities/string";
|
|
6
5
|
import { OBJECT_TYPE_NAME } from "../typeNames";
|
|
7
6
|
import { ARGUMENT_RULE_NAME } from "../ruleNames";
|
|
8
7
|
import { nodeQuery, typeNameFromTypeNode, variableNameFromVariableNode } from "../utilities/query";
|
|
@@ -16,7 +15,7 @@ export default function verifyTerm(termNode, types, context) {
|
|
|
16
15
|
|
|
17
16
|
context.begin(termNode);
|
|
18
17
|
|
|
19
|
-
const termString = nodeAsString(termNode);
|
|
18
|
+
const termString = context.nodeAsString(termNode);
|
|
20
19
|
|
|
21
20
|
context.debug(`Verifying the '${termString}' term...`);
|
|
22
21
|
|
|
@@ -218,7 +217,7 @@ function verifyArgumentNode(argumentNode, constructorArgumentNode, context) {
|
|
|
218
217
|
const termNode = termNodeQuery(argumentNode);
|
|
219
218
|
|
|
220
219
|
if (termNode === null) {
|
|
221
|
-
const argumentString = nodeAsString(argumentNode);
|
|
220
|
+
const argumentString = context.nodeAsString(argumentNode);
|
|
222
221
|
|
|
223
222
|
context.error(`The ${argumentString} argument should be a term, not a type`);
|
|
224
223
|
} else {
|