occam-verify-cli 1.0.956 → 1.0.973

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 (81) hide show
  1. package/lib/context/bounded.js +11 -7
  2. package/lib/context.js +17 -5
  3. package/lib/element/assertion/signature.js +17 -19
  4. package/lib/element/assertion/subproof.js +36 -39
  5. package/lib/element/assertion/type.js +20 -1
  6. package/lib/element/assumption/metaLevel.js +18 -17
  7. package/lib/element/assumption.js +52 -3
  8. package/lib/element/combinator.js +10 -12
  9. package/lib/element/conclusion.js +33 -33
  10. package/lib/element/constructor.js +7 -11
  11. package/lib/element/deduction.js +33 -33
  12. package/lib/element/equivalence.js +11 -7
  13. package/lib/element/hypothesis.js +45 -19
  14. package/lib/element/judgement.js +1 -1
  15. package/lib/element/label.js +9 -11
  16. package/lib/element/proofAssertion/premise.js +98 -87
  17. package/lib/element/proofAssertion/step.js +27 -27
  18. package/lib/element/proofAssertion/supposition.js +99 -88
  19. package/lib/element/proofAssertion.js +3 -3
  20. package/lib/element/reference.js +30 -38
  21. package/lib/element/signature.js +38 -47
  22. package/lib/element/statement.js +18 -58
  23. package/lib/element/substitution/frame.js +34 -42
  24. package/lib/element/substitution/reference.js +12 -13
  25. package/lib/element/substitution/statement.js +26 -31
  26. package/lib/element/substitution/term.js +32 -37
  27. package/lib/element/term.js +2 -2
  28. package/lib/element/topLevelAssertion/axiom.js +33 -34
  29. package/lib/element/topLevelAssertion.js +30 -7
  30. package/lib/element/topLevelMetaAssertion.js +2 -2
  31. package/lib/process/discharge.js +38 -0
  32. package/lib/process/unification.js +228 -0
  33. package/lib/process/unify.js +9 -5
  34. package/lib/process/validation.js +291 -0
  35. package/lib/utilities/context.js +69 -105
  36. package/lib/utilities/element.js +2 -4
  37. package/lib/utilities/string.js +4 -4
  38. package/package.json +1 -1
  39. package/src/context/bounded.js +19 -7
  40. package/src/context.js +26 -6
  41. package/src/element/assertion/signature.js +21 -26
  42. package/src/element/assertion/subproof.js +43 -45
  43. package/src/element/assertion/type.js +30 -1
  44. package/src/element/assumption/metaLevel.js +26 -22
  45. package/src/element/assumption.js +80 -2
  46. package/src/element/combinator.js +11 -14
  47. package/src/element/conclusion.js +38 -37
  48. package/src/element/constructor.js +8 -13
  49. package/src/element/deduction.js +38 -37
  50. package/src/element/equivalence.js +17 -13
  51. package/src/element/hypothesis.js +59 -19
  52. package/src/element/judgement.js +1 -1
  53. package/src/element/label.js +10 -12
  54. package/src/element/proofAssertion/premise.js +123 -107
  55. package/src/element/proofAssertion/step.js +29 -29
  56. package/src/element/proofAssertion/supposition.js +124 -108
  57. package/src/element/proofAssertion.js +2 -2
  58. package/src/element/reference.js +36 -47
  59. package/src/element/signature.js +42 -53
  60. package/src/element/statement.js +18 -89
  61. package/src/element/substitution/frame.js +45 -58
  62. package/src/element/substitution/reference.js +13 -16
  63. package/src/element/substitution/statement.js +27 -34
  64. package/src/element/substitution/term.js +37 -46
  65. package/src/element/term.js +1 -1
  66. package/src/element/topLevelAssertion/axiom.js +43 -45
  67. package/src/element/topLevelAssertion.js +42 -6
  68. package/src/element/topLevelMetaAssertion.js +2 -2
  69. package/src/process/discharge.js +33 -0
  70. package/src/{utilities → process}/unification.js +21 -27
  71. package/src/process/unify.js +9 -5
  72. package/src/{utilities → process}/validation.js +2 -2
  73. package/src/utilities/context.js +77 -128
  74. package/src/utilities/element.js +2 -5
  75. package/src/utilities/string.js +6 -6
  76. package/lib/context/ephemeral.js +0 -28
  77. package/lib/context/synoptic.js +0 -255
  78. package/lib/utilities/unification.js +0 -233
  79. package/lib/utilities/validation.js +0 -291
  80. package/src/context/ephemeral.js +0 -17
  81. package/src/context/synoptic.js +0 -361
