occam-verify-cli 0.0.1016 → 0.0.1020

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 (151) hide show
  1. package/lib/argument.js +12 -11
  2. package/lib/assignment/equality.js +3 -3
  3. package/lib/axiom.js +102 -6
  4. package/lib/combinator.js +12 -12
  5. package/lib/conclusion.js +3 -4
  6. package/lib/consequent.js +75 -14
  7. package/lib/constructor/bracketed.js +3 -3
  8. package/lib/constructor.js +68 -18
  9. package/lib/context/file.js +49 -89
  10. package/lib/context/local.js +34 -58
  11. package/lib/declaration/combinator.js +3 -3
  12. package/lib/declaration/metavariable.js +15 -4
  13. package/lib/declaration/type.js +3 -3
  14. package/lib/declaration/variable.js +146 -0
  15. package/lib/equality.js +95 -19
  16. package/lib/index.js +6 -1
  17. package/lib/label.js +9 -9
  18. package/lib/lemma.js +107 -6
  19. package/lib/metavariable.js +14 -21
  20. package/lib/mixins/statement/qualified/unify.js +3 -3
  21. package/lib/mixins/statement/verify.js +4 -5
  22. package/lib/mixins/term/unify.js +82 -0
  23. package/lib/mixins/term/verify.js +44 -0
  24. package/lib/node/term/constructor/bracketed.js +15 -11
  25. package/lib/premise.js +3 -5
  26. package/lib/proofStep.js +2 -2
  27. package/lib/reference.js +9 -9
  28. package/lib/rule.js +5 -5
  29. package/lib/ruleNames.js +5 -5
  30. package/lib/statement/qualified.js +6 -3
  31. package/lib/statement.js +22 -39
  32. package/lib/supposition.js +75 -50
  33. package/lib/term.js +62 -16
  34. package/lib/topLevelAssertion.js +98 -33
  35. package/lib/type.js +22 -31
  36. package/lib/unifier/equality.js +12 -4
  37. package/lib/unifier/intrinsicLevel.js +1 -4
  38. package/lib/unifier/metaLevel.js +1 -4
  39. package/lib/unifier/metavariable.js +10 -7
  40. package/lib/unifier/statementWithCombinator.js +18 -9
  41. package/lib/unifier/termWithConstructor.js +11 -4
  42. package/lib/unify/frameWithMetaType.js +2 -2
  43. package/lib/utilities/name.js +9 -2
  44. package/lib/utilities/node.js +14 -14
  45. package/lib/utilities/tokens.js +7 -7
  46. package/lib/utilities/unify.js +3 -3
  47. package/lib/variable.js +155 -20
  48. package/lib/verifier/statementAsCombinator.js +2 -2
  49. package/lib/verifier/termAsConstructor.js +2 -2
  50. package/lib/verifier/topLevel.js +7 -7
  51. package/lib/verify/assertion/type.js +3 -4
  52. package/lib/verify/conjecture.js +2 -3
  53. package/lib/verify/frame.js +2 -6
  54. package/lib/verify/lemma.js +2 -3
  55. package/lib/verify/metaLemma.js +2 -3
  56. package/lib/verify/metatheorem.js +2 -3
  57. package/lib/verify/metavariableGivenMetaType.js +3 -3
  58. package/lib/verify/theorem.js +2 -3
  59. package/package.json +1 -1
  60. package/src/argument.js +11 -9
  61. package/src/assignment/equality.js +3 -4
  62. package/src/axiom.js +78 -1
  63. package/src/combinator.js +10 -9
  64. package/src/conclusion.js +2 -4
  65. package/src/consequent.js +88 -13
  66. package/src/constructor/bracketed.js +4 -1
  67. package/src/constructor.js +18 -14
  68. package/src/context/file.js +50 -93
  69. package/src/context/local.js +13 -31
  70. package/src/declaration/combinator.js +2 -2
  71. package/src/declaration/metavariable.js +20 -6
  72. package/src/declaration/type.js +2 -2
  73. package/src/declaration/variable.js +78 -0
  74. package/src/equality.js +123 -22
  75. package/src/index.js +6 -0
  76. package/src/label.js +7 -7
  77. package/src/lemma.js +91 -1
  78. package/src/metavariable.js +13 -22
  79. package/src/mixins/statement/qualified/unify.js +2 -2
  80. package/src/mixins/statement/verify.js +5 -5
  81. package/src/mixins/term/unify.js +110 -0
  82. package/src/mixins/term/verify.js +47 -0
  83. package/src/node/term/constructor/bracketed.js +4 -3
  84. package/src/premise.js +2 -5
  85. package/src/proofStep.js +1 -1
  86. package/src/reference.js +7 -7
  87. package/src/rule.js +4 -4
  88. package/src/ruleNames.js +1 -1
  89. package/src/statement/qualified.js +7 -3
  90. package/src/statement.js +28 -60
  91. package/src/supposition.js +106 -53
  92. package/src/term.js +70 -14
  93. package/src/topLevelAssertion.js +120 -33
  94. package/src/type.js +39 -41
  95. package/src/unifier/equality.js +15 -3
  96. package/src/unifier/intrinsicLevel.js +0 -4
  97. package/src/unifier/metaLevel.js +0 -4
  98. package/src/unifier/metavariable.js +16 -8
  99. package/src/unifier/statementWithCombinator.js +33 -11
  100. package/src/unifier/termWithConstructor.js +17 -4
  101. package/src/unify/frameWithMetaType.js +1 -1
  102. package/src/utilities/name.js +9 -1
  103. package/src/utilities/node.js +14 -14
  104. package/src/utilities/tokens.js +4 -4
  105. package/src/utilities/unify.js +2 -2
  106. package/src/variable.js +158 -22
  107. package/src/verifier/statementAsCombinator.js +1 -1
  108. package/src/verifier/termAsConstructor.js +1 -1
  109. package/src/verifier/topLevel.js +9 -6
  110. package/src/verify/assertion/type.js +1 -1
  111. package/src/verify/conjecture.js +1 -1
  112. package/src/verify/frame.js +1 -7
  113. package/src/verify/lemma.js +1 -1
  114. package/src/verify/metaLemma.js +1 -1
  115. package/src/verify/metatheorem.js +1 -1
  116. package/src/verify/metavariableGivenMetaType.js +2 -2
  117. package/src/verify/theorem.js +1 -1
  118. package/lib/tokens/constructorTerm/bracketed.js +0 -17
  119. package/lib/unify/termWithBracketedConstructor.js +0 -39
  120. package/lib/unify/termWithConstructor.js +0 -37
  121. package/lib/unify/termWithConstructors.js +0 -34
  122. package/lib/unify/termWithTerm.js +0 -27
  123. package/lib/unify/termWithType.js +0 -24
  124. package/lib/verify/axiom.js +0 -45
  125. package/lib/verify/consequent.js +0 -38
  126. package/lib/verify/declaration/variable.js +0 -67
  127. package/lib/verify/equality.js +0 -92
  128. package/lib/verify/proofStep.js +0 -28
  129. package/lib/verify/term.js +0 -97
  130. package/lib/verify/termAsConstructor.js +0 -58
  131. package/lib/verify/termGivenType.js +0 -34
  132. package/lib/verify/terms.js +0 -38
  133. package/lib/verify/type.js +0 -23
  134. package/lib/verify/variable.js +0 -25
  135. package/src/tokens/constructorTerm/bracketed.js +0 -10
  136. package/src/unify/termWithBracketedConstructor.js +0 -39
  137. package/src/unify/termWithConstructor.js +0 -39
  138. package/src/unify/termWithConstructors.js +0 -27
  139. package/src/unify/termWithTerm.js +0 -24
  140. package/src/unify/termWithType.js +0 -14
  141. package/src/verify/axiom.js +0 -56
  142. package/src/verify/consequent.js +0 -40
  143. package/src/verify/declaration/variable.js +0 -85
  144. package/src/verify/equality.js +0 -118
  145. package/src/verify/proofStep.js +0 -21
  146. package/src/verify/term.js +0 -123
  147. package/src/verify/termAsConstructor.js +0 -66
  148. package/src/verify/termGivenType.js +0 -32
  149. package/src/verify/terms.js +0 -38
  150. package/src/verify/type.js +0 -19
  151. package/src/verify/variable.js +0 -21
