occam-verify-cli 1.0.220 → 1.0.223

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 (47) hide show
  1. package/lib/context/local.js +5 -43
  2. package/lib/dom/assertion/property.js +4 -2
  3. package/lib/dom/assertion/type.js +4 -2
  4. package/lib/dom/axiom.js +9 -9
  5. package/lib/dom/equality.js +21 -6
  6. package/lib/dom/judgement.js +4 -2
  7. package/lib/dom/rule.js +13 -5
  8. package/lib/dom/statement.js +7 -7
  9. package/lib/dom/step.js +18 -21
  10. package/lib/dom/subproof.js +12 -15
  11. package/lib/dom/substitution/term.js +2 -16
  12. package/lib/dom/substitution.js +1 -8
  13. package/lib/dom/topLevelAssertion.js +18 -31
  14. package/lib/dom/topLevelMetaAssertion.js +13 -5
  15. package/lib/dom/variable.js +3 -3
  16. package/lib/equivalence.js +54 -33
  17. package/lib/equivalences.js +57 -101
  18. package/lib/mixins/step/unify.js +42 -24
  19. package/lib/unifier/equantional.js +170 -0
  20. package/lib/utilities/brackets.js +2 -2
  21. package/lib/utilities/subproof.js +2 -2
  22. package/lib/utilities/unification.js +1 -11
  23. package/package.json +1 -1
  24. package/src/context/local.js +5 -48
  25. package/src/dom/assertion/property.js +3 -1
  26. package/src/dom/assertion/type.js +3 -1
  27. package/src/dom/axiom.js +12 -10
  28. package/src/dom/equality.js +26 -9
  29. package/src/dom/judgement.js +3 -1
  30. package/src/dom/rule.js +20 -5
  31. package/src/dom/statement.js +5 -5
  32. package/src/dom/step.js +28 -34
  33. package/src/dom/subproof.js +15 -25
  34. package/src/dom/substitution/term.js +1 -19
  35. package/src/dom/substitution.js +0 -6
  36. package/src/dom/topLevelAssertion.js +20 -41
  37. package/src/dom/topLevelMetaAssertion.js +20 -5
  38. package/src/dom/variable.js +3 -2
  39. package/src/equivalence.js +69 -46
  40. package/src/equivalences.js +53 -115
  41. package/src/mixins/step/unify.js +54 -33
  42. package/src/unifier/equantional.js +90 -0
  43. package/src/utilities/brackets.js +1 -1
  44. package/src/utilities/subproof.js +1 -1
  45. package/src/utilities/unification.js +0 -14
  46. package/lib/unifier/equality.js +0 -155
  47. package/src/unifier/equality.js +0 -70
