occam-verify-cli 1.0.923 → 1.0.931
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/bounded.js +19 -18
- package/lib/context/file/nominal.js +1 -13
- package/lib/context/mnemic.js +1 -5
- package/lib/context.js +17 -26
- package/lib/element/assertion/contained.js +4 -6
- package/lib/element/assertion/defined.js +19 -21
- package/lib/element/assertion/type.js +43 -14
- package/lib/element/constructor/bracketed.js +3 -2
- package/lib/element/constructor.js +5 -3
- package/lib/element/declaration/variable.js +2 -1
- package/lib/element/hypothesis.js +55 -40
- package/lib/element/metavariable.js +13 -7
- package/lib/element/proofAssertion/step.js +1 -5
- package/lib/element/section.js +21 -27
- package/lib/element/statement.js +8 -3
- package/lib/element/substitution/statement.js +14 -15
- package/lib/element/substitution.js +17 -1
- package/lib/element/term.js +22 -13
- package/lib/element/topLevelAssertion.js +6 -2
- package/lib/element/type.js +4 -4
- package/lib/element/variable.js +29 -13
- package/lib/utilities/assignment.js +25 -9
- package/lib/utilities/element.js +37 -23
- package/lib/utilities/equivalences.js +2 -2
- package/lib/utilities/string.js +36 -35
- package/lib/utilities/substitutions.js +14 -26
- package/lib/utilities/unification.js +45 -44
- package/lib/utilities/validation.js +5 -3
- package/package.json +1 -1
- package/src/context/bounded.js +19 -17
- package/src/context/file/nominal.js +0 -18
- package/src/context/mnemic.js +0 -7
- package/src/context.js +24 -43
- package/src/element/assertion/contained.js +6 -11
- package/src/element/assertion/defined.js +32 -36
- package/src/element/assertion/type.js +61 -18
- package/src/element/constructor/bracketed.js +4 -1
- package/src/element/constructor.js +7 -2
- package/src/element/declaration/variable.js +2 -0
- package/src/element/hypothesis.js +71 -54
- package/src/element/metavariable.js +20 -11
- package/src/element/proofAssertion/step.js +0 -6
- package/src/element/section.js +24 -31
- package/src/element/statement.js +11 -1
- package/src/element/substitution/statement.js +23 -21
- package/src/element/substitution.js +24 -0
- package/src/element/term.js +29 -11
- package/src/element/topLevelAssertion.js +8 -2
- package/src/element/type.js +4 -4
- package/src/element/variable.js +42 -14
- package/src/utilities/assignment.js +34 -8
- package/src/utilities/element.js +44 -29
- package/src/utilities/equivalences.js +1 -1
- package/src/utilities/string.js +59 -53
- package/src/utilities/substitutions.js +14 -40
- package/src/utilities/unification.js +60 -60
- package/src/utilities/validation.js +7 -2
package/src/element/section.js
CHANGED
|
@@ -1,38 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { Element } from "occam-languages";
|
|
3
|
+
import { Element, asynchronousUtilities } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
+
import {enclose} from "../utilities/context";
|
|
7
|
+
|
|
8
|
+
const { asyncEvery } = asynchronousUtilities;
|
|
6
9
|
|
|
7
10
|
export default define(class Section extends Element {
|
|
8
|
-
constructor(context, string, node, lineIndex, hypotheses,
|
|
11
|
+
constructor(context, string, node, lineIndex, hypotheses, topLevelAssertion) {
|
|
9
12
|
super(context, string, node, lineIndex);
|
|
10
13
|
|
|
11
14
|
this.hypotheses = hypotheses;
|
|
12
|
-
this.
|
|
13
|
-
this.lemma = lemma;
|
|
14
|
-
this.theorem = theorem;
|
|
15
|
-
this.conjecture = conjecture;
|
|
15
|
+
this.topLevelAssertion = topLevelAssertion;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
getHypotheses() {
|
|
19
19
|
return this.hypotheses;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
return this.
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
getLemma() {
|
|
27
|
-
return this.lemma;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
getTheorem() {
|
|
31
|
-
return this.theorem;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
getConjecture() {
|
|
35
|
-
return this.conjecture;
|
|
22
|
+
getTopLevelAssertion() {
|
|
23
|
+
return this.topLevelAssertion;
|
|
36
24
|
}
|
|
37
25
|
|
|
38
26
|
getSectionNode() {
|
|
@@ -45,22 +33,27 @@ export default define(class Section extends Element {
|
|
|
45
33
|
async verify(context) {
|
|
46
34
|
let verifies = false;
|
|
47
35
|
|
|
36
|
+
await this.break(context);
|
|
37
|
+
|
|
48
38
|
const sectionString = this.getString(); ///
|
|
49
39
|
|
|
50
40
|
context.trace(`Verifying the '${sectionString}' section...`);
|
|
51
41
|
|
|
52
|
-
|
|
42
|
+
await enclose(async (context) => {
|
|
43
|
+
const hypothesesVerify = await this.verifyHypotheses(context);
|
|
53
44
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
topLevelAssertionVerifies = await topLevelAssertion.verify(context);
|
|
45
|
+
if (hypothesesVerify) {
|
|
46
|
+
context.assignAssignments();
|
|
57
47
|
|
|
58
|
-
|
|
59
|
-
topLevelAssertion.setHypotheses(this.hypotheses);
|
|
48
|
+
const topLevelAssertionVerifies = await this.topLevelAssertion.verify(context);
|
|
60
49
|
|
|
61
|
-
|
|
50
|
+
if (topLevelAssertionVerifies) {
|
|
51
|
+
this.topLevelAssertion.setHypotheses(this.hypotheses);
|
|
52
|
+
|
|
53
|
+
verifies = true;
|
|
54
|
+
}
|
|
62
55
|
}
|
|
63
|
-
}
|
|
56
|
+
}, context);
|
|
64
57
|
|
|
65
58
|
if (verifies) {
|
|
66
59
|
context.debug(`...verified the '${sectionString}' section.`);
|
|
@@ -69,9 +62,9 @@ export default define(class Section extends Element {
|
|
|
69
62
|
return verifies;
|
|
70
63
|
}
|
|
71
64
|
|
|
72
|
-
verifyHypotheses() {
|
|
73
|
-
const hypothesesVerify = this.hypotheses
|
|
74
|
-
const hypothesisVerifies = hypothesis.verify(
|
|
65
|
+
async verifyHypotheses(context) {
|
|
66
|
+
const hypothesesVerify = await asyncEvery(this.hypotheses, async (hypothesis) => {
|
|
67
|
+
const hypothesisVerifies = await hypothesis.verify(context);
|
|
75
68
|
|
|
76
69
|
if (hypothesisVerifies) {
|
|
77
70
|
return true;
|
package/src/element/statement.js
CHANGED
|
@@ -7,7 +7,6 @@ import { unifyStatement } from "../process/unify";
|
|
|
7
7
|
import { validateStatements } from "../utilities/validation";
|
|
8
8
|
import { instantiateStatement } from "../process/instantiate";
|
|
9
9
|
import { reconcile, instantiate } from "../utilities/context";
|
|
10
|
-
import {getEntryStats} from "necessary/lib/utilities/fileSystem";
|
|
11
10
|
|
|
12
11
|
export default define(class Statement extends Element {
|
|
13
12
|
getStatementNode() {
|
|
@@ -307,9 +306,20 @@ export default define(class Statement extends Element {
|
|
|
307
306
|
context.trace(`Unifying the '${statementString}' statement independently...`);
|
|
308
307
|
|
|
309
308
|
const statementNode = this.getStatementNode(),
|
|
309
|
+
typeAssertionNode = statementNode.getTypeAssertionNode(),
|
|
310
310
|
definedAssertionNode = statementNode.getDefinedAssertionNode(),
|
|
311
311
|
containedAssertionNode = statementNode.getContainedAssertionNode();
|
|
312
312
|
|
|
313
|
+
if (typeAssertionNode !== null) {
|
|
314
|
+
const context = generalContext, ///
|
|
315
|
+
typeAssertion = context.findAssertionByAssertionNode(typeAssertionNode),
|
|
316
|
+
typeAssertionUnifiesIndependently = typeAssertion.unifyIndependently(generalContext, specificContext);
|
|
317
|
+
|
|
318
|
+
if (typeAssertionUnifiesIndependently) {
|
|
319
|
+
unifiesIndependently = true;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
313
323
|
if (definedAssertionNode !== null) {
|
|
314
324
|
const context = generalContext, ///
|
|
315
325
|
definedAssertion = context.findAssertionByAssertionNode(definedAssertionNode),
|
|
@@ -257,29 +257,29 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
257
257
|
|
|
258
258
|
context.trace(`Unifying the '${complexSubstitutionString}' complex substitution with the '${simpleSubstitutionString}' simple substitution...`);
|
|
259
259
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const generalContext = context; ///
|
|
267
|
-
|
|
268
|
-
context = specificContext; ///
|
|
260
|
+
const simpleSubstitution = this, ///
|
|
261
|
+
simpleSubstitutionGSpecificContext = simpleSubstitution.getSpecificContext(),
|
|
262
|
+
complexSubstitutionGSpecificContext = complexSubstitution.getSpecificContext(),
|
|
263
|
+
generalContext = simpleSubstitutionGSpecificContext, ///
|
|
264
|
+
specificContext = complexSubstitutionGSpecificContext; ///
|
|
269
265
|
|
|
270
266
|
let simpleSubstitutionUnifies = false;
|
|
271
267
|
|
|
272
|
-
|
|
273
|
-
const
|
|
274
|
-
replacementStatementUnifies = this.unifyReplacementStatement(replacementStatement, generalContext, specificContext);
|
|
268
|
+
join((context) => {
|
|
269
|
+
const specificContext = context; ///
|
|
275
270
|
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
|
|
271
|
+
reconcile((specificContext) => {
|
|
272
|
+
const replacementStatement = complexSubstitution.getReplacementStatement(),
|
|
273
|
+
replacementStatementUnifies = this.unifyReplacementStatement(replacementStatement, generalContext, specificContext);
|
|
279
274
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
275
|
+
if (replacementStatementUnifies) {
|
|
276
|
+
const context = specificContext, ///
|
|
277
|
+
soleNonTrivialDerivedSubstitution = context.getSoleNonTrivialDerivedSubstitution();
|
|
278
|
+
|
|
279
|
+
substitution = soleNonTrivialDerivedSubstitution; ///
|
|
280
|
+
}
|
|
281
|
+
}, specificContext);
|
|
282
|
+
}, specificContext, context);
|
|
283
283
|
|
|
284
284
|
if (substitution !== null) {
|
|
285
285
|
substitution = substitution.validate(context); ///
|
|
@@ -320,8 +320,9 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
320
320
|
let resolved = false;
|
|
321
321
|
|
|
322
322
|
const metavariableNode = this.getMetavariableNode(),
|
|
323
|
-
|
|
324
|
-
complexSubstitution = this
|
|
323
|
+
simpleDerivedSubstitution = context.findSimpleDerivedSubstitutionByMetavariableNode(metavariableNode), ///
|
|
324
|
+
complexSubstitution = this,
|
|
325
|
+
simpleSubstitution = simpleDerivedSubstitution; ///
|
|
325
326
|
|
|
326
327
|
if (simpleSubstitution !== null) {
|
|
327
328
|
const substitutionString = this.getString(); ///
|
|
@@ -331,7 +332,8 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
331
332
|
const substitution = simpleSubstitution.unifyComplexSubstitution(complexSubstitution, context);
|
|
332
333
|
|
|
333
334
|
if (substitution !== null) {
|
|
334
|
-
const
|
|
335
|
+
const simpleSubstitution = substitution, ///
|
|
336
|
+
simpleSubstitutionUnifies = complexSubstitution.unifySimpleSubstitution(simpleSubstitution, context);
|
|
335
337
|
|
|
336
338
|
if (simpleSubstitutionUnifies) {
|
|
337
339
|
resolved = true;
|
|
@@ -165,6 +165,30 @@ export default class Substitution extends Element {
|
|
|
165
165
|
return metavariableNode;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
getReplacementTerm() {
|
|
169
|
+
const replacementTerm = null;
|
|
170
|
+
|
|
171
|
+
return replacementTerm;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
getReplacementFrame() {
|
|
175
|
+
const replacementFrame = null;
|
|
176
|
+
|
|
177
|
+
return replacementFrame;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
getReplacementStatement() {
|
|
181
|
+
const replacementStatement = null;
|
|
182
|
+
|
|
183
|
+
return replacementStatement;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
getReplacementReference() {
|
|
187
|
+
const replacementReference = null;
|
|
188
|
+
|
|
189
|
+
return replacementReference;
|
|
190
|
+
}
|
|
191
|
+
|
|
168
192
|
isSimple() {
|
|
169
193
|
const simple = true;
|
|
170
194
|
|
package/src/element/term.js
CHANGED
|
@@ -9,25 +9,34 @@ import { validateTerms } from "../utilities/validation";
|
|
|
9
9
|
import { instantiateTerm } from "../process/instantiate";
|
|
10
10
|
import { variablesFromTerm } from "../utilities/equivalence";
|
|
11
11
|
import { unifyTermIntrinsically } from "../process/unify";
|
|
12
|
-
import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
|
|
12
|
+
import { typeFromJSON, typeToTypeJSON, provisionalFromJSON, provisionalToProvisionalJSON } from "../utilities/json";
|
|
13
13
|
|
|
14
14
|
const { filter } = arrayUtilities;
|
|
15
15
|
|
|
16
16
|
export default define(class Term extends Element {
|
|
17
|
-
constructor(context, string, node, lineIndex, type) {
|
|
18
|
-
super(context, string, node, lineIndex);
|
|
17
|
+
constructor(context, string, node, lineIndex, type, provisional) {
|
|
18
|
+
super(context, string, node, lineIndex, provisional);
|
|
19
19
|
|
|
20
20
|
this.type = type;
|
|
21
|
+
this.provisional = provisional;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
getType() {
|
|
24
25
|
return this.type;
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
isProvisional() {
|
|
29
|
+
return this.provisional;
|
|
30
|
+
}
|
|
31
|
+
|
|
27
32
|
setType(type) {
|
|
28
33
|
this.type = type;
|
|
29
34
|
}
|
|
30
35
|
|
|
36
|
+
setProvisional(provisional) {
|
|
37
|
+
this.provisional = provisional;
|
|
38
|
+
}
|
|
39
|
+
|
|
31
40
|
getTermNode() {
|
|
32
41
|
const node = this.getNode(),
|
|
33
42
|
termNode = node; ///
|
|
@@ -49,6 +58,13 @@ export default define(class Term extends Element {
|
|
|
49
58
|
return variableIdentifier;
|
|
50
59
|
}
|
|
51
60
|
|
|
61
|
+
isEstablished() {
|
|
62
|
+
const provisional = this.isProvisional(),
|
|
63
|
+
established = !provisional;
|
|
64
|
+
|
|
65
|
+
return established;
|
|
66
|
+
}
|
|
67
|
+
|
|
52
68
|
isEqualTo(term) {
|
|
53
69
|
const termNode = term.getNode(),
|
|
54
70
|
termNodeMatches = this.matchTermNode(termNode),
|
|
@@ -83,8 +99,6 @@ export default define(class Term extends Element {
|
|
|
83
99
|
return singular;
|
|
84
100
|
}
|
|
85
101
|
|
|
86
|
-
isProvisional() { return this.type.isProvisional(); }
|
|
87
|
-
|
|
88
102
|
isInitiallyGrounded(context) {
|
|
89
103
|
const term = this, ///
|
|
90
104
|
variables = variablesFromTerm(term, context),
|
|
@@ -110,7 +124,7 @@ export default define(class Term extends Element {
|
|
|
110
124
|
}
|
|
111
125
|
|
|
112
126
|
matchVariableNode(variableNode) {
|
|
113
|
-
let
|
|
127
|
+
let variableNodeMatches = false;
|
|
114
128
|
|
|
115
129
|
const singular = this.isSingular();
|
|
116
130
|
|
|
@@ -123,11 +137,11 @@ export default define(class Term extends Element {
|
|
|
123
137
|
variableNodeAMatchesVariableNodeB = variableNodeA.match(variableNodeB);
|
|
124
138
|
|
|
125
139
|
if (variableNodeAMatchesVariableNodeB) {
|
|
126
|
-
|
|
140
|
+
variableNodeMatches = true; ///
|
|
127
141
|
}
|
|
128
142
|
}
|
|
129
143
|
|
|
130
|
-
return
|
|
144
|
+
return variableNodeMatches;
|
|
131
145
|
}
|
|
132
146
|
|
|
133
147
|
compareTerm(term) {
|
|
@@ -273,13 +287,16 @@ export default define(class Term extends Element {
|
|
|
273
287
|
|
|
274
288
|
toJSON() {
|
|
275
289
|
const typeJSON = typeToTypeJSON(this.type),
|
|
290
|
+
provisionalJSON = provisionalToProvisionalJSON(this.provisional),
|
|
276
291
|
string = this.getString(), ///
|
|
277
292
|
lineIndex = this.getLineIndex(),
|
|
278
293
|
type = typeJSON, ///
|
|
294
|
+
provisional = provisionalJSON, ///
|
|
279
295
|
json = {
|
|
280
296
|
string,
|
|
281
297
|
lineIndex,
|
|
282
|
-
type
|
|
298
|
+
type,
|
|
299
|
+
provisional
|
|
283
300
|
};
|
|
284
301
|
|
|
285
302
|
return json;
|
|
@@ -292,11 +309,12 @@ export default define(class Term extends Element {
|
|
|
292
309
|
const { string, lineIndex } = json,
|
|
293
310
|
termNode = instantiateTerm(string, context),
|
|
294
311
|
node = termNode, ///
|
|
295
|
-
type = typeFromJSON(json, context)
|
|
312
|
+
type = typeFromJSON(json, context),
|
|
313
|
+
provisional = provisionalFromJSON(json, context);
|
|
296
314
|
|
|
297
315
|
context = null;
|
|
298
316
|
|
|
299
|
-
const term = new Term(context, string, node, lineIndex, type);
|
|
317
|
+
const term = new Term(context, string, node, lineIndex, type, provisional);
|
|
300
318
|
|
|
301
319
|
return term;
|
|
302
320
|
}, context);
|
|
@@ -4,7 +4,7 @@ import { arrayUtilities } from "necessary";
|
|
|
4
4
|
import { Element, asynchronousUtilities } from "occam-languages";
|
|
5
5
|
|
|
6
6
|
import { enclose } from "../utilities/context";
|
|
7
|
-
import {
|
|
7
|
+
import { topLevelAssertionStringFromLabelsSignatureSuppositionsAndDeduction } from "../utilities/string";
|
|
8
8
|
import { labelsFromJSON,
|
|
9
9
|
deductionFromJSON,
|
|
10
10
|
signatureFromJSON,
|
|
@@ -65,6 +65,12 @@ export default class TopLevelAssertion extends Element {
|
|
|
65
65
|
return supposition;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
isSatisfiable() {
|
|
69
|
+
const satisfiable = false;
|
|
70
|
+
|
|
71
|
+
return satisfiable;
|
|
72
|
+
}
|
|
73
|
+
|
|
68
74
|
isHypothetical() {
|
|
69
75
|
const hypothesesLength = this.hypotheses.length,
|
|
70
76
|
hypothetical = (hypothesesLength > 0);
|
|
@@ -374,7 +380,7 @@ export default class TopLevelAssertion extends Element {
|
|
|
374
380
|
suppositions = suppositionsFromJSON(json, context),
|
|
375
381
|
signature = signatureFromJSON(json, context),
|
|
376
382
|
hypotheses = hypothesesFromJSON(json, context),
|
|
377
|
-
topLevelAssertionString =
|
|
383
|
+
topLevelAssertionString = topLevelAssertionStringFromLabelsSignatureSuppositionsAndDeduction(labels, signature, suppositions, deduction),
|
|
378
384
|
node = null,
|
|
379
385
|
proof = null,
|
|
380
386
|
string = topLevelAssertionString, ///
|
package/src/element/type.js
CHANGED
|
@@ -103,11 +103,11 @@ export default define(class Type extends Element {
|
|
|
103
103
|
this.provisional = provisional;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
106
|
+
isEstablished(includeSuperTypes = true) {
|
|
107
|
+
const provisional = this.isProvisional(includeSuperTypes),
|
|
108
|
+
established = !provisional;
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
return established;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
isPrefixed() {
|
package/src/element/variable.js
CHANGED
|
@@ -7,29 +7,39 @@ import elements from "../elements";
|
|
|
7
7
|
import { define } from "../elements";
|
|
8
8
|
import { instantiate } from "../utilities/context";
|
|
9
9
|
import { instantiateVariable } from "../process/instantiate";
|
|
10
|
-
import {
|
|
11
|
-
import { variableFromTermNode,
|
|
10
|
+
import { provisionallyStringFromProvisional } from "../utilities/string";
|
|
11
|
+
import { variableFromTermNode, identifierFromVariableNode } from "../utilities/element";
|
|
12
|
+
import { typeFromJSON, typeToTypeJSON, provisionalFromJSON, provisionalToProvisionalJSON } from "../utilities/json";
|
|
12
13
|
|
|
13
14
|
export default define(class Variable extends Element {
|
|
14
|
-
constructor(context, string, node, lineIndex, type, identifier) {
|
|
15
|
+
constructor(context, string, node, lineIndex, type, identifier, provisional) {
|
|
15
16
|
super(context, string, node, lineIndex);
|
|
16
17
|
|
|
17
18
|
this.type = type;
|
|
18
19
|
this.identifier = identifier;
|
|
20
|
+
this.provisional = provisional;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getType() {
|
|
24
|
+
return this.type;
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
getIdentifier() {
|
|
22
28
|
return this.identifier;
|
|
23
29
|
}
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
return this.
|
|
31
|
+
isProvisional() {
|
|
32
|
+
return this.provisional;
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
setType(type) {
|
|
30
36
|
this.type = type;
|
|
31
37
|
}
|
|
32
38
|
|
|
39
|
+
setProvisional(provisional) {
|
|
40
|
+
this.provisional = provisional;
|
|
41
|
+
}
|
|
42
|
+
|
|
33
43
|
getVariableNode() {
|
|
34
44
|
const node = this.getNode(),
|
|
35
45
|
variableNode = node; //
|
|
@@ -39,6 +49,13 @@ export default define(class Variable extends Element {
|
|
|
39
49
|
|
|
40
50
|
getTypeString() { return this.type.getString(); }
|
|
41
51
|
|
|
52
|
+
isEstablished() {
|
|
53
|
+
const provisional = this.isProvisional(),
|
|
54
|
+
established = !provisional;
|
|
55
|
+
|
|
56
|
+
return established;
|
|
57
|
+
}
|
|
58
|
+
|
|
42
59
|
isIdentifierEqualTo(identifier) {
|
|
43
60
|
const identifierEqualTo = (this.identifier === identifier);
|
|
44
61
|
|
|
@@ -83,12 +100,16 @@ export default define(class Variable extends Element {
|
|
|
83
100
|
if (declaredVariable !== null) {
|
|
84
101
|
const type = declaredVariable.getType(),
|
|
85
102
|
typeString = type.getString(),
|
|
86
|
-
|
|
103
|
+
provisional = declaredVariable.isProvisional(),
|
|
104
|
+
variableString = this.getString(), ///
|
|
105
|
+
provisinallyString = provisionallyStringFromProvisional(provisional);
|
|
87
106
|
|
|
88
|
-
context.trace(`Setting the '${variableString}' variable's type to the '${typeString}' type.`);
|
|
107
|
+
context.trace(`Setting the '${variableString}' variable's type to the '${typeString}' type${provisinallyString}.`);
|
|
89
108
|
|
|
90
109
|
this.type = type;
|
|
91
110
|
|
|
111
|
+
this.provisional = provisional;
|
|
112
|
+
|
|
92
113
|
variable = this;
|
|
93
114
|
|
|
94
115
|
validates = true;
|
|
@@ -151,10 +172,13 @@ export default define(class Variable extends Element {
|
|
|
151
172
|
termTypeEqualToOrSubTypeOfVariableType = termType.isEqualToOrSubTypeOf(variableType);
|
|
152
173
|
|
|
153
174
|
if (termTypeEqualToOrSubTypeOfVariableType) {
|
|
154
|
-
const { TermSubstitution } = elements
|
|
155
|
-
termSubstitution = TermSubstitution.fromTermAndVariable(term, variable, generalContext, specificContext);
|
|
175
|
+
const { TermSubstitution } = elements;
|
|
156
176
|
|
|
157
|
-
termSubstitution
|
|
177
|
+
let termSubstitution;
|
|
178
|
+
|
|
179
|
+
termSubstitution = TermSubstitution.fromTermAndVariable(term, variable, generalContext, specificContext);
|
|
180
|
+
|
|
181
|
+
termSubstitution = termSubstitution.validate(context); ///
|
|
158
182
|
|
|
159
183
|
const derivedSubstitution = termSubstitution; ///
|
|
160
184
|
|
|
@@ -173,13 +197,16 @@ export default define(class Variable extends Element {
|
|
|
173
197
|
|
|
174
198
|
toJSON() {
|
|
175
199
|
const typeJSON = typeToTypeJSON(this.type),
|
|
176
|
-
|
|
200
|
+
provisionalJSON = provisionalToProvisionalJSON(this.provisional),
|
|
177
201
|
string = this.getString(), ///
|
|
178
202
|
lineIndex = this.getLineIndex(),
|
|
203
|
+
type = typeJSON, ///
|
|
204
|
+
provisional = provisionalJSON, ///
|
|
179
205
|
json = {
|
|
180
206
|
string,
|
|
181
207
|
lineIndex,
|
|
182
|
-
type
|
|
208
|
+
type,
|
|
209
|
+
provisional
|
|
183
210
|
};
|
|
184
211
|
|
|
185
212
|
return json;
|
|
@@ -193,11 +220,12 @@ export default define(class Variable extends Element {
|
|
|
193
220
|
variableNode = instantiateVariable(string, context),
|
|
194
221
|
node = variableNode, ///
|
|
195
222
|
type = typeFromJSON(json, context),
|
|
196
|
-
identifier =
|
|
223
|
+
identifier = identifierFromVariableNode(variableNode, context),
|
|
224
|
+
provisional = provisionalFromJSON(json, context);
|
|
197
225
|
|
|
198
226
|
context = null;
|
|
199
227
|
|
|
200
|
-
const variable = new Variable(context, string, node, lineIndex, type, identifier);
|
|
228
|
+
const variable = new Variable(context, string, node, lineIndex, type, identifier, provisional);
|
|
201
229
|
|
|
202
230
|
return variable;
|
|
203
231
|
}, context);
|
|
@@ -11,19 +11,45 @@ export function variableAssignmentFromTermAndType(term, type, context) {
|
|
|
11
11
|
|
|
12
12
|
if (termSingular) {
|
|
13
13
|
const termType = term.getType(),
|
|
14
|
+
termTypeEqualToType = termType.isEqualTo(type),
|
|
14
15
|
termTypeSuperTypeOfType = termType.isSuperTypeOf(type);
|
|
15
16
|
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
if (false) {
|
|
18
|
+
///
|
|
19
|
+
} else if (termTypeEqualToType) {
|
|
20
|
+
const termProvisional = term.isProvisional();
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
if (termProvisional) {
|
|
23
|
+
const type = term.getType(),
|
|
24
|
+
variableNode = term.getVariableNode(),
|
|
25
|
+
variable = variableFromVariableNode(variableNode, context),
|
|
26
|
+
provisional = false;
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
const declaredVariable = variable; ///
|
|
28
|
+
variable.setType(type);
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
variable.setProvisional(provisional);
|
|
31
|
+
|
|
32
|
+
variableAssignment = (context) => {
|
|
33
|
+
const declaredVariable = variable; ///
|
|
34
|
+
|
|
35
|
+
context.addDeclaredVariable(declaredVariable);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
} else if (termTypeSuperTypeOfType) {
|
|
39
|
+
const termEstablished = term.isEstablished();
|
|
40
|
+
|
|
41
|
+
if (termEstablished) {
|
|
42
|
+
const variableNode = term.getVariableNode(),
|
|
43
|
+
variable = variableFromVariableNode(variableNode, context);
|
|
44
|
+
|
|
45
|
+
variable.setType(type);
|
|
46
|
+
|
|
47
|
+
variableAssignment = (context) => {
|
|
48
|
+
const declaredVariable = variable; ///
|
|
49
|
+
|
|
50
|
+
context.addDeclaredVariable(declaredVariable);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
27
53
|
}
|
|
28
54
|
}
|
|
29
55
|
|