occam-verify-cli 0.0.700 → 0.0.704
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 +2 -2
- package/lib/assignment/metavariable.js +2 -2
- package/lib/assignment/variable.js +2 -2
- package/lib/collection.js +44 -6
- package/lib/conclusion.js +6 -6
- package/lib/consequent.js +4 -4
- package/lib/context/file.js +9 -2
- package/lib/context/local.js +27 -64
- package/lib/context/localMeta.js +8 -1
- package/lib/equality.js +20 -4
- package/lib/premise.js +9 -9
- package/lib/supposition.js +4 -4
- package/lib/utilities/collection.js +27 -13
- package/lib/verifier/node/statementAsCombinator.js +7 -17
- package/lib/verifier/node/termAsConstructor.js +10 -45
- 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/consequent.js +3 -3
- package/lib/verify/derivation.js +28 -6
- package/lib/verify/equality.js +9 -4
- package/lib/verify/givenType.js +32 -0
- package/lib/verify/metastatement.js +7 -25
- package/lib/verify/statement/qualified.js +135 -37
- package/lib/verify/statement.js +44 -33
- package/lib/verify/supposition.js +13 -8
- package/lib/verify/suppositions.js +2 -11
- package/lib/verify/term.js +35 -50
- package/lib/verify/termAndGivenType.js +39 -0
- package/lib/verify/termAsGivenVariable.js +36 -0
- package/lib/verify/type.js +28 -4
- package/lib/verify/typeAssertion.js +35 -22
- package/package.json +1 -1
- package/src/assignment/equality.js +2 -2
- package/src/assignment/metavariable.js +2 -2
- package/src/assignment/variable.js +2 -2
- package/src/collection.js +55 -5
- package/src/conclusion.js +6 -6
- package/src/consequent.js +4 -4
- package/src/context/file.js +7 -1
- package/src/context/local.js +33 -78
- package/src/context/localMeta.js +6 -0
- package/src/equality.js +23 -2
- package/src/premise.js +10 -10
- package/src/supposition.js +3 -3
- package/src/utilities/collection.js +31 -11
- package/src/verifier/node/statementAsCombinator.js +5 -24
- package/src/verifier/node/termAsConstructor.js +6 -47
- 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/consequent.js +4 -4
- package/src/verify/derivation.js +37 -8
- package/src/verify/equality.js +12 -3
- package/src/verify/{standaloneType.js → givenType.js} +7 -7
- package/src/verify/metastatement.js +8 -35
- package/src/verify/statement/qualified.js +194 -39
- package/src/verify/statement.js +65 -44
- package/src/verify/supposition.js +15 -8
- package/src/verify/suppositions.js +1 -13
- package/src/verify/term.js +42 -58
- package/src/verify/termAndGivenType.js +37 -0
- package/src/verify/termAsGivenVariable.js +39 -0
- package/src/verify/type.js +26 -0
- package/src/verify/typeAssertion.js +50 -28
- 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/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,53 @@ function verifyStatement(statementNode, assignments, derived, context, verifyAhe
|
|
|
38
38
|
return statementVerified;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
export default verifyStatement;
|
|
41
|
+
export function verifyStandaloneStatement(statementNode, fileContext, verifyAhead) {
|
|
42
|
+
let standaloneStatementVerified;
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
let statementVerifiedAgainstCombinators;
|
|
44
|
+
const statementString = fileContext.nodeAsString(statementNode);
|
|
49
45
|
|
|
50
|
-
|
|
46
|
+
fileContext.trace(`Verifying the '${statementString}' standalone statement...`, statementNode);
|
|
51
47
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
const context = fileContext, ///
|
|
49
|
+
derived = false,
|
|
50
|
+
assignments = [],
|
|
51
|
+
statementVerified = verifyStatement(statementNode, assignments, derived, context, verifyAhead);
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
const statementVerifiedAgainstCombinator = verifyStatementAgainstCombinator(statementNode, combinator, context, verifyAhead);
|
|
53
|
+
standaloneStatementVerified = statementVerified; ///
|
|
59
54
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
55
|
+
if (standaloneStatementVerified) {
|
|
56
|
+
fileContext.debug(`...verified the '${statementString}' standalone statement.`, statementNode);
|
|
57
|
+
}
|
|
64
58
|
|
|
65
|
-
return
|
|
59
|
+
return standaloneStatementVerified;
|
|
66
60
|
}
|
|
67
61
|
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
Object.assign(statementNodesVerifier, {
|
|
63
|
+
verifyStatement
|
|
64
|
+
});
|
|
70
65
|
|
|
71
|
-
|
|
72
|
-
combinatorString = combinator.getString();
|
|
66
|
+
export default verifyStatement;
|
|
73
67
|
|
|
74
|
-
|
|
68
|
+
function verifyStatementAsEquality(statementNode, assignments, derived, context, verifyAhead) {
|
|
69
|
+
let statementVerifiedAsEquality = false;
|
|
75
70
|
|
|
76
|
-
const
|
|
77
|
-
nonTerminalNodeA = statementNode, ///
|
|
78
|
-
nonTerminalNodeB = combinatorStatementNode, ///
|
|
79
|
-
nonTerminalNodeVerified = statementNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, context, verifyAhead);
|
|
71
|
+
const equalityNode = equalityNodeQuery(statementNode);
|
|
80
72
|
|
|
81
|
-
|
|
73
|
+
if (equalityNode !== null) {
|
|
74
|
+
const statementString = context.nodeAsString(statementNode);
|
|
82
75
|
|
|
83
|
-
|
|
84
|
-
|
|
76
|
+
context.trace(`Verifying the '${statementString}' statement as an equality...`, statementNode);
|
|
77
|
+
|
|
78
|
+
const equalityVerified = verifyEquality(equalityNode, assignments, derived, context, verifyAhead);
|
|
79
|
+
|
|
80
|
+
statementVerifiedAsEquality = equalityVerified; ///
|
|
81
|
+
|
|
82
|
+
if (statementVerifiedAsEquality) {
|
|
83
|
+
context.debug(`...verified the '${statementString}' statement as an equality.`, statementNode);
|
|
84
|
+
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
return
|
|
87
|
+
return statementVerifiedAsEquality;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
function verifyStatementAsTypeAssertion(statementNode, assignments, derived, context, verifyAhead) {
|
|
@@ -109,24 +109,45 @@ function verifyStatementAsTypeAssertion(statementNode, assignments, derived, con
|
|
|
109
109
|
return statementVerifiedAsTypeAssertion;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
function
|
|
113
|
-
let
|
|
112
|
+
function verifyStatementAgainstCombinators(statementNode, assignments, derived, context, verifyAhead) {
|
|
113
|
+
let statementVerifiedAgainstCombinators;
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
let combinators = context.getCombinators();
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
combinators = [ ///
|
|
118
|
+
bracketedCombinator,
|
|
119
|
+
...combinators
|
|
120
|
+
];
|
|
119
121
|
|
|
120
|
-
|
|
122
|
+
statementVerifiedAgainstCombinators = combinators.some((combinator) => {
|
|
123
|
+
const statementVerifiedAgainstCombinator = verifyStatementAgainstCombinator(statementNode, combinator, context, verifyAhead);
|
|
121
124
|
|
|
122
|
-
|
|
125
|
+
if (statementVerifiedAgainstCombinator) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
123
129
|
|
|
124
|
-
|
|
130
|
+
return statementVerifiedAgainstCombinators;
|
|
131
|
+
}
|
|
125
132
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
function verifyStatementAgainstCombinator(statementNode, combinator, context, verifyAhead) {
|
|
134
|
+
let statementVerifiedAgainstCombinator;
|
|
135
|
+
|
|
136
|
+
const statementString = context.nodeAsString(statementNode),
|
|
137
|
+
combinatorString = combinator.getString();
|
|
138
|
+
|
|
139
|
+
context.trace(`Verifying the '${statementString}' statement against the '${combinatorString}' combinator...`, statementNode);
|
|
140
|
+
|
|
141
|
+
const combinatorStatementNode = combinator.getStatementNode(),
|
|
142
|
+
nonTerminalNodeA = statementNode, ///
|
|
143
|
+
nonTerminalNodeB = combinatorStatementNode, ///
|
|
144
|
+
nonTerminalNodeVerified = statementNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, context, verifyAhead);
|
|
145
|
+
|
|
146
|
+
statementVerifiedAgainstCombinator = nonTerminalNodeVerified; ///
|
|
147
|
+
|
|
148
|
+
if (statementVerifiedAgainstCombinator) {
|
|
149
|
+
context.debug(`...verified the '${statementString}' statement against the '${combinatorString}' combinator.`, statementNode);
|
|
129
150
|
}
|
|
130
151
|
|
|
131
|
-
return
|
|
152
|
+
return statementVerifiedAgainstCombinator;
|
|
132
153
|
}
|
|
@@ -9,30 +9,37 @@ import { nodeQuery } from "../utilities/query";
|
|
|
9
9
|
const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
|
|
10
10
|
unqualifiedStatementNodeQuery = nodeQuery("/supposition/unqualifiedStatement!");
|
|
11
11
|
|
|
12
|
-
export default function verifySupposition(suppositionNode, suppositions,
|
|
13
|
-
let suppositionVerified;
|
|
12
|
+
export default function verifySupposition(suppositionNode, suppositions, localContext) {
|
|
13
|
+
let suppositionVerified = false;
|
|
14
14
|
|
|
15
15
|
const suppositionString = localContext.nodeAsString(suppositionNode);
|
|
16
16
|
|
|
17
17
|
localContext.trace(`Verifying the '${suppositionString}' supposition...`, suppositionNode);
|
|
18
18
|
|
|
19
19
|
const derived = false,
|
|
20
|
+
assignments = [],
|
|
20
21
|
unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
|
|
21
22
|
unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, assignments, derived, localContext);
|
|
22
23
|
|
|
23
24
|
if (unqualifiedStatementVerified) {
|
|
25
|
+
suppositionVerified = assignments.every((assignment) => { ///
|
|
26
|
+
const assigned = assignment.assign(localContext);
|
|
27
|
+
|
|
28
|
+
if (assigned) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (suppositionVerified) {
|
|
24
35
|
const statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
25
|
-
|
|
26
|
-
|
|
36
|
+
supposition = Supposition.fromStatementNode(statementNode),
|
|
37
|
+
proofStep = ProofStep.fromStatementNode(statementNode);
|
|
27
38
|
|
|
28
39
|
suppositions.push(supposition);
|
|
29
40
|
|
|
30
41
|
localContext.addProofStep(proofStep);
|
|
31
42
|
|
|
32
|
-
suppositionVerified = true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (suppositionVerified) {
|
|
36
43
|
localContext.debug(`...verified the '${suppositionString}' supposition.`, suppositionNode);
|
|
37
44
|
}
|
|
38
45
|
|
|
@@ -5,25 +5,13 @@ import verifySupposition from "../verify/supposition";
|
|
|
5
5
|
export default function verifySuppositions(suppositionNodes, suppositions, localContext) {
|
|
6
6
|
let suppositionsVerified;
|
|
7
7
|
|
|
8
|
-
const assignments = [];
|
|
9
|
-
|
|
10
8
|
suppositionsVerified = suppositionNodes.every((suppositionNode) => {
|
|
11
|
-
const suppositionVerified = verifySupposition(suppositionNode, suppositions,
|
|
9
|
+
const suppositionVerified = verifySupposition(suppositionNode, suppositions, localContext);
|
|
12
10
|
|
|
13
11
|
if (suppositionVerified) {
|
|
14
12
|
return true;
|
|
15
13
|
}
|
|
16
14
|
});
|
|
17
15
|
|
|
18
|
-
if (suppositionsVerified) {
|
|
19
|
-
suppositionsVerified = assignments.every((assignment) => { ///
|
|
20
|
-
const assigned = assignment.assign(localContext);
|
|
21
|
-
|
|
22
|
-
if (assigned) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
16
|
return suppositionsVerified;
|
|
29
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
|
|
|
@@ -35,71 +33,41 @@ function verifyTerm(termNode, terms, context, verifyAhead) {
|
|
|
35
33
|
return termVerified;
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
36
|
+
export function verifyStandaloneTerm(termNode, fileContext, verifyAhead) {
|
|
37
|
+
let standaloneTermVerified;
|
|
41
38
|
|
|
42
|
-
|
|
39
|
+
const termString = fileContext.nodeAsString(termNode);
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
let termVerifiedAgainstConstructors;
|
|
41
|
+
fileContext.trace(`Verifying the '${termString}' standalone term...`, termNode);
|
|
46
42
|
|
|
47
|
-
const
|
|
43
|
+
const terms = [],
|
|
44
|
+
context = fileContext, ///
|
|
45
|
+
termVerified = verifyTerm(termNode, terms, context, verifyAhead);
|
|
48
46
|
|
|
49
|
-
|
|
50
|
-
const termVerifiedAgainstConstructor = verifyTermAgainstConstructor(termNode, terms, constructor, context, verifyAhead);
|
|
47
|
+
standaloneTermVerified = termVerified; ///
|
|
51
48
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
49
|
+
if (standaloneTermVerified) {
|
|
50
|
+
fileContext.debug(`...verified the '${termString}' standalone term.`, termNode);
|
|
51
|
+
}
|
|
56
52
|
|
|
57
|
-
return
|
|
53
|
+
return standaloneTermVerified;
|
|
58
54
|
}
|
|
59
55
|
|
|
60
|
-
|
|
61
|
-
|
|
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 variable = context.findVariableByVariableNode(variableNode);
|
|
71
|
-
|
|
72
|
-
if (variable !== null) {
|
|
73
|
-
let verifiedAhead;
|
|
74
|
-
|
|
75
|
-
variables.push(variable);
|
|
76
|
-
|
|
77
|
-
verifiedAhead = verifyAhead();
|
|
78
|
-
|
|
79
|
-
if (!verifiedAhead) {
|
|
80
|
-
variables.pop();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
termVerifiedAsVariable = verifiedAhead; ///
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (termVerifiedAsVariable) {
|
|
87
|
-
context.debug(`...verified the '${termString}' term as a variable.`, termNode);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
56
|
+
Object.assign(termNodesVerifier, {
|
|
57
|
+
verifyTerm
|
|
58
|
+
});
|
|
90
59
|
|
|
91
|
-
|
|
92
|
-
}
|
|
60
|
+
export default verifyTerm;
|
|
93
61
|
|
|
94
|
-
function
|
|
95
|
-
let
|
|
62
|
+
function verifyTermAsVariable(termNode, terms, context, verifyAhead) {
|
|
63
|
+
let termVerifiedAsVariable;
|
|
96
64
|
|
|
97
65
|
const termString = context.nodeAsString(termNode);
|
|
98
66
|
|
|
99
|
-
context.trace(`Verifying the '${termString}' term as a
|
|
67
|
+
context.trace(`Verifying the '${termString}' term as a variable...`, termNode);
|
|
100
68
|
|
|
101
69
|
const variables = [],
|
|
102
|
-
|
|
70
|
+
termVerifiedAsGivenVariable = verifyTermAsGivenVariable(termNode, variables, context, () => {
|
|
103
71
|
let verifiedAhead;
|
|
104
72
|
|
|
105
73
|
const firstVariable = first(variables),
|
|
@@ -118,13 +86,29 @@ function verifyTermAsStandaloneVariable(termNode, terms, context, verifyAhead) {
|
|
|
118
86
|
return verifiedAhead;
|
|
119
87
|
});
|
|
120
88
|
|
|
121
|
-
|
|
89
|
+
termVerifiedAsVariable = termVerifiedAsGivenVariable; ///
|
|
122
90
|
|
|
123
|
-
if (
|
|
124
|
-
context.debug(`...verified the '${termString}' term as a
|
|
91
|
+
if (termVerifiedAsVariable) {
|
|
92
|
+
context.debug(`...verified the '${termString}' term as a variable.`, termNode);
|
|
125
93
|
}
|
|
126
94
|
|
|
127
|
-
return
|
|
95
|
+
return termVerifiedAsVariable;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function verifyTermAgainstConstructors(termNode, terms, context, verifyAhead) {
|
|
99
|
+
let termVerifiedAgainstConstructors;
|
|
100
|
+
|
|
101
|
+
const constructors = context.getConstructors();
|
|
102
|
+
|
|
103
|
+
termVerifiedAgainstConstructors = constructors.some((constructor) => {
|
|
104
|
+
const termVerifiedAgainstConstructor = verifyTermAgainstConstructor(termNode, terms, constructor, context, verifyAhead);
|
|
105
|
+
|
|
106
|
+
if (termVerifiedAgainstConstructor) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return termVerifiedAgainstConstructors;
|
|
128
112
|
}
|
|
129
113
|
|
|
130
114
|
function verifyTermAgainstConstructor(termNode, terms, constructor, context, verifyAhead) {
|