package/src/reference.js CHANGED
@@ -25,20 +25,20 @@ export default class Reference {
25
25
  return metavariableNode;
26
26
  }
27
27
 
28
- verify(fileContext) {
29
- let verified;
28
+ verifyAtTopLevel(fileContext) {
29
+ let verifiedAtTopLevel;
30
30
 
31
31
  const referenceString = this.getString(); ///
32
32
 
33
- fileContext.trace(`Verifying the '${referenceString}' reference...`);
33
+ fileContext.trace(`Verifying the '${referenceString}' reference at top level...`);
34
34
 
35
- verified = true;
35
+ verifiedAtTopLevel = true;
36
36
 
37
- if (verified) {
38
- fileContext.debug(`...verified the '${referenceString}' reference.`);
37
+ if (verifiedAtTopLevel) {
38
+ fileContext.debug(`...verified the '${referenceString}' reference at top level.`);
39
39
  }
40
40
 
41
- return verified;
41
+ return verifiedAtTopLevel;
42
42
  }
43
43
 
44
44
  toJSON() {
package/src/rule.js CHANGED
@@ -97,15 +97,15 @@ export default class Rule {
97
97
 
98
98
  this.fileContext.trace(`Verifying the '${labelsString}' rule...`);
99
99
 
100
- const labelsVerified = this.labels.every((label) => {
101
- const labelVVerified = label.verify(this.fileContext);
100
+ const labelsVerifiedAtTopLevel = this.labels.every((label) => {
101
+ const labelVVerifiedAtTopLevel = label.verifyAtTopLevel(this.fileContext);
102
102
 
103
- if (labelVVerified) {
103
+ if (labelVVerifiedAtTopLevel) {
104
104
  return true;
105
105
  }
106
106
  });
107
107
 
108
- if (labelsVerified) {
108
+ if (labelsVerifiedAtTopLevel) {
109
109
  const localContext = LocalContext.fromFileContext(this.fileContext),
110
110
  premisesVerified = this.premises.every((premise) => {
111
111
  const premiseVerified = premise.verify(localContext);
package/src/ruleNames.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- export const TERM_RULE_NAME = "term";
3
+ export const VARIABLE_RULE_NAME = "variable";
4
4
  export const METAVARIABLE_RULE_NAME = "metavariable";
5
5
  export const UNQUALIFIED_STATEMENT_RULE_NAME = "unqualifiedStatement";
6
6
  export const CONSTRUCTOR_DECLARATION_RULE_NAME = "constructorDeclaration";
@@ -65,7 +65,7 @@ export default class QualifiedStatement {
65
65
  let unified;
66
66
 
67
67
  const qualifiedStatement = this, ///
68
- qualifiedStatementString = trim(this.string); ///
68
+ qualifiedStatementString = this.string; ///
69
69
 
70
70
  localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement...`);
71
71
 
@@ -86,13 +86,17 @@ export default class QualifiedStatement {
86
86
  let qualifiedStatement = null;
87
87
 
88
88
  if (qualifiedStatementNode !== null) {
89
+ let string;
89
90
  const statementNode = statementNodeQuery(qualifiedStatementNode),
90
91
  referenceNode = referenceNodeQuery(qualifiedStatementNode),
91
92
  localContext = LocalContext.fromFileContext(fileContext),
92
93
  statement = Statement.fromStatementNode(statementNode, localContext),
93
94
  reference = Reference.fromReferenceNode(referenceNode, fileContext),
94
- node = qualifiedStatementNode, ///
95
- string = trim(fileContext.nodeAsString(node)); ///
95
+ node = qualifiedStatementNode; ///
96
+
97
+ string = fileContext.nodeAsString(node);
98
+
99
+ string = trim(string); ///
96
100
 
97
101
  qualifiedStatement = new QualifiedStatement(string, statement, reference);
98
102
  }
package/src/statement.js CHANGED
@@ -5,8 +5,8 @@ import unifyMixins from "./mixins/statement/unify";
5
5
  import verifyMixins from "./mixins/statement/verify";
6
6
  import statementAsCombinatorVerifier from "./verifier/statementAsCombinator";
7
7
 
8
+ import { STATEMENT_META_TYPE_NAME } from "./metaTypeNames";
8
9
  import { statementNodeFromStatementString } from "./utilities/node";
9
- import { FRAME_META_TYPE_NAME, REFERENCE_META_TYPE_NAME, STATEMENT_META_TYPE_NAME } from "./metaTypeNames";
10
10
 
11
11
  class Statement {
12
12
  constructor(string, node) {
@@ -39,13 +39,15 @@ class Statement {
39
39
  localContext.trace(`Verifying the '${statementString}' statement...`);
40
40
 
41
41
  if (!verified) {
42
- verified = unifyMixins.some((unifyMixin) => { ///
42
+ const unified = unifyMixins.some((unifyMixin) => {
43
43
  const unified = unifyMixin(statement, assignments, stated, localContext);
44
44
 
45
45
  if (unified) {
46
46
  return true;
47
47
  }
48
48
  });
49
+
50
+ verified = unified; ///
49
51
  }
50
52
 
51
53
  if (!verified) {
@@ -65,70 +67,41 @@ class Statement {
65
67
  return verified;
66
68
  }
67
69
 
68
- unifyWithMetaType(metaType, assignments, stated, localContext) {
69
- let unifiedWithMetaType;
70
-
71
- const verifiedGivenMetaType = this.verifyGivenMetaType(metaType, assignments, stated, localContext);
72
-
73
- unifiedWithMetaType = verifiedGivenMetaType; ///
74
-
75
- return unifiedWithMetaType;
76
- }
77
-
78
- verifyAsCombinator(fileContext) {
79
- let verifiedAsCombinator;
70
+ verifyAtTopLevel(fileContext) {
71
+ let verifiedAtTopLevel;
80
72
 
81
73
  const statementNode = this.node, ///
82
74
  statementString = this.string; ///
83
75
 
84
- fileContext.trace(`Verifying the '${statementString}' statement as a combinator...`);
76
+ fileContext.trace(`Verifying the '${statementString}' statement at top level...`);
85
77
 
86
- verifiedAsCombinator = statementAsCombinatorVerifier.verifyStatement(statementNode, fileContext);
78
+ verifiedAtTopLevel = statementAsCombinatorVerifier.verifyStatement(statementNode, fileContext);
87
79
 
88
- if (verifiedAsCombinator) {
89
- fileContext.debug(`...verified the '${statementString}' statement as a combinator.`, statementNode);
80
+ if (verifiedAtTopLevel) {
81
+ fileContext.debug(`...verified the '${statementString}' statement at top level.`, statementNode);
90
82
  }
91
83
 
92
- return verifiedAsCombinator;
84
+ return verifiedAtTopLevel;
93
85
  }
94
86
 
95
87
  verifyGivenMetaType(metaType, assignments, stated, localContext) {
96
- let verifiedGivenMetaType;
88
+ let verifiedGivenMetaType = false;
89
+
90
+ const metaTypeString = metaType.getString(),
91
+ statementString = this.string; ///
92
+
93
+ localContext.trace(`Verifying the '${statementString}' given the '${metaTypeString}' meta-type...`);
97
94
 
98
95
  const metaTypeName = metaType.getName();
99
96
 
100
- switch (metaTypeName) {
101
- case FRAME_META_TYPE_NAME:
102
- case REFERENCE_META_TYPE_NAME: {
103
- debugger
104
-
105
- // verifiedGivenMetaType = false;
106
- //
107
- // const metavariableNode = metavariableNodeQuery(statementNode);
108
- //
109
- // if (metavariableNode !== null) {
110
- // const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
111
- // metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
112
- //
113
- // if (metavariable !== null) {
114
- // const metavariableMetaType = metavariable.getMetaType();
115
- //
116
- // if (metavariableMetaType === metaType) {
117
- // verifiedGivenMetaType = true;
118
- // }
119
- // }
120
- // }
121
-
122
- break;
123
- }
124
-
125
- case STATEMENT_META_TYPE_NAME: {
126
- const verified = this.verify(assignments, stated, localContext)
127
-
128
- verifiedGivenMetaType = verified; ///
129
-
130
- break;
131
- }
97
+ if (metaTypeName === STATEMENT_META_TYPE_NAME) {
98
+ const verified = this.verify(assignments, stated, localContext)
99
+
100
+ verifiedGivenMetaType = verified; ///
101
+ }
102
+
103
+ if (verifiedGivenMetaType) {
104
+ localContext.debug(`...verified the '${statementString}' given the '${metaTypeString}' meta-type.`);
132
105
  }
133
106
 
134
107
  return verifiedGivenMetaType;
@@ -156,14 +129,9 @@ class Statement {
156
129
  }
157
130
 
158
131
  static fromStatementNode(statementNode, localContext) {
159
- let statement;
160
-
161
- if (statementNode !== null) {
162
- const node = statementNode, ///
163
- string = localContext.nodeAsString(node);
164
-
165
- statement = new Statement(string, node);
166
- }
132
+ const node = statementNode, ///
133
+ string = localContext.nodeAsString(node),
134
+ statement = new Statement(string, node);
167
135
 
168
136
  return statement;
169
137
  }
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  import ProofStep from "./proofStep";
4
+ import LocalContext from "./context/local";
5
+ import metaLevelUnifier from "./unifier/metaLevel";
6
+ import SubproofAssertion from "./assertion/subproof";
4
7
  import UnqualifiedStatement from "./statement/unqualified";
5
8
 
6
- import { trim } from "./utilities/string";
7
9
  import { nodeQuery } from "./utilities/query";
8
10
  import { assignAssignments } from "./utilities/assignments";
9
11
 
@@ -27,56 +29,86 @@ export default class Supposition {
27
29
 
28
30
  getStatement() { return this.unqualifiedStatement.getStatement(); }
29
31
 
30
- // unifyStatement(statementNodeB, substitutions, localContextA, localContextB) {
31
- // let statementUnified = false;
32
- //
33
- // if (this.statementNode !== null) {
34
- // const nodeA = this.statementNode, ///
35
- // nodeB = statementNodeB, ///
36
- // unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
37
- //
38
- // statementUnified = unified; ///
39
- // }
40
- //
41
- // return statementUnified;
42
- // }
43
-
44
- // unifySubproof(subproofNodeB, substitutions, localContextA, localContextB) {
45
- // let subproofUnified = false;
46
- //
47
- // if (this.statementNode !== null) {
48
- // const statementNodeA = this.statementNode,
49
- // subproofAssertionNodeA = subproofAssertionNodeQuery(statementNodeA); ///
50
- //
51
- // if (subproofAssertionNodeA !== null) {
52
- // const subproofAssertionStatementNodesA = subproofAssertionStatementNodesQuery(subproofAssertionNodeA), ///
53
- // subproofSuppositionStatementNodesB = subproofSuppositionStatementNodesQuery(subproofNodeB), ///
54
- // subproofLastProofStepStatementNodeB = subproofLastProofStepStatementNodeQuery(subproofNodeB), ///
55
- // subproofStatementNodesB = [
56
- // ...subproofSuppositionStatementNodesB,
57
- // subproofLastProofStepStatementNodeB
58
- // ];
59
- //
60
- // subproofUnified = match(subproofAssertionStatementNodesA, subproofStatementNodesB, (subproofAssertionStatementNodeA, subproofStatementNodeB) => {
61
- // const nodeA = subproofAssertionStatementNodeA, ///
62
- // nodeB = subproofStatementNodeB, ///
63
- // unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
64
- //
65
- // if (unified) {
66
- // return true;
67
- // }
68
- // });
69
- // }
70
- // }
71
- //
72
- // return subproofUnified;
73
- // }
32
+ unifyProofStep(proofStep, substitutions, localContext) {
33
+ let proofStepUnified = false;
34
+
35
+ const subproof = proofStep.getSubproof(),
36
+ statement = proofStep.getStatement();
37
+
38
+ substitutions.snapshot();
39
+
40
+ if (false) {
41
+ ///
42
+ } else if (subproof !== null) {
43
+ proofStepUnified = this.unifySubproof(subproof, substitutions, localContext);
44
+ } else if (statement !== null) {
45
+ proofStepUnified = this.unifyStatement(statement, substitutions, localContext);
46
+ }
47
+
48
+ proofStepUnified ?
49
+ substitutions.continue() :
50
+ substitutions.rollback(localContext);
51
+
52
+ return proofStepUnified;
53
+ }
54
+
55
+ unifyStatement(statement, substitutions, localContext) {
56
+ let statementUnified;
57
+
58
+ const supposition = this, ///
59
+ statementString = statement.getString(),
60
+ suppositionStatement = supposition.getStatement(),
61
+ suppositionStatementString = suppositionStatement.getString();
62
+
63
+ localContext.trace(`Unifying the '${statementString}' statement with the supposition's '${suppositionStatementString}' statement...`);
64
+
65
+ const statementNode = statement.getNode(),
66
+ suppositionStatementNode = suppositionStatement.getNode(),
67
+ nodeA = suppositionStatementNode, ///
68
+ nodeB = statementNode, ///
69
+ fileContextA = this.fileContext, ///
70
+ localContextA = LocalContext.fromFileContext(fileContextA),
71
+ localContextB = localContext, ///
72
+ unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
73
+
74
+ statementUnified = unified; ///
75
+
76
+ if (statementUnified) {
77
+ localContext.debug(`...unified the '${statementString}' statement with the supposition's '${suppositionStatementString}' statement.`);
78
+ }
79
+
80
+ return statementUnified;
81
+ }
82
+
83
+ unifySubproof(subproof, substitutions, localContext) {
84
+ let subproofUnified = false;
85
+
86
+ const supposition = this, ///
87
+ subproofString = subproof.getString(),
88
+ suppositionStatement = supposition.getStatement(),
89
+ suppositionStatementString = suppositionStatement.getString();
90
+
91
+ localContext.trace(`Unifying the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement...`);
92
+
93
+ const statement = this.unqualifiedStatement.getStatement(),
94
+ statementNode = statement.getNode(),
95
+ subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, this.fileContext);
96
+
97
+ if (subproofAssertion !== null) {
98
+ subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, localContext);
99
+ }
100
+
101
+ if (subproofUnified) {
102
+ localContext.debug(`...unified the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement.`);
103
+ }
104
+
105
+ return subproofUnified;
106
+ }
74
107
 
75
108
  verify(localContext) {
76
- let verified = false,
77
- suppositionString = this.getString(); ///
109
+ let verified = false;
78
110
 
79
- suppositionString = trim(suppositionString); ///
111
+ const suppositionString = this.getString(); ///
80
112
 
81
113
  if (this.unqualifiedStatement !== null) {
82
114
  localContext.trace(`Verifying the '${suppositionString}' supposition...`);
@@ -97,22 +129,43 @@ export default class Supposition {
97
129
  }
98
130
  }
99
131
 
132
+ if (verified) {
133
+ localContext.debug(`...verified the '${suppositionString}' supposition.`);
134
+ }
100
135
  } else {
101
136
  localContext.debug(`The '${suppositionString}' supposition cannot be verified because it is nonsense.`);
102
137
  }
103
138
 
104
- if (verified) {
105
- localContext.debug(`...verified the '${suppositionString}' supposition.`);
106
- }
107
-
108
139
  return verified;
109
140
  }
110
141
 
142
+ toJSON() {
143
+ const unqualifiedStatementJSON = this.unqualifiedStatement.toJSON(),
144
+ unqualifiedStatement = unqualifiedStatementJSON, ///
145
+ json = {
146
+ unqualifiedStatement
147
+ };
148
+
149
+ return json;
150
+ }
151
+
152
+ static fromJSON(json, fileContext) {
153
+ let { unqualifiedStatement } = json;
154
+
155
+ json = unqualifiedStatement; ///
156
+
157
+ unqualifiedStatement = UnqualifiedStatement.fromJSON(json, fileContext);
158
+
159
+ const supposition = new Supposition(fileContext, unqualifiedStatement);
160
+
161
+ return supposition;
162
+ }
163
+
111
164
  static fromSuppositionNode(suppositionNode, fileContext) {
112
165
  const unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
113
166
  unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
114
167
  supposition = new Supposition(fileContext, unqualifiedStatement);
115
168
 
116
- return supposition;
169
+ return supposition
117
170
  }
118
171
  }
package/src/term.js CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  import shim from "./shim";
4
4
  import Type from "./type";
5
+ import unifyMixins from "./mixins/term/unify";
6
+ import verifyMixins from "./mixins/term/verify";
5
7
  import termAsConstructorVerifier from "./verifier/termAsConstructor";
6
8
 
7
9
  import { filter } from "./utilities/array";
@@ -29,6 +31,10 @@ class Term {
29
31
  return this.type;
30
32
  }
31
33
 
34
+ setType(type) {
35
+ this.type = type;
36
+ }
37
+
32
38
  match(term) {
33
39
  const node = term.getNode(),
34
40
  matches = this.node.match(node);
@@ -91,17 +97,38 @@ class Term {
91
97
  return implicitlyGrounded;
92
98
  }
93
99
 
94
- verify(fileContext) {
100
+ verify(localContext, verifyAhead) {
95
101
  let verified = false;
96
102
 
97
- const termString = this.string; ///
103
+ const term = this, ///
104
+ termString = this.string; ///
105
+
106
+ localContext.trace(`Verifying the '${termString}' term...`);
107
+
108
+ if (!verified) {
109
+ const unified = unifyMixins.some((unifyMixin) => { ///
110
+ const unified = unifyMixin(term, localContext, verifyAhead);
111
+
112
+ if (unified) {
113
+ return true;
114
+ }
115
+ });
98
116
 
99
- fileContext.trace(`Verifying the '${termString}' term...`);
117
+ verified = unified; ///
118
+ }
119
+
120
+ if (!verified) {
121
+ verified = verifyMixins.some((verifyMixin) => {
122
+ const verified = verifyMixin(term, localContext, verifyAhead);
100
123
 
101
- debugger
124
+ if (verified) {
125
+ return true;
126
+ }
127
+ });
128
+ }
102
129
 
103
130
  if (verified) {
104
- fileContext.debug(`...verified the '${termString}' type.`);
131
+ localContext.debug(`...verified the '${termString}' term.`);
105
132
  }
106
133
 
107
134
  return verified;
@@ -135,22 +162,51 @@ class Term {
135
162
  return typeVerified;
136
163
  }
137
164
 
138
- verifyAsConstructor(fileContext) {
139
- let verifiedAsConstructor;
165
+ verifyGivenType(type, localContext) {
166
+ let verifiedGivenType;
167
+
168
+ const termString = this.getString(),
169
+ typeString = type.getString();
170
+
171
+ localContext.trace(`Verifying the '${termString}' term given the '${typeString}' type...`);
172
+
173
+ const verified = this.verify(localContext, () => {
174
+ let verifiedAhead;
175
+
176
+ const typeEqualToOrSubTypeOfGivenTypeType = this.type.isEqualToOrSubTypeOf(type);
177
+
178
+ if (typeEqualToOrSubTypeOfGivenTypeType) {
179
+ verifiedAhead = true;
180
+ }
181
+
182
+ return verifiedAhead;
183
+ });
184
+
185
+ verifiedGivenType = verified; ///
186
+
187
+ if (verifiedGivenType) {
188
+ localContext.debug(`...verified the '${termString}' term given the '${typeString}' type.`);
189
+ }
190
+
191
+ return verifiedGivenType;
192
+ }
193
+
194
+ verifyAtTopLevel(fileContext) {
195
+ let verifiedAtTopLevel;
140
196
 
141
197
  const termString = this.string; ///
142
198
 
143
- fileContext.trace(`Verifying the '${termString}' term as a constructor...`);
199
+ fileContext.trace(`Verifying the '${termString}' term at top level...`);
144
200
 
145
201
  const termNode = this.node; ///
146
202
 
147
- verifiedAsConstructor = termAsConstructorVerifier.verifyTerm(termNode, fileContext);
203
+ verifiedAtTopLevel = termAsConstructorVerifier.verifyTerm(termNode, fileContext);
148
204
 
149
- if (verifiedAsConstructor) {
150
- fileContext.debug(`...verified the '${termString}' term as a constructor.`, termNode);
205
+ if (verifiedAtTopLevel) {
206
+ fileContext.debug(`...verified the '${termString}' term at top level.`, termNode);
151
207
  }
152
208
 
153
- return verifiedAsConstructor;
209
+ return verifiedAtTopLevel;
154
210
  }
155
211
 
156
212
  toJSON() {
@@ -190,9 +246,9 @@ class Term {
190
246
  return term;
191
247
  }
192
248
 
193
- static fromTermNode(termNode, fileContext) {
249
+ static fromTermNode(termNode, localContext) {
194
250
  const node = termNode, ///
195
- string = fileContext.nodeAsString(node),
251
+ string = localContext.nodeAsString(node),
196
252
  type = null,
197
253
  term = new Term(string, node, type);
198
254