occam-verify-cli 1.0.800 → 1.0.806

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 (73) hide show
  1. package/lib/context/branching.js +2 -2
  2. package/lib/context/ephemeral.js +186 -69
  3. package/lib/context/file/nominal.js +87 -52
  4. package/lib/context/liminal.js +2 -2
  5. package/lib/context/proof.js +55 -55
  6. package/lib/context/synthetic.js +151 -74
  7. package/lib/context.js +57 -17
  8. package/lib/element/assertion/defined.js +3 -3
  9. package/lib/element/assumption/metaLevel.js +6 -4
  10. package/lib/element/combinator.js +4 -2
  11. package/lib/element/conclusion.js +4 -2
  12. package/lib/element/constructor.js +4 -2
  13. package/lib/element/declaration/metavariable.js +10 -9
  14. package/lib/element/declaration/variable.js +7 -7
  15. package/lib/element/deduction.js +4 -2
  16. package/lib/element/label.js +9 -5
  17. package/lib/element/metavariable.js +34 -34
  18. package/lib/element/proofAssertion/premise.js +4 -3
  19. package/lib/element/proofAssertion/step.js +4 -2
  20. package/lib/element/reference.js +6 -4
  21. package/lib/element/statement.js +9 -1
  22. package/lib/element/substitution/frame.js +43 -29
  23. package/lib/element/substitution/reference.js +38 -28
  24. package/lib/element/substitution/statement.js +46 -38
  25. package/lib/element/substitution/term.js +49 -35
  26. package/lib/element/variable.js +6 -7
  27. package/lib/preamble.js +1 -2
  28. package/lib/process/assign.js +11 -10
  29. package/lib/process/equate.js +3 -2
  30. package/lib/process/unify.js +7 -7
  31. package/lib/utilities/context.js +13 -5
  32. package/lib/utilities/element.js +1 -1
  33. package/lib/utilities/equivalences.js +131 -0
  34. package/lib/utilities/json.js +59 -1
  35. package/lib/utilities/validation.js +4 -3
  36. package/package.json +2 -2
  37. package/src/context/branching.js +2 -2
  38. package/src/context/ephemeral.js +421 -237
  39. package/src/context/file/nominal.js +127 -77
  40. package/src/context/liminal.js +2 -2
  41. package/src/context/proof.js +81 -82
  42. package/src/context/synthetic.js +198 -88
  43. package/src/context.js +81 -20
  44. package/src/element/assertion/defined.js +4 -4
  45. package/src/element/assumption/metaLevel.js +8 -6
  46. package/src/element/combinator.js +4 -2
  47. package/src/element/conclusion.js +4 -2
  48. package/src/element/constructor.js +4 -2
  49. package/src/element/declaration/metavariable.js +10 -8
  50. package/src/element/declaration/variable.js +8 -7
  51. package/src/element/deduction.js +4 -2
  52. package/src/element/label.js +11 -7
  53. package/src/element/metavariable.js +11 -11
  54. package/src/element/proofAssertion/premise.js +4 -4
  55. package/src/element/proofAssertion/step.js +4 -2
  56. package/src/element/reference.js +7 -5
  57. package/src/element/statement.js +14 -0
  58. package/src/element/substitution/frame.js +47 -32
  59. package/src/element/substitution/reference.js +44 -34
  60. package/src/element/substitution/statement.js +63 -54
  61. package/src/element/substitution/term.js +53 -38
  62. package/src/element/variable.js +6 -7
  63. package/src/preamble.js +0 -1
  64. package/src/process/assign.js +17 -14
  65. package/src/process/equate.js +3 -1
  66. package/src/process/unify.js +10 -13
  67. package/src/utilities/context.js +13 -6
  68. package/src/utilities/element.js +1 -0
  69. package/src/utilities/equivalences.js +158 -0
  70. package/src/utilities/json.js +66 -0
  71. package/src/utilities/validation.js +6 -5
  72. package/lib/element/equivalences.js +0 -173
  73. package/src/element/equivalences.js +0 -237
@@ -40,149 +40,257 @@ export default class EphemeralContext extends Context {
40
40
  }
41
41
 
42
42
  getTerms() {
43
- return this.terms;
43
+ let terms;
44
+
45
+ const context = this.getContext();
46
+
47
+ terms = context.getTerms();
48
+
49
+ terms = [ ///
50
+ ...this.terms,
51
+ ...terms
52
+ ];
53
+
54
+ return terms;
44
55
  }
45
56
 
