occam-verify-cli 0.0.1245 → 0.0.1247

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 (74) hide show
  1. package/lib/context/file.js +172 -210
  2. package/lib/context/local.js +95 -125
  3. package/lib/dom/assertion/contained.js +44 -22
  4. package/lib/dom/assertion/defined.js +34 -17
  5. package/lib/dom/combinator/bracketed.js +167 -0
  6. package/lib/dom/combinator.js +163 -0
  7. package/lib/{constructor → dom/constructor}/bracketed.js +7 -7
  8. package/lib/dom/constructor.js +190 -0
  9. package/lib/dom/declaration/combinator.js +2 -8
  10. package/lib/dom/declaration/constructor.js +42 -7
  11. package/lib/dom/declaration.js +113 -71
  12. package/lib/dom/equality.js +3 -3
  13. package/lib/dom/frame.js +111 -76
  14. package/lib/dom/judgement.js +29 -3
  15. package/lib/dom/label.js +22 -15
  16. package/lib/dom/metaLemma.js +20 -41
  17. package/lib/dom/metatheorem.js +20 -41
  18. package/lib/dom/metavariable.js +7 -7
  19. package/lib/dom/reference.js +32 -18
  20. package/lib/dom/rule.js +3 -4
  21. package/lib/dom/statement.js +2 -2
  22. package/lib/dom/term.js +2 -2
  23. package/lib/dom/topLevelAssertion.js +50 -71
  24. package/lib/dom/type.js +3 -3
  25. package/lib/dom/variable.js +5 -5
  26. package/lib/equivalence.js +2 -2
  27. package/lib/index.js +7 -3
  28. package/lib/mixins/statement/verify.js +3 -3
  29. package/lib/mixins/term/verify.js +2 -3
  30. package/lib/substitution/statement.js +2 -2
  31. package/lib/unifier/{label.js → reference.js} +14 -14
  32. package/lib/utilities/json.js +5 -7
  33. package/lib/utilities/unification.js +25 -6
  34. package/lib/verifier/combinator.js +3 -3
  35. package/lib/verifier/constructor.js +3 -3
  36. package/package.json +5 -5
  37. package/src/context/file.js +166 -206
  38. package/src/context/local.js +73 -83
  39. package/src/dom/assertion/contained.js +60 -27
  40. package/src/dom/assertion/defined.js +44 -20
  41. package/src/{combinator → dom/combinator}/bracketed.js +6 -5
  42. package/src/{combinator.js → dom/combinator.js} +8 -7
  43. package/src/{constructor → dom/constructor}/bracketed.js +6 -5
  44. package/src/{constructor.js → dom/constructor.js} +8 -7
  45. package/src/dom/declaration/combinator.js +2 -3
  46. package/src/dom/declaration/constructor.js +3 -2
  47. package/src/dom/declaration.js +133 -101
  48. package/src/dom/equality.js +2 -2
  49. package/src/dom/frame.js +151 -95
  50. package/src/dom/judgement.js +36 -2
  51. package/src/dom/label.js +18 -13
  52. package/src/dom/metaLemma.js +23 -55
  53. package/src/dom/metatheorem.js +23 -55
  54. package/src/dom/metavariable.js +6 -6
  55. package/src/dom/reference.js +43 -25
  56. package/src/dom/rule.js +2 -2
  57. package/src/dom/statement.js +1 -1
  58. package/src/dom/term.js +1 -1
  59. package/src/dom/topLevelAssertion.js +53 -86
  60. package/src/dom/type.js +2 -2
  61. package/src/dom/variable.js +4 -4
  62. package/src/equivalence.js +1 -1
  63. package/src/index.js +4 -0
  64. package/src/mixins/statement/verify.js +3 -2
  65. package/src/mixins/term/verify.js +2 -3
  66. package/src/substitution/statement.js +1 -1
  67. package/src/unifier/{label.js → reference.js} +6 -6
  68. package/src/utilities/json.js +4 -4
  69. package/src/utilities/unification.js +43 -5
  70. package/src/verifier/combinator.js +2 -2
  71. package/src/verifier/constructor.js +2 -2
  72. package/lib/combinator/bracketed.js +0 -126
  73. package/lib/combinator.js +0 -122
  74. package/lib/constructor.js +0 -149
@@ -313,97 +313,60 @@ export default class FileContext {
313
313
  return fileContext;
314
314
  }
315
315
 
