occam-verify-cli 0.0.1246 → 0.0.1248

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