occam-verify-cli 1.0.708 → 1.0.714
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/element/assertion/property.js +8 -5
- package/lib/element/assertion/satisfies.js +13 -12
- package/lib/element/assumption.js +3 -3
- package/lib/element/combinator.js +20 -20
- package/lib/element/conclusion.js +8 -8
- package/lib/element/constructor.js +21 -21
- package/lib/element/declaration/combinator.js +10 -10
- package/lib/element/declaration/constructor.js +10 -10
- package/lib/element/deduction.js +10 -10
- package/lib/element/frame.js +19 -7
- package/lib/element/metavariable.js +1 -1
- package/lib/element/proofAssertion/premise.js +29 -24
- package/lib/element/proofAssertion/step.js +15 -14
- package/lib/element/proofAssertion/supposition.js +30 -25
- package/lib/element/reference.js +4 -7
- package/lib/element/rule.js +2 -2
- package/lib/element/signature.js +7 -7
- package/lib/element/statement.js +5 -3
- package/lib/element/subproof.js +2 -2
- package/lib/element/term.js +8 -9
- package/lib/element/topLevelAssertion/axiom.js +19 -19
- package/lib/pass/zip.js +23 -0
- package/lib/process/unify.js +11 -21
- package/lib/process/validate.js +116 -2
- package/lib/process/verify.js +6 -125
- package/lib/utilities/context.js +1 -9
- package/lib/utilities/unification.js +2 -11
- package/lib/utilities/validation.js +6 -6
- package/package.json +1 -1
- package/src/element/assertion/property.js +8 -4
- package/src/element/assertion/satisfies.js +10 -10
- package/src/element/assumption.js +2 -2
- package/src/element/combinator.js +19 -19
- package/src/element/conclusion.js +8 -8
- package/src/element/constructor.js +21 -20
- package/src/element/declaration/combinator.js +9 -9
- package/src/element/declaration/constructor.js +9 -9
- package/src/element/deduction.js +10 -10
- package/src/element/frame.js +26 -7
- package/src/element/metavariable.js +0 -1
- package/src/element/proofAssertion/premise.js +43 -33
- package/src/element/proofAssertion/step.js +17 -16
- package/src/element/proofAssertion/supposition.js +44 -34
- package/src/element/reference.js +6 -11
- package/src/element/rule.js +1 -1
- package/src/element/signature.js +6 -6
- package/src/element/statement.js +4 -2
- package/src/element/subproof.js +1 -2
- package/src/element/term.js +9 -10
- package/src/element/topLevelAssertion/axiom.js +18 -18
- package/src/pass/zip.js +19 -0
- package/src/process/unify.js +4 -34
- package/src/process/validate.js +161 -1
- package/src/process/verify.js +2 -166
- package/src/utilities/context.js +0 -9
- package/src/utilities/unification.js +1 -15
- package/src/utilities/validation.js +5 -5
|
@@ -19,7 +19,7 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
19
19
|
return satisfiable;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
compareSignature(signature,
|
|
22
|
+
compareSignature(signature, context) {
|
|
23
23
|
let comparesToSignature = false;
|
|
24
24
|
|
|
25
25
|
const satisfiable = this.isSatisfiable();
|
|
@@ -36,7 +36,7 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
36
36
|
|
|
37
37
|
const generalContext = context; ///
|
|
38
38
|
|
|
39
|
-
comparesToSignature = signatureA.compare(signatureB,
|
|
39
|
+
comparesToSignature = signatureA.compare(signatureB, generalContext, specificContext);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
return comparesToSignature;
|
|
@@ -87,7 +87,7 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
87
87
|
return signatureVerifies;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
unifyStep(step,
|
|
90
|
+
unifyStep(step, context) {
|
|
91
91
|
let stepUnifies = false;
|
|
92
92
|
|
|
93
93
|
context = step.getContext();
|
|
@@ -103,7 +103,7 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
103
103
|
context.trace(`Unable to unify the '${stepString}' step with the '${axiomString}' axiom because the axiom is not unconditional.`);
|
|
104
104
|
} else {
|
|
105
105
|
const statement = step.getStatement(),
|
|
106
|
-
statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement,
|
|
106
|
+
statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, context);
|
|
107
107
|
|
|
108
108
|
if (statementUnifiesWithDeduction) {
|
|
109
109
|
stepUnifies = true;
|
|
@@ -117,7 +117,7 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
117
117
|
return stepUnifies;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
unifySubproof(subproof,
|
|
120
|
+
unifySubproof(subproof, context) {
|
|
121
121
|
let subproofUnifies = false;
|
|
122
122
|
|
|
123
123
|
const axiomString = this.getString(),
|
|
@@ -131,11 +131,11 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
131
131
|
context.trace(`Unable to unify the '${subproofString}' subproof with the '${axiomString}' axiom because the axiom is unconditional.`);
|
|
132
132
|
} else {
|
|
133
133
|
const lastProofAssertion = subproof.getLastProofAssertion(),
|
|
134
|
-
lastProofAssertionUnifies = this.unifyLastProofAssertion(lastProofAssertion,
|
|
134
|
+
lastProofAssertionUnifies = this.unifyLastProofAssertion(lastProofAssertion, context);
|
|
135
135
|
|
|
136
136
|
if (lastProofAssertionUnifies) {
|
|
137
137
|
const suppositions = subproof.getSuppositions(),
|
|
138
|
-
suppositionsUnify = this.unifySuppositions(suppositions,
|
|
138
|
+
suppositionsUnify = this.unifySuppositions(suppositions, context);
|
|
139
139
|
|
|
140
140
|
if (suppositionsUnify) {
|
|
141
141
|
subproofUnifies = true;
|
|
@@ -150,7 +150,7 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
150
150
|
return subproofUnifies;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
unifyDeduction(deduction,
|
|
153
|
+
unifyDeduction(deduction, generalContext, specificContext) {
|
|
154
154
|
let deductionUnifies;
|
|
155
155
|
|
|
156
156
|
const specificDeduction = deduction; ///
|
|
@@ -161,12 +161,12 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
161
161
|
|
|
162
162
|
deduction = specificDeduction; ///
|
|
163
163
|
|
|
164
|
-
deductionUnifies = generalDeduction.unifyDeduction(deduction,
|
|
164
|
+
deductionUnifies = generalDeduction.unifyDeduction(deduction, generalContext, specificContext);
|
|
165
165
|
|
|
166
166
|
return deductionUnifies;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
unifySupposition(supposition, index,
|
|
169
|
+
unifySupposition(supposition, index, generalContext, specificContext) {
|
|
170
170
|
let suppositionUnifies;
|
|
171
171
|
|
|
172
172
|
const specificSupposition = supposition; ///
|
|
@@ -177,12 +177,12 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
177
177
|
|
|
178
178
|
supposition = specificSupposition; ///
|
|
179
179
|
|
|
180
|
-
suppositionUnifies = generalSupposition.unifySupposition(supposition,
|
|
180
|
+
suppositionUnifies = generalSupposition.unifySupposition(supposition, generalContext, specificContext);
|
|
181
181
|
|
|
182
182
|
return suppositionUnifies;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
unifySuppositions(suppositions,
|
|
185
|
+
unifySuppositions(suppositions, generalContext, specificContext) {
|
|
186
186
|
let suppositionsUnify = false;
|
|
187
187
|
|
|
188
188
|
const specificSuppositions = suppositions; ///
|
|
@@ -197,7 +197,7 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
197
197
|
suppositions = specificSuppositions; ///
|
|
198
198
|
|
|
199
199
|
suppositionsUnify = suppositions.every((supposition, index) => {
|
|
200
|
-
const suppositionUnifies = this.unifySupposition(supposition, index,
|
|
200
|
+
const suppositionUnifies = this.unifySupposition(supposition, index, generalContext, specificContext);
|
|
201
201
|
|
|
202
202
|
if (suppositionUnifies) {
|
|
203
203
|
return true;
|
|
@@ -208,7 +208,7 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
208
208
|
return suppositionsUnify;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
unifyLastProofAssertion(lastProofAssertion,
|
|
211
|
+
unifyLastProofAssertion(lastProofAssertion, context) {
|
|
212
212
|
let lastProofAssertionUnifies = false;
|
|
213
213
|
|
|
214
214
|
const axiomString = this.getString(),
|
|
@@ -217,7 +217,7 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
217
217
|
context.trace(`Unifying the '${lastProofAssertionString}' last proof assertion with the '${axiomString}' axiom...`)
|
|
218
218
|
|
|
219
219
|
const statement = lastProofAssertion.getStatement(),
|
|
220
|
-
statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement,
|
|
220
|
+
statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, context);
|
|
221
221
|
|
|
222
222
|
if (statementUnifiesWithDeduction) {
|
|
223
223
|
lastProofAssertionUnifies = true;
|
|
@@ -230,7 +230,7 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
230
230
|
return lastProofAssertionUnifies;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
unifyTopLevelAssertion(topLevelAssertion,
|
|
233
|
+
unifyTopLevelAssertion(topLevelAssertion, context) {
|
|
234
234
|
let topLevelAssertionUnifies = false;
|
|
235
235
|
|
|
236
236
|
const axiomString = this.getString(),
|
|
@@ -250,11 +250,11 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
250
250
|
context = specificContext; ///
|
|
251
251
|
|
|
252
252
|
const deduction = topLevelAssertion.getDeduction(),
|
|
253
|
-
deductionUnifies = this.unifyDeduction(deduction,
|
|
253
|
+
deductionUnifies = this.unifyDeduction(deduction, generalContext, specificContext);
|
|
254
254
|
|
|
255
255
|
if (deductionUnifies) {
|
|
256
256
|
const suppositions = topLevelAssertion.getSuppositions(),
|
|
257
|
-
suppositionsUnify = this.unifySuppositions(suppositions,
|
|
257
|
+
suppositionsUnify = this.unifySuppositions(suppositions, generalContext, specificContext);
|
|
258
258
|
|
|
259
259
|
topLevelAssertionUnifies = suppositionsUnify; ///
|
|
260
260
|
}
|
package/src/pass/zip.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { ZipPass as ZipPassBase } from "occam-languages";
|
|
4
|
+
|
|
5
|
+
export default class ZipPass extends ZipPassBase {
|
|
6
|
+
run(generalNonTerminalNode, specificNonTerminalNode, ...remainingArguments) {
|
|
7
|
+
let success = false;
|
|
8
|
+
|
|
9
|
+
const specificChildNodes = specificNonTerminalNode.getChildNodes(), ///
|
|
10
|
+
generalChildNodes = generalNonTerminalNode.getChildNodes(), ///
|
|
11
|
+
descended = this.descend(generalChildNodes, specificChildNodes, ...remainingArguments);
|
|
12
|
+
|
|
13
|
+
if (descended) {
|
|
14
|
+
success = true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return success;
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/process/unify.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { queryUtilities, ZipPass as ZipPassBase } from "occam-languages";
|
|
4
|
+
|
|
5
|
+
import ZipPass from "../pass/zip";
|
|
4
6
|
|
|
5
7
|
import { termFromTermNode, frameFromFrameNode, statementFromStatementNode } from "../utilities/element";
|
|
6
8
|
|
|
@@ -16,7 +18,7 @@ const typeNodeQuery = nodeQuery("/type"),
|
|
|
16
18
|
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!"),
|
|
17
19
|
assumptionMetavariableNodeQuery = nodeQuery("/assumption/metavariable!");
|
|
18
20
|
|
|
19
|
-
class MetaLevelPass extends
|
|
21
|
+
class MetaLevelPass extends ZipPassBase {
|
|
20
22
|
static maps = [
|
|
21
23
|
{
|
|
22
24
|
generalNodeQuery: assumptionMetavariableNodeQuery,
|
|
@@ -145,22 +147,6 @@ class MetaLevelPass extends ZipPass {
|
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
class CombinatorPass extends ZipPass {
|
|
148
|
-
run(combinatorStatementNode, statementNode, stated, generalContext, specificContext) {
|
|
149
|
-
let success = false;
|
|
150
|
-
|
|
151
|
-
const specificnonTerminalNode = statementNode, ///
|
|
152
|
-
generalcnonTerminalNode = combinatorStatementNode, ///
|
|
153
|
-
specificChildNodes = specificnonTerminalNode.getChildNodes(), ///
|
|
154
|
-
generalcChildNodes = generalcnonTerminalNode.getChildNodes(), ///
|
|
155
|
-
descended = this.descend(generalcChildNodes, specificChildNodes, stated, generalContext, specificContext);
|
|
156
|
-
|
|
157
|
-
if (descended) {
|
|
158
|
-
success = true;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return success;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
150
|
static maps = [
|
|
165
151
|
{
|
|
166
152
|
generalNodeQuery: metaTypeNodeQuery,
|
|
@@ -250,22 +236,6 @@ class CombinatorPass extends ZipPass {
|
|
|
250
236
|
}
|
|
251
237
|
|
|
252
238
|
class ConstructorPass extends ZipPass {
|
|
253
|
-
run(constructorTermNode, termNode, generalContext, specificContext) {
|
|
254
|
-
let success = false;
|
|
255
|
-
|
|
256
|
-
const specificnonTerminalNode = termNode, ///
|
|
257
|
-
generalcnonTerminalNode = constructorTermNode, ///
|
|
258
|
-
specificChildNodes = specificnonTerminalNode.getChildNodes(), ///
|
|
259
|
-
generalcChildNodes = generalcnonTerminalNode.getChildNodes(), ///
|
|
260
|
-
descended = this.descend(generalcChildNodes, specificChildNodes, generalContext, specificContext);
|
|
261
|
-
|
|
262
|
-
if (descended) {
|
|
263
|
-
success = true;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
return success;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
239
|
static maps = [
|
|
270
240
|
{
|
|
271
241
|
generalNodeQuery: typeNodeQuery,
|
package/src/process/validate.js
CHANGED
|
@@ -149,8 +149,142 @@ class StatementPass extends SimplePass {
|
|
|
149
149
|
];
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
class ConbinatorPass extends SimplePass {
|
|
153
|
+
run(statementNode, context) {
|
|
154
|
+
let success = false;
|
|
155
|
+
|
|
156
|
+
const nonTerminalNode = statementNode, ///
|
|
157
|
+
childNodes = nonTerminalNode.getChildNodes(), ///
|
|
158
|
+
descended = this.descend(childNodes, context);
|
|
159
|
+
|
|
160
|
+
if (descended) {
|
|
161
|
+
success = true;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return success;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
static maps = [
|
|
168
|
+
{
|
|
169
|
+
nodeQuery: statementNodeQuery,
|
|
170
|
+
run: (statementNode, context) => {
|
|
171
|
+
let success = false;
|
|
172
|
+
|
|
173
|
+
let statement;
|
|
174
|
+
|
|
175
|
+
const stated = true;
|
|
176
|
+
|
|
177
|
+
statement = statementFromStatementNode(statementNode, context);
|
|
178
|
+
|
|
179
|
+
statement = statement.validate(stated, context);
|
|
180
|
+
|
|
181
|
+
if (statement !== null) {
|
|
182
|
+
success = true;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return success;
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
nodeQuery: termNodeQuery,
|
|
190
|
+
run: (termNode, context) => {
|
|
191
|
+
let success = false;
|
|
192
|
+
|
|
193
|
+
let term;
|
|
194
|
+
|
|
195
|
+
term = termFromTermNode(termNode, context);
|
|
196
|
+
|
|
197
|
+
term = term.validate(context, () => { ///
|
|
198
|
+
const validatesForwards = true;
|
|
199
|
+
|
|
200
|
+
return validatesForwards;
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
if (term !== null) {
|
|
204
|
+
success = true;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return success;
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
nodeQuery: typeNodeQuery,
|
|
212
|
+
run: (typeNode, context) => {
|
|
213
|
+
let success = false;
|
|
214
|
+
|
|
215
|
+
const nominalTypeName = typeNode.getNominalTypeName(),
|
|
216
|
+
typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
|
|
217
|
+
|
|
218
|
+
if (typePresent) {
|
|
219
|
+
success = true;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return success;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
class ConstructorPass extends SimplePass {
|
|
229
|
+
run(termNode, context) {
|
|
230
|
+
let success = false;
|
|
231
|
+
|
|
232
|
+
const nonTerminalNode = termNode, ///
|
|
233
|
+
childNodes = nonTerminalNode.getChildNodes(), ///
|
|
234
|
+
descended = this.descend(childNodes, context);
|
|
235
|
+
|
|
236
|
+
if (descended) {
|
|
237
|
+
success = true;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return success;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
static maps = [
|
|
244
|
+
{
|
|
245
|
+
nodeQuery: termNodeQuery,
|
|
246
|
+
run: (termNode, context) => {
|
|
247
|
+
let success = false;
|
|
248
|
+
|
|
249
|
+
let term;
|
|
250
|
+
|
|
251
|
+
term = termFromTermNode(termNode, context);
|
|
252
|
+
|
|
253
|
+
term = term.validate(context, () => { ///
|
|
254
|
+
const validatesForwards = true;
|
|
255
|
+
|
|
256
|
+
return validatesForwards;
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
if (term !== null) {
|
|
260
|
+
success = true;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return success;
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
nodeQuery: typeNodeQuery,
|
|
268
|
+
run: (typeNode, context) => {
|
|
269
|
+
let success = false;
|
|
270
|
+
|
|
271
|
+
const nominalTypeName = typeNode.getNominalTypeName(),
|
|
272
|
+
typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
|
|
273
|
+
|
|
274
|
+
if (typePresent) {
|
|
275
|
+
success = true;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return success;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
];
|
|
282
|
+
}
|
|
283
|
+
|
|
152
284
|
const termPass = new TermPass(),
|
|
153
|
-
statementPass = new StatementPass()
|
|
285
|
+
statementPass = new StatementPass(),
|
|
286
|
+
combinatorPass = new ConbinatorPass(),
|
|
287
|
+
constructorPass = new ConstructorPass();
|
|
154
288
|
|
|
155
289
|
export function validateTerm(termNode, context, validateForwards) {
|
|
156
290
|
let termValidates = false;
|
|
@@ -177,3 +311,29 @@ export function validateStatement(statementNode, context) {
|
|
|
177
311
|
|
|
178
312
|
return statementValidates;
|
|
179
313
|
}
|
|
314
|
+
|
|
315
|
+
export function validateTermAsConstructor(term, context) {
|
|
316
|
+
let termValidatesAsConstructor = false;
|
|
317
|
+
|
|
318
|
+
const termNode = term.getNode(),
|
|
319
|
+
success = constructorPass.run(termNode, context);
|
|
320
|
+
|
|
321
|
+
if (success) {
|
|
322
|
+
termValidatesAsConstructor = true;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return termValidatesAsConstructor;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export function validateStatementAsCombinator(statement, context) {
|
|
329
|
+
let statementValidatesAsCombinator = false;
|
|
330
|
+
|
|
331
|
+
const statementNode = statement.getNode(),
|
|
332
|
+
success = combinatorPass.run(statementNode, context);
|
|
333
|
+
|
|
334
|
+
if (success) {
|
|
335
|
+
statementValidatesAsCombinator = true;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return statementValidatesAsCombinator;
|
|
339
|
+
}
|
package/src/process/verify.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { AsyncPass,
|
|
3
|
+
import { AsyncPass, queryUtilities } from "occam-languages"
|
|
4
4
|
|
|
5
|
-
import { termFromTermNode, statementFromStatementNode } from "../utilities/element";
|
|
6
5
|
import { ruleFromRuleNode,
|
|
7
6
|
errorFromErrorNode,
|
|
8
7
|
axiomFromAxiomNode,
|
|
@@ -23,15 +22,12 @@ import { ruleFromRuleNode,
|
|
|
23
22
|
const { nodeQuery } = queryUtilities;
|
|
24
23
|
|
|
25
24
|
const ruleNodeQuery = nodeQuery("/rule"),
|
|
26
|
-
termNodeQuery = nodeQuery("/term"),
|
|
27
|
-
typeNodeQuery = nodeQuery("/type"),
|
|
28
25
|
errorNodeQuery = nodeQuery("/error"),
|
|
29
26
|
axiomNodeQuery = nodeQuery("/axiom"),
|
|
30
27
|
lemmaNodeQuery = nodeQuery("/lemma"),
|
|
31
28
|
sectionNodeQuery = nodeQuery("/section"),
|
|
32
29
|
theoremNodeQuery = nodeQuery("/theorem"),
|
|
33
30
|
metaLemmaNodeQuery = nodeQuery("/metaLemma"),
|
|
34
|
-
statementNodeQuery = nodeQuery("/statement"),
|
|
35
31
|
conjectureNodeQuery = nodeQuery("/conjecture"),
|
|
36
32
|
metatheoremNodeQuery = nodeQuery("/metatheorem"),
|
|
37
33
|
variableDeclarationNodeQuery = nodeQuery("/variableDeclaration"),
|
|
@@ -287,141 +283,7 @@ class TopLevelPass extends AsyncPass {
|
|
|
287
283
|
];
|
|
288
284
|
}
|
|
289
285
|
|
|
290
|
-
|
|
291
|
-
run(statementNode, context) {
|
|
292
|
-
let success = false;
|
|
293
|
-
|
|
294
|
-
const nonTerminalNode = statementNode, ///
|
|
295
|
-
childNodes = nonTerminalNode.getChildNodes(), ///
|
|
296
|
-
descended = this.descend(childNodes, context);
|
|
297
|
-
|
|
298
|
-
if (descended) {
|
|
299
|
-
success = true;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
return success;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
static maps = [
|
|
306
|
-
{
|
|
307
|
-
nodeQuery: statementNodeQuery,
|
|
308
|
-
run: (statementNode, context) => {
|
|
309
|
-
let success = false;
|
|
310
|
-
|
|
311
|
-
let statement;
|
|
312
|
-
|
|
313
|
-
const stated = true;
|
|
314
|
-
|
|
315
|
-
statement = statementFromStatementNode(statementNode, context);
|
|
316
|
-
|
|
317
|
-
statement = statement.validate(stated, context);
|
|
318
|
-
|
|
319
|
-
if (statement !== null) {
|
|
320
|
-
success = true;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
return success;
|
|
324
|
-
}
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
nodeQuery: termNodeQuery,
|
|
328
|
-
run: (termNode, context) => {
|
|
329
|
-
let success = false;
|
|
330
|
-
|
|
331
|
-
let term;
|
|
332
|
-
|
|
333
|
-
term = termFromTermNode(termNode, context);
|
|
334
|
-
|
|
335
|
-
term = term.validate(context, () => { ///
|
|
336
|
-
const validatesForwards = true;
|
|
337
|
-
|
|
338
|
-
return validatesForwards;
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
if (term !== null) {
|
|
342
|
-
success = true;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
return success;
|
|
346
|
-
}
|
|
347
|
-
},
|
|
348
|
-
{
|
|
349
|
-
nodeQuery: typeNodeQuery,
|
|
350
|
-
run: (typeNode, context) => {
|
|
351
|
-
let success = false;
|
|
352
|
-
|
|
353
|
-
const nominalTypeName = typeNode.getNominalTypeName(),
|
|
354
|
-
typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
|
|
355
|
-
|
|
356
|
-
if (typePresent) {
|
|
357
|
-
success = true;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
return success;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
];
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
class ConstructorPass extends SimplePass {
|
|
367
|
-
run(termNode, context) {
|
|
368
|
-
let success = false;
|
|
369
|
-
|
|
370
|
-
const nonTerminalNode = termNode, ///
|
|
371
|
-
childNodes = nonTerminalNode.getChildNodes(), ///
|
|
372
|
-
descended = this.descend(childNodes, context);
|
|
373
|
-
|
|
374
|
-
if (descended) {
|
|
375
|
-
success = true;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
return success;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
static maps = [
|
|
382
|
-
{
|
|
383
|
-
nodeQuery: termNodeQuery,
|
|
384
|
-
run: (termNode, context) => {
|
|
385
|
-
let success = false;
|
|
386
|
-
|
|
387
|
-
let term;
|
|
388
|
-
|
|
389
|
-
term = termFromTermNode(termNode, context);
|
|
390
|
-
|
|
391
|
-
term = term.validate(context, () => { ///
|
|
392
|
-
const validatesForwards = true;
|
|
393
|
-
|
|
394
|
-
return validatesForwards;
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
if (term !== null) {
|
|
398
|
-
success = true;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
return success;
|
|
402
|
-
}
|
|
403
|
-
},
|
|
404
|
-
{
|
|
405
|
-
nodeQuery: typeNodeQuery,
|
|
406
|
-
run: (typeNode, context) => {
|
|
407
|
-
let success = false;
|
|
408
|
-
|
|
409
|
-
const nominalTypeName = typeNode.getNominalTypeName(),
|
|
410
|
-
typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
|
|
411
|
-
|
|
412
|
-
if (typePresent) {
|
|
413
|
-
success = true;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
return success;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
];
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
const topLevelPass = new TopLevelPass(),
|
|
423
|
-
combinatorPass = new ConbinatorPass(),
|
|
424
|
-
constructorPass = new ConstructorPass();
|
|
286
|
+
const topLevelPass = new TopLevelPass();
|
|
425
287
|
|
|
426
288
|
export async function verifyFile(fileNode, context) {
|
|
427
289
|
let fileVerifies = false;
|
|
@@ -435,29 +297,3 @@ export async function verifyFile(fileNode, context) {
|
|
|
435
297
|
|
|
436
298
|
return fileVerifies;
|
|
437
299
|
}
|
|
438
|
-
|
|
439
|
-
export function verifyTermAsConstructor(term, context) {
|
|
440
|
-
let termVerifiesAsConstructor = false;
|
|
441
|
-
|
|
442
|
-
const termNode = term.getNode(),
|
|
443
|
-
success = constructorPass.run(termNode, context);
|
|
444
|
-
|
|
445
|
-
if (success) {
|
|
446
|
-
termVerifiesAsConstructor = true;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
return termVerifiesAsConstructor;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
export function verifyStatementAsCombinator(statement, context) {
|
|
453
|
-
let statementVerifiesAsCombinator = false;
|
|
454
|
-
|
|
455
|
-
const statementNode = statement.getNode(),
|
|
456
|
-
success = combinatorPass.run(statementNode, context);
|
|
457
|
-
|
|
458
|
-
if (success) {
|
|
459
|
-
statementVerifiesAsCombinator = true;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
return statementVerifiesAsCombinator;
|
|
463
|
-
}
|
package/src/utilities/context.js
CHANGED
|
@@ -46,14 +46,6 @@ export async function asyncScope(innerFunction, context) {
|
|
|
46
46
|
return await innerFunction(context);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export async function asyncAttempt(innerFunction, context) {
|
|
50
|
-
const ephemeralContext = EphemeralContext.fromNothing(context);
|
|
51
|
-
|
|
52
|
-
context = ephemeralContext; ///
|
|
53
|
-
|
|
54
|
-
return await innerFunction(context);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
49
|
export async function asyncLiminally(innerFunction, context) {
|
|
58
50
|
const liminalContext = LiminalContext.fromNothing(context);
|
|
59
51
|
|
|
@@ -61,4 +53,3 @@ export async function asyncLiminally(innerFunction, context) {
|
|
|
61
53
|
|
|
62
54
|
return await innerFunction(context);
|
|
63
55
|
}
|
|
64
|
-
|
|
@@ -112,8 +112,7 @@ async function unifyStatementAsSatisfiesAssertion(statement, reference, satisfie
|
|
|
112
112
|
const satisfiable = axiom.isSatisfiable();
|
|
113
113
|
|
|
114
114
|
if (satisfiable) {
|
|
115
|
-
const
|
|
116
|
-
topLevelAssertionUnifies = axiom.unifyTopLevelAssertion(topLevelAssertion, substitutions, context);
|
|
115
|
+
const topLevelAssertionUnifies = axiom.unifyTopLevelAssertion(topLevelAssertion, context);
|
|
117
116
|
|
|
118
117
|
if (topLevelAssertionUnifies) {
|
|
119
118
|
const substitutionsCorrelates = satisfiesAssertion.correlateSubstitutions(substitutions, context);
|
|
@@ -155,19 +154,6 @@ async function unifyStatementWithTopLevelAssertion(statement, reference, satisfi
|
|
|
155
154
|
statementAndSubproofOrProofAssertionsUnify = await topLevelAssertion.unifyStatementAndSubproofOrProofAssertions(statement, subproofOrProofAssertions, context);
|
|
156
155
|
|
|
157
156
|
if (statementAndSubproofOrProofAssertionsUnify) {
|
|
158
|
-
const metavariable = reference.getMetavariable();
|
|
159
|
-
|
|
160
|
-
debugger
|
|
161
|
-
|
|
162
|
-
// synthetically((context) => {
|
|
163
|
-
// const { StatementSubstitution } = elements;
|
|
164
|
-
//
|
|
165
|
-
// StatementSubstitution.fromStatementAndMetavariable(statement, metavariable, context);
|
|
166
|
-
|
|
167
|
-
// vaiddate
|
|
168
|
-
//
|
|
169
|
-
// }, generalContext, specificContext);
|
|
170
|
-
|
|
171
157
|
statementUnifiesWithTopLevelAssertion = true;
|
|
172
158
|
}
|
|
173
159
|
|
|
@@ -73,7 +73,7 @@ function unifyTermWithBracketedConstructor(term, context, validateForwards) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
function validateStatementAsMetavariable(statement, stated, context) {
|
|
76
|
-
let
|
|
76
|
+
let statementValidatesAsMetavariable = false;
|
|
77
77
|
|
|
78
78
|
const statementNode = statement.getNode(),
|
|
79
79
|
metavariableNode = statementNode.getMetavariableNode();
|
|
@@ -87,7 +87,7 @@ function validateStatementAsMetavariable(statement, stated, context) {
|
|
|
87
87
|
metavariable = context.findMetavariableByMetavariableName(metavariableName);
|
|
88
88
|
|
|
89
89
|
if (metavariable !== null) {
|
|
90
|
-
|
|
90
|
+
statementValidatesAsMetavariable = true;
|
|
91
91
|
|
|
92
92
|
const { TermSubstitution, FrameSubstitution } = elements,
|
|
93
93
|
frameSubstitution = FrameSubstitution.fromStatement(statement, context),
|
|
@@ -104,17 +104,17 @@ function validateStatementAsMetavariable(statement, stated, context) {
|
|
|
104
104
|
substitution = substitution.validate(generalContext, specificContext);
|
|
105
105
|
|
|
106
106
|
if (substitution === null) {
|
|
107
|
-
|
|
107
|
+
statementValidatesAsMetavariable = false;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
if (
|
|
112
|
+
if (statementValidatesAsMetavariable) {
|
|
113
113
|
context.debug(`...validated the '${statementString}' statement as a metavariable.`);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
return
|
|
117
|
+
return statementValidatesAsMetavariable;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
function unifyStatementWithCombinators(statement, stated, context) {
|