occam-verify-cli 0.0.1066 → 0.0.1067
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/assertion/contained.js +2 -1
- package/lib/assertion/defined.js +2 -1
- package/lib/conclusion.js +6 -2
- package/lib/consequent.js +6 -2
- package/lib/context/file.js +7 -7
- package/lib/context/local.js +12 -25
- package/lib/metavariable.js +15 -54
- package/lib/mixins/statement/unify.js +17 -2
- package/lib/mixins/statement/verify.js +2 -11
- package/lib/premise.js +6 -2
- package/lib/proofStep.js +22 -13
- package/lib/rule.js +6 -2
- package/lib/statement/qualified.js +30 -17
- package/lib/statement/unqualified.js +5 -5
- package/lib/statement.js +18 -9
- package/lib/subproof.js +1 -1
- package/lib/substitution/frameForMetavariable.js +35 -27
- package/lib/substitution/statementForMetavariable.js +93 -54
- package/lib/substitution/termForVariable.js +30 -31
- package/lib/substitution.js +48 -13
- package/lib/substitutions.js +22 -19
- package/lib/supposition.js +6 -2
- package/lib/unifier/metaLevel.js +14 -11
- package/lib/unify/metavariableWithFrame.js +2 -2
- package/lib/variable.js +10 -10
- package/package.json +2 -2
- package/src/assertion/contained.js +2 -0
- package/src/assertion/defined.js +2 -0
- package/src/conclusion.js +8 -1
- package/src/consequent.js +8 -1
- package/src/context/file.js +6 -8
- package/src/context/local.js +12 -33
- package/src/metavariable.js +24 -74
- package/src/mixins/statement/unify.js +24 -1
- package/src/mixins/statement/verify.js +1 -15
- package/src/premise.js +8 -1
- package/src/proofStep.js +28 -12
- package/src/rule.js +7 -1
- package/src/statement/qualified.js +38 -21
- package/src/statement/unqualified.js +4 -4
- package/src/statement.js +18 -12
- package/src/subproof.js +0 -1
- package/src/substitution/frameForMetavariable.js +47 -42
- package/src/substitution/statementForMetavariable.js +102 -61
- package/src/substitution/termForVariable.js +41 -50
- package/src/substitution.js +40 -11
- package/src/substitutions.js +32 -25
- package/src/supposition.js +8 -1
- package/src/unifier/metaLevel.js +23 -17
- package/src/unify/metavariableWithFrame.js +2 -2
- package/src/variable.js +7 -7
- package/lib/resolve/complexSubstitutionAgainstSimpleSubstitution.js +0 -62
- package/lib/resolve/substitution.js +0 -27
- package/lib/resolve/substitutions.js +0 -37
- package/src/resolve/complexSubstitutionAgainstSimpleSubstitution.js +0 -79
- package/src/resolve/substitution.js +0 -19
- package/src/resolve/substitutions.js +0 -31
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import shim from "../shim";
|
|
3
4
|
import Substitution from "../substitution";
|
|
4
5
|
|
|
5
6
|
import { nodeQuery } from "../utilities/query";
|
|
@@ -10,11 +11,12 @@ const substitutionNodeQuery = nodeQuery("/statement/substitution"),
|
|
|
10
11
|
substitutionMetavariableNodeQuery = nodeQuery("/substitution/metavariable!");
|
|
11
12
|
|
|
12
13
|
export default class FrameForMetavariableSubstitution extends Substitution {
|
|
13
|
-
constructor(string, frameNode, metavariableNode) {
|
|
14
|
+
constructor(string, frameNode, metavariableNode, substitutionNode) {
|
|
14
15
|
super(string);
|
|
15
16
|
|
|
16
17
|
this.frameNode = frameNode;
|
|
17
18
|
this.metavariableNode = metavariableNode;
|
|
19
|
+
this.substitutionNode = substitutionNode;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
getFrameNode() {
|
|
@@ -25,10 +27,8 @@ export default class FrameForMetavariableSubstitution extends Substitution {
|
|
|
25
27
|
return this.metavariableNode;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return node;
|
|
30
|
+
getSubstitutionNode() {
|
|
31
|
+
return this.substitutionNode;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
transformed(substitutions) {
|
|
@@ -38,9 +38,11 @@ export default class FrameForMetavariableSubstitution extends Substitution {
|
|
|
38
38
|
transformedMetavariableNode = transformMetavariableNode(this.metavariableNode, substitutions);
|
|
39
39
|
|
|
40
40
|
if ((transformedFrameNode !== null) && (transformedMetavariableNode !== null)) {
|
|
41
|
-
const
|
|
41
|
+
const string = null, ///
|
|
42
|
+
frameNode = transformedFrameNode, ///
|
|
42
43
|
metavariableNode = transformedMetavariableNode, ///
|
|
43
|
-
|
|
44
|
+
substitutionNode = null,
|
|
45
|
+
frameForMetavariableSubstitution = new FrameForMetavariableSubstitution(string, frameNode, metavariableNode, substitutionNode);
|
|
44
46
|
|
|
45
47
|
transformedSubstitution = frameForMetavariableSubstitution; ///
|
|
46
48
|
}
|
|
@@ -49,11 +51,17 @@ export default class FrameForMetavariableSubstitution extends Substitution {
|
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
isEqualTo(substitution) {
|
|
54
|
+
let equalTo = false;
|
|
55
|
+
|
|
52
56
|
const frameNode = substitution.getFrameNode(),
|
|
53
|
-
metavariableNode = substitution.getMetavariableNode()
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
metavariableNode = substitution.getMetavariableNode();
|
|
58
|
+
|
|
59
|
+
if ((frameNode !== null) && (metavariableNode !== null)) {
|
|
60
|
+
const frameNodeMatches = this.matchFrameNode(frameNode),
|
|
61
|
+
metavariableNodeMatches = this.matchMetavariableNode(metavariableNode);
|
|
62
|
+
|
|
63
|
+
equalTo = (frameNodeMatches && metavariableNodeMatches);
|
|
64
|
+
}
|
|
57
65
|
|
|
58
66
|
return equalTo;
|
|
59
67
|
}
|
|
@@ -70,22 +78,18 @@ export default class FrameForMetavariableSubstitution extends Substitution {
|
|
|
70
78
|
return metavariableNodeMatches;
|
|
71
79
|
}
|
|
72
80
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const substitutionNode = substitution.getNode(),
|
|
77
|
-
substitutionFrameNode = substitutionFrameNodeQuery(substitutionNode);
|
|
81
|
+
matchSubstitutionNode(substitutionNode) {
|
|
82
|
+
const substitutionNodeMatches = this.substitutionNode.match(substitutionNode);
|
|
78
83
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
metavariableNode = substitutionMetavariableNode, ///
|
|
82
|
-
frameNode = substitutionFrameNode, ///
|
|
83
|
-
string = stringFromFrameNodeAndMetavariableNode(frameNode, metavariableNode, localContextA, localContextB);
|
|
84
|
+
return substitutionNodeMatches;
|
|
85
|
+
}
|
|
84
86
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
matchMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
|
|
88
|
+
const metavariableNodeMatches = this.matchMetavariableNode(metavariableNode),
|
|
89
|
+
substitutionNodeMatches = this.matchSubstitutionNode(substitutionNode),
|
|
90
|
+
metavariableNodeAndSubstitutionNodeMatches = (metavariableNodeMatches && substitutionNodeMatches);
|
|
87
91
|
|
|
88
|
-
return
|
|
92
|
+
return metavariableNodeAndSubstitutionNodeMatches;
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
static fromStatementNode(statementNode, localContext) {
|
|
@@ -94,29 +98,32 @@ export default class FrameForMetavariableSubstitution extends Substitution {
|
|
|
94
98
|
const substitutionNode = substitutionNodeQuery(statementNode);
|
|
95
99
|
|
|
96
100
|
if (substitutionNode !== null) {
|
|
97
|
-
|
|
101
|
+
let substitutionFrameNode = substitutionFrameNodeQuery(substitutionNode);
|
|
98
102
|
|
|
99
103
|
if (substitutionFrameNode !== null) {
|
|
100
|
-
const
|
|
104
|
+
const { Frame, Metavariable } = shim,
|
|
105
|
+
substitutionMetavariableNode = substitutionMetavariableNodeQuery(substitutionNode),
|
|
101
106
|
metavariableNode = substitutionMetavariableNode, ///
|
|
102
107
|
frameNode = substitutionFrameNode, ///
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
string =
|
|
108
|
+
frame = Frame.fromTermNode(frameNode, localContext),
|
|
109
|
+
variable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
|
|
110
|
+
string = stringFromFrameAndMetavariable(frame, variable, localContext);
|
|
106
111
|
|
|
107
|
-
frameForMetavariableSubstitution = new FrameForMetavariableSubstitution(string, frameNode, metavariableNode);
|
|
112
|
+
frameForMetavariableSubstitution = new FrameForMetavariableSubstitution(string, frameNode, metavariableNode, substitutionNode);
|
|
108
113
|
}
|
|
109
|
-
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
return frameForMetavariableSubstitution;
|
|
113
117
|
}
|
|
114
118
|
|
|
115
|
-
static
|
|
116
|
-
const string =
|
|
117
|
-
|
|
119
|
+
static fromFrameAndMetavariable(frame, metavariable, localContext) {
|
|
120
|
+
const string = stringFromFrameAndMetavariable(frame, metavariable, localContext),
|
|
121
|
+
frameNode = frame.getNode(),
|
|
122
|
+
metavariableNode = metavariable.getNode(),
|
|
123
|
+
substitutionNode = null,
|
|
124
|
+
statementForMetavariableSubstitution = new FrameForMetavariableSubstitution(string, frameNode, metavariableNode, substitutionNode);
|
|
118
125
|
|
|
119
|
-
return
|
|
126
|
+
return statementForMetavariableSubstitution;
|
|
120
127
|
}
|
|
121
128
|
}
|
|
122
129
|
|
|
@@ -165,13 +172,11 @@ function transformMetavariableNode(metavariableNode, substitutions) {
|
|
|
165
172
|
return transformedMetavariableNode;
|
|
166
173
|
}
|
|
167
174
|
|
|
168
|
-
function
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
string = `[${frameStringB} for ${metavariableStringA}]`;
|
|
175
|
+
function stringFromFrameAndMetavariable(frame, metavariable, localContext) {
|
|
176
|
+
const frameNode = frame.getNode(),
|
|
177
|
+
frameString = localContext.nodeAsString(frameNode),
|
|
178
|
+
metavariableString = metavariable.getString(),
|
|
179
|
+
string = `[[${frameString}] for [${metavariableString}]]`;
|
|
174
180
|
|
|
175
181
|
return string;
|
|
176
182
|
}
|
|
177
|
-
|
|
@@ -2,36 +2,41 @@
|
|
|
2
2
|
|
|
3
3
|
import shim from "../shim";
|
|
4
4
|
import Substitution from "../substitution";
|
|
5
|
-
import
|
|
6
|
-
import FrameForMetavariableSubstitution from "../substitution/frameForMetavariable";
|
|
5
|
+
import Substitutions from "../substitutions";
|
|
7
6
|
|
|
8
7
|
import { stripBracketsFromStatement } from "../utilities/brackets";
|
|
9
8
|
|
|
10
9
|
export default class StatementForMetavariableSubstitution extends Substitution {
|
|
11
|
-
constructor(string,
|
|
10
|
+
constructor(string, statement, metavariable, substitution) {
|
|
12
11
|
super(string);
|
|
13
12
|
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
13
|
+
this.statement = statement;
|
|
14
|
+
this.metavariable = metavariable;
|
|
16
15
|
this.substitution = substitution;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
return this.
|
|
18
|
+
getStatement() {
|
|
19
|
+
return this.statement;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
return this.
|
|
22
|
+
getMetavariable() {
|
|
23
|
+
return this.metavariable;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
getSubstitution() {
|
|
28
27
|
return this.substitution;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
const
|
|
30
|
+
getStatementNode() {
|
|
31
|
+
const statementNode = this.statement.getNode();
|
|
32
|
+
|
|
33
|
+
return statementNode;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getMetavariableNode() {
|
|
37
|
+
const metavariableNode = this.metavariable.getNode();
|
|
33
38
|
|
|
34
|
-
return
|
|
39
|
+
return metavariableNode;
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
isSimple() {
|
|
@@ -40,89 +45,125 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
40
45
|
return simple;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
resolve(substitutions, localContext) {
|
|
49
|
+
let resolved = false;
|
|
45
50
|
|
|
46
|
-
const
|
|
51
|
+
const substitutionString = this.string;
|
|
47
52
|
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
localContext.trace(`Resolving the ${substitutionString} substitution...`);
|
|
54
|
+
|
|
55
|
+
const metavariableNode = this.getMetavariableNode(),
|
|
56
|
+
simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableNode(metavariableNode);
|
|
57
|
+
|
|
58
|
+
if (simpleSubstitution !== null) {
|
|
59
|
+
const substitution = simpleSubstitution, ///
|
|
60
|
+
substitutionResolved = substitution.resolveSubstitution(this.substitution, this.statement, substitutions, localContext);
|
|
50
61
|
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
resolved = substitutionResolved; ///
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (resolved) {
|
|
66
|
+
localContext.debug(`...resolved the ${substitutionString} substitution.`);
|
|
67
|
+
}
|
|
53
68
|
|
|
54
|
-
return
|
|
69
|
+
return resolved;
|
|
55
70
|
}
|
|
56
71
|
|
|
57
|
-
|
|
58
|
-
let
|
|
72
|
+
resolveSubstitution(substitution, statement, substitutions, localContext) {
|
|
73
|
+
let substitutionResolved = false;
|
|
59
74
|
|
|
60
|
-
|
|
75
|
+
const substitutionString = substitution.getString();
|
|
61
76
|
|
|
62
|
-
|
|
77
|
+
localContext.trace(`Resolving the ${substitutionString} substitution...`);
|
|
63
78
|
|
|
64
|
-
|
|
79
|
+
const transformedSubstitution = substitution.transformed(substitutions, localContext);
|
|
65
80
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
metavariableNode = metavariable.getNode(),
|
|
69
|
-
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(string, statementNode, metavariableNode, substitution);
|
|
81
|
+
if (transformedSubstitution !== null) {
|
|
82
|
+
const transformedSubstitutionString = transformedSubstitution.getString();
|
|
70
83
|
|
|
71
|
-
|
|
72
|
-
}
|
|
84
|
+
localContext.trace(`Transformed the substitution to ${transformedSubstitutionString}...`);
|
|
73
85
|
|
|
74
|
-
|
|
75
|
-
let statementNode = statement.getNode();
|
|
86
|
+
substitutions = Substitutions.fromNothing(); ///
|
|
76
87
|
|
|
77
|
-
|
|
88
|
+
const localContextA = localContext, ///
|
|
89
|
+
localContextB = localContext, ///
|
|
90
|
+
statementUnified = this.statement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
78
91
|
|
|
79
|
-
|
|
92
|
+
if (statementUnified) {
|
|
93
|
+
const substitutionsLength = substitutions.getLength();
|
|
80
94
|
|
|
81
|
-
|
|
95
|
+
if (substitutionsLength === 1) {
|
|
96
|
+
const firstSubstitution = substitutions.getFirstSubstitution(),
|
|
97
|
+
substitution = firstSubstitution, ///
|
|
98
|
+
substitutionEqualToTransformedSubstitution = substitution.isEqualTo(transformedSubstitution);
|
|
82
99
|
|
|
83
|
-
|
|
84
|
-
|
|
100
|
+
substitutionResolved = substitutionEqualToTransformedSubstitution; ///
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
85
104
|
|
|
86
|
-
|
|
105
|
+
if (substitutionResolved) {
|
|
106
|
+
localContext.debug(`...resolved the ${substitutionString} substitution.`);
|
|
107
|
+
}
|
|
87
108
|
|
|
88
|
-
|
|
109
|
+
return substitutionResolved;
|
|
110
|
+
}
|
|
89
111
|
|
|
90
|
-
|
|
112
|
+
matchStatementNode(statementNode) {
|
|
113
|
+
statementNode = stripBracketsFromStatement(statementNode); ///
|
|
114
|
+
|
|
115
|
+
const statementNodeMatches = this.statement.matchStatementNode(statementNode);
|
|
116
|
+
|
|
117
|
+
return statementNodeMatches;
|
|
91
118
|
}
|
|
92
|
-
}
|
|
93
119
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
120
|
+
matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
|
|
121
|
+
|
|
122
|
+
matchSubstitutionNode(substitutionNode) {
|
|
123
|
+
let substitutionNodeMatches;
|
|
97
124
|
|
|
98
|
-
if (
|
|
99
|
-
|
|
125
|
+
if ((substitutionNode === null) && (this.substitution === null)) {
|
|
126
|
+
substitutionNodeMatches = true;
|
|
127
|
+
} else if ((substitutionNode === null) && (this.substitution !== null)) {
|
|
128
|
+
substitutionNodeMatches = false;
|
|
129
|
+
} else if ((substitutionNode !== null) && (this.substitution === null)) {
|
|
130
|
+
substitutionNodeMatches = false;
|
|
131
|
+
} else {
|
|
132
|
+
substitutionNodeMatches = this.substitution.matchSubstitutionNode(substitutionNode);
|
|
100
133
|
}
|
|
134
|
+
|
|
135
|
+
return substitutionNodeMatches;
|
|
101
136
|
}
|
|
102
137
|
|
|
103
|
-
|
|
104
|
-
const
|
|
138
|
+
matchMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
|
|
139
|
+
const metavariableNodeMatches = this.matchMetavariableNode(metavariableNode),
|
|
140
|
+
substitutionNodeMatches = this.matchSubstitutionNode(substitutionNode),
|
|
141
|
+
metavariableNodeAndSubstitutionNodeMatches = (metavariableNodeMatches && substitutionNodeMatches);
|
|
105
142
|
|
|
106
|
-
|
|
107
|
-
substitution = frameForMetavariableSubstitution; ///
|
|
108
|
-
}
|
|
143
|
+
return metavariableNodeAndSubstitutionNodeMatches;
|
|
109
144
|
}
|
|
110
145
|
|
|
111
|
-
|
|
112
|
-
|
|
146
|
+
static fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext) {
|
|
147
|
+
let statementNode = statement.getNode();
|
|
113
148
|
|
|
114
|
-
|
|
115
|
-
const statementString = statement.getString(),
|
|
116
|
-
metavariableString = metavariable.getString(),
|
|
117
|
-
string = `[${statementString} for ${metavariableString}]`;
|
|
149
|
+
statementNode = stripBracketsFromStatement(statementNode); ///
|
|
118
150
|
|
|
119
|
-
|
|
151
|
+
const { Statement } = shim;
|
|
152
|
+
|
|
153
|
+
statement = Statement.fromStatementNode(statementNode, localContext);
|
|
154
|
+
|
|
155
|
+
const string = stringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext),
|
|
156
|
+
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(string, statement, metavariable, substitution);
|
|
157
|
+
|
|
158
|
+
return statementForMetavariableSubstitution;
|
|
159
|
+
}
|
|
120
160
|
}
|
|
121
161
|
|
|
122
|
-
function stringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution) {
|
|
162
|
+
function stringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext) {
|
|
123
163
|
let string;
|
|
124
164
|
|
|
125
|
-
const
|
|
165
|
+
const statementNode = statement.getNode(),
|
|
166
|
+
statementString = localContext.nodeAsString(statementNode),
|
|
126
167
|
metavariableString = metavariable.getString();
|
|
127
168
|
|
|
128
169
|
if (substitution === null) {
|
|
@@ -12,11 +12,12 @@ const substitutionNodeQuery = nodeQuery("/statement/substitution"),
|
|
|
12
12
|
substitutionsVariableNodeQuery = nodeQuery("/substitution/variable!");
|
|
13
13
|
|
|
14
14
|
export default class TermForVariableSubstitution extends Substitution {
|
|
15
|
-
constructor(string, termNode, variableNode) {
|
|
15
|
+
constructor(string, termNode, variableNode, substitutionNode) {
|
|
16
16
|
super(string);
|
|
17
17
|
|
|
18
18
|
this.termNode = termNode;
|
|
19
19
|
this.variableNode = variableNode;
|
|
20
|
+
this.substitutionNode = substitutionNode;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
getTermNode() {
|
|
@@ -27,7 +28,11 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
27
28
|
return this.variableNode;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
getSubstitutionNode() {
|
|
32
|
+
return this.substitutionNode;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
transformed(substitutions, localContext) {
|
|
31
36
|
let transformedSubstitution = null;
|
|
32
37
|
|
|
33
38
|
const transformedTermNode = transformTermNode(this.termNode, substitutions),
|
|
@@ -36,7 +41,11 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
36
41
|
if ((transformedTermNode !== null) && (transformedVariableNode !== null)) {
|
|
37
42
|
const termNode = transformedTermNode, ///
|
|
38
43
|
variableNode = transformedVariableNode, ///
|
|
39
|
-
|
|
44
|
+
termString = localContext.nodeAsString(termNode),
|
|
45
|
+
variableString = localContext.nodeAsString(variableNode),
|
|
46
|
+
string = `[${termString} for ${variableString}]`,
|
|
47
|
+
substitutionNode = null,
|
|
48
|
+
termForVariableSubstitution = new TermForVariableSubstitution(string, termNode, variableNode, substitutionNode);
|
|
40
49
|
|
|
41
50
|
transformedSubstitution = termForVariableSubstitution; ///
|
|
42
51
|
}
|
|
@@ -45,11 +54,17 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
isEqualTo(substitution) {
|
|
57
|
+
let equalTo = false;
|
|
58
|
+
|
|
48
59
|
const termNode = substitution.getTermNode(),
|
|
49
|
-
variableNode = substitution.getVariableNode()
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
variableNode = substitution.getVariableNode();
|
|
61
|
+
|
|
62
|
+
if ((termNode !== null) && (variableNode !== null)) {
|
|
63
|
+
const termNodeMatches = this.matchTermNode(termNode),
|
|
64
|
+
variableNodeMatches = this.matchVariableNode(variableNode);
|
|
65
|
+
|
|
66
|
+
equalTo = (termNodeMatches && variableNodeMatches);
|
|
67
|
+
}
|
|
53
68
|
|
|
54
69
|
return equalTo;
|
|
55
70
|
}
|
|
@@ -68,6 +83,12 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
68
83
|
return variableNodeMatches;
|
|
69
84
|
}
|
|
70
85
|
|
|
86
|
+
matchSubstitutionNode(substitutionNode) {
|
|
87
|
+
const substitutionNodeMatches = this.substitutionNode.match(substitutionNode);
|
|
88
|
+
|
|
89
|
+
return substitutionNodeMatches;
|
|
90
|
+
}
|
|
91
|
+
|
|
71
92
|
unifyWithEquivalence(equivalence, substitutions, localContextA, localContextB) {
|
|
72
93
|
let unifiedWithEquivalence;
|
|
73
94
|
|
|
@@ -84,34 +105,6 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
84
105
|
return unifiedWithEquivalence;
|
|
85
106
|
}
|
|
86
107
|
|
|
87
|
-
static fromSubstitution(substitution, localContext) {
|
|
88
|
-
let termForVariableSubstitution = null;
|
|
89
|
-
|
|
90
|
-
const substitutionNode = substitution.getNode();
|
|
91
|
-
|
|
92
|
-
let substitutionTermNode = substitutionTermNodeQuery(substitutionNode);
|
|
93
|
-
|
|
94
|
-
if (substitutionTermNode !== null) {
|
|
95
|
-
let termNode;
|
|
96
|
-
|
|
97
|
-
const substitutionVariableNode = substitutionsVariableNodeQuery(substitutionNode),
|
|
98
|
-
variableNode = substitutionVariableNode; ///
|
|
99
|
-
|
|
100
|
-
termNode = substitutionTermNode; ///
|
|
101
|
-
|
|
102
|
-
termNode = stripBracketsFromTerm(termNode); ///
|
|
103
|
-
|
|
104
|
-
const { Term, Variable } = shim,
|
|
105
|
-
term = Term.fromTermNode(termNode, localContext),
|
|
106
|
-
variable = Variable.fromVariableNode(variableNode, localContext),
|
|
107
|
-
string = stringFromTermAndVariable(term, variable);
|
|
108
|
-
|
|
109
|
-
termForVariableSubstitution = new TermForVariableSubstitution(string, termNode, variableNode);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return termForVariableSubstitution;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
108
|
static fromStatementNode(statementNode, localContext) {
|
|
116
109
|
let termForVariableSubstitution = null;
|
|
117
110
|
|
|
@@ -121,33 +114,30 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
121
114
|
let substitutionTermNode = substitutionTermNodeQuery(substitutionNode);
|
|
122
115
|
|
|
123
116
|
if (substitutionTermNode !== null) {
|
|
124
|
-
let termNode;
|
|
125
|
-
|
|
126
|
-
const substitutionVariableNode = substitutionsVariableNodeQuery(substitutionNode),
|
|
127
|
-
variableNode = substitutionVariableNode; ///
|
|
128
|
-
|
|
129
|
-
termNode = substitutionTermNode; ///
|
|
130
|
-
|
|
131
117
|
const { Term, Variable } = shim,
|
|
118
|
+
substitutionVariableNode = substitutionsVariableNodeQuery(substitutionNode),
|
|
119
|
+
variableNode = substitutionVariableNode, ///
|
|
120
|
+
termNode = substitutionTermNode, ///
|
|
132
121
|
term = Term.fromTermNode(termNode, localContext),
|
|
133
122
|
variable = Variable.fromVariableNode(variableNode, localContext),
|
|
134
|
-
string = stringFromTermAndVariable(term, variable);
|
|
123
|
+
string = stringFromTermAndVariable(term, variable, localContext);
|
|
135
124
|
|
|
136
|
-
termForVariableSubstitution = new TermForVariableSubstitution(string, termNode, variableNode);
|
|
125
|
+
termForVariableSubstitution = new TermForVariableSubstitution(string, termNode, variableNode, substitutionNode);
|
|
137
126
|
}
|
|
138
127
|
}
|
|
139
128
|
|
|
140
129
|
return termForVariableSubstitution;
|
|
141
130
|
}
|
|
142
131
|
|
|
143
|
-
static fromTernAndVariable(term, variable) {
|
|
132
|
+
static fromTernAndVariable(term, variable, localContext) {
|
|
144
133
|
let termNode = term.getNode();
|
|
145
134
|
|
|
146
135
|
termNode = stripBracketsFromTerm(termNode); ///
|
|
147
136
|
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
137
|
+
const string = stringFromTermAndVariable(term, variable, localContext),
|
|
138
|
+
variableNode = variable.getNode(),
|
|
139
|
+
substitutionNode = null,
|
|
140
|
+
termForVariableSubstitution = new TermForVariableSubstitution(string, termNode, variableNode, substitutionNode);
|
|
151
141
|
|
|
152
142
|
return termForVariableSubstitution;
|
|
153
143
|
}
|
|
@@ -198,8 +188,9 @@ function transformVariableNode(variableNode, substitutions) {
|
|
|
198
188
|
return transformedVariableNode;
|
|
199
189
|
}
|
|
200
190
|
|
|
201
|
-
function stringFromTermAndVariable(term, variable) {
|
|
202
|
-
const
|
|
191
|
+
function stringFromTermAndVariable(term, variable, localContext) {
|
|
192
|
+
const termNode = term.getNode(),
|
|
193
|
+
termString = localContext.nodeAsString(termNode),
|
|
203
194
|
variableString = variable.getString(),
|
|
204
195
|
string = `[${termString} for ${variableString}]`;
|
|
205
196
|
|
package/src/substitution.js
CHANGED
|
@@ -9,24 +9,22 @@ export default class Substitution {
|
|
|
9
9
|
return this.string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
const
|
|
12
|
+
getTermNode() {
|
|
13
|
+
const termNode = null;
|
|
14
14
|
|
|
15
|
-
return
|
|
15
|
+
return termNode;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
complex = !simple;
|
|
18
|
+
getFrameNode() {
|
|
19
|
+
const frameNode = null;
|
|
21
20
|
|
|
22
|
-
return
|
|
21
|
+
return frameNode;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
resolved = simple; ///
|
|
24
|
+
getStatementNode() {
|
|
25
|
+
const statementNode = null;
|
|
28
26
|
|
|
29
|
-
return
|
|
27
|
+
return statementNode;
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
getVariableNode() {
|
|
@@ -41,18 +39,49 @@ export default class Substitution {
|
|
|
41
39
|
return metavariableNode;
|
|
42
40
|
}
|
|
43
41
|
|
|
42
|
+
getSubstitutionNode() {
|
|
43
|
+
const substitutionNode = null;
|
|
44
|
+
|
|
45
|
+
return substitutionNode;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
isSimple() {
|
|
49
|
+
const simple = true;
|
|
50
|
+
|
|
51
|
+
return simple;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
isComplex() {
|
|
55
|
+
const simple = this.isSimple(),
|
|
56
|
+
complex = !simple;
|
|
57
|
+
|
|
58
|
+
return complex;
|
|
59
|
+
}
|
|
60
|
+
|
|
44
61
|
isEqualTo(substitution) {
|
|
45
62
|
const equalTo = false;
|
|
46
63
|
|
|
47
64
|
return equalTo;
|
|
48
65
|
}
|
|
49
66
|
|
|
67
|
+
resolve(substitutions, localContext) {
|
|
68
|
+
const resolved = true;
|
|
69
|
+
|
|
70
|
+
return resolved;
|
|
71
|
+
}
|
|
72
|
+
|
|
50
73
|
matchTermNode(termNode) {
|
|
51
74
|
const termNodeMatches = false;
|
|
52
75
|
|
|
53
76
|
return termNodeMatches;
|
|
54
77
|
}
|
|
55
78
|
|
|
79
|
+
matchFrameNode(frameNode) {
|
|
80
|
+
const frameNodeMatches = false;
|
|
81
|
+
|
|
82
|
+
return frameNodeMatches;
|
|
83
|
+
}
|
|
84
|
+
|
|
56
85
|
matchVariableNode(variableNode) {
|
|
57
86
|
const variableNodeMatches = false;
|
|
58
87
|
|