occam-verify-cli 0.0.1248 → 0.0.1250
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/constants.js +9 -1
- package/lib/context/file.js +76 -12
- package/lib/context/local.js +16 -4
- package/lib/dom/conclusion.js +1 -7
- package/lib/dom/consequent.js +1 -7
- package/lib/dom/declaration.js +59 -102
- package/lib/dom/frame.js +91 -105
- package/lib/dom/judgement.js +4 -2
- package/lib/dom/label.js +17 -9
- package/lib/dom/metavariable.js +18 -16
- package/lib/dom/reference.js +29 -41
- package/lib/dom/rule.js +7 -9
- package/lib/dom/statement.js +54 -54
- package/lib/dom/topLevelAssertion.js +13 -6
- package/lib/dom/topLevelMetaAssertion.js +10 -11
- package/lib/dom/variable.js +6 -6
- package/lib/equivalence.js +3 -3
- package/lib/equivalences.js +2 -2
- package/lib/substitution/term.js +8 -1
- package/lib/substitution.js +15 -1
- package/lib/substitutions.js +27 -11
- package/lib/unifier/intrinsicLevel.js +6 -6
- package/lib/unifier/metaLevel.js +3 -3
- package/lib/utilities/unification.js +17 -36
- package/package.json +1 -1
- package/src/constants.js +2 -0
- package/src/context/file.js +59 -10
- package/src/context/local.js +5 -1
- package/src/dom/conclusion.js +0 -2
- package/src/dom/consequent.js +0 -2
- package/src/dom/declaration.js +88 -92
- package/src/dom/frame.js +111 -125
- package/src/dom/judgement.js +3 -1
- package/src/dom/label.js +17 -4
- package/src/dom/metavariable.js +17 -13
- package/src/dom/reference.js +45 -47
- package/src/dom/rule.js +11 -7
- package/src/dom/statement.js +68 -66
- package/src/dom/topLevelAssertion.js +11 -5
- package/src/dom/topLevelMetaAssertion.js +10 -13
- package/src/dom/variable.js +7 -7
- package/src/equivalence.js +1 -1
- package/src/equivalences.js +1 -1
- package/src/substitution/term.js +8 -0
- package/src/substitution.js +13 -0
- package/src/substitutions.js +31 -11
- package/src/unifier/intrinsicLevel.js +5 -7
- package/src/unifier/metaLevel.js +2 -4
- package/src/utilities/unification.js +29 -67
- package/lib/unifier/reference.js +0 -145
- package/src/unifier/reference.js +0 -56
package/src/dom/statement.js
CHANGED
|
@@ -105,10 +105,75 @@ export default domAssigned(class Statement {
|
|
|
105
105
|
return frameContained;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
const
|
|
108
|
+
match(statement) {
|
|
109
|
+
const statementNode = statement.getNode(),
|
|
110
|
+
statementNodeMatchesNode = this.node.match(statementNode),
|
|
111
|
+
matches = statementNodeMatchesNode; ///
|
|
110
112
|
|
|
111
|
-
return
|
|
113
|
+
return matches;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
verify(assignments, stated, context) {
|
|
117
|
+
let verified;
|
|
118
|
+
|
|
119
|
+
const statementString = this.string; ///
|
|
120
|
+
|
|
121
|
+
context.trace(`Verifying the '${statementString}' statement...`);
|
|
122
|
+
|
|
123
|
+
verified = verifyMixins.some((verifyMixin) => {
|
|
124
|
+
const statement = this, ///
|
|
125
|
+
verified = verifyMixin(statement, assignments, stated, context);
|
|
126
|
+
|
|
127
|
+
if (verified) {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
if (verified) {
|
|
133
|
+
context.debug(`...verified the '${statementString}' statement.`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return verified;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
verifyWhenDeclared(fileContext) {
|
|
140
|
+
let verifiedWhenDeclared;
|
|
141
|
+
|
|
142
|
+
const statementNode = this.node, ///
|
|
143
|
+
statementString = this.string; ///
|
|
144
|
+
|
|
145
|
+
fileContext.trace(`Verifying the '${statementString}' statement when declared...`);
|
|
146
|
+
|
|
147
|
+
verifiedWhenDeclared = combinatorVerifier.verifyStatement(statementNode, fileContext);
|
|
148
|
+
|
|
149
|
+
if (verifiedWhenDeclared) {
|
|
150
|
+
fileContext.debug(`...verified the '${statementString}' statement when declared.`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return verifiedWhenDeclared;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
verifyGivenMetaType(metaType, assignments, stated, context) {
|
|
157
|
+
let verifiedGivenMetaType = false;
|
|
158
|
+
|
|
159
|
+
const metaTypeString = metaType.getString(),
|
|
160
|
+
statementString = this.string; ///
|
|
161
|
+
|
|
162
|
+
context.trace(`Verifying the '${statementString}' statement given the '${metaTypeString}' meta-type...`);
|
|
163
|
+
|
|
164
|
+
const metaTypeName = metaType.getName();
|
|
165
|
+
|
|
166
|
+
if (metaTypeName === STATEMENT_META_TYPE_NAME) {
|
|
167
|
+
const verified = this.verify(assignments, stated, context)
|
|
168
|
+
|
|
169
|
+
verifiedGivenMetaType = verified; ///
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (verifiedGivenMetaType) {
|
|
173
|
+
context.debug(`...verified the '${statementString}' statement given the '${metaTypeString}' meta-type.`);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return verifiedGivenMetaType;
|
|
112
177
|
}
|
|
113
178
|
|
|
114
179
|
unifySubproof(subproof, substitutions, generalContext, specificContext) {
|
|
@@ -209,69 +274,6 @@ export default domAssigned(class Statement {
|
|
|
209
274
|
return unifiedWithProofSteps;
|
|
210
275
|
}
|
|
211
276
|
|
|
212
|
-
verify(assignments, stated, context) {
|
|
213
|
-
let verified;
|
|
214
|
-
|
|
215
|
-
const statementString = this.string; ///
|
|
216
|
-
|
|
217
|
-
context.trace(`Verifying the '${statementString}' statement...`);
|
|
218
|
-
|
|
219
|
-
verified = verifyMixins.some((verifyMixin) => {
|
|
220
|
-
const statement = this, ///
|
|
221
|
-
verified = verifyMixin(statement, assignments, stated, context);
|
|
222
|
-
|
|
223
|
-
if (verified) {
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
if (verified) {
|
|
229
|
-
context.debug(`...verified the '${statementString}' statement.`);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return verified;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
verifyWhenDeclared(fileContext) {
|
|
236
|
-
let verifiedWhenDeclared;
|
|
237
|
-
|
|
238
|
-
const statementNode = this.node, ///
|
|
239
|
-
statementString = this.string; ///
|
|
240
|
-
|
|
241
|
-
fileContext.trace(`Verifying the '${statementString}' statement when declared...`);
|
|
242
|
-
|
|
243
|
-
verifiedWhenDeclared = combinatorVerifier.verifyStatement(statementNode, fileContext);
|
|
244
|
-
|
|
245
|
-
if (verifiedWhenDeclared) {
|
|
246
|
-
fileContext.debug(`...verified the '${statementString}' statement when declared.`);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return verifiedWhenDeclared;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
verifyGivenMetaType(metaType, assignments, stated, context) {
|
|
253
|
-
let verifiedGivenMetaType = false;
|
|
254
|
-
|
|
255
|
-
const metaTypeString = metaType.getString(),
|
|
256
|
-
statementString = this.string; ///
|
|
257
|
-
|
|
258
|
-
context.trace(`Verifying the '${statementString}' statement given the '${metaTypeString}' meta-type...`);
|
|
259
|
-
|
|
260
|
-
const metaTypeName = metaType.getName();
|
|
261
|
-
|
|
262
|
-
if (metaTypeName === STATEMENT_META_TYPE_NAME) {
|
|
263
|
-
const verified = this.verify(assignments, stated, context)
|
|
264
|
-
|
|
265
|
-
verifiedGivenMetaType = verified; ///
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (verifiedGivenMetaType) {
|
|
269
|
-
context.debug(`...verified the '${statementString}' statement given the '${metaTypeString}' meta-type.`);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
return verifiedGivenMetaType;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
277
|
toJSON() {
|
|
276
278
|
const string = this.string, ///
|
|
277
279
|
json = {
|
|
@@ -57,7 +57,7 @@ export default class TopLevelAssertion {
|
|
|
57
57
|
return this.proof;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
getStatement() { return this.consequent.getStatement(); }
|
|
61
61
|
|
|
62
62
|
matchMetavariableName(metavariableName) {
|
|
63
63
|
const metavariableNameMatches = this.labels.some((label) => {
|
|
@@ -238,11 +238,10 @@ export default class TopLevelAssertion {
|
|
|
238
238
|
|
|
239
239
|
static fromJSON(Class, json, fileContext) {
|
|
240
240
|
const labels = labelsFromJSON(json, fileContext),
|
|
241
|
-
labelsString = labelsStringFromLabels(labels),
|
|
242
241
|
suppositions = suppositionsFromJSON(json, fileContext),
|
|
243
242
|
consequent = consequentFromJSON(json, fileContext),
|
|
244
243
|
proof = null,
|
|
245
|
-
string =
|
|
244
|
+
string = stringFromLabelsAndConsequent(labels, consequent),
|
|
246
245
|
topLevelAssertion = new Class(fileContext, string, labels, suppositions, consequent, proof);
|
|
247
246
|
|
|
248
247
|
return topLevelAssertion;
|
|
@@ -250,11 +249,10 @@ export default class TopLevelAssertion {
|
|
|
250
249
|
|
|
251
250
|
static fromNode(Class, node, fileContext) {
|
|
252
251
|
const labels = labelsFromNode(node, fileContext),
|
|
253
|
-
labelsString = labelsStringFromLabels(labels),
|
|
254
252
|
suppositions = suppositionsFromNode(node, fileContext),
|
|
255
253
|
consequent = consequentFromNode(node, fileContext),
|
|
256
254
|
proof = proofFromNode(node, fileContext),
|
|
257
|
-
string =
|
|
255
|
+
string = stringFromLabelsAndConsequent(labels, consequent),
|
|
258
256
|
metaLemma = new Class(fileContext, string, labels, suppositions, consequent, proof);
|
|
259
257
|
|
|
260
258
|
return metaLemma;
|
|
@@ -314,3 +312,11 @@ export function labelsStringFromLabels(labels) {
|
|
|
314
312
|
|
|
315
313
|
return labelsString;
|
|
316
314
|
}
|
|
315
|
+
|
|
316
|
+
export function stringFromLabelsAndConsequent(labels, consequent) {
|
|
317
|
+
const consequentString = consequent.getString(),
|
|
318
|
+
labelsString = labelsStringFromLabels(labels),
|
|
319
|
+
string = `${labelsString} :: ${consequentString}`;
|
|
320
|
+
|
|
321
|
+
return string;
|
|
322
|
+
}
|
|
@@ -8,7 +8,7 @@ import Substitutions from "../substitutions";
|
|
|
8
8
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
9
9
|
|
|
10
10
|
import { nodeQuery } from "../utilities/query";
|
|
11
|
-
import { proofFromNode, consequentFromNode, suppositionsFromNode,
|
|
11
|
+
import { proofFromNode, consequentFromNode, suppositionsFromNode, stringFromLabelsAndConsequent } from "./topLevelAssertion";
|
|
12
12
|
import { labelsFromJSON,
|
|
13
13
|
labelsToLabelsJSON,
|
|
14
14
|
consequentFromJSON,
|
|
@@ -41,6 +41,13 @@ export default class TopLevelMetaAssertion extends TopLevelAssertion {
|
|
|
41
41
|
return label;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
matchReference(reference) {
|
|
45
|
+
const label = this.getLabel(),
|
|
46
|
+
referenceMatches = label.matchReference(reference);
|
|
47
|
+
|
|
48
|
+
return referenceMatches;
|
|
49
|
+
}
|
|
50
|
+
|
|
44
51
|
verify() {
|
|
45
52
|
let verified = false;
|
|
46
53
|
|
|
@@ -88,14 +95,6 @@ export default class TopLevelMetaAssertion extends TopLevelAssertion {
|
|
|
88
95
|
return labelsVerified;
|
|
89
96
|
}
|
|
90
97
|
|
|
91
|
-
verifyWhenStated(statement, reference, context) {
|
|
92
|
-
let verifiedWhenStated;
|
|
93
|
-
|
|
94
|
-
debugger
|
|
95
|
-
|
|
96
|
-
return verifiedWhenStated;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
98
|
toJSON() {
|
|
100
99
|
const labelsJSON = labelsToLabelsJSON(this.labels),
|
|
101
100
|
consequentJSON = consequentToConsequentJSON(this.consequent),
|
|
@@ -118,11 +117,10 @@ export default class TopLevelMetaAssertion extends TopLevelAssertion {
|
|
|
118
117
|
static fromJSON(Class, json, fileContext) {
|
|
119
118
|
const labels = labelsFromJSON(json, fileContext),
|
|
120
119
|
substitutions = substitutionsFromJSON(json, fileContext),
|
|
121
|
-
labelsString = labelsStringFromLabels(labels),
|
|
122
120
|
suppositions = suppositionsFromJSON(json, fileContext),
|
|
123
121
|
consequent = consequentFromJSON(json, fileContext),
|
|
124
122
|
proof = null,
|
|
125
|
-
string =
|
|
123
|
+
string = stringFromLabelsAndConsequent(labels, consequent),
|
|
126
124
|
topLevelAssertion = new Class(fileContext, string, labels, suppositions, consequent, proof, substitutions);
|
|
127
125
|
|
|
128
126
|
return topLevelAssertion;
|
|
@@ -131,11 +129,10 @@ export default class TopLevelMetaAssertion extends TopLevelAssertion {
|
|
|
131
129
|
static fromNode(Class, node, fileContext) {
|
|
132
130
|
const labels = labelsFromNode(node, fileContext),
|
|
133
131
|
substitutions = Substitutions.fromNothing(),
|
|
134
|
-
labelsString = labelsStringFromLabels(labels),
|
|
135
132
|
suppositions = suppositionsFromNode(node, fileContext),
|
|
136
133
|
consequent = consequentFromNode(node, fileContext),
|
|
137
134
|
proof = proofFromNode(node, fileContext),
|
|
138
|
-
string =
|
|
135
|
+
string = stringFromLabelsAndConsequent(labels, consequent),
|
|
139
136
|
metaLemma = new Class(fileContext, string, labels, suppositions, consequent, proof, substitutions);
|
|
140
137
|
|
|
141
138
|
return metaLemma;
|
package/src/dom/variable.js
CHANGED
|
@@ -166,13 +166,13 @@ export default domAssigned(class Variable {
|
|
|
166
166
|
return verifiedWhenDeclared;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
unifyTerm(term, substitutions, generalContext, specificContext
|
|
169
|
+
unifyTerm(term, substitutions, generalContext, specificContext) {
|
|
170
170
|
let termUnified = false;
|
|
171
171
|
|
|
172
172
|
const termString = term.getString(),
|
|
173
173
|
variableString = this.string; ///
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
generalContext.trace(`Unifying the '${termString}' term with the '${variableString}' variable...`);
|
|
176
176
|
|
|
177
177
|
const effectivelyEqualToTerm = this.isEffectivelyEqualToTerm(term, generalContext, specificContext);
|
|
178
178
|
|
|
@@ -190,15 +190,15 @@ export default domAssigned(class Variable {
|
|
|
190
190
|
termUnified = true;
|
|
191
191
|
}
|
|
192
192
|
} else {
|
|
193
|
-
let context
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
let context;
|
|
194
|
+
|
|
195
|
+
context = specificContext; ///
|
|
196
196
|
|
|
197
197
|
const variable = this, ///
|
|
198
198
|
termSubstitution = TermSubstitution.fromTernAndVariable(term, variable, context),
|
|
199
199
|
substitution = termSubstitution; ///
|
|
200
200
|
|
|
201
|
-
context =
|
|
201
|
+
context = generalContext; ///
|
|
202
202
|
|
|
203
203
|
substitutions.addSubstitution(substitution, context);
|
|
204
204
|
|
|
@@ -207,7 +207,7 @@ export default domAssigned(class Variable {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
if (termUnified) {
|
|
210
|
-
|
|
210
|
+
generalContext.debug(`...unified the '${termString}' term with the '${variableString}' variable.`);
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
return termUnified;
|
package/src/equivalence.js
CHANGED
package/src/equivalences.js
CHANGED
|
@@ -43,7 +43,7 @@ export default class Equivalences {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
addEquivalence(equivalence, context) {
|
|
46
|
-
const equivalenceString = equivalence.
|
|
46
|
+
const equivalenceString = equivalence.asString();
|
|
47
47
|
|
|
48
48
|
context.trace(`Added the '${equivalenceString}' equivalence.`);
|
|
49
49
|
|
package/src/substitution/term.js
CHANGED
|
@@ -47,6 +47,14 @@ export default class TermSubstitution extends Substitution {
|
|
|
47
47
|
|
|
48
48
|
matchName(name) { return this.variable.matchName(name); }
|
|
49
49
|
|
|
50
|
+
matchSubstitution(substitution) {
|
|
51
|
+
const term = substitution.getTerm(),
|
|
52
|
+
variable = substitution.getVariable(),
|
|
53
|
+
termMatches = this.term.match
|
|
54
|
+
|
|
55
|
+
return substitutionMatches;
|
|
56
|
+
}
|
|
57
|
+
|
|
50
58
|
unifyWithEquivalence(equivalence) {
|
|
51
59
|
let unifiedWithEquivalence;
|
|
52
60
|
|
package/src/substitution.js
CHANGED
|
@@ -129,6 +129,13 @@ export default class Substitution {
|
|
|
129
129
|
return resolved;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
match(substitution) {
|
|
133
|
+
const equalTo = this.isEqualTo(substitution),
|
|
134
|
+
matches = equalTo; ///
|
|
135
|
+
|
|
136
|
+
return matches;
|
|
137
|
+
}
|
|
138
|
+
|
|
132
139
|
matchName(name) {
|
|
133
140
|
const nameMatches = false;
|
|
134
141
|
|
|
@@ -146,4 +153,10 @@ export default class Substitution {
|
|
|
146
153
|
|
|
147
154
|
return unifiedWithEquivalence;
|
|
148
155
|
}
|
|
156
|
+
|
|
157
|
+
matchSubstitution(substitution) {
|
|
158
|
+
const substitutionMatches = false;
|
|
159
|
+
|
|
160
|
+
return substitutionMatches;
|
|
161
|
+
}
|
|
149
162
|
}
|
package/src/substitutions.js
CHANGED
|
@@ -4,7 +4,7 @@ import { arrayUtilities } from "necessary";
|
|
|
4
4
|
|
|
5
5
|
import { EMPTY_STRING } from "./constants";
|
|
6
6
|
|
|
7
|
-
const { find, first, clear, prune, filter, compress } = arrayUtilities;
|
|
7
|
+
const { find, first, clear, prune, filter, compress, correlate } = arrayUtilities;
|
|
8
8
|
|
|
9
9
|
export default class Substitutions {
|
|
10
10
|
constructor(array, savedArray) {
|
|
@@ -200,6 +200,20 @@ export default class Substitutions {
|
|
|
200
200
|
context.trace(`Removed the ${substitutionString} substitution.`);
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
matchSubstitutions(substitutions) {
|
|
204
|
+
const array = substitutions.getArray(),
|
|
205
|
+
correlates = correlate(array, this.array, (substitutionA, substitutionB) => {
|
|
206
|
+
const substitutionAMatchesSubstitutionB = substitutionA.match(substitutionB);
|
|
207
|
+
|
|
208
|
+
if (substitutionAMatchesSubstitutionB) {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
}),
|
|
212
|
+
match = correlates; ///
|
|
213
|
+
|
|
214
|
+
return match;
|
|
215
|
+
}
|
|
216
|
+
|
|
203
217
|
clear() {
|
|
204
218
|
clear(this.array);
|
|
205
219
|
|
|
@@ -278,19 +292,25 @@ export default class Substitutions {
|
|
|
278
292
|
this.savedArray = null;
|
|
279
293
|
}
|
|
280
294
|
|
|
281
|
-
|
|
282
|
-
let string
|
|
283
|
-
|
|
295
|
+
asString() {
|
|
296
|
+
let string;
|
|
297
|
+
|
|
298
|
+
const length = this.getLength();
|
|
299
|
+
|
|
300
|
+
if (length === 0) {
|
|
301
|
+
string = EMPTY_STRING;
|
|
302
|
+
} else {
|
|
303
|
+
const substitutionsString = this.array.reduce((substitutionsString, substitution) => {
|
|
304
|
+
const substitutionString = substitution.getString();
|
|
284
305
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
306
|
+
substitutionsString = (substitutionsString === null) ?
|
|
307
|
+
substitutionString :
|
|
308
|
+
`${substitutionsString}, ${substitutionString}`;
|
|
288
309
|
|
|
289
|
-
|
|
290
|
-
|
|
310
|
+
return substitutionsString;
|
|
311
|
+
}, null);
|
|
291
312
|
|
|
292
|
-
|
|
293
|
-
string = ` ${string}`;
|
|
313
|
+
string = substitutionsString; ///
|
|
294
314
|
}
|
|
295
315
|
|
|
296
316
|
return string;
|
|
@@ -9,16 +9,14 @@ const termNodeQuery = nodeQuery("/term"),
|
|
|
9
9
|
termVariableNodeQuery = nodeQuery("/term/variable!");
|
|
10
10
|
|
|
11
11
|
class IntrinsicLevelUnifier extends Unifier {
|
|
12
|
-
unify(
|
|
13
|
-
let
|
|
12
|
+
unify(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext) {
|
|
13
|
+
let unifiedAtIntrinsicLevel;
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
specificNonTerminalNode = specificNode, ///
|
|
17
|
-
nonTerminalNodeUnified = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext);
|
|
15
|
+
const nonTerminalNodeUnified = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext);
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
unifiedAtIntrinsicLevel = nonTerminalNodeUnified; ///
|
|
20
18
|
|
|
21
|
-
return
|
|
19
|
+
return unifiedAtIntrinsicLevel;
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
static maps = [
|
package/src/unifier/metaLevel.js
CHANGED
|
@@ -17,12 +17,10 @@ const termNodeQuery = nodeQuery("/term"),
|
|
|
17
17
|
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!");
|
|
18
18
|
|
|
19
19
|
class MetaLevelUnifier extends Unifier {
|
|
20
|
-
unify(
|
|
20
|
+
unify(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext) {
|
|
21
21
|
let unifiedAtMetaLevel;
|
|
22
22
|
|
|
23
|
-
const
|
|
24
|
-
specificNonTerminalNode = specificNode, ///
|
|
25
|
-
nonTerminalNodeUnified = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext);
|
|
23
|
+
const nonTerminalNodeUnified = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext);
|
|
26
24
|
|
|
27
25
|
unifiedAtMetaLevel = nonTerminalNodeUnified; ///
|
|
28
26
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use string";
|
|
2
2
|
|
|
3
3
|
import LocalContext from "../context/local";
|
|
4
|
-
import Substitutions from "../substitutions";
|
|
5
4
|
import equalityUnifier from "../unifier/equality";
|
|
6
|
-
import referenceUnifier from "../unifier/reference";
|
|
7
5
|
import metaLevelUnifier from "../unifier/metaLevel";
|
|
8
6
|
import metavariableUnifier from "../unifier/metavariable";
|
|
9
7
|
import intrinsicLevelUnifier from "../unifier/intrinsicLevel";
|
|
@@ -35,9 +33,9 @@ export function unifyStatement(generalStatement, specificStatement, substitution
|
|
|
35
33
|
|
|
36
34
|
specificContext = contextFromTokens(specificStatementTokens, specificContext); ///
|
|
37
35
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
unifiedAtMetaLevel = metaLevelUnifier.unify(
|
|
36
|
+
const generalNonTerminalNode = generalStatementNode, ///
|
|
37
|
+
specificNonTerminalNode = specificStatementNode, ///
|
|
38
|
+
unifiedAtMetaLevel = metaLevelUnifier.unify(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext);
|
|
41
39
|
|
|
42
40
|
statementUnified = unifiedAtMetaLevel; ///
|
|
43
41
|
|
|
@@ -56,9 +54,9 @@ export function unifySubstitution(generalSubstitution, specificSubstitution, sub
|
|
|
56
54
|
|
|
57
55
|
specificContext = contextFromTokens(specificSubstitutionTokens, specificContext); ///
|
|
58
56
|
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
unifiedAtMetaLevel = metaLevelUnifier.unify(
|
|
57
|
+
const generalNonTerminalNode = generalSubstitutionNode, ///
|
|
58
|
+
specificNonTerminalNode = specificSubstitutionNode,
|
|
59
|
+
unifiedAtMetaLevel = metaLevelUnifier.unify(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext);
|
|
62
60
|
|
|
63
61
|
substitutionUnified = unifiedAtMetaLevel; ///
|
|
64
62
|
|
|
@@ -82,75 +80,36 @@ export function unifyMetavariable(generalMetavariable, specificMetavariable, gen
|
|
|
82
80
|
return metavariableUnified;
|
|
83
81
|
}
|
|
84
82
|
|
|
85
|
-
export function
|
|
86
|
-
let
|
|
87
|
-
|
|
88
|
-
let generalContext,
|
|
89
|
-
specificContext;
|
|
90
|
-
|
|
91
|
-
const fileContext = label.getFileContext(),
|
|
92
|
-
labelMetavariable = label.getMetavariable(),
|
|
93
|
-
referenceMetavariable = reference.getMetavariable(),
|
|
94
|
-
labelMetavariableNode = labelMetavariable.getNode(),
|
|
95
|
-
labelMetavariableTokens = labelMetavariable.getTokens(),
|
|
96
|
-
referenceMetavariableNode = referenceMetavariable.getNode(),
|
|
97
|
-
referenceMetavariableTokens = referenceMetavariable.getTokens();
|
|
98
|
-
|
|
99
|
-
generalContext = context; ///
|
|
100
|
-
|
|
101
|
-
specificContext = fileContext; ///
|
|
102
|
-
|
|
103
|
-
generalContext = contextFromTokens(labelMetavariableTokens, generalContext); ///
|
|
104
|
-
|
|
105
|
-
specificContext = contextFromTokens(referenceMetavariableTokens, specificContext); ///
|
|
83
|
+
export function unifyTermWithConstructor(term, constructor, context) {
|
|
84
|
+
let termUnifiedWithConstructor;
|
|
106
85
|
|
|
107
|
-
const
|
|
108
|
-
|
|
86
|
+
const termNode = term.getNode(),
|
|
87
|
+
constructorTerm = constructor.getTerm(),
|
|
88
|
+
constructorTermNode = constructorTerm.getNode();
|
|
109
89
|
|
|
110
|
-
|
|
90
|
+
termUnifiedWithConstructor = termWithConstructorUnifier.unify(constructorTermNode, termNode, context);
|
|
111
91
|
|
|
112
|
-
return
|
|
92
|
+
return termUnifiedWithConstructor;
|
|
113
93
|
}
|
|
114
94
|
|
|
115
|
-
export function
|
|
116
|
-
let
|
|
117
|
-
|
|
118
|
-
let generalContext,
|
|
119
|
-
specificContext;
|
|
120
|
-
|
|
121
|
-
const fileContext = context.getFileContext(),
|
|
122
|
-
metavariableNode = metavariable.getNode(),
|
|
123
|
-
metavariableTokens = metavariable.getTokens(),
|
|
124
|
-
referenceMetavariable = reference.getMetavariable(),
|
|
125
|
-
referenceMetavariableNode = referenceMetavariable.getNode(),
|
|
126
|
-
referenceMetavariableTokens = referenceMetavariable.getTokens();
|
|
127
|
-
|
|
128
|
-
generalContext = context; ///
|
|
129
|
-
|
|
130
|
-
specificContext = fileContext; ///
|
|
131
|
-
|
|
132
|
-
generalContext = contextFromTokens(metavariableTokens, generalContext); ///
|
|
133
|
-
|
|
134
|
-
specificContext = contextFromTokens(referenceMetavariableTokens, specificContext); ///
|
|
135
|
-
|
|
136
|
-
const substitutions = Substitutions.fromNothing(),
|
|
137
|
-
referenceUnified = referenceUnifier.unify(metavariableNode, referenceMetavariableNode, substitutions, generalContext, specificContext);
|
|
95
|
+
export function unifyStatementIntrinsically(generalStatement, specificStatement, substitutions, generalContext, specificContext) {
|
|
96
|
+
let metavariableUnifiedIntrinsically;
|
|
138
97
|
|
|
139
|
-
|
|
98
|
+
const generalStatementNode = generalStatement.getNode(),
|
|
99
|
+
specificStatementNode = specificStatement.getNode(),
|
|
100
|
+
generalStatementTokens = generalStatement.getTokens(),
|
|
101
|
+
specificStatementTokens = specificStatement.getTokens();
|
|
140
102
|
|
|
141
|
-
|
|
142
|
-
}
|
|
103
|
+
generalContext = contextFromTokens(generalStatementTokens, generalContext); ///
|
|
143
104
|
|
|
144
|
-
|
|
145
|
-
let termUnifiedWithConstructor;
|
|
105
|
+
specificContext = contextFromTokens(specificStatementTokens, specificContext); ///
|
|
146
106
|
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
constructorTermNode = constructorTerm.getNode();
|
|
107
|
+
const generalNonTerminalNode = generalStatementNode, ///
|
|
108
|
+
specificNonTerminalNode = specificStatementNode; ///
|
|
150
109
|
|
|
151
|
-
|
|
110
|
+
metavariableUnifiedIntrinsically = intrinsicLevelUnifier.unify(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext);
|
|
152
111
|
|
|
153
|
-
return
|
|
112
|
+
return metavariableUnifiedIntrinsically;
|
|
154
113
|
}
|
|
155
114
|
|
|
156
115
|
export function unifyStatementWithCombinator(statement, combinator, assignments, stated, context) {
|
|
@@ -186,7 +145,10 @@ export function unifyMetavariableIntrinsically(generalMetavariable, specificMeta
|
|
|
186
145
|
|
|
187
146
|
specificContext = contextFromTokens(specificMetavariableTokens, specificContext); ///
|
|
188
147
|
|
|
189
|
-
|
|
148
|
+
const generalNonTerminalNode = generalMetavariableNode, ///
|
|
149
|
+
specificNonTerminalNode = specificMetavariableNode; ///
|
|
150
|
+
|
|
151
|
+
metavariableUnifiedIntrinsically = intrinsicLevelUnifier.unify(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext);
|
|
190
152
|
|
|
191
153
|
return metavariableUnifiedIntrinsically;
|
|
192
154
|
}
|