occam-verify-cli 0.0.1111 → 0.0.1114

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 (197) hide show
  1. package/lib/combinator/bracketed.js +15 -65
  2. package/lib/combinator.js +4 -8
  3. package/lib/constructor/bracketed.js +24 -101
  4. package/lib/constructor.js +4 -8
  5. package/lib/context/file.js +41 -12
  6. package/lib/context/local.js +45 -25
  7. package/lib/context/release.js +2 -2
  8. package/lib/dom/assertion/contained.js +287 -0
  9. package/lib/dom/assertion/defined.js +266 -0
  10. package/lib/dom/assertion/subproof.js +210 -0
  11. package/lib/dom/assertion/type.js +240 -0
  12. package/lib/{axiom.js → dom/axiom.js} +18 -8
  13. package/lib/dom/conclusion.js +171 -0
  14. package/lib/{conjecture.js → dom/conjecture.js} +18 -8
  15. package/lib/dom/consequent.js +171 -0
  16. package/lib/dom/declaration/combinator.js +105 -0
  17. package/lib/dom/declaration/constructor.js +140 -0
  18. package/lib/dom/declaration/metavariable.js +154 -0
  19. package/lib/dom/declaration/type.js +140 -0
  20. package/lib/dom/declaration/variable.js +155 -0
  21. package/lib/{declaration.js → dom/declaration.js} +62 -18
  22. package/lib/dom/derivation.js +137 -0
  23. package/lib/dom/equality.js +260 -0
  24. package/lib/dom/error.js +85 -0
  25. package/lib/dom/frame.js +372 -0
  26. package/lib/dom/judgement.js +198 -0
  27. package/lib/dom/label.js +190 -0
  28. package/lib/{lemma.js → dom/lemma.js} +19 -9
  29. package/lib/{metaLemma.js → dom/metaLemma.js} +19 -9
  30. package/lib/dom/metaType.js +261 -0
  31. package/lib/dom/metatheorem.js +273 -0
  32. package/lib/dom/metavariable.js +463 -0
  33. package/lib/dom/premise.js +221 -0
  34. package/lib/dom/proof.js +154 -0
  35. package/lib/dom/proofStep.js +239 -0
  36. package/lib/dom/reference.js +218 -0
  37. package/lib/dom/rule.js +311 -0
  38. package/lib/dom/statement.js +379 -0
  39. package/lib/dom/subDerivation.js +137 -0
  40. package/lib/dom/subproof.js +211 -0
  41. package/lib/dom/supposition.js +221 -0
  42. package/lib/dom/term.js +354 -0
  43. package/lib/{theorem.js → dom/theorem.js} +18 -8
  44. package/lib/dom/topLevelAssertion.js +306 -0
  45. package/lib/dom/type.js +327 -0
  46. package/lib/dom/variable.js +328 -0
  47. package/lib/dom.js +27 -0
  48. package/lib/equivalences.js +307 -0
  49. package/lib/index.js +40 -35
  50. package/lib/mixins/proofStep/unify.js +86 -0
  51. package/lib/mixins/statement/verify.js +27 -2
  52. package/lib/mixins/term/verify.js +24 -4
  53. package/lib/substitution/frame.js +3 -3
  54. package/lib/substitution/statement.js +17 -16
  55. package/lib/substitution/term.js +10 -7
  56. package/lib/substitution.js +4 -31
  57. package/lib/substitutions.js +24 -56
  58. package/lib/unifier/equality.js +2 -3
  59. package/lib/unifier/label.js +3 -3
  60. package/lib/unifier/metaLevel.js +9 -8
  61. package/lib/unifier/metavariable.js +3 -3
  62. package/lib/unifier/statementWithCombinator.js +5 -5
  63. package/lib/unifier/termWithConstructor.js +3 -3
  64. package/lib/utilities/json.js +26 -40
  65. package/lib/utilities/string.js +6 -8
  66. package/lib/utilities/subproof.js +2 -2
  67. package/lib/utilities/substitutions.js +7 -6
  68. package/lib/utilities/verification.js +22 -14
  69. package/lib/verifier/combinator.js +4 -4
  70. package/lib/verifier/constructor.js +3 -3
  71. package/lib/verifier/topLevel.js +15 -21
  72. package/package.json +1 -1
  73. package/src/combinator/bracketed.js +11 -4
  74. package/src/combinator.js +3 -10
  75. package/src/constructor/bracketed.js +17 -5
  76. package/src/constructor.js +3 -9
  77. package/src/context/file.js +42 -11
  78. package/src/context/local.js +26 -34
  79. package/src/context/release.js +1 -1
  80. package/src/{assertion → dom/assertion}/contained.js +11 -8
  81. package/src/{assertion → dom/assertion}/defined.js +14 -11
  82. package/src/{assertion → dom/assertion}/subproof.js +11 -62
  83. package/src/{assertion → dom/assertion}/type.js +11 -8
  84. package/src/{axiom.js → dom/axiom.js} +6 -9
  85. package/src/dom/conclusion.js +95 -0
  86. package/src/{conjecture.js → dom/conjecture.js} +5 -8
  87. package/src/dom/consequent.js +95 -0
  88. package/src/{declaration → dom/declaration}/combinator.js +8 -5
  89. package/src/{declaration → dom/declaration}/constructor.js +8 -4
  90. package/src/{declaration → dom/declaration}/metavariable.js +8 -5
  91. package/src/{declaration → dom/declaration}/type.js +8 -4
  92. package/src/{declaration → dom/declaration}/variable.js +9 -6
  93. package/src/{declaration.js → dom/declaration.js} +11 -16
  94. package/src/{derivation.js → dom/derivation.js} +9 -12
  95. package/src/{equality.js → dom/equality.js} +11 -14
  96. package/src/{error.js → dom/error.js} +6 -3
  97. package/src/{frame.js → dom/frame.js} +14 -23
  98. package/src/{judgement.js → dom/judgement.js} +8 -11
  99. package/src/{label.js → dom/label.js} +9 -16
  100. package/src/{lemma.js → dom/lemma.js} +5 -9
  101. package/src/{metaLemma.js → dom/metaLemma.js} +6 -9
  102. package/src/{metaType.js → dom/metaType.js} +7 -10
  103. package/src/{metatheorem.js → dom/metatheorem.js} +6 -10
  104. package/src/{metavariable.js → dom/metavariable.js} +79 -77
  105. package/src/dom/premise.js +173 -0
  106. package/src/{proof.js → dom/proof.js} +8 -11
  107. package/src/dom/proofStep.js +173 -0
  108. package/src/{reference.js → dom/reference.js} +48 -20
  109. package/src/{rule.js → dom/rule.js} +13 -17
  110. package/src/{statement.js → dom/statement.js} +142 -71
  111. package/src/{subDerivation.js → dom/subDerivation.js} +9 -12
  112. package/src/{subproof.js → dom/subproof.js} +14 -47
  113. package/src/dom/supposition.js +173 -0
  114. package/src/{term.js → dom/term.js} +24 -45
  115. package/src/{theorem.js → dom/theorem.js} +5 -8
  116. package/src/{topLevelAssertion.js → dom/topLevelAssertion.js} +12 -14
  117. package/src/{type.js → dom/type.js} +9 -12
  118. package/src/{variable.js → dom/variable.js} +20 -28
  119. package/src/dom.js +13 -0
  120. package/src/equivalences.js +278 -0
  121. package/src/index.js +39 -34
  122. package/src/mixins/proofStep/unify.js +115 -0
  123. package/src/mixins/statement/verify.js +33 -1
  124. package/src/mixins/term/verify.js +33 -3
  125. package/src/substitution/frame.js +2 -2
  126. package/src/substitution/statement.js +20 -18
  127. package/src/substitution/term.js +12 -5
  128. package/src/substitution.js +4 -29
  129. package/src/substitutions.js +35 -73
  130. package/src/unifier/equality.js +1 -2
  131. package/src/unifier/label.js +2 -2
  132. package/src/unifier/metaLevel.js +9 -7
  133. package/src/unifier/metavariable.js +2 -2
  134. package/src/unifier/statementWithCombinator.js +4 -4
  135. package/src/unifier/termWithConstructor.js +2 -2
  136. package/src/utilities/json.js +23 -42
  137. package/src/utilities/string.js +8 -6
  138. package/src/utilities/subproof.js +2 -2
  139. package/src/utilities/substitutions.js +7 -5
  140. package/src/utilities/verification.js +29 -13
  141. package/src/verifier/combinator.js +3 -3
  142. package/src/verifier/constructor.js +3 -3
  143. package/src/verifier/topLevel.js +20 -21
  144. package/lib/assertion/contained.js +0 -232
  145. package/lib/assertion/defined.js +0 -211
  146. package/lib/assertion/subproof.js +0 -203
  147. package/lib/assertion/type.js +0 -185
  148. package/lib/conclusion.js +0 -130
  149. package/lib/consequent.js +0 -130
  150. package/lib/declaration/combinator.js +0 -90
  151. package/lib/declaration/constructor.js +0 -90
  152. package/lib/declaration/metavariable.js +0 -104
  153. package/lib/declaration/type.js +0 -90
  154. package/lib/declaration/variable.js +0 -105
  155. package/lib/derivation.js +0 -91
  156. package/lib/equality.js +0 -209
  157. package/lib/error.js +0 -70
  158. package/lib/frame.js +0 -331
  159. package/lib/judgement.js +0 -147
  160. package/lib/label.js +0 -141
  161. package/lib/metaType.js +0 -255
  162. package/lib/metatheorem.js +0 -263
  163. package/lib/metavariable.js +0 -399
  164. package/lib/mixins/statement/qualified/unify.js +0 -69
  165. package/lib/mixins/statement/unify.js +0 -42
  166. package/lib/mixins/statement/unifyIndependenntly.js +0 -46
  167. package/lib/mixins/term/unify.js +0 -40
  168. package/lib/premise.js +0 -184
  169. package/lib/proof.js +0 -103
  170. package/lib/proofStep.js +0 -179
  171. package/lib/reference.js +0 -145
  172. package/lib/rule.js +0 -259
  173. package/lib/shim.js +0 -14
  174. package/lib/statement/qualified.js +0 -152
  175. package/lib/statement/unqualified.js +0 -175
  176. package/lib/statement.js +0 -270
  177. package/lib/subDerivation.js +0 -91
  178. package/lib/subproof.js +0 -181
  179. package/lib/supposition.js +0 -184
  180. package/lib/term.js +0 -318
  181. package/lib/topLevelAssertion.js +0 -305
  182. package/lib/type.js +0 -321
  183. package/lib/utilities/equivalences.js +0 -178
  184. package/lib/variable.js +0 -281
  185. package/src/conclusion.js +0 -96
  186. package/src/consequent.js +0 -96
  187. package/src/mixins/statement/qualified/unify.js +0 -103
  188. package/src/mixins/statement/unify.js +0 -41
  189. package/src/mixins/statement/unifyIndependenntly.js +0 -58
  190. package/src/mixins/term/unify.js +0 -36
  191. package/src/premise.js +0 -183
  192. package/src/proofStep.js +0 -181
  193. package/src/shim.js +0 -5
  194. package/src/statement/qualified.js +0 -133
  195. package/src/statement/unqualified.js +0 -166
  196. package/src/supposition.js +0 -183
  197. package/src/utilities/equivalences.js +0 -183
