occam-verify-cli 1.0.792 → 1.0.799
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/context/ephemeral.js +41 -11
- package/lib/context/file/nominal.js +5 -1
- package/lib/context/liminal.js +39 -16
- package/lib/context/proof.js +35 -40
- package/lib/context.js +23 -3
- package/lib/element/assertion/contained.js +10 -14
- package/lib/element/assertion/defined.js +6 -8
- package/lib/element/assumption/metaLevel.js +181 -0
- package/lib/element/assumption.js +24 -44
- package/lib/element/frame.js +12 -18
- package/lib/element/hypothesis.js +1 -1
- package/lib/element/judgement.js +19 -15
- package/lib/element/metavariable.js +73 -48
- package/lib/element/proofAssertion/step.js +5 -7
- package/lib/element/reference.js +21 -19
- package/lib/element/substitution/frame.js +12 -16
- package/lib/element/substitution/reference.js +20 -1
- package/lib/element/substitution/statement.js +22 -2
- package/lib/element/topLevelMetaAssertion.js +9 -9
- package/lib/node/assumption/metaLevel.js +27 -0
- package/lib/node/assumption.js +5 -5
- package/lib/node/declaration/metavariable.js +4 -4
- package/lib/node/frame.js +5 -2
- package/lib/nonTerminalNodeMap.js +3 -1
- package/lib/preamble.js +2 -1
- package/lib/process/instantiate.js +8 -2
- package/lib/process/unify.js +22 -35
- package/lib/ruleNames.js +5 -1
- package/lib/utilities/context.js +5 -5
- package/lib/utilities/element.js +34 -26
- package/lib/utilities/json.js +23 -1
- package/lib/utilities/string.js +25 -14
- package/lib/utilities/unification.js +3 -3
- package/lib/utilities/validation.js +9 -14
- package/package.json +4 -4
- package/src/context/ephemeral.js +63 -12
- package/src/context/file/nominal.js +6 -0
- package/src/context/liminal.js +54 -16
- package/src/context/proof.js +41 -47
- package/src/context.js +35 -2
- package/src/element/assertion/contained.js +10 -14
- package/src/element/assertion/defined.js +6 -8
- package/src/element/assumption/metaLevel.js +263 -0
- package/src/element/assumption.js +35 -63
- package/src/element/frame.js +11 -17
- package/src/element/hypothesis.js +1 -1
- package/src/element/judgement.js +18 -19
- package/src/element/metavariable.js +98 -58
- package/src/element/proofAssertion/step.js +5 -7
- package/src/element/reference.js +30 -23
- package/src/element/substitution/frame.js +11 -15
- package/src/element/substitution/reference.js +33 -0
- package/src/element/substitution/statement.js +33 -1
- package/src/element/topLevelMetaAssertion.js +15 -15
- package/src/node/assumption/metaLevel.js +23 -0
- package/src/node/assumption.js +8 -8
- package/src/node/declaration/metavariable.js +4 -4
- package/src/node/frame.js +6 -1
- package/src/nonTerminalNodeMap.js +3 -0
- package/src/preamble.js +1 -0
- package/src/process/instantiate.js +4 -0
- package/src/process/unify.js +25 -50
- package/src/ruleNames.js +1 -0
- package/src/utilities/context.js +4 -4
- package/src/utilities/element.js +47 -35
- package/src/utilities/json.js +27 -1
- package/src/utilities/string.js +34 -19
- package/src/utilities/unification.js +3 -3
- package/src/utilities/validation.js +10 -16
|
@@ -5,9 +5,7 @@ import { Element } from "occam-languages";
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
import { unifyAssumption } from "../process/unify";
|
|
7
7
|
import { instantiateAssumption } from "../process/instantiate";
|
|
8
|
-
import {
|
|
9
|
-
import { join, descend, reconcile, instantiate } from "../utilities/context";
|
|
10
|
-
import { assumptionStringFromStatementAndReference } from "../utilities/string";
|
|
8
|
+
import { join, reconcile, instantiate } from "../utilities/context";
|
|
11
9
|
|
|
12
10
|
export default define(class Assumption extends Element {
|
|
13
11
|
constructor(context, string, node, reference, statement) {
|
|
@@ -44,12 +42,6 @@ export default define(class Assumption extends Element {
|
|
|
44
42
|
return equalTo;
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
isMetaLevel() {
|
|
48
|
-
const metaLevel = (this.context !== null);
|
|
49
|
-
|
|
50
|
-
return metaLevel;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
45
|
matchAssumptionNode(assumptionNode) {
|
|
54
46
|
const node = assumptionNode, ///
|
|
55
47
|
nodeMatches = this.matchNode(node),
|
|
@@ -58,9 +50,9 @@ export default define(class Assumption extends Element {
|
|
|
58
50
|
return assumptionNodeMatches;
|
|
59
51
|
}
|
|
60
52
|
|
|
61
|
-
findValidAssumption(context
|
|
53
|
+
findValidAssumption(context) {
|
|
62
54
|
const assumptionNode = this.getAssumptionNode(),
|
|
63
|
-
assumption = context.findAssumptionByAssumptionNode(assumptionNode
|
|
55
|
+
assumption = context.findAssumptionByAssumptionNode(assumptionNode),
|
|
64
56
|
validAssumption = assumption; ///
|
|
65
57
|
|
|
66
58
|
return validAssumption;
|
|
@@ -69,17 +61,11 @@ export default define(class Assumption extends Element {
|
|
|
69
61
|
validate(context) {
|
|
70
62
|
let assumption = null;
|
|
71
63
|
|
|
72
|
-
const metaLevel = this.isMetaLevel();
|
|
73
|
-
|
|
74
|
-
if (metaLevel) {
|
|
75
|
-
context = this.getContext();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
64
|
const assumptionString = this.getString(); ///
|
|
79
65
|
|
|
80
66
|
context.trace(`Validating the '${assumptionString}' assumption...`);
|
|
81
67
|
|
|
82
|
-
const validAssumption = this.findValidAssumption(context
|
|
68
|
+
const validAssumption = this.findValidAssumption(context);
|
|
83
69
|
|
|
84
70
|
if (validAssumption) {
|
|
85
71
|
assumption = validAssumption; ///
|
|
@@ -114,7 +100,7 @@ export default define(class Assumption extends Element {
|
|
|
114
100
|
if (validates) {
|
|
115
101
|
assumption = this; ///
|
|
116
102
|
|
|
117
|
-
context.addAssumption(assumption
|
|
103
|
+
context.addAssumption(assumption);
|
|
118
104
|
|
|
119
105
|
context.debug(`...validated the '${assumptionString}' assumption.`);
|
|
120
106
|
}
|
|
@@ -170,13 +156,11 @@ export default define(class Assumption extends Element {
|
|
|
170
156
|
|
|
171
157
|
context.trace(`Validating the '${assumptionString}' assumption's '${statementString}' statement...`);
|
|
172
158
|
|
|
173
|
-
|
|
174
|
-
const statement = this.statement.validate(context);
|
|
159
|
+
const statement = this.statement.validate(context);
|
|
175
160
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}, context);
|
|
161
|
+
if (statement !== null) {
|
|
162
|
+
statementValidates = true;
|
|
163
|
+
}
|
|
180
164
|
|
|
181
165
|
if (statementValidates) {
|
|
182
166
|
context.debug(`...validated the '${assumptionString}' assumption's '${statementString}' statement.`);
|
|
@@ -207,6 +191,7 @@ export default define(class Assumption extends Element {
|
|
|
207
191
|
const assumptionString = this.getString(); ///
|
|
208
192
|
|
|
209
193
|
context.trace(`Validating the '${assumptionString}' derived assumption...`);
|
|
194
|
+
|
|
210
195
|
const topLevelMetaAssertion = this.getTopLevelMetaAssertion();
|
|
211
196
|
|
|
212
197
|
if (topLevelMetaAssertion !== null) {
|
|
@@ -222,37 +207,43 @@ export default define(class Assumption extends Element {
|
|
|
222
207
|
return validatesWhenDerived;
|
|
223
208
|
}
|
|
224
209
|
|
|
225
|
-
|
|
226
|
-
let
|
|
210
|
+
unifyMetaLevelAssumption(metaLevelAssumption, context) {
|
|
211
|
+
let metaLevelAssumptionUnifies;
|
|
227
212
|
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
specificAssumption = assumption, ///
|
|
231
|
-
generalAssumptionString = generalAssumption.getString(),
|
|
232
|
-
specificAssumptionString = specificAssumption.getString();
|
|
233
|
-
|
|
234
|
-
context.trace(`Unifying the '${specificAssumptionString}' assumption with the '${generalAssumptionString}' assumption...`);
|
|
213
|
+
const assumptionString = this.getString(), ///
|
|
214
|
+
metaLevelAssumptionString = metaLevelAssumption.getString();
|
|
235
215
|
|
|
236
|
-
|
|
216
|
+
context.trace(`Unifying the '${metaLevelAssumptionString}' meta-level assumption with the '${assumptionString}' assumption...`);
|
|
237
217
|
|
|
238
|
-
|
|
218
|
+
const metaLevelAssumptionContext = metaLevelAssumption.getContext(),
|
|
219
|
+
assumptionContext = this.getContext(),
|
|
220
|
+
generalContext = assumptionContext, ///
|
|
221
|
+
specificContext = metaLevelAssumptionContext; ///
|
|
239
222
|
|
|
240
223
|
join((specificContext) => {
|
|
241
224
|
reconcile((specificContext) => {
|
|
242
|
-
|
|
225
|
+
const generalAssumption = this, ///
|
|
226
|
+
specificAssumption = metaLevelAssumption, ///
|
|
227
|
+
assumptionUnifies = unifyAssumption(generalAssumption, specificAssumption, generalContext, specificContext);
|
|
243
228
|
|
|
244
229
|
if (assumptionUnifies) {
|
|
245
|
-
|
|
246
|
-
|
|
230
|
+
const assumption = this, ///
|
|
231
|
+
specificContextQualifies = specificContext.qualify(assumption, metaLevelAssumption);
|
|
247
232
|
|
|
233
|
+
if (specificContextQualifies) {
|
|
234
|
+
specificContext.commit(context);
|
|
235
|
+
|
|
236
|
+
metaLevelAssumptionUnifies = true;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
248
239
|
}, specificContext);
|
|
249
240
|
}, specificContext, context);
|
|
250
241
|
|
|
251
|
-
if (
|
|
252
|
-
context.debug(`...unified the '${
|
|
242
|
+
if (metaLevelAssumptionUnifies) {
|
|
243
|
+
context.debug(`...unified the '${metaLevelAssumptionString}' meta-level assumption with the '${assumptionString}' assumption.`);
|
|
253
244
|
}
|
|
254
245
|
|
|
255
|
-
return
|
|
246
|
+
return metaLevelAssumptionUnifies;
|
|
256
247
|
}
|
|
257
248
|
|
|
258
249
|
unifyTopLevelMetaAssertion(topLevelMetaAssertion, context) {
|
|
@@ -293,33 +284,14 @@ export default define(class Assumption extends Element {
|
|
|
293
284
|
assumptionNode = instantiateAssumption(string, context),
|
|
294
285
|
node = assumptionNode, ///
|
|
295
286
|
reference = referenceFromAssumptionNode(assumptionNode, context),
|
|
296
|
-
statement = statementFromAssumptionNode(assumptionNode, context)
|
|
297
|
-
|
|
298
|
-
context = null; ///
|
|
299
|
-
|
|
300
|
-
const assumption = new Assumption(context, string, node, reference, statement);
|
|
287
|
+
statement = statementFromAssumptionNode(assumptionNode, context),
|
|
288
|
+
assumption = new Assumption(context, string, node, reference, statement);
|
|
301
289
|
|
|
302
290
|
return assumption;
|
|
303
291
|
}, context);
|
|
304
292
|
|
|
305
293
|
return assumption;
|
|
306
294
|
}
|
|
307
|
-
|
|
308
|
-
static fromStatementAndReference(statement, reference, context) {
|
|
309
|
-
let assumption;
|
|
310
|
-
|
|
311
|
-
instantiate((context) => {
|
|
312
|
-
const assumptionString = assumptionStringFromStatementAndReference(statement, reference),
|
|
313
|
-
string = assumptionString, ///
|
|
314
|
-
assumptionNode = instantiateAssumption(string, context);
|
|
315
|
-
|
|
316
|
-
assumption = assumptionFromAssumptionNode(assumptionNode, context);
|
|
317
|
-
|
|
318
|
-
assumption.setContext(context);
|
|
319
|
-
}, context);
|
|
320
|
-
|
|
321
|
-
return assumption;
|
|
322
|
-
}
|
|
323
295
|
});
|
|
324
296
|
|
|
325
297
|
function referenceFromAssumptionNode(assumptionNode, context) {
|
package/src/element/frame.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
+
import { instantiate } from "../utilities/context";
|
|
6
7
|
import { instantiateFrame } from "../process/instantiate";
|
|
7
8
|
import { FRAME_META_TYPE_NAME } from "../metaTypeNames";
|
|
8
9
|
import { metavariableFromFrameNode } from "../utilities/element";
|
|
9
|
-
import { descend, reconcile, instantiate } from "../utilities/context";
|
|
10
10
|
import { assumptionsStringFromAssumptions } from "../utilities/string";
|
|
11
11
|
|
|
12
12
|
export default define(class Frame extends Element {
|
|
@@ -225,17 +225,13 @@ export default define(class Frame extends Element {
|
|
|
225
225
|
|
|
226
226
|
context.trace(`Validating the '${frameString}' frame's '${assumptionstring}' assumption.`);
|
|
227
227
|
|
|
228
|
-
|
|
229
|
-
descend((context) => {
|
|
230
|
-
assumption = assumption.validate(context); ///
|
|
228
|
+
assumption = assumption.validate(context); ///
|
|
231
229
|
|
|
232
|
-
|
|
233
|
-
|
|
230
|
+
if (assumption !== null) {
|
|
231
|
+
assumptions.push(assumption);
|
|
234
232
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}, context);
|
|
238
|
-
}, context);
|
|
233
|
+
assumptionValidates = true;
|
|
234
|
+
}
|
|
239
235
|
|
|
240
236
|
if (assumptionValidates) {
|
|
241
237
|
context.debug(`...validated the '${frameString}' frame's '${assumptionstring}' assumption.`);
|
|
@@ -247,9 +243,9 @@ export default define(class Frame extends Element {
|
|
|
247
243
|
validateAssumptions(context) {
|
|
248
244
|
let assumptionsValidate;
|
|
249
245
|
|
|
250
|
-
const
|
|
246
|
+
const assumptionsLength = this.assumptions.length;
|
|
251
247
|
|
|
252
|
-
if (
|
|
248
|
+
if (assumptionsLength) {
|
|
253
249
|
const frameString = this.getString(), ///
|
|
254
250
|
assumptionsString = assumptionsStringFromAssumptions(this.assumptions);
|
|
255
251
|
|
|
@@ -278,11 +274,11 @@ export default define(class Frame extends Element {
|
|
|
278
274
|
}
|
|
279
275
|
|
|
280
276
|
validatMetavariable(context) {
|
|
281
|
-
let metavariableValidates =
|
|
277
|
+
let metavariableValidates = true; ///
|
|
282
278
|
|
|
283
|
-
|
|
279
|
+
if (this.metavariable !== null) {
|
|
280
|
+
metavariableValidates = false;
|
|
284
281
|
|
|
285
|
-
if (singular) {
|
|
286
282
|
const frameString = this.getString(), ///
|
|
287
283
|
metavariableString = this.metavariable.getString();
|
|
288
284
|
|
|
@@ -296,8 +292,6 @@ export default define(class Frame extends Element {
|
|
|
296
292
|
if (metavariableMetaTypeEqualToFrameMetaType) {
|
|
297
293
|
metavariableValidates = true;
|
|
298
294
|
}
|
|
299
|
-
} else {
|
|
300
|
-
metavariableValidates = true;
|
|
301
295
|
}
|
|
302
296
|
|
|
303
297
|
return metavariableValidates;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import {descend, instantiate} from "../utilities/context";
|
|
6
|
+
import { descend, instantiate } from "../utilities/context";
|
|
7
7
|
import { instantiateHypothesis } from "../process/instantiate";
|
|
8
8
|
import { statementFromHypothesisNode } from "../utilities/element";
|
|
9
9
|
|
package/src/element/judgement.js
CHANGED
|
@@ -38,10 +38,14 @@ export default define(class Judgement extends Element {
|
|
|
38
38
|
return singular;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
getAssumptions() { return this.frame.getAssumptions(); }
|
|
42
|
+
|
|
41
43
|
getMetavariable() { return this.frame.getMetavariable(); }
|
|
42
44
|
|
|
43
45
|
getMetavariableNode() { return this.frame.getMetavariableNode(); }
|
|
44
46
|
|
|
47
|
+
getTopLevelMetaAssertion() { return this.assumption.getTopLevelMetaAssertion(); }
|
|
48
|
+
|
|
45
49
|
matchJudgementNode(judgementNode) {
|
|
46
50
|
const node = judgementNode, ///
|
|
47
51
|
nodeMatches = this.matchNode(node),
|
|
@@ -186,38 +190,33 @@ export default define(class Judgement extends Element {
|
|
|
186
190
|
|
|
187
191
|
context.trace(`Validating the '${judgementString}' derived judgement...`);
|
|
188
192
|
|
|
189
|
-
const
|
|
190
|
-
|
|
193
|
+
const metavariableNode = this.getMetavariableNode(),
|
|
194
|
+
topLevelMetaAssertion = this.getTopLevelMetaAssertion(),
|
|
195
|
+
metaLevelAssumptions = topLevelMetaAssertion.getMetaLevelAssumptions(),
|
|
191
196
|
judgements = context.findJudgementsByMetavariableNode(metavariableNode);
|
|
192
197
|
|
|
193
198
|
let assumptions;
|
|
194
199
|
|
|
195
|
-
assumptions =
|
|
196
|
-
|
|
197
|
-
const specificAssumptions = assumptions; ///
|
|
198
|
-
|
|
199
|
-
assumptions = assumptionsFromJudgements(judgements);
|
|
200
|
+
assumptions = this.getAssumptions();
|
|
200
201
|
|
|
201
|
-
|
|
202
|
+
assumptions = assumptionsFromJudgements(judgements, assumptions);
|
|
202
203
|
|
|
203
204
|
reconcile((context) => {
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
const
|
|
207
|
-
specificContext = context, ///
|
|
208
|
-
specificAssumptionUnifies = generalAssumption.unifyAssumption(specificAssumption, generalContext, specificContext);
|
|
205
|
+
const metaLevelAssumptionsUnify = metaLevelAssumptions.every((metaLevelAssumption) => {
|
|
206
|
+
const metaLevelAssumptionUnifies = assumptions.some((assumption) => {
|
|
207
|
+
const metaLevelAssumptionUnifies = assumption.unifyMetaLevelAssumption(metaLevelAssumption, context);
|
|
209
208
|
|
|
210
|
-
if (
|
|
209
|
+
if (metaLevelAssumptionUnifies) {
|
|
211
210
|
return true;
|
|
212
211
|
}
|
|
213
212
|
});
|
|
214
213
|
|
|
215
|
-
if (
|
|
214
|
+
if (metaLevelAssumptionUnifies) {
|
|
216
215
|
return true;
|
|
217
216
|
}
|
|
218
217
|
});
|
|
219
218
|
|
|
220
|
-
if (
|
|
219
|
+
if (metaLevelAssumptionsUnify) {
|
|
221
220
|
validatesWhenDerived = true;
|
|
222
221
|
}
|
|
223
222
|
}, context);
|
|
@@ -284,11 +283,11 @@ function frameFromJudgementNode(judgementNode, context) {
|
|
|
284
283
|
return frame;
|
|
285
284
|
}
|
|
286
285
|
|
|
287
|
-
function assumptionsFromJudgements(judgements) {
|
|
288
|
-
|
|
286
|
+
function assumptionsFromJudgements(judgements, assumptions = []) {
|
|
287
|
+
judgements.map((judgement) => {
|
|
289
288
|
const assumption = judgement.getAssumption();
|
|
290
289
|
|
|
291
|
-
|
|
290
|
+
assumptions.push(assumption);
|
|
292
291
|
});
|
|
293
292
|
|
|
294
293
|
return assumptions;
|
|
@@ -56,6 +56,22 @@ export default define(class Metavariable extends Element {
|
|
|
56
56
|
return metavariableName;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
isDeclared(context) {
|
|
60
|
+
const metavariableName = this.getMetavariableName(),
|
|
61
|
+
metavariable = context.findMetavariableByMetavariableName(metavariableName),
|
|
62
|
+
declared = (metavariable !== null);
|
|
63
|
+
|
|
64
|
+
return declared;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
isEqualTo(metavariable) {
|
|
68
|
+
const metavariableNode = metavariable.getNode(),
|
|
69
|
+
metavariableNodeMatches = this.matchMetavariableNode(metavariableNode),
|
|
70
|
+
equalTo = metavariableNodeMatches; ///
|
|
71
|
+
|
|
72
|
+
return equalTo;
|
|
73
|
+
}
|
|
74
|
+
|
|
59
75
|
isMetaTypeEqualTo(metaType) { return this.metaType.isEqualTo(metaType); }
|
|
60
76
|
|
|
61
77
|
matchMetavariableNode(metavariableNode) {
|
|
@@ -148,39 +164,90 @@ export default define(class Metavariable extends Element {
|
|
|
148
164
|
return typeVerifies;
|
|
149
165
|
}
|
|
150
166
|
|
|
151
|
-
|
|
167
|
+
findValidMetavariable(context) {
|
|
168
|
+
const metavariableNode = this.getMetavariableNode(),
|
|
169
|
+
metavariable = context.findMetavariableByMetavariableNode(metavariableNode),
|
|
170
|
+
validMetavariable = metavariable; ///
|
|
171
|
+
|
|
172
|
+
return validMetavariable;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
validate(strict, context) {
|
|
176
|
+
if (context === undefined) {
|
|
177
|
+
context = strict; ///
|
|
178
|
+
|
|
179
|
+
strict = false;
|
|
180
|
+
}
|
|
181
|
+
|
|
152
182
|
let metavariable = null;
|
|
153
183
|
|
|
154
184
|
const metavariableString = this.getString(); ///
|
|
155
185
|
|
|
156
186
|
context.trace(`Validating the '${metavariableString}' metavariable...`);
|
|
157
187
|
|
|
158
|
-
|
|
188
|
+
const validMetavariable = this.findValidMetavariable(context),
|
|
189
|
+
valid = (validMetavariable !== null);
|
|
159
190
|
|
|
160
|
-
|
|
191
|
+
if (valid) {
|
|
192
|
+
metavariable = validMetavariable; ///
|
|
161
193
|
|
|
162
|
-
|
|
163
|
-
|
|
194
|
+
context.debug(`...the '${metavariableString}' metavariable is already valid.`);
|
|
195
|
+
} else {
|
|
196
|
+
let validates = false;
|
|
164
197
|
|
|
165
|
-
|
|
166
|
-
|
|
198
|
+
const typeValidates = this.validateType(strict, context);
|
|
199
|
+
|
|
200
|
+
if (typeValidates) {
|
|
201
|
+
const termValidates = this.validateTerm(strict, context);
|
|
167
202
|
|
|
168
|
-
if (
|
|
169
|
-
|
|
203
|
+
if (termValidates) {
|
|
204
|
+
const nameValidates = this.validateName(strict, context);
|
|
205
|
+
|
|
206
|
+
if (nameValidates) {
|
|
207
|
+
validates = true;
|
|
208
|
+
}
|
|
170
209
|
}
|
|
171
210
|
}
|
|
172
|
-
}
|
|
173
211
|
|
|
174
|
-
|
|
175
|
-
|
|
212
|
+
if (validates) {
|
|
213
|
+
metavariable = this; ///
|
|
214
|
+
|
|
215
|
+
const declared = this.isDeclared(context);
|
|
176
216
|
|
|
177
|
-
|
|
217
|
+
if (declared) {
|
|
218
|
+
context.addMetavariable(metavariable);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
context.debug(`...validated the '${metavariableString}' metavariable.`);
|
|
222
|
+
}
|
|
178
223
|
}
|
|
179
224
|
|
|
180
225
|
return metavariable;
|
|
181
226
|
}
|
|
182
227
|
|
|
183
|
-
|
|
228
|
+
validateType(strict, context) {
|
|
229
|
+
let typeValidates = false;
|
|
230
|
+
|
|
231
|
+
const metavariableString = this.getString(); ///
|
|
232
|
+
|
|
233
|
+
context.trace(`Validating the '${metavariableString}' metavariable's type...`);
|
|
234
|
+
|
|
235
|
+
if (this.type === null) {
|
|
236
|
+
typeValidates = true;
|
|
237
|
+
} else {
|
|
238
|
+
const typeString = this.type.getString();
|
|
239
|
+
|
|
240
|
+
context.trace(`A '${typeString}' type is present in the '${metavariableString}' metavariable.`);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (typeValidates) {
|
|
244
|
+
context.trace(`...validated the '${metavariableString}' metavariable's type.`);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return typeValidates;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
validateTerm(strict, context) {
|
|
184
251
|
let termValidates = true; ///
|
|
185
252
|
|
|
186
253
|
if (this.term !== null) {
|
|
@@ -197,20 +264,19 @@ export default define(class Metavariable extends Element {
|
|
|
197
264
|
let term = null;
|
|
198
265
|
|
|
199
266
|
if (metavariable !== null) {
|
|
200
|
-
const type = metavariable.getType()
|
|
201
|
-
metavariableString = metavariable.getString();
|
|
267
|
+
const type = metavariable.getType();
|
|
202
268
|
|
|
203
269
|
if (type !== null) {
|
|
204
270
|
term = this.term.validateGivenType(type, context);
|
|
205
|
-
} else {
|
|
206
|
-
context.trace(`The '${metavariableString}' metavariable does not have a type`);
|
|
207
271
|
}
|
|
208
272
|
} else {
|
|
209
|
-
|
|
210
|
-
|
|
273
|
+
if (!strict) {
|
|
274
|
+
term = this.term.validate(context, (term) => {
|
|
275
|
+
const validatesForwards = true;
|
|
211
276
|
|
|
212
|
-
|
|
213
|
-
|
|
277
|
+
return validatesForwards;
|
|
278
|
+
});
|
|
279
|
+
}
|
|
214
280
|
}
|
|
215
281
|
|
|
216
282
|
if (term !== null) {
|
|
@@ -227,8 +293,8 @@ export default define(class Metavariable extends Element {
|
|
|
227
293
|
return termValidates;
|
|
228
294
|
}
|
|
229
295
|
|
|
230
|
-
validateName(context) {
|
|
231
|
-
let
|
|
296
|
+
validateName(strict, context) {
|
|
297
|
+
let nameValidates = true; ///
|
|
232
298
|
|
|
233
299
|
const metavariableName = this.getMetavariableName(), ///
|
|
234
300
|
metavariableString = this.getString(); ///
|
|
@@ -239,40 +305,22 @@ export default define(class Metavariable extends Element {
|
|
|
239
305
|
|
|
240
306
|
if (metavariable !== null) {
|
|
241
307
|
const metaType = metavariable.getMetaType(),
|
|
242
|
-
|
|
308
|
+
metaTypeString = metaType.getString();
|
|
243
309
|
|
|
244
310
|
this.metaType = metaType;
|
|
245
311
|
|
|
246
|
-
context.trace(`Setting the '${metavariableString}' metavariable's meta-type to the '${
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if (termValidates) {
|
|
250
|
-
context.debug(`...validated the '${metavariableString}' metavariable's '${metavariableName}' name.`);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return termValidates;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
validateType(context) {
|
|
257
|
-
let typeValidates = false;
|
|
258
|
-
|
|
259
|
-
const metavariableString = this.getString(); ///
|
|
260
|
-
|
|
261
|
-
context.trace(`Validating the '${metavariableString}' metavariable's type...`);
|
|
262
|
-
|
|
263
|
-
if (this.type === null) {
|
|
264
|
-
typeValidates = true;
|
|
312
|
+
context.trace(`Setting the '${metavariableString}' metavariable's meta-type to the '${metaTypeString}' meta-type.`);
|
|
265
313
|
} else {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
314
|
+
if (strict) {
|
|
315
|
+
nameValidates = false;
|
|
316
|
+
}
|
|
269
317
|
}
|
|
270
318
|
|
|
271
|
-
if (
|
|
272
|
-
context.
|
|
319
|
+
if (nameValidates) {
|
|
320
|
+
context.debug(`...validated the '${metavariableString}' metavariable's '${metavariableName}' name.`);
|
|
273
321
|
}
|
|
274
322
|
|
|
275
|
-
return
|
|
323
|
+
return nameValidates;
|
|
276
324
|
}
|
|
277
325
|
|
|
278
326
|
unifyFrame(frame, generalContext, specificContext) {
|
|
@@ -365,14 +413,6 @@ export default define(class Metavariable extends Element {
|
|
|
365
413
|
StatementSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context) :
|
|
366
414
|
StatementSubstitution.fromStatementAndMetavariable(statement, metavariable, context);
|
|
367
415
|
|
|
368
|
-
if (substitution !== null) {
|
|
369
|
-
const context = generalContext; ///
|
|
370
|
-
|
|
371
|
-
substitution = statementSubstitution.getSubstitution();
|
|
372
|
-
|
|
373
|
-
substitution.setContext(context);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
416
|
statementSubstitution.validate(generalContext, specificContext);
|
|
377
417
|
|
|
378
418
|
statementUnifies = true;
|
|
@@ -7,7 +7,7 @@ import ProofAssertion from "../proofAssertion";
|
|
|
7
7
|
|
|
8
8
|
import { define } from "../../elements";
|
|
9
9
|
import { unifyStatements } from "../../utilities/unification";
|
|
10
|
-
import { derive, attempt,
|
|
10
|
+
import { derive, attempt, asyncReconcile } from "../../utilities/context";
|
|
11
11
|
|
|
12
12
|
const { asyncSome } = asynchronousUtilities;
|
|
13
13
|
|
|
@@ -184,13 +184,11 @@ export default define(class Step extends ProofAssertion {
|
|
|
184
184
|
|
|
185
185
|
context.trace(`Validating the '${stepString}' step's '${satisfiesAssertionString}' satisfies assertion... `);
|
|
186
186
|
|
|
187
|
-
|
|
188
|
-
const satisfiesAssertion = this.satisfiesAssertion.validate(context);
|
|
187
|
+
const satisfiesAssertion = this.satisfiesAssertion.validate(context);
|
|
189
188
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}, context);
|
|
189
|
+
if (satisfiesAssertion === null) {
|
|
190
|
+
satisfiesAssertionValidates = false;
|
|
191
|
+
}
|
|
194
192
|
|
|
195
193
|
if (satisfiesAssertionValidates) {
|
|
196
194
|
context.debug(`...validating the '${stepString}' step's '${satisfiesAssertionString}' satisfies assertion. `);
|