occam-verify-cli 1.0.635 → 1.0.638
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/nominal.js +1 -1
- package/lib/context/liminal.js +3 -3
- package/lib/context/scoped.js +25 -3
- package/lib/context.js +8 -1
- package/lib/element/assertion/contained.js +34 -23
- package/lib/element/assertion/defined.js +30 -21
- package/lib/element/assertion/property.js +24 -21
- package/lib/element/assertion/satisfies.js +19 -14
- package/lib/element/assertion/subproof.js +18 -13
- package/lib/element/assertion/type.js +23 -20
- package/lib/element/assertion.js +5 -5
- package/lib/element/assumption.js +31 -25
- package/lib/element/combinator/bracketed.js +3 -3
- package/lib/element/combinator.js +3 -3
- package/lib/element/conclusion.js +6 -2
- package/lib/element/constructor/bracketed.js +5 -3
- package/lib/element/deduction.js +6 -2
- package/lib/element/derivation.js +4 -5
- package/lib/element/equality.js +32 -27
- package/lib/element/frame.js +26 -21
- package/lib/element/hypothesis.js +8 -10
- package/lib/element/judgement.js +54 -22
- package/lib/element/metavariable.js +18 -10
- package/lib/element/proofAssertion/premise.js +8 -8
- package/lib/element/proofAssertion/step.js +16 -11
- package/lib/element/proofAssertion/supposition.js +7 -7
- package/lib/element/proofAssertion.js +7 -5
- package/lib/element/propertyRelation.js +7 -3
- package/lib/element/reference.js +28 -21
- package/lib/element/rule.js +4 -11
- package/lib/element/signature.js +10 -4
- package/lib/element/statement.js +17 -17
- package/lib/element/subDerivation.js +4 -11
- package/lib/element/subproof.js +37 -29
- package/lib/element/substitution/frame.js +18 -10
- package/lib/element/substitution/reference.js +17 -9
- package/lib/element/substitution/statement.js +16 -10
- package/lib/element/substitution/term.js +19 -9
- package/lib/element/substitution.js +5 -5
- package/lib/element/term.js +14 -14
- package/lib/element/topLevelAssertion.js +4 -11
- package/lib/element/topLevelMetaAssertion.js +4 -11
- package/lib/element/variable.js +6 -3
- package/lib/process/assign.js +1 -9
- package/lib/process/unify.js +8 -8
- package/lib/process/validate.js +14 -7
- package/lib/process/verify.js +14 -7
- package/lib/utilities/unification.js +6 -6
- package/lib/utilities/validation.js +68 -55
- package/package.json +1 -1
- package/src/context/file/nominal.js +2 -2
- package/src/context/liminal.js +2 -2
- package/src/context/scoped.js +20 -2
- package/src/context.js +6 -0
- package/src/element/assertion/contained.js +40 -24
- package/src/element/assertion/defined.js +38 -24
- package/src/element/assertion/property.js +28 -22
- package/src/element/assertion/satisfies.js +21 -13
- package/src/element/assertion/subproof.js +21 -13
- package/src/element/assertion/type.js +28 -22
- package/src/element/assertion.js +4 -4
- package/src/element/assumption.js +31 -23
- package/src/element/combinator/bracketed.js +2 -2
- package/src/element/combinator.js +2 -2
- package/src/element/conclusion.js +7 -2
- package/src/element/constructor/bracketed.js +4 -2
- package/src/element/deduction.js +7 -2
- package/src/element/derivation.js +2 -3
- package/src/element/equality.js +45 -34
- package/src/element/frame.js +31 -21
- package/src/element/hypothesis.js +9 -6
- package/src/element/judgement.js +64 -20
- package/src/element/metavariable.js +31 -16
- package/src/element/proofAssertion/premise.js +7 -7
- package/src/element/proofAssertion/step.js +16 -10
- package/src/element/proofAssertion/supposition.js +6 -6
- package/src/element/proofAssertion.js +7 -4
- package/src/element/propertyRelation.js +8 -2
- package/src/element/reference.js +31 -21
- package/src/element/rule.js +3 -6
- package/src/element/signature.js +21 -10
- package/src/element/statement.js +14 -14
- package/src/element/subDerivation.js +2 -5
- package/src/element/subproof.js +9 -3
- package/src/element/substitution/frame.js +21 -9
- package/src/element/substitution/reference.js +20 -8
- package/src/element/substitution/statement.js +17 -9
- package/src/element/substitution/term.js +24 -8
- package/src/element/substitution.js +4 -4
- package/src/element/term.js +13 -13
- package/src/element/topLevelAssertion.js +3 -6
- package/src/element/topLevelMetaAssertion.js +3 -6
- package/src/element/variable.js +8 -4
- package/src/process/assign.js +0 -6
- package/src/process/unify.js +7 -7
- package/src/process/validate.js +23 -14
- package/src/process/verify.js +26 -17
- package/src/utilities/unification.js +4 -5
- package/src/utilities/validation.js +83 -75
package/src/element/reference.js
CHANGED
|
@@ -54,12 +54,12 @@ export default define(class Reference extends Element {
|
|
|
54
54
|
return equalTo;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
findValidRefernece(context) {
|
|
58
58
|
const metavariableNode = this.getMetavariableNode(),
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
reference = context.findReferenceByMetavariableNode(metavariableNode),
|
|
60
|
+
validReference = reference; ///
|
|
61
61
|
|
|
62
|
-
return
|
|
62
|
+
return validReference;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
isEqualTo(reference) {
|
|
@@ -111,38 +111,48 @@ export default define(class Reference extends Element {
|
|
|
111
111
|
matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
|
|
112
112
|
|
|
113
113
|
validate(context) {
|
|
114
|
-
let
|
|
114
|
+
let reference = null;
|
|
115
115
|
|
|
116
116
|
const referenceString = this.getString(); ///
|
|
117
117
|
|
|
118
118
|
context.trace(`Validating the '${referenceString}' reference...`);
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
const metavariableValidates = this.validateMetavariable(context);
|
|
120
|
+
const validRefernece = this.findValidRefernece(context);
|
|
122
121
|
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
if (validRefernece !== null) {
|
|
123
|
+
reference = validRefernece; ///
|
|
124
|
+
|
|
125
|
+
context.debug(`...the '${referenceString}' reference is alrady valid.`);
|
|
126
|
+
} else {
|
|
127
|
+
let validates = false;
|
|
128
|
+
|
|
129
|
+
if (!validates) {
|
|
130
|
+
const metavariableValidates = this.validateMetavariable(context);
|
|
131
|
+
|
|
132
|
+
if (metavariableValidates) {
|
|
133
|
+
validates = true;
|
|
134
|
+
}
|
|
125
135
|
}
|
|
126
|
-
}
|
|
127
136
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
137
|
+
if (!validates) {
|
|
138
|
+
const reference = this, ///
|
|
139
|
+
labelPresent = context.isLabelPresentByReference(reference);
|
|
131
140
|
|
|
132
|
-
|
|
133
|
-
|
|
141
|
+
if (labelPresent) {
|
|
142
|
+
validates = true;
|
|
143
|
+
}
|
|
134
144
|
}
|
|
135
|
-
}
|
|
136
145
|
|
|
137
|
-
|
|
138
|
-
|
|
146
|
+
if (validates) {
|
|
147
|
+
const reference = this; ///
|
|
139
148
|
|
|
140
|
-
|
|
149
|
+
context.addReference(reference);
|
|
141
150
|
|
|
142
|
-
|
|
151
|
+
context.debug(`...validated the '${referenceString}' reference.`);
|
|
152
|
+
}
|
|
143
153
|
}
|
|
144
154
|
|
|
145
|
-
return
|
|
155
|
+
return reference;
|
|
146
156
|
}
|
|
147
157
|
|
|
148
158
|
validateMetavariable(context) {
|
package/src/element/rule.js
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
import { Element, asynchronousUtilities } from "occam-languages";
|
|
5
5
|
|
|
6
|
-
import assignAssignments from "../process/assign";
|
|
7
|
-
|
|
8
6
|
import { define } from "../elements";
|
|
9
7
|
import { asyncScope } from "../utilities/context";
|
|
10
8
|
import { labelsFromJSON,
|
|
@@ -180,14 +178,13 @@ export default define(class Rule extends Element {
|
|
|
180
178
|
context.trace(`Verifying the '${ruleString}' rule's premises...`);
|
|
181
179
|
|
|
182
180
|
premisesVerify = await asyncForwardsEvery(this.premises, async (premise) => {
|
|
183
|
-
const
|
|
184
|
-
premiseVerifies = await premise.verify(assignments, context)
|
|
181
|
+
const premiseVerifies = await premise.verify(context)
|
|
185
182
|
|
|
186
183
|
if (premiseVerifies) {
|
|
187
|
-
assignAssignments(assignments, context);
|
|
188
|
-
|
|
189
184
|
const subproofOrProofAssertion = premise; ////
|
|
190
185
|
|
|
186
|
+
context.assignAssignments();
|
|
187
|
+
|
|
191
188
|
context.addSubproofOrProofAssertion(subproofOrProofAssertion);
|
|
192
189
|
|
|
193
190
|
return true;
|
package/src/element/signature.js
CHANGED
|
@@ -28,23 +28,34 @@ export default define(class Signature extends Element {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
verify(context) {
|
|
31
|
-
let verifies;
|
|
31
|
+
let verifies = false;
|
|
32
32
|
|
|
33
33
|
const signatureString = this.getString(); ///
|
|
34
34
|
|
|
35
35
|
context.trace(`Verifying the '${signatureString}' signature...`);
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const terms = [],
|
|
38
|
+
termsValidate = this.terms.every((term) => {
|
|
39
|
+
term = term.validate(context, () => { ///
|
|
40
|
+
const validatesForwards = true;
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
return validatesForwards;
|
|
43
|
+
});
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
const termValidates = (term !== null);
|
|
46
|
+
|
|
47
|
+
if (termValidates) {
|
|
48
|
+
terms.push(term);
|
|
49
|
+
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (termsValidate) {
|
|
55
|
+
this.terms = terms;
|
|
56
|
+
|
|
57
|
+
verifies = true;
|
|
58
|
+
}
|
|
48
59
|
|
|
49
60
|
if (verifies) {
|
|
50
61
|
context.debug(`...verified the '${signatureString}' signature.`);
|
package/src/element/statement.js
CHANGED
|
@@ -62,12 +62,12 @@ export default define(class Statement extends Element {
|
|
|
62
62
|
return comparesToMetavariableName;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
findValidStatment(context) {
|
|
66
66
|
const statementNode = this.getStatementNode(),
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
statement = context.findStatementByStatementNode(statementNode),
|
|
68
|
+
validStatement = statement; ///
|
|
69
69
|
|
|
70
|
-
return
|
|
70
|
+
return validStatement;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
isEqualTo(statement) {
|
|
@@ -172,23 +172,23 @@ export default define(class Statement extends Element {
|
|
|
172
172
|
return comparesToMetavariableName;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
validate(
|
|
176
|
-
let
|
|
175
|
+
validate(stated, context) {
|
|
176
|
+
let statement = null;
|
|
177
177
|
|
|
178
178
|
const statementString = this.getString(); ///
|
|
179
179
|
|
|
180
180
|
context.trace(`Validating the '${statementString}' statement...`);
|
|
181
181
|
|
|
182
|
-
const
|
|
182
|
+
const validStatement = this.findValidStatment(context);
|
|
183
183
|
|
|
184
|
-
if (
|
|
185
|
-
|
|
184
|
+
if (validStatement !== null) {
|
|
185
|
+
statement = validStatement; ///
|
|
186
186
|
|
|
187
187
|
context.debug(`...the '${statementString}' statement is alrady valid.`);
|
|
188
188
|
} else {
|
|
189
|
-
validates = validateStatements.some((validateStatement) => {
|
|
189
|
+
const validates = validateStatements.some((validateStatement) => {
|
|
190
190
|
const statement = this, ///
|
|
191
|
-
statementValidates = validateStatement(statement,
|
|
191
|
+
statementValidates = validateStatement(statement, stated, context);
|
|
192
192
|
|
|
193
193
|
if (statementValidates) {
|
|
194
194
|
return true;
|
|
@@ -204,10 +204,10 @@ export default define(class Statement extends Element {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
return
|
|
207
|
+
return statement;
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
validateGivenMetaType(metaType,
|
|
210
|
+
validateGivenMetaType(metaType, stated, context) {
|
|
211
211
|
let validatesGivenMetaType = false;
|
|
212
212
|
|
|
213
213
|
const metaTypeString = metaType.getString(),
|
|
@@ -218,7 +218,7 @@ export default define(class Statement extends Element {
|
|
|
218
218
|
const metaTypeName = metaType.getName();
|
|
219
219
|
|
|
220
220
|
if (metaTypeName === STATEMENT_META_TYPE_NAME) {
|
|
221
|
-
const validates = this.validate(
|
|
221
|
+
const validates = this.validate(stated, context)
|
|
222
222
|
|
|
223
223
|
validatesGivenMetaType = validates; ///
|
|
224
224
|
}
|
|
@@ -5,8 +5,6 @@ import { Element, asynchronousUtilities } from "occam-languages";
|
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
7
|
|
|
8
|
-
import assignAssignments from "../process/assign";
|
|
9
|
-
|
|
10
8
|
const { last } = arrayUtilities,
|
|
11
9
|
{ asyncEvery } = asynchronousUtilities;
|
|
12
10
|
|
|
@@ -39,11 +37,10 @@ export default define(class SubDerivation extends Element {
|
|
|
39
37
|
let verifies;
|
|
40
38
|
|
|
41
39
|
verifies = await asyncEvery(this.subproofOrProofAssertions, async (subproofOrProofAssertion) => { ///
|
|
42
|
-
const
|
|
43
|
-
subproofOrProofAssertionVarifies = await subproofOrProofAssertion.verify(assignments, context);
|
|
40
|
+
const subproofOrProofAssertionVarifies = await subproofOrProofAssertion.verify(context);
|
|
44
41
|
|
|
45
42
|
if (subproofOrProofAssertionVarifies) {
|
|
46
|
-
assignAssignments(
|
|
43
|
+
context.assignAssignments();
|
|
47
44
|
|
|
48
45
|
context.addSubproofOrProofAssertion(subproofOrProofAssertion);
|
|
49
46
|
|
package/src/element/subproof.js
CHANGED
|
@@ -54,14 +54,20 @@ export default define(class Subproof extends Element {
|
|
|
54
54
|
return proofAssertion;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
async verify(
|
|
57
|
+
async verify(context) {
|
|
58
58
|
let verifies = false;
|
|
59
59
|
|
|
60
60
|
await asyncScope(async () => {
|
|
61
|
-
const suppositionsVerify = asyncEvery(this.suppositions, async (supposition) => {
|
|
62
|
-
const suppositionVerifies = await supposition.verify(
|
|
61
|
+
const suppositionsVerify = await asyncEvery(this.suppositions, async (supposition) => {
|
|
62
|
+
const suppositionVerifies = await supposition.verify(context);
|
|
63
63
|
|
|
64
64
|
if (suppositionVerifies) {
|
|
65
|
+
const subproofOrProofAssertion = supposition; ////
|
|
66
|
+
|
|
67
|
+
context.assignAssignments(context);
|
|
68
|
+
|
|
69
|
+
context.addSubproofOrProofAssertion(subproofOrProofAssertion);
|
|
70
|
+
|
|
65
71
|
return true;
|
|
66
72
|
}
|
|
67
73
|
});
|
|
@@ -71,7 +71,7 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
validate(generalContext, specificContext) {
|
|
74
|
-
let
|
|
74
|
+
let frameSubstitution = null;
|
|
75
75
|
|
|
76
76
|
const context = this.getContext();
|
|
77
77
|
|
|
@@ -81,13 +81,15 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
81
81
|
|
|
82
82
|
context.trace(`Validating the '${frameSubstitutionString}' frame substitution...`);
|
|
83
83
|
|
|
84
|
-
const
|
|
84
|
+
const validSubstitution = this.findValidSubstiution(context);
|
|
85
85
|
|
|
86
|
-
if (
|
|
87
|
-
|
|
86
|
+
if (validSubstitution) {
|
|
87
|
+
frameSubstitution = validSubstitution; ///
|
|
88
88
|
|
|
89
89
|
context.debug(`...the '${frameSubstitutionString}' frame substitution is already valid.`);
|
|
90
90
|
} else {
|
|
91
|
+
let validates = false;
|
|
92
|
+
|
|
91
93
|
const targetFrameValidates = this.validateTargetFrame(generalContext, specificContext);
|
|
92
94
|
|
|
93
95
|
if (targetFrameValidates) {
|
|
@@ -101,13 +103,15 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
101
103
|
if (validates) {
|
|
102
104
|
const substitution = this; ///
|
|
103
105
|
|
|
106
|
+
frameSubstitution = substitution; ///
|
|
107
|
+
|
|
104
108
|
context.addSubstitution(substitution);
|
|
105
109
|
|
|
106
110
|
context.debug(`...validated the '${frameSubstitutionString}' frame substitution.`);
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
113
|
|
|
110
|
-
return
|
|
114
|
+
return frameSubstitution;
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
validateTargetFrame(generalContext, specificContext) {
|
|
@@ -123,9 +127,13 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
123
127
|
|
|
124
128
|
if (targetFrameSingular) {
|
|
125
129
|
const stated = true,
|
|
126
|
-
|
|
130
|
+
tragetFrame = this.targetFrame.validate(stated, context);
|
|
131
|
+
|
|
132
|
+
if (tragetFrame !== null) {
|
|
133
|
+
this.targetFrame = tragetFrame;
|
|
127
134
|
|
|
128
|
-
|
|
135
|
+
targetFrameValidates = true;
|
|
136
|
+
}
|
|
129
137
|
} else {
|
|
130
138
|
context.debug(`The '${frameSubstitutionString}' frame subtitution's '${targetFrameString}' target frame is not singular.`);
|
|
131
139
|
}
|
|
@@ -147,9 +155,13 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
147
155
|
context.trace(`Validating the '${frameSubstitutionString}' frame subtitution's '${replacementFrameString}' replacement frame...`);
|
|
148
156
|
|
|
149
157
|
const stated = true,
|
|
150
|
-
|
|
158
|
+
replacementFrame = this.replacementFrame.validate(stated, context);
|
|
159
|
+
|
|
160
|
+
if (replacementFrame !== null) {
|
|
161
|
+
this.replacementFrame = replacementFrame;
|
|
151
162
|
|
|
152
|
-
|
|
163
|
+
replacementFrameValidates = true;
|
|
164
|
+
}
|
|
153
165
|
|
|
154
166
|
if (replacementFrameValidates) {
|
|
155
167
|
context.debug(`...validated the '${frameSubstitutionString}' frame subtitution's '${replacementFrameString}' replacement frame.`);
|
|
@@ -71,7 +71,7 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
validate(generalContext, specificContext) {
|
|
74
|
-
let
|
|
74
|
+
let referenceSubstitution = null;
|
|
75
75
|
|
|
76
76
|
const context = this.getContext();
|
|
77
77
|
|
|
@@ -81,13 +81,15 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
81
81
|
|
|
82
82
|
context.trace(`Validating the '${referenceSubstitutionString}' reference substitution...`);
|
|
83
83
|
|
|
84
|
-
const
|
|
84
|
+
const validSubstitution = this.findValidSubstiution(context);
|
|
85
85
|
|
|
86
|
-
if (
|
|
87
|
-
|
|
86
|
+
if (validSubstitution) {
|
|
87
|
+
referenceSubstitution = validSubstitution; ///
|
|
88
88
|
|
|
89
89
|
context.debug(`...the '${referenceSubstitutionString}' reference substitution is already valid.`);
|
|
90
90
|
} else {
|
|
91
|
+
let validates = false;
|
|
92
|
+
|
|
91
93
|
const targetReferenceValidates = this.validateTargetReference(generalContext, specificContext);
|
|
92
94
|
|
|
93
95
|
if (targetReferenceValidates) {
|
|
@@ -101,13 +103,15 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
101
103
|
if (validates) {
|
|
102
104
|
const subsitution = this; ///
|
|
103
105
|
|
|
106
|
+
referenceSubstitution = subsitution; ///
|
|
107
|
+
|
|
104
108
|
context.addSubstitution(subsitution);
|
|
105
109
|
|
|
106
110
|
context.debug(`...validated the '${referenceSubstitutionString}' reference substitution.`);
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
113
|
|
|
110
|
-
return
|
|
114
|
+
return referenceSubstitution;
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
validateTargetReference(generalContext, specificContext) {
|
|
@@ -122,7 +126,11 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
122
126
|
const targetReferenceSingular = this.targetReference.isSingular();
|
|
123
127
|
|
|
124
128
|
if (targetReferenceSingular) {
|
|
125
|
-
|
|
129
|
+
const targetReference = this.targetReference.validate(context);
|
|
130
|
+
|
|
131
|
+
if (targetReference !== null) {
|
|
132
|
+
targetReferenceValidates = true;
|
|
133
|
+
}
|
|
126
134
|
} else {
|
|
127
135
|
context.debug(`The '${referenceSubstitutionString}' reference subtitution's '${targetReferenceString}' target reference is not singular.`);
|
|
128
136
|
}
|
|
@@ -135,7 +143,7 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
135
143
|
}
|
|
136
144
|
|
|
137
145
|
validateReplacementReference(generalContext, specificContext) {
|
|
138
|
-
let replacementReferenceValidates;
|
|
146
|
+
let replacementReferenceValidates = false;
|
|
139
147
|
|
|
140
148
|
const context = specificContext, ///
|
|
141
149
|
replacementReferenceString = this.replacementReference.getString(),
|
|
@@ -143,7 +151,11 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
143
151
|
|
|
144
152
|
context.trace(`Validating the '${referenceSubstitutionString}' reference subtitution's '${replacementReferenceString}' replacement reference...`);
|
|
145
153
|
|
|
146
|
-
|
|
154
|
+
const replacementReference = this.replacementReference.validate(context);
|
|
155
|
+
|
|
156
|
+
if (replacementReference !== null) {
|
|
157
|
+
replacementReferenceValidates = true;
|
|
158
|
+
}
|
|
147
159
|
|
|
148
160
|
if (replacementReferenceValidates) {
|
|
149
161
|
context.debug(`...validated the '${referenceSubstitutionString}' reference subtitution's '${replacementReferenceString}' replacement reference.`);
|
|
@@ -107,7 +107,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
107
107
|
compareMetavariable(metavariable) { return this.targetStatement.compareMetavariable(metavariable); }
|
|
108
108
|
|
|
109
109
|
validate(generalContext, specificContext) {
|
|
110
|
-
let
|
|
110
|
+
let statementSubstitution = null;
|
|
111
111
|
|
|
112
112
|
const context = this.getContext();
|
|
113
113
|
|
|
@@ -117,13 +117,15 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
117
117
|
|
|
118
118
|
context.trace(`Validating the '${statementSubstitutionString}' statement substitution...`);
|
|
119
119
|
|
|
120
|
-
const
|
|
120
|
+
const validSubstitution = this.findValidSubstiution(context);
|
|
121
121
|
|
|
122
|
-
if (
|
|
123
|
-
|
|
122
|
+
if (validSubstitution) {
|
|
123
|
+
statementSubstitution = validSubstitution; ///
|
|
124
124
|
|
|
125
125
|
context.debug(`...the '${statementSubstitutionString}' statement substitution is already valid.`);
|
|
126
126
|
} else {
|
|
127
|
+
let validates = false;
|
|
128
|
+
|
|
127
129
|
const targetStatementValidates = this.validateTargetStatement(generalContext, specificContext);
|
|
128
130
|
|
|
129
131
|
if (targetStatementValidates) {
|
|
@@ -137,13 +139,15 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
137
139
|
if (validates) {
|
|
138
140
|
const substitution = this; ///
|
|
139
141
|
|
|
142
|
+
statementSubstitution = substitution; ///
|
|
143
|
+
|
|
140
144
|
context.addSubstitution(substitution);
|
|
141
145
|
|
|
142
146
|
context.debug(`...validated the '${statementSubstitutionString}' statement substitution.`);
|
|
143
147
|
}
|
|
144
148
|
}
|
|
145
149
|
|
|
146
|
-
return
|
|
150
|
+
return statementSubstitution;
|
|
147
151
|
}
|
|
148
152
|
|
|
149
153
|
validateTargetStatement(generalContext, specificContext) {
|
|
@@ -159,9 +163,11 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
159
163
|
|
|
160
164
|
if (targetStatementSingular) {
|
|
161
165
|
const stated = true,
|
|
162
|
-
|
|
166
|
+
targetStatement = this.targetStatement.validate(stated, context);
|
|
163
167
|
|
|
164
|
-
|
|
168
|
+
if (targetStatement !== null) {
|
|
169
|
+
targetStatementValidates = true;
|
|
170
|
+
}
|
|
165
171
|
} else {
|
|
166
172
|
context.debug(`The '${statementSubstitutionString}' statement subtitution's '${targetStatementString}' target statement is not singular.`);
|
|
167
173
|
}
|
|
@@ -183,9 +189,11 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
183
189
|
context.trace(`Validating the '${statementSubstitutionString}' statement subtitution's '${replacementStatementString}' replacement statement...`);
|
|
184
190
|
|
|
185
191
|
const stated = true,
|
|
186
|
-
|
|
192
|
+
replacementStatement = this.replacementStatement.validate(stated, context);
|
|
187
193
|
|
|
188
|
-
|
|
194
|
+
if (replacementStatement !== null) {
|
|
195
|
+
replacementStatementValidates = true;
|
|
196
|
+
}
|
|
189
197
|
|
|
190
198
|
if (replacementStatementValidates) {
|
|
191
199
|
context.debug(`...validated the '${statementSubstitutionString}' statement subtitution's '${replacementStatementString}' replacement statement.`);
|
|
@@ -74,7 +74,7 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
validate(generalContext, specificContext) {
|
|
77
|
-
let
|
|
77
|
+
let termSubstitution = null;
|
|
78
78
|
|
|
79
79
|
const context = this.getContext();
|
|
80
80
|
|
|
@@ -84,13 +84,15 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
84
84
|
|
|
85
85
|
context.trace(`Validating the '${termSubstitutionString}' term substitution...`);
|
|
86
86
|
|
|
87
|
-
const
|
|
87
|
+
const validSubstitution = this.findValidSubstiution(context);
|
|
88
88
|
|
|
89
|
-
if (
|
|
90
|
-
|
|
89
|
+
if (validSubstitution) {
|
|
90
|
+
termSubstitution = validSubstitution; ///
|
|
91
91
|
|
|
92
92
|
context.debug(`...the '${termSubstitutionString}' term substitution is alrady valid.`);
|
|
93
93
|
} else {
|
|
94
|
+
let validates = false;
|
|
95
|
+
|
|
94
96
|
const targetTermValidates = this.validateTargetTerm(generalContext, specificContext);
|
|
95
97
|
|
|
96
98
|
if (targetTermValidates) {
|
|
@@ -104,13 +106,15 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
104
106
|
if (validates) {
|
|
105
107
|
const substitution = this; ///
|
|
106
108
|
|
|
109
|
+
termSubstitution = substitution; ///
|
|
110
|
+
|
|
107
111
|
context.addSubstitution(substitution);
|
|
108
112
|
|
|
109
113
|
context.debug(`...validated the '${termSubstitutionString}' term substitution.`);
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
116
|
|
|
113
|
-
return
|
|
117
|
+
return termSubstitution;
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
validateTargetTerm(generalContext, specificContext) {
|
|
@@ -125,11 +129,17 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
125
129
|
const targetTermSingular = this.targetTerm.isSingular();
|
|
126
130
|
|
|
127
131
|
if (targetTermSingular) {
|
|
128
|
-
|
|
132
|
+
const targetTerm = this.targetTerm.validate(context, () => {
|
|
129
133
|
const validatesForwards = true;
|
|
130
134
|
|
|
131
135
|
return validatesForwards;
|
|
132
136
|
});
|
|
137
|
+
|
|
138
|
+
if (targetTerm !== null) {
|
|
139
|
+
this.targetTerm = targetTerm;
|
|
140
|
+
|
|
141
|
+
targetTermValidates = true;
|
|
142
|
+
}
|
|
133
143
|
} else {
|
|
134
144
|
context.debug(`The '${termSubstitutionString}' term subtitution's '${targetTermString}' target term is not singular.`);
|
|
135
145
|
}
|
|
@@ -142,7 +152,7 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
142
152
|
}
|
|
143
153
|
|
|
144
154
|
validateReplacementTerm(generalContext, specificContext) {
|
|
145
|
-
let replacementTermValidates;
|
|
155
|
+
let replacementTermValidates = false;
|
|
146
156
|
|
|
147
157
|
const context = specificContext, ///
|
|
148
158
|
replacementTermString = this.replacementTerm.getString(),
|
|
@@ -150,12 +160,18 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
150
160
|
|
|
151
161
|
context.trace(`Validating the '${termSubstitutionString}' term subtitution's '${replacementTermString}' replacement term...`);
|
|
152
162
|
|
|
153
|
-
|
|
163
|
+
const replacementTerm = this.replacementTerm.validate(context, () => {
|
|
154
164
|
const validatesForwards = true;
|
|
155
165
|
|
|
156
166
|
return validatesForwards;
|
|
157
167
|
});
|
|
158
168
|
|
|
169
|
+
if (replacementTerm !== null) {
|
|
170
|
+
this.replacementTerm = replacementTerm;
|
|
171
|
+
|
|
172
|
+
replacementTermValidates = true;
|
|
173
|
+
}
|
|
174
|
+
|
|
159
175
|
if (replacementTermValidates) {
|
|
160
176
|
context.debug(`...validated the '${termSubstitutionString}' term subtitution's '${replacementTermString}' replacement term...`);
|
|
161
177
|
}
|
|
@@ -34,12 +34,12 @@ export default class Substitution extends Element {
|
|
|
34
34
|
return equalTo;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
findValidSubstiution(context) {
|
|
38
38
|
const substitutionNode = this.getSubstitutionNode(),
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
substitution = context.findSubstitutionBySubstitutionNode(substitutionNode),
|
|
40
|
+
validSubstitution = substitution; ///
|
|
41
41
|
|
|
42
|
-
return
|
|
42
|
+
return validSubstitution;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
isEqualTo(substitution) {
|