occam-verify-cli 1.0.764 → 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 +16 -47
  2. package/lib/context/illative.js +28 -0
  3. package/lib/context/nested.js +27 -0
  4. package/lib/context/nominal.js +2 -4
  5. package/lib/context/proof.js +232 -0
  6. package/lib/context/thetic.js +28 -0
  7. package/lib/context.js +37 -12
  8. package/lib/element/assertion/contained.js +24 -22
  9. package/lib/element/assertion/defined.js +20 -19
  10. package/lib/element/assertion/property.js +14 -13
  11. package/lib/element/assertion/satisfies.js +9 -10
  12. package/lib/element/assertion/subproof.js +23 -26
  13. package/lib/element/assertion/type.js +9 -11
  14. package/lib/element/assumption.js +46 -55
  15. package/lib/element/combinator/bracketed.js +3 -3
  16. package/lib/element/combinator.js +20 -20
  17. package/lib/element/conclusion.js +33 -29
  18. package/lib/element/constructor.js +19 -18
  19. package/lib/element/deduction.js +33 -29
  20. package/lib/element/equality.js +13 -15
  21. package/lib/element/equivalence.js +58 -49
  22. package/lib/element/frame.js +41 -34
  23. package/lib/element/hypothesis.js +7 -5
  24. package/lib/element/judgement.js +33 -73
  25. package/lib/element/label.js +22 -22
  26. package/lib/element/metavariable.js +23 -7
  27. package/lib/element/proofAssertion/premise.js +48 -35
  28. package/lib/element/proofAssertion/step.js +35 -20
  29. package/lib/element/proofAssertion/supposition.js +48 -34
  30. package/lib/element/proofAssertion.js +1 -14
  31. package/lib/element/reference.js +79 -52
  32. package/lib/element/signature.js +44 -3
  33. package/lib/element/statement.js +28 -28
  34. package/lib/element/substitution/frame.js +28 -23
  35. package/lib/element/substitution/metaLevel.js +34 -30
  36. package/lib/element/substitution/reference.js +12 -11
  37. package/lib/element/substitution/statement.js +44 -39
  38. package/lib/element/substitution/term.js +12 -11
  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 -25
  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 +6 -4
  51. package/lib/utilities/validation.js +39 -31
  52. package/package.json +1 -1
  53. package/src/context/file/nominal.js +26 -74
  54. package/src/context/illative.js +17 -0
  55. package/src/context/nested.js +15 -0
  56. package/src/context/nominal.js +1 -5
  57. package/src/context/{scoped.js → proof.js} +73 -73
  58. package/src/context/thetic.js +17 -0
  59. package/src/context.js +58 -17
  60. package/src/element/assertion/contained.js +28 -28
  61. package/src/element/assertion/defined.js +23 -23
  62. package/src/element/assertion/property.js +15 -14
  63. package/src/element/assertion/satisfies.js +8 -10
  64. package/src/element/assertion/subproof.js +26 -31
  65. package/src/element/assertion/type.js +10 -12
  66. package/src/element/assumption.js +51 -74
  67. package/src/element/combinator/bracketed.js +2 -2
  68. package/src/element/combinator.js +23 -29
  69. package/src/element/conclusion.js +37 -40
  70. package/src/element/constructor.js +29 -34
  71. package/src/element/deduction.js +36 -39
  72. package/src/element/equality.js +16 -18
  73. package/src/element/equivalence.js +77 -64
  74. package/src/element/frame.js +43 -35
  75. package/src/element/hypothesis.js +7 -6
  76. package/src/element/judgement.js +37 -43
  77. package/src/element/label.js +25 -31
  78. package/src/element/metavariable.js +32 -12
  79. package/src/element/proofAssertion/premise.js +63 -49
  80. package/src/element/proofAssertion/step.js +43 -23
  81. package/src/element/proofAssertion/supposition.js +64 -50
  82. package/src/element/proofAssertion.js +0 -22
  83. package/src/element/reference.js +118 -79
  84. package/src/element/signature.js +5 -2
  85. package/src/element/statement.js +30 -33
  86. package/src/element/substitution/frame.js +32 -30
  87. package/src/element/substitution/metaLevel.js +43 -46
  88. package/src/element/substitution/reference.js +17 -17
  89. package/src/element/substitution/statement.js +58 -56
  90. package/src/element/substitution/term.js +17 -17
  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 +79 -36
  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 +7 -6
  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
