occam-verify-cli 1.0.457 → 1.0.473

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 (161) hide show
  1. package/lib/constants.js +13 -1
  2. package/lib/context/ephemeral.js +270 -0
  3. package/lib/context/file.js +102 -66
  4. package/lib/context/liminal.js +120 -0
  5. package/lib/context/literal.js +92 -0
  6. package/lib/context/nominal.js +15 -1
  7. package/lib/context/release.js +66 -7
  8. package/lib/context/scoped.js +48 -40
  9. package/lib/context/synthetic.js +133 -0
  10. package/lib/element/assertion/contained.js +66 -66
  11. package/lib/element/assertion/defined.js +32 -32
  12. package/lib/element/assertion/property.js +39 -39
  13. package/lib/element/assertion/satisfies.js +22 -22
  14. package/lib/element/assumption.js +5 -8
  15. package/lib/element/conclusion.js +14 -13
  16. package/lib/element/constructor.js +2 -2
  17. package/lib/element/deduction.js +14 -13
  18. package/lib/element/derivation.js +3 -3
  19. package/lib/element/equality.js +5 -5
  20. package/lib/element/equivalence.js +112 -107
  21. package/lib/element/equivalences.js +24 -10
  22. package/lib/element/error.js +3 -3
  23. package/lib/element/frame.js +38 -21
  24. package/lib/element/hypothesis.js +2 -2
  25. package/lib/element/judgement.js +6 -5
  26. package/lib/element/metaType.js +1 -2
  27. package/lib/element/metavariable.js +46 -35
  28. package/lib/element/parameter.js +13 -5
  29. package/lib/element/procedureCall.js +16 -16
  30. package/lib/element/proof.js +14 -13
  31. package/lib/element/proofAssertion/premise.js +41 -30
  32. package/lib/element/proofAssertion/step.js +39 -35
  33. package/lib/element/proofAssertion/supposition.js +43 -32
  34. package/lib/element/proofAssertion.js +19 -5
  35. package/lib/element/propertyRelation.js +2 -2
  36. package/lib/element/reference.js +50 -9
  37. package/lib/element/rule.js +26 -28
  38. package/lib/element/section.js +2 -2
  39. package/lib/element/signature.js +9 -6
  40. package/lib/element/statement.js +44 -31
  41. package/lib/element/subproof.js +18 -17
  42. package/lib/element/substitution/frame.js +83 -46
  43. package/lib/element/substitution/reference.js +101 -19
  44. package/lib/element/substitution/statement.js +122 -75
  45. package/lib/element/substitution/term.js +93 -57
  46. package/lib/element/substitution.js +20 -69
  47. package/lib/element/substitutions.js +49 -34
  48. package/lib/element/term.js +30 -21
  49. package/lib/element/topLevelAssertion/axiom.js +8 -6
  50. package/lib/element/topLevelAssertion/conjecture.js +4 -4
  51. package/lib/element/topLevelAssertion/lemma.js +4 -4
  52. package/lib/element/topLevelAssertion/theorem.js +2 -2
  53. package/lib/element/topLevelAssertion.js +30 -23
  54. package/lib/element/topLevelMetaAssertion/metaLemma.js +2 -2
  55. package/lib/element/topLevelMetaAssertion/metatheorem.js +2 -2
  56. package/lib/element/topLevelMetaAssertion.js +16 -12
  57. package/lib/element/variable.js +30 -22
  58. package/lib/index.js +3 -3
  59. package/lib/main.js +3 -3
  60. package/lib/node/frame.js +2 -2
  61. package/lib/node/metavariable.js +4 -4
  62. package/lib/node/parameter.js +28 -7
  63. package/lib/node/substitution/frame.js +9 -31
  64. package/lib/node/substitution/reference.js +137 -0
  65. package/lib/node/substitution/statement.js +9 -31
  66. package/lib/node/substitution/term.js +9 -23
  67. package/lib/nonTerminalNodeMap.js +3 -2
  68. package/lib/process/instantiate.js +2 -14
  69. package/lib/process/unify.js +5 -5
  70. package/lib/tokenTypes.js +22 -0
  71. package/lib/utilities/context.js +54 -19
  72. package/lib/utilities/element.js +161 -336
  73. package/lib/utilities/instance.js +4 -4
  74. package/lib/utilities/string.js +18 -4
  75. package/lib/utilities/unification.js +24 -18
  76. package/lib/utilities/validation.js +31 -31
  77. package/package.json +2 -2
  78. package/src/constants.js +12 -0
  79. package/src/context/{transient.js → ephemeral.js} +15 -112
  80. package/src/context/file.js +66 -67
  81. package/src/context/liminal.js +67 -0
  82. package/src/context/{fragment.js → literal.js} +17 -4
  83. package/src/context/nominal.js +12 -0
  84. package/src/context/release.js +44 -6
  85. package/src/context/scoped.js +41 -31
  86. package/src/context/synthetic.js +60 -0
  87. package/src/element/assertion/contained.js +49 -47
  88. package/src/element/assertion/defined.js +29 -27
  89. package/src/element/assertion/property.js +35 -35
  90. package/src/element/assertion/satisfies.js +19 -18
  91. package/src/element/assumption.js +4 -10
  92. package/src/element/conclusion.js +16 -19
  93. package/src/element/constructor.js +1 -1
  94. package/src/element/deduction.js +16 -21
  95. package/src/element/derivation.js +2 -2
  96. package/src/element/equality.js +4 -4
  97. package/src/element/equivalence.js +115 -135
  98. package/src/element/equivalences.js +9 -7
  99. package/src/element/error.js +4 -2
  100. package/src/element/frame.js +50 -23
  101. package/src/element/hypothesis.js +1 -1
  102. package/src/element/judgement.js +9 -4
  103. package/src/element/metaType.js +0 -1
  104. package/src/element/metavariable.js +54 -53
  105. package/src/element/parameter.js +10 -5
  106. package/src/element/procedureCall.js +20 -18
  107. package/src/element/proof.js +14 -16
  108. package/src/element/proofAssertion/premise.js +46 -42
  109. package/src/element/proofAssertion/step.js +45 -40
  110. package/src/element/proofAssertion/supposition.js +56 -45
  111. package/src/element/proofAssertion.js +23 -5
  112. package/src/element/propertyRelation.js +1 -1
  113. package/src/element/reference.js +64 -16
  114. package/src/element/rule.js +31 -37
  115. package/src/element/section.js +1 -1
  116. package/src/element/signature.js +8 -8
  117. package/src/element/statement.js +51 -40
  118. package/src/element/subproof.js +16 -18
  119. package/src/element/substitution/frame.js +99 -42
  120. package/src/element/substitution/reference.js +120 -20
  121. package/src/element/substitution/statement.js +160 -89
  122. package/src/element/substitution/term.js +104 -63
  123. package/src/element/substitution.js +16 -58
  124. package/src/element/substitutions.js +43 -41
  125. package/src/element/term.js +37 -32
  126. package/src/element/topLevelAssertion/axiom.js +8 -6
  127. package/src/element/topLevelAssertion/conjecture.js +1 -2
  128. package/src/element/topLevelAssertion/lemma.js +2 -3
  129. package/src/element/topLevelAssertion/theorem.js +1 -1
  130. package/src/element/topLevelAssertion.js +31 -27
  131. package/src/element/topLevelMetaAssertion/metaLemma.js +1 -2
  132. package/src/element/topLevelMetaAssertion/metatheorem.js +1 -2
  133. package/src/element/topLevelMetaAssertion.js +15 -13
  134. package/src/element/variable.js +30 -31
  135. package/src/index.js +2 -1
  136. package/src/main.js +2 -1
  137. package/src/node/frame.js +1 -1
  138. package/src/node/metavariable.js +3 -3
  139. package/src/node/parameter.js +32 -5
  140. package/src/node/substitution/frame.js +6 -32
  141. package/src/node/substitution/reference.js +38 -0
  142. package/src/node/substitution/statement.js +6 -32
  143. package/src/node/substitution/term.js +6 -22
  144. package/src/nonTerminalNodeMap.js +3 -0
  145. package/src/process/instantiate.js +0 -8
  146. package/src/process/unify.js +4 -4
  147. package/src/tokenTypes.js +4 -0
  148. package/src/utilities/context.js +43 -17
  149. package/src/utilities/element.js +187 -401
  150. package/src/utilities/instance.js +3 -3
  151. package/src/utilities/string.js +21 -5
  152. package/src/utilities/unification.js +26 -23
  153. package/src/utilities/validation.js +47 -47
  154. package/lib/context/fragment.js +0 -77
  155. package/lib/context/transient.js +0 -371
  156. package/lib/log.js +0 -150
  157. package/lib/utilities/fragment.js +0 -23
  158. package/lib/utilities/node.js +0 -71
  159. package/src/log.js +0 -118
  160. package/src/utilities/fragment.js +0 -11
  161. package/src/utilities/node.js +0 -85
