occam-verify-cli 1.0.611 → 1.0.617
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/ephemeral.js +59 -31
- package/lib/context/file/nominal.js +45 -19
- package/lib/context/liminal.js +38 -53
- package/lib/context/scoped.js +34 -26
- package/lib/context.js +74 -46
- package/lib/element/assertion/contained.js +8 -1
- package/lib/element/assertion/defined.js +8 -1
- package/lib/element/assertion/property.js +8 -1
- package/lib/element/assertion/satisfies.js +8 -1
- package/lib/element/assertion/subproof.js +8 -1
- package/lib/element/assertion/type.js +8 -1
- package/lib/element/assertion.js +5 -9
- package/lib/element/assumption.js +21 -14
- package/lib/element/combinator/bracketed.js +8 -1
- package/lib/element/combinator.js +8 -1
- package/lib/element/conclusion.js +8 -1
- package/lib/element/constructor/bracketed.js +8 -1
- package/lib/element/constructor.js +8 -1
- package/lib/element/declaration/combinator.js +8 -1
- package/lib/element/declaration/complexType.js +8 -1
- package/lib/element/declaration/constructor.js +32 -25
- package/lib/element/declaration/metavariable.js +9 -9
- package/lib/element/declaration/simpleType.js +8 -1
- package/lib/element/declaration/typePrefix.js +8 -1
- package/lib/element/declaration/variable.js +16 -9
- package/lib/element/declaration.js +3 -7
- package/lib/element/deduction.js +8 -1
- package/lib/element/derivation.js +8 -1
- package/lib/element/equality.js +8 -1
- package/lib/element/equivalence.js +8 -1
- package/lib/element/equivalences.js +8 -1
- package/lib/element/error.js +10 -7
- package/lib/element/hypothesis.js +8 -1
- package/lib/element/judgement.js +9 -2
- package/lib/element/label.js +8 -1
- package/lib/element/metaType.js +8 -1
- package/lib/element/metavariable.js +11 -14
- package/lib/element/parameter.js +8 -1
- package/lib/element/procedureCall.js +21 -29
- package/lib/element/procedureReference.js +15 -1
- package/lib/element/proof.js +8 -1
- package/lib/element/proofAssertion/premise.js +8 -1
- package/lib/element/proofAssertion/step.js +8 -1
- package/lib/element/proofAssertion/supposition.js +8 -1
- package/lib/element/proofAssertion.js +8 -1
- package/lib/element/property.js +8 -1
- package/lib/element/propertyRelation.js +8 -1
- package/lib/element/reference.js +8 -8
- package/lib/element/rule.js +10 -7
- package/lib/element/section.js +8 -1
- package/lib/element/signature.js +8 -1
- package/lib/element/statement.js +12 -16
- package/lib/element/subDerivation.js +8 -1
- package/lib/element/subproof.js +8 -1
- package/lib/element/substitution/frame.js +11 -4
- package/lib/element/substitution/reference.js +11 -4
- package/lib/element/substitution/statement.js +16 -15
- package/lib/element/substitution/term.js +10 -3
- package/lib/element/substitution.js +3 -7
- package/lib/element/topLevelAssertion/axiom.js +8 -1
- package/lib/element/topLevelAssertion/conjecture.js +8 -1
- package/lib/element/topLevelAssertion/lemma.js +8 -1
- package/lib/element/topLevelAssertion/theorem.js +8 -1
- package/lib/element/topLevelAssertion.js +3 -7
- package/lib/element/topLevelMetaAssertion/metaLemma.js +8 -1
- package/lib/element/topLevelMetaAssertion/metatheorem.js +8 -1
- package/lib/element/type.js +8 -1
- package/lib/element/typePrefix.js +8 -1
- package/lib/element/variable.js +8 -3
- package/lib/preamble.js +1 -2
- package/lib/process/assign.js +2 -3
- package/lib/utilities/element.js +3 -3
- package/lib/utilities/substitutions.js +11 -12
- package/lib/utilities/unification.js +30 -15
- package/package.json +2 -2
- package/src/context/ephemeral.js +64 -32
- package/src/context/file/nominal.js +82 -17
- package/src/context/liminal.js +40 -65
- package/src/context/scoped.js +47 -31
- package/src/context.js +68 -40
- package/src/element/assertion/contained.js +7 -0
- package/src/element/assertion/defined.js +7 -0
- package/src/element/assertion/property.js +7 -0
- package/src/element/assertion/satisfies.js +7 -0
- package/src/element/assertion/subproof.js +7 -0
- package/src/element/assertion/type.js +7 -0
- package/src/element/assertion.js +4 -8
- package/src/element/assumption.js +11 -4
- package/src/element/combinator/bracketed.js +7 -0
- package/src/element/combinator.js +7 -0
- package/src/element/conclusion.js +7 -0
- package/src/element/constructor/bracketed.js +7 -0
- package/src/element/constructor.js +7 -0
- package/src/element/declaration/combinator.js +7 -0
- package/src/element/declaration/complexType.js +7 -0
- package/src/element/declaration/constructor.js +31 -24
- package/src/element/declaration/metavariable.js +6 -6
- package/src/element/declaration/simpleType.js +7 -0
- package/src/element/declaration/typePrefix.js +7 -0
- package/src/element/declaration/variable.js +13 -6
- package/src/element/declaration.js +1 -3
- package/src/element/deduction.js +7 -0
- package/src/element/derivation.js +7 -0
- package/src/element/equality.js +7 -0
- package/src/element/equivalence.js +8 -0
- package/src/element/equivalences.js +7 -0
- package/src/element/error.js +5 -2
- package/src/element/hypothesis.js +7 -0
- package/src/element/judgement.js +8 -2
- package/src/element/label.js +7 -0
- package/src/element/metaType.js +7 -0
- package/src/element/metavariable.js +13 -18
- package/src/element/parameter.js +7 -0
- package/src/element/procedureCall.js +21 -14
- package/src/element/procedureReference.js +13 -0
- package/src/element/proof.js +7 -0
- package/src/element/proofAssertion/premise.js +7 -0
- package/src/element/proofAssertion/step.js +7 -0
- package/src/element/proofAssertion/supposition.js +7 -0
- package/src/element/proofAssertion.js +7 -0
- package/src/element/property.js +7 -0
- package/src/element/propertyRelation.js +7 -0
- package/src/element/reference.js +8 -7
- package/src/element/rule.js +8 -9
- package/src/element/section.js +7 -0
- package/src/element/signature.js +7 -0
- package/src/element/statement.js +9 -14
- package/src/element/subDerivation.js +7 -0
- package/src/element/subproof.js +7 -0
- package/src/element/substitution/frame.js +10 -3
- package/src/element/substitution/reference.js +10 -3
- package/src/element/substitution/statement.js +11 -17
- package/src/element/substitution/term.js +9 -2
- package/src/element/substitution.js +0 -4
- package/src/element/topLevelAssertion/axiom.js +7 -0
- package/src/element/topLevelAssertion/conjecture.js +7 -0
- package/src/element/topLevelAssertion/lemma.js +7 -0
- package/src/element/topLevelAssertion/theorem.js +7 -0
- package/src/element/topLevelAssertion.js +1 -9
- package/src/element/topLevelMetaAssertion/metaLemma.js +7 -0
- package/src/element/topLevelMetaAssertion/metatheorem.js +7 -0
- package/src/element/type.js +7 -0
- package/src/element/typePrefix.js +7 -0
- package/src/element/variable.js +7 -4
- package/src/preamble.js +0 -1
- package/src/process/assign.js +1 -3
- package/src/utilities/element.js +2 -2
- package/src/utilities/substitutions.js +8 -12
- package/src/utilities/unification.js +2 -4
- package/lib/element/substitutions.js +0 -225
- package/src/element/substitutions.js +0 -84
|
@@ -259,54 +259,119 @@ export default class NominalFileContext extends FileContext {
|
|
|
259
259
|
|
|
260
260
|
addType(type) {
|
|
261
261
|
this.types.push(type);
|
|
262
|
+
|
|
263
|
+
const filePath = this.getFilePath(),
|
|
264
|
+
typeString = type.toString();
|
|
265
|
+
|
|
266
|
+
this.trace(`Added the '${typeString}' type to the '${filePath}' file context.`)
|
|
262
267
|
}
|
|
263
268
|
|
|
264
269
|
addRule(rule) {
|
|
265
270
|
this.rules.push(rule);
|
|
271
|
+
|
|
272
|
+
const filePath = this.getFilePath(),
|
|
273
|
+
ruleString = rule.toString();
|
|
274
|
+
|
|
275
|
+
this.trace(`Added the '${ruleString}' rule to the '${filePath}' file context.`)
|
|
266
276
|
}
|
|
267
277
|
|
|
268
278
|
addAxiom(axiom) {
|
|
269
279
|
this.axioms.push(axiom);
|
|
280
|
+
|
|
281
|
+
const filePath = this.getFilePath(),
|
|
282
|
+
axiomString = axiom.toString();
|
|
283
|
+
|
|
284
|
+
this.trace(`Added the '${axiomString}' axiom to the '${filePath}' file context.`)
|
|
270
285
|
}
|
|
271
286
|
|
|
272
287
|
addLemma(lemma) {
|
|
273
288
|
this.lemmas.push(lemma);
|
|
289
|
+
|
|
290
|
+
const filePath = this.getFilePath(),
|
|
291
|
+
lemmaString = lemma.toString();
|
|
292
|
+
|
|
293
|
+
this.trace(`Added the '${lemmaString}' lemma to the '${filePath}' file context.`)
|
|
274
294
|
}
|
|
275
295
|
|
|
276
296
|
addTheorem(theorem) {
|
|
277
297
|
this.theorems.push(theorem);
|
|
298
|
+
|
|
299
|
+
const filePath = this.getFilePath(),
|
|
300
|
+
theoremString = theorem.toString();
|
|
301
|
+
|
|
302
|
+
this.trace(`Added the '${theoremString}' theorem to the '${filePath}' file context.`)
|
|
278
303
|
}
|
|
279
304
|
|
|
280
305
|
addVariable(variable) {
|
|
281
306
|
this.variables.push(variable);
|
|
307
|
+
|
|
308
|
+
const filePath = this.getFilePath(),
|
|
309
|
+
variableString = variable.toString();
|
|
310
|
+
|
|
311
|
+
this.trace(`Added the '${variableString}' variable to the '${filePath}' file context.`)
|
|
282
312
|
}
|
|
283
313
|
|
|
284
314
|
addMetaLemma(metaLemma) {
|
|
285
315
|
this.metaLemmas.push(metaLemma);
|
|
316
|
+
|
|
317
|
+
const filePath = this.getFilePath(),
|
|
318
|
+
metaLemmaString = metaLemma.toString();
|
|
319
|
+
|
|
320
|
+
this.trace(`Added the '${metaLemmaString}' meta-lemma to the '${filePath}' file context.`)
|
|
286
321
|
}
|
|
287
322
|
|
|
288
323
|
addConjecture(conjecture) {
|
|
289
324
|
this.conjectures.push(conjecture);
|
|
325
|
+
|
|
326
|
+
const filePath = this.getFilePath(),
|
|
327
|
+
ocnjectureString = ocnjecture.toString();
|
|
328
|
+
|
|
329
|
+
this.trace(`Added the '${ocnjectureString}' ocnjecture to the '${filePath}' file context.`)
|
|
290
330
|
}
|
|
291
331
|
|
|
292
332
|
addCombinator(combinator) {
|
|
293
333
|
this.combinators.push(combinator);
|
|
334
|
+
|
|
335
|
+
const filePath = this.getFilePath(),
|
|
336
|
+
combinatorString = combinator.toString();
|
|
337
|
+
|
|
338
|
+
this.trace(`Added the '${combinatorString}' combinator to the '${filePath}' file context.`)
|
|
294
339
|
}
|
|
295
340
|
|
|
296
341
|
addTypePrefix(typePrefix) {
|
|
297
342
|
this.typePrefixes.push(typePrefix);
|
|
343
|
+
|
|
344
|
+
const filePath = this.getFilePath(),
|
|
345
|
+
typePrefixString = typePrefix.toString();
|
|
346
|
+
|
|
347
|
+
this.trace(`Added the '${typePrefixString}' type-prefix to the '${filePath}' file context.`)
|
|
298
348
|
}
|
|
299
349
|
|
|
300
350
|
addConstructor(constructor) {
|
|
301
351
|
this.constructors.push(constructor);
|
|
352
|
+
|
|
353
|
+
const filePath = this.getFilePath(),
|
|
354
|
+
constructorString = constructor.toString();
|
|
355
|
+
|
|
356
|
+
this.trace(`Added the '${constructorString}' constructor to the '${filePath}' file context.`)
|
|
302
357
|
}
|
|
303
358
|
|
|
304
359
|
addMetatheorem(metatheorem) {
|
|
305
360
|
this.metatheorems.push(metatheorem);
|
|
361
|
+
|
|
362
|
+
const filePath = this.getFilePath(),
|
|
363
|
+
metatheoremString = metatheorem.toString();
|
|
364
|
+
|
|
365
|
+
this.trace(`Added the '${metatheoremString}' metatheorem to the '${filePath}' file context.`)
|
|
306
366
|
}
|
|
307
367
|
|
|
308
368
|
addMetavariable(metavariable) {
|
|
309
369
|
this.metavariables.push(metavariable);
|
|
370
|
+
|
|
371
|
+
const filePath = this.getFilePath(),
|
|
372
|
+
metavariableString = metavariable.toString();
|
|
373
|
+
|
|
374
|
+
this.trace(`Added the '${metavariableString}' metavariable to the '${filePath}' file context.`)
|
|
310
375
|
}
|
|
311
376
|
|
|
312
377
|
findLabelByReference(reference, context) {
|
|
@@ -404,10 +469,10 @@ export default class NominalFileContext extends FileContext {
|
|
|
404
469
|
return theorem;
|
|
405
470
|
}
|
|
406
471
|
|
|
407
|
-
|
|
472
|
+
findProcedureByProcedureName(procedureName) {
|
|
408
473
|
const procedures = this.getProcedures(),
|
|
409
474
|
procedure = procedures.find((procedure) => {
|
|
410
|
-
const nameMatches = procedure.matchName(
|
|
475
|
+
const nameMatches = procedure.matchName(procedureName);
|
|
411
476
|
|
|
412
477
|
if (nameMatches) {
|
|
413
478
|
return true;
|
|
@@ -650,14 +715,6 @@ export default class NominalFileContext extends FileContext {
|
|
|
650
715
|
return metavariable;
|
|
651
716
|
}
|
|
652
717
|
|
|
653
|
-
isMetavariablePresent(metavariable) {
|
|
654
|
-
metavariable = this.findMetavariable(metavariable);
|
|
655
|
-
|
|
656
|
-
const metavariablePresent = (metavariable !== null);
|
|
657
|
-
|
|
658
|
-
return metavariablePresent;
|
|
659
|
-
}
|
|
660
|
-
|
|
661
718
|
isTypePresentByTypeName(typeName, includeRelease = true, includeDependencies = true) {
|
|
662
719
|
const type = this.findTypeByTypeName(typeName, includeRelease, includeDependencies),
|
|
663
720
|
typePresent = (type !== null);
|
|
@@ -714,6 +771,21 @@ export default class NominalFileContext extends FileContext {
|
|
|
714
771
|
return metavariablePresent;
|
|
715
772
|
}
|
|
716
773
|
|
|
774
|
+
isMetavariablePresent(metavariable) {
|
|
775
|
+
metavariable = this.findMetavariable(metavariable);
|
|
776
|
+
|
|
777
|
+
const metavariablePresent = (metavariable !== null);
|
|
778
|
+
|
|
779
|
+
return metavariablePresent;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
isProcedurePresentByProcedureName(procedureName) {
|
|
783
|
+
const procedure = this.findProcedureByProcedureName(procedureName),
|
|
784
|
+
procedurePresent = (procedure !== null);
|
|
785
|
+
|
|
786
|
+
return procedurePresent;
|
|
787
|
+
}
|
|
788
|
+
|
|
717
789
|
isLabelPresentByReference(reference) {
|
|
718
790
|
const labels = this.getLabels(),
|
|
719
791
|
labelPresent = labels.some((label) => {
|
|
@@ -728,13 +800,6 @@ export default class NominalFileContext extends FileContext {
|
|
|
728
800
|
return labelPresent;
|
|
729
801
|
}
|
|
730
802
|
|
|
731
|
-
isProcedurePresentByName(name) {
|
|
732
|
-
const procedure = this.findProcedureByName(name),
|
|
733
|
-
procedurePresent = (procedure !== null);
|
|
734
|
-
|
|
735
|
-
return procedurePresent;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
803
|
isMetavariablePresentByReference(reference) {
|
|
739
804
|
const metavariables = this.getMetavariables(),
|
|
740
805
|
metavariablePresent = metavariables.some((metavariable) => {
|
package/src/context/liminal.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
|
-
import {
|
|
5
|
-
import { substitutionsStringFromSubstitutions } from "../utilities/string";
|
|
4
|
+
import { metavariableNamesFromSubstitutions } from "../utilities/substitutions";
|
|
6
5
|
|
|
7
6
|
import Context from "../context";
|
|
8
7
|
|
|
9
|
-
const { find, first
|
|
8
|
+
const { find, first } = arrayUtilities;
|
|
10
9
|
|
|
11
10
|
export default class LiminalContext extends Context {
|
|
12
11
|
constructor(context, substitutions) {
|
|
@@ -62,68 +61,42 @@ export default class LiminalContext extends Context {
|
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
addSubstitution(substitution) {
|
|
65
|
-
const context = this,
|
|
64
|
+
const context = this, ///
|
|
65
|
+
substitutionA = substitution, ///
|
|
66
66
|
substitutionString = substitution.getString();
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
...this.substitutions,
|
|
70
|
-
substitution
|
|
71
|
-
];
|
|
68
|
+
context.trace(`Adding the '${substitutionString}' substitution to the liminal context...`);
|
|
72
69
|
|
|
73
|
-
|
|
74
|
-
const
|
|
70
|
+
const substitutionB = this.substitutions.find((substitution) => {
|
|
71
|
+
const substitutionB = substitution, ///
|
|
72
|
+
substitutionAEqualToSubstitutionB = substitutionA.isEqualTo(substitutionB);
|
|
75
73
|
|
|
76
|
-
if (
|
|
74
|
+
if (substitutionAEqualToSubstitutionB) {
|
|
77
75
|
return true;
|
|
78
76
|
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
context.trace(`Added the '${substitutionString}' substitution to the context.`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
addSubstitutions(substitutions) {
|
|
85
|
-
const context = this,
|
|
86
|
-
substitutionsString = substitutionsStringFromSubstitutions(substitutions);
|
|
87
|
-
|
|
88
|
-
this.substitutions = [ ///
|
|
89
|
-
...this.substitutions,
|
|
90
|
-
...substitutions
|
|
91
|
-
];
|
|
92
|
-
|
|
93
|
-
compress(this.substitutions, (substitutionA, substitutionB) => {
|
|
94
|
-
const substitutionAEqualToAssertionB = substitutionA.isEqualTo(substitutionB);
|
|
77
|
+
}) || null;
|
|
95
78
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
79
|
+
if (substitutionB !== null) {
|
|
80
|
+
context.trace(`The '${substitutionString}' substitution has already been added to the liminal context.`);
|
|
81
|
+
} else {
|
|
82
|
+
this.substitutions.push(substitution);
|
|
100
83
|
|
|
101
|
-
|
|
84
|
+
context.debug(`...added the '${substitutionString}' substitution to the liminal context.`);
|
|
85
|
+
}
|
|
102
86
|
}
|
|
103
87
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
substitutionString = substitution.getString();
|
|
108
|
-
|
|
109
|
-
prune(this.substitutions, (substitution) => {
|
|
110
|
-
const substitutionB = substitution,
|
|
111
|
-
substitutionAEqualTosubstitutionB = substitutionA.isEqualTo(substitutionB);
|
|
112
|
-
|
|
113
|
-
if (!substitutionAEqualTosubstitutionB) {
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
88
|
+
addSubstitutions(substitutions) {
|
|
89
|
+
substitutions.forEach((substitution) => {
|
|
90
|
+
this.addSubstitution(substitution);
|
|
116
91
|
});
|
|
117
|
-
|
|
118
|
-
context.trace(`Removed the '${substitutionString}' substitution to the context.`);
|
|
119
92
|
}
|
|
120
93
|
|
|
121
94
|
resolveSubstitutions(generalContext, specificContext) {
|
|
122
95
|
const substitutions = this.getSubstitutions(),
|
|
123
|
-
|
|
96
|
+
metavariableNames = metavariableNamesFromSubstitutions(substitutions);
|
|
124
97
|
|
|
125
|
-
|
|
126
|
-
const complexSubstitutions = this.
|
|
98
|
+
metavariableNames.forEach((metavariableName) => {
|
|
99
|
+
const complexSubstitutions = this.findComplexSubstitutionsByMetavariableName(metavariableName),
|
|
127
100
|
complexSubstitutionsResolved = complexSubstitutions.every((complexSubstitution) => {
|
|
128
101
|
const substitution = complexSubstitution, ///
|
|
129
102
|
resolved = substitution.isResolved();
|
|
@@ -139,11 +112,11 @@ export default class LiminalContext extends Context {
|
|
|
139
112
|
});
|
|
140
113
|
}
|
|
141
114
|
|
|
142
|
-
areSubstitutionsResolved(
|
|
115
|
+
areSubstitutionsResolved() {
|
|
143
116
|
const substitutions = this.getSubstitutions(),
|
|
144
|
-
|
|
145
|
-
resolved =
|
|
146
|
-
const complexSubstitutions = this.
|
|
117
|
+
metavariableNames = metavariableNamesFromSubstitutions(substitutions),
|
|
118
|
+
resolved = metavariableNames.every((metavariableName) => {
|
|
119
|
+
const complexSubstitutions = this.findComplexSubstitutionsByMetavariableName(metavariableName),
|
|
147
120
|
complexSubstitutionsResolved = complexSubstitutions.every((complexSubstitution) => {
|
|
148
121
|
const complexSubstitutionResolved = complexSubstitution.isResolved();
|
|
149
122
|
|
|
@@ -165,6 +138,8 @@ export default class LiminalContext extends Context {
|
|
|
165
138
|
context = this.getContext();
|
|
166
139
|
}
|
|
167
140
|
|
|
141
|
+
context.debug(`Commiting the limiinal context`);
|
|
142
|
+
|
|
168
143
|
context.addSubstitutions(this.substitutions);
|
|
169
144
|
}
|
|
170
145
|
|
|
@@ -213,15 +188,15 @@ export default class LiminalContext extends Context {
|
|
|
213
188
|
return substitution;
|
|
214
189
|
}
|
|
215
190
|
|
|
216
|
-
|
|
191
|
+
findSimpleSubstitutionByMetavariableName(metavariableName) {
|
|
217
192
|
const simpleSubstitution = this.findSubstitution((substitution) => {
|
|
218
193
|
const substitutionSimple = substitution.isSimple();
|
|
219
194
|
|
|
220
195
|
if (substitutionSimple) {
|
|
221
196
|
const simpleSubstitution = substitution, ///
|
|
222
|
-
|
|
197
|
+
simpleSubstitutionMatchesMetavariableName = simpleSubstitution.matchMetavariableName(metavariableName);
|
|
223
198
|
|
|
224
|
-
if (
|
|
199
|
+
if (simpleSubstitutionMatchesMetavariableName) {
|
|
225
200
|
return true;
|
|
226
201
|
}
|
|
227
202
|
}
|
|
@@ -230,21 +205,21 @@ export default class LiminalContext extends Context {
|
|
|
230
205
|
return simpleSubstitution;
|
|
231
206
|
}
|
|
232
207
|
|
|
233
|
-
|
|
234
|
-
const
|
|
208
|
+
findComplexSubstitutionsByMetavariableName(metavariableName) {
|
|
209
|
+
const complexSubstitution = this.findSubstitutions((substitution) => {
|
|
235
210
|
const substitutionComplex = substitution.isComplex();
|
|
236
211
|
|
|
237
212
|
if (substitutionComplex) {
|
|
238
|
-
const complexSubstitution = substitution,
|
|
239
|
-
|
|
213
|
+
const complexSubstitution = substitution, ///
|
|
214
|
+
complexSubstitutionMatchesMetavariableName = complexSubstitution.matchMetavariableName(metavariableName);
|
|
240
215
|
|
|
241
|
-
if (
|
|
216
|
+
if (complexSubstitutionMatchesMetavariableName) {
|
|
242
217
|
return true;
|
|
243
218
|
}
|
|
244
219
|
}
|
|
245
|
-
});
|
|
220
|
+
}) || null;
|
|
246
221
|
|
|
247
|
-
return
|
|
222
|
+
return complexSubstitution;
|
|
248
223
|
}
|
|
249
224
|
|
|
250
225
|
findSubstitutionByMetavariableNameAndSubstitution(metavariableName, substitution) {
|
|
@@ -266,8 +241,8 @@ export default class LiminalContext extends Context {
|
|
|
266
241
|
return substitution;
|
|
267
242
|
}
|
|
268
243
|
|
|
269
|
-
|
|
270
|
-
const simpleSubstitution = this.
|
|
244
|
+
isSimpleSubstitutionPresentByMetavariableName(metavariableName) {
|
|
245
|
+
const simpleSubstitution = this.findSimpleSubstitutionByMetavariableName(metavariableName),
|
|
271
246
|
simpleSubstitutionPresent = (simpleSubstitution !== null);
|
|
272
247
|
|
|
273
248
|
return simpleSubstitutionPresent;
|
package/src/context/scoped.js
CHANGED
|
@@ -109,77 +109,93 @@ class ScopedContext extends Context {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
addEquality(equality) {
|
|
112
|
-
let equalityAdded;
|
|
112
|
+
let equalityAdded = false;
|
|
113
113
|
|
|
114
|
-
const
|
|
114
|
+
const context = this, ///
|
|
115
|
+
equalityString = equality.getString();
|
|
116
|
+
|
|
117
|
+
context.trace(`Adding the '${equalityString}' equality to the scoped context...`);
|
|
118
|
+
|
|
119
|
+
const equalityRelfexive = equality.isReflexive();
|
|
115
120
|
|
|
116
|
-
if (
|
|
121
|
+
if (equalityRelfexive) {
|
|
122
|
+
context.trace(`The '${equalityString}' equality is reflexive and will not added to the scoped context.`);
|
|
123
|
+
} else {
|
|
117
124
|
const { Equivalence } = elements,
|
|
118
125
|
equivalence = Equivalence.fromEquality(equality),
|
|
119
126
|
context = this; ///
|
|
120
127
|
|
|
121
128
|
this.equivalences = this.equivalences.mergedWithEquivalence(equivalence, context);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
equalityAdded = true;
|
|
125
129
|
|
|
126
|
-
|
|
127
|
-
const context = this, ///
|
|
128
|
-
equalityString = equality.getString();
|
|
130
|
+
equalityAdded = true;
|
|
129
131
|
|
|
130
|
-
context.
|
|
132
|
+
context.debug(`...added the '${equalityString}' equality to the scoped context.`);
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
return equalityAdded;
|
|
134
136
|
}
|
|
135
137
|
|
|
136
|
-
addVariable(variable
|
|
137
|
-
|
|
138
|
+
addVariable(variable) {
|
|
139
|
+
const context = this, ///
|
|
140
|
+
variableA = variable, ///
|
|
141
|
+
variableString = variable.getString();
|
|
138
142
|
|
|
139
|
-
|
|
140
|
-
variablePresent = this.isVariablePresentByVariableIdentifier(variableIdentifier, nested);
|
|
143
|
+
context.trace(`Adding the '${variableString}' variable to the scoped context...`);
|
|
141
144
|
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
const variableB = this.variables.find((variable) => {
|
|
146
|
+
const variableB = variable, ///
|
|
147
|
+
variableAComparesToVariableB = variableA.compare(variableB);
|
|
144
148
|
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
if (variableAComparesToVariableB) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
}) || null;
|
|
147
153
|
|
|
148
|
-
if (
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
if (variableB !== null) {
|
|
155
|
+
context.trace(`The '${variableString}' variable has already been added to the scoped context.`);
|
|
156
|
+
} else {
|
|
157
|
+
this.variables.push(variable);
|
|
151
158
|
|
|
152
|
-
context.
|
|
159
|
+
context.debug(`...added the '${variableString}' variable to the scoped context.`);
|
|
153
160
|
}
|
|
154
|
-
|
|
155
|
-
return variableAdded;
|
|
156
161
|
}
|
|
157
162
|
|
|
158
163
|
addJudgement(judgement) {
|
|
159
164
|
let judgementAdded = false;
|
|
160
165
|
|
|
166
|
+
const context = this, ///
|
|
167
|
+
judgementString = judgement.getString();
|
|
168
|
+
|
|
169
|
+
context.trace(`Adding the '${judgementString}' judgement to the scoped context...`);
|
|
170
|
+
|
|
161
171
|
const metavariable = judgement.getMetavariable(),
|
|
162
172
|
metavariableName = metavariable.getMetavariableName(),
|
|
163
173
|
judgementPresent = this.isJudgementPresentByMetavariableName(metavariableName);
|
|
164
174
|
|
|
165
|
-
if (
|
|
175
|
+
if (judgementPresent) {
|
|
176
|
+
const metavariableString = metavariable.getString();
|
|
177
|
+
|
|
178
|
+
context.trace(`A '${judgementString}' judgement for the '${metavariableString}' metavariable is already present.`);
|
|
179
|
+
} else {
|
|
166
180
|
this.judgements.push(judgement);
|
|
167
181
|
|
|
168
182
|
judgementAdded = true;
|
|
169
|
-
}
|
|
170
183
|
|
|
171
|
-
|
|
172
|
-
const context = this, ///
|
|
173
|
-
judgementString = judgement.getString();
|
|
174
|
-
|
|
175
|
-
context.trace(`Added the '${judgementString}' judgement.`)
|
|
184
|
+
context.debug(`...added the '${judgementString}' judgement to the scoped context.`);
|
|
176
185
|
}
|
|
177
186
|
|
|
178
187
|
return judgementAdded;
|
|
179
188
|
}
|
|
180
189
|
|
|
181
190
|
addSubproofOrProofAssertion(subproofOrProofAssertion) {
|
|
191
|
+
const context = this, ///
|
|
192
|
+
subproofOrProofAssertionString = subproofOrProofAssertion.getString();
|
|
193
|
+
|
|
194
|
+
context.trace(`Adding the '${subproofOrProofAssertionString}' subproof or proof assertion to the scoped context...`);
|
|
195
|
+
|
|
182
196
|
this.subproofOrProofAssertions.push(subproofOrProofAssertion);
|
|
197
|
+
|
|
198
|
+
context.debug(`...added the '${subproofOrProofAssertionString}' subproof or proof assertion to the scoped context.`);
|
|
183
199
|
}
|
|
184
200
|
|
|
185
201
|
findEquivalenceByTerm(term) { return this.equivalences.findEquivalenceByTerm(term); }
|