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.
Files changed (106) hide show
  1. package/lib/context/file/nominal.js +11 -11
  2. package/lib/context/illative.js +28 -0
  3. package/lib/context/nested.js +27 -0
  4. package/lib/context/proof.js +232 -0
  5. package/lib/context/thetic.js +28 -0
  6. package/lib/context.js +15 -21
  7. package/lib/element/assertion/contained.js +24 -22
  8. package/lib/element/assertion/defined.js +20 -19
  9. package/lib/element/assertion/property.js +14 -13
  10. package/lib/element/assertion/satisfies.js +8 -9
  11. package/lib/element/assertion/subproof.js +23 -26
  12. package/lib/element/assertion/type.js +9 -11
  13. package/lib/element/assumption.js +32 -39
  14. package/lib/element/combinator/bracketed.js +3 -3
  15. package/lib/element/combinator.js +20 -20
  16. package/lib/element/conclusion.js +33 -29
  17. package/lib/element/constructor.js +19 -18
  18. package/lib/element/deduction.js +33 -29
  19. package/lib/element/equality.js +13 -15
  20. package/lib/element/equivalence.js +59 -52
  21. package/lib/element/frame.js +41 -34
  22. package/lib/element/hypothesis.js +7 -5
  23. package/lib/element/judgement.js +32 -73
  24. package/lib/element/label.js +22 -22
  25. package/lib/element/metavariable.js +23 -7
  26. package/lib/element/proofAssertion/premise.js +48 -35
  27. package/lib/element/proofAssertion/step.js +35 -20
  28. package/lib/element/proofAssertion/supposition.js +48 -34
  29. package/lib/element/proofAssertion.js +1 -14
  30. package/lib/element/reference.js +80 -53
  31. package/lib/element/signature.js +44 -3
  32. package/lib/element/statement.js +28 -29
  33. package/lib/element/subproof.js +2 -2
  34. package/lib/element/substitution/frame.js +24 -19
  35. package/lib/element/substitution/metaLevel.js +31 -27
  36. package/lib/element/substitution/reference.js +11 -10
  37. package/lib/element/substitution/statement.js +30 -23
  38. package/lib/element/substitution/term.js +11 -10
  39. package/lib/element/term.js +24 -20
  40. package/lib/element/topLevelMetaAssertion.js +2 -2
  41. package/lib/element/variable.js +6 -2
  42. package/lib/process/assign.js +10 -4
  43. package/lib/process/unify.js +8 -8
  44. package/lib/process/validate.js +10 -8
  45. package/lib/utilities/context.js +68 -23
  46. package/lib/utilities/element.js +55 -27
  47. package/lib/utilities/json.js +8 -8
  48. package/lib/utilities/statement.js +1 -8
  49. package/lib/utilities/string.js +12 -1
  50. package/lib/utilities/unification.js +9 -7
  51. package/lib/utilities/validation.js +39 -31
  52. package/package.json +1 -1
  53. package/src/context/file/nominal.js +14 -16
  54. package/src/context/illative.js +17 -0
  55. package/src/context/nested.js +15 -0
  56. package/src/context/{scoped.js → proof.js} +73 -73
  57. package/src/context/thetic.js +17 -0
  58. package/src/context.js +23 -36
  59. package/src/element/assertion/contained.js +28 -28
  60. package/src/element/assertion/defined.js +23 -23
  61. package/src/element/assertion/property.js +15 -14
  62. package/src/element/assertion/satisfies.js +7 -9
  63. package/src/element/assertion/subproof.js +26 -31
  64. package/src/element/assertion/type.js +10 -12
  65. package/src/element/assumption.js +33 -54
  66. package/src/element/combinator/bracketed.js +2 -2
  67. package/src/element/combinator.js +23 -29
  68. package/src/element/conclusion.js +37 -40
  69. package/src/element/constructor.js +29 -34
  70. package/src/element/deduction.js +36 -39
  71. package/src/element/equality.js +16 -18
  72. package/src/element/equivalence.js +76 -67
  73. package/src/element/frame.js +42 -34
  74. package/src/element/hypothesis.js +7 -6
  75. package/src/element/judgement.js +34 -44
  76. package/src/element/label.js +25 -31
  77. package/src/element/metavariable.js +32 -12
  78. package/src/element/proofAssertion/premise.js +63 -49
  79. package/src/element/proofAssertion/step.js +43 -23
  80. package/src/element/proofAssertion/supposition.js +64 -50
  81. package/src/element/proofAssertion.js +0 -22
  82. package/src/element/reference.js +119 -80
  83. package/src/element/signature.js +5 -2
  84. package/src/element/statement.js +30 -35
  85. package/src/element/subproof.js +1 -1
  86. package/src/element/substitution/frame.js +27 -26
  87. package/src/element/substitution/metaLevel.js +38 -42
  88. package/src/element/substitution/reference.js +13 -14
  89. package/src/element/substitution/statement.js +35 -33
  90. package/src/element/substitution/term.js +13 -14
  91. package/src/element/term.js +42 -34
  92. package/src/element/topLevelMetaAssertion.js +1 -1
  93. package/src/element/variable.js +8 -1
  94. package/src/process/assign.js +9 -3
  95. package/src/process/unify.js +7 -7
  96. package/src/process/validate.js +9 -8
  97. package/src/utilities/context.js +82 -31
  98. package/src/utilities/element.js +68 -31
  99. package/src/utilities/json.js +13 -13
  100. package/src/utilities/statement.js +1 -9
  101. package/src/utilities/string.js +16 -2
  102. package/src/utilities/unification.js +10 -9
  103. package/src/utilities/validation.js +50 -38
  104. package/lib/context/scoped.js +0 -232
  105. package/lib/utilities/term.js +0 -17
  106. package/src/utilities/term.js +0 -10