46
57
  getFrames() {
47
- return this.frames;
58
+ let frames;
59
+
60
+ const context = this.getContext();
61
+
62
+ frames = context.getFrames();
63
+
64
+ frames = [ ///
65
+ ...this.frames,
66
+ ...frames
67
+ ];
68
+
69
+ return frames;
48
70
  }
49
71
 
50
72
  getEqualities() {
51
- return this.equalities;
73
+ let equalities;
74
+
75
+ const context = this.getContext();
76
+
77
+ equalities = context.getEqualities();
78
+
79
+ equalities = [ ///
80
+ ...this.equalities,
81
+ ...equalities
82
+ ];
83
+
84
+ return equalities;
52
85
  }
53
86
 
54
87
  getJudgements() {
55
- return this.judgements;
88
+ let judgements;
89
+
90
+ const context = this.getContext();
91
+
92
+ judgements = context.getJudgements();
93
+
94
+ judgements = [ ///
95
+ ...this.judgements,
96
+ ...judgements
97
+ ];
98
+
99
+ return judgements;
56
100
  }
57
101
 
58
102
  getStatements() {
59
- return this.statements;
103
+ let statements;
104
+
105
+ const context = this.getContext();
106
+
107
+ statements = context.getStatements();
108
+
109
+ statements = [ ///
110
+ ...this.statements,
111
+ ...statements
112
+ ];
113
+
114
+ return statements;
60
115
  }
61
116
 
62
117
  getAssertions() {
63
- return this.assertions;
118
+ let assertions;
119
+
120
+ const context = this.getContext();
121
+
122
+ assertions = context.getAssertions();
123
+
124
+ assertions = [ ///
125
+ ...this.assertions,
126
+ ...assertions
127
+ ];
128
+
129
+ return assertions;
64
130
  }
65
131
 
66
132
  getReferences() {
67
- return this.references;
133
+ let references;
134
+
135
+ const context = this.getContext();
136
+
137
+ references = context.getReferences();
138
+
139
+ references = [ ///
140
+ ...this.references,
141
+ ...references
142
+ ];
143
+
144
+ return references;
68
145
  }
69
146
 
70
147
  getAssumptions() {
71
- return this.assumptions;
148
+ let assumptions;
149
+
150
+ const context = this.getContext();
151
+
152
+ assumptions = context.getAssumptions();
153
+
154
+ assumptions = [ ///
155
+ ...this.assumptions,
156
+ ...assumptions
157
+ ];
158
+
159
+ return assumptions;
72
160
  }
73
161
 
74
162
  getMetavariables() {
75
- return this.metavariables;
163
+ let metavariables;
164
+
165
+ const context = this.getContext();
166
+
167
+ metavariables = context.getMetavariables();
168
+
169
+ metavariables = [ ///
170
+ ...this.metavariables,
171
+ ...metavariables
172
+ ];
173
+
174
+ return metavariables;
76
175
  }
77
176
 
78
177
  getSubstitutions() {
79
- return this.substitutions;
80
- }
81
-
82
- addTerms(terms) {
83
- terms.forEach((term) => {
84
- this.addTerm(term);
85
- });
178
+ let substitutions;
179
+
180
+ const context = this.getContext();
181
+
182
+ substitutions = context.getSubstitutions();
183
+
184
+ substitutions = [ ///
185
+ ...this.substitutions,
186
+ ...substitutions
187
+ ];
188
+
189
+ return substitutions;
86
190
  }
87
191
 
88
192
  addTerm(term) {
89
- const termA = term, ///
90
- context = this, ///
193
+ const context = this, ///
194
+ termA = term, ///
91
195
  termString = term.getString();
92
196
 
93
197
  context.trace(`Adding the '${termString}' term to the ephemeral context...`);
94
198
 
95
- const termB = this.terms.find((term) => {
96
- const termB = term, ///
97
- termAEqualToTermB = termA.isEqualTo(termB);
98
-
99
- if (termAEqualToTermB) {
100
- return true;
101
- }
102
- }) || null;
199
+ const terms = this.getTerms(),
200
+ termB = terms.find((term) => {
201
+ const termB = term, ///
202
+ termAEqualToTermB = termA.isEqualTo(termB);
203
+
204
+ if (termAEqualToTermB) {
205
+ return true;
206
+ }
207
+ }) || null;
103
208
 
104
209
  if (termB !== null) {
105
210
  context.trace(`The '${termString}' term has already been added to the ephemeral context.`);
106
211
  } else {
107
212
  this.terms.push(term);
108
-
109
- context.debug(`...added the '${termString}' term to the ephemeral context.`);
110
213
  }
214
+
215
+ context.debug(`...added the '${termString}' term to the ephemeral context.`);
111
216
  }
