occam-verify-cli 1.0.747 → 1.0.757
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 +5 -10
- package/lib/context/scoped.js +6 -5
- package/lib/context/synthetic.js +7 -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 +111 -14
- package/lib/element/assertion/type.js +7 -7
- package/lib/element/assumption.js +21 -33
- package/lib/element/combinator.js +4 -4
- package/lib/element/conclusion.js +3 -7
- package/lib/element/constructor/bracketed.js +9 -8
- package/lib/element/constructor.js +9 -5
- package/lib/element/deduction.js +17 -20
- package/lib/element/derivation.js +4 -4
- 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 +65 -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 +7 -7
- package/lib/element/proofAssertion/premise.js +12 -18
- package/lib/element/proofAssertion/step.js +3 -3
- package/lib/element/proofAssertion/supposition.js +13 -19
- package/lib/element/property.js +2 -2
- package/lib/element/propertyRelation.js +3 -3
- package/lib/element/reference.js +11 -9
- package/lib/element/rule.js +2 -2
- package/lib/element/signature.js +3 -3
- package/lib/element/statement.js +100 -59
- package/lib/element/subDerivation.js +4 -4
- package/lib/element/subproof.js +7 -7
- 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 +73 -60
- package/lib/element/substitution/term.js +10 -10
- package/lib/element/term.js +17 -14
- package/lib/element/topLevelAssertion/axiom.js +15 -13
- package/lib/element/topLevelAssertion.js +2 -5
- package/lib/element/topLevelMetaAssertion.js +27 -3
- package/lib/element/type.js +2 -2
- package/lib/element/typePrefix.js +2 -2
- package/lib/element/variable.js +6 -3
- package/lib/process/unify.js +51 -9
- 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/releaseContext.js +3 -3
- package/lib/utilities/string.js +2 -2
- package/lib/utilities/validation.js +13 -5
- package/package.json +3 -3
- package/src/context/branching.js +59 -0
- package/src/context/ephemeral.js +12 -0
- package/src/context/file/nominal.js +4 -12
- package/src/context/scoped.js +6 -4
- package/src/context/synthetic.js +9 -2
- package/src/context.js +14 -0
- package/src/element/assertion/contained.js +8 -8
- 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 +191 -18
- package/src/element/assertion/type.js +7 -7
- package/src/element/assumption.js +21 -52
- package/src/element/combinator.js +4 -4
- package/src/element/conclusion.js +3 -10
- package/src/element/constructor/bracketed.js +9 -7
- package/src/element/constructor.js +11 -5
- package/src/element/deduction.js +17 -23
- package/src/element/derivation.js +4 -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 +96 -32
- 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 +8 -8
- package/src/element/proofAssertion/premise.js +22 -32
- package/src/element/proofAssertion/step.js +3 -3
- package/src/element/proofAssertion/supposition.js +27 -36
- package/src/element/property.js +2 -2
- package/src/element/propertyRelation.js +3 -3
- package/src/element/reference.js +11 -9
- package/src/element/rule.js +2 -2
- package/src/element/signature.js +3 -3
- package/src/element/statement.js +154 -88
- package/src/element/subDerivation.js +4 -3
- package/src/element/subproof.js +6 -6
- 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 +99 -76
- package/src/element/substitution/term.js +10 -10
- package/src/element/term.js +22 -16
- package/src/element/topLevelAssertion/axiom.js +20 -16
- package/src/element/topLevelAssertion.js +2 -4
- package/src/element/topLevelMetaAssertion.js +42 -3
- package/src/element/type.js +3 -2
- package/src/element/typePrefix.js +2 -2
- package/src/element/variable.js +12 -3
- package/src/process/unify.js +78 -9
- 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/releaseContext.js +1 -1
- package/src/utilities/string.js +3 -3
- package/src/utilities/validation.js +16 -4
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import { attempt,
|
|
6
|
+
import { attempt, instantiate } from "../utilities/context";
|
|
7
7
|
import { instantiateConclusion } from "../process/instantiate";
|
|
8
8
|
import { statementFromConclusionNode } from "../utilities/element";
|
|
9
9
|
import { ephemeralContextFromJSON, ephemeralContextToEphemeralContextJSON } from "../utilities/json";
|
|
@@ -63,7 +63,7 @@ export default define(class Conclusion extends Element {
|
|
|
63
63
|
const statementValidates = this.validateStatement(context);
|
|
64
64
|
|
|
65
65
|
if (statementValidates) {
|
|
66
|
-
|
|
66
|
+
context.commit(this);
|
|
67
67
|
|
|
68
68
|
validates = true;
|
|
69
69
|
}
|
|
@@ -150,7 +150,7 @@ export default define(class Conclusion extends Element {
|
|
|
150
150
|
|
|
151
151
|
context = ephemeralContext; ///
|
|
152
152
|
|
|
153
|
-
const conclusion =
|
|
153
|
+
const conclusion = instantiate((context) => {
|
|
154
154
|
const { string } = json,
|
|
155
155
|
conclusionNode = instantiateConclusion(string, context),
|
|
156
156
|
node = conclusionNode, ///
|
|
@@ -163,10 +163,3 @@ export default define(class Conclusion extends Element {
|
|
|
163
163
|
return conclusion;
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
|
-
|
|
167
|
-
function statementFromConclusionNode(conclusionNode, context) {
|
|
168
|
-
const statementNode = conclusionNode.getStatementNode(),
|
|
169
|
-
statement = context.findStatementByStatementNode(statementNode);
|
|
170
|
-
|
|
171
|
-
return statement;
|
|
172
|
-
}
|
|
@@ -20,7 +20,7 @@ export default define(class BracketedConstructor extends Constructor {
|
|
|
20
20
|
|
|
21
21
|
context.trace(`Unifying the '${termString}' term with the bracketed constructor...`);
|
|
22
22
|
|
|
23
|
-
termUnifies = super.unifyTerm(term, context, () => {
|
|
23
|
+
termUnifies = super.unifyTerm(term, context, (term) => {
|
|
24
24
|
let validatesForwards = false;
|
|
25
25
|
|
|
26
26
|
const bracketedTerm = term, ///
|
|
@@ -28,23 +28,25 @@ export default define(class BracketedConstructor extends Constructor {
|
|
|
28
28
|
singularTermNode = bracketedTermNode.getSingularTermNode();
|
|
29
29
|
|
|
30
30
|
if (singularTermNode !== null) {
|
|
31
|
-
const
|
|
31
|
+
const bracketlessTermNode = singularTermNode; ///
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
let bracketlessTerm;
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
bracketlessTerm = termFromTermNode(bracketlessTermNode, context);
|
|
36
|
+
|
|
37
|
+
bracketlessTerm = bracketlessTerm.validate(context, (bracketlessTerm) => { ///
|
|
36
38
|
let validatesForwards;
|
|
37
39
|
|
|
38
|
-
const type =
|
|
40
|
+
const type = bracketlessTerm.getType();
|
|
39
41
|
|
|
40
42
|
bracketedTerm.setType(type);
|
|
41
43
|
|
|
42
|
-
validatesForwards = validateForwards();
|
|
44
|
+
validatesForwards = validateForwards(bracketedTerm);
|
|
43
45
|
|
|
44
46
|
return validatesForwards;
|
|
45
47
|
});
|
|
46
48
|
|
|
47
|
-
if (
|
|
49
|
+
if (bracketlessTerm !== null) {
|
|
48
50
|
validatesForwards = true;
|
|
49
51
|
}
|
|
50
52
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import { attempt,
|
|
6
|
+
import { attempt, instantiate } from "../utilities/context";
|
|
7
7
|
import { instantiateConstructor } from "../process/instantiate";
|
|
8
8
|
import { termFromConstructorNode } from "../utilities/element";
|
|
9
9
|
import { unifyTermWithConstructor } from "../process/unify";
|
|
@@ -64,7 +64,7 @@ export default define(class Constructor extends Element {
|
|
|
64
64
|
const termValidates = this.validateTerm(context);
|
|
65
65
|
|
|
66
66
|
if (termValidates) {
|
|
67
|
-
|
|
67
|
+
context.commit(this);
|
|
68
68
|
|
|
69
69
|
validates = true;
|
|
70
70
|
}
|
|
@@ -122,11 +122,17 @@ export default define(class Constructor extends Element {
|
|
|
122
122
|
if (termUnifiesWithConstructor) {
|
|
123
123
|
let validatesForwards;
|
|
124
124
|
|
|
125
|
+
const typeString = this.type.getString();
|
|
126
|
+
|
|
127
|
+
context.trace(`Setting the '${termString}' term's type to the '${constructorString}' constructor's '${typeString}' type.`);
|
|
128
|
+
|
|
125
129
|
term.setType(this.type);
|
|
126
130
|
|
|
127
|
-
validatesForwards = validateForwards();
|
|
131
|
+
validatesForwards = validateForwards(term);
|
|
128
132
|
|
|
129
|
-
|
|
133
|
+
if (validatesForwards) {
|
|
134
|
+
termUnifies = true;
|
|
135
|
+
}
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
if (termUnifies) {
|
|
@@ -167,7 +173,7 @@ export default define(class Constructor extends Element {
|
|
|
167
173
|
|
|
168
174
|
context = ephemeralContext; ///
|
|
169
175
|
|
|
170
|
-
const constructor =
|
|
176
|
+
const constructor = instantiate((context) => {
|
|
171
177
|
const { string } = json,
|
|
172
178
|
constructorNode = instantiateConstructor(string, context),
|
|
173
179
|
node = constructorNode, ///
|
package/src/element/deduction.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import { attempt,
|
|
6
|
+
import { attempt, instantiate } from "../utilities/context";
|
|
7
7
|
import { instantiateDeduction } from "../process/instantiate";
|
|
8
|
+
import { statementFromDeductionNode } from "../utilities/element";
|
|
8
9
|
import { ephemeralContextFromJSON, ephemeralContextToEphemeralContextJSON } from "../utilities/json";
|
|
9
10
|
|
|
10
11
|
export default define(class Deduction extends Element {
|
|
@@ -30,9 +31,9 @@ export default define(class Deduction extends Element {
|
|
|
30
31
|
|
|
31
32
|
await this.break(context);
|
|
32
33
|
|
|
33
|
-
const
|
|
34
|
+
const deductionString = this.getString(); ///
|
|
34
35
|
|
|
35
|
-
context.trace(`Verifying the '${
|
|
36
|
+
context.trace(`Verifying the '${deductionString}' deduction...`);
|
|
36
37
|
|
|
37
38
|
if (this.statement !== null) {
|
|
38
39
|
const validates = this.validate(context);
|
|
@@ -41,11 +42,11 @@ export default define(class Deduction extends Element {
|
|
|
41
42
|
verifies = true;
|
|
42
43
|
}
|
|
43
44
|
} else {
|
|
44
|
-
context.debug(`Unable to verify the '${
|
|
45
|
+
context.debug(`Unable to verify the '${deductionString}' deduction because it is nonsense.`);
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
if (verifies) {
|
|
48
|
-
context.debug(`...verified the '${
|
|
49
|
+
context.debug(`...verified the '${deductionString}' deduction.`);
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
return verifies;
|
|
@@ -54,22 +55,22 @@ export default define(class Deduction extends Element {
|
|
|
54
55
|
validate(context) {
|
|
55
56
|
let validates = false;
|
|
56
57
|
|
|
57
|
-
const
|
|
58
|
+
const deductionString = this.getString(); ///
|
|
58
59
|
|
|
59
|
-
context.trace(`Validating the '${
|
|
60
|
+
context.trace(`Validating the '${deductionString}' deduction...`);
|
|
60
61
|
|
|
61
62
|
attempt((context) => {
|
|
62
63
|
const statementValidates = this.validateStatement(context);
|
|
63
64
|
|
|
64
65
|
if (statementValidates) {
|
|
65
|
-
|
|
66
|
+
context.commit(this);
|
|
66
67
|
|
|
67
68
|
validates = true;
|
|
68
69
|
}
|
|
69
70
|
}, context);
|
|
70
71
|
|
|
71
72
|
if (validates) {
|
|
72
|
-
context.debug(`...validated the '${
|
|
73
|
+
context.debug(`...validated the '${deductionString}' deduction.`);
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
return validates;
|
|
@@ -79,9 +80,9 @@ export default define(class Deduction extends Element {
|
|
|
79
80
|
let statementValidates;
|
|
80
81
|
|
|
81
82
|
const statementString = this.statement.getString(),
|
|
82
|
-
|
|
83
|
+
deductionnString = this.getString(); ///
|
|
83
84
|
|
|
84
|
-
context.trace(`Validating the '${
|
|
85
|
+
context.trace(`Validating the '${deductionnString}' deductionn's '${statementString}' statement...`);
|
|
85
86
|
|
|
86
87
|
const stated = true,
|
|
87
88
|
statement = this.statement.validate(stated, context);
|
|
@@ -91,7 +92,7 @@ export default define(class Deduction extends Element {
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
if (statementValidates) {
|
|
94
|
-
context.trace(`...validated the '${
|
|
95
|
+
context.trace(`...validated the '${deductionnString}' deductionn's '${statementString}' statement.`);
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
return statementValidates;
|
|
@@ -174,23 +175,16 @@ export default define(class Deduction extends Element {
|
|
|
174
175
|
|
|
175
176
|
context = ephemeralContext; ///
|
|
176
177
|
|
|
177
|
-
const
|
|
178
|
+
const deduction = instantiate((context) => {
|
|
178
179
|
const { string } = json,
|
|
179
180
|
deductionNode = instantiateDeduction(string, context),
|
|
180
181
|
node = deductionNode, ///
|
|
181
182
|
statement = statementFromDeductionNode(deductionNode, context),
|
|
182
|
-
|
|
183
|
+
deduction = new Deduction(context, string, node, statement);
|
|
183
184
|
|
|
184
|
-
return
|
|
185
|
+
return deduction;
|
|
185
186
|
}, context);
|
|
186
187
|
|
|
187
|
-
return
|
|
188
|
+
return deduction;
|
|
188
189
|
}
|
|
189
190
|
});
|
|
190
|
-
|
|
191
|
-
function statementFromDeductionNode(deductionNode, context) {
|
|
192
|
-
const statementNode = deductionNode.getStatementNode(),
|
|
193
|
-
statement = context.findStatementByStatementNode(statementNode);
|
|
194
|
-
|
|
195
|
-
return statement;
|
|
196
|
-
}
|
|
@@ -28,11 +28,12 @@ export default define(class Derivation extends Element {
|
|
|
28
28
|
return derivationNode;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
getLastStep() {
|
|
32
32
|
const lastSubproofOrProofAssertion = last(this.subproofOrProofAssertions),
|
|
33
|
-
lastProofAssertion = lastSubproofOrProofAssertion
|
|
33
|
+
lastProofAssertion = lastSubproofOrProofAssertion, ///
|
|
34
|
+
lastStep = lastProofAssertion; ///
|
|
34
35
|
|
|
35
|
-
return
|
|
36
|
+
return lastStep;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
async verify(context) {
|
package/src/element/equality.js
CHANGED
|
@@ -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 { equateTerms } from "../process/equate";
|
|
8
8
|
import { instantiateEquality } from "../process/instantiate";
|
|
9
9
|
import { equalityAssignmentFromEquality, leftVariableAssignmentFromEquality, rightVariableAssignmentFromEquality } from "../process/assign";
|
|
@@ -172,11 +172,19 @@ export default define(class Equality extends Element {
|
|
|
172
172
|
let leftTerm,
|
|
173
173
|
rightTerm;
|
|
174
174
|
|
|
175
|
-
leftTerm = this.leftTerm.validate(context, () => {
|
|
175
|
+
leftTerm = this.leftTerm.validate(context, (leftTerm) => {
|
|
176
176
|
let validatesForwards = false;
|
|
177
177
|
|
|
178
|
-
rightTerm = this.rightTerm.validate(context, () => {
|
|
179
|
-
|
|
178
|
+
rightTerm = this.rightTerm.validate(context, (rightTerm) => {
|
|
179
|
+
let validatesForwards = false;
|
|
180
|
+
|
|
181
|
+
const leftTermType = leftTerm.getType(),
|
|
182
|
+
rightTermType = rightTerm.getType(),
|
|
183
|
+
leftTermTypeComparableToRightTermType = leftTermType.isComparableTo(rightTermType);
|
|
184
|
+
|
|
185
|
+
if (leftTermTypeComparableToRightTermType) {
|
|
186
|
+
validatesForwards = true;
|
|
187
|
+
}
|
|
180
188
|
|
|
181
189
|
return validatesForwards;
|
|
182
190
|
});
|
|
@@ -189,17 +197,11 @@ export default define(class Equality extends Element {
|
|
|
189
197
|
});
|
|
190
198
|
|
|
191
199
|
if (leftTerm !== null) {
|
|
192
|
-
|
|
193
|
-
rightTermType = rightTerm.getType(),
|
|
194
|
-
leftTermTypeComparableToRightTermType = leftTermType.isComparableTo(rightTermType);
|
|
200
|
+
this.leftTerm = leftTerm;
|
|
195
201
|
|
|
196
|
-
|
|
197
|
-
this.leftTerm = leftTerm;
|
|
202
|
+
this.rightTerm = rightTerm;
|
|
198
203
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
termsValidate = true;
|
|
202
|
-
}
|
|
204
|
+
termsValidate = true;
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
if (termsValidate) {
|
|
@@ -278,7 +280,7 @@ export default define(class Equality extends Element {
|
|
|
278
280
|
}
|
|
279
281
|
|
|
280
282
|
static fromJSON(json, context) {
|
|
281
|
-
const equality =
|
|
283
|
+
const equality = instantiate((context) => {
|
|
282
284
|
const { string } = json,
|
|
283
285
|
equalityNode = instantiateEquality(string, context),
|
|
284
286
|
node = equalityNode, ///
|
|
@@ -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 { instantiateEquivalence } from "../process/instantiate";
|
|
9
9
|
import { stripBracketsFromTermNode } from "../utilities/brackets";
|
|
10
10
|
import { equivalenceStringFromTerms } from "../utilities/string";
|
|
@@ -232,7 +232,7 @@ export default define(class Equivalence extends Element {
|
|
|
232
232
|
const terms = equivalence.getTerms(),
|
|
233
233
|
combinedTerms = this.combineTerms(terms);
|
|
234
234
|
|
|
235
|
-
return
|
|
235
|
+
return instantiate((context) => {
|
|
236
236
|
const terms = combinedTerms, ///
|
|
237
237
|
equivalenceString = equivalenceStringFromTerms(terms),
|
|
238
238
|
string = equivalenceString, ///
|
|
@@ -246,7 +246,7 @@ export default define(class Equivalence extends Element {
|
|
|
246
246
|
static name = "Equivalence";
|
|
247
247
|
|
|
248
248
|
static fromEquality(equality, context) {
|
|
249
|
-
return
|
|
249
|
+
return instantiate((context) => {
|
|
250
250
|
const terms = equality.getTerms(),
|
|
251
251
|
equivalenceString = equivalenceStringFromTerms(terms),
|
|
252
252
|
string = equivalenceString, ///
|
package/src/element/frame.js
CHANGED
|
@@ -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 { instantiateFrame } from "../process/instantiate";
|
|
8
8
|
import { FRAME_META_TYPE_NAME } from "../metaTypeNames";
|
|
9
9
|
import { metavariableFromFrameNode } from "../utilities/element";
|
|
@@ -343,7 +343,7 @@ export default define(class Frame extends Element {
|
|
|
343
343
|
static name = "Frame";
|
|
344
344
|
|
|
345
345
|
static fromJSON(json, context) {
|
|
346
|
-
const frame =
|
|
346
|
+
const frame = instantiate((context) => {
|
|
347
347
|
const { string } = json,
|
|
348
348
|
frameNode = instantiateFrame(string, context),
|
|
349
349
|
node = frameNode, ///
|
|
@@ -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 { instantiateHypothesis } from "../process/instantiate";
|
|
8
8
|
import { statementFromHypothesisNode } from "../utilities/element";
|
|
9
9
|
|
|
@@ -100,7 +100,7 @@ export default define(class Hypothesis extends Element {
|
|
|
100
100
|
static name = "Hypothesis";
|
|
101
101
|
|
|
102
102
|
static fromJSON(json, context) {
|
|
103
|
-
const hypothesis =
|
|
103
|
+
const hypothesis = instantiate((context) => {
|
|
104
104
|
const { string } = json,
|
|
105
105
|
hypothesisNode = instantiateHypothesis(string, context),
|
|
106
106
|
node = hypothesisNode, ///
|
package/src/element/judgement.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 { instantiateJudgement } from "../process/instantiate";
|
|
10
10
|
import { judgementAssignmentFromJudgement } from "../process/assign";
|
|
11
11
|
|
|
@@ -218,7 +218,7 @@ export default define(class Judgement extends Element {
|
|
|
218
218
|
static name = "Judgement";
|
|
219
219
|
|
|
220
220
|
static fromJSON(json, context) {
|
|
221
|
-
const judgement =
|
|
221
|
+
const judgement = instantiate((context) => {
|
|
222
222
|
const { string } = json,
|
|
223
223
|
judgementNode = instantiateJudgement(string, context),
|
|
224
224
|
node = judgementNode, ///
|
package/src/element/label.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Element } from "occam-languages";
|
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
import { instantiateLabel } from "../process/instantiate";
|
|
7
|
-
import { attempt,
|
|
7
|
+
import { attempt, instantiate } from "../utilities/context";
|
|
8
8
|
import { metavariableFromLabelNode } from "../utilities/element";
|
|
9
9
|
import { ephemeralContextFromJSON, ephemeralContextToEphemeralContextJSON } from "../utilities/json";
|
|
10
10
|
|
|
@@ -90,7 +90,7 @@ export default define(class Label extends Element {
|
|
|
90
90
|
const metavariableValidates = this.validateMetavariable(context);
|
|
91
91
|
|
|
92
92
|
if (metavariableValidates) {
|
|
93
|
-
|
|
93
|
+
context.commit(this);
|
|
94
94
|
|
|
95
95
|
validates = true;
|
|
96
96
|
}
|
|
@@ -109,7 +109,7 @@ export default define(class Label extends Element {
|
|
|
109
109
|
const labelString = this.getString(), ///
|
|
110
110
|
metavariableString = this.metavariable.getString();
|
|
111
111
|
|
|
112
|
-
context.trace(`Validating the '${labelString}' label's '${metavariableString}' metavariable
|
|
112
|
+
context.trace(`Validating the '${labelString}' label's '${metavariableString}' metavariable...`);
|
|
113
113
|
|
|
114
114
|
const metavariable = this.metavariable.validate(context);
|
|
115
115
|
|
|
@@ -153,7 +153,7 @@ export default define(class Label extends Element {
|
|
|
153
153
|
|
|
154
154
|
context = ephemeralContext; ///
|
|
155
155
|
|
|
156
|
-
const label =
|
|
156
|
+
const label = instantiate((context) => {
|
|
157
157
|
const { string } = json,
|
|
158
158
|
labelNode = instantiateLabel(string, context),
|
|
159
159
|
metavariable = metavariableFromLabelNode(labelNode, context),
|
|
@@ -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 { EMPTY_STRING } from "../constants";
|
|
10
10
|
import { instantiateMetavariable } from "../process/instantiate";
|
|
11
11
|
import { metaTypeFromJSON, metaTypeToMetaTypeJSON } from "../utilities/json";
|
|
@@ -130,10 +130,12 @@ export default define(class Metavariable extends Element {
|
|
|
130
130
|
context.trace(`Verifying the '${metavariableString}' metavariable's '${typeString}' type...`);
|
|
131
131
|
|
|
132
132
|
const typeName = this.type.getName(),
|
|
133
|
-
|
|
133
|
+
type = context.findTypeByTypeName(typeName);
|
|
134
134
|
|
|
135
|
-
if (
|
|
136
|
-
|
|
135
|
+
if (type !== null) {
|
|
136
|
+
this.type = type;
|
|
137
|
+
|
|
138
|
+
typeVerifies = true;
|
|
137
139
|
|
|
138
140
|
context.error(`Type '${typeName}' is not present.`);
|
|
139
141
|
}
|
|
@@ -155,25 +157,17 @@ export default define(class Metavariable extends Element {
|
|
|
155
157
|
|
|
156
158
|
let validates = false;
|
|
157
159
|
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
if (termValidates) {
|
|
161
|
-
const typeValidates = this.validateType(context);
|
|
162
|
-
|
|
163
|
-
if (typeValidates) {
|
|
164
|
-
let metavariable;
|
|
165
|
-
|
|
166
|
-
metavariable = this; ///
|
|
160
|
+
const typeValidates = this.validateType(context);
|
|
167
161
|
|
|
168
|
-
|
|
162
|
+
if (typeValidates) {
|
|
163
|
+
const termValidates = this.validateTerm(context);
|
|
169
164
|
|
|
170
|
-
|
|
171
|
-
|
|
165
|
+
if (termValidates) {
|
|
166
|
+
const nameValidates = this.validateName(context);
|
|
172
167
|
|
|
173
|
-
|
|
168
|
+
if (nameValidates) {
|
|
169
|
+
validates = true;
|
|
174
170
|
}
|
|
175
|
-
|
|
176
|
-
validates = true;
|
|
177
171
|
}
|
|
178
172
|
}
|
|
179
173
|
|
|
@@ -187,19 +181,43 @@ export default define(class Metavariable extends Element {
|
|
|
187
181
|
}
|
|
188
182
|
|
|
189
183
|
validateTerm(context) {
|
|
190
|
-
let termValidates = true;
|
|
184
|
+
let termValidates = true; ///
|
|
191
185
|
|
|
192
186
|
if (this.term !== null) {
|
|
187
|
+
termValidates = false;
|
|
188
|
+
|
|
193
189
|
const termString = this.term.getString(),
|
|
194
190
|
metavariableString = this.getString();
|
|
195
191
|
|
|
196
192
|
context.trace(`Validating the '${metavariableString}' metavariable's '${termString}' term...`);
|
|
197
193
|
|
|
198
|
-
|
|
199
|
-
|
|
194
|
+
const metavariableName = this.getMetavariableName(),
|
|
195
|
+
metavariable = context.findMetavariableByMetavariableName(metavariableName);
|
|
196
|
+
|
|
197
|
+
let term = null;
|
|
198
|
+
|
|
199
|
+
if (metavariable !== null) {
|
|
200
|
+
const type = metavariable.getType(),
|
|
201
|
+
metavariableString = metavariable.getString();
|
|
202
|
+
|
|
203
|
+
if (type !== null) {
|
|
204
|
+
term = this.term.validateGivenType(type, context);
|
|
205
|
+
} else {
|
|
206
|
+
context.trace(`The '${metavariableString}' metavariable does not have a type`);
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
term = this.term.validate(context, (term) => {
|
|
210
|
+
const validatesForwards = true;
|
|
211
|
+
|
|
212
|
+
return validatesForwards;
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (term !== null) {
|
|
217
|
+
this.term = term;
|
|
200
218
|
|
|
201
|
-
|
|
202
|
-
}
|
|
219
|
+
termValidates = true;
|
|
220
|
+
}
|
|
203
221
|
|
|
204
222
|
if (termValidates) {
|
|
205
223
|
context.debug(`...validated the '${metavariableString}' metavariable's '${termString}' term.`);
|
|
@@ -209,18 +227,51 @@ export default define(class Metavariable extends Element {
|
|
|
209
227
|
return termValidates;
|
|
210
228
|
}
|
|
211
229
|
|
|
230
|
+
validateName(context) {
|
|
231
|
+
let termValidates = true; ///
|
|
232
|
+
|
|
233
|
+
const metavariableName = this.getMetavariableName(), ///
|
|
234
|
+
metavariableString = this.getString(); ///
|
|
235
|
+
|
|
236
|
+
context.trace(`Validating the '${metavariableString}' metavariable's '${metavariableName}' name...`);
|
|
237
|
+
|
|
238
|
+
const metavariable = context.findMetavariableByMetavariableName(metavariableName);
|
|
239
|
+
|
|
240
|
+
if (metavariable !== null) {
|
|
241
|
+
const metaType = metavariable.getMetaType(),
|
|
242
|
+
metaTypeSTring = metaType.getString();
|
|
243
|
+
|
|
244
|
+
this.metaType = metaType;
|
|
245
|
+
|
|
246
|
+
context.trace(`Setting the '${metavariableString}' metavariable's meta-type to the '${metaTypeSTring}' meta-type.`);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (termValidates) {
|
|
250
|
+
context.debug(`...validated the '${metavariableString}' metavariable's '${metavariableName}' name.`);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return termValidates;
|
|
254
|
+
}
|
|
255
|
+
|
|
212
256
|
validateType(context) {
|
|
213
|
-
let typeValidates =
|
|
257
|
+
let typeValidates = false;
|
|
214
258
|
|
|
215
|
-
|
|
216
|
-
const typeString = this.type.getString(),
|
|
217
|
-
metavariableString = this.getString();
|
|
259
|
+
const metavariableString = this.getString(); ///
|
|
218
260
|
|
|
219
|
-
|
|
261
|
+
context.trace(`Validating the '${metavariableString}' metavariable's type...`);
|
|
262
|
+
|
|
263
|
+
if (this.type === null) {
|
|
264
|
+
typeValidates = true;
|
|
265
|
+
} else {
|
|
266
|
+
const typeString = this.type.getString();
|
|
220
267
|
|
|
221
268
|
context.trace(`A '${typeString}' type is present in the '${metavariableString}' metavariable.`);
|
|
222
269
|
}
|
|
223
270
|
|
|
271
|
+
if (typeValidates) {
|
|
272
|
+
context.trace(`...validated the '${metavariableString}' metavariable's type.`);
|
|
273
|
+
}
|
|
274
|
+
|
|
224
275
|
return typeValidates;
|
|
225
276
|
}
|
|
226
277
|
|
|
@@ -246,6 +297,11 @@ export default define(class Metavariable extends Element {
|
|
|
246
297
|
substitutionFrameComparesToFrame = substitution.compareFrame(frame, context);
|
|
247
298
|
|
|
248
299
|
if (substitutionFrameComparesToFrame) {
|
|
300
|
+
const frameSubstitution = substitution, ///
|
|
301
|
+
frameSubstitutionString = frameSubstitution.getString();
|
|
302
|
+
|
|
303
|
+
context.trace(`The '${frameSubstitutionString}' frame substitution is already present.`);
|
|
304
|
+
|
|
249
305
|
frameUnifies = true;
|
|
250
306
|
}
|
|
251
307
|
} else {
|
|
@@ -282,8 +338,6 @@ export default define(class Metavariable extends Element {
|
|
|
282
338
|
substitution.getString() :
|
|
283
339
|
EMPTY_STRING;
|
|
284
340
|
|
|
285
|
-
|
|
286
|
-
|
|
287
341
|
context.trace(`Unifying the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable...`);
|
|
288
342
|
|
|
289
343
|
const metavariable = this, ///
|
|
@@ -305,6 +359,11 @@ export default define(class Metavariable extends Element {
|
|
|
305
359
|
const substitutionComparesToStatement = substitution.compareStatement(statement, context);
|
|
306
360
|
|
|
307
361
|
if (substitutionComparesToStatement) {
|
|
362
|
+
const statementSubstitution = substitution, //
|
|
363
|
+
statementSubstitutionString = statementSubstitution.getString();
|
|
364
|
+
|
|
365
|
+
context.trace(`The '${statementSubstitutionString}' statement substitution is already present.`);
|
|
366
|
+
|
|
308
367
|
statementUnifies = true;
|
|
309
368
|
}
|
|
310
369
|
} else {
|
|
@@ -362,6 +421,11 @@ export default define(class Metavariable extends Element {
|
|
|
362
421
|
substitutionReferenceComparesToReference = substitution.compareReference(reference, context);
|
|
363
422
|
|
|
364
423
|
if (substitutionReferenceComparesToReference) {
|
|
424
|
+
const referenceSubstitution = substitution, ///
|
|
425
|
+
referenceSubstitutionString = referenceSubstitution.getString();
|
|
426
|
+
|
|
427
|
+
context.trace(`The '${referenceSubstitutionString}' reference substitution is already present.`);
|
|
428
|
+
|
|
365
429
|
referenceUnifies = true;
|
|
366
430
|
}
|
|
367
431
|
} else {
|
|
@@ -545,7 +609,7 @@ export default define(class Metavariable extends Element {
|
|
|
545
609
|
static name = "Metavariable";
|
|
546
610
|
|
|
547
611
|
static fromJSON(json, context) {
|
|
548
|
-
const metavariable =
|
|
612
|
+
const metavariable = instantiate((context) => {
|
|
549
613
|
const { string } = json,
|
|
550
614
|
metavariableNode = instantiateMetavariable(string, context),
|
|
551
615
|
node = metavariableNode, ///
|
package/src/element/parameter.js
CHANGED
|
@@ -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 { instantiateParameter } from "../process/instantiate";
|
|
8
8
|
import { nameFromParaneterNode, identifierFromParameterNode } from "../utilities/element";
|
|
9
9
|
|
|
@@ -61,7 +61,7 @@ export default define(class Parameter extends Element {
|
|
|
61
61
|
static name = "Parameter";
|
|
62
62
|
|
|
63
63
|
static fromJSON(json, context) {
|
|
64
|
-
const parameter =
|
|
64
|
+
const parameter = instantiate((context) => {
|
|
65
65
|
const { string } = json,
|
|
66
66
|
parameterNode = instantiateParameter(string, context),
|
|
67
67
|
node = parameterNode, ///
|