occam-verify-cli 1.0.951 → 1.0.956
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.
- package/lib/context/aphasic.js +27 -0
- package/lib/context/ephemeral.js +28 -0
- package/lib/context/liminal.js +2 -2
- package/lib/context/synoptic.js +6 -2
- package/lib/element/assertion/signature.js +2 -2
- package/lib/element/assertion/subproof.js +2 -2
- package/lib/element/conclusion.js +2 -2
- package/lib/element/constructor.js +2 -2
- package/lib/element/deduction.js +2 -2
- package/lib/element/label.js +8 -6
- package/lib/element/metavariable.js +3 -3
- package/lib/element/parameter.js +2 -2
- package/lib/element/procedureCall.js +1 -1
- package/lib/element/proofAssertion/step.js +3 -3
- package/lib/element/property.js +1 -2
- package/lib/element/reference.js +7 -5
- package/lib/element/section.js +1 -1
- package/lib/element/signature.js +7 -5
- package/lib/element/statement.js +2 -2
- package/lib/element/substitution/frame.js +87 -13
- package/lib/element/substitution/reference.js +3 -3
- package/lib/element/substitution/statement.js +53 -58
- package/lib/element/substitution/term.js +75 -4
- package/lib/element/substitution.js +1 -5
- package/lib/element/variable.js +2 -2
- package/lib/process/unify.js +2 -51
- package/lib/utilities/context.js +50 -14
- package/package.json +4 -4
- package/src/context/aphasic.js +15 -0
- package/src/context/ephemeral.js +17 -0
- package/src/context/liminal.js +1 -1
- package/src/context/synoptic.js +9 -1
- package/src/element/assertion/signature.js +1 -1
- package/src/element/assertion/subproof.js +1 -2
- package/src/element/conclusion.js +2 -2
- package/src/element/constructor.js +1 -1
- package/src/element/deduction.js +2 -2
- package/src/element/label.js +9 -7
- package/src/element/metavariable.js +2 -2
- package/src/element/parameter.js +1 -1
- package/src/element/procedureCall.js +1 -1
- package/src/element/proofAssertion/step.js +3 -2
- package/src/element/property.js +0 -1
- package/src/element/reference.js +8 -6
- package/src/element/section.js +1 -1
- package/src/element/signature.js +8 -6
- package/src/element/statement.js +1 -1
- package/src/element/substitution/frame.js +159 -22
- package/src/element/substitution/reference.js +3 -3
- package/src/element/substitution/statement.js +84 -83
- package/src/element/substitution/term.js +137 -4
- package/src/element/substitution.js +0 -6
- package/src/element/variable.js +1 -1
- package/src/process/unify.js +0 -76
- package/src/utilities/context.js +68 -19
|
@@ -7,7 +7,7 @@ import { breakPointFromJSON } from "../../utilities/breakPoint";
|
|
|
7
7
|
import { instantiateFrameSubstitution } from "../../process/instantiate";
|
|
8
8
|
import { frameSubstitutionFromFrameSubstitutionNode } from "../../utilities/element";
|
|
9
9
|
import { frameSubstitutionStringFromFrameAndMetavariable } from "../../utilities/string";
|
|
10
|
-
import { ablate, ablates, manifest, attempts,
|
|
10
|
+
import { join, ablate, ablates, manifest, attempts, reconcile, sequester, instantiate, unserialises } from "../../utilities/context";
|
|
11
11
|
|
|
12
12
|
export default define(class FrameSubstitution extends Substitution {
|
|
13
13
|
constructor(contexts, string, node, breakPoint, targetFrame, replacementFrame) {
|
|
@@ -136,7 +136,7 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
136
136
|
|
|
137
137
|
if (targetFrameSingular) {
|
|
138
138
|
manifest((context) => {
|
|
139
|
-
|
|
139
|
+
sequester((context) => {
|
|
140
140
|
const tragetFrame = this.targetFrame.validate(context);
|
|
141
141
|
|
|
142
142
|
if (tragetFrame !== null) {
|
|
@@ -167,7 +167,7 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
167
167
|
|
|
168
168
|
context.trace(`Validating the '${frameSubstitutionString}' frame substitution's replacement frame...`);
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
sequester((context) => {
|
|
171
171
|
const replacementFrame = this.replacementFrame.validate(context);
|
|
172
172
|
|
|
173
173
|
if (replacementFrame !== null) {
|
|
@@ -184,6 +184,127 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
184
184
|
return replacementFrameValidates;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
unifySubstitution(substitution, context) {
|
|
188
|
+
let substitutionUnifies = false;
|
|
189
|
+
|
|
190
|
+
const generalSubstitution = this, ///
|
|
191
|
+
specificSubstitution = substitution,
|
|
192
|
+
generalSubstitutionString = generalSubstitution.getString(),
|
|
193
|
+
specificSubstitutionString = specificSubstitution.getString();
|
|
194
|
+
|
|
195
|
+
context.trace(`Unifying the '${specificSubstitutionString}' substitution with the '${generalSubstitutionString}' substitution...`);
|
|
196
|
+
|
|
197
|
+
reconcile((context) => {
|
|
198
|
+
const replacementFrameUnifies = this.unifyReplacementFrame(substitution, context);
|
|
199
|
+
|
|
200
|
+
if (replacementFrameUnifies) {
|
|
201
|
+
const targetFrameUnifies = this.unifyTargetFrame(substitution, context);
|
|
202
|
+
|
|
203
|
+
if (targetFrameUnifies) {
|
|
204
|
+
context.commit();
|
|
205
|
+
|
|
206
|
+
substitutionUnifies = true;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}, context);
|
|
210
|
+
|
|
211
|
+
if (substitutionUnifies) {
|
|
212
|
+
context.debug(`...unified the '${specificSubstitutionString}' substitution with the '${generalSubstitutionString}' substitution.`);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return substitutionUnifies;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
unifyTargetFrame(substitution, context) {
|
|
219
|
+
let targetFrameUnifies = false;
|
|
220
|
+
|
|
221
|
+
const generalSubstitution = this, ///
|
|
222
|
+
specificSubstitution = substitution,
|
|
223
|
+
generalSubstitutionString = generalSubstitution.getString(),
|
|
224
|
+
specificSubstitutionString = specificSubstitution.getString();
|
|
225
|
+
|
|
226
|
+
context.trace(`Unifying the '${specificSubstitutionString}' substitution's target frame with the '${generalSubstitutionString}' substitution's target frame...`);
|
|
227
|
+
|
|
228
|
+
const generalSubstitutionGeneralContext = generalSubstitution.getGeneralContext(),
|
|
229
|
+
specificSubstitutionGeneralContext = specificSubstitution.getGeneralContext(),
|
|
230
|
+
generalSubstitutionTargetFrame = generalSubstitution.getTargetFrame(),
|
|
231
|
+
specificSubstitutionTargetFrame = specificSubstitution.getTargetFrame(),
|
|
232
|
+
generalContext = generalSubstitutionGeneralContext, ///
|
|
233
|
+
specificContext = specificSubstitutionGeneralContext, ///
|
|
234
|
+
generalFrame = generalSubstitutionTargetFrame, ///
|
|
235
|
+
specificFrame = specificSubstitutionTargetFrame; ///
|
|
236
|
+
|
|
237
|
+
join((specificContext) => {
|
|
238
|
+
reconcile((specificContext) => {
|
|
239
|
+
const generalFrameNode = generalFrame.getNode(),
|
|
240
|
+
generalMetavariable = metavariableFromFrameNode(generalFrameNode, generalContext);
|
|
241
|
+
|
|
242
|
+
if (generalMetavariable !== null) {
|
|
243
|
+
const frame = specificFrame, ///
|
|
244
|
+
metavariable = generalMetavariable, ///
|
|
245
|
+
frameUnifies = metavariable.unifyFrame(frame, generalContext, specificContext);
|
|
246
|
+
|
|
247
|
+
if (frameUnifies) {
|
|
248
|
+
specificContext.commit(context);
|
|
249
|
+
|
|
250
|
+
targetFrameUnifies = true;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}, specificContext);
|
|
254
|
+
}, specificContext, context);
|
|
255
|
+
|
|
256
|
+
if (targetFrameUnifies) {
|
|
257
|
+
context.trace(`...unified the '${specificSubstitutionString}' substitution's target frame with the '${generalSubstitutionString}' substitution's target frame.`);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return targetFrameUnifies;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
unifyReplacementFrame(substitution, context) {
|
|
264
|
+
let replacementFrameUnifies = false;
|
|
265
|
+
|
|
266
|
+
const generalSubstitution = this, ///
|
|
267
|
+
specificSubstitution = substitution,
|
|
268
|
+
generalSubstitutionString = generalSubstitution.getString(),
|
|
269
|
+
specificSubstitutionString = specificSubstitution.getString();
|
|
270
|
+
|
|
271
|
+
context.trace(`Unifying the '${specificSubstitutionString}' substitution's replacement frame with the '${generalSubstitutionString}' substitution's replacement frame...`);
|
|
272
|
+
|
|
273
|
+
const generalSubstitutionSpecificContext = generalSubstitution.getSpecificContext(),
|
|
274
|
+
specificSubstitutionSpecificContext = specificSubstitution.getSpecificContext(),
|
|
275
|
+
generalSubstitutionReplacementFrame = generalSubstitution.getReplacementFrame(),
|
|
276
|
+
specificSubstitutionReplacementFrame = specificSubstitution.getReplacementFrame(),
|
|
277
|
+
generalContext = generalSubstitutionSpecificContext, ///
|
|
278
|
+
specificContext = specificSubstitutionSpecificContext, ///
|
|
279
|
+
generalFrame = generalSubstitutionReplacementFrame, ///
|
|
280
|
+
specificFrame = specificSubstitutionReplacementFrame; ///
|
|
281
|
+
|
|
282
|
+
join((specificContext) => {
|
|
283
|
+
reconcile((specificContext) => {
|
|
284
|
+
const generalFrameNode = generalFrame.getNode(),
|
|
285
|
+
generalMetavariable = metavariableFromFrameNode(generalFrameNode, generalContext);
|
|
286
|
+
|
|
287
|
+
if (generalMetavariable !== null) {
|
|
288
|
+
const frame = specificFrame, ///
|
|
289
|
+
metavariable = generalMetavariable, ///
|
|
290
|
+
frameUnifies = metavariable.unifyFrame(frame, generalContext, specificContext);
|
|
291
|
+
|
|
292
|
+
if (frameUnifies) {
|
|
293
|
+
specificContext.commit(context);
|
|
294
|
+
|
|
295
|
+
replacementFrameUnifies = true;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}, specificContext);
|
|
299
|
+
}, specificContext, context);
|
|
300
|
+
|
|
301
|
+
if (replacementFrameUnifies) {
|
|
302
|
+
context.trace(`...unified the '${specificSubstitutionString}' substitution's replacement frame with the '${generalSubstitutionString}' substitution's replacement frame.`);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return replacementFrameUnifies;
|
|
306
|
+
}
|
|
307
|
+
|
|
187
308
|
static name = "FrameSubstitution";
|
|
188
309
|
|
|
189
310
|
static fromJSON(json, context) {
|
|
@@ -192,25 +313,29 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
192
313
|
const { name } = json;
|
|
193
314
|
|
|
194
315
|
if (this.name === name) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
specificContext
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
316
|
+
const forced = true;
|
|
317
|
+
|
|
318
|
+
ablate((context) => {
|
|
319
|
+
unserialises((json, generalContext, specificContext) => {
|
|
320
|
+
const context = specificContext; ///
|
|
321
|
+
|
|
322
|
+
instantiate((context) => {
|
|
323
|
+
const { string } = json,
|
|
324
|
+
frameSubstitutionNode = instantiateFrameSubstitution(string, context),
|
|
325
|
+
node = frameSubstitutionNode, ///
|
|
326
|
+
breakPoint = breakPointFromJSON(json),
|
|
327
|
+
targetFrame = targetFrameFromFrameSubstitutionNode(frameSubstitutionNode, context),
|
|
328
|
+
replacementFrame = replacementFrameFromFrameSubstitutionNode(frameSubstitutionNode, context),
|
|
329
|
+
specificContext = context, ///
|
|
330
|
+
contexts = [
|
|
331
|
+
generalContext,
|
|
332
|
+
specificContext
|
|
333
|
+
];
|
|
334
|
+
|
|
335
|
+
frameSubstitutionn = new FrameSubstitution(contexts, string, node, breakPoint, targetFrame, replacementFrame);
|
|
336
|
+
}, context);
|
|
337
|
+
}, json, context);
|
|
338
|
+
}, forced, context);
|
|
214
339
|
}
|
|
215
340
|
|
|
216
341
|
return frameSubstitutionn;
|
|
@@ -253,6 +378,18 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
253
378
|
}
|
|
254
379
|
});
|
|
255
380
|
|
|
381
|
+
function metavariableFromFrameNode(frameNode, context) {
|
|
382
|
+
let metavariable = null;
|
|
383
|
+
|
|
384
|
+
const metavariableNode = frameNode.getMetavariableNode();
|
|
385
|
+
|
|
386
|
+
if (metavariableNode !== null) {
|
|
387
|
+
metavariable = context.findMetavariableByMetavariableNode(metavariableNode);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return metavariable;
|
|
391
|
+
}
|
|
392
|
+
|
|
256
393
|
function targetFrameFromFrameSubstitutionNode(frameSubstitutionNode, context) {
|
|
257
394
|
const targetFrameNode = frameSubstitutionNode.getTargetFrameNode(),
|
|
258
395
|
targetFrame = context.findFrameByFrameNode(targetFrameNode);
|
|
@@ -7,7 +7,7 @@ import { breakPointFromJSON } from "../../utilities/breakPoint";
|
|
|
7
7
|
import { instantiateReferenceSubstitution } from "../../process/instantiate";
|
|
8
8
|
import { referenceSubstitutionFromReferenceSubstitutionNode } from "../../utilities/element";
|
|
9
9
|
import { referenceSubstitutionStringFromReferenceAndMetavariable } from "../../utilities/string";
|
|
10
|
-
import { ablates, manifest, attempts,
|
|
10
|
+
import { ablates, manifest, attempts, sequester, instantiate, unserialises } from "../../utilities/context";
|
|
11
11
|
|
|
12
12
|
export default define(class ReferenceSubstitution extends Substitution {
|
|
13
13
|
constructor(context, string, node, breakPoint, targetReference, replacementReference) {
|
|
@@ -150,7 +150,7 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
150
150
|
context.trace(`Validating the '${referenceSubstitutionString}' reference substitution's target reference...`);
|
|
151
151
|
|
|
152
152
|
manifest((context) => {
|
|
153
|
-
|
|
153
|
+
sequester((context) => {
|
|
154
154
|
const targetReference = this.targetReference.validate(context);
|
|
155
155
|
|
|
156
156
|
if (targetReference !== null) {
|
|
@@ -174,7 +174,7 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
174
174
|
|
|
175
175
|
context.trace(`Validating the '${referenceSubstitutionString}' reference substitution's replacement reference...`);
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
sequester((context) => {
|
|
178
178
|
const replacementReference = this.replacementReference.validate(context);
|
|
179
179
|
|
|
180
180
|
if (replacementReference !== null) {
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
import Substitution from "../substitution";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
-
import { unifySubstitution } from "../../process/unify";
|
|
7
|
-
import { stripBracketsFromStatement } from "../../utilities/brackets";
|
|
8
6
|
import { breakPointFromJSON } from "../../utilities/breakPoint";
|
|
7
|
+
import { stripBracketsFromStatement } from "../../utilities/brackets";
|
|
9
8
|
import { instantiateStatementSubstitution } from "../../process/instantiate";
|
|
10
9
|
import { statementSubstitutionFromStatementSubstitutionNode } from "../../utilities/element";
|
|
11
|
-
import { join, ablates, manifest, attempts,
|
|
10
|
+
import { join, ablates, manifest, attempts, sequester, reconcile, instantiate, unserialises } from "../../utilities/context";
|
|
12
11
|
import { statementSubstitutionStringFromStatementAndMetavariable, statementSubstitutionStringFromStatementMetavariableAndSubstitution } from "../../utilities/string";
|
|
13
12
|
|
|
14
13
|
export default define(class StatementSubstitution extends Substitution {
|
|
@@ -174,7 +173,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
174
173
|
|
|
175
174
|
if (targetStatementSingular) {
|
|
176
175
|
manifest((context) => {
|
|
177
|
-
|
|
176
|
+
sequester((context) => {
|
|
178
177
|
const targetStatement = this.targetStatement.validate(context);
|
|
179
178
|
|
|
180
179
|
if (targetStatement !== null) {
|
|
@@ -203,7 +202,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
203
202
|
|
|
204
203
|
context.trace(`Validating the '${statementSubstitutionString}' statement substitution's replacement statement...`);
|
|
205
204
|
|
|
206
|
-
|
|
205
|
+
sequester((context) => {
|
|
207
206
|
const replacementStatement = this.replacementStatement.validate(context);
|
|
208
207
|
|
|
209
208
|
if (replacementStatement !== null) {
|
|
@@ -218,132 +217,134 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
218
217
|
return replacementStatementValidates;
|
|
219
218
|
}
|
|
220
219
|
|
|
221
|
-
|
|
222
|
-
let
|
|
220
|
+
unifyTargetStatement(substitution, context) {
|
|
221
|
+
let targetStatemnentUnifies = false;
|
|
223
222
|
|
|
224
|
-
const
|
|
225
|
-
|
|
223
|
+
const generalSubstitution = this, ///
|
|
224
|
+
specificSubstitution = substitution,
|
|
225
|
+
generalSubstitutionString = generalSubstitution.getString(),
|
|
226
|
+
specificSubstitutionString = specificSubstitution.getString();
|
|
226
227
|
|
|
227
|
-
context.trace(`Unifying the '${
|
|
228
|
+
context.trace(`Unifying the '${specificSubstitutionString}' substitution's target statement with the '${generalSubstitutionString}' substitution's target statement...`);
|
|
228
229
|
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
const generalSubstitutionGeneralContext = generalSubstitution.getGeneralContext(),
|
|
231
|
+
specificSubstitutionGeneralContext = specificSubstitution.getGeneralContext(),
|
|
232
|
+
generalSubstitutionTargetStatement = generalSubstitution.getTargetStatement(),
|
|
233
|
+
specificSubstitutionTargetStatement = specificSubstitution.getTargetStatement(),
|
|
234
|
+
generalContext = generalSubstitutionGeneralContext, ///
|
|
235
|
+
specificContext = specificSubstitutionGeneralContext, ///
|
|
236
|
+
generalStatement = generalSubstitutionTargetStatement, ///
|
|
237
|
+
specificStatement = specificSubstitutionTargetStatement; ///
|
|
233
238
|
|
|
234
239
|
join((specificContext) => {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
simpleSubstitutionUnifies = unifySubstitution(generalSubstitution, specificSubstitution, generalContext, specificContext);
|
|
240
|
+
reconcile((specificContext) => {
|
|
241
|
+
const statementUnifies = generalStatement.unifyStatement(specificStatement, generalContext, specificContext);
|
|
238
242
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
}, specificContext)
|
|
243
|
-
}, ...generalContexts);
|
|
244
|
-
}, ...specificContexts, context);
|
|
243
|
+
if (statementUnifies) {
|
|
244
|
+
specificContext.commit(context);
|
|
245
245
|
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
targetStatemnentUnifies = true;
|
|
247
|
+
}
|
|
248
|
+
}, specificContext);
|
|
249
|
+
}, specificContext, context);
|
|
250
|
+
|
|
251
|
+
if (targetStatemnentUnifies) {
|
|
252
|
+
context.trace(`...unified the '${specificSubstitutionString}' substitution's target statement with the '${generalSubstitutionString}' substitution's target statement.`);
|
|
248
253
|
}
|
|
249
254
|
|
|
250
|
-
return
|
|
255
|
+
return targetStatemnentUnifies;
|
|
251
256
|
}
|
|
252
257
|
|
|
253
|
-
|
|
254
|
-
let
|
|
255
|
-
|
|
256
|
-
const simpleSubstitutionString = this.getString(), ///
|
|
257
|
-
complexSubstitutionString = complexSubstitution.getString(); ///
|
|
258
|
-
|
|
259
|
-
context.trace(`Unifying the '${complexSubstitutionString}' complex substitution with the '${simpleSubstitutionString}' simple substitution...`);
|
|
258
|
+
unifyReplacementStatement(substitution, context) {
|
|
259
|
+
let replacementStatemnentUnifies = false;
|
|
260
260
|
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
specificContext = complexSubstitutionGSpecificContext; ///
|
|
261
|
+
const generalSubstitution = this, ///
|
|
262
|
+
specificSubstitution = substitution,
|
|
263
|
+
generalSubstitutionString = generalSubstitution.getString(),
|
|
264
|
+
specificSubstitutionString = specificSubstitution.getString();
|
|
266
265
|
|
|
267
|
-
|
|
266
|
+
context.trace(`Unifying the '${specificSubstitutionString}' substitution's replacement statement with the '${generalSubstitutionString}' substitution's replacement statement...`);
|
|
268
267
|
|
|
269
|
-
|
|
270
|
-
|
|
268
|
+
const generalSubstitutionSpecificContext = generalSubstitution.getSpecificContext(),
|
|
269
|
+
specificSubstitutionSpecificContext = specificSubstitution.getSpecificContext(),
|
|
270
|
+
generalSubstitutionReplacementStatement = generalSubstitution.getReplacementStatement(),
|
|
271
|
+
specificSubstitutionReplacementStatement = specificSubstitution.getReplacementStatement(),
|
|
272
|
+
generalContext = generalSubstitutionSpecificContext, ///
|
|
273
|
+
specificContext = specificSubstitutionSpecificContext, ///
|
|
274
|
+
generalStatement = generalSubstitutionReplacementStatement, ///
|
|
275
|
+
specificStatement = specificSubstitutionReplacementStatement; ///
|
|
271
276
|
|
|
277
|
+
join((specificContext) => {
|
|
272
278
|
reconcile((specificContext) => {
|
|
273
|
-
const
|
|
274
|
-
replacementStatementUnifies = this.unifyReplacementStatement(replacementStatement, generalContext, specificContext);
|
|
279
|
+
const statementUnifies = generalStatement.unifyStatement(specificStatement, generalContext, specificContext);
|
|
275
280
|
|
|
276
|
-
if (
|
|
277
|
-
|
|
278
|
-
soleNonTrivialDerivedSubstitution = context.getSoleNonTrivialDerivedSubstitution();
|
|
281
|
+
if (statementUnifies) {
|
|
282
|
+
specificContext.commit(context);
|
|
279
283
|
|
|
280
|
-
|
|
284
|
+
replacementStatemnentUnifies = true;
|
|
281
285
|
}
|
|
282
286
|
}, specificContext);
|
|
283
287
|
}, specificContext, context);
|
|
284
288
|
|
|
285
|
-
if (
|
|
286
|
-
substitution
|
|
287
|
-
|
|
288
|
-
simpleSubstitutionUnifies = true;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (simpleSubstitutionUnifies) {
|
|
292
|
-
context.debug(`...unified the '${complexSubstitutionString}' complex substitution with the '${simpleSubstitutionString}' simple substitution.`);
|
|
289
|
+
if (replacementStatemnentUnifies) {
|
|
290
|
+
context.trace(`...unified the '${specificSubstitutionString}' substitution's replacement statement with the '${generalSubstitutionString}' substitution's replacement statement.`);
|
|
293
291
|
}
|
|
294
292
|
|
|
295
|
-
return
|
|
293
|
+
return replacementStatemnentUnifies;
|
|
296
294
|
}
|
|
297
295
|
|
|
298
|
-
|
|
299
|
-
let
|
|
296
|
+
unifyComplexSubstitution(complexSubstitution, context) {
|
|
297
|
+
let substitution = null;
|
|
300
298
|
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
299
|
+
const simpleSubstitution = this, ///
|
|
300
|
+
simpleSubstitutionString = simpleSubstitution.getString(), ///
|
|
301
|
+
complexSubstitutionString = complexSubstitution.getString(); ///
|
|
302
|
+
|
|
303
|
+
context.trace(`Unifying the '${complexSubstitutionString}' complex substitution with the '${simpleSubstitutionString}' simple substitution...`);
|
|
304
|
+
|
|
305
|
+
let simpleSubstitutionUnifies = false;
|
|
304
306
|
|
|
305
|
-
context
|
|
307
|
+
reconcile((context) => {
|
|
308
|
+
const replacementStatementUnifies = this.unifyReplacementStatement(complexSubstitution, context);
|
|
306
309
|
|
|
307
|
-
|
|
310
|
+
if (replacementStatementUnifies) {
|
|
311
|
+
const soleNonTrivialDerivedSubstitution = context.getSoleNonTrivialDerivedSubstitution();
|
|
308
312
|
|
|
309
|
-
|
|
310
|
-
|
|
313
|
+
substitution = soleNonTrivialDerivedSubstitution; ///
|
|
314
|
+
}
|
|
315
|
+
}, context);
|
|
316
|
+
|
|
317
|
+
if (substitution !== null) {
|
|
318
|
+
simpleSubstitutionUnifies = true;
|
|
311
319
|
}
|
|
312
320
|
|
|
313
|
-
if (
|
|
314
|
-
context.debug(`...unified the '${
|
|
321
|
+
if (simpleSubstitutionUnifies) {
|
|
322
|
+
context.debug(`...unified the '${complexSubstitutionString}' complex substitution with the '${simpleSubstitutionString}' simple substitution.`);
|
|
315
323
|
}
|
|
316
324
|
|
|
317
|
-
return
|
|
325
|
+
return substitution;
|
|
318
326
|
}
|
|
319
327
|
|
|
320
328
|
resolve(context) {
|
|
321
|
-
let resolved = false;
|
|
322
|
-
|
|
323
329
|
const metavariableNode = this.getMetavariableNode(),
|
|
324
|
-
simpleDerivedSubstitution = context.findSimpleDerivedSubstitutionByMetavariableNode(metavariableNode)
|
|
325
|
-
complexSubstitution = this,
|
|
326
|
-
simpleSubstitution = simpleDerivedSubstitution; ///
|
|
330
|
+
simpleDerivedSubstitution = context.findSimpleDerivedSubstitutionByMetavariableNode(metavariableNode);
|
|
327
331
|
|
|
328
|
-
if (
|
|
329
|
-
const
|
|
332
|
+
if (simpleDerivedSubstitution !== null) {
|
|
333
|
+
const simpleSubstitution = simpleDerivedSubstitution, ///
|
|
334
|
+
complexSubstitution = this, ///
|
|
335
|
+
complexSubstitutionString = complexSubstitution.getString();
|
|
330
336
|
|
|
331
|
-
context.trace(`Resolving the ${
|
|
337
|
+
context.trace(`Resolving the ${complexSubstitutionString}' complex substitution...`);
|
|
332
338
|
|
|
333
339
|
const substitution = simpleSubstitution.unifyComplexSubstitution(complexSubstitution, context);
|
|
334
340
|
|
|
335
341
|
if (substitution !== null) {
|
|
336
|
-
const
|
|
337
|
-
simpleSubstitutionUnifies = complexSubstitution.unifySimpleSubstitution(simpleSubstitution, context);
|
|
342
|
+
const simpleSubstitutionUnifies = this.substitution.unifySubstitution(substitution, context);
|
|
338
343
|
|
|
339
344
|
if (simpleSubstitutionUnifies) {
|
|
340
|
-
resolved = true;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (resolved) {
|
|
344
345
|
this.resolved = true;
|
|
345
346
|
|
|
346
|
-
context.debug(`...resolved the '${
|
|
347
|
+
context.debug(`...resolved the '${complexSubstitutionString}' complex substitution.`);
|
|
347
348
|
}
|
|
348
349
|
}
|
|
349
350
|
}
|