316
- isMetavariableDeclared(metavariable, generalContext, specificContext) {
317
- metavariable = this.findMetavariable(metavariable, generalContext, specificContext); ///
318
-
319
- const metavariableDeclared = (metavariable !== null);
320
-
321
- return metavariableDeclared;
316
+ addType(type) {
317
+ this.types.push(type);
322
318
  }
323
319
 
324
- isTypeDeclaredByTypeName(typeName) {
325
- const type = this.findTypeByTypeName(typeName),
326
- typeDeclared = (type !== null);
327
-
328
- return typeDeclared;
320
+ addRule(rule) {
321
+ this.rules.push(rule);
329
322
  }
330
323
 
331
- isVariableDeclaredByVariableName(variableName) {
332
- const variable = this.findVariableByVariableName(variableName),
333
- variableDeclared = (variable !== null);
334
-
335
- return variableDeclared;
324
+ addAxiom(axiom) {
325
+ this.axioms.push(axiom);
336
326
  }
337
327
 
338
- isMetavariableDeclaredByMetavariableName(metavariableName) {
339
- const metavariable = this.findMetavariableByMetavariableName(metavariableName),
340
- metavariableDeclared = (metavariable !== null);
341
-
342
- return metavariableDeclared;
328
+ addLemma(lemma) {
329
+ this.lemmas.push(lemma);
343
330
  }
344
331
 
345
- isLabelPresentByMetavariableName(metavariableName) {
346
- const label = this.findLabelByMetavariableName(metavariableName),
347
- labelPresent = (label !== null);
348
-
349
- return labelPresent;
332
+ addTheorem(theorem) {
333
+ this.theorems.push(theorem);
350
334
  }
351
335
 
352
- isLabelPresentByMetavariableNode(metavariableNode) {
353
- const label = this.findLabelByMetavariableNode(metavariableNode),
354
- labelPresent = (label !== null);
355
-
356
- return labelPresent;
336
+ addVariable(variable) {
337
+ this.variables.push(variable);
357
338
  }
358
339
 
359
- findTypeByTypeName(typeName) {
360
- let types = this.getTypes();
361
-
362
- types.push(objectType);
363
-
364
- const type = types.find((type) => {
365
- const typeNameMatches = type.matchTypeName(typeName);
366
-
367
- if (typeNameMatches) {
368
- return true;
369
- }
370
- }) || null;
371
-
372
- return type;
340
+ addMetaLemma(metaLemma) {
341
+ this.metaLemmas.push(metaLemma);
373
342
  }
374
343
 
375
- findMetaTypeByMetaTypeName(metaTypeName) {
376
- const metaTypes = this.getMetaTypes(),
377
- metaType = metaTypes.find((metaType) => {
378
- const metaTypeNameMatches = metaType.matchMetaTypeName(metaTypeName);
379
-
380
- if (metaTypeNameMatches) {
381
- return true;
382
- }
383
- }) || null;
344
+ addConjecture(conjecture) {
345
+ this.conjectures.push(conjecture);
346
+ }
384
347
 
385
- return metaType;
348
+ addCombinator(combinator) {
349
+ this.combinators.push(combinator);
386
350
  }
387
351
 
388
- findVariableByVariableName(variableName) {
389
- const variables = this.getVariables(),
390
- variable = variables.find((variable) => {
391
- const variableNameMatches = variable.matchVariableName(variableName);
352
+ addConstructor(constructor) {
353
+ this.constructors.push(constructor);
354
+ }
392
355
 
393
- if (variableNameMatches) {
394
- return true;
395
- }
396
- }) || null;
356
+ addMetatheorem(metatheorem) {
357
+ this.metatheorems.push(metatheorem);
358
+ }
397
359
 
398
- return variable;
360
+ addMetavariable(metavariable) {
361
+ this.metavariables.push(metavariable);
399
362
  }
400
363
 
401
- findLabelByMetavariableName(metavariableName) {
364
+ findLabelByReference(reference, context) {
402
365
  const labels = this.getLabels(),
403
366
  label = labels.find((label) => {
404
- const metavariableNameMatches = label.matchMetavariableName(metavariableName);
367
+ const metavariableUnified = label.unifyReference(reference, context);
405
368
 
406
- if (metavariableNameMatches) {
369
+ if (metavariableUnified) {
407
370
  return true;
408
371
  }
409
372
  }) || null;
@@ -411,19 +374,6 @@ export default class FileContext {
411
374
  return label;
412
375
  }
413
376
 
414
- findLabelByMetavariableNode(metavariableNode) {
415
- const labels = this.getLabels(),
416
- label = labels.find((label) => {
417
- const metavariableNodeMatches = label.matchMetavariableNode(metavariableNode);
418
-
419
- if (metavariableNodeMatches) {
420
- return true;
421
- }
422
- }) || null;
423
-
424
- return label;
425
- }
426
-
427
377
  findRuleByReference(reference) {
428
378
  const rules = this.getRules(),
429
379
  metavariableName = reference.getMetavariableName(),
@@ -509,14 +459,14 @@ export default class FileContext {
509
459
  }
510
460
 
511
461
  findMetaLemmasByReference(reference) {
512
- const metaLemmas = this.getMetaLemmas();
462
+ const metaLemmas = this.getMetaLemmas(),
463
+ substitutions = Substitutions.fromNothing();
513
464
 
514
465
  filter(metaLemmas, (metaLemma) => {
515
466
  const context = this, ///
516
- substitutions = Substitutions.fromNothing(),
517
- referenceUnified = metaLemma.unifyReference(reference, substitutions, context);
467
+ metaLemmaUnified = reference.unifyMetaLemma(metaLemma, substitutions, context);
518
468
 
519
- if (referenceUnified) {
469
+ if (metaLemmaUnified) {
520
470
  return true;
521
471
  }
522
472
  });
@@ -525,14 +475,14 @@ export default class FileContext {
525
475
  }
526
476
 
527
477
  findMetatheoremsByReference(reference) {
528
- const metatheorems = this.getMetatheorems();
478
+ const metatheorems = this.getMetatheorems(),
479
+ substitutions = Substitutions.fromNothing();
529
480
 
530
- filter(metatheorems, (metatheorem) => {
481
+ filter(metatheorems, (metatheorem) => {
531
482
  const context = this, ///
532
- substitutions = Substitutions.fromNothing(),
533
- referenceUnified = metatheorem.unifyReference(reference, substitutions, context);
483
+ metatheoremUnified = reference.unifyMetatheorem(metatheorem, substitutions, context);
534
484
 
535
- if (referenceUnified) {
485
+ if (metatheoremUnified) {
536
486
  return true;
537
487
  }
538
488
  });
@@ -550,22 +500,93 @@ export default class FileContext {
550
500
  return axiomLemmaTheoremConjecture;
551
501
  }
552
502
 
553
- findVariable(variable) {
554
- const specificVariable = variable, ///
555
- variables = this.getVariables();
503
+ findMetavariable(metavariable, generalContext, specificContext) {
504
+ const specificMetavariable = metavariable, ///
505
+ metavariables = this.getMetavariables();
506
+
507
+ metavariable = metavariables.find((metavariable) => {
508
+ const generalMetavariable = metavariable; ///
509
+
510
+ metavariable = specificMetavariable; ///
511
+
512
+ const metavariableUnified = generalMetavariable.unifyMetavariable(metavariable, generalContext, specificContext);
513
+
514
+ if (metavariableUnified) {
515
+ return true;
516
+ }
517
+ }) || null;
518
+
519
+ return metavariable;
520
+ }
521
+
522
+ findTypeByTypeName(typeName) {
523
+ let types = this.getTypes();
524
+
525
+ types.push(objectType);
556
526
 
557
- variable = variables.find((variable) => {
558
- const generalVariable = variable,
559
- generalVariableEqualToSpecificVariable = generalVariable.isEqualTo(specificVariable);
527
+ const type = types.find((type) => {
528
+ const typeNameMatches = type.matchTypeName(typeName);
560
529
 
561
- if (generalVariableEqualToSpecificVariable) {
530
+ if (typeNameMatches) {
562
531
  return true;
563
532
  }
564
533
  }) || null;
565
534
 
535
+ return type;
536
+ }
537
+
538
+ findMetaTypeByMetaTypeName(metaTypeName) {
539
+ const metaTypes = this.getMetaTypes(),
540
+ metaType = metaTypes.find((metaType) => {
541
+ const metaTypeNameMatches = metaType.matchMetaTypeName(metaTypeName);
542
+
543
+ if (metaTypeNameMatches) {
544
+ return true;
545
+ }
546
+ }) || null;
547
+
548
+ return metaType;
549
+ }
550
+
551
+ findVariableByVariableName(variableName) {
552
+ const variables = this.getVariables(),
553
+ variable = variables.find((variable) => {
554
+ const variableNameMatches = variable.matchVariableName(variableName);
555
+
556
+ if (variableNameMatches) {
557
+ return true;
558
+ }
559
+ }) || null;
560
+
566
561
  return variable;
567
562
  }
568
563
 
564
+ findLabelByMetavariableName(metavariableName) {
565
+ const labels = this.getLabels(),
566
+ label = labels.find((label) => {
567
+ const metavariableNameMatches = label.matchMetavariableName(metavariableName);
568
+
569
+ if (metavariableNameMatches) {
570
+ return true;
571
+ }
572
+ }) || null;
573
+
574
+ return label;
575
+ }
576
+
577
+ findLabelByMetavariableNode(metavariableNode) {
578
+ const labels = this.getLabels(),
579
+ label = labels.find((label) => {
580
+ const metavariableNodeMatches = label.matchMetavariableNode(metavariableNode);
581
+
582
+ if (metavariableNodeMatches) {
583
+ return true;
584
+ }
585
+ }) || null;
586
+
587
+ return label;
588
+ }
589
+
569
590
  findJudgementByMetavariable(metavariable) {
570
591
  const judgements = this.getJudgements(),
571
592
  judgement = judgements.find((judgement) => {
@@ -596,96 +617,83 @@ export default class FileContext {
596
617
  return metavariable;
597
618
  }
598
619
 
599
- findMetavariable(metavariable, generalContext, specificContext) {
600
- const specificMetavariable = metavariable, ///
601
- metavariables = this.getMetavariables();
602
-
603
- metavariable = metavariables.find((metavariable) => {
604
- const generalMetavariable = metavariable; ///
605
-
606
- metavariable = specificMetavariable; ///
607
-
608
- const metavariableUnified = generalMetavariable.unifyMetavariable(metavariable, generalContext, specificContext);
620
+ isMetavariablePresent(metavariable, generalContext, specificContext) {
621
+ metavariable = this.findMetavariable(metavariable, generalContext, specificContext); ///
609
622
 
610
- if (metavariableUnified) {
611
- return true;
612
- }
613
- }) || null;
623
+ const metavariablePresent = (metavariable !== null);
614
624
 
615
- return metavariable;
625
+ return metavariablePresent;
616
626
  }
617
627
 
618
- isRulePresentByReference(reference) {
619
- const rule = this.findRuleByReference(reference),
620
- rulePresent = (rule !== null);
628
+ isTypePresentByTypeName(typeName) {
629
+ const type = this.findTypeByTypeName(typeName),
630
+ typeDeclared = (type !== null);
621
631
 
622
- return rulePresent;
632
+ return typeDeclared;
623
633
  }
624
634
 
625
- isAxiomPresentByReference(reference) {
626
- const axiom = this.findAxiomByReference(reference),
627
- axiomPresent = (axiom !== null);
635
+ isVariablePresentByVariableName(variableName) {
636
+ const variable = this.findVariableByVariableName(variableName),
637
+ variablePresent = (variable !== null);
628
638
 
629
- return axiomPresent;
639
+ return variablePresent;
630
640
  }
631
641
 
632
- isLemmaPresentByReference(reference) {
633
- const lemma = this.findLemmaByReference(reference),
634
- lemmaPresent = (lemma !== null);
642
+ isLabelPresentByMetavariableName(metavariableName) {
643
+ const label = this.findLabelByMetavariableName(metavariableName),
644
+ labelPresent = (label !== null);
635
645
 
636
- return lemmaPresent;
646
+ return labelPresent;
637
647
  }
638
648
 
639
- isTheoremPresentByReference(reference) {
640
- const theorem = this.findTheoremByReference(reference),
641
- theoremPresent = (theorem !== null);
649
+ isLabelPresentByMetavariableNode(metavariableNode) {
650
+ const label = this.findLabelByMetavariableNode(metavariableNode),
651
+ labelPresent = (label !== null);
642
652
 
643
- return theoremPresent;
653
+ return labelPresent;
644
654
  }
645
655
 
646
- isProcedurePresentByReference(reference) {
647
- const procedure = this.findProcedureByReference(reference),
648
- procedurePresent = (procedure !== null);
656
+ isMetavariablePresentByMetavariableName(metavariableName) {
657
+ const metavariable = this.findMetavariableByMetavariableName(metavariableName),
658
+ metavariablePresent = (metavariable !== null);
649
659
 
650
- return procedurePresent;
660
+ return metavariablePresent;
651
661
  }
652
662
 
653
- isConjecturePresentByReference(reference) {
654
- const conjecture = this.findConjectureByReference(reference),
655
- conjecturePresent = (conjecture !== null);
656
-
657
- return conjecturePresent;
658
- }
663
+ isLabelPresentByReference(reference) {
664
+ const labels = this.getLabels(),
665
+ labelPresent = labels.some((label) => {
666
+ const context = this, ///
667
+ substitutions = Substitutions.fromNothing(),
668
+ labelUnified = reference.unifyLabel(label, substitutions, context);
659
669
 
660
- isAxiomLemmaTheoremConjecturePresentByReference(reference) {
661
- const axiomLemmaTheoremConjecture = this.findAxiomLemmaTheoremConjectureByReference(reference),
662
- axiomLemmaTheoremConjecturePresent = (axiomLemmaTheoremConjecture !== null);
670
+ if (labelUnified) {
671
+ return true;
672
+ }
673
+ });
663
674
 
664
- return axiomLemmaTheoremConjecturePresent;
675
+ return labelPresent;
665
676
  }
666
677
 
667
- areMetaLemmasPresentByReference(reference) {
668
- const metaLemmas = this.findMetaLemmasByReference(reference),
669
- metaLemmasLength = metaLemmas.length,
670
- metaLemmasPresent = (metaLemmasLength > 0);
678
+ isProcedurePresentByReference(reference) {
679
+ const procedure = this.findProcedureByReference(reference),
680
+ procedurePresent = (procedure !== null);
671
681
 
672
- return metaLemmasPresent;
682
+ return procedurePresent;
673
683
  }
674
684
 
675
- areMetatheoremsPresentByReference(reference) {
676
- const metatheorems = this.findMetatheoremsByReference(reference),
677
- metatheoremsLength = metatheorems.length, ///
678
- metatheoremsPresent = (metatheoremsLength > 0);
679
-
680
- return metatheoremsPresent;
681
- }
685
+ isMetavariablePresentByReference(reference) {
686
+ const metavariables = this.getMetavariables(),
687
+ metavariablePresent = metavariables.some((metavariable) => {
688
+ const context = this, ///
689
+ metavariableUnified = reference.unifyMetavariable(metavariable, context);
682
690
 
683
- areMetaLemmasMetaTheoremsPresentByReference(reference) {
684
- const metaLemmasPresent = this.areMetaLemmasPresentByReference(reference),
685
- metatheoremsPresent = this.areMetatheoremsPresentByReference(reference),
686
- metaLemmasMetaTheoremsPresent = (metaLemmasPresent || metatheoremsPresent);
691
+ if (metavariableUnified) {
692
+ return true;
693
+ }
694
+ });
687
695
 
688
- return metaLemmasMetaTheoremsPresent;
696
+ return metavariablePresent;
689
697
  }
690
698
 
691
699
  nodeAsString(node, tokens = null) {
@@ -730,54 +738,6 @@ export default class FileContext {
730
738
 
731
739
  tokensAsString(tokens) { return tokensAsString(tokens); }
732
740
 
733
- addType(type) {
734
- this.types.push(type);
735
- }
736
-
737
- addRule(rule) {
738
- this.rules.push(rule);
739
- }
740
-
741
- addAxiom(axiom) {
742
- this.axioms.push(axiom);
743
- }
744
-
745
- addLemma(lemma) {
746
- this.lemmas.push(lemma);
747
- }
748
-
749
- addTheorem(theorem) {
750
- this.theorems.push(theorem);
751
- }
752
-
753
- addVariable(variable) {
754
- this.variables.push(variable);
755
- }
756
-
757
- addMetaLemma(metaLemma) {
758
- this.metaLemmas.push(metaLemma);
759
- }
760
-
761
- addConjecture(conjecture) {
762
- this.conjectures.push(conjecture);
763
- }
764
-
765
- addCombinator(combinator) {
766
- this.combinators.push(combinator);
767
- }
768
-
769
- addConstructor(constructor) {
770
- this.constructors.push(constructor);
771
- }
772
-
773
- addMetatheorem(metatheorem) {
774
- this.metatheorems.push(metatheorem);
775
- }
776
-
777
- addMetavariable(metavariable) {
778
- this.metavariables.push(metavariable);
779
- }
780
-
781
741
  findFile(filePath) { return this.releaseContext.findFile(filePath); }
782
742
 
783
743
  trace(message) { this.releaseContext.trace(message, this.filePath); }