occam-verify-cli 1.0.768 → 1.0.781
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/file/nominal.js +11 -11
- package/lib/context/illative.js +28 -0
- package/lib/context/nested.js +31 -0
- package/lib/context/proof.js +242 -0
- package/lib/context/thetic.js +28 -0
- package/lib/context.js +19 -21
- package/lib/element/assertion/contained.js +32 -24
- package/lib/element/assertion/defined.js +47 -40
- package/lib/element/assertion/property.js +18 -13
- package/lib/element/assertion/satisfies.js +12 -9
- package/lib/element/assertion/subproof.js +28 -26
- package/lib/element/assertion/type.js +14 -12
- package/lib/element/assumption.js +40 -50
- package/lib/element/combinator/bracketed.js +3 -3
- package/lib/element/combinator.js +20 -20
- package/lib/element/conclusion.js +33 -29
- package/lib/element/constructor.js +19 -18
- package/lib/element/deduction.js +33 -29
- package/lib/element/equality.js +13 -15
- package/lib/element/equivalence.js +59 -52
- package/lib/element/equivalences.js +4 -2
- package/lib/element/frame.js +74 -53
- package/lib/element/hypothesis.js +7 -5
- package/lib/element/judgement.js +41 -74
- package/lib/element/label.js +22 -22
- package/lib/element/metavariable.js +31 -11
- package/lib/element/proofAssertion/premise.js +48 -35
- package/lib/element/proofAssertion/step.js +77 -22
- package/lib/element/proofAssertion/supposition.js +48 -34
- package/lib/element/proofAssertion.js +1 -14
- package/lib/element/reference.js +80 -53
- package/lib/element/signature.js +44 -3
- package/lib/element/statement.js +28 -29
- package/lib/element/subproof.js +2 -2
- package/lib/element/substitution/frame.js +24 -19
- package/lib/element/substitution/metaLevel.js +31 -27
- package/lib/element/substitution/reference.js +11 -10
- package/lib/element/substitution/statement.js +30 -23
- package/lib/element/substitution/term.js +11 -10
- package/lib/element/term.js +24 -20
- package/lib/element/topLevelMetaAssertion.js +2 -2
- package/lib/element/variable.js +6 -2
- package/lib/process/assign.js +10 -4
- package/lib/process/unify.js +8 -8
- package/lib/process/validate.js +10 -8
- package/lib/utilities/context.js +68 -23
- package/lib/utilities/element.js +55 -27
- package/lib/utilities/json.js +8 -8
- package/lib/utilities/string.js +12 -1
- package/lib/utilities/unification.js +14 -12
- package/lib/utilities/validation.js +55 -40
- package/package.json +4 -4
- package/src/context/file/nominal.js +14 -16
- package/src/context/illative.js +17 -0
- package/src/context/nested.js +21 -0
- package/src/context/{scoped.js → proof.js} +65 -51
- package/src/context/thetic.js +17 -0
- package/src/context.js +30 -36
- package/src/element/assertion/contained.js +44 -31
- package/src/element/assertion/defined.js +55 -46
- package/src/element/assertion/property.js +23 -15
- package/src/element/assertion/satisfies.js +15 -10
- package/src/element/assertion/subproof.js +34 -31
- package/src/element/assertion/type.js +18 -13
- package/src/element/assumption.js +40 -69
- package/src/element/combinator/bracketed.js +2 -2
- package/src/element/combinator.js +23 -29
- package/src/element/conclusion.js +37 -40
- package/src/element/constructor.js +29 -34
- package/src/element/deduction.js +36 -39
- package/src/element/equality.js +16 -18
- package/src/element/equivalence.js +76 -67
- package/src/element/equivalences.js +5 -2
- package/src/element/frame.js +96 -65
- package/src/element/hypothesis.js +7 -6
- package/src/element/judgement.js +45 -45
- package/src/element/label.js +25 -31
- package/src/element/metavariable.js +48 -21
- package/src/element/proofAssertion/premise.js +63 -49
- package/src/element/proofAssertion/step.js +47 -26
- package/src/element/proofAssertion/supposition.js +64 -50
- package/src/element/proofAssertion.js +0 -22
- package/src/element/reference.js +119 -80
- package/src/element/signature.js +5 -2
- package/src/element/statement.js +30 -35
- package/src/element/subproof.js +1 -1
- package/src/element/substitution/frame.js +27 -26
- package/src/element/substitution/metaLevel.js +38 -42
- package/src/element/substitution/reference.js +13 -14
- package/src/element/substitution/statement.js +35 -33
- package/src/element/substitution/term.js +13 -14
- package/src/element/term.js +42 -34
- package/src/element/topLevelMetaAssertion.js +1 -1
- package/src/element/variable.js +8 -1
- package/src/process/assign.js +9 -3
- package/src/process/unify.js +7 -7
- package/src/process/validate.js +9 -8
- package/src/utilities/context.js +82 -31
- package/src/utilities/element.js +68 -31
- package/src/utilities/json.js +13 -13
- package/src/utilities/string.js +16 -2
- package/src/utilities/unification.js +18 -16
- package/src/utilities/validation.js +73 -53
- package/lib/context/scoped.js +0 -232
- package/lib/utilities/statement.js +0 -78
- package/lib/utilities/term.js +0 -17
- package/src/utilities/statement.js +0 -74
- package/src/utilities/term.js +0 -10
package/src/element/statement.js
CHANGED
|
@@ -7,7 +7,7 @@ import { define } from "../elements";
|
|
|
7
7
|
import { unifyStatement } from "../process/unify";
|
|
8
8
|
import { validateStatements } from "../utilities/validation";
|
|
9
9
|
import { instantiateStatement } from "../process/instantiate";
|
|
10
|
-
import { reconcile, instantiate } from "../utilities/context";
|
|
10
|
+
import { join, reconcile, instantiate } from "../utilities/context";
|
|
11
11
|
|
|
12
12
|
const { backwardsSome } = arrayUtilities;
|
|
13
13
|
|
|
@@ -184,7 +184,7 @@ export default define(class Statement extends Element {
|
|
|
184
184
|
return frameContained;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
validate(
|
|
187
|
+
validate(context) {
|
|
188
188
|
let statement = null;
|
|
189
189
|
|
|
190
190
|
const statementString = this.getString(); ///
|
|
@@ -200,7 +200,7 @@ export default define(class Statement extends Element {
|
|
|
200
200
|
} else {
|
|
201
201
|
const validates = validateStatements.some((validateStatement) => {
|
|
202
202
|
const statement = this, ///
|
|
203
|
-
statementValidates = validateStatement(statement,
|
|
203
|
+
statementValidates = validateStatement(statement, context);
|
|
204
204
|
|
|
205
205
|
if (statementValidates) {
|
|
206
206
|
return true;
|
|
@@ -244,36 +244,33 @@ export default define(class Statement extends Element {
|
|
|
244
244
|
return subproofUnifies;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
unifyDeduction(deduction,
|
|
247
|
+
unifyDeduction(deduction, context) {
|
|
248
248
|
let deductionUnifies = false;
|
|
249
249
|
|
|
250
250
|
const statementString = this.getString(), ///
|
|
251
251
|
deductionString = deduction.getString(),
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
deductionContext = deduction.getContext(),
|
|
253
|
+
deductionStatement = deduction.getStatement();
|
|
254
254
|
|
|
255
|
-
|
|
255
|
+
context.trace(`Unifying the '${deductionString}' deduction with the '${statementString}' statement...`);
|
|
256
256
|
|
|
257
|
-
|
|
257
|
+
const generalContext = context, ///
|
|
258
|
+
specificContext = deductionContext; ///
|
|
258
259
|
|
|
259
|
-
|
|
260
|
+
join((specificContext) => {
|
|
261
|
+
reconcile((specificContext) => {
|
|
262
|
+
const deductionStatementUnifies = this.unifyStatement(deductionStatement, generalContext, specificContext);
|
|
260
263
|
|
|
261
|
-
|
|
264
|
+
if (deductionStatementUnifies) {
|
|
265
|
+
specificContext.commit(context);
|
|
262
266
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if (deductionStatementUnfies) {
|
|
269
|
-
specificContext.commit();
|
|
270
|
-
|
|
271
|
-
deductionUnifies = true;
|
|
272
|
-
}
|
|
273
|
-
}, specificContext);
|
|
267
|
+
deductionUnifies = true;
|
|
268
|
+
}
|
|
269
|
+
}, specificContext);
|
|
270
|
+
}, specificContext, context);
|
|
274
271
|
|
|
275
272
|
if (deductionUnifies) {
|
|
276
|
-
context.debug(`...unified the '${deductionString}' deduction
|
|
273
|
+
context.debug(`...unified the '${deductionString}' deduction with the '${statementString}' statement.`);
|
|
277
274
|
}
|
|
278
275
|
|
|
279
276
|
return deductionUnifies;
|
|
@@ -338,41 +335,39 @@ export default define(class Statement extends Element {
|
|
|
338
335
|
return unifiesIndependently;
|
|
339
336
|
}
|
|
340
337
|
|
|
341
|
-
unifyTopLevelMetaAssertion(topLevelMetaAssertion,
|
|
342
|
-
let
|
|
338
|
+
unifyTopLevelMetaAssertion(topLevelMetaAssertion, context) {
|
|
339
|
+
let topLevelAssertionUnifies = false;
|
|
343
340
|
|
|
344
|
-
const
|
|
345
|
-
statementString = this.getString(), ///
|
|
341
|
+
const statementString = this.getString(), ///
|
|
346
342
|
topLevelMetaAssertionString = topLevelMetaAssertion.getString();
|
|
347
343
|
|
|
348
344
|
context.trace(`Unifying the '${topLevelMetaAssertionString}' top level meta-assertion with the '${statementString}' statement...`);
|
|
349
345
|
|
|
350
|
-
const
|
|
346
|
+
const unconditional = topLevelMetaAssertion.isUnconditional();
|
|
351
347
|
|
|
352
|
-
if (
|
|
348
|
+
if (unconditional) {
|
|
353
349
|
const deduction = topLevelMetaAssertion.getDeduction(),
|
|
354
|
-
deductionUnifies = this.unifyDeduction(deduction,
|
|
350
|
+
deductionUnifies = this.unifyDeduction(deduction, context);
|
|
355
351
|
|
|
356
352
|
if (deductionUnifies) {
|
|
357
|
-
|
|
353
|
+
topLevelAssertionUnifies = true;
|
|
358
354
|
}
|
|
359
355
|
} else {
|
|
360
356
|
const statementNode = this.getStatementNode(),
|
|
361
357
|
subproofAssertionNode = statementNode.getSubproofAssertionNode();
|
|
362
358
|
|
|
363
359
|
if (subproofAssertionNode !== null) {
|
|
364
|
-
const
|
|
365
|
-
subproofAssertion = context.findAssertionByAssertionNode(subproofAssertionNode);
|
|
360
|
+
const subproofAssertion = context.findAssertionByAssertionNode(subproofAssertionNode);
|
|
366
361
|
|
|
367
|
-
|
|
362
|
+
topLevelAssertionUnifies = subproofAssertion.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
|
|
368
363
|
}
|
|
369
364
|
}
|
|
370
365
|
|
|
371
|
-
if (
|
|
366
|
+
if (topLevelAssertionUnifies) {
|
|
372
367
|
context.debug(`...unified the '${topLevelMetaAssertionString}' top level meta-assertion with the '${statementString}' statement.`);
|
|
373
368
|
}
|
|
374
369
|
|
|
375
|
-
return
|
|
370
|
+
return topLevelAssertionUnifies;
|
|
376
371
|
}
|
|
377
372
|
|
|
378
373
|
toJSON() {
|
package/src/element/subproof.js
CHANGED
|
@@ -121,7 +121,7 @@ export default define(class Subproof extends Element {
|
|
|
121
121
|
context.trace(`Unifying the '${subproofString}' subproof with the '${satisfiesAssertionString}' satisfies assertion...`)
|
|
122
122
|
|
|
123
123
|
const reference = satisfiesAssertion.getReference(),
|
|
124
|
-
axiom = context.findAxiomByReference(reference
|
|
124
|
+
axiom = context.findAxiomByReference(reference);
|
|
125
125
|
|
|
126
126
|
if (axiom !== null) {
|
|
127
127
|
const axiomSatisfiable = axiom.isSatisfiable();
|
|
@@ -4,7 +4,7 @@ import Substitution from "../substitution";
|
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
6
|
import { instantiateFrameSubstitution } from "../../process/instantiate";
|
|
7
|
-
import {
|
|
7
|
+
import { descend, simplify, instantiate } from "../../utilities/context";
|
|
8
8
|
import { frameSubstitutionStringFromFrameAndMetavariable } from "../../utilities/string";
|
|
9
9
|
import { frameSubstitutionFromStatementNode, frameSubstitutionFromFrameSubstitutionNode } from "../../utilities/element";
|
|
10
10
|
|
|
@@ -123,14 +123,15 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
123
123
|
const targetFrameSingular = this.targetFrame.isSingular();
|
|
124
124
|
|
|
125
125
|
if (targetFrameSingular) {
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
descend((context) => {
|
|
127
|
+
const tragetFrame = this.targetFrame.validate(context);
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
if (tragetFrame !== null) {
|
|
130
|
+
this.targetFrame = tragetFrame;
|
|
131
131
|
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
targetFrameValidates = true;
|
|
133
|
+
}
|
|
134
|
+
}, context);
|
|
134
135
|
} else {
|
|
135
136
|
context.debug(`The '${frameSubstitutionString}' frame substitution's '${targetFrameString}' target frame is not singular.`);
|
|
136
137
|
}
|
|
@@ -151,14 +152,15 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
151
152
|
|
|
152
153
|
context.trace(`Validating the '${frameSubstitutionString}' frame substitution's '${replacementFrameString}' replacement frame...`);
|
|
153
154
|
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
descend((context) => {
|
|
156
|
+
const replacementFrame = this.replacementFrame.validate(context);
|
|
156
157
|
|
|
157
|
-
|
|
158
|
-
|
|
158
|
+
if (replacementFrame !== null) {
|
|
159
|
+
this.replacementFrame = replacementFrame;
|
|
159
160
|
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
replacementFrameValidates = true;
|
|
162
|
+
}
|
|
163
|
+
}, context);
|
|
162
164
|
|
|
163
165
|
if (replacementFrameValidates) {
|
|
164
166
|
context.debug(`...validated the '${frameSubstitutionString}' frame substitution's '${replacementFrameString}' replacement frame.`);
|
|
@@ -175,7 +177,7 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
175
177
|
const { name } = json;
|
|
176
178
|
|
|
177
179
|
if (this.name === name) {
|
|
178
|
-
|
|
180
|
+
instantiate((context) => {
|
|
179
181
|
const { string } = json,
|
|
180
182
|
frameSubstitutionNode = instantiateFrameSubstitution(string, context),
|
|
181
183
|
node = frameSubstitutionNode, ///
|
|
@@ -184,9 +186,7 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
184
186
|
|
|
185
187
|
context = null;
|
|
186
188
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return frameSubstitutionn;
|
|
189
|
+
frameSubstitutionn = new FrameSubstitution(context, string, node, targetFrame, replacementFrame);
|
|
190
190
|
}, context);
|
|
191
191
|
}
|
|
192
192
|
|
|
@@ -201,18 +201,19 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
static fromFrameAndMetavariable(frame, metavariable, context) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
context = santisedContext; ///
|
|
204
|
+
let frameSubstitution
|
|
207
205
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
206
|
+
simplify((context) => {
|
|
207
|
+
instantiate((context) => {
|
|
208
|
+
const frameSubstitutionString = frameSubstitutionStringFromFrameAndMetavariable(frame, metavariable),
|
|
209
|
+
string = frameSubstitutionString, ///
|
|
210
|
+
frameSubstitutionNode = instantiateFrameSubstitution(string, context);
|
|
213
211
|
|
|
214
|
-
|
|
212
|
+
frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context);
|
|
213
|
+
}, context);
|
|
215
214
|
}, context);
|
|
215
|
+
|
|
216
|
+
return frameSubstitution;
|
|
216
217
|
}
|
|
217
218
|
});
|
|
218
219
|
|
|
@@ -4,10 +4,9 @@ import Substitution from "../substitution";
|
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
6
|
import { instantiateMetaLevelSubstitution } from "../../process/instantiate";
|
|
7
|
-
import { instantiate, sanitisedContextFromContext } from "../../utilities/context";
|
|
8
7
|
import { metaLevelSubstitutionFromMetaLevelSubstitutionNode } from "../../utilities/element";
|
|
9
8
|
import { metaLevelSubstitutionStringFromStatementAndReference } from "../../utilities/string";
|
|
10
|
-
import {
|
|
9
|
+
import { descend, simplify, serialise, unserialise, instantiate } from "../../utilities/context";
|
|
11
10
|
|
|
12
11
|
export default define(class MetaLevelSubstitution extends Substitution {
|
|
13
12
|
constructor(context, string, node, targetReference, replacementStatement) {
|
|
@@ -132,12 +131,13 @@ export default define(class MetaLevelSubstitution extends Substitution {
|
|
|
132
131
|
|
|
133
132
|
context.trace(`Validating the '${metaLevelSubstitutionString}' meta-level substitution's '${replacementStatementString}' replacement statement...`);
|
|
134
133
|
|
|
135
|
-
|
|
136
|
-
replacementStatement = this.replacementStatement.validate(
|
|
134
|
+
descend((context) => {
|
|
135
|
+
const replacementStatement = this.replacementStatement.validate(context);
|
|
137
136
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
if (replacementStatement !== null) {
|
|
138
|
+
replacementStatementValidates = true;
|
|
139
|
+
}
|
|
140
|
+
}, context);
|
|
141
141
|
|
|
142
142
|
if (replacementStatementValidates) {
|
|
143
143
|
context.debug(`...validated the '${metaLevelSubstitutionString}' meta-level substitution's '${replacementStatementString}' replacement statement.`);
|
|
@@ -147,57 +147,53 @@ export default define(class MetaLevelSubstitution extends Substitution {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
toJSON() {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
context = this.getContext();
|
|
153
|
-
|
|
154
|
-
const ephemeralContext = context, ///
|
|
155
|
-
ephemeralContextJSON = ephemeralContextToEphemeralContextJSON(ephemeralContext),
|
|
156
|
-
contextJSON = ephemeralContextJSON; ///
|
|
157
|
-
|
|
158
|
-
context = contextJSON; ///
|
|
150
|
+
const context = this.getContext();
|
|
159
151
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
152
|
+
return serialise((context) => {
|
|
153
|
+
const string = this.getString(),
|
|
154
|
+
json = {
|
|
155
|
+
context,
|
|
156
|
+
string
|
|
157
|
+
};
|
|
165
158
|
|
|
166
|
-
|
|
159
|
+
return json;
|
|
160
|
+
}, context);
|
|
167
161
|
}
|
|
168
162
|
|
|
169
163
|
static name = "MetaLevelSubstitution";
|
|
170
164
|
|
|
171
165
|
static fromJSON(json, context) {
|
|
172
|
-
|
|
166
|
+
let metaLevelSubstitution;
|
|
173
167
|
|
|
174
|
-
context
|
|
168
|
+
unserialise((json, context) => {
|
|
169
|
+
instantiate((context) => {
|
|
170
|
+
const { string } = json,
|
|
171
|
+
metaLevelSubstitutionNode = instantiateMetaLevelSubstitution(string, context),
|
|
172
|
+
node = metaLevelSubstitutionNode, ///
|
|
173
|
+
targetReference = targetReferenceFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context),
|
|
174
|
+
replacementStatement = replacementStatementFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context);
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
node = metaLevelSubstitutionNode, ///
|
|
180
|
-
targetReference = targetReferenceFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context),
|
|
181
|
-
replacementStatement = replacementStatementFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context),
|
|
182
|
-
metaLevelSubstitution = new MetaLevelSubstitution(context, string, node, targetReference, replacementStatement);
|
|
176
|
+
metaLevelSubstitution = new MetaLevelSubstitution(context, string, node, targetReference, replacementStatement);
|
|
177
|
+
}, context);
|
|
178
|
+
}, json, context);
|
|
183
179
|
|
|
184
|
-
|
|
185
|
-
}, context);
|
|
180
|
+
return metaLevelSubstitution;
|
|
186
181
|
}
|
|
187
182
|
|
|
188
183
|
static fromStatementAndReference(statement, reference, context) {
|
|
189
|
-
|
|
184
|
+
let metaLevelSubstitution;
|
|
190
185
|
|
|
191
|
-
context
|
|
186
|
+
simplify((context) => {
|
|
187
|
+
instantiate((context) => {
|
|
188
|
+
const metaLevelSubstitutionString = metaLevelSubstitutionStringFromStatementAndReference(statement, reference),
|
|
189
|
+
string = metaLevelSubstitutionString, ///
|
|
190
|
+
metaLevelSubstitutionNode = instantiateMetaLevelSubstitution(string, context);
|
|
192
191
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
string = metaLevelSubstitutionString, ///
|
|
196
|
-
metaLevelSubstitutionNode = instantiateMetaLevelSubstitution(string, context),
|
|
197
|
-
metaLevelSubstitution = metaLevelSubstitutionFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context);
|
|
198
|
-
|
|
199
|
-
return metaLevelSubstitution;
|
|
192
|
+
metaLevelSubstitution = metaLevelSubstitutionFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context);
|
|
193
|
+
}, context);
|
|
200
194
|
}, context);
|
|
195
|
+
|
|
196
|
+
return metaLevelSubstitution;
|
|
201
197
|
}
|
|
202
198
|
});
|
|
203
199
|
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import Substitution from "../substitution";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
+
import { simplify, instantiate } from "../../utilities/context";
|
|
6
7
|
import { instantiateReferenceSubstitution } from "../../process/instantiate";
|
|
7
|
-
import { instantiate, sanitisedContextFromContext } from "../../utilities/context";
|
|
8
8
|
import { referenceSubstitutionFromReferenceSubstitutionNode } from "../../utilities/element";
|
|
9
9
|
import { referenceSubstitutionStringFromReferenceAndMetavariable } from "../../utilities/string";
|
|
10
10
|
|
|
@@ -163,7 +163,7 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
163
163
|
const { name } = json;
|
|
164
164
|
|
|
165
165
|
if (this.name === name) {
|
|
166
|
-
|
|
166
|
+
instantiate((context) => {
|
|
167
167
|
const { string } = json,
|
|
168
168
|
referenceSubstitutionNode = instantiateReferenceSubstitution(string, context),
|
|
169
169
|
node = referenceSubstitutionNode, ///
|
|
@@ -172,9 +172,7 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
172
172
|
|
|
173
173
|
context = null;
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return referenceSubstitutionn;
|
|
175
|
+
referenceSubstitutionn = new ReferenceSubstitution(context, string, node, targetReference, replacementReference);
|
|
178
176
|
}, context);
|
|
179
177
|
}
|
|
180
178
|
|
|
@@ -182,18 +180,19 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
182
180
|
}
|
|
183
181
|
|
|
184
182
|
static fromReferenceAndMetavariable(reference, metavariable, context) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
context = santisedContext; ///
|
|
183
|
+
let referenceSubstitution;
|
|
188
184
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
185
|
+
simplify((context) => {
|
|
186
|
+
instantiate((context) => {
|
|
187
|
+
const referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
|
|
188
|
+
string = referenceSubstitutionString, ///
|
|
189
|
+
referenceSubstitutionNode = instantiateReferenceSubstitution(string, context);
|
|
194
190
|
|
|
195
|
-
|
|
191
|
+
referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
|
|
192
|
+
}, context);
|
|
196
193
|
}, context);
|
|
194
|
+
|
|
195
|
+
return referenceSubstitution;
|
|
197
196
|
}
|
|
198
197
|
});
|
|
199
198
|
|
|
@@ -6,8 +6,8 @@ import { define } from "../../elements";
|
|
|
6
6
|
import { unifySubstitution } from "../../process/unify";
|
|
7
7
|
import { stripBracketsFromStatement } from "../../utilities/brackets";
|
|
8
8
|
import { instantiateStatementSubstitution } from "../../process/instantiate";
|
|
9
|
+
import { join, simplify, descend, reconcile, instantiate } from "../../utilities/context";
|
|
9
10
|
import { statementSubstitutionFromStatementSubstitutionNode } from "../../utilities/element";
|
|
10
|
-
import { join, reconcile, instantiate, sanitisedContextFromContext } from "../../utilities/context";
|
|
11
11
|
import { statementSubstitutionStringFromStatementAndMetavariable, statementSubstitutionStringFromStatementMetavariableAndSubstitution } from "../../utilities/string";
|
|
12
12
|
|
|
13
13
|
export default define(class StatementSubstitution extends Substitution {
|
|
@@ -158,12 +158,13 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
158
158
|
const targetStatementSingular = this.targetStatement.isSingular();
|
|
159
159
|
|
|
160
160
|
if (targetStatementSingular) {
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
descend((context) => {
|
|
162
|
+
const targetStatement = this.targetStatement.validate(context);
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
if (targetStatement !== null) {
|
|
165
|
+
targetStatementValidates = true;
|
|
166
|
+
}
|
|
167
|
+
}, context);
|
|
167
168
|
} else {
|
|
168
169
|
context.debug(`The '${statementSubstitutionString}' statement substitution's '${targetStatementString}' target statement is not singular.`);
|
|
169
170
|
}
|
|
@@ -184,12 +185,13 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
184
185
|
|
|
185
186
|
context.trace(`Validating the '${statementSubstitutionString}' statement substitution's '${replacementStatementString}' replacement statement...`);
|
|
186
187
|
|
|
187
|
-
|
|
188
|
-
|
|
188
|
+
descend((context) => {
|
|
189
|
+
const replacementStatement = this.replacementStatement.validate(context);
|
|
189
190
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
if (replacementStatement !== null) {
|
|
192
|
+
replacementStatementValidates = true;
|
|
193
|
+
}
|
|
194
|
+
}, context);
|
|
193
195
|
|
|
194
196
|
if (replacementStatementValidates) {
|
|
195
197
|
context.debug(`...validated the '${statementSubstitutionString}' statement substitution's '${replacementStatementString}' replacement statement.`);
|
|
@@ -344,7 +346,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
344
346
|
const { name } = json;
|
|
345
347
|
|
|
346
348
|
if (this.name === name) {
|
|
347
|
-
|
|
349
|
+
instantiate((context) => {
|
|
348
350
|
const { string } = json,
|
|
349
351
|
statementSubstitutionNode = instantiateStatementSubstitution(string, context),
|
|
350
352
|
node = statementSubstitutionNode, ///
|
|
@@ -353,9 +355,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
353
355
|
|
|
354
356
|
context = null;
|
|
355
357
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return statementSubstitutionn;
|
|
358
|
+
statementSubstitutionn = new StatementSubstitution(context, string, node, targetStatement, replacementStatement);
|
|
359
359
|
}, context);
|
|
360
360
|
}
|
|
361
361
|
|
|
@@ -365,35 +365,37 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
365
365
|
static fromStatementAndMetavariable(statement, metavariable, context) {
|
|
366
366
|
statement = stripBracketsFromStatement(statement, context); ///
|
|
367
367
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
context = santisedContext; ///
|
|
368
|
+
let statementSubstitution;
|
|
371
369
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
370
|
+
simplify((context) => {
|
|
371
|
+
instantiate((context) => {
|
|
372
|
+
const statementSubstitutionString = statementSubstitutionStringFromStatementAndMetavariable(statement, metavariable, context),
|
|
373
|
+
string = statementSubstitutionString, ///
|
|
374
|
+
statementSubstitutionNode = instantiateStatementSubstitution(string, context);
|
|
377
375
|
|
|
378
|
-
|
|
376
|
+
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
|
|
377
|
+
}, context);
|
|
379
378
|
}, context);
|
|
379
|
+
|
|
380
|
+
return statementSubstitution;
|
|
380
381
|
}
|
|
381
382
|
|
|
382
383
|
static fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context) {
|
|
383
384
|
statement = stripBracketsFromStatement(statement, context); ///
|
|
384
385
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
context = santisedContext; ///
|
|
386
|
+
let statementSubstitution;
|
|
388
387
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
388
|
+
simplify((context) => {
|
|
389
|
+
instantiate((context) => {
|
|
390
|
+
const statementSubstitutionString = statementSubstitutionStringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution),
|
|
391
|
+
string = statementSubstitutionString, ///
|
|
392
|
+
statementSubstitutionNode = instantiateStatementSubstitution(string, context);
|
|
394
393
|
|
|
395
|
-
|
|
394
|
+
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
|
|
395
|
+
}, context);
|
|
396
396
|
}, context);
|
|
397
|
+
|
|
398
|
+
return statementSubstitution;
|
|
397
399
|
}
|
|
398
400
|
});
|
|
399
401
|
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import Substitution from "../substitution";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
+
import { simplify, instantiate } from "../../utilities/context";
|
|
6
7
|
import { stripBracketsFromTerm } from "../../utilities/brackets";
|
|
7
8
|
import { instantiateTermSubstitution } from "../../process/instantiate";
|
|
8
|
-
import { instantiate, sanitisedContextFromContext } from "../../utilities/context";
|
|
9
9
|
import { termSubstitutionStringFromTermAndVariable } from "../../utilities/string";
|
|
10
10
|
import { termSubstitutionFromStatementNode, termSubstitutionFromTermSubstitutionNode } from "../../utilities/element";
|
|
11
11
|
|
|
@@ -184,7 +184,7 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
184
184
|
const { name } = json;
|
|
185
185
|
|
|
186
186
|
if (this.name === name) {
|
|
187
|
-
|
|
187
|
+
instantiate((context) => {
|
|
188
188
|
const { string } = json,
|
|
189
189
|
termSubstitutionNode = instantiateTermSubstitution(string, context),
|
|
190
190
|
node = termSubstitutionNode, ///
|
|
@@ -193,9 +193,7 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
193
193
|
|
|
194
194
|
context = null;
|
|
195
195
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return termSubstitutionn;
|
|
196
|
+
termSubstitutionn = new TermSubstitution(context, string, node, targetTerm, replacementTerm);
|
|
199
197
|
}, context);
|
|
200
198
|
}
|
|
201
199
|
|
|
@@ -212,18 +210,19 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
212
210
|
static fromTermAndVariable(term, variable, context) {
|
|
213
211
|
term = stripBracketsFromTerm(term, context); ///
|
|
214
212
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
context = santisedContext; ///
|
|
213
|
+
let termSubstitution;
|
|
218
214
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
215
|
+
simplify((context) => {
|
|
216
|
+
instantiate((context) => {
|
|
217
|
+
const termSubstitutionString = termSubstitutionStringFromTermAndVariable(term, variable),
|
|
218
|
+
string = termSubstitutionString, ///
|
|
219
|
+
termSubstitutionNode = instantiateTermSubstitution(string, context);
|
|
224
220
|
|
|
225
|
-
|
|
221
|
+
termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, context);
|
|
222
|
+
}, context);
|
|
226
223
|
}, context);
|
|
224
|
+
|
|
225
|
+
return termSubstitution;
|
|
227
226
|
}
|
|
228
227
|
});
|
|
229
228
|
|