occam-verify-cli 1.0.800 → 1.0.806
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/branching.js +2 -2
- package/lib/context/ephemeral.js +186 -69
- package/lib/context/file/nominal.js +87 -52
- package/lib/context/liminal.js +2 -2
- package/lib/context/proof.js +55 -55
- package/lib/context/synthetic.js +151 -74
- package/lib/context.js +57 -17
- package/lib/element/assertion/defined.js +3 -3
- package/lib/element/assumption/metaLevel.js +6 -4
- package/lib/element/combinator.js +4 -2
- package/lib/element/conclusion.js +4 -2
- package/lib/element/constructor.js +4 -2
- package/lib/element/declaration/metavariable.js +10 -9
- package/lib/element/declaration/variable.js +7 -7
- package/lib/element/deduction.js +4 -2
- package/lib/element/label.js +9 -5
- package/lib/element/metavariable.js +34 -34
- package/lib/element/proofAssertion/premise.js +4 -3
- package/lib/element/proofAssertion/step.js +4 -2
- package/lib/element/reference.js +6 -4
- package/lib/element/statement.js +9 -1
- package/lib/element/substitution/frame.js +43 -29
- package/lib/element/substitution/reference.js +38 -28
- package/lib/element/substitution/statement.js +46 -38
- package/lib/element/substitution/term.js +49 -35
- package/lib/element/variable.js +6 -7
- package/lib/preamble.js +1 -2
- package/lib/process/assign.js +11 -10
- package/lib/process/equate.js +3 -2
- package/lib/process/unify.js +7 -7
- package/lib/utilities/context.js +13 -5
- package/lib/utilities/element.js +1 -1
- package/lib/utilities/equivalences.js +131 -0
- package/lib/utilities/json.js +59 -1
- package/lib/utilities/validation.js +4 -3
- package/package.json +2 -2
- package/src/context/branching.js +2 -2
- package/src/context/ephemeral.js +421 -237
- package/src/context/file/nominal.js +127 -77
- package/src/context/liminal.js +2 -2
- package/src/context/proof.js +81 -82
- package/src/context/synthetic.js +198 -88
- package/src/context.js +81 -20
- package/src/element/assertion/defined.js +4 -4
- package/src/element/assumption/metaLevel.js +8 -6
- package/src/element/combinator.js +4 -2
- package/src/element/conclusion.js +4 -2
- package/src/element/constructor.js +4 -2
- package/src/element/declaration/metavariable.js +10 -8
- package/src/element/declaration/variable.js +8 -7
- package/src/element/deduction.js +4 -2
- package/src/element/label.js +11 -7
- package/src/element/metavariable.js +11 -11
- package/src/element/proofAssertion/premise.js +4 -4
- package/src/element/proofAssertion/step.js +4 -2
- package/src/element/reference.js +7 -5
- package/src/element/statement.js +14 -0
- package/src/element/substitution/frame.js +47 -32
- package/src/element/substitution/reference.js +44 -34
- package/src/element/substitution/statement.js +63 -54
- package/src/element/substitution/term.js +53 -38
- package/src/element/variable.js +6 -7
- package/src/preamble.js +0 -1
- package/src/process/assign.js +17 -14
- package/src/process/equate.js +3 -1
- package/src/process/unify.js +10 -13
- package/src/utilities/context.js +13 -6
- package/src/utilities/element.js +1 -0
- package/src/utilities/equivalences.js +158 -0
- package/src/utilities/json.js +66 -0
- package/src/utilities/validation.js +6 -5
- package/lib/element/equivalences.js +0 -173
- package/src/element/equivalences.js +0 -237
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import Substitution from "../substitution";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
-
import { attempt, instantiate } from "../../utilities/context";
|
|
7
6
|
import { instantiateFrameSubstitution } from "../../process/instantiate";
|
|
7
|
+
import { frameSubstitutionFromFrameSubstitutionNode } from "../../utilities/element";
|
|
8
|
+
import { join, ablate, descend, attempt, instantiate } from "../../utilities/context";
|
|
8
9
|
import { frameSubstitutionStringFromFrameAndMetavariable } from "../../utilities/string";
|
|
9
|
-
import { frameSubstitutionFromStatementNode, frameSubstitutionFromFrameSubstitutionNode } from "../../utilities/element";
|
|
10
10
|
|
|
11
11
|
export default define(class FrameSubstitution extends Substitution {
|
|
12
12
|
constructor(context, string, node, targetFrame, replacementFrame) {
|
|
@@ -87,24 +87,26 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
87
87
|
|
|
88
88
|
context.debug(`...the '${frameSubstitutionString}' frame substitution is already valid.`);
|
|
89
89
|
} else {
|
|
90
|
-
const context = this.getContext()
|
|
91
|
-
specificContext = context; ///
|
|
90
|
+
const context = this.getContext();
|
|
92
91
|
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
join((context) => {
|
|
93
|
+
attempt((context) => {
|
|
94
|
+
const specificContext = context, ///,
|
|
95
|
+
targetFrameValidates = this.validateTargetFrame(generalContext, specificContext);
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
if (targetFrameValidates) {
|
|
98
|
+
const replacementFrameValidates = this.validateReplacementFrame(generalContext, specificContext);
|
|
98
99
|
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
if (replacementFrameValidates) {
|
|
101
|
+
validates = true;
|
|
102
|
+
}
|
|
101
103
|
}
|
|
102
|
-
}
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
if (validates) {
|
|
106
|
+
context.commit(this);
|
|
107
|
+
}
|
|
108
|
+
}, context);
|
|
109
|
+
}, specificContext, context);
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
if (validates) {
|
|
@@ -132,13 +134,15 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
132
134
|
const targetFrameSingular = this.targetFrame.isSingular();
|
|
133
135
|
|
|
134
136
|
if (targetFrameSingular) {
|
|
135
|
-
|
|
137
|
+
descend((context) => {
|
|
138
|
+
const tragetFrame = this.targetFrame.validate(context);
|
|
136
139
|
|
|
137
|
-
|
|
138
|
-
|
|
140
|
+
if (tragetFrame !== null) {
|
|
141
|
+
this.targetFrame = tragetFrame;
|
|
139
142
|
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
targetFrameValidates = true;
|
|
144
|
+
}
|
|
145
|
+
}, context);
|
|
142
146
|
} else {
|
|
143
147
|
context.debug(`The '${frameSubstitutionString}' frame substitution's '${targetFrameString}' target frame is not singular.`);
|
|
144
148
|
}
|
|
@@ -159,13 +163,15 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
159
163
|
|
|
160
164
|
context.trace(`Validating the '${frameSubstitutionString}' frame substitution's '${replacementFrameString}' replacement frame...`);
|
|
161
165
|
|
|
162
|
-
|
|
166
|
+
descend((context) => {
|
|
167
|
+
const replacementFrame = this.replacementFrame.validate(context);
|
|
163
168
|
|
|
164
|
-
|
|
165
|
-
|
|
169
|
+
if (replacementFrame !== null) {
|
|
170
|
+
this.replacementFrame = replacementFrame;
|
|
166
171
|
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
replacementFrameValidates = true;
|
|
173
|
+
}
|
|
174
|
+
}, context);
|
|
169
175
|
|
|
170
176
|
if (replacementFrameValidates) {
|
|
171
177
|
context.debug(`...validated the '${frameSubstitutionString}' frame substitution's '${replacementFrameString}' replacement frame.`);
|
|
@@ -197,8 +203,15 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
197
203
|
}
|
|
198
204
|
|
|
199
205
|
static fromStatement(statement, context) {
|
|
200
|
-
|
|
201
|
-
|
|
206
|
+
let frameSubstitution = null;
|
|
207
|
+
|
|
208
|
+
const frameSubstitutionNode = statement.getFrameSubstitutionNode();
|
|
209
|
+
|
|
210
|
+
if (frameSubstitutionNode !== null) {
|
|
211
|
+
ablate((context) => {
|
|
212
|
+
frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context);
|
|
213
|
+
}, context);
|
|
214
|
+
}
|
|
202
215
|
|
|
203
216
|
return frameSubstitution;
|
|
204
217
|
}
|
|
@@ -206,12 +219,14 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
206
219
|
static fromFrameAndMetavariable(frame, metavariable, context) {
|
|
207
220
|
let frameSubstitution
|
|
208
221
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
222
|
+
ablate((context) => {
|
|
223
|
+
instantiate((context) => {
|
|
224
|
+
const frameSubstitutionString = frameSubstitutionStringFromFrameAndMetavariable(frame, metavariable),
|
|
225
|
+
string = frameSubstitutionString, ///
|
|
226
|
+
frameSubstitutionNode = instantiateFrameSubstitution(string, context);
|
|
213
227
|
|
|
214
|
-
|
|
228
|
+
frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context);
|
|
229
|
+
}, context);
|
|
215
230
|
}, context);
|
|
216
231
|
|
|
217
232
|
return frameSubstitution;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import Substitution from "../substitution";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
-
import { attempt, instantiate } from "../../utilities/context";
|
|
7
6
|
import { instantiateReferenceSubstitution } from "../../process/instantiate";
|
|
7
|
+
import { join, descend, ablate, attempt, instantiate } from "../../utilities/context";
|
|
8
8
|
import { referenceSubstitutionFromReferenceSubstitutionNode } from "../../utilities/element";
|
|
9
9
|
import { referenceSubstitutionStringFromReferenceAndMetavariable } from "../../utilities/string";
|
|
10
10
|
|
|
@@ -104,24 +104,26 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
104
104
|
|
|
105
105
|
context.debug(`...the '${referenceSubstitutionString}' reference substitution is already valid.`);
|
|
106
106
|
} else {
|
|
107
|
-
const context = this.getContext()
|
|
108
|
-
specificContext = context; ///
|
|
107
|
+
const context = this.getContext();
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
join((context) => {
|
|
110
|
+
attempt((context) => {
|
|
111
|
+
const specificContext = context, ///
|
|
112
|
+
targetReferenceValidates = this.validateTargetReference(generalContext, specificContext);
|
|
112
113
|
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
if (targetReferenceValidates) {
|
|
115
|
+
const replacementReferenceValidates = this.validateReplacementReference(generalContext, specificContext);
|
|
115
116
|
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
if (replacementReferenceValidates) {
|
|
118
|
+
validates = true;
|
|
119
|
+
}
|
|
118
120
|
}
|
|
119
|
-
}
|
|
120
121
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
if (validates) {
|
|
123
|
+
context.commit(this);
|
|
124
|
+
}
|
|
125
|
+
}, context);
|
|
126
|
+
}, specificContext, context);
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
if (validates) {
|
|
@@ -146,11 +148,13 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
146
148
|
|
|
147
149
|
context.trace(`Validating the '${referenceSubstitutionString}' reference substitution's '${targetReferenceString}' target reference...`);
|
|
148
150
|
|
|
149
|
-
|
|
151
|
+
descend((context) => {
|
|
152
|
+
const targetReference = this.targetReference.validate(context);
|
|
150
153
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
+
if (targetReference !== null) {
|
|
155
|
+
targetReferenceValidates = true;
|
|
156
|
+
}
|
|
157
|
+
}, context);
|
|
154
158
|
|
|
155
159
|
if (targetReferenceValidates) {
|
|
156
160
|
context.debug(`...validated the '${referenceSubstitutionString}' reference substitution's '${targetReferenceString}' target reference...`);
|
|
@@ -168,11 +172,13 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
168
172
|
|
|
169
173
|
context.trace(`Validating the '${referenceSubstitutionString}' reference substitution's '${replacementReferenceString}' replacement reference...`);
|
|
170
174
|
|
|
171
|
-
|
|
175
|
+
descend((context) => {
|
|
176
|
+
const replacementReference = this.replacementReference.validate(context);
|
|
172
177
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
178
|
+
if (replacementReference !== null) {
|
|
179
|
+
replacementReferenceValidates = true;
|
|
180
|
+
}
|
|
181
|
+
}, context);
|
|
176
182
|
|
|
177
183
|
if (replacementReferenceValidates) {
|
|
178
184
|
context.debug(`...validated the '${referenceSubstitutionString}' reference substitution's '${replacementReferenceString}' replacement reference.`);
|
|
@@ -206,12 +212,14 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
206
212
|
static fromReferenceAndMetavariable(reference, metavariable, context) {
|
|
207
213
|
let referenceSubstitution;
|
|
208
214
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
215
|
+
ablate((context) => {
|
|
216
|
+
instantiate((context) => {
|
|
217
|
+
const referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
|
|
218
|
+
string = referenceSubstitutionString, ///
|
|
219
|
+
referenceSubstitutionNode = instantiateReferenceSubstitution(string, context);
|
|
213
220
|
|
|
214
|
-
|
|
221
|
+
referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
|
|
222
|
+
}, context);
|
|
215
223
|
}, context);
|
|
216
224
|
|
|
217
225
|
return referenceSubstitution;
|
|
@@ -220,14 +228,16 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
220
228
|
static fromAssumptionAndMetaLevelAssumption(assumption, metaLevelAssumption, context) {
|
|
221
229
|
let referenceSubstitution;
|
|
222
230
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
231
|
+
ablate((context) => {
|
|
232
|
+
instantiate((context) => {
|
|
233
|
+
const reference = metaLevelAssumption.getReference(),
|
|
234
|
+
metavariable = assumption.getMetavariable(),
|
|
235
|
+
referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
|
|
236
|
+
string = referenceSubstitutionString, ///
|
|
237
|
+
referenceSubstitutionNode = instantiateReferenceSubstitution(string, context);
|
|
229
238
|
|
|
230
|
-
|
|
239
|
+
referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
|
|
240
|
+
}, context);
|
|
231
241
|
}, context);
|
|
232
242
|
|
|
233
243
|
return referenceSubstitution;
|
|
@@ -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, attempt, descend, reconcile, instantiate } from "../../utilities/context";
|
|
10
9
|
import { statementSubstitutionFromStatementSubstitutionNode } from "../../utilities/element";
|
|
10
|
+
import { join, ablate, attempt, descend, reconcile, instantiate } from "../../utilities/context";
|
|
11
11
|
import { statementSubstitutionStringFromStatementAndMetavariable, statementSubstitutionStringFromStatementMetavariableAndSubstitution } from "../../utilities/string";
|
|
12
12
|
|
|
13
13
|
export default define(class StatementSubstitution extends Substitution {
|
|
@@ -122,28 +122,30 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
122
122
|
|
|
123
123
|
context.debug(`...the '${statementSubstitutionString}' statement substitution is already valid.`);
|
|
124
124
|
} else {
|
|
125
|
-
const context = this.getContext()
|
|
126
|
-
specificContext = context; ///
|
|
125
|
+
const context = this.getContext();
|
|
127
126
|
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
join((context) => {
|
|
128
|
+
attempt((context) => {
|
|
129
|
+
const specificContext = context, ///
|
|
130
|
+
targetStatementValidates = this.validateTargetStatement(generalContext, specificContext);
|
|
130
131
|
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
if (targetStatementValidates) {
|
|
133
|
+
const replacementStatementValidates = this.validateReplacementStatement(generalContext, specificContext);
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
if (replacementStatementValidates) {
|
|
136
|
+
const substitutionValidates = this.validateSubstitution(generalContext, specificContext);
|
|
136
137
|
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
if (substitutionValidates) {
|
|
139
|
+
validates = true;
|
|
140
|
+
}
|
|
139
141
|
}
|
|
140
142
|
}
|
|
141
|
-
}
|
|
142
143
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
if (validates) {
|
|
145
|
+
context.commit(this);
|
|
146
|
+
}
|
|
147
|
+
}, context);
|
|
148
|
+
}, specificContext, context);
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
if (validates) {
|
|
@@ -169,9 +171,9 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
169
171
|
|
|
170
172
|
context.trace(`Validating the '${statementSubstitutionString}' statement substitution's '${substitutionString}' substitution...`);
|
|
171
173
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
174
|
+
const generalContext = context, ///
|
|
175
|
+
specificContext = context, ///
|
|
176
|
+
substitution = this.substitution.validate(generalContext, specificContext);
|
|
175
177
|
|
|
176
178
|
if (substitution !== null) {
|
|
177
179
|
this.substitution = substitution;
|
|
@@ -190,7 +192,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
190
192
|
validateTargetStatement(generalContext, specificContext) {
|
|
191
193
|
let targetStatementValidates = false;
|
|
192
194
|
|
|
193
|
-
const context = generalContext,
|
|
195
|
+
const context = generalContext, ///
|
|
194
196
|
targetStatementString = this.targetStatement.getString(),
|
|
195
197
|
statementSubstitutionString = this.getString(); ///
|
|
196
198
|
|
|
@@ -344,38 +346,41 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
344
346
|
let resolved = false;
|
|
345
347
|
|
|
346
348
|
const context = specificContext, ///
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
context.trace(`Resolving the ${substitutionString} substitution...`);
|
|
350
|
-
|
|
351
|
-
const metavariableName = this.getMetavariableName(),
|
|
349
|
+
metavariableName = this.getMetavariableName(),
|
|
352
350
|
simpleSubstitution = context.findSimpleSubstitutionByMetavariableName(metavariableName);
|
|
353
351
|
|
|
354
352
|
if (simpleSubstitution !== null) {
|
|
353
|
+
const substitutionString = this.getString(); ///
|
|
354
|
+
|
|
355
|
+
context.trace(`Resolving the ${substitutionString} substitution...`);
|
|
356
|
+
|
|
355
357
|
const substitution = this.unifyWithSimpleSubstitution(simpleSubstitution, generalContext, specificContext); ///
|
|
356
358
|
|
|
357
359
|
if (substitution !== null) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
const substitutionContext = this.substitution.getContext(),
|
|
364
|
-
generalContext = substitutionContext, ///
|
|
365
|
-
specificContext = context, ///
|
|
366
|
-
substitutionUnifies = this.unifySubstitution(substitution, generalContext, specificContext);
|
|
367
|
-
|
|
368
|
-
if (substitutionUnifies) {
|
|
369
|
-
resolved = true;
|
|
370
|
-
}
|
|
371
|
-
}, complexSubstitutionContext, simpleSubstitutionContext, context);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
360
|
+
let context;
|
|
361
|
+
|
|
362
|
+
context = substitution.getContext();
|
|
363
|
+
|
|
364
|
+
const specificContext = context; ///
|
|
374
365
|
|
|
375
|
-
|
|
376
|
-
this.resolved = true;
|
|
366
|
+
context = this.substitution.getContext();
|
|
377
367
|
|
|
378
|
-
|
|
368
|
+
const generalContext = context; ///
|
|
369
|
+
|
|
370
|
+
context = specificContext; ///
|
|
371
|
+
|
|
372
|
+
const substitutionUnifies = this.unifySubstitution(substitution, generalContext, specificContext);
|
|
373
|
+
|
|
374
|
+
if (substitutionUnifies) {
|
|
375
|
+
resolved = true;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (resolved) {
|
|
379
|
+
this.resolved = true;
|
|
380
|
+
|
|
381
|
+
context.debug(`...resolved the '${substitutionString}' substitution.`);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
379
384
|
}
|
|
380
385
|
}
|
|
381
386
|
|
|
@@ -406,12 +411,14 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
406
411
|
|
|
407
412
|
let statementSubstitution;
|
|
408
413
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
414
|
+
ablate((context) => {
|
|
415
|
+
instantiate((context) => {
|
|
416
|
+
const statementSubstitutionString = statementSubstitutionStringFromStatementAndMetavariable(statement, metavariable, context),
|
|
417
|
+
string = statementSubstitutionString, ///
|
|
418
|
+
statementSubstitutionNode = instantiateStatementSubstitution(string, context);
|
|
413
419
|
|
|
414
|
-
|
|
420
|
+
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
|
|
421
|
+
}, context);
|
|
415
422
|
}, context);
|
|
416
423
|
|
|
417
424
|
return statementSubstitution;
|
|
@@ -422,12 +429,14 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
422
429
|
|
|
423
430
|
let statementSubstitution;
|
|
424
431
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
432
|
+
ablate((context) => {
|
|
433
|
+
instantiate((context) => {
|
|
434
|
+
const statementSubstitutionString = statementSubstitutionStringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution),
|
|
435
|
+
string = statementSubstitutionString, ///
|
|
436
|
+
statementSubstitutionNode = instantiateStatementSubstitution(string, context);
|
|
429
437
|
|
|
430
|
-
|
|
438
|
+
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
|
|
439
|
+
}, context);
|
|
431
440
|
}, context);
|
|
432
441
|
|
|
433
442
|
return statementSubstitution;
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
import Substitution from "../substitution";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
-
import { attempt, instantiate } from "../../utilities/context";
|
|
7
6
|
import { stripBracketsFromTerm } from "../../utilities/brackets";
|
|
8
7
|
import { instantiateTermSubstitution } from "../../process/instantiate";
|
|
8
|
+
import { termSubstitutionFromTermSubstitutionNode } from "../../utilities/element";
|
|
9
9
|
import { termSubstitutionStringFromTermAndVariable } from "../../utilities/string";
|
|
10
|
-
import {
|
|
10
|
+
import { join, ablate, descend, attempt, instantiate } from "../../utilities/context";
|
|
11
11
|
|
|
12
12
|
export default define(class TermSubstitution extends Substitution {
|
|
13
13
|
constructor(context, string, node, targetTerm, replacementTerm) {
|
|
@@ -90,24 +90,26 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
90
90
|
|
|
91
91
|
context.debug(`...the '${termSubstitutionString}' term substitution is already valid.`);
|
|
92
92
|
} else {
|
|
93
|
-
const context = this.getContext()
|
|
94
|
-
specificContext = context; ///
|
|
93
|
+
const context = this.getContext();
|
|
95
94
|
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
join((context) => {
|
|
96
|
+
attempt((context) => {
|
|
97
|
+
const specificContext = context, ///
|
|
98
|
+
targetTermValidates = this.validateTargetTerm(generalContext, specificContext);
|
|
98
99
|
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
if (targetTermValidates) {
|
|
101
|
+
const replacementTermValidates = this.validateReplacementTerm(generalContext, specificContext);
|
|
101
102
|
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
if (replacementTermValidates) {
|
|
104
|
+
validates = true;
|
|
105
|
+
}
|
|
104
106
|
}
|
|
105
|
-
}
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
if (validates) {
|
|
109
|
+
context.commit(this);
|
|
110
|
+
}
|
|
111
|
+
}, context);
|
|
112
|
+
}, specificContext, context);
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
if (validates) {
|
|
@@ -135,17 +137,19 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
135
137
|
const targetTermSingular = this.targetTerm.isSingular();
|
|
136
138
|
|
|
137
139
|
if (targetTermSingular) {
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
+
descend((context) => {
|
|
141
|
+
const targetTerm = this.targetTerm.validate(context, (targetTerm) => {
|
|
142
|
+
const validatesForwards = true;
|
|
140
143
|
|
|
141
|
-
|
|
142
|
-
|
|
144
|
+
return validatesForwards;
|
|
145
|
+
});
|
|
143
146
|
|
|
144
|
-
|
|
145
|
-
|
|
147
|
+
if (targetTerm !== null) {
|
|
148
|
+
this.targetTerm = targetTerm;
|
|
146
149
|
|
|
147
|
-
|
|
148
|
-
|
|
150
|
+
targetTermValidates = true;
|
|
151
|
+
}
|
|
152
|
+
}, context);
|
|
149
153
|
} else {
|
|
150
154
|
context.debug(`The '${termSubstitutionString}' term substitution's '${targetTermString}' target term is not singular.`);
|
|
151
155
|
}
|
|
@@ -166,17 +170,19 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
166
170
|
|
|
167
171
|
context.trace(`Validating the '${termSubstitutionString}' term substitution's '${replacementTermString}' replacement term...`);
|
|
168
172
|
|
|
169
|
-
|
|
170
|
-
const
|
|
173
|
+
descend((context) => {
|
|
174
|
+
const replacementTerm = this.replacementTerm.validate(context, (replacementTerm) => {
|
|
175
|
+
const validatesForwards = true;
|
|
171
176
|
|
|
172
|
-
|
|
173
|
-
|
|
177
|
+
return validatesForwards;
|
|
178
|
+
});
|
|
174
179
|
|
|
175
|
-
|
|
176
|
-
|
|
180
|
+
if (replacementTerm !== null) {
|
|
181
|
+
this.replacementTerm = replacementTerm;
|
|
177
182
|
|
|
178
|
-
|
|
179
|
-
|
|
183
|
+
replacementTermValidates = true;
|
|
184
|
+
}
|
|
185
|
+
}, context);
|
|
180
186
|
|
|
181
187
|
if (replacementTermValidates) {
|
|
182
188
|
context.debug(`...validated the '${termSubstitutionString}' term substitution's '${replacementTermString}' replacement term...`);
|
|
@@ -208,8 +214,15 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
208
214
|
}
|
|
209
215
|
|
|
210
216
|
static fromStatement(statement, context) {
|
|
211
|
-
|
|
212
|
-
|
|
217
|
+
let termSubstitution = null;
|
|
218
|
+
|
|
219
|
+
const termSubstitutionNode = statement.getTermSubstitutionNode();
|
|
220
|
+
|
|
221
|
+
if (termSubstitutionNode !== null) {
|
|
222
|
+
ablate((context) => {
|
|
223
|
+
termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, context);
|
|
224
|
+
}, context);
|
|
225
|
+
}
|
|
213
226
|
|
|
214
227
|
return termSubstitution;
|
|
215
228
|
}
|
|
@@ -219,12 +232,14 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
219
232
|
|
|
220
233
|
let termSubstitution;
|
|
221
234
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
235
|
+
ablate((context) => {
|
|
236
|
+
instantiate((context) => {
|
|
237
|
+
const termSubstitutionString = termSubstitutionStringFromTermAndVariable(term, variable),
|
|
238
|
+
string = termSubstitutionString, ///
|
|
239
|
+
termSubstitutionNode = instantiateTermSubstitution(string, context);
|
|
226
240
|
|
|
227
|
-
|
|
241
|
+
termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, context);
|
|
242
|
+
}, context);
|
|
228
243
|
}, context);
|
|
229
244
|
|
|
230
245
|
return termSubstitution;
|
package/src/element/variable.js
CHANGED
|
@@ -77,12 +77,11 @@ export default define(class Variable extends Element {
|
|
|
77
77
|
|
|
78
78
|
let validates = false;
|
|
79
79
|
|
|
80
|
-
const variableIdentifier = this.identifier
|
|
80
|
+
const variableIdentifier = this.identifier, ///
|
|
81
|
+
declaredVariable = context.findDeclaredVariableByVariableIdentifier(variableIdentifier);
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (variable !== null) {
|
|
85
|
-
const type = variable.getType(),
|
|
83
|
+
if (declaredVariable !== null) {
|
|
84
|
+
const type = declaredVariable.getType(),
|
|
86
85
|
typeString = type.getString(),
|
|
87
86
|
variableString = this.getString(); ///
|
|
88
87
|
|
|
@@ -138,9 +137,9 @@ export default define(class Variable extends Element {
|
|
|
138
137
|
|
|
139
138
|
context = generalContext; ///
|
|
140
139
|
|
|
141
|
-
const
|
|
140
|
+
const variableNode = variable.getIdentifier();
|
|
142
141
|
|
|
143
|
-
variable = context.
|
|
142
|
+
variable = context.findVariableByVariableNode(variableNode);
|
|
144
143
|
|
|
145
144
|
context = specificContext; ///
|
|
146
145
|
|
package/src/preamble.js
CHANGED
|
@@ -36,7 +36,6 @@ import Constructor from "./element/constructor";
|
|
|
36
36
|
import Supposition from "./element/proofAssertion/supposition";
|
|
37
37
|
import Metatheorem from "./element/topLevelMetaAssertion/metatheorem";
|
|
38
38
|
import Equivalence from "./element/equivalence";
|
|
39
|
-
import Equivalences from "./element/equivalences";
|
|
40
39
|
import Metavariable from "./element/metavariable";
|
|
41
40
|
import ProcedureCall from "./element/procedureCall";
|
|
42
41
|
import SubDerivation from "./element/subDerivation";
|