occam-verify-cli 1.0.800 → 1.0.809
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/bounded.js +242 -0
- 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/synoptic.js +212 -0
- 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/derivation.js +1 -7
- package/lib/element/label.js +9 -5
- package/lib/element/metavariable.js +34 -34
- package/lib/element/procedureCall.js +2 -2
- package/lib/element/proof.js +2 -2
- package/lib/element/proofAssertion/premise.js +4 -3
- package/lib/element/proofAssertion/step.js +5 -3
- package/lib/element/reference.js +6 -4
- package/lib/element/rule.js +2 -2
- package/lib/element/statement.js +9 -1
- package/lib/element/subproof.js +2 -2
- package/lib/element/substitution/frame.js +43 -29
- package/lib/element/substitution/reference.js +38 -28
- package/lib/element/substitution/statement.js +52 -42
- package/lib/element/substitution/term.js +49 -35
- package/lib/element/topLevelAssertion.js +2 -2
- package/lib/element/topLevelMetaAssertion.js +2 -2
- 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 +51 -44
- package/lib/utilities/element.js +1 -1
- package/lib/utilities/equivalences.js +131 -0
- package/lib/utilities/instance.js +3 -3
- package/lib/utilities/json.js +59 -1
- package/lib/utilities/validation.js +4 -3
- package/package.json +4 -4
- package/src/context/{proof.js → bounded.js} +84 -85
- 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/synoptic.js +290 -0
- 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/derivation.js +0 -2
- package/src/element/label.js +11 -7
- package/src/element/metavariable.js +11 -11
- package/src/element/procedureCall.js +2 -2
- package/src/element/proof.js +2 -2
- package/src/element/proofAssertion/premise.js +4 -4
- package/src/element/proofAssertion/step.js +6 -4
- package/src/element/reference.js +7 -5
- package/src/element/rule.js +2 -2
- package/src/element/statement.js +14 -0
- package/src/element/subproof.js +2 -2
- package/src/element/substitution/frame.js +47 -32
- package/src/element/substitution/reference.js +44 -34
- package/src/element/substitution/statement.js +69 -58
- package/src/element/substitution/term.js +53 -38
- package/src/element/topLevelAssertion.js +2 -2
- package/src/element/topLevelMetaAssertion.js +2 -2
- 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 +54 -49
- package/src/utilities/element.js +1 -0
- package/src/utilities/equivalences.js +158 -0
- package/src/utilities/instance.js +3 -3
- package/src/utilities/json.js +66 -0
- package/src/utilities/validation.js +6 -5
- package/lib/context/proof.js +0 -242
- package/lib/context/synthetic.js +0 -135
- package/lib/element/equivalences.js +0 -173
- package/src/context/synthetic.js +0 -180
- 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,15 +171,17 @@ 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
|
+
descend((context) => {
|
|
175
|
+
const generalContext = context, ///
|
|
176
|
+
specificContext = context, ///
|
|
177
|
+
substitution = this.substitution.validate(generalContext, specificContext);
|
|
175
178
|
|
|
176
|
-
|
|
177
|
-
|
|
179
|
+
if (substitution !== null) {
|
|
180
|
+
this.substitution = substitution;
|
|
178
181
|
|
|
179
|
-
|
|
180
|
-
|
|
182
|
+
substitutionValidates = true;
|
|
183
|
+
}
|
|
184
|
+
}, context);
|
|
181
185
|
|
|
182
186
|
if (substitutionValidates) {
|
|
183
187
|
context.debug(`...validatewd the '${statementSubstitutionString}' statement substitution's '${substitutionString}' substitution.`);
|
|
@@ -190,7 +194,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
190
194
|
validateTargetStatement(generalContext, specificContext) {
|
|
191
195
|
let targetStatementValidates = false;
|
|
192
196
|
|
|
193
|
-
const context = generalContext,
|
|
197
|
+
const context = generalContext, ///
|
|
194
198
|
targetStatementString = this.targetStatement.getString(),
|
|
195
199
|
statementSubstitutionString = this.getString(); ///
|
|
196
200
|
|
|
@@ -344,38 +348,41 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
344
348
|
let resolved = false;
|
|
345
349
|
|
|
346
350
|
const context = specificContext, ///
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
context.trace(`Resolving the ${substitutionString} substitution...`);
|
|
350
|
-
|
|
351
|
-
const metavariableName = this.getMetavariableName(),
|
|
351
|
+
metavariableName = this.getMetavariableName(),
|
|
352
352
|
simpleSubstitution = context.findSimpleSubstitutionByMetavariableName(metavariableName);
|
|
353
353
|
|
|
354
354
|
if (simpleSubstitution !== null) {
|
|
355
|
+
const substitutionString = this.getString(); ///
|
|
356
|
+
|
|
357
|
+
context.trace(`Resolving the ${substitutionString} substitution...`);
|
|
358
|
+
|
|
355
359
|
const substitution = this.unifyWithSimpleSubstitution(simpleSubstitution, generalContext, specificContext); ///
|
|
356
360
|
|
|
357
361
|
if (substitution !== null) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
specificContext = context, ///
|
|
366
|
-
substitutionUnifies = this.unifySubstitution(substitution, generalContext, specificContext);
|
|
367
|
-
|
|
368
|
-
if (substitutionUnifies) {
|
|
369
|
-
resolved = true;
|
|
370
|
-
}
|
|
371
|
-
}, complexSubstitutionContext, simpleSubstitutionContext, context);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
362
|
+
let context;
|
|
363
|
+
|
|
364
|
+
context = substitution.getContext();
|
|
365
|
+
|
|
366
|
+
const specificContext = context; ///
|
|
367
|
+
|
|
368
|
+
context = this.substitution.getContext();
|
|
374
369
|
|
|
375
|
-
|
|
376
|
-
|
|
370
|
+
const generalContext = context; ///
|
|
371
|
+
|
|
372
|
+
context = specificContext; ///
|
|
373
|
+
|
|
374
|
+
const substitutionUnifies = this.unifySubstitution(substitution, generalContext, specificContext);
|
|
375
|
+
|
|
376
|
+
if (substitutionUnifies) {
|
|
377
|
+
resolved = true;
|
|
378
|
+
}
|
|
377
379
|
|
|
378
|
-
|
|
380
|
+
if (resolved) {
|
|
381
|
+
this.resolved = true;
|
|
382
|
+
|
|
383
|
+
context.debug(`...resolved the '${substitutionString}' substitution.`);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
379
386
|
}
|
|
380
387
|
}
|
|
381
388
|
|
|
@@ -406,12 +413,14 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
406
413
|
|
|
407
414
|
let statementSubstitution;
|
|
408
415
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
416
|
+
ablate((context) => {
|
|
417
|
+
instantiate((context) => {
|
|
418
|
+
const statementSubstitutionString = statementSubstitutionStringFromStatementAndMetavariable(statement, metavariable, context),
|
|
419
|
+
string = statementSubstitutionString, ///
|
|
420
|
+
statementSubstitutionNode = instantiateStatementSubstitution(string, context);
|
|
413
421
|
|
|
414
|
-
|
|
422
|
+
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
|
|
423
|
+
}, context);
|
|
415
424
|
}, context);
|
|
416
425
|
|
|
417
426
|
return statementSubstitution;
|
|
@@ -422,12 +431,14 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
422
431
|
|
|
423
432
|
let statementSubstitution;
|
|
424
433
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
434
|
+
ablate((context) => {
|
|
435
|
+
instantiate((context) => {
|
|
436
|
+
const statementSubstitutionString = statementSubstitutionStringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution),
|
|
437
|
+
string = statementSubstitutionString, ///
|
|
438
|
+
statementSubstitutionNode = instantiateStatementSubstitution(string, context);
|
|
429
439
|
|
|
430
|
-
|
|
440
|
+
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
|
|
441
|
+
}, context);
|
|
431
442
|
}, context);
|
|
432
443
|
|
|
433
444
|
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;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
import { Element, asynchronousUtilities } from "occam-languages";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { enclose } from "../utilities/context";
|
|
7
7
|
import { topLevelAssertionStringFromLabelsSuppositionsAndDeduction } from "../utilities/string";
|
|
8
8
|
import { labelsFromJSON,
|
|
9
9
|
deductionFromJSON,
|
|
@@ -150,7 +150,7 @@ export default class TopLevelAssertion extends Element {
|
|
|
150
150
|
|
|
151
151
|
context.trace(`Verifying the '${topLevelAssertionString}' top level assertion...`);
|
|
152
152
|
|
|
153
|
-
await
|
|
153
|
+
await enclose(async (context) => {
|
|
154
154
|
const labelsVerify = this.verifyLabels();
|
|
155
155
|
|
|
156
156
|
if (labelsVerify) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { Element, asynchronousUtilities } from "occam-languages";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { enclose } from "../utilities/context";
|
|
6
6
|
import { topLevelMetaAssertionStringFromLabelSuppositionsDeductionAndMetaLevelAssumptions } from "../utilities/string";
|
|
7
7
|
import { labelFromJSON,
|
|
8
8
|
labelToLabelJSON,
|
|
@@ -103,7 +103,7 @@ export default class TopLevelMetaAssertion extends Element {
|
|
|
103
103
|
|
|
104
104
|
context.trace(`Verifying the '${topLevelMetaAssertionString}' top level meta assertion...`);
|
|
105
105
|
|
|
106
|
-
await
|
|
106
|
+
await enclose(async (context) => {
|
|
107
107
|
const labelVerifies = this.verifyLabel();
|
|
108
108
|
|
|
109
109
|
if (labelVerifies) {
|