occam-verify-cli 1.0.718 → 1.0.721
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/file/nominal.js +1 -1
- package/lib/element/assumption.js +1 -11
- package/lib/element/declaration/metavariable.js +18 -34
- package/lib/element/equality.js +2 -2
- package/lib/element/frame.js +37 -61
- package/lib/element/metavariable.js +90 -35
- package/lib/element/proofAssertion/step.js +4 -4
- package/lib/element/proofAssertion.js +2 -2
- package/lib/element/reference.js +33 -32
- package/lib/element/statement.js +1 -18
- package/lib/element/variable.js +1 -17
- package/lib/process/equate.js +5 -5
- package/lib/process/unify.js +20 -17
- package/lib/process/validate.js +2 -120
- package/lib/utilities/element.js +29 -16
- package/package.json +1 -1
- package/src/context/file/nominal.js +6 -6
- package/src/element/assumption.js +1 -18
- package/src/element/declaration/metavariable.js +26 -49
- package/src/element/equality.js +1 -3
- package/src/element/frame.js +45 -83
- package/src/element/metavariable.js +128 -42
- package/src/element/proofAssertion/step.js +3 -3
- package/src/element/proofAssertion.js +1 -3
- package/src/element/reference.js +46 -47
- package/src/element/statement.js +0 -26
- package/src/element/variable.js +0 -25
- package/src/process/equate.js +8 -4
- package/src/process/unify.js +23 -22
- package/src/process/validate.js +2 -168
- package/src/utilities/element.js +36 -21
package/package.json
CHANGED
|
@@ -498,13 +498,13 @@ export default class NominalFileContext extends FileContext {
|
|
|
498
498
|
|
|
499
499
|
findMetatheoremByReference(reference) {
|
|
500
500
|
const metatheorems = this.getMetatheorems(),
|
|
501
|
-
|
|
502
|
-
|
|
501
|
+
metatheorem = metatheorems.find((metatheorem) => {
|
|
502
|
+
const metatheoremComparesToReference = metatheorem.compareReference(reference);
|
|
503
503
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
504
|
+
if (metatheoremComparesToReference) {
|
|
505
|
+
return true;
|
|
506
|
+
}
|
|
507
|
+
}) || null;
|
|
508
508
|
|
|
509
509
|
return metatheorem;
|
|
510
510
|
}
|
|
@@ -150,7 +150,7 @@ export default define(class Assumption extends Element {
|
|
|
150
150
|
let statementValidates = false;
|
|
151
151
|
|
|
152
152
|
const assumptionString = this.getString(), ///
|
|
153
|
-
|
|
153
|
+
statementString = this.statement.getString();
|
|
154
154
|
|
|
155
155
|
context.trace(`Validating the '${assumptionString}' assumption's '${statementString}' statement...`);
|
|
156
156
|
|
|
@@ -169,23 +169,6 @@ export default define(class Assumption extends Element {
|
|
|
169
169
|
return statementValidates;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
validateReferenceAsMetavariable(stated, context) {
|
|
173
|
-
let referenceValidatesAsMetavariable;
|
|
174
|
-
|
|
175
|
-
const referenceString = this.reference.getString(),
|
|
176
|
-
assumptionString = this.getString(); ///
|
|
177
|
-
|
|
178
|
-
context.trace(`Validating the '${assumptionString}' assumption's '${referenceString}' reference as s metavariable...`);
|
|
179
|
-
|
|
180
|
-
referenceValidatesAsMetavariable = this.reference.validateAsMetavariable(context);
|
|
181
|
-
|
|
182
|
-
if (referenceValidatesAsMetavariable) {
|
|
183
|
-
context.debug(`...validated the '${assumptionString}' assumption's '${referenceString}' reference as a metavariable.`);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return referenceValidatesAsMetavariable;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
172
|
validateWhenStated(context) {
|
|
190
173
|
let validatesWhenStated;
|
|
191
174
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import Declaration from "../declaration";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
+
import { verifyMetavariable } from "../../process/verify";
|
|
6
7
|
|
|
7
8
|
export default define(class MetavariableDeclaration extends Declaration {
|
|
8
9
|
constructor(context, string, node, metaType, metavariable) {
|
|
@@ -34,11 +35,9 @@ export default define(class MetavariableDeclaration extends Declaration {
|
|
|
34
35
|
const metavariableVerifies = this.verifyMetavariable();
|
|
35
36
|
|
|
36
37
|
if (metavariableVerifies) {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
if (metavariableTypeVerified) {
|
|
40
|
-
this.metavariable.setMetaType(this.metaType);
|
|
38
|
+
const metaTypeVerifies = this.verifyMetaType();
|
|
41
39
|
|
|
40
|
+
if (metaTypeVerifies) {
|
|
42
41
|
context.addMetavariable(this.metavariable);
|
|
43
42
|
|
|
44
43
|
verifies = true;
|
|
@@ -52,6 +51,24 @@ export default define(class MetavariableDeclaration extends Declaration {
|
|
|
52
51
|
return verifies;
|
|
53
52
|
}
|
|
54
53
|
|
|
54
|
+
verifyMetaType() {
|
|
55
|
+
let metaTypeVerifies = true;
|
|
56
|
+
|
|
57
|
+
const context = this.getContext(),
|
|
58
|
+
metaTypeString = this.metaType.getString(),
|
|
59
|
+
metaTypeDeclarationString = this.getString(); ///
|
|
60
|
+
|
|
61
|
+
context.trace(`Verifying the '${metaTypeDeclarationString}' variable declaration's '${metaTypeString}' metaType...`);
|
|
62
|
+
|
|
63
|
+
this.metavariable.setMetaType(this.metaType);
|
|
64
|
+
|
|
65
|
+
if (metaTypeVerifies) {
|
|
66
|
+
context.debug(`...verified the '${metaTypeDeclarationString}' variable declaration's '${metaTypeString}' metaType.`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return metaTypeVerifies;
|
|
70
|
+
}
|
|
71
|
+
|
|
55
72
|
verifyMetavariable() {
|
|
56
73
|
let metavariableVerifies = false;
|
|
57
74
|
|
|
@@ -61,20 +78,13 @@ export default define(class MetavariableDeclaration extends Declaration {
|
|
|
61
78
|
|
|
62
79
|
context.trace(`Verifying the '${metavariableDeclarationString}' variable declaration's '${metavariableString}' metavariable...`);
|
|
63
80
|
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (termNode === null) {
|
|
68
|
-
const metavariableName = this.metavariable.getName(),
|
|
69
|
-
metavariablePresent = context.isMetavariablePresentByMetavariableName(metavariableName);
|
|
81
|
+
const metavariableName = this.metavariable.getName(),
|
|
82
|
+
metavariablePresent = context.isMetavariablePresentByMetavariableName(metavariableName);
|
|
70
83
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} else {
|
|
74
|
-
context.debug(`The '${metavariableName}' metavariable is already present.`);
|
|
75
|
-
}
|
|
84
|
+
if (!metavariablePresent) {
|
|
85
|
+
metavariableVerifies = this.metavariable.verify(context);
|
|
76
86
|
} else {
|
|
77
|
-
context.debug(`
|
|
87
|
+
context.debug(`The '${metavariableName}' metavariable is already present.`);
|
|
78
88
|
}
|
|
79
89
|
|
|
80
90
|
if (metavariableVerifies) {
|
|
@@ -84,38 +94,5 @@ export default define(class MetavariableDeclaration extends Declaration {
|
|
|
84
94
|
return metavariableVerifies;
|
|
85
95
|
}
|
|
86
96
|
|
|
87
|
-
verifyMetavariableType() {
|
|
88
|
-
let metavariableTypeVerified = false;
|
|
89
|
-
|
|
90
|
-
const context = this.getContext(),
|
|
91
|
-
metavariableType = this.metavariable.getType();
|
|
92
|
-
|
|
93
|
-
if (metavariableType === null) {
|
|
94
|
-
metavariableTypeVerified = true;
|
|
95
|
-
} else {
|
|
96
|
-
const metavariableTypeString = metavariableType.getString(),
|
|
97
|
-
metavariableDeclarationString = this.getString(); ///
|
|
98
|
-
|
|
99
|
-
context.trace(`Verifying the '${metavariableDeclarationString}' metavariable declaration's '${metavariableTypeString}' metavariable type...`);
|
|
100
|
-
|
|
101
|
-
const nominalTypeName = metavariableType.getNominalTypeName(),
|
|
102
|
-
type = context.findTypeByNominalTypeName(nominalTypeName);
|
|
103
|
-
|
|
104
|
-
if (type === null) {
|
|
105
|
-
this.metavariable.setType(type);
|
|
106
|
-
|
|
107
|
-
metavariableTypeVerified = true;
|
|
108
|
-
} else {
|
|
109
|
-
context.debug(`The '${metavariableTypeString}' type is not present.`);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (metavariableTypeVerified) {
|
|
113
|
-
context.debug(`...verified the '${metavariableDeclarationString}' metavariable declaration's '${metavariableTypeString}' metavariable type.`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return metavariableTypeVerified;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
97
|
static name = "MetavariableDeclaration";
|
|
121
98
|
});
|
package/src/element/equality.js
CHANGED
|
@@ -102,9 +102,7 @@ export default define(class Equality extends Element {
|
|
|
102
102
|
isEqual(context) {
|
|
103
103
|
let equal = false;
|
|
104
104
|
|
|
105
|
-
const
|
|
106
|
-
rightTermNode = this.rightTerm.getNode(),
|
|
107
|
-
termsEquate = equateTerms(leftTermNode, rightTermNode, context);
|
|
105
|
+
const termsEquate = equateTerms(this.leftTerm, this.rightTerm, context);
|
|
108
106
|
|
|
109
107
|
if (termsEquate) {
|
|
110
108
|
equal = true;
|
package/src/element/frame.js
CHANGED
|
@@ -6,23 +6,23 @@ import { define } from "../elements";
|
|
|
6
6
|
import { literally } from "../utilities/context";
|
|
7
7
|
import { instantiateFrame } from "../process/instantiate";
|
|
8
8
|
import { FRAME_META_TYPE_NAME } from "../metaTypeNames";
|
|
9
|
-
import {
|
|
9
|
+
import { metavariableFromFrameNode } from "../utilities/element";
|
|
10
10
|
import { assumptionsStringFromAssumptions } from "../utilities/string";
|
|
11
11
|
|
|
12
12
|
export default define(class Frame extends Element {
|
|
13
|
-
constructor(context, string, node,
|
|
13
|
+
constructor(context, string, node, assumptions, metavariable) {
|
|
14
14
|
super(context, string, node);
|
|
15
15
|
|
|
16
|
-
this.reference = reference;
|
|
17
16
|
this.assumptions = assumptions;
|
|
17
|
+
this.metavariable = metavariable;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
getAssumptions() {
|
|
21
21
|
return this.assumptions;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
return this.
|
|
24
|
+
getMetavariable() {
|
|
25
|
+
return this.metavariable;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
getFrameNode() {
|
|
@@ -32,30 +32,18 @@ export default define(class Frame extends Element {
|
|
|
32
32
|
return frameNode;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
getMetavariableName() {
|
|
36
|
-
const frameNode = this.getFrameNode(),
|
|
37
|
-
referenceName = frameNode.getMetavariableName();
|
|
38
|
-
|
|
39
|
-
return referenceName;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
35
|
getMetavariableNode() {
|
|
43
36
|
const frameNode = this.getFrameNode(),
|
|
44
|
-
|
|
37
|
+
metavariableNode = frameNode.getMetavariableNode();
|
|
45
38
|
|
|
46
|
-
return
|
|
39
|
+
return metavariableNode;
|
|
47
40
|
}
|
|
48
41
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const singular = this.isSingular();
|
|
53
|
-
|
|
54
|
-
if (singular) {
|
|
55
|
-
metavariable = this.reference.getMetavariable();
|
|
56
|
-
}
|
|
42
|
+
getMetavariableName() {
|
|
43
|
+
const frameNode = this.getFrameNode(),
|
|
44
|
+
metavariableName = frameNode.getMetavariableName();
|
|
57
45
|
|
|
58
|
-
return
|
|
46
|
+
return metavariableName;
|
|
59
47
|
}
|
|
60
48
|
|
|
61
49
|
matchFrameNode(frameNode) {
|
|
@@ -196,21 +184,24 @@ export default define(class Frame extends Element {
|
|
|
196
184
|
} else {
|
|
197
185
|
let validates = false;
|
|
198
186
|
|
|
199
|
-
const
|
|
200
|
-
assumptionsValidate = this.validateAssumptions(stated, context);
|
|
187
|
+
const metavariableValidates = this.validatMetavariable(stated, context);
|
|
201
188
|
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
validatesWhenDerived = false;
|
|
189
|
+
if (metavariableValidates) {
|
|
190
|
+
const assumptionsValidate = this.validateAssumptions(stated, context);
|
|
205
191
|
|
|
206
|
-
if (
|
|
207
|
-
validatesWhenStated =
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
192
|
+
if (assumptionsValidate) {
|
|
193
|
+
let validatesWhenStated = false,
|
|
194
|
+
validatesWhenDerived = false;
|
|
195
|
+
|
|
196
|
+
if (stated) {
|
|
197
|
+
validatesWhenStated = this.validateWhenStated(context);
|
|
198
|
+
} else {
|
|
199
|
+
validatesWhenDerived = this.validateWhenDerived(context);
|
|
200
|
+
}
|
|
211
201
|
|
|
212
|
-
|
|
213
|
-
|
|
202
|
+
if (validatesWhenStated || validatesWhenDerived) {
|
|
203
|
+
validates = true;
|
|
204
|
+
}
|
|
214
205
|
}
|
|
215
206
|
}
|
|
216
207
|
|
|
@@ -264,36 +255,6 @@ export default define(class Frame extends Element {
|
|
|
264
255
|
return validatesWhenDerived;
|
|
265
256
|
}
|
|
266
257
|
|
|
267
|
-
validateReference(stated, context) {
|
|
268
|
-
let referenceValidates = false;
|
|
269
|
-
|
|
270
|
-
const singular = this.isSingular();
|
|
271
|
-
|
|
272
|
-
if (singular) {
|
|
273
|
-
const frameString = this.getString(), ///
|
|
274
|
-
referenceString = this.reference.getString();
|
|
275
|
-
|
|
276
|
-
context.trace(`Validating the '${frameString}' frame's '${referenceString}' reference...`);
|
|
277
|
-
|
|
278
|
-
const metavariable = this.getMetavariable(),
|
|
279
|
-
metaTypeName = FRAME_META_TYPE_NAME,
|
|
280
|
-
frameMetaType = context.findMetaTypeByMetaTypeName(metaTypeName),
|
|
281
|
-
validatesGivenMetaType = metavariable.validateGivenMetaType(frameMetaType, context);
|
|
282
|
-
|
|
283
|
-
if (validatesGivenMetaType) {
|
|
284
|
-
referenceValidates = true;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
if (referenceValidates) {
|
|
288
|
-
context.debug(`...validated the '${frameString}' frame's '${referenceString}' reference.`);
|
|
289
|
-
}
|
|
290
|
-
} else {
|
|
291
|
-
referenceValidates = true;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
return referenceValidates;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
258
|
validateAssumption(assumption, context) {
|
|
298
259
|
let assumptionValidates;
|
|
299
260
|
|
|
@@ -348,29 +309,30 @@ export default define(class Frame extends Element {
|
|
|
348
309
|
return assumptionsValidate;
|
|
349
310
|
}
|
|
350
311
|
|
|
351
|
-
|
|
352
|
-
let
|
|
312
|
+
validatMetavariable(stated, context) {
|
|
313
|
+
let metavariableValidates = false;
|
|
353
314
|
|
|
354
|
-
const
|
|
355
|
-
metaTypeString = metaType.getString();
|
|
315
|
+
const singular = this.isSingular();
|
|
356
316
|
|
|
357
|
-
|
|
317
|
+
if (singular) {
|
|
318
|
+
const frameString = this.getString(), ///
|
|
319
|
+
metavariableString = this.metavariable.getString();
|
|
358
320
|
|
|
359
|
-
|
|
321
|
+
context.trace(`Validating the '${frameString}' frame's '${metavariableString}' metavariable...`);
|
|
360
322
|
|
|
361
|
-
|
|
362
|
-
|
|
323
|
+
const metavariable = this.metavariable.validate(context), ///
|
|
324
|
+
metaTypeName = FRAME_META_TYPE_NAME,
|
|
325
|
+
frameMetaType = context.findMetaTypeByMetaTypeName(metaTypeName),
|
|
326
|
+
metavariableMetaTypeEqualToFrameMetaType = metavariable.isMetaTypeEqualTo(frameMetaType);
|
|
363
327
|
|
|
364
|
-
if (
|
|
365
|
-
|
|
328
|
+
if (metavariableMetaTypeEqualToFrameMetaType) {
|
|
329
|
+
metavariableValidates = true;
|
|
366
330
|
}
|
|
331
|
+
} else {
|
|
332
|
+
metavariableValidates = true;
|
|
367
333
|
}
|
|
368
334
|
|
|
369
|
-
|
|
370
|
-
context.debug(`...validated the '${frameString}' frame given the '${metaTypeString}' meta-type.`);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
return validatesGivenMetaType;
|
|
335
|
+
return metavariableValidates;
|
|
374
336
|
}
|
|
375
337
|
|
|
376
338
|
toJSON() {
|
|
@@ -389,12 +351,12 @@ export default define(class Frame extends Element {
|
|
|
389
351
|
const { string } = json,
|
|
390
352
|
frameNode = instantiateFrame(string, context),
|
|
391
353
|
node = frameNode, ///
|
|
392
|
-
|
|
393
|
-
|
|
354
|
+
assumptions = assumptionsFromFrameNode(frameNode, context),
|
|
355
|
+
metavariable = metavariableFromFrameNode(frameNode, context);
|
|
394
356
|
|
|
395
357
|
context = null;
|
|
396
358
|
|
|
397
|
-
const frame = new Frame(context, string, node, assumptions,
|
|
359
|
+
const frame = new Frame(context, string, node, assumptions, metavariable);
|
|
398
360
|
|
|
399
361
|
return frame;
|
|
400
362
|
}, context);
|
|
@@ -7,17 +7,17 @@ import elements from "../elements";
|
|
|
7
7
|
import { define } from "../elements";
|
|
8
8
|
import { literally } from "../utilities/context";
|
|
9
9
|
import { EMPTY_STRING } from "../constants";
|
|
10
|
-
import { metaTypeToMetaTypeJSON } from "../utilities/json";
|
|
11
10
|
import { instantiateMetavariable } from "../process/instantiate";
|
|
12
|
-
import {
|
|
13
|
-
import { typeFromJSON, metaTypeFromJSON, typeToTypeJSON } from "../utilities/json";
|
|
11
|
+
import { metaTypeFromJSON, metaTypeToMetaTypeJSON } from "../utilities/json";
|
|
14
12
|
import { unifyMetavariable, unifyMetavariableIntrinsically } from "../process/unify";
|
|
13
|
+
import { nameFromMetavariableNode, termFromMetavariableNode, typeFromMetavariableNode } from "../utilities/element";
|
|
15
14
|
|
|
16
15
|
export default define(class Metavariable extends Element {
|
|
17
|
-
constructor(context, string, node, name, type, metaType) {
|
|
16
|
+
constructor(context, string, node, name, term, type, metaType) {
|
|
18
17
|
super(context, string, node);
|
|
19
18
|
|
|
20
19
|
this.name = name;
|
|
20
|
+
this.term = term;
|
|
21
21
|
this.type = type;
|
|
22
22
|
this.metaType = metaType;
|
|
23
23
|
}
|
|
@@ -26,6 +26,10 @@ export default define(class Metavariable extends Element {
|
|
|
26
26
|
return this.name;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
getTerm() {
|
|
30
|
+
return this.term;
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
getType() {
|
|
30
34
|
return this.type;
|
|
31
35
|
}
|
|
@@ -34,28 +38,26 @@ export default define(class Metavariable extends Element {
|
|
|
34
38
|
return this.metaType;
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
setType(type) {
|
|
38
|
-
this.type = type;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
41
|
setMetaType(metaType) {
|
|
42
42
|
this.metaType = metaType;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
getMetavariableNode() {
|
|
46
46
|
const node = this.getNode(),
|
|
47
|
-
|
|
47
|
+
metavariableNode = node; ///
|
|
48
48
|
|
|
49
|
-
return
|
|
49
|
+
return metavariableNode;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
getMetavariableName() {
|
|
53
|
-
const
|
|
54
|
-
metavariableName =
|
|
53
|
+
const metavariableNode = this.getMetavariableNode(),
|
|
54
|
+
metavariableName = metavariableNode.getMetavariableName();
|
|
55
55
|
|
|
56
56
|
return metavariableName;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
isMetaTypeEqualTo(metaType) { return this.metaType.isEqualTo(metaType); }
|
|
60
|
+
|
|
59
61
|
compare(metavariable) {
|
|
60
62
|
const metavariableName = metavariable.getName(),
|
|
61
63
|
comparesToMetavariableName = this.compareMetavariableName(metavariableName),
|
|
@@ -64,8 +66,6 @@ export default define(class Metavariable extends Element {
|
|
|
64
66
|
return comparesToMetavariable;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
isMetaTypeEqualTo(metaType) { return this.metaType.isEqualTo(metaType); }
|
|
68
|
-
|
|
69
69
|
compareMetavariableName(metavariableName) {
|
|
70
70
|
const nameMetavariableName = (this.name === metavariableName),
|
|
71
71
|
comparesToMetavariableName = nameMetavariableName; ///
|
|
@@ -85,52 +85,140 @@ export default define(class Metavariable extends Element {
|
|
|
85
85
|
return metavariableNodeMatches;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
verify(context) {
|
|
89
|
+
let verifies = false;
|
|
90
|
+
|
|
91
|
+
const metavariableString = this.getString();
|
|
92
|
+
|
|
93
|
+
context.trace(`Verifying the '${metavariableString}' metavariable...`);
|
|
94
|
+
|
|
95
|
+
const termVerifies = this.verifyTerm(context);
|
|
96
|
+
|
|
97
|
+
if (termVerifies) {
|
|
98
|
+
const typeVerifies = this.verifyType(context);
|
|
99
|
+
|
|
100
|
+
if (typeVerifies) {
|
|
101
|
+
verifies = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (verifies) {
|
|
106
|
+
context.debug(`...verified the '${metavariableString}' metavariable.`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return verifies;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
verifyTerm(context) {
|
|
113
|
+
let termVerifies = true; ///
|
|
114
|
+
|
|
115
|
+
if (this.term !== null) {
|
|
116
|
+
const termString = this.term.getString(),
|
|
117
|
+
metavariableString = this.getString();
|
|
118
|
+
|
|
119
|
+
termVerifies = false;
|
|
120
|
+
|
|
121
|
+
context.trace(`A '${termString}' term is present in the '${metavariableString}' metavariable.`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return termVerifies;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
verifyType(context) {
|
|
128
|
+
let typeVerifies = true; ///
|
|
129
|
+
|
|
130
|
+
if (this.type !== null) {
|
|
131
|
+
const typeString = this.type.getString(),
|
|
132
|
+
metavariableString = this.getString();
|
|
133
|
+
|
|
134
|
+
context.trace(`Verifying the '${metavariableString}' metavariable's '${typeString}' type...`);
|
|
135
|
+
|
|
136
|
+
const typeName = this.type.getName(),
|
|
137
|
+
typePresent = context.isTypePresentByTypeName(typeName);
|
|
138
|
+
|
|
139
|
+
if (!typePresent) {
|
|
140
|
+
typeVerifies = false;
|
|
141
|
+
|
|
142
|
+
context.error(`Type '${typeName}' is not present.`);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (typeVerifies) {
|
|
146
|
+
context.debug(`...verifieds the '${metavariableString}' metavariable's '${typeString}' type.`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return typeVerifies;
|
|
151
|
+
}
|
|
152
|
+
|
|
88
153
|
validate(context) {
|
|
89
|
-
let
|
|
154
|
+
let metavariable = null;
|
|
90
155
|
|
|
91
156
|
const metavariableString = this.getString(); ///
|
|
92
157
|
|
|
93
158
|
context.trace(`Validating the '${metavariableString}' metavariable...`);
|
|
94
159
|
|
|
95
|
-
|
|
96
|
-
|
|
160
|
+
let validates = false;
|
|
161
|
+
|
|
162
|
+
const termValidates = this.validateTerm(context);
|
|
163
|
+
|
|
164
|
+
if (termValidates) {
|
|
165
|
+
const typeValidates = this.validateType(context);
|
|
97
166
|
|
|
98
|
-
|
|
99
|
-
|
|
167
|
+
if (typeValidates) {
|
|
168
|
+
const metavariableName = this.name, ///
|
|
169
|
+
metavariable = context.findMetavariableByMetavariableName(metavariableName);
|
|
170
|
+
|
|
171
|
+
if (metavariable !== null) {
|
|
172
|
+
const metaType = metavariable.getMetaType();
|
|
173
|
+
|
|
174
|
+
this.metaType = metaType;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
validates = true;
|
|
178
|
+
}
|
|
100
179
|
}
|
|
101
180
|
|
|
102
181
|
if (validates) {
|
|
182
|
+
metavariable = this; ///
|
|
183
|
+
|
|
103
184
|
context.debug(`...validated the '${metavariableString}' metavariable.`);
|
|
104
185
|
}
|
|
105
186
|
|
|
106
|
-
return
|
|
187
|
+
return metavariable;
|
|
107
188
|
}
|
|
108
189
|
|
|
109
|
-
|
|
110
|
-
let
|
|
190
|
+
validateTerm(context) {
|
|
191
|
+
let termValidates = true;
|
|
111
192
|
|
|
112
|
-
|
|
113
|
-
|
|
193
|
+
if (this.term !== null) {
|
|
194
|
+
const termString = this.term.getString(),
|
|
195
|
+
metavariableString = this.getString();
|
|
114
196
|
|
|
115
|
-
|
|
197
|
+
context.trace(`Validating the '${metavariableString}' metavariable's '${termString}' term...`);
|
|
116
198
|
|
|
117
|
-
|
|
199
|
+
termValidates = this.term.validate(context);
|
|
118
200
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (metavariable !== null) {
|
|
122
|
-
const metavariableMetaTypeEqualToMetaType = metavariable.isMetaTypeEqualTo(metaType);
|
|
123
|
-
|
|
124
|
-
if (metavariableMetaTypeEqualToMetaType) {
|
|
125
|
-
validatesGivenMetaType = true;
|
|
201
|
+
if (termValidates) {
|
|
202
|
+
context.debug(`...validated the '${metavariableString}' metavariable's '${termString}' term.`);
|
|
126
203
|
}
|
|
127
204
|
}
|
|
128
205
|
|
|
129
|
-
|
|
130
|
-
|
|
206
|
+
return termValidates;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
validateType(context) {
|
|
210
|
+
let typeValidates = true; ///
|
|
211
|
+
|
|
212
|
+
if (this.type !== null) {
|
|
213
|
+
const typeString = this.type.getString(),
|
|
214
|
+
metavariableString = this.getString();
|
|
215
|
+
|
|
216
|
+
typeValidates = false;
|
|
217
|
+
|
|
218
|
+
context.trace(`A '${typeString}' type is present in the '${metavariableString}' metavariable.`);
|
|
131
219
|
}
|
|
132
220
|
|
|
133
|
-
return
|
|
221
|
+
return typeValidates;
|
|
134
222
|
}
|
|
135
223
|
|
|
136
224
|
unifyFrame(frame, generalContext, specificContext) {
|
|
@@ -438,14 +526,11 @@ export default define(class Metavariable extends Element {
|
|
|
438
526
|
}
|
|
439
527
|
|
|
440
528
|
toJSON() {
|
|
441
|
-
const
|
|
442
|
-
metaTypeJSON = metaTypeToMetaTypeJSON(this.metaType),
|
|
443
|
-
type = typeJSON, ///
|
|
529
|
+
const metaTypeJSON = metaTypeToMetaTypeJSON(this.metaType),
|
|
444
530
|
metaType = metaTypeJSON, ///
|
|
445
531
|
string = this.getString(), ///
|
|
446
532
|
json = {
|
|
447
533
|
string,
|
|
448
|
-
type,
|
|
449
534
|
metaType
|
|
450
535
|
};
|
|
451
536
|
|
|
@@ -460,9 +545,10 @@ export default define(class Metavariable extends Element {
|
|
|
460
545
|
metavariableNode = instantiateMetavariable(string, context),
|
|
461
546
|
node = metavariableNode, ///
|
|
462
547
|
name = nameFromMetavariableNode(metavariableNode, context),
|
|
463
|
-
|
|
548
|
+
term = termFromMetavariableNode(metavariableNode, context),
|
|
549
|
+
type = typeFromMetavariableNode(metavariableNode, context),
|
|
464
550
|
metaType = metaTypeFromJSON(json, context),
|
|
465
|
-
metavariable = new Metavariable(context, string, node, name, type, metaType);
|
|
551
|
+
metavariable = new Metavariable(context, string, node, name, term, type, metaType);
|
|
466
552
|
|
|
467
553
|
return metavariable;
|
|
468
554
|
}, context);
|
|
@@ -133,7 +133,7 @@ export default define(class Step extends ProofAssertion {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
validateReference(context) {
|
|
136
|
-
let referenceValidates = true;
|
|
136
|
+
let referenceValidates = true; ///
|
|
137
137
|
|
|
138
138
|
if (this.reference !== null) {
|
|
139
139
|
const stepString = this.getString(), ///
|
|
@@ -167,8 +167,8 @@ export default define(class Step extends ProofAssertion {
|
|
|
167
167
|
const stated = true,
|
|
168
168
|
satisfiesAssertion = this.satisfiesAssertion.validate(stated, context);
|
|
169
169
|
|
|
170
|
-
if (satisfiesAssertion
|
|
171
|
-
satisfiesAssertionValidates =
|
|
170
|
+
if (satisfiesAssertion === null) {
|
|
171
|
+
satisfiesAssertionValidates = false;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
if (satisfiesAssertionValidates) {
|