occam-verify-cli 1.0.457 → 1.0.473

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 (161) hide show
  1. package/lib/constants.js +13 -1
  2. package/lib/context/ephemeral.js +270 -0
  3. package/lib/context/file.js +102 -66
  4. package/lib/context/liminal.js +120 -0
  5. package/lib/context/literal.js +92 -0
  6. package/lib/context/nominal.js +15 -1
  7. package/lib/context/release.js +66 -7
  8. package/lib/context/scoped.js +48 -40
  9. package/lib/context/synthetic.js +133 -0
  10. package/lib/element/assertion/contained.js +66 -66
  11. package/lib/element/assertion/defined.js +32 -32
  12. package/lib/element/assertion/property.js +39 -39
  13. package/lib/element/assertion/satisfies.js +22 -22
  14. package/lib/element/assumption.js +5 -8
  15. package/lib/element/conclusion.js +14 -13
  16. package/lib/element/constructor.js +2 -2
  17. package/lib/element/deduction.js +14 -13
  18. package/lib/element/derivation.js +3 -3
  19. package/lib/element/equality.js +5 -5
  20. package/lib/element/equivalence.js +112 -107
  21. package/lib/element/equivalences.js +24 -10
  22. package/lib/element/error.js +3 -3
  23. package/lib/element/frame.js +38 -21
  24. package/lib/element/hypothesis.js +2 -2
  25. package/lib/element/judgement.js +6 -5
  26. package/lib/element/metaType.js +1 -2
  27. package/lib/element/metavariable.js +46 -35
  28. package/lib/element/parameter.js +13 -5
  29. package/lib/element/procedureCall.js +16 -16
  30. package/lib/element/proof.js +14 -13
  31. package/lib/element/proofAssertion/premise.js +41 -30
  32. package/lib/element/proofAssertion/step.js +39 -35
  33. package/lib/element/proofAssertion/supposition.js +43 -32
  34. package/lib/element/proofAssertion.js +19 -5
  35. package/lib/element/propertyRelation.js +2 -2
  36. package/lib/element/reference.js +50 -9
  37. package/lib/element/rule.js +26 -28
  38. package/lib/element/section.js +2 -2
  39. package/lib/element/signature.js +9 -6
  40. package/lib/element/statement.js +44 -31
  41. package/lib/element/subproof.js +18 -17
  42. package/lib/element/substitution/frame.js +83 -46
  43. package/lib/element/substitution/reference.js +101 -19
  44. package/lib/element/substitution/statement.js +122 -75
  45. package/lib/element/substitution/term.js +93 -57
  46. package/lib/element/substitution.js +20 -69
  47. package/lib/element/substitutions.js +49 -34
  48. package/lib/element/term.js +30 -21
  49. package/lib/element/topLevelAssertion/axiom.js +8 -6
  50. package/lib/element/topLevelAssertion/conjecture.js +4 -4
  51. package/lib/element/topLevelAssertion/lemma.js +4 -4
  52. package/lib/element/topLevelAssertion/theorem.js +2 -2
  53. package/lib/element/topLevelAssertion.js +30 -23
  54. package/lib/element/topLevelMetaAssertion/metaLemma.js +2 -2
  55. package/lib/element/topLevelMetaAssertion/metatheorem.js +2 -2
  56. package/lib/element/topLevelMetaAssertion.js +16 -12
  57. package/lib/element/variable.js +30 -22
  58. package/lib/index.js +3 -3
  59. package/lib/main.js +3 -3
  60. package/lib/node/frame.js +2 -2
  61. package/lib/node/metavariable.js +4 -4
  62. package/lib/node/parameter.js +28 -7
  63. package/lib/node/substitution/frame.js +9 -31
  64. package/lib/node/substitution/reference.js +137 -0
  65. package/lib/node/substitution/statement.js +9 -31
  66. package/lib/node/substitution/term.js +9 -23
  67. package/lib/nonTerminalNodeMap.js +3 -2
  68. package/lib/process/instantiate.js +2 -14
  69. package/lib/process/unify.js +5 -5
  70. package/lib/tokenTypes.js +22 -0
  71. package/lib/utilities/context.js +54 -19
  72. package/lib/utilities/element.js +161 -336
  73. package/lib/utilities/instance.js +4 -4
  74. package/lib/utilities/string.js +18 -4
  75. package/lib/utilities/unification.js +24 -18
  76. package/lib/utilities/validation.js +31 -31
  77. package/package.json +2 -2
  78. package/src/constants.js +12 -0
  79. package/src/context/{transient.js → ephemeral.js} +15 -112
  80. package/src/context/file.js +66 -67
  81. package/src/context/liminal.js +67 -0
  82. package/src/context/{fragment.js → literal.js} +17 -4
  83. package/src/context/nominal.js +12 -0
  84. package/src/context/release.js +44 -6
  85. package/src/context/scoped.js +41 -31
  86. package/src/context/synthetic.js +60 -0
  87. package/src/element/assertion/contained.js +49 -47
  88. package/src/element/assertion/defined.js +29 -27
  89. package/src/element/assertion/property.js +35 -35
  90. package/src/element/assertion/satisfies.js +19 -18
  91. package/src/element/assumption.js +4 -10
  92. package/src/element/conclusion.js +16 -19
  93. package/src/element/constructor.js +1 -1
  94. package/src/element/deduction.js +16 -21
  95. package/src/element/derivation.js +2 -2
  96. package/src/element/equality.js +4 -4
  97. package/src/element/equivalence.js +115 -135
  98. package/src/element/equivalences.js +9 -7
  99. package/src/element/error.js +4 -2
  100. package/src/element/frame.js +50 -23
  101. package/src/element/hypothesis.js +1 -1
  102. package/src/element/judgement.js +9 -4
  103. package/src/element/metaType.js +0 -1
  104. package/src/element/metavariable.js +54 -53
  105. package/src/element/parameter.js +10 -5
  106. package/src/element/procedureCall.js +20 -18
  107. package/src/element/proof.js +14 -16
  108. package/src/element/proofAssertion/premise.js +46 -42
  109. package/src/element/proofAssertion/step.js +45 -40
  110. package/src/element/proofAssertion/supposition.js +56 -45
  111. package/src/element/proofAssertion.js +23 -5
  112. package/src/element/propertyRelation.js +1 -1
  113. package/src/element/reference.js +64 -16
  114. package/src/element/rule.js +31 -37
  115. package/src/element/section.js +1 -1
  116. package/src/element/signature.js +8 -8
  117. package/src/element/statement.js +51 -40
  118. package/src/element/subproof.js +16 -18
  119. package/src/element/substitution/frame.js +99 -42
  120. package/src/element/substitution/reference.js +120 -20
  121. package/src/element/substitution/statement.js +160 -89
  122. package/src/element/substitution/term.js +104 -63
  123. package/src/element/substitution.js +16 -58
  124. package/src/element/substitutions.js +43 -41
  125. package/src/element/term.js +37 -32
  126. package/src/element/topLevelAssertion/axiom.js +8 -6
  127. package/src/element/topLevelAssertion/conjecture.js +1 -2
  128. package/src/element/topLevelAssertion/lemma.js +2 -3
  129. package/src/element/topLevelAssertion/theorem.js +1 -1
  130. package/src/element/topLevelAssertion.js +31 -27
  131. package/src/element/topLevelMetaAssertion/metaLemma.js +1 -2
  132. package/src/element/topLevelMetaAssertion/metatheorem.js +1 -2
  133. package/src/element/topLevelMetaAssertion.js +15 -13
  134. package/src/element/variable.js +30 -31
  135. package/src/index.js +2 -1
  136. package/src/main.js +2 -1
  137. package/src/node/frame.js +1 -1
  138. package/src/node/metavariable.js +3 -3
  139. package/src/node/parameter.js +32 -5
  140. package/src/node/substitution/frame.js +6 -32
  141. package/src/node/substitution/reference.js +38 -0
  142. package/src/node/substitution/statement.js +6 -32
  143. package/src/node/substitution/term.js +6 -22
  144. package/src/nonTerminalNodeMap.js +3 -0
  145. package/src/process/instantiate.js +0 -8
  146. package/src/process/unify.js +4 -4
  147. package/src/tokenTypes.js +4 -0
  148. package/src/utilities/context.js +43 -17
  149. package/src/utilities/element.js +187 -401
  150. package/src/utilities/instance.js +3 -3
  151. package/src/utilities/string.js +21 -5
  152. package/src/utilities/unification.js +26 -23
  153. package/src/utilities/validation.js +47 -47
  154. package/lib/context/fragment.js +0 -77
  155. package/lib/context/transient.js +0 -371
  156. package/lib/log.js +0 -150
  157. package/lib/utilities/fragment.js +0 -23
  158. package/lib/utilities/node.js +0 -71
  159. package/src/log.js +0 -118
  160. package/src/utilities/fragment.js +0 -11
  161. package/src/utilities/node.js +0 -85
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
+ import { contextUtilities } from "occam-furtle";
4
5
 
