occam-nominal 1.0.334 → 1.0.340
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.js +5 -1
- package/lib/element/assertion/contained.js +4 -4
- package/lib/element/assertion/defined.js +3 -3
- package/lib/element/assertion/subproof.js +6 -6
- package/lib/element/assertion/type.js +3 -3
- package/lib/element/assumption.js +134 -111
- package/lib/element/combinator/bracketed.js +2 -2
- package/lib/element/constraint.js +114 -102
- package/lib/element/constructor/bracketed.js +3 -3
- package/lib/element/deduction.js +2 -2
- package/lib/element/equality.js +3 -3
- package/lib/element/frame.js +3 -3
- package/lib/element/goal.js +67 -57
- package/lib/element/hypothesis.js +2 -2
- package/lib/element/judgement.js +15 -16
- package/lib/element/label.js +25 -22
- package/lib/element/metaType.js +2 -2
- package/lib/element/metavariable.js +54 -45
- package/lib/element/parameter.js +2 -2
- package/lib/element/procedureCall.js +2 -2
- package/lib/element/procedureReference.js +2 -2
- package/lib/element/proofAssertion/step.js +7 -7
- package/lib/element/proofAssertion/supposition.js +2 -2
- package/lib/element/proofAssertion.js +2 -2
- package/lib/element/reference.js +27 -24
- package/lib/element/schema.js +165 -154
- package/lib/element/signature.js +2 -2
- package/lib/element/statement.js +7 -5
- package/lib/element/substitution/reference.js +22 -29
- package/lib/element/substitution/statement.js +5 -5
- package/lib/element/term.js +2 -2
- package/lib/element/typePrefix.js +2 -2
- package/lib/element/variable.js +2 -2
- package/lib/process/unification.js +41 -47
- package/lib/process/unify.js +10 -10
- package/lib/process/validate.js +6 -6
- package/lib/process/validation.js +13 -13
- package/package.json +9 -9
- package/src/context.js +6 -0
- package/src/element/assertion/contained.js +3 -3
- package/src/element/assertion/defined.js +2 -2
- package/src/element/assertion/subproof.js +5 -5
- package/src/element/assertion/type.js +2 -2
- package/src/element/assumption.js +158 -132
- package/src/element/combinator/bracketed.js +1 -1
- package/src/element/constraint.js +134 -125
- package/src/element/constructor/bracketed.js +2 -2
- package/src/element/deduction.js +1 -1
- package/src/element/equality.js +2 -2
- package/src/element/frame.js +2 -2
- package/src/element/goal.js +82 -74
- package/src/element/hypothesis.js +2 -2
- package/src/element/judgement.js +20 -22
- package/src/element/label.js +26 -25
- package/src/element/metaType.js +2 -2
- package/src/element/metavariable.js +70 -53
- package/src/element/parameter.js +2 -2
- package/src/element/procedureCall.js +2 -2
- package/src/element/procedureReference.js +2 -2
- package/src/element/proofAssertion/step.js +6 -6
- package/src/element/proofAssertion/supposition.js +1 -1
- package/src/element/proofAssertion.js +1 -1
- package/src/element/reference.js +28 -27
- package/src/element/schema.js +193 -195
- package/src/element/signature.js +2 -2
- package/src/element/statement.js +9 -5
- package/src/element/substitution/reference.js +22 -35
- package/src/element/substitution/statement.js +4 -4
- package/src/element/term.js +1 -1
- package/src/element/typePrefix.js +2 -2
- package/src/element/variable.js +1 -1
- package/src/process/unification.js +44 -59
- package/src/process/unify.js +9 -9
- package/src/process/validate.js +5 -5
- package/src/process/validation.js +12 -12
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { Element, breakPointUtilities } from "occam-languages";
|
|
3
|
+
import { Element, breakPointUtilities, continuationUtilities } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
+
import { all, exists } from "../utilities/continuation";
|
|
6
7
|
import { unifyStatement } from "../process/unify";
|
|
7
8
|
import { instantiateConstraint } from "../process/instantiate";
|
|
8
9
|
import { stripBracketsFromStatement } from "../utilities/brackets";
|
|
@@ -10,7 +11,8 @@ import { constraintFromConstraintNode } from "../utilities/element";
|
|
|
10
11
|
import { constraintStringFromReferenceAndStatement } from "../utilities/string";
|
|
11
12
|
import { ablate, attempt, descend, reconcile, serialise, unserialise, instantiate } from "../utilities/context";
|
|
12
13
|
|
|
13
|
-
const {
|
|
14
|
+
const { some } = continuationUtilities,
|
|
15
|
+
{ breakPointFromJSON, breakPointToBreakPointJSON } = breakPointUtilities;
|
|
14
16
|
|
|
15
17
|
export default define(class Constraint extends Element {
|
|
16
18
|
constructor(context, string, node, breakPoint, reference, statement) {
|
|
@@ -61,123 +63,124 @@ export default define(class Constraint extends Element {
|
|
|
61
63
|
return validConstraint;
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
let constraint = null;
|
|
66
|
-
|
|
66
|
+
validate(context, continuation) {
|
|
67
67
|
const constraintString = this.getString(); ///
|
|
68
68
|
|
|
69
69
|
context.trace(`Validating the '${constraintString}' constraint...`);
|
|
70
70
|
|
|
71
|
-
let validates = false;
|
|
72
|
-
|
|
73
71
|
const validConstraint = this.findValidConstraint(context);
|
|
74
72
|
|
|
75
73
|
if (validConstraint !== null) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
constraint = validConstraint; ///
|
|
74
|
+
const constraint = validConstraint; ///
|
|
79
75
|
|
|
80
76
|
context.debug(`...the '${constraintString}' constraint is already valid.`);
|
|
81
|
-
} else {
|
|
82
|
-
const temporaryContext = context; ///
|
|
83
77
|
|
|
78
|
+
return continuation(constraint);
|
|
79
|
+
} else {
|
|
84
80
|
context = this.getContext();
|
|
85
81
|
|
|
86
82
|
attempt((context) => {
|
|
87
|
-
const
|
|
83
|
+
const validateStatement = this.validateStatement.bind(this),
|
|
84
|
+
validateReference = this.validateReference.bind(this);
|
|
88
85
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
return all([
|
|
87
|
+
validateStatement,
|
|
88
|
+
validateReference
|
|
89
|
+
], context, (validates) => {
|
|
90
|
+
if (!validates) {
|
|
91
|
+
const constraint = null;
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
return continuation(constraint);
|
|
94
|
+
}
|
|
97
95
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
} else {
|
|
101
|
-
validatesWhenDerived = this.validateWhenDerived(context);
|
|
102
|
-
}
|
|
96
|
+
const validateWhenStated = this.validateWhenStated.bind(this),
|
|
97
|
+
validateWhenDerived = this.validateWhenDerived.bind(this);
|
|
103
98
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
99
|
+
return exists([
|
|
100
|
+
validateWhenStated,
|
|
101
|
+
validateWhenDerived
|
|
102
|
+
], context, (validates) => {
|
|
103
|
+
let constraint = null;
|
|
109
104
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
}, context);
|
|
105
|
+
if (validates) {
|
|
106
|
+
constraint = this; ///
|
|
114
107
|
|
|
115
|
-
|
|
108
|
+
context.addConstraint(constraint);
|
|
109
|
+
}
|
|
116
110
|
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
if (validates) {
|
|
112
|
+
this.commit(context);
|
|
113
|
+
}
|
|
119
114
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
if (validates) {
|
|
116
|
+
context.debug(`...validated the '${constraintString}' constraint.`);
|
|
117
|
+
}
|
|
123
118
|
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
return continuation(constraint);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}, context);
|
|
126
123
|
}
|
|
127
|
-
|
|
128
|
-
return constraint;
|
|
129
124
|
}
|
|
130
125
|
|
|
131
|
-
validateReference(context) {
|
|
126
|
+
validateReference(context, continuation) {
|
|
132
127
|
let referenceValidates = false;
|
|
133
128
|
|
|
134
129
|
const constraintString = this.getString(); ///
|
|
135
130
|
|
|
136
131
|
context.trace(`Validating the '${constraintString}' constraint's reference...`);
|
|
137
132
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
metavariableDeclared = metavariable.isDeclared();
|
|
133
|
+
this.reference.validate(context, (reference) => {
|
|
134
|
+
if (reference !== null) {
|
|
135
|
+
const metavariable = this.reference.getMetavariable(),
|
|
136
|
+
metavariableDeclared = metavariable.isDeclared();
|
|
143
137
|
|
|
144
|
-
|
|
145
|
-
|
|
138
|
+
if (metavariableDeclared) {
|
|
139
|
+
this.reference = reference;
|
|
146
140
|
|
|
147
|
-
|
|
141
|
+
referenceValidates = true;
|
|
142
|
+
}
|
|
148
143
|
}
|
|
149
|
-
}
|
|
150
144
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
145
|
+
if (referenceValidates) {
|
|
146
|
+
context.debug(`...validated the '${constraintString}' constraint's reference.`);
|
|
147
|
+
}
|
|
154
148
|
|
|
155
|
-
|
|
149
|
+
return continuation(referenceValidates);
|
|
150
|
+
});
|
|
156
151
|
}
|
|
157
152
|
|
|
158
|
-
|
|
159
|
-
let statementValidates = false;
|
|
160
|
-
|
|
153
|
+
validateStatement(context, continuation) {
|
|
161
154
|
const constraintString = this.getString(); ///
|
|
162
155
|
|
|
163
156
|
context.trace(`Validating the '${constraintString}' constraint's statement...`);
|
|
164
157
|
|
|
165
|
-
descend(
|
|
166
|
-
|
|
158
|
+
descend((context) => {
|
|
159
|
+
this.statement.validate(context, (statement) => {
|
|
160
|
+
let statementValidates = false;
|
|
167
161
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}, context);
|
|
162
|
+
if (statement !== null) {
|
|
163
|
+
statementValidates = true;
|
|
164
|
+
}
|
|
172
165
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
166
|
+
if (statementValidates) {
|
|
167
|
+
context.debug(`...validated the '${constraintString}' constraint's statement.`);
|
|
168
|
+
}
|
|
176
169
|
|
|
177
|
-
|
|
170
|
+
return continuation(statementValidates);
|
|
171
|
+
});
|
|
172
|
+
}, context);
|
|
178
173
|
}
|
|
179
174
|
|
|
180
|
-
validateWhenStated(context) {
|
|
175
|
+
validateWhenStated(context, continuation) {
|
|
176
|
+
const stated = context.isStated();
|
|
177
|
+
|
|
178
|
+
if (!stated) {
|
|
179
|
+
const validatesWhenStated = false;
|
|
180
|
+
|
|
181
|
+
return continuation(validatesWhenStated);
|
|
182
|
+
}
|
|
183
|
+
|
|
181
184
|
let validatesWhenStated;
|
|
182
185
|
|
|
183
186
|
const constraintString = this.getString(); ///
|
|
@@ -190,10 +193,18 @@ export default define(class Constraint extends Element {
|
|
|
190
193
|
context.debug(`...validated the '${constraintString}' stated constraint.`);
|
|
191
194
|
}
|
|
192
195
|
|
|
193
|
-
return validatesWhenStated;
|
|
196
|
+
return continuation(validatesWhenStated);
|
|
194
197
|
}
|
|
195
198
|
|
|
196
|
-
validateWhenDerived(context) {
|
|
199
|
+
validateWhenDerived(context, continuation) {
|
|
200
|
+
const stated = context.isStated();
|
|
201
|
+
|
|
202
|
+
if (stated) {
|
|
203
|
+
const validatesWhenDerived = false;
|
|
204
|
+
|
|
205
|
+
return continuation(validatesWhenDerived);
|
|
206
|
+
}
|
|
207
|
+
|
|
197
208
|
let validatesWhenDerived;
|
|
198
209
|
|
|
199
210
|
const constraintString = this.getString(); ///
|
|
@@ -206,36 +217,34 @@ export default define(class Constraint extends Element {
|
|
|
206
217
|
context.debug(`...validated the '${constraintString}' derived constraint.`);
|
|
207
218
|
}
|
|
208
219
|
|
|
209
|
-
return validatesWhenDerived;
|
|
220
|
+
return continuation(validatesWhenDerived);
|
|
210
221
|
}
|
|
211
222
|
|
|
212
|
-
unifyReference(reference, generalContext, specificContext) {
|
|
213
|
-
|
|
223
|
+
unifyReference(reference, generalContext, specificContext, continuation) {
|
|
224
|
+
if (reference === null) {
|
|
225
|
+
const referenceUnifies = true; ///
|
|
214
226
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
referenceString = reference.getString(),
|
|
218
|
-
constraintString = this.getString(); ///
|
|
227
|
+
return continuation(referenceUnifies);
|
|
228
|
+
}
|
|
219
229
|
|
|
220
|
-
|
|
230
|
+
const context = specificContext, ///
|
|
231
|
+
referenceString = reference.getString(),
|
|
232
|
+
constraintString = this.getString(); ///
|
|
221
233
|
|
|
222
|
-
|
|
234
|
+
context.trace(`Unifying the '${referenceString}' reference with the '${constraintString}' constraint's reference...`);
|
|
223
235
|
|
|
224
|
-
|
|
236
|
+
const metavariable = this.getMetavariable();
|
|
225
237
|
|
|
238
|
+
return metavariable.unifyReference(reference, generalContext, specificContext, (referenceUnifies) => {
|
|
226
239
|
if (referenceUnifies) {
|
|
227
240
|
context.debug(`..unified the '${referenceString}' with the '${constraintString}' constraint's reference.`);
|
|
228
241
|
}
|
|
229
|
-
} else {
|
|
230
|
-
referenceUnifies = true; ///
|
|
231
|
-
}
|
|
232
242
|
|
|
233
|
-
|
|
243
|
+
return continuation(referenceUnifies);
|
|
244
|
+
});
|
|
234
245
|
}
|
|
235
246
|
|
|
236
|
-
|
|
237
|
-
let statementUnifies;
|
|
238
|
-
|
|
247
|
+
unifyStatement(statement, generalContext, specificContext, continuation) {
|
|
239
248
|
const context = specificContext, ///
|
|
240
249
|
statementString = statement.getString(),
|
|
241
250
|
constraintString = this.getString(); ///
|
|
@@ -245,18 +254,16 @@ export default define(class Constraint extends Element {
|
|
|
245
254
|
const generalStatement = this.statement, ///
|
|
246
255
|
specificStatement = stripBracketsFromStatement(statement, context); ///
|
|
247
256
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
257
|
+
return unifyStatement(generalStatement, specificStatement, generalContext, specificContext, (statementUnifies) => {
|
|
258
|
+
if (statementUnifies) {
|
|
259
|
+
context.debug(`...unified the '${statementString}' statement with the '${constraintString}' constraint's statement.`);
|
|
260
|
+
}
|
|
253
261
|
|
|
254
|
-
|
|
262
|
+
return continuation(statementUnifies);
|
|
263
|
+
});
|
|
255
264
|
}
|
|
256
265
|
|
|
257
|
-
|
|
258
|
-
let assumptionUnifies = false;
|
|
259
|
-
|
|
266
|
+
unifyAssumption(assumption, context, continuation) {
|
|
260
267
|
const assumptionString = assumption.getString(), ///
|
|
261
268
|
constraintString = this.getString();
|
|
262
269
|
|
|
@@ -265,40 +272,42 @@ export default define(class Constraint extends Element {
|
|
|
265
272
|
const constraintContext = this.getContext(), ///
|
|
266
273
|
generalContext = constraintContext; ///
|
|
267
274
|
|
|
268
|
-
reconcile(
|
|
275
|
+
reconcile((context) => {
|
|
269
276
|
const reference = assumption.getReference(),
|
|
270
|
-
specificContext = context
|
|
271
|
-
referneceUnifies = this.unifyReference(reference, generalContext, specificContext);
|
|
272
|
-
|
|
273
|
-
if (referneceUnifies) {
|
|
274
|
-
const statement = assumption.getStatement(),
|
|
275
|
-
statementUnified = this.unifyStatement(statement, generalContext, specificContext);
|
|
277
|
+
specificContext = context; ///
|
|
276
278
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
+
return this.unifyReference(reference, generalContext, specificContext, (referneceUnifies) => {
|
|
280
|
+
if (!referneceUnifies) {
|
|
281
|
+
const assumptionUnifies = false;
|
|
279
282
|
|
|
280
|
-
assumptionUnifies
|
|
283
|
+
return continuation(assumptionUnifies);
|
|
281
284
|
}
|
|
282
|
-
}
|
|
283
|
-
}, context);
|
|
284
285
|
|
|
285
|
-
|
|
286
|
-
context.debug(`...unified the '${assumptionString}' assumption with the '${constraintString}' constraint...`);
|
|
287
|
-
}
|
|
286
|
+
const statement = assumption.getStatement();
|
|
288
287
|
|
|
289
|
-
|
|
290
|
-
|
|
288
|
+
return this.unifyStatement(statement, generalContext, specificContext, (statementUnifies) => {
|
|
289
|
+
let assumptionUnifies = false;
|
|
291
290
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
const assumptionUnifies = this.unifyAssumption(assumption, context);
|
|
291
|
+
if (statementUnifies) {
|
|
292
|
+
context.commit();
|
|
295
293
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
294
|
+
assumptionUnifies = true;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (assumptionUnifies) {
|
|
298
|
+
context.debug(`...unified the '${assumptionString}' assumption with the '${constraintString}' constraint...`);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return continuation(assumptionUnifies);
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
}, context);
|
|
305
|
+
}
|
|
300
306
|
|
|
301
|
-
|
|
307
|
+
unifyAssumptions(assumptions, context, continuation) {
|
|
308
|
+
some(assumptions, (assumption, continuation) => {
|
|
309
|
+
this.unifyAssumption(assumption, context, continuation);
|
|
310
|
+
}, continuation);
|
|
302
311
|
}
|
|
303
312
|
|
|
304
313
|
toJSON() {
|
|
@@ -18,7 +18,7 @@ export default define(class BracketedConstructor extends Constructor {
|
|
|
18
18
|
|
|
19
19
|
context.trace(`Unifying the '${termString}' term with the bracketed constructor...`);
|
|
20
20
|
|
|
21
|
-
super.unifyTerm(term, context, (termUnifies) => {
|
|
21
|
+
return super.unifyTerm(term, context, (termUnifies) => {
|
|
22
22
|
if (!termUnifies) {
|
|
23
23
|
return continuation(termUnifies);
|
|
24
24
|
}
|
|
@@ -36,7 +36,7 @@ export default define(class BracketedConstructor extends Constructor {
|
|
|
36
36
|
const bracketlessTermNode = singularTermNode, ///
|
|
37
37
|
bracketlessTerm = termFromTermNode(bracketlessTermNode, context);
|
|
38
38
|
|
|
39
|
-
bracketlessTerm.validate(context, (bracketlessTerm, context) => {
|
|
39
|
+
return bracketlessTerm.validate(context, (bracketlessTerm, context) => {
|
|
40
40
|
if (bracketlessTerm === null) {
|
|
41
41
|
const termUnifies = false;
|
|
42
42
|
|
package/src/element/deduction.js
CHANGED
package/src/element/equality.js
CHANGED
|
@@ -172,14 +172,14 @@ export default define(class Equality extends Element {
|
|
|
172
172
|
|
|
173
173
|
context.trace(`Validating the '${equalityString}' equality's terms...`);
|
|
174
174
|
|
|
175
|
-
this.leftTerm.validate(context, (leftTerm, context) => {
|
|
175
|
+
return this.leftTerm.validate(context, (leftTerm, context) => {
|
|
176
176
|
if (leftTerm === null) {
|
|
177
177
|
const termsValidate = false;
|
|
178
178
|
|
|
179
179
|
return continuation(termsValidate);
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
this.rightTerm.validate(context, (rightTerm, context) => {
|
|
182
|
+
return this.rightTerm.validate(context, (rightTerm, context) => {
|
|
183
183
|
if (rightTerm === null) {
|
|
184
184
|
const termsValidate = false;
|
|
185
185
|
|
package/src/element/frame.js
CHANGED
|
@@ -197,7 +197,7 @@ export default define(class Frame extends Element {
|
|
|
197
197
|
|
|
198
198
|
context.trace(`Validating the '${frameString}' frame's '${assumptionString}' assumption.`);
|
|
199
199
|
|
|
200
|
-
assumption.validate(context, (assumption) => {
|
|
200
|
+
return assumption.validate(context, (assumption) => {
|
|
201
201
|
let assumptionValidates = false;
|
|
202
202
|
|
|
203
203
|
if (assumption !== null) {
|
|
@@ -253,7 +253,7 @@ export default define(class Frame extends Element {
|
|
|
253
253
|
|
|
254
254
|
context.trace(`Validating the '${frameString}' frame's metavariable...`);
|
|
255
255
|
|
|
256
|
-
this.metavariable.validate(context, (metavariable) => {
|
|
256
|
+
return this.metavariable.validate(context, (metavariable) => {
|
|
257
257
|
let metavariableValidates = false;
|
|
258
258
|
|
|
259
259
|
if (metavariable !== null) {
|