occam-verify-cli 1.0.768 → 1.0.776
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 +11 -11
- package/lib/context/illative.js +28 -0
- package/lib/context/nested.js +27 -0
- package/lib/context/proof.js +232 -0
- package/lib/context/thetic.js +28 -0
- package/lib/context.js +15 -21
- package/lib/element/assertion/contained.js +24 -22
- package/lib/element/assertion/defined.js +20 -19
- package/lib/element/assertion/property.js +14 -13
- package/lib/element/assertion/satisfies.js +8 -9
- package/lib/element/assertion/subproof.js +23 -26
- package/lib/element/assertion/type.js +9 -11
- package/lib/element/assumption.js +32 -39
- package/lib/element/combinator/bracketed.js +3 -3
- package/lib/element/combinator.js +20 -20
- package/lib/element/conclusion.js +33 -29
- package/lib/element/constructor.js +19 -18
- package/lib/element/deduction.js +33 -29
- package/lib/element/equality.js +13 -15
- package/lib/element/equivalence.js +59 -52
- package/lib/element/frame.js +41 -34
- package/lib/element/hypothesis.js +7 -5
- package/lib/element/judgement.js +32 -73
- package/lib/element/label.js +22 -22
- package/lib/element/metavariable.js +23 -7
- package/lib/element/proofAssertion/premise.js +48 -35
- package/lib/element/proofAssertion/step.js +35 -20
- package/lib/element/proofAssertion/supposition.js +48 -34
- package/lib/element/proofAssertion.js +1 -14
- package/lib/element/reference.js +80 -53
- package/lib/element/signature.js +44 -3
- package/lib/element/statement.js +28 -29
- package/lib/element/subproof.js +2 -2
- package/lib/element/substitution/frame.js +24 -19
- package/lib/element/substitution/metaLevel.js +31 -27
- package/lib/element/substitution/reference.js +11 -10
- package/lib/element/substitution/statement.js +30 -23
- package/lib/element/substitution/term.js +11 -10
- package/lib/element/term.js +24 -20
- package/lib/element/topLevelMetaAssertion.js +2 -2
- package/lib/element/variable.js +6 -2
- package/lib/process/assign.js +10 -4
- package/lib/process/unify.js +8 -8
- package/lib/process/validate.js +10 -8
- package/lib/utilities/context.js +68 -23
- package/lib/utilities/element.js +55 -27
- package/lib/utilities/json.js +8 -8
- package/lib/utilities/statement.js +1 -8
- package/lib/utilities/string.js +12 -1
- package/lib/utilities/unification.js +9 -7
- package/lib/utilities/validation.js +39 -31
- package/package.json +1 -1
- package/src/context/file/nominal.js +14 -16
- package/src/context/illative.js +17 -0
- package/src/context/nested.js +15 -0
- package/src/context/{scoped.js → proof.js} +73 -73
- package/src/context/thetic.js +17 -0
- package/src/context.js +23 -36
- package/src/element/assertion/contained.js +28 -28
- package/src/element/assertion/defined.js +23 -23
- package/src/element/assertion/property.js +15 -14
- package/src/element/assertion/satisfies.js +7 -9
- package/src/element/assertion/subproof.js +26 -31
- package/src/element/assertion/type.js +10 -12
- package/src/element/assumption.js +33 -54
- package/src/element/combinator/bracketed.js +2 -2
- package/src/element/combinator.js +23 -29
- package/src/element/conclusion.js +37 -40
- package/src/element/constructor.js +29 -34
- package/src/element/deduction.js +36 -39
- package/src/element/equality.js +16 -18
- package/src/element/equivalence.js +76 -67
- package/src/element/frame.js +42 -34
- package/src/element/hypothesis.js +7 -6
- package/src/element/judgement.js +34 -44
- package/src/element/label.js +25 -31
- package/src/element/metavariable.js +32 -12
- package/src/element/proofAssertion/premise.js +63 -49
- package/src/element/proofAssertion/step.js +43 -23
- package/src/element/proofAssertion/supposition.js +64 -50
- package/src/element/proofAssertion.js +0 -22
- package/src/element/reference.js +119 -80
- package/src/element/signature.js +5 -2
- package/src/element/statement.js +30 -35
- package/src/element/subproof.js +1 -1
- package/src/element/substitution/frame.js +27 -26
- package/src/element/substitution/metaLevel.js +38 -42
- package/src/element/substitution/reference.js +13 -14
- package/src/element/substitution/statement.js +35 -33
- package/src/element/substitution/term.js +13 -14
- package/src/element/term.js +42 -34
- package/src/element/topLevelMetaAssertion.js +1 -1
- package/src/element/variable.js +8 -1
- package/src/process/assign.js +9 -3
- package/src/process/unify.js +7 -7
- package/src/process/validate.js +9 -8
- package/src/utilities/context.js +82 -31
- package/src/utilities/element.js +68 -31
- package/src/utilities/json.js +13 -13
- package/src/utilities/statement.js +1 -9
- package/src/utilities/string.js +16 -2
- package/src/utilities/unification.js +10 -9
- package/src/utilities/validation.js +50 -38
- package/lib/context/scoped.js +0 -232
- package/lib/utilities/term.js +0 -17
- package/src/utilities/term.js +0 -10
package/src/element/frame.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import { instantiate } from "../utilities/context";
|
|
7
6
|
import { instantiateFrame } from "../process/instantiate";
|
|
8
7
|
import { FRAME_META_TYPE_NAME } from "../metaTypeNames";
|
|
9
8
|
import { metavariableFromFrameNode } from "../utilities/element";
|
|
10
|
-
import {
|
|
9
|
+
import { descend, reconcile, instantiate } from "../utilities/context";
|
|
10
|
+
import { assumptionsStringFromAssumptions, metaLevelSubstitutionsStringFromMetaLevelSubstitutions } from "../utilities/string";
|
|
11
11
|
|
|
12
12
|
export default define(class Frame extends Element {
|
|
13
13
|
constructor(context, string, node, assumptions, metavariable) {
|
|
@@ -97,17 +97,17 @@ export default define(class Frame extends Element {
|
|
|
97
97
|
return comparesToParamter;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
let
|
|
100
|
+
compareMetaLevelSubstitution(metaLevelSubstitution, context) {
|
|
101
|
+
let comparesToMetaLevelSubstitution = false;
|
|
102
102
|
|
|
103
103
|
const frameString = this.getString(), ///
|
|
104
|
-
|
|
104
|
+
metaLevelSubstitutioString = metaLevelSubstitution.getString();
|
|
105
105
|
|
|
106
|
-
context.trace(`Comparing the '${frameString}' frame to the '${
|
|
106
|
+
context.trace(`Comparing the '${frameString}' frame to the '${metaLevelSubstitutioString}' meta-level substitutio...`);
|
|
107
107
|
|
|
108
|
-
if (!
|
|
109
|
-
|
|
110
|
-
const assumptionComparesToSubstitution = assumption.
|
|
108
|
+
if (!comparesToMetaLevelSubstitution) {
|
|
109
|
+
comparesToMetaLevelSubstitution = this.assumptions.some((assumption) => {
|
|
110
|
+
const assumptionComparesToSubstitution = assumption.compareMetaLevelSubstitution(metaLevelSubstitution, context);
|
|
111
111
|
|
|
112
112
|
if (assumptionComparesToSubstitution) {
|
|
113
113
|
return true;
|
|
@@ -115,34 +115,34 @@ export default define(class Frame extends Element {
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
if (
|
|
119
|
-
context.debug(`...compared the the '${frameString}' frame to the '${
|
|
118
|
+
if (comparesToMetaLevelSubstitution) {
|
|
119
|
+
context.debug(`...compared the the '${frameString}' frame to the '${metaLevelSubstitutioString}' meta-Level-substituution.`);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
return
|
|
122
|
+
return comparesToMetaLevelSubstitution;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
let
|
|
125
|
+
compareMetaLevelSubstitutions(metaLevelSubstitutions, context) {
|
|
126
|
+
let comparesToMetaLevelSubstitutions;
|
|
127
127
|
|
|
128
128
|
const frameString = this.getString(), ///
|
|
129
|
-
|
|
129
|
+
metaLevelSubstitutionsString = metaLevelSubstitutionsStringFromMetaLevelSubstitutions(metaLevelSubstitutions);
|
|
130
130
|
|
|
131
|
-
context.trace(`Comparing the '${frameString}' frame to the '${
|
|
131
|
+
context.trace(`Comparing the '${frameString}' frame to the '${metaLevelSubstitutionsString}' meta-level substitutio...`);
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
const
|
|
133
|
+
comparesToMetaLevelSubstitutions = metaLevelSubstitutions.every((metaLevelSubstitution) => {
|
|
134
|
+
const compaaresToMetaLevelSubstitution = this.compareMetaLevelSubstitution(metaLevelSubstitution, context);
|
|
135
135
|
|
|
136
|
-
if (
|
|
136
|
+
if (compaaresToMetaLevelSubstitution) {
|
|
137
137
|
return true;
|
|
138
138
|
}
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
-
if (
|
|
142
|
-
context.debug(`...compared the '${frameString}' frame to the '${
|
|
141
|
+
if (comparesToMetaLevelSubstitutions) {
|
|
142
|
+
context.debug(`...compared the '${frameString}' frame to the '${metaLevelSubstitutionsString}' metaLevelSubstitutions.`);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
return
|
|
145
|
+
return comparesToMetaLevelSubstitutions;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
compareMetavariableName(metavariableName) {
|
|
@@ -163,7 +163,7 @@ export default define(class Frame extends Element {
|
|
|
163
163
|
return comparesToMetavariableName;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
validate(
|
|
166
|
+
validate(context) {
|
|
167
167
|
let frame = null;
|
|
168
168
|
|
|
169
169
|
const frameString = this.getString(); ///
|
|
@@ -180,12 +180,14 @@ export default define(class Frame extends Element {
|
|
|
180
180
|
} else {
|
|
181
181
|
let validates = false;
|
|
182
182
|
|
|
183
|
-
const metavariableValidates = this.validatMetavariable(
|
|
183
|
+
const metavariableValidates = this.validatMetavariable(context);
|
|
184
184
|
|
|
185
185
|
if (metavariableValidates) {
|
|
186
|
-
const assumptionsValidate = this.validateAssumptions(
|
|
186
|
+
const assumptionsValidate = this.validateAssumptions(context);
|
|
187
187
|
|
|
188
188
|
if (assumptionsValidate) {
|
|
189
|
+
const stated = context.isStated();
|
|
190
|
+
|
|
189
191
|
let validatesWhenStated = false,
|
|
190
192
|
validatesWhenDerived = false;
|
|
191
193
|
|
|
@@ -251,17 +253,25 @@ export default define(class Frame extends Element {
|
|
|
251
253
|
return validatesWhenDerived;
|
|
252
254
|
}
|
|
253
255
|
|
|
254
|
-
validateAssumption(assumption, context) {
|
|
255
|
-
let assumptionValidates;
|
|
256
|
+
validateAssumption(assumption, assumptions, context) {
|
|
257
|
+
let assumptionValidates = false;
|
|
256
258
|
|
|
257
259
|
const frameString = this.getString(), ///
|
|
258
260
|
assumptionstring = assumption.getString();
|
|
259
261
|
|
|
260
262
|
context.trace(`Validating the '${frameString}' frame's '${assumptionstring}' assumption.`);
|
|
261
263
|
|
|
262
|
-
|
|
264
|
+
reconcile((context) => {
|
|
265
|
+
descend((context) => {
|
|
266
|
+
assumption = assumption.validate(context); ///
|
|
263
267
|
|
|
264
|
-
|
|
268
|
+
if (assumption !== null) {
|
|
269
|
+
assumptions.push(assumption);
|
|
270
|
+
|
|
271
|
+
assumptionValidates = true;
|
|
272
|
+
}
|
|
273
|
+
}, context);
|
|
274
|
+
}, context);
|
|
265
275
|
|
|
266
276
|
if (assumptionValidates) {
|
|
267
277
|
context.debug(`...validated the '${frameString}' frame's '${assumptionstring}' assumption.`);
|
|
@@ -270,7 +280,7 @@ export default define(class Frame extends Element {
|
|
|
270
280
|
return assumptionValidates;
|
|
271
281
|
}
|
|
272
282
|
|
|
273
|
-
validateAssumptions(
|
|
283
|
+
validateAssumptions(context) {
|
|
274
284
|
let assumptionsValidate;
|
|
275
285
|
|
|
276
286
|
const singular = this.isSingular();
|
|
@@ -284,11 +294,9 @@ export default define(class Frame extends Element {
|
|
|
284
294
|
const assumptions = [];
|
|
285
295
|
|
|
286
296
|
assumptionsValidate = this.assumptions.every((assumption) => {
|
|
287
|
-
const assumptionValidates = this.validateAssumption(assumption, context);
|
|
297
|
+
const assumptionValidates = this.validateAssumption(assumption, assumptions, context);
|
|
288
298
|
|
|
289
299
|
if (assumptionValidates) {
|
|
290
|
-
assumptions.push(assumption);
|
|
291
|
-
|
|
292
300
|
return true;
|
|
293
301
|
}
|
|
294
302
|
});
|
|
@@ -305,7 +313,7 @@ export default define(class Frame extends Element {
|
|
|
305
313
|
return assumptionsValidate;
|
|
306
314
|
}
|
|
307
315
|
|
|
308
|
-
validatMetavariable(
|
|
316
|
+
validatMetavariable(context) {
|
|
309
317
|
let metavariableValidates = false;
|
|
310
318
|
|
|
311
319
|
const singular = this.isSingular();
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import {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
|
|
|
@@ -61,12 +61,13 @@ export default define(class Hypothesis extends Element {
|
|
|
61
61
|
} else if (this.statement !== null) {
|
|
62
62
|
let statementValidates = false;
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
descend((context) => {
|
|
65
|
+
const statement = this.statement.validate(context);
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
if (statement !== null) {
|
|
68
|
+
statementValidates = true;
|
|
69
|
+
}
|
|
70
|
+
}, context);
|
|
70
71
|
|
|
71
72
|
if (statementValidates) {
|
|
72
73
|
const subproofOrProofAssertion = this; ///
|
package/src/element/judgement.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
|
-
import elements from "../elements";
|
|
6
|
-
|
|
7
5
|
import { define } from "../elements";
|
|
8
6
|
import { instantiateJudgement } from "../process/instantiate";
|
|
9
7
|
import { reconcile, instantiate } from "../utilities/context";
|
|
@@ -41,8 +39,6 @@ export default define(class Judgement extends Element {
|
|
|
41
39
|
|
|
42
40
|
getMetavariable() { return this.frame.getMetavariable(); }
|
|
43
41
|
|
|
44
|
-
compareMetavariableName(metavariableName) { return this.frame.compareMetavariableName(metavariableName); }
|
|
45
|
-
|
|
46
42
|
matchJudgementNode(judgementNode) {
|
|
47
43
|
const node = judgementNode, ///
|
|
48
44
|
nodeMatches = this.matchNode(node),
|
|
@@ -51,6 +47,8 @@ export default define(class Judgement extends Element {
|
|
|
51
47
|
return judgementNodeMatches;
|
|
52
48
|
}
|
|
53
49
|
|
|
50
|
+
compareMetavariableName(metavariableName) { return this.frame.compareMetavariableName(metavariableName); }
|
|
51
|
+
|
|
54
52
|
findValidJudgement(context) {
|
|
55
53
|
const judgementNode = this.getJudgementNode(),
|
|
56
54
|
judgement = context.findJudgementByJudgementNode(judgementNode),
|
|
@@ -59,7 +57,7 @@ export default define(class Judgement extends Element {
|
|
|
59
57
|
return validJudgemenet;
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
validate(
|
|
60
|
+
validate(context) {
|
|
63
61
|
let judgement = null;
|
|
64
62
|
|
|
65
63
|
const judgementString = this.getString(); ///
|
|
@@ -76,34 +74,36 @@ export default define(class Judgement extends Element {
|
|
|
76
74
|
let validates = false;
|
|
77
75
|
|
|
78
76
|
reconcile((context) => {
|
|
77
|
+
const frameValidates = this.validateFrame(context);
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const frameValidates = this.validateFrame(stated, context);
|
|
79
|
+
if (frameValidates) {
|
|
80
|
+
const assumptionValidates = this.validateAssumption(context);
|
|
83
81
|
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
if (assumptionValidates) {
|
|
83
|
+
const stated = context.isStated();
|
|
86
84
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
validatesWhenDerived = false;
|
|
85
|
+
let validatesWhenStated = false,
|
|
86
|
+
validatesWhenDerived = false;
|
|
90
87
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
if (stated) {
|
|
89
|
+
validatesWhenStated = this.validateWhenStated(context);
|
|
90
|
+
} else {
|
|
91
|
+
validatesWhenDerived = this.validateWhenDerived(context);
|
|
92
|
+
}
|
|
96
93
|
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
if (validatesWhenStated || validatesWhenDerived) {
|
|
95
|
+
validates = true;
|
|
96
|
+
}
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
|
-
}
|
|
99
|
+
}, context);
|
|
102
100
|
|
|
103
101
|
if (validates) {
|
|
104
102
|
judgement = this; ///
|
|
105
103
|
|
|
106
|
-
|
|
104
|
+
this.assign(context);
|
|
105
|
+
|
|
106
|
+
context.addJudgement(judgement);
|
|
107
107
|
|
|
108
108
|
context.debug(`...validated the '${judgementString}' judgement.`);
|
|
109
109
|
}
|
|
@@ -112,7 +112,7 @@ export default define(class Judgement extends Element {
|
|
|
112
112
|
return judgement;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
validateFrame(
|
|
115
|
+
validateFrame(context) {
|
|
116
116
|
let frameValidates = false;
|
|
117
117
|
|
|
118
118
|
const frameString = this.frame.getString(),
|
|
@@ -120,7 +120,7 @@ export default define(class Judgement extends Element {
|
|
|
120
120
|
|
|
121
121
|
context.trace(`Validating the '${judgementString}' judgement's '${frameString}' frame...`);
|
|
122
122
|
|
|
123
|
-
const frame = this.frame.validate(
|
|
123
|
+
const frame = this.frame.validate(context);
|
|
124
124
|
|
|
125
125
|
if (frame !== null) {
|
|
126
126
|
this.frame = frame;
|
|
@@ -135,7 +135,7 @@ export default define(class Judgement extends Element {
|
|
|
135
135
|
return frameValidates;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
validateAssumption(
|
|
138
|
+
validateAssumption(context) {
|
|
139
139
|
let assumptionValidates = false;
|
|
140
140
|
|
|
141
141
|
const assumptionString = this.assumption.getString(),
|
|
@@ -143,7 +143,7 @@ export default define(class Judgement extends Element {
|
|
|
143
143
|
|
|
144
144
|
context.trace(`Validating the '${judgementString}' judgement's '${assumptionString}' assumption...`);
|
|
145
145
|
|
|
146
|
-
const assumption = this.assumption.validate(
|
|
146
|
+
const assumption = this.assumption.validate(context);
|
|
147
147
|
|
|
148
148
|
if (assumption !== null) {
|
|
149
149
|
this.assumption = assumption;
|
|
@@ -181,11 +181,9 @@ export default define(class Judgement extends Element {
|
|
|
181
181
|
|
|
182
182
|
context.trace(`Validating the '${judgementString}' derived judgement...`);
|
|
183
183
|
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
substitutions = topLevelMetaAssertion.getSubstitutions(),
|
|
188
|
-
frameComparesToSubstitutions = this.frame.compareSubstitutions(substitutions, context);
|
|
184
|
+
const topLevelMetaAssertion = this.assumption.getTopLevelMetaAssertion(),
|
|
185
|
+
metaLevelSubstitutions = topLevelMetaAssertion.getMetaLevelSubstitutions(),
|
|
186
|
+
frameComparesToSubstitutions = this.frame.compareMetaLevelSubstitutions(metaLevelSubstitutions, context);
|
|
189
187
|
|
|
190
188
|
if (frameComparesToSubstitutions) {
|
|
191
189
|
validatesWhenDerived = true;
|
|
@@ -198,16 +196,17 @@ export default define(class Judgement extends Element {
|
|
|
198
196
|
return validatesWhenDerived;
|
|
199
197
|
}
|
|
200
198
|
|
|
201
|
-
assign(
|
|
199
|
+
assign(context) {
|
|
200
|
+
const stated = context.isStated();
|
|
201
|
+
|
|
202
202
|
if (!stated) {
|
|
203
203
|
return;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
const judgement = this, ///
|
|
207
|
-
judgementAssignment = judgementAssignmentFromJudgement(judgement, context)
|
|
208
|
-
assignment = judgementAssignment; ///
|
|
207
|
+
judgementAssignment = judgementAssignmentFromJudgement(judgement, context);
|
|
209
208
|
|
|
210
|
-
context.addAssignment(
|
|
209
|
+
context.addAssignment(judgementAssignment);
|
|
211
210
|
}
|
|
212
211
|
|
|
213
212
|
toJSON() {
|
|
@@ -251,12 +250,3 @@ function assumptionFromJudgementNode(judgementNode, context) {
|
|
|
251
250
|
|
|
252
251
|
return assumption;
|
|
253
252
|
}
|
|
254
|
-
|
|
255
|
-
function referenceFromMetavariable(metavariable, context) {
|
|
256
|
-
const { Reference } = elements,
|
|
257
|
-
metavariableNode = metavariable.getNode(),
|
|
258
|
-
reference = Reference.fromMetavariableNode(metavariableNode, context);
|
|
259
|
-
|
|
260
|
-
return reference;
|
|
261
|
-
}
|
|
262
|
-
|
package/src/element/label.js
CHANGED
|
@@ -4,9 +4,8 @@ import { Element } from "occam-languages";
|
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
import { instantiateLabel } from "../process/instantiate";
|
|
7
|
-
import { attempt, instantiate } from "../utilities/context";
|
|
8
7
|
import { metavariableFromLabelNode } from "../utilities/element";
|
|
9
|
-
import {
|
|
8
|
+
import { attempt, serialise, unserialise, instantiate } from "../utilities/context";
|
|
10
9
|
|
|
11
10
|
export default define(class Label extends Element {
|
|
12
11
|
constructor(context, string, node, metavariable) {
|
|
@@ -38,10 +37,6 @@ export default define(class Label extends Element {
|
|
|
38
37
|
return labelNodeMatches;
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
compareMetavariable(metavariable) { return this.metavariable.compare(metavariable); }
|
|
42
|
-
|
|
43
|
-
compareMetavariableName(metavariableName) { return this.metavariable.compareMetavariableName(metavariableName); }
|
|
44
|
-
|
|
45
40
|
compareReference(reference) {
|
|
46
41
|
const metavariable = reference.getMetavariable(),
|
|
47
42
|
metavariableComparesToMetavariable = this.compareMetavariable(metavariable),
|
|
@@ -50,6 +45,10 @@ export default define(class Label extends Element {
|
|
|
50
45
|
return comparesToReference;
|
|
51
46
|
}
|
|
52
47
|
|
|
48
|
+
compareMetavariable(metavariable) { return this.metavariable.compare(metavariable); }
|
|
49
|
+
|
|
50
|
+
compareMetavariableName(metavariableName) { return this.metavariable.compareMetavariableName(metavariableName); }
|
|
51
|
+
|
|
53
52
|
verify() {
|
|
54
53
|
let verifies = false;
|
|
55
54
|
|
|
@@ -127,40 +126,35 @@ export default define(class Label extends Element {
|
|
|
127
126
|
}
|
|
128
127
|
|
|
129
128
|
toJSON() {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
context = this.getContext();
|
|
133
|
-
|
|
134
|
-
const ephemeralContext = context, ///
|
|
135
|
-
ephemeralContextJSON = ephemeralContextToEphemeralContextJSON(ephemeralContext),
|
|
136
|
-
contextJSON = ephemeralContextJSON; ///
|
|
129
|
+
const context = this.getContext();
|
|
137
130
|
|
|
138
|
-
context
|
|
131
|
+
return serialise((context) => {
|
|
132
|
+
const string = this.getString(),
|
|
133
|
+
json = {
|
|
134
|
+
context,
|
|
135
|
+
string
|
|
136
|
+
};
|
|
139
137
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
context,
|
|
143
|
-
string
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
return json;
|
|
138
|
+
return json;
|
|
139
|
+
}, context);
|
|
147
140
|
}
|
|
148
141
|
|
|
149
142
|
static name = "Label";
|
|
150
143
|
|
|
151
144
|
static fromJSON(json, context) {
|
|
152
|
-
|
|
145
|
+
let label;
|
|
153
146
|
|
|
154
|
-
context
|
|
147
|
+
unserialise((json, context) => {
|
|
148
|
+
instantiate((context) => {
|
|
149
|
+
const { string } = json,
|
|
150
|
+
labelNode = instantiateLabel(string, context),
|
|
151
|
+
node = labelNode, ///
|
|
152
|
+
metavariable = metavariableFromLabelNode(labelNode, context);
|
|
155
153
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
node = labelNode, ///
|
|
160
|
-
metavariable = metavariableFromLabelNode(labelNode, context),
|
|
161
|
-
label = new Label(context, string, node, metavariable);
|
|
154
|
+
label = new Label(context, string, node, metavariable);
|
|
155
|
+
}, context);
|
|
156
|
+
}, json, context);
|
|
162
157
|
|
|
163
|
-
|
|
164
|
-
}, context);
|
|
158
|
+
return label;
|
|
165
159
|
}
|
|
166
160
|
});
|
|
@@ -486,11 +486,11 @@ export default define(class Metavariable extends Element {
|
|
|
486
486
|
if (frameSingular) {
|
|
487
487
|
const frameMetavariableName = frame.getMetavariableName(),
|
|
488
488
|
frameMetavariable = context.findMetavariableByMetavariableName(frameMetavariableName),
|
|
489
|
-
|
|
490
|
-
specificMetavariable = frameMetavariable, ///
|
|
491
|
-
metavariableUnifiesIntrinsically = unifyMetavariableIntrinsically(generalMetavariable, specificMetavariable, generalContext, specificContext);
|
|
489
|
+
frameMetavariableUnifiesIntrinsically = this.unifyMetavariableIntrinsically(frameMetavariable, generalContext, specificContext);
|
|
492
490
|
|
|
493
|
-
|
|
491
|
+
if (frameMetavariableUnifiesIntrinsically) {
|
|
492
|
+
frameMetavariableUnifies = true;
|
|
493
|
+
}
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
496
|
}
|
|
@@ -522,11 +522,11 @@ export default define(class Metavariable extends Element {
|
|
|
522
522
|
referenceMetavariableUnifies = true;
|
|
523
523
|
} else {
|
|
524
524
|
const referenceMetavariable = reference.getMetavariable(),
|
|
525
|
-
|
|
526
|
-
specificMetavariable = referenceMetavariable, ///
|
|
527
|
-
metavariableUnifiesIntrinsically = unifyMetavariableIntrinsically(generalMetavariable, specificMetavariable, generalContext, specificContext);
|
|
525
|
+
referenceMetavariableUnifiesIntrinsically = this.unifyMetavariableIntrinsically(referenceMetavariable, generalContext, specificContext);
|
|
528
526
|
|
|
529
|
-
|
|
527
|
+
if (referenceMetavariableUnifiesIntrinsically) {
|
|
528
|
+
referenceMetavariableUnifies = true;
|
|
529
|
+
}
|
|
530
530
|
}
|
|
531
531
|
}
|
|
532
532
|
|
|
@@ -561,11 +561,11 @@ export default define(class Metavariable extends Element {
|
|
|
561
561
|
if (statementSingular) {
|
|
562
562
|
const statementMetavariableName = statement.getMetavariableName(),
|
|
563
563
|
statementMetavariable = context.findMetavariableByMetavariableName(statementMetavariableName),
|
|
564
|
-
|
|
565
|
-
specificMetavariable = statementMetavariable, ///
|
|
566
|
-
metavariableUnifiesIntrinsically = unifyMetavariableIntrinsically(generalMetavariable, specificMetavariable, generalContext, specificContext);
|
|
564
|
+
statementMetavariableUnifiesIntrinsically = this.unifyMetavariableIntrinsically(statementMetavariable, generalContext, specificContext);
|
|
567
565
|
|
|
568
|
-
|
|
566
|
+
if (statementMetavariableUnifiesIntrinsically) {
|
|
567
|
+
statementMetavariableUnifies = true;
|
|
568
|
+
}
|
|
569
569
|
}
|
|
570
570
|
}
|
|
571
571
|
}
|
|
@@ -577,6 +577,26 @@ export default define(class Metavariable extends Element {
|
|
|
577
577
|
return statementMetavariableUnifies;
|
|
578
578
|
}
|
|
579
579
|
|
|
580
|
+
unifyMetavariableIntrinsically(metavariable, generalContext, specificContext) {
|
|
581
|
+
let metavariableUnifiesIntrinsically;
|
|
582
|
+
|
|
583
|
+
const context = specificContext, ///
|
|
584
|
+
generalMetavariable = this, ///
|
|
585
|
+
specificMetavariable = metavariable,
|
|
586
|
+
generalMetavariableString = generalMetavariable.getString(), ///
|
|
587
|
+
specificMetavariableString = specificMetavariable.getString();
|
|
588
|
+
|
|
589
|
+
context.trace(`Unifying the '${specificMetavariableString}' metavariable with the '${generalMetavariableString}' metavariable intrinsically...`);
|
|
590
|
+
|
|
591
|
+
metavariableUnifiesIntrinsically = unifyMetavariableIntrinsically(generalMetavariable, specificMetavariable, generalContext, specificContext);
|
|
592
|
+
|
|
593
|
+
if (metavariableUnifiesIntrinsically) {
|
|
594
|
+
context.debug(`...unified the '${specificMetavariableString}' metavariable with the '${generalMetavariableString}' metavariable intrinsically.`);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
return metavariableUnifiesIntrinsically;
|
|
598
|
+
}
|
|
599
|
+
|
|
580
600
|
toJSON() {
|
|
581
601
|
const metaTypeJSON = metaTypeToMetaTypeJSON(this.metaType),
|
|
582
602
|
metaType = metaTypeJSON, ///
|