occam-verify-cli 0.0.526 → 0.0.529

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 (221) hide show
  1. package/README.md +4 -0
  2. package/bin/abbreviations.js +5 -1
  3. package/bin/action/help.js +4 -0
  4. package/bin/action/verify.js +35 -13
  5. package/bin/actions.js +11 -6
  6. package/bin/defaults.js +4 -0
  7. package/bin/options.js +4 -0
  8. package/bin/utilities/releaseContext.js +5 -7
  9. package/lib/assertion/type.js +10 -40
  10. package/lib/axiom.js +8 -8
  11. package/lib/axiomLemmaTheoremConjecture.js +190 -0
  12. package/lib/combinator.js +4 -3
  13. package/lib/conclusion.js +8 -7
  14. package/lib/conjecture.js +141 -0
  15. package/lib/consequence.js +6 -5
  16. package/lib/constants.js +11 -27
  17. package/lib/constructor.js +5 -4
  18. package/lib/context/file.js +88 -73
  19. package/lib/context/metaproof.js +51 -20
  20. package/lib/context/proof.js +48 -114
  21. package/lib/context/release/directory.js +25 -6
  22. package/lib/context/release/file.js +38 -25
  23. package/lib/context/release.js +32 -51
  24. package/lib/equality.js +79 -51
  25. package/lib/index.js +4 -16
  26. package/lib/kinds.js +5 -1
  27. package/lib/label.js +4 -3
  28. package/lib/lemma.js +8 -8
  29. package/lib/log.js +146 -0
  30. package/lib/matcher.js +25 -75
  31. package/lib/metaTypeNames.js +13 -0
  32. package/lib/mixins/file.js +62 -2
  33. package/lib/mixins/logging.js +13 -13
  34. package/lib/node/metastatement/bracketed.js +16 -0
  35. package/lib/node/statement/bracketed.js +16 -0
  36. package/lib/node/statement/combinator/bracketed.js +17 -0
  37. package/lib/node/statement/combinator/equality.js +17 -0
  38. package/lib/node/statement/equality.js +16 -0
  39. package/lib/ocmbinator/bracketed.js +3 -4
  40. package/lib/ocmbinator/equality.js +3 -4
  41. package/lib/premise.js +13 -12
  42. package/lib/rule.js +5 -5
  43. package/lib/ruleNames.js +1 -9
  44. package/lib/step/metaproof.js +28 -25
  45. package/lib/step/proof.js +23 -1
  46. package/lib/substitution/metastatementForMetavariable.js +16 -13
  47. package/lib/substitution/statementForMetavariable.js +16 -13
  48. package/lib/substitution/termForVariable.js +76 -0
  49. package/lib/supposition.js +7 -6
  50. package/lib/theorem.js +8 -8
  51. package/lib/type.js +12 -5
  52. package/lib/utilities/metaproof.js +60 -0
  53. package/lib/utilities/node.js +56 -0
  54. package/lib/utilities/proof.js +60 -0
  55. package/lib/utilities/releaseContext.js +24 -12
  56. package/lib/utilities/string.js +3 -38
  57. package/lib/variable.js +4 -38
  58. package/lib/{matcher → verifier}/metastatementForMetavariable/conclusion.js +12 -12
  59. package/lib/{matcher → verifier}/metastatementForMetavariable/premise.js +12 -12
  60. package/lib/verifier/metastatementForMetavariable.js +198 -0
  61. package/lib/{matcher → verifier}/statementForMetavariable/conclusion.js +12 -12
  62. package/lib/{matcher → verifier}/statementForMetavariable/premise.js +12 -12
  63. package/lib/verifier/statementForMetavariable.js +203 -0
  64. package/lib/{matcher/statementForVariable → verifier/termForVariable}/consequence.js +13 -13
  65. package/lib/{matcher/statementForVariable → verifier/termForVariable}/supposition.js +13 -13
  66. package/lib/verifier/termForVariable.js +198 -0
  67. package/lib/verifier.js +92 -0
  68. package/lib/verify/assertion/type.js +62 -41
  69. package/lib/verify/axiom.js +3 -6
  70. package/lib/verify/conclusion.js +2 -4
  71. package/lib/verify/conjecture.js +54 -0
  72. package/lib/verify/consequence.js +2 -4
  73. package/lib/verify/declaration/combinator.js +1 -3
  74. package/lib/verify/declaration/constructor.js +1 -3
  75. package/lib/verify/declaration/topLevel.js +7 -5
  76. package/lib/verify/declaration/type.js +1 -3
  77. package/lib/verify/declaration/variable.js +1 -3
  78. package/lib/verify/derivation.js +1 -5
  79. package/lib/verify/label.js +1 -3
  80. package/lib/verify/lemma.js +3 -6
  81. package/lib/verify/metastatement/qualified.js +2 -5
  82. package/lib/verify/metastatement/unqualified.js +2 -5
  83. package/lib/verify/metastatement.js +1 -3
  84. package/lib/verify/premise.js +2 -4
  85. package/lib/verify/proof.js +3 -5
  86. package/lib/verify/rule.js +3 -6
  87. package/lib/verify/ruleDerivation.js +1 -5
  88. package/lib/verify/ruleProof.js +3 -5
  89. package/lib/verify/statement/qualified.js +40 -13
  90. package/lib/verify/statement/unqualified.js +2 -5
  91. package/lib/verify/statement.js +56 -62
  92. package/lib/verify/statementAsCombinator.js +4 -6
  93. package/lib/verify/supposition.js +2 -4
  94. package/lib/verify/term.js +4 -10
  95. package/lib/verify/termAsConstructor.js +6 -9
  96. package/lib/verify/theorem.js +3 -6
  97. package/lib/verify/type.js +5 -9
  98. package/lib/verify/variable.js +5 -9
  99. package/package.json +1 -1
  100. package/src/assertion/type.js +7 -32
  101. package/src/axiom.js +4 -4
  102. package/src/{axiomLemmaTheorem.js → axiomLemmaTheoremConjecture.js} +9 -9
  103. package/src/combinator.js +3 -3
  104. package/src/conclusion.js +7 -7
  105. package/src/conjecture.js +13 -0
  106. package/src/consequence.js +5 -5
  107. package/src/constants.js +3 -7
  108. package/src/constructor.js +4 -4
  109. package/src/context/file.js +85 -65
  110. package/src/context/metaproof.js +55 -15
  111. package/src/context/proof.js +53 -50
  112. package/src/context/release/directory.js +31 -7
  113. package/src/context/release/file.js +47 -31
  114. package/src/context/release.js +23 -32
  115. package/src/equality.js +108 -61
  116. package/src/index.js +2 -4
  117. package/src/kinds.js +1 -0
  118. package/src/label.js +3 -3
  119. package/src/lemma.js +4 -4
  120. package/src/log.js +116 -0
  121. package/src/matcher.js +32 -24
  122. package/src/metaTypeNames.js +3 -0
  123. package/src/mixins/file.js +46 -1
  124. package/src/mixins/logging.js +6 -6
  125. package/src/node/metastatement/bracketed.js +9 -0
  126. package/src/node/statement/bracketed.js +9 -0
  127. package/src/node/statement/combinator/bracketed.js +10 -0
  128. package/src/node/statement/combinator/equality.js +11 -0
  129. package/src/node/statement/equality.js +10 -0
  130. package/src/ocmbinator/bracketed.js +2 -5
  131. package/src/ocmbinator/equality.js +2 -5
  132. package/src/premise.js +13 -13
  133. package/src/rule.js +4 -4
  134. package/src/ruleNames.js +0 -2
  135. package/src/step/metaproof.js +32 -29
  136. package/src/step/proof.js +28 -0
  137. package/src/substitution/metastatementForMetavariable.js +10 -15
  138. package/src/substitution/statementForMetavariable.js +11 -16
  139. package/src/substitution/termForVariable.js +36 -0
  140. package/src/supposition.js +6 -6
  141. package/src/theorem.js +4 -4
  142. package/src/type.js +17 -7
  143. package/src/utilities/metaproof.js +62 -0
  144. package/src/utilities/node.js +73 -0
  145. package/src/utilities/proof.js +62 -0
  146. package/src/utilities/releaseContext.js +30 -12
  147. package/src/utilities/string.js +4 -53
  148. package/src/variable.js +4 -37
  149. package/src/verifier/metastatementForMetavariable/conclusion.js +9 -0
  150. package/src/verifier/metastatementForMetavariable/premise.js +9 -0
  151. package/src/verifier/metastatementForMetavariable.js +89 -0
  152. package/src/verifier/statementForMetavariable/conclusion.js +9 -0
  153. package/src/verifier/statementForMetavariable/premise.js +9 -0
  154. package/src/verifier/statementForMetavariable.js +105 -0
  155. package/src/verifier/termForVariable/consequence.js +9 -0
  156. package/src/verifier/termForVariable/supposition.js +9 -0
  157. package/src/verifier/termForVariable.js +89 -0
  158. package/src/verifier.js +74 -0
  159. package/src/verify/assertion/type.js +74 -74
  160. package/src/verify/axiom.js +2 -9
  161. package/src/verify/conclusion.js +1 -7
  162. package/src/verify/conjecture.js +67 -0
  163. package/src/verify/consequence.js +1 -7
  164. package/src/verify/declaration/combinator.js +0 -6
  165. package/src/verify/declaration/constructor.js +0 -6
  166. package/src/verify/declaration/topLevel.js +7 -6
  167. package/src/verify/declaration/type.js +0 -6
  168. package/src/verify/declaration/variable.js +0 -6
  169. package/src/verify/derivation.js +0 -12
  170. package/src/verify/label.js +0 -6
  171. package/src/verify/lemma.js +4 -11
  172. package/src/verify/metastatement/qualified.js +1 -8
  173. package/src/verify/metastatement/unqualified.js +1 -8
  174. package/src/verify/metastatement.js +0 -6
  175. package/src/verify/premise.js +1 -7
  176. package/src/verify/proof.js +1 -7
  177. package/src/verify/rule.js +2 -9
  178. package/src/verify/ruleDerivation.js +0 -12
  179. package/src/verify/ruleProof.js +1 -7
  180. package/src/verify/statement/qualified.js +54 -20
  181. package/src/verify/statement/unqualified.js +1 -8
  182. package/src/verify/statement.js +65 -95
  183. package/src/verify/statementAsCombinator.js +3 -9
  184. package/src/verify/supposition.js +1 -7
  185. package/src/verify/term.js +3 -21
  186. package/src/verify/termAsConstructor.js +5 -13
  187. package/src/verify/theorem.js +2 -9
  188. package/src/verify/type.js +4 -13
  189. package/src/verify/variable.js +4 -13
  190. package/bin/callbacks.js +0 -48
  191. package/lib/axiomLemmaTheorem.js +0 -190
  192. package/lib/callbacks.js +0 -75
  193. package/lib/context/release/combinator.js +0 -64
  194. package/lib/jsonTypes.js +0 -30
  195. package/lib/matcher/metastatementForMetavariable.js +0 -201
  196. package/lib/matcher/statementForMetavariable.js +0 -201
  197. package/lib/matcher/statementForVariable.js +0 -201
  198. package/lib/mixins/callbacks.js +0 -27
  199. package/lib/substitution/statementForVariable.js +0 -86
  200. package/lib/utilities/json.js +0 -187
  201. package/lib/utilities/substitution.js +0 -61
  202. package/lib/utilities/version.js +0 -32
  203. package/lib/versionChanges.js +0 -34
  204. package/src/callbacks.js +0 -39
  205. package/src/context/release/combinator.js +0 -39
  206. package/src/jsonTypes.js +0 -6
  207. package/src/matcher/metastatementForMetavariable/conclusion.js +0 -9
  208. package/src/matcher/metastatementForMetavariable/premise.js +0 -9
  209. package/src/matcher/metastatementForMetavariable.js +0 -99
  210. package/src/matcher/statementForMetavariable/conclusion.js +0 -9
  211. package/src/matcher/statementForMetavariable/premise.js +0 -9
  212. package/src/matcher/statementForMetavariable.js +0 -99
  213. package/src/matcher/statementForVariable/consequence.js +0 -9
  214. package/src/matcher/statementForVariable/supposition.js +0 -9
  215. package/src/matcher/statementForVariable.js +0 -99
  216. package/src/mixins/callbacks.js +0 -15
  217. package/src/substitution/statementForVariable.js +0 -64
  218. package/src/utilities/json.js +0 -264
  219. package/src/utilities/substitution.js +0 -79
  220. package/src/utilities/version.js +0 -30
  221. package/src/versionChanges.js +0 -11
