occam-verify-cli 1.0.809 → 1.0.814

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 (91) hide show
  1. package/lib/context/bounded.js +6 -6
  2. package/lib/context/branching.js +3 -3
  3. package/lib/context/ephemeral.js +3 -3
  4. package/lib/context/file/nominal.js +16 -16
  5. package/lib/context/liminal.js +26 -30
  6. package/lib/context/synoptic.js +62 -2
  7. package/lib/context.js +66 -54
  8. package/lib/element/assertion/defined.js +8 -8
  9. package/lib/element/assertion/satisfies.js +15 -11
  10. package/lib/element/assertion.js +5 -5
  11. package/lib/element/assumption/metaLevel.js +3 -3
  12. package/lib/element/conclusion.js +11 -8
  13. package/lib/element/deduction.js +11 -8
  14. package/lib/element/frame.js +6 -14
  15. package/lib/element/label.js +5 -8
  16. package/lib/element/metavariable.js +17 -17
  17. package/lib/element/procedureCall.js +10 -6
  18. package/lib/element/proofAssertion/premise.js +27 -27
  19. package/lib/element/proofAssertion/step.js +25 -5
  20. package/lib/element/proofAssertion/supposition.js +27 -27
  21. package/lib/element/proofAssertion.js +10 -10
  22. package/lib/element/reference.js +9 -13
  23. package/lib/element/rule.js +41 -43
  24. package/lib/element/signature.js +4 -4
  25. package/lib/element/statement.js +35 -45
  26. package/lib/element/subproof.js +4 -4
  27. package/lib/element/substitution/frame.js +16 -11
  28. package/lib/element/substitution/reference.js +15 -10
  29. package/lib/element/substitution/statement.js +55 -51
  30. package/lib/element/substitution/term.js +15 -10
  31. package/lib/element/substitution.js +29 -31
  32. package/lib/element/term.js +1 -16
  33. package/lib/element/topLevelAssertion/axiom.js +5 -3
  34. package/lib/element/topLevelAssertion.js +36 -38
  35. package/lib/element/variable.js +6 -6
  36. package/lib/node/frame.js +1 -9
  37. package/lib/node/statement.js +1 -9
  38. package/lib/node/term.js +1 -19
  39. package/lib/process/assign.js +23 -31
  40. package/lib/utilities/element.js +33 -5
  41. package/lib/utilities/equivalence.js +4 -4
  42. package/lib/utilities/equivalences.js +28 -13
  43. package/lib/utilities/string.js +2 -2
  44. package/lib/utilities/substitutions.js +16 -15
  45. package/lib/utilities/unification.js +133 -124
  46. package/package.json +1 -1
  47. package/src/context/bounded.js +5 -5
  48. package/src/context/branching.js +2 -2
  49. package/src/context/ephemeral.js +2 -2
  50. package/src/context/file/nominal.js +15 -15
  51. package/src/context/liminal.js +29 -35
  52. package/src/context/synoptic.js +81 -1
  53. package/src/context.js +88 -69
  54. package/src/element/assertion/defined.js +8 -8
  55. package/src/element/assertion/satisfies.js +17 -10
  56. package/src/element/assertion.js +8 -8
  57. package/src/element/assumption/metaLevel.js +4 -2
  58. package/src/element/conclusion.js +12 -7
  59. package/src/element/deduction.js +12 -7
  60. package/src/element/frame.js +7 -20
  61. package/src/element/label.js +3 -5
  62. package/src/element/metavariable.js +27 -27
  63. package/src/element/procedureCall.js +14 -9
  64. package/src/element/proofAssertion/premise.js +41 -41
  65. package/src/element/proofAssertion/step.js +37 -7
  66. package/src/element/proofAssertion/supposition.js +41 -41
  67. package/src/element/proofAssertion.js +10 -9
  68. package/src/element/reference.js +9 -13
  69. package/src/element/rule.js +57 -61
  70. package/src/element/signature.js +3 -3
  71. package/src/element/statement.js +54 -68
  72. package/src/element/subproof.js +3 -3
  73. package/src/element/substitution/frame.js +18 -8
  74. package/src/element/substitution/reference.js +16 -7
  75. package/src/element/substitution/statement.js +78 -67
  76. package/src/element/substitution/term.js +15 -6
  77. package/src/element/substitution.js +38 -41
  78. package/src/element/term.js +0 -26
  79. package/src/element/topLevelAssertion/axiom.js +5 -2
  80. package/src/element/topLevelAssertion.js +49 -53
  81. package/src/element/variable.js +5 -5
  82. package/src/node/frame.js +0 -12
  83. package/src/node/statement.js +0 -12
  84. package/src/node/term.js +0 -28
  85. package/src/process/assign.js +35 -46
  86. package/src/utilities/element.js +32 -4
  87. package/src/utilities/equivalence.js +3 -4
  88. package/src/utilities/equivalences.js +29 -17
  89. package/src/utilities/string.js +2 -2
  90. package/src/utilities/substitutions.js +17 -15
  91. package/src/utilities/unification.js +145 -119