@@ -4,103 +4,190 @@ import elements from "../../elements";
4
4
  import Substitution from "../substitution";
5
5
 
6
6
  import { define } from "../../elements";
7
- import { withinFragment } from "../../utilities/fragment";
7
+ import { literally } from "../../utilities/context";
8
8
  import { unifySubstitution } from "../../process/unify";
9
9
  import { stripBracketsFromStatement } from "../../utilities/brackets";
10
10
  import { instantiateStatementSubstitution } from "../../process/instantiate";
11
11
  import { statementSubstitutionFromStatementSubstitutionNode } from "../../utilities/element";
12
- import { statementFromJSON, statementToStatementJSON, metavariableFromJSON, metavariableToMetavariableJSON } from "../../utilities/json";
12
+ import { statementToStatementJSON, metavariableToMetavariableJSON } from "../../utilities/json";
13
13
  import { statementSubstitutionStringFromStatementAndMetavariable, statementSubstitutionStringFromStatementMetavariableAndSubstitution } from "../../utilities/string";
14
14
 
15
15
  export default define(class StatementSubstitution extends Substitution {
16
- constructor(context, string, node, resolved, statement, metavariable, substitution) {
16
+ constructor(context, string, node, resolved, substitution, targetStatement, replacementStatement) {
17
17
  super(context, string, node);
18
18
 
19
19
  this.resolved = resolved;
20
- this.statement = statement;
21
- this.metavariable = metavariable;
22
20
  this.substitution = substitution;
21
+ this.targetStatement = targetStatement;
22
+ this.replacementStatement = replacementStatement;
23
23
  }
24
24
 
25
25
  isResolved() {
26
26
  return this.resolved;
27
27
  }
28
28
 
29
- getStatement() {
30
- return this.statement;
29
+ getSubstitution() {
30
+ return this.substitution;
31
31
  }
32
32
 
33
- getMetavariable() {
34
- return this.metavariable;
33
+ getTargetStatement() {
34
+ return this.targetStatement;
35
35
  }
36
36
 
37
- getSubstitution() {
38
- return this.substitution;
37
+ getReplacementStatement() {
38
+ return this.replacementStatement;
39
+ }
40
+
41
+ getTargetNode() {
42
+ const targetStatementNode = this.targetStatement.getNode(),
43
+ targetNode = targetStatementNode; ///
44
+
45
+ return targetNode;
39
46
  }
40
47
 
41
48
  getReplacementNode() {
42
- const statementNode = this.statement.getNode(),
43
- replacementNode = statementNode; ///
49
+ const replacementStatementNode = this.replacementStatement.getNode(),
50
+ replacementNode = replacementStatementNode; ///
44
51
 
45
52
  return replacementNode;
46
53
  }
47
54
 
48
- setStatement(statement) {
49
- this.statement = statement;
55
+ isSimple() {
56
+ const simple = (this.substitution === null);
57
+
58
+ return simple;
50
59
  }
51
60
 
52
- setMetavariable(metavariable) {
53
- this.metavariable = metavariable;
61
+ compareStatement(statement, context) {
62
+ statement = stripBracketsFromStatement(statement, context); ///
63
+
64
+ const replacementStatementEqualToStatement = this.replacementStatement.isEqualTo(statement),
65
+ comparesToStatement = replacementStatementEqualToStatement; ///
66
+
67
+ return comparesToStatement;
54
68
  }
55
69
 
56
- setSubstitution(substitution) {
57
- this.substitution = substitution;
70
+ compareParameter(parameter) {
71
+ const targetStatementComparesToParameter = this.targetStatement.compareParameter(parameter),
72
+ comparesToParameter = targetStatementComparesToParameter; ///
73
+
74
+ return comparesToParameter;
58
75
  }
59
76
 
60
- isMetavariableEqualToMetavariable(metavariable) { return this.metavariable.isEqualTo(metavariable); }
77
+ compareSubstitution(substitution) {
78
+ let comparesToSubstitution = false;
61
79
 
62
- isSubstitutionEqualToSubstitution(substitution) {
63
- let substitutionEqualToSubstitution;
80
+ if (false) {
81
+ ///
82
+ } else if ((this.substitution === null) && (substitution === null)){
83
+ comparesToSubstitution = true;
84
+ } else if ((this.substitution !== null) && (substitution !== null)){
85
+ const substitutionEqualToSubstituion = this.substitution.isEqualTo(substitution);
64
86
 
65
- if (this.substitution === null) {
66
- substitutionEqualToSubstitution = (substitution === null);
67
- } else {
68
- if (substitution === null) {
69
- substitutionEqualToSubstitution = false;
70
- } else {
71
- substitutionEqualToSubstitution = this.substitution.isEqualTo(substitution);
87
+ if (substitutionEqualToSubstituion) {
88
+ comparesToSubstitution = true;
72
89
  }
73
90
  }
74
91
 
75
- return substitutionEqualToSubstitution;
92
+ return comparesToSubstitution;
76
93
  }
77
94
 
78
- compareStatesment(statement, context) {
79
- statement = stripBracketsFromStatement(statement, context); ///
95
+ validate(context) {
96
+ let validates = false;
80
97
 
81
- const statementEqualToStatement = this.statement.isEqualTo(statement),
82
- comparesToStatement = statementEqualToStatement; ///
98
+ const statementSubstitutionString = this.getString(); ///
83
99
 
84
- return comparesToStatement;
100
+ context.trace(`Validating the '${statementSubstitutionString}' statement substitution...`);
101
+
102
+ const targetStatementValidates = this.validateTargetStatement(context);
103
+
104
+ if (targetStatementValidates) {
105
+ const replacementStatementValidates = this.validateReplacementStatement(context);
106
+
107
+ if (replacementStatementValidates) {
108
+ validates = true;
109
+ }
110
+ }
111
+
112
+ if (validates) {
113
+ const substititoin = this; ///
114
+
115
+ context.addSubstitution(substititoin);
116
+
117
+ context.debug(`...validated the '${statementSubstitutionString}' statement substitution.`);
118
+ }
119
+
120
+ return validates;
85
121
  }
86
122
 
87
- isSimple() {
88
- const simple = (this.substitution === null);
123
+ validateTargetStatement(context) {
124
+ let targetStatementValidates = false;
89
125
 
90
- return simple;
126
+ const targetStatementString = this.targetStatement.getString(),
127
+ statementSubstitutionString = this.getString(); ///
128
+
129
+ context.trace(`Validating the '${statementSubstitutionString}' statement subtitution's '${targetStatementString}' target statement...`);
130
+
131
+ const targetStatementSingular = this.targetStatement.isSingular();
132
+
133
+ if (targetStatementSingular) {
134
+ const stated = true,
135
+ assignments = null;
136
+
137
+ targetStatementValidates = this.targetStatement.validate(assignments, stated, context);
138
+ } else {
139
+ context.debug(`The '${statementSubstitutionString}' statement subtitution's '${targetStatementString}' target statement is not singular.`);
140
+ }
141
+
142
+ if (targetStatementValidates) {
143
+ context.debug(`...validated the '${statementSubstitutionString}' statement subtitution's '${targetStatementString}' target statement...`);
144
+ }
145
+
146
+ return targetStatementValidates;
147
+ }
148
+
149
+ validateReplacementStatement(context) {
150
+ let replacementStatementValidates;
151
+
152
+ const replacementStatementString = this.replacementStatement.getString(),
153
+ statementSubstitutionString = this.getString(); ///
154
+
155
+ context.trace(`Validating the '${statementSubstitutionString}' statement subtitution's '${replacementStatementString}' replacement statement...`);
156
+
157
+ const stated = true,
158
+ assignments = null;
159
+
160
+ replacementStatementValidates = this.replacementStatement.validate(assignments, stated, context);
161
+
162
+ if (replacementStatementValidates) {
163
+ context.debug(`...validated the '${statementSubstitutionString}' statement subtitution's '${replacementStatementString}' replacement statement...`);
164
+ }
165
+
166
+ return replacementStatementValidates;
91
167
  }
92
168
 
93
169
  unifyStatement(statement, context) {
94
- let substitution = null;
170
+ let statementUnifies = false;
95
171
 
96
- const { Substitutions } = elements,
97
- substitutions = Substitutions.fromNothing(),
98
- specificContext = context; ///
172
+ const statementString = statement.getString(),
173
+ statementSubstitutionString = this.getString();
174
+
175
+ context.trace(`Unifying the '${statementString}' statement with the '${statementSubstitutionString}' statement substiution's statement...`);
176
+
177
+ const specificContext = context; ///
99
178
 
100
179
  context = this.getContext();
101
180
 
102
- const generalContext = context, ///
103
- statementUnifies = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
181
+ const generalContext = context; ///
182
+
183
+ context = specificContext; ///
184
+
185
+ const { Substitutions } = elements,
186
+ substitutions = Substitutions.fromNothing(context);
187
+
188
+ statementUnifies = this.replacementStatement.unifyStatement(statement, substitutions, generalContext, specificContext);
189
+
190
+ let substitution = null;
104
191
 
105
192
  if (statementUnifies) {
106
193
  const substitutionsNonTrivialLength = substitutions.getNonTrivialLength();
@@ -109,9 +196,15 @@ export default define(class StatementSubstitution extends Substitution {
109
196
  const firstSubstitution = substitutions.getFirstSubstitution();
110
197
 
111
198
  substitution = firstSubstitution; ///
199
+ } else {
200
+ statementUnifies = false;
112
201
  }
113
202
  }
114
203
 
204
+ if (statementUnifies) {
205
+ context.trace(`...unified the '${statementString}' statement with the '${statementSubstitutionString}' statement substiution's statement.`);
206
+ }
207
+
115
208
  return substitution;
116
209
  }
117
210
 
@@ -142,41 +235,28 @@ export default define(class StatementSubstitution extends Substitution {
142
235
  }
143
236
 
144
237
  resolve(substitutions, context) {
145
- const substitutionString = this.string; ///
238
+ context = this.getContext();
239
+
240
+ const substitutionString = this.getString(); ///
146
241
 
147
242
  context.trace(`Resolving the ${substitutionString} substitution...`);
148
243
 
149
- substitutions.snapshot();
244
+ substitutions.snapshot(context);
150
245
 
151
246
  const metavariable = this.getMetavariable(),
152
- simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariable(metavariable);
153
-
154
- if (simpleSubstitution !== null) {
155
- let context;
156
-
157
- context = this.getContext();
247
+ simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariable(metavariable),
248
+ substitution = simpleSubstitution.unifyStatement(this.replacementStatement, context);
158
249
 
159
- const substitution = simpleSubstitution.unifyStatement(this.statement, context);
250
+ if (substitution !== null) {
251
+ const substitutionUnifies = this.unifySubstitution(substitution, substitutions, context);
160
252
 
161
- if (substitution !== null) {
162
- context = simpleSubstitution.getContext();
163
-
164
- const simpleContext = context; ///
165
-
166
- context = substitution.getContext();
167
-
168
- context.merge(simpleContext);
169
-
170
- const substitutionUnifies = this.unifySubstitution(substitution, substitutions, context);
171
-
172
- if (substitutionUnifies) {
173
- this.resolved = true;
174
- }
253
+ if (substitutionUnifies) {
254
+ this.resolved = true;
175
255
  }
176
256
  }
177
257
 
178
258
  this.resolved ?
179
- substitutions.continue() :
259
+ substitutions.continue(context) :
180
260
  substitutions.rollback(context);
181
261
 
182
262
  if (this.resolved) {
@@ -185,11 +265,11 @@ export default define(class StatementSubstitution extends Substitution {
185
265
  }
186
266
 
187
267
  toJSON() {
188
- const metavariableJSON = metavariableToMetavariableJSON(this.metavariable),
189
- statementJSON = statementToStatementJSON(this.statement),
268
+ const metavariableJSON = metavariableToMetavariableJSON(this.targetStatement),
269
+ statementJSON = statementToStatementJSON(this.replacementStatement),
190
270
  metavariable = metavariableJSON, ///
191
271
  statement = statementJSON, ///
192
- string = this.string, ///
272
+ string = this.getString(), ///
193
273
  json = {
194
274
  string,
195
275
  statement,
@@ -202,45 +282,36 @@ export default define(class StatementSubstitution extends Substitution {
202
282
  static name = "StatementSubstitution";
203
283
 
204
284
  static fromJSON(json, context) {
205
- const { string } = json,
206
- statementSubstitutionNode = instantiateStatementSubstitution(string, context),
207
- node = statementSubstitutionNode,
208
- resolved = true,
209
- statement = statementFromJSON(json, context),
210
- metavariable = metavariableFromJSON(json, context),
211
- substitution = null, ///
212
- statementSubstitution = new StatementSubstitution(context, string, node, resolved, statement, metavariable, substitution);
213
-
214
- return statementSubstitution;
285
+ ///
215
286
  }
216
287
 
217
288
  static fromStatementAndMetavariable(statement, metavariable, context) {
218
289
  statement = stripBracketsFromStatement(statement, context); ///
219
290
 
220
- const statementSubstitution = withinFragment((context) => {
291
+ return literally((context) => {
221
292
  const statementSubstitutionString = statementSubstitutionStringFromStatementAndMetavariable(statement, metavariable, context),
222
293
  string = statementSubstitutionString, ///
223
294
  statementSubstitutionNode = instantiateStatementSubstitution(string, context),
224
- statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context)
295
+ statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
296
+
297
+ statementSubstitution.validate(context);
225
298
 
226
299
  return statementSubstitution;
227
300
  }, context);
228
-
229
- return statementSubstitution;
230
301
  }
231
302
 
232
303
  static fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context) {
233
304
  statement = stripBracketsFromStatement(statement, context); ///
234
305
 
235
- const statementSubstitution = withinFragment((context) => {
306
+ return literally((context) => {
236
307
  const statementSubstitutionString = statementSubstitutionStringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution),
237
308
  string = statementSubstitutionString, ///
238
309
  statementSubstitutionNode = instantiateStatementSubstitution(string, context),
239
- statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context)
310
+ statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, substitution, context);
311
+
312
+ statementSubstitution.validate(context);
240
313
 
241
314
  return statementSubstitution;
242
315
  }, context);
243
-
244
- return statementSubstitution;
245
316
  }
246
317
  });
@@ -3,97 +3,139 @@
3
3
  import Substitution from "../substitution";
4
4
 
5
5
  import { define } from "../../elements";
6
+ import { literally } from "../../utilities/context";
6
7
  import { stripBracketsFromTerm } from "../../utilities/brackets";
7
8
  import { instantiateTermSubstitution } from "../../process/instantiate";
9
+ import { termSubstitutionStringFromTermAndVariable } from "../../utilities/string";
8
10
  import { termSubstitutionFromStatementNode, termSubstitutionFromTermSubstitutionNode } from "../../utilities/element";
9
11
 
10
12
  export default define(class TermSubstitution extends Substitution {
11
- constructor(context, string, node, term, variable) {
13
+ constructor(context, string, node, targetTerm, replacementTerm) {
12
14
  super(context, string, node);
13
15
 
14
- this.term = term;
15
- this.variable = variable;
16
+ this.targetTerm = targetTerm;
17
+ this.replacementTerm = replacementTerm;
16
18
  }
17
19
 
18
- getTerm() {
19
- return this.term;
20
+ getTargetTerm() {
21
+ return this.targetTerm;
20
22
  }
21
23
 
22
- getVariable() {
23
- return this.variable;
24
+ getReplacementTerm() {
25
+ return this.replacementTerm;
26
+ }
27
+
28
+ getTargetNode() {
29
+ const targetTermNode = this.targetTerm.getNode(),
30
+ tergetNode = targetTermNode; ///
31
+
32
+ return tergetNode;
24
33
  }
25
34
 
26
35
  getReplacementNode() {
27
- const termNode = this.term.getNode(),
28
- replacementNode = termNode; ///
36
+ const replacementTermNode = this.replacementTerm.getNode(),
37
+ replacementNode = replacementTermNode; ///
29
38
 
30
39
  return replacementNode;
31
40
  }
32
41
 
33
- isTermEqualToTerm(term, context) {
42
+ isTrivial() {
43
+ const targetTermEqualToReplacementTerm = this.targetTerm.isEqualTo(this.replacementTerm),
44
+ trivial = targetTermEqualToReplacementTerm; ///
45
+
46
+ return trivial;
47
+ }
48
+
49
+ compareTerm(term, context) {
34
50
  term = stripBracketsFromTerm(term, context); ///
35
51
 
36
- const termEqualToTerm = this.term.isEqualTo(term);
52
+ const termEqualToReplacementTerm = this.replacementTerm.isEqualTo(term),
53
+ comparedToTerm = termEqualToReplacementTerm; ///
37
54
 
38
- return termEqualToTerm;
55
+ return comparedToTerm;
39
56
  }
40
57
 
41
- isTrivial() {
42
- let trivial = false;
58
+ compareParameter(parameter) {
59
+ const targetTermComparesToParameter = this.targetTerm.compareParameter(parameter),
60
+ comparesToParameter = targetTermComparesToParameter; ///
61
+
62
+ return comparesToParameter;
63
+ }
64
+
65
+ validate(context) {
66
+ let validates = false;
67
+
68
+ const termSubstitutionString = this.getString(); ///
69
+
70
+ context.trace(`Validating the '${termSubstitutionString}' term substitution...`);
71
+
72
+ const targetTermValidates = this.validateTargetTerm(context);
43
73
 
44
- const termComparesToVaraible = this.term.compareVariable(this.variable);
74
+ if (targetTermValidates) {
75
+ const replacementTermValidates = this.validateReplacementTerm(context);
45
76
 
46
- if (termComparesToVaraible) {
47
- trivial = true;
77
+ if (replacementTermValidates) {
78
+ validates = true;
79
+ }
48
80
  }
49
81
 
50
- return trivial;
51
- }
82
+ if (validates) {
83
+ const substititoin = this; ///
84
+
85
+ context.addSubstitution(substititoin);
52
86
 
53
- verify(context) {
54
- let verifies = false;
87
+ context.debug(`...validated the '${termSubstitutionString}' term substitution.`);
88
+ }
55
89
 
56
- const termSubstitutionString = this.string; ///
90
+ return validates;
91
+ }
57
92
 
58
- context.trace(`Verifiying the '${termSubstitutionString}' term substitution...`);
93
+ validateTargetTerm(context) {
94
+ let targetTermValidates = false;
59
95
 
60
- const termSingular = this.term.isSingular();
96
+ const targetTermString = this.targetTerm.getString(),
97
+ termSubstitutionString = this.getString(); ///
61
98
 
62
- if (termSingular) {
63
- if (this.variable !== null) {
64
- const variableIdentifier = this.variable.getIdentifier(),
65
- variablePresent = context.isVariablePresentByVariableIdentifier(variableIdentifier);
99
+ context.trace(`Validating the '${termSubstitutionString}' term subtitution's '${targetTermString}' target term...`);
66
100
 
67
- if (variablePresent) {
68
- const termNode = this.term.getNode(),
69
- variableIdentifier = termNode.getVariableIdentifier(),
70
- termVariableIdentifier = variableIdentifier, ///
71
- termVariablePresent = context.isVariablePresentByVariableIdentifier(termVariableIdentifier);
101
+ const targetTermSingular = this.targetTerm.isSingular();
72
102
 
73
- if (termVariablePresent) {
74
- verifies = true;
75
- } else {
76
- context.debug(`The '${termSubstitutionString}' term substitution's general term's variable is not present.`);
77
- }
78
- } else {
79
- context.debug(`The '${termSubstitutionString}' term substitution's specific term's variable is not present.`);
80
- }
81
- } else {
82
- context.debug(`The '${termSubstitutionString}' term substitution's general term is not singular.`);
83
- }
103
+ if (targetTermSingular) {
104
+ targetTermValidates = this.targetTerm.validate(context, () => {
105
+ const verifiesAhead = true;
106
+
107
+ return verifiesAhead;
108
+ });
84
109
  } else {
85
- context.debug(`The '${termSubstitutionString}' term substitution's specific term is not singular.`);
110
+ context.debug(`The '${termSubstitutionString}' term subtitution's '${targetTermString}' target term is not singular.`);
86
111
  }
87
112
 
88
- if (verifies) {
89
- const substititoin = this; ///
113
+ if (targetTermValidates) {
114
+ context.debug(`...validated the '${termSubstitutionString}' term subtitution's '${targetTermString}' target term...`);
115
+ }
90
116
 
91
- context.addSubstitution(substititoin);
117
+ return targetTermValidates;
118
+ }
119
+
120
+ validateReplacementTerm(context) {
121
+ let replacementTermValidates;
92
122
 
93
- context.debug(`...verified the '${termSubstitutionString}' term substitution.`);
123
+ const replacementTermString = this.replacementTerm.getString(),
124
+ termSubstitutionString = this.getString(); ///
125
+
126
+ context.trace(`Validating the '${termSubstitutionString}' term subtitution's '${replacementTermString}' replacement term...`);
127
+
128
+ replacementTermValidates = this.replacementTerm.validate(context, () => {
129
+ const validatesAhead = true;
130
+
131
+ return validatesAhead;
132
+ });
133
+
134
+ if (replacementTermValidates) {
135
+ context.debug(`...validated the '${termSubstitutionString}' term subtitution's '${replacementTermString}' replacement term...`);
94
136
  }
95
137
 
96
- return verifies;
138
+ return replacementTermValidates;
97
139
  }
98
140
 
99
141
  static name = "TermSubstitution";
@@ -105,19 +147,18 @@ export default define(class TermSubstitution extends Substitution {
105
147
  return termSubstitution;
106
148
  }
107
149
 
108
- static fromTermAndMetavariable(term, metavariable, context) {
109
- const string = stringFromTermAndVariable(term, metavariable),
110
- termSubstitutionNode = instantiateTermSubstitution(string, context),
111
- termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, context);
150
+ static fromTermAndVariable(term, variable, context) {
151
+ term = stripBracketsFromTerm(term, context); ///
152
+
153
+ return literally((context) => {
154
+ const termSubstitutionString = termSubstitutionStringFromTermAndVariable(term, variable),
155
+ string = termSubstitutionString, ///
156
+ termSubstitutionNode = instantiateTermSubstitution(string, context),
157
+ termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, context);
112
158
 
113
- return termSubstitution;
159
+ termSubstitution.validate(context);
160
+
161
+ return termSubstitution;
162
+ }, context);
114
163
  }
115
164
  });
116
-
117
- function stringFromTermAndVariable(term, variable) {
118
- const termString = term.getString(),
119
- variableString = variable.getString(),
120
- string = `[${termString} for ${variableString}]`;
121
-
122
- return string;
123
- }