occam-verify-cli 1.0.924 → 1.0.932

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.
Files changed (57) hide show
  1. package/lib/context/bounded.js +19 -18
  2. package/lib/context/file/nominal.js +1 -13
  3. package/lib/context/mnemic.js +1 -5
  4. package/lib/context.js +17 -26
  5. package/lib/element/assertion/contained.js +4 -6
  6. package/lib/element/assertion/defined.js +19 -21
  7. package/lib/element/assertion/type.js +43 -14
  8. package/lib/element/constructor/bracketed.js +3 -2
  9. package/lib/element/constructor.js +5 -3
  10. package/lib/element/declaration/variable.js +2 -1
  11. package/lib/element/hypothesis.js +55 -40
  12. package/lib/element/metavariable.js +13 -7
  13. package/lib/element/proofAssertion/step.js +1 -5
  14. package/lib/element/section.js +21 -27
  15. package/lib/element/statement.js +8 -3
  16. package/lib/element/substitution/statement.js +14 -15
  17. package/lib/element/substitution.js +17 -1
  18. package/lib/element/term.js +22 -13
  19. package/lib/element/topLevelAssertion.js +6 -2
  20. package/lib/element/type.js +4 -4
  21. package/lib/element/variable.js +57 -33
  22. package/lib/utilities/assignment.js +25 -9
  23. package/lib/utilities/element.js +37 -23
  24. package/lib/utilities/equivalences.js +2 -2
  25. package/lib/utilities/string.js +36 -35
  26. package/lib/utilities/substitutions.js +14 -26
  27. package/lib/utilities/unification.js +45 -44
  28. package/lib/utilities/validation.js +5 -3
  29. package/package.json +1 -1
  30. package/src/context/bounded.js +19 -17
  31. package/src/context/file/nominal.js +0 -18
  32. package/src/context/mnemic.js +0 -7
  33. package/src/context.js +24 -43
  34. package/src/element/assertion/contained.js +6 -11
  35. package/src/element/assertion/defined.js +32 -36
  36. package/src/element/assertion/type.js +61 -18
  37. package/src/element/constructor/bracketed.js +4 -1
  38. package/src/element/constructor.js +7 -2
  39. package/src/element/declaration/variable.js +2 -0
  40. package/src/element/hypothesis.js +71 -54
  41. package/src/element/metavariable.js +20 -11
  42. package/src/element/proofAssertion/step.js +0 -6
  43. package/src/element/section.js +24 -31
  44. package/src/element/statement.js +11 -1
  45. package/src/element/substitution/statement.js +23 -21
  46. package/src/element/substitution.js +24 -0
  47. package/src/element/term.js +29 -11
  48. package/src/element/topLevelAssertion.js +8 -2
  49. package/src/element/type.js +4 -4
  50. package/src/element/variable.js +81 -44
  51. package/src/utilities/assignment.js +34 -8
  52. package/src/utilities/element.js +44 -29
  53. package/src/utilities/equivalences.js +1 -1
  54. package/src/utilities/string.js +59 -53
  55. package/src/utilities/substitutions.js +14 -40
  56. package/src/utilities/unification.js +60 -60
  57. package/src/utilities/validation.js +7 -2
