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
@@ -2,7 +2,6 @@
2
2
 
3
3
  import Equality from "../equality";
4
4
  import verifyTerm from "../verify/term";
5
- import equalityCombinator from "../ocmbinator/equality";
6
5
  import bracketedCombinator from "../ocmbinator/bracketed";
7
6
  import verifyTypeAssertion from "../verify/assertion/type";
8
7
 
@@ -10,75 +9,82 @@ import { first } from "../utilities/array";
10
9
  import { objectType } from "../type";
11
10
  import { OBJECT_TYPE_NAME } from "../typeNames";
12
11
  import { STATEMENT_META_TYPE } from "../metaTypes";
13
- import { MAXIMUM_INDEXES_LENGTH } from "../constants";
14
12
  import { nodeQuery, typeNameFromTypeNode } from "../utilities/query";
15
13
  import { ARGUMENT_RULE_NAME, META_ARGUMENT_RULE_NAME } from "../ruleNames";
16
14
 
17
15
  const termNodeQuery = nodeQuery("/argument/term!"),
18
16
  typeNodeQuery = nodeQuery("/argument/type!"),
19
- metaTypeNodeQuery = nodeQuery("/metaArgument/metaType!/@meta-type"),
17
+ metaTypeNodeQuery = nodeQuery("/metaArgument/metaType!"),
20
18
  statementNodeQuery = nodeQuery("/metaArgument/statement!"),
21
- typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion!");
19
+ typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion!"),
20
+ metaTypeTerminalNodeQuery = nodeQuery("/metaType/@meta-type");
22
21
 
23
22
  export default function verifyStatement(statementNode, assertions, derived, context) {
24
23
  let statementVerified = false;
25
24
 
26
- context.begin(statementNode);
27
-
28
25
  if (!statementVerified) {
29
- const statementVerifiedAsEquality = verifyStatementAsEquality(statementNode, derived, context);
26
+ const statementVerifiedAgainstCombinators = verifyStatementAgainstCombinators(statementNode, context);
30
27
 
31
- statementVerified = statementVerifiedAsEquality; //
28
+ statementVerified = statementVerifiedAgainstCombinators; ///
32
29
  }
33
30
 
34
31
  if (!statementVerified) {
35
- const statementVerifiedAsTypeAssertion = verifyStatementAsTypeAssertion(statementNode, assertions, context);
32
+ const statementVerifiedAsTypeAssertion = verifyStatementAsTypeAssertion(statementNode, assertions, derived, context);
36
33
 
37
34
  statementVerified = statementVerifiedAsTypeAssertion; ///
38
35
  }
39
36
 
40
37
  if (!statementVerified) {
41
- const statementVerifiedAgainstCombinators = verifyStatementAgainstCombinators(statementNode, context);
38
+ const statementVerifiedAsEquality = verifyStatementAsEquality(statementNode, derived, context);
42
39
 
43
- statementVerified = statementVerifiedAgainstCombinators; ///
40
+ statementVerified = statementVerifiedAsEquality; //
44
41
  }
45
42
 
46
- statementVerified ?
47
- context.complete(statementNode) :
48
- context.halt(statementNode);
49
-
50
43
  return statementVerified;
51
44
  }
52
45
 
