occam-nominal 1.0.430 → 1.0.431
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/file/nominal.js +1 -5
- package/lib/context/mnemic.js +6 -44
- package/lib/context.js +1 -13
- package/lib/element/assertion/signature.js +10 -5
- package/lib/element/constructor/bracketed.js +1 -6
- package/lib/element/fact/step.js +2 -2
- package/lib/element/signature.js +33 -29
- package/lib/element/term.js +11 -11
- package/lib/process/unification.js +1 -2
- package/lib/process/unify.js +63 -60
- package/lib/utilities/string.js +7 -3
- package/package.json +5 -5
- package/src/context/file/nominal.js +0 -7
- package/src/context/mnemic.js +3 -69
- package/src/context.js +0 -21
- package/src/element/assertion/signature.js +11 -5
- package/src/element/constructor/bracketed.js +0 -8
- package/src/element/fact/step.js +1 -1
- package/src/element/signature.js +36 -35
- package/src/element/term.js +10 -12
- package/src/process/unification.js +0 -2
- package/src/process/unify.js +94 -83
- package/src/utilities/string.js +8 -2
package/src/process/unify.js
CHANGED
|
@@ -7,7 +7,6 @@ import { ContinuationZipPass as AsynchronousContinuationZipPass } from "occam-la
|
|
|
7
7
|
import ContinuationZipPassBase from "../pass/continuationZip"; ///
|
|
8
8
|
|
|
9
9
|
import { declare } from "../utilities/state";
|
|
10
|
-
import { reconcile } from "../utilities/context";
|
|
11
10
|
import { FRAME_META_TYPE_NAME, STATEMENT_META_TYPE_NAME } from "../metaTypeNames";
|
|
12
11
|
import { termFromTermNode, frameFromFrameNode, statementFromStatementNode } from "../utilities/element";
|
|
13
12
|
|
|
@@ -36,39 +35,39 @@ class ContinuationZipPass extends ContinuationZipPassBase {
|
|
|
36
35
|
|
|
37
36
|
class UnifyStatementPass extends AsynchronousContinuationZipPass {
|
|
38
37
|
static maps = [
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
},
|
|
38
|
+
// {
|
|
39
|
+
// generalNodeQuery: assumptionMetavariableNodeQuery,
|
|
40
|
+
// specificNodeQuery: assumptionMetavariableNodeQuery,
|
|
41
|
+
// run: (generalAssumptionMetavariableNode, specificAssumptionMetavariableNode, generalContext, specificContext, continuation) => {
|
|
42
|
+
// let context,
|
|
43
|
+
// reference,
|
|
44
|
+
// metavariableNode;
|
|
45
|
+
//
|
|
46
|
+
// context = generalContext; ///
|
|
47
|
+
//
|
|
48
|
+
// metavariableNode = generalAssumptionMetavariableNode; ///
|
|
49
|
+
//
|
|
50
|
+
// reference = context.findReferenceByMetavariableNode(metavariableNode);
|
|
51
|
+
//
|
|
52
|
+
// const metavariable = reference.getMetavariable();
|
|
53
|
+
//
|
|
54
|
+
// context = specificContext; ///
|
|
55
|
+
//
|
|
56
|
+
// metavariableNode = specificAssumptionMetavariableNode; ///
|
|
57
|
+
//
|
|
58
|
+
// reference = context.findReferenceByMetavariableNode(metavariableNode);
|
|
59
|
+
//
|
|
60
|
+
// return metavariable.unifyReference(reference, generalContext, specificContext, (referenceUnifies) => {
|
|
61
|
+
// let success = false;
|
|
62
|
+
//
|
|
63
|
+
// if (referenceUnifies) {
|
|
64
|
+
// success = true;
|
|
65
|
+
// }
|
|
66
|
+
//
|
|
67
|
+
// return continuation(success, generalContext, specificContext);
|
|
68
|
+
// });
|
|
69
|
+
// }
|
|
70
|
+
// },
|
|
72
71
|
{
|
|
73
72
|
generalNodeQuery: statementMetavariableNodeQuery,
|
|
74
73
|
specificNodeQuery: statementNodeQuery,
|
|
@@ -155,33 +154,33 @@ class UnifyStatementPass extends AsynchronousContinuationZipPass {
|
|
|
155
154
|
});
|
|
156
155
|
}
|
|
157
156
|
},
|
|
158
|
-
{
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
157
|
+
// {
|
|
158
|
+
// generalNodeQuery: signatureNodeQuery,
|
|
159
|
+
// specificNodeQuery: signatureNodeQuery,
|
|
160
|
+
// run: (generalSignatureNode, specificSignatureNode, generalContext, specificContext, continuation) => {
|
|
161
|
+
// let context;
|
|
162
|
+
//
|
|
163
|
+
// context = generalContext; ///
|
|
164
|
+
//
|
|
165
|
+
// const generalSignature = context.findSignatureBySignatureNode(generalSignatureNode);
|
|
166
|
+
//
|
|
167
|
+
// context = specificContext; ///
|
|
168
|
+
//
|
|
169
|
+
// const specificSignature = context.findSignatureBySignatureNode(specificSignatureNode);
|
|
170
|
+
//
|
|
171
|
+
// return reconcile((context) => {
|
|
172
|
+
// return generalSignature.unifySignature(specificSignature, context, (signatureUnifies) => {
|
|
173
|
+
// let success = false;
|
|
174
|
+
//
|
|
175
|
+
// if (signatureUnifies) {
|
|
176
|
+
// success = true;
|
|
177
|
+
// }
|
|
178
|
+
//
|
|
179
|
+
// return continuation(success, generalContext, specificContext);
|
|
180
|
+
// });
|
|
181
|
+
// }, context);
|
|
182
|
+
// }
|
|
183
|
+
// }
|
|
185
184
|
];
|
|
186
185
|
}
|
|
187
186
|
|
|
@@ -223,14 +222,12 @@ class UnifyMetavariablePass extends ContinuationZipPass {
|
|
|
223
222
|
];
|
|
224
223
|
}
|
|
225
224
|
|
|
226
|
-
class UnifyTermIntrinsicallyPass extends
|
|
225
|
+
class UnifyTermIntrinsicallyPass extends AsynchronousContinuationZipPass {
|
|
227
226
|
static maps = [
|
|
228
227
|
{
|
|
229
228
|
generalNodeQuery: termVariableNodeQuery,
|
|
230
229
|
specificNodeQuery: termNodeQuery,
|
|
231
230
|
run: (generalTermVariableNode, specificTermNode, generalContext, specificContext, continuation) => {
|
|
232
|
-
let success = false;
|
|
233
|
-
|
|
234
231
|
const termNode = specificTermNode, ///
|
|
235
232
|
variableNode = generalTermVariableNode; ///
|
|
236
233
|
|
|
@@ -244,20 +241,17 @@ class UnifyTermIntrinsicallyPass extends ContinuationZipPassBase {
|
|
|
244
241
|
|
|
245
242
|
context = specificContext; ///
|
|
246
243
|
|
|
247
|
-
const term = context.findTermByTermNode(termNode)
|
|
248
|
-
termUnifies = variable.unifyTerm(term, generalContext, specificContext, (context) => {
|
|
249
|
-
let termUnifies;
|
|
250
|
-
|
|
251
|
-
termUnifies = continuation(context);
|
|
244
|
+
const term = context.findTermByTermNode(termNode);
|
|
252
245
|
|
|
253
|
-
|
|
254
|
-
|
|
246
|
+
return variable.unifyTerm(term, generalContext, specificContext, (termUnifies) => {
|
|
247
|
+
let success = false;
|
|
255
248
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
249
|
+
if (termUnifies) {
|
|
250
|
+
success = true;
|
|
251
|
+
}
|
|
259
252
|
|
|
260
|
-
|
|
253
|
+
return continuation(success);
|
|
254
|
+
});
|
|
261
255
|
}
|
|
262
256
|
}
|
|
263
257
|
];
|
|
@@ -561,12 +555,20 @@ const unifyStatementPass = new UnifyStatementPass(),
|
|
|
561
555
|
unifyStatementWithCombinatorPass = new UnifyStatementWithCombinatorPass();
|
|
562
556
|
|
|
563
557
|
export function unifyStatement(generalStatement, specificStatement, generalContext, specificContext, continuation) {
|
|
558
|
+
let statementUnifies = false;
|
|
559
|
+
|
|
564
560
|
const generalStatementNode = generalStatement.getNode(),
|
|
565
561
|
specificStatementNode = specificStatement.getNode(),
|
|
566
562
|
generalNode = generalStatementNode, ///
|
|
567
563
|
specificNode = specificStatementNode; ///
|
|
568
564
|
|
|
569
|
-
return unifyStatementPass.run(generalNode, specificNode, generalContext, specificContext,
|
|
565
|
+
return unifyStatementPass.run(generalNode, specificNode, generalContext, specificContext, (success) => {
|
|
566
|
+
if (success) {
|
|
567
|
+
statementUnifies = true;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
return continuation(statementUnifies);
|
|
571
|
+
});
|
|
570
572
|
}
|
|
571
573
|
|
|
572
574
|
export function unifyMetavariable(generalMetavariable, specificMetavariable, generalContext, specificContext, continuation) {
|
|
@@ -589,23 +591,32 @@ export function unifyTermIntrinsically(generalTerm, specificTerm, generalContext
|
|
|
589
591
|
const generalTermNode = generalTerm.getNode(),
|
|
590
592
|
specificTermNode = specificTerm.getNode(),
|
|
591
593
|
generalNode = generalTermNode, ///
|
|
592
|
-
specificNode = specificTermNode
|
|
593
|
-
success = unifyTermInstrinsicallyPass.run(generalNode, specificNode, generalContext, specificContext, continuation);
|
|
594
|
+
specificNode = specificTermNode; ///
|
|
594
595
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
596
|
+
return unifyTermInstrinsicallyPass.run(generalNode, specificNode, generalContext, specificContext, (success) => {
|
|
597
|
+
if (success) {
|
|
598
|
+
termUnifiesIntrinsically = true;
|
|
599
|
+
}
|
|
598
600
|
|
|
599
|
-
|
|
601
|
+
return continuation(termUnifiesIntrinsically);
|
|
602
|
+
});
|
|
600
603
|
}
|
|
601
604
|
|
|
602
605
|
export function unifyMetavariableIntrinsically(generalMetavariable, specificMetavariable, generalContext, specificContext, continuation) {
|
|
606
|
+
let metavaraibleUnifiesIntrinsically = false;
|
|
607
|
+
|
|
603
608
|
const generalMetavariableNode = generalMetavariable.getNode(),
|
|
604
609
|
specificMetavariableNode = specificMetavariable.getNode(),
|
|
605
610
|
generalNode = generalMetavariableNode, ///
|
|
606
611
|
specificNode = specificMetavariableNode;
|
|
607
612
|
|
|
608
|
-
return unifyMetavariableIntrisicallyPass.run(generalNode, specificNode, generalContext, specificContext,
|
|
613
|
+
return unifyMetavariableIntrisicallyPass.run(generalNode, specificNode, generalContext, specificContext, (success) => {
|
|
614
|
+
if (success) {
|
|
615
|
+
metavaraibleUnifiesIntrinsically = true;
|
|
616
|
+
|
|
617
|
+
return continuation(metavaraibleUnifiesIntrinsically);
|
|
618
|
+
}
|
|
619
|
+
});
|
|
609
620
|
}
|
|
610
621
|
|
|
611
622
|
export function unifyTermWithProperty(term, property, generalContext, specificContext, continuation) {
|
package/src/utilities/string.js
CHANGED
|
@@ -3,9 +3,15 @@
|
|
|
3
3
|
import { baseTypeFromNothing } from "../utilities/type";
|
|
4
4
|
import { EMPTY_STRING, PROVISIONAL, PROVISIONALLY } from "../constants";
|
|
5
5
|
|
|
6
|
-
export function termsStringFromTerms(terms) {
|
|
6
|
+
export function termsStringFromTerms(terms, quoted = false) {
|
|
7
7
|
const termsString = terms.reduce((termsString, term) => {
|
|
8
|
-
|
|
8
|
+
let termString;
|
|
9
|
+
|
|
10
|
+
termString = term.getString();
|
|
11
|
+
|
|
12
|
+
if (quoted) {
|
|
13
|
+
termString = `'${termString}'`;
|
|
14
|
+
}
|
|
9
15
|
|
|
10
16
|
termsString = (termsString !== null) ?
|
|
11
17
|
`${termsString}, ${termString}` :
|