@@ -57,7 +57,7 @@ export default define(class PropertyAssertion extends Assertion {
57
57
  return comparesToTermAndPropertyRelation;
58
58
  }
59
59
 
60
- validate(stated, context) {
60
+ validate(context) {
61
61
  let propertyAssertion = null;
62
62
 
63
63
  const propertyAssertionString = this.getString(); ///
@@ -73,12 +73,14 @@ export default define(class PropertyAssertion extends Assertion {
73
73
  } else {
74
74
  let validates = false;
75
75
 
76
- const termValidates = this.validateTerm(stated, context);
76
+ const termValidates = this.validateTerm(context);
77
77
 
78
78
  if (termValidates) {
79
- const propertyRelationVerifies = this.validatePropertyRelation(stated, context);
79
+ const propertyRelationVerifies = this.validatePropertyRelation(context);
80
80
 
81
81
  if (propertyRelationVerifies) {
82
+ const stated = context.isStated();
83
+
82
84
  let validatesWhenStated = false,
83
85
  validatesWhenDerived = false;
84
86
 
@@ -99,7 +101,7 @@ export default define(class PropertyAssertion extends Assertion {
99
101
 
100
102
  propertyAssertion = assertion; ///
101
103
 
102
- this.assign(stated, context);
104
+ this.assign(context);
103
105
 
104
106
  context.addAssertion(assertion);
105
107
 
@@ -110,7 +112,7 @@ export default define(class PropertyAssertion extends Assertion {
110
112
  return propertyAssertion;
111
113
  }
112
114
 
113
- validateTerm(stated, context) {
115
+ validateTerm(context) {
114
116
  let termValidates = false;
115
117
 
116
118
  const termString = this.term.getString();
@@ -136,7 +138,7 @@ export default define(class PropertyAssertion extends Assertion {
136
138
  return termValidates;
137
139
  }
138
140
 
139
- validatePropertyRelation(stated, context) {
141
+ validatePropertyRelation(context) {
140
142
  let propertyRelationValidates = false;
141
143
 
142
144
  const propertyRelationString = this.propertyRelation.getString();
@@ -188,16 +190,17 @@ export default define(class PropertyAssertion extends Assertion {
188
190
  return validatesWhenDerived;
189
191
  }
190
192
 
191
- assign(stated, context) {
193
+ assign(context) {
194
+ const stated = context.isStated();
195
+
192
196
  if (!stated) {
193
197
  return;
194
198
  }
195
199
 
196
200
  const propertyAssertion = this, ///
197
- variableAssigment = variableAssignmentFromPrepertyAssertion(propertyAssertion, context),
198
- assignment = variableAssigment; ///
201
+ variableAssigment = variableAssignmentFromPrepertyAssertion(propertyAssertion, context);
199
202
 
200
- context.addAssignment(assignment);
203
+ context.addAssignment(variableAssigment);
201
204
  }
202
205
 
203
206
  static name = "PropertyAssertion";
@@ -208,7 +211,7 @@ export default define(class PropertyAssertion extends Assertion {
208
211
  const { name } = json;
209
212
 
210
213
  if (this.name === name) {
211
- propertyAssertion = instantiate((context) => {
214
+ instantiate((context) => {
212
215
  const { string } = json,
213
216
  propertyAssertionNode = instantiatePropertyAssertion(string, context),
214
217
  node = propertyAssertionNode, ///
@@ -217,9 +220,7 @@ export default define(class PropertyAssertion extends Assertion {
217
220
 
218
221
  context = null;
219
222
 
220
- const propertyAssertion = new PropertyAssertion(context, string, node, term, propertyRelation);
221
-
222
- return propertyAssertion;
223
+ propertyAssertion = new PropertyAssertion(context, string, node, term, propertyRelation);
223
224
  }, context);
224
225
  }
225
226
 
@@ -34,7 +34,7 @@ export default define(class SatisfiesAssertion extends Assertion {
34
34
 
35
35
  correlateSubstitutions(substitutions, context) { return this.signature.correlateSubstitutions(substitutions, context); }
36
36
 
37
- validate(stated, context) {
37
+ validate(context) {
38
38
  let satisfiesAssertion = null;
39
39
 
40
40
  const satisfiesAssertionString = this.getString(); ///
@@ -50,10 +50,10 @@ export default define(class SatisfiesAssertion extends Assertion {
50
50
  } else {
51
51
  let validates = true;
52
52
 
53
- const signatureVerifies = this.validateSignature(stated, context);
53
+ const signatureVerifies = this.validateSignature(context);
54
54
 
55
55
  if (signatureVerifies) {
56
- const referenceVerifies = this.validateReference(stated, context);
56
+ const referenceVerifies = this.validateReference(context);
57
57
 
58
58
  if (referenceVerifies) {
59
59
  validates = true;
@@ -76,7 +76,7 @@ export default define(class SatisfiesAssertion extends Assertion {
76
76
  return satisfiesAssertion;
77
77
  }
78
78
 
79
- validateSignature(stated, context) {
79
+ validateSignature(context) {
80
80
  let signatureValidates = false;
81
81
 
82
82
  const signature = this.signature.validate(context);
@@ -88,7 +88,7 @@ export default define(class SatisfiesAssertion extends Assertion {
88
88
  return signatureValidates;
89
89
  }
90
90
 
91
- validateReference(stated, context) {
91
+ validateReference(context) {
92
92
  let referenceVerifies = false;
93
93
 
94
94
  const referenceString = this.reference.getString(),
@@ -165,7 +165,7 @@ export default define(class SatisfiesAssertion extends Assertion {
165
165
  const { name } = json;
166
166
 
167
167
  if (this.name === name) {
168
- satisfiesAssertion = instantiate((context) => {const { string } = json,
168
+ instantiate((context) => {const { string } = json,
169
169
  definedAssertionNode = instantiateSatisfiesAssertion(string, context),
170
170
  node = definedAssertionNode, ///
171
171
  signature = signatureFromJSatisfiesAssertionNode(definedAssertionNode, context),
@@ -173,9 +173,7 @@ export default define(class SatisfiesAssertion extends Assertion {
173
173
 
174
174
  context = null;
175
175
 
176
- const satisfiesAssertion = new SatisfiesAssertion(context, string, node, signature, reference);
177
-
178
- return satisfiesAssertion;
176
+ satisfiesAssertion = new SatisfiesAssertion(context, string, node, signature, reference);
179
177
  }, context);
180
178
  }
181
179
 
@@ -6,7 +6,7 @@ import Assertion from "../assertion";
6
6
 
7
7
  import { define } from "../../elements";
8
8
  import { reconcile } from "../../utilities/context";
9
- import { join, instantiate } from "../../utilities/context";
9
+ import { join, descend, instantiate } from "../../utilities/context";
10
10
  import { instantiateSubproofAssertion } from "../../process/instantiate";
11
11
 
12
12
  const { last, front, backwardsEvery } = arrayUtilities;
@@ -49,7 +49,7 @@ export default define(class SubproofAssertion extends Assertion {
49
49
  return subproofAssertionNode;
50
50
  }
51
51
 
52
- validate(stated, context) {
52
+ validate(context) {
53
53
  let subproofAssertion = null;
54
54
 
55
55
  const subproofAssertionString = this.getString(); ///
@@ -65,7 +65,7 @@ export default define(class SubproofAssertion extends Assertion {
65
65
  } else {
66
66
  let validates = false;
67
67
 
68
- const statementsValidate = this.validateStatements(stated, context);
68
+ const statementsValidate = this.validateStatements(context);
69
69
 
70
70
  if (statementsValidate) {
71
71
  validates = true;
@@ -85,17 +85,17 @@ export default define(class SubproofAssertion extends Assertion {
85
85
  return subproofAssertion;
86
86
  }
87
87
 
88
- validateStatements(stated, context) {
89
- stated = true; ///
90
-
91
- const statementsValidate = this.statements.map((statement) => {
88
+ validateStatements(context) {
89
+ const statementsValidate = this.statements.every((statement) => {
92
90
  let statementValidates = false;
93
91
 
94
- statement = statement.validate(stated, context); ///
92
+ descend((context) => {
93
+ statement = statement.validate(context); ///
95
94
 
96
- if (statement !== null) {
97
- statementValidates = true;
98
- }
95
+ if (statement !== null) {
96
+ statementValidates = true;
97
+ }
98
+ }, context);
99
99
 
100
100
  if (statementValidates) {
101
101
  return true;
@@ -239,7 +239,7 @@ export default define(class SubproofAssertion extends Assertion {
239
239
  return suppositionUnifies;
240
240
  }
241
241
 
242
- unifySuppositions(suppositions, generalContext, specificContext) {
242
+ unifySuppositions(suppositions, generalContxt, spsecificContext) {
243
243
  let suppositionsUnify = false;
244
244
 
245
245
  const supposedStatements = this.getSupposedStatements(),
@@ -248,7 +248,7 @@ export default define(class SubproofAssertion extends Assertion {
248
248
 
249
249
  if (suppositionsLength === supposedStatementsLength) {
250
250
  suppositionsUnify = backwardsEvery(suppositions, (supposition, index) => {
251
- const suppositionUnifies = this.unifySupposition(supposition, index, generalContext, specificContext);
251
+ const suppositionUnifies = this.unifySupposition(supposition, index, generalContxt, spsecificContext);
252
252
 
253
253
  if (suppositionUnifies) {
254
254
  return true;
@@ -259,30 +259,27 @@ export default define(class SubproofAssertion extends Assertion {
259
259
  return suppositionsUnify;
260
260
  }
261
261
 
262
- unifyTopLevelMetaAssertion(topLevelMetaAssertion, generalContext, specificContext) {
262
+ unifyTopLevelMetaAssertion(topLevelMetaAssertion, context) {
263
263
  let topLevelMetaAssertionUnifies = false;
264
264
 
265
- const context = specificContext, ///
265
+ const generalContext = context, ///
266
+ specificContext = context, ///
266
267
  subproofAssertionString = this.getString(), ///
267
268
  topLevelMetaAssertionString = topLevelMetaAssertion.getString();
268
269
 
269
270
  context.trace(`Unifying the '${topLevelMetaAssertionString}' top level meta-assertion with the '${subproofAssertionString}' subproof assertion...`);
270
271
 
271
- reconcile((specificContext) => {
272
- const deduction = topLevelMetaAssertion.getDeduction(),
273
- deductionUnifies = this.unifyDeduction(deduction, generalContext, specificContext);
274
-
275
- if (deductionUnifies) {
276
- const suppositions = topLevelMetaAssertion.getSuppositions(),
277
- suppositionsUnify = this.unifySuppositions(suppositions, generalContext, specificContext);
272
+ const deduction = topLevelMetaAssertion.getDeduction(),
273
+ deductionUnifies = this.unifyDeduction(deduction, generalContext, specificContext);
278
274
 
279
- if (suppositionsUnify) {
280
- specificContext.commit();
275
+ if (deductionUnifies) {
276
+ const suppositions = topLevelMetaAssertion.getSuppositions(),
277
+ suppositionsUnify = this.unifySuppositions(suppositions, generalContext, specificContext);
281
278
 
282
- topLevelMetaAssertionUnifies = true;
283
- }
279
+ if (suppositionsUnify) {
280
+ topLevelMetaAssertionUnifies = true;
284
281
  }
285
- }, specificContext);
282
+ }
286
283
 
287
284
  if (topLevelMetaAssertionUnifies) {
288
285
  context.debug(`...unified the '${topLevelMetaAssertionString}' top level meta-assertion with the '${subproofAssertionString}' subproof assertion.`);
@@ -299,7 +296,7 @@ export default define(class SubproofAssertion extends Assertion {
299
296
  const { name } = json;
300
297
 
301
298
  if (this.name === name) {
302
- subproorAssertion = instantiate((context) => {
299
+ instantiate((context) => {
303
300
  const { string } = json,
304
301
  subproofAssertionNode = instantiateSubproofAssertion(string, context),
305
302
  statements = statementsFromSubproofAssertionNode(subproofAssertionNode, context),
@@ -307,9 +304,7 @@ export default define(class SubproofAssertion extends Assertion {
307
304
 
308
305
  context = null;
309
306
 
310
- const subproorAssertion = new SubproofAssertion(context, string, node, statements);
311
-
312
- return subproorAssertion;
307
+ subproorAssertion = new SubproofAssertion(context, string, node, statements);
313
308
  }, context);
314
309
  }
315
310
 
@@ -32,7 +32,7 @@ export default define(class TypeAssertion extends Assertion {
32
32
  return typeAssertionNode;
33
33
  }
34
34
 
35
- validate(stated, context) {
35
+ validate(context) {
36
36
  let typeAssertion = null;
37
37
 
38
38
  const typeAssertionString = this.getString(); ///
@@ -51,6 +51,8 @@ export default define(class TypeAssertion extends Assertion {
51
51
  const typeValidates = this.validateType(context);
52
52
 
53
53
  if (typeValidates) {
54
+ const stated = context.isStated();
55
+
54
56
  let validatesWhenStated = false,
55
57
  validatesWhenDerived = false;
56
58
 
@@ -70,7 +72,7 @@ export default define(class TypeAssertion extends Assertion {
70
72
 
71
73
  typeAssertion = assertion; ///
72
74
 
73
- this.assign(stated, context);
75
+ this.assign(context);
74
76
 
75
77
  context.addAssertion(assertion);
76
78
 
@@ -177,7 +179,9 @@ export default define(class TypeAssertion extends Assertion {
177
179
  return validatesWhenDerived;
178
180
  }
179
181
 
180
- assign(stated, context) {
182
+ assign(context) {
183
+ const stated = context.isStated();
184
+
181
185
  if (!stated) {
182
186
  return;
183
187
  }
@@ -185,11 +189,7 @@ export default define(class TypeAssertion extends Assertion {
185
189
  const typeAssertion = this, ///
186
190
  variableAssigment = variableAssignmentFromTypeAssertion(typeAssertion, context);
187
191
 
188
- if (variableAssigment !== null) {
189
- const assignment = variableAssigment; ///
190
-
191
- context.addAssignment(assignment);
192
- }
192
+ context.addAssignment(variableAssigment);
193
193
  }
194
194
 
195
195
  toJSON() {
@@ -214,7 +214,7 @@ export default define(class TypeAssertion extends Assertion {
214
214
  const { name } = json;
215
215
 
216
216
  if (this.name === name) {
217
- typeAssertion = instantiate((context) => {
217
+ instantiate((context) => {
218
218
  const { string } = json,
219
219
  typeAssertionNode = instantiateTypeAssertion(string, context),
220
220
  term = termFromTypeAssertionNode(typeAssertionNode, context),
@@ -223,9 +223,7 @@ export default define(class TypeAssertion extends Assertion {
223
223
 
224
224
  context = null;
225
225
 
226
- const typeAssertion = new TypeAssertion(context, string, node, term, type);
227
-
228
- return typeAssertion;
226
+ typeAssertion = new TypeAssertion(context, string, node, term, type);
229
227
  }, context);
230
228
  }
231
229
 
@@ -3,8 +3,8 @@
3
3
  import { Element } from "occam-languages";
4
4
 
5
5
  import { define } from "../elements";
6
+ import { descend, instantiate } from "../utilities/context";
6
7
  import { instantiateAssumption } from "../process/instantiate";
7
- import { instantiate, reconcile } from "../utilities/context";
8
8
 
9
9
  export default define(class Assumption extends Element {
10
10
  constructor(context, string, node, reference, statement) {
@@ -31,6 +31,8 @@ export default define(class Assumption extends Element {
31
31
 
32
32
  getMetavariable() { return this.reference.getMetavariable(); }
33
33
 
34
+ getTopLevelMetaAssertion() { return this.reference.getTopLevelMetaAssertion(); }
35
+
34
36
  matchAssumptionNode(assumptionNode) {
35
37
  const node = assumptionNode, ///
36
38
  nodeMatches = this.matchNode(node),
@@ -71,7 +73,7 @@ export default define(class Assumption extends Element {
71
73
  return validAssumption;
72
74
  }
73
75
 
74
- validate(stated, context) {
76
+ validate(context) {
75
77
  let assumption = null;
76
78
 
77
79
  const assumptionString = this.getString(); ///
@@ -87,12 +89,14 @@ export default define(class Assumption extends Element {
87
89
  } else {
88
90
  let validates = false;
89
91
 
90
- const statementValidates = this.validateStatement(stated, context);
92
+ const statementValidates = this.validateStatement(context);
91
93
 
92
94
  if (statementValidates) {
93
- const referenceValidates = this.validateReference(stated, context);
95
+ const referenceValidates = this.validateReference(context);
94
96
 
95
97
  if (referenceValidates) {
98
+ const stated = context.isStated();
99
+
96
100
  let validatesWhenStated = false,
97
101
  validatesWhenDerived = false;
98
102
 
@@ -120,11 +124,11 @@ export default define(class Assumption extends Element {
120
124
  return assumption;
121
125
  }
122
126
 
123
- validateReference(stated, context) {
127
+ validateReference(context) {
124
128
  let referenceValidates = false;
125
129
 
126
- const assumptionString = this.getString(), ///
127
- referenceString = this.reference.getString();
130
+ const referenceString = this.reference.getString(),
131
+ assumptionString = this.getString(); ///
128
132
 
129
133
  context.trace(`Validating the '${assumptionString}' assumption's '${referenceString}' reference...`);
130
134
 
@@ -137,7 +141,7 @@ export default define(class Assumption extends Element {
137
141
  if (metavariablePresent) {
138
142
  referenceValidates = true;
139
143
  } else {
140
- const topLevelMetaAssertions = context.findTopLevelMetaAssertionsByReference(this.reference, context),
144
+ const topLevelMetaAssertions = context.findTopLevelMetaAssertionsByReference(this.reference),
141
145
  topLevelMetaAssertionsCompare = topLevelMetaAssertions.some((topLevelMetaAssertion) => {
142
146
  const topLevelMetaAssertionUnifies = this.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
143
147
 
@@ -153,13 +157,13 @@ export default define(class Assumption extends Element {
153
157
  }
154
158
 
155
159
  if (referenceValidates) {
156
- context.debug(`...validated the '${assumptionString}' assumption's '${referenceString}' statement.`);
160
+ context.debug(`...validated the '${assumptionString}' assumption's '${referenceString}' reference.`);
157
161
  }
158
162
 
159
163
  return referenceValidates;
160
164
  }
161
165
 
162
- validateStatement(stated, context) {
166
+ validateStatement(context) {
163
167
  let statementValidates = false;
164
168
 
165
169
  const assumptionString = this.getString(), ///
@@ -167,13 +171,13 @@ export default define(class Assumption extends Element {
167
171
 
168
172
  context.trace(`Validating the '${assumptionString}' assumption's '${statementString}' statement...`);
169
173
 
170
- stated = true; ///
171
-
172
- const statement = this.statement.validate(stated, context);
174
+ descend((context) => {
175
+ const statement = this.statement.validate(context);
173
176
 
174
- if (statement !== null) {
175
- statementValidates = true;
176
- }
177
+ if (statement !== null) {
178
+ statementValidates = true;
179
+ }
180
+ }, context);
177
181
 
178
182
  if (statementValidates) {
179
183
  context.debug(`...validated the '${assumptionString}' assumption's '${statementString}' statement.`);
@@ -199,13 +203,19 @@ export default define(class Assumption extends Element {
199
203
  }
200
204
 
201
205
  validateWhenDerived(context) {
202
- let validatesWhenDerived;
206
+ let validatesWhenDerived = false;
203
207
 
204
208
  const assumptionString = this.getString(); ///
205
209
 
206
210
  context.trace(`Validating the '${assumptionString}' derived assumption...`);
207
211
 
208
- validatesWhenDerived = true;
212
+ const topLevelMetaAssertion = this.getTopLevelMetaAssertion();
213
+
214
+ if (topLevelMetaAssertion !== null) {
215
+ validatesWhenDerived = true;
216
+ } else {
217
+ context.debug(`The '${assumptionString}' asumption did not unify a top level meta-assumption.`);
218
+ }
209
219
 
210
220
  if (validatesWhenDerived) {
211
221
  context.debug(`...validated the '${assumptionString}' derived assumption.`);
@@ -214,50 +224,19 @@ export default define(class Assumption extends Element {
214
224
  return validatesWhenDerived;
215
225
  }
216
226
 
217
- unifyLabel(label, generalContext, specificContext) {
218
- let labelUnifiesWithReference;
219
-
220
- const context = generalContext, ///
221
- labelString = label.getString(),
222
- assumptionString = this.getString(); //;/
223
-
224
- context.trace(`Unifying the '${labelString}' label with the '${assumptionString}' assumption...`);
225
-
226
- const labelUnifies = this.reference.unifyLabel(label, context);
227
-
228
- labelUnifiesWithReference = labelUnifies; ///
229
-
230
- if (labelUnifiesWithReference) {
231
- context.debug(`...unified the '${labelString}' label with the '${assumptionString}' assumption.`);
232
- }
233
-
234
- return labelUnifiesWithReference;
235
- }
236
-
237
227
  unifyTopLevelMetaAssertion(topLevelMetaAssertion, context) {
238
- let topLevelMetaAssertionUnifies = false;
228
+ let topLevelMetaAssertionUnifies;
239
229
 
240
230
  const assumptionString = this.getString(), ///
241
231
  topLevelMetaAssertionString = topLevelMetaAssertion.getString();
242
232
 
243
233
  context.trace(`Unifying the '${topLevelMetaAssertionString}' top level meta-assertion with the '${assumptionString}' assumption...`);
244
234
 
245
- const generalContext = context; ///
246
-
247
- context = topLevelMetaAssertion.getContext(); ///
235
+ topLevelMetaAssertionUnifies = this.reference.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
248
236
 
249
- const specificContext = context; ///
250
-
251
- reconcile((specificContext) => {
252
- const label = topLevelMetaAssertion.getLabel(),
253
- labelUnifies = this.unifyLabel(label, generalContext, specificContext);
254
-
255
- if (labelUnifies) {
256
- topLevelMetaAssertionUnifies = this.statement.unifyTopLevelMetaAssertion(topLevelMetaAssertion, generalContext, specificContext);
257
-
258
- specificContext.commit(context);
259
- }
260
- }, specificContext);
237
+ if (topLevelMetaAssertionUnifies) {
238
+ topLevelMetaAssertionUnifies = this.statement.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
239
+ }
261
240
 
262
241
  if (topLevelMetaAssertionUnifies) {
263
242
  context.trace(`...unified the '${topLevelMetaAssertionString}' top level meta-assertion with the '${assumptionString}' assumption...`);
@@ -12,14 +12,14 @@ export default define(class BracketedCombinator extends Combinator {
12
12
  return bracketedCombinatorNode;
13
13
  }
14
14
 
15
- unifyStatement(statement, stated, context) {
15
+ unifyStatement(statement, context) {
16
16
  let statementUnifies;
17
17
 
18
18
  const statementString = statement.getString();
19
19
 
20
20
  context.trace(`Unifying the '${statementString}' statement with the bracketed combinator...`);
21
21
 
22
- statementUnifies = super.unifyStatement(statement, stated, context);
22
+ statementUnifies = super.unifyStatement(statement, context);
23
23
 
24
24
  if (statementUnifies) {
25
25
  context.debug(`...unified the '${statementString}' statement with the bracketed combinator.`);
@@ -3,12 +3,11 @@
3
3
  import { Element } from "occam-languages";
4
4
 
5
5
  import { define } from "../elements";
6
- import { attempt, instantiate } from "../utilities/context";
7
6
  import { instantiateCombinator } from "../process/instantiate";
8
7
  import { statementFromCombinatorNode } from "../utilities/element";
9
8
  import { unifyStatementWithCombinator } from "../process/unify";
10
9
  import { validateStatementAsCombinator } from "../process/validate";
11
- import { ephemeralContextFromJSON, ephemeralContextToEphemeralContextJSON } from "../utilities/json";
10
+ import { attempt, serialise, unserialise, instantiate } from "../utilities/context";
12
11
 
13
12
  export default define(class Combinator extends Element {
14
13
  constructor(context, string, node, statement) {
@@ -73,7 +72,7 @@ export default define(class Combinator extends Element {
73
72
  return statementValidates;
74
73
  }
75
74
 
76
- unifyStatement(statement, stated, context) {
75
+ unifyStatement(statement, context) {
77
76
  let statementUnifies;
78
77
 
79
78
  const statementString = statement.getString(),
@@ -90,7 +89,7 @@ export default define(class Combinator extends Element {
90
89
  context = specifiContext; ///
91
90
 
92
91
  const combinator = this, ///
93
- statementUnifiesWithCombinator = unifyStatementWithCombinator(statement, combinator, stated, generalContext, specifiContext);
92
+ statementUnifiesWithCombinator = unifyStatementWithCombinator(statement, combinator, generalContext, specifiContext);
94
93
 
95
94
  statementUnifies = statementUnifiesWithCombinator; ///
96
95
 
@@ -102,40 +101,35 @@ export default define(class Combinator extends Element {
102
101
  }
103
102
 
104
103
  toJSON() {
105
- let context;
104
+ const context = this.getContext();
106
105
 
107
- context = this.getContext();
108
-
109
- const ephemeralContext = context, ///
110
- ephemeralContextJSON = ephemeralContextToEphemeralContextJSON(ephemeralContext),
111
- contextJSON = ephemeralContextJSON; ///
112
-
113
- context = contextJSON; ///
106
+ return serialise((context) => {
107
+ const string = this.getString(),
108
+ json = {
109
+ context,
110
+ string
111
+ };
114
112
 
115
- const string = this.getString(),
116
- json = {
117
- context,
118
- string
119
- };
120
-
121
- return json;
113
+ return json;
114
+ }, context);
122
115
  }
123
116
 
124
117
  static name = "Combinator";
125
118
 
126
119
  static fromJSON(json, context) {
127
- const ephemeralContext = ephemeralContextFromJSON(json, context);
120
+ let combinator;
128
121
 
129
- context = ephemeralContext; ///
122
+ unserialise((json, context) => {
123
+ instantiate((context) => {
124
+ const { string } = json,
125
+ combinatorNode = instantiateCombinator(string, context),
126
+ node = combinatorNode, ///
127
+ statement = statementFromCombinatorNode(combinatorNode, context);
130
128
 
131
- return instantiate((context) => {
132
- const { string } = json,
133
- combinatorNode = instantiateCombinator(string, context),
134
- node = combinatorNode, ///
135
- statement = statementFromCombinatorNode(combinatorNode, context),
136
- combinator = new Combinator(context, string, node, statement);
129
+ combinator = new Combinator(context, string, node, statement);
130
+ }, context);
131
+ }, json, context);
137
132
 
138
- return combinator;
139
- }, context);
133
+ return combinator;
140
134
  }
141
135
  });