occam-verify-cli 1.0.764 → 1.0.776
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 +16 -47
- package/lib/context/illative.js +28 -0
- package/lib/context/nested.js +27 -0
- package/lib/context/nominal.js +2 -4
- package/lib/context/proof.js +232 -0
- package/lib/context/thetic.js +28 -0
- package/lib/context.js +37 -12
- package/lib/element/assertion/contained.js +24 -22
- package/lib/element/assertion/defined.js +20 -19
- package/lib/element/assertion/property.js +14 -13
- package/lib/element/assertion/satisfies.js +9 -10
- package/lib/element/assertion/subproof.js +23 -26
- package/lib/element/assertion/type.js +9 -11
- package/lib/element/assumption.js +46 -55
- package/lib/element/combinator/bracketed.js +3 -3
- package/lib/element/combinator.js +20 -20
- package/lib/element/conclusion.js +33 -29
- package/lib/element/constructor.js +19 -18
- package/lib/element/deduction.js +33 -29
- package/lib/element/equality.js +13 -15
- package/lib/element/equivalence.js +58 -49
- package/lib/element/frame.js +41 -34
- package/lib/element/hypothesis.js +7 -5
- package/lib/element/judgement.js +33 -73
- package/lib/element/label.js +22 -22
- package/lib/element/metavariable.js +23 -7
- package/lib/element/proofAssertion/premise.js +48 -35
- package/lib/element/proofAssertion/step.js +35 -20
- package/lib/element/proofAssertion/supposition.js +48 -34
- package/lib/element/proofAssertion.js +1 -14
- package/lib/element/reference.js +79 -52
- package/lib/element/signature.js +44 -3
- package/lib/element/statement.js +28 -28
- package/lib/element/substitution/frame.js +28 -23
- package/lib/element/substitution/metaLevel.js +34 -30
- package/lib/element/substitution/reference.js +12 -11
- package/lib/element/substitution/statement.js +44 -39
- package/lib/element/substitution/term.js +12 -11
- package/lib/element/term.js +24 -20
- package/lib/element/topLevelMetaAssertion.js +2 -2
- package/lib/element/variable.js +6 -2
- package/lib/process/assign.js +10 -4
- package/lib/process/unify.js +8 -8
- package/lib/process/validate.js +10 -8
- package/lib/utilities/context.js +68 -25
- package/lib/utilities/element.js +55 -27
- package/lib/utilities/json.js +8 -8
- package/lib/utilities/statement.js +1 -8
- package/lib/utilities/string.js +12 -1
- package/lib/utilities/unification.js +6 -4
- package/lib/utilities/validation.js +39 -31
- package/package.json +1 -1
- package/src/context/file/nominal.js +26 -74
- package/src/context/illative.js +17 -0
- package/src/context/nested.js +15 -0
- package/src/context/nominal.js +1 -5
- package/src/context/{scoped.js → proof.js} +73 -73
- package/src/context/thetic.js +17 -0
- package/src/context.js +58 -17
- package/src/element/assertion/contained.js +28 -28
- package/src/element/assertion/defined.js +23 -23
- package/src/element/assertion/property.js +15 -14
- package/src/element/assertion/satisfies.js +8 -10
- package/src/element/assertion/subproof.js +26 -31
- package/src/element/assertion/type.js +10 -12
- package/src/element/assumption.js +51 -74
- package/src/element/combinator/bracketed.js +2 -2
- package/src/element/combinator.js +23 -29
- package/src/element/conclusion.js +37 -40
- package/src/element/constructor.js +29 -34
- package/src/element/deduction.js +36 -39
- package/src/element/equality.js +16 -18
- package/src/element/equivalence.js +77 -64
- package/src/element/frame.js +43 -35
- package/src/element/hypothesis.js +7 -6
- package/src/element/judgement.js +37 -43
- package/src/element/label.js +25 -31
- package/src/element/metavariable.js +32 -12
- package/src/element/proofAssertion/premise.js +63 -49
- package/src/element/proofAssertion/step.js +43 -23
- package/src/element/proofAssertion/supposition.js +64 -50
- package/src/element/proofAssertion.js +0 -22
- package/src/element/reference.js +118 -79
- package/src/element/signature.js +5 -2
- package/src/element/statement.js +30 -33
- package/src/element/substitution/frame.js +32 -30
- package/src/element/substitution/metaLevel.js +43 -46
- package/src/element/substitution/reference.js +17 -17
- package/src/element/substitution/statement.js +58 -56
- package/src/element/substitution/term.js +17 -17
- package/src/element/term.js +42 -34
- package/src/element/topLevelMetaAssertion.js +1 -1
- package/src/element/variable.js +8 -1
- package/src/process/assign.js +9 -3
- package/src/process/unify.js +7 -7
- package/src/process/validate.js +9 -8
- package/src/utilities/context.js +79 -36
- package/src/utilities/element.js +68 -31
- package/src/utilities/json.js +13 -13
- package/src/utilities/statement.js +1 -9
- package/src/utilities/string.js +16 -2
- package/src/utilities/unification.js +7 -6
- package/src/utilities/validation.js +50 -38
- package/lib/context/scoped.js +0 -232
- package/lib/utilities/term.js +0 -17
- package/src/utilities/term.js +0 -10
package/src/element/equality.js
CHANGED
|
@@ -6,6 +6,7 @@ import { define } from "../elements";
|
|
|
6
6
|
import { instantiate } from "../utilities/context";
|
|
7
7
|
import { equateTerms } from "../process/equate";
|
|
8
8
|
import { instantiateEquality } from "../process/instantiate";
|
|
9
|
+
import { equalityFromStatementNode } from "../utilities/element";
|
|
9
10
|
import { equalityAssignmentFromEquality, leftVariableAssignmentFromEquality, rightVariableAssignmentFromEquality } from "../process/assign";
|
|
10
11
|
|
|
11
12
|
export default define(class Equality extends Element {
|
|
@@ -115,7 +116,7 @@ export default define(class Equality extends Element {
|
|
|
115
116
|
return validEquality;
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
validate(
|
|
119
|
+
validate(context) {
|
|
119
120
|
let equality = null;
|
|
120
121
|
|
|
121
122
|
const equalityString = this.getString(); ///
|
|
@@ -134,6 +135,8 @@ export default define(class Equality extends Element {
|
|
|
134
135
|
const termsValidate = this.validateTerms(context);
|
|
135
136
|
|
|
136
137
|
if (termsValidate) {
|
|
138
|
+
const stated = context.isStated();
|
|
139
|
+
|
|
137
140
|
let validatesWhenStated = false,
|
|
138
141
|
validatesWhenDerived = false;
|
|
139
142
|
|
|
@@ -151,7 +154,7 @@ export default define(class Equality extends Element {
|
|
|
151
154
|
if (validates) {
|
|
152
155
|
equality = this; ///
|
|
153
156
|
|
|
154
|
-
this.assign(
|
|
157
|
+
this.assign(context);
|
|
155
158
|
|
|
156
159
|
context.addEquality(equality);
|
|
157
160
|
|
|
@@ -243,29 +246,17 @@ export default define(class Equality extends Element {
|
|
|
243
246
|
return validatesWhenDerived;
|
|
244
247
|
}
|
|
245
248
|
|
|
246
|
-
assign(
|
|
249
|
+
assign(context) {
|
|
247
250
|
const equality = this, ///
|
|
248
251
|
equalityAssignment = equalityAssignmentFromEquality(equality, context),
|
|
249
252
|
leftVariableAssignment = leftVariableAssignmentFromEquality(equality, context),
|
|
250
253
|
rightVariableAssignment = rightVariableAssignmentFromEquality(equality, context);
|
|
251
254
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
assignment = equalityAssignment; ///
|
|
255
|
-
|
|
256
|
-
context.addAssignment(assignment);
|
|
257
|
-
|
|
258
|
-
if (leftVariableAssignment !== null) {
|
|
259
|
-
assignment = leftVariableAssignment; ///
|
|
260
|
-
|
|
261
|
-
context.addAssignment(assignment);
|
|
262
|
-
}
|
|
255
|
+
context.addAssignment(equalityAssignment);
|
|
263
256
|
|
|
264
|
-
|
|
265
|
-
assignment = rightVariableAssignment; ///
|
|
257
|
+
context.addAssignment(leftVariableAssignment);
|
|
266
258
|
|
|
267
|
-
|
|
268
|
-
}
|
|
259
|
+
context.addAssignment(rightVariableAssignment);
|
|
269
260
|
}
|
|
270
261
|
|
|
271
262
|
static name = "Equality";
|
|
@@ -294,6 +285,13 @@ export default define(class Equality extends Element {
|
|
|
294
285
|
return equality;
|
|
295
286
|
}, context);
|
|
296
287
|
}
|
|
288
|
+
|
|
289
|
+
static fromStatement(statement, context) {
|
|
290
|
+
const statementNode = statement.getNode(),
|
|
291
|
+
equality = equalityFromStatementNode(statementNode, context);
|
|
292
|
+
|
|
293
|
+
return equality;
|
|
294
|
+
}
|
|
297
295
|
});
|
|
298
296
|
|
|
299
297
|
function leftTermFromEqualityNode(equalityNode, context) {
|
|
@@ -13,16 +13,29 @@ import { equivalenceFromEquivalenceNode } from "../utilities/element";
|
|
|
13
13
|
const { compress } = arrayUtilities;
|
|
14
14
|
|
|
15
15
|
export default define(class Equivalence extends Element {
|
|
16
|
-
constructor(context, string, node, terms) {
|
|
16
|
+
constructor(context, string, node, type, terms) {
|
|
17
17
|
super(context, string, node);
|
|
18
18
|
|
|
19
|
+
this.type = type;
|
|
19
20
|
this.terms = terms;
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
getType() {
|
|
24
|
+
return this.type;
|
|
25
|
+
}
|
|
26
|
+
|
|
22
27
|
getTerms() {
|
|
23
28
|
return this.terms;
|
|
24
29
|
}
|
|
25
30
|
|
|
31
|
+
setType(type) {
|
|
32
|
+
this.type = type;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
setTerms(terms) {
|
|
36
|
+
this.terms = terms;
|
|
37
|
+
}
|
|
38
|
+
|
|
26
39
|
getEquivalenceNode() {
|
|
27
40
|
const node = this.getNode(),
|
|
28
41
|
equivalenceNode = node; ///
|
|
@@ -30,26 +43,6 @@ export default define(class Equivalence extends Element {
|
|
|
30
43
|
return equivalenceNode;
|
|
31
44
|
}
|
|
32
45
|
|
|
33
|
-
getType() {
|
|
34
|
-
const type = this.terms.reduce((type, term) => {
|
|
35
|
-
const termType = term.getType();
|
|
36
|
-
|
|
37
|
-
if (type === null) {
|
|
38
|
-
type = termType; ///
|
|
39
|
-
} else {
|
|
40
|
-
const termTypeSubTypeOfType = termType.isSubTypeOf(type);
|
|
41
|
-
|
|
42
|
-
if (termTypeSubTypeOfType) {
|
|
43
|
-
type = termType; ///
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return type;
|
|
48
|
-
}, null);
|
|
49
|
-
|
|
50
|
-
return type;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
46
|
getGroundedTerms(definedVariables, groundedTerms, context) {
|
|
54
47
|
this.terms.forEach((term) => {
|
|
55
48
|
const termGrounded = term.isGrounded(definedVariables, context);
|
|
@@ -133,20 +126,6 @@ export default define(class Equivalence extends Element {
|
|
|
133
126
|
return implicitlyGrounded;
|
|
134
127
|
}
|
|
135
128
|
|
|
136
|
-
compareTerm(term) {
|
|
137
|
-
const termA = term, ///
|
|
138
|
-
comparesToTerm = this.someTerm((term) => {
|
|
139
|
-
const termB = term, ///
|
|
140
|
-
termAEqualToTermB = termA.isEqualTo(termB);
|
|
141
|
-
|
|
142
|
-
if (termAEqualToTermB) {
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
return comparesToTerm;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
129
|
matchTermNode(termNode) {
|
|
151
130
|
termNode = stripBracketsFromTermNode(termNode); ///
|
|
152
131
|
|
|
@@ -173,36 +152,31 @@ export default define(class Equivalence extends Element {
|
|
|
173
152
|
return termNodesMatch;
|
|
174
153
|
}
|
|
175
154
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const termNode = term.getNode(),
|
|
180
|
-
singularVariableNode = termNode.getSingularVariableNode();
|
|
155
|
+
someTerm(callback) { return this.terms.some(callback); }
|
|
156
|
+
|
|
157
|
+
everyTerm(callback) { return this.terms.every(callback); }
|
|
181
158
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
159
|
+
compareTerm(term) {
|
|
160
|
+
const termA = term, ///
|
|
161
|
+
comparesToTerm = this.someTerm((term) => {
|
|
162
|
+
const termB = term, ///
|
|
163
|
+
termAComparesToTermB = termA.compareTerm(termB);
|
|
185
164
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
165
|
+
if (termAComparesToTermB) {
|
|
166
|
+
return true;
|
|
189
167
|
}
|
|
190
168
|
});
|
|
191
169
|
|
|
192
|
-
return
|
|
170
|
+
return comparesToTerm;
|
|
193
171
|
}
|
|
194
172
|
|
|
195
|
-
someTerm(callback) { return this.terms.some(callback); }
|
|
196
|
-
|
|
197
|
-
everyTerm(callback) { return this.terms.every(callback); }
|
|
198
|
-
|
|
199
173
|
someOtherTerm(term, callback) {
|
|
200
174
|
const termA = term, ///
|
|
201
175
|
terms = this.terms.filter((term) => {
|
|
202
176
|
const termB = term, ///
|
|
203
|
-
|
|
177
|
+
termAComparesToTermB = termA.compareTerm(termB);
|
|
204
178
|
|
|
205
|
-
if (!
|
|
179
|
+
if (!termAComparesToTermB) {
|
|
206
180
|
return true;
|
|
207
181
|
}
|
|
208
182
|
}),
|
|
@@ -218,9 +192,9 @@ export default define(class Equivalence extends Element {
|
|
|
218
192
|
];
|
|
219
193
|
|
|
220
194
|
compress(combinedTerms, (combinedTermA, combinedTermB) => {
|
|
221
|
-
const
|
|
195
|
+
const combinedTermAComparesToCombinedTermB = combinedTermA.compareTerm(combinedTermB);
|
|
222
196
|
|
|
223
|
-
if (!
|
|
197
|
+
if (!combinedTermAComparesToCombinedTermB) {
|
|
224
198
|
return true;
|
|
225
199
|
}
|
|
226
200
|
});
|
|
@@ -229,31 +203,70 @@ export default define(class Equivalence extends Element {
|
|
|
229
203
|
}
|
|
230
204
|
|
|
231
205
|
mergedWith(equivalence, context) {
|
|
232
|
-
|
|
206
|
+
let type;
|
|
207
|
+
|
|
208
|
+
type = equivalence.getType();
|
|
209
|
+
|
|
210
|
+
const types = [
|
|
211
|
+
this.type,
|
|
212
|
+
type
|
|
213
|
+
],
|
|
214
|
+
terms = equivalence.getTerms(),
|
|
215
|
+
combinedType = combinedTypeFromTypes(types),
|
|
233
216
|
combinedTerms = this.combineTerms(terms);
|
|
234
217
|
|
|
235
|
-
|
|
218
|
+
type = combinedType; ///
|
|
219
|
+
|
|
220
|
+
instantiate((context) => {
|
|
236
221
|
const terms = combinedTerms, ///
|
|
237
222
|
equivalenceString = equivalenceStringFromTerms(terms),
|
|
238
223
|
string = equivalenceString, ///
|
|
239
|
-
equivalenceNode = instantiateEquivalence(string, context)
|
|
240
|
-
equivalence = equivalenceFromEquivalenceNode(equivalenceNode, context);
|
|
224
|
+
equivalenceNode = instantiateEquivalence(string, context);
|
|
241
225
|
|
|
242
|
-
|
|
226
|
+
equivalence = equivalenceFromEquivalenceNode(equivalenceNode, context);
|
|
243
227
|
}, context);
|
|
228
|
+
|
|
229
|
+
equivalence.setType(type);
|
|
230
|
+
|
|
231
|
+
return equivalence;
|
|
244
232
|
}
|
|
245
233
|
|
|
246
234
|
static name = "Equivalence";
|
|
247
235
|
|
|
248
236
|
static fromEquality(equality, context) {
|
|
249
|
-
|
|
237
|
+
let equivalence;
|
|
238
|
+
|
|
239
|
+
const type = equality.getType();
|
|
240
|
+
|
|
241
|
+
instantiate((context) => {
|
|
250
242
|
const terms = equality.getTerms(),
|
|
251
243
|
equivalenceString = equivalenceStringFromTerms(terms),
|
|
252
244
|
string = equivalenceString, ///
|
|
253
|
-
equivalenceNode = instantiateEquivalence(string, context)
|
|
254
|
-
equivalence = equivalenceFromEquivalenceNode(equivalenceNode, context);
|
|
245
|
+
equivalenceNode = instantiateEquivalence(string, context);
|
|
255
246
|
|
|
256
|
-
|
|
247
|
+
equivalence = equivalenceFromEquivalenceNode(equivalenceNode, context);
|
|
257
248
|
}, context);
|
|
249
|
+
|
|
250
|
+
equivalence.setType(type);
|
|
251
|
+
|
|
252
|
+
return equivalence;
|
|
258
253
|
}
|
|
259
254
|
});
|
|
255
|
+
|
|
256
|
+
function combinedTypeFromTypes(types) {
|
|
257
|
+
const combinedType = types.reduce((combinedType, type) => {
|
|
258
|
+
if (combinedType === null) {
|
|
259
|
+
combinedType = type; ///
|
|
260
|
+
} else {
|
|
261
|
+
const typeSubTypeOfCombinedType = type.isSubTypeOf(combinedType);
|
|
262
|
+
|
|
263
|
+
if (typeSubTypeOfCombinedType) {
|
|
264
|
+
combinedType = type; ///
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return combinedType;
|
|
269
|
+
}, null);
|
|
270
|
+
|
|
271
|
+
return combinedType;
|
|
272
|
+
}
|
package/src/element/frame.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import { instantiate } from "../utilities/context";
|
|
7
6
|
import { instantiateFrame } from "../process/instantiate";
|
|
8
7
|
import { FRAME_META_TYPE_NAME } from "../metaTypeNames";
|
|
9
8
|
import { metavariableFromFrameNode } from "../utilities/element";
|
|
10
|
-
import {
|
|
9
|
+
import { descend, reconcile, instantiate } from "../utilities/context";
|
|
10
|
+
import { assumptionsStringFromAssumptions, metaLevelSubstitutionsStringFromMetaLevelSubstitutions } from "../utilities/string";
|
|
11
11
|
|
|
12
12
|
export default define(class Frame extends Element {
|
|
13
13
|
constructor(context, string, node, assumptions, metavariable) {
|
|
@@ -97,17 +97,17 @@ export default define(class Frame extends Element {
|
|
|
97
97
|
return comparesToParamter;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
let
|
|
100
|
+
compareMetaLevelSubstitution(metaLevelSubstitution, context) {
|
|
101
|
+
let comparesToMetaLevelSubstitution = false;
|
|
102
102
|
|
|
103
103
|
const frameString = this.getString(), ///
|
|
104
|
-
|
|
104
|
+
metaLevelSubstitutioString = metaLevelSubstitution.getString();
|
|
105
105
|
|
|
106
|
-
context.trace(`Comparing the '${frameString}' frame to the '${
|
|
106
|
+
context.trace(`Comparing the '${frameString}' frame to the '${metaLevelSubstitutioString}' meta-level substitutio...`);
|
|
107
107
|
|
|
108
|
-
if (!
|
|
109
|
-
|
|
110
|
-
const assumptionComparesToSubstitution = assumption.
|
|
108
|
+
if (!comparesToMetaLevelSubstitution) {
|
|
109
|
+
comparesToMetaLevelSubstitution = this.assumptions.some((assumption) => {
|
|
110
|
+
const assumptionComparesToSubstitution = assumption.compareMetaLevelSubstitution(metaLevelSubstitution, context);
|
|
111
111
|
|
|
112
112
|
if (assumptionComparesToSubstitution) {
|
|
113
113
|
return true;
|
|
@@ -115,34 +115,34 @@ export default define(class Frame extends Element {
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
if (
|
|
119
|
-
context.debug(`...compared the the '${frameString}' frame to the '${
|
|
118
|
+
if (comparesToMetaLevelSubstitution) {
|
|
119
|
+
context.debug(`...compared the the '${frameString}' frame to the '${metaLevelSubstitutioString}' meta-Level-substituution.`);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
return
|
|
122
|
+
return comparesToMetaLevelSubstitution;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
let
|
|
125
|
+
compareMetaLevelSubstitutions(metaLevelSubstitutions, context) {
|
|
126
|
+
let comparesToMetaLevelSubstitutions;
|
|
127
127
|
|
|
128
128
|
const frameString = this.getString(), ///
|
|
129
|
-
|
|
129
|
+
metaLevelSubstitutionsString = metaLevelSubstitutionsStringFromMetaLevelSubstitutions(metaLevelSubstitutions);
|
|
130
130
|
|
|
131
|
-
context.trace(`Comparing the '${frameString}' frame to the '${
|
|
131
|
+
context.trace(`Comparing the '${frameString}' frame to the '${metaLevelSubstitutionsString}' meta-level substitutio...`);
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
const
|
|
133
|
+
comparesToMetaLevelSubstitutions = metaLevelSubstitutions.every((metaLevelSubstitution) => {
|
|
134
|
+
const compaaresToMetaLevelSubstitution = this.compareMetaLevelSubstitution(metaLevelSubstitution, context);
|
|
135
135
|
|
|
136
|
-
if (
|
|
136
|
+
if (compaaresToMetaLevelSubstitution) {
|
|
137
137
|
return true;
|
|
138
138
|
}
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
-
if (
|
|
142
|
-
context.debug(`...compared the '${frameString}' frame to the '${
|
|
141
|
+
if (comparesToMetaLevelSubstitutions) {
|
|
142
|
+
context.debug(`...compared the '${frameString}' frame to the '${metaLevelSubstitutionsString}' metaLevelSubstitutions.`);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
return
|
|
145
|
+
return comparesToMetaLevelSubstitutions;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
compareMetavariableName(metavariableName) {
|
|
@@ -163,7 +163,7 @@ export default define(class Frame extends Element {
|
|
|
163
163
|
return comparesToMetavariableName;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
validate(
|
|
166
|
+
validate(context) {
|
|
167
167
|
let frame = null;
|
|
168
168
|
|
|
169
169
|
const frameString = this.getString(); ///
|
|
@@ -180,12 +180,14 @@ export default define(class Frame extends Element {
|
|
|
180
180
|
} else {
|
|
181
181
|
let validates = false;
|
|
182
182
|
|
|
183
|
-
const metavariableValidates = this.validatMetavariable(
|
|
183
|
+
const metavariableValidates = this.validatMetavariable(context);
|
|
184
184
|
|
|
185
185
|
if (metavariableValidates) {
|
|
186
|
-
const assumptionsValidate = this.validateAssumptions(
|
|
186
|
+
const assumptionsValidate = this.validateAssumptions(context);
|
|
187
187
|
|
|
188
188
|
if (assumptionsValidate) {
|
|
189
|
+
const stated = context.isStated();
|
|
190
|
+
|
|
189
191
|
let validatesWhenStated = false,
|
|
190
192
|
validatesWhenDerived = false;
|
|
191
193
|
|
|
@@ -251,17 +253,25 @@ export default define(class Frame extends Element {
|
|
|
251
253
|
return validatesWhenDerived;
|
|
252
254
|
}
|
|
253
255
|
|
|
254
|
-
validateAssumption(assumption, context) {
|
|
255
|
-
let assumptionValidates;
|
|
256
|
+
validateAssumption(assumption, assumptions, context) {
|
|
257
|
+
let assumptionValidates = false;
|
|
256
258
|
|
|
257
259
|
const frameString = this.getString(), ///
|
|
258
260
|
assumptionstring = assumption.getString();
|
|
259
261
|
|
|
260
262
|
context.trace(`Validating the '${frameString}' frame's '${assumptionstring}' assumption.`);
|
|
261
263
|
|
|
262
|
-
|
|
264
|
+
reconcile((context) => {
|
|
265
|
+
descend((context) => {
|
|
266
|
+
assumption = assumption.validate(context); ///
|
|
263
267
|
|
|
264
|
-
|
|
268
|
+
if (assumption !== null) {
|
|
269
|
+
assumptions.push(assumption);
|
|
270
|
+
|
|
271
|
+
assumptionValidates = true;
|
|
272
|
+
}
|
|
273
|
+
}, context);
|
|
274
|
+
}, context);
|
|
265
275
|
|
|
266
276
|
if (assumptionValidates) {
|
|
267
277
|
context.debug(`...validated the '${frameString}' frame's '${assumptionstring}' assumption.`);
|
|
@@ -270,7 +280,7 @@ export default define(class Frame extends Element {
|
|
|
270
280
|
return assumptionValidates;
|
|
271
281
|
}
|
|
272
282
|
|
|
273
|
-
validateAssumptions(
|
|
283
|
+
validateAssumptions(context) {
|
|
274
284
|
let assumptionsValidate;
|
|
275
285
|
|
|
276
286
|
const singular = this.isSingular();
|
|
@@ -284,11 +294,9 @@ export default define(class Frame extends Element {
|
|
|
284
294
|
const assumptions = [];
|
|
285
295
|
|
|
286
296
|
assumptionsValidate = this.assumptions.every((assumption) => {
|
|
287
|
-
const assumptionValidates = this.validateAssumption(assumption, context);
|
|
297
|
+
const assumptionValidates = this.validateAssumption(assumption, assumptions, context);
|
|
288
298
|
|
|
289
299
|
if (assumptionValidates) {
|
|
290
|
-
assumptions.push(assumption);
|
|
291
|
-
|
|
292
300
|
return true;
|
|
293
301
|
}
|
|
294
302
|
});
|
|
@@ -305,7 +313,7 @@ export default define(class Frame extends Element {
|
|
|
305
313
|
return assumptionsValidate;
|
|
306
314
|
}
|
|
307
315
|
|
|
308
|
-
validatMetavariable(
|
|
316
|
+
validatMetavariable(context) {
|
|
309
317
|
let metavariableValidates = false;
|
|
310
318
|
|
|
311
319
|
const singular = this.isSingular();
|
|
@@ -316,7 +324,7 @@ export default define(class Frame extends Element {
|
|
|
316
324
|
|
|
317
325
|
context.trace(`Validating the '${frameString}' frame's '${metavariableString}' metavariable...`);
|
|
318
326
|
|
|
319
|
-
const metavariable = this.metavariable.validate(context),
|
|
327
|
+
const metavariable = this.metavariable.validate(context),
|
|
320
328
|
metaTypeName = FRAME_META_TYPE_NAME,
|
|
321
329
|
frameMetaType = context.findMetaTypeByMetaTypeName(metaTypeName),
|
|
322
330
|
metavariableMetaTypeEqualToFrameMetaType = metavariable.isMetaTypeEqualTo(frameMetaType);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import {instantiate} from "../utilities/context";
|
|
6
|
+
import {descend, instantiate} from "../utilities/context";
|
|
7
7
|
import { instantiateHypothesis } from "../process/instantiate";
|
|
8
8
|
import { statementFromHypothesisNode } from "../utilities/element";
|
|
9
9
|
|
|
@@ -61,12 +61,13 @@ export default define(class Hypothesis extends Element {
|
|
|
61
61
|
} else if (this.statement !== null) {
|
|
62
62
|
let statementValidates = false;
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
descend((context) => {
|
|
65
|
+
const statement = this.statement.validate(context);
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
if (statement !== null) {
|
|
68
|
+
statementValidates = true;
|
|
69
|
+
}
|
|
70
|
+
}, context);
|
|
70
71
|
|
|
71
72
|
if (statementValidates) {
|
|
72
73
|
const subproofOrProofAssertion = this; ///
|
package/src/element/judgement.js
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
|
-
import elements from "../elements";
|
|
6
|
-
|
|
7
5
|
import { define } from "../elements";
|
|
8
|
-
import { instantiate } from "../utilities/context";
|
|
9
6
|
import { instantiateJudgement } from "../process/instantiate";
|
|
7
|
+
import { reconcile, instantiate } from "../utilities/context";
|
|
10
8
|
import { judgementAssignmentFromJudgement } from "../process/assign";
|
|
11
9
|
|
|
12
10
|
export default define(class Judgement extends Element {
|
|
@@ -41,8 +39,6 @@ export default define(class Judgement extends Element {
|
|
|
41
39
|
|
|
42
40
|
getMetavariable() { return this.frame.getMetavariable(); }
|
|
43
41
|
|
|
44
|
-
compareMetavariableName(metavariableName) { return this.frame.compareMetavariableName(metavariableName); }
|
|
45
|
-
|
|
46
42
|
matchJudgementNode(judgementNode) {
|
|
47
43
|
const node = judgementNode, ///
|
|
48
44
|
nodeMatches = this.matchNode(node),
|
|
@@ -51,6 +47,8 @@ export default define(class Judgement extends Element {
|
|
|
51
47
|
return judgementNodeMatches;
|
|
52
48
|
}
|
|
53
49
|
|
|
50
|
+
compareMetavariableName(metavariableName) { return this.frame.compareMetavariableName(metavariableName); }
|
|
51
|
+
|
|
54
52
|
findValidJudgement(context) {
|
|
55
53
|
const judgementNode = this.getJudgementNode(),
|
|
56
54
|
judgement = context.findJudgementByJudgementNode(judgementNode),
|
|
@@ -59,7 +57,7 @@ export default define(class Judgement extends Element {
|
|
|
59
57
|
return validJudgemenet;
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
validate(
|
|
60
|
+
validate(context) {
|
|
63
61
|
let judgement = null;
|
|
64
62
|
|
|
65
63
|
const judgementString = this.getString(); ///
|
|
@@ -75,31 +73,37 @@ export default define(class Judgement extends Element {
|
|
|
75
73
|
} else {
|
|
76
74
|
let validates = false;
|
|
77
75
|
|
|
78
|
-
|
|
76
|
+
reconcile((context) => {
|
|
77
|
+
const frameValidates = this.validateFrame(context);
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
if (frameValidates) {
|
|
80
|
+
const assumptionValidates = this.validateAssumption(context);
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
validatesWhenDerived = false;
|
|
82
|
+
if (assumptionValidates) {
|
|
83
|
+
const stated = context.isStated();
|
|
86
84
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
let validatesWhenStated = false,
|
|
86
|
+
validatesWhenDerived = false;
|
|
87
|
+
|
|
88
|
+
if (stated) {
|
|
89
|
+
validatesWhenStated = this.validateWhenStated(context);
|
|
90
|
+
} else {
|
|
91
|
+
validatesWhenDerived = this.validateWhenDerived(context);
|
|
92
|
+
}
|
|
92
93
|
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
if (validatesWhenStated || validatesWhenDerived) {
|
|
95
|
+
validates = true;
|
|
96
|
+
}
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
|
-
}
|
|
99
|
+
}, context);
|
|
98
100
|
|
|
99
101
|
if (validates) {
|
|
100
102
|
judgement = this; ///
|
|
101
103
|
|
|
102
|
-
|
|
104
|
+
this.assign(context);
|
|
105
|
+
|
|
106
|
+
context.addJudgement(judgement);
|
|
103
107
|
|
|
104
108
|
context.debug(`...validated the '${judgementString}' judgement.`);
|
|
105
109
|
}
|
|
@@ -108,7 +112,7 @@ export default define(class Judgement extends Element {
|
|
|
108
112
|
return judgement;
|
|
109
113
|
}
|
|
110
114
|
|
|
111
|
-
validateFrame(
|
|
115
|
+
validateFrame(context) {
|
|
112
116
|
let frameValidates = false;
|
|
113
117
|
|
|
114
118
|
const frameString = this.frame.getString(),
|
|
@@ -116,7 +120,7 @@ export default define(class Judgement extends Element {
|
|
|
116
120
|
|
|
117
121
|
context.trace(`Validating the '${judgementString}' judgement's '${frameString}' frame...`);
|
|
118
122
|
|
|
119
|
-
const frame = this.frame.validate(
|
|
123
|
+
const frame = this.frame.validate(context);
|
|
120
124
|
|
|
121
125
|
if (frame !== null) {
|
|
122
126
|
this.frame = frame;
|
|
@@ -131,7 +135,7 @@ export default define(class Judgement extends Element {
|
|
|
131
135
|
return frameValidates;
|
|
132
136
|
}
|
|
133
137
|
|
|
134
|
-
validateAssumption(
|
|
138
|
+
validateAssumption(context) {
|
|
135
139
|
let assumptionValidates = false;
|
|
136
140
|
|
|
137
141
|
const assumptionString = this.assumption.getString(),
|
|
@@ -139,7 +143,7 @@ export default define(class Judgement extends Element {
|
|
|
139
143
|
|
|
140
144
|
context.trace(`Validating the '${judgementString}' judgement's '${assumptionString}' assumption...`);
|
|
141
145
|
|
|
142
|
-
const assumption = this.assumption.validate(
|
|
146
|
+
const assumption = this.assumption.validate(context);
|
|
143
147
|
|
|
144
148
|
if (assumption !== null) {
|
|
145
149
|
this.assumption = assumption;
|
|
@@ -177,11 +181,9 @@ export default define(class Judgement extends Element {
|
|
|
177
181
|
|
|
178
182
|
context.trace(`Validating the '${judgementString}' derived judgement...`);
|
|
179
183
|
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
substitutions = topLevelMetaAssertion.getSubstitutions(),
|
|
184
|
-
frameComparesToSubstitutions = this.frame.compareSubstitutions(substitutions, context);
|
|
184
|
+
const topLevelMetaAssertion = this.assumption.getTopLevelMetaAssertion(),
|
|
185
|
+
metaLevelSubstitutions = topLevelMetaAssertion.getMetaLevelSubstitutions(),
|
|
186
|
+
frameComparesToSubstitutions = this.frame.compareMetaLevelSubstitutions(metaLevelSubstitutions, context);
|
|
185
187
|
|
|
186
188
|
if (frameComparesToSubstitutions) {
|
|
187
189
|
validatesWhenDerived = true;
|
|
@@ -194,16 +196,17 @@ export default define(class Judgement extends Element {
|
|
|
194
196
|
return validatesWhenDerived;
|
|
195
197
|
}
|
|
196
198
|
|
|
197
|
-
assign(
|
|
199
|
+
assign(context) {
|
|
200
|
+
const stated = context.isStated();
|
|
201
|
+
|
|
198
202
|
if (!stated) {
|
|
199
203
|
return;
|
|
200
204
|
}
|
|
201
205
|
|
|
202
206
|
const judgement = this, ///
|
|
203
|
-
judgementAssignment = judgementAssignmentFromJudgement(judgement, context)
|
|
204
|
-
assignment = judgementAssignment; ///
|
|
207
|
+
judgementAssignment = judgementAssignmentFromJudgement(judgement, context);
|
|
205
208
|
|
|
206
|
-
context.addAssignment(
|
|
209
|
+
context.addAssignment(judgementAssignment);
|
|
207
210
|
}
|
|
208
211
|
|
|
209
212
|
toJSON() {
|
|
@@ -247,12 +250,3 @@ function assumptionFromJudgementNode(judgementNode, context) {
|
|
|
247
250
|
|
|
248
251
|
return assumption;
|
|
249
252
|
}
|
|
250
|
-
|
|
251
|
-
function referenceFromMetavariable(metavariable, context) {
|
|
252
|
-
const { Reference } = elements,
|
|
253
|
-
metavariableNode = metavariable.getNode(),
|
|
254
|
-
reference = Reference.fromMetavariableNode(metavariableNode, context);
|
|
255
|
-
|
|
256
|
-
return reference;
|
|
257
|
-
}
|
|
258
|
-
|