occam-verify-cli 1.0.746 → 1.0.753
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/branching.js +56 -0
- package/lib/context/ephemeral.js +10 -1
- package/lib/context/file/nominal.js +1 -6
- package/lib/context/synthetic.js +3 -3
- package/lib/context.js +9 -1
- package/lib/element/assertion/contained.js +7 -7
- package/lib/element/assertion/defined.js +7 -7
- package/lib/element/assertion/property.js +3 -3
- package/lib/element/assertion/satisfies.js +2 -2
- package/lib/element/assertion/subproof.js +2 -2
- package/lib/element/assertion/type.js +7 -7
- package/lib/element/assumption.js +2 -2
- package/lib/element/combinator.js +4 -4
- package/lib/element/conclusion.js +3 -3
- package/lib/element/constructor/bracketed.js +9 -8
- package/lib/element/constructor.js +9 -5
- package/lib/element/deduction.js +3 -3
- package/lib/element/equality.js +12 -11
- package/lib/element/equivalence.js +3 -3
- package/lib/element/frame.js +2 -2
- package/lib/element/hypothesis.js +2 -2
- package/lib/element/judgement.js +2 -2
- package/lib/element/label.js +4 -4
- package/lib/element/metavariable.js +59 -25
- package/lib/element/parameter.js +2 -2
- package/lib/element/procedureCall.js +2 -2
- package/lib/element/procedureReference.js +2 -2
- package/lib/element/proof.js +2 -2
- package/lib/element/proofAssertion/premise.js +5 -5
- package/lib/element/proofAssertion/step.js +3 -3
- package/lib/element/proofAssertion/supposition.js +5 -5
- package/lib/element/property.js +2 -2
- package/lib/element/propertyRelation.js +3 -3
- package/lib/element/reference.js +2 -2
- package/lib/element/rule.js +2 -2
- package/lib/element/signature.js +3 -3
- package/lib/element/statement.js +2 -2
- package/lib/element/subproof.js +2 -2
- package/lib/element/substitution/frame.js +8 -8
- package/lib/element/substitution/metaLevel.js +7 -7
- package/lib/element/substitution/reference.js +7 -7
- package/lib/element/substitution/statement.js +17 -21
- package/lib/element/substitution/term.js +10 -10
- package/lib/element/term.js +17 -14
- package/lib/element/topLevelAssertion.js +2 -2
- package/lib/element/topLevelMetaAssertion.js +2 -2
- package/lib/element/type.js +2 -2
- package/lib/element/typePrefix.js +2 -2
- package/lib/element/variable.js +4 -3
- package/lib/process/unify.js +11 -7
- package/lib/process/validate.js +5 -5
- package/lib/utilities/context.js +28 -20
- package/lib/utilities/element.js +2 -2
- package/lib/utilities/instance.js +3 -3
- package/lib/utilities/validation.js +13 -5
- package/package.json +1 -1
- package/src/context/branching.js +59 -0
- package/src/context/ephemeral.js +12 -0
- package/src/context/file/nominal.js +0 -8
- package/src/context/synthetic.js +3 -2
- package/src/context.js +14 -0
- package/src/element/assertion/contained.js +7 -7
- package/src/element/assertion/defined.js +7 -7
- package/src/element/assertion/property.js +4 -4
- package/src/element/assertion/satisfies.js +2 -2
- package/src/element/assertion/subproof.js +2 -2
- package/src/element/assertion/type.js +7 -7
- package/src/element/assumption.js +2 -2
- package/src/element/combinator.js +4 -4
- package/src/element/conclusion.js +3 -3
- package/src/element/constructor/bracketed.js +9 -7
- package/src/element/constructor.js +11 -5
- package/src/element/deduction.js +3 -3
- package/src/element/equality.js +16 -14
- package/src/element/equivalence.js +3 -3
- package/src/element/frame.js +2 -2
- package/src/element/hypothesis.js +2 -2
- package/src/element/judgement.js +2 -2
- package/src/element/label.js +4 -4
- package/src/element/metavariable.js +81 -30
- package/src/element/parameter.js +2 -2
- package/src/element/procedureCall.js +2 -2
- package/src/element/procedureReference.js +2 -2
- package/src/element/proof.js +2 -2
- package/src/element/proofAssertion/premise.js +5 -5
- package/src/element/proofAssertion/step.js +3 -3
- package/src/element/proofAssertion/supposition.js +5 -5
- package/src/element/property.js +2 -2
- package/src/element/propertyRelation.js +3 -3
- package/src/element/reference.js +2 -2
- package/src/element/rule.js +2 -2
- package/src/element/signature.js +3 -3
- package/src/element/statement.js +2 -2
- package/src/element/subproof.js +2 -2
- package/src/element/substitution/frame.js +8 -8
- package/src/element/substitution/metaLevel.js +7 -7
- package/src/element/substitution/reference.js +7 -7
- package/src/element/substitution/statement.js +17 -24
- package/src/element/substitution/term.js +10 -10
- package/src/element/term.js +22 -16
- package/src/element/topLevelAssertion.js +2 -2
- package/src/element/topLevelMetaAssertion.js +2 -2
- package/src/element/type.js +3 -2
- package/src/element/typePrefix.js +2 -2
- package/src/element/variable.js +7 -3
- package/src/process/unify.js +15 -8
- package/src/process/validate.js +4 -4
- package/src/utilities/context.js +20 -12
- package/src/utilities/element.js +2 -2
- package/src/utilities/instance.js +3 -3
- package/src/utilities/validation.js +16 -4
package/src/element/term.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Element } from "occam-languages";
|
|
|
4
4
|
import { arrayUtilities } from "necessary";
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
|
-
import {
|
|
7
|
+
import { instantiate } from "../utilities/context";
|
|
8
8
|
import { validateTerms } from "../utilities/validation";
|
|
9
9
|
import { instantiateTerm } from "../process/instantiate";
|
|
10
10
|
import { variablesFromTerm } from "../utilities/equivalence";
|
|
@@ -158,12 +158,14 @@ export default define(class Term extends Element {
|
|
|
158
158
|
valid = (validTerm !== null);
|
|
159
159
|
|
|
160
160
|
if (valid) {
|
|
161
|
-
|
|
161
|
+
term = validTerm; ///
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
term = validTerm; ///
|
|
163
|
+
context.debug(`...the '${termString}' term is already valid.`);
|
|
165
164
|
|
|
166
|
-
|
|
165
|
+
const validatesForward = validateForwards(term);
|
|
166
|
+
|
|
167
|
+
if (!validatesForward) {
|
|
168
|
+
term = null;
|
|
167
169
|
}
|
|
168
170
|
} else {
|
|
169
171
|
const validates = validateTerms.some((validateTerm) => { ///
|
|
@@ -188,33 +190,37 @@ export default define(class Term extends Element {
|
|
|
188
190
|
}
|
|
189
191
|
|
|
190
192
|
validateGivenType(type, context) {
|
|
191
|
-
let
|
|
193
|
+
let term;
|
|
192
194
|
|
|
193
195
|
const typeString = type.getString(),
|
|
194
196
|
termString = this.getString(); ///
|
|
195
197
|
|
|
196
198
|
context.trace(`Validating the '${termString}' term given the '${typeString}' type...`);
|
|
197
199
|
|
|
198
|
-
|
|
199
|
-
const validatesForwards = true;
|
|
200
|
+
let validatesGivenType = false;
|
|
200
201
|
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
term = this.validate(context, (term) => {
|
|
203
|
+
let validatesForwards = false;
|
|
203
204
|
|
|
204
|
-
if (term !== null) {
|
|
205
205
|
const termType = term.getType(),
|
|
206
|
-
|
|
206
|
+
termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(type);
|
|
207
207
|
|
|
208
|
-
if (
|
|
209
|
-
|
|
208
|
+
if (termTypeEqualToOrSubTypeOfType) {
|
|
209
|
+
validatesForwards = true;
|
|
210
210
|
}
|
|
211
|
+
|
|
212
|
+
return validatesForwards;
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
if (term !== null) {
|
|
216
|
+
validatesGivenType = true;
|
|
211
217
|
}
|
|
212
218
|
|
|
213
219
|
if (validatesGivenType) {
|
|
214
220
|
context.debug(`...validated the '${termString}' term given the '${typeString}' type.`);
|
|
215
221
|
}
|
|
216
222
|
|
|
217
|
-
return
|
|
223
|
+
return term;
|
|
218
224
|
}
|
|
219
225
|
|
|
220
226
|
toJSON() {
|
|
@@ -232,7 +238,7 @@ export default define(class Term extends Element {
|
|
|
232
238
|
static name = "Term";
|
|
233
239
|
|
|
234
240
|
static fromJSON(json, context) {
|
|
235
|
-
const term =
|
|
241
|
+
const term = instantiate((context) => {
|
|
236
242
|
const { string } = json,
|
|
237
243
|
termNode = instantiateTerm(string, context),
|
|
238
244
|
node = termNode, ///
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
import { Element, asynchronousUtilities } from "occam-languages";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { asyncRestrict } from "../utilities/context";
|
|
7
7
|
import { topLevelAssertionStringFromLabelsSuppositionsAndDeduction } from "../utilities/string";
|
|
8
8
|
import { labelsFromJSON,
|
|
9
9
|
deductionFromJSON,
|
|
@@ -152,7 +152,7 @@ export default class TopLevelAssertion extends Element {
|
|
|
152
152
|
|
|
153
153
|
context.trace(`Verifying the '${topLevelAssertionString}' top level assertion...`);
|
|
154
154
|
|
|
155
|
-
await
|
|
155
|
+
await asyncRestrict(async (context) => {
|
|
156
156
|
const labelsVerify = this.verifyLabels();
|
|
157
157
|
|
|
158
158
|
if (labelsVerify) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { Element, asynchronousUtilities } from "occam-languages";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { asyncRestrict } from "../utilities/context";
|
|
6
6
|
import { topLevelMetaAssertionStringFromLabelSuppositionsAndDeduction } from "../utilities/string";
|
|
7
7
|
import { labelFromJSON,
|
|
8
8
|
labelToLabelJSON,
|
|
@@ -64,7 +64,7 @@ export default class TopLevelMetaAssertion extends Element {
|
|
|
64
64
|
|
|
65
65
|
context.trace(`Verifying the '${topLevelMetaAssertionString}' top level meta assertion...`);
|
|
66
66
|
|
|
67
|
-
await
|
|
67
|
+
await asyncRestrict(async (context) => {
|
|
68
68
|
const labelVerifies = this.verifyLabel();
|
|
69
69
|
|
|
70
70
|
if (labelVerifies) {
|
package/src/element/type.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Element } from "occam-languages";
|
|
|
4
4
|
import { arrayUtilities } from "necessary";
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
|
-
import {
|
|
7
|
+
import { instantiate } from "../utilities/context";
|
|
8
8
|
import { instantiateType } from "../process/instantiate";
|
|
9
9
|
import { baseTypeFromNothing } from "../utilities/type";
|
|
10
10
|
import { nameFromTypeNode, prefixNameFromTypeNode } from "../utilities/element";
|
|
@@ -15,6 +15,7 @@ const { push, first } = arrayUtilities;
|
|
|
15
15
|
export default define(class Type extends Element {
|
|
16
16
|
constructor(context, string, node, name, prefixName, superTypes, properties, provisional) {
|
|
17
17
|
super(context, string, node);
|
|
18
|
+
|
|
18
19
|
this.name = name;
|
|
19
20
|
this.prefixName = prefixName;
|
|
20
21
|
this.superTypes = superTypes;
|
|
@@ -315,7 +316,7 @@ export default define(class Type extends Element {
|
|
|
315
316
|
static name = "Type";
|
|
316
317
|
|
|
317
318
|
static fromJSON(json, context) {
|
|
318
|
-
const type =
|
|
319
|
+
const type = instantiate((context) => {
|
|
319
320
|
const { string } = json,
|
|
320
321
|
typeNode = instantiateType(string, context),
|
|
321
322
|
node = typeNode, ///
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import {
|
|
6
|
+
import { instantiate } from "../utilities/context";
|
|
7
7
|
import { instantiateTypePrefix } from "../process/instantiate";
|
|
8
8
|
import { nameFromTypePrefixNode } from "../utilities/element";
|
|
9
9
|
|
|
@@ -43,7 +43,7 @@ export default define(class TypePrefix extends Element {
|
|
|
43
43
|
static name = "TypePrefix";
|
|
44
44
|
|
|
45
45
|
static fromJSON(json, context) {
|
|
46
|
-
const typePrefix =
|
|
46
|
+
const typePrefix = instantiate((context) => {const { string } = json,
|
|
47
47
|
typePrefixNode = instantiateTypePrefix(string, context),
|
|
48
48
|
node = typePrefixNode, ///
|
|
49
49
|
name = nameFromTypePrefixNode(typePrefixNode, context);
|
package/src/element/variable.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Element } from "occam-languages";
|
|
|
5
5
|
import elements from "../elements";
|
|
6
6
|
|
|
7
7
|
import { define } from "../elements";
|
|
8
|
-
import {
|
|
8
|
+
import { instantiate } from "../utilities/context";
|
|
9
9
|
import { instantiateVariable } from "../process/instantiate";
|
|
10
10
|
import {identifierFromVarialbeNode, variableFromVariableNode} from "../utilities/element";
|
|
11
11
|
import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
|
|
@@ -82,7 +82,11 @@ export default define(class Variable extends Element {
|
|
|
82
82
|
variable = context.findVariableByVariableIdentifier(variableIdentifier);
|
|
83
83
|
|
|
84
84
|
if (variable !== null) {
|
|
85
|
-
const type = variable.getType()
|
|
85
|
+
const type = variable.getType(),
|
|
86
|
+
typeString = type.getString(),
|
|
87
|
+
variableString = this.getString(); ///
|
|
88
|
+
|
|
89
|
+
context.trace(`Setting the '${variableString}' variable's type to the '${typeString}' type.`);
|
|
86
90
|
|
|
87
91
|
this.type = type;
|
|
88
92
|
|
|
@@ -180,7 +184,7 @@ export default define(class Variable extends Element {
|
|
|
180
184
|
static name = "Variable";
|
|
181
185
|
|
|
182
186
|
static fromJSON(json, context) {
|
|
183
|
-
const variable =
|
|
187
|
+
const variable = instantiate((context) => {
|
|
184
188
|
const { string } = json,
|
|
185
189
|
variableNode = instantiateVariable(string, context),
|
|
186
190
|
node = variableNode, ///
|
package/src/process/unify.js
CHANGED
|
@@ -223,10 +223,13 @@ class CombinatorPass extends ZipPass {
|
|
|
223
223
|
|
|
224
224
|
context = specificContext; ///
|
|
225
225
|
|
|
226
|
-
|
|
227
|
-
termValidatesGivenType = term.validateGivenType(type, context);
|
|
226
|
+
let term;
|
|
228
227
|
|
|
229
|
-
|
|
228
|
+
term = termFromTermNode(termNode, context);
|
|
229
|
+
|
|
230
|
+
term = term.validateGivenType(type, context);
|
|
231
|
+
|
|
232
|
+
if (term !== null) {
|
|
230
233
|
success = true;
|
|
231
234
|
}
|
|
232
235
|
|
|
@@ -257,10 +260,13 @@ class ConstructorPass extends ZipPass {
|
|
|
257
260
|
if (type !== null) {
|
|
258
261
|
context = specificContext; ///
|
|
259
262
|
|
|
260
|
-
|
|
261
|
-
|
|
263
|
+
let term;
|
|
264
|
+
|
|
265
|
+
term = termFromTermNode(termNode, context);
|
|
266
|
+
|
|
267
|
+
term = term.validateGivenType(type, context);
|
|
262
268
|
|
|
263
|
-
if (
|
|
269
|
+
if (term !== null) {
|
|
264
270
|
success = true;
|
|
265
271
|
}
|
|
266
272
|
}
|
|
@@ -285,9 +291,10 @@ class MetavariablePass extends ZipPass {
|
|
|
285
291
|
type = generalContext.findTypeByNominalTypeName(nominalTypeName),
|
|
286
292
|
context = specificContext, ///
|
|
287
293
|
term = context.findTermByTermNode(termNode),
|
|
288
|
-
|
|
294
|
+
termType = term.getType(),
|
|
295
|
+
termTypeEqualToOrSubTypeOfGivenTypeType = termType.isEqualToOrSubTypeOf(type);
|
|
289
296
|
|
|
290
|
-
if (
|
|
297
|
+
if (termTypeEqualToOrSubTypeOfGivenTypeType) {
|
|
291
298
|
success = true;
|
|
292
299
|
}
|
|
293
300
|
|
package/src/process/validate.js
CHANGED
|
@@ -11,7 +11,7 @@ const termNodeQuery = nodeQuery("/term"),
|
|
|
11
11
|
typeNodeQuery = nodeQuery("/type"),
|
|
12
12
|
statementNodeQuery = nodeQuery("/statement");
|
|
13
13
|
|
|
14
|
-
class
|
|
14
|
+
class CombinatorPass extends SimplePass {
|
|
15
15
|
run(statementNode, context) {
|
|
16
16
|
let success = false;
|
|
17
17
|
|
|
@@ -56,7 +56,7 @@ class ConbinatorPass extends SimplePass {
|
|
|
56
56
|
|
|
57
57
|
term = termFromTermNode(termNode, context);
|
|
58
58
|
|
|
59
|
-
term = term.validate(context, () => { ///
|
|
59
|
+
term = term.validate(context, (term) => { ///
|
|
60
60
|
const validatesForwards = true;
|
|
61
61
|
|
|
62
62
|
return validatesForwards;
|
|
@@ -112,7 +112,7 @@ class ConstructorPass extends SimplePass {
|
|
|
112
112
|
|
|
113
113
|
term = termFromTermNode(termNode, context);
|
|
114
114
|
|
|
115
|
-
term = term.validate(context, () => { ///
|
|
115
|
+
term = term.validate(context, (term) => { ///
|
|
116
116
|
const validatesForwards = true;
|
|
117
117
|
|
|
118
118
|
return validatesForwards;
|
|
@@ -143,7 +143,7 @@ class ConstructorPass extends SimplePass {
|
|
|
143
143
|
];
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
const combinatorPass = new
|
|
146
|
+
const combinatorPass = new CombinatorPass(),
|
|
147
147
|
constructorPass = new ConstructorPass();
|
|
148
148
|
|
|
149
149
|
export function validateTermAsConstructor(term, context) {
|
package/src/utilities/context.js
CHANGED
|
@@ -5,6 +5,22 @@ import LiminalContext from "../context/liminal";
|
|
|
5
5
|
import LiteralContext from "../context/literal";
|
|
6
6
|
import EphemeralContext from "../context/ephemeral";
|
|
7
7
|
import SyntheticContext from "../context/synthetic";
|
|
8
|
+
import BranchingContext from "../context/branching";
|
|
9
|
+
|
|
10
|
+
export function join(innerFunction, ...contexts) {
|
|
11
|
+
const syntheticContext = SyntheticContext.fromContexts(...contexts),
|
|
12
|
+
context = syntheticContext; ///
|
|
13
|
+
|
|
14
|
+
return innerFunction(context);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function choose(innerFunction, context) {
|
|
18
|
+
const branchingContext = BranchingContext.fromNothing(context);
|
|
19
|
+
|
|
20
|
+
context = branchingContext; ///
|
|
21
|
+
|
|
22
|
+
return innerFunction(context);
|
|
23
|
+
}
|
|
8
24
|
|
|
9
25
|
export function attempt(innerFunction, context) {
|
|
10
26
|
const ephemeralContext = EphemeralContext.fromNothing(context);
|
|
@@ -14,7 +30,7 @@ export function attempt(innerFunction, context) {
|
|
|
14
30
|
return innerFunction(context);
|
|
15
31
|
}
|
|
16
32
|
|
|
17
|
-
export function
|
|
33
|
+
export function reconcile(innerFunction, context) {
|
|
18
34
|
const liminalContext = LiminalContext.fromNothing(context);
|
|
19
35
|
|
|
20
36
|
context = liminalContext; ///
|
|
@@ -22,7 +38,7 @@ export function liminally(innerFunction, context) {
|
|
|
22
38
|
return innerFunction(context);
|
|
23
39
|
}
|
|
24
40
|
|
|
25
|
-
export function
|
|
41
|
+
export function instantiate(innerFunction, context) {
|
|
26
42
|
const literalContext = LiteralContext.fromNothing(context);
|
|
27
43
|
|
|
28
44
|
context = literalContext; ///
|
|
@@ -30,15 +46,7 @@ export function literally(innerFunction, context) {
|
|
|
30
46
|
return innerFunction(context);
|
|
31
47
|
}
|
|
32
48
|
|
|
33
|
-
export function
|
|
34
|
-
const syntheticContext = SyntheticContext.fromContexts(contexts, context);
|
|
35
|
-
|
|
36
|
-
context = syntheticContext; ///
|
|
37
|
-
|
|
38
|
-
return innerFunction(context);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export async function asyncScope(innerFunction, metaLevelSubstitutions, context) {
|
|
49
|
+
export async function asyncRestrict(innerFunction, metaLevelSubstitutions, context) {
|
|
42
50
|
if (context === undefined) {
|
|
43
51
|
context = metaLevelSubstitutions; ///
|
|
44
52
|
|
|
@@ -52,7 +60,7 @@ export async function asyncScope(innerFunction, metaLevelSubstitutions, context)
|
|
|
52
60
|
return await innerFunction(context);
|
|
53
61
|
}
|
|
54
62
|
|
|
55
|
-
export async function
|
|
63
|
+
export async function asyncReconcile(innerFunction, context) {
|
|
56
64
|
const liminalContext = LiminalContext.fromNothing(context);
|
|
57
65
|
|
|
58
66
|
context = liminalContext; ///
|
package/src/utilities/element.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import elements from "../elements";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { instantiate } from "../utilities/context";
|
|
6
6
|
import { baseTypeFromNothing } from "../utilities/type";
|
|
7
7
|
import { instantiateReference } from "../process/instantiate";
|
|
8
8
|
import { equivalenceStringFromTerms,
|
|
@@ -1363,7 +1363,7 @@ export function metavariableFromReferenceNode(referenceNode, context) {
|
|
|
1363
1363
|
export function referenceFromMetavariableNode(metavariableNode, context) {
|
|
1364
1364
|
const metavariableString = context.nodeAsString(metavariableNode);
|
|
1365
1365
|
|
|
1366
|
-
return
|
|
1366
|
+
return instantiate((context) => {
|
|
1367
1367
|
const referenceString = metavariableString, ///
|
|
1368
1368
|
string = referenceString, ///
|
|
1369
1369
|
referenceNode = instantiateReference(string, context),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import nominalContext from "../context/nominal";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { instantiate } from "../utilities/context";
|
|
6
6
|
import { BASE_TYPE_SYMBOL } from "../constants";
|
|
7
7
|
import { STATEMENT_META_TYPE_NAME } from "../metaTypeNames";
|
|
8
8
|
import { instantiateCombinator, instantiateConstructor } from "../process/instantiate";
|
|
@@ -15,7 +15,7 @@ export function bracketedCombinatorFromNothing() {
|
|
|
15
15
|
if (bracketedCombinator === null) {
|
|
16
16
|
const context = nominalContext; ///
|
|
17
17
|
|
|
18
|
-
bracketedCombinator =
|
|
18
|
+
bracketedCombinator = instantiate((context) => {
|
|
19
19
|
const bracketedCombinatorString = `(${STATEMENT_META_TYPE_NAME})`,
|
|
20
20
|
string = bracketedCombinatorString, ///
|
|
21
21
|
combinatorNode = instantiateCombinator(string, context),
|
|
@@ -33,7 +33,7 @@ export function bracketedConstructorFromNothing() {
|
|
|
33
33
|
if (bracketedConstructor === null) {
|
|
34
34
|
const context = nominalContext; ///
|
|
35
35
|
|
|
36
|
-
bracketedConstructor =
|
|
36
|
+
bracketedConstructor = instantiate((context) => {
|
|
37
37
|
const bracketedConstructorString = `(${BASE_TYPE_SYMBOL})`,
|
|
38
38
|
string = bracketedConstructorString, ///
|
|
39
39
|
constructorNode = instantiateConstructor(string, context),
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import elements from "../elements";
|
|
4
4
|
|
|
5
|
+
import { choose } from "./context";
|
|
5
6
|
import { variableFromTerm } from "../utilities/term";
|
|
6
7
|
import { bracketedConstructorFromNothing, bracketedCombinatorFromNothing } from "../utilities/instance";
|
|
7
8
|
import { equalityFromStatement,
|
|
@@ -29,11 +30,14 @@ function validateTermAsVariable(term, context, validateForwards) {
|
|
|
29
30
|
variable = variable.validate(context);
|
|
30
31
|
|
|
31
32
|
if (variable !== null) {
|
|
32
|
-
const type = variable.getType()
|
|
33
|
+
const type = variable.getType(),
|
|
34
|
+
typeString = type.getString();
|
|
35
|
+
|
|
36
|
+
context.trace(`Setting the '${termString}' term's type to the '${typeString}' type.`);
|
|
33
37
|
|
|
34
38
|
term.setType(type);
|
|
35
39
|
|
|
36
|
-
const validatesForwards = validateForwards();
|
|
40
|
+
const validatesForwards = validateForwards(term);
|
|
37
41
|
|
|
38
42
|
if (validatesForwards) {
|
|
39
43
|
termValidatesAsVariable = true;
|
|
@@ -54,9 +58,17 @@ function unifyTermWithConstructors(term, context, validateForwards) {
|
|
|
54
58
|
const constructors = context.getConstructors();
|
|
55
59
|
|
|
56
60
|
termUnifiesWithConstructors = constructors.some((constructor) => {
|
|
57
|
-
|
|
61
|
+
let termUnifies;
|
|
62
|
+
|
|
63
|
+
choose((context) => {
|
|
64
|
+
termUnifies = constructor.unifyTerm(term, context, validateForwards);
|
|
65
|
+
|
|
66
|
+
if (termUnifies) {
|
|
67
|
+
context.commit();
|
|
68
|
+
}
|
|
69
|
+
}, context);
|
|
58
70
|
|
|
59
|
-
if (
|
|
71
|
+
if (termUnifies) {
|
|
60
72
|
return true;
|
|
61
73
|
}
|
|
62
74
|
});
|