@@ -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, axiom, lemma, theorem, conjecture) {
11
+ constructor(context, string, node, lineIndex, hypotheses, topLevelAssertion) {
9
12
  super(context, string, node, lineIndex);
10
13
 
11
14
  this.hypotheses = hypotheses;
12
- this.axiom = axiom;
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
- getAxiom() {
23
- return this.axiom;
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
- const hypothesesVerify = this.verifyHypotheses();
42
+ await enclose(async (context) => {
43
+ const hypothesesVerify = await this.verifyHypotheses(context);
53
44
 
54
- if (hypothesesVerify) {
55
- const topLevelAssertion = (this.axiom || this.lemma || this.theorem || this.conjecture),
56
- topLevelAssertionVerifies = await topLevelAssertion.verify(context);
45
+ if (hypothesesVerify) {
46
+ context.assignAssignments();
57
47
 
58
- if (topLevelAssertionVerifies) {
59
- topLevelAssertion.setHypotheses(this.hypotheses);
48
+ const topLevelAssertionVerifies = await this.topLevelAssertion.verify(context);
60
49
 
61
- verifies = true;
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.every((hypothesis) => {
74
- const hypothesisVerifies = hypothesis.verify(this.context);
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;
@@ -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
- context = complexSubstitution.getContext();
261
-
262
- const specificContext = context; ///
263
-
264
- context = this.getContext();
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
- reconcile((specificContext) => {
273
- const replacementStatement = complexSubstitution.getReplacementStatement(),
274
- replacementStatementUnifies = this.unifyReplacementStatement(replacementStatement, generalContext, specificContext);
268
+ join((context) => {
269
+ const specificContext = context; ///
275
270
 
276
- if (replacementStatementUnifies) {
277
- const context = specificContext, ///
278
- soleNonTrivialDerivedSubstitution = context.getSoleNonTrivialDerivedSubstitution();
271
+ reconcile((specificContext) => {
272
+ const replacementStatement = complexSubstitution.getReplacementStatement(),
273
+ replacementStatementUnifies = this.unifyReplacementStatement(replacementStatement, generalContext, specificContext);
279
274
 
280
- substitution = soleNonTrivialDerivedSubstitution; ///
281
- }
282
- }, specificContext);
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
- simpleSubstitution = context.findSimpleSubstitutionByMetavariableNode(metavariableNode),
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 simpleSubstitutionUnifies = complexSubstitution.unifySimpleSubstitution(substitution, context);
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
 
@@ -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 varialbeNodeMatches = false;
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
- varialbeNodeMatches = true; ///
140
+ variableNodeMatches = true; ///
127
141
  }
128
142
  }
129
143
 
130
- return varialbeNodeMatches;
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 { topLevelAssertionStringFromLabelsSuppositionsAndDeduction } from "../utilities/string";
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 = topLevelAssertionStringFromLabelsSuppositionsAndDeduction(labels, suppositions, deduction),
383
+ topLevelAssertionString = topLevelAssertionStringFromLabelsSignatureSuppositionsAndDeduction(labels, signature, suppositions, deduction),
378
384
  node = null,
379
385
  proof = null,
380
386
  string = topLevelAssertionString, ///
@@ -103,11 +103,11 @@ export default define(class Type extends Element {
103
103
  this.provisional = provisional;
104
104
  }
105
105
 
106
- replaceSuperType(superType, index) {
107
- const start = index,
108
- deleteCount = 1;
106
+ isEstablished(includeSuperTypes = true) {
107
+ const provisional = this.isProvisional(includeSuperTypes),
108
+ established = !provisional;
109
109
 
110
- this.superTypes.splice(start, deleteCount, superType);
110
+ return established;
111
111
  }
112
112
 
113
113
  isPrefixed() {
@@ -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 { typeFromJSON, typeToTypeJSON } from "../utilities/json";
11
- import { variableFromTermNode, identifierFromVarialbeNode } from "../utilities/element";
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
- getType() {
26
- return this.type;
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
- variableString = this.getString(); ///
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;
@@ -112,74 +133,89 @@ export default define(class Variable extends Element {
112
133
 
113
134
  context.trace(`Unifying the '${termString}' term with the '${variableString}' variable...`);
114
135
 
115
- let variable,
116
- derivedSubstitution;
136
+ const variable = this, ///
137
+ termVariableUnifies = this.unifyTermVariable(term, generalContext, specificContext);
117
138
 
118
- variable = this; ///
139
+ if (termVariableUnifies) {
140
+ termUnifies = true;
141
+ } else {
142
+ const variableNode = variable.getNode(),
143
+ derivedSubstitution = context.findDerivedSubstitutionByVariableNode(variableNode);
119
144
 
120
- const variableNode = variable.getNode();
145
+ if (derivedSubstitution !== null) {
146
+ const derivedSubstitutionTermComparesToTerm = derivedSubstitution.compareTerm(term, context);
121
147
 
122
- derivedSubstitution = context.findDerivedSubstitutionByVariableNode(variableNode);
148
+ if (derivedSubstitutionTermComparesToTerm) {
149
+ const derivedSubstitutionString = derivedSubstitution.getString();
123
150
 
124
- if (derivedSubstitution !== null) {
125
- const derivedSubstitutionComparesToTerm = derivedSubstitution.compareTerm(term, context);
151
+ context.trace(`The '${derivedSubstitutionString}' derived substitution is already present.`);
126
152
 
127
- if (derivedSubstitutionComparesToTerm) {
128
- const derivedSubstitutionString = derivedSubstitution.getString();
153
+ termUnifies = true;
154
+ }
155
+ } else {
156
+ const { TermSubstitution } = elements;
129
157
 
130
- context.trace(`The '${derivedSubstitutionString}' derived substitution is already present.`);
158
+ let termSubstitution;
131
159
 
132
- termUnifies = true;
133
- }
134
- } else {
135
- let context;
160
+ termSubstitution = TermSubstitution.fromTermAndVariable(term, variable, generalContext, specificContext);
136
161
 
137
- context = generalContext; ///
162
+ termSubstitution = termSubstitution.validate(context); ///
138
163
 
139
- const variableNode = variable.getNode();
164
+ const derivedSubstitution = termSubstitution; ///
140
165
 
141
- variable = context.findVariableByVariableNode(variableNode);
166
+ context.addDerivedSubstitution(derivedSubstitution);
142
167
 
143
- context = specificContext; ///
168
+ termUnifies = true;
169
+ }
170
+ }
144
171
 
145
- const termNode = term.getNode();
172
+ if (termUnifies) {
173
+ context.debug(`...unified the '${termString}' term with the '${variableString}' variable.`);
174
+ }
146
175
 
147
- term = context.findTermByTermNode(termNode);
176
+ return termUnifies;
177
+ }
148
178
 
149
- const termType = term.getType(),
150
- variableType = variable.getType(),
151
- termTypeEqualToOrSubTypeOfVariableType = termType.isEqualToOrSubTypeOf(variableType);
179
+ unifyTermVariable(term, generalContext, specificContext) {
180
+ let termVariableUnifies = false;
152
181
 
153
- if (termTypeEqualToOrSubTypeOfVariableType) {
154
- const { TermSubstitution } = elements,
155
- termSubstitution = TermSubstitution.fromTermAndVariable(term, variable, generalContext, specificContext);
182
+ const context = specificContext, ///
183
+ termString = term.getString(),
184
+ variableString = this.getString(); ///
156
185
 
157
- termSubstitution.validate(context);
186
+ context.trace(`Unifying the '${termString}' term's variable with the '${variableString}' variable...`);
158
187
 
159
- const derivedSubstitution = termSubstitution; ///
188
+ const generalContextFilePath = generalContext.getFilePath(),
189
+ specificContextFilePath = specificContext.getFilePath();
160
190
 
161
- context.addDerivedSubstitution(derivedSubstitution);
191
+ if (generalContextFilePath === specificContextFilePath) {
192
+ const variableNode = this.getVariableNode(), ///
193
+ variableNodeMatches = term.matchVariableNode(variableNode);
162
194
 
163
- termUnifies = true;
195
+ if (variableNodeMatches) {
196
+ termVariableUnifies = true;
164
197
  }
165
198
  }
166
199
 
167
- if (termUnifies) {
168
- context.debug(`...unified the '${termString}' term with the '${variableString}' variable.`);
200
+ if (termVariableUnifies) {
201
+ context.debug(`...unified the '${termString}' term's variable with the '${variableString}' variable.`);
169
202
  }
170
203
 
171
- return termUnifies;
204
+ return termVariableUnifies;
172
205
  }
173
206
 
174
207
  toJSON() {
175
208
  const typeJSON = typeToTypeJSON(this.type),
176
- type = typeJSON, ///
209
+ provisionalJSON = provisionalToProvisionalJSON(this.provisional),
177
210
  string = this.getString(), ///
178
211
  lineIndex = this.getLineIndex(),
212
+ type = typeJSON, ///
213
+ provisional = provisionalJSON, ///
179
214
  json = {
180
215
  string,
181
216
  lineIndex,
182
- type
217
+ type,
218
+ provisional
183
219
  };
184
220
 
185
221
  return json;
@@ -193,11 +229,12 @@ export default define(class Variable extends Element {
193
229
  variableNode = instantiateVariable(string, context),
194
230
  node = variableNode, ///
195
231
  type = typeFromJSON(json, context),
196
- identifier = identifierFromVarialbeNode(variableNode, context);
232
+ identifier = identifierFromVariableNode(variableNode, context),
233
+ provisional = provisionalFromJSON(json, context);
197
234
 
198
235
  context = null;
199
236
 
200
- const variable = new Variable(context, string, node, lineIndex, type, identifier);
237
+ const variable = new Variable(context, string, node, lineIndex, type, identifier, provisional);
201
238
 
202
239
  return variable;
203
240
  }, 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 (termTypeSuperTypeOfType) {
17
- const variableNode = term.getVariableNode(),
18
- variable = variableFromVariableNode(variableNode, context);
17
+ if (false) {
18
+ ///
19
+ } else if (termTypeEqualToType) {
20
+ const termProvisional = term.isProvisional();
19
21
 
20
- variable.setType(type);
22
+ if (termProvisional) {
23
+ const type = term.getType(),
24
+ variableNode = term.getVariableNode(),
25
+ variable = variableFromVariableNode(variableNode, context),
26
+ provisional = false;
21
27
 
22
- variableAssignment = (context) => {
23
- const declaredVariable = variable; ///
28
+ variable.setType(type);
24
29
 
25
- context.addDeclaredVariable(declaredVariable);
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