occam-verify-cli 0.0.968 → 0.0.971

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 (145) hide show
  1. package/bin/action/verify.js +6 -8
  2. package/lib/constants.js +5 -1
  3. package/lib/context/file.js +48 -53
  4. package/lib/context/local.js +45 -39
  5. package/lib/context/release.js +3 -3
  6. package/lib/declaration.js +9 -7
  7. package/lib/equivalence.js +23 -21
  8. package/lib/judgement.js +3 -3
  9. package/lib/label.js +3 -3
  10. package/lib/log.js +3 -3
  11. package/lib/metaType.js +7 -7
  12. package/lib/metavariable.js +7 -7
  13. package/lib/node/term/bracketed.js +16 -0
  14. package/lib/proofStep.js +3 -29
  15. package/lib/releaseContext/initialise.js +11 -17
  16. package/lib/resolve/substitutions.js +99 -0
  17. package/lib/rule.js +10 -6
  18. package/lib/substitution/statementForMetavariable.js +93 -98
  19. package/lib/substitution/termForVariable.js +45 -54
  20. package/lib/substitution.js +51 -9
  21. package/lib/substitutions.js +165 -12
  22. package/lib/term.js +8 -1
  23. package/lib/topLevelAssertion.js +10 -6
  24. package/lib/type.js +5 -5
  25. package/lib/unifier/metaLevel.js +10 -3
  26. package/lib/unifier/statementWithCombinator.js +6 -6
  27. package/lib/unifier.js +2 -2
  28. package/lib/unify/metavariableWithStatement.js +13 -48
  29. package/lib/unify/metavariableWithStatementGivenSubstitution.js +39 -0
  30. package/lib/unify/premiseWithProofStep.js +3 -3
  31. package/lib/unify/statement/qualified.js +117 -0
  32. package/lib/unify/statement/unqualified.js +25 -0
  33. package/lib/unify/statementWithBracketedCombinator.js +3 -3
  34. package/lib/unify/statementWithCombinators.js +5 -5
  35. package/lib/unify/statementWithMetaType.js +3 -3
  36. package/lib/unify/statementWithSttaemetnGivenEquivalences.js +45 -0
  37. package/lib/unify/suppositionWithProffStep.js +3 -3
  38. package/lib/unify/variableWithTerm.js +11 -26
  39. package/lib/utilities/array.js +5 -14
  40. package/lib/utilities/assertion.js +24 -0
  41. package/lib/utilities/brackets.js +60 -0
  42. package/lib/utilities/message.js +52 -0
  43. package/lib/utilities/name.js +7 -7
  44. package/lib/utilities/node.js +10 -17
  45. package/lib/utilities/string.js +1 -7
  46. package/lib/utilities/subproof.js +19 -0
  47. package/lib/utilities/unify.js +30 -11
  48. package/lib/variable.js +8 -8
  49. package/lib/verifier/metaLevel.js +6 -6
  50. package/lib/verifier/statementAsCombinator.js +2 -2
  51. package/lib/verify/assertion/contained.js +66 -32
  52. package/lib/verify/assertion/defined.js +51 -46
  53. package/lib/verify/assertion/subproof.js +9 -9
  54. package/lib/verify/assertion/type.js +11 -11
  55. package/lib/verify/conclusion.js +6 -6
  56. package/lib/verify/consequent.js +6 -6
  57. package/lib/verify/declaration/metavariable.js +2 -2
  58. package/lib/verify/declaration.js +34 -20
  59. package/lib/verify/equality.js +13 -13
  60. package/lib/verify/frame.js +38 -24
  61. package/lib/verify/judgement.js +13 -13
  62. package/lib/verify/metavariable.js +2 -2
  63. package/lib/verify/premise.js +5 -5
  64. package/lib/verify/proofStep.js +15 -24
  65. package/lib/verify/statement/qualified.js +15 -124
  66. package/lib/verify/statement/unqualified.js +23 -24
  67. package/lib/verify/statement.js +24 -24
  68. package/lib/verify/statementGivenMetaType.js +3 -3
  69. package/lib/verify/supposition.js +5 -5
  70. package/package.json +2 -2
  71. package/src/constants.js +1 -0
  72. package/src/context/file.js +49 -55
  73. package/src/context/local.js +34 -31
  74. package/src/context/release.js +2 -2
  75. package/src/declaration.js +12 -10
  76. package/src/equivalence.js +27 -26
  77. package/src/judgement.js +2 -2
  78. package/src/label.js +2 -2
  79. package/src/log.js +1 -1
  80. package/src/metaType.js +7 -7
  81. package/src/metavariable.js +7 -7
  82. package/src/node/term/bracketed.js +9 -0
  83. package/src/proofStep.js +3 -48
  84. package/src/releaseContext/initialise.js +13 -24
  85. package/src/resolve/substitutions.js +134 -0
  86. package/src/rule.js +10 -5
  87. package/src/substitution/statementForMetavariable.js +99 -85
  88. package/src/substitution/termForVariable.js +50 -65
  89. package/src/substitution.js +46 -8
  90. package/src/substitutions.js +176 -10
  91. package/src/term.js +6 -0
  92. package/src/topLevelAssertion.js +10 -5
  93. package/src/type.js +4 -4
  94. package/src/unifier/metaLevel.js +11 -3
  95. package/src/unifier/statementWithCombinator.js +5 -5
  96. package/src/unifier.js +1 -1
  97. package/src/unify/metavariableWithStatement.js +17 -71
  98. package/src/unify/metavariableWithStatementGivenSubstitution.js +39 -0
  99. package/src/unify/premiseWithProofStep.js +1 -1
  100. package/src/unify/statement/qualified.js +183 -0
  101. package/src/unify/statement/unqualified.js +24 -0
  102. package/src/unify/statementWithBracketedCombinator.js +2 -2
  103. package/src/unify/statementWithCombinators.js +4 -4
  104. package/src/unify/statementWithMetaType.js +2 -2
  105. package/src/unify/statementWithSttaemetnGivenEquivalences.js +51 -0
  106. package/src/unify/suppositionWithProffStep.js +1 -1
  107. package/src/unify/variableWithTerm.js +14 -35
  108. package/src/utilities/array.js +1 -16
  109. package/src/utilities/assertion.js +19 -0
  110. package/src/utilities/brackets.js +56 -0
  111. package/src/utilities/name.js +8 -8
  112. package/src/utilities/node.js +14 -17
  113. package/src/utilities/string.js +2 -2
  114. package/src/utilities/subproof.js +18 -0
  115. package/src/utilities/unify.js +24 -12
  116. package/src/variable.js +11 -11
  117. package/src/verifier/metaLevel.js +5 -5
  118. package/src/verifier/statementAsCombinator.js +2 -2
  119. package/src/verify/assertion/contained.js +80 -38
  120. package/src/verify/assertion/defined.js +64 -55
  121. package/src/verify/assertion/subproof.js +8 -8
  122. package/src/verify/assertion/type.js +11 -11
  123. package/src/verify/conclusion.js +8 -8
  124. package/src/verify/consequent.js +8 -8
  125. package/src/verify/declaration/metavariable.js +4 -3
  126. package/src/verify/declaration.js +46 -23
  127. package/src/verify/equality.js +13 -13
  128. package/src/verify/frame.js +48 -28
  129. package/src/verify/judgement.js +13 -13
  130. package/src/verify/metavariable.js +3 -3
  131. package/src/verify/premise.js +6 -6
  132. package/src/verify/proofStep.js +14 -31
  133. package/src/verify/statement/qualified.js +18 -199
  134. package/src/verify/statement/unqualified.js +25 -31
  135. package/src/verify/statement.js +23 -23
  136. package/src/verify/statementGivenMetaType.js +2 -2
  137. package/src/verify/supposition.js +6 -6
  138. package/lib/unify/statementAtainstStatement.js +0 -49
  139. package/lib/utilities/lineIndex.js +0 -52
  140. package/lib/utilities/match.js +0 -59
  141. package/lib/utilities/verify.js +0 -19
  142. package/src/unify/statementAtainstStatement.js +0 -56
  143. package/src/utilities/match.js +0 -53
  144. package/src/utilities/verify.js +0 -14
  145. /package/src/utilities/{lineIndex.js → message.js} +0 -0
