occam-verify-cli 0.0.526 → 0.0.527
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/assertion/type.js +10 -40
- package/lib/axiom.js +7 -7
- package/lib/axiomLemmaTheoremConjecture.js +190 -0
- package/lib/conjecture.js +141 -0
- package/lib/consequence.js +3 -3
- package/lib/constants.js +4 -16
- package/lib/context/file.js +76 -39
- package/lib/context/metaproof.js +40 -10
- package/lib/context/proof.js +38 -105
- package/lib/context/release/directory.js +20 -1
- package/lib/context/release/file.js +27 -3
- package/lib/equality.js +78 -51
- package/lib/index.js +1 -13
- package/lib/kinds.js +5 -1
- package/lib/lemma.js +7 -7
- package/lib/matcher/metastatementForMetavariable.js +16 -19
- package/lib/matcher/statementForMetavariable.js +22 -20
- package/lib/matcher/{statementForVariable → termForVariable}/consequence.js +13 -13
- package/lib/matcher/{statementForVariable → termForVariable}/supposition.js +13 -13
- package/lib/matcher/termForVariable.js +198 -0
- package/lib/matcher.js +23 -64
- package/lib/mixins/file.js +62 -2
- package/lib/premise.js +4 -4
- package/lib/ruleNames.js +1 -9
- package/lib/step/proof.js +22 -1
- package/lib/substitution/statementForMetavariable.js +12 -8
- package/lib/substitution/termForVariable.js +86 -0
- package/lib/supposition.js +4 -4
- package/lib/theorem.js +7 -7
- package/lib/type.js +9 -2
- package/lib/utilities/string.js +3 -7
- package/lib/utilities/substitution.js +4 -5
- package/lib/variable.js +4 -38
- package/lib/verify/assertion/type.js +59 -36
- package/lib/verify/axiom.js +1 -2
- package/lib/verify/conjecture.js +56 -0
- package/lib/verify/declaration/topLevel.js +7 -3
- package/lib/verify/lemma.js +1 -2
- package/lib/verify/metastatement/qualified.js +1 -2
- package/lib/verify/metastatement/unqualified.js +1 -2
- package/lib/verify/rule.js +1 -2
- package/lib/verify/statement/qualified.js +39 -10
- package/lib/verify/statement/unqualified.js +1 -2
- package/lib/verify/statement.js +44 -47
- package/lib/verify/theorem.js +1 -2
- package/package.json +1 -1
- package/src/assertion/type.js +7 -32
- package/src/axiom.js +4 -4
- package/src/{axiomLemmaTheorem.js → axiomLemmaTheoremConjecture.js} +5 -5
- package/src/conjecture.js +13 -0
- package/src/consequence.js +2 -2
- package/src/constants.js +1 -4
- package/src/context/file.js +81 -37
- package/src/context/metaproof.js +42 -5
- package/src/context/proof.js +42 -41
- package/src/context/release/directory.js +24 -0
- package/src/context/release/file.js +34 -3
- package/src/equality.js +110 -61
- package/src/index.js +0 -3
- package/src/kinds.js +1 -0
- package/src/lemma.js +4 -4
- package/src/matcher/metastatementForMetavariable.js +22 -32
- package/src/matcher/statementForMetavariable.js +40 -34
- package/src/matcher/termForVariable/consequence.js +9 -0
- package/src/matcher/termForVariable/supposition.js +9 -0
- package/src/matcher/termForVariable.js +89 -0
- package/src/matcher.js +28 -22
- package/src/mixins/file.js +46 -1
- package/src/premise.js +4 -4
- package/src/ruleNames.js +0 -2
- package/src/step/proof.js +27 -0
- package/src/substitution/statementForMetavariable.js +17 -10
- package/src/substitution/termForVariable.js +64 -0
- package/src/supposition.js +3 -3
- package/src/theorem.js +4 -4
- package/src/type.js +14 -4
- package/src/utilities/string.js +4 -6
- package/src/utilities/substitution.js +6 -4
- package/src/variable.js +4 -37
- package/src/verify/assertion/type.js +70 -64
- package/src/verify/axiom.js +0 -1
- package/src/verify/conjecture.js +73 -0
- package/src/verify/declaration/topLevel.js +7 -0
- package/src/verify/lemma.js +0 -1
- package/src/verify/metastatement/qualified.js +0 -1
- package/src/verify/metastatement/unqualified.js +0 -1
- package/src/verify/rule.js +0 -1
- package/src/verify/statement/qualified.js +53 -13
- package/src/verify/statement/unqualified.js +0 -1
- package/src/verify/statement.js +46 -66
- package/src/verify/theorem.js +0 -1
- package/lib/axiomLemmaTheorem.js +0 -190
- package/lib/jsonTypes.js +0 -30
- package/lib/matcher/statementForVariable.js +0 -201
- package/lib/substitution/statementForVariable.js +0 -86
- package/lib/utilities/json.js +0 -187
- package/lib/utilities/version.js +0 -32
- package/lib/versionChanges.js +0 -34
- package/src/jsonTypes.js +0 -6
- package/src/matcher/statementForVariable/consequence.js +0 -9
- package/src/matcher/statementForVariable/supposition.js +0 -9
- package/src/matcher/statementForVariable.js +0 -99
- package/src/substitution/statementForVariable.js +0 -64
- package/src/utilities/json.js +0 -264
- package/src/utilities/version.js +0 -30
- package/src/versionChanges.js +0 -11
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Variable from "../../variable";
|
|
3
4
|
import TypeAssertion from "../../assertion/type";
|
|
4
5
|
|
|
5
6
|
import { first } from "../../utilities/array";
|
|
6
|
-
import {
|
|
7
|
+
import { verifyTermAsVariable } from "../../verify/term";
|
|
7
8
|
import { nodeQuery, typeNameFromTypeNode } from "../../utilities/query";
|
|
8
|
-
import { verifyTermAsVariable, verifyTermAgainstConstructors } from "../../verify/term";
|
|
9
9
|
|
|
10
10
|
const termNodeQuery = nodeQuery("/typeAssertion/term"),
|
|
11
11
|
typeNodeQuery = nodeQuery("/typeAssertion/type");
|
|
12
12
|
|
|
13
|
-
export default function verifyTypeAssertion(typeAssertionNode, assertions, proofContext) {
|
|
13
|
+
export default function verifyTypeAssertion(typeAssertionNode, assertions, derived, proofContext) {
|
|
14
14
|
let typeAssertionVerified = false;
|
|
15
15
|
|
|
16
16
|
proofContext.begin(typeAssertionNode);
|
|
@@ -27,16 +27,16 @@ export default function verifyTypeAssertion(typeAssertionNode, assertions, proof
|
|
|
27
27
|
proofContext.error(`The ${typeName} type is not present.`);
|
|
28
28
|
} else {
|
|
29
29
|
if (!typeAssertionVerified) {
|
|
30
|
-
const variableTypeAssertionVerified = verifyVariableTypeAssertion(typeAssertionNode, assertions, proofContext);
|
|
30
|
+
const variableTypeAssertionVerified = verifyVariableTypeAssertion(typeAssertionNode, assertions, derived, proofContext);
|
|
31
31
|
|
|
32
32
|
typeAssertionVerified = variableTypeAssertionVerified; ///
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
if (!typeAssertionVerified) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
35
|
+
// if (!typeAssertionVerified) {
|
|
36
|
+
// const termTypeAssertionVerified = verifyTermTypeAssertion(typeAssertionNode, assertions, proofContext);
|
|
37
|
+
//
|
|
38
|
+
// typeAssertionVerified = termTypeAssertionVerified; ///
|
|
39
|
+
// }
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
if (typeAssertionVerified) {
|
|
@@ -50,7 +50,7 @@ export default function verifyTypeAssertion(typeAssertionNode, assertions, proof
|
|
|
50
50
|
return typeAssertionVerified;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
function verifyVariableTypeAssertion(typeAssertionNode, assertions, proofContext) {
|
|
53
|
+
function verifyVariableTypeAssertion(typeAssertionNode, assertions, derived, proofContext) {
|
|
54
54
|
let variableTypeAssertionVerified = false;
|
|
55
55
|
|
|
56
56
|
const context = proofContext, ///
|
|
@@ -59,18 +59,28 @@ function verifyVariableTypeAssertion(typeAssertionNode, assertions, proofContext
|
|
|
59
59
|
termVerifiedAsVariable = verifyTermAsVariable(termNode, variables, context);
|
|
60
60
|
|
|
61
61
|
if (termVerifiedAsVariable) {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
const typeNode = typeNodeQuery(typeAssertionNode),
|
|
63
|
+
typeName = typeNameFromTypeNode(typeNode),
|
|
64
|
+
assertedTypeName = typeName, ///
|
|
65
|
+
assertedType = proofContext.findTypeByTypeName(assertedTypeName),
|
|
66
|
+
firstVariable = first(variables),
|
|
67
|
+
variable = firstVariable, ///
|
|
68
|
+
variableName = variable.getName(),
|
|
69
|
+
variableType = variable.getType();
|
|
70
|
+
|
|
71
|
+
if (derived) {
|
|
72
|
+
const variableTypeEqualToOrSubTypeOfAssertedType = variableType.isEqualToOrSubTypeOf(assertedType);
|
|
73
|
+
|
|
74
|
+
if (!variableTypeEqualToOrSubTypeOfAssertedType) {
|
|
75
|
+
const assertedTypeName = assertedType.getName(),
|
|
76
|
+
variableTypeName = variableType.getName();
|
|
77
|
+
|
|
78
|
+
proofContext.error(`The '${variableName}' variable's '${variableTypeName}' type is not equal to or a sub-type of the '${assertedTypeName}' asserted type.`);
|
|
79
|
+
} else {
|
|
80
|
+
variableTypeAssertionVerified = true;
|
|
81
|
+
}
|
|
64
82
|
} else {
|
|
65
|
-
const
|
|
66
|
-
typeName = typeNameFromTypeNode(typeNode),
|
|
67
|
-
assertedTypeName = typeName, ///
|
|
68
|
-
assertedType = proofContext.findTypeByTypeName(assertedTypeName),
|
|
69
|
-
firstVariable = first(variables),
|
|
70
|
-
variable = firstVariable, ///
|
|
71
|
-
variableName = variable.getName(),
|
|
72
|
-
variableType = variable.getType(),
|
|
73
|
-
assertedTypeEqualToOrSubTypeOfVariableType = assertedType.isEqualToOrSubTypeOf(variableType);
|
|
83
|
+
const assertedTypeEqualToOrSubTypeOfVariableType = assertedType.isEqualToOrSubTypeOf(variableType);
|
|
74
84
|
|
|
75
85
|
if (!assertedTypeEqualToOrSubTypeOfVariableType) {
|
|
76
86
|
const assertedTypeName = assertedType.getName(),
|
|
@@ -79,7 +89,9 @@ function verifyVariableTypeAssertion(typeAssertionNode, assertions, proofContext
|
|
|
79
89
|
proofContext.error(`The '${assertedTypeName}' asserted type is not equal to or a sub-type of the '${variableName}' variable's '${variableTypeName}' type.`);
|
|
80
90
|
} else {
|
|
81
91
|
const type = assertedType, ///
|
|
82
|
-
|
|
92
|
+
name = variableName, ///
|
|
93
|
+
variable = Variable.fromTypeAndName(type, name),
|
|
94
|
+
typeAssertion = TypeAssertion.fromVariable(variable),
|
|
83
95
|
assertion = typeAssertion; ///
|
|
84
96
|
|
|
85
97
|
assertions.push(assertion);
|
|
@@ -92,46 +104,40 @@ function verifyVariableTypeAssertion(typeAssertionNode, assertions, proofContext
|
|
|
92
104
|
return variableTypeAssertionVerified;
|
|
93
105
|
}
|
|
94
106
|
|
|
95
|
-
function verifyTermTypeAssertion(typeAssertionNode, assertions, proofContext) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return termTypeAssertionVerified;
|
|
136
|
-
}
|
|
107
|
+
// function verifyTermTypeAssertion(typeAssertionNode, assertions, proofContext) {
|
|
108
|
+
// let termTypeAssertionVerified = false;
|
|
109
|
+
//
|
|
110
|
+
// const types = [],
|
|
111
|
+
// context = proofContext, ///
|
|
112
|
+
// termNode = termNodeQuery(typeAssertionNode),
|
|
113
|
+
// termVerifiedAgainstConstructors = verifyTermAgainstConstructors(termNode, types, context);
|
|
114
|
+
//
|
|
115
|
+
// if (termVerifiedAgainstConstructors) {
|
|
116
|
+
// const typeNode = typeNodeQuery(typeAssertionNode),
|
|
117
|
+
// typeName = typeNameFromTypeNode(typeNode),
|
|
118
|
+
// assertedTypeName = typeName, ///
|
|
119
|
+
// assertedType = proofContext.findTypeByTypeName(assertedTypeName),
|
|
120
|
+
// firstType = first(types),
|
|
121
|
+
// termType = firstType,
|
|
122
|
+
// termString = proofContext.nodeAsString(termNode),
|
|
123
|
+
// termTypeEqualToOrSubTypeOfAssertedType = termType.isEqualToOrSubTypeOf(assertedType);
|
|
124
|
+
//
|
|
125
|
+
// if (!termTypeEqualToOrSubTypeOfAssertedType) {
|
|
126
|
+
// const termTypeName = termType.getName(),
|
|
127
|
+
// assertedTypeName = assertedType.getName();
|
|
128
|
+
//
|
|
129
|
+
// proofContext.error(`The '${termString}' term's '${termTypeName}' type is not equal to or a sub-type of the '${assertedTypeName}' asserted type.`);
|
|
130
|
+
// } else {
|
|
131
|
+
// const type = assertedType, ///
|
|
132
|
+
// typeAssertion = TypeAssertion.fromTypeAndTermNode(type, termNode),
|
|
133
|
+
// assertion = typeAssertion; ///
|
|
134
|
+
//
|
|
135
|
+
// assertions.push(assertion);
|
|
136
|
+
//
|
|
137
|
+
// termTypeAssertionVerified = true;
|
|
138
|
+
// }
|
|
139
|
+
// }
|
|
140
|
+
//
|
|
141
|
+
// return termTypeAssertionVerified;
|
|
142
|
+
// }
|
|
137
143
|
|
package/src/verify/axiom.js
CHANGED
|
@@ -7,7 +7,6 @@ import verifySupposition from "../verify/supposition";
|
|
|
7
7
|
import verifyConsequence from "../verify/consequence";
|
|
8
8
|
|
|
9
9
|
import { first } from "../utilities/array";
|
|
10
|
-
import { nodesAsString } from "../utilities/string";
|
|
11
10
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
12
11
|
|
|
13
12
|
const labelNodesQuery = nodesQuery("/axiom/label"),
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Conjecture from "../conjecture";
|
|
4
|
+
import verifyProof from "../verify/proof";
|
|
5
|
+
import ProofContext from "../context/proof";
|
|
6
|
+
import verifyLabels from "../verify/labels";
|
|
7
|
+
import verifySupposition from "./supposition";
|
|
8
|
+
import verifyConsequence from "./consequence";
|
|
9
|
+
|
|
10
|
+
import { first } from "../utilities/array";
|
|
11
|
+
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
12
|
+
|
|
13
|
+
const proofNodeQuery = nodeQuery("/conjecture/proof!"),
|
|
14
|
+
labelNodesQuery = nodesQuery("/conjecture/label"),
|
|
15
|
+
consequenceNodeQuery = nodeQuery("/conjecture/consequence!"),
|
|
16
|
+
suppositionsNodeQuery = nodesQuery("/conjecture/supposition");
|
|
17
|
+
|
|
18
|
+
export default function verifyConjecture(conjectureNode, fileContext) {
|
|
19
|
+
let conjectureVerified = false;
|
|
20
|
+
|
|
21
|
+
fileContext.begin(conjectureNode);
|
|
22
|
+
|
|
23
|
+
const labelNodes = labelNodesQuery(conjectureNode),
|
|
24
|
+
labelsString = fileContext.nodesAsString(labelNodes),
|
|
25
|
+
proofContext = ProofContext.fromFileContext(fileContext);
|
|
26
|
+
|
|
27
|
+
fileContext.debug(`Verifying the '${labelsString}' conjecture...`);
|
|
28
|
+
|
|
29
|
+
const labels = [],
|
|
30
|
+
labelsVerified = verifyLabels(labelNodes, labels, fileContext);
|
|
31
|
+
|
|
32
|
+
if (labelsVerified) {
|
|
33
|
+
const suppositions = [],
|
|
34
|
+
suppositionNodes = suppositionsNodeQuery(conjectureNode),
|
|
35
|
+
suppositionsVerified = suppositionNodes.every((suppositionNode) => {
|
|
36
|
+
const suppositionVerified = verifySupposition(suppositionNode, suppositions, proofContext);
|
|
37
|
+
|
|
38
|
+
if (suppositionVerified) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (suppositionsVerified) {
|
|
44
|
+
const consequences = [],
|
|
45
|
+
consequenceNode = consequenceNodeQuery(conjectureNode),
|
|
46
|
+
consequenceVerified = verifyConsequence(consequenceNode, consequences, proofContext);
|
|
47
|
+
|
|
48
|
+
if (consequenceVerified) {
|
|
49
|
+
const proofNode = proofNodeQuery(conjectureNode),
|
|
50
|
+
firstConsequence = first(consequences),
|
|
51
|
+
consequence = firstConsequence; ///
|
|
52
|
+
|
|
53
|
+
verifyProof(proofNode, consequence, proofContext);
|
|
54
|
+
|
|
55
|
+
const conjecture = Conjecture.fromLabelsSuppositionsAndConsequence(labels, suppositions, consequence);
|
|
56
|
+
|
|
57
|
+
fileContext.addConjecture(conjecture);
|
|
58
|
+
|
|
59
|
+
conjectureVerified = true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (conjectureVerified) {
|
|
65
|
+
fileContext.info(`Verified the '${labelsString}' conjecture.`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
conjectureVerified ?
|
|
69
|
+
fileContext.complete(conjectureNode) :
|
|
70
|
+
fileContext.complete(conjectureNode);
|
|
71
|
+
|
|
72
|
+
return conjectureVerified;
|
|
73
|
+
}
|
|
@@ -4,6 +4,7 @@ import verifyRule from "../../verify/rule";
|
|
|
4
4
|
import verifyAxiom from "../../verify/axiom";
|
|
5
5
|
import verifyLemma from "../../verify/lemma";
|
|
6
6
|
import verifyTheorem from "../../verify/theorem";
|
|
7
|
+
import verifyConjecture from "../../verify/conjecture";
|
|
7
8
|
import verifyTypeDeclaration from "../../verify/declaration/type";
|
|
8
9
|
import verifyVariableDeclaration from "../../verify/declaration/variable";
|
|
9
10
|
import verifyCombinatorDeclaration from "../../verify/declaration/combinator";
|
|
@@ -15,6 +16,7 @@ const ruleNodeQuery = nodeQuery("/topLevelDeclaration/rule!"),
|
|
|
15
16
|
axiomNodeQuery = nodeQuery("/topLevelDeclaration/axiom!"),
|
|
16
17
|
lemmaNodeQuery = nodeQuery("/topLevelDeclaration/lemma!"),
|
|
17
18
|
theoremNodeQuery = nodeQuery("/topLevelDeclaration/theorem!"),
|
|
19
|
+
conjectureNodeQuery = nodeQuery("/topLevelDeclaration/conjecture!"),
|
|
18
20
|
typeDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/typeDeclaration!"),
|
|
19
21
|
variableDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/variableDeclaration!"),
|
|
20
22
|
combinatorDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/combinatorDeclaration!"),
|
|
@@ -30,6 +32,7 @@ export default function verifyTopLevelDeclaration(topLevelDeclarationNode, fileC
|
|
|
30
32
|
axiomNode = axiomNodeQuery(node),
|
|
31
33
|
lemmaNode = lemmaNodeQuery(node),
|
|
32
34
|
theoremNode = theoremNodeQuery(node),
|
|
35
|
+
conjectureNode = conjectureNodeQuery(node),
|
|
33
36
|
typeDeclarationNode = typeDeclarationNodeQuery(node),
|
|
34
37
|
variableDeclarationNode = variableDeclarationNodeQuery(node),
|
|
35
38
|
combinatorDeclarationNode = combinatorDeclarationNodeQuery(node),
|
|
@@ -53,6 +56,10 @@ export default function verifyTopLevelDeclaration(topLevelDeclarationNode, fileC
|
|
|
53
56
|
const theoremVerified = verifyTheorem(theoremNode, fileContext);
|
|
54
57
|
|
|
55
58
|
topLevelDeclarationVerified = theoremVerified; ///
|
|
59
|
+
} else if (conjectureNode !== null) {
|
|
60
|
+
const conjectureVerified = verifyConjecture(conjectureNode, fileContext);
|
|
61
|
+
|
|
62
|
+
topLevelDeclarationVerified = conjectureVerified; ///
|
|
56
63
|
} else if (typeDeclarationNode !== null) {
|
|
57
64
|
const typeDeclarationVerified = verifyTypeDeclaration(typeDeclarationNode, fileContext);
|
|
58
65
|
|
package/src/verify/lemma.js
CHANGED
|
@@ -9,7 +9,6 @@ import verifyConsequence from "./consequence";
|
|
|
9
9
|
|
|
10
10
|
import { first } from "../utilities/array";
|
|
11
11
|
import { EMPTY_STRING } from "../constants";
|
|
12
|
-
import { nodesAsString } from "../utilities/string";
|
|
13
12
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
14
13
|
|
|
15
14
|
const proofNodeQuery = nodeQuery("/lemma/proof!"),
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import verifyMetastatement from "../../verify/metastatement";
|
|
4
4
|
|
|
5
|
-
import { nodeAsString } from "../../utilities/string";
|
|
6
5
|
import { nodeQuery, referenceNameFromReferenceNode } from "../../utilities/query";
|
|
7
6
|
|
|
8
7
|
const referenceNodeQuery = nodeQuery("/qualifiedMetastatement/qualification!/reference!"),
|
package/src/verify/rule.js
CHANGED
|
@@ -8,7 +8,6 @@ import MetaproofContext from "../context/metaproof";
|
|
|
8
8
|
import verifyConclusion from "../verify/conclusion";
|
|
9
9
|
|
|
10
10
|
import { first } from "../utilities/array";
|
|
11
|
-
import { nodesAsString } from "../utilities/string";
|
|
12
11
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
13
12
|
|
|
14
13
|
const labelNodesQuery = nodesQuery("/rule/label"),
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import verifyStatement from "../../verify/statement";
|
|
4
4
|
|
|
5
|
-
import { nodeAsString } from "../../utilities/string";
|
|
6
5
|
import { nodeQuery, referenceNameFromReferenceNode } from "../../utilities/query";
|
|
7
6
|
|
|
8
7
|
const referenceNodeQuery = nodeQuery("/qualifiedStatement/qualification!/reference!"),
|
|
@@ -20,24 +19,65 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, asserti
|
|
|
20
19
|
|
|
21
20
|
proofContext.debug(`Verifying the '${statementString}' qualified statement...`);
|
|
22
21
|
|
|
23
|
-
let ruleMatchesStatement = true;
|
|
24
|
-
|
|
25
22
|
const referenceNode = referenceNodeQuery(qualifiedStatementNode);
|
|
26
23
|
|
|
27
|
-
if (referenceNode
|
|
28
|
-
const referenceName = referenceNameFromReferenceNode(referenceNode),
|
|
29
|
-
rule = proofContext.findRuleByReferenceName(referenceName);
|
|
30
|
-
|
|
31
|
-
if (rule !== null) {
|
|
32
|
-
ruleMatchesStatement = rule.matchStatement(statementNode, proofContext);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (ruleMatchesStatement) {
|
|
24
|
+
if (referenceNode === null) {
|
|
37
25
|
const context = proofContext,
|
|
38
26
|
statementVerified = verifyStatement(statementNode, assertions, derived, context);
|
|
39
27
|
|
|
40
28
|
qualifiedStatementVerified = statementVerified; ///
|
|
29
|
+
} else {
|
|
30
|
+
const referenceName = referenceNameFromReferenceNode(referenceNode);
|
|
31
|
+
|
|
32
|
+
if (!qualifiedStatementVerified) {
|
|
33
|
+
const rule = proofContext.findRuleByReferenceName(referenceName);
|
|
34
|
+
|
|
35
|
+
if (rule !== null) {
|
|
36
|
+
const ruleMatchesStatement = rule.matchStatement(statementNode, proofContext);
|
|
37
|
+
|
|
38
|
+
qualifiedStatementVerified = ruleMatchesStatement; ///
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!qualifiedStatementVerified) {
|
|
43
|
+
const axiom = proofContext.findAxiomByReferenceName(referenceName);
|
|
44
|
+
|
|
45
|
+
if (axiom !== null) {
|
|
46
|
+
const axiomMatchesStatement = axiom.matchStatement(statementNode, proofContext);
|
|
47
|
+
|
|
48
|
+
qualifiedStatementVerified = axiomMatchesStatement; ///
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!qualifiedStatementVerified) {
|
|
53
|
+
const lemma = proofContext.findLemmaByReferenceName(referenceName);
|
|
54
|
+
|
|
55
|
+
if (lemma !== null) {
|
|
56
|
+
const lemmaMatchesStatement = lemma.matchStatement(statementNode, proofContext);
|
|
57
|
+
|
|
58
|
+
qualifiedStatementVerified = lemmaMatchesStatement; ///
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!qualifiedStatementVerified) {
|
|
63
|
+
const theorem = proofContext.findTheoremByReferenceName(referenceName);
|
|
64
|
+
|
|
65
|
+
if (theorem !== null) {
|
|
66
|
+
const theoremMatchesStatement = theorem.matchStatement(statementNode, proofContext);
|
|
67
|
+
|
|
68
|
+
qualifiedStatementVerified = theoremMatchesStatement; ///
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!qualifiedStatementVerified) {
|
|
73
|
+
const conjecture = proofContext.findConjectureByReferenceName(referenceName);
|
|
74
|
+
|
|
75
|
+
if (conjecture !== null) {
|
|
76
|
+
const conjectureMatchesStatement = conjecture.matchStatement(statementNode, proofContext);
|
|
77
|
+
|
|
78
|
+
qualifiedStatementVerified = conjectureMatchesStatement; ///
|
|
79
|
+
}
|
|
80
|
+
}
|
|
41
81
|
}
|
|
42
82
|
}
|
|
43
83
|
|
package/src/verify/statement.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import Equality from "../equality";
|
|
4
4
|
import verifyTerm from "../verify/term";
|
|
5
|
-
import equalityCombinator from "../ocmbinator/equality";
|
|
6
5
|
import bracketedCombinator from "../ocmbinator/bracketed";
|
|
7
6
|
import verifyTypeAssertion from "../verify/assertion/type";
|
|
8
7
|
|
|
@@ -10,7 +9,6 @@ import { first } from "../utilities/array";
|
|
|
10
9
|
import { objectType } from "../type";
|
|
11
10
|
import { OBJECT_TYPE_NAME } from "../typeNames";
|
|
12
11
|
import { STATEMENT_META_TYPE } from "../metaTypes";
|
|
13
|
-
import { MAXIMUM_INDEXES_LENGTH } from "../constants";
|
|
14
12
|
import { nodeQuery, typeNameFromTypeNode } from "../utilities/query";
|
|
15
13
|
import { ARGUMENT_RULE_NAME, META_ARGUMENT_RULE_NAME } from "../ruleNames";
|
|
16
14
|
|
|
@@ -26,21 +24,21 @@ export default function verifyStatement(statementNode, assertions, derived, cont
|
|
|
26
24
|
context.begin(statementNode);
|
|
27
25
|
|
|
28
26
|
if (!statementVerified) {
|
|
29
|
-
const
|
|
27
|
+
const statementVerifiedAgainstCombinators = verifyStatementAgainstCombinators(statementNode, context);
|
|
30
28
|
|
|
31
|
-
statementVerified =
|
|
29
|
+
statementVerified = statementVerifiedAgainstCombinators; ///
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
if (!statementVerified) {
|
|
35
|
-
const statementVerifiedAsTypeAssertion = verifyStatementAsTypeAssertion(statementNode, assertions, context);
|
|
33
|
+
const statementVerifiedAsTypeAssertion = verifyStatementAsTypeAssertion(statementNode, assertions, derived, context);
|
|
36
34
|
|
|
37
35
|
statementVerified = statementVerifiedAsTypeAssertion; ///
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
if (!statementVerified) {
|
|
41
|
-
const
|
|
39
|
+
const statementVerifiedAsEquality = verifyStatementAsEquality(statementNode, derived, context);
|
|
42
40
|
|
|
43
|
-
statementVerified =
|
|
41
|
+
statementVerified = statementVerifiedAsEquality; //
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
statementVerified ?
|
|
@@ -50,40 +48,14 @@ export default function verifyStatement(statementNode, assertions, derived, cont
|
|
|
50
48
|
return statementVerified;
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (statementVerifiedAgainstCombinator) {
|
|
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
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return statementVerifiedAsEquality;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function verifyStatementAsTypeAssertion(statementNode, assertions, context) {
|
|
76
|
-
let statementVerifiedAsTypeAssertion = false;
|
|
77
|
-
|
|
78
|
-
const typeAssertionNode = typeAssertionNodeQuery(statementNode);
|
|
79
|
-
|
|
80
|
-
if (typeAssertionNode !== null) {
|
|
81
|
-
const typeAssertionVerified = verifyTypeAssertion(typeAssertionNode, assertions, context);
|
|
82
|
-
|
|
83
|
-
statementVerifiedAsTypeAssertion = typeAssertionVerified; ///
|
|
84
|
-
}
|
|
51
|
+
export function verifyStatementAgainstCombinator(statementNode, combinator, context) {
|
|
52
|
+
const combinatorStatementNode = combinator.getStatementNode(),
|
|
53
|
+
node = statementNode, ///
|
|
54
|
+
combinatorNode = combinatorStatementNode, ///
|
|
55
|
+
nodeVerified = verifyNode(node, combinatorNode, context),
|
|
56
|
+
statementVerifiedAgainstCombinator = nodeVerified; ///
|
|
85
57
|
|
|
86
|
-
return
|
|
58
|
+
return statementVerifiedAgainstCombinator;
|
|
87
59
|
}
|
|
88
60
|
|
|
89
61
|
function verifyStatementAgainstCombinators(statementNode, context) {
|
|
@@ -111,14 +83,40 @@ function verifyStatementAgainstCombinators(statementNode, context) {
|
|
|
111
83
|
return statementVerifiedAgainstCombinators;
|
|
112
84
|
}
|
|
113
85
|
|
|
114
|
-
function
|
|
115
|
-
|
|
116
|
-
node = statementNode, ///
|
|
117
|
-
combinatorNode = combinatorStatementNode, ///
|
|
118
|
-
nodeVerified = verifyNode(node, combinatorNode, context),
|
|
119
|
-
statementVerifiedAgainstCombinator = nodeVerified; ///
|
|
86
|
+
function verifyStatementAsTypeAssertion(statementNode, assertions, derived, context) {
|
|
87
|
+
let statementVerifiedAsTypeAssertion = false;
|
|
120
88
|
|
|
121
|
-
|
|
89
|
+
const typeAssertionNode = typeAssertionNodeQuery(statementNode);
|
|
90
|
+
|
|
91
|
+
if (typeAssertionNode !== null) {
|
|
92
|
+
const typeAssertionVerified = verifyTypeAssertion(typeAssertionNode, assertions, derived, context);
|
|
93
|
+
|
|
94
|
+
statementVerifiedAsTypeAssertion = typeAssertionVerified; ///
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return statementVerifiedAsTypeAssertion;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function verifyStatementAsEquality(statementNode, derived, context) {
|
|
101
|
+
let statementVerifiedAsEquality = false;
|
|
102
|
+
|
|
103
|
+
const equality = Equality.fromStatementNode(statementNode, context);
|
|
104
|
+
|
|
105
|
+
if (equality !== null) {
|
|
106
|
+
statementVerifiedAsEquality = true; ///
|
|
107
|
+
|
|
108
|
+
if (derived) {
|
|
109
|
+
const equalities = context.getEqualities();
|
|
110
|
+
|
|
111
|
+
if (equalities !== null) {
|
|
112
|
+
const equalityEquates = equality.equate(equalities, context);
|
|
113
|
+
|
|
114
|
+
statementVerifiedAsEquality = equalityEquates; ///
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return statementVerifiedAsEquality;
|
|
122
120
|
}
|
|
123
121
|
|
|
124
122
|
function verifyNode(node, combinatorNode, context) {
|
|
@@ -266,7 +264,7 @@ function verifyMetaargumentNode(metaArgumentNode, combinatorMetaargumentNode, co
|
|
|
266
264
|
context.error(`The '${metaArgumentString}' meta-argument should be a statement, not a meta-type.`);
|
|
267
265
|
} else {
|
|
268
266
|
const derived = false,
|
|
269
|
-
assertions =
|
|
267
|
+
assertions = [],
|
|
270
268
|
statementVerified = verifyStatement(statementNode, assertions, derived, context);
|
|
271
269
|
|
|
272
270
|
if (statementVerified) {
|
|
@@ -290,21 +288,3 @@ function verifyMetaargumentNode(metaArgumentNode, combinatorMetaargumentNode, co
|
|
|
290
288
|
|
|
291
289
|
return metaArgumentNodeVerified;
|
|
292
290
|
}
|
|
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
|
-
}
|
package/src/verify/theorem.js
CHANGED
|
@@ -8,7 +8,6 @@ import verifySupposition from "./supposition";
|
|
|
8
8
|
import verifyConsequence from "./consequence";
|
|
9
9
|
|
|
10
10
|
import { first } from "../utilities/array";
|
|
11
|
-
import { nodesAsString } from "../utilities/string";
|
|
12
11
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
13
12
|
|
|
14
13
|
const proofNodeQuery = nodeQuery("/theorem/proof!"),
|