@@ -7,7 +7,7 @@ import Consequence from "./consequence";
7
7
  import { prune } from "./utilities/array";
8
8
  import { someSubArray } from "./utilities/array";
9
9
 
10
- export default class AxiomLemmaTheorem {
10
+ export default class AxiomLemmaTheoremConjecture {
11
11
  constructor(labels, suppositions, consequence) {
12
12
  this.labels = labels;
13
13
  this.suppositions = suppositions;
@@ -90,14 +90,14 @@ export default class AxiomLemmaTheorem {
90
90
  return json;
91
91
  }
92
92
 
93
- static fromJSON(Class, json, releaseContext) {
93
+ static fromJSON(Class, json, lexer, parser) {
94
94
  let { labels } = json;
95
95
 
96
96
  const labelsJSON = labels; ///
97
97
 
98
98
  labels = labelsJSON.map((labelJSON) => {
99
99
  const json = labelJSON, ///
100
- label = Label.fromJSON(json, releaseContext);
100
+ label = Label.fromJSON(json, lexer, parser);
101
101
 
102
102
  return label;
103
103
  });
@@ -108,7 +108,7 @@ export default class AxiomLemmaTheorem {
108
108
 
109
109
  suppositions = suppositionsJSON.map((suppositionJSON) => {
110
110
  const json = suppositionJSON, ///
111
- supposition = Supposition.fromJSON(json, releaseContext);
111
+ supposition = Supposition.fromJSON(json, lexer, parser);
112
112
 
113
113
  return supposition;
114
114
  });
@@ -119,7 +119,7 @@ export default class AxiomLemmaTheorem {
119
119
 
120
120
  json = consequenceJSON; ///
121
121
 
122
- consequence = Consequence.fromJSON(json, releaseContext);
122
+ consequence = Consequence.fromJSON(json, lexer, parser);
123
123
 
124
124
  return new Class(labels, suppositions, consequence); ///
125
125
  }
@@ -156,7 +156,7 @@ function matchSupposition(supposition, proofSteps, substitutions) {
156
156
  }
157
157
 
158
158
  function matchSuppositions(supposition, proofSteps, substitutions) {
159
- const suppositionsMatches = supposition.every((supposition) => {
159
+ const suppositionsMatch = supposition.every((supposition) => {
160
160
  const suppositionMatches = matchSupposition(supposition, proofSteps, substitutions);
161
161
 
162
162
  if (suppositionMatches) {
@@ -164,7 +164,7 @@ function matchSuppositions(supposition, proofSteps, substitutions) {
164
164
  }
165
165
  });
166
166
 
167
- return suppositionsMatches;
167
+ return suppositionsMatch;
168
168
  }
169
169
 
170
170
  function matchConsequence(consequence, statementNode, substitutions) {
@@ -178,9 +178,9 @@ function matchSuppositionsAndConsequence(suppositions, consequence, proofSteps,
178
178
  let suppositionsMatchConsequence = false;
179
179
 
180
180
  const substitutions = [],
181
- suppositionsMatches = matchSuppositions(suppositions, proofSteps, substitutions);
181
+ suppositionsMatch = matchSuppositions(suppositions, proofSteps, substitutions);
182
182
 
183
- if (suppositionsMatches) {
183
+ if (suppositionsMatch) {
184
184
  const consequenceMatches = matchConsequence(consequence, statementNode, substitutions);
185
185
 
186
186
  suppositionsMatchConsequence = consequenceMatches; ///
package/src/combinator.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { nodeAsString } from "./utilities/string";
4
4
  import { COMBINATOR_KIND } from "./kinds";
5
- import { statementNodeFromStatementString } from "./utilities/string";
5
+ import { statementNodeFromStatementString } from "./utilities/node";
6
6
 
7
7
  export default class Combinator {
8
8
  constructor(statementNode) {
@@ -35,10 +35,10 @@ export default class Combinator {
35
35
  return json;
36
36
  }
37
37
 
38
- static fromJSON(json, releaseContext) {
38
+ static fromJSON(json, lexer, parser) {
39
39
  const { statement } = json,
40
40
  statementString = statement, ///
41
- statementNode = statementNodeFromStatementString(statementString, releaseContext),
41
+ statementNode = statementNodeFromStatementString(statementString, lexer, parser),
42
42
  combinator = new Combinator(statementNode);
43
43
 
44
44
  return combinator;
package/src/conclusion.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  import { nodeAsString } from "./utilities/string";
4
- import { metastatementNodeFromMetastatementString } from "./utilities/string";
5
- import { conclusionStatementForMetavariableMatcher } from "./matcher/statementForMetavariable/conclusion";
6
- import { conclusionMetastatementForMetavariableMatcher } from "./matcher/metastatementForMetavariable/conclusion";
4
+ import { metastatementNodeFromMetastatementString } from "./utilities/node";
5
+ import { conclusionStatementForMetavariableVerifier } from "./verifier/statementForMetavariable/conclusion";
6
+ import { conclusionMetastatementForMetavariableVerifier } from "./verifier/metastatementForMetavariable/conclusion";
7
7
 
8
8
  export default class Conclusion {
9
9
  constructor(metastatementNode) {
@@ -17,7 +17,7 @@ export default class Conclusion {
17
17
  matchStatementNode(statementNode, substitutions) {
18
18
  const nonTerminalNodeA = this.metastatementNode, ///
19
19
  nonTerminalNodeB = statementNode, ///
20
- nonTerminalNodeMatches = conclusionStatementForMetavariableMatcher.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions),
20
+ nonTerminalNodeMatches = conclusionStatementForMetavariableVerifier.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions),
21
21
  statementNodeMatches = nonTerminalNodeMatches; ///
22
22
 
23
23
  return statementNodeMatches;
@@ -26,7 +26,7 @@ export default class Conclusion {
26
26
  matchMetastatementNode(metastatementNode, substitutions) {
27
27
  const nonTerminalNodeA = this.metastatementNode, ///
28
28
  nonTerminalNodeB = metastatementNode, ///
29
- nonTerminalNodeMatches = conclusionMetastatementForMetavariableMatcher.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions),
29
+ nonTerminalNodeMatches = conclusionMetastatementForMetavariableVerifier.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions),
30
30
  metastatementNodeMatches = nonTerminalNodeMatches; ///
31
31
 
32
32
  return metastatementNodeMatches;
@@ -42,10 +42,10 @@ export default class Conclusion {
42
42
  return json;
43
43
  }
44
44
 
45
- static fromJSON(json, releaseContext) {
45
+ static fromJSON(json, lexer, parser) {
46
46
  const { metastatement } = json,
47
47
  metastatementString = metastatement, ///
48
- metastatementNode = metastatementNodeFromMetastatementString(metastatementString, releaseContext),
48
+ metastatementNode = metastatementNodeFromMetastatementString(metastatementString, lexer, parser),
49
49
  conclusion = new Conclusion(metastatementNode);
50
50
 
51
51
  return conclusion;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ import AxiomLemmaTheoremConjecture from "./axiomLemmaTheoremConjecture";
4
+
5
+ import { CONJECTURE_KIND } from "./kinds";
6
+
7
+ export default class Conjecture extends AxiomLemmaTheoremConjecture {
8
+ static kind = CONJECTURE_KIND;
9
+
10
+ static fromJSON(json, lexer, parser) { return AxiomLemmaTheoremConjecture.fromJSON(Conjecture, json, lexer, parser); }
11
+
12
+ static fromLabelsSuppositionsAndConsequence(labels, suppositions, consequence) { return AxiomLemmaTheoremConjecture.fromLabelsSuppositionsAndConsequence(Conjecture, labels, suppositions, consequence); }
13
+ }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  import { nodeAsString } from "./utilities/string";
4
- import { statementNodeFromStatementString } from "./utilities/string";
5
- import { consequenceStatementForVariableMatcher } from "./matcher/statementForVariable/consequence";
4
+ import { statementNodeFromStatementString } from "./utilities/node";
5
+ import { consequenceTermForVariableVerifier } from "./verifier/termForVariable/consequence";
6
6
 
7
7
  export default class Consequence {
8
8
  constructor(statementNode) {
@@ -16,7 +16,7 @@ export default class Consequence {
16
16
  matchStatementNode(statementNode, substitutions) {
17
17
  const nonTerminalNodeA = this.statementNode, ///
18
18
  nonTerminalNodeB = statementNode, ///
19
- nonTerminalNodeMatches = consequenceStatementForVariableMatcher.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions),
19
+ nonTerminalNodeMatches = consequenceTermForVariableVerifier.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions),
20
20
  statementNodeMatches = nonTerminalNodeMatches; ///
21
21
 
22
22
  return statementNodeMatches;
@@ -32,10 +32,10 @@ export default class Consequence {
32
32
  return json;
33
33
  }
34
34
 
35
- static fromJSON(json, releaseContext) {
35
+ static fromJSON(json, lexer, parser) {
36
36
  const { statement } = json,
37
37
  statementString = statement, ///
38
- statementNode = statementNodeFromStatementString(statementString, releaseContext),
38
+ statementNode = statementNodeFromStatementString(statementString, lexer, parser),
39
39
  consequence = new Consequence(statementNode);
40
40
 
41
41
  return consequence;
package/src/constants.js CHANGED
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  export const COMMA = ',';
4
- export const STRING = "string";
5
- export const NUMBER = "number";
6
- export const BOOLEAN = "boolean";
7
4
  export const EMPTY_STRING = "";
8
- export const LEFT_BRACKET = "(";
9
- export const RIGHT_BRACKET = ")";
10
- export const EQUALS_CHARACTER = "=";
5
+ export const EQUALITY_DEPTH = 2;
11
6
  export const MAXIMUM_INDEXES_LENGTH = 10;
7
+ export const BRACKETED_STATEMENT_DEPTH = 2;
12
8
  export const MAXIMUM_PERMUTATION_LENGTH = 5;
13
- export const BRACKETED_CHILD_NODES_LENGTH = 3;
9
+ export const BRACKETED_METASTATEMENT_DEPTH = 1;
@@ -4,7 +4,7 @@ import Type from "./type";
4
4
 
5
5
  import { nodeAsString } from "./utilities/string";
6
6
  import { CONSTRUCTOR_KIND } from "./kinds";
7
- import { termNodeFromTermString } from "./utilities/string";
7
+ import { termNodeFromTermString } from "./utilities/node";
8
8
 
9
9
  export default class Constructor {
10
10
  constructor(termNode, type) {
@@ -54,10 +54,10 @@ export default class Constructor {
54
54
  return json;
55
55
  }
56
56
 
57
- static fromJSON(json, releaseContext) {
57
+ static fromJSON(json, lexer, parser) {
58
58
  const { term } = json,
59
59
  termString = term, ///
60
- termNode = termNodeFromTermString(termString, releaseContext);
60
+ termNode = termNodeFromTermString(termString, lexer, parser);
61
61
 
62
62
  let { type } = json;
63
63
 
@@ -66,7 +66,7 @@ export default class Constructor {
66
66
 
67
67
  json = typeJSON; ///
68
68
 
69
- type = Type.fromJSON(json, releaseContext);
69
+ type = Type.fromJSON(json, lexer, parser);
70
70
 
71
71
  const typeName = type.getName();
72
72
 
@@ -4,10 +4,9 @@ import { rewriteNodes } from "occam-grammar-utilities";
4
4
 
5
5
  import { push } from "../utilities/array";
6
6
  import { nodeAsString, nodesAsString } from "../utilities/string";
7
- import { leastLineIndexFromNodeAndTokens, greatestLineIndexFromNodeAndTokens } from "../utilities/tokens";
8
7
 
9
8
  export default class FileContext {
10
- constructor(releaseContext, filePath, tokens, node, types, rules, axioms, lemmas, theorems, variables, combinators, constructors) {
9
+ constructor(releaseContext, filePath, tokens, node, types, rules, axioms, lemmas, theorems, conjectures, combinators, constructors, variables, metavariables) {
11
10
  this.releaseContext = releaseContext;
12
11
  this.filePath = filePath;
13
12
  this.tokens = tokens;
@@ -17,9 +16,11 @@ export default class FileContext {
17
16
  this.axioms = axioms;
18
17
  this.lemmas = lemmas;
19
18
  this.theorems = theorems;
20
- this.variables = variables;
19
+ this.conjectures = conjectures;
21
20
  this.combinators = combinators;
22
21
  this.constructors = constructors;
22
+ this.variables = variables;
23
+ this.metavariables = metavariables;
23
24
  }
24
25
 
25
26
  getReleaseContext() {
@@ -38,8 +39,16 @@ export default class FileContext {
38
39
  return this.node;
39
40
  }
40
41
 
41
- getVariables() {
42
- return this.variables;
42
+ getProofSteps() {
43
+ const proofSteps = []; ///
44
+
45
+ return proofSteps;
46
+ }
47
+
48
+ getMetaproofSteps() {
49
+ const metaproofSteps = []; ///
50
+
51
+ return metaproofSteps;
43
52
  }
44
53
 
45
54
  getLabels(includeRelease = true) {
@@ -148,6 +157,20 @@ export default class FileContext {
148
157
  return theorems;
149
158
  }
150
159
 
160
+ getConjectures(includeRelease = true) {
161
+ const conjectures = [];
162
+
163
+ push(conjectures, this.conjectures);
164
+
165
+ if (includeRelease) {
166
+ const releaseContextConjectures = this.releaseContext.getConjectures();
167
+
168
+ push(conjectures, releaseContextConjectures);
169
+ }
170
+
171
+ return conjectures;
172
+ }
173
+
151
174
  getCombinators(includeRelease = true) {
152
175
  const combinators = [];
153
176
 
@@ -176,16 +199,12 @@ export default class FileContext {
176
199
  return constructors;
177
200
  }
178
201
 
179
- getProofSteps() {
180
- const proofSteps = []; ///
181
-
182
- return proofSteps;
202
+ getVariables() {
203
+ return this.variables;
183
204
  }
184
205
 
185
- getMetaproofSteps() {
186
- const metaproofSteps = []; ///
187
-
188
- return metaproofSteps;
206
+ getMetavariables() {
207
+ return this.metavariables;
189
208
  }
190
209
 
191
210
  findTypeByTypeName(typeName) {
@@ -271,18 +290,25 @@ export default class FileContext {
271
290
  return theorem;
272
291
  }
273
292
 
274
- findVariableByVariableName(variableName) {
275
- const name = variableName, ///
276
- variables = this.getVariables(),
277
- variable = variables.find((variable) => {
278
- const matches = variable.matchName(name);
293
+ findConjectureByReferenceName(referenceName) {
294
+ const labelName = referenceName, ///
295
+ conjectures = this.getConjectures(),
296
+ conjecture = conjectures.find((conjecture) => {
297
+ const conjectureMatchesLabelName = conjecture.matchLabelName(labelName);
279
298
 
280
- if (matches) {
299
+ if (conjectureMatchesLabelName) {
281
300
  return true;
282
301
  }
283
302
  }) || null;
284
303
 
285
- return variable;
304
+ return conjecture;
305
+ }
306
+
307
+ isLabelPresentByLabelName(labelName) {
308
+ const label = this.findLabelByLabelName(labelName),
309
+ labelPresent = (label !== null);
310
+
311
+ return labelPresent;
286
312
  }
287
313
 
288
314
  isTypePresentByTypeName(typeName) {
@@ -292,11 +318,30 @@ export default class FileContext {
292
318
  return typePresent;
293
319
  }
294
320
 
295
- isLabelPresentByLabelName(labelName) {
296
- const label = this.findLabelByLabelName(labelName),
297
- labelPresent = (label !== null);
321
+ nodeAsString(node) {
322
+ const string = nodeAsString(node, this.tokens);
298
323
 
299
- return labelPresent;
324
+ return string;
325
+ }
326
+
327
+ nodesAsString(node) {
328
+ const string = nodesAsString(node, this.tokens);
329
+
330
+ return string;
331
+ }
332
+
333
+ findVariableByVariableName(variableName) {
334
+ const name = variableName, ///
335
+ variables = this.getVariables(),
336
+ variable = variables.find((variable) => {
337
+ const matches = variable.matchName(name);
338
+
339
+ if (matches) {
340
+ return true;
341
+ }
342
+ }) || null;
343
+
344
+ return variable;
300
345
  }
301
346
 
302
347
  isVariablePresentByVariableName(variableName) {
@@ -344,50 +389,17 @@ export default class FileContext {
344
389
  this.constructors.push(constructor);
345
390
  }
346
391
 
347
- nodeAsString(node) {
348
- const string = nodeAsString(node, this.tokens);
349
-
350
- return string;
351
- }
352
-
353
- nodesAsString(node) {
354
- const string = nodesAsString(node, this.tokens);
392
+ trace(message, node) { this.releaseContext.trace(message, node, this.tokens, this.filePath); }
355
393
 
356
- return string;
357
- }
358
-
359
- trace(message) { this.releaseContext.trace(message); }
394
+ debug(message, node) { this.releaseContext.debug(message, node, this.tokens, this.filePath); }
360
395
 
361
- debug(message) { this.releaseContext.debug(message); }
396
+ info(message, node) { this.releaseContext.info(message, node, this.tokens, this.filePath); }
362
397
 
363
- info(message) { this.releaseContext.info(message); }
398
+ warning(message, node) { this.releaseContext.warning(message, node, this.tokens, this.filePath); }
364
399
 
365
- warning(message) { this.releaseContext.warning(message); }
400
+ error(message, node) { this.releaseContext.error(message, node, this.tokens, this.filePath); }
366
401
 
367
- error(message) { this.releaseContext.error(message); }
368
-
369
- fatal(message) { this.releaseContext.fatal(message); }
370
-
371
- halt(node) {
372
- const leastLineIndex = leastLineIndexFromNodeAndTokens(node, this.tokens),
373
- greatestLineIndex = greatestLineIndexFromNodeAndTokens(node, this.tokens);
374
-
375
- this.releaseContext.halt(this.filePath, leastLineIndex, greatestLineIndex);
376
- }
377
-
378
- begin(node) {
379
- const leastLineIndex = leastLineIndexFromNodeAndTokens(node, this.tokens),
380
- greatestLineIndex = greatestLineIndexFromNodeAndTokens(node, this.tokens);
381
-
382
- this.releaseContext.begin(this.filePath, leastLineIndex, greatestLineIndex);
383
- }
384
-
385
- complete(node) {
386
- const leastLineIndex = leastLineIndexFromNodeAndTokens(node, this.tokens),
387
- greatestLineIndex = greatestLineIndexFromNodeAndTokens(node, this.tokens);
388
-
389
- this.releaseContext.complete(this.filePath, leastLineIndex, greatestLineIndex);
390
- }
402
+ fatal(message, node) { this.releaseContext.fatal(message, node, this.tokens, this.filePath); }
391
403
 
392
404
  toJSON() {
393
405
  const json = [];
@@ -422,6 +434,12 @@ export default class FileContext {
422
434
  json.push(theoremJSON);
423
435
  });
424
436
 
437
+ this.conjectures.forEach((conjecture) => {
438
+ const conjectureJSON = conjecture.toJSON(this.tokens);
439
+
440
+ json.push(conjectureJSON);
441
+ });
442
+
425
443
  this.combinators.forEach((combinator) => {
426
444
  const combinatorJSON = combinator.toJSON(this.tokens);
427
445
 
@@ -452,10 +470,12 @@ export default class FileContext {
452
470
  axioms = [],
453
471
  lemmas = [],
454
472
  theorems = [],
455
- variables = [],
473
+ conjectures = [],
456
474
  combinators = [],
457
475
  constructors = [],
458
- fileContext = new FileContext(releaseContext, filePath, tokens, node, types, rules, axioms, lemmas, theorems, variables, combinators, constructors);
476
+ variables = [],
477
+ metavariables = [],
478
+ fileContext = new FileContext(releaseContext, filePath, tokens, node, types, rules, axioms, lemmas, theorems, conjectures, combinators, constructors, variables, metavariables);
459
479
 
460
480
  return fileContext;
461
481
  }
@@ -2,13 +2,13 @@
2
2
 
3
3
  import fileMixins from "../mixins/file";
4
4
  import loggingMixins from "../mixins/logging";
5
- import callbacksMixins from "../mixins/callbacks";
6
5
 
7
- import { last } from "../utilities/array";
6
+ import { push, last } from "../utilities/array";
8
7
 
9
8
  class MetaproofContext {
10
- constructor(context, metaproofSteps) {
9
+ constructor(context, metavariables, metaproofSteps) {
11
10
  this.context = context;
11
+ this.metavariables = metavariables;
12
12
  this.metaproofSteps = metaproofSteps;
13
13
  }
14
14
 
@@ -16,6 +16,20 @@ class MetaproofContext {
16
16
  return this.context;
17
17
  }
18
18
 
19
+ getVariables() { return this.context.getVariables(); }
20
+
21
+ getMetavariables() {
22
+ const metavariables = [];
23
+
24
+ push(metavariables, this.metavariables);
25
+
26
+ const contextMetavariables = this.context.getMetavariables();
27
+
28
+ push(metavariables, contextMetavariables);
29
+
30
+ return metavariables;
31
+ }
32
+
19
33
  getMetaproofSteps() {
20
34
  let metaproofSteps = this.context.getMetaproofSteps();
21
35
 
@@ -39,20 +53,28 @@ class MetaproofContext {
39
53
  return lastMetaproofStep;
40
54
  }
41
55
 
56
+ addMetavariable(metavariable) {
57
+ this.metavariables.push(metavariable);
58
+ }
59
+
42
60
  addMetaproofStep(metaproofStep) {
43
61
  this.metaproofSteps.push(metaproofStep);
44
62
  }
45
63
 
46
64
  matchMetastatement(metastatementNode) {
47
- let metastatementMatches;
65
+ let metastatementMatches = false;
48
66
 
49
- metastatementMatches = this.metaproofSteps.some((metaproofStep) => {
50
- metastatementMatches = metaproofStep.matchMetastatement(metastatementNode);
67
+ if (!metastatementMatches) {
68
+ const proofStepMatchesMetastatement = this.metaproofSteps.some((metaproofStep) => {
69
+ const proofStepMatchesMetastatement = metaproofStep.match(metastatementNode);
70
+
71
+ if (proofStepMatchesMetastatement) {
72
+ return true;
73
+ }
74
+ });
51
75
 
52
- if (metastatementMatches) {
53
- return true;
54
- }
55
- });
76
+ metastatementMatches = proofStepMatchesMetastatement; ///
77
+ }
56
78
 
57
79
  if (!metastatementMatches) {
58
80
  metastatementMatches = this.context.matchMetastatement(metastatementNode);
@@ -61,23 +83,42 @@ class MetaproofContext {
61
83
  return metastatementMatches;
62
84
  }
63
85
 
64
- nodeAsString(node) { return this.context.nodeAsString(node); }
86
+ findMetavariableByMetavariableName(metavariableName) {
87
+ const name = metavariableName, ///
88
+ metavariables = this.getMetavariables(),
89
+ metavariable = metavariables.find((metavariable) => {
90
+ const matches = metavariable.matchName(name);
91
+
92
+ if (matches) {
93
+ return true;
94
+ }
95
+ }) || null;
96
+
97
+ return metavariable;
98
+ }
99
+
100
+ isMetavariablePresentByVariableName(metavariableName) {
101
+ const metavariable = this.findMetavariableByMetavariableName(metavariableName),
102
+ metavariablePresent = (metavariable !== null);
65
103
 
66
- nodesAsString(node) { return this.context.nodesAsString(node); }
104
+ return metavariablePresent;
105
+ }
67
106
 
68
107
  static fromFileContext(fileContext) {
69
108
  const context = fileContext, ///
109
+ metavariables = [],
70
110
  metaproofSteps = [],
71
- metaproofContext = new MetaproofContext(context, metaproofSteps);
111
+ metaproofContext = new MetaproofContext(context, metavariables, metaproofSteps);
72
112
 
73
113
  return metaproofContext;
74
114
  }
75
115
 
76
116
  static fromMetaproofContext(metaproofContext) {
77
117
  const context = metaproofContext, ///
118
+ metavariables = [],
78
119
  metaproofSteps = [];
79
120
 
80
- metaproofContext = new MetaproofContext(context, metaproofSteps); ///
121
+ metaproofContext = new MetaproofContext(context, metavariables, metaproofSteps); ///
81
122
 
82
123
  return metaproofContext;
83
124
  }
@@ -85,6 +126,5 @@ class MetaproofContext {
85
126
 
86
127
  Object.assign(MetaproofContext.prototype, fileMixins);
87
128
  Object.assign(MetaproofContext.prototype, loggingMixins);
88
- Object.assign(MetaproofContext.prototype, callbacksMixins);
89
129
 
90
130
  export default MetaproofContext;