@@ -30,6 +30,8 @@ export default define(class Assumption extends Element {
30
30
  return assumptionNode;
31
31
  }
32
32
 
33
+ getStatementNode() { return this.statement.getStatementNode(); }
34
+
33
35
  getMetavariable() { return this.reference.getMetavariable(); }
34
36
 
35
37
  getTopLevelMetaAssertion() { return this.reference.getTopLevelMetaAssertion(); }
@@ -50,6 +52,19 @@ export default define(class Assumption extends Element {
50
52
  return assumptionNodeMatches;
51
53
  }
52
54
 
55
+ findSubproofAssertion(context) {
56
+ let subproofAssertion = null;
57
+
58
+ const statementNode = this.getStatementNode(),
59
+ subproofAssertionNode = statementNode.getSubproofAssertionNode();
60
+
61
+ if (subproofAssertionNode !== null) {
62
+ subproofAssertion = context.findAssertionByAssertionNode(subproofAssertionNode);
63
+ }
64
+
65
+ return subproofAssertion;
66
+ }
67
+
53
68
  findValidAssumption(context) {
54
69
  const assumptionNode = this.getAssumptionNode(),
55
70
  assumption = context.findAssumptionByAssumptionNode(assumptionNode),
@@ -206,8 +221,56 @@ export default define(class Assumption extends Element {
206
221
  return validatesWhenDerived;
207
222
  }
208
223
 
224
+ unifyStatement(statement, generalContext, specificContext) {
225
+ let statementUnifies;
226
+
227
+ const context = specificContext, ///
228
+ statementString = statement.getString(),
229
+ proofAssertionString = this.getString(); ///
230
+
231
+ context.trace(`Unifying the '${statementString}' statement with the '${proofAssertionString}' assumption's statement...`);
232
+
233
+ statementUnifies = this.statement.unifyStatement(statement, generalContext, specificContext);
234
+
235
+ if (statementUnifies) {
236
+ context.debug(`...unified the '${statementString}' statement with the '${proofAssertionString}' assumption's statement.`);
237
+ }
238
+
239
+ return statementUnifies;
240
+ }
241
+
242
+ unifyDeduction(deduction, context) {
243
+ let deductionUnifies = false;
244
+
245
+ const deductionString = deduction.getString(),
246
+ assumptionString = this.getString(); ///
247
+
248
+ context.trace(`Unifying the '${deductionString}' deduction with the '${assumptionString}' assumption's statement...`);
249
+
250
+ const deductionContext = deduction.getContext(),
251
+ generalContext = context, ///
252
+ specificContext = deductionContext; ///
253
+
254
+ reconcile((specificContext) => {
255
+ const statement = deduction.getStatement(),
256
+ statementUnifies = this.unifyStatement(statement, generalContext, specificContext);
257
+
258
+ if (statementUnifies) {
259
+ specificContext.commit(context);
260
+
261
+ deductionUnifies = true;
262
+ }
263
+ }, specificContext);
264
+
265
+ if (deductionUnifies) {
266
+ context.debug(`...unified the '${deductionString}' deduction with the '${assumptionString}' assumption's statement.`);
267
+ }
268
+
269
+ return deductionUnifies;
270
+ }
271
+
209
272
  unifyTopLevelMetaAssertion(topLevelMetaAssertion, context) {
210
- let topLevelMetaAssertionUnifies;
273
+ let topLevelMetaAssertionUnifies = false;
211
274
 
212
275
  const assumptionString = this.getString(), ///
213
276
  topLevelMetaAssertionString = topLevelMetaAssertion.getString();
@@ -218,7 +281,22 @@ export default define(class Assumption extends Element {
218
281
  topLevelMetaAssertionUnifies = this.reference.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
219
282
 
220
283
  if (topLevelMetaAssertionUnifies) {
221
- topLevelMetaAssertionUnifies = this.statement.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
284
+ const subproofAssertion = this.findSubproofAssertion(context);
285
+
286
+ if (subproofAssertion !== null) {
287
+ topLevelMetaAssertionUnifies = subproofAssertion.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
288
+ } else {
289
+ const unconditional = topLevelMetaAssertion.isUnconditional();
290
+
291
+ if (unconditional) {
292
+ const deduction = topLevelMetaAssertion.getDeduction(),
293
+ deductionUnifies = this.unifyDeduction(deduction, context);
294
+
295
+ if (deductionUnifies) {
296
+ topLevelMetaAssertionUnifies = true;
297
+ }
298
+ }
299
+ }
222
300
  }
223
301
  }, context);
224
302
 
@@ -75,25 +75,22 @@ export default define(class Combinator extends Element {
75
75
  }
76
76
 
77
77
  unifyStatement(statement, context) {
78
- let statementUnifies;
78
+ let statementUnifies = false;
79
79
 
80
80
  const statementString = statement.getString(),
81
81
  combinatorString = this.getString(); ///
82
82
 
83
83
  context.trace(`Unifying the '${statementString}' statement with the '${combinatorString}' combinator...`);
84
84
 
85
- const specifiContext = context; ///
86
-
87
- context = this.getContext();
88
-
89
- const generalContext = context; ///
90
-
91
- context = specifiContext; ///
92
-
93
85
  const combinator = this, ///
86
+ combinatorContext = combinator.getContext(),
87
+ generalContext = combinatorContext, ///
88
+ specifiContext = context, ///
94
89
  statementUnifiesWithCombinator = unifyStatementWithCombinator(statement, combinator, generalContext, specifiContext);
95
90
 
96
- statementUnifies = statementUnifiesWithCombinator; ///
91
+ if (statementUnifiesWithCombinator) {
92
+ statementUnifies = true;
93
+ }
97
94
 
98
95
  if (statementUnifies) {
99
96
  context.debug(`...unified the '${statementString}' statement with the '${combinatorString}' combinator.`);
@@ -131,8 +128,8 @@ export default define(class Combinator extends Element {
131
128
  static fromJSON(json, context) {
132
129
  let combinator;
133
130
 
134
- unserialise((json, context) => {
135
- instantiate((context) => {
131
+ instantiate((context) => {
132
+ unserialise((json, context) => {
136
133
  const { string } = json,
137
134
  combinatorNode = instantiateCombinator(string, context),
138
135
  node = combinatorNode, ///
@@ -140,8 +137,8 @@ export default define(class Combinator extends Element {
140
137
  statement = statementFromCombinatorNode(combinatorNode, context);
141
138
 
142
139
  combinator = new Combinator(context, string, node, breakPoint, statement);
143
- }, context);
144
- }, json, context);
140
+ }, json, context);
141
+ }, context);
145
142
 
146
143
  return combinator;
147
144
  }
@@ -5,7 +5,7 @@ import { Element } from "occam-languages";
5
5
  import { define } from "../elements";
6
6
  import { instantiateConclusion } from "../process/instantiate";
7
7
  import { breakPointFromJSON, breakPointToBreakPointJSON } from "../utilities/breakPoint";
8
- import { declare, attempt, sequester, serialise, unserialise, instantiate } from "../utilities/context";
8
+ import { elide, declare, attempt, reconcile, serialise, unserialise, instantiate } from "../utilities/context";
9
9
 
10
10
  export default define(class Conclusion extends Element {
11
11
  constructor(context, string, node, breakPoint, statement) {
@@ -35,11 +35,15 @@ export default define(class Conclusion extends Element {
35
35
  context.trace(`Verifying the '${conclusionString}' conclusion...`);
36
36
 
37
37
  if (this.statement !== null) {
38
- const validates = this.validate(context);
39
-
40
- if (validates) {
41
- verifies = true;
42
- }
38
+ declare((context) => {
39
+ elide((context) => {
40
+ const validates = this.validate(context);
41
+
42
+ if (validates) {
43
+ verifies = true;
44
+ }
45
+ }, context);
46
+ }, context);
43
47
  } else {
44
48
  context.debug(`Unable to verify the '${conclusionString}' conclusion because it is nonsense.`);
45
49
  }
@@ -58,18 +62,16 @@ export default define(class Conclusion extends Element {
58
62
 
59
63
  context.trace(`Validating the '${conclusionString}' conclusion...`);
60
64
 
61
- declare((context) => {
62
- attempt((context) => {
63
- const statementValidates = this.validateStatement(context);
65
+ attempt((context) => {
66
+ const statementValidates = this.validateStatement(context);
64
67
 
65
- if (statementValidates) {
66
- validates = true;
67
- }
68
+ if (statementValidates) {
69
+ validates = true;
70
+ }
68
71
 
69
- if (validates) {
70
- this.commit(context);
71
- }
72
- }, context);
72
+ if (validates) {
73
+ this.commit(context);
74
+ }
73
75
  }, context);
74
76
 
75
77
  if (validates) {
@@ -86,13 +88,11 @@ export default define(class Conclusion extends Element {
86
88
 
87
89
  context.trace(`Validating the '${conclusionString}' conclusion's statement...`);
88
90
 
89
- sequester((context) => {
90
- const statement = this.statement.validate(context);
91
+ const statement = this.statement.validate(context);
91
92
 
92
- if (statement !== null) {
93
- statementValidates = true;
94
- }
95
- }, context);
93
+ if (statement !== null) {
94
+ statementValidates = true;
95
+ }
96
96
 
97
97
  if (statementValidates) {
98
98
  context.trace(`...validated the '${conclusionString}' conclusion's statement.`);
@@ -109,20 +109,21 @@ export default define(class Conclusion extends Element {
109
109
 
110
110
  context.trace(`Unifying the '${stepString}' step with the '${conclusionString}' conclusion...`);
111
111
 
112
- const specificContext = context; ///
113
-
114
- context = this.getContext();
115
-
116
- const generalContext = context; ///
112
+ const stepContext = step.getContext(),
113
+ conclusionContext = this.getContext(),
114
+ generalContext = conclusionContext, ///
115
+ specificContext = stepContext; ///
117
116
 
118
- context = specificContext; ///
117
+ reconcile((specificContext) => {
118
+ const statement = step.getStatement(),
119
+ statementUnifies = this.statement.unifyStatement(statement, generalContext, specificContext);
119
120
 
120
- const statement = step.getStatement(),
121
- statementUnifies = this.statement.unifyStatement(statement, generalContext, specificContext);
121
+ if (statementUnifies) {
122
+ specificContext.commit(context);
122
123
 
123
- if (statementUnifies) {
124
- stepUnifies = true;
125
- }
124
+ stepUnifies = true;
125
+ }
126
+ }, specificContext);
126
127
 
127
128
  if (stepUnifies) {
128
129
  context.debug(`...unified the '${stepString}' step with the '${conclusionString}' conclusion.`);
@@ -160,8 +161,8 @@ export default define(class Conclusion extends Element {
160
161
  static fromJSON(json, context) {
161
162
  let conclusion;
162
163
 
163
- unserialise((json, context) => {
164
- instantiate((context) => {
164
+ instantiate((context) => {
165
+ unserialise((json, context) => {
165
166
  const { string } = json,
166
167
  conclusionNode = instantiateConclusion(string, context),
167
168
  node = conclusionNode, ///
@@ -169,8 +170,8 @@ export default define(class Conclusion extends Element {
169
170
  statement = statementFromConclusionNode(conclusionNode, context);
170
171
 
171
172
  conclusion = new Conclusion(context, string, node, breakPoint, statement);
172
- }, context);
173
- }, json, context);
173
+ }, json, context);
174
+ }, context);
174
175
 
175
176
  return conclusion;
176
177
  }
@@ -106,19 +106,14 @@ export default define(class Constructor extends Element {
106
106
 
107
107
  const termString = term.getString(),
108
108
  includeType = false,
109
- constructorString = this.getString(includeType);
109
+ constructorString = this.getString(includeType); ///
110
110
 
111
111
  context.trace(`Unifying the '${termString}' term with the '${constructorString}' constructor...`);
112
112
 
113
- const specifiContext = context; ///
114
-
115
- context = this.getContext();
116
-
117
- const generalContext = context; ///
118
-
119
- context = specifiContext; ///
120
-
121
113
  const constructor = this, ///
114
+ constructorContext = constructor.getContext(),
115
+ generalContext = constructorContext, ///
116
+ specifiContext = context, ///
122
117
  termUnifiesWithConstructor = unifyTermWithConstructor(term, constructor, generalContext, specifiContext);
123
118
 
124
119
  if (termUnifiesWithConstructor) {
@@ -175,8 +170,8 @@ export default define(class Constructor extends Element {
175
170
  static fromJSON(json, context) {
176
171
  let constructor;
177
172
 
178
- unserialise((json, context) => {
179
- instantiate((context) => {
173
+ instantiate((context) => {
174
+ unserialise((json, context) => {
180
175
  const { string } = json,
181
176
  constructorNode = instantiateConstructor(string, context),
182
177
  node = constructorNode, ///
@@ -185,8 +180,8 @@ export default define(class Constructor extends Element {
185
180
  type = typeFromJSON(json, context);
186
181
 
187
182
  constructor = new Constructor(context, string, node, breakPoint, term, type);
188
- }, context);
189
- }, json, context);
183
+ }, json, context);
184
+ }, context);
190
185
 
191
186
  return constructor;
192
187
  }
@@ -5,7 +5,7 @@ import { Element } from "occam-languages";
5
5
  import { define } from "../elements";
6
6
  import { instantiateDeduction } from "../process/instantiate";
7
7
  import { breakPointFromJSON, breakPointToBreakPointJSON } from "../utilities/breakPoint";
8
- import { declare, attempt, sequester, serialise, unserialise, instantiate } from "../utilities/context";
8
+ import { elide, declare, attempt, serialise, unserialise, instantiate, reconcile } from "../utilities/context";
9
9
 
10
10
  export default define(class Deduction extends Element {
11
11
  constructor(context, string, node, breakPoint, statement) {
@@ -35,11 +35,15 @@ export default define(class Deduction extends Element {
35
35
  context.trace(`Verifying the '${deductionString}' deduction...`);
36
36
 
37
37
  if (this.statement !== null) {
38
- const validates = this.validate(context);
39
-
40
- if (validates) {
41
- verifies = true;
42
- }
38
+ declare((context) => {
39
+ elide((context) => {
40
+ const validates = this.validate(context);
41
+
42
+ if (validates) {
43
+ verifies = true;
44
+ }
45
+ }, context);
46
+ }, context);
43
47
  } else {
44
48
  context.debug(`Unable to verify the '${deductionString}' deduction because it is nonsense.`);
45
49
  }
@@ -58,18 +62,16 @@ export default define(class Deduction extends Element {
58
62
 
59
63
  context.trace(`Validating the '${deductionString}' deduction...`);
60
64
 
61
- declare((context) => {
62
- attempt((context) => {
63
- const statementValidates = this.validateStatement(context);
65
+ attempt((context) => {
66
+ const statementValidates = this.validateStatement(context);
64
67
 
65
- if (statementValidates) {
66
- validates = true;
67
- }
68
+ if (statementValidates) {
69
+ validates = true;
70
+ }
68
71
 
69
- if (validates) {
70
- this.commit(context);
71
- }
72
- }, context);
72
+ if (validates) {
73
+ this.commit(context);
74
+ }
73
75
  }, context);
74
76
 
75
77
  if (validates) {
@@ -86,13 +88,11 @@ export default define(class Deduction extends Element {
86
88
 
87
89
  context.trace(`Validating the '${deductionnString}' deductionn's statement...`);
88
90
 
89
- sequester((context) => {
90
- const statement = this.statement.validate(context);
91
+ const statement = this.statement.validate(context);
91
92
 
92
- if (statement !== null) {
93
- statementValidates = true;
94
- }
95
- }, context);
93
+ if (statement !== null) {
94
+ statementValidates = true;
95
+ }
96
96
 
97
97
  if (statementValidates) {
98
98
  context.trace(`...validated the '${deductionnString}' deductionn's statement.`);
@@ -109,20 +109,21 @@ export default define(class Deduction extends Element {
109
109
 
110
110
  context.trace(`Unifying the '${stepString}' step with the '${deductionString}' deduction...`);
111
111
 
112
- const specificContext = context; ///
113
-
114
- context = this.getContext();
115
-
116
- const generalContext = context; ///
112
+ const stepContext = step.getContext(),
113
+ deductionContext = this.getContext(),
114
+ generalContext = deductionContext, ///
115
+ specificContext = stepContext; ///
117
116
 
118
- context = specificContext; ///
117
+ reconcile((specificContext) => {
118
+ const statement = step.getStatement(),
119
+ statementUnifies = this.statement.unifyStatement(statement, generalContext, specificContext);
119
120
 
120
- const statement = step.getStatement(),
121
- statementUnifies = this.statement.unifyStatement(statement, generalContext, specificContext);
121
+ if (statementUnifies) {
122
+ specificContext.commit(context);
122
123
 
123
- if (statementUnifies) {
124
- stepUnifies = true;
125
- }
124
+ stepUnifies = true;
125
+ }
126
+ }, specificContext);
126
127
 
127
128
  if (stepUnifies) {
128
129
  context.debug(`...unified the '${stepString}' step with the '${deductionString}' deduction.`);
@@ -160,8 +161,8 @@ export default define(class Deduction extends Element {
160
161
  static fromJSON(json, context) {
161
162
  let deduction;
162
163
 
163
- unserialise((json, context) => {
164
- instantiate((context) => {
164
+ instantiate((context) => {
165
+ unserialise((json, context) => {
165
166
  const { string } = json,
166
167
  deductionNode = instantiateDeduction(string, context),
167
168
  node = deductionNode, ///
@@ -169,8 +170,8 @@ export default define(class Deduction extends Element {
169
170
  statement = statementFromDeductionNode(deductionNode, context);
170
171
 
171
172
  deduction = new Deduction(context, string, node, breakPoint, statement);
172
- }, context);
173
- }, json, context);
173
+ }, json, context);
174
+ }, context);
174
175
 
175
176
  return deduction;
176
177
  }
@@ -4,7 +4,7 @@ import { Element } from "occam-languages";
4
4
  import { arrayUtilities } from "necessary";
5
5
 
6
6
  import { define } from "../elements";
7
- import { instantiate } from "../utilities/context";
7
+ import { ablate, instantiate } from "../utilities/context";
8
8
  import { instantiateEquivalence } from "../process/instantiate";
9
9
  import { stripBracketsFromTermNode } from "../utilities/brackets";
10
10
  import { equivalenceStringFromTerms } from "../utilities/string";
@@ -217,13 +217,15 @@ export default define(class Equivalence extends Element {
217
217
 
218
218
  type = combinedType; ///
219
219
 
220
- instantiate((context) => {
221
- const terms = combinedTerms, ///
222
- equivalenceString = equivalenceStringFromTerms(terms),
223
- string = equivalenceString, ///
224
- equivalenceNode = instantiateEquivalence(string, context);
220
+ ablate((context) => {
221
+ instantiate((context) => {
222
+ const terms = combinedTerms, ///
223
+ equivalenceString = equivalenceStringFromTerms(terms),
224
+ string = equivalenceString, ///
225
+ equivalenceNode = instantiateEquivalence(string, context);
225
226
 
226
- equivalence = equivalenceFromEquivalenceNode(equivalenceNode, context);
227
+ equivalence = equivalenceFromEquivalenceNode(equivalenceNode, context);
228
+ }, context);
227
229
  }, context);
228
230
 
229
231
  equivalence.setType(type);
@@ -238,13 +240,15 @@ export default define(class Equivalence extends Element {
238
240
 
239
241
  const type = equality.getType();
240
242
 
241
- instantiate((context) => {
242
- const terms = equality.getTerms(),
243
- equivalenceString = equivalenceStringFromTerms(terms),
244
- string = equivalenceString, ///
245
- equivalenceNode = instantiateEquivalence(string, context);
243
+ ablate((context) => {
244
+ instantiate((context) => {
245
+ const terms = equality.getTerms(),
246
+ equivalenceString = equivalenceStringFromTerms(terms),
247
+ string = equivalenceString, ///
248
+ equivalenceNode = instantiateEquivalence(string, context);
246
249
 
247
- equivalence = equivalenceFromEquivalenceNode(equivalenceNode, context);
250
+ equivalence = equivalenceFromEquivalenceNode(equivalenceNode, context);
251
+ }, context);
248
252
  }, context);
249
253
 
250
254
  equivalence.setType(type);
@@ -36,11 +36,13 @@ export default define(class Hypothesis extends Element {
36
36
  context.trace(`Verifying the '${hypothesisString}' hypothesis...`);
37
37
 
38
38
  if (this.statement !== null) {
39
- const validates = this.validate(context);
39
+ declare((context) => {
40
+ const validates = this.validate(context);
40
41
 
41
- if (validates) {
42
- verifies = true;
43
- }
42
+ if (validates) {
43
+ verifies = true;
44
+ }
45
+ }, context)
44
46
  } else {
45
47
  context.debug(`Unable to verify the '${hypothesisString}' hypothesis because it is nonsense.`);
46
48
  }
@@ -59,19 +61,17 @@ export default define(class Hypothesis extends Element {
59
61
 
60
62
  context.trace(`Validating the '${hypothesisString}' hypothesis...`);
61
63
 
62
- declare((context) => {
63
- attempt((context) => {
64
- const statementValidates = this.validateStatement(context);
64
+ attempt((context) => {
65
+ const statementValidates = this.validateStatement(context);
65
66
 
66
- if (statementValidates) {
67
- validates = true;
68
- }
67
+ if (statementValidates) {
68
+ validates = true;
69
+ }
69
70
 
70
- if (validates) {
71
- this.commit(context);
72
- }
73
- }, context);
74
- }, context)
71
+ if (validates) {
72
+ this.commit(context);
73
+ }
74
+ }, context);
75
75
 
76
76
  if (validates) {
77
77
  context.debug(`...validated the '${hypothesisString}' hypothesis.`);
@@ -80,6 +80,26 @@ export default define(class Hypothesis extends Element {
80
80
  return validates;
81
81
  }
82
82
 
83
+ discharge(context) {
84
+ let discharges = false;
85
+
86
+ const hypothesisString = this.getString(); ///
87
+
88
+ context.trace(`Discharging the '${hypothesisString}' hypothesis...`);
89
+
90
+ const statementDischarges = this.dischargeStatement(context);
91
+
92
+ if (statementDischarges) {
93
+ discharges = true;
94
+ }
95
+
96
+ if (discharges) {
97
+ context.debug(`...discharged the '${hypothesisString}' hypothesis.`);
98
+ }
99
+
100
+ return discharges;
101
+ }
102
+
83
103
  validateStatement(context) {
84
104
  let statementValidates = false;
85
105
 
@@ -100,6 +120,26 @@ export default define(class Hypothesis extends Element {
100
120
  return statementValidates;
101
121
  }
102
122
 
123
+ dischargeStatement(context) {
124
+ let statementDischarges = false;
125
+
126
+ const hypothesisString = this.getString();
127
+
128
+ context.trace(`Discharging the '${hypothesisString}' hypothesis's statement... `);
129
+
130
+ const discharges = this.statement.discharge(context); ///
131
+
132
+ if (discharges) {
133
+ statementDischarges = true;
134
+ }
135
+
136
+ if (statementDischarges) {
137
+ context.debug(`...discharged the '${hypothesisString}' hypothesis' statement. `);
138
+ }
139
+
140
+ return statementDischarges;
141
+ }
142
+
103
143
  static name = "Hypothesis";
104
144
 
105
145
  toJSON() {
@@ -129,8 +169,8 @@ export default define(class Hypothesis extends Element {
129
169
  static fromJSON(json, context) {
130
170
  let hypothesis;
131
171
 
132
- unserialise((json, context) => {
133
- instantiate((context) => {
172
+ instantiate((context) => {
173
+ unserialise((json, context) => {
134
174
  const { string } = json,
135
175
  hypothesisNode = instantiateHypothesis(string, context),
136
176
  node = hypothesisNode, ///
@@ -138,8 +178,8 @@ export default define(class Hypothesis extends Element {
138
178
  statement = statementFromHypothesisNode(hypothesisNode, context);
139
179
 
140
180
  hypothesis = new Hypothesis(context, string, node, breakPoint, statement);
141
- }, context);
142
- }, json, context);
181
+ }, json, context);
182
+ }, context);
143
183
 
144
184
  return hypothesis;
145
185
  }
@@ -4,7 +4,7 @@ import { Element } from "occam-languages";
4
4
 
5
5
  import { define } from "../elements";
6
6
  import { instantiateJudgement } from "../process/instantiate";
7
- import { reconcile, instantiate } from "../utilities/context";
7
+ import { reconcile, instantiate,} from "../utilities/context";
8
8
  import { judgementFromStatementNode } from "../utilities/element";
9
9
  import { judgementAssignmentFromJudgement } from "../process/assign";
10
10
  import { breakPointFromJSON, breakPointToBreakPointJSON } from "../utilities/breakPoint";