occam-verify-cli 0.0.698 → 0.0.702
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 +4 -4
- package/lib/assignment/metavariable.js +4 -4
- package/lib/assignment/variable.js +4 -4
- package/lib/collection.js +44 -6
- package/lib/conclusion.js +6 -6
- package/lib/consequent.js +4 -4
- package/lib/constructor.js +3 -10
- package/lib/context/file.js +12 -73
- package/lib/context/local.js +31 -70
- package/lib/context/localMeta.js +12 -9
- package/lib/context/release.js +2 -4
- package/lib/equality.js +22 -6
- package/lib/metaType.js +10 -10
- package/lib/metavariable.js +3 -10
- package/lib/mixins/context.js +107 -0
- package/lib/premise.js +9 -9
- package/lib/ruleNames.js +9 -1
- package/lib/supposition.js +4 -4
- package/lib/type.js +23 -27
- package/lib/utilities/collection.js +27 -13
- package/lib/utilities/node.js +3 -73
- package/lib/utilities/tokens.js +1 -8
- package/lib/variable.js +11 -10
- package/lib/verifier/node/statementAsCombinator.js +4 -1
- package/lib/verifier/node/termAsConstructor.js +4 -20
- package/lib/verifier/nodes/equality.js +169 -0
- package/lib/verifier/nodes/metastatementForMetavariable.js +6 -7
- package/lib/verifier/nodes/statement.js +12 -4
- package/lib/verifier/nodes/statementForMetavariable.js +6 -7
- package/lib/verifier/nodes/termForVariable.js +19 -20
- package/lib/verify/axiom.js +3 -8
- package/lib/verify/conclusion.js +2 -2
- package/lib/verify/conjecture.js +4 -9
- package/lib/verify/consequent.js +3 -3
- package/lib/verify/derivation.js +30 -13
- package/lib/verify/equality.js +17 -12
- package/lib/verify/givenType.js +32 -0
- package/lib/verify/lemma.js +4 -9
- package/lib/verify/metastatement.js +3 -3
- package/lib/verify/premises.js +28 -0
- package/lib/verify/rule.js +3 -8
- package/lib/verify/ruleDerivation.js +6 -8
- package/lib/verify/statement/qualified.js +135 -37
- package/lib/verify/statement.js +34 -42
- package/lib/verify/supposition.js +6 -7
- package/lib/verify/suppositions.js +28 -0
- package/lib/verify/term.js +25 -60
- package/lib/verify/termAndGivenType.js +39 -0
- package/lib/verify/termAsGivenVariable.js +36 -0
- package/lib/verify/theorem.js +3 -8
- package/lib/verify/typeAssertion.js +44 -27
- package/package.json +1 -1
- package/src/assignment/equality.js +5 -5
- package/src/assignment/metavariable.js +5 -5
- package/src/assignment/variable.js +7 -5
- package/src/collection.js +55 -5
- package/src/conclusion.js +6 -6
- package/src/consequent.js +4 -4
- package/src/constructor.js +2 -7
- package/src/context/file.js +16 -13
- package/src/context/local.js +39 -86
- package/src/context/localMeta.js +11 -7
- package/src/context/release.js +6 -9
- package/src/equality.js +25 -4
- package/src/metaType.js +10 -10
- package/src/metavariable.js +2 -7
- package/src/mixins/{file.js → context.js} +20 -2
- package/src/premise.js +10 -10
- package/src/ruleNames.js +2 -0
- package/src/supposition.js +3 -3
- package/src/type.js +27 -39
- package/src/utilities/collection.js +31 -11
- package/src/utilities/node.js +3 -81
- package/src/utilities/tokens.js +0 -8
- package/src/variable.js +9 -6
- package/src/verifier/node/statementAsCombinator.js +7 -1
- package/src/verifier/node/termAsConstructor.js +5 -26
- package/src/verifier/nodes/equality.js +47 -0
- package/src/verifier/nodes/metastatementForMetavariable.js +10 -10
- package/src/verifier/nodes/statement.js +1 -1
- package/src/verifier/nodes/statementForMetavariable.js +10 -10
- package/src/verifier/nodes/termForVariable.js +30 -30
- package/src/verify/axiom.js +2 -8
- package/src/verify/conclusion.js +1 -1
- package/src/verify/conjecture.js +3 -9
- package/src/verify/consequent.js +4 -4
- package/src/verify/derivation.js +39 -16
- package/src/verify/equality.js +20 -11
- package/src/verify/{standaloneType.js → givenType.js} +7 -7
- package/src/verify/lemma.js +3 -9
- package/src/verify/metastatement.js +2 -2
- package/src/verify/premises.js +17 -0
- package/src/verify/rule.js +2 -8
- package/src/verify/ruleDerivation.js +5 -7
- package/src/verify/statement/qualified.js +194 -39
- package/src/verify/statement.js +47 -47
- package/src/verify/supposition.js +10 -12
- package/src/verify/suppositions.js +17 -0
- package/src/verify/term.js +26 -64
- package/src/verify/termAndGivenType.js +37 -0
- package/src/verify/termAsGivenVariable.js +39 -0
- package/src/verify/theorem.js +2 -8
- package/src/verify/typeAssertion.js +59 -32
- package/lib/mixins/file.js +0 -83
- package/lib/mixins/logging.js +0 -39
- package/lib/verifier/nodes/metastatementForMetavariable/conclusion.js +0 -114
- package/lib/verifier/nodes/metastatementForMetavariable/premise.js +0 -114
- package/lib/verifier/nodes/statementForMetavariable/conclusion.js +0 -114
- package/lib/verifier/nodes/statementForMetavariable/premise.js +0 -114
- package/lib/verifier/nodes/termForVariable/consequent.js +0 -114
- package/lib/verifier/nodes/termForVariable/supposition.js +0 -114
- package/lib/verify/standaloneType.js +0 -32
- package/lib/verify/termAndStandaloneType.js +0 -39
- package/lib/verify/termAsVariableAndStandaloneType.js +0 -39
- package/src/mixins/logging.js +0 -24
- package/src/verifier/nodes/metastatementForMetavariable/conclusion.js +0 -11
- package/src/verifier/nodes/metastatementForMetavariable/premise.js +0 -11
- package/src/verifier/nodes/statementForMetavariable/conclusion.js +0 -11
- package/src/verifier/nodes/statementForMetavariable/premise.js +0 -11
- package/src/verifier/nodes/termForVariable/consequent.js +0 -11
- package/src/verifier/nodes/termForVariable/supposition.js +0 -11
- package/src/verify/termAndStandaloneType.js +0 -37
- package/src/verify/termAsVariableAndStandaloneType.js +0 -38
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import verifyEquality from "../equality";
|
|
4
|
+
import verifyTypeAssertion from "../typeAssertion";
|
|
5
|
+
|
|
3
6
|
import { nodeQuery, referenceNameFromReferenceNode } from "../../utilities/query";
|
|
4
7
|
|
|
5
|
-
const
|
|
6
|
-
|
|
8
|
+
const equalityNodeQuery = nodeQuery("/qualifiedStatement/statement/equality!"),
|
|
9
|
+
referenceNodeQuery = nodeQuery("/qualifiedStatement/qualification!/reference!"),
|
|
10
|
+
statementNodeQuery = nodeQuery("/qualifiedStatement/statement!"),
|
|
11
|
+
typeAssertionNodeQuery = nodeQuery("/qualifiedStatement/statement/typeAssertion!");
|
|
7
12
|
|
|
8
13
|
export default function verifyQualifiedStatement(qualifiedStatementNode, assignments, derived, localContext) {
|
|
9
14
|
let qualifiedStatementVerified = false;
|
|
@@ -11,68 +16,218 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
|
|
|
11
16
|
const statementNode = statementNodeQuery(qualifiedStatementNode);
|
|
12
17
|
|
|
13
18
|
if (statementNode !== null) {
|
|
14
|
-
const
|
|
15
|
-
statementLocalContext = localContext; ///
|
|
19
|
+
const qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
16
20
|
|
|
17
|
-
localContext.trace(`Verifying the '${
|
|
21
|
+
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement...`, qualifiedStatementNode);
|
|
18
22
|
|
|
19
23
|
const referenceNode = referenceNodeQuery(qualifiedStatementNode),
|
|
20
|
-
referenceName = referenceNameFromReferenceNode(referenceNode)
|
|
24
|
+
referenceName = referenceNameFromReferenceNode(referenceNode),
|
|
25
|
+
verifyQualifiedStatementFunctions = [
|
|
26
|
+
verifyQualifiedStatementAAgainstRule,
|
|
27
|
+
verifyQualifiedStatementAAgainstAxiom,
|
|
28
|
+
verifyQualifiedStatementAAgainstLemma,
|
|
29
|
+
verifyQualifiedStatementAAgainstTheorem,
|
|
30
|
+
verifyQualifiedStatementAAgainstConjecture
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
qualifiedStatementVerified = verifyQualifiedStatementFunctions.some((verifyQualifiedStatementFunction) => { ///
|
|
34
|
+
const qualifiedStatementVerified = verifyQualifiedStatementFunction(qualifiedStatementNode, referenceName, localContext);
|
|
35
|
+
|
|
36
|
+
if (qualifiedStatementVerified) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
21
40
|
|
|
22
|
-
if (
|
|
23
|
-
|
|
41
|
+
if (qualifiedStatementVerified) {
|
|
42
|
+
derived = false; ///
|
|
24
43
|
|
|
25
|
-
|
|
26
|
-
|
|
44
|
+
const context = localContext, ///
|
|
45
|
+
verifyQualifiedStatementFunctions = [
|
|
46
|
+
verifyQualifiedStatementAsEquality,
|
|
47
|
+
verifyQualifiedStatementAsTypeAssertion
|
|
48
|
+
];
|
|
27
49
|
|
|
28
|
-
|
|
29
|
-
|
|
50
|
+
qualifiedStatementVerified = verifyQualifiedStatementFunctions.every((verifyQualifiedStatementFunction) => { ///
|
|
51
|
+
const qualifiedStatementVerified = verifyQualifiedStatementFunction(qualifiedStatementNode, assignments, derived, context, () => {
|
|
52
|
+
const verifiedAhead = true;
|
|
53
|
+
|
|
54
|
+
return verifiedAhead;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (qualifiedStatementVerified) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
30
61
|
}
|
|
31
62
|
|
|
32
|
-
if (
|
|
33
|
-
|
|
63
|
+
if (qualifiedStatementVerified) {
|
|
64
|
+
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement.`, qualifiedStatementNode);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
34
67
|
|
|
35
|
-
|
|
36
|
-
|
|
68
|
+
return qualifiedStatementVerified;
|
|
69
|
+
}
|
|
37
70
|
|
|
38
|
-
|
|
39
|
-
|
|
71
|
+
function verifyQualifiedStatementAAgainstRule(qualifiedStatementNode, referenceName, localContext) {
|
|
72
|
+
let qualifiedStatementVerifiedAgainstRule = false;
|
|
73
|
+
|
|
74
|
+
const rule = localContext.findRuleByReferenceName(referenceName);
|
|
75
|
+
|
|
76
|
+
if (rule !== null) {
|
|
77
|
+
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
78
|
+
statementLocalContext = localContext, ///
|
|
79
|
+
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
80
|
+
|
|
81
|
+
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceName}' rule...`, statementNode);
|
|
82
|
+
|
|
83
|
+
const ruleMatchesStatement = rule.matchStatement(statementNode, statementLocalContext);
|
|
84
|
+
|
|
85
|
+
qualifiedStatementVerifiedAgainstRule = ruleMatchesStatement; ///
|
|
86
|
+
|
|
87
|
+
if (qualifiedStatementVerifiedAgainstRule) {
|
|
88
|
+
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceName}' rule.`, statementNode);
|
|
40
89
|
}
|
|
90
|
+
}
|
|
41
91
|
|
|
42
|
-
|
|
43
|
-
|
|
92
|
+
return qualifiedStatementVerifiedAgainstRule;
|
|
93
|
+
}
|
|
44
94
|
|
|
45
|
-
|
|
46
|
-
|
|
95
|
+
function verifyQualifiedStatementAAgainstAxiom(qualifiedStatementNode, referenceName, localContext) {
|
|
96
|
+
let qualifiedStatementVerifiedAgainstAxiom = false;
|
|
47
97
|
|
|
48
|
-
|
|
49
|
-
|
|
98
|
+
const axiom = localContext.findAxiomByReferenceName(referenceName);
|
|
99
|
+
|
|
100
|
+
if (axiom !== null) {
|
|
101
|
+
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
102
|
+
statementLocalContext = localContext, ///
|
|
103
|
+
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
104
|
+
|
|
105
|
+
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceName}' axiom...`, statementNode);
|
|
106
|
+
|
|
107
|
+
const axiomMatchesStatement = axiom.matchStatement(statementNode, statementLocalContext);
|
|
108
|
+
|
|
109
|
+
qualifiedStatementVerifiedAgainstAxiom = axiomMatchesStatement; ///
|
|
110
|
+
|
|
111
|
+
if (qualifiedStatementVerifiedAgainstAxiom) {
|
|
112
|
+
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceName}' axiom.`, statementNode);
|
|
50
113
|
}
|
|
114
|
+
}
|
|
51
115
|
|
|
52
|
-
|
|
53
|
-
|
|
116
|
+
return qualifiedStatementVerifiedAgainstAxiom;
|
|
117
|
+
}
|
|
54
118
|
|
|
55
|
-
|
|
56
|
-
|
|
119
|
+
function verifyQualifiedStatementAAgainstLemma(qualifiedStatementNode, referenceName, localContext) {
|
|
120
|
+
let qualifiedStatementVerifiedAgainstLemma = false;
|
|
57
121
|
|
|
58
|
-
|
|
59
|
-
|
|
122
|
+
const lemma = localContext.findLemmaByReferenceName(referenceName);
|
|
123
|
+
|
|
124
|
+
if (lemma !== null) {
|
|
125
|
+
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
126
|
+
statementLocalContext = localContext, ///
|
|
127
|
+
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
128
|
+
|
|
129
|
+
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceName}' lemma...`, statementNode);
|
|
130
|
+
|
|
131
|
+
const lemmaMatchesStatement = lemma.matchStatement(statementNode, statementLocalContext);
|
|
132
|
+
|
|
133
|
+
qualifiedStatementVerifiedAgainstLemma = lemmaMatchesStatement; ///
|
|
134
|
+
|
|
135
|
+
if (qualifiedStatementVerifiedAgainstLemma) {
|
|
136
|
+
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceName}' lemma.`, statementNode);
|
|
60
137
|
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return qualifiedStatementVerifiedAgainstLemma;
|
|
141
|
+
}
|
|
61
142
|
|
|
62
|
-
|
|
63
|
-
|
|
143
|
+
function verifyQualifiedStatementAAgainstTheorem(qualifiedStatementNode, referenceName, localContext) {
|
|
144
|
+
let qualifiedStatementVerifiedAgainstTheorem = false;
|
|
64
145
|
|
|
65
|
-
|
|
66
|
-
const conjectureMatchesStatement = conjecture.matchStatement(statementNode, statementLocalContext);
|
|
146
|
+
const theorem = localContext.findTheoremByReferenceName(referenceName);
|
|
67
147
|
|
|
68
|
-
|
|
69
|
-
|
|
148
|
+
if (theorem !== null) {
|
|
149
|
+
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
150
|
+
statementLocalContext = localContext, ///
|
|
151
|
+
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
152
|
+
|
|
153
|
+
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceName}' theorem...`, statementNode);
|
|
154
|
+
|
|
155
|
+
const theoremMatchesStatement = theorem.matchStatement(statementNode, statementLocalContext);
|
|
156
|
+
|
|
157
|
+
qualifiedStatementVerifiedAgainstTheorem = theoremMatchesStatement; ///
|
|
158
|
+
|
|
159
|
+
if (qualifiedStatementVerifiedAgainstTheorem) {
|
|
160
|
+
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceName}' theorem.`, statementNode);
|
|
70
161
|
}
|
|
162
|
+
}
|
|
71
163
|
|
|
72
|
-
|
|
73
|
-
|
|
164
|
+
return qualifiedStatementVerifiedAgainstTheorem;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function verifyQualifiedStatementAAgainstConjecture(qualifiedStatementNode, referenceName, localContext) {
|
|
168
|
+
let qualifiedStatementVerifiedAgainstConjecture = false;
|
|
169
|
+
|
|
170
|
+
const conjecture = localContext.findConjectureByReferenceName(referenceName);
|
|
171
|
+
|
|
172
|
+
if (conjecture !== null) {
|
|
173
|
+
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
174
|
+
statementLocalContext = localContext, ///
|
|
175
|
+
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
176
|
+
|
|
177
|
+
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceName}' conjecture...`, statementNode);
|
|
178
|
+
|
|
179
|
+
const conjectureMatchesStatement = conjecture.matchStatement(statementNode, statementLocalContext);
|
|
180
|
+
|
|
181
|
+
qualifiedStatementVerifiedAgainstConjecture = conjectureMatchesStatement; ///
|
|
182
|
+
|
|
183
|
+
if (qualifiedStatementVerifiedAgainstConjecture) {
|
|
184
|
+
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceName}' conjecture.`, statementNode);
|
|
74
185
|
}
|
|
75
186
|
}
|
|
76
187
|
|
|
77
|
-
return
|
|
188
|
+
return qualifiedStatementVerifiedAgainstConjecture;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function verifyQualifiedStatementAsEquality(qualifiedStatementNode, assignments, derived, context, verifyAhead) {
|
|
192
|
+
let statementVerifiedAsEquality = true; ///
|
|
193
|
+
|
|
194
|
+
const equalityNode = equalityNodeQuery(qualifiedStatementNode);
|
|
195
|
+
|
|
196
|
+
if (equalityNode !== null) {
|
|
197
|
+
const qualifiedStatementString = context.nodeAsString(qualifiedStatementNode);
|
|
198
|
+
|
|
199
|
+
context.trace(`Verifying the '${qualifiedStatementString}' qualified statement as an equality...`, qualifiedStatementNode);
|
|
200
|
+
|
|
201
|
+
const equalityVerified = verifyEquality(equalityNode, assignments, derived, context, verifyAhead);
|
|
202
|
+
|
|
203
|
+
statementVerifiedAsEquality = equalityVerified; ///
|
|
204
|
+
|
|
205
|
+
if (statementVerifiedAsEquality) {
|
|
206
|
+
context.debug(`...verified the '${qualifiedStatementString}' qualified statement as an equality.`, qualifiedStatementNode);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return statementVerifiedAsEquality;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function verifyQualifiedStatementAsTypeAssertion(qualifiedStatementNode, assignments, derived, context, verifyAhead) {
|
|
214
|
+
let statementVerifiedAsTypeAssertion = true; ///
|
|
215
|
+
|
|
216
|
+
const typeAssertionNode = typeAssertionNodeQuery(qualifiedStatementNode);
|
|
217
|
+
|
|
218
|
+
if (typeAssertionNode !== null) {
|
|
219
|
+
const qualifiedStatementString = context.nodeAsString(qualifiedStatementNode);
|
|
220
|
+
|
|
221
|
+
context.trace(`Verifying the '${qualifiedStatementString}' qualified statement as a type assertion...`, qualifiedStatementNode);
|
|
222
|
+
|
|
223
|
+
const typeAssertionVerified = verifyTypeAssertion(typeAssertionNode, assignments, derived, context, verifyAhead);
|
|
224
|
+
|
|
225
|
+
statementVerifiedAsTypeAssertion = typeAssertionVerified; ///
|
|
226
|
+
|
|
227
|
+
if (statementVerifiedAsTypeAssertion) {
|
|
228
|
+
context.debug(`...verified the '${qualifiedStatementString}' qualified statement as a type assertion.`, qualifiedStatementNode);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return statementVerifiedAsTypeAssertion;
|
|
78
233
|
}
|
package/src/verify/statement.js
CHANGED
|
@@ -38,53 +38,32 @@ function verifyStatement(statementNode, assignments, derived, context, verifyAhe
|
|
|
38
38
|
return statementVerified;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
Object.assign(
|
|
42
|
-
|
|
41
|
+
Object.assign(statementNodesVerifier, {
|
|
42
|
+
verifyStatement
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
export default verifyStatement;
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
let
|
|
49
|
-
|
|
50
|
-
let combinators = context.getCombinators();
|
|
51
|
-
|
|
52
|
-
combinators = [ ///
|
|
53
|
-
bracketedCombinator,
|
|
54
|
-
...combinators
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
statementVerifiedAgainstCombinators = combinators.some((combinator) => {
|
|
58
|
-
const statementVerifiedAgainstCombinator = verifyStatementAgainstCombinator(statementNode, combinator, context, verifyAhead);
|
|
59
|
-
|
|
60
|
-
if (statementVerifiedAgainstCombinator) {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
return statementVerifiedAgainstCombinators;
|
|
66
|
-
}
|
|
47
|
+
function verifyStatementAsEquality(statementNode, assignments, derived, context, verifyAhead) {
|
|
48
|
+
let statementVerifiedAsEquality = false;
|
|
67
49
|
|
|
68
|
-
|
|
69
|
-
let statementVerifiedAgainstCombinator;
|
|
50
|
+
const equalityNode = equalityNodeQuery(statementNode);
|
|
70
51
|
|
|
71
|
-
|
|
72
|
-
|
|
52
|
+
if (equalityNode !== null) {
|
|
53
|
+
const statementString = context.nodeAsString(statementNode);
|
|
73
54
|
|
|
74
|
-
|
|
55
|
+
context.trace(`Verifying the '${statementString}' statement as an equality...`, statementNode);
|
|
75
56
|
|
|
76
|
-
|
|
77
|
-
nonTerminalNodeA = statementNode, ///
|
|
78
|
-
nonTerminalNodeB = combinatorStatementNode, ///
|
|
79
|
-
nonTerminalNodeVerified = statementNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, context, verifyAhead);
|
|
57
|
+
const equalityVerified = verifyEquality(equalityNode, assignments, derived, context, verifyAhead);
|
|
80
58
|
|
|
81
|
-
|
|
59
|
+
statementVerifiedAsEquality = equalityVerified; ///
|
|
82
60
|
|
|
83
|
-
|
|
84
|
-
|
|
61
|
+
if (statementVerifiedAsEquality) {
|
|
62
|
+
context.debug(`...verified the '${statementString}' statement as an equality.`, statementNode);
|
|
63
|
+
}
|
|
85
64
|
}
|
|
86
65
|
|
|
87
|
-
return
|
|
66
|
+
return statementVerifiedAsEquality;
|
|
88
67
|
}
|
|
89
68
|
|
|
90
69
|
function verifyStatementAsTypeAssertion(statementNode, assignments, derived, context, verifyAhead) {
|
|
@@ -109,24 +88,45 @@ function verifyStatementAsTypeAssertion(statementNode, assignments, derived, con
|
|
|
109
88
|
return statementVerifiedAsTypeAssertion;
|
|
110
89
|
}
|
|
111
90
|
|
|
112
|
-
function
|
|
113
|
-
let
|
|
91
|
+
function verifyStatementAgainstCombinators(statementNode, assignments, derived, context, verifyAhead) {
|
|
92
|
+
let statementVerifiedAgainstCombinators;
|
|
114
93
|
|
|
115
|
-
|
|
94
|
+
let combinators = context.getCombinators();
|
|
116
95
|
|
|
117
|
-
|
|
118
|
-
|
|
96
|
+
combinators = [ ///
|
|
97
|
+
bracketedCombinator,
|
|
98
|
+
...combinators
|
|
99
|
+
];
|
|
119
100
|
|
|
120
|
-
|
|
101
|
+
statementVerifiedAgainstCombinators = combinators.some((combinator) => {
|
|
102
|
+
const statementVerifiedAgainstCombinator = verifyStatementAgainstCombinator(statementNode, combinator, context, verifyAhead);
|
|
121
103
|
|
|
122
|
-
|
|
104
|
+
if (statementVerifiedAgainstCombinator) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
123
108
|
|
|
124
|
-
|
|
109
|
+
return statementVerifiedAgainstCombinators;
|
|
110
|
+
}
|
|
125
111
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
112
|
+
function verifyStatementAgainstCombinator(statementNode, combinator, context, verifyAhead) {
|
|
113
|
+
let statementVerifiedAgainstCombinator;
|
|
114
|
+
|
|
115
|
+
const statementString = context.nodeAsString(statementNode),
|
|
116
|
+
combinatorString = combinator.getString();
|
|
117
|
+
|
|
118
|
+
context.trace(`Verifying the '${statementString}' statement against the '${combinatorString}' combinator...`, statementNode);
|
|
119
|
+
|
|
120
|
+
const combinatorStatementNode = combinator.getStatementNode(),
|
|
121
|
+
nonTerminalNodeA = statementNode, ///
|
|
122
|
+
nonTerminalNodeB = combinatorStatementNode, ///
|
|
123
|
+
nonTerminalNodeVerified = statementNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, context, verifyAhead);
|
|
124
|
+
|
|
125
|
+
statementVerifiedAgainstCombinator = nonTerminalNodeVerified; ///
|
|
126
|
+
|
|
127
|
+
if (statementVerifiedAgainstCombinator) {
|
|
128
|
+
context.debug(`...verified the '${statementString}' statement against the '${combinatorString}' combinator.`, statementNode);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
return
|
|
131
|
+
return statementVerifiedAgainstCombinator;
|
|
132
132
|
}
|
|
@@ -10,7 +10,7 @@ const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
|
|
|
10
10
|
unqualifiedStatementNodeQuery = nodeQuery("/supposition/unqualifiedStatement!");
|
|
11
11
|
|
|
12
12
|
export default function verifySupposition(suppositionNode, suppositions, localContext) {
|
|
13
|
-
let suppositionVerified;
|
|
13
|
+
let suppositionVerified = false;
|
|
14
14
|
|
|
15
15
|
const suppositionString = localContext.nodeAsString(suppositionNode);
|
|
16
16
|
|
|
@@ -22,26 +22,24 @@ export default function verifySupposition(suppositionNode, suppositions, localCo
|
|
|
22
22
|
unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, assignments, derived, localContext);
|
|
23
23
|
|
|
24
24
|
if (unqualifiedStatementVerified) {
|
|
25
|
-
|
|
26
|
-
proofStep = ProofStep.fromStatementNode(statementNode),
|
|
27
|
-
supposition = Supposition.fromStatementNode(statementNode);
|
|
28
|
-
|
|
29
|
-
suppositions.push(supposition);
|
|
30
|
-
|
|
31
|
-
localContext.addProofStep(proofStep);
|
|
32
|
-
|
|
33
|
-
assignments.every((assignment) => {
|
|
25
|
+
suppositionVerified = assignments.every((assignment) => { ///
|
|
34
26
|
const assigned = assignment.assign(localContext);
|
|
35
27
|
|
|
36
28
|
if (assigned) {
|
|
37
29
|
return true;
|
|
38
30
|
}
|
|
39
31
|
});
|
|
40
|
-
|
|
41
|
-
suppositionVerified = true;
|
|
42
32
|
}
|
|
43
33
|
|
|
44
34
|
if (suppositionVerified) {
|
|
35
|
+
const statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
36
|
+
supposition = Supposition.fromStatementNode(statementNode),
|
|
37
|
+
proofStep = ProofStep.fromStatementNode(statementNode);
|
|
38
|
+
|
|
39
|
+
suppositions.push(supposition);
|
|
40
|
+
|
|
41
|
+
localContext.addProofStep(proofStep);
|
|
42
|
+
|
|
45
43
|
localContext.debug(`...verified the '${suppositionString}' supposition.`, suppositionNode);
|
|
46
44
|
}
|
|
47
45
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import verifySupposition from "../verify/supposition";
|
|
4
|
+
|
|
5
|
+
export default function verifySuppositions(suppositionNodes, suppositions, localContext) {
|
|
6
|
+
let suppositionsVerified;
|
|
7
|
+
|
|
8
|
+
suppositionsVerified = suppositionNodes.every((suppositionNode) => {
|
|
9
|
+
const suppositionVerified = verifySupposition(suppositionNode, suppositions, localContext);
|
|
10
|
+
|
|
11
|
+
if (suppositionVerified) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return suppositionsVerified;
|
|
17
|
+
}
|
package/src/verify/term.js
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import Term from "../term";
|
|
4
4
|
import termNodesVerifier from "../verifier/nodes/term";
|
|
5
|
+
import verifyTermAsGivenVariable from "../verify/termAsGivenVariable";
|
|
5
6
|
|
|
6
7
|
import { first } from "../utilities/array";
|
|
7
|
-
import { nodeQuery } from "../utilities/query";
|
|
8
|
-
|
|
9
|
-
const variableNodeQuery = nodeQuery("/term/variable!");
|
|
10
8
|
|
|
11
9
|
function verifyTerm(termNode, terms, context, verifyAhead) {
|
|
12
10
|
let termVerified;
|
|
@@ -16,7 +14,7 @@ function verifyTerm(termNode, terms, context, verifyAhead) {
|
|
|
16
14
|
context.trace(`Verifying the '${termString}' term...`, termNode);
|
|
17
15
|
|
|
18
16
|
const verifyTermFunctions = [
|
|
19
|
-
|
|
17
|
+
verifyTermAsVariable,
|
|
20
18
|
verifyTermAgainstConstructors
|
|
21
19
|
];
|
|
22
20
|
|
|
@@ -41,67 +39,15 @@ Object.assign(termNodesVerifier, {
|
|
|
41
39
|
|
|
42
40
|
export default verifyTerm;
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
let
|
|
46
|
-
|
|
47
|
-
const constructors = context.getConstructors();
|
|
48
|
-
|
|
49
|
-
termVerifiedAgainstConstructors = constructors.some((constructor) => {
|
|
50
|
-
const termVerifiedAgainstConstructor = verifyTermAgainstConstructor(termNode, terms, constructor, context, verifyAhead);
|
|
51
|
-
|
|
52
|
-
if (termVerifiedAgainstConstructor) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
return termVerifiedAgainstConstructors;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function verifyTermAsVariable(termNode, variables, context, verifyAhead) {
|
|
61
|
-
let termVerifiedAsVariable = false;
|
|
62
|
-
|
|
63
|
-
const variableNode = variableNodeQuery(termNode);
|
|
64
|
-
|
|
65
|
-
if (variableNode !== null) {
|
|
66
|
-
const termString = context.nodeAsString(termNode);
|
|
67
|
-
|
|
68
|
-
context.trace(`Verifying the '${termString}' term as a variable...`, termNode);
|
|
69
|
-
|
|
70
|
-
const variablePresent = context.isVariablePresentByVariableNode(variableNode);
|
|
71
|
-
|
|
72
|
-
if (variablePresent) {
|
|
73
|
-
let verifiedAhead;
|
|
74
|
-
|
|
75
|
-
const variable = context.findVariableByVariableNode(variableNode);
|
|
76
|
-
|
|
77
|
-
variables.push(variable);
|
|
78
|
-
|
|
79
|
-
verifiedAhead = verifyAhead();
|
|
80
|
-
|
|
81
|
-
if (!verifiedAhead) {
|
|
82
|
-
variables.pop();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
termVerifiedAsVariable = verifiedAhead; ///
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (termVerifiedAsVariable) {
|
|
89
|
-
context.debug(`...verified the '${termString}' term as a variable.`, termNode);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return termVerifiedAsVariable;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function verifyTermAsStandaloneVariable(termNode, terms, context, verifyAhead) {
|
|
97
|
-
let termVerifiedAsStandaloneVariable;
|
|
42
|
+
function verifyTermAsVariable(termNode, terms, context, verifyAhead) {
|
|
43
|
+
let termVerifiedAsVariable;
|
|
98
44
|
|
|
99
45
|
const termString = context.nodeAsString(termNode);
|
|
100
46
|
|
|
101
|
-
context.trace(`Verifying the '${termString}' term as a
|
|
47
|
+
context.trace(`Verifying the '${termString}' term as a variable...`, termNode);
|
|
102
48
|
|
|
103
49
|
const variables = [],
|
|
104
|
-
|
|
50
|
+
termVerifiedAsGivenVariable = verifyTermAsGivenVariable(termNode, variables, context, () => {
|
|
105
51
|
let verifiedAhead;
|
|
106
52
|
|
|
107
53
|
const firstVariable = first(variables),
|
|
@@ -120,13 +66,29 @@ function verifyTermAsStandaloneVariable(termNode, terms, context, verifyAhead) {
|
|
|
120
66
|
return verifiedAhead;
|
|
121
67
|
});
|
|
122
68
|
|
|
123
|
-
|
|
69
|
+
termVerifiedAsVariable = termVerifiedAsGivenVariable; ///
|
|
124
70
|
|
|
125
|
-
if (
|
|
126
|
-
context.debug(`...verified the '${termString}' term as a
|
|
71
|
+
if (termVerifiedAsVariable) {
|
|
72
|
+
context.debug(`...verified the '${termString}' term as a variable.`, termNode);
|
|
127
73
|
}
|
|
128
74
|
|
|
129
|
-
return
|
|
75
|
+
return termVerifiedAsVariable;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function verifyTermAgainstConstructors(termNode, terms, context, verifyAhead) {
|
|
79
|
+
let termVerifiedAgainstConstructors;
|
|
80
|
+
|
|
81
|
+
const constructors = context.getConstructors();
|
|
82
|
+
|
|
83
|
+
termVerifiedAgainstConstructors = constructors.some((constructor) => {
|
|
84
|
+
const termVerifiedAgainstConstructor = verifyTermAgainstConstructor(termNode, terms, constructor, context, verifyAhead);
|
|
85
|
+
|
|
86
|
+
if (termVerifiedAgainstConstructor) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
return termVerifiedAgainstConstructors;
|
|
130
92
|
}
|
|
131
93
|
|
|
132
94
|
function verifyTermAgainstConstructor(termNode, terms, constructor, context, verifyAhead) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import verifyTerm from "../verify/term";
|
|
4
|
+
import verifyGivenType from "../verify/givenType";
|
|
5
|
+
|
|
6
|
+
export default function verifyTermAndGivenType(termNode, typeNode, terms, types, context, verifyAhead) {
|
|
7
|
+
let termAndGivenTypeVerified;
|
|
8
|
+
|
|
9
|
+
const termString = context.nodeAsString(termNode),
|
|
10
|
+
typeString = context.nodeAsString(typeNode);
|
|
11
|
+
|
|
12
|
+
context.trace(`Verifying the '${termString}' term and the given '${typeString}' type...`, termNode);
|
|
13
|
+
|
|
14
|
+
const termVerified = verifyTerm(termNode, terms, context, () => {
|
|
15
|
+
let verifiedAhead;
|
|
16
|
+
|
|
17
|
+
const givenTypeVerified = verifyGivenType(typeNode, types, context, () => {
|
|
18
|
+
let verifiedAhead;
|
|
19
|
+
|
|
20
|
+
verifiedAhead = verifyAhead();
|
|
21
|
+
|
|
22
|
+
return verifiedAhead;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
verifiedAhead = givenTypeVerified; ///
|
|
26
|
+
|
|
27
|
+
return verifiedAhead;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
termAndGivenTypeVerified = termVerified; ///
|
|
31
|
+
|
|
32
|
+
if (termAndGivenTypeVerified) {
|
|
33
|
+
context.debug(`...verified the '${termString}' term and the given '${typeString}' type.`, termNode);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return termAndGivenTypeVerified
|
|
37
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { nodeQuery } from "../utilities/query";
|
|
4
|
+
|
|
5
|
+
const variableNodeQuery = nodeQuery("/term/variable!");
|
|
6
|
+
|
|
7
|
+
export default function verifyTermAsGivenVariable(termNode, variables, context, verifyAhead) {
|
|
8
|
+
let termVerifiedAsVariable = false;
|
|
9
|
+
|
|
10
|
+
const variableNode = variableNodeQuery(termNode);
|
|
11
|
+
|
|
12
|
+
if (variableNode !== null) {
|
|
13
|
+
const termString = context.nodeAsString(termNode);
|
|
14
|
+
|
|
15
|
+
context.trace(`Verifying the '${termString}' term as a given variable...`, termNode);
|
|
16
|
+
|
|
17
|
+
const variable = context.findVariableByVariableNode(variableNode);
|
|
18
|
+
|
|
19
|
+
if (variable !== null) {
|
|
20
|
+
let verifiedAhead;
|
|
21
|
+
|
|
22
|
+
variables.push(variable);
|
|
23
|
+
|
|
24
|
+
verifiedAhead = verifyAhead();
|
|
25
|
+
|
|
26
|
+
if (!verifiedAhead) {
|
|
27
|
+
variables.pop();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
termVerifiedAsVariable = verifiedAhead; ///
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (termVerifiedAsVariable) {
|
|
34
|
+
context.debug(`...verified the '${termString}' term as a given variable.`, termNode);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return termVerifiedAsVariable;
|
|
39
|
+
}
|