5
6
  import elements from "../elements";
6
7
 
8
+ import { LEVELS } from "../constants";
7
9
  import { verifyFile } from "../process/verify";
8
- import { chainContext } from "../utilities/context";
9
10
  import { baseTypeFromNothing } from "../types";
10
11
  import { nodeAsString, nodesAsString } from "../utilities/node";
11
12
  import { typesFromJSON,
@@ -33,7 +34,9 @@ import { typesFromJSON,
33
34
  metatheoremsToMetatheoremsJSON,
34
35
  metavariablesToMetavariablesJSON } from "../utilities/json";
35
36
 
36
- const { push, filter } = arrayUtilities;
37
+ const { push, filter } = arrayUtilities,
38
+ { chainContext, lineIndexFromNodeAndTokens } = contextUtilities,
39
+ [ TRACE_LEVEL, DEBUG_LEVEL, INFO_LEVEL, WARNING_LEVEL, ERROR_LEVEL ] = LEVELS;
37
40
 
38
41
  export default class FileContext {
39
42
  constructor(context, filePath, lineIndex, tokens, node, types, rules, axioms, lemmas, theorems, variables, metaLemmas, conjectures, combinators, typePrefixes, constructors, metatheorems, metavariables) {
@@ -87,7 +90,7 @@ export default class FileContext {
87
90
 
88
91
  getEquivalences() {
89
92
  const { Equivalences } = elements,
90
- equivalences = Equivalences.fromNothing();
93
+ equivalences = Equivalences.fromNothing(context);
91
94
 
92
95
  return equivalences;
93
96
  }
@@ -250,12 +253,6 @@ export default class FileContext {
250
253
  return this.metavariables;
251
254
  }
252
255
 
253
- getFileContext() {
254
- const fileContext = this; ///
255
-
256
- return fileContext;
257
- }
258
-
259
256
  addType(type) {
260
257
  this.types.push(type);
261
258
  }
@@ -496,12 +493,9 @@ export default class FileContext {
496
493
  specificMetavariable = metavariable; ///
497
494
 
498
495
  metavariable = metavariables.find((metavariable) => {
499
- const generalMetavariable = metavariable; ///
500
-
501
- metavariable = specificMetavariable; ///
502
-
503
496
  const context = this, ///
504
- metavariableUnifies = generalMetavariable.unifyMetavariable(metavariable, context);
497
+ generalMetavariable = metavariable, ///
498
+ metavariableUnifies = generalMetavariable.unifyMetavariable(specificMetavariable, context);
505
499
 
506
500
  if (metavariableUnifies) {
507
501
  return true;
@@ -737,10 +731,8 @@ export default class FileContext {
737
731
  isLabelPresentByReference(reference) {
738
732
  const labels = this.getLabels(),
739
733
  labelPresent = labels.some((label) => {
740
- const { Substitutions } = elements,
741
- context = this, ///
742
- substitutions = Substitutions.fromNothing(),
743
- labelUnifies = reference.unifyLabel(label, substitutions, context);
734
+ const context = this, ///
735
+ labelUnifies = reference.unifyLabel(label, context);
744
736
 
745
737
  if (labelUnifies) {
746
738
  return true;
@@ -778,6 +770,20 @@ export default class FileContext {
778
770
  return topLevelMetaAssertionPresent;
779
771
  }
780
772
 
773
+ getFileContext() {
774
+ const fileContext = this; ///
775
+
776
+ return fileContext;
777
+ }
778
+
779
+ getDepth() {
780
+ let depth = this.context.getDepth();
781
+
782
+ depth++;
783
+
784
+ return depth;
785
+ }
786
+
781
787
  nodeAsString(node) {
782
788
  const string = nodeAsString(node, this.tokens);
783
789
 
@@ -791,33 +797,44 @@ export default class FileContext {
791
797
  }
792
798
 
793
799
  trace(message, node = null) {
794
- this.lineIndex = lineIndexFromNodeAndTokens(node, this.tokens, this.lineIndex);
800
+ const level = TRACE_LEVEL;
795
801
 
796
- this.context.trace(message, this.filePath, this.lineIndex);
802
+ this.writeToLog(level, message, node);
797
803
  }
798
804
 
799
805
  debug(message, node = null) {
800
- this.lineIndex = lineIndexFromNodeAndTokens(node, this.tokens, this.lineIndex);
806
+ const level = DEBUG_LEVEL;
801
807
 
802
- this.context.debug(message, this.filePath, this.lineIndex);
808
+ this.writeToLog(level, message, node);
803
809
  }
804
810
 
805
811
  info(message, node = null) {
806
- this.lineIndex = lineIndexFromNodeAndTokens(node, this.tokens, this.lineIndex);
812
+ const level = INFO_LEVEL;
807
813
 
808
- this.context.info(message, this.filePath, this.lineIndex);
814
+ this.writeToLog(level, message, node);
809
815
  }
810
816
 
811
817
  warning(message, node = null) {
812
- this.lineIndex = lineIndexFromNodeAndTokens(node, this.tokens, this.lineIndex);
818
+ const level = WARNING_LEVEL;
813
819
 
814
- this.context.warning(message, this.filePath, this.lineIndex);
820
+ this.writeToLog(level, message, node);
815
821
  }
816
822
 
817
823
  error(message, node = null) {
818
- this.lineIndex = lineIndexFromNodeAndTokens(node, this.tokens, this.lineIndex);
824
+ const level = ERROR_LEVEL;
819
825
 
820
- this.context.error(message, this.filePath, this.lineIndex);
826
+ this.writeToLog(level, message, node);
827
+ }
828
+
829
+ writeToLog(level, message, node) {
830
+ const lineIndex = lineIndexFromNodeAndTokens(node, this.tokens, this.lineIndex),
831
+ filePath = (lineIndex === null) ?
832
+ this.filePath :
833
+ null;
834
+
835
+ this.context.writeToLog(level, message, filePath, lineIndex);
836
+
837
+ this.lineIndex = lineIndex;
821
838
  }
822
839
 
823
840
  verify() {
@@ -835,9 +852,9 @@ export default class FileContext {
835
852
 
836
853
  verifies = verifyFile(fileNode, context);
837
854
 
838
- if (!verifies) {
839
- this.clear();
840
- }
855
+ verifies ?
856
+ this.complete() :
857
+ this.clear();
841
858
 
842
859
  if (verifies) {
843
860
  this.info(`...verified the '${this.filePath}' file.`);
@@ -847,7 +864,24 @@ export default class FileContext {
847
864
  return verifies;
848
865
  }
849
866
 
867
+ prepare() {
868
+ if (this.tokens !== null) {
869
+ return;
870
+ }
871
+
872
+ const file = this.findFile(this.filePath),
873
+ lexer = this.getLexer(),
874
+ parser = this.getParser(),
875
+ content = file.getContent();
876
+
877
+ this.tokens = lexer.tokenise(content);
878
+
879
+ this.node = parser.parse(this.tokens);
880
+ }
881
+
850
882
  clear() {
883
+ this.lineIndex = null;
884
+
851
885
  this.types = [];
852
886
  this.rules = [];
853
887
  this.axioms = [];
@@ -863,21 +897,8 @@ export default class FileContext {
863
897
  this.metavariables = [];
864
898
  }
865
899
 
866
- prepare() {
900
+ complete() {
867
901
  this.lineIndex = null;
868
-
869
- if (this.tokens !== null) {
870
- return;
871
- }
872
-
873
- const file = this.findFile(this.filePath),
874
- lexer = this.getLexer(),
875
- parser = this.getParser(),
876
- content = file.getContent();
877
-
878
- this.tokens = lexer.tokenise(content);
879
-
880
- this.node = parser.parse(this.tokens);
881
902
  }
882
903
 
883
904
  initialise(json) {
@@ -999,25 +1020,3 @@ export default class FileContext {
999
1020
  return fileContext;
1000
1021
  }
1001
1022
  }
1002
-
1003
- function lineIndexFromNodeAndTokens(node, tokens, lineIndex) {
1004
- if (node !== null) {
1005
- lineIndex = 0;
1006
-
1007
- const firstSignificantTokenIndex = node.getFirstSignificantTokenIndex(tokens);
1008
-
1009
- tokens.some((token, tokenIndex) => {
1010
- const tokenEndOfLineToken = token.isEndOfLineToken();
1011
-
1012
- if (tokenEndOfLineToken) {
1013
- lineIndex += 1;
1014
- }
1015
-
1016
- if (tokenIndex === firstSignificantTokenIndex) {
1017
- return true;
1018
- }
1019
- });
1020
- }
1021
-
1022
- return lineIndex;
1023
- }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ import { arrayUtilities } from "necessary";
4
+ import { contextUtilities } from "occam-furtle";
5
+
6
+ const { extract } = arrayUtilities,
7
+ { chainContext } = contextUtilities;
8
+
9
+ export default class LiminalContext {
10
+ constructor(context, substitutions) {
11
+ this.context = context;
12
+ this.substitutions = substitutions;
13
+
14
+ return chainContext(this);
15
+ }
16
+
17
+ getContext() {
18
+ return this.context;
19
+ }
20
+
21
+ getSubstitutions() {
22
+ let substitutions = this.context.getSubstitutions();
23
+
24
+ substitutions = [ ///
25
+ ...this.substitutions,
26
+ ...substitutions
27
+ ]
28
+
29
+ return substitutions;
30
+ }
31
+
32
+ addSubstitution(substitution) {
33
+ const context = this, ///
34
+ substitutionA = substitution, ///
35
+ substitutionString = substitution.getString();
36
+
37
+ extract(this.substitutions, (substitution) => {
38
+ const substitutionB = substitution, ///
39
+ substitutionAEqualToAssertionB = substitutionA.isEqualTo(substitutionB);
40
+
41
+ if (substitutionAEqualToAssertionB) {
42
+ return true;
43
+ }
44
+ });
45
+
46
+ context.trace(`Added the '${substitutionString}' substitution to the context.`);
47
+
48
+ this.substitutions.push(substitution);
49
+ }
50
+
51
+ getFileContext() { return this.context.getFileContext(); }
52
+
53
+ getDepth() {
54
+ let depth = this.context.getDepth();
55
+
56
+ depth++;
57
+
58
+ return depth;
59
+ }
60
+
61
+ static fromNothing(context) {
62
+ const substitutions = [],
63
+ emphemeralContext = new LiminalContext(context, substitutions);
64
+
65
+ return emphemeralContext;
66
+ }
67
+ }
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
 
3
+ import { contextUtilities } from "occam-furtle";
4
+
3
5
  import { nodeAsString } from "../utilities/node";
4
- import { chainContext } from "../utilities/context";
5
6
 
6
- export default class FragmentContext {
7
+ const { chainContext } = contextUtilities;
8
+
9
+ export default class LiteralContext {
7
10
  constructor(context, tokens) {
8
11
  this.context = context;
9
12
  this.tokens = tokens;
@@ -29,10 +32,20 @@ export default class FragmentContext {
29
32
  return string;
30
33
  }
31
34
 
35
+ getFileContext() { return this.context.getFileContext(); }
36
+
37
+ getDepth() {
38
+ let depth = this.context.getDepth();
39
+
40
+ depth++;
41
+
42
+ return depth;
43
+ }
44
+
32
45
  static fromNothing(context) {
33
46
  const tokens = null,
34
- fragmentContext = new FragmentContext(context, tokens);
47
+ literalContext = new LiteralContext(context, tokens);
35
48
 
36
- return fragmentContext;
49
+ return literalContext;
37
50
  }
38
51
  }
@@ -16,6 +16,18 @@ class NominalContext {
16
16
  return this.parser;
17
17
  }
18
18
 
19
+ getFileContext() {
20
+ const fileContext = null;
21
+
22
+ return fileContext;
23
+ }
24
+
25
+ getDepth() {
26
+ const depth = -1;
27
+
28
+ return depth;
29
+ }
30
+
19
31
  static fromNothing() {
20
32
  const lexer = nominalLexer, ///
21
33
  parser = nominalParser, ///
@@ -10,13 +10,15 @@ import FileContext from "../context/file";
10
10
  import NominalLexer from "../nominal/lexer";
11
11
  import NominalParser from "../nominal/parser";
12
12
 
13
+ import { LEVELS } from "../constants";
13
14
  import { getMetaTypes } from "../metaTypes";
14
15
  import { customGrammarFromNameAndEntries, combinedCustomGrammarFromReleaseContexts } from "../utilities/customGrammar";
15
16
 
16
17
  const { nominalLexerFromCombinedCustomGrammar } = lexersUtilities,
17
18
  { nominalParserFromCombinedCustomGrammar } = parsersUtilities,
18
19
  { tail, push, first, clear, filter, resolve, compress } = arrayUtilities,
19
- { isFilePathFurtleFilePath, isFilePathNominalFilePath } = filePathUtilities;
20
+ { isFilePathFurtleFilePath, isFilePathNominalFilePath } = filePathUtilities,
21
+ [ TRACE_LEVEL, DEBUG_LEVEL, INFO_LEVEL, WARNING_LEVEL, ERROR_LEVEL ] = LEVELS;
20
22
 
21
23
  export default class ReleaseContext {
22
24
  constructor(log, name, json, entries, lexer, parser, verified, initialised, fileContexts, customGrammar, dependencyReleaseContexts) {
@@ -430,15 +432,51 @@ export default class ReleaseContext {
430
432
 
431
433
  matchShortenedVersion(shortenedVersion) { return this.entries.matchShortenedVersion(shortenedVersion); }
432
434
 
433
- trace(message, filePath = null, lineIndex = null) { this.log.trace(message, filePath, lineIndex); }
435
+ trace(message, filePath = null, lineIndex = null) {
436
+ const level = TRACE_LEVEL;
434
437
 
435
- debug(message, filePath = null, lineIndex = null) { this.log.debug(message, filePath, lineIndex); }
438
+ this.writeToLog(level, message, filePath, lineIndex);
439
+ }
440
+
441
+ debug(message, filePath = null, lineIndex = null) {
442
+ const level = DEBUG_LEVEL
443
+
444
+ this.writeToLog(level, message, filePath, lineIndex);
445
+ }
446
+
447
+ info(message, filePath = null, lineIndex = null) {
448
+ const level = INFO_LEVEL;
436
449
 
437
- info(message, filePath = null, lineIndex = null) { this.log.info(message, filePath, lineIndex); }
450
+ this.writeToLog(level, message, filePath, lineIndex);
451
+ }
452
+
453
+ warning(message, filePath = null, lineIndex = null) {
454
+ const level = WARNING_LEVEL;
438
455
 
439
- warning(message, filePath = null, lineIndex = null) { this.log.warning(message, filePath, lineIndex); }
456
+ this.writeToLog(level, message, filePath, lineIndex);
457
+ }
440
458
 
441
- error(message, filePath = null, lineIndex = null) { this.log.error(message, filePath, lineIndex); }
459
+ error(message, filePath = null, lineIndex = null) {
460
+ const level = ERROR_LEVEL;
461
+
462
+ this.writeToLog(level, message, filePath, lineIndex);
463
+ }
464
+
465
+ writeToLog(level, message, filePath, lineIndex) {
466
+ this.log.write(level, message, filePath, lineIndex);
467
+ }
468
+
469
+ getFileContext() {
470
+ const fileContext = null;
471
+
472
+ return fileContext;
473
+ }
474
+
475
+ getDepth() {
476
+ const depth = -1;
477
+
478
+ return depth;
479
+ }
442
480
 
443
481
  initialise(releaseContexts) {
444
482
  const combinedCustomGrammar = combinedCustomGrammarFromReleaseContexts(releaseContexts),
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
+ import { contextUtilities } from "occam-furtle";
4
5
 
5
6
  import elements from "../elements";
6
7
 
7
- import { chainContext } from "../utilities/context";
8
-
9
- const { last } = arrayUtilities;
8
+ const { last } = arrayUtilities,
9
+ { chainContext } = contextUtilities;
10
10
 
11
11
  class ScopedContext {
12
12
  constructor(context, variables, judgements, equivalences, subproofOrProofAssertions) {
@@ -54,7 +54,9 @@ class ScopedContext {
54
54
  getEquivalences() {
55
55
  let equivalences = this.context.getEquivalences();
56
56
 
57
- equivalences = this.equivalences.mergedWith(equivalences); ///
57
+ const context = this; ///
58
+
59
+ equivalences = this.equivalences.mergedWith(equivalences, context); ///
58
60
 
59
61
  return equivalences;
60
62
  }
@@ -169,18 +171,7 @@ class ScopedContext {
169
171
  this.subproofOrProofAssertions.push(subproofOrProofAssertion);
170
172
  }
171
173
 
172
- findVariableByVariableIdentifier(variableIdentifier, nested = true) {
173
- const variables = this.getVariables(nested),
174
- variable = variables.find((variable) => {
175
- const variableComparesToVariableIdentifier = variable.compareVariableIdentifier(variableIdentifier);
176
-
177
- if (variableComparesToVariableIdentifier) {
178
- return true;
179
- }
180
- }) || null;
181
-
182
- return variable;
183
- }
174
+ findEquivalenceByTerm(term) { return this.equivalences.findEquivalenceByTerm(term); }
184
175
 
185
176
  findJudgementByMetavariable(metavariable) {
186
177
  const judgements = this.getJudgements(),
@@ -200,22 +191,17 @@ class ScopedContext {
200
191
  return judgement;
201
192
  }
202
193
 
203
- findEquivalenceByTerm(term) { return this.equivalences.findEquivalenceByTerm(term); }
204
-
205
- isTypePresentByTypeName(typeName, includeRelease = true, includeDependencies = true) { return this.context.isTypePresentByTypeName(typeName, includeRelease, includeDependencies); }
206
-
207
- isVariablePresentByVariableIdentifier(variableIdentifier, nested = true) {
208
- const variable = this.findVariableByVariableIdentifier(variableIdentifier, nested),
209
- variablePresent = (variable !== null);
210
-
211
- return variablePresent;
212
- }
194
+ findVariableByVariableIdentifier(variableIdentifier, nested = true) {
195
+ const variables = this.getVariables(nested),
196
+ variable = variables.find((variable) => {
197
+ const variableComparesToVariableIdentifier = variable.compareVariableIdentifier(variableIdentifier);
213
198
 
214
- isJudgementPresentByMetavariable(metavariable) {
215
- const judgement = this.findJudgementByMetavariable(metavariable),
216
- judgementPresent = (judgement !== null);
199
+ if (variableComparesToVariableIdentifier) {
200
+ return true;
201
+ }
202
+ }) || null;
217
203
 
218
- return judgementPresent;
204
+ return variable;
219
205
  }
220
206
 
221
207
  isTermGrounded(term) {
@@ -266,6 +252,20 @@ class ScopedContext {
266
252
  return metavariableDefined
267
253
  }
268
254
 
255
+ isJudgementPresentByMetavariable(metavariable) {
256
+ const judgement = this.findJudgementByMetavariable(metavariable),
257
+ judgementPresent = (judgement !== null);
258
+
259
+ return judgementPresent;
260
+ }
261
+
262
+ isVariablePresentByVariableIdentifier(variableIdentifier, nested = true) {
263
+ const variable = this.findVariableByVariableIdentifier(variableIdentifier, nested),
264
+ variablePresent = (variable !== null);
265
+
266
+ return variablePresent;
267
+ }
268
+
269
269
  compareTermAndPropertyRelation(term, propertyRelation) {
270
270
  const context = this, ///
271
271
  proofAssertions = this.getProofAssertions(),
@@ -280,11 +280,21 @@ class ScopedContext {
280
280
  return comparesToTermAndPropertyRelation;
281
281
  }
282
282
 
283
+ getFileContext() { return this.context.getFileContext(); }
284
+
285
+ getDepth() {
286
+ let depth = this.context.getDepth();
287
+
288
+ depth++;
289
+
290
+ return depth;
291
+ }
292
+
283
293
  static fromNothing(context) {
284
294
  const { Equivalences } = elements,
285
295
  variables = [],
286
296
  judgements = [],
287
- equivalences = Equivalences.fromNothing(),
297
+ equivalences = Equivalences.fromNothing(context),
288
298
  subproofOrProofAssertions = [],
289
299
  scopedContext = new ScopedContext(context, variables, judgements, equivalences, subproofOrProofAssertions);
290
300
 
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ import { contextUtilities } from "occam-furtle";
4
+
5
+ const { chainContext } = contextUtilities;
6
+
7
+ export default class SyntheticContext {
8
+ constructor(context, generalContext, specificContext) {
9
+ this.context = context;
10
+ this.generalContext = generalContext;
11
+ this.specificContext = specificContext;
12
+
13
+ return chainContext(this);
14
+ }
15
+
16
+ getContext() {
17
+ return this.context;
18
+ }
19
+
20
+ getGeneralContext() {
21
+ return this.generalContext;
22
+ }
23
+
24
+ getSpecificContext() {
25
+ return this.specificContext;
26
+ }
27
+
28
+ findTermByTermNode(termNode) { return this.specificContext.findTermByTermNode(termNode); }
29
+
30
+ findFrameByFrameNode(frameNode) { return this.specificContext.findFrameByFrameNode(frameNode); }
31
+
32
+ findTypeByNominalTypeName(nominalTypeName) { return this.specificContext.findTypeByNominalTypeName(nominalTypeName); }
33
+
34
+ isTypePresentByNominalTypeName(nominalTypeName) { return this.specificContext.isTypePresentByNominalTypeName(nominalTypeName); }
35
+
36
+ findVariableByVariableIdentifier(variableIdentifier) { return this.generalContext.findVariableByVariableIdentifier(variableIdentifier); }
37
+
38
+ findMetavariableByMetavariableName(metavariableName) { return this.generalContext.findMetavariableByMetavariableName(metavariableName); }
39
+
40
+ isVariablePresentByVariableIdentifier(variableIdentifier) { this.generalContext.isVariablePresentByVariableIdentifier(variableIdentifier); }
41
+
42
+ isMetavariablePresentByMetavariableName(metavariableName) { this.generalContext.isMetavariablePresentByMetavariableName(metavariableName); }
43
+
44
+ getFileContext() { return this.context.getFileContext(); }
45
+
46
+ getDepth() {
47
+ let depth = this.context.getDepth();
48
+
49
+ depth++;
50
+
51
+ return depth;
52
+ }
53
+
54
+ static fromNothing(generalContext, specificContext) {
55
+ const context = specificContext, ///
56
+ syntheticContext = new SyntheticContext(context, generalContext, specificContext);
57
+
58
+ return syntheticContext;
59
+ }
60
+ }