occam-verify-cli 1.0.871 → 1.0.873
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/mnemic.js +21 -121
- package/lib/element/assumption.js +7 -5
- package/lib/element/metavariable.js +5 -26
- package/lib/element/reference.js +3 -19
- package/lib/element/statement.js +8 -10
- package/lib/element/substitution/frame.js +8 -7
- package/lib/element/substitution/reference.js +7 -7
- package/lib/element/substitution/statement.js +5 -3
- package/lib/element/substitution/term.js +8 -6
- package/lib/process/unify.js +32 -32
- package/lib/utilities/context.js +25 -13
- package/lib/utilities/json.js +8 -4
- package/lib/utilities/validation.js +2 -2
- package/package.json +4 -4
- package/src/context/mnemic.js +10 -160
- package/src/element/assumption.js +7 -5
- package/src/element/metavariable.js +5 -36
- package/src/element/reference.js +3 -28
- package/src/element/statement.js +8 -10
- package/src/element/substitution/frame.js +9 -6
- package/src/element/substitution/reference.js +7 -7
- package/src/element/substitution/statement.js +7 -3
- package/src/element/substitution/term.js +10 -5
- package/src/process/unify.js +49 -49
- package/src/utilities/context.js +29 -13
- package/src/utilities/json.js +10 -6
- package/src/utilities/validation.js +2 -4
package/src/process/unify.js
CHANGED
|
@@ -147,6 +147,38 @@ class StatementPass extends ZipPassBase {
|
|
|
147
147
|
];
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
class IntrinsicPass extends ZipPass {
|
|
151
|
+
static maps = [
|
|
152
|
+
{
|
|
153
|
+
generalNodeQuery: termVariableNodeQuery,
|
|
154
|
+
specificNodeQuery: termNodeQuery,
|
|
155
|
+
run: (generalTermVariableNode, specificTermNode, generalContext, specificContext) => {
|
|
156
|
+
let success = false;
|
|
157
|
+
|
|
158
|
+
const termNode = specificTermNode, ///
|
|
159
|
+
variableNode = generalTermVariableNode; ///
|
|
160
|
+
|
|
161
|
+
let context;
|
|
162
|
+
|
|
163
|
+
context = generalContext; ///
|
|
164
|
+
|
|
165
|
+
const variable = context.findVariableByVariableNode(variableNode);
|
|
166
|
+
|
|
167
|
+
context = specificContext; ///
|
|
168
|
+
|
|
169
|
+
const term = context.findTermByTermNode(termNode),
|
|
170
|
+
termUnifies = variable.unifyTerm(term, generalContext, specificContext);
|
|
171
|
+
|
|
172
|
+
if (termUnifies) {
|
|
173
|
+
success = true;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return success;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
|
|
150
182
|
class CombinatorPass extends ZipPass {
|
|
151
183
|
static maps = [
|
|
152
184
|
{
|
|
@@ -370,44 +402,12 @@ class SubstitutionPass extends ZipPass {
|
|
|
370
402
|
];
|
|
371
403
|
}
|
|
372
404
|
|
|
373
|
-
class IntrinsicLevelPass extends ZipPass {
|
|
374
|
-
static maps = [
|
|
375
|
-
{
|
|
376
|
-
generalNodeQuery: termVariableNodeQuery,
|
|
377
|
-
specificNodeQuery: termNodeQuery,
|
|
378
|
-
run: (generalTermVariableNode, specificTermNode, generalContext, specificContext) => {
|
|
379
|
-
let success = false;
|
|
380
|
-
|
|
381
|
-
const termNode = specificTermNode, ///
|
|
382
|
-
variableNode = generalTermVariableNode; ///
|
|
383
|
-
|
|
384
|
-
let context;
|
|
385
|
-
|
|
386
|
-
context = generalContext; ///
|
|
387
|
-
|
|
388
|
-
const variable = context.findVariableByVariableNode(variableNode);
|
|
389
|
-
|
|
390
|
-
context = specificContext; ///
|
|
391
|
-
|
|
392
|
-
const term = context.findTermByTermNode(termNode),
|
|
393
|
-
termUnifies = variable.unifyTerm(term, generalContext, specificContext);
|
|
394
|
-
|
|
395
|
-
if (termUnifies) {
|
|
396
|
-
success = true;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
return success;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
];
|
|
403
|
-
}
|
|
404
|
-
|
|
405
405
|
const statementPass = new StatementPass(),
|
|
406
|
+
intrinsicPass = new IntrinsicPass(),
|
|
406
407
|
combinatorPass = new CombinatorPass(),
|
|
407
408
|
constructorPass = new ConstructorPass(),
|
|
408
409
|
metavariablePass = new MetavariablePass(),
|
|
409
|
-
substitutionPass = new SubstitutionPass()
|
|
410
|
-
intrinsicLevelPass = new IntrinsicLevelPass();
|
|
410
|
+
substitutionPass = new SubstitutionPass();
|
|
411
411
|
|
|
412
412
|
export function unifyStatement(generalStatement, specificStatement, generalContext, specificContext) {
|
|
413
413
|
let statementUnifies = false;
|
|
@@ -425,6 +425,20 @@ export function unifyStatement(generalStatement, specificStatement, generalConte
|
|
|
425
425
|
return statementUnifies;
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
+
export function unifyMetavariable(generalMetavariable, specificMetavariable, generalContext, specificContext) {
|
|
429
|
+
let metavariableUnifies = false;
|
|
430
|
+
|
|
431
|
+
const generalMetavariableNode = generalMetavariable.getNode(),
|
|
432
|
+
specificMetavariableNode = specificMetavariable.getNode(),
|
|
433
|
+
success = metavariablePass.run(generalMetavariableNode, specificMetavariableNode, generalContext, specificContext);
|
|
434
|
+
|
|
435
|
+
if (success) {
|
|
436
|
+
metavariableUnifies = true;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
return metavariableUnifies;
|
|
440
|
+
}
|
|
441
|
+
|
|
428
442
|
export function unifySubstitution(generalSubstitution, specificSubstitution, generalContext, specificContext) {
|
|
429
443
|
let substitutionUnifies = false;
|
|
430
444
|
|
|
@@ -441,20 +455,6 @@ export function unifySubstitution(generalSubstitution, specificSubstitution, gen
|
|
|
441
455
|
return substitutionUnifies;
|
|
442
456
|
}
|
|
443
457
|
|
|
444
|
-
export function unifyMetavariable(generalMetavariable, specificMetavariable, generalContext, specificContext) {
|
|
445
|
-
let metavariableUnifies = false;
|
|
446
|
-
|
|
447
|
-
const generalMetavariableNode = generalMetavariable.getNode(),
|
|
448
|
-
specificMetavariableNode = specificMetavariable.getNode(),
|
|
449
|
-
success = metavariablePass.run(generalMetavariableNode, specificMetavariableNode, generalContext, specificContext);
|
|
450
|
-
|
|
451
|
-
if (success) {
|
|
452
|
-
metavariableUnifies = true;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
return metavariableUnifies;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
458
|
export function unifyTermWithConstructor(term, constructor, generalContext, specificContext) {
|
|
459
459
|
let termUnifiesWithConstructor = false;
|
|
460
460
|
|
|
@@ -492,7 +492,7 @@ export function unifyMetavariableIntrinsically(generalMetavariable, specificMeta
|
|
|
492
492
|
specificMetavariableNode = specificMetavariable.getNode(),
|
|
493
493
|
generalNode = generalMetavariableNode, ///
|
|
494
494
|
specificNode = specificMetavariableNode, ///
|
|
495
|
-
success =
|
|
495
|
+
success = intrinsicPass.run(generalNode, specificNode, generalContext, specificContext);
|
|
496
496
|
|
|
497
497
|
if (success) {
|
|
498
498
|
metavariableUnifiesIntrinsically = true;
|
package/src/utilities/context.js
CHANGED
|
@@ -36,12 +36,16 @@ export function ground(innerFunction) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export function ablate(innerFunction, context) {
|
|
39
|
-
|
|
39
|
+
const released = context.isReleased();
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
if (!released) {
|
|
42
|
+
let contextNominalFileContext = (context instanceof NominalFileContext);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
while (!contextNominalFileContext) {
|
|
45
|
+
context = context.getContext();
|
|
46
|
+
|
|
47
|
+
contextNominalFileContext = (context instanceof NominalFileContext);
|
|
48
|
+
}
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
return innerFunction(context);
|
|
@@ -80,9 +84,13 @@ export function descend(innerFunction, context) {
|
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
export function attempt(innerFunction, context) {
|
|
83
|
-
const
|
|
87
|
+
const released = context.isReleased();
|
|
88
|
+
|
|
89
|
+
if (!released) {
|
|
90
|
+
const mnemicContext = MenmicContext.fromNothing(context);
|
|
84
91
|
|
|
85
|
-
|
|
92
|
+
context = mnemicContext; ///
|
|
93
|
+
}
|
|
86
94
|
|
|
87
95
|
return innerFunction(context);
|
|
88
96
|
}
|
|
@@ -143,12 +151,16 @@ export function unserialise(innerFunction, json, context) {
|
|
|
143
151
|
|
|
144
152
|
export function ablates(innerFunction, ...contexts) {
|
|
145
153
|
contexts = contexts.map((context) => { ///
|
|
146
|
-
|
|
154
|
+
const released = context.isReleased();
|
|
147
155
|
|
|
148
|
-
|
|
149
|
-
|
|
156
|
+
if (!released) {
|
|
157
|
+
let contextNominalFileContext = (context instanceof NominalFileContext);
|
|
150
158
|
|
|
151
|
-
|
|
159
|
+
while (!contextNominalFileContext) {
|
|
160
|
+
context = context.getContext();
|
|
161
|
+
|
|
162
|
+
contextNominalFileContext = (context instanceof NominalFileContext);
|
|
163
|
+
}
|
|
152
164
|
}
|
|
153
165
|
|
|
154
166
|
return context;
|
|
@@ -158,10 +170,14 @@ export function ablates(innerFunction, ...contexts) {
|
|
|
158
170
|
}
|
|
159
171
|
|
|
160
172
|
export function attempts(innerFunction, ...contexts) {
|
|
161
|
-
contexts = contexts.map((context) => {
|
|
162
|
-
const
|
|
173
|
+
contexts = contexts.map((context) => { ///
|
|
174
|
+
const released = context.isReleased();
|
|
163
175
|
|
|
164
|
-
|
|
176
|
+
if (!released) {
|
|
177
|
+
const mnemicContext = MenmicContext.fromNothing(context);
|
|
178
|
+
|
|
179
|
+
context = mnemicContext; ///
|
|
180
|
+
}
|
|
165
181
|
|
|
166
182
|
return context;
|
|
167
183
|
});
|
package/src/utilities/json.js
CHANGED
|
@@ -772,9 +772,13 @@ export function termToTermJSON(term) {
|
|
|
772
772
|
}
|
|
773
773
|
|
|
774
774
|
export function typeToTypeJSON(type) {
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
775
|
+
let typeJSON = null;
|
|
776
|
+
|
|
777
|
+
if (type !== null) {
|
|
778
|
+
const abridged = true;
|
|
779
|
+
|
|
780
|
+
typeJSON = type.toJSON(abridged);
|
|
781
|
+
}
|
|
778
782
|
|
|
779
783
|
return typeJSON;
|
|
780
784
|
}
|
|
@@ -1008,9 +1012,9 @@ export function hypothesesToHypothesesJSON(hypotheses) {
|
|
|
1008
1012
|
}
|
|
1009
1013
|
|
|
1010
1014
|
export function superTypesToSuperTypesJSON(superTypes) {
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1013
|
-
|
|
1015
|
+
const superTypesJSON = superTypes.map((superType) => {
|
|
1016
|
+
const abridged = true,
|
|
1017
|
+
superTypeJSON = superType.toJSON(abridged);
|
|
1014
1018
|
|
|
1015
1019
|
return superTypeJSON;
|
|
1016
1020
|
});
|
|
@@ -104,10 +104,8 @@ function validateStatementAsMetavariable(statement, context) {
|
|
|
104
104
|
|
|
105
105
|
let substitution;
|
|
106
106
|
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
termSubstitution = TermSubstitution.fromStatement(statement, generalContext, specificContext),
|
|
110
|
-
frameSubstitution = FrameSubstitution.fromStatement(statement, generalContext, specificContext);
|
|
107
|
+
const termSubstitution = TermSubstitution.fromStatement(statement, context),
|
|
108
|
+
frameSubstitution = FrameSubstitution.fromStatement(statement, context);
|
|
111
109
|
|
|
112
110
|
substitution = (termSubstitution || frameSubstitution);
|
|
113
111
|
|