package/src/dom/rule.js CHANGED
@@ -222,7 +222,7 @@ export default domAssigned(class Rule {
222
222
  labels = labelsFromJSON(json, fileContext),
223
223
  premises = premisesFromJSON(json, fileContext),
224
224
  conclusion = conclusionFromJSON(json, fileContext),
225
- string = stringFromLabelsAndConclusion(labels, conclusion);
225
+ string = stringFromLabelsPremisesAndConclusion(labels, premises, conclusion);
226
226
 
227
227
  rule = new Rule(fileContext, string, labels, premises, conclusion, proof);
228
228
 
@@ -234,7 +234,7 @@ export default domAssigned(class Rule {
234
234
  labels = labelsFromRuleNode(ruleNode, fileContext),
235
235
  premises = premisesFromRuleNode(ruleNode, fileContext),
236
236
  conclusion = conclusionFromRuleNode(ruleNode, fileContext),
237
- string = stringFromLabelsAndConclusion(labels, conclusion),
237
+ string = stringFromLabelsPremisesAndConclusion(labels, premises, conclusion),
238
238
  rule = new Rule(fileContext, string, labels, premises, conclusion, proof);
239
239
 
240
240
  return rule;
@@ -281,10 +281,25 @@ function conclusionFromRuleNode(ruleNode, fileContext) {
281
281
  return conclusion;
282
282
  }
283
283
 
284
- function stringFromLabelsAndConclusion(labels, conclusion) {
285
- const conclusionString = conclusion.getString(),
284
+ function premisesStringFromPremises(premises) {
285
+ const premisesString = premises.reduce((premisesString, premise) => {
286
+ const premiseString = premise.getString();
287
+
288
+ premisesString = (premisesString !== null) ?
289
+ `${premisesString}, ${premiseString}` :
290
+ premiseString; ///
291
+
292
+ return premisesString;
293
+ }, null);
294
+
295
+ return premisesString;
296
+ }
297
+
298
+ function stringFromLabelsPremisesAndConclusion(labels, premises, conclusion) {
299
+ const premisesString = premisesStringFromPremises(premises),
300
+ conclusionString = conclusion.getString(),
286
301
  labelsString = labelsStringFromLabels(labels),
287
- string = `${labelsString} :: ${conclusionString}`;
302
+ string = `${labelsString} :: [${premisesString}] ... ${conclusionString}`;
288
303
 
289
304
  return string;
290
305
  }
@@ -224,19 +224,19 @@ export default domAssigned(class Statement {
224
224
  return unifiedIndependently;
225
225
  }
226
226
 
227
- unifyWithStepsOrSubproofs(stepsOrSubproofs, context) {
228
- let unifiedWithSteps;
227
+ equateWithStepsOrSubproofs(stepsOrSubproofs, context) {
228
+ let equateDdWithStepsOrSubproofs;
229
229
 
230
- unifiedWithSteps = backwardsSome(stepsOrSubproofs, (stepOrSubproof) => {
230
+ equateDdWithStepsOrSubproofs = backwardsSome(stepsOrSubproofs, (stepOrSubproof) => {
231
231
  const statement = this, ///
232
- statementUnified = stepOrSubproof.unifyStatement(statement, context);
232
+ statementUnified = stepOrSubproof.equateWithStatement(statement, context);
233
233
 
234
234
  if (statementUnified) {
235
235
  return true;
236
236
  }
237
237
  });
238
238
 
239
- return unifiedWithSteps;
239
+ return equateDdWithStepsOrSubproofs;
240
240
  }
241
241
 
242
242
  toJSON() {
package/src/dom/step.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  import dom from "../dom";
4
4
  import unifyMixins from "../mixins/step/unify";
5
- import LocalContext from "../context/local";
6
5
  import Substitutions from "../substitutions";
6
+ import equationalUnifier from "../unifier/equantional";
7
7
 
8
8
  import { domAssigned } from "../dom";
9
9
  import { propertyAssertionFromStatement } from "../utilities/context";
@@ -105,55 +105,49 @@ export default domAssigned(class Step {
105
105
  return verified;
106
106
  }
107
107
 
108
- unifyStatement(statement, context) {
109
- let statementUnified;
108
+ equateWithStatement(statement, context) {
109
+ let statementEquated;
110
110
 
111
- const substitutions = Substitutions.fromNothing(),
112
- generalContext = context, ///
113
- specificContext = context; ///
111
+ const statementA = statement, ///
112
+ statementB = this.statement, ///
113
+ statementANode = statementA.getNode(),
114
+ statementBNode = statementB.getNode(),
115
+ statementsEquated = equationalUnifier.equateStatements(statementANode, statementBNode, context);
114
116
 
115
- statementUnified = statement.unifyStatement(this.statement, substitutions, generalContext, specificContext);
117
+ statementEquated = statementsEquated; ///
116
118
 
117
- if (statementUnified) {
118
- substitutions.removeTrivialSubstitutions();
119
-
120
- const equivalences = context.getEquivalences(),
121
- substitutionsUnified = equivalences.unifySubstitutions(substitutions);
122
-
123
- statementUnified = substitutionsUnified; ///
124
- }
125
-
126
- return statementUnified;
119
+ return statementEquated;
127
120
  }
128
121
 
129
122
  unifySatisfiesAssertion(satisfiesAssertion, context) {
130
123
  let unifySatisfiesAssertion = false;
131
124
 
125
+ const stepString = this.string, ///
126
+ satisfiesAssertionString = satisfiesAssertion.getString();
127
+
128
+ context.trace(`Unifying hte '${satisfiesAssertionString}' with the '${stepString}' step...`);
129
+
132
130
  const reference = satisfiesAssertion.getReference(),
133
131
  axiom = context.findAxiomByReference(reference);
134
132
 
135
133
  if (axiom !== null) {
136
- const axiomUnconditional = axiom.isUnconditional();
137
-
138
- if (axiomUnconditional) {
139
- const step = this, ///
140
- fileContext = axiom.getFileContext(),
141
- localContext = LocalContext.fromFileContext(fileContext),
142
- substitutions = Substitutions.fromNothing(),
143
- generalContext = localContext, ///
144
- specificContext = context, ///
145
- statementUnified = axiom.unifyStep(step, substitutions, generalContext, specificContext);
146
-
147
- if (statementUnified) {
148
- const substitutionsMatch = satisfiesAssertion.matchSubstitutions(substitutions, context);
149
-
150
- if (substitutionsMatch) {
151
- unifySatisfiesAssertion = true;
152
- }
134
+ const step = this, ///
135
+ substitutions = Substitutions.fromNothing(),
136
+ statementUnified = axiom.unifyStep(step, substitutions, context);
137
+
138
+ if (statementUnified) {
139
+ const substitutionsMatch = satisfiesAssertion.matchSubstitutions(substitutions, context);
140
+
141
+ if (substitutionsMatch) {
142
+ unifySatisfiesAssertion = true;
153
143
  }
154
144
  }
155
145
  }
156
146
 
147
+ if (unifySatisfiesAssertion) {
148
+ context.debug(`...unified hte '${satisfiesAssertionString}' with the '${stepString}' step.`);
149
+ }
150
+
157
151
  return unifySatisfiesAssertion;
158
152
  }
159
153
 
@@ -88,25 +88,10 @@ export default domAssigned(class Subproof {
88
88
  return subproofVerified;
89
89
  }
90
90
 
91
- unifyStatement(statement, context) {
91
+ equateWithStatement(statement, context) {
92
92
  let statementUnified = false;
93
93
 
94
- const subproof = this,
95
- substitutions = Substitutions.fromNothing(),
96
- generalContext = context, ///
97
- specificContext = context, ///
98
- subproofUnified = statement.unifySubproof(subproof, substitutions, generalContext, specificContext);
99
-
100
- if (subproofUnified) {
101
- if (statementUnified) {
102
- const equivalences = context.getEquivalences(),
103
- substitutionsUnified = equivalences.unifySubstitutions(substitutions);
104
-
105
- if (substitutionsUnified) {
106
- statementUnified = true;
107
- }
108
- }
109
- }
94
+ debugger
110
95
 
111
96
  return statementUnified;
112
97
  }
@@ -114,20 +99,21 @@ export default domAssigned(class Subproof {
114
99
  unifySatisfiesAssertion(satisfiesAssertion, context) {
115
100
  let unifySatisfiesAssertion = false;
116
101
 
102
+ const subproofString = this.string, ///
103
+ satisfiesAssertionString = satisfiesAssertion.getString();
104
+
105
+ context.trace(`Unifying the '${satisfiesAssertionString}' satisfies assertion with the '${subproofString}' subproof...`)
106
+
117
107
  const reference = satisfiesAssertion.getReference(),
118
108
  axiom = context.findAxiomByReference(reference);
119
109
 
120
110
  if (axiom !== null) {
121
- const axiomUnconditional = axiom.isUnconditional();
111
+ const axiomSatisfiable = axiom.isSatisfiable();
122
112
 
123
- if (!axiomUnconditional) {
124
- const subproof = this,
125
- fileContext = axiom.getFileContext(),
126
- localContext = LocalContext.fromFileContext(fileContext),
113
+ if (axiomSatisfiable) {
114
+ const subproof = this, ///
127
115
  substitutions = Substitutions.fromNothing(),
128
- generalContext = localContext, ///
129
- specificContext = context, ///
130
- statementUnified = axiom.unifySubproof(subproof, substitutions, generalContext, specificContext);
116
+ statementUnified = axiom.unifySubproof(subproof, substitutions, context);
131
117
 
132
118
  if (statementUnified) {
133
119
  const substitutionsMatch = satisfiesAssertion.matchSubstitutions(substitutions, context);
@@ -139,6 +125,10 @@ export default domAssigned(class Subproof {
139
125
  }
140
126
  }
141
127
 
128
+ if (unifySatisfiesAssertion) {
129
+ context.debug(`...unified the '${satisfiesAssertionString}' satisfies assertion with the '${subproofString}' subproof.`)
130
+ }
131
+
142
132
  return unifySatisfiesAssertion;
143
133
  }
144
134
 
@@ -33,7 +33,7 @@ export default domAssigned(class TermSubstitution extends Substitution {
33
33
  }
34
34
 
35
35
  isTermEqualTo(term, context) {
36
- term = stripBracketsFromTerm(term); ///
36
+ term = stripBracketsFromTerm(term, context); ///
37
37
 
38
38
  const termEqualTo = this.term.isEqualTo(term);
39
39
 
@@ -51,24 +51,6 @@ export default domAssigned(class TermSubstitution extends Substitution {
51
51
 
52
52
  matchName(name) { return this.variable.matchName(name); }
53
53
 
54
- unifyWithEquivalence(equivalence) {
55
- let unifiedWithEquivalence;
56
-
57
- const termNode = this.term.getNode(),
58
- equivalenceMatchesTermNode = equivalence.matchTermNode(termNode);
59
-
60
- if (equivalenceMatchesTermNode) {
61
- const variableNode = this.variable.getNode(),
62
- equivalenceMatchesVariableNode = equivalence.matchVariableNode(variableNode);
63
-
64
- if (equivalenceMatchesVariableNode) {
65
- unifiedWithEquivalence = true;
66
- }
67
- }
68
-
69
- return unifiedWithEquivalence;
70
- }
71
-
72
54
  static fromStatementNode(statementNode, context) {
73
55
  let termSubstitution = null;
74
56
 
@@ -153,10 +153,4 @@ export default class Substitution {
153
153
 
154
154
  return replacementNode;
155
155
  }
156
-
157
- unifyWithEquivalence(equivalence) {
158
- let unifiedWithEquivalence = false;
159
-
160
- return unifiedWithEquivalence;
161
- }
162
156
  }
@@ -64,13 +64,6 @@ export default class TopLevelAssertion {
64
64
  return supposition;
65
65
  }
66
66
 
67
- isUnconditional() {
68
- const suppositionsLength = this.suppositions.length,
69
- unconditional = (suppositionsLength === 0);
70
-
71
- return unconditional;
72
- }
73
-
74
67
  matchMetavariableName(metavariableName) {
75
68
  const metavariableNameMatches = this.labels.some((label) => {
76
69
  const metavariableNameMatches = label.matchMetavariableName(metavariableName);
@@ -131,35 +124,6 @@ export default class TopLevelAssertion {
131
124
  return labelsVerified;
132
125
  }
133
126
 
134
- unifyStatement(statement, context) {
135
- let statementUnified;
136
-
137
- const statementString = statement.getString(),
138
- axiomLemmaTheoremConjecture = this, ///
139
- axiomLemmaTheoremConjectureString = axiomLemmaTheoremConjecture.getString();
140
-
141
- context.trace(`Unifying the '${statementString}' statement with the '${axiomLemmaTheoremConjectureString}' axiom, lemma, theorem or conjecture...`);
142
-
143
- const suppositions = this.getSuppositions(),
144
- suppositionsLength = suppositions.length;
145
-
146
- if (suppositionsLength === 0) {
147
- const substitutions = Substitutions.fromNothing(),
148
- localContext = LocalContext.fromFileContext(this.fileContext),
149
- generalContext = localContext, ///
150
- specificContext = context, ///
151
- statementUnifiedWithDeduction = this.unifyStatementWithDeduction(statement, substitutions, generalContext, specificContext);
152
-
153
- statementUnified = statementUnifiedWithDeduction; ///
154
- }
155
-
156
- if (statementUnified) {
157
- context.debug(`...unified the '${statementString}' statement with the '${axiomLemmaTheoremConjectureString}' axiom, lemma, theorem or conjecture.`);
158
- }
159
-
160
- return statementUnified;
161
- }
162
-
163
127
  unifyStatementWithDeduction(statement, substitutions, generalContext, specificContext) {
164
128
  let deductionUnified;
165
129
 
@@ -255,7 +219,7 @@ export default class TopLevelAssertion {
255
219
  suppositions = suppositionsFromJSON(json, fileContext),
256
220
  signature = signatureFromJSON(json, fileContext),
257
221
  proof = null,
258
- string = stringFromLabelsAndDeduction(labels, deduction),
222
+ string = stringFromLabelsSuppositionsAndDeduction(labels, suppositions, deduction),
259
223
  topLevelAssertion = new Class(fileContext, string, labels, suppositions, deduction, proof, signature);
260
224
 
261
225
  return topLevelAssertion;
@@ -273,7 +237,7 @@ export default class TopLevelAssertion {
273
237
  deduction = deductionFromDeductionNode(deductionNode, fileContext),
274
238
  suppositions = suppositionsFromSuppositionNodes(suppositionNodes, fileContext),
275
239
  signature = signatureFromSignatureNode(signatureNode, fileContext),
276
- string = stringFromLabelsAndDeduction(labels, deduction),
240
+ string = stringFromLabelsSuppositionsAndDeduction(labels, suppositions, deduction),
277
241
  topLevelAssertion = new Class(fileContext, string, labels, suppositions, deduction, proof, signature);
278
242
 
279
243
  return topLevelAssertion;
@@ -342,12 +306,27 @@ export function labelsStringFromLabels(labels) {
342
306
  return labelsString;
343
307
  }
344
308
 
345
- export function stringFromLabelsAndDeduction(labels, deduction) {
346
- const deductionString = deduction.getString(),
309
+ export function suppositionsStringFromSuppositions(suppositions) {
310
+ const suppositionsString = suppositions.reduce((suppositionsString, supposition) => {
311
+ const suppositionString = supposition.getString();
312
+
313
+ suppositionsString = (suppositionsString !== null) ?
314
+ `${suppositionsString}, ${suppositionString}` :
315
+ suppositionString; ///
316
+
317
+ return suppositionsString;
318
+ }, null);
319
+
320
+ return suppositionsString;
321
+ }
322
+
323
+ export function stringFromLabelsSuppositionsAndDeduction(labels, suppositions, deduction) {
324
+ const suppositionsString = suppositionsStringFromSuppositions(suppositions),
325
+ deductionString = deduction.getString(),
347
326
  labelsString = labelsStringFromLabels(labels),
348
327
  string = (labelsString === null) ?
349
328
  deductionString : ///
350
- `${labelsString} :: ${deductionString}`;
329
+ `${labelsString} :: [${suppositionsString}] ... ${deductionString}`;
351
330
 
352
331
  return string;
353
332
  }
@@ -128,7 +128,7 @@ export default class TopLevelMetaAssertion {
128
128
  suppositions = suppositionsFromJSON(json, fileContext),
129
129
  substitutions = substitutionsFromJSON(json, fileContext),
130
130
  proof = null,
131
- string = stringFromLabelAndDeduction(label, deduction),
131
+ string = stringFromLabelASuppositionsAndDeduction(label, suppositions, deduction),
132
132
  topLevelMetaAssertion = new Class(fileContext, string, label, suppositions, deduction, proof, substitutions);
133
133
 
134
134
  return topLevelMetaAssertion;
@@ -145,7 +145,7 @@ export default class TopLevelMetaAssertion {
145
145
  deduction = deductionFromDeductionNode(deductionNode, fileContext),
146
146
  suppositions = suppositionsFromSuppositionNodes(suppositionNodes, fileContext),
147
147
  substitutions = Substitutions.fromNothing(),
148
- string = stringFromLabelAndDeduction(label, deduction),
148
+ string = stringFromLabelASuppositionsAndDeduction(label, suppositions, deduction),
149
149
  topLevelMetaAssertion = new Class(fileContext, string, label, suppositions, deduction, proof, substitutions);
150
150
 
151
151
  return topLevelMetaAssertion;
@@ -172,12 +172,27 @@ function labelStringFromLabel(label) {
172
172
  return labelsString;
173
173
  }
174
174
 
175
- function stringFromLabelAndDeduction(label, deduction) {
176
- const deductionString = deduction.getString(),
175
+ function suppositionsStringFromSuppositions(suppositions) {
176
+ const suppositionsString = suppositions.reduce((suppositionsString, supposition) => {
177
+ const suppositionString = supposition.getString();
178
+
179
+ suppositionsString = (suppositionsString !== null) ?
180
+ `${suppositionsString}, ${suppositionString}` :
181
+ suppositionString; ///
182
+
183
+ return suppositionsString;
184
+ }, null);
185
+
186
+ return suppositionsString;
187
+ }
188
+
189
+ function stringFromLabelASuppositionsAndDeduction(label, suppositions, deduction) {
190
+ const suppositionsString = suppositionsStringFromSuppositions(suppositions),
191
+ deductionString = deduction.getString(),
177
192
  labelString = labelStringFromLabel(label),
178
193
  string = (labelString === null) ?
179
194
  deductionString : ///
180
- `${labelString} :: ${deductionString}`;
195
+ `${labelString} :: [${suppositionsString}] ... ${deductionString}`;
181
196
 
182
197
  return string;
183
198
  }
@@ -124,8 +124,9 @@ export default domAssigned(class Variable {
124
124
  substitutionPresent = substitutions.isSubstitutionPresentByVariable(variable);
125
125
 
126
126
  if (substitutionPresent) {
127
- const substitution = substitutions.findSubstitutionByVariable(variable),
128
- substitutionTermEqualToTerm = substitution.isTermEqualTo(term);
127
+ const context = specificContext, ///
128
+ substitution = substitutions.findSubstitutionByVariable(variable),
129
+ substitutionTermEqualToTerm = substitution.isTermEqualTo(term, context);
129
130
 
130
131
  if (substitutionTermEqualToTerm) {
131
132
  termUnified = true;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ import { arrayUtilities } from "necessary";
4
+
3
5
  import { stripBracketsFromTermNode } from "./utilities/brackets";
4
6
 
7
+ const { compress } = arrayUtilities;
8
+
5
9
  export default class Equivalence {
6
10
  constructor(terms) {
7
11
  this.terms = terms;
@@ -15,9 +19,23 @@ export default class Equivalence {
15
19
  const termString = term.getString(),
16
20
  equivalenceString = this.asString(); ///
17
21
 
18
- context.trace(`Adding the '${termString}' term to the '${equivalenceString}' equivalence.`);
22
+ context.trace(`Adding the '${termString}' term to the '${equivalenceString}' equivalence....`);
19
23
 
20
- this.terms.push(term);
24
+ const termA = term, ///
25
+ termPresent = this.someTerm((term) => {
26
+ const termB = term, ///
27
+ termAEqualToTermB = termA.isEqualTo(termB);
28
+
29
+ if (termAEqualToTermB) {
30
+ return true;
31
+ }
32
+ });
33
+
34
+ if (!termPresent) {
35
+ this.terms.push(term);
36
+
37
+ context.debug(`...added the '${termString}' term to the '${equivalenceString}' equivalence.`);
38
+ }
21
39
  }
22
40
 
23
41
  getType() {
@@ -40,19 +58,6 @@ export default class Equivalence {
40
58
  return type;
41
59
  }
42
60
 
43
- matchType(type) {
44
- const typeA = type; ///
45
-
46
- type = this.getType();
47
-
48
- const typeB = type; ///
49
-
50
- const typeAEqualToTypeB = typeA.isEqualTo(typeB),
51
- typeMatches = typeAEqualToTypeB; ///
52
-
53
- return typeMatches;
54
- }
55
-
56
61
  equateTerm(term) {
57
62
  const termA = term, ///
58
63
  termEquates = this.someTerm((term) => {
@@ -112,8 +117,45 @@ export default class Equivalence {
112
117
  return variableNodeMatches;
113
118
  }
114
119
 
120
+ isDisjointFrom(equivalence) {
121
+ const disjointFrom = equivalence.everyTerm((term) => {
122
+ const termEquates = this.equateTerm(term);
123
+
124
+ if (!termEquates) {
125
+ return true;
126
+ }
127
+ });
128
+
129
+ return disjointFrom;
130
+ }
131
+
132
+ mergedWith(equivalence) {
133
+ const equivalenceA = this,
134
+ equivalenceB = equivalence, ///
135
+ equivalenceATerms = equivalenceA.getTerms(),
136
+ equivalenceTermsB = equivalenceB.getTerms(),
137
+ terms = [
138
+ ...equivalenceATerms,
139
+ ...equivalenceTermsB
140
+ ];
141
+
142
+ compress(terms, (termA, termB) => {
143
+ const termAEqualToTermB = termA.isEqualTo(termB);
144
+
145
+ if (termAEqualToTermB) {
146
+ return true;
147
+ }
148
+ });
149
+
150
+ equivalence = new Equivalence(terms);
151
+
152
+ return equivalence;
153
+ }
154
+
115
155
  someTerm(callback) { return this.terms.some(callback); }
116
156
 
157
+ everyTerm(callback) { return this.terms.every(callback); }
158
+
117
159
  someOtherTerm(term, callback) {
118
160
  const termA = term, ///
119
161
  terms = this.terms.filter((term) => {
@@ -201,43 +243,24 @@ export default class Equivalence {
201
243
  }
202
244
 
203
245
  asString() {
204
- let string;
205
-
206
- string = this.terms.reduce((string, term) => {
207
- const termString = term.getString();
208
-
209
- string = (string === null) ?
210
- termString :
211
- `${string} = ${termString}`;
212
-
213
- return string;
214
- }, null);
215
-
216
246
  const type = this.getType(),
217
- typeString = type.getString();
218
-
219
- string = `${string}:${typeString}`;
247
+ typeString = type.getString(),
248
+ termsString = this.terms.reduce((termsString, term) => {
249
+ const termString = term.getString();
220
250
 
221
- return string;
222
- }
251
+ termsString = (termsString === null) ?
252
+ termString :
253
+ `${termsString} = ${termString}`;
223
254
 
224
- static merge(leftEquivalence, rightEquivalence) {
225
- const leftEquivalenceTerms = leftEquivalence.getTerms(),
226
- rightEquivalenceTerms = rightEquivalence.getTerms(),
227
- terms = [
228
- ...leftEquivalenceTerms,
229
- ...rightEquivalenceTerms
230
- ],
231
- equivalence = new Equivalence(terms);
255
+ return termsString;
256
+ }, null),
257
+ string = `${termsString}:${typeString}`;
232
258
 
233
- return equivalence;
259
+ return string;
234
260
  }
235
261
 
236
- static fromLeftTermAndRightTerm(leftTerm, rightTerm) {
237
- const terms = [
238
- leftTerm,
239
- rightTerm
240
- ],
262
+ static fromEquality(equality) {
263
+ const terms = equality.getTerms(),
241
264
  equivalence = new Equivalence(terms);
242
265
 
243
266
  return equivalence;