occam-verify-cli 1.0.848 → 1.0.849

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.
@@ -101,7 +101,7 @@ export default define(class StatementSubstitution extends Substitution {
101
101
  return comparesToSubstitution;
102
102
  }
103
103
 
104
- validate(generalContext, specificContext) {
104
+ validate(substitution, generalContext, specificContext) {
105
105
  let statementSubstitution = null;
106
106
 
107
107
  const context = specificContext, ///
@@ -120,28 +120,29 @@ export default define(class StatementSubstitution extends Substitution {
120
120
  } else {
121
121
  const context = this.getContext();
122
122
 
123
- join((context) => {
124
- attempt((context) => {
125
- const specificContext = context, ///
126
- targetStatementValidates = this.validateTargetStatement(generalContext, specificContext);
123
+ join((generalContext) => {
124
+ join((specificContext) => {
125
+ attempt((generalContext, specificContext) => {
126
+ const targetStatementValidates = this.validateTargetStatement(generalContext, specificContext);
127
127
 
128
- if (targetStatementValidates) {
129
- const replacementStatementValidates = this.validateReplacementStatement(generalContext, specificContext);
128
+ if (targetStatementValidates) {
129
+ const replacementStatementValidates = this.validateReplacementStatement(generalContext, specificContext);
130
130
 
131
- if (replacementStatementValidates) {
132
- const substitutionValidates = this.validateSubstitution(generalContext, specificContext);
131
+ if (replacementStatementValidates) {
132
+ const substitutionValidates = this.validateSubstitution(substitution, generalContext, specificContext);
133
133
 
134
- if (substitutionValidates) {
135
- validates = true;
134
+ if (substitutionValidates) {
135
+ validates = true;
136
+ }
136
137
  }
137
138
  }
138
- }
139
139
 
140
- if (validates) {
141
- context.commit(this);
142
- }
143
- }, context);
144
- }, specificContext, context);
140
+ if (validates) {
141
+ this.setContexts(generalContext, specificContext);
142
+ }
143
+ }, generalContext, specificContext);
144
+ }, specificContext, context);
145
+ }, generalContext, context);
145
146
  }
146
147
 
147
148
  if (validates) {
@@ -151,35 +152,25 @@ export default define(class StatementSubstitution extends Substitution {
151
152
 
152
153
  context.addSubstitution(substitution);
153
154
 
154
- this.setGeneralContext(generalContext);
155
-
156
155
  context.debug(`...validated the '${statementSubstitutionString}' statement substitution.`);
157
156
  }
158
157
 
159
158
  return statementSubstitution;
160
159
  }
161
160
 
162
- validateSubstitution(generalContext, specificContext) {
161
+ validateSubstitution(substitution, generalContext, specificContext) {
163
162
  let substitutionValidates = true;
164
163
 
165
- if (this.substitution !== null) {
164
+ if (substitution !== null) {
166
165
  const context = generalContext, ///
167
166
  substitutionString = this.substitution.getString(),
168
167
  statementSubstitutionString = this.getString();
169
168
 
170
169
  context.trace(`Validating the '${statementSubstitutionString}' statement substitution's '${substitutionString}' substitution...`);
171
170
 
172
- descend((context) => {
173
- const generalContext = context, ///
174
- specificContext = context, ///
175
- substitution = this.substitution.validate(generalContext, specificContext);
176
-
177
- if (substitution !== null) {
178
- this.substitution = substitution;
171
+ this.substitution = substitution;
179
172
 
180
- substitutionValidates = true;
181
- }
182
- }, context);
173
+ substitutionValidates = true;
183
174
 
184
175
  if (substitutionValidates) {
185
176
  context.debug(`...validatewd the '${statementSubstitutionString}' statement substitution's '${substitutionString}' substitution.`);
@@ -251,12 +242,10 @@ export default define(class StatementSubstitution extends Substitution {
251
242
 
252
243
  context.trace(`Unifying the '${simpleSubstitutionString}' simple substitution with the '${substitutionString}' substitution...`);
253
244
 
254
- const generalSubstitution = this.substitution, ///
255
- specificSubstitution = simpleSubstitution, ///
256
- generalSubstitutionGeneralContext = generalSubstitution.getGeneralContext(),
257
- generalSubstitutionSpecificContext = generalSubstitution.getSpecificContext(),
258
- specificSubstitutionGeneralContext = specificSubstitution.getGeneralContext(),
259
- specificSubstitutionSpecificContext = specificSubstitution.getSpecificContext();
245
+ const specificSubstitution = simpleSubstitution, ///
246
+ generalSubstitution = this.substitution, ///
247
+ specificContexts = specificSubstitution.getContexts(), ///
248
+ generalContexts = generalSubstitution.getContexts();
260
249
 
261
250
  join((specificContext) => {
262
251
  join((generalContext) => {
@@ -267,8 +256,8 @@ export default define(class StatementSubstitution extends Substitution {
267
256
  specificContext.commit(context);
268
257
  }
269
258
  }, specificContext)
270
- }, generalSubstitutionSpecificContext, generalSubstitutionGeneralContext);
271
- }, specificSubstitutionSpecificContext, specificSubstitutionGeneralContext, context);
259
+ }, ...generalContexts);
260
+ }, ...specificContexts, context);
272
261
 
273
262
  if (simpleSubstitutionUnifies) {
274
263
  context.trace(`...unified the '${simpleSubstitutionString}' simple substitution with the '${substitutionString}' substitution.`);
@@ -311,7 +300,7 @@ export default define(class StatementSubstitution extends Substitution {
311
300
  }, specificContext);
312
301
 
313
302
  if (substitution !== null) {
314
- substitution = substitution.validate(generalContext, specificContext);
303
+ substitution = substitution.validate(generalContext, specificContext); ///
315
304
 
316
305
  simpleSubstitutionUnifies = true;
317
306
  }
@@ -378,21 +367,21 @@ export default define(class StatementSubstitution extends Substitution {
378
367
  static name = "StatementSubstitution";
379
368
 
380
369
  toJSON() {
381
- const context = this.getContext();
370
+ const contexts = this.getContexts();
382
371
 
383
- return serialise((context) => {
372
+ return serialise((...contexts) => {
384
373
  const { name } = this.constructor,
385
374
  string = this.getString(),
386
375
  lineIndex = this.getLineIndex(),
387
376
  json = {
388
377
  name,
389
- context,
378
+ contexts,
390
379
  string,
391
380
  lineIndex
392
381
  };
393
382
 
394
383
  return json;
395
- }, context);
384
+ }, ...contexts);
396
385
  }
397
386
 
398
387
  static fromJSON(json, context) {
@@ -401,12 +390,13 @@ export default define(class StatementSubstitution extends Substitution {
401
390
  const { name } = json;
402
391
 
403
392
  if (this.name === name) {
404
- unserialise((json, context) => {
393
+ unserialise((json, generalContext, specificContext) => {
394
+ const context = specificContext; ///
395
+
405
396
  instantiate((context) => {
406
397
  const { string, lineIndex } = json,
407
398
  statementSubstitutionNode = instantiateStatementSubstitution(string, context),
408
399
  node = statementSubstitutionNode, ///
409
- generalContext = generalContextFromStatementSubstitutionNode(statementSubstitutionNode, context),
410
400
  resolved = resolvedFromStatementSubstitutionNode(statementSubstitutionNode, context),
411
401
  substitution = substitutionFromStatementSubstitutionNode(statementSubstitutionNode, context),
412
402
  targetStatement = targetStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
@@ -483,9 +473,3 @@ function substitutionFromStatementSubstitutionNode(statementSubstitutionNode, co
483
473
 
484
474
  return substitution;
485
475
  }
486
-
487
- function generalContextFromStatementSubstitutionNode(statementSubstitutionNode, context) {
488
- const generalContext = context; ///
489
-
490
- return generalContext;
491
- }
@@ -92,24 +92,25 @@ export default define(class TermSubstitution extends Substitution {
92
92
  } else {
93
93
  const context = this.getContext();
94
94
 
95
- join((context) => {
96
- attempt((context) => {
97
- const specificContext = context, ///
98
- targetTermValidates = this.validateTargetTerm(generalContext, specificContext);
95
+ join((generalContext) => {
96
+ join((specificContext) => {
97
+ attempt((generalContext, specificContext) => {
98
+ const targetTermValidates = this.validateTargetTerm(generalContext, specificContext);
99
99
 
100
- if (targetTermValidates) {
101
- const replacementTermValidates = this.validateReplacementTerm(generalContext, specificContext);
100
+ if (targetTermValidates) {
101
+ const replacementTermValidates = this.validateReplacementTerm(generalContext, specificContext);
102
102
 
103
- if (replacementTermValidates) {
104
- validates = true;
103
+ if (replacementTermValidates) {
104
+ validates = true;
105
+ }
105
106
  }
106
- }
107
107
 
108
- if (validates) {
109
- context.commit(this);
110
- }
111
- }, context);
112
- }, specificContext, context);
108
+ if (validates) {
109
+ this.setContexts(generalContext, specificContext);
110
+ }
111
+ }, generalContext, specificContext);
112
+ }, specificContext, context);
113
+ }, generalContext, context);
113
114
  }
114
115
 
115
116
  if (validates) {
@@ -119,8 +120,6 @@ export default define(class TermSubstitution extends Substitution {
119
120
 
120
121
  context.addSubstitution(substitution);
121
122
 
122
- this.setGeneralContext(generalContext);
123
-
124
123
  context.debug(`...validated the '${termSubstitutionString}' term substitution.`);
125
124
  }
126
125
 
@@ -196,21 +195,21 @@ export default define(class TermSubstitution extends Substitution {
196
195
  static name = "TermSubstitution";
197
196
 
198
197
  toJSON() {
199
- const context = this.getContext();
198
+ const contexts = this.getContexts();
200
199
 
201
- return serialise((context) => {
200
+ return serialise((...contexts) => {
202
201
  const { name } = this.constructor,
203
202
  string = this.getString(),
204
203
  lineIndex = this.getLineIndex(),
205
204
  json = {
206
205
  name,
207
- context,
206
+ contexts,
208
207
  string,
209
208
  lineIndex
210
209
  };
211
210
 
212
211
  return json;
213
- }, context);
212
+ }, ...contexts);
214
213
  }
215
214
 
216
215
  static fromJSON(json, context) {
@@ -219,12 +218,13 @@ export default define(class TermSubstitution extends Substitution {
219
218
  const { name } = json;
220
219
 
221
220
  if (this.name === name) {
222
- unserialise((json, context) => {
221
+ unserialise((json, generalContext, specificContext) => {
222
+ const context = specificContext; ///
223
+
223
224
  instantiate((context) => {
224
225
  const { string, lineIndex } = json,
225
226
  termSubstitutionNode = instantiateTermSubstitution(string, context),
226
227
  node = termSubstitutionNode, ///
227
- generalContext = generalContextFromTermSubstitutionNode(termSubstitutionNode, context),
228
228
  targetTerm = targetTermFromTermSubstitutionNode(termSubstitutionNode, context),
229
229
  replacementTerm = replacementTermFromTermSubstitutionNode(termSubstitutionNode, context);
230
230
 
@@ -282,9 +282,3 @@ function replacementTermFromTermSubstitutionNode(termSubstitutionNode, context)
282
282
 
283
283
  return replacementTerm;
284
284
  }
285
-
286
- function generalContextFromTermSubstitutionNode(termSubstitutionNode, context) {
287
- const generalContext = context; ///
288
-
289
- return generalContext;
290
- }
@@ -39,10 +39,34 @@ export default class Substitution extends Element {
39
39
  return specificContext;
40
40
  }
41
41
 
42
+ getContexts() {
43
+ const generalContext = this.getGeneralContext(),
44
+ specificContext = this.getSpecificContext(),
45
+ contexts = [
46
+ generalContext,
47
+ specificContext
48
+ ];
49
+
50
+ return contexts;
51
+ }
52
+
42
53
  setGeneralContext(generalContext) {
43
54
  this.generalContext = generalContext;
44
55
  }
45
56
 
57
+ setSpecificContext(specifiContext) {
58
+ const context = specifiContext; ///
59
+
60
+ this.setContext(context);
61
+ }
62
+
63
+ setContexts(...contexts) {
64
+ const [ generalContext, specificContext ] = contexts;
65
+
66
+ this.setGeneralContext(generalContext);
67
+ this.setSpecificContext(specificContext);
68
+ }
69
+
46
70
  isEqualTo(substitution) {
47
71
  const substitutionNode = substitution.getNode(),
48
72
  substitutionNodeMatches = this.matchSubstitutionNode(substitutionNode),
@@ -12,7 +12,7 @@ import EphemeralContext from "../context/ephemeral";
12
12
  import BranchingContext from "../context/branching";
13
13
  import NominalFileContext from "../context/file/nominal";
14
14
 
15
- import { ephemeralContextFromJSON, ephemeralContextToEphemeralContextJSON } from "../utilities/json";
15
+ import { ephemeralContextsFromJSON, ephemeralContextToEphemeralContextJSON } from "../utilities/json";
16
16
 
17
17
  export function join(innerFunction, ...contexts) {
18
18
  const synopticContext = SynopticContext.fromContexts(...contexts),
@@ -71,20 +71,24 @@ export function declare(innerFunction, context) {
71
71
  return innerFunction(context);
72
72
  }
73
73
 
74
- export function attempt(innerFunction, context) {
75
- const ephemeralContext = EphemeralContext.fromNothing(context);
74
+ export function descend(innerFunction, context) {
75
+ const nestedContext = NestedContext.fromNothing(context);
76
76
 
77
- context = ephemeralContext; ///
77
+ context = nestedContext; ///
78
78
 
79
79
  return innerFunction(context);
80
80
  }
81
81
 
82
- export function descend(innerFunction, context) {
83
- const nestedContext = NestedContext.fromNothing(context);
82
+ export function attempt(innerFunction, ...contexts) {
83
+ contexts = contexts.map((context) => { ///
84
+ const ephemeralContext = EphemeralContext.fromNothing(context);
84
85
 
85
- context = nestedContext; ///
86
+ context = ephemeralContext; ///
86
87
 
87
- return innerFunction(context);
88
+ return context;
89
+ })
90
+
91
+ return innerFunction(...contexts);
88
92
  }
89
93
 
90
94
  export function enclose(innerFunction, metaLevelAssumptions, context) {
@@ -115,22 +119,25 @@ export function reconcile(innerFunction, context) {
115
119
  return innerFunction(context);
116
120
  }
117
121
 
118
- export function serialise(innerFunction, context) {
119
- const ephemeralContext = context, ///
120
- ephemeralContextJSON = ephemeralContextToEphemeralContextJSON(ephemeralContext),
121
- contextJSON = ephemeralContextJSON; ///
122
+ export function serialise(innerFunction, ...contexts) {
123
+ contexts = contexts.map((context) => { ///
124
+ const ephemeralContext = context, ///
125
+ ephemeralContextJSON = ephemeralContextToEphemeralContextJSON(ephemeralContext),
126
+ contextJSON = ephemeralContextJSON; ///
122
127
 
123
- context = contextJSON; ///
128
+ context = contextJSON; ///
124
129
 
125
- return innerFunction(context);
130
+ return context;
131
+ });
132
+
133
+ return innerFunction(...contexts);
126
134
  }
127
135
 
128
136
  export function unserialise(innerFunction, json, context) {
129
- const ephemeralContext = ephemeralContextFromJSON(json, context);
130
-
131
- context = ephemeralContext; ///
137
+ const ephemeralContexts = ephemeralContextsFromJSON(json, context),
138
+ contexts = ephemeralContexts; ///
132
139
 
133
- return innerFunction(json, context);
140
+ return innerFunction(json, ...contexts);
134
141
  }
135
142
 
136
143
  export function instantiate(innerFunction, context) {
@@ -659,18 +659,27 @@ export function metavariablesFromJSON(json, context) {
659
659
  return metavariables;
660
660
  }
661
661
 
662
- export function ephemeralContextFromJSON(json, context) {
663
- const releaseContext = context;
662
+ export function ephemeralContextsFromJSON(json, context) {
663
+ const releaseContext = context; ///
664
664
 
665
- ({context} = json);
665
+ const { contexts = [] } = json;
666
666
 
667
- json = context; ///
667
+ ({ context = null } = json);
668
668
 
669
- context = releaseContext; ///
669
+ if (context !== null) {
670
+ contexts.push(context);
671
+ }
672
+
673
+ const contextsJSON = contexts, ///
674
+ ephemeralContexts = contextsJSON.map((contextJSON) => {
675
+ const json = contextJSON, ///
676
+ context = releaseContext, ///
677
+ emphemeralContext = EphemeralContext.fromJSON(json, context);
670
678
 
671
- const emphemeralContext = EphemeralContext.fromJSON(json, context);
679
+ return emphemeralContext; ///
680
+ });
672
681
 
673
- return emphemeralContext;
682
+ return ephemeralContexts;
674
683
  }
675
684
 
676
685
  export function declaredVariablesFromJSON(json, context) {