@@ -2,16 +2,15 @@
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
4
 
5
- import shim from "./shim";
6
- import unifyMixins from "./mixins/term/unify";
7
- import verifyMixins from "./mixins/term/verify";
8
- import constructorVerifier from "./verifier/constructor";
5
+ import dom from "../dom";
6
+ import verifyMixins from "../mixins/term/verify";
7
+ import constructorVerifier from "../verifier/constructor";
9
8
 
10
9
  import { objectType } from "./type";
11
- import { nodeQuery, nodesQuery } from "./utilities/query"
12
- import { termNodeFromTermString } from "./nodeAndTokens/term";
13
- import { variableNameFromVariableNode } from "./utilities/name";
14
- import { typeFromJSON, typeToTypeJSON } from "./utilities/json";
10
+ import { domAssigned } from "../dom";
11
+ import { nodeQuery, nodesQuery } from "../utilities/query"
12
+ import { termNodeFromTermString } from "../nodeAndTokens/term";
13
+ import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
15
14
 
16
15
  const { filter, compress } = arrayUtilities;
17
16
 
@@ -19,7 +18,7 @@ const termNodeQuery = nodeQuery("/*/term[0]"),
19
18
  variableNodeQuery = nodeQuery("/term/variable!"),
20
19
  variableNodesQuery = nodesQuery("//variable");
