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
|
@@ -28,28 +28,30 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
28
28
|
return typeAssertionNode;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
validate(
|
|
32
|
-
let
|
|
31
|
+
validate(stated, context) {
|
|
32
|
+
let typeAssertion = null;
|
|
33
33
|
|
|
34
34
|
const typeAssertionString = this.getString(); ///
|
|
35
35
|
|
|
36
36
|
context.trace(`Validating the '${typeAssertionString}' type assertion...`);
|
|
37
37
|
|
|
38
|
-
const
|
|
38
|
+
const validAssertion = this.findValidAssertion(context);
|
|
39
39
|
|
|
40
|
-
if (
|
|
41
|
-
|
|
40
|
+
if (validAssertion) {
|
|
41
|
+
typeAssertion = validAssertion; ///
|
|
42
42
|
|
|
43
43
|
context.debug(`...the '${typeAssertionString}' type assertion is already valid.`);
|
|
44
44
|
} else {
|
|
45
|
+
let validates = false;
|
|
46
|
+
|
|
45
47
|
const typeValidates = this.validateType(context);
|
|
46
48
|
|
|
47
49
|
if (typeValidates) {
|
|
48
50
|
let validatesWhenStated = false,
|
|
49
|
-
|
|
51
|
+
validatesWhenDerived = false;
|
|
50
52
|
|
|
51
53
|
if (stated) {
|
|
52
|
-
validatesWhenStated = this.validateWhenStated(
|
|
54
|
+
validatesWhenStated = this.validateWhenStated(context);
|
|
53
55
|
} else {
|
|
54
56
|
validatesWhenDerived = this.validateWhenDerived(context);
|
|
55
57
|
}
|
|
@@ -62,15 +64,17 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
62
64
|
if (validates) {
|
|
63
65
|
const assertion = this; ///
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
typeAssertion = assertion; ///
|
|
66
68
|
|
|
67
|
-
this.assign(
|
|
69
|
+
this.assign(stated, context);
|
|
70
|
+
|
|
71
|
+
context.addAssertion(assertion);
|
|
68
72
|
|
|
69
73
|
context.debug(`...verified the '${typeAssertionString}' type assertion.`);
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
76
|
|
|
73
|
-
return
|
|
77
|
+
return typeAssertion;
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
validateType(context) {
|
|
@@ -98,14 +102,14 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
98
102
|
return typeValidates;
|
|
99
103
|
}
|
|
100
104
|
|
|
101
|
-
validateWhenStated(
|
|
105
|
+
validateWhenStated(context) {
|
|
102
106
|
let validatesWhenStated = false;
|
|
103
107
|
|
|
104
108
|
const typeAssertionString = this.getString(); ///
|
|
105
109
|
|
|
106
110
|
context.trace(`Validating the '${typeAssertionString}' stated type assertion...`);
|
|
107
111
|
|
|
108
|
-
const
|
|
112
|
+
const term = this.term.validate(context, () => {
|
|
109
113
|
let validatesForwards;
|
|
110
114
|
|
|
111
115
|
const termType = this.term.getType(),
|
|
@@ -118,7 +122,9 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
118
122
|
return validatesForwards;
|
|
119
123
|
});
|
|
120
124
|
|
|
121
|
-
if (
|
|
125
|
+
if (term !== null) {
|
|
126
|
+
this.term = term;
|
|
127
|
+
|
|
122
128
|
validatesWhenStated = true;
|
|
123
129
|
}
|
|
124
130
|
|
|
@@ -130,13 +136,13 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
validateWhenDerived(context) {
|
|
133
|
-
let validatesWhenDerived;
|
|
139
|
+
let validatesWhenDerived = false;
|
|
134
140
|
|
|
135
141
|
const typeAssertionString = this.getString(); ///
|
|
136
142
|
|
|
137
143
|
context.trace(`Validating the '${typeAssertionString}' derived type assertion...`);
|
|
138
144
|
|
|
139
|
-
const
|
|
145
|
+
const term = this.term.validate(context, () => {
|
|
140
146
|
let validatesForwards = false;
|
|
141
147
|
|
|
142
148
|
const termType = this.term.getType(),
|
|
@@ -153,7 +159,11 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
153
159
|
return validatesForwards;
|
|
154
160
|
});
|
|
155
161
|
|
|
156
|
-
|
|
162
|
+
if (term !== null) {
|
|
163
|
+
this.term = term;
|
|
164
|
+
|
|
165
|
+
validatesWhenDerived = true;
|
|
166
|
+
}
|
|
157
167
|
|
|
158
168
|
if (validatesWhenDerived) {
|
|
159
169
|
context.debug(`...verified the '${typeAssertionString}' derived type assertion.`);
|
|
@@ -162,11 +172,7 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
162
172
|
return validatesWhenDerived;
|
|
163
173
|
}
|
|
164
174
|
|
|
165
|
-
assign(
|
|
166
|
-
if (assignments === null) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
|
|
175
|
+
assign(stated, context) {
|
|
170
176
|
if (!stated) {
|
|
171
177
|
return;
|
|
172
178
|
}
|
|
@@ -175,7 +181,7 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
175
181
|
variableAssigment = variableAssignmentFromTypeAssertion(typeAssertion, context),
|
|
176
182
|
assignment = variableAssigment; ///
|
|
177
183
|
|
|
178
|
-
|
|
184
|
+
context.addAassignment(assignment);
|
|
179
185
|
}
|
|
180
186
|
|
|
181
187
|
static name = "TypeAssertion";
|
package/src/element/assertion.js
CHANGED
|
@@ -22,12 +22,12 @@ export default class Assertion extends Element {
|
|
|
22
22
|
return assertionNodeMatches;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
findValidAssertion(context) {
|
|
26
26
|
const assertionNode = this.getAssertionNode(),
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
assertion = context.findAssertionByAssertionNode(assertionNode),
|
|
28
|
+
validAssertion = assertion; ///
|
|
29
29
|
|
|
30
|
-
return
|
|
30
|
+
return validAssertion;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
isEqualTo(assertion) {
|
|
@@ -67,39 +67,41 @@ export default define(class Assumption extends Element {
|
|
|
67
67
|
return comparesToSubstituion;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
findValidAssumption(context) {
|
|
71
71
|
const assumptionNode = this.getAssumptionNode(),
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
assumption = context.findAssumptionByAssumptionNode(assumptionNode),
|
|
73
|
+
validAssumption = assumption; ///
|
|
74
74
|
|
|
75
|
-
return
|
|
75
|
+
return validAssumption;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
validate(
|
|
79
|
-
let
|
|
78
|
+
validate(stated, context) {
|
|
79
|
+
let assumption = null;
|
|
80
80
|
|
|
81
81
|
const assumptionString = this.getString(); ///
|
|
82
82
|
|
|
83
83
|
context.trace(`Validating the '${assumptionString}' assumption...`);
|
|
84
84
|
|
|
85
|
-
const
|
|
85
|
+
const validAssumption = this.findValidAssumption(context);
|
|
86
86
|
|
|
87
|
-
if (
|
|
88
|
-
|
|
87
|
+
if (validAssumption) {
|
|
88
|
+
assumption = validAssumption; ///
|
|
89
89
|
|
|
90
90
|
context.debug(`...the '${assumptionString}' assumption is already valid.`);
|
|
91
91
|
} else {
|
|
92
|
-
|
|
92
|
+
let validates = false;
|
|
93
|
+
|
|
94
|
+
const referenceValidates = this.validateReference(stated, context);
|
|
93
95
|
|
|
94
96
|
if (referenceValidates) {
|
|
95
|
-
const statementValidates = this.validateStatement(
|
|
97
|
+
const statementValidates = this.validateStatement(stated, context);
|
|
96
98
|
|
|
97
99
|
if (statementValidates) {
|
|
98
100
|
let validatesWhenStated = false,
|
|
99
101
|
validatesWhenDerived = false;
|
|
100
102
|
|
|
101
103
|
if (stated) {
|
|
102
|
-
validatesWhenStated = this.validateWhenStated(
|
|
104
|
+
validatesWhenStated = this.validateWhenStated(context);
|
|
103
105
|
} else {
|
|
104
106
|
validatesWhenDerived = this.validateWhenDerived(context);
|
|
105
107
|
}
|
|
@@ -119,18 +121,22 @@ export default define(class Assumption extends Element {
|
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
123
|
|
|
122
|
-
return
|
|
124
|
+
return assumption;
|
|
123
125
|
}
|
|
124
126
|
|
|
125
|
-
validateReference(
|
|
126
|
-
let referenceValidates;
|
|
127
|
+
validateReference(stated, context) {
|
|
128
|
+
let referenceValidates = false;
|
|
127
129
|
|
|
128
130
|
const assumptionString = this.getString(), ///
|
|
129
131
|
referenceString = this.reference.getString();
|
|
130
132
|
|
|
131
133
|
context.trace(`Validating the '${assumptionString}' assumption's '${referenceString}' reference...`);
|
|
132
134
|
|
|
133
|
-
|
|
135
|
+
const reference = this.reference.validate(context);
|
|
136
|
+
|
|
137
|
+
if (reference !== null) {
|
|
138
|
+
referenceValidates = true;
|
|
139
|
+
}
|
|
134
140
|
|
|
135
141
|
if (referenceValidates) {
|
|
136
142
|
context.debug(`...validated the '${assumptionString}' assumption's '${referenceString}' statement.`);
|
|
@@ -139,19 +145,21 @@ export default define(class Assumption extends Element {
|
|
|
139
145
|
return referenceValidates;
|
|
140
146
|
}
|
|
141
147
|
|
|
142
|
-
validateStatement(
|
|
143
|
-
let statementValidates;
|
|
148
|
+
validateStatement(stated, context) {
|
|
149
|
+
let statementValidates = false;
|
|
144
150
|
|
|
145
151
|
const assumptionString = this.getString(), ///
|
|
146
|
-
|
|
152
|
+
statementString = this.statement.getString();
|
|
147
153
|
|
|
148
154
|
context.trace(`Validating the '${assumptionString}' assumption's '${statementString}' statement...`);
|
|
149
155
|
|
|
150
156
|
stated = true; ///
|
|
151
157
|
|
|
152
|
-
|
|
158
|
+
const statement = this.statement.validate(stated, context);
|
|
153
159
|
|
|
154
|
-
|
|
160
|
+
if (statement !== null) {
|
|
161
|
+
statementValidates = true;
|
|
162
|
+
}
|
|
155
163
|
|
|
156
164
|
if (statementValidates) {
|
|
157
165
|
context.debug(`...validated the '${assumptionString}' assumption's '${statementString}' statement.`);
|
|
@@ -160,7 +168,7 @@ export default define(class Assumption extends Element {
|
|
|
160
168
|
return statementValidates;
|
|
161
169
|
}
|
|
162
170
|
|
|
163
|
-
validateReferenceAsMetavariable(
|
|
171
|
+
validateReferenceAsMetavariable(stated, context) {
|
|
164
172
|
let referenceValidatesAsMetavariable;
|
|
165
173
|
|
|
166
174
|
const referenceString = this.reference.getString(),
|
|
@@ -177,7 +185,7 @@ export default define(class Assumption extends Element {
|
|
|
177
185
|
return referenceValidatesAsMetavariable;
|
|
178
186
|
}
|
|
179
187
|
|
|
180
|
-
validateWhenStated(
|
|
188
|
+
validateWhenStated(context) {
|
|
181
189
|
let validatesWhenStated;
|
|
182
190
|
|
|
183
191
|
const assumptionString = this.getString(); ///
|
|
@@ -12,14 +12,14 @@ export default define(class BracketedCombinator extends Combinator {
|
|
|
12
12
|
return bracketedCombinatorNode;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
unifyStatement(statement,
|
|
15
|
+
unifyStatement(statement, stated, context) {
|
|
16
16
|
let statementUnifies;
|
|
17
17
|
|
|
18
18
|
const statementString = statement.getString();
|
|
19
19
|
|
|
20
20
|
context.trace(`Unifying the '${statementString}' statement with the bracketed combinator...`);
|
|
21
21
|
|
|
22
|
-
statementUnifies = super.unifyStatement(statement,
|
|
22
|
+
statementUnifies = super.unifyStatement(statement, stated, context);
|
|
23
23
|
|
|
24
24
|
if (statementUnifies) {
|
|
25
25
|
context.debug(`...unified the '${statementString}' statement with the bracketed combinator.`);
|
|
@@ -47,7 +47,7 @@ export default define(class Combinator extends Element {
|
|
|
47
47
|
return verifies;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
unifyStatement(statement,
|
|
50
|
+
unifyStatement(statement, stated, context) {
|
|
51
51
|
let statementUnifies;
|
|
52
52
|
|
|
53
53
|
const statementString = statement.getString(),
|
|
@@ -64,7 +64,7 @@ export default define(class Combinator extends Element {
|
|
|
64
64
|
context = specifiContext; ///
|
|
65
65
|
|
|
66
66
|
const combinator = this, ///
|
|
67
|
-
statementUnifiesWithCombinator = unifyStatementWithCombinator(statement, combinator,
|
|
67
|
+
statementUnifiesWithCombinator = unifyStatementWithCombinator(statement, combinator, stated, generalContext, specifiContext);
|
|
68
68
|
|
|
69
69
|
statementUnifies = statementUnifiesWithCombinator; ///
|
|
70
70
|
|
|
@@ -35,9 +35,14 @@ export default define(class Conclusion extends Element {
|
|
|
35
35
|
|
|
36
36
|
if (this.statement !== null) {
|
|
37
37
|
attempt((context) => {
|
|
38
|
+
let statementValidates = false;
|
|
39
|
+
|
|
38
40
|
const stated = true,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
statement = this.statement.validate(stated, context);
|
|
42
|
+
|
|
43
|
+
if (statement !== null) {
|
|
44
|
+
statementValidates = true;
|
|
45
|
+
}
|
|
41
46
|
|
|
42
47
|
if (statementValidates) {
|
|
43
48
|
this.setContext(context);
|
|
@@ -32,7 +32,7 @@ export default define(class BracketedConstructor extends Constructor {
|
|
|
32
32
|
|
|
33
33
|
term = termFromTermNode(termNode, context);
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
term = term.validate(context, () => {
|
|
36
36
|
let validatesForwards;
|
|
37
37
|
|
|
38
38
|
const type = term.getType();
|
|
@@ -44,7 +44,9 @@ export default define(class BracketedConstructor extends Constructor {
|
|
|
44
44
|
return validatesForwards;
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
if (term !== null) {
|
|
48
|
+
validatesForwards = true;
|
|
49
|
+
}
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
return validatesForwards;
|
package/src/element/deduction.js
CHANGED
|
@@ -35,9 +35,14 @@ export default define(class Deduction extends Element {
|
|
|
35
35
|
|
|
36
36
|
if (this.statement !== null) {
|
|
37
37
|
attempt((context) => {
|
|
38
|
+
let statementValidates = false;
|
|
39
|
+
|
|
38
40
|
const stated = true,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
statement = this.statement.validate(stated, context);
|
|
42
|
+
|
|
43
|
+
if (statement !== null) {
|
|
44
|
+
statementValidates = true;
|
|
45
|
+
}
|
|
41
46
|
|
|
42
47
|
if (statementValidates) {
|
|
43
48
|
this.setContext(context);
|
|
@@ -39,11 +39,10 @@ export default define(class Derivation extends Element {
|
|
|
39
39
|
let verifies;
|
|
40
40
|
|
|
41
41
|
verifies = await asyncEvery(this.subproofOrProofAssertions, async (subproofOrProofAssertion) => { ///
|
|
42
|
-
const
|
|
43
|
-
subproofOrProofAssertionVerifies = await subproofOrProofAssertion.verify(assignments, context);
|
|
42
|
+
const subproofOrProofAssertionVerifies = await subproofOrProofAssertion.verify(context);
|
|
44
43
|
|
|
45
44
|
if (subproofOrProofAssertionVerifies) {
|
|
46
|
-
assignAssignments(
|
|
45
|
+
context.assignAssignments();
|
|
47
46
|
|
|
48
47
|
context.addSubproofOrProofAssertion(subproofOrProofAssertion);
|
|
49
48
|
|
package/src/element/equality.js
CHANGED
|
@@ -111,28 +111,30 @@ export default define(class Equality extends Element {
|
|
|
111
111
|
return equal;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
findValidEquality(context) {
|
|
115
115
|
const equalityNode = this.getEqualityNode(),
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
equality = context.findEqualityByEqualityNode(equalityNode),
|
|
117
|
+
validEquality = equality; ///
|
|
118
118
|
|
|
119
|
-
return
|
|
119
|
+
return validEquality;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
validate(
|
|
123
|
-
let
|
|
122
|
+
validate(stated, context) {
|
|
123
|
+
let equality = false;
|
|
124
124
|
|
|
125
125
|
const equalityString = this.getString(); ///
|
|
126
126
|
|
|
127
127
|
context.trace(`Validating the '${equalityString}' equality...`);
|
|
128
128
|
|
|
129
|
-
const
|
|
129
|
+
const validEquality = this.isValid(context);
|
|
130
130
|
|
|
131
|
-
if (
|
|
132
|
-
|
|
131
|
+
if (validEquality !== null) {
|
|
132
|
+
equality = validEquality; ///
|
|
133
133
|
|
|
134
134
|
context.debug(`...the '${equalityString}' equality is already valid.`);
|
|
135
135
|
} else {
|
|
136
|
+
let validates = false;
|
|
137
|
+
|
|
136
138
|
const termsValidate = this.validateTerms(context);
|
|
137
139
|
|
|
138
140
|
if (termsValidate) {
|
|
@@ -140,7 +142,7 @@ export default define(class Equality extends Element {
|
|
|
140
142
|
validatesWhenDerived = false;
|
|
141
143
|
|
|
142
144
|
if (stated) {
|
|
143
|
-
validatesWhenStated = this.validateWhenStated(
|
|
145
|
+
validatesWhenStated = this.validateWhenStated(context);
|
|
144
146
|
} else {
|
|
145
147
|
validatesWhenDerived = this.validateWhenDerived(context);
|
|
146
148
|
}
|
|
@@ -153,45 +155,58 @@ export default define(class Equality extends Element {
|
|
|
153
155
|
if (validates) {
|
|
154
156
|
const equality = this; ///
|
|
155
157
|
|
|
156
|
-
|
|
158
|
+
this.assign(stated, context);
|
|
157
159
|
|
|
158
|
-
|
|
160
|
+
context.addEquality(equality);
|
|
159
161
|
|
|
160
162
|
context.debug(`...validated the '${equalityString}' equality.`);
|
|
161
163
|
}
|
|
162
164
|
}
|
|
163
165
|
|
|
164
|
-
return
|
|
166
|
+
return equality;
|
|
165
167
|
}
|
|
166
168
|
|
|
167
169
|
validateTerms(context) {
|
|
168
|
-
let termsValidate;
|
|
170
|
+
let termsValidate = false;
|
|
169
171
|
|
|
170
172
|
const equalityString = this.getString(); ///
|
|
171
173
|
|
|
172
174
|
context.trace(`Validating the '${equalityString}' equality's terms...`);
|
|
173
175
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
+
let leftTerm,
|
|
177
|
+
rightTerm = null;
|
|
176
178
|
|
|
177
|
-
|
|
179
|
+
leftTerm = this.leftTerm.validate(context, () => {
|
|
178
180
|
let validatesForwards;
|
|
179
181
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
182
|
+
rightTerm = this.rightTerm.validate(context, () => {
|
|
183
|
+
let validatesForwards;
|
|
184
|
+
|
|
185
|
+
const leftTermType = this.leftTerm.getType(),
|
|
186
|
+
rightTermType = this.rightTerm.getType(),
|
|
187
|
+
leftTermTypeComparableToRightTermType = leftTermType.isComparableTo(rightTermType);
|
|
188
|
+
|
|
189
|
+
validatesForwards = leftTermTypeComparableToRightTermType; ///
|
|
190
|
+
|
|
191
|
+
return validatesForwards;
|
|
192
|
+
});
|
|
183
193
|
|
|
184
|
-
|
|
194
|
+
const rightTermValidates = (rightTerm !== null);
|
|
195
|
+
|
|
196
|
+
validatesForwards = rightTermValidates; ///
|
|
185
197
|
|
|
186
198
|
return validatesForwards;
|
|
187
199
|
});
|
|
188
200
|
|
|
189
|
-
|
|
201
|
+
const leftTermValidates = (leftTerm !== null);
|
|
202
|
+
|
|
203
|
+
if (leftTermValidates) {
|
|
204
|
+
this.leftTerm = leftTerm;
|
|
190
205
|
|
|
191
|
-
|
|
192
|
-
});
|
|
206
|
+
this.rightTerm = rightTerm;
|
|
193
207
|
|
|
194
|
-
|
|
208
|
+
termsValidate = true;
|
|
209
|
+
}
|
|
195
210
|
|
|
196
211
|
if (termsValidate) {
|
|
197
212
|
context.debug(`...validated the '${equalityString}' equality's terms.`);
|
|
@@ -200,7 +215,7 @@ export default define(class Equality extends Element {
|
|
|
200
215
|
return termsValidate;
|
|
201
216
|
}
|
|
202
217
|
|
|
203
|
-
validateWhenStated(
|
|
218
|
+
validateWhenStated(context) {
|
|
204
219
|
let validatesWhenStated;
|
|
205
220
|
|
|
206
221
|
const equalityString = this.getString(); ///
|
|
@@ -232,11 +247,7 @@ export default define(class Equality extends Element {
|
|
|
232
247
|
return validatesWhenDerived;
|
|
233
248
|
}
|
|
234
249
|
|
|
235
|
-
assign(
|
|
236
|
-
if (assignments === null) {
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
|
|
250
|
+
assign(stated, context) {
|
|
240
251
|
const equality = this, ///
|
|
241
252
|
equalityAssignment = equalityAssignmentFromEquality(equality, context),
|
|
242
253
|
leftVariableAssignment = leftVariableAssignmentFromEquality(equality, context),
|
|
@@ -246,18 +257,18 @@ export default define(class Equality extends Element {
|
|
|
246
257
|
|
|
247
258
|
assignment = equalityAssignment; ///
|
|
248
259
|
|
|
249
|
-
|
|
260
|
+
context.addAssignment(assignment);
|
|
250
261
|
|
|
251
262
|
if (leftVariableAssignment !== null) {
|
|
252
263
|
assignment = leftVariableAssignment; ///
|
|
253
264
|
|
|
254
|
-
|
|
265
|
+
context.addAssignment(assignment);
|
|
255
266
|
}
|
|
256
267
|
|
|
257
268
|
if (rightVariableAssignment !== null) {
|
|
258
269
|
assignment = rightVariableAssignment; ///
|
|
259
270
|
|
|
260
|
-
|
|
271
|
+
context.addAssignment(assignment);
|
|
261
272
|
}
|
|
262
273
|
}
|
|
263
274
|
|