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
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ import TermForVariableVerifier from "../../verifier/termForVariable";
4
+
5
+ class SuppositionTermForVariableVerifier extends TermForVariableVerifier {
6
+ static createSubstitutions = true;
7
+ }
8
+
9
+ export const suppositionTermForVariableVerifier = new SuppositionTermForVariableVerifier();
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ import Verifier from "../verifier";
4
+ import TermForVariableSubstitution from "../substitution/termForVariable";
5
+
6
+ import { nodeQuery } from "../utilities/query";
7
+ import { TERM_RULE_NAME } from "../ruleNames";
8
+ import { variableNameFromVariableNode } from "../utilities/query";
9
+
10
+ const variableNodeQuery = nodeQuery('/term/variable!');
11
+
12
+ export default class TermForVariableVerifier extends Verifier {
13
+ matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
14
+ let nonTerminalNodeMatches = false;
15
+
16
+ const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(),
17
+ nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName();
18
+
19
+ if (nonTerminalNodeBRuleName === nonTerminalNodeARuleName) {
20
+ const nonTerminalNodeARuleNameTermRuleName = (nonTerminalNodeARuleName === TERM_RULE_NAME),
21
+ nonTerminalNodeBRuleNameTermRuleName = (nonTerminalNodeBRuleName === TERM_RULE_NAME);
22
+
23
+ if (nonTerminalNodeARuleNameTermRuleName && nonTerminalNodeBRuleNameTermRuleName) {
24
+ const termNodeA = nonTerminalNodeA, ///
25
+ termNodeB = nonTerminalNodeB, ///
26
+ termNodeMatches = this.matchTermNode(termNodeA, termNodeB, substitutions);
27
+
28
+ if (termNodeMatches) {
29
+ nonTerminalNodeMatches = true; ///
30
+ } else {
31
+ nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
32
+ }
33
+ } else {
34
+ nonTerminalNodeMatches = super.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
35
+ }
36
+ }
37
+
38
+ return nonTerminalNodeMatches;
39
+ }
40
+
41
+ matchTermNode(termNodeA, termNodeB, substitutions) {
42
+ let termNodeMatches = false;
43
+
44
+ const variableNodeA = variableNodeQuery(termNodeA);
45
+
46
+ if (variableNodeA !== null) {
47
+ const variableMatches = this.matchVariableNode(variableNodeA, termNodeB, substitutions);
48
+
49
+ termNodeMatches = variableMatches; ///
50
+ }
51
+
52
+ return termNodeMatches;
53
+ }
54
+
55
+ matchVariableNode(variableNodeB, termNodeB, substitutions) {
56
+ let variableMatches;
57
+
58
+ const variableNameA = variableNameFromVariableNode(variableNodeB),
59
+ substitution = substitutions.find((substitution) => {
60
+ const variableName = substitution.getVariableName();
61
+
62
+ if (variableName === variableNameA) {
63
+ return true;
64
+ }
65
+ }) || null;
66
+
67
+ if (substitution !== null) {
68
+ const termNode = termNodeB, ///
69
+ substitutionNodesMatch = substitution.matchTermNode(termNode);
70
+
71
+ variableMatches = substitutionNodesMatch; ///
72
+ } else {
73
+ const { createSubstitutions } = this.constructor;
74
+
75
+ if (createSubstitutions) {
76
+ const variableName = variableNameA, ///
77
+ termNode = termNodeB, ///
78
+ termForVariableSubstitution = TermForVariableSubstitution.fromVariableNameAndTermNode(variableName, termNode),
79
+ substitution = termForVariableSubstitution; ///
80
+
81
+ substitutions.push(substitution);
82
+ }
83
+
84
+ variableMatches = true;
85
+ }
86
+
87
+ return variableMatches;
88
+ }
89
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ export default class Verifier {
4
+ matchNode(nodeA, nodeB, substitutions) {
5
+ let nodeMatches = false;
6
+
7
+ const nodeATerminalNode = nodeA.isTerminalNode(),
8
+ nodeBTerminalNode = nodeB.isTerminalNode();
9
+
10
+ if (nodeATerminalNode === nodeBTerminalNode) {
11
+ if (nodeATerminalNode) {
12
+ const terminalNodeA = nodeA, ///
13
+ terminalNodeB = nodeB, ///
14
+ terminalNodeMatches = this.matchTerminalNode(terminalNodeA, terminalNodeB);
15
+
16
+ nodeMatches = terminalNodeMatches; ///
17
+ } else {
18
+ const nonTerminalNodeA = nodeA, ///
19
+ nonTerminalNodeB = nodeB, ///
20
+ nonTerminalNodeMatches = this.matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions);
21
+
22
+ nodeMatches = nonTerminalNodeMatches; ///
23
+ }
24
+ }
25
+
26
+ return nodeMatches;
27
+ }
28
+
29
+ matchNodes(nodesA, nodesB, substitutions) {
30
+ let nodesMatch = false;
31
+
32
+ const nodesALength = nodesA.length,
33
+ nodesBLength = nodesB.length;
34
+
35
+ if (nodesALength === nodesBLength) {
36
+ nodesMatch = nodesA.every((nodeA, index) => {
37
+ const nodeB = nodesB[index],
38
+ nodeMatches = this.matchNode(nodeA, nodeB, substitutions);
39
+
40
+ if (nodeMatches) {
41
+ return true;
42
+ }
43
+ })
44
+ }
45
+
46
+ return nodesMatch;
47
+ }
48
+
49
+ matchTerminalNode(terminalNodeA, terminalNodeB, substitutions) {
50
+ const matches = terminalNodeA.match(terminalNodeB),
51
+ terminalNodeMatches = matches; ///
52
+
53
+ return terminalNodeMatches;
54
+ }
55
+
56
+ matchNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions) {
57
+ let nonTerminalNodeMatches = false;
58
+
59
+ const nonTerminalNodeARuleName = nonTerminalNodeA.getRuleName(), ///
60
+ nonTerminalNodeBRuleName = nonTerminalNodeB.getRuleName(); ///
61
+
62
+ if (nonTerminalNodeARuleName === nonTerminalNodeBRuleName) {
63
+ const nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
64
+ nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
65
+ nodesA = nonTerminalNodeAChildNodes, ///
66
+ nodesB = nonTerminalNodeBChildNodes, ///
67
+ nodesMatch = this.matchNodes(nodesA, nodesB, substitutions);
68
+
69
+ nonTerminalNodeMatches = nodesMatch; ///
70
+ }
71
+
72
+ return nonTerminalNodeMatches;
73
+ }
74
+ }
@@ -1,56 +1,50 @@
1
1
  "use strict";