21
20
 
22
- class Term {
21
+ export default domAssigned(class Term {
23
22
  constructor(string, node, type) {
24
23
  this.string = string;
25
24
  this.node = node;
@@ -43,7 +42,7 @@ class Term {
43
42
  }
44
43
 
45
44
  getVariable(context) {
46
- const { Variable } = shim,
45
+ const { Variable } = dom,
47
46
  termNode = this.node, ///
48
47
  variable = Variable.fromTermNode(termNode, context);
49
48
 
@@ -53,7 +52,7 @@ class Term {
53
52
  getVariables(context) {
54
53
  const variableNodes = variableNodesQuery(this.node),
55
54
  variables = variableNodes.map((variableNode) => {
56
- const { Variable } = shim,
55
+ const { Variable } = dom,
57
56
  variable = Variable.fromVariableNode(variableNode, context);
58
57
 
59
58
  return variable;
@@ -79,15 +78,13 @@ class Term {
79
78
  isEqualTo(term) {
80
79
  let equalTo = false;
81
80
 
82
- if (term !== null) {
83
- const termString = term.getString();
81
+ const termString = term.getString();
84
82
 
85
- if (termString === this.string) {
86
- const termType = term.getType();
83
+ if (termString === this.string) {
84
+ const termType = term.getType();
87
85
 
88
- if (termType === this.type) {
89
- equalTo = true;
90
- }
86
+ if (termType === this.type) {
87
+ equalTo = true;
91
88
  }
92
89
  }
93
90
 
@@ -128,34 +125,20 @@ class Term {
128
125
  }
129
126
 
130
127
  verify(context, verifyAhead) {
131
- let verified = false;
128
+ let verified;
132
129
 
133
130
  const term = this, ///
134
131
  termString = this.string; ///
135
132
 
136
133
  context.trace(`Verifying the '${termString}' term...`);
137
134
 
138
- if (!verified) {
139
- verified = verifyMixins.some((verifyMixin) => {
140
- const verified = verifyMixin(term, context, verifyAhead);
135
+ verified = verifyMixins.some((verifyMixin) => {
136
+ const verified = verifyMixin(term, context, verifyAhead);
141
137
 
142
- if (verified) {
143
- return true;
144
- }
145
- });
146
- }
147
-
148
- if (!verified) {
149
- const unified = unifyMixins.some((unifyMixin) => { ///
150
- const unified = unifyMixin(term, context, verifyAhead);
151
-
152
- if (unified) {
153
- return true;
154
- }
155
- });
156
-
157
- verified = unified; ///
158
- }
138
+ if (verified) {
139
+ return true;
140
+ }
141
+ });
159
142
 
160
143
  if (verified) {
161
144
  context.debug(`...verified the '${termString}' term.`);
@@ -257,6 +240,8 @@ class Term {
257
240
  return json;
258
241
  }
259
242
 
243
+ static name = "Term";
244
+
260
245
  static fromJSON(json, fileContext) {
261
246
  const { string } = json,
262
247
  context = fileContext, ///
@@ -330,10 +315,4 @@ class Term {
330
315
 
331
316
  return term;
332
317
  }
333
- }
334
-
335
- Object.assign(shim, {
336
- Term
337
318
  });
338
-
339
- export default Term;
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
 
3
- import shim from "./shim";
4
3
  import TopLevelAssertion from "./topLevelAssertion";
5
4
 
6
- class Theorem extends TopLevelAssertion {
5
+ import { domAssigned } from "../dom";
6
+
7
+ export default domAssigned(class Theorem extends TopLevelAssertion {
7
8
  verify() {
8
9
  let verified;
9
10
 
@@ -25,13 +26,9 @@ class Theorem extends TopLevelAssertion {
25
26
  return verified;
26
27
  }
27
28
 
29
+ static name = "Theorem";
30
+
28
31
  static fromJSON(json, fileContext) { return TopLevelAssertion.fromJSON(Theorem, json, fileContext); }
29
32
 
30
33
  static fromTheoremNode(metaLemmaNode, fileContext) { return TopLevelAssertion.fromNode(Theorem, metaLemmaNode, fileContext); }
31
- }
32
-
33
- Object.assign(shim, {
34
- Theorem
35
34
  });
36
-
37
- export default Theorem;
@@ -2,11 +2,12 @@
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
4
 
5
- import shim from "./shim";
6
- import LocalContext from "./context/local";
5
+ import dom from "../dom";
6
+ import LocalContext from "../context/local";
7
+ import Substitutions from "../substitutions";
7
8
 
8
- import { EMPTY_STRING } from "./constants";
9
- import { nodeQuery, nodesQuery } from "./utilities/query";
9
+ import { EMPTY_STRING } from "../constants";
10
+ import { nodeQuery, nodesQuery } from "../utilities/query";
10
11
  import { labelsFromJSON,
11
12
  labelsToLabelsJSON,
12
13
  consequentFromJSON,
@@ -14,9 +15,9 @@ import { labelsFromJSON,
14
15
  substitutionsFromJSON,
15
16
  consequentToConsequentJSON,
16
17
  suppositionsToSuppositionsJSON,
17
- substitutionsToSubstitutionsJSON } from "./utilities/json";
18
+ substitutionsToSubstitutionsJSON } from "../utilities/json";
18
19
 
19
- const { extract, reverse, backwardsEvery } = arrayUtilities;
20
+ const { reverse, extract, backwardsEvery } = arrayUtilities;
20
21
 
21
22
  const proofNodeQuery = nodeQuery("/*/proof"),
22
23
  labelNodesQuery = nodesQuery("/*/label"),
@@ -85,8 +86,7 @@ export default class TopLevelAssertion {
85
86
 
86
87
  context.trace(`Unifying the '${referenceString}' reference with the '${axiomLemmaTheoremConjectureString}' axiom, lemma, theorem or conjecture...`);
87
88
 
88
- const { Substitutions } = shim,
89
- substitutions = Substitutions.fromNothing(),
89
+ const substitutions = Substitutions.fromNothing(),
90
90
  fileContext = this.getFileContext(),
91
91
  localContext = LocalContext.fromFileContext(fileContext),
92
92
  generalContext = localContext, ///
@@ -123,8 +123,7 @@ export default class TopLevelAssertion {
123
123
  suppositionsLength = suppositions.length;
124
124
 
125
125
  if (suppositionsLength === 0) {
126
- const { Substitutions } = shim,
127
- substitutions = Substitutions.fromNothing(),
126
+ const substitutions = Substitutions.fromNothing(),
128
127
  localContext = LocalContext.fromFileContext(this.fileContext),
129
128
  generalContext = localContext, ///
130
129
  specificContext = context, ///
@@ -147,8 +146,7 @@ export default class TopLevelAssertion {
147
146
  generalContext = localContext, ///
148
147
  specificContext = context; ///
149
148
 
150
- const { Substitutions } = shim,
151
- substitutions = Substitutions.fromNothing(),
149
+ const substitutions = Substitutions.fromNothing(),
152
150
  statementUnifiedWithConsequent = this.unifyStatementWithConsequent(statement, substitutions, generalContext, specificContext);
153
151
 
154
152
  if (statementUnifiedWithConsequent) {
@@ -291,7 +289,7 @@ export default class TopLevelAssertion {
291
289
  }
292
290
 
293
291
  static fromNode(Class, node, fileContext) {
294
- const { Label, Proof, Consequent, Supposition, Substitutions } = shim,
292
+ const { Label, Proof, Consequent, Supposition } = dom,
295
293
  proofNode = proofNodeQuery(node),
296
294
  labelNodes = labelNodesQuery(node),
297
295
  consequentNode = consequentNodeQuery(node),
@@ -322,7 +320,7 @@ export function stringFromLabels(labels) {
322
320
 
323
321
  string = (string === EMPTY_STRING) ?
324
322
  labelString: ///
325
- `${labelString}, ${labelString}`;
323
+ `${string}, ${labelString}`;
326
324
 
327
325
  return string;
328
326
  }, EMPTY_STRING);
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
 
3
- import shim from "./shim";
4
-
5
- import { nodeQuery } from "./utilities/query";
6
- import { OBJECT_TYPE_NAME } from "./typeNames";
7
- import { typeNameFromTypeNode } from "./utilities/name";
8
- import { superTypeFromJSON, superTypeToSuperTypeJSON } from "./utilities/json";
3
+ import { nodeQuery } from "../utilities/query";
4
+ import { domAssigned } from "../dom";
5
+ import { OBJECT_TYPE_NAME } from "../typeNames";
6
+ import { typeNameFromTypeNode } from "../utilities/name";
7
+ import { superTypeFromJSON, superTypeToSuperTypeJSON } from "../utilities/json";
9
8
 
10
9
  const typeDeclarationTypeNodeQuery = nodeQuery("/typeDeclaration/type[0]"),
11
10
  typeDeclarationSuperTypeNodeQuery = nodeQuery("/typeDeclaration/type[1]"),
@@ -149,6 +148,8 @@ class Type {
149
148
  return json;
150
149
  }
151
150
 
151
+ static name = "Type";
152
+
152
153
  static fromJSON(json, fileContext) {
153
154
  const { name } = json,
154
155
  typeName = name, ///
@@ -206,6 +207,8 @@ class Type {
206
207
  }
207
208
  }
208
209
 
210
+ export default domAssigned(Type);
211
+
209
212
  function stringFromTypeNameAndSuperType(typeName, superType) {
210
213
  let string = typeName; ///
211
214
 
@@ -219,12 +222,6 @@ function stringFromTypeNameAndSuperType(typeName, superType) {
219
222
  return string;
220
223
  }
221
224
 
222
- Object.assign(shim, {
223
- Type
224
- });
225
-
226
- export default Type;
227
-
228
225
  class ObjectType extends Type {
229
226
  toJSON() {
230
227
  const superType = null,
@@ -1,20 +1,21 @@
1
1
  "use strict";
2
2
 
3
- import shim from "./shim";
4
- import LocalContext from "./context/local";
5
- import TermSubstitution from "./substitution/term";
3
+ import dom from "../dom";
4
+ import LocalContext from "../context/local";
5
+ import TermSubstitution from "../substitution/term";
6
6
 
7
- import { nodeQuery } from "./utilities/query";
7
+ import { nodeQuery } from "../utilities/query";
8
8
  import { objectType } from "./type";
9
- import { variableNameFromVariableNode} from "./utilities/name";
10
- import { typeFromJSON, typeToTypeJSON } from "./utilities/json";
11
- import { variableNodeFromVariableString } from "./nodeAndTokens/variable";
9
+ import { domAssigned } from "../dom";
10
+ import { variableNameFromVariableNode} from "../utilities/name";
11
+ import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
12
+ import { variableNodeFromVariableString } from "../nodeAndTokens/variable";
12
13
 
13
14
  const termVariableNodeQuery = nodeQuery("/term/variable!"),
14
15
  variableDeclarationTypeNodeQuery = nodeQuery("/variableDeclaration/type"),
15
16
  variableDeclarationVariableNodeQuery = nodeQuery("/variableDeclaration/variable");
16
17
 
17
- class Variable {
18
+ export default domAssigned(class Variable {
18
19
  constructor(string, node, name, type) {
19
20
  this.string = string;
20
21
  this.node = node;
@@ -49,19 +50,14 @@ class Variable {
49
50
  }
50
51
 
51
52
  isEqualTo(variable) {
52
- let equalTo = false;
53
-
54
- if (variable !== null) {
55
- const variableString = variable.getString();
56
-
57
- equalTo = (variableString === this.string);
58
- }
53
+ const variableString = variable.getString(),
54
+ equalTo = (variableString === this.string);
59
55
 
60
56
  return equalTo;
61
57
  }
62
58
 
63
- isEssentiallyEqualToTerm(term, generalContext, specificContext) {
64
- let essentiallyEqualToTerm = false;
59
+ isEffectivelyEqualToTerm(term, generalContext, specificContext) {
60
+ let effectivelyEqualToTerm = false;
65
61
 
66
62
  const generalContextFilePath = generalContext.getFilePath(),
67
63
  specificContextFilePath = specificContext.getFilePath();
@@ -70,11 +66,11 @@ class Variable {
70
66
  const termString = term.getString();
71
67
 
72
68
  if (termString === this.string) {
73
- essentiallyEqualToTerm = true;
69
+ effectivelyEqualToTerm = true;
74
70
  }
75
71
  }
76
72
 
77
- return essentiallyEqualToTerm;
73
+ return effectivelyEqualToTerm;
78
74
  }
79
75
 
80
76
  verify(context) {
@@ -174,9 +170,9 @@ class Variable {
174
170
 
175
171
  specificContext.trace(`Unifying the '${termString}' term with the '${variableString}' variable...`);
176
172
 
177
- const essentiallyEqualToTerm = this.isEssentiallyEqualToTerm(term, generalContext, specificContext);
173
+ const effectivelyEqualToTerm = this.isEffectivelyEqualToTerm(term, generalContext, specificContext);
178
174
 
179
- if (essentiallyEqualToTerm) {
175
+ if (effectivelyEqualToTerm) {
180
176
  termUnified = true;
181
177
  } else {
182
178
  const variable = this, ///
@@ -225,6 +221,8 @@ class Variable {
225
221
  return json;
226
222
  }
227
223
 
224
+ static name = "Variable";
225
+
228
226
  static fromJSON(json, fileContext) {
229
227
  const { string } = json,
230
228
  localContext = LocalContext.fromFileContext(fileContext),
@@ -291,7 +289,7 @@ class Variable {
291
289
  }
292
290
 
293
291
  static fromVariableDeclarationNode(variableDeclarationNode, fileContext) {
294
- const { Type } = shim,
292
+ const { Type } = dom,
295
293
  variableDeclarationTypeNode = variableDeclarationTypeNodeQuery(variableDeclarationNode),
296
294
  variableDeclarationVariableNode = variableDeclarationVariableNodeQuery(variableDeclarationNode),
297
295
  typeNode = variableDeclarationTypeNode, ///
@@ -307,10 +305,4 @@ class Variable {
307
305
 
308
306
  return variable;
309
307
  }
310
- }
311
-
312
- Object.assign(shim, {
313
- Variable
314
308
  });
315
-
316
- export default Variable;
package/src/dom.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ const dom = {};
4
+
5
+ export function domAssigned(Class) {
6
+ const { name } = Class;
7
+
8
+ dom[name] = Class;
9
+
10
+ return Class;
11
+ }
12
+
13
+ export default dom;
@@ -0,0 +1,278 @@
1
+ "use strict";
2
+
3
+ import { arrayUtilities } from "necessary";
4
+
5
+ import Equivalence from "./equivalence";
6
+
7
+ const { push, compress, separate } = arrayUtilities;
8
+
9
+ export default class Equivalences {
10
+ constructor(array) {
11
+ this.array = array;
12
+ }
13
+
14
+ getArray() {
15
+ return this.array;
16
+ }
17
+
18
+ getLength() { return this.array.length; }
19
+
20
+ getTypes() {
21
+ const types = this.array.map((equivalence) => {
22
+ const type = equivalence.getType();
23
+
24
+ return type;
25
+ });
26
+
27
+ return types;
28
+ }
29
+
30
+ pushEquivalences(equivalences) {
31
+ const array = equivalences.getArray();
32
+
33
+ push(this.array, array);
34
+ }
35
+
36
+ forEachEquivalence(callback) { this.array.forEach(callback); }
37
+
38
+ separateEquivalences(equivalencesA, equivalencesB, callback) {
39
+ const arrayA = equivalencesA.getArray(),
40
+ arrayB = equivalencesB.getArray();
41
+
42
+ separate(this.array, arrayA, arrayB, callback);
43
+ }
44
+
45
+ addEquivalence(equivalence, context) {
46
+ const equivalenceString = equivalence.getString();
47
+
48
+ context.trace(`Added the '${equivalenceString}' equivalence.`);
49
+
50
+ this.array.push(equivalence);
51
+ }
52
+
53
+ removeEquivalence(equivalence, context) {
54
+ const index = this.array.indexOf(equivalence),
55
+ start = index, ///
56
+ deleteCount = 1,
57
+ equivalenceString = equivalence.getString();
58
+
59
+ context.trace(`Removed the '${equivalenceString}' equivalence.`);
60
+
61
+ this.array.splice(start, deleteCount);
62
+ }
63
+
64
+ findEquivalenceByType(type) {
65
+ const equivalence = this.array.find((equivalence) => {
66
+ const equivalenceMatchesType = equivalence.matchType(type);
67
+
68
+ if (equivalenceMatchesType) {
69
+ return true;
70
+ }
71
+ }) || null;
72
+
73
+ return equivalence;
74
+ }
75
+
76
+ findEquivalenceByTerm(equivalences, term) {
77
+ const equivalence = this.array.find((equivalence) => {
78
+ const termEquates = equivalence.equateTerm(term);
79
+
80
+ if (termEquates) {
81
+ return true;
82
+ }
83
+ }) || null;
84
+
85
+ return equivalence;
86
+ }
87
+
88
+ findEquivalenceByTermNodes(equivalences, termNodes) {
89
+ const equivalence = this.array.find((equivalence) => {
90
+ const equivalenceMatchesTerms = equivalence.matchTermNodes(termNodes);
91
+
92
+ if (equivalenceMatchesTerms) {
93
+ return true;
94
+ }
95
+ }) || null;
96
+
97
+ return equivalence;
98
+ }
99
+
100
+ separateInitiallyGroundedEquivalences(remainingEquivalences, initiallyGroundedEquivalences, context) {
101
+ this.separateEquivalences(remainingEquivalences, initiallyGroundedEquivalences, (equivalence) => {
102
+ const equivalenceInitiallyGrounded = equivalence.isInitiallyGrounded(context);
103
+
104
+ if (!equivalenceInitiallyGrounded) {
105
+ return true;
106
+ }
107
+ });
108
+ }
109
+
110
+ separateImplicitlyGroundedEquivalences(remainingEquivalences, implicitlyGroundedEquivalences, definedVariables, context) {
111
+ this.separateEquivalences(remainingEquivalences, implicitlyGroundedEquivalences, (equivalence) => {
112
+ const equivalenceImplicitlyGrounded = equivalence.isImplicitlyGrounded(definedVariables, context);
113
+
114
+ if (!equivalenceImplicitlyGrounded) {
115
+ return true;
116
+ }
117
+ });
118
+ }
119
+
120
+ separateGroundedTermsAndDefinedVariables(groundedTerms, definedVariables, context) {
121
+ let equivalences = this,
122
+ groundedEquivalences,
123
+ remainingEquivalences,
124
+ initiallyGroundedEquivalences,
125
+ implicitlyGroundedEquivalences;
126
+
127
+ remainingEquivalences =Equivalences.fromNothing();
128
+
129
+ initiallyGroundedEquivalences = Equivalences.fromNothing();
130
+
131
+ equivalences.separateInitiallyGroundedEquivalences(remainingEquivalences, initiallyGroundedEquivalences, context);
132
+
133
+ const initiallyGroundedEquivalencesLength = initiallyGroundedEquivalences.getLength();
134
+
135
+ if (initiallyGroundedEquivalencesLength > 0) {
136
+ groundedEquivalences = initiallyGroundedEquivalences; ///
137
+
138
+ let implicitlyGroundedEquivalencesLength = 1;
139
+
140
+ while (implicitlyGroundedEquivalencesLength > 0) {
141
+ let definedVariablesLength = 0,
142
+ previousDefinedVariablesLength = -1;
143
+
144
+ while (definedVariablesLength > previousDefinedVariablesLength) {
145
+ previousDefinedVariablesLength = definedVariablesLength; ///
146
+
147
+ groundedTermsFromGroundedEquivalencesAndDefinedVariables(groundedEquivalences, definedVariables, groundedTerms, context);
148
+
149
+ definedVariablesFromGroundedTerms(groundedTerms, definedVariables, context);
150
+
151
+ definedVariablesLength = definedVariables.length;
152
+ }
153
+
154
+ equivalences = remainingEquivalences; ///
155
+
156
+ remainingEquivalences = [];
157
+
158
+ implicitlyGroundedEquivalences = [];
159
+
160
+ equivalences.separateImplicitlyGroundedEquivalences(remainingEquivalences, implicitlyGroundedEquivalences, definedVariables, context);
161
+
162
+ groundedEquivalences.pushEquivalences(implicitlyGroundedEquivalences);
163
+
164
+ implicitlyGroundedEquivalencesLength = implicitlyGroundedEquivalences.getLength(); ///
165
+ }
166
+ }
167
+ }
168
+
169
+ unifySubstitutions(substitutions) {
170
+ const substitutionsUnified = substitutions.everySubstitution((substitution) => {
171
+ const substitutionUnified = this.unifySubstitution(substitution);
172
+
173
+ if (substitutionUnified) {
174
+ return true;
175
+ }
176
+ });
177
+
178
+ return substitutionsUnified;
179
+ }
180
+
181
+ unifySubstitution(substitution) {
182
+ const substitutionUnified = this.array.some((equivalence) => {
183
+ const substitutionUnifiedWithEquivalence = substitution.unifyWithEquivalence(equivalence);
184
+
185
+ if (substitutionUnifiedWithEquivalence) {
186
+ return true;
187
+ }
188
+ });
189
+
190
+ return substitutionUnified;
191
+ }
192
+
193
+ mergedWith(equivalences) {
194
+ const equivalencesA = this, ///
195
+ equivalencesB = equivalences;
196
+
197
+ equivalences = mergeEquivalences(equivalencesA, equivalencesB); ///
198
+
199
+ return equivalences;
200
+ }
201
+
202
+ static fromArray(array) {
203
+ const equivalences = new Equivalences(array);
204
+
205
+ return equivalences;
206
+ }
207
+
208
+ static fromNothing() {
209
+ const array = [],
210
+ equivalences = new Equivalences(array);
211
+
212
+ return equivalences;
213
+ }
214
+ }
215
+
216
+ function mergeEquivalences(equivalencesA, equivalencesB) {
217
+ const typesA = equivalencesA.getTypes(),
218
+ typesB = equivalencesB.getTypes(),
219
+ types = [
220
+ ...typesA,
221
+ ...typesB
222
+ ];
223
+
224
+ compress(types, (typeA, typeB) => {
225
+ if (typeA === typeB) {
226
+ return true;
227
+ }
228
+ });
229
+
230
+ const array = types.map((type) => {
231
+ let equivalence;
232
+
233
+ const equivalenceA = equivalencesA.findEquivalenceByType(type), ///
234
+ equivalenceB = equivalencesB.findEquivalenceByType(type); ///
235
+
236
+ if ((equivalenceA !== null) && (equivalenceB !== null)) {
237
+ const leftEquivalence = equivalenceA, ///
238
+ rightEquivalence = equivalenceB; ///
239
+
240
+ equivalence = Equivalence.merge(leftEquivalence, rightEquivalence);
241
+ } else if (equivalenceA !== null) {
242
+ equivalence = equivalenceA; ///
243
+ } else if (equivalenceB !== null) {
244
+ equivalence = equivalenceB; ///
245
+ }
246
+
247
+ return equivalence;
248
+ });
249
+
250
+ const equivalences = Equivalences.fromArray(array);
251
+
252
+ return equivalences;
253
+ }
254
+
255
+ function definedVariablesFromGroundedTerms(groundedTerms, definedVariables, context) {
256
+ const terms = groundedTerms, ///
257
+ variables = definedVariables; ///
258
+
259
+ terms.forEach((term) => {
260
+ const termVariables = term.getVariables(context);
261
+
262
+ termVariables.forEach((termVariable) => {
263
+ const variablesIncludesTermVariable = variables.includes(termVariable);
264
+
265
+ if (!variablesIncludesTermVariable) {
266
+ const variable = termVariable; ///
267
+
268
+ variables.push(variable);
269
+ }
270
+ });
271
+ });
272
+ }
273
+
274
+ function groundedTermsFromGroundedEquivalencesAndDefinedVariables(groundedEquivalences, definedVariables, groundedTerms, context) {
275
+ groundedEquivalences.forEachEquivalence((groundedEquivalence) => {
276
+ groundedEquivalence.getGroundedTerms(definedVariables, groundedTerms, context);
277
+ });
278
+ }