112
217
 
113
218
  addFrame(frame) {
114
- const frameA = frame, ///
115
- context = this, ///
219
+ const context = this, ///
220
+ frameA = frame, ///
116
221
  frameString = frame.getString();
117
222
 
118
223
  context.trace(`Adding the '${frameString}' frame to the ephemeral context...`);
119
224
 
120
- const frameB = this.frames.find((frame) => {
121
- const frameB = frame, ///
122
- frameAEqualToFrameB = frameA.isEqualTo(frameB);
123
-
124
- if (frameAEqualToFrameB) {
125
- return true;
126
- }
127
- }) || null;
225
+ const frames = this.getFrames(),
226
+ frameB = frames.find((frame) => {
227
+ const frameB = frame, ///
228
+ frameAEqualToFrameB = frameA.isEqualTo(frameB);
229
+
230
+ if (frameAEqualToFrameB) {
231
+ return true;
232
+ }
233
+ }) || null;
128
234
 
129
235
  if (frameB !== null) {
130
236
  context.trace(`The '${frameString}' frame has already been added to the ephemeral context.`);
131
237
  } else {
132
238
  this.frames.push(frame);
133
-
134
- context.debug(`...added the '${frameString}' frame to the ephemeral context.`);
135
239
  }
240
+
241
+ context.debug(`...added the '${frameString}' frame to the ephemeral context.`);
136
242
  }
137
243
 
138
244
  addEquality(equality) {
139
- const equalityA = equality, ///
140
- context = this, ///
245
+ const context = this, ///
246
+ equalityA = equality, ///
141
247
  equalityString = equality.getString();
142
248
 
143
249
  context.trace(`Adding the '${equalityString}' equality to the ephemeral context...`);
144
250
 
145
- const equalityB = this.equalities.find((equality) => {
146
- const equalityB = equality, ///
147
- equalityAEqualToEqualityB = equalityA.isEqualTo(equalityB);
148
-
149
- if (equalityAEqualToEqualityB) {
150
- return true;
151
- }
152
- }) || null;
251
+ const equalities = this.getEqualities(),
252
+ equalityB = equalities.find((equality) => {
253
+ const equalityB = equality, ///
254
+ equalityAEqualToEqualityB = equalityA.isEqualTo(equalityB);
255
+
256
+ if (equalityAEqualToEqualityB) {
257
+ return true;
258
+ }
259
+ }) || null;
153
260
 
154
261
  if (equalityB !== null) {
155
262
  context.trace(`The '${equalityString}' equality has already been added to the ephemeral context.`);
156
263
  } else {
157
264
  this.equalities.push(equality);
158
-
159
- context.debug(`...added the '${equalityString}' equality to the ephemeral context.`);
160
265
  }
266
+
267
+ context.debug(`...added the '${equalityString}' equality to the ephemeral context.`);
161
268
  }
162
269
 
163
270
  addJudgement(judgement) {
164
- const judgementA = judgement, ///
165
- context = this, ///
271
+ const context = this, ///
272
+ judgementA = judgement, ///
166
273
  judgementString = judgement.getString();
167
274
 
168
275
  context.trace(`Adding the '${judgementString}' judgement to the ephemeral context...`);
169
276
 
170
- const judgementB = this.judgements.find((judgement) => {
171
- const judgementB = judgement, ///
172
- judgementAEqualToEqualityB = judgementA.isEqualTo(judgementB);
173
-
174
- if (judgementAEqualToEqualityB) {
175
- return true;
176
- }
177
- }) || null;
277
+ const judgements = this.getJudgements(),
278
+ judgementB = judgements.find((judgement) => {
279
+ const judgementB = judgement, ///
280
+ judgementAEqualToEqualityB = judgementA.isEqualTo(judgementB);
281
+
282
+ if (judgementAEqualToEqualityB) {
283
+ return true;
284
+ }
285
+ }) || null;
178
286
 
179
287
  if (judgementB !== null) {
180
288
  context.trace(`The '${judgementString}' judgement has already been added to the ephemeral context.`);
181
289
  } else {
182
290
  this.judgements.push(judgement);
183
-
184
- context.debug(`...added the '${judgementString}' judgement to the ephemeral context.`);
185
291
  }
292
+
293
+ context.debug(`...added the '${judgementString}' judgement to the ephemeral context.`);
186
294
  }
