occam-verify-cli 1.0.587 → 1.0.602
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/ephemeral.js +74 -2
- package/lib/context/file/nominal.js +11 -9
- package/lib/context/liminal.js +161 -24
- package/lib/context/literal.js +8 -2
- package/lib/context/scoped.js +4 -28
- package/lib/context/synthetic.js +146 -0
- package/lib/context.js +170 -1
- package/lib/element/assertion/contained.js +21 -15
- package/lib/element/assertion/defined.js +45 -65
- package/lib/element/assertion/property.js +25 -19
- package/lib/element/assertion/satisfies.js +14 -8
- package/lib/element/assertion/subproof.js +12 -6
- package/lib/element/assertion.js +47 -1
- package/lib/element/assumption.js +12 -12
- package/lib/element/conclusion.js +2 -2
- package/lib/element/deduction.js +2 -2
- package/lib/element/frame.js +61 -29
- package/lib/element/judgement.js +7 -1
- package/lib/element/label.js +8 -8
- package/lib/element/metavariable.js +71 -59
- package/lib/element/procedureCall.js +24 -8
- package/lib/element/proof.js +43 -35
- package/lib/element/proofAssertion/premise.js +122 -97
- package/lib/element/proofAssertion/step.js +161 -115
- package/lib/element/proofAssertion/supposition.js +157 -118
- package/lib/element/proofAssertion.js +3 -3
- package/lib/element/reference.js +40 -7
- package/lib/element/rule.js +227 -95
- package/lib/element/signature.js +2 -1
- package/lib/element/statement.js +67 -34
- package/lib/element/substitution/frame.js +36 -16
- package/lib/element/substitution/reference.js +36 -16
- package/lib/element/substitution/statement.js +94 -55
- package/lib/element/substitution/term.js +36 -16
- package/lib/element/substitution.js +54 -17
- package/lib/element/substitutions.js +4 -276
- package/lib/element/term.js +60 -31
- package/lib/element/topLevelAssertion/axiom.js +13 -4
- package/lib/element/topLevelAssertion/conjecture.js +7 -2
- package/lib/element/topLevelAssertion/theorem.js +7 -2
- package/lib/element/topLevelAssertion.js +201 -134
- package/lib/element/topLevelMetaAssertion.js +310 -51
- package/lib/element/variable.js +15 -6
- package/lib/node/substitution/statement.js +33 -1
- package/lib/process/unify.js +6 -6
- package/lib/utilities/context.js +10 -25
- package/lib/utilities/element.js +34 -9
- package/lib/utilities/statement.js +1 -8
- package/lib/utilities/string.js +12 -1
- package/lib/utilities/substitutions.js +42 -16
- package/lib/utilities/unification.js +3 -1
- package/lib/utilities/validation.js +2 -2
- package/package.json +4 -4
- package/src/context/ephemeral.js +73 -1
- package/src/context/file/nominal.js +14 -11
- package/src/context/liminal.js +180 -25
- package/src/context/literal.js +3 -1
- package/src/context/scoped.js +3 -35
- package/src/context/synthetic.js +49 -0
- package/src/context.js +163 -1
- package/src/element/assertion/contained.js +28 -20
- package/src/element/assertion/defined.js +62 -34
- package/src/element/assertion/property.js +27 -19
- package/src/element/assertion/satisfies.js +15 -7
- package/src/element/assertion/subproof.js +13 -5
- package/src/element/assertion.js +35 -0
- package/src/element/assumption.js +5 -5
- package/src/element/conclusion.js +2 -4
- package/src/element/deduction.js +2 -4
- package/src/element/frame.js +71 -39
- package/src/element/judgement.js +2 -0
- package/src/element/label.js +4 -4
- package/src/element/metavariable.js +94 -75
- package/src/element/procedureCall.js +6 -6
- package/src/element/proof.js +6 -6
- package/src/element/proofAssertion/premise.js +101 -69
- package/src/element/proofAssertion/step.js +78 -39
- package/src/element/proofAssertion/supposition.js +141 -115
- package/src/element/proofAssertion.js +3 -2
- package/src/element/reference.js +52 -10
- package/src/element/rule.js +138 -76
- package/src/element/signature.js +2 -0
- package/src/element/statement.js +76 -45
- package/src/element/substitution/frame.js +44 -15
- package/src/element/substitution/reference.js +44 -15
- package/src/element/substitution/statement.js +124 -72
- package/src/element/substitution/term.js +43 -15
- package/src/element/substitution.js +55 -18
- package/src/element/substitutions.js +1 -258
- package/src/element/term.js +65 -34
- package/src/element/topLevelAssertion/axiom.js +1 -1
- package/src/element/topLevelAssertion/conjecture.js +1 -1
- package/src/element/topLevelAssertion/theorem.js +1 -1
- package/src/element/topLevelAssertion.js +128 -48
- package/src/element/topLevelMetaAssertion.js +86 -32
- package/src/element/variable.js +15 -5
- package/src/node/substitution/statement.js +33 -0
- package/src/process/unify.js +6 -8
- package/src/utilities/context.js +9 -8
- package/src/utilities/element.js +37 -10
- package/src/utilities/statement.js +0 -7
- package/src/utilities/string.js +14 -0
- package/src/utilities/substitutions.js +59 -17
- package/src/utilities/unification.js +4 -0
- package/src/utilities/validation.js +3 -1
|
@@ -38,6 +38,21 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
38
38
|
return replacementNode;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
getMetavariable(generalContext, specificContext) {
|
|
42
|
+
let metavariable = null;
|
|
43
|
+
|
|
44
|
+
const targetReferenceNode = this.targetReference.getNode(),
|
|
45
|
+
metavariableName = targetReferenceNode.getMetavariableName();
|
|
46
|
+
|
|
47
|
+
if (metavariableName !== null) {
|
|
48
|
+
const context = generalContext; ///
|
|
49
|
+
|
|
50
|
+
metavariable = context.findMetavariableByMetavariableName(metavariableName);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return metavariable;
|
|
54
|
+
}
|
|
55
|
+
|
|
41
56
|
isTrivial() {
|
|
42
57
|
const targetReferenceEqualToReplacementReference = this.targetReference.isEqualTo(this.replacementReference),
|
|
43
58
|
trivial = targetReferenceEqualToReplacementReference; ///
|
|
@@ -59,38 +74,51 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
59
74
|
return comparesToParameter;
|
|
60
75
|
}
|
|
61
76
|
|
|
62
|
-
validate(
|
|
77
|
+
validate(generalContext, specificContext) {
|
|
63
78
|
let validates = false;
|
|
64
79
|
|
|
80
|
+
const context = this.getContext();
|
|
81
|
+
|
|
82
|
+
specificContext = context; ///
|
|
83
|
+
|
|
65
84
|
const referenceSubstitutionString = this.getString(); ///
|
|
66
85
|
|
|
67
86
|
context.trace(`Validating the '${referenceSubstitutionString}' reference substitution...`);
|
|
68
87
|
|
|
69
|
-
const
|
|
88
|
+
const valid = this.isValid(context);
|
|
70
89
|
|
|
71
|
-
if (
|
|
72
|
-
|
|
90
|
+
if (valid) {
|
|
91
|
+
validates = true;
|
|
92
|
+
|
|
93
|
+
context.debug(`...the '${referenceSubstitutionString}' reference substitution is already valid.`);
|
|
94
|
+
} else {
|
|
95
|
+
const targetReferenceValidates = this.validateTargetReference(generalContext, specificContext);
|
|
96
|
+
|
|
97
|
+
if (targetReferenceValidates) {
|
|
98
|
+
const replacementReferenceValidates = this.validateReplacementReference(generalContext, specificContext);
|
|
73
99
|
|
|
74
|
-
|
|
75
|
-
|
|
100
|
+
if (replacementReferenceValidates) {
|
|
101
|
+
validates = true;
|
|
102
|
+
}
|
|
76
103
|
}
|
|
77
|
-
}
|
|
78
104
|
|
|
79
|
-
|
|
80
|
-
|
|
105
|
+
if (validates) {
|
|
106
|
+
const substititoin = this; ///
|
|
81
107
|
|
|
82
|
-
|
|
108
|
+
context.addSubstitution(substititoin);
|
|
83
109
|
|
|
84
|
-
|
|
110
|
+
context.debug(`...validated the '${referenceSubstitutionString}' reference substitution.`);
|
|
111
|
+
}
|
|
85
112
|
}
|
|
86
113
|
|
|
87
114
|
return validates;
|
|
88
115
|
}
|
|
89
116
|
|
|
90
|
-
validateTargetReference(
|
|
117
|
+
validateTargetReference(generalContext, specificContext) {
|
|
91
118
|
let targetReferenceValidates = false;
|
|
92
119
|
|
|
93
|
-
const
|
|
120
|
+
const context = generalContext, ///
|
|
121
|
+
targetReferenceString = this.targetReference.getString(),
|
|
94
122
|
referenceSubstitutionString = this.getString(); ///
|
|
95
123
|
|
|
96
124
|
context.trace(`Validating the '${referenceSubstitutionString}' reference subtitution's '${targetReferenceString}' target reference...`);
|
|
@@ -110,10 +138,11 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
110
138
|
return targetReferenceValidates;
|
|
111
139
|
}
|
|
112
140
|
|
|
113
|
-
validateReplacementReference(
|
|
141
|
+
validateReplacementReference(generalContext, specificContext) {
|
|
114
142
|
let replacementReferenceValidates;
|
|
115
143
|
|
|
116
|
-
const
|
|
144
|
+
const context = specificContext, ///
|
|
145
|
+
replacementReferenceString = this.replacementReference.getString(),
|
|
117
146
|
referenceSubstitutionString = this.getString(); ///
|
|
118
147
|
|
|
119
148
|
context.trace(`Validating the '${referenceSubstitutionString}' reference subtitution's '${replacementReferenceString}' replacement reference...`);
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import Substitution from "../substitution";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
-
import { literally } from "../../utilities/context";
|
|
7
6
|
import { unifySubstitution } from "../../process/unify";
|
|
8
7
|
import { stripBracketsFromStatement } from "../../utilities/brackets";
|
|
9
8
|
import { instantiateStatementSubstitution } from "../../process/instantiate";
|
|
9
|
+
import { liminally, literally, synthetically } from "../../utilities/context";
|
|
10
10
|
import { statementSubstitutionFromStatementSubstitutionNode } from "../../utilities/element";
|
|
11
11
|
import { statementToStatementJSON, metavariableToMetavariableJSON } from "../../utilities/json";
|
|
12
12
|
import { statementSubstitutionStringFromStatementAndMetavariable, statementSubstitutionStringFromStatementMetavariableAndSubstitution } from "../../utilities/string";
|
|
@@ -37,6 +37,21 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
37
37
|
return this.replacementStatement;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
getMetavariable(generalContext, specificContext) {
|
|
41
|
+
let metavariable = null;
|
|
42
|
+
|
|
43
|
+
const targetStatementNode = this.targetStatement.getNode(),
|
|
44
|
+
metavariableName = targetStatementNode.getMetavariableName();
|
|
45
|
+
|
|
46
|
+
if (metavariableName !== null) {
|
|
47
|
+
const context = generalContext; ///
|
|
48
|
+
|
|
49
|
+
metavariable = context.findMetavariableByMetavariableName(metavariableName);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return metavariable;
|
|
53
|
+
}
|
|
54
|
+
|
|
40
55
|
getTargetNode() {
|
|
41
56
|
const targetStatementNode = this.targetStatement.getNode(),
|
|
42
57
|
targetNode = targetStatementNode; ///
|
|
@@ -91,38 +106,53 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
91
106
|
return comparesToSubstitution;
|
|
92
107
|
}
|
|
93
108
|
|
|
94
|
-
|
|
109
|
+
compareMetavariable(metavariable) { return this.targetStatement.compareMetavariable(metavariable); }
|
|
110
|
+
|
|
111
|
+
validate(generalContext, specificContext) {
|
|
95
112
|
let validates = false;
|
|
96
113
|
|
|
114
|
+
const context = this.getContext();
|
|
115
|
+
|
|
116
|
+
specificContext = context; ///
|
|
117
|
+
|
|
97
118
|
const statementSubstitutionString = this.getString(); ///
|
|
98
119
|
|
|
99
120
|
context.trace(`Validating the '${statementSubstitutionString}' statement substitution...`);
|
|
100
121
|
|
|
101
|
-
const
|
|
122
|
+
const valid = this.isValid(context);
|
|
102
123
|
|
|
103
|
-
if (
|
|
104
|
-
|
|
124
|
+
if (valid) {
|
|
125
|
+
validates = true;
|
|
105
126
|
|
|
106
|
-
|
|
107
|
-
|
|
127
|
+
context.debug(`...the '${statementSubstitutionString}' statement substitution is already valid.`);
|
|
128
|
+
} else {
|
|
129
|
+
const targetStatementValidates = this.validateTargetStatement(generalContext, specificContext);
|
|
130
|
+
|
|
131
|
+
if (targetStatementValidates) {
|
|
132
|
+
const replacementStatementValidates = this.validateReplacementStatement(generalContext, specificContext);
|
|
133
|
+
|
|
134
|
+
if (replacementStatementValidates) {
|
|
135
|
+
validates = true;
|
|
136
|
+
}
|
|
108
137
|
}
|
|
109
|
-
}
|
|
110
138
|
|
|
111
|
-
|
|
112
|
-
|
|
139
|
+
if (validates) {
|
|
140
|
+
const substititoin = this; ///
|
|
113
141
|
|
|
114
|
-
|
|
142
|
+
context.addSubstitution(substititoin);
|
|
115
143
|
|
|
116
|
-
|
|
144
|
+
context.debug(`...validated the '${statementSubstitutionString}' statement substitution.`);
|
|
145
|
+
}
|
|
117
146
|
}
|
|
118
147
|
|
|
119
148
|
return validates;
|
|
120
149
|
}
|
|
121
150
|
|
|
122
|
-
validateTargetStatement(
|
|
151
|
+
validateTargetStatement(generalContext, specificContext) {
|
|
123
152
|
let targetStatementValidates = false;
|
|
124
153
|
|
|
125
|
-
const
|
|
154
|
+
const context = generalContext, ///
|
|
155
|
+
targetStatementString = this.targetStatement.getString(),
|
|
126
156
|
statementSubstitutionString = this.getString(); ///
|
|
127
157
|
|
|
128
158
|
context.trace(`Validating the '${statementSubstitutionString}' statement subtitution's '${targetStatementString}' target statement...`);
|
|
@@ -145,10 +175,11 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
145
175
|
return targetStatementValidates;
|
|
146
176
|
}
|
|
147
177
|
|
|
148
|
-
validateReplacementStatement(
|
|
178
|
+
validateReplacementStatement(generalContext, specificContext) {
|
|
149
179
|
let replacementStatementValidates;
|
|
150
180
|
|
|
151
|
-
const
|
|
181
|
+
const context = specificContext, ///
|
|
182
|
+
replacementStatementString = this.replacementStatement.getString(),
|
|
152
183
|
statementSubstitutionString = this.getString(); ///
|
|
153
184
|
|
|
154
185
|
context.trace(`Validating the '${statementSubstitutionString}' statement subtitution's '${replacementStatementString}' replacement statement...`);
|
|
@@ -165,65 +196,39 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
165
196
|
return replacementStatementValidates;
|
|
166
197
|
}
|
|
167
198
|
|
|
168
|
-
|
|
169
|
-
let
|
|
170
|
-
|
|
171
|
-
const statementString = statement.getString(),
|
|
172
|
-
statementSubstitutionString = this.getString();
|
|
173
|
-
|
|
174
|
-
context.trace(`Unifying the '${statementString}' statement with the '${statementSubstitutionString}' statement substiution's statement...`);
|
|
175
|
-
|
|
176
|
-
const specificContext = context; ///
|
|
199
|
+
unifyReplacementStatement(replacementStatement, generalContext, specificContext) {
|
|
200
|
+
let replacementStatemnentUnifies = false;
|
|
177
201
|
|
|
178
|
-
context =
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
context = specificContext; ///
|
|
202
|
+
const context = specificContext, ///
|
|
203
|
+
substitutionString = this.getString(), ///
|
|
204
|
+
replacementStatementString = replacementStatement.getString(),
|
|
205
|
+
substitutionReplacementStatementString = this.replacementStatement.getString(); ///
|
|
183
206
|
|
|
184
|
-
|
|
207
|
+
context.trace(`Unifying the '${replacementStatementString}' replacement statement with the '${substitutionString}' substiution's '${substitutionReplacementStatementString}' replacement statement...`);
|
|
185
208
|
|
|
186
|
-
statementUnifies = this.replacementStatement.unifyStatement(
|
|
187
|
-
|
|
188
|
-
let substitution = null;
|
|
209
|
+
const statementUnifies = this.replacementStatement.unifyStatement(replacementStatement, generalContext, specificContext);
|
|
189
210
|
|
|
190
211
|
if (statementUnifies) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (substitutionsNonTrivialLength === 1) {
|
|
194
|
-
const firstSubstitution = substitutions.getFirstSubstitution();
|
|
195
|
-
|
|
196
|
-
substitution = firstSubstitution; ///
|
|
197
|
-
} else {
|
|
198
|
-
statementUnifies = false;
|
|
199
|
-
}
|
|
212
|
+
replacementStatemnentUnifies = true;
|
|
200
213
|
}
|
|
201
214
|
|
|
202
|
-
if (
|
|
203
|
-
context.
|
|
215
|
+
if (replacementStatemnentUnifies) {
|
|
216
|
+
context.debug(`...unified the '${replacementStatementString}' replacement statement with the '${substitutionString}' substiution's '${substitutionReplacementStatementString}' replacement statement.`);
|
|
204
217
|
}
|
|
205
218
|
|
|
206
|
-
return
|
|
219
|
+
return replacementStatemnentUnifies;
|
|
207
220
|
}
|
|
208
221
|
|
|
209
|
-
unifySubstitution(substitution,
|
|
210
|
-
const
|
|
222
|
+
unifySubstitution(substitution, generalContext, specificContext) {
|
|
223
|
+
const context = specificContext,
|
|
224
|
+
generalSubstitution = this.substitution, ///
|
|
211
225
|
specificSubstitution = substitution, ///
|
|
212
226
|
generalSubstitutionString = generalSubstitution.getString(),
|
|
213
227
|
specificSubstitutionString = specificSubstitution.getString();
|
|
214
228
|
|
|
215
229
|
context.trace(`Unifying the '${specificSubstitutionString}' substitution with the '${generalSubstitutionString}' substitution...`);
|
|
216
230
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
substitutionContext = this.substitution.getContext();
|
|
220
|
-
|
|
221
|
-
const generalContext = substitutionContext; ///
|
|
222
|
-
|
|
223
|
-
substitutionContext = substitution.getContext();
|
|
224
|
-
|
|
225
|
-
const specificContext = substitutionContext, ///
|
|
226
|
-
substitutionUnifies = unifySubstitution(generalSubstitution, specificSubstitution, substitutions, generalContext, specificContext);
|
|
231
|
+
const substitutionUnifies = unifySubstitution(generalSubstitution, specificSubstitution, generalContext, specificContext);
|
|
227
232
|
|
|
228
233
|
if (substitutionUnifies) {
|
|
229
234
|
context.trace(`...unified the '${specificSubstitutionString}' substitution with the '${generalSubstitutionString}' substitution.`);
|
|
@@ -232,30 +237,77 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
232
237
|
return substitutionUnifies;
|
|
233
238
|
}
|
|
234
239
|
|
|
235
|
-
resolve(
|
|
240
|
+
resolve(generalContext, specificContext) {
|
|
241
|
+
let context;
|
|
242
|
+
|
|
236
243
|
context = this.getContext();
|
|
237
244
|
|
|
238
245
|
const substitutionString = this.getString(); ///
|
|
239
246
|
|
|
240
247
|
context.trace(`Resolving the ${substitutionString} substitution...`);
|
|
241
248
|
|
|
242
|
-
|
|
249
|
+
context = generalContext; ///
|
|
250
|
+
|
|
251
|
+
const metavariable = this.getMetavariable(generalContext, specificContext);
|
|
243
252
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
253
|
+
context = specificContext; ///
|
|
254
|
+
|
|
255
|
+
const simpleSubstitution = context.findSimpleSubstitutionByMetavariable(metavariable);
|
|
256
|
+
|
|
257
|
+
context = this.getContext();
|
|
247
258
|
|
|
248
|
-
|
|
249
|
-
|
|
259
|
+
const subtitution = liminally((context) => {
|
|
260
|
+
let substitution = null;
|
|
250
261
|
|
|
251
|
-
|
|
252
|
-
|
|
262
|
+
const specificContext = context; ///
|
|
263
|
+
|
|
264
|
+
context = simpleSubstitution.getContext();
|
|
265
|
+
|
|
266
|
+
const generalContext = context; ///
|
|
267
|
+
|
|
268
|
+
context = specificContext; ///
|
|
269
|
+
|
|
270
|
+
const replacementStatementUnifies = simpleSubstitution.unifyReplacementStatement(this.replacementStatement, generalContext, specificContext);
|
|
271
|
+
|
|
272
|
+
if (replacementStatementUnifies) {
|
|
273
|
+
const nested = false,
|
|
274
|
+
soleNonTrivialSubstitution = context.getSoleNonTrivialSubstitution(nested);
|
|
275
|
+
|
|
276
|
+
substitution = soleNonTrivialSubstitution; ///
|
|
253
277
|
}
|
|
254
|
-
}
|
|
255
278
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
279
|
+
return substitution;
|
|
280
|
+
}, context);
|
|
281
|
+
|
|
282
|
+
if (subtitution !== null) {
|
|
283
|
+
liminally((specificContext) => {
|
|
284
|
+
const contexts = [];
|
|
285
|
+
|
|
286
|
+
context = simpleSubstitution.getContext();
|
|
287
|
+
|
|
288
|
+
contexts.push(context);
|
|
289
|
+
|
|
290
|
+
context = this.getContext();
|
|
291
|
+
|
|
292
|
+
contexts.push(context);
|
|
293
|
+
|
|
294
|
+
context = specificContext; ///
|
|
295
|
+
|
|
296
|
+
synthetically((context) => {
|
|
297
|
+
const specificContext = context; ///
|
|
298
|
+
|
|
299
|
+
context = this.substitution.getContext();
|
|
300
|
+
|
|
301
|
+
const generalContext = context; ///
|
|
302
|
+
|
|
303
|
+
this.unifySubstitution(subtitution, generalContext, specificContext);
|
|
304
|
+
}, contexts, context);
|
|
305
|
+
|
|
306
|
+
specificContext.commit();
|
|
307
|
+
}, specificContext);
|
|
308
|
+
|
|
309
|
+
this.resolved = true;
|
|
310
|
+
}
|
|
259
311
|
|
|
260
312
|
if (this.resolved) {
|
|
261
313
|
context.debug(`...resolved the '${substitutionString}' substitution.`);
|
|
@@ -303,7 +355,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
303
355
|
const statementSubstitutionString = statementSubstitutionStringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution),
|
|
304
356
|
string = statementSubstitutionString, ///
|
|
305
357
|
statementSubstitutionNode = instantiateStatementSubstitution(string, context),
|
|
306
|
-
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode,
|
|
358
|
+
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
|
|
307
359
|
|
|
308
360
|
return statementSubstitution;
|
|
309
361
|
}, context);
|
|
@@ -39,6 +39,20 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
39
39
|
return replacementNode;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
getVariable(generalContext, specificContext) {
|
|
43
|
+
let variable = null;
|
|
44
|
+
|
|
45
|
+
const targetTermNode = this.targetTerm.getNode(),
|
|
46
|
+
variableIdentifier = targetTermNode.getVariableIdentifier();
|
|
47
|
+
|
|
48
|
+
if (variableIdentifier !== null) {
|
|
49
|
+
const context = specificContext; ///
|
|
50
|
+
variable = context.findVariableByVariableIdentifier(variableIdentifier);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return variable;
|
|
54
|
+
}
|
|
55
|
+
|
|
42
56
|
isTrivial() {
|
|
43
57
|
const targetTermEqualToReplacementTerm = this.targetTerm.isEqualTo(this.replacementTerm),
|
|
44
58
|
trivial = targetTermEqualToReplacementTerm; ///
|
|
@@ -62,38 +76,51 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
62
76
|
return comparesToParameter;
|
|
63
77
|
}
|
|
64
78
|
|
|
65
|
-
validate(
|
|
79
|
+
validate(generalContext, specificContext) {
|
|
66
80
|
let validates = false;
|
|
67
81
|
|
|
82
|
+
const context = this.getContext();
|
|
83
|
+
|
|
84
|
+
specificContext = context; ///
|
|
85
|
+
|
|
68
86
|
const termSubstitutionString = this.getString(); ///
|
|
69
87
|
|
|
70
88
|
context.trace(`Validating the '${termSubstitutionString}' term substitution...`);
|
|
71
89
|
|
|
72
|
-
const
|
|
90
|
+
const valid = this.isValid(context);
|
|
73
91
|
|
|
74
|
-
if (
|
|
75
|
-
|
|
92
|
+
if (valid) {
|
|
93
|
+
validates = true;
|
|
94
|
+
|
|
95
|
+
context.debug(`...the '${termSubstitutionString}' term substitution is alrady valid.`);
|
|
96
|
+
} else {
|
|
97
|
+
const targetTermValidates = this.validateTargetTerm(generalContext, specificContext);
|
|
76
98
|
|
|
77
|
-
if (
|
|
78
|
-
|
|
99
|
+
if (targetTermValidates) {
|
|
100
|
+
const replacementTermValidates = this.validateReplacementTerm(generalContext, specificContext);
|
|
101
|
+
|
|
102
|
+
if (replacementTermValidates) {
|
|
103
|
+
validates = true;
|
|
104
|
+
}
|
|
79
105
|
}
|
|
80
|
-
}
|
|
81
106
|
|
|
82
|
-
|
|
83
|
-
|
|
107
|
+
if (validates) {
|
|
108
|
+
const substititoin = this; ///
|
|
84
109
|
|
|
85
|
-
|
|
110
|
+
context.addSubstitution(substititoin);
|
|
86
111
|
|
|
87
|
-
|
|
112
|
+
context.debug(`...validated the '${termSubstitutionString}' term substitution.`);
|
|
113
|
+
}
|
|
88
114
|
}
|
|
89
115
|
|
|
90
116
|
return validates;
|
|
91
117
|
}
|
|
92
118
|
|
|
93
|
-
validateTargetTerm(
|
|
119
|
+
validateTargetTerm(generalContext, specificContext) {
|
|
94
120
|
let targetTermValidates = false;
|
|
95
121
|
|
|
96
|
-
const
|
|
122
|
+
const context = generalContext, ///
|
|
123
|
+
targetTermString = this.targetTerm.getString(),
|
|
97
124
|
termSubstitutionString = this.getString(); ///
|
|
98
125
|
|
|
99
126
|
context.trace(`Validating the '${termSubstitutionString}' term subtitution's '${targetTermString}' target term...`);
|
|
@@ -117,10 +144,11 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
117
144
|
return targetTermValidates;
|
|
118
145
|
}
|
|
119
146
|
|
|
120
|
-
validateReplacementTerm(
|
|
147
|
+
validateReplacementTerm(generalContext, specificContext) {
|
|
121
148
|
let replacementTermValidates;
|
|
122
149
|
|
|
123
|
-
const
|
|
150
|
+
const context = specificContext, ///
|
|
151
|
+
replacementTermString = this.replacementTerm.getString(),
|
|
124
152
|
termSubstitutionString = this.getString(); ///
|
|
125
153
|
|
|
126
154
|
context.trace(`Validating the '${termSubstitutionString}' term subtitution's '${replacementTermString}' replacement term...`);
|
|
@@ -25,6 +25,47 @@ export default class Substitution extends Element {
|
|
|
25
25
|
return primitive;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
getMetavariable(context) {
|
|
29
|
+
const metavariable = null;
|
|
30
|
+
|
|
31
|
+
return metavariable;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getSubstitutionNode() {
|
|
35
|
+
const node = this.getNode(),
|
|
36
|
+
substitutionNode = node; ///
|
|
37
|
+
|
|
38
|
+
return substitutionNode;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
matchSubstitutionNode(substitutionNode) {
|
|
42
|
+
const substitutionNodeA = substitutionNode; ///
|
|
43
|
+
|
|
44
|
+
substitutionNode = this.getSubstitutionNode();
|
|
45
|
+
|
|
46
|
+
const substitutionNodeB = substitutionNode, ///
|
|
47
|
+
substitutionNodeAAMatchesSubstitutionBNodeB = substitutionNodeA.match(substitutionNodeB),
|
|
48
|
+
equalTo = substitutionNodeAAMatchesSubstitutionBNodeB; ///
|
|
49
|
+
|
|
50
|
+
return equalTo;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
isValid(context) {
|
|
54
|
+
const substitutionNode = this.getSubstitutionNode(),
|
|
55
|
+
substitutionPresent = context.isSubstitutionPresentBySubstitutionNode(substitutionNode),
|
|
56
|
+
valid = substitutionPresent; ///
|
|
57
|
+
|
|
58
|
+
return valid;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
isEqualTo(substitution) {
|
|
62
|
+
const substitutionNode = substitution.getNode(),
|
|
63
|
+
substitutionNodeMatches = this.matchSubstitutionNode(substitutionNode),
|
|
64
|
+
equalTo = substitutionNodeMatches; ///
|
|
65
|
+
|
|
66
|
+
return equalTo;
|
|
67
|
+
}
|
|
68
|
+
|
|
28
69
|
isSimple() {
|
|
29
70
|
const simple = true;
|
|
30
71
|
|
|
@@ -44,6 +85,13 @@ export default class Substitution extends Element {
|
|
|
44
85
|
return trivial;
|
|
45
86
|
}
|
|
46
87
|
|
|
88
|
+
isNonTrivial() {
|
|
89
|
+
const trivial = this.isTrivial(),
|
|
90
|
+
nonTrivlal = !trivial;
|
|
91
|
+
|
|
92
|
+
return nonTrivlal;
|
|
93
|
+
}
|
|
94
|
+
|
|
47
95
|
isFrameEqualToFrame(frame) {
|
|
48
96
|
const frameEqualToFrame = false;
|
|
49
97
|
|
|
@@ -56,21 +104,10 @@ export default class Substitution extends Element {
|
|
|
56
104
|
return referenceEqualToReference;
|
|
57
105
|
}
|
|
58
106
|
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
return metavariableEqualToMetavariable;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
isEqualTo(substitution) {
|
|
66
|
-
const substitutionA = this, ///
|
|
67
|
-
substitutionB = substitution, ///
|
|
68
|
-
substitutionANode = substitutionA.getNode(),
|
|
69
|
-
substitutionBNode = substitutionB.getNode(),
|
|
70
|
-
substitutionANodeMatchesSubstitutionBNode = substitutionANode.match(substitutionBNode),
|
|
71
|
-
equalTo = substitutionANodeMatchesSubstitutionBNode; ///
|
|
107
|
+
compare(substitution) {
|
|
108
|
+
const comparesToSubstitution = false;
|
|
72
109
|
|
|
73
|
-
return
|
|
110
|
+
return comparesToSubstitution;
|
|
74
111
|
}
|
|
75
112
|
|
|
76
113
|
compareTerm(term, context) {
|
|
@@ -91,13 +128,13 @@ export default class Substitution extends Element {
|
|
|
91
128
|
return comparesToParameter;
|
|
92
129
|
}
|
|
93
130
|
|
|
94
|
-
|
|
95
|
-
const
|
|
131
|
+
compareMetavariable(metavariable) {
|
|
132
|
+
const compaaresToMetavariable = false;
|
|
96
133
|
|
|
97
|
-
return
|
|
134
|
+
return compaaresToMetavariable;
|
|
98
135
|
}
|
|
99
136
|
|
|
100
|
-
resolve(substitutions,
|
|
137
|
+
resolve(substitutions, generalContext, specificContext) {
|
|
101
138
|
const resolved = true;
|
|
102
139
|
|
|
103
140
|
return resolved;
|