occam-verify-cli 1.0.905 → 1.0.910
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.js +5 -1
- package/lib/element/assertion/contained.js +6 -3
- package/lib/element/assertion/defined.js +6 -3
- package/lib/element/assertion/property.js +6 -3
- package/lib/element/assertion/satisfies.js +25 -8
- package/lib/element/assertion/subproof.js +5 -3
- package/lib/element/assertion/type.js +6 -3
- package/lib/element/assumption/metaLevel.js +5 -3
- package/lib/element/assumption.js +6 -3
- package/lib/element/equality.js +6 -3
- package/lib/element/frame.js +8 -5
- package/lib/element/judgement.js +6 -3
- package/lib/element/metavariable.js +8 -5
- package/lib/element/property.js +12 -5
- package/lib/element/propertyRelation.js +6 -3
- package/lib/element/reference.js +8 -4
- package/lib/element/signature.js +73 -60
- package/lib/element/statement.js +7 -3
- package/lib/element/substitution/frame.js +7 -4
- package/lib/element/substitution/reference.js +7 -4
- package/lib/element/substitution/statement.js +7 -4
- package/lib/element/substitution/term.js +6 -4
- package/lib/element/term.js +26 -7
- package/lib/element/topLevelAssertion/axiom.js +14 -16
- package/lib/element/variable.js +2 -2
- package/lib/process/unify.js +56 -24
- package/lib/utilities/element.js +3 -14
- package/package.json +4 -4
- package/src/context.js +7 -0
- package/src/element/assertion/contained.js +8 -4
- package/src/element/assertion/defined.js +8 -4
- package/src/element/assertion/property.js +8 -4
- package/src/element/assertion/satisfies.js +34 -9
- package/src/element/assertion/subproof.js +6 -4
- package/src/element/assertion/type.js +8 -4
- package/src/element/assumption/metaLevel.js +6 -4
- package/src/element/assumption.js +8 -4
- package/src/element/equality.js +8 -4
- package/src/element/frame.js +10 -7
- package/src/element/judgement.js +8 -4
- package/src/element/metavariable.js +10 -7
- package/src/element/property.js +14 -6
- package/src/element/propertyRelation.js +8 -4
- package/src/element/reference.js +11 -5
- package/src/element/signature.js +118 -37
- package/src/element/statement.js +9 -3
- package/src/element/substitution/frame.js +9 -5
- package/src/element/substitution/reference.js +9 -5
- package/src/element/substitution/statement.js +9 -5
- package/src/element/substitution/term.js +7 -5
- package/src/element/term.js +39 -9
- package/src/element/topLevelAssertion/axiom.js +23 -26
- package/src/element/variable.js +2 -2
- package/src/process/unify.js +84 -35
- package/src/utilities/element.js +3 -20
package/src/element/signature.js
CHANGED
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
import { arrayUtilities } from "necessary";
|
|
5
5
|
|
|
6
|
-
import elements from "../elements";
|
|
7
|
-
|
|
8
6
|
import { define } from "../elements";
|
|
9
7
|
import { instantiateSignature } from "../process/instantiate";
|
|
10
8
|
import { termsFromSignatureNode } from "../utilities/element";
|
|
11
|
-
import { attempt, serialise, unserialise, instantiate } from "../utilities/context";
|
|
9
|
+
import { attempt, reconcile, serialise, unserialise, instantiate } from "../utilities/context";
|
|
12
10
|
|
|
13
11
|
const { match, compare, correlate } = arrayUtilities;
|
|
14
12
|
|
|
@@ -30,6 +28,27 @@ export default define(class Signature extends Element {
|
|
|
30
28
|
return signatureNode;
|
|
31
29
|
}
|
|
32
30
|
|
|
31
|
+
getLength() {
|
|
32
|
+
const termsLength = this.terms.length,
|
|
33
|
+
length = termsLength; ///
|
|
34
|
+
|
|
35
|
+
return length;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getTerm(index) {
|
|
39
|
+
const term = this.terms[index];
|
|
40
|
+
|
|
41
|
+
return term;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
findValidSignature(context) {
|
|
45
|
+
const signatureNode = this.getSignatureNode(),
|
|
46
|
+
signature = context.findSignatureBySignatureNode(signatureNode),
|
|
47
|
+
validSignature = signature; ///
|
|
48
|
+
|
|
49
|
+
return validSignature;
|
|
50
|
+
}
|
|
51
|
+
|
|
33
52
|
verify(context) {
|
|
34
53
|
let verifies = false;
|
|
35
54
|
|
|
@@ -50,12 +69,60 @@ export default define(class Signature extends Element {
|
|
|
50
69
|
}, context);
|
|
51
70
|
|
|
52
71
|
if (verifies) {
|
|
53
|
-
context.debug(`...
|
|
72
|
+
context.debug(`...validated the '${signatureString}' signature.`);
|
|
54
73
|
}
|
|
55
74
|
|
|
56
75
|
return verifies;
|
|
57
76
|
}
|
|
58
77
|
|
|
78
|
+
validate(context) {
|
|
79
|
+
let signature = null;
|
|
80
|
+
|
|
81
|
+
const signatureString = this.getString(); ///
|
|
82
|
+
|
|
83
|
+
context.trace(`Validating the '${signatureString}' signature...`);
|
|
84
|
+
|
|
85
|
+
let validates = false;
|
|
86
|
+
|
|
87
|
+
const validSignature = this.findValidSignature(context);
|
|
88
|
+
|
|
89
|
+
if (validSignature) {
|
|
90
|
+
signature = validSignature; ///
|
|
91
|
+
|
|
92
|
+
context.debug(`...the '${signatureString}' signature is already valid.`);
|
|
93
|
+
} else {
|
|
94
|
+
const specificContext = context; ///
|
|
95
|
+
|
|
96
|
+
context = this.getContext();
|
|
97
|
+
|
|
98
|
+
attempt((context) => {
|
|
99
|
+
const termsValidate = this.validateTerms(context);
|
|
100
|
+
|
|
101
|
+
if (termsValidate !== null) {
|
|
102
|
+
validates = true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (validates) {
|
|
106
|
+
this.commit(context);
|
|
107
|
+
}
|
|
108
|
+
}, context);
|
|
109
|
+
|
|
110
|
+
context = specificContext; ///
|
|
111
|
+
|
|
112
|
+
if (validates) {
|
|
113
|
+
signature = this; ///
|
|
114
|
+
|
|
115
|
+
context.addSignature(signature);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (validates) {
|
|
120
|
+
context.debug(`...validated the '${signatureString}' signature.`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return signature;
|
|
124
|
+
}
|
|
125
|
+
|
|
59
126
|
validateTerms(context) {
|
|
60
127
|
let termsValidate;
|
|
61
128
|
|
|
@@ -90,40 +157,54 @@ export default define(class Signature extends Element {
|
|
|
90
157
|
return termsValidate
|
|
91
158
|
}
|
|
92
159
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
160
|
+
unifySignature(signature, context) {
|
|
161
|
+
let signatureUnifies = false;
|
|
162
|
+
|
|
163
|
+
const generalSignature = this,
|
|
164
|
+
specificSignature = signature, ///
|
|
165
|
+
generalSignatureString = generalSignature.getString(),
|
|
166
|
+
specificSignatureString = specificSignature.getString();
|
|
167
|
+
|
|
168
|
+
context.trace(`Unifying the '${specificSignatureString}' signature with the '${generalSignatureString}' signature...`);
|
|
169
|
+
|
|
170
|
+
context = specificSignature.getContext();
|
|
171
|
+
|
|
172
|
+
const specificContext = context; ///
|
|
173
|
+
|
|
174
|
+
context = this.getContext();
|
|
175
|
+
|
|
176
|
+
const generalContext = context; ///
|
|
177
|
+
|
|
178
|
+
context = specificContext; ///
|
|
179
|
+
|
|
180
|
+
reconcile((specificContext) => {
|
|
181
|
+
const generalSignatureTerms = generalSignature.getTerms(),
|
|
182
|
+
specificSignatureTerms = specificSignature.getTerms(),
|
|
183
|
+
generalTerms = generalSignatureTerms, ///
|
|
184
|
+
specificTerms = specificSignatureTerms; ///
|
|
185
|
+
|
|
186
|
+
signatureUnifies = match(generalTerms, specificTerms, (generalTerm, specificTerm) => {
|
|
187
|
+
let termUnifies;
|
|
188
|
+
|
|
189
|
+
reconcile((specificContext) => {
|
|
190
|
+
termUnifies = generalTerm.unifyTerm(specificTerm, generalContext, specificContext);
|
|
191
|
+
|
|
192
|
+
if (termUnifies) {
|
|
193
|
+
specificContext.commit();
|
|
194
|
+
}
|
|
195
|
+
}, specificContext);
|
|
196
|
+
|
|
197
|
+
if (termUnifies) {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}, specificContext);
|
|
202
|
+
|
|
203
|
+
if (signatureUnifies) {
|
|
204
|
+
context.debug(`...unified the '${specificSignatureString}' signature with the '${generalSignatureString}' signature.`);
|
|
205
|
+
}
|
|
125
206
|
|
|
126
|
-
return
|
|
207
|
+
return signatureUnifies;
|
|
127
208
|
}
|
|
128
209
|
|
|
129
210
|
compareSubstitutions(substitutions, context) {
|
package/src/element/statement.js
CHANGED
|
@@ -192,14 +192,18 @@ export default define(class Statement extends Element {
|
|
|
192
192
|
|
|
193
193
|
context.trace(`Validating the '${statementString}' statement...`);
|
|
194
194
|
|
|
195
|
+
let validates;
|
|
196
|
+
|
|
195
197
|
const validStatement = this.findValidStatment(context);
|
|
196
198
|
|
|
197
199
|
if (validStatement !== null) {
|
|
200
|
+
validates = true;
|
|
201
|
+
|
|
198
202
|
statement = validStatement; ///
|
|
199
203
|
|
|
200
204
|
context.debug(`...the '${statementString}' statement is already valid.`);
|
|
201
205
|
} else {
|
|
202
|
-
|
|
206
|
+
validates = validateStatements.some((validateStatement) => {
|
|
203
207
|
const statement = this, ///
|
|
204
208
|
statementValidates = validateStatement(statement, context);
|
|
205
209
|
|
|
@@ -212,11 +216,13 @@ export default define(class Statement extends Element {
|
|
|
212
216
|
statement = this; ///
|
|
213
217
|
|
|
214
218
|
context.addStatement(statement);
|
|
215
|
-
|
|
216
|
-
context.debug(`...validated the '${statementString}' statement.`);
|
|
217
219
|
}
|
|
218
220
|
}
|
|
219
221
|
|
|
222
|
+
if (validates) {
|
|
223
|
+
context.debug(`...validated the '${statementString}' statement.`);
|
|
224
|
+
}
|
|
225
|
+
|
|
220
226
|
return statement;
|
|
221
227
|
}
|
|
222
228
|
|
|
@@ -82,6 +82,8 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
82
82
|
const validSubstitution = this.findValidSubstitution(context);
|
|
83
83
|
|
|
84
84
|
if (validSubstitution) {
|
|
85
|
+
validates = true;
|
|
86
|
+
|
|
85
87
|
frameSubstitution = validSubstitution; ///
|
|
86
88
|
|
|
87
89
|
context.debug(`...the '${frameSubstitutionString}' frame substitution is already valid.`);
|
|
@@ -104,15 +106,17 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
104
106
|
this.commit(generalContext, specificContext);
|
|
105
107
|
}
|
|
106
108
|
}, generalContext, specificContext);
|
|
107
|
-
}
|
|
108
109
|
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
if (validates) {
|
|
111
|
+
const substitution = this; ///
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
frameSubstitution = substitution; ///
|
|
113
114
|
|
|
114
|
-
|
|
115
|
+
context.addSubstitution(substitution);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
115
118
|
|
|
119
|
+
if (validates) {
|
|
116
120
|
context.debug(`...validated the '${frameSubstitutionString}' frame substitution.`);
|
|
117
121
|
}
|
|
118
122
|
|
|
@@ -99,6 +99,8 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
99
99
|
const validSubstitution = this.findValidSubstitution(context);
|
|
100
100
|
|
|
101
101
|
if (validSubstitution) {
|
|
102
|
+
validates = true;
|
|
103
|
+
|
|
102
104
|
referenceSubstitution = validSubstitution; ///
|
|
103
105
|
|
|
104
106
|
context.debug(`...the '${referenceSubstitutionString}' reference substitution is already valid.`);
|
|
@@ -121,15 +123,17 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
121
123
|
this.commit(generalContext, specificContext);
|
|
122
124
|
}
|
|
123
125
|
}, generalContext, specificContext);
|
|
124
|
-
}
|
|
125
126
|
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
if (validates) {
|
|
128
|
+
const substitution = this; ///
|
|
128
129
|
|
|
129
|
-
|
|
130
|
+
referenceSubstitution = substitution; ///
|
|
130
131
|
|
|
131
|
-
|
|
132
|
+
context.addSubstitution(substitution);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
132
135
|
|
|
136
|
+
if (validates) {
|
|
133
137
|
context.debug(`...validated the '${referenceSubstitutionString}' reference substitution.`);
|
|
134
138
|
}
|
|
135
139
|
|
|
@@ -95,6 +95,8 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
95
95
|
const validSubstitution = this.findValidSubstitution(context);
|
|
96
96
|
|
|
97
97
|
if (validSubstitution) {
|
|
98
|
+
validates = true;
|
|
99
|
+
|
|
98
100
|
statementSubstitution = validSubstitution; ///
|
|
99
101
|
|
|
100
102
|
context.debug(`...the '${statementSubstitutionString}' statement substitution is already valid.`);
|
|
@@ -121,15 +123,17 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
121
123
|
this.commit(generalContext, specificContext);
|
|
122
124
|
}
|
|
123
125
|
}, generalContext, specificContext);
|
|
124
|
-
}
|
|
125
126
|
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
if (validates) {
|
|
128
|
+
const substitution = this; ///
|
|
128
129
|
|
|
129
|
-
|
|
130
|
+
statementSubstitution = substitution; ///
|
|
130
131
|
|
|
131
|
-
|
|
132
|
+
context.addSubstitution(substitution);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
132
135
|
|
|
136
|
+
if (validates) {
|
|
133
137
|
context.debug(`...validated the '${statementSubstitutionString}' statement substitution.`);
|
|
134
138
|
}
|
|
135
139
|
|
|
@@ -107,15 +107,17 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
107
107
|
this.commit(generalContext, specificContext);
|
|
108
108
|
}
|
|
109
109
|
}, generalContext, specificContext);
|
|
110
|
-
}
|
|
111
110
|
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
if (validates) {
|
|
112
|
+
const substitution = this; ///
|
|
114
113
|
|
|
115
|
-
|
|
114
|
+
termSubstitution = substitution; ///
|
|
116
115
|
|
|
117
|
-
|
|
116
|
+
context.addSubstitution(substitution);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
118
119
|
|
|
120
|
+
if (validates) {
|
|
119
121
|
context.debug(`...validated the '${termSubstitutionString}' term substitution.`);
|
|
120
122
|
}
|
|
121
123
|
|
package/src/element/term.js
CHANGED
|
@@ -8,6 +8,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";
|
|
11
|
+
import { unifyTermIntrinsically } from "../process/unify";
|
|
11
12
|
import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
|
|
12
13
|
|
|
13
14
|
const { filter } = arrayUtilities;
|
|
@@ -172,21 +173,24 @@ export default define(class Term extends Element {
|
|
|
172
173
|
|
|
173
174
|
context.trace(`Validating the '${termString}' term...`);
|
|
174
175
|
|
|
175
|
-
|
|
176
|
-
valid = (validTerm !== null);
|
|
176
|
+
let validates = false;
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
term = validTerm; ///
|
|
178
|
+
const validTerm = this.findValidTerm(context);
|
|
180
179
|
|
|
181
|
-
|
|
180
|
+
if (validTerm !== null) {
|
|
181
|
+
term = validTerm; ///
|
|
182
182
|
|
|
183
183
|
const validatesForward = validateForwards(term);
|
|
184
184
|
|
|
185
|
-
if (
|
|
185
|
+
if (validatesForward) {
|
|
186
|
+
validates = true;
|
|
187
|
+
|
|
188
|
+
context.debug(`...the '${termString}' term is already valid.`);
|
|
189
|
+
} else {
|
|
186
190
|
term = null;
|
|
187
191
|
}
|
|
188
192
|
} else {
|
|
189
|
-
|
|
193
|
+
validates = validateTerms.some((validateTerm) => { ///
|
|
190
194
|
const term = this, ///
|
|
191
195
|
termValidates = validateTerm(term, context, validateForwards);
|
|
192
196
|
|
|
@@ -199,11 +203,13 @@ export default define(class Term extends Element {
|
|
|
199
203
|
term = this; ///
|
|
200
204
|
|
|
201
205
|
context.addTerm(term);
|
|
202
|
-
|
|
203
|
-
context.debug(`...validated the '${termString}' term.`);
|
|
204
206
|
}
|
|
205
207
|
}
|
|
206
208
|
|
|
209
|
+
if (validates) {
|
|
210
|
+
context.debug(`...validated the '${termString}' term.`);
|
|
211
|
+
}
|
|
212
|
+
|
|
207
213
|
return term;
|
|
208
214
|
}
|
|
209
215
|
|
|
@@ -241,6 +247,30 @@ export default define(class Term extends Element {
|
|
|
241
247
|
return term;
|
|
242
248
|
}
|
|
243
249
|
|
|
250
|
+
unifyTerm(term, generalContext, specificContext) {
|
|
251
|
+
let termUnifies = false;
|
|
252
|
+
|
|
253
|
+
const context = specificContext, ///
|
|
254
|
+
generalTerm = this,
|
|
255
|
+
specificTerm = term,
|
|
256
|
+
generalTermString = generalTerm.getString(),
|
|
257
|
+
specifixTermString = specificTerm.getString();
|
|
258
|
+
|
|
259
|
+
context.trace(`Unifying the '${specifixTermString}' term with the '${generalTermString}' term...`);
|
|
260
|
+
|
|
261
|
+
const termUnifiesIntrinsically = unifyTermIntrinsically(generalTerm, specificTerm, generalContext, specificContext);
|
|
262
|
+
|
|
263
|
+
if (termUnifiesIntrinsically) {
|
|
264
|
+
termUnifies = true;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (termUnifies) {
|
|
268
|
+
context.debug(`...unified the '${specifixTermString}' term with the '${generalTermString}' term.`);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return termUnifies;
|
|
272
|
+
}
|
|
273
|
+
|
|
244
274
|
toJSON() {
|
|
245
275
|
const typeJSON = typeToTypeJSON(this.type),
|
|
246
276
|
string = this.getString(), ///
|
|
@@ -23,32 +23,6 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
23
23
|
return satisfiable;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
compareSignature(signature, context) {
|
|
27
|
-
let comparesToSignature = false;
|
|
28
|
-
|
|
29
|
-
const satisfiable = this.isSatisfiable();
|
|
30
|
-
|
|
31
|
-
if (satisfiable) {
|
|
32
|
-
const signatureA = signature; ///
|
|
33
|
-
|
|
34
|
-
signature = this.getSignature()
|
|
35
|
-
|
|
36
|
-
const signatureB = signature, ///
|
|
37
|
-
specificContext = context; ///
|
|
38
|
-
|
|
39
|
-
context = this.getContext();
|
|
40
|
-
|
|
41
|
-
const generalContext = context, ///
|
|
42
|
-
signatureAComparesToSignatureB = signatureA.compareSignature(signatureB, generalContext, specificContext);
|
|
43
|
-
|
|
44
|
-
if (signatureAComparesToSignatureB) {
|
|
45
|
-
comparesToSignature = true;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return comparesToSignature;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
26
|
async verify(context) {
|
|
53
27
|
let verifies;
|
|
54
28
|
|
|
@@ -242,6 +216,29 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
242
216
|
return lastStepUnifies;
|
|
243
217
|
}
|
|
244
218
|
|
|
219
|
+
unifySignature(signature, context) {
|
|
220
|
+
let signatureUnifies;
|
|
221
|
+
|
|
222
|
+
const axiomString = this.getString(), ///
|
|
223
|
+
signatureString = signature.getString();
|
|
224
|
+
|
|
225
|
+
context.trace(`Unifying the '${signatureString}' signature with the '${axiomString}' axiom...`);
|
|
226
|
+
|
|
227
|
+
const specificSignature = signature; ///
|
|
228
|
+
|
|
229
|
+
signature = this.getSignature();
|
|
230
|
+
|
|
231
|
+
const generalSignature = signature; ///
|
|
232
|
+
|
|
233
|
+
signatureUnifies = generalSignature.unifySignature(specificSignature, context);
|
|
234
|
+
|
|
235
|
+
if (signatureUnifies) {
|
|
236
|
+
context.debug(`...unified the '${signatureString}' signature with the '${axiomString}' axiom.`);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return signatureUnifies;
|
|
240
|
+
}
|
|
241
|
+
|
|
245
242
|
unifyTopLevelAssertion(topLevelAssertion, context) {
|
|
246
243
|
let topLevelAssertionUnifies = false;
|
|
247
244
|
|
package/src/element/variable.js
CHANGED
|
@@ -89,14 +89,14 @@ export default define(class Variable extends Element {
|
|
|
89
89
|
|
|
90
90
|
this.type = type;
|
|
91
91
|
|
|
92
|
+
variable = this;
|
|
93
|
+
|
|
92
94
|
validates = true;
|
|
93
95
|
} else {
|
|
94
96
|
context.debug(`The '${variableString}' variable is not present.`);
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
if (validates) {
|
|
98
|
-
variable = this; ///
|
|
99
|
-
|
|
100
100
|
context.debug(`...validated the '${variableString}' variable.`);
|
|
101
101
|
}
|
|
102
102
|
|
package/src/process/unify.js
CHANGED
|
@@ -147,38 +147,6 @@ 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
|
-
|
|
182
150
|
class CombinatorPass extends ZipPass {
|
|
183
151
|
static maps = [
|
|
184
152
|
{
|
|
@@ -402,12 +370,77 @@ class SubstitutionPass extends ZipPass {
|
|
|
402
370
|
];
|
|
403
371
|
}
|
|
404
372
|
|
|
373
|
+
class IntrinsicTermPass extends ZipPassBase {
|
|
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
|
+
class IntrinsicMetavariablePass extends ZipPass {
|
|
406
|
+
static maps = [
|
|
407
|
+
{
|
|
408
|
+
generalNodeQuery: termVariableNodeQuery,
|
|
409
|
+
specificNodeQuery: termNodeQuery,
|
|
410
|
+
run: (generalTermVariableNode, specificTermNode, generalContext, specificContext) => {
|
|
411
|
+
let success = false;
|
|
412
|
+
|
|
413
|
+
const termNode = specificTermNode, ///
|
|
414
|
+
variableNode = generalTermVariableNode; ///
|
|
415
|
+
|
|
416
|
+
let context;
|
|
417
|
+
|
|
418
|
+
context = generalContext; ///
|
|
419
|
+
|
|
420
|
+
const variable = context.findVariableByVariableNode(variableNode);
|
|
421
|
+
|
|
422
|
+
context = specificContext; ///
|
|
423
|
+
|
|
424
|
+
const term = context.findTermByTermNode(termNode),
|
|
425
|
+
termUnifies = variable.unifyTerm(term, generalContext, specificContext);
|
|
426
|
+
|
|
427
|
+
if (termUnifies) {
|
|
428
|
+
success = true;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return success;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
];
|
|
435
|
+
}
|
|
436
|
+
|
|
405
437
|
const statementPass = new StatementPass(),
|
|
406
|
-
intrinsicPass = new IntrinsicPass(),
|
|
407
438
|
combinatorPass = new CombinatorPass(),
|
|
408
439
|
constructorPass = new ConstructorPass(),
|
|
409
440
|
metavariablePass = new MetavariablePass(),
|
|
410
|
-
substitutionPass = new SubstitutionPass()
|
|
441
|
+
substitutionPass = new SubstitutionPass(),
|
|
442
|
+
intrinsicTermPass = new IntrinsicTermPass(),
|
|
443
|
+
intrinsicMetavariablePass = new IntrinsicMetavariablePass();
|
|
411
444
|
|
|
412
445
|
export function unifyStatement(generalStatement, specificStatement, generalContext, specificContext) {
|
|
413
446
|
let statementUnifies = false;
|
|
@@ -485,6 +518,22 @@ export function unifyStatementWithCombinator(statement, combinator, generalConte
|
|
|
485
518
|
return statementUnifiesWithCombinator;
|
|
486
519
|
}
|
|
487
520
|
|
|
521
|
+
export function unifyTermIntrinsically(generalTerm, specificTerm, generalContext, specificContext) {
|
|
522
|
+
let termUnifiesIntrinsically = false;
|
|
523
|
+
|
|
524
|
+
const generalTermNode = generalTerm.getNode(),
|
|
525
|
+
specificTermNode = specificTerm.getNode(),
|
|
526
|
+
generalNode = generalTermNode, ///
|
|
527
|
+
specificNode = specificTermNode, ///
|
|
528
|
+
success = intrinsicTermPass.run(generalNode, specificNode, generalContext, specificContext);
|
|
529
|
+
|
|
530
|
+
if (success) {
|
|
531
|
+
termUnifiesIntrinsically = true;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
return termUnifiesIntrinsically;
|
|
535
|
+
}
|
|
536
|
+
|
|
488
537
|
export function unifyMetavariableIntrinsically(generalMetavariable, specificMetavariable, generalContext, specificContext) {
|
|
489
538
|
let metavariableUnifiesIntrinsically = false;
|
|
490
539
|
|
|
@@ -492,7 +541,7 @@ export function unifyMetavariableIntrinsically(generalMetavariable, specificMeta
|
|
|
492
541
|
specificMetavariableNode = specificMetavariable.getNode(),
|
|
493
542
|
generalNode = generalMetavariableNode, ///
|
|
494
543
|
specificNode = specificMetavariableNode, ///
|
|
495
|
-
success =
|
|
544
|
+
success = intrinsicMetavariablePass.run(generalNode, specificNode, generalContext, specificContext);
|
|
496
545
|
|
|
497
546
|
if (success) {
|
|
498
547
|
metavariableUnifiesIntrinsically = true;
|