@@ -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 referenceValidates = this.validateReference(stated, context);
92
+ const statementValidates = this.validateStatement(context);
93
+
94
+ if (statementValidates) {
95
+ const referenceValidates = this.validateReference(context);
91
96
 
92
- if (referenceValidates) {
93
- const statementValidates = this.validateStatement(stated, context);
97
+ if (referenceValidates) {
98
+ const stated = context.isStated();
94
99
 
95
- if (statementValidates) {
96
100
  let validatesWhenStated = false,
97
101
  validatesWhenDerived = false;
98
102
 
@@ -120,28 +124,46 @@ 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
 
131
135
  const reference = this.reference.validate(context);
132
136
 
133
137
  if (reference !== null) {
134
- referenceValidates = true;
138
+ const metavariable = this.reference.getMetavariable(),
139
+ metavariablePresent = context.isMetavariablePresent(metavariable, context);
140
+
141
+ if (metavariablePresent) {
142
+ referenceValidates = true;
143
+ } else {
144
+ const topLevelMetaAssertions = context.findTopLevelMetaAssertionsByReference(this.reference),
145
+ topLevelMetaAssertionsCompare = topLevelMetaAssertions.some((topLevelMetaAssertion) => {
146
+ const topLevelMetaAssertionUnifies = this.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
147
+
148
+ if (topLevelMetaAssertionUnifies) {
149
+ return true;
150
+ }
151
+ });
152
+
153
+ if (topLevelMetaAssertionsCompare) {
154
+ referenceValidates = true;
155
+ }
156
+ }
135
157
  }
136
158
 
137
159
  if (referenceValidates) {
138
- context.debug(`...validated the '${assumptionString}' assumption's '${referenceString}' statement.`);
160
+ context.debug(`...validated the '${assumptionString}' assumption's '${referenceString}' reference.`);
139
161
  }
140
162
 
141
163
  return referenceValidates;
142
164
  }
143
165
 
144
- validateStatement(stated, context) {
166
+ validateStatement(context) {
145
167
  let statementValidates = false;
146
168
 
147
169
  const assumptionString = this.getString(), ///
@@ -149,13 +171,13 @@ export default define(class Assumption extends Element {
149
171
 
150
172
  context.trace(`Validating the '${assumptionString}' assumption's '${statementString}' statement...`);
151
173
 
152
- stated = true; ///
153
-
154
- const statement = this.statement.validate(stated, context);
174
+ descend((context) => {
175
+ const statement = this.statement.validate(context);
155
176
 
156
- if (statement !== null) {
157
- statementValidates = true;
158
- }
177
+ if (statement !== null) {
178
+ statementValidates = true;
179
+ }
180
+ }, context);
159
181
 
160
182
  if (statementValidates) {
161
183
  context.debug(`...validated the '${assumptionString}' assumption's '${statementString}' statement.`);
@@ -165,31 +187,13 @@ export default define(class Assumption extends Element {
165
187
  }
166
188
 
167
189
  validateWhenStated(context) {
168
- let validatesWhenStated = false;
190
+ let validatesWhenStated;
169
191
 
170
192
  const assumptionString = this.getString(); ///
171
193
 
172
194
  context.trace(`Validating the '${assumptionString}' stated assumption...`);
173
195
 
174
- const metavariable = this.reference.getMetavariable(),
175
- metavariablePresent = context.isMetavariablePresent(metavariable, context);
176
-
177
- if (metavariablePresent) {
178
- validatesWhenStated = true;
179
- } else {
180
- const topLevelMetaAssertions = context.findTopLevelMetaAssertionsByReference(this.reference),
181
- topLevelMetaAssertionsCompare = topLevelMetaAssertions.some((topLevelMetaAssertion) => {
182
- const topLevelMetaAssertionCompares = this.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
183
-
184
- if (topLevelMetaAssertionCompares) {
185
- return true;
186
- }
187
- });
188
-
189
- if (topLevelMetaAssertionsCompare) {
190
- validatesWhenStated = true;
191
- }
192
- }
196
+ validatesWhenStated = true
193
197
 
194
198
  if (validatesWhenStated) {
195
199
  context.debug(`...validated the '${assumptionString}' stated assumption.`);
@@ -205,10 +209,12 @@ export default define(class Assumption extends Element {
205
209
 
206
210
  context.trace(`Validating the '${assumptionString}' derived assumption...`);
207
211
 
208
- const topLevelMetaAssertionPresent = context.isTopLevelMetaAssertionPresentByReference(this.reference);
212
+ const topLevelMetaAssertion = this.getTopLevelMetaAssertion();
209
213
 
210
- if (topLevelMetaAssertionPresent) {
214
+ if (topLevelMetaAssertion !== null) {
211
215
  validatesWhenDerived = true;
216
+ } else {
217
+ context.debug(`The '${assumptionString}' asumption did not unify a top level meta-assumption.`);
212
218
  }
213
219
 
214
220
  if (validatesWhenDerived) {
@@ -218,48 +224,19 @@ export default define(class Assumption extends Element {
218
224
  return validatesWhenDerived;
219
225
  }
220
226
 
221
- unifyLabel(label, generalContext, specificContext) {
222
- let labelUnifiesWithReference;
223
-
224
- const context = generalContext, ///
225
- labelString = label.getString(),
226
- assumptionString = this.getString(); //;/
227
-
228
- context.trace(`Unifying the '${labelString}' label with the '${assumptionString}' assumption...`);
229
-
230
- const labelUnifies = this.reference.unifyLabel(label, context);
231
-
232
- labelUnifiesWithReference = labelUnifies; ///
233
-
234
- if (labelUnifiesWithReference) {
235
- context.debug(`...unified the '${labelString}' label with the '${assumptionString}' assumption.`);
236
- }
237
-
238
- return labelUnifiesWithReference;
239
- }
240
-
241
227
  unifyTopLevelMetaAssertion(topLevelMetaAssertion, context) {
242
- let topLevelMetaAssertionUnifies = false;
228
+ let topLevelMetaAssertionUnifies;
243
229
 
244
230
  const assumptionString = this.getString(), ///
245
231
  topLevelMetaAssertionString = topLevelMetaAssertion.getString();
246
232
 
247
233
  context.trace(`Unifying the '${topLevelMetaAssertionString}' top level meta-assertion with the '${assumptionString}' assumption...`);
248
234
 
249
- const generalContext = context; ///
250
-
251
- context = topLevelMetaAssertion.getContext(); ///
252
-
253
- const specificContext = context; ///
254
-
255
- reconcile((specificContext) => {
256
- const label = topLevelMetaAssertion.getLabel(),
257
- labelUnifies = this.unifyLabel(label, generalContext, specificContext);
235
+ topLevelMetaAssertionUnifies = this.reference.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
258
236
 
259
- if (labelUnifies) {
260
- topLevelMetaAssertionUnifies = this.statement.unifyTopLevelMetaAssertion(topLevelMetaAssertion, generalContext, specificContext);
261
- }
262
- }, specificContext);
237
+ if (topLevelMetaAssertionUnifies) {
238
+ topLevelMetaAssertionUnifies = this.statement.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
239
+ }
263
240
 
264
241
  if (topLevelMetaAssertionUnifies) {
265
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
  });
@@ -3,11 +3,10 @@
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 { instantiateConclusion } from "../process/instantiate";
8
- import { ephemeralContextFromJSON, ephemeralContextToEphemeralContextJSON } from "../utilities/json";
7
+ import { declare, attempt, descend, serialise, unserialise, instantiate } from "../utilities/context";
9
8
 
10
- export default define(class Conclusion extends Element {
9
+ export default define(class Conclusion extends Element {
11
10
  constructor(context, string, node, statement) {
12
11
  super(context, string, node);
13
12
 
@@ -58,14 +57,16 @@ export default define(class Conclusion extends Element {
58
57
 
59
58
  context.trace(`Validating the '${conclusionString}' conclusion...`);
60
59
 
61
- attempt((context) => {
62
- const statementValidates = this.validateStatement(context);
60
+ declare((context) => {
61
+ attempt((context) => {
62
+ const statementValidates = this.validateStatement(context);
63
63
 
64
- if (statementValidates) {
65
- context.commit(this);
64
+ if (statementValidates) {
65
+ context.commit(this);
66
66
 
67
- validates = true;
68
- }
67
+ validates = true;
68
+ }
69
+ }, context);
69
70
  }, context);
70
71
 
71
72
  if (validates) {
@@ -76,19 +77,20 @@ export default define(class Conclusion extends Element {
76
77
  }
77
78
 
78
79
  validateStatement(context) {
79
- let statementValidates;
80
+ let statementValidates = false;
80
81
 
81
82
  const statementString = this.statement.getString(),
82
83
  conclusionString = this.getString(); ///
83
84
 
84
85
  context.trace(`Validating the '${conclusionString}' conclusion's '${statementString}' statement...`);
85
86
 
86
- const stated = true,
87
- statement = this.statement.validate(stated, context);
87
+ descend((context) => {
88
+ const statement = this.statement.validate(context);
88
89
 
89
- if (statement !== null) {
90
- statementValidates = true;
91
- }
90
+ if (statement !== null) {
91
+ statementValidates = true;
92
+ }
93
+ }, context);
92
94
 
93
95
  if (statementValidates) {
94
96
  context.trace(`...validated the '${conclusionString}' conclusion's '${statementString}' statement.`);
@@ -123,41 +125,36 @@ export default define(class Conclusion extends Element {
123
125
  }
124
126
 
125
127
  toJSON() {
126
- let context;
127
-
128
- context = this.getContext();
129
-
130
- const ephemeralContext = context, ///
131
- ephemeralContextJSON = ephemeralContextToEphemeralContextJSON(ephemeralContext),
132
- contextJSON = ephemeralContextJSON; ///
133
-
134
- context = contextJSON; ///
128
+ const context = this.getContext();
135
129
 
136
- const string = this.getString(),
137
- json = {
138
- context,
139
- string
140
- };
130
+ return serialise((context) => {
131
+ const string = this.getString(),
132
+ json = {
133
+ context,
134
+ string
135
+ };
141
136
 
142
- return json;
137
+ return json;
138
+ }, context);
143
139
  }
144
140
 
145
141
  static name = "Conclusion";
146
142
 
147
143
  static fromJSON(json, context) {
148
- const ephemeralContext = ephemeralContextFromJSON(json, context);
144
+ let conclusion;
149
145
 
150
- context = ephemeralContext; ///
146
+ unserialise((json, context) => {
147
+ instantiate((context) => {
148
+ const { string } = json,
149
+ conclusionNode = instantiateConclusion(string, context),
150
+ node = conclusionNode, ///
151
+ statement = statementFromConclusionNode(conclusionNode, context);
151
152
 
152
- return instantiate((context) => {
153
- const { string } = json,
154
- conclusionNode = instantiateConclusion(string, context),
155
- node = conclusionNode, ///
156
- statement = statementFromConclusionNode(conclusionNode, context),
157
- conclusion = new Conclusion(context, string, node, statement);
153
+ conclusion = new Conclusion(context, string, node, statement);
154
+ }, context);
155
+ }, json, context);
158
156
 
159
- return conclusion;
160
- }, context);
157
+ return conclusion;
161
158
  }
162
159
  });
163
160
 
@@ -3,12 +3,12 @@
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 { instantiateConstructor } from "../process/instantiate";
8
7
  import { termFromConstructorNode } from "../utilities/element";
9
8
  import { unifyTermWithConstructor } from "../process/unify";
10
9
  import { validateTermAsConstructor } from "../process/validate";
11
- import { typeFromJSON, typeToTypeJSON, ephemeralContextFromJSON, ephemeralContextToEphemeralContextJSON } from "../utilities/json";
10
+ import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
11
+ import { attempt, serialise, unserialise, instantiate } from "../utilities/context";
12
12
 
13
13
  export default define(class Constructor extends Element {
14
14
  constructor(context, string, node, term, type) {
@@ -143,45 +143,40 @@ export default define(class Constructor extends Element {
143
143
  }
144
144
 
145
145
  toJSON() {
146
- let context;
147
-
148
- context = this.getContext();
149
-
150
- const ephemeralContext = context, ///
151
- ephemeralContextJSON = ephemeralContextToEphemeralContextJSON(ephemeralContext),
152
- contextJSON = ephemeralContextJSON; ///
153
-
154
- context = contextJSON; ///
155
-
156
- const includeType = false,
157
- typeJSON = typeToTypeJSON(this.type),
158
- string = this.getString(includeType),
159
- type = typeJSON, ///
160
- json = {
161
- context,
162
- string,
163
- type
164
- };
165
-
166
- return json;
146
+ const context = this.getContext();
147
+
148
+ return serialise((context) => {
149
+ const includeType = false,
150
+ typeJSON = typeToTypeJSON(this.type),
151
+ string = this.getString(includeType),
152
+ type = typeJSON, ///
153
+ json = {
154
+ context,
155
+ string,
156
+ type
157
+ };
158
+
159
+ return json;
160
+ }, context);
167
161
  }
168
162
 
169
163
  static name = "Constructor";
170
164
 
171
165
  static fromJSON(json, context) {
172
- const ephemeralContext = ephemeralContextFromJSON(json, context);
166
+ let constructor;
173
167
 
174
- context = ephemeralContext; ///
168
+ unserialise((json, context) => {
169
+ instantiate((context) => {
170
+ const { string } = json,
171
+ constructorNode = instantiateConstructor(string, context),
172
+ node = constructorNode, ///
173
+ term = termFromConstructorNode(constructorNode, context),
174
+ type = typeFromJSON(json, context);
175
175
 
176
- return instantiate((context) => {
177
- const { string } = json,
178
- constructorNode = instantiateConstructor(string, context),
179
- node = constructorNode, ///
180
- term = termFromConstructorNode(constructorNode, context),
181
- type = typeFromJSON(json, context),
182
- constructor = new Constructor(context, string, node, term, type);
176
+ constructor = new Constructor(context, string, node, term, type);
177
+ }, context);
178
+ }, json, context);
183
179
 
184
- return constructor;
185
- }, context);
180
+ return constructor;
186
181
  }
187
182
  });
@@ -3,9 +3,8 @@
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 { instantiateDeduction } from "../process/instantiate";
8
- import { ephemeralContextFromJSON, ephemeralContextToEphemeralContextJSON } from "../utilities/json";
7
+ import { declare, attempt, descend, serialise, unserialise, instantiate } from "../utilities/context";
9
8
 
10
9
  export default define(class Deduction extends Element {
11
10
  constructor(context, string, node, statement) {
@@ -58,14 +57,16 @@ export default define(class Deduction extends Element {
58
57
 
59
58
  context.trace(`Validating the '${deductionString}' deduction...`);
60
59
 
61
- attempt((context) => {
62
- const statementValidates = this.validateStatement(context);
60
+ declare((context) => {
61
+ attempt((context) => {
62
+ const statementValidates = this.validateStatement(context);
63
63
 
64
- if (statementValidates) {
65
- context.commit(this);
64
+ if (statementValidates) {
65
+ context.commit(this);
66
66
 
67
- validates = true;
68
- }
67
+ validates = true;
68
+ }
69
+ }, context);
69
70
  }, context);
70
71
 
71
72
  if (validates) {
@@ -76,19 +77,20 @@ export default define(class Deduction extends Element {
76
77
  }
77
78
 
78
79
  validateStatement(context) {
79
- let statementValidates;
80
+ let statementValidates = false;
80
81
 
81
82
  const statementString = this.statement.getString(),
82
83
  deductionnString = this.getString(); ///
83
84
 
84
85
  context.trace(`Validating the '${deductionnString}' deductionn's '${statementString}' statement...`);
85
86
 
86
- const stated = true,
87
- statement = this.statement.validate(stated, context);
87
+ descend((context) => {
88
+ const statement = this.statement.validate(context);
88
89
 
89
- if (statement !== null) {
90
- statementValidates = true;
91
- }
90
+ if (statement !== null) {
91
+ statementValidates = true;
92
+ }
93
+ }, context);
92
94
 
93
95
  if (statementValidates) {
94
96
  context.trace(`...validated the '${deductionnString}' deductionn's '${statementString}' statement.`);
@@ -148,41 +150,36 @@ export default define(class Deduction extends Element {
148
150
  }
149
151
 
150
152
  toJSON() {
151
- let context;
152
-
153
- context = this.getContext();
154
-
155
- const ephemeralContext = context, ///
156
- ephemeralContextJSON = ephemeralContextToEphemeralContextJSON(ephemeralContext),
157
- contextJSON = ephemeralContextJSON; ///
158
-
159
- context = contextJSON; ///
153
+ const context = this.getContext();
160
154
 
161
- const string = this.getString(),
162
- json = {
163
- context,
164
- string
165
- };
155
+ return serialise((context) => {
156
+ const string = this.getString(),
157
+ json = {
158
+ context,
159
+ string
160
+ };
166
161
 
167
- return json;
162
+ return json;
163
+ }, context);
168
164
  }
169
165
 
170
166
  static name = "Deduction";
171
167
 
172
168
  static fromJSON(json, context) {
173
- const ephemeralContext = ephemeralContextFromJSON(json, context);
169
+ let deduction;
174
170
 
175
- context = ephemeralContext; ///
171
+ unserialise((json, context) => {
172
+ instantiate((context) => {
173
+ const { string } = json,
174
+ deductionNode = instantiateDeduction(string, context),
175
+ node = deductionNode, ///
176
+ statement = statementFromDeductionNode(deductionNode, context);
176
177
 
177
- return instantiate((context) => {
178
- const { string } = json,
179
- deductionNode = instantiateDeduction(string, context),
180
- node = deductionNode, ///
181
- statement = statementFromDeductionNode(deductionNode, context),
182
- deduction = new Deduction(context, string, node, statement);
178
+ deduction = new Deduction(context, string, node, statement);
179
+ }, context);
180
+ }, json, context);
183
181
 
184
- return deduction;
185
- }, context);
182
+ return deduction;
186
183
  }
187
184
  });
188
185