@@ -3,26 +3,27 @@
3
3
  import Substitution from "../substitution";
4
4
 
5
5
  import { nodeQuery } from "../utilities/query";
6
+ import { stripBracketsFromTerm } from "../utilities/brackets";
6
7
 
7
- const termNodeQuery = nodeQuery("/*/term!"),
8
+ const termNodeQuery = nodeQuery("/substitution/term!"),
8
9
  variableNodeQuery = nodeQuery("/*/variable!");
9
10
 
10
11
  export default class TermForVariableSubstitution extends Substitution {
11
- constructor(variableNode, termNode) {
12
+ constructor(termNode, variableNode) {
12
13
  super();
13
14
 
14
- this.variableNode = variableNode;
15
15
  this.termNode = termNode;
16
- }
17
-
18
- getVariableNode() {
19
- return this.variableNode;
16
+ this.variableNode = variableNode;
20
17
  }
21
18
 
22
19
  getTermNode() {
23
20
  return this.termNode;
24
21
  }
25
22
 
23
+ getVariableNode() {
24
+ return this.variableNode;
25
+ }
26
+
26
27
  getNode() {
27
28
  const node = this.termNode; ///
28
29
 
@@ -32,12 +33,11 @@ export default class TermForVariableSubstitution extends Substitution {
32
33
  transformed(substitutions) {
33
34
  let transformedSubstitution = null;
34
35
 
35
- const transformedTermNode = transformTermNode(this.termNode, substitutions),
36
- transformedVariableNode = transformVariableNode(this.variableNode, substitutions);
36
+ const transformedTermNode = transformTermNode(this.termNode, substitutions);
37
37
 
38
- if ((transformedTermNode !== null) && (transformedVariableNode !== null)) {
38
+ if (transformedTermNode !== null) {
39
39
  const termNode = transformedTermNode, ///
40
- variableNode = transformedVariableNode,
40
+ variableNode = this.variableNode, ///
41
41
  termForVariableSubstitution = new TermForVariableSubstitution(termNode, variableNode);
42
42
 
43
43
  transformedSubstitution = termForVariableSubstitution; ///
@@ -46,29 +46,41 @@ export default class TermForVariableSubstitution extends Substitution {
46
46
  return transformedSubstitution;
47
47
  }
48
48
 
49
+ match(substitution) {
50
+ const termNode = substitution.getTermNode(),
51
+ variableNode = substitution.getVariableNode(),
52
+ termNodeMatches = this.matchTermNode(termNode),
53
+ variableNodeMatches = this.matchVariableNode(variableNode),
54
+ matches = (termNodeMatches && variableNodeMatches);
55
+
56
+ return matches;
57
+ }
58
+
49
59
  matchTermNode(termNode) {
50
- const matchesTermNode = this.termNode.match(termNode);
60
+ termNode = stripBracketsFromTerm(termNode); ///
51
61
 
52
- return matchesTermNode;
62
+ const termNodeMatches = this.termNode.match(termNode);
63
+
64
+ return termNodeMatches;
53
65
  }
54
66
 
55
67
  matchVariableNode(variableNode) {
56
- const matchesVariableNode = this.variableNode.match(variableNode);
68
+ const metavariableNodeMatches = this.variableNode.match(variableNode);
57
69
 
58
- return matchesVariableNode;
70
+ return metavariableNodeMatches;
59
71
  }
60
72
 
61
73
  unifyWithEquivalence(equivalence, substitutions, localContextA, localContextB) {
62
74
  let unifiedWithEquivalence;
63
75
 
64
- const equivalenceMatchesVariableNode = equivalence.matchVariableNode(this.variableNode);
76
+ const equivalenceMatchesTermNode = equivalence.matchTermNode(this.termNode);
65
77
 
66
- if (equivalenceMatchesVariableNode) {
67
- const equivalenceMatchesTermNode = equivalence.matchTermNode(this.termNode);
78
+ if (equivalenceMatchesTermNode) {
79
+ const equivalenceMatchesVariableNode = equivalence.matchVariableNode(this.variableNode);
68
80
 
69
- if (equivalenceMatchesTermNode) {
70
- unifiedWithEquivalence = true;
71
- }
81
+ if (equivalenceMatchesVariableNode) {
82
+ unifiedWithEquivalence = true;
83
+ }
72
84
  }
73
85
 
74
86
  return unifiedWithEquivalence;
@@ -78,38 +90,32 @@ export default class TermForVariableSubstitution extends Substitution {
78
90
  const termNodeB = this.termNode, ///
79
91
  termStringB = localContextB.nodeAsString(termNodeB),
80
92
  variableNodeA = this.variableNode, ///
81
- variableStringA = localContextA.nodeAsString(variableNodeA),
82
- string = `[${termStringB} for ${variableStringA}]`;
93
+ variableStringA = localContextA.nodeAsString(variableNodeA);
94
+
95
+ const string = `[${termStringB} for ${variableStringA}]`;
83
96
 
84
97
  return string;
85
98
  }
86
99
 
87
100
  static fromSubstitutionNode(substitutionNode) {
88
- const termNode = termNodeQuery(substitutionNode),
89
- variableNode = variableNodeQuery(substitutionNode),
90
- termForVariableSubstitution = new TermForVariableSubstitution(variableNode, termNode);
101
+ let termForVariableSubstitution = null;
91
102
 
92
- return termForVariableSubstitution;
93
- }
103
+ let termNode = termNodeQuery(substitutionNode),
104
+ variableNode = variableNodeQuery(substitutionNode);
105
+
106
+ if (termNode !== null) {
107
+ termNode = stripBracketsFromTerm(termNode); ///
94
108
 
95
- static fromVariableNodeAndTermNode(variableNode, termNode) {
96
- const termForVariableSubstitution = new TermForVariableSubstitution(variableNode, termNode);
109
+ termForVariableSubstitution = new TermForVariableSubstitution(termNode, variableNode);
110
+ }
97
111
 
98
112
  return termForVariableSubstitution;
99
113
  }
100
114
 
101
- static fromSubstitutionAndSubstitutions(substitution, substitutions) {
102
- let termNode = substitution.getTermNode(),
103
- variableNode = substitution.getVariableNode();
104
-
105
- const transformedTermNode = transformTermNode(termNode, substitutions),
106
- transformedVariableNode = transformVariableNode(variableNode, substitutions); ///
115
+ static fromTernNodeAndVariableNode(termNode, variableNode) {
116
+ termNode = stripBracketsFromTerm(termNode); ///
107
117
 
108
- termNode = transformedTermNode; ///
109
-
110
- variableNode = transformedVariableNode; ///
111
-
112
- const termForVariableSubstitution = new TermForVariableSubstitution(variableNode, termNode);
118
+ const termForVariableSubstitution = new TermForVariableSubstitution(termNode, variableNode);
113
119
 
114
120
  return termForVariableSubstitution;
115
121
  }
@@ -118,11 +124,11 @@ export default class TermForVariableSubstitution extends Substitution {
118
124
  function transformTermNode(termNode, substitutions) {
119
125
  let transformedTermNode = null;
120
126
 
121
- const termVariableNode = variableNodeQuery(termNode);
127
+ const variableNode = variableNodeQuery(termNode);
122
128
 
123
- if (termVariableNode !== null) {
129
+ if (variableNode !== null) {
124
130
  substitutions.someSubstitution((substitution) => {
125
- const substitutionMatchesVariableNode = substitution.matchVariableNode(termVariableNode);
131
+ const substitutionMatchesVariableNode = substitution.matchVariableNode(variableNode);
126
132
 
127
133
  if (substitutionMatchesVariableNode) {
128
134
  const termNode = substitution.getTermNode();
@@ -136,24 +142,3 @@ function transformTermNode(termNode, substitutions) {
136
142
 
137
143
  return transformedTermNode;
138
144
  }
139
-
140
- function transformVariableNode(variableNode, substitutions) {
141
- let transformedVariableNode = null;
142
-
143
- substitutions.someSubstitution((substitution) => {
144
- const substitutionMatchesVariableNode = substitution.matchVariableNode(variableNode);
145
-
146
- if (substitutionMatchesVariableNode) {
147
- const termNode = substitution.getTermNode(),
148
- variableNode = variableNodeQuery(termNode);
149
-
150
- if (variableNode !== null) {
151
- transformedVariableNode = variableNode; ///
152
-
153
- return true;
154
- }
155
- }
156
- });
157
-
158
- return transformedVariableNode;
159
- }
@@ -1,28 +1,66 @@
1
1
  "use strict";
2
2
 
3
3
  export default class Substitution {
4
+ isSimple() {
5
+ const simple = true;
6
+
7
+ return simple;
8
+ }
9
+
10
+ isComplex() {
11
+ const simple = this.isSimple(),
12
+ complex = !simple;
13
+
14
+ return complex;
15
+ }
16
+
17
+ isResolved() {
18
+ const simple = this.isSimple(),
19
+ resolved = simple; ///
20
+
21
+ return resolved;
22
+ }
23
+
24
+ getMetavariableNode() {
25
+ const metavariableNode = null;
26
+
27
+ return metavariableNode;
28
+ }
29
+
4
30
  matchTermNode(termNode) {
5
- const matchesTermNode = false;
31
+ const termNodeMatches = false;
6
32
 
7
- return matchesTermNode;
33
+ return termNodeMatches;
8
34
  }
9
35
 
10
36
  matchVariableNode(variableNode) {
11
- const matchesMetavariableNode = false;
37
+ const variableNodeMatches = false;
12
38
 
13
- return matchesMetavariableNode;
39
+ return variableNodeMatches;
14
40
  }
15
41
 
16
42
  matchStatementNode(statementNode) {
17
- const matchesStatementNode = false;
43
+ const statementNodeMatches = false;
18
44
 
19
- return matchesStatementNode;
45
+ return statementNodeMatches;
20
46
  }
21
47
 
22
48
  matchMetavariableNode(metavariableNode) {
23
- const matchesMetavariableNode = false;
49
+ const metavariableNodeMatches = false;
50
+
51
+ return metavariableNodeMatches;
52
+ }
53
+
54
+ matchMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
55
+ const metavariableNodeAndSubstitutionNodeMatches = false;
56
+
57
+ return metavariableNodeAndSubstitutionNodeMatches;
58
+ }
59
+
60
+ unifyWithEquivalence(equivalence, substitutions, localContextA, localContextB) {
61
+ let unifiedWithEquivalence = false;
24
62
 
25
- return matchesMetavariableNode;
63
+ return unifiedWithEquivalence;
26
64
  }
27
65
 
28
66
  unifyWithEquivalences(equivalences, substitutions, localContextA, localContextB) {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
- import { prune, compare, rightDifference } from "./utilities/array";
3
+ import { EMPTY_STRING } from "./constants";
4
+ import { find, first, prune, compress, rightDifference } from "./utilities/array";
4
5
 
5
6
  export default class Substitutions {
6
7
  constructor(array, savedArray) {
@@ -16,26 +17,160 @@ export default class Substitutions {
16
17
  return this.savedArray;
17
18
  }
18
19
 
19
- hasChanged() {
20
- const compares = compare(this.array, this.savedArray),
21
- changed = !compares; ///
20
+ getFirstSubstitution() {
21
+ let firstSubstitution = null;
22
22
 
23
- return changed;
23
+ const length = this.array.length;
24
+
25
+ if (length > 0) {
26
+ firstSubstitution = first(this.array);
27
+ }
28
+
29
+ return firstSubstitution;
30
+ }
31
+
32
+ getMetavariableNodes() {
33
+ const metavariableNodes = [];
34
+
35
+ this.forEachSubstitution((substitution) => {
36
+ const metavariableNode = substitution.getMetavariableNode();
37
+
38
+ if (metavariableNode !== null) {
39
+ metavariableNodes.push(metavariableNode);
40
+ }
41
+ });
42
+
43
+ compress(metavariableNodes, (metavariableNodeA, metavariableNodeB) => {
44
+ const metavariableNodeAMatchesMetavariableNodeB = metavariableNodeA.match(metavariableNodeB);
45
+
46
+ if (metavariableNodeAMatchesMetavariableNodeB) {
47
+ return true;
48
+ }
49
+ });
50
+
51
+ return metavariableNodes;
24
52
  }
25
53
 
26
- findSubstitution(callback) { return this.array.find(callback); }
54
+ findSubstitution(callback) { return this.array.find(callback) || null; } ///
27
55
 
28
56
  someSubstitution(callback) { return this.array.some(callback); }
29
57
 
30
58
  everySubstitution(callback) { return this.array.every(callback); }
31
59
 
60
+ forEachSubstitution(callback) { this.array.forEach(callback); }
61
+
62
+ findSubstitutions(callback) {
63
+ const array = find(this.array, callback),
64
+ substitutions = Substitutions.fromArray(array);
65
+
66
+ return substitutions;
67
+ }
68
+
69
+ filterSubstitution(callback) {
70
+ const array = this.array.filter(callback),
71
+ substitutions = Substitutions.fromArray(array);
72
+
73
+ return substitutions;
74
+ }
75
+
76
+ findSimpleSubstitution() {
77
+ const simpleSubstitution = this.findSubstitution((substitution) => {
78
+ const substitutionSimple = substitution.isSimple();
79
+
80
+ if (substitutionSimple) {
81
+ return true;
82
+ }
83
+ });
84
+
85
+ return simpleSubstitution;
86
+ }
87
+
88
+ findSubstitutionByVariableNode(variableNode) {
89
+ const substitution = this.findSubstitution((substitution) => {
90
+ const substitutionMatchesVariableNode = substitution.matchVariableNode(variableNode);
91
+
92
+ if (substitutionMatchesVariableNode) {
93
+ return true;
94
+ }
95
+ });
96
+
97
+ return substitution;
98
+ }
99
+
100
+ findSubstitutionsByMetavariableNode(metavariableNode) {
101
+ const substitutions = this.findSubstitutions((substitution) => {
102
+ const substitutionMatchesMetavariableNode = substitution.matchMetavariableNode(metavariableNode);
103
+
104
+ if (substitutionMatchesMetavariableNode) {
105
+ return true;
106
+ }
107
+ });
108
+
109
+ return substitutions;
110
+ }
111
+
112
+ findSimpleSubstitutionByMetavariableNode(metavariableNode) {
113
+ const substitutions = this.findSubstitutionsByMetavariableNode(metavariableNode),
114
+ simpleSubstitutions = substitutions.filterSubstitution((substitution) => {
115
+ const substitutionSimple = substitution.isSimple();
116
+
117
+ if (substitutionSimple) {
118
+ return true;
119
+ }
120
+ }),
121
+ firstSimpleSubstitution = simpleSubstitutions.getFirstSubstitution(),
122
+ simpleSubstitution = firstSimpleSubstitution; ///
123
+
124
+ return simpleSubstitution;
125
+ }
126
+
127
+ findComplexSubstitutionsByMetavariableNode(metavariableNode) {
128
+ const substitutions = this.findSubstitutionsByMetavariableNode(metavariableNode),
129
+ complexSubstitutions = substitutions.filterSubstitution((substitution) => {
130
+ const substitutionComplex = substitution.isComplex();
131
+
132
+ if (substitutionComplex) {
133
+ return true;
134
+ }
135
+ });
136
+
137
+ return complexSubstitutions;
138
+ }
139
+
140
+ findSubstitutionsByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
141
+ const substitutions = this.findSubstitutions((substitution) => {
142
+ const substitutionMatchesMetavariableNodeAndSubstitutionNode = substitution.matchMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode);
143
+
144
+ if (substitutionMatchesMetavariableNodeAndSubstitutionNode) {
145
+ return true;
146
+ }
147
+ });
148
+
149
+ return substitutions;
150
+ }
151
+
152
+ findComplexSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
153
+ const substitutions = this.findSubstitutionsByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode),
154
+ complexSubstitutions = substitutions.filterSubstitution((substitution) => {
155
+ const substitutionComplex = substitution.isComplex();
156
+
157
+ if (substitutionComplex) {
158
+ return true;
159
+ }
160
+ }),
161
+ firstComplexSubstitution = complexSubstitutions.getFirstSubstitution(),
162
+ complexSubstitution = firstComplexSubstitution; ///
163
+
164
+ return complexSubstitution;
165
+ }
166
+
32
167
  addSubstitution(substitution, localContextA, localContextB) {
33
168
  this.array.push(substitution);
34
169
 
35
170
  const substitutionNode = substitution.getNode(),
36
171
  substitutionString = substitution.asString(localContextA, localContextB);
37
172
 
38
- localContextB.trace(`Added the '${substitutionString}' substitution.`, substitutionNode);
173
+ localContextB.trace(`Added the ${substitutionString} substitution.`, substitutionNode);
39
174
  }
40
175
 
41
176
  removeSubstitution(substitution, localContextA, localContextB) {
@@ -52,7 +187,7 @@ export default class Substitutions {
52
187
  const substitutionNode = substitution.getNode(),
53
188
  substitutionString = substitution.asString(localContextA, localContextB);
54
189
 
55
- localContextB.trace(`Removed the '${substitutionString}' substitution.`, substitutionNode);
190
+ localContextB.trace(`Removed the ${substitutionString} substitution.`, substitutionNode);
56
191
  }
57
192
 
58
193
  unifyWithEquivalences(equivalences, localContextA, localContextB) {
@@ -68,6 +203,16 @@ export default class Substitutions {
68
203
  return unifiedWithEquivalences;
69
204
  }
70
205
 
206
+ areResolved() {
207
+ const resolved = this.everySubstitution((substitution) => {
208
+ const substitutionResolved = substitution.isResolved();
209
+
210
+ return substitutionResolved;
211
+ });
212
+
213
+ return resolved;
214
+ }
215
+
71
216
  snapshot() {
72
217
  this.savedArray = [
73
218
  ...this.array
@@ -96,8 +241,29 @@ export default class Substitutions {
96
241
  this.savedArray = null;
97
242
  }
98
243
 
99
- transform() {
100
- ///
244
+ asString(localContextA, localContextB) {
245
+ let string = this.array.reduce((string, substitution) => {
246
+ const substitutionString = substitution.asString(localContextA, localContextB);
247
+
248
+ string = (string === null) ?
249
+ substitutionString :
250
+ `${string}, ${substitutionString}`;
251
+
252
+ return string;
253
+ }, EMPTY_STRING);
254
+
255
+ if (string !== EMPTY_STRING) {
256
+ string = ` ${string}`;
257
+ }
258
+
259
+ return string;
260
+ }
261
+
262
+ static fromArray(array) {
263
+ const savedArray = [],
264
+ substitutions = new Substitutions(array, savedArray);
265
+
266
+ return substitutions;
101
267
  }
102
268
 
103
269
  static fromNothing() {
package/src/term.js CHANGED
@@ -60,6 +60,12 @@ export default class Term {
60
60
  return grounded;
61
61
  }
62
62
 
63
+ matchTermNode(termNode) {
64
+ const termNodeMatches = this.node.match(termNode);
65
+
66
+ return termNodeMatches;
67
+ }
68
+
63
69
  isInitiallyGrounded(localContext) {
64
70
  const variables = this.getVariables(localContext),
65
71
  variablesLength = variables.length,
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import Substitutions from "./substitutions";
4
+ import resolveSubstitutions from "./resolve/substitutions";
4
5
  import unifyConsequentWithStatement from "./unify/consequentWithStatement";
5
6
  import unifySuppositionsWithProofSteps from "./unify/suppositionsWithProofSteps";
6
7
 
@@ -48,22 +49,26 @@ export default class TopLevelAssertion {
48
49
  const consequentA = this.consequent, ///
49
50
  consequentUnified = unifyConsequentWithStatement(consequentA, statementNode, substitutions, fileContextA, localContext);
50
51
 
51
- statementUnified = consequentUnified; ///
52
+ if (consequentUnified) {
53
+ const substitutionsResolved = resolveSubstitutions(substitutions, fileContextA, localContextB);
54
+
55
+ statementUnified = substitutionsResolved; ///
56
+ }
52
57
  }
53
58
 
54
59
  return statementUnified;
55
60
  }
56
61
 
57
62
  matchMetavariableNode(metavariableNode) {
58
- const matchesMetavariableNode = this.labels.some((label) => {
59
- const labelMatchesMetavariableNode = label.matchMetavariableNode(metavariableNode);
63
+ const metavariableNodeMatches = this.labels.some((label) => {
64
+ const metavariableNodeMatches = label.matchMetavariableNode(metavariableNode);
60
65
 
61
- if (labelMatchesMetavariableNode) {
66
+ if (metavariableNodeMatches) {
62
67
  return true;
63
68
  }
64
69
  });
65
70
 
66
- return matchesMetavariableNode;
71
+ return metavariableNodeMatches;
67
72
  }
68
73
 
69
74
  static fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(Class, labels, suppositions, consequent, substitutions, fileContext) { return new Class(labels, suppositions, consequent, substitutions, fileContext); }
package/src/type.js CHANGED
@@ -92,15 +92,15 @@ export default class Type {
92
92
  }
93
93
 
94
94
  matchName(name) {
95
- const matchesName = (this.name === name);
95
+ const nodeMatches = (this.name === name);
96
96
 
97
- return matchesName;
97
+ return nodeMatches;
98
98
  }
99
99
 
100
100
  matchTypeName(typeName) {
101
- const matchesTypeName = (this.name === typeName);
101
+ const typeNameMatches = (this.name === typeName);
102
102
 
103
- return matchesTypeName;
103
+ return typeNameMatches;
104
104
  }
105
105
 
106
106
  matchTypeNode(typeNode) {
@@ -4,6 +4,7 @@ import shim from "../shim";
4
4
  import Unifier from "../unifier";
5
5
  import unifyVariableWithTerm from "../unify/variableWithTerm";
6
6
  import unifyMetavariableWithStatement from "../unify/metavariableWithStatement";
7
+ import unifyMetavariableWithStatementGivenSubstitution from "../unify/metavariableWithStatementGivenSubstitution";
7
8
 
8
9
  import { nodeQuery } from "../utilities/query";
9
10
 
@@ -36,10 +37,17 @@ class MetaLevelUnifier extends Unifier {
36
37
  const metavariableNodeA = metavariableNodeQuery(statementNodeA);
37
38
 
38
39
  if (metavariableNodeA !== null) {
39
- const substitutionNodeA = substitutionNodeQuery(statementNodeA),
40
- metavariableUnifiedWithStatement = unifyMetavariableWithStatement(metavariableNodeA, statementNodeB, substitutionNodeA, substitutions, localContextA, localContextB);
40
+ const substitutionNodeA = substitutionNodeQuery(statementNodeA);
41
41
 
42
- statementUnifiedWithStatement = metavariableUnifiedWithStatement; ///
42
+ if (substitutionNodeA === null) {
43
+ const metavariableUnifiedWithStatement = unifyMetavariableWithStatement(metavariableNodeA, statementNodeB, substitutions, localContextA, localContextB);
44
+
45
+ statementUnifiedWithStatement = metavariableUnifiedWithStatement; ///
46
+ } else {
47
+ const metavariableUnifiedWithStatementGivenSubstitution = unifyMetavariableWithStatementGivenSubstitution(metavariableNodeA, statementNodeB, substitutionNodeA, substitutions, localContextA, localContextB);
48
+
49
+ statementUnifiedWithStatement = metavariableUnifiedWithStatementGivenSubstitution; ///
50
+ }
43
51
  } else {
44
52
  const nonTerminalNodeA = statementNodeA, ///
45
53
  nonTerminalNodeB = statementNodeB, ///
@@ -12,12 +12,12 @@ const termNodeQuery = nodeQuery("/term!"),
12
12
  statementNodeQuery = nodeQuery("/statement!");
13
13
 
14
14
  class StatementWithCombinatorUnifier extends Unifier {
15
- unify(statementNode, combinatorStatementNode, assignments, derived, localContext) {
15
+ unify(statementNode, combinatorStatementNode, assignments, stated, localContext) {
16
16
  let statementUnifiedWithCombinator;
17
17
 
18
18
  const nonTerminalNodeA = statementNode, ///
19
19
  nonTerminalNodeB = combinatorStatementNode, ///
20
- nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, assignments, derived, localContext);
20
+ nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, assignments, stated, localContext);
21
21
 
22
22
  statementUnifiedWithCombinator = nonTerminalNodeUnified; ///
23
23
 
@@ -28,10 +28,10 @@ class StatementWithCombinatorUnifier extends Unifier {
28
28
  {
29
29
  nodeQueryA: statementNodeQuery,
30
30
  nodeQueryB: metaTypeNodeQuery,
31
- unify: (statementNodeA, metaTypeNodeB, assignments, derived, localContext) => {
31
+ unify: (statementNodeA, metaTypeNodeB, assignments, stated, localContext) => {
32
32
  const metaTypeNode = metaTypeNodeB, ///
33
33
  statementNode = statementNodeA, ///
34
- statementUnifiedWithMetaType = unifyStatementWithMetaType(statementNode, metaTypeNode, assignments, derived, localContext);
34
+ statementUnifiedWithMetaType = unifyStatementWithMetaType(statementNode, metaTypeNode, assignments, stated, localContext);
35
35
 
36
36
  return statementUnifiedWithMetaType;
37
37
  }
@@ -39,7 +39,7 @@ class StatementWithCombinatorUnifier extends Unifier {
39
39
  {
40
40
  nodeQueryA: termNodeQuery,
41
41
  nodeQueryB: typeNodeQuery,
42
- unify: (termNodeA, typeNodeB, assignments, derived, localContext) => {
42
+ unify: (termNodeA, typeNodeB, assignments, stated, localContext) => {
43
43
  const termNode = termNodeA, ///
44
44
  typeNode = typeNodeB, ///
45
45
  termUnifiedWithType = unifyTermWithType(termNode, typeNode, localContext);
package/src/unifier.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  import { nodeQuery } from "./utilities/query";
4
+ import { isLastRemainingArgumentFunction } from "./utilities/arguments";
4
5
  import { terminalNodeMapFromNodes, areTerminalNodeMapsEqual } from "./utilities/unifier";
5
- import {isLastRemainingArgumentFunction} from "./utilities/arguments";
6
6
 
7
7
  const nonTerminalNodeQuery = nodeQuery("/*");
8
8