occam-verify-cli 1.0.747 → 1.0.757
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 +56 -0
- package/lib/context/ephemeral.js +10 -1
- package/lib/context/file/nominal.js +5 -10
- package/lib/context/scoped.js +6 -5
- package/lib/context/synthetic.js +7 -3
- package/lib/context.js +9 -1
- package/lib/element/assertion/contained.js +7 -7
- package/lib/element/assertion/defined.js +7 -7
- package/lib/element/assertion/property.js +3 -3
- package/lib/element/assertion/satisfies.js +2 -2
- package/lib/element/assertion/subproof.js +111 -14
- package/lib/element/assertion/type.js +7 -7
- package/lib/element/assumption.js +21 -33
- package/lib/element/combinator.js +4 -4
- package/lib/element/conclusion.js +3 -7
- package/lib/element/constructor/bracketed.js +9 -8
- package/lib/element/constructor.js +9 -5
- package/lib/element/deduction.js +17 -20
- package/lib/element/derivation.js +4 -4
- package/lib/element/equality.js +12 -11
- package/lib/element/equivalence.js +3 -3
- package/lib/element/frame.js +2 -2
- package/lib/element/hypothesis.js +2 -2
- package/lib/element/judgement.js +2 -2
- package/lib/element/label.js +4 -4
- package/lib/element/metavariable.js +65 -25
- package/lib/element/parameter.js +2 -2
- package/lib/element/procedureCall.js +2 -2
- package/lib/element/procedureReference.js +2 -2
- package/lib/element/proof.js +7 -7
- package/lib/element/proofAssertion/premise.js +12 -18
- package/lib/element/proofAssertion/step.js +3 -3
- package/lib/element/proofAssertion/supposition.js +13 -19
- package/lib/element/property.js +2 -2
- package/lib/element/propertyRelation.js +3 -3
- package/lib/element/reference.js +11 -9
- package/lib/element/rule.js +2 -2
- package/lib/element/signature.js +3 -3
- package/lib/element/statement.js +100 -59
- package/lib/element/subDerivation.js +4 -4
- package/lib/element/subproof.js +7 -7
- package/lib/element/substitution/frame.js +8 -8
- package/lib/element/substitution/metaLevel.js +7 -7
- package/lib/element/substitution/reference.js +7 -7
- package/lib/element/substitution/statement.js +73 -60
- package/lib/element/substitution/term.js +10 -10
- package/lib/element/term.js +17 -14
- package/lib/element/topLevelAssertion/axiom.js +15 -13
- package/lib/element/topLevelAssertion.js +2 -5
- package/lib/element/topLevelMetaAssertion.js +27 -3
- package/lib/element/type.js +2 -2
- package/lib/element/typePrefix.js +2 -2
- package/lib/element/variable.js +6 -3
- package/lib/process/unify.js +51 -9
- package/lib/process/validate.js +5 -5
- package/lib/utilities/context.js +28 -20
- package/lib/utilities/element.js +2 -2
- package/lib/utilities/instance.js +3 -3
- package/lib/utilities/releaseContext.js +3 -3
- package/lib/utilities/string.js +2 -2
- package/lib/utilities/validation.js +13 -5
- package/package.json +3 -3
- package/src/context/branching.js +59 -0
- package/src/context/ephemeral.js +12 -0
- package/src/context/file/nominal.js +4 -12
- package/src/context/scoped.js +6 -4
- package/src/context/synthetic.js +9 -2
- package/src/context.js +14 -0
- package/src/element/assertion/contained.js +8 -8
- package/src/element/assertion/defined.js +7 -7
- package/src/element/assertion/property.js +4 -4
- package/src/element/assertion/satisfies.js +2 -2
- package/src/element/assertion/subproof.js +191 -18
- package/src/element/assertion/type.js +7 -7
- package/src/element/assumption.js +21 -52
- package/src/element/combinator.js +4 -4
- package/src/element/conclusion.js +3 -10
- package/src/element/constructor/bracketed.js +9 -7
- package/src/element/constructor.js +11 -5
- package/src/element/deduction.js +17 -23
- package/src/element/derivation.js +4 -3
- package/src/element/equality.js +16 -14
- package/src/element/equivalence.js +3 -3
- package/src/element/frame.js +2 -2
- package/src/element/hypothesis.js +2 -2
- package/src/element/judgement.js +2 -2
- package/src/element/label.js +4 -4
- package/src/element/metavariable.js +96 -32
- package/src/element/parameter.js +2 -2
- package/src/element/procedureCall.js +2 -2
- package/src/element/procedureReference.js +2 -2
- package/src/element/proof.js +8 -8
- package/src/element/proofAssertion/premise.js +22 -32
- package/src/element/proofAssertion/step.js +3 -3
- package/src/element/proofAssertion/supposition.js +27 -36
- package/src/element/property.js +2 -2
- package/src/element/propertyRelation.js +3 -3
- package/src/element/reference.js +11 -9
- package/src/element/rule.js +2 -2
- package/src/element/signature.js +3 -3
- package/src/element/statement.js +154 -88
- package/src/element/subDerivation.js +4 -3
- package/src/element/subproof.js +6 -6
- package/src/element/substitution/frame.js +8 -8
- package/src/element/substitution/metaLevel.js +7 -7
- package/src/element/substitution/reference.js +7 -7
- package/src/element/substitution/statement.js +99 -76
- package/src/element/substitution/term.js +10 -10
- package/src/element/term.js +22 -16
- package/src/element/topLevelAssertion/axiom.js +20 -16
- package/src/element/topLevelAssertion.js +2 -4
- package/src/element/topLevelMetaAssertion.js +42 -3
- package/src/element/type.js +3 -2
- package/src/element/typePrefix.js +2 -2
- package/src/element/variable.js +12 -3
- package/src/process/unify.js +78 -9
- package/src/process/validate.js +4 -4
- package/src/utilities/context.js +20 -12
- package/src/utilities/element.js +2 -2
- package/src/utilities/instance.js +3 -3
- package/src/utilities/releaseContext.js +1 -1
- package/src/utilities/string.js +3 -3
- package/src/utilities/validation.js +16 -4
|
@@ -4,9 +4,9 @@ import Substitution from "../substitution";
|
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
6
|
import { unifySubstitution } from "../../process/unify";
|
|
7
|
+
import { join, reconcile, instantiate } from "../../utilities/context";
|
|
7
8
|
import { stripBracketsFromStatement } from "../../utilities/brackets";
|
|
8
9
|
import { instantiateStatementSubstitution } from "../../process/instantiate";
|
|
9
|
-
import { liminally, literally, synthetically } from "../../utilities/context";
|
|
10
10
|
import { statementSubstitutionFromStatementSubstitutionNode } from "../../utilities/element";
|
|
11
11
|
import { statementSubstitutionStringFromStatementAndMetavariable, statementSubstitutionStringFromStatementMetavariableAndSubstitution } from "../../utilities/string";
|
|
12
12
|
|
|
@@ -156,7 +156,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
156
156
|
targetStatementString = this.targetStatement.getString(),
|
|
157
157
|
statementSubstitutionString = this.getString(); ///
|
|
158
158
|
|
|
159
|
-
context.trace(`Validating the '${statementSubstitutionString}' statement
|
|
159
|
+
context.trace(`Validating the '${statementSubstitutionString}' statement substitution's '${targetStatementString}' target statement...`);
|
|
160
160
|
|
|
161
161
|
const targetStatementSingular = this.targetStatement.isSingular();
|
|
162
162
|
|
|
@@ -168,11 +168,11 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
168
168
|
targetStatementValidates = true;
|
|
169
169
|
}
|
|
170
170
|
} else {
|
|
171
|
-
context.debug(`The '${statementSubstitutionString}' statement
|
|
171
|
+
context.debug(`The '${statementSubstitutionString}' statement substitution's '${targetStatementString}' target statement is not singular.`);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
if (targetStatementValidates) {
|
|
175
|
-
context.debug(`...validated the '${statementSubstitutionString}' statement
|
|
175
|
+
context.debug(`...validated the '${statementSubstitutionString}' statement substitution's '${targetStatementString}' target statement...`);
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
return targetStatementValidates;
|
|
@@ -185,7 +185,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
185
185
|
replacementStatementString = this.replacementStatement.getString(),
|
|
186
186
|
statementSubstitutionString = this.getString(); ///
|
|
187
187
|
|
|
188
|
-
context.trace(`Validating the '${statementSubstitutionString}' statement
|
|
188
|
+
context.trace(`Validating the '${statementSubstitutionString}' statement substitution's '${replacementStatementString}' replacement statement...`);
|
|
189
189
|
|
|
190
190
|
const stated = true,
|
|
191
191
|
replacementStatement = this.replacementStatement.validate(stated, context);
|
|
@@ -195,36 +195,15 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
if (replacementStatementValidates) {
|
|
198
|
-
context.debug(`...validated the '${statementSubstitutionString}' statement
|
|
198
|
+
context.debug(`...validated the '${statementSubstitutionString}' statement substitution's '${replacementStatementString}' replacement statement.`);
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
return replacementStatementValidates;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
unifyReplacementStatement(replacementStatement, generalContext, specificContext) {
|
|
205
|
-
let replacementStatemnentUnifies = false;
|
|
206
|
-
|
|
207
|
-
const context = specificContext, ///
|
|
208
|
-
substitutionString = this.getString(), ///
|
|
209
|
-
replacementStatementString = replacementStatement.getString(),
|
|
210
|
-
substitutionReplacementStatementString = this.replacementStatement.getString(); ///
|
|
211
|
-
|
|
212
|
-
context.trace(`Unifying the '${replacementStatementString}' replacement statement with the '${substitutionString}' substiution's '${substitutionReplacementStatementString}' replacement statement...`);
|
|
213
|
-
|
|
214
|
-
const statementUnifies = this.replacementStatement.unifyStatement(replacementStatement, generalContext, specificContext);
|
|
215
|
-
|
|
216
|
-
if (statementUnifies) {
|
|
217
|
-
replacementStatemnentUnifies = true;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (replacementStatemnentUnifies) {
|
|
221
|
-
context.debug(`...unified the '${replacementStatementString}' replacement statement with the '${substitutionString}' substiution's '${substitutionReplacementStatementString}' replacement statement.`);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return replacementStatemnentUnifies;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
204
|
unifySubstitution(substitution, generalContext, specificContext) {
|
|
205
|
+
let substitutionUnifies;
|
|
206
|
+
|
|
228
207
|
const context = specificContext,
|
|
229
208
|
generalSubstitution = this.substitution, ///
|
|
230
209
|
specificSubstitution = substitution, ///
|
|
@@ -233,7 +212,13 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
233
212
|
|
|
234
213
|
context.trace(`Unifying the '${specificSubstitutionString}' substitution with the '${generalSubstitutionString}' substitution...`);
|
|
235
214
|
|
|
236
|
-
|
|
215
|
+
reconcile((specificContext) => {
|
|
216
|
+
substitutionUnifies = unifySubstitution(generalSubstitution, specificSubstitution, generalContext, specificContext);
|
|
217
|
+
|
|
218
|
+
if (substitutionUnifies) {
|
|
219
|
+
specificContext.commit();
|
|
220
|
+
}
|
|
221
|
+
}, specificContext);
|
|
237
222
|
|
|
238
223
|
if (substitutionUnifies) {
|
|
239
224
|
context.trace(`...unified the '${specificSubstitutionString}' substitution with the '${generalSubstitutionString}' substitution.`);
|
|
@@ -242,81 +227,119 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
242
227
|
return substitutionUnifies;
|
|
243
228
|
}
|
|
244
229
|
|
|
245
|
-
|
|
246
|
-
let
|
|
230
|
+
uniffyComplexSubstitution(complexSubstitution, generalContext, specificContext) {
|
|
231
|
+
let substitution = null;
|
|
247
232
|
|
|
248
|
-
context =
|
|
233
|
+
const context = specificContext, ///
|
|
234
|
+
simpleSubstitutionString = this.getString(), ///
|
|
235
|
+
complexSubstitutionString = complexSubstitution.getString(); ///
|
|
249
236
|
|
|
250
|
-
|
|
237
|
+
context.trace(`Unifying the '${complexSubstitutionString}' complex substitution with the '${simpleSubstitutionString}' simple substitution...`);
|
|
251
238
|
|
|
252
|
-
|
|
239
|
+
let simpleSubstitutionUnifies = false;
|
|
253
240
|
|
|
254
|
-
|
|
241
|
+
reconcile((specificContext) => {
|
|
242
|
+
const replacementStatement = complexSubstitution.getReplacementStatement(),
|
|
243
|
+
replacementStatementUnifies = this.unifyReplacementStatement(replacementStatement, generalContext, specificContext);
|
|
255
244
|
|
|
256
|
-
|
|
245
|
+
if (replacementStatementUnifies) {
|
|
246
|
+
const nested = false,
|
|
247
|
+
context = specificContext, ///
|
|
248
|
+
soleNonTrivialSubstitution = context.getSoleNonTrivialSubstitution(nested);
|
|
257
249
|
|
|
258
|
-
|
|
250
|
+
substitution = soleNonTrivialSubstitution; ///
|
|
251
|
+
}
|
|
252
|
+
}, specificContext);
|
|
259
253
|
|
|
260
|
-
|
|
254
|
+
if (substitution !== null) {
|
|
255
|
+
simpleSubstitutionUnifies = true;
|
|
256
|
+
}
|
|
261
257
|
|
|
262
|
-
if (
|
|
263
|
-
context
|
|
258
|
+
if (simpleSubstitutionUnifies) {
|
|
259
|
+
context.debug(`...unified the '${complexSubstitutionString}' complex substitution with the '${simpleSubstitutionString}' simple substitution.`);
|
|
260
|
+
}
|
|
264
261
|
|
|
265
|
-
|
|
266
|
-
|
|
262
|
+
return substitution;
|
|
263
|
+
}
|
|
267
264
|
|
|
268
|
-
|
|
265
|
+
unifyReplacementStatement(replacementStatement, generalContext, specificContext) {
|
|
266
|
+
let replacementStatemnentUnifies = false;
|
|
269
267
|
|
|
270
|
-
|
|
268
|
+
const context = specificContext, ///
|
|
269
|
+
replacementStatementString = replacementStatement.getString(),
|
|
270
|
+
substitutionReplacementStatementString = this.replacementStatement.getString(); ///
|
|
271
271
|
|
|
272
|
-
|
|
272
|
+
context.trace(`Unifying the '${replacementStatementString}' replacement statement with the '${substitutionReplacementStatementString}' replacement statement...`);
|
|
273
273
|
|
|
274
|
-
|
|
274
|
+
const statementUnifies = this.replacementStatement.unifyStatement(replacementStatement, generalContext, specificContext);
|
|
275
275
|
|
|
276
|
-
|
|
276
|
+
if (statementUnifies) {
|
|
277
|
+
replacementStatemnentUnifies = true;
|
|
278
|
+
}
|
|
277
279
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
280
|
+
if (replacementStatemnentUnifies) {
|
|
281
|
+
context.debug(`...unified the '${replacementStatementString}' replacement statement with the '${substitutionReplacementStatementString}' replacement statement.`);
|
|
282
|
+
}
|
|
281
283
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
return replacementStatemnentUnifies;
|
|
285
|
+
}
|
|
284
286
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
+
unifyWithSipmleSubstitution(simpleSubstitution, generalContext, specificContext) {
|
|
288
|
+
let substitution;
|
|
287
289
|
|
|
288
|
-
|
|
289
|
-
liminally((specificContext) => {
|
|
290
|
-
const contexts = [];
|
|
290
|
+
const complexSubstitution = this; ///
|
|
291
291
|
|
|
292
|
-
|
|
292
|
+
let context;
|
|
293
293
|
|
|
294
|
-
|
|
294
|
+
context = this.getContext();
|
|
295
|
+
|
|
296
|
+
specificContext = context; ///
|
|
295
297
|
|
|
296
|
-
|
|
298
|
+
context = simpleSubstitution.getContext();
|
|
297
299
|
|
|
298
|
-
|
|
300
|
+
generalContext = context; ///
|
|
299
301
|
|
|
300
|
-
|
|
302
|
+
substitution = simpleSubstitution.uniffyComplexSubstitution(complexSubstitution, generalContext, specificContext);
|
|
301
303
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
+
return substitution;
|
|
305
|
+
}
|
|
304
306
|
|
|
305
|
-
|
|
307
|
+
resolve(generalContext, specificContext) {
|
|
308
|
+
let resolved = false;
|
|
306
309
|
|
|
307
|
-
|
|
310
|
+
const context = specificContext, ///
|
|
311
|
+
substitutionString = this.getString(); ///
|
|
308
312
|
|
|
309
|
-
|
|
310
|
-
}, contexts, context);
|
|
313
|
+
context.trace(`Resolving the ${substitutionString} substitution...`);
|
|
311
314
|
|
|
312
|
-
|
|
313
|
-
|
|
315
|
+
const metavariableName = this.getMetavariableName(),
|
|
316
|
+
simpleSubstitution = context.findSimpleSubstitutionByMetavariableName(metavariableName);
|
|
314
317
|
|
|
315
|
-
|
|
318
|
+
if (simpleSubstitution !== null) {
|
|
319
|
+
const substitution = this.unifyWithSipmleSubstitution(simpleSubstitution, generalContext, specificContext); ///
|
|
320
|
+
|
|
321
|
+
if (substitution !== null) {
|
|
322
|
+
const complexSubstitution = this, ///
|
|
323
|
+
simpleSubstitutionComplex = simpleSubstitution.getContext(),
|
|
324
|
+
complexSubstitutionContext = complexSubstitution.getContext();
|
|
325
|
+
|
|
326
|
+
join((context) => {
|
|
327
|
+
const specificContext = context; ///
|
|
328
|
+
|
|
329
|
+
context = this.substitution.getContext();
|
|
330
|
+
|
|
331
|
+
const generalContext = context; ///
|
|
332
|
+
|
|
333
|
+
this.unifySubstitution(substitution, generalContext, specificContext);
|
|
334
|
+
}, complexSubstitutionContext, simpleSubstitutionComplex, context);
|
|
335
|
+
|
|
336
|
+
resolved = true;
|
|
316
337
|
}
|
|
317
338
|
}
|
|
318
339
|
|
|
319
|
-
if (
|
|
340
|
+
if (resolved) {
|
|
341
|
+
this.resolved = true;
|
|
342
|
+
|
|
320
343
|
context.debug(`...resolved the '${substitutionString}' substitution.`);
|
|
321
344
|
}
|
|
322
345
|
}
|
|
@@ -329,7 +352,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
329
352
|
const { name } = json;
|
|
330
353
|
|
|
331
354
|
if (this.name === name) {
|
|
332
|
-
|
|
355
|
+
instantiate((context) => {
|
|
333
356
|
const { string } = json,
|
|
334
357
|
statementSubstitutionNode = instantiateStatementSubstitution(string, context),
|
|
335
358
|
node = statementSubstitutionNode, ///
|
|
@@ -348,7 +371,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
348
371
|
static fromStatementAndMetavariable(statement, metavariable, context) {
|
|
349
372
|
statement = stripBracketsFromStatement(statement, context); ///
|
|
350
373
|
|
|
351
|
-
return
|
|
374
|
+
return instantiate((context) => {
|
|
352
375
|
const statementSubstitutionString = statementSubstitutionStringFromStatementAndMetavariable(statement, metavariable, context),
|
|
353
376
|
string = statementSubstitutionString, ///
|
|
354
377
|
statementSubstitutionNode = instantiateStatementSubstitution(string, context),
|
|
@@ -361,7 +384,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
361
384
|
static fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context) {
|
|
362
385
|
statement = stripBracketsFromStatement(statement, context); ///
|
|
363
386
|
|
|
364
|
-
return
|
|
387
|
+
return instantiate((context) => {
|
|
365
388
|
const statementSubstitutionString = statementSubstitutionStringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution),
|
|
366
389
|
string = statementSubstitutionString, ///
|
|
367
390
|
statementSubstitutionNode = instantiateStatementSubstitution(string, context),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import Substitution from "../substitution";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
-
import {
|
|
6
|
+
import { instantiate } from "../../utilities/context";
|
|
7
7
|
import { stripBracketsFromTerm } from "../../utilities/brackets";
|
|
8
8
|
import { instantiateTermSubstitution } from "../../process/instantiate";
|
|
9
9
|
import { termSubstitutionStringFromTermAndVariable } from "../../utilities/string";
|
|
@@ -124,12 +124,12 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
124
124
|
targetTermString = this.targetTerm.getString(),
|
|
125
125
|
termSubstitutionString = this.getString(); ///
|
|
126
126
|
|
|
127
|
-
context.trace(`Validating the '${termSubstitutionString}' term
|
|
127
|
+
context.trace(`Validating the '${termSubstitutionString}' term substitution's '${targetTermString}' target term...`);
|
|
128
128
|
|
|
129
129
|
const targetTermSingular = this.targetTerm.isSingular();
|
|
130
130
|
|
|
131
131
|
if (targetTermSingular) {
|
|
132
|
-
const targetTerm = this.targetTerm.validate(context, () => {
|
|
132
|
+
const targetTerm = this.targetTerm.validate(context, (targetTerm) => {
|
|
133
133
|
const validatesForwards = true;
|
|
134
134
|
|
|
135
135
|
return validatesForwards;
|
|
@@ -141,11 +141,11 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
141
141
|
targetTermValidates = true;
|
|
142
142
|
}
|
|
143
143
|
} else {
|
|
144
|
-
context.debug(`The '${termSubstitutionString}' term
|
|
144
|
+
context.debug(`The '${termSubstitutionString}' term substitution's '${targetTermString}' target term is not singular.`);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
if (targetTermValidates) {
|
|
148
|
-
context.debug(`...validated the '${termSubstitutionString}' term
|
|
148
|
+
context.debug(`...validated the '${termSubstitutionString}' term substitution's '${targetTermString}' target term...`);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
return targetTermValidates;
|
|
@@ -158,9 +158,9 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
158
158
|
replacementTermString = this.replacementTerm.getString(),
|
|
159
159
|
termSubstitutionString = this.getString(); ///
|
|
160
160
|
|
|
161
|
-
context.trace(`Validating the '${termSubstitutionString}' term
|
|
161
|
+
context.trace(`Validating the '${termSubstitutionString}' term substitution's '${replacementTermString}' replacement term...`);
|
|
162
162
|
|
|
163
|
-
const replacementTerm = this.replacementTerm.validate(context, () => {
|
|
163
|
+
const replacementTerm = this.replacementTerm.validate(context, (replacementTerm) => {
|
|
164
164
|
const validatesForwards = true;
|
|
165
165
|
|
|
166
166
|
return validatesForwards;
|
|
@@ -173,7 +173,7 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
if (replacementTermValidates) {
|
|
176
|
-
context.debug(`...validated the '${termSubstitutionString}' term
|
|
176
|
+
context.debug(`...validated the '${termSubstitutionString}' term substitution's '${replacementTermString}' replacement term...`);
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
return replacementTermValidates;
|
|
@@ -187,7 +187,7 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
187
187
|
const { name } = json;
|
|
188
188
|
|
|
189
189
|
if (this.name === name) {
|
|
190
|
-
|
|
190
|
+
instantiate((context) => {
|
|
191
191
|
const { string } = json,
|
|
192
192
|
termSubstitutionNode = instantiateTermSubstitution(string, context),
|
|
193
193
|
node = termSubstitutionNode, ///
|
|
@@ -213,7 +213,7 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
213
213
|
static fromTermAndVariable(term, variable, context) {
|
|
214
214
|
term = stripBracketsFromTerm(term, context); ///
|
|
215
215
|
|
|
216
|
-
return
|
|
216
|
+
return instantiate((context) => {
|
|
217
217
|
const termSubstitutionString = termSubstitutionStringFromTermAndVariable(term, variable),
|
|
218
218
|
string = termSubstitutionString, ///
|
|
219
219
|
termSubstitutionNode = instantiateTermSubstitution(string, context),
|
package/src/element/term.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Element } from "occam-languages";
|
|
|
4
4
|
import { arrayUtilities } from "necessary";
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
|
-
import {
|
|
7
|
+
import { instantiate } from "../utilities/context";
|
|
8
8
|
import { validateTerms } from "../utilities/validation";
|
|
9
9
|
import { instantiateTerm } from "../process/instantiate";
|
|
10
10
|
import { variablesFromTerm } from "../utilities/equivalence";
|
|
@@ -158,12 +158,14 @@ export default define(class Term extends Element {
|
|
|
158
158
|
valid = (validTerm !== null);
|
|
159
159
|
|
|
160
160
|
if (valid) {
|
|
161
|
-
|
|
161
|
+
term = validTerm; ///
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
term = validTerm; ///
|
|
163
|
+
context.debug(`...the '${termString}' term is already valid.`);
|
|
165
164
|
|
|
166
|
-
|
|
165
|
+
const validatesForward = validateForwards(term);
|
|
166
|
+
|
|
167
|
+
if (!validatesForward) {
|
|
168
|
+
term = null;
|
|
167
169
|
}
|
|
168
170
|
} else {
|
|
169
171
|
const validates = validateTerms.some((validateTerm) => { ///
|
|
@@ -188,33 +190,37 @@ export default define(class Term extends Element {
|
|
|
188
190
|
}
|
|
189
191
|
|
|
190
192
|
validateGivenType(type, context) {
|
|
191
|
-
let
|
|
193
|
+
let term;
|
|
192
194
|
|
|
193
195
|
const typeString = type.getString(),
|
|
194
196
|
termString = this.getString(); ///
|
|
195
197
|
|
|
196
198
|
context.trace(`Validating the '${termString}' term given the '${typeString}' type...`);
|
|
197
199
|
|
|
198
|
-
|
|
199
|
-
const validatesForwards = true;
|
|
200
|
+
let validatesGivenType = false;
|
|
200
201
|
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
term = this.validate(context, (term) => {
|
|
203
|
+
let validatesForwards = false;
|
|
203
204
|
|
|
204
|
-
if (term !== null) {
|
|
205
205
|
const termType = term.getType(),
|
|
206
|
-
|
|
206
|
+
termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(type);
|
|
207
207
|
|
|
208
|
-
if (
|
|
209
|
-
|
|
208
|
+
if (termTypeEqualToOrSubTypeOfType) {
|
|
209
|
+
validatesForwards = true;
|
|
210
210
|
}
|
|
211
|
+
|
|
212
|
+
return validatesForwards;
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
if (term !== null) {
|
|
216
|
+
validatesGivenType = true;
|
|
211
217
|
}
|
|
212
218
|
|
|
213
219
|
if (validatesGivenType) {
|
|
214
220
|
context.debug(`...validated the '${termString}' term given the '${typeString}' type.`);
|
|
215
221
|
}
|
|
216
222
|
|
|
217
|
-
return
|
|
223
|
+
return term;
|
|
218
224
|
}
|
|
219
225
|
|
|
220
226
|
toJSON() {
|
|
@@ -232,7 +238,7 @@ export default define(class Term extends Element {
|
|
|
232
238
|
static name = "Term";
|
|
233
239
|
|
|
234
240
|
static fromJSON(json, context) {
|
|
235
|
-
const term =
|
|
241
|
+
const term = instantiate((context) => {
|
|
236
242
|
const { string } = json,
|
|
237
243
|
termNode = instantiateTerm(string, context),
|
|
238
244
|
node = termNode, ///
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
3
5
|
import TopLevelAssertion from "../topLevelAssertion";
|
|
4
6
|
|
|
5
7
|
import { define } from "../../elements";
|
|
6
8
|
|
|
9
|
+
const { backwardsEvery } = arrayUtilities;
|
|
10
|
+
|
|
7
11
|
export default define(class Axiom extends TopLevelAssertion {
|
|
8
12
|
getAxiomNode() {
|
|
9
13
|
const node = this.getNode(),
|
|
@@ -120,7 +124,7 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
120
124
|
unifySubproof(subproof, context) {
|
|
121
125
|
let subproofUnifies = false;
|
|
122
126
|
|
|
123
|
-
const axiomString = this.getString(),
|
|
127
|
+
const axiomString = this.getString(), ///
|
|
124
128
|
subproofString = subproof.getString();
|
|
125
129
|
|
|
126
130
|
context.trace(`Unifying the '${subproofString}' subproof with the '${axiomString}' axiom...`);
|
|
@@ -130,10 +134,10 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
130
134
|
if (unconditional) {
|
|
131
135
|
context.trace(`Unable to unify the '${subproofString}' subproof with the '${axiomString}' axiom because the axiom is unconditional.`);
|
|
132
136
|
} else {
|
|
133
|
-
const
|
|
134
|
-
|
|
137
|
+
const lastStep = subproof.getLastStep(),
|
|
138
|
+
lastStepUnifies = this.unifyLastStep(lastStep, context);
|
|
135
139
|
|
|
136
|
-
if (
|
|
140
|
+
if (lastStepUnifies) {
|
|
137
141
|
const suppositions = subproof.getSuppositions(),
|
|
138
142
|
suppositionsUnify = this.unifySuppositions(suppositions, context);
|
|
139
143
|
|
|
@@ -196,7 +200,7 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
196
200
|
if (generalSuppositionsLength === specificSuppositionsLength) {
|
|
197
201
|
suppositions = specificSuppositions; ///
|
|
198
202
|
|
|
199
|
-
suppositionsUnify = suppositions
|
|
203
|
+
suppositionsUnify = backwardsEvery(suppositions, (supposition, index) => {
|
|
200
204
|
const suppositionUnifies = this.unifySupposition(supposition, index, generalContext, specificContext);
|
|
201
205
|
|
|
202
206
|
if (suppositionUnifies) {
|
|
@@ -208,32 +212,32 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
208
212
|
return suppositionsUnify;
|
|
209
213
|
}
|
|
210
214
|
|
|
211
|
-
|
|
212
|
-
let
|
|
215
|
+
unifyLastStep(lastStep, context) {
|
|
216
|
+
let lastStepUnifies = false;
|
|
213
217
|
|
|
214
|
-
const axiomString = this.getString(),
|
|
215
|
-
|
|
218
|
+
const axiomString = this.getString(), ///
|
|
219
|
+
lastStepString = lastStep.getString();
|
|
216
220
|
|
|
217
|
-
context.trace(`Unifying the '${
|
|
221
|
+
context.trace(`Unifying the '${lastStepString}' last step with the '${axiomString}' axiom...`);
|
|
218
222
|
|
|
219
|
-
const statement =
|
|
223
|
+
const statement = lastStep.getStatement(),
|
|
220
224
|
statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, context);
|
|
221
225
|
|
|
222
226
|
if (statementUnifiesWithDeduction) {
|
|
223
|
-
|
|
227
|
+
lastStepUnifies = true;
|
|
224
228
|
}
|
|
225
229
|
|
|
226
|
-
if (
|
|
227
|
-
context.debug(`...unified the '${
|
|
230
|
+
if (lastStepUnifies) {
|
|
231
|
+
context.debug(`...unified the '${lastStepString}' last step with the '${axiomString}' axiom.`);
|
|
228
232
|
}
|
|
229
233
|
|
|
230
|
-
return
|
|
234
|
+
return lastStepUnifies;
|
|
231
235
|
}
|
|
232
236
|
|
|
233
237
|
unifyTopLevelAssertion(topLevelAssertion, context) {
|
|
234
238
|
let topLevelAssertionUnifies = false;
|
|
235
239
|
|
|
236
|
-
const axiomString = this.getString(),
|
|
240
|
+
const axiomString = this.getString(), ///
|
|
237
241
|
topLevelAssertionString = topLevelAssertion.getString();
|
|
238
242
|
|
|
239
243
|
context.trace(`Unifying the '${topLevelAssertionString}' top level assertion with the '${axiomString}' axiom...`);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
import { Element, asynchronousUtilities } from "occam-languages";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { asyncRestrict } from "../utilities/context";
|
|
7
7
|
import { topLevelAssertionStringFromLabelsSuppositionsAndDeduction } from "../utilities/string";
|
|
8
8
|
import { labelsFromJSON,
|
|
9
9
|
deductionFromJSON,
|
|
@@ -59,8 +59,6 @@ export default class TopLevelAssertion extends Element {
|
|
|
59
59
|
this.hypotheses = hypotheses;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
getStatement() { return this.deduction.getStatement(); }
|
|
63
|
-
|
|
64
62
|
isHypothetical() {
|
|
65
63
|
const hypothesesLength = this.hypotheses.length,
|
|
66
64
|
hypothetical = (hypothesesLength > 0);
|
|
@@ -152,7 +150,7 @@ export default class TopLevelAssertion extends Element {
|
|
|
152
150
|
|
|
153
151
|
context.trace(`Verifying the '${topLevelAssertionString}' top level assertion...`);
|
|
154
152
|
|
|
155
|
-
await
|
|
153
|
+
await asyncRestrict(async (context) => {
|
|
156
154
|
const labelsVerify = this.verifyLabels();
|
|
157
155
|
|
|
158
156
|
if (labelsVerify) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { Element, asynchronousUtilities } from "occam-languages";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { asyncRestrict } from "../utilities/context";
|
|
6
6
|
import { topLevelMetaAssertionStringFromLabelSuppositionsAndDeduction } from "../utilities/string";
|
|
7
7
|
import { labelFromJSON,
|
|
8
8
|
labelToLabelJSON,
|
|
@@ -46,7 +46,46 @@ export default class TopLevelMetaAssertion extends Element {
|
|
|
46
46
|
return this.metaLevelSubstitutions;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
getStatement() {
|
|
49
|
+
getStatement() {
|
|
50
|
+
let statement = null;
|
|
51
|
+
|
|
52
|
+
const unconditional = this.isUnconditional();
|
|
53
|
+
|
|
54
|
+
if (unconditional) {
|
|
55
|
+
statement = this.deduction.getStatement();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return statement;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
getStatements() {
|
|
62
|
+
let statements = null;
|
|
63
|
+
|
|
64
|
+
const unconditional = this.isUnconditional();
|
|
65
|
+
|
|
66
|
+
if (!unconditional) {
|
|
67
|
+
const suppositionStatements = this.suppositions.map((supposition) => {
|
|
68
|
+
const suppositionStatement = supposition.getStatement();
|
|
69
|
+
|
|
70
|
+
return suppositionStatement;
|
|
71
|
+
}),
|
|
72
|
+
deductionStatement = this.deduction.getStatement();
|
|
73
|
+
|
|
74
|
+
statements = [
|
|
75
|
+
...suppositionStatements,
|
|
76
|
+
deductionStatement
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return statements;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
isUnconditional() {
|
|
84
|
+
const suppositionsLength = this.suppositions.length,
|
|
85
|
+
unconditional = (suppositionsLength === 0);
|
|
86
|
+
|
|
87
|
+
return unconditional;
|
|
88
|
+
}
|
|
50
89
|
|
|
51
90
|
compareReference(reference) {
|
|
52
91
|
const label = this.getLabel(),
|
|
@@ -64,7 +103,7 @@ export default class TopLevelMetaAssertion extends Element {
|
|
|
64
103
|
|
|
65
104
|
context.trace(`Verifying the '${topLevelMetaAssertionString}' top level meta assertion...`);
|
|
66
105
|
|
|
67
|
-
await
|
|
106
|
+
await asyncRestrict(async (context) => {
|
|
68
107
|
const labelVerifies = this.verifyLabel();
|
|
69
108
|
|
|
70
109
|
if (labelVerifies) {
|
package/src/element/type.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Element } from "occam-languages";
|
|
|
4
4
|
import { arrayUtilities } from "necessary";
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
|
-
import {
|
|
7
|
+
import { instantiate } from "../utilities/context";
|
|
8
8
|
import { instantiateType } from "../process/instantiate";
|
|
9
9
|
import { baseTypeFromNothing } from "../utilities/type";
|
|
10
10
|
import { nameFromTypeNode, prefixNameFromTypeNode } from "../utilities/element";
|
|
@@ -15,6 +15,7 @@ const { push, first } = arrayUtilities;
|
|
|
15
15
|
export default define(class Type extends Element {
|
|
16
16
|
constructor(context, string, node, name, prefixName, superTypes, properties, provisional) {
|
|
17
17
|
super(context, string, node);
|
|
18
|
+
|
|
18
19
|
this.name = name;
|
|
19
20
|
this.prefixName = prefixName;
|
|
20
21
|
this.superTypes = superTypes;
|
|
@@ -315,7 +316,7 @@ export default define(class Type extends Element {
|
|
|
315
316
|
static name = "Type";
|
|
316
317
|
|
|
317
318
|
static fromJSON(json, context) {
|
|
318
|
-
const type =
|
|
319
|
+
const type = instantiate((context) => {
|
|
319
320
|
const { string } = json,
|
|
320
321
|
typeNode = instantiateType(string, context),
|
|
321
322
|
node = typeNode, ///
|