occam-verify-cli 0.0.836 → 0.0.839
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 +5 -1
- package/lib/context/file.js +24 -9
- package/lib/context/local.js +77 -39
- package/lib/context/localMeta.js +3 -3
- package/lib/context/release.js +4 -5
- package/lib/equality.js +2 -2
- package/lib/equivalence.js +244 -0
- package/lib/log.js +3 -3
- package/lib/term.js +40 -1
- package/lib/utilities/array.js +5 -5
- package/lib/utilities/equivalences.js +169 -0
- package/lib/verifier/node/metastatement.js +12 -31
- package/lib/verifier/node/statementAsCombinator.js +4 -4
- package/lib/verifier/node/termAsConstructor.js +7 -27
- package/lib/verifier/nodes/equality.js +8 -8
- package/lib/verifier/nodes/metaLevelToIntrinsicLevel.js +22 -6
- package/lib/verify/containment.js +22 -12
- package/lib/verify/defining.js +38 -0
- package/lib/verify/metavariable.js +26 -4
- package/lib/verify/statement.js +62 -45
- package/lib/verify/term.js +6 -6
- package/lib/verify/type.js +7 -7
- package/lib/verify/variable.js +26 -4
- package/package.json +2 -2
- package/src/constants.js +1 -0
- package/src/context/file.js +35 -8
- package/src/context/local.js +113 -44
- package/src/context/localMeta.js +3 -3
- package/src/context/release.js +6 -9
- package/src/equality.js +2 -2
- package/src/{collection.js → equivalence.js} +84 -28
- package/src/log.js +2 -2
- package/src/term.js +48 -0
- package/src/utilities/array.js +1 -1
- package/src/utilities/equivalences.js +152 -0
- package/src/verifier/node/metastatement.js +23 -51
- package/src/verifier/node/statementAsCombinator.js +9 -6
- package/src/verifier/node/termAsConstructor.js +13 -44
- package/src/verifier/nodes/equality.js +7 -7
- package/src/verifier/nodes/metaLevelToIntrinsicLevel.js +38 -12
- package/src/verify/containment.js +31 -20
- package/src/verify/defining.js +43 -0
- package/src/verify/metavariable.js +22 -0
- package/src/verify/statement.js +88 -54
- package/src/verify/term.js +4 -5
- package/src/verify/type.js +6 -7
- package/src/verify/variable.js +22 -0
- package/lib/collection.js +0 -192
- package/lib/utilities/collection.js +0 -121
- package/src/utilities/collection.js +0 -103
package/src/context/local.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Variable from "../variable";
|
|
4
|
-
import
|
|
4
|
+
import Equivalence from "../equivalence";
|
|
5
5
|
import contextMixins from "../mixins/context";
|
|
6
6
|
|
|
7
7
|
import { last } from "../utilities/array";
|
|
8
|
-
import {
|
|
8
|
+
import { mergeEquivalences,
|
|
9
|
+
separateEquivalences,
|
|
10
|
+
findEquivalenceByTerm,
|
|
11
|
+
compressDefinedVariables,
|
|
12
|
+
definedVariablesFromGroundedEquivalences,
|
|
13
|
+
implicitlyGroundedEquivalencesFromRemainingEquivalencesAndDefinedVariables } from "../utilities/equivalences";
|
|
9
14
|
|
|
10
15
|
class LocalContext {
|
|
11
|
-
constructor(context, variables, proofSteps,
|
|
16
|
+
constructor(context, variables, proofSteps, equivalences) {
|
|
12
17
|
this.context = context;
|
|
13
18
|
this.variables = variables;
|
|
14
19
|
this.proofSteps = proofSteps;
|
|
15
|
-
this.
|
|
20
|
+
this.equivalences = equivalences;
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
getContext() {
|
|
@@ -23,8 +28,8 @@ class LocalContext {
|
|
|
23
28
|
let variables = this.context.getVariables();
|
|
24
29
|
|
|
25
30
|
variables = [ ///
|
|
26
|
-
...
|
|
27
|
-
...variables
|
|
31
|
+
...variables,
|
|
32
|
+
...this.variables
|
|
28
33
|
];
|
|
29
34
|
|
|
30
35
|
return variables;
|
|
@@ -34,23 +39,23 @@ class LocalContext {
|
|
|
34
39
|
let proofSteps = this.context.getProofSteps();
|
|
35
40
|
|
|
36
41
|
proofSteps = [ ///
|
|
37
|
-
...
|
|
38
|
-
...proofSteps
|
|
42
|
+
...proofSteps,
|
|
43
|
+
...this.proofSteps
|
|
39
44
|
];
|
|
40
45
|
|
|
41
46
|
return proofSteps;
|
|
42
47
|
}
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
let
|
|
49
|
+
getEquivalences() {
|
|
50
|
+
let equivalences = this.context.getEquivalences();
|
|
46
51
|
|
|
47
|
-
const
|
|
48
|
-
|
|
52
|
+
const equivalencesA = this.equivalences, ///
|
|
53
|
+
equivalencesB = equivalences,
|
|
49
54
|
localContext = this; ///
|
|
50
55
|
|
|
51
|
-
|
|
56
|
+
equivalences = mergeEquivalences(equivalencesA, equivalencesB, localContext); ///
|
|
52
57
|
|
|
53
|
-
return
|
|
58
|
+
return equivalences;
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
getLastProofStep() {
|
|
@@ -70,14 +75,14 @@ class LocalContext {
|
|
|
70
75
|
getTermType(term) {
|
|
71
76
|
let termType;
|
|
72
77
|
|
|
73
|
-
const
|
|
74
|
-
|
|
78
|
+
const equivalences = this.getEquivalences(),
|
|
79
|
+
equivalence = findEquivalenceByTerm(equivalences, term);
|
|
75
80
|
|
|
76
|
-
if (
|
|
81
|
+
if (equivalence !== null) {
|
|
77
82
|
const localContext = this, ///
|
|
78
|
-
|
|
83
|
+
equivalenceType = equivalence.getType(localContext);
|
|
79
84
|
|
|
80
|
-
termType =
|
|
85
|
+
termType = equivalenceType; ///
|
|
81
86
|
} else {
|
|
82
87
|
termType = term.getType();
|
|
83
88
|
}
|
|
@@ -85,6 +90,53 @@ class LocalContext {
|
|
|
85
90
|
return termType;
|
|
86
91
|
}
|
|
87
92
|
|
|
93
|
+
isVariableDefined(variable) {
|
|
94
|
+
let variableDefined = false;
|
|
95
|
+
|
|
96
|
+
const equivalences = this.getEquivalences(),
|
|
97
|
+
remainingEquivalences = [],
|
|
98
|
+
initiallyGroundedEquivalences = [];
|
|
99
|
+
|
|
100
|
+
separateEquivalences(equivalences, remainingEquivalences, initiallyGroundedEquivalences);
|
|
101
|
+
|
|
102
|
+
const initiallyGroundedEquivalencesLength = initiallyGroundedEquivalences.length;
|
|
103
|
+
|
|
104
|
+
if (initiallyGroundedEquivalencesLength > 0) {
|
|
105
|
+
let groundedEquivalences,
|
|
106
|
+
implicitlyGroundedEquivalences,
|
|
107
|
+
implicitlyGroundedEquivalencesLength;
|
|
108
|
+
|
|
109
|
+
const context = this,
|
|
110
|
+
definedVariables = [];
|
|
111
|
+
|
|
112
|
+
groundedEquivalences = initiallyGroundedEquivalences; ///
|
|
113
|
+
|
|
114
|
+
definedVariablesFromGroundedEquivalences(groundedEquivalences, definedVariables, context);
|
|
115
|
+
|
|
116
|
+
implicitlyGroundedEquivalences = implicitlyGroundedEquivalencesFromRemainingEquivalencesAndDefinedVariables(remainingEquivalences, definedVariables);
|
|
117
|
+
|
|
118
|
+
implicitlyGroundedEquivalencesLength = implicitlyGroundedEquivalences.length;
|
|
119
|
+
|
|
120
|
+
while (implicitlyGroundedEquivalencesLength > 0) {
|
|
121
|
+
groundedEquivalences = implicitlyGroundedEquivalences; ///
|
|
122
|
+
|
|
123
|
+
definedVariablesFromGroundedEquivalences(groundedEquivalences, definedVariables, context);
|
|
124
|
+
|
|
125
|
+
implicitlyGroundedEquivalences = implicitlyGroundedEquivalencesFromRemainingEquivalencesAndDefinedVariables(remainingEquivalences, definedVariables);
|
|
126
|
+
|
|
127
|
+
implicitlyGroundedEquivalencesLength = implicitlyGroundedEquivalences.length;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
compressDefinedVariables(definedVariables);
|
|
131
|
+
|
|
132
|
+
const definedVariablesIncludesVariable = definedVariables.includes(variable);
|
|
133
|
+
|
|
134
|
+
variableDefined = definedVariablesIncludesVariable; ///
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return variableDefined;
|
|
138
|
+
}
|
|
139
|
+
|
|
88
140
|
addEquality(equality) {
|
|
89
141
|
let equalityAdded;
|
|
90
142
|
|
|
@@ -95,36 +147,45 @@ class LocalContext {
|
|
|
95
147
|
} else {
|
|
96
148
|
const leftTerm = equality.getLeftTerm(),
|
|
97
149
|
rightTerm = equality.getRightTerm(),
|
|
98
|
-
|
|
99
|
-
|
|
150
|
+
leftEquivalence = findEquivalenceByTerm(this.equivalences, leftTerm),
|
|
151
|
+
rightEquivalence = findEquivalenceByTerm(this.equivalences, rightTerm);
|
|
100
152
|
|
|
101
153
|
if (false) {
|
|
102
154
|
///
|
|
103
|
-
} else if ((
|
|
104
|
-
const
|
|
155
|
+
} else if ((leftEquivalence === null) && (rightEquivalence === null)) {
|
|
156
|
+
const equivalence = Equivalence.fromLeftTermAndRightTerm(leftTerm, rightTerm);
|
|
105
157
|
|
|
106
|
-
this.
|
|
158
|
+
this.addEquivalence(equivalence);
|
|
107
159
|
|
|
108
160
|
equalityAdded = true;
|
|
109
|
-
} else if ((
|
|
110
|
-
|
|
161
|
+
} else if ((leftEquivalence !== null) && (rightEquivalence === null)) {
|
|
162
|
+
leftEquivalence.addTerm(rightTerm);
|
|
111
163
|
|
|
112
164
|
equalityAdded = true;
|
|
113
|
-
} else if ((
|
|
114
|
-
|
|
165
|
+
} else if ((leftEquivalence === null) && (rightEquivalence !== null)) {
|
|
166
|
+
rightEquivalence.addTerm(leftTerm);
|
|
115
167
|
|
|
116
168
|
equalityAdded = true;
|
|
117
|
-
} else if ((
|
|
118
|
-
|
|
119
|
-
const collection = leftCollection; ///
|
|
120
|
-
|
|
121
|
-
collection.addTerm(leftTerm);
|
|
122
|
-
collection.addTerm(rightTerm);
|
|
169
|
+
} else if ((leftEquivalence !== null) && (rightEquivalence !== null)) {
|
|
170
|
+
let equivalence;
|
|
123
171
|
|
|
124
|
-
|
|
172
|
+
if (leftEquivalence === rightEquivalence) {
|
|
173
|
+
equivalence = leftEquivalence; ///
|
|
125
174
|
} else {
|
|
126
|
-
|
|
175
|
+
equivalence = Equivalence.merge(leftEquivalence, rightEquivalence);
|
|
176
|
+
|
|
177
|
+
this.removeEquivalence(leftEquivalence);
|
|
178
|
+
|
|
179
|
+
this.removeEquivalence(rightEquivalence);
|
|
180
|
+
|
|
181
|
+
this.addEquivalence(equivalence);
|
|
127
182
|
}
|
|
183
|
+
|
|
184
|
+
equivalence.addTerm(leftTerm);
|
|
185
|
+
|
|
186
|
+
equivalence.addTerm(rightTerm);
|
|
187
|
+
|
|
188
|
+
equalityAdded = true;
|
|
128
189
|
}
|
|
129
190
|
}
|
|
130
191
|
|
|
@@ -156,8 +217,8 @@ class LocalContext {
|
|
|
156
217
|
this.proofSteps.push(proofStep);
|
|
157
218
|
}
|
|
158
219
|
|
|
159
|
-
|
|
160
|
-
this.
|
|
220
|
+
addEquivalence(equivalence) {
|
|
221
|
+
this.equivalences.push(equivalence);
|
|
161
222
|
}
|
|
162
223
|
|
|
163
224
|
matchStatement(statementNode) {
|
|
@@ -182,6 +243,14 @@ class LocalContext {
|
|
|
182
243
|
return statementMatches;
|
|
183
244
|
}
|
|
184
245
|
|
|
246
|
+
removeEquivalence(equivalence) {
|
|
247
|
+
const index = this.equivalences.indexOf(equivalence),
|
|
248
|
+
start = index, ///
|
|
249
|
+
deleteCount = 1;
|
|
250
|
+
|
|
251
|
+
this.equivalences.splice(start, deleteCount);
|
|
252
|
+
}
|
|
253
|
+
|
|
185
254
|
findVariableByVariableNode(variableNode) {
|
|
186
255
|
const node = variableNode, ///
|
|
187
256
|
variables = this.getVariables(),
|
|
@@ -222,8 +291,8 @@ class LocalContext {
|
|
|
222
291
|
const context = fileContext, ///
|
|
223
292
|
variables = [],
|
|
224
293
|
proofSteps = [],
|
|
225
|
-
|
|
226
|
-
localContext = new LocalContext(context, variables, proofSteps,
|
|
294
|
+
equivalences = [],
|
|
295
|
+
localContext = new LocalContext(context, variables, proofSteps, equivalences);
|
|
227
296
|
|
|
228
297
|
return localContext;
|
|
229
298
|
}
|
|
@@ -232,9 +301,9 @@ class LocalContext {
|
|
|
232
301
|
const context = localContext, ///
|
|
233
302
|
variables = [],
|
|
234
303
|
proofSteps = [],
|
|
235
|
-
|
|
304
|
+
equivalences = [];
|
|
236
305
|
|
|
237
|
-
localContext = new LocalContext(context, variables, proofSteps,
|
|
306
|
+
localContext = new LocalContext(context, variables, proofSteps, equivalences);
|
|
238
307
|
|
|
239
308
|
return localContext;
|
|
240
309
|
}
|
|
@@ -253,8 +322,8 @@ class LocalContext {
|
|
|
253
322
|
|
|
254
323
|
const context = fileContext, ///
|
|
255
324
|
proofSteps = [],
|
|
256
|
-
|
|
257
|
-
localContext = new LocalContext(context, variables, proofSteps,
|
|
325
|
+
equivalences = [],
|
|
326
|
+
localContext = new LocalContext(context, variables, proofSteps, equivalences);
|
|
258
327
|
|
|
259
328
|
return localContext;
|
|
260
329
|
}
|
package/src/context/localMeta.js
CHANGED
|
@@ -25,8 +25,8 @@ class LocalMetaContext {
|
|
|
25
25
|
let metavariables = this.context.getMetavariables();
|
|
26
26
|
|
|
27
27
|
metavariables = [ ///
|
|
28
|
-
...this.metavariables,
|
|
29
28
|
...metavariables,
|
|
29
|
+
...this.metavariables
|
|
30
30
|
]
|
|
31
31
|
|
|
32
32
|
return metavariables;
|
|
@@ -36,8 +36,8 @@ class LocalMetaContext {
|
|
|
36
36
|
let metaproofSteps = this.context.getMetaproofSteps();
|
|
37
37
|
|
|
38
38
|
metaproofSteps = [ ///
|
|
39
|
-
...
|
|
40
|
-
...metaproofSteps
|
|
39
|
+
...metaproofSteps,
|
|
40
|
+
...this.metaproofSteps
|
|
41
41
|
];
|
|
42
42
|
|
|
43
43
|
return metaproofSteps;
|
package/src/context/release.js
CHANGED
|
@@ -343,16 +343,16 @@ export default class ReleaseContext {
|
|
|
343
343
|
releaseContexts = releaseContexts.slice(); ///
|
|
344
344
|
|
|
345
345
|
const combinedCustomGrammar = combinedCustomGrammarFromReleaseContexts(releaseContexts),
|
|
346
|
-
|
|
347
|
-
dependencyReleaseContexts = releaseContexts; ///
|
|
348
|
-
|
|
349
|
-
const florenceLexer = florenceLexerFromCombinedCustomGrammar(combinedCustomGrammar),
|
|
346
|
+
florenceLexer = florenceLexerFromCombinedCustomGrammar(combinedCustomGrammar),
|
|
350
347
|
florenceParser = florenceParserFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
351
348
|
|
|
352
349
|
this.lexer = florenceLexer; ///
|
|
353
350
|
|
|
354
351
|
this.parser = florenceParser; ///
|
|
355
352
|
|
|
353
|
+
const releaseContext = releaseContexts.shift(),
|
|
354
|
+
dependencyReleaseContexts = releaseContexts; ///
|
|
355
|
+
|
|
356
356
|
this.dependencyReleaseContexts = dependencyReleaseContexts;
|
|
357
357
|
|
|
358
358
|
if (this.json !== null) {
|
|
@@ -360,10 +360,7 @@ export default class ReleaseContext {
|
|
|
360
360
|
|
|
361
361
|
fileContextsJSON.forEach((fileContextJSON) => {
|
|
362
362
|
const json = fileContextJSON, ///
|
|
363
|
-
|
|
364
|
-
fileContext = FileContext.fromFilePathAndReleaseContext(filePath, releaseContext);
|
|
365
|
-
|
|
366
|
-
fileContext.initialise(json);
|
|
363
|
+
fileContext = FileContext.fromJSONAndReleaseContext(json, releaseContext);
|
|
367
364
|
|
|
368
365
|
this.fileContexts.push(fileContext);
|
|
369
366
|
});
|
|
@@ -394,4 +391,4 @@ export default class ReleaseContext {
|
|
|
394
391
|
|
|
395
392
|
return releaseContext;
|
|
396
393
|
}
|
|
397
|
-
}
|
|
394
|
+
}
|
package/src/equality.js
CHANGED
|
@@ -35,9 +35,9 @@ export default class Equality {
|
|
|
35
35
|
rightTermNode = rightTerm.getNode(),
|
|
36
36
|
nonTerminalNodeA = leftTermNode, ///
|
|
37
37
|
nonTerminalNodeB = rightTermNode, ///
|
|
38
|
-
|
|
38
|
+
equivalences = context.getEquivalences(),
|
|
39
39
|
localContext = this, ///
|
|
40
|
-
nonTerminalNodeVerified = equalityNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB,
|
|
40
|
+
nonTerminalNodeVerified = equalityNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, equivalences, localContext, () => {
|
|
41
41
|
const verifiedAhead = true;
|
|
42
42
|
|
|
43
43
|
return verifiedAhead;
|
|
@@ -4,7 +4,7 @@ import { nodeQuery } from "./utilities/query";
|
|
|
4
4
|
|
|
5
5
|
const variableNodeQuery = nodeQuery("/term/variable!");
|
|
6
6
|
|
|
7
|
-
export default class
|
|
7
|
+
export default class Equivalence {
|
|
8
8
|
constructor(terms) {
|
|
9
9
|
this.terms = terms;
|
|
10
10
|
}
|
|
@@ -68,6 +68,18 @@ export default class Collection {
|
|
|
68
68
|
return termMatches;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
matchTerms(terms) {
|
|
72
|
+
const termsMatch = terms.every((term) => {
|
|
73
|
+
const termMatches = this.matchTerm(term);
|
|
74
|
+
|
|
75
|
+
if (termMatches) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
return termsMatch;
|
|
81
|
+
}
|
|
82
|
+
|
|
71
83
|
matchTermNode(termNode) {
|
|
72
84
|
const termNodeA = termNode, ///
|
|
73
85
|
termNodeMatches = this.terms.some((term) => {
|
|
@@ -83,18 +95,6 @@ export default class Collection {
|
|
|
83
95
|
return termNodeMatches;
|
|
84
96
|
}
|
|
85
97
|
|
|
86
|
-
matchTerms(terms) {
|
|
87
|
-
const termsMatch = terms.every((term) => {
|
|
88
|
-
const termMatches = this.matchTerm(term);
|
|
89
|
-
|
|
90
|
-
if (termMatches) {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
return termsMatch;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
98
|
matchTermNodes(termNodes) {
|
|
99
99
|
const termNodesMatch = termNodes.every((termNode) => {
|
|
100
100
|
const termNodeMatches = this.matchTermNode(termNode);
|
|
@@ -107,28 +107,84 @@ export default class Collection {
|
|
|
107
107
|
return termNodesMatch;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
110
|
+
getVariables(context) {
|
|
111
|
+
const variables = [];
|
|
112
|
+
|
|
113
|
+
this.terms.forEach((term) => {
|
|
114
|
+
term.getVariables(variables, context);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
return variables;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
isInitiallyGrounded() {
|
|
121
|
+
const initiallyGroundedTerms = this.getInitiallyGroundedTerms(),
|
|
122
|
+
initiallyGroundedTermsLength = initiallyGroundedTerms.length,
|
|
123
|
+
initiallyGrounded = (initiallyGroundedTermsLength > 0);
|
|
124
|
+
|
|
125
|
+
return initiallyGrounded;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
isImplicitlyGrounded(definedVariables) {
|
|
129
|
+
const implicitlyGroundedTerms = this.getImplicitlyGroundedTerms(definedVariables),
|
|
130
|
+
implicitlyGroundedTermsLength = implicitlyGroundedTerms.length,
|
|
131
|
+
implicitlyGrounded = (implicitlyGroundedTermsLength > 0);
|
|
132
|
+
|
|
133
|
+
return implicitlyGrounded;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
getInitiallyGroundedTerms() {
|
|
137
|
+
const initiallyGroundedTerms = this.terms.reduce((initiallyGroundedTerms, term) => {
|
|
138
|
+
const termInitiallyGrounded = term.isInitiallyGrounded();
|
|
139
|
+
|
|
140
|
+
if (termInitiallyGrounded) {
|
|
141
|
+
const initiallyGroundedTerm = term; ///
|
|
142
|
+
|
|
143
|
+
initiallyGroundedTerms.push(initiallyGroundedTerm);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return initiallyGroundedTerms;
|
|
147
|
+
}, []);
|
|
148
|
+
|
|
149
|
+
return initiallyGroundedTerms;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
getImplicitlyGroundedTerms(definedVariables) {
|
|
153
|
+
const implicitlyGroundedTerms = this.terms.reduce((implicitlyGroundedTerms, term) => {
|
|
154
|
+
const termImplicitlyGrounded = term.isImplicitlyGrounded(definedVariables);
|
|
155
|
+
|
|
156
|
+
if (termImplicitlyGrounded) {
|
|
157
|
+
const implicitlyGroundedTerm = term; ///
|
|
158
|
+
|
|
159
|
+
implicitlyGroundedTerms.push(implicitlyGroundedTerm);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return implicitlyGroundedTerms;
|
|
163
|
+
}, []);
|
|
164
|
+
|
|
165
|
+
return implicitlyGroundedTerms;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
static merge(leftEquivalence, rightEquivalence) {
|
|
169
|
+
const leftEquivalenceTerms = leftEquivalence.getTerms(),
|
|
170
|
+
rightEquivalenceTerms = rightEquivalence.getTerms(),
|
|
113
171
|
terms = [
|
|
114
|
-
|
|
115
|
-
|
|
172
|
+
...leftEquivalenceTerms,
|
|
173
|
+
...rightEquivalenceTerms
|
|
116
174
|
],
|
|
117
|
-
|
|
175
|
+
equivalence = new Equivalence(terms);
|
|
118
176
|
|
|
119
|
-
return
|
|
177
|
+
return equivalence;
|
|
120
178
|
}
|
|
121
179
|
|
|
122
|
-
static
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
...collectionATerms,
|
|
127
|
-
...collectionBTerms
|
|
180
|
+
static fromLeftTermAndRightTerm(leftTerm, rightTerm) {
|
|
181
|
+
const terms = [
|
|
182
|
+
leftTerm,
|
|
183
|
+
rightTerm
|
|
128
184
|
],
|
|
129
|
-
|
|
185
|
+
equivalence = new Equivalence(terms);
|
|
130
186
|
|
|
131
|
-
return
|
|
187
|
+
return equivalence;
|
|
132
188
|
}
|
|
133
189
|
}
|
|
134
190
|
|
package/src/log.js
CHANGED
|
@@ -106,8 +106,8 @@ export default class Log {
|
|
|
106
106
|
function formatMessage(level, message, node = null, tokens = null, filePath = null) {
|
|
107
107
|
const upperCaseLevel = level.toUpperCase();
|
|
108
108
|
|
|
109
|
-
if (node === null) {
|
|
110
|
-
message = `${upperCaseLevel}: ${message}`;
|
|
109
|
+
if ((node === null) || (tokens === null)) {
|
|
110
|
+
message = `${upperCaseLevel}: ${filePath} - ${message}`;
|
|
111
111
|
} else {
|
|
112
112
|
const leastLineIndex = leastLineIndexFromNodeAndTokens(node, tokens),
|
|
113
113
|
leastLineNumber = leastLineIndex, ///
|
package/src/term.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { nodesQuery } from "./utilities/query"
|
|
4
|
+
|
|
5
|
+
const variableNodesQuery = nodesQuery("//variable");
|
|
6
|
+
|
|
3
7
|
export default class Term {
|
|
4
8
|
constructor(node, type) {
|
|
5
9
|
this.node = node;
|
|
@@ -21,6 +25,50 @@ export default class Term {
|
|
|
21
25
|
return matches;
|
|
22
26
|
}
|
|
23
27
|
|
|
28
|
+
getVariables(variables, context) {
|
|
29
|
+
const variableNodes = variableNodesQuery(this.node);
|
|
30
|
+
|
|
31
|
+
variableNodes.forEach((variableNode) => {
|
|
32
|
+
const variable = context.findVariableByVariableNode(variableNode),
|
|
33
|
+
variablesIncludesVariable = variables.includes(variable);
|
|
34
|
+
|
|
35
|
+
if (!variablesIncludesVariable) {
|
|
36
|
+
variables.push(variable);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return variables;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
isInitiallyGrounded() {
|
|
44
|
+
const definedVariables = [],
|
|
45
|
+
implicitlyGrounded = this.isImplicitlyGrounded(definedVariables),
|
|
46
|
+
initiallyGrounded = implicitlyGrounded; ///
|
|
47
|
+
|
|
48
|
+
return initiallyGrounded;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
isImplicitlyGrounded(definedVariables) {
|
|
52
|
+
const variableNodes = variableNodesQuery(this.node),
|
|
53
|
+
variables = definedVariables, ///
|
|
54
|
+
nodes = variableNodes, ///
|
|
55
|
+
implicitlyGrounded = nodes.every((node) => {
|
|
56
|
+
const variableMatchesNode = variables.some((variable) => {
|
|
57
|
+
const variableMatchesNode = variable.matchNode(node);
|
|
58
|
+
|
|
59
|
+
if (variableMatchesNode) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (variableMatchesNode) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return implicitlyGrounded;
|
|
70
|
+
}
|
|
71
|
+
|
|
24
72
|
static fromTermNodeAndType(termNode, type) {
|
|
25
73
|
const node = termNode, ///
|
|
26
74
|
term = new Term(node, type);
|
package/src/utilities/array.js
CHANGED
|
@@ -6,7 +6,7 @@ import permutationsMatrix from "../permutationsMatrix";
|
|
|
6
6
|
|
|
7
7
|
import { MAXIMUM_INDEXES_LENGTH, MAXIMUM_PERMUTATION_LENGTH } from "../constants";
|
|
8
8
|
|
|
9
|
-
export const { first, second,
|
|
9
|
+
export const { first, second, last, push, prune, match, filter, compress, separate } = arrayUtilities;
|
|
10
10
|
|
|
11
11
|
export function someSubArray(array, subArrayLength, callback) {
|
|
12
12
|
let found = false;
|