occam-verify-cli 0.0.842 → 0.0.844
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.js +8 -1
- package/lib/context/local.js +22 -21
- package/lib/equivalence.js +24 -14
- package/lib/log.js +2 -2
- package/lib/substitution/statementForMetavariable.js +67 -10
- package/lib/substitution/termForVariable.js +56 -1
- package/lib/term.js +22 -17
- package/lib/utilities/array.js +11 -1
- package/lib/utilities/equivalences.js +83 -67
- package/lib/verifier/nodes/metaLevelToIntrinsicLevel.js +69 -18
- package/lib/verify/defining.js +41 -13
- package/package.json +1 -1
- package/src/context/file.js +6 -0
- package/src/context/local.js +29 -41
- package/src/equivalence.js +26 -14
- package/src/log.js +3 -1
- package/src/substitution/statementForMetavariable.js +70 -6
- package/src/substitution/termForVariable.js +77 -1
- package/src/term.js +29 -23
- package/src/utilities/array.js +6 -0
- package/src/utilities/equivalences.js +114 -67
- package/src/verifier/nodes/metaLevelToIntrinsicLevel.js +44 -26
- package/src/verify/defining.js +49 -14
package/src/context/local.js
CHANGED
|
@@ -5,12 +5,7 @@ import Equivalence from "../equivalence";
|
|
|
5
5
|
import contextMixins from "../mixins/context";
|
|
6
6
|
|
|
7
7
|
import { last } from "../utilities/array";
|
|
8
|
-
import { mergeEquivalences,
|
|
9
|
-
separateEquivalences,
|
|
10
|
-
findEquivalenceByTerm,
|
|
11
|
-
compressDefinedVariables,
|
|
12
|
-
definedVariablesFromGroundedEquivalences,
|
|
13
|
-
implicitlyGroundedEquivalencesFromRemainingEquivalencesAndDefinedVariables } from "../utilities/equivalences";
|
|
8
|
+
import { mergeEquivalences, findEquivalenceByTerm, groundedTermsAndDefinedVariablesFromFromEquivalences } from "../utilities/equivalences";
|
|
14
9
|
|
|
15
10
|
class LocalContext {
|
|
16
11
|
constructor(context, variables, proofSteps, equivalences) {
|
|
@@ -90,49 +85,42 @@ class LocalContext {
|
|
|
90
85
|
return termType;
|
|
91
86
|
}
|
|
92
87
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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);
|
|
88
|
+
isTermGrounded(term) {
|
|
89
|
+
const context = this,
|
|
90
|
+
equivalences = this.getEquivalences(),
|
|
91
|
+
groundedTerms = [],
|
|
92
|
+
definedVariables = [];
|
|
117
93
|
|
|
118
|
-
|
|
94
|
+
groundedTermsAndDefinedVariablesFromFromEquivalences(equivalences, groundedTerms, definedVariables, context);
|
|
119
95
|
|
|
120
|
-
|
|
121
|
-
|
|
96
|
+
const termMatchesGroundedTerm = groundedTerms.some((groundedTerm) => {
|
|
97
|
+
const termMatchesGroundedTerm = term.match(groundedTerm);
|
|
122
98
|
|
|
123
|
-
|
|
99
|
+
if (termMatchesGroundedTerm) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
}),
|
|
103
|
+
termGrounded = termMatchesGroundedTerm; ///
|
|
124
104
|
|
|
125
|
-
|
|
105
|
+
return termGrounded;
|
|
106
|
+
}
|
|
126
107
|
|
|
127
|
-
|
|
128
|
-
|
|
108
|
+
isVariableDefined(variable) {
|
|
109
|
+
const context = this,
|
|
110
|
+
equivalences = this.getEquivalences(),
|
|
111
|
+
groundedTerms = [],
|
|
112
|
+
definedVariables = [];
|
|
129
113
|
|
|
130
|
-
|
|
114
|
+
groundedTermsAndDefinedVariablesFromFromEquivalences(equivalences, groundedTerms, definedVariables, context);
|
|
131
115
|
|
|
132
|
-
|
|
116
|
+
const variableMatchesDefinedVariable = definedVariables.some((definedVariable) => {
|
|
117
|
+
const variableMatchesDefinedVariable = variable.match(definedVariable);
|
|
133
118
|
|
|
134
|
-
|
|
135
|
-
|
|
119
|
+
if (variableMatchesDefinedVariable) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
variableDefined = variableMatchesDefinedVariable; ///
|
|
136
124
|
|
|
137
125
|
return variableDefined;
|
|
138
126
|
}
|
package/src/equivalence.js
CHANGED
|
@@ -107,35 +107,47 @@ export default class Equivalence {
|
|
|
107
107
|
return termNodesMatch;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
const variables = [];
|
|
112
|
-
|
|
110
|
+
getGroundedTerms(definedVariables, groundedTerms, context) {
|
|
113
111
|
this.terms.forEach((term) => {
|
|
114
|
-
term.
|
|
115
|
-
|
|
112
|
+
const termGrounded = term.isGrounded(definedVariables, context);
|
|
113
|
+
|
|
114
|
+
if (termGrounded) {
|
|
115
|
+
const termMatchesGroundedTerm = groundedTerms.some((groundedTerm) => {
|
|
116
|
+
const termMatchesGroundedTerm = term.match(groundedTerm);
|
|
117
|
+
|
|
118
|
+
if (termMatchesGroundedTerm) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
})
|
|
116
122
|
|
|
117
|
-
|
|
123
|
+
if (!termMatchesGroundedTerm) {
|
|
124
|
+
const groundedTerm = term;
|
|
125
|
+
|
|
126
|
+
groundedTerms.push(groundedTerm);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
118
130
|
}
|
|
119
131
|
|
|
120
|
-
isInitiallyGrounded() {
|
|
121
|
-
const initiallyGroundedTerms = this.getInitiallyGroundedTerms(),
|
|
132
|
+
isInitiallyGrounded(context) {
|
|
133
|
+
const initiallyGroundedTerms = this.getInitiallyGroundedTerms(context),
|
|
122
134
|
initiallyGroundedTermsLength = initiallyGroundedTerms.length,
|
|
123
135
|
initiallyGrounded = (initiallyGroundedTermsLength > 0);
|
|
124
136
|
|
|
125
137
|
return initiallyGrounded;
|
|
126
138
|
}
|
|
127
139
|
|
|
128
|
-
isImplicitlyGrounded(definedVariables) {
|
|
129
|
-
const implicitlyGroundedTerms = this.getImplicitlyGroundedTerms(definedVariables),
|
|
140
|
+
isImplicitlyGrounded(definedVariables, context) {
|
|
141
|
+
const implicitlyGroundedTerms = this.getImplicitlyGroundedTerms(definedVariables, context),
|
|
130
142
|
implicitlyGroundedTermsLength = implicitlyGroundedTerms.length,
|
|
131
143
|
implicitlyGrounded = (implicitlyGroundedTermsLength > 0);
|
|
132
144
|
|
|
133
145
|
return implicitlyGrounded;
|
|
134
146
|
}
|
|
135
147
|
|
|
136
|
-
getInitiallyGroundedTerms() {
|
|
148
|
+
getInitiallyGroundedTerms(context) {
|
|
137
149
|
const initiallyGroundedTerms = this.terms.reduce((initiallyGroundedTerms, term) => {
|
|
138
|
-
const termInitiallyGrounded = term.isInitiallyGrounded();
|
|
150
|
+
const termInitiallyGrounded = term.isInitiallyGrounded(context);
|
|
139
151
|
|
|
140
152
|
if (termInitiallyGrounded) {
|
|
141
153
|
const initiallyGroundedTerm = term; ///
|
|
@@ -149,9 +161,9 @@ export default class Equivalence {
|
|
|
149
161
|
return initiallyGroundedTerms;
|
|
150
162
|
}
|
|
151
163
|
|
|
152
|
-
getImplicitlyGroundedTerms(definedVariables) {
|
|
164
|
+
getImplicitlyGroundedTerms(definedVariables, context) {
|
|
153
165
|
const implicitlyGroundedTerms = this.terms.reduce((implicitlyGroundedTerms, term) => {
|
|
154
|
-
const termImplicitlyGrounded = term.isImplicitlyGrounded(definedVariables);
|
|
166
|
+
const termImplicitlyGrounded = term.isImplicitlyGrounded(definedVariables, context);
|
|
155
167
|
|
|
156
168
|
if (termImplicitlyGrounded) {
|
|
157
169
|
const implicitlyGroundedTerm = term; ///
|
package/src/log.js
CHANGED
|
@@ -107,7 +107,9 @@ function formatMessage(level, message, node = null, tokens = null, filePath = nu
|
|
|
107
107
|
const upperCaseLevel = level.toUpperCase();
|
|
108
108
|
|
|
109
109
|
if ((node === null) || (tokens === null)) {
|
|
110
|
-
message =
|
|
110
|
+
message = (filePath !== null) ?
|
|
111
|
+
`${upperCaseLevel}: ${filePath} - ${message}`:
|
|
112
|
+
`${upperCaseLevel}: ${message}`;
|
|
111
113
|
} else {
|
|
112
114
|
const leastLineIndex = leastLineIndexFromNodeAndTokens(node, tokens),
|
|
113
115
|
leastLineNumber = leastLineIndex, ///
|
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
import Substitution from "../substitution";
|
|
4
4
|
|
|
5
|
+
import TermForVariableSubstitution from "./termForVariable";
|
|
6
|
+
import intrinsicLevelNodesVerifier from "../verifier/nodes/intrinsicLevel";
|
|
7
|
+
|
|
5
8
|
import { bracketedStatementChildNodeFromStatementNode } from "../utilities/proof";
|
|
6
9
|
|
|
7
10
|
export default class StatementForMetavariableSubstitution extends Substitution {
|
|
8
|
-
constructor(metavariableNode, statementNode) {
|
|
11
|
+
constructor(metavariableNode, statementNode, substitution) {
|
|
9
12
|
super();
|
|
10
13
|
|
|
11
14
|
this.metavariableNode = metavariableNode;
|
|
12
15
|
this.statementNode = statementNode;
|
|
16
|
+
this.substitution = substitution;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
getMetavariableNode() {
|
|
@@ -20,10 +24,14 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
20
24
|
return this.statementNode;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
getSubstitution() {
|
|
28
|
+
return this.substitution;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
matchStatementNode(statementNode, substitutions, localContextA, localContextB) {
|
|
24
32
|
let statementNodeMatches;
|
|
25
33
|
|
|
26
|
-
statementNodeMatches = this.
|
|
34
|
+
statementNodeMatches = this.matchStatementNodeEx(statementNode, substitutions, localContextA, localContextB);
|
|
27
35
|
|
|
28
36
|
if (!statementNodeMatches) {
|
|
29
37
|
const bracketedStatementChildNode = bracketedStatementChildNodeFromStatementNode(statementNode);
|
|
@@ -31,13 +39,29 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
31
39
|
if (bracketedStatementChildNode !== null) {
|
|
32
40
|
const statementNode = bracketedStatementChildNode; ///
|
|
33
41
|
|
|
34
|
-
statementNodeMatches = this.
|
|
42
|
+
statementNodeMatches = this.matchStatementNodeEx(statementNode, substitutions, localContextA, localContextB);
|
|
35
43
|
}
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
return statementNodeMatches;
|
|
39
47
|
}
|
|
40
48
|
|
|
49
|
+
matchStatementNodeEx(statementNode, substitutions, localContextA, localContextB) {
|
|
50
|
+
let statementNodeMatches;
|
|
51
|
+
|
|
52
|
+
if (this.substitution === null) {
|
|
53
|
+
statementNodeMatches = this.statementNode.match(statementNode);
|
|
54
|
+
} else {
|
|
55
|
+
const substitution = this.substitution,
|
|
56
|
+
statementNodeA = statementNode, ///
|
|
57
|
+
statementNodeB = this.statementNode; ///
|
|
58
|
+
|
|
59
|
+
statementNodeMatches = matchStatementNode(statementNodeA, statementNodeB, substitution, substitutions, localContextA, localContextB);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return statementNodeMatches;
|
|
63
|
+
}
|
|
64
|
+
|
|
41
65
|
matchMetavariableNode(metavariableNode) {
|
|
42
66
|
const metavariableNodeMatches = this.metavariableNode.match(metavariableNode);
|
|
43
67
|
|
|
@@ -45,16 +69,56 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
45
69
|
}
|
|
46
70
|
|
|
47
71
|
static fromMetavariableNodeAndStatementNode(metavariableNode, statementNode) {
|
|
48
|
-
|
|
72
|
+
const substitution = null;
|
|
73
|
+
|
|
74
|
+
let statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(metavariableNode, statementNode, substitution);
|
|
75
|
+
|
|
76
|
+
const bracketedStatementChildNode = bracketedStatementChildNodeFromStatementNode(statementNode);
|
|
77
|
+
|
|
78
|
+
if (bracketedStatementChildNode !== null) {
|
|
79
|
+
const statementNode = bracketedStatementChildNode; ///
|
|
80
|
+
|
|
81
|
+
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(metavariableNode, statementNode, substitution);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return statementForMetavariableSubstitution;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static fromMetavariableNodeStatementNodeAndSubstitution(metavariableNode, statementNode, substitution) {
|
|
88
|
+
let statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(metavariableNode, statementNode, substitution);
|
|
49
89
|
|
|
50
90
|
const bracketedStatementChildNode = bracketedStatementChildNodeFromStatementNode(statementNode);
|
|
51
91
|
|
|
52
92
|
if (bracketedStatementChildNode !== null) {
|
|
53
93
|
const statementNode = bracketedStatementChildNode; ///
|
|
54
94
|
|
|
55
|
-
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(metavariableNode, statementNode);
|
|
95
|
+
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(metavariableNode, statementNode, substitution);
|
|
56
96
|
}
|
|
57
97
|
|
|
58
98
|
return statementForMetavariableSubstitution;
|
|
59
99
|
}
|
|
60
100
|
}
|
|
101
|
+
|
|
102
|
+
export function matchStatementNode(statementNodeA, statementNodeB, substitution, substitutions, localContextA, localContextB) {
|
|
103
|
+
let statementNodeMatches;
|
|
104
|
+
|
|
105
|
+
const termForVariableSubstitution = TermForVariableSubstitution.fromSubstitutionAndSubstitutions(substitution, substitutions);
|
|
106
|
+
|
|
107
|
+
substitution = termForVariableSubstitution; ///
|
|
108
|
+
|
|
109
|
+
substitutions = [ ///
|
|
110
|
+
substitution
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
const nonTerminalNodeA = statementNodeA, ///
|
|
114
|
+
nonTerminalNodeB = statementNodeB, ///
|
|
115
|
+
nonTerminalNodeVerified = intrinsicLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
116
|
+
const verifiedAhead = true;
|
|
117
|
+
|
|
118
|
+
return verifiedAhead;
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
statementNodeMatches = nonTerminalNodeVerified; ///
|
|
122
|
+
|
|
123
|
+
return statementNodeMatches;
|
|
124
|
+
}
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import Substitution from "../substitution";
|
|
4
4
|
|
|
5
|
+
import { nodeQuery } from "../utilities/query";
|
|
6
|
+
|
|
7
|
+
const termNodeQuery = nodeQuery("/*/term!"),
|
|
8
|
+
variableNodeQuery = nodeQuery("/*/variable!");
|
|
9
|
+
|
|
5
10
|
export default class TermForVariableSubstitution extends Substitution {
|
|
6
11
|
constructor(variableNode, termNode) {
|
|
7
12
|
super();
|
|
@@ -30,9 +35,80 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
30
35
|
return variableNodeMatches;
|
|
31
36
|
}
|
|
32
37
|
|
|
38
|
+
static fromSubstitutionNode(substitutionNode) {
|
|
39
|
+
const termNode = termNodeQuery(substitutionNode),
|
|
40
|
+
variableNode = variableNodeQuery(substitutionNode),
|
|
41
|
+
termForVariableSubstitution = new TermForVariableSubstitution(variableNode, termNode);
|
|
42
|
+
|
|
43
|
+
return termForVariableSubstitution;
|
|
44
|
+
}
|
|
45
|
+
|
|
33
46
|
static fromVariableNodeAndTermNode(variableNode, termNode) {
|
|
34
47
|
const termForVariableSubstitution = new TermForVariableSubstitution(variableNode, termNode);
|
|
35
48
|
|
|
36
49
|
return termForVariableSubstitution;
|
|
37
50
|
}
|
|
38
|
-
|
|
51
|
+
|
|
52
|
+
static fromSubstitutionAndSubstitutions(substitution, substitutions) {
|
|
53
|
+
let termNode = substitution.getTermNode(),
|
|
54
|
+
variableNode = substitution.getVariableNode();
|
|
55
|
+
|
|
56
|
+
termNode = substituteTermNode(termNode, substitutions); ///
|
|
57
|
+
|
|
58
|
+
variableNode = substituteVariableNode(variableNode, substitutions); ///
|
|
59
|
+
|
|
60
|
+
const termForVariableSubstitution = new TermForVariableSubstitution(variableNode, termNode);
|
|
61
|
+
|
|
62
|
+
return termForVariableSubstitution;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static fromSubstitutionNodeAndSubstitutions(substitutionNode, substitutions) {
|
|
66
|
+
let termNode = termNodeQuery(substitutionNode),
|
|
67
|
+
variableNode = variableNodeQuery(substitutionNode);
|
|
68
|
+
|
|
69
|
+
termNode = substituteTermNode(termNode, substitutions); ///
|
|
70
|
+
|
|
71
|
+
variableNode = substituteVariableNode(variableNode, substitutions); ///
|
|
72
|
+
|
|
73
|
+
const termForVariableSubstitution = new TermForVariableSubstitution(variableNode, termNode);
|
|
74
|
+
|
|
75
|
+
return termForVariableSubstitution;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function substituteTermNode(termNode, substitutions) {
|
|
80
|
+
const termVariableNode = variableNodeQuery(termNode);
|
|
81
|
+
|
|
82
|
+
if (termVariableNode !== null) {
|
|
83
|
+
substitutions.some((substitution) => {
|
|
84
|
+
const variableNodeMatches = substitution.matchVariableNode(termVariableNode);
|
|
85
|
+
|
|
86
|
+
if (variableNodeMatches) {
|
|
87
|
+
termNode = substitution.getTermNode(); ///
|
|
88
|
+
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return termNode;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function substituteVariableNode(variableNode, substitutions) {
|
|
98
|
+
substitutions.some((substitution) => {
|
|
99
|
+
const variableNodeMatches = substitution.matchVariableNode(variableNode);
|
|
100
|
+
|
|
101
|
+
if (variableNodeMatches) {
|
|
102
|
+
const termNode = substitution.getTermNode(),
|
|
103
|
+
termVariableNode = variableNodeQuery(termNode);
|
|
104
|
+
|
|
105
|
+
if (termVariableNode !== null) {
|
|
106
|
+
variableNode = termVariableNode; ///
|
|
107
|
+
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
return variableNode;
|
|
114
|
+
}
|
package/src/term.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { filter } from "./utilities/array";
|
|
3
4
|
import { nodesQuery } from "./utilities/query"
|
|
4
5
|
|
|
5
6
|
const variableNodesQuery = nodesQuery("//variable");
|
|
@@ -25,8 +26,9 @@ export default class Term {
|
|
|
25
26
|
return matches;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
getVariables(
|
|
29
|
-
const
|
|
29
|
+
getVariables(context) {
|
|
30
|
+
const variables = [],
|
|
31
|
+
variableNodes = variableNodesQuery(this.node);
|
|
30
32
|
|
|
31
33
|
variableNodes.forEach((variableNode) => {
|
|
32
34
|
const variable = context.findVariableByVariableNode(variableNode),
|
|
@@ -40,31 +42,35 @@ export default class Term {
|
|
|
40
42
|
return variables;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
isGrounded(definedVariables, context) {
|
|
46
|
+
const variables = this.getVariables(context);
|
|
47
|
+
|
|
48
|
+
filter(variables, (variable) => {
|
|
49
|
+
const definedVariablesIncludesVariable = definedVariables.includes(variable);
|
|
50
|
+
|
|
51
|
+
if (!definedVariablesIncludesVariable) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const undefinedVariables = variables, ///
|
|
57
|
+
undefinedVariablesLength = undefinedVariables.length,
|
|
58
|
+
grounded = (undefinedVariablesLength <= 1);
|
|
59
|
+
|
|
60
|
+
return grounded;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
isInitiallyGrounded(context) {
|
|
64
|
+
const variables = this.getVariables(context),
|
|
65
|
+
variablesLength = variables.length,
|
|
66
|
+
initiallyGrounded = (variablesLength === 0);
|
|
47
67
|
|
|
48
68
|
return initiallyGrounded;
|
|
49
69
|
}
|
|
50
70
|
|
|
51
|
-
isImplicitlyGrounded(definedVariables) {
|
|
52
|
-
const
|
|
53
|
-
|
|
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
|
-
});
|
|
71
|
+
isImplicitlyGrounded(definedVariables, context) {
|
|
72
|
+
const grounded = this.isGrounded(definedVariables, context),
|
|
73
|
+
implicitlyGrounded = grounded; ///
|
|
68
74
|
|
|
69
75
|
return implicitlyGrounded;
|
|
70
76
|
}
|
package/src/utilities/array.js
CHANGED
|
@@ -29,6 +29,12 @@ export function someSubArray(array, subArrayLength, callback) {
|
|
|
29
29
|
permutations = permutationsMatrix[indexesLength][permutationLength];
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
if (subArrayLength === 4) {
|
|
33
|
+
permutations = [
|
|
34
|
+
[ 0, 2, 3, 4 ]
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
|
|
32
38
|
if (permutations !== null) {
|
|
33
39
|
found = permutations.some((permutation) => {
|
|
34
40
|
if (permutation !== null) {
|