@@ -16,8 +16,8 @@ import { labelsFromJSON,
16
16
  hypothesesToHypothesesJSON,
17
17
  suppositionsToSuppositionsJSON } from "../utilities/json";
18
18
 
19
- const { extract, reverse, correlate } = arrayUtilities,
20
- { asyncForwardsEvery, asyncBackwardsEvery } = asynchronousUtilities;
19
+ const { reverse, correlate } = arrayUtilities,
20
+ { asyncExtract, asyncForwardsEvery, asyncBackwardsEvery } = asynchronousUtilities;
21
21
 
22
22
  export default class TopLevelAssertion extends Element {
23
23
  constructor(context, string, node, labels, suppositions, deduction, proof, signature, hypotheses) {
@@ -59,6 +59,12 @@ export default class TopLevelAssertion extends Element {
59
59
  this.hypotheses = hypotheses;
60
60
  }
61
61
 
62
+ getSupposition(index) {
63
+ const supposition = this.suppositions[index] || null;
64
+
65
+ return supposition;
66
+ }
67
+
62
68
  isHypothetical() {
63
69
  const hypothesesLength = this.hypotheses.length,
64
70
  hypothetical = (hypothesesLength > 0);
@@ -73,22 +79,16 @@ export default class TopLevelAssertion extends Element {
73
79
  return unconditional;
74
80
  }
75
81
 
76
- getSupposition(index) {
77
- const supposition = this.suppositions[index] || null;
78
-
79
- return supposition;
80
- }
82
+ matchMetavariableNode(metavariableNode) {
83
+ const metavariableNodeMatches = this.labels.some((label) => {
84
+ const metavariableNodeMatches = label.matchMetavariableNode(metavariableNode);
81
85
 
82
- compareMetavariableName(metavariableName) {
83
- const comparesToMetavariableName = this.labels.some((label) => {
84
- const labelComparesToMetavariableName = label.compareMetavariableName(metavariableName);
85
-
86
- if (labelComparesToMetavariableName) {
86
+ if (metavariableNodeMatches) {
87
87
  return true;
88
88
  }
89
89
  });
90
90
 
91
- return comparesToMetavariableName;
91
+ return metavariableNodeMatches;
92
92
  }
93
93
 
94
94
  correlateHypotheses(context) {
@@ -120,28 +120,6 @@ export default class TopLevelAssertion extends Element {
120
120
  return correlatesToHypotheses;
121
121
  }
122
122
 
123
- unifyStatementWithDeduction(statement, context) {
124
- let statementUnifiesWithDeduction = false;
125
-
126
- const statementString = statement.getString(),
127
- deductionString = this.deduction.getString(),
128
- topLevelAssertionString = this.getString(); ///
129
-
130
- context.trace(`Unifying the '${statementString}' statement with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction...`);
131
-
132
- const statementUnifies = this.deduction.unifyStatement(statement, context);
133
-
134
- if (statementUnifies) {
135
- statementUnifiesWithDeduction = true;
136
- }
137
-
138
- if (statementUnifiesWithDeduction) {
139
- context.debug(`...unified the '${statementString}' statement with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction.`);
140
- }
141
-
142
- return statementUnifiesWithDeduction;
143
- }
144
-
145
123
  async verify() {
146
124
  let verifies = false;
147
125
 
@@ -304,47 +282,65 @@ export default class TopLevelAssertion extends Element {
304
282
  return suppositionsVerify;
305
283
  }
306
284
 
307
- async unifyStatementAndSubproofOrProofAssertions(statement, subproofOrProofAssertions, context) {
308
- let statementAndSubproofOrProofAssertionsUnify = false;
285
+ async unifyStepWithDeduction(step, context) {
286
+ let stepUnifiesWithDeduction = false;
287
+
288
+ await this.break(context);
289
+
290
+ const stepString = step.getString(),
291
+ deductionString = this.deduction.getString(),
292
+ topLevelAssertionString = this.getString(); ///
293
+
294
+ context.trace(`Unifying the '${stepString}' step with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction...`);
295
+
296
+ const stepUnifies = await this.deduction.unifyStep(step, context);
297
+
298
+ if (stepUnifies) {
299
+ stepUnifiesWithDeduction = true;
300
+ }
301
+
302
+ if (stepUnifiesWithDeduction) {
303
+ context.debug(`...unified the '${stepString}' step with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction.`);
304
+ }
305
+
306
+ return stepUnifiesWithDeduction;
307
+ }
308
+
309
+ async unifyStepAndSubproofOrProofAssertions(step, subproofOrProofAssertions, context) {
310
+ let stepAndSubproofOrProofAssertionsUnify = false;
309
311
 
310
312
  const correlatesToHypotheses = this.correlateHypotheses(context);
311
313
 
312
314
  if (correlatesToHypotheses) {
313
- const statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, context);
315
+ const stepUnifiesWithDeduction = await this.unifyStepWithDeduction(step, context);
314
316
 
315
- if (statementUnifiesWithDeduction) {
317
+ if (stepUnifiesWithDeduction) {
316
318
  const subproofOrProofAssertionsUnifiesWithSuppositions = await this.unifySubproofOrProofAssertionsWithSuppositions(subproofOrProofAssertions, context);
317
319
 
318
320
  if (subproofOrProofAssertionsUnifiesWithSuppositions) {
319
321
  const substitutionsResolved = context.areSubstitutionsResolved();
320
322
 
321
323
  if (substitutionsResolved) {
322
- statementAndSubproofOrProofAssertionsUnify = true;
324
+ stepAndSubproofOrProofAssertionsUnify = true;
323
325
  }
324
326
  }
325
327
  }
326
328
  }
327
329
 
328
- return statementAndSubproofOrProofAssertionsUnify;
330
+ return stepAndSubproofOrProofAssertionsUnify;
329
331
  }
330
332
 
331
333
  async unifySubproofOrProofAssertionsWithSupposition(subproofOrProofAssertions, supposition, context) {
332
334
  let subproofOrProofAssertionsUnifiesWithSupposition = false;
333
335
 
336
+ await this.break(context);
337
+
334
338
  if (!subproofOrProofAssertionsUnifiesWithSupposition) {
335
- const subproofOrProofAssertion = extract(subproofOrProofAssertions, (subproofOrProofAssertion) => {
336
- const subproofOrProofAssertionUnifies = supposition.unifySubproofOrProofAssertion(subproofOrProofAssertion, context);
339
+ const subproofOrProofAssertion = await asyncExtract(subproofOrProofAssertions, async (subproofOrProofAssertion) => {
340
+ const subproofOrProofAssertionUnifies = await supposition.unifySubproofOrProofAssertion(subproofOrProofAssertion, context);
337
341
 
338
342
  if (subproofOrProofAssertionUnifies) {
339
- const specificContext = context; ///
340
-
341
- context = this.getContext();
342
-
343
- const generalContext = context; ///
344
-
345
- context = specificContext; ///
346
-
347
- context.resolveSubstitutions(generalContext, specificContext);
343
+ context.resolveSubstitutions();
348
344
 
349
345
  return true;
350
346
  }
@@ -371,7 +367,7 @@ export default class TopLevelAssertion extends Element {
371
367
 
372
368
  subproofOrProofAssertions = reverse(subproofOrProofAssertions); ///
373
369
 
374
- subproofOrProofAssertionsUnifiesWithSuppositions = asyncBackwardsEvery(this.suppositions, async (supposition) => {
370
+ subproofOrProofAssertionsUnifiesWithSuppositions = await asyncBackwardsEvery(this.suppositions, async (supposition) => {
375
371
  const stepUnifiesWithSupposition = await this.unifySubproofOrProofAssertionsWithSupposition(subproofOrProofAssertions, supposition, context);
376
372
 
377
373
  if (stepUnifiesWithSupposition) {
@@ -45,11 +45,11 @@ export default define(class Variable extends Element {
45
45
  return identifierEqualTo;
46
46
  }
47
47
 
48
- compare(variable) {
48
+ compareVariable(variable) {
49
49
  const variableIdentifier = variable.getIdentifier(),
50
- comparesTo = (this.identifier === variableIdentifier);
50
+ comparesToVariable = (this.identifier === variableIdentifier);
51
51
 
52
- return comparesTo;
52
+ return comparesToVariable;
53
53
  }
54
54
 
55
55
  compareParamter(parameter) {
@@ -117,9 +117,9 @@ export default define(class Variable extends Element {
117
117
 
118
118
  variable = this; ///
119
119
 
120
- const variableIdentifier = variable.getIdentifier();
120
+ const variableNode = variable.getNode();
121
121
 
122
- substitution = context.findSubstitutionByVariableIdentifier(variableIdentifier);
122
+ substitution = context.findSubstitutionByVariableNode(variableNode);
123
123
 
124
124
  if (substitution !== null) {
125
125
  const substitutionComparesToTerm = substitution.compareTerm(term, context);
package/src/node/frame.js CHANGED
@@ -22,18 +22,6 @@ export default class FrameNode extends NonTerminalNode {
22
22
  return singular;
23
23
  }
24
24
 
25
- getMetavariableName() {
26
- let metavariableName = null;
27
-
28
- const metavariableNode = this.getMetavariableNode();
29
-
30
- if (metavariableNode !== null) {
31
- metavariableName = metavariableNode.getMetavariableName();
32
- }
33
-
34
- return metavariableName;
35
- }
36
-
37
25
  getAssumptionNodes() {
38
26
  const ruleName = ASSUMPTION_RULE_NAME,
39
27
  declarationNodes = this.getNodesByRuleName(ruleName);
@@ -31,18 +31,6 @@ export default class StatementNode extends NonTerminalNode {
31
31
  return singular;
32
32
  }
33
33
 
34
- getMetavariableName() {
35
- let metavariableName = null;
36
-
37
- const metavariableNode = this.getMetavariableNode();
38
-
39
- if (metavariableNode !== null) {
40
- metavariableName = metavariableNode.getMetavariableName();
41
- }
42
-
43
- return metavariableName;
44
- }
45
-
46
34
  getMetavariableNode() {
47
35
  const singularMetavariableNode = this.getSingularMetavariableNode(),
48
36
  metavariableNode = singularMetavariableNode; ///
package/src/node/term.js CHANGED
@@ -36,34 +36,6 @@ export default class TermNode extends NonTerminalNode {
36
36
  return singularTermNode;
37
37
  }
38
38
 
39
- getVariableIdentifier() {
40
- let variableIdentifier = null;
41
-
42
- const singular = this.isSingular();
43
-
44
- if (singular) {
45
- const singularVariableNode = this.getSingularVariableNode();
46
-
47
- variableIdentifier = singularVariableNode.getVariableIdentifier();
48
- }
49
-
50
- return variableIdentifier;
51
- }
52
-
53
- getSingularVariableIdentifier() {
54
- let singularVariableIdentifier = null;
55
-
56
- const singularVariableNode = this.getSingularVariableNode();
57
-
58
- if (singularVariableNode !== null) {
59
- const variableIdentifier = singularVariableNode.getVariableIdentifier();
60
-
61
- singularVariableIdentifier = variableIdentifier; ///
62
- }
63
-
64
- return singularVariableIdentifier;
65
- }
66
-
67
39
  getVariableNodes() {
68
40
  const ruleName = VARIABLE_RULE_NAME,
69
41
  variableNodes = this.getNodesByRuleName(ruleName);
@@ -24,37 +24,17 @@ export function judgementAssignmentFromJudgement(judgement, context) {
24
24
  }
25
25
 
26
26
  export function leftVariableAssignmentFromEquality(equality, context) {
27
- let leftVariableAssignment = (contxt) => {
28
- ///
29
- };
30
-
31
27
  const type = equality.getType(),
32
- leftTermNode = equality.getLeftTermNode(),
33
- singularVariableNode = leftTermNode.getSingularVariableNode();
34
-
35
- if (singularVariableNode !== null) {
36
- const leftVariableNode = singularVariableNode; ///
37
-
38
- leftVariableAssignment = variableAssignmentFromVariableNodeAndType(leftVariableNode, type, context);
39
- }
28
+ leftTerm = equality.getLeftTerm(),
29
+ leftVariableAssignment = variableAssignmentFromTermAndType(leftTerm, type, context);
40
30
 
41
31
  return leftVariableAssignment;
42
32
  }
43
33
 
44
34
  export function rightVariableAssignmentFromEquality(equality, context) {
45
- let rightVariableAssignment = (context) => {
46
- ///
47
- };
48
-
49
35
  const type = equality.getType(),
50
- rightTermNode = equality.getRightTermNode(),
51
- singularVariableNode = rightTermNode.getSingularVariableNode();
52
-
53
- if (singularVariableNode !== null) {
54
- const rightVariableNode = singularVariableNode; ///
55
-
56
- rightVariableAssignment = variableAssignmentFromVariableNodeAndType(rightVariableNode, type, context);
57
- }
36
+ rightTerm = equality.getRightTerm(),
37
+ rightVariableAssignment = variableAssignmentFromTermAndType(rightTerm, type, context);
58
38
 
59
39
  return rightVariableAssignment;
60
40
  }
@@ -68,15 +48,10 @@ export function variableAssignmentFromTypeAssertion(typeAssertion, context) {
68
48
  termSingular = term.isSingular();
69
49
 
70
50
  if (termSingular) {
71
- const variableIdentifier = term.getVariableIdentifier(),
72
- variable = context.findVariableByVariableIdentifier(variableIdentifier);
51
+ const type = typeAssertion.getType(),
52
+ variableNode = term.getVariableNode();
73
53
 
74
- if (variable !== null) {
75
- const type = typeAssertion.getType(),
76
- variableNode = variable.getNode();
77
-
78
- variableAssignment = variableAssignmentFromVariableNodeAndType(variableNode, type, context);
79
- }
54
+ variableAssignment = variableAssignmentFromTermAndType(variableNode, type, context);
80
55
  }
81
56
 
82
57
  return variableAssignment;
@@ -104,26 +79,40 @@ export function variableAssignmentFromPrepertyAssertion(propertyAssertion, conte
104
79
 
105
80
  }
106
81
 
107
- function variableAssignmentFromVariableNodeAndType(variableNode, type, context) {
108
- const variable = variableFromVariableNode(variableNode, context);
82
+ function variableAssignmentFromTermAndType(term, type, context) {
83
+ let variableAssignment = (context) => {
84
+ ///
85
+ };
86
+
87
+ const termSingular = term.isSingular();
109
88
 
110
- variable.setType(type);
89
+ if (termSingular) {
90
+ const termType = term.getType(),
91
+ termTypeEqualToType = termType.isEqualTo(type);
111
92
 
112
- const variableAssignment = (context) => {
113
- const declaredVariable = variable; ///
93
+ if (!termTypeEqualToType) {
94
+ const variableNode = term.getVariableNode(),
95
+ variable = variableFromVariableNode(variableNode, context);
114
96
 
115
- context.addDeclaredVariable(declaredVariable);
97
+ variable.setType(type);
116
98
 
117
- const declaredVariableTypeString = declaredVariable.getTypeString(),
118
- declaredVariableString = declaredVariable.getString(),
119
- assigned = true; ///
99
+ variableAssignment = (context) => {
100
+ const declaredVariable = variable; ///
120
101
 
121
- assigned ?
122
- context.trace(`Assigned the '${declaredVariableString}' declared variable with type '${declaredVariableTypeString}'.`) :
123
- context.debug(`Unable to assign the '${declaredVariableString}' declared variable with type '${declaredVariableTypeString}'.`);
102
+ context.addDeclaredVariable(declaredVariable);
124
103
 
125
- return assigned;
126
- };
104
+ const declaredVariableTypeString = declaredVariable.getTypeString(),
105
+ declaredVariableString = declaredVariable.getString(),
106
+ assigned = true; ///
107
+
108
+ assigned ?
109
+ context.trace(`Assigned the '${declaredVariableString}' declared variable with type '${declaredVariableTypeString}'.`) :
110
+ context.debug(`Unable to assign the '${declaredVariableString}' declared variable with type '${declaredVariableTypeString}'.`);
111
+
112
+ return assigned;
113
+ };
114
+ }
115
+ }
127
116
 
128
117
  return variableAssignment;
129
118
  }
@@ -618,9 +618,10 @@ export function termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, c
618
618
  const { TermSubstitution } = elements,
619
619
  node = termSubstitutionNode, ///
620
620
  string = context.nodeAsString(node),
621
+ generalContext = generalContextFromTermSubstitutionNode(termSubstitutionNode, context),
621
622
  targetTerm = targetTermFromTermSubstitutionNode(termSubstitutionNode, context),
622
623
  replacementTerm = replacementTermFromTermSubstitutionNode(termSubstitutionNode, context),
623
- termSubstitution = new TermSubstitution(context, string, node, targetTerm, replacementTerm);
624
+ termSubstitution = new TermSubstitution(context, string, node, generalContext, targetTerm, replacementTerm);
624
625
 
625
626
  return termSubstitution;
626
627
  }
@@ -629,9 +630,10 @@ export function frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode
629
630
  const { FrameSubstitution } = elements,
630
631
  node = frameSubstitutionNode, ///
631
632
  string = context.nodeAsString(node),
633
+ generalContext = generalContextFromFrameSubstitutionNode(frameSubstitutionNode, context),
632
634
  targetFrame = targetFrameFromFrameSubstitutionNode(frameSubstitutionNode, context),
633
635
  replacementFrame = replacementFrameFromFrameSubstitutionNode(frameSubstitutionNode, context),
634
- frameSubstitution = new FrameSubstitution(context, string, node, targetFrame, replacementFrame);
636
+ frameSubstitution = new FrameSubstitution(context, string, node, generalContext, targetFrame, replacementFrame);
635
637
 
636
638
  return frameSubstitution;
637
639
  }
@@ -767,9 +769,10 @@ export function referenceSubstitutionFromReferenceSubstitutionNode(referenceSubs
767
769
  const { ReferenceSubstitution } = elements,
768
770
  node = referenceSubstitutionNode, ///
769
771
  string = context.nodeAsString(node),
772
+ generalContext = generalContextFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
770
773
  targetReference = targetReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
771
774
  replacementReference = replacementReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
772
- referenceSubstitution = new ReferenceSubstitution(context, string, node, targetReference, replacementReference);
775
+ referenceSubstitution = new ReferenceSubstitution(context, string, node, generalContext, targetReference, replacementReference);
773
776
 
774
777
  return referenceSubstitution;
775
778
  }
@@ -779,11 +782,12 @@ export function statementSubstitutionFromStatementSubstitutionNode(statementSubs
779
782
  const { StatementSubstitution } = elements,
780
783
  node = statementSubstitutionNode, ///
781
784
  string = context.nodeAsString(node),
785
+ generalContext = generalContextFromStatementSubstitutionNode(statementSubstitutionNode, context),
782
786
  resolved = resolvedFromStatementSubstitutionNode(statementSubstitutionNode, context),
783
787
  substitution = substitutionFromStatementSubstitutionNode(statementSubstitutionNode, context),
784
788
  targetStatement = targetStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
785
789
  replacementStatement = replacementStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
786
- statementSubstitution = new StatementSubstitution(context, string, node, resolved, substitution, targetStatement, replacementStatement);
790
+ statementSubstitution = new StatementSubstitution(context, string, node, generalContext, resolved, substitution, targetStatement, replacementStatement);
787
791
 
788
792
  return statementSubstitution;
789
793
  }
@@ -1757,6 +1761,12 @@ export function topLevelMetaAssertionFromReferenceNode(referenceNode, context) {
1757
1761
  return topLevelMetaAssertion;
1758
1762
  }
1759
1763
 
1764
+ export function generalContextFromTermSubstitutionNode(termSubstitutionNode, context) {
1765
+ const generalContext = null;
1766
+
1767
+ return generalContext;
1768
+ }
1769
+
1760
1770
  export function deductionFromTopLevelMetaAssertionNode(metaLemmaMetathoremNode, context) {
1761
1771
  const deductionNode = metaLemmaMetathoremNode.getDeductionNode(),
1762
1772
  deduction = deductionFromDeductionNode(deductionNode, context);
@@ -1778,6 +1788,12 @@ export function replacementTermFromTermSubstitutionNode(termSubstitutionNode, co
1778
1788
  return replacementTerm;
1779
1789
  }
1780
1790
 
1791
+ export function generalContextFromFrameSubstitutionNode(frameSubstitutionNode, context) {
1792
+ const generalContext = null;
1793
+
1794
+ return generalContext;
1795
+ }
1796
+
1781
1797
  export function superTypesFromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, context) {
1782
1798
  let superTypes = [];
1783
1799
 
@@ -1881,6 +1897,18 @@ export function provisionalFromComplexTypeDeclarationNode(complexTypeDeclaration
1881
1897
  return provisional;
1882
1898
  }
1883
1899
 
1900
+ export function generalContextFromStatementSubstitutionNode(statementSubstitutionNode, context) {
1901
+ const generalContext = null;
1902
+
1903
+ return generalContext;
1904
+ }
1905
+
1906
+ export function generalContextFromReferenceSubstitutionNode(referenceSubstitutionNode, context) {
1907
+ const generalContext = null;
1908
+
1909
+ return generalContext;
1910
+ }
1911
+
1884
1912
  export function metavariableFromMetavariableDeclarationNode(metavariableDeclarationNode, context) {
1885
1913
  const metavariableNode = metavariableDeclarationNode.getMetavariableNode(),
1886
1914
  metavariable = metavariableFromMetavariableNode(metavariableNode, context);
@@ -8,16 +8,15 @@ export function variablesFromTerm(term, context) {
8
8
  const termNode = term.getNode(),
9
9
  variableNodes = termNode.getVariableNodes(),
10
10
  variables = variableNodes.map((variableNode) => {
11
- const variableIdentifier = variableNode.getVariableIdentifier(),
12
- variable = context.findVariableByVariableIdentifier(variableIdentifier);
11
+ const variable = context.findVariableByVariableNode(variableNode);
13
12
 
14
13
  return variable;
15
14
  });
16
15
 
17
16
  compress(variables, (variableA, variableB) => {
18
- const variableAEqualToVariableB = variableA.isEqualTo(variableB);
17
+ const variableAComparesToVariableB = variableA.compareVariable(variableB);
19
18
 
20
- if (!variableAEqualToVariableB) {
19
+ if (!variableAComparesToVariableB) {
21
20
  return true;
22
21
  }
23
22
  });
@@ -2,6 +2,8 @@
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
4
 
5
+ import elements from "../elements";
6
+
5
7
  import { variablesFromTerm } from "../utilities/equivalence";
6
8
 
7
9
  const { push, separate } = arrayUtilities;
@@ -30,6 +32,16 @@ export function findEquivalenceByTerm(equivalences, term) {
30
32
  return equivalence;
31
33
  }
32
34
 
35
+ export function equivalencesFromEquality(equality, context) {
36
+ const { Equivalence } = elements,
37
+ eaulivalence = Equivalence.fromEquality(equality, context),
38
+ equivalences = [
39
+ eaulivalence
40
+ ];
41
+
42
+ return equivalences;
43
+ }
44
+
33
45
  export function findEquivalenceByTermNodes(equivalences, termNodes) {
34
46
  const equivalence = equivalences.find((equivalence) => {
35
47
  const termNodeMatches = equivalence.matchTermNodes(termNodes);
@@ -114,6 +126,23 @@ function mergeEquivalence(equivalencesA, equivalenceB, context) {
114
126
  return equivalencesA;
115
127
  }
116
128
 
129
+ function definedVariablesFromGroundedTerms(groundedTerms, definedVariables, context) {
130
+ groundedTerms.forEach((groundedTerm) => {
131
+ const term = groundedTerm, ///
132
+ variables = variablesFromTerm(term, context);
133
+
134
+ variables.forEach((variable) => {
135
+ const definedVariablesIncludesTermVariable = definedVariables.includes(variable);
136
+
137
+ if (!definedVariablesIncludesTermVariable) {
138
+ const definedVariable = variable; ///
139
+
140
+ definedVariables.push(definedVariable);
141
+ }
142
+ });
143
+ });
144
+ }
145
+
117
146
  function separateInitiallyGroundedEquivalences(equivalences, remainingEquivalences, initiallyGroundedEquivalences, context) {
118
147
  separate(equivalences, remainingEquivalences, initiallyGroundedEquivalences, (equivalence) => {
119
148
  const equivalenceInitiallyGrounded = equivalence.isInitiallyGrounded(context);
@@ -134,23 +163,6 @@ function separateImplicitlyGroundedEquivalences(equivalences, remainingEquivalen
134
163
  });
135
164
  }
136
165
 
137
- function definedVariablesFromGroundedTerms(groundedTerms, definedVariables, context) {
138
- groundedTerms.forEach((groundedTerm) => {
139
- const term = groundedTerm, ///
140
- variables = variablesFromTerm(term, context);
141
-
142
- variables.forEach((variable) => {
143
- const definedVariablesIncludesTermVariable = definedVariables.includes(variable);
144
-
145
- if (!definedVariablesIncludesTermVariable) {
146
- const definedVariable = variable; ///
147
-
148
- definedVariables.push(definedVariable);
149
- }
150
- });
151
- });
152
- }
153
-
154
166
  function groundedTermsFromGroundedEquivalencesAndDefinedVariables(groundedEquivalences, definedVariables, groundedTerms, context) {
155
167
  groundedEquivalences.forEach((groundedEquivalence) => {
156
168
  groundedEquivalence.getGroundedTerms(definedVariables, groundedTerms, context);
@@ -160,8 +160,8 @@ export function termSubstitutionStringFromTermAndVariable(term, variable) {
160
160
  }
161
161
 
162
162
  export function rulsStringFromLabelsPremisesAndConclusion(labels, premises, conclusion) {
163
- const premisesString = premisesStringFromPremises(premises),
164
- conclusionString = conclusion.getString(),
163
+ const conclusionString = conclusion.getString(),
164
+ premisesString = premisesStringFromPremises(premises),
165
165
  labelsString = labelsStringFromLabels(labels),
166
166
  ruleString = (premisesString !== null) ?
167
167
  `${labelsString} :: [${premisesString}]...${conclusionString}` :
@@ -12,8 +12,8 @@ export function termFromTermAndSubstitutions(term, generalContext, specificConte
12
12
  term = null; ///
13
13
 
14
14
  if (termSingular) {
15
- const variableIdentifier = termNode.getVariableIdentifier(),
16
- substitution = specificContext.findSubstitutionByVariableIdentifier(variableIdentifier);
15
+ const variableNode = termNode.getVariableNode(),
16
+ substitution = specificContext.findSubstitutionByVariableNode(variableNode);
17
17
 
18
18
  if (substitution !== null) {
19
19
  const termSubstitution = substitution, ///
@@ -35,8 +35,8 @@ export function frameFromFrameAndSubstitutions(frame, generalContext, specificCo
35
35
  frame = null; ///
36
36
 
37
37
  if (frameSingular) {
38
- const metavariableName = frameNode.getMetavariableName(),
39
- substitution = specificContext.findSubstitutionByMetavariableName(metavariableName);
38
+ const metavariableNode = frameNode.getMetavariableNode(),
39
+ substitution = specificContext.findSubstitutionByMetavariableNode(metavariableNode);
40
40
 
41
41
  if (substitution !== null) {
42
42
  const frameSubstitution = substitution, ///
@@ -78,11 +78,11 @@ export function statementFromStatementAndSubstitutions(statement, generalContext
78
78
  specificContext = context; ///
79
79
  }
80
80
 
81
- const metavariableName = statementNode.getMetavariableName();
81
+ const metavariableNode = statementNode.getMetavariableNode();
82
82
 
83
83
  substitution = (substitution !== null) ?
84
- specificContext.findSubstitutionByMetavariableNameAndSubstitution(metavariableName, substitution) :
85
- specificContext.findSubstitutionByMetavariableName(metavariableName);
84
+ specificContext.findSubstitutionByMetavariableNodeAndSubstitution(metavariableNode, substitution) :
85
+ specificContext.findSubstitutionByMetavariableNode(metavariableNode);
86
86
 
87
87
  if (substitution !== null) {
88
88
  const statementSubstitution = substitution, ///
@@ -96,22 +96,24 @@ export function statementFromStatementAndSubstitutions(statement, generalContext
96
96
  return statement;
97
97
  }
98
98
 
99
- export function metavariableNamesFromSubstitutions(substitutions) {
100
- const metavariableNames = [];
99
+ export function metavariableNodesFromSubstitutions(substitutions) {
100
+ const metavariableNodes = [];
101
101
 
102
102
  substitutions.forEach((substitution) => {
103
- const metavariableName = substitution.getMetavariableName();
103
+ const metavariableNode = substitution.getMetavariableNode();
104
104
 
105
- if (metavariableName !== null) {
106
- metavariableNames.push(metavariableName);
105
+ if (metavariableNode !== null) {
106
+ metavariableNodes.push(metavariableNode);
107
107
  }
108
108
  });
109
109
 
110
- compress(metavariableNames, (metavariableNameA, metavariableNameB) => {
111
- if (metavariableNameA !== metavariableNameB) {
110
+ compress(metavariableNodes, (metavariableNodeA, metavariableNodeB) => {
111
+ const metavariableNodeAMatchesetavariableNodeB = metavariableNodeA.match(metavariableNodeB);
112
+
113
+ if (!metavariableNodeAMatchesetavariableNodeB) {
112
114
  return true;
113
115
  }
114
116
  });
115
117
 
116
- return metavariableNames;
118
+ return metavariableNodes;
117
119
  }