53
- function verifyStatementAsEquality(statementNode, derived, context) {
54
- let statementVerifiedAsEquality = false;
46
+ export function verifyStatementAgainstCombinator(statementNode, combinator, context) {
47
+ const combinatorStatementNode = combinator.getStatementNode(),
48
+ node = statementNode, ///
49
+ combinatorNode = combinatorStatementNode, ///
50
+ nodeVerified = verifyNode(node, combinatorNode, context),
51
+ statementVerifiedAgainstCombinator = nodeVerified; ///
52
+
53
+ return statementVerifiedAgainstCombinator;
54
+ }
55
55
 
56
- const combinator = equalityCombinator, ///
57
- statementVerifiedAgainstCombinator = verifyStatementAgainstCombinator(statementNode, combinator, context);
56
+ function verifyStatementAgainstCombinators(statementNode, context) {
57
+ let statementVerifiedAgainstCombinators = false;
58
58
 
59
- if (statementVerifiedAgainstCombinator) {
60
- statementVerifiedAsEquality = true;
59
+ let combinators = context.getCombinators();
61
60
 
62
- if (derived) {
63
- const equality = Equality.fromStatementNode(statementNode),
64
- proofSteps = context.getProofSteps(),
65
- equalities = equalitiesFromProofSteps(proofSteps),
66
- equalityEquates = equality.equate(equalities);
61
+ combinators = [ ///
62
+ bracketedCombinator,
63
+ ...combinators
64
+ ];
67
65
 
68
- statementVerifiedAsEquality = equalityEquates; ///
66
+ const combinator = combinators.find((combinator) => {
67
+ const statementVerifiedAgainstCombinator = verifyStatementAgainstCombinator(statementNode, combinator, context);
68
+
69
+ if (statementVerifiedAgainstCombinator) {
70
+ return true;
69
71
  }
72
+ }) || null;
73
+
74
+ if (combinator !== null) {
75
+ statementVerifiedAgainstCombinators = true;
70
76
  }
71
77
 
72
- return statementVerifiedAsEquality;
78
+ return statementVerifiedAgainstCombinators;
73
79
  }
74
80
 
75
- function verifyStatementAsTypeAssertion(statementNode, assertions, context) {
81
+ function verifyStatementAsTypeAssertion(statementNode, assertions, derived, context) {
76
82
  let statementVerifiedAsTypeAssertion = false;
77
83
 
78
84
  const typeAssertionNode = typeAssertionNodeQuery(statementNode);
79
85
 
80
86
  if (typeAssertionNode !== null) {
81
- const typeAssertionVerified = verifyTypeAssertion(typeAssertionNode, assertions, context);
87
+ const typeAssertionVerified = verifyTypeAssertion(typeAssertionNode, assertions, derived, context);
82
88
 
83
89
  statementVerifiedAsTypeAssertion = typeAssertionVerified; ///
84
90
  }
@@ -86,39 +92,26 @@ function verifyStatementAsTypeAssertion(statementNode, assertions, context) {
86
92
  return statementVerifiedAsTypeAssertion;
87
93
  }
88
94
 
89
- function verifyStatementAgainstCombinators(statementNode, context) {
90
- let statementVerifiedAgainstCombinators = false;
95
+ function verifyStatementAsEquality(statementNode, derived, context) {
96
+ let statementVerifiedAsEquality = false;
91
97
 
92
- let combinators = context.getCombinators();
98
+ const equality = Equality.fromStatementNode(statementNode, context);
93
99
 
94
- combinators = [ ///
95
- bracketedCombinator,
96
- ...combinators
97
- ];
100
+ if (equality !== null) {
101
+ statementVerifiedAsEquality = true; ///
98
102
 
99
- const combinator = combinators.find((combinator) => {
100
- const statementVerifiedAgainstCombinator = verifyStatementAgainstCombinator(statementNode, combinator, context);
103
+ if (derived) {
104
+ const equalities = context.getEqualities();
101
105
 
102
- if (statementVerifiedAgainstCombinator) {
103
- return true;
104
- }
105
- }) || null;
106
+ if (equalities !== null) {
107
+ const equalityEquates = equality.equate(equalities, context);
106
108
 
107
- if (combinator !== null) {
108
- statementVerifiedAgainstCombinators = true;
109
+ statementVerifiedAsEquality = equalityEquates; ///
110
+ }
111
+ }
109
112
  }
110
113
 
111
- return statementVerifiedAgainstCombinators;
112
- }
113
-
114
- function verifyStatementAgainstCombinator(statementNode, combinator, context) {
115
- const combinatorStatementNode = combinator.getStatementNode(),
116
- node = statementNode, ///
117
- combinatorNode = combinatorStatementNode, ///
118
- nodeVerified = verifyNode(node, combinatorNode, context),
119
- statementVerifiedAgainstCombinator = nodeVerified; ///
120
-
121
- return statementVerifiedAgainstCombinator;
114
+ return statementVerifiedAsEquality;
122
115
  }
123
116
 
124
117
  function verifyNode(node, combinatorNode, context) {
@@ -231,7 +224,7 @@ function verifyArgumentNode(argumentNode, combinatorArgumentNode, context) {
231
224
  if (termNode === null) {
232
225
  const argumentString = context.nodeAsString(argumentNode);
233
226
 
234
- context.error(`The ${argumentString} argument should be a term, not a type`);
227
+ context.error(`The ${argumentString} argument should be a term, not a type`, argumentNode);
235
228
  } else {
236
229
  const types = [],
237
230
  termVerified = verifyTerm(termNode, types, context);
@@ -258,53 +251,30 @@ function verifyArgumentNode(argumentNode, combinatorArgumentNode, context) {
258
251
  function verifyMetaargumentNode(metaArgumentNode, combinatorMetaargumentNode, context) {
259
252
  let metaArgumentNodeVerified = false;
260
253
 
261
- const statementNode = statementNodeQuery(metaArgumentNode);
254
+ const statementNode = statementNodeQuery(metaArgumentNode),
255
+ combinatorMetaTYpeNode = metaTypeNodeQuery(combinatorMetaargumentNode);
262
256
 
263
257
  if (statementNode === null) {
264
258
  const metaArgumentString = context.nodeAsString(metaArgumentNode);
265
259
 
266
- context.error(`The '${metaArgumentString}' meta-argument should be a statement, not a meta-type.`);
260
+ context.error(`Expected a statement but got a '${metaArgumentString}' meta-type.`, metaArgumentNode);
267
261
  } else {
268
- const derived = false,
269
- assertions = null,
270
- statementVerified = verifyStatement(statementNode, assertions, derived, context);
271
-
272
- if (statementVerified) {
273
- const combinatorMetaTYpeNode = metaTypeNodeQuery(combinatorMetaargumentNode);
274
-
275
- if (combinatorMetaTYpeNode !== null) {
276
- const terminalNode = combinatorMetaTYpeNode, ///
277
- terminalNodeContent = terminalNode.getContent(),
278
- terminalNodeContentStatementMetaType = (terminalNodeContent === STATEMENT_META_TYPE);
279
-
280
- metaArgumentNodeVerified = terminalNodeContentStatementMetaType; ///
281
- }
282
-
283
- if (!metaArgumentNodeVerified) {
284
- const combinatorMetaargumentString = context.nodeAsString(combinatorMetaargumentNode);
262
+ if (combinatorMetaTYpeNode === null) {
263
+ const combinatorMetaargumentString = context.nodeAsString(combinatorMetaargumentNode);
285
264
 
286
- context.error(`The '${combinatorMetaargumentString}' combinator meta-argument should be the 'Statement' meta-type.`);
265
+ context.error(`Expected a meta-type but got a '${combinatorMetaargumentString}' statement.`, metaArgumentNode);
266
+ } else {
267
+ const combinatorMetaTypeTerminalNode = metaTypeTerminalNodeQuery(combinatorMetaTYpeNode),
268
+ content = combinatorMetaTypeTerminalNode.getContent(),
269
+ contentStatementMetaType = (content === STATEMENT_META_TYPE);
270
+
271
+ if (!contentStatementMetaType) {
272
+ context.error(`Expected the meta-type to be 'Statement' but got '${content}'.`, metaArgumentNode);
273
+ } else {
274
+ metaArgumentNodeVerified = true;
287
275
  }
288
276
  }
289
277
  }
290
278
 
291
279
  return metaArgumentNodeVerified;
292
280
  }
293
-
294
- function equalitiesFromProofSteps(proofSteps) {
295
- const start = -MAXIMUM_INDEXES_LENGTH; ///
296
-
297
- proofSteps = proofSteps.slice(start); ///
298
-
299
- const equalities = proofSteps.reduce((equalities, proofStep, index) => {
300
- const equality = Equality.fromProofStep(proofStep);
301
-
302
- if (equality !== null) {
303
- equalities.push(equality);
304
- }
305
-
306
- return equalities;
307
- }, []);
308
-
309
- return equalities;
310
- }
@@ -10,11 +10,9 @@ import { TYPE_RULE_NAME, TERM_RULE_NAME, STATEMENT_RULE_NAME } from "../ruleName
10
10
  export default function verifyStatementAsCombinator(statementNode, fileContext) {
11
11
  let statementVerifiedAsCombinator = false;
12
12
 
13
- fileContext.begin(statementNode);
14
-
15
13
  const statementString = fileContext.nodeAsString(statementNode);
16
14
 
17
- fileContext.debug(`Verifying the '${statementString}' combinator....`);
15
+ fileContext.debug(`Verifying the '${statementString}' combinator....`, statementNode);
18
16
 
19
17
  const nonTerminalNode = statementNode, ///
20
18
  childNodes = nonTerminalNode.getChildNodes(),
@@ -29,13 +27,9 @@ export default function verifyStatementAsCombinator(statementNode, fileContext)
29
27
  }
30
28
 
31
29
  if (statementVerifiedAsCombinator) {
32
- fileContext.info(`Verified the '${statementString}' combinator.`);
30
+ fileContext.info(`Verified the '${statementString}' combinator.`, statementNode);
33
31
  }
34
32
 
35
- statementVerifiedAsCombinator ?
36
- fileContext.complete(statementNode) :
37
- fileContext.halt(statementNode);
38
-
39
33
  return statementVerifiedAsCombinator;
40
34
  }
41
35
 
@@ -131,7 +125,7 @@ function verifyTypeNode(typeNode, fileContext) {
131
125
  typePresent = fileContext.isTypePresentByTypeName(typeName);
132
126
 
133
127
  if (!typePresent) {
134
- fileContext.error(`The type '${typeName}' is missing.`);
128
+ fileContext.error(`The type '${typeName}' not present.`, typeNode);
135
129
  } else {
136
130
  typeNodeVerified = true;
137
131
  }
@@ -12,11 +12,9 @@ const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
12
12
  export default function verifySupposition(suppositionNode, suppositions, proofContext) {
13
13
  let suppositionVerified;
14
14
 
15
- proofContext.begin(suppositionNode);
16
-
17
15
  const suppositionString = proofContext.nodeAsString(suppositionNode);
18
16
 
19
- proofContext.debug(`Verifying the '${suppositionString}' supposition...`);
17
+ proofContext.debug(`Verifying the '${suppositionString}' supposition...`, suppositionNode);
20
18
 
21
19
  const derived = false,
22
20
  assertions = [],
@@ -39,9 +37,5 @@ export default function verifySupposition(suppositionNode, suppositions, proofCo
39
37
  suppositionVerified = true;
40
38
  }
41
39
 
42
- suppositionVerified ?
43
- proofContext.complete(suppositionNode) :
44
- proofContext.halt(suppositionNode);
45
-
46
40
  return suppositionVerified;
47
41
  }
@@ -13,11 +13,9 @@ const termNodeQuery = nodeQuery("/argument/term!"),
13
13
  export default function verifyTerm(termNode, types, context) {
14
14
  let termVerified = false;
15
15
 
16
- context.begin(termNode);
17
-
18
16
  const termString = context.nodeAsString(termNode);
19
17
 
20
- context.debug(`Verifying the '${termString}' term...`);
18
+ context.trace(`Verifying the '${termString}' term...`, termNode);
21
19
 
22
20
  if (!termVerified) {
23
21
  const variables = [],
@@ -43,21 +41,15 @@ export default function verifyTerm(termNode, types, context) {
43
41
  }
44
42
 
45
43
  if (termVerified) {
46
- context.info(`Verified the '${termString}' term.`);
44
+ context.debug(`Verified the '${termString}' term.`, termNode);
47
45
  }
48
46
 
49
- termVerified ?
50
- context.complete(termNode) :
51
- context.halt(termNode);
52
-
53
47
  return termVerified;
54
48
  }
55
49
 
56
50
  export function verifyTermAsVariable(termNode, variables, context) {
57
51
  let termVerifiedAsVariable = false;
58
52
 
59
- context.begin(termNode);
60
-
61
53
  const variableNode = variableNodeQuery(termNode);
62
54
 
63
55
  if (variableNode !== null) {
@@ -73,18 +65,12 @@ export function verifyTermAsVariable(termNode, variables, context) {
73
65
  }
74
66
  }
75
67
 
76
- termVerifiedAsVariable ?
77
- context.complete(termNode) :
78
- context.halt(termNode);
79
-
80
68
  return termVerifiedAsVariable;
81
69
  }
82
70
 
83
71
  export function verifyTermAgainstConstructors(termNode, types, context) {
84
72
  let termVerifiedAgainstConstructors = false;
85
73
 
86
- context.begin(termNode);
87
-
88
74
  const constructors = context.getConstructors(),
89
75
  constructor = constructors.find((constructor) => {
90
76
  const termVerifiedAgainstConstructor = verifyTermAgainstConstructor(termNode, constructor, context);
@@ -102,10 +88,6 @@ export function verifyTermAgainstConstructors(termNode, types, context) {
102
88
  termVerifiedAgainstConstructors = true;
103
89
  }
104
90
 
105
- termVerifiedAgainstConstructors ?
106
- context.complete(termNode) :
107
- context.halt(termNode);
108
-
109
91
  return termVerifiedAgainstConstructors;
110
92
  }
111
93
 
@@ -219,7 +201,7 @@ function verifyArgumentNode(argumentNode, constructorArgumentNode, context) {
219
201
  if (termNode === null) {
220
202
  const argumentString = context.nodeAsString(argumentNode);
221
203
 
222
- context.error(`The ${argumentString} argument should be a term, not a type`);
204
+ context.error(`The ${argumentString} argument should be a term, not a type`, argumentNode);
223
205
  } else {
224
206
  const types = [],
225
207
  termVerified = verifyTerm(termNode, types, context);
@@ -12,15 +12,11 @@ const typeNodeQuery = nodeQuery("/argument/type");
12
12
  export default function verifyTermAsConstructor(termNode, typeNode, fileContext) {
13
13
  let termVerifiedAsConstructor = false;
14
14
 
15
- fileContext.begin(termNode);
16
-
17
15
  let type = null;
18
16
 
19
17
  const nonTerminalNode = termNode, ///
20
18
  termString = fileContext.nodeAsString(termNode);
21
19
 
22
- fileContext.debug(`Verifying the '${termString}' constructor...`);
23
-
24
20
  const childNodes = nonTerminalNode.getChildNodes(),
25
21
  childNodesVerified = verifyChildNodes(childNodes, fileContext);
26
22
 
@@ -35,7 +31,7 @@ export default function verifyTermAsConstructor(termNode, typeNode, fileContext)
35
31
  if (type !== null) {
36
32
  termVerifiedAsConstructor = true;
37
33
  } else {
38
- fileContext.error(`The '${termString}' constructor's '${typeName}' type is missing.`);
34
+ fileContext.error(`The '${termString}' constructor's '${typeName}' type is not present.`, termNode);
39
35
  }
40
36
  }
41
37
  }
@@ -47,13 +43,9 @@ export default function verifyTermAsConstructor(termNode, typeNode, fileContext)
47
43
  }
48
44
 
49
45
  if (termVerifiedAsConstructor) {
50
- fileContext.info(`Verified the '${termString}' constructor.`);
46
+ fileContext.info(`Verified the '${termString}' constructor.`, termNode);
51
47
  }
52
48
 
53
- termVerifiedAsConstructor ?
54
- fileContext.complete(termNode) :
55
- fileContext.halt(termNode);
56
-
57
49
  return termVerifiedAsConstructor;
58
50
  }
59
51
 
@@ -124,7 +116,7 @@ function verifyNonTerminalNode(nonTerminalNode, fileContext) {
124
116
  if (type !== null) {
125
117
  const termString = fileContext.nodeAsString(termNode);
126
118
 
127
- fileContext.error(`The type of the constructor's compound '${termString}' term node is not null.`);
119
+ fileContext.error(`The type of the constructor's compound '${termString}' term node is not null.`, termNode);
128
120
  } else {
129
121
  nonTerminalNodeVerified = true; ///
130
122
  }
@@ -154,13 +146,13 @@ function verifyArgumentNode(argumentNode, fileContext) {
154
146
  if (typeNode === null) {
155
147
  const argumentString = fileContext.nodeAsString(argumentNode);
156
148
 
157
- fileContext.error(`The ${argumentString} argument should be a type.`);
149
+ fileContext.error(`The ${argumentString} argument should be a type.`, argumentNode);
158
150
  } else {
159
151
  const typeName = typeNameFromTypeNode(typeNode),
160
152
  typePresent = fileContext.isTypePresentByTypeName(typeName);
161
153
 
162
154
  if (!typePresent) {
163
- fileContext.error(`The type '${typeName}' is missing.`);
155
+ fileContext.error(`The type '${typeName}' is not present.`, argumentNode);
164
156
  } else {
165
157
  typeNodeVerified = true;
166
158
  }
@@ -8,7 +8,6 @@ import verifySupposition from "./supposition";
8
8
  import verifyConsequence from "./consequence";
9
9
 
10
10
  import { first } from "../utilities/array";
11
- import { nodesAsString } from "../utilities/string";
12
11
  import { nodeQuery, nodesQuery } from "../utilities/query";
13
12
 
14
13
  const proofNodeQuery = nodeQuery("/theorem/proof!"),
@@ -19,13 +18,11 @@ const proofNodeQuery = nodeQuery("/theorem/proof!"),
19
18
  export default function verifyTheorem(theoremNode, fileContext) {
20
19
  let theoremVerified = false;
21
20
 
22
- fileContext.begin(theoremNode);
23
-
24
21
  const labelNodes = labelNodesQuery(theoremNode),
25
22
  labelsString = fileContext.nodesAsString(labelNodes),
26
23
  proofContext = ProofContext.fromFileContext(fileContext);
27
24
 
28
- fileContext.debug(`Verifying the '${labelsString}' theorem...`);
25
+ fileContext.debug(`Verifying the '${labelsString}' theorem...`, theoremNode);
29
26
 
30
27
  const labels = [],
31
28
  labelsVerified = verifyLabels(labelNodes, labels, fileContext);
@@ -64,12 +61,8 @@ export default function verifyTheorem(theoremNode, fileContext) {
64
61
  }
65
62
 
66
63
  if (theoremVerified) {
67
- fileContext.info(`Verified the '${labelsString}' theorem.`);
64
+ fileContext.info(`Verified the '${labelsString}' theorem.`, theoremNode);
68
65
  }
69
66
 
70
- theoremVerified ?
71
- fileContext.complete(theoremNode) :
72
- fileContext.complete(theoremNode);
73
-
74
67
  return theoremVerified;
75
68
  }
@@ -7,17 +7,12 @@ import { typeNameFromTypeNode } from "../utilities/query";
7
7
  export default function verifyType(typeNode, superTypeNode, fileContext) {
8
8
  let typeVerified = false;
9
9
 
10
- fileContext.begin(typeNode);
11
-
12
- const typeString = fileContext.nodeAsString(typeNode);
13
-
14
- fileContext.debug(`Verifying the '${typeString}' type...`);
15
-
16
10
  const typeName = typeNameFromTypeNode(typeNode),
11
+ typeString = fileContext.nodeAsString(typeNode),
17
12
  typePresent = fileContext.isTypePresentByTypeName(typeName);
18
13
 
19
14
  if (typePresent) {
20
- fileContext.error(`The type '${typeName}' is already present.`);
15
+ fileContext.error(`The type '${typeName}' is already present.`, typeNode);
21
16
  } else {
22
17
  let type;
23
18
 
@@ -29,7 +24,7 @@ export default function verifyType(typeNode, superTypeNode, fileContext) {
29
24
  const superType = fileContext.findTypeByTypeName(superTypeName);
30
25
 
31
26
  if (superType === null) {
32
- fileContext.error(`The super-type '${superTypeName}' is missing.`);
27
+ fileContext.error(`The super-type '${superTypeName}' is not present.`, typeNode);
33
28
  } else {
34
29
  type = Type.fromTypeNameAndSuperType(typeName, superType);
35
30
  }
@@ -43,12 +38,8 @@ export default function verifyType(typeNode, superTypeNode, fileContext) {
43
38
  }
44
39
 
45
40
  if (typeVerified) {
46
- fileContext.info(`Verified the '${typeString}' type.`);
41
+ fileContext.info(`Verified the '${typeString}' type.`, typeNode);
47
42
  }
48
43
 
49
- typeVerified ?
50
- fileContext.complete(typeNode):
51
- fileContext.halt(typeNode);
52
-
53
44
  return typeVerified;
54
45
  }
@@ -8,17 +8,12 @@ import { typeNameFromTypeNode, variableNameFromVariableNode } from "../utilities
8
8
  export default function verifyVariable(variableNode, typeNode, fileContext) {
9
9
  let variableVerified = false;
10
10
 
11
- fileContext.begin(variableNode);
12
-
13
- const variableString = fileContext.nodeAsString(variableNode);
14
-
15
- fileContext.debug(`Verifying the '${variableString}' variable...`);
16
-
17
11
  const variableName = variableNameFromVariableNode(variableNode),
12
+ variableString = fileContext.nodeAsString(variableNode),
18
13
  variablePresent = fileContext.isVariablePresentByVariableName(variableName);
19
14
 
20
15
  if (variablePresent) {
21
- fileContext.error(`The variable '${variableName}' is already present.`);
16
+ fileContext.error(`The variable '${variableName}' is already present.`, variableNode);
22
17
  } else {
23
18
  let variable;
24
19
 
@@ -33,7 +28,7 @@ export default function verifyVariable(variableNode, typeNode, fileContext) {
33
28
  const type = fileContext.findTypeByTypeName(typeName);
34
29
 
35
30
  if (type === null) {
36
- fileContext.error(`The '${variableName}' variable's '${typeName}' type is missing.`);
31
+ fileContext.error(`The '${variableName}' variable's '${typeName}' type is not present.`, variableNode);
37
32
  } else {
38
33
  const name = variableName; ///
39
34
 
@@ -49,12 +44,8 @@ export default function verifyVariable(variableNode, typeNode, fileContext) {
49
44
  }
50
45
 
51
46
  if (variableVerified) {
52
- fileContext.info(`Verified the '${variableString}' variable.`);
47
+ fileContext.info(`Verified the '${variableString}' variable.`, variableNode);
53
48
  }
54
49
 
55
- variableVerified ?
56
- fileContext.complete(variableNode) :
57
- fileContext.halt(variableNode);
58
-
59
50
  return variableVerified;
60
51
  }
package/bin/callbacks.js DELETED
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- const { Callbacks } = require("../lib/index"), ///
4
- { loggingUtilities } = require("necessary");
5
-
6
- const { log } = loggingUtilities,
7
- { trace } = log,
8
- { HALT_MESSAGE, BEGIN_MESSAGE, COMPLETED_MESSAGE } = Callbacks;
9
-
10
- function halt(filePath, leastLineIndex, greatestLineIndex) {
11
- let message = HALT_MESSAGE;
12
-
13
- message = formatMessage(message, filePath, leastLineIndex, greatestLineIndex); ///
14
-
15
- trace(message);
16
- }
17
-
18
- function begin(filePath, leastLineIndex, greatestLineIndex) {
19
- let message = BEGIN_MESSAGE;
20
-
21
- message = formatMessage(message, filePath, leastLineIndex, greatestLineIndex); ///
22
-
23
- trace(message);
24
- }
25
-
26
- function complete(filePath, leastLineIndex, greatestLineIndex) {
27
- let message = COMPLETED_MESSAGE;
28
-
29
- message = formatMessage(message, filePath, leastLineIndex, greatestLineIndex); ///
30
-
31
- trace(message);
32
- }
33
-
34
- const callbacks = Callbacks.fromHaltBeginAndComplete(halt, begin, complete);
35
-
36
- module.exports = callbacks;
37
-
38
- function formatMessage(message, filePath, leastLineIndex, greatestLineIndex) {
39
- if (leastLineIndex === greatestLineIndex) {
40
- const lineIndex = leastLineIndex; ///
41
-
42
- message = `'${filePath}' : [${lineIndex}] - ${message}`;
43
- } else {
44
- message = `'${filePath}' : [${leastLineIndex}-${greatestLineIndex}] - ${message}`;
45
- }
46
-
47
- return message;
48
- }