occam-verify-cli 1.0.871 → 1.0.872

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.
@@ -175,260 +175,110 @@ export default class MnemicContext extends Context {
175
175
 
176
176
  addTerm(term) {
177
177
  const context = this, ///
178
- termA = term, ///
179
178
  termString = term.getString();
180
179
 
181
180
  context.trace(`Adding the '${termString}' term to the mnemic context...`);
182
181
 
183
- const terms = this.getTerms(),
184
- termB = terms.find((term) => {
185
- const termB = term, ///
186
- termAComparesToTermB = termA.compareTerm(termB);
187
-
188
- if (termAComparesToTermB) {
189
- return true;
190
- }
191
- }) || null;
192
-
193
- if (termB !== null) {
194
- context.trace(`The '${termString}' term has already been added to the mnemic context.`);
195
- } else {
196
- this.terms.push(term);
197
- }
182
+ this.terms.push(term);
198
183
 
199
184
  context.debug(`...added the '${termString}' term to the mnemic context.`);
200
185
  }
201
186
 
202
187
  addFrame(frame) {
203
188
  const context = this, ///
204
- frameA = frame, ///
205
189
  frameString = frame.getString();
206
190
 
207
191
  context.trace(`Adding the '${frameString}' frame to the mnemic context...`);
208
192
 
209
- const frames = this.getFrames(),
210
- frameB = frames.find((frame) => {
211
- const frameB = frame, ///
212
- frameAEqualToFrameB = frameA.isEqualTo(frameB);
213
-
214
- if (frameAEqualToFrameB) {
215
- return true;
216
- }
217
- }) || null;
218
-
219
- if (frameB !== null) {
220
- context.trace(`The '${frameString}' frame has already been added to the mnemic context.`);
221
- } else {
222
- this.frames.push(frame);
223
- }
193
+ this.frames.push(frame);
224
194
 
225
195
  context.debug(`...added the '${frameString}' frame to the mnemic context.`);
226
196
  }
227
197
 
228
198
  addEquality(equality) {
229
199
  const context = this, ///
230
- equalityA = equality, ///
231
200
  equalityString = equality.getString();
232
201
 
233
202
  context.trace(`Adding the '${equalityString}' equality to the mnemic context...`);
234
203
 
235
- const equalities = this.getEqualities(),
236
- equalityB = equalities.find((equality) => {
237
- const equalityB = equality, ///
238
- equalityAEqualToEqualityB = equalityA.isEqualTo(equalityB);
239
-
240
- if (equalityAEqualToEqualityB) {
241
- return true;
242
- }
243
- }) || null;
244
-
245
- if (equalityB !== null) {
246
- context.trace(`The '${equalityString}' equality has already been added to the mnemic context.`);
247
- } else {
248
- this.equalities.push(equality);
249
- }
204
+ this.equalities.push(equality);
250
205
 
251
206
  context.debug(`...added the '${equalityString}' equality to the mnemic context.`);
252
207
  }
253
208
 
254
209
  addJudgement(judgement) {
255
210
  const context = this, ///
256
- judgementA = judgement, ///
257
211
  judgementString = judgement.getString();
258
212
 
259
213
  context.trace(`Adding the '${judgementString}' judgement to the mnemic context...`);
260
214
 
261
- const judgements = this.getJudgements(),
262
- judgementB = judgements.find((judgement) => {
263
- const judgementB = judgement, ///
264
- judgementAEqualToEqualityB = judgementA.isEqualTo(judgementB);
265
-
266
- if (judgementAEqualToEqualityB) {
267
- return true;
268
- }
269
- }) || null;
270
-
271
- if (judgementB !== null) {
272
- context.trace(`The '${judgementString}' judgement has already been added to the mnemic context.`);
273
- } else {
274
- this.judgements.push(judgement);
275
- }
215
+ this.judgements.push(judgement);
276
216
 
277
217
  context.debug(`...added the '${judgementString}' judgement to the mnemic context.`);
278
218
  }
279
219
 
280
220
  addStatement(statement) {
281
221
  const context = this, ///
282
- statementA = statement, ///
283
222
  statementString = statement.getString();
284
223
 
285
224
  context.trace(`Adding the '${statementString}' statement to the mnemic context...`);
286
225
 
287
- const statements = this.getStatements(),
288
- statementB = statements.find((statement) => {
289
- const statementB = statement, ///
290
- statementAEqualToStatementB = statementA.isEqualTo(statementB);
291
-
292
- if (statementAEqualToStatementB) {
293
- return true;
294
- }
295
- }) || null;
296
-
297
- if (statementB !== null) {
298
- context.trace(`The '${statementString}' statement has already been added to the mnemic context.`);
299
- } else {
300
- this.statements.push(statement);
301
- }
226
+ this.statements.push(statement);
302
227
 
303
228
  context.debug(`...added the '${statementString}' statement to the mnemic context.`);
304
229
  }
305
230
 
306
231
  addAssertion(assertion) {
307
232
  const context = this, ///
308
- assertionA = assertion, ///
309
233
  assertionString = assertion.getString();
310
234
 
311
235
  context.trace(`Adding the '${assertionString}' assertion to the mnemic context...`);
312
236
 
313
- const assertions = this.getAssumptions(),
314
- assertionB = assertions.find((assertion) => {
315
- const assertionB = assertion, ///
316
- assertionAEqualToAssertionB = assertionA.isEqualTo(assertionB);
317
-
318
- if (assertionAEqualToAssertionB) {
319
- return true;
320
- }
321
- }) || null;
322
-
323
- if (assertionB !== null) {
324
- context.trace(`The '${assertionString}' assertion has already been added to the mnemic context.`);
325
- } else {
326
- this.assertions.push(assertion);
327
- }
237
+ this.assertions.push(assertion);
328
238
 
329
239
  context.debug(`...added the '${assertionString}' assertion to the mnemic context.`);
330
240
  }
331
241
 
332
242
  addReference(reference) {
333
243
  const context = this, ///
334
- referenceA = reference, ///
335
244
  referenceString = reference.getString();
336
245
 
337
246
  context.trace(`Adding the '${referenceString}' reference to the mnemic context...`);
338
247
 
339
- const references = this.getReferences(),
340
- referenceB = references.find((reference) => {
341
- const referenceB = reference, ///
342
- referenceAEqualToReferenceB = referenceA.isEqualTo(referenceB);
343
-
344
- if (referenceAEqualToReferenceB) {
345
- return true;
346
- }
347
- }) || null;
348
-
349
- if (referenceB !== null) {
350
- context.trace(`The '${referenceString}' reference has already been added to the mnemic context.`);
351
- } else {
352
- this.references.push(reference);
353
- }
248
+ this.references.push(reference);
354
249
 
355
250
  context.debug(`...added the '${referenceString}' reference to the mnemic context.`);
356
251
  }
357
252
 
358
253
  addAssumption(assumption) {
359
254
  const context = this, ///
360
- assumptionA = assumption, ///
361
255
  assumptionString = assumption.getString();
362
256
 
363
257
  context.trace(`Adding the '${assumptionString}' assumption to the mnemic context...`);
364
258
 
365
- const assumptions = this.getAssumptions(),
366
- assumptionB = assumptions.find((assumption) => {
367
- const assumptionB = assumption, ///
368
- assumptionAEqualToAssumptionB = assumptionA.isEqualTo(assumptionB);
369
-
370
- if (assumptionAEqualToAssumptionB) {
371
- return true;
372
- }
373
- }) || null;
374
-
375
- if (assumptionB !== null) {
376
- context.trace(`The '${assumptionString}' assumption has already been added to the mnemic context.`);
377
- } else {
378
- this.assumptions.push(assumption);
379
- }
259
+ this.assumptions.push(assumption);
380
260
 
381
261
  context.debug(`...added the '${assumptionString}' assumption to the mnemic context.`);
382
262
  }
383
263
 
384
264
  addMetavariable(metavariable) {
385
265
  const context = this, ///
386
- metavariableA = metavariable, ///
387
266
  metavariableString = metavariable.getString();
388
267
 
389
268
  context.trace(`Adding the '${metavariableString}' metavariable to the mnemic context...`);
390
269
 
391
- const metavariables = this.getMetavariables(),
392
- metavariableB = metavariables.find((metavariable) => {
393
- const metavariableB = metavariable, ///
394
- metavariableAEqualToSubstitutionB = metavariableA.isEqualTo(metavariableB);
395
-
396
- if (metavariableAEqualToSubstitutionB) {
397
- return true;
398
- }
399
- }) || null;
400
-
401
- if (metavariableB !== null) {
402
- context.trace(`The '${metavariableString}' metavariable has already been added to the mnemic context.`);
403
- } else {
404
- this.metavariables.push(metavariable);
405
- }
270
+ this.metavariables.push(metavariable);
406
271
 
407
272
  context.debug(`...added the '${metavariableString}' metavariable to the mnemic context.`);
408
273
  }
409
274
 
410
275
  addSubstitution(substitution) {
411
276
  const context = this, ///
412
- substitutionA = substitution, ///
413
277
  substitutionString = substitution.getString();
414
278
 
415
279
  context.trace(`Adding the '${substitutionString}' substitution to the mnemic context...`);
416
280
 
417
- const substitutions = this.getSubstitutions(),
418
- substitutionB = substitutions.find((substitution) => {
419
- const substitutionB = substitution, ///
420
- substitutionAEqualToSubstitutionB = substitutionA.isEqualTo(substitutionB);
421
-
422
- if (substitutionAEqualToSubstitutionB) {
423
- return true;
424
- }
425
- }) || null;
426
-
427
- if (substitutionB !== null) {
428
- context.trace(`The '${substitutionString}' substitution has already been added to the mnemic context.`);
429
- } else {
430
- this.substitutions.push(substitution);
431
- }
281
+ this.substitutions.push(substitution);
432
282
 
433
283
  context.debug(`...added the '${substitutionString}' substitution to the mnemic context.`);
434
284
  }
@@ -3,7 +3,7 @@
3
3
  import { Element } from "occam-languages";
4
4
 
5
5
  import { define } from "../elements";
6
- import { instantiate } from "../utilities/context";
6
+ import {instantiate, reconcile} from "../utilities/context";
7
7
  import { instantiateAssumption } from "../process/instantiate";
8
8
 
9
9
  export default define(class Assumption extends Element {
@@ -209,11 +209,13 @@ export default define(class Assumption extends Element {
209
209
 
210
210
  context.trace(`Unifying the '${topLevelMetaAssertionString}' top level meta-assertion with the '${assumptionString}' assumption...`);
211
211
 
212
- topLevelMetaAssertionUnifies = this.reference.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
212
+ reconcile((context) => {
213
+ topLevelMetaAssertionUnifies = this.reference.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
213
214
 
214
- if (topLevelMetaAssertionUnifies) {
215
- topLevelMetaAssertionUnifies = this.statement.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
216
- }
215
+ if (topLevelMetaAssertionUnifies) {
216
+ topLevelMetaAssertionUnifies = this.statement.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
217
+ }
218
+ }, context);
217
219
 
218
220
  if (topLevelMetaAssertionUnifies) {
219
221
  context.trace(`...unified the '${topLevelMetaAssertionString}' top level meta-assertion with the '${assumptionString}' assumption...`);
@@ -274,18 +274,13 @@ export default define(class Reference extends Element {
274
274
  const label = topLevelMetaAssertion.getLabel(),
275
275
  labelContext = label.getContext(),
276
276
  referenceString = this.getString(), ///
277
- temporaryContext = context, ///
277
+ referenceContext = this.getContext(), ///
278
278
  topLevelMetaAssertionString = topLevelMetaAssertion.getString();
279
279
 
280
280
  context.trace(`Unifying the '${topLevelMetaAssertionString}' top level meta-assertion with the '${referenceString}' reference...`);
281
281
 
282
- const specificContext = labelContext; ///
283
-
284
- context = this.getContext();
285
-
286
- const generalContext = context; ///
287
-
288
- context = temporaryContext; ///
282
+ const generalContext = referenceContext, ///
283
+ specificContext = labelContext; ///
289
284
 
290
285
  join((specificContext) => {
291
286
  reconcile((specificContext) => {
@@ -6,7 +6,7 @@ import { define } from "../../elements";
6
6
  import { instantiateFrameSubstitution } from "../../process/instantiate";
7
7
  import { frameSubstitutionFromFrameSubstitutionNode } from "../../utilities/element";
8
8
  import { frameSubstitutionStringFromFrameAndMetavariable } from "../../utilities/string";
9
- import { ablate, ablates, attempts, descend, instantiate, unserialises } from "../../utilities/context";
9
+ import { ablate, attempts, descend, instantiate, unserialises } from "../../utilities/context";
10
10
 
11
11
  export default define(class FrameSubstitution extends Substitution {
12
12
  constructor(contexts, string, node, lineIndex, targetFrame, replacementFrame) {
@@ -208,15 +208,18 @@ export default define(class FrameSubstitution extends Substitution {
208
208
  return frameSubstitutionn;
209
209
  }
210
210
 
211
- static fromStatement(statement, generalContext, specificContext) {
211
+ static fromStatement(statement, context) {
212
212
  let frameSubstitution = null;
213
213
 
214
214
  const frameSubstitutionNode = statement.getFrameSubstitutionNode();
215
215
 
216
216
  if (frameSubstitutionNode !== null) {
217
- ablates((generalContext, specificContext) => {
217
+ ablate((context) => {
218
+ const generalContext = context, ///
219
+ specificContext = context; ///
220
+
218
221
  frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, generalContext, specificContext);
219
- }, generalContext, specificContext);
222
+ }, context);
220
223
  }
221
224
 
222
225
  return frameSubstitution;
@@ -7,7 +7,7 @@ import { stripBracketsFromTerm } from "../../utilities/brackets";
7
7
  import { instantiateTermSubstitution } from "../../process/instantiate";
8
8
  import { termSubstitutionFromTermSubstitutionNode } from "../../utilities/element";
9
9
  import { termSubstitutionStringFromTermAndVariable } from "../../utilities/string";
10
- import { ablate, ablates, attempts, descend, instantiate, unserialises } from "../../utilities/context";
10
+ import { ablate, attempts, descend, instantiate, unserialises } from "../../utilities/context";
11
11
 
12
12
  export default define(class TermSubstitution extends Substitution {
13
13
  constructor(context, string, node, lineIndex, targetTerm, replacementTerm) {
@@ -219,15 +219,18 @@ export default define(class TermSubstitution extends Substitution {
219
219
  return termSubstitutionn;
220
220
  }
221
221
 
222
- static fromStatement(statement, generalContext, specificContext) {
222
+ static fromStatement(statement, context) {
223
223
  let termSubstitution = null;
224
224
 
225
225
  const termSubstitutionNode = statement.getTermSubstitutionNode();
226
226
 
227
227
  if (termSubstitutionNode !== null) {
228
- ablates((generalContext, specificContext) => {
228
+ ablate((context) => {
229
+ const generalContext = context, ///
230
+ specificContext = context; ///
231
+
229
232
  termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, generalContext, specificContext);
230
- }, generalContext, specificContext);
233
+ }, context);
231
234
  }
232
235
 
233
236
  return termSubstitution;
@@ -141,24 +141,8 @@ export function unserialise(innerFunction, json, context) {
141
141
  return innerFunction(json, context);
142
142
  }
143
143
 
144
- export function ablates(innerFunction, ...contexts) {
145
- contexts = contexts.map((context) => { ///
146
- let contextNominalFileContext = (context instanceof NominalFileContext);
147
-
148
- while (!contextNominalFileContext) {
149
- context = context.getContext();
150
-
151
- contextNominalFileContext = (context instanceof NominalFileContext);
152
- }
153
-
154
- return context;
155
- });
156
-
157
- return innerFunction(...contexts);
158
- }
159
-
160
144
  export function attempts(innerFunction, ...contexts) {
161
- contexts = contexts.map((context) => {
145
+ contexts = contexts.map((context) => { ///
162
146
  const mnemicContext = MenmicContext.fromNothing(context);
163
147
 
164
148
  context = mnemicContext; ///
@@ -772,9 +772,13 @@ export function termToTermJSON(term) {
772
772
  }
773
773
 
774
774
  export function typeToTypeJSON(type) {
775
- const typeJSON = (type !== null) ?
776
- type.toJSON() :
777
- null;
775
+ let typeJSON = null;
776
+
777
+ if (type !== null) {
778
+ const abridged = true;
779
+
780
+ typeJSON = type.toJSON(abridged);
781
+ }
778
782
 
779
783
  return typeJSON;
780
784
  }
@@ -1008,9 +1012,9 @@ export function hypothesesToHypothesesJSON(hypotheses) {
1008
1012
  }
1009
1013
 
1010
1014
  export function superTypesToSuperTypesJSON(superTypes) {
1011
- const abridged = true,
1012
- superTypesJSON = superTypes.map((superType) => {
1013
- const superTypeJSON = superType.toJSON(abridged);
1015
+ const superTypesJSON = superTypes.map((superType) => {
1016
+ const abridged = true,
1017
+ superTypeJSON = superType.toJSON(abridged);
1014
1018
 
1015
1019
  return superTypeJSON;
1016
1020
  });
@@ -104,10 +104,8 @@ function validateStatementAsMetavariable(statement, context) {
104
104
 
105
105
  let substitution;
106
106
 
107
- const generalContext = context, ///
108
- specificContext = context, ///
109
- termSubstitution = TermSubstitution.fromStatement(statement, generalContext, specificContext),
110
- frameSubstitution = FrameSubstitution.fromStatement(statement, generalContext, specificContext);
107
+ const termSubstitution = TermSubstitution.fromStatement(statement, context),
108
+ frameSubstitution = FrameSubstitution.fromStatement(statement, context);
111
109
 
112
110
  substitution = (termSubstitution || frameSubstitution);
113
111