2
2
 
3
+ import Variable from "../../variable";
3
4
  import TypeAssertion from "../../assertion/type";
4
5
 
5
6
  import { first } from "../../utilities/array";
6
- import { nodeAsString } from "../../utilities/string";
7
+ import { verifyTermAsVariable } from "../../verify/term";
7
8
  import { nodeQuery, typeNameFromTypeNode } from "../../utilities/query";
8
- import { verifyTermAsVariable, verifyTermAgainstConstructors } from "../../verify/term";
9
9
 
10
10
  const termNodeQuery = nodeQuery("/typeAssertion/term"),
11
11
  typeNodeQuery = nodeQuery("/typeAssertion/type");
12
12
 
13
- export default function verifyTypeAssertion(typeAssertionNode, assertions, proofContext) {
13
+ export default function verifyTypeAssertion(typeAssertionNode, assertions, derived, proofContext) {
14
14
  let typeAssertionVerified = false;
15
15
 
16
- proofContext.begin(typeAssertionNode);
17
-
18
16
  const typeAssertionString = proofContext.nodeAsString(typeAssertionNode);
19
17
 
20
- proofContext.debug(`Verifying the '${typeAssertionString}' type assertion...`);
18
+ proofContext.debug(`Verifying the '${typeAssertionString}' type assertion...`, typeAssertionNode);
21
19
 
22
20
  const typeNode = typeNodeQuery(typeAssertionNode),
23
21
  typeName = typeNameFromTypeNode(typeNode),
24
22
  typePresent = proofContext.isTypePresentByTypeName(typeName);
25
23
 
26
24
  if (!typePresent) {
27
- proofContext.error(`The ${typeName} type is not present.`);
25
+ proofContext.error(`The ${typeName} type is not present.`, typeAssertionNode);
28
26
  } else {
29
27
  if (!typeAssertionVerified) {
30
- const variableTypeAssertionVerified = verifyVariableTypeAssertion(typeAssertionNode, assertions, proofContext);
28
+ const variableTypeAssertionVerified = verifyVariableTypeAssertion(typeAssertionNode, assertions, derived, proofContext);
31
29
 
32
30
  typeAssertionVerified = variableTypeAssertionVerified; ///
33
31
  }
34
32
 
35
- if (!typeAssertionVerified) {
36
- const termTypeAssertionVerified = verifyTermTypeAssertion(typeAssertionNode, assertions, proofContext);
37
-
38
- typeAssertionVerified = termTypeAssertionVerified; ///
39
- }
33
+ // if (!typeAssertionVerified) {
34
+ // const termTypeAssertionVerified = verifyTermTypeAssertion(typeAssertionNode, assertions, proofContext);
35
+ //
36
+ // typeAssertionVerified = termTypeAssertionVerified; ///
37
+ // }
40
38
  }
41
39
 
42
40
  if (typeAssertionVerified) {
43
- proofContext.info(`Verified the '${typeAssertionString}' statement type assertion.`);
41
+ proofContext.info(`Verified the '${typeAssertionString}' statement type assertion.`, typeAssertionNode);
44
42
  }
45
43
 
46
- typeAssertionVerified ?
47
- proofContext.complete(typeAssertionNode) :
48
- proofContext.halt(typeAssertionNode);
49
-
50
44
  return typeAssertionVerified;
51
45
  }
52
46
 
53
- function verifyVariableTypeAssertion(typeAssertionNode, assertions, proofContext) {
47
+ function verifyVariableTypeAssertion(typeAssertionNode, assertions, derived, proofContext) {
54
48
  let variableTypeAssertionVerified = false;
55
49
 
56
50
  const context = proofContext, ///
@@ -59,27 +53,39 @@ function verifyVariableTypeAssertion(typeAssertionNode, assertions, proofContext
59
53
  termVerifiedAsVariable = verifyTermAsVariable(termNode, variables, context);
60
54
 
61
55
  if (termVerifiedAsVariable) {
62
- if (assertions === null) {
63
- variableTypeAssertionVerified = true;
56
+ const typeNode = typeNodeQuery(typeAssertionNode),
57
+ typeName = typeNameFromTypeNode(typeNode),
58
+ assertedTypeName = typeName, ///
59
+ assertedType = proofContext.findTypeByTypeName(assertedTypeName),
60
+ firstVariable = first(variables),
61
+ variable = firstVariable, ///
62
+ variableName = variable.getName(),
63
+ variableType = variable.getType();
64
+
65
+ if (derived) {
66
+ const variableTypeEqualToOrSubTypeOfAssertedType = variableType.isEqualToOrSubTypeOf(assertedType);
67
+
68
+ if (!variableTypeEqualToOrSubTypeOfAssertedType) {
69
+ const assertedTypeName = assertedType.getName(),
70
+ variableTypeName = variableType.getName();
71
+
72
+ proofContext.error(`The '${variableName}' variable's '${variableTypeName}' type is not equal to or a sub-type of the '${assertedTypeName}' asserted type.`, typeAssertionNode);
73
+ } else {
74
+ variableTypeAssertionVerified = true;
75
+ }
64
76
  } else {
65
- const typeNode = typeNodeQuery(typeAssertionNode),
66
- typeName = typeNameFromTypeNode(typeNode),
67
- assertedTypeName = typeName, ///
68
- assertedType = proofContext.findTypeByTypeName(assertedTypeName),
69
- firstVariable = first(variables),
70
- variable = firstVariable, ///
71
- variableName = variable.getName(),
72
- variableType = variable.getType(),
73
- assertedTypeEqualToOrSubTypeOfVariableType = assertedType.isEqualToOrSubTypeOf(variableType);
77
+ const assertedTypeEqualToOrSubTypeOfVariableType = assertedType.isEqualToOrSubTypeOf(variableType);
74
78
 
75
79
  if (!assertedTypeEqualToOrSubTypeOfVariableType) {
76
80
  const assertedTypeName = assertedType.getName(),
77
81
  variableTypeName = variableType.getName();
78
82
 
79
- proofContext.error(`The '${assertedTypeName}' asserted type is not equal to or a sub-type of the '${variableName}' variable's '${variableTypeName}' type.`);
83
+ proofContext.error(`The '${assertedTypeName}' asserted type is not equal to or a sub-type of the '${variableName}' variable's '${variableTypeName}' type.`, typeAssertionNode);
80
84
  } else {
81
85
  const type = assertedType, ///
82
- typeAssertion = TypeAssertion.fromTypeAndVariableName(type, variableName),
86
+ name = variableName, ///
87
+ variable = Variable.fromTypeAndName(type, name),
88
+ typeAssertion = TypeAssertion.fromVariable(variable),
83
89
  assertion = typeAssertion; ///
84
90
 
85
91
  assertions.push(assertion);
@@ -92,46 +98,40 @@ function verifyVariableTypeAssertion(typeAssertionNode, assertions, proofContext
92
98
  return variableTypeAssertionVerified;
93
99
  }
94
100
 
95
- function verifyTermTypeAssertion(typeAssertionNode, assertions, proofContext) {
96
- let termTypeAssertionVerified = false;
97
-
98
- const types = [],
99
- context = proofContext, ///
100
- termNode = termNodeQuery(typeAssertionNode),
101
- termVerifiedAgainstConstructors = verifyTermAgainstConstructors(termNode, types, context);
102
-
103
- if (termVerifiedAgainstConstructors) {
104
- if (assertions === null) {
105
- termTypeAssertionVerified = true;
106
- } else {
107
- const typeNode = typeNodeQuery(typeAssertionNode),
108
- typeName = typeNameFromTypeNode(typeNode),
109
- assertedTypeName = typeName, ///
110
- assertedType = proofContext.findTypeByTypeName(assertedTypeName),
111
- firstType = first(types),
112
- termType = firstType,
113
- termString = proofContext.nodeAsString(termNode),
114
- assertedTypeEqualToTermType = (termType === null) ?
115
- true : ///
116
- assertedType.isEqualTo(termType);
117
-
118
- if (!assertedTypeEqualToTermType) {
119
- const termTypeName = termType.getName(),
120
- assertedTypeName = assertedType.getName();
121
-
122
- proofContext.error(`The '${assertedTypeName}' asserted type is not equal to the '${termString}' term's '${termTypeName}' type.`);
123
- } else {
124
- const type = assertedType, ///
125
- typeAssertion = TypeAssertion.fromTypeAndTermNode(type, termNode),
126
- assertion = typeAssertion; ///
127
-
128
- assertions.push(assertion);
129
-
130
- termTypeAssertionVerified = true;
131
- }
132
- }
133
- }
134
-
135
- return termTypeAssertionVerified;
136
- }
101
+ // function verifyTermTypeAssertion(typeAssertionNode, assertions, proofContext) {
102
+ // let termTypeAssertionVerified = false;
103
+ //
104
+ // const types = [],
105
+ // context = proofContext, ///
106
+ // termNode = termNodeQuery(typeAssertionNode),
107
+ // termVerifiedAgainstConstructors = verifyTermAgainstConstructors(termNode, types, context);
108
+ //
109
+ // if (termVerifiedAgainstConstructors) {
110
+ // const typeNode = typeNodeQuery(typeAssertionNode),
111
+ // typeName = typeNameFromTypeNode(typeNode),
112
+ // assertedTypeName = typeName, ///
113
+ // assertedType = proofContext.findTypeByTypeName(assertedTypeName),
114
+ // firstType = first(types),
115
+ // termType = firstType,
116
+ // termString = proofContext.nodeAsString(termNode),
117
+ // termTypeEqualToOrSubTypeOfAssertedType = termType.isEqualToOrSubTypeOf(assertedType);
118
+ //
119
+ // if (!termTypeEqualToOrSubTypeOfAssertedType) {
120
+ // const termTypeName = termType.getName(),
121
+ // assertedTypeName = assertedType.getName();
122
+ //
123
+ // proofContext.error(`The '${termString}' term's '${termTypeName}' type is not equal to or a sub-type of the '${assertedTypeName}' asserted type.`);
124
+ // } else {
125
+ // const type = assertedType, ///
126
+ // typeAssertion = TypeAssertion.fromTypeAndTermNode(type, termNode),
127
+ // assertion = typeAssertion; ///
128
+ //
129
+ // assertions.push(assertion);
130
+ //
131
+ // termTypeAssertionVerified = true;
132
+ // }
133
+ // }
134
+ //
135
+ // return termTypeAssertionVerified;
136
+ // }
137
137
 
@@ -7,7 +7,6 @@ import verifySupposition from "../verify/supposition";
7
7
  import verifyConsequence from "../verify/consequence";
8
8
 
9
9
  import { first } from "../utilities/array";
10
- import { nodesAsString } from "../utilities/string";
11
10
  import { nodeQuery, nodesQuery } from "../utilities/query";
12
11
 
13
12
  const labelNodesQuery = nodesQuery("/axiom/label"),
@@ -17,13 +16,11 @@ const labelNodesQuery = nodesQuery("/axiom/label"),
17
16
  export default function verifyAxiom(axiomNode, fileContext) {
18
17
  let axiomVerified = false;
19
18
 
20
- fileContext.begin(axiomNode);
21
-
22
19
  const labelNodes = labelNodesQuery(axiomNode),
23
20
  labelsString = fileContext.nodesAsString(labelNodes),
24
21
  proofContext = ProofContext.fromFileContext(fileContext);
25
22
 
26
- fileContext.debug(`Verifying the '${labelsString}' axiom...`);
23
+ fileContext.debug(`Verifying the '${labelsString}' axiom...`, axiomNode);
27
24
 
28
25
  const labels = [],
29
26
  labelsVerified = verifyLabels(labelNodes, labels, fileContext);
@@ -57,12 +54,8 @@ export default function verifyAxiom(axiomNode, fileContext) {
57
54
  }
58
55
 
59
56
  if (axiomVerified) {
60
- fileContext.info(`Verified the '${labelsString}' axiom.`);
57
+ fileContext.info(`Verified the '${labelsString}' axiom.`, axiomNode);
61
58
  }
62
59
 
63
- axiomVerified ?
64
- fileContext.complete(axiomNode) :
65
- fileContext.complete(axiomNode);
66
-
67
60
  return axiomVerified;
68
61
  }
@@ -11,11 +11,9 @@ const metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatemen
11
11
  export default function verifyConclusion(conclusionNode, conclusions, metaproofContext) {
12
12
  let conclusionVerified = false;
13
13
 
14
- metaproofContext.begin(conclusionNode);
15
-
16
14
  const conclusionString = metaproofContext.nodeAsString(conclusionNode);
17
15
 
18
- metaproofContext.debug(`Verifying the '${conclusionString}' conclusion...`);
16
+ metaproofContext.debug(`Verifying the '${conclusionString}' conclusion...`, conclusionNode);
19
17
 
20
18
  const derived = false,
21
19
  assertions = [],
@@ -31,9 +29,5 @@ export default function verifyConclusion(conclusionNode, conclusions, metaproofC
31
29
  conclusionVerified = true;
32
30
  }
33
31
 
34
- conclusionVerified ?
35
- metaproofContext.complete(conclusionNode) :
36
- metaproofContext.halt(conclusionNode);
37
-
38
32
  return conclusionVerified;
39
33
  }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ import Conjecture from "../conjecture";
4
+ import verifyProof from "../verify/proof";
5
+ import ProofContext from "../context/proof";
6
+ import verifyLabels from "../verify/labels";
7
+ import verifySupposition from "./supposition";
8
+ import verifyConsequence from "./consequence";
9
+
10
+ import { first } from "../utilities/array";
11
+ import { nodeQuery, nodesQuery } from "../utilities/query";
12
+
13
+ const proofNodeQuery = nodeQuery("/conjecture/proof!"),
14
+ labelNodesQuery = nodesQuery("/conjecture/label"),
15
+ consequenceNodeQuery = nodeQuery("/conjecture/consequence!"),
16
+ suppositionsNodeQuery = nodesQuery("/conjecture/supposition");
17
+
18
+ export default function verifyConjecture(conjectureNode, fileContext) {
19
+ let conjectureVerified = false;
20
+
21
+ const labelNodes = labelNodesQuery(conjectureNode),
22
+ labelsString = fileContext.nodesAsString(labelNodes),
23
+ proofContext = ProofContext.fromFileContext(fileContext);
24
+
25
+ fileContext.debug(`Verifying the '${labelsString}' conjecture...`, conjectureNode);
26
+
27
+ const labels = [],
28
+ labelsVerified = verifyLabels(labelNodes, labels, fileContext);
29
+
30
+ if (labelsVerified) {
31
+ const suppositions = [],
32
+ suppositionNodes = suppositionsNodeQuery(conjectureNode),
33
+ suppositionsVerified = suppositionNodes.every((suppositionNode) => {
34
+ const suppositionVerified = verifySupposition(suppositionNode, suppositions, proofContext);
35
+
36
+ if (suppositionVerified) {
37
+ return true;
38
+ }
39
+ });
40
+
41
+ if (suppositionsVerified) {
42
+ const consequences = [],
43
+ consequenceNode = consequenceNodeQuery(conjectureNode),
44
+ consequenceVerified = verifyConsequence(consequenceNode, consequences, proofContext);
45
+
46
+ if (consequenceVerified) {
47
+ const proofNode = proofNodeQuery(conjectureNode),
48
+ firstConsequence = first(consequences),
49
+ consequence = firstConsequence; ///
50
+
51
+ verifyProof(proofNode, consequence, proofContext);
52
+
53
+ const conjecture = Conjecture.fromLabelsSuppositionsAndConsequence(labels, suppositions, consequence);
54
+
55
+ fileContext.addConjecture(conjecture);
56
+
57
+ conjectureVerified = true;
58
+ }
59
+ }
60
+ }
61
+
62
+ if (conjectureVerified) {
63
+ fileContext.info(`Verified the '${labelsString}' conjecture.`, conjectureNode);
64
+ }
65
+
66
+ return conjectureVerified;
67
+ }
@@ -11,11 +11,9 @@ const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
11
11
  export default function verifyConsequence(consequenceNode, consequences, proofContext) {
12
12
  let consequenceVerified = false;
13
13
 
14
- proofContext.begin(consequenceNode);
15
-
16
14
  const consequenceString = proofContext.nodeAsString(consequenceNode);
17
15
 
18
- proofContext.debug(`Verifying the '${consequenceString}' consequence...`);
16
+ proofContext.debug(`Verifying the '${consequenceString}' consequence...`, consequenceNode);
19
17
 
20
18
  const derived = false,
21
19
  assertions = [],
@@ -31,9 +29,5 @@ export default function verifyConsequence(consequenceNode, consequences, proofCo
31
29
  consequenceVerified = true;
32
30
  }
33
31
 
34
- consequenceVerified ?
35
- proofContext.complete(consequenceNode) :
36
- proofContext.halt(consequenceNode);
37
-
38
32
  return consequenceVerified;
39
33
  }
@@ -9,16 +9,10 @@ const statementNodeQuery = nodeQuery("/combinatorDeclaration/statement");
9
9
  export default function verifyCombinatorDeclaration(combinatorDeclarationNode, fileContext) {
10
10
  let combinatorDeclarationVerified;
11
11
 
12
- fileContext.begin(combinatorDeclarationNode);
13
-
14
12
  const statementNode = statementNodeQuery(combinatorDeclarationNode),
15
13
  statementVerifiedAsCombinator = verifyStatementAsCombinator(statementNode, fileContext);
16
14
 
17
15
  combinatorDeclarationVerified = statementVerifiedAsCombinator; ///
18
16
 
19
- combinatorDeclarationVerified ?
20
- fileContext.complete(combinatorDeclarationNode) :
21
- fileContext.halt(combinatorDeclarationNode);
22
-
23
17
  return combinatorDeclarationVerified;
24
18
  }
@@ -10,17 +10,11 @@ const termNodeQuery = nodeQuery("/constructorDeclaration/term"),
10
10
  export default function verifyConstructorDeclaration(constructorDeclarationNode, fileContext) {
11
11
  let constructorDeclarationVerified;
12
12
 
13
- fileContext.begin(constructorDeclarationNode);
14
-
15
13
  const termNode = termNodeQuery(constructorDeclarationNode),
16
14
  typeNode = typeNodeQuery(constructorDeclarationNode),
17
15
  termVerifiedAsConstructor = verifyTermAsConstructor(termNode, typeNode, fileContext);
18
16
 
19
17
  constructorDeclarationVerified = termVerifiedAsConstructor; ///
20
18
 
21
- constructorDeclarationVerified ?
22
- fileContext.complete(constructorDeclarationNode) :
23
- fileContext.halt(constructorDeclarationNode);
24
-
25
19
  return constructorDeclarationVerified;
26
20
  }
@@ -4,6 +4,7 @@ import verifyRule from "../../verify/rule";
4
4
  import verifyAxiom from "../../verify/axiom";
5
5
  import verifyLemma from "../../verify/lemma";
6
6
  import verifyTheorem from "../../verify/theorem";
7
+ import verifyConjecture from "../../verify/conjecture";
7
8
  import verifyTypeDeclaration from "../../verify/declaration/type";
8
9
  import verifyVariableDeclaration from "../../verify/declaration/variable";
9
10
  import verifyCombinatorDeclaration from "../../verify/declaration/combinator";
@@ -15,6 +16,7 @@ const ruleNodeQuery = nodeQuery("/topLevelDeclaration/rule!"),
15
16
  axiomNodeQuery = nodeQuery("/topLevelDeclaration/axiom!"),
16
17
  lemmaNodeQuery = nodeQuery("/topLevelDeclaration/lemma!"),
17
18
  theoremNodeQuery = nodeQuery("/topLevelDeclaration/theorem!"),
19
+ conjectureNodeQuery = nodeQuery("/topLevelDeclaration/conjecture!"),
18
20
  typeDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/typeDeclaration!"),
19
21
  variableDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/variableDeclaration!"),
20
22
  combinatorDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/combinatorDeclaration!"),
@@ -23,13 +25,12 @@ const ruleNodeQuery = nodeQuery("/topLevelDeclaration/rule!"),
23
25
  export default function verifyTopLevelDeclaration(topLevelDeclarationNode, fileContext) {
24
26
  let topLevelDeclarationVerified = false;
25
27
 
26
- fileContext.begin(topLevelDeclarationNode);
27
-
28
28
  const node = topLevelDeclarationNode, ///
29
29
  ruleNode = ruleNodeQuery(node),
30
30
  axiomNode = axiomNodeQuery(node),
31
31
  lemmaNode = lemmaNodeQuery(node),
32
32
  theoremNode = theoremNodeQuery(node),
33
+ conjectureNode = conjectureNodeQuery(node),
33
34
  typeDeclarationNode = typeDeclarationNodeQuery(node),
34
35
  variableDeclarationNode = variableDeclarationNodeQuery(node),
35
36
  combinatorDeclarationNode = combinatorDeclarationNodeQuery(node),
@@ -53,6 +54,10 @@ export default function verifyTopLevelDeclaration(topLevelDeclarationNode, fileC
53
54
  const theoremVerified = verifyTheorem(theoremNode, fileContext);
54
55
 
55
56
  topLevelDeclarationVerified = theoremVerified; ///
57
+ } else if (conjectureNode !== null) {
58
+ const conjectureVerified = verifyConjecture(conjectureNode, fileContext);
59
+
60
+ topLevelDeclarationVerified = conjectureVerified; ///
56
61
  } else if (typeDeclarationNode !== null) {
57
62
  const typeDeclarationVerified = verifyTypeDeclaration(typeDeclarationNode, fileContext);
58
63
 
@@ -71,9 +76,5 @@ export default function verifyTopLevelDeclaration(topLevelDeclarationNode, fileC
71
76
  topLevelDeclarationVerified = constructorDeclarationVerified; ///
72
77
  }
73
78
 
74
- topLevelDeclarationVerified ?
75
- fileContext.complete(topLevelDeclarationNode) :
76
- fileContext.halt(topLevelDeclarationNode);
77
-
78
79
  return topLevelDeclarationVerified;
79
80
  }
@@ -10,8 +10,6 @@ const firstTypeNodeQuery = nodeQuery("/typeDeclaration/type[0]"),
10
10
  export default function verifyTypeDeclaration(typeDeclarationNode, fileContext) {
11
11
  let typeDeclarationVerified;
12
12
 
13
- fileContext.begin(typeDeclarationNode);
14
-
15
13
  const firstTypeNode = firstTypeNodeQuery(typeDeclarationNode),
16
14
  secondTypeNode = secondTypeNodeQuery(typeDeclarationNode),
17
15
  typeNode = firstTypeNode, ///
@@ -21,9 +19,5 @@ export default function verifyTypeDeclaration(typeDeclarationNode, fileContext)
21
19
 
22
20
  typeDeclarationVerified = typeVerified; ///
23
21
 
24
- typeDeclarationVerified ?
25
- fileContext.complete(typeDeclarationNode) :
26
- fileContext.halt(typeDeclarationNode);
27
-
28
22
  return typeDeclarationVerified;
29
23
  }
@@ -10,17 +10,11 @@ const typeNodeQuery = nodeQuery("/variableDeclaration/type"),
10
10
  export default function verifyVariableDeclaration(variableDeclarationNode, fileContext) {
11
11
  let variableDeclarationVerified;
12
12
 
13
- fileContext.begin(variableDeclarationNode);
14
-
15
13
  const typeNode = typeNodeQuery(variableDeclarationNode),
16
14
  variableNode = variableNodeQuery(variableDeclarationNode),
17
15
  variableVVerified = verifyVariable(variableNode, typeNode, fileContext);
18
16
 
19
17
  variableDeclarationVerified = variableVVerified; ///
20
18
 
21
- variableDeclarationVerified ?
22
- fileContext.complete(variableDeclarationNode) :
23
- fileContext.halt(variableDeclarationNode);
24
-
25
19
  return variableDeclarationVerified;
26
20
  }