187
295
 
188
296
  addStatement(statement) {
@@ -192,22 +300,23 @@ export default class EphemeralContext extends Context {
192
300
 
193
301
  context.trace(`Adding the '${statementString}' statement to the ephemeral context...`);
194
302
 
195
- const statementB = this.statements.find((statement) => {
196
- const statementB = statement, ///
197
- statementAEqualToStatementB = statementA.isEqualTo(statementB);
198
-
199
- if (statementAEqualToStatementB) {
200
- return true;
201
- }
202
- }) || null;
303
+ const statements = this.getStatements(),
304
+ statementB = statements.find((statement) => {
305
+ const statementB = statement, ///
306
+ statementAEqualToStatementB = statementA.isEqualTo(statementB);
307
+
308
+ if (statementAEqualToStatementB) {
309
+ return true;
310
+ }
311
+ }) || null;
203
312
 
204
313
  if (statementB !== null) {
205
314
  context.trace(`The '${statementString}' statement has already been added to the ephemeral context.`);
206
315
  } else {
207
316
  this.statements.push(statement);
208
-
209
- context.debug(`...added the '${statementString}' statement to the ephemeral context.`);
210
317
  }
318
+
319
+ context.debug(`...added the '${statementString}' statement to the ephemeral context.`);
211
320
  }
212
321
 
213
322
  addAssertion(assertion) {
@@ -217,22 +326,23 @@ export default class EphemeralContext extends Context {
217
326
 
218
327
  context.trace(`Adding the '${assertionString}' assertion to the ephemeral context...`);
219
328
 
220
- const assertionB = this.assertions.find((assertion) => {
221
- const assertionB = assertion, ///
222
- assertionAEqualToAssertionB = assertionA.isEqualTo(assertionB);
223
-
224
- if (assertionAEqualToAssertionB) {
225
- return true;
226
- }
227
- }) || null;
329
+ const assertions = this.getAssumptions(),
330
+ assertionB = assertions.find((assertion) => {
331
+ const assertionB = assertion, ///
332
+ assertionAEqualToAssertionB = assertionA.isEqualTo(assertionB);
333
+
334
+ if (assertionAEqualToAssertionB) {
335
+ return true;
336
+ }
337
+ }) || null;
228
338
 
229
339
  if (assertionB !== null) {
230
340
  context.trace(`The '${assertionString}' assertion has already been added to the ephemeral context.`);
231
341
  } else {
232
342
  this.assertions.push(assertion);
233
-
234
- context.debug(`...added the '${assertionString}' assertion to the ephemeral context.`);
235
343
  }
344
+
345
+ context.debug(`...added the '${assertionString}' assertion to the ephemeral context.`);
236
346
  }
237
347
 
238
348
  addReference(reference) {
@@ -242,22 +352,23 @@ export default class EphemeralContext extends Context {
242
352
 
243
353
  context.trace(`Adding the '${referenceString}' reference to the ephemeral context...`);
244
354
 
245
- const referenceB = this.references.find((reference) => {
246
- const referenceB = reference, ///
247
- referenceAEqualToReferenceB = referenceA.isEqualTo(referenceB);
248
-
249
- if (referenceAEqualToReferenceB) {
250
- return true;
251
- }
252
- }) || null;
355
+ const references = this.getReferences(),
356
+ referenceB = references.find((reference) => {
357
+ const referenceB = reference, ///
358
+ referenceAEqualToReferenceB = referenceA.isEqualTo(referenceB);
359
+
360
+ if (referenceAEqualToReferenceB) {
361
+ return true;
362
+ }
363
+ }) || null;
253
364
 
254
365
  if (referenceB !== null) {
255
366
  context.trace(`The '${referenceString}' reference has already been added to the ephemeral context.`);
256
367
  } else {
257
368
  this.references.push(reference);
258
-
259
- context.debug(`...added the '${referenceString}' reference to the ephemeral context.`);
260
369
  }
370
+
371
+ context.debug(`...added the '${referenceString}' reference to the ephemeral context.`);
261
372
  }
262
373
 
263
374
  addAssumption(assumption) {
@@ -267,22 +378,23 @@ export default class EphemeralContext extends Context {
267
378
 
268
379
  context.trace(`Adding the '${assumptionString}' assumption to the ephemeral context...`);
269
380
 
270
- const assumptionB = this.assumptions.find((assumption) => {
271
- const assumptionB = assumption, ///
272
- assumptionAEqualToAssumptionB = assumptionA.isEqualTo(assumptionB);
273
-
274
- if (assumptionAEqualToAssumptionB) {
275
- return true;
276
- }
277
- }) || null;
381
+ const assumptions = this.getAssumptions(),
382
+ assumptionB = assumptions.find((assumption) => {
383
+ const assumptionB = assumption, ///
384
+ assumptionAEqualToAssumptionB = assumptionA.isEqualTo(assumptionB);
385
+
386
+ if (assumptionAEqualToAssumptionB) {
387
+ return true;
388
+ }
389
+ }) || null;
278
390
 
279
391
  if (assumptionB !== null) {
280
392
  context.trace(`The '${assumptionString}' assumption has already been added to the ephemeral context.`);
281
393
  } else {
282
394
  this.assumptions.push(assumption);
283
-
284
- context.debug(`...added the '${assumptionString}' assumption to the ephemeral context.`);
285
395
  }
396
+
397
+ context.debug(`...added the '${assumptionString}' assumption to the ephemeral context.`);
286
398
  }
287
399
 
288
400
  addMetavariable(metavariable) {
@@ -292,22 +404,23 @@ export default class EphemeralContext extends Context {
292
404
 
293
405
  context.trace(`Adding the '${metavariableString}' metavariable to the ephemeral context...`);
294
406
 
295
- const metavariableB = this.metavariables.find((metavariable) => {
296
- const metavariableB = metavariable, ///
297
- metavariableAEqualToSubstitutionB = metavariableA.isEqualTo(metavariableB);
298
-
299
- if (metavariableAEqualToSubstitutionB) {
300
- return true;
301
- }
302
- }) || null;
407
+ const metavariables = this.getMetavariables(),
408
+ metavariableB = metavariables.find((metavariable) => {
409
+ const metavariableB = metavariable, ///
410
+ metavariableAEqualToSubstitutionB = metavariableA.isEqualTo(metavariableB);
411
+
412
+ if (metavariableAEqualToSubstitutionB) {
413
+ return true;
414
+ }
415
+ }) || null;
303
416
 
304
417
  if (metavariableB !== null) {
305
418
  context.trace(`The '${metavariableString}' metavariable has already been added to the ephemeral context.`);
306
419
  } else {
307
420
  this.metavariables.push(metavariable);
308
-
309
- context.debug(`...added the '${metavariableString}' metavariable to the ephemeral context.`);
310
421
  }
422
+
423
+ context.debug(`...added the '${metavariableString}' metavariable to the ephemeral context.`);
311
424
  }
312
425
 
313
426
  addSubstitution(substitution) {
@@ -317,166 +430,224 @@ export default class EphemeralContext extends Context {
317
430
 
318
431
  context.trace(`Adding the '${substitutionString}' substitution to the ephemeral context...`);
319
432
 
320
- const substitutionB = this.substitutions.find((substitution) => {
321
- const substitutionB = substitution, ///
322
- substitutionAEqualToSubstitutionB = substitutionA.isEqualTo(substitutionB);
323
-
324
- if (substitutionAEqualToSubstitutionB) {
325
- return true;
326
- }
327
- }) || null;
433
+ const substitutions = this.getSubstitutions(),
434
+ substitutionB = substitutions.find((substitution) => {
435
+ const substitutionB = substitution, ///
436
+ substitutionAEqualToSubstitutionB = substitutionA.isEqualTo(substitutionB);
437
+
438
+ if (substitutionAEqualToSubstitutionB) {
439
+ return true;
440
+ }
441
+ }) || null;
328
442
 
329
443
  if (substitutionB !== null) {
330
444
  context.trace(`The '${substitutionString}' substitution has already been added to the ephemeral context.`);
331
445
  } else {
332
446
  this.substitutions.push(substitution);
333
-
334
- context.debug(`...added the '${substitutionString}' substitution to the ephemeral context.`);
335
447
  }
448
+
449
+ context.debug(`...added the '${substitutionString}' substitution to the ephemeral context.`);
336
450
  }
337
451
 
338
- retrieveEphemeralContext() {
339
- const ephemeralContext = this; ///
452
+ addTerms(terms) {
453
+ terms.forEach((term) => {
454
+ this.addTerm(term);
455
+ });
456
+ }
340
457
 
341
- return ephemeralContext;
458
+ addFrames(frames) {
459
+ frames.forEach((frame) => {
460
+ this.addFrame(frame);
461
+ });
342
462
  }
343
463
 
344
- findTermByTermNode(termNode) {
345
- const term = this.terms.find((term) => {
346
- const termNodeMatches = term.matchTermNode(termNode);
464
+ addEqualities(equalities) {
465
+ equalities.forEach((equality) => {
466
+ this.addEquality(equality);
467
+ });
468
+ }
347
469
 
348
- if (termNodeMatches) {
349
- return true;
350
- }
351
- }) || null;
470
+ addJudgements(judgements) {
471
+ judgements.forEach((judgement) => {
472
+ this.addJudgement(judgement);
473
+ });
474
+ }
475
+
476
+ addAssertions(assertions) {
477
+ assertions.forEach((assertion) => {
478
+ this.addAssertion(assertion);
479
+ });
480
+ }
481
+
482
+ addStatements(statements) {
483
+ statements.forEach((statement) => {
484
+ this.addStatement(statement);
485
+ });
486
+ }
487
+
488
+ addReferences(references) {
489
+ references.forEach((reference) => {
490
+ this.addReference(reference);
491
+ });
492
+ }
493
+
494
+ addAssumptions(assumptions) {
495
+ assumptions.forEach((assumption) => {
496
+ this.addAssumption(assumption);
497
+ });
498
+ }
499
+
500
+ addMetavariables(metavariables) {
501
+ metavariables.forEach((metavariable) => {
502
+ this.addMetavariable(metavariable);
503
+ });
504
+ }
505
+
506
+ addSubstitutions(substitutions) {
507
+ substitutions.forEach((substitution) => {
508
+ this.addSubstitution(substitution);
509
+ });
510
+ }
511
+
512
+ findTermByTermNode(termNode) {
513
+ const terms = this.getTerms(),
514
+ term = terms.find((term) => {
515
+ const termNodeMatches = term.matchTermNode(termNode);
516
+
517
+ if (termNodeMatches) {
518
+ return true;
519
+ }
520
+ }) || null;
352
521
 
353
522
  return term;
354
523
  }
355
524
 
356
525
  findFrameByFrameNode(frameNode) {
357
- const frame = this.frames.find((frame) => {
358
- const frameNodeMatches = frame.matchFrameNode(frameNode);
526
+ const frames = this.getFrames(),
527
+ frame = frames.find((frame) => {
528
+ const frameNodeMatches = frame.matchFrameNode(frameNode);
359
529
 
360
- if (frameNodeMatches) {
361
- return true;
362
- }
363
- }) || null;
530
+ if (frameNodeMatches) {
531
+ return true;
532
+ }
533
+ }) || null;
364
534
 
365
535
  return frame;
366
536
  }
367
537
 
368
538
  findEqualityByEqualityNode(equalityNode) {
369
- const equality = this.equalities.find((equality) => {
370
- const equalityNodeMatches = equality.matchEqualityNode(equalityNode);
539
+ const equalities = this.getEqualities(),
540
+ equality = equalities.find((equality) => {
541
+ const equalityNodeMatches = equality.matchEqualityNode(equalityNode);
371
542
 
372
- if (equalityNodeMatches) {
373
- return true;
374
- }
375
- }) || null;
543
+ if (equalityNodeMatches) {
544
+ return true;
545
+ }
546
+ }) || null;
376
547
 
377
548
  return equality;
378
549
  }
379
550
 
380
551
  findJudgementByJudgementNode(judgementNode) {
381
- const judgement = this.judgements.find((judgement) => {
382
- const judgementNodeMatches = judgement.matchJudgementNode(judgementNode);
552
+ const judgements = this.getJudgements(),
553
+ judgement = judgements.find((judgement) => {
554
+ const judgementNodeMatches = judgement.matchJudgementNode(judgementNode);
383
555
 
384
- if (judgementNodeMatches) {
385
- return true;
386
- }
387
- }) || null;
556
+ if (judgementNodeMatches) {
557
+ return true;
558
+ }
559
+ }) || null;
388
560
 
389
561
  return judgement;
390
562
  }
391
563
 
392
564
  findStatementByStatementNode(statementNode) {
393
- const statement = this.statements.find((statement) => {
394
- const statementNodeMatches = statement.matchStatementNode(statementNode);
565
+ const statements = this.getStatements(),
566
+ statement = statements.find((statement) => {
567
+ const statementNodeMatches = statement.matchStatementNode(statementNode);
395
568
 
396
- if (statementNodeMatches) {
397
- return true;
398
- }
399
- }) || null;
569
+ if (statementNodeMatches) {
570
+ return true;
571
+ }
572
+ }) || null;
400
573
 
401
574
  return statement;
402
575
  }
403
576
 
404
577
  findReferenceByReferenceNode(referenceNode) {
405
- const reference = this.references.find((reference) => {
406
- const referenceMatcheReferenceNode = reference.matchReferenceNode(referenceNode);
578
+ const references = this.getReferences(),
579
+ reference = references.find((reference) => {
580
+ const referenceMatcheReferenceNode = reference.matchReferenceNode(referenceNode);
407
581
 
408
- if (referenceMatcheReferenceNode) {
409
- return true;
410
- }
411
- }) || null;
582
+ if (referenceMatcheReferenceNode) {
583
+ return true;
584
+ }
585
+ }) || null;
412
586
 
413
587
  return reference;
414
588
  }
415
589
 
416
590
  findAssertionByAssertionNode(assertionNode) {
417
- const assertion = this.assertions.find((assertion) => {
418
- const assertionNodeMatches = assertion.matchAssertionNode(assertionNode);
591
+ const assertions = this.getAssertions(),
592
+ assertion = assertions.find((assertion) => {
593
+ const assertionNodeMatches = assertion.matchAssertionNode(assertionNode);
419
594
 
420
- if (assertionNodeMatches) {
421
- return true;
422
- }
423
- }) || null;
595
+ if (assertionNodeMatches) {
596
+ return true;
597
+ }
598
+ }) || null;
424
599
 
425
600
  return assertion;
426
601
  }
427
602
 
428
- findAssumptionByAssumptionNode(assumptionNode, metaLevel = false) {
429
- let assumption;
603
+ findAssumptionByAssumptionNode(assumptionNode) {
604
+ const assumptions = this.getAssumptions(),
605
+ assumption = assumptions.find((assumption) => {
606
+ const assumptionNodeMatches = assumption.matchAssumptionNode(assumptionNode);
430
607
 
431
- if (metaLevel) {
432
- const context = this.getContext();
433
-
434
- assumption = context.findAssumptionByAssumptionNode(assumptionNode, metaLevel);
435
- } else {
436
- assumption = this.assumptions.find((assumption) => {
437
- const assumptionNodeMatches = assumption.matchAssumptionNode(assumptionNode);
438
-
439
- if (assumptionNodeMatches) {
440
- return true;
441
- }
442
- }) || null;
443
- }
608
+ if (assumptionNodeMatches) {
609
+ return true;
610
+ }
611
+ }) || null;
444
612
 
445
613
  return assumption;
446
614
  }
447
615
 
448
616
  findReferenceByMetavariableNode(metavariableNode) {
449
- const reference = this.references.find((reference) => {
450
- const referenceMatcheMetavariableNode = reference.matchMetavariableNode(metavariableNode);
617
+ const references = this.getReferences(),
618
+ reference = references.find((reference) => {
619
+ const referenceMatcheMetavariableNode = reference.matchMetavariableNode(metavariableNode);
451
620
 
452
- if (referenceMatcheMetavariableNode) {
453
- return true;
454
- }
455
- }) || null;
621
+ if (referenceMatcheMetavariableNode) {
622
+ return true;
623
+ }
624
+ }) || null;
456
625
 
457
626
  return reference;
458
627
  }
459
628
 
460
629
  findMetavariableByMetavariableNode(metavariableNode) {
461
- const metavariable = this.metavariables.find((metavariable) => {
462
- const metavariableNodeMatches = metavariable.matchMetavariableNode(metavariableNode);
630
+ const metavariables = this.getMetavariables(),
631
+ metavariable = metavariables.find((metavariable) => {
632
+ const metavariableNodeMatches = metavariable.matchMetavariableNode(metavariableNode);
463
633
 
464
- if (metavariableNodeMatches) {
465
- return true;
466
- }
467
- }) || null;
634
+ if (metavariableNodeMatches) {
635
+ return true;
636
+ }
637
+ }) || null;
468
638
 
469
639
  return metavariable;
470
640
  }
471
641
 
472
642
  findSubstitutionBySubstitutionNode(substitutionNode) {
473
- const substitution = this.substitutions.find((substitution) => {
474
- const substitutionNodeMatches = substitution.matchSubstitutionNode(substitutionNode);
643
+ const substitutions = this.getSubstitutions(),
644
+ substitution = substitutions.find((substitution) => {
645
+ const substitutionNodeMatches = substitution.matchSubstitutionNode(substitutionNode);
475
646
 
476
- if (substitutionNodeMatches) {
477
- return true;
478
- }
479
- }) || null;
647
+ if (substitutionNodeMatches) {
648
+ return true;
649
+ }
650
+ }) || null;
480
651
 
481
652
  return substitution;
482
653
  }
@@ -523,8 +694,8 @@ export default class EphemeralContext extends Context {
523
694
  return assertionPresent;
524
695
  }
525
696
 
526
- isAssumptionPresentByAssumptionNode(assumptionNode, metaLevel = false) {
527
- const assumption = this.findAssumptionByAssumptionNode(assumptionNode, metaLevel),
697
+ isAssumptionPresentByAssumptionNode(assumptionNode) {
698
+ const assumption = this.findAssumptionByAssumptionNode(assumptionNode),
528
699
  assumptionPresent = (assumption !== null);
529
700
 
530
701
  return assumptionPresent;
@@ -578,38 +749,51 @@ export default class EphemeralContext extends Context {
578
749
  }
579
750
 
580
751
  toJSON() {
581
- const termsJSON = termsToTermsJSON(this.terms),
582
- framesJSON = framesToFramesJSON(this.frames),
583
- judgementsJSON = judgementsToJudgementsJSON(this.judgements),
584
- equalitiesJSON = equalitiesToEqualitiesJSON(this.equalities),
585
- statementsJSON = statementsToStatementsJSON(this.statements),
586
- assertionsJSON = assertionsToAssertionsJSON(this.assertions),
587
- referencesJSON = referencesToReferencesJSON(this.references),
588
- assumptionsJSON = assumptionsToAssumptionsJSON(this.assumptions),
589
- metavariablesJSON = metavariablesToMetavariablesJSON(this.metavariables),
590
- substitutionsJSON = substitutionsToSubstitutionsJSON(this.substitutions),
591
- terms = termsJSON, ///
592
- frames = framesJSON, ///
593
- judgements = judgementsJSON, ///
594
- equalities = equalitiesJSON, ///
595
- statements = statementsJSON, ///
596
- assertions = assertionsJSON, ///
597
- references = referencesJSON, ///
598
- assumptions = assumptionsJSON, ///
599
- metavariables = metavariablesJSON, //
600
- substitutions = substitutionsJSON, ///
601
- json = {
602
- terms,
603
- frames,
604
- judgements,
605
- equalities,
606
- statements,
607
- assertions,
608
- references,
609
- assumptions,
610
- metavariables,
611
- substitutions
612
- };
752
+ let terms = this.getTerms(),
753
+ frames = this.getFrames(),
754
+ judgements = this.getJudgements(),
755
+ equalities = this.getEqualities(),
756
+ statements = this.getStatements(),
757
+ assertions = this.getAssertions(),
758
+ references = this.getReferences(),
759
+ assumptions = this.getAssumptions(),
760
+ metavariables = this.getMetavariables(),
761
+ substitutions = this.getSubstitutions();
762
+
763
+ const termsJSON = termsToTermsJSON(terms),
764
+ framesJSON = framesToFramesJSON(frames),
765
+ judgementsJSON = judgementsToJudgementsJSON(judgements),
766
+ equalitiesJSON = equalitiesToEqualitiesJSON(equalities),
767
+ statementsJSON = statementsToStatementsJSON(statements),
768
+ assertionsJSON = assertionsToAssertionsJSON(assertions),
769
+ referencesJSON = referencesToReferencesJSON(references),
770
+ assumptionsJSON = assumptionsToAssumptionsJSON(assumptions),
771
+ metavariablesJSON = metavariablesToMetavariablesJSON(metavariables),
772
+ substitutionsJSON = substitutionsToSubstitutionsJSON(substitutions);
773
+
774
+ terms = termsJSON; ///
775
+ frames = framesJSON; ///
776
+ judgements = judgementsJSON; ///
777
+ equalities = equalitiesJSON; ///
778
+ statements = statementsJSON; ///
779
+ assertions = assertionsJSON; ///
780
+ references = referencesJSON; ///
781
+ assumptions = assumptionsJSON; ///
782
+ metavariables = metavariablesJSON; //
783
+ substitutions = substitutionsJSON; ///
784
+
785
+ const json = {
786
+ terms,
787
+ frames,
788
+ judgements,
789
+ equalities,
790
+ statements,
791
+ assertions,
792
+ references,
793
+ assumptions,
794
+ metavariables,
795
+ substitutions
796
+ };
613
797
 
614
798
  return json;
615
799
  }