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
|
@@ -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 { instantiateCombinator } from "../process/instantiate";
|
|
8
8
|
import { statementFromCombinatorNode } from "../utilities/element";
|
|
9
9
|
import { unifyStatementWithCombinator } from "../process/unify";
|
|
@@ -21,7 +21,7 @@ export default define(class Combinator extends Element {
|
|
|
21
21
|
return this.statement;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
getCombinatoryNode() {
|
|
25
25
|
const node = this.getNode(),
|
|
26
26
|
combinatorNode = node; ///
|
|
27
27
|
|
|
@@ -39,7 +39,7 @@ export default define(class Combinator extends Element {
|
|
|
39
39
|
const statementValidates = this.validateStatement(context);
|
|
40
40
|
|
|
41
41
|
if (statementValidates) {
|
|
42
|
-
|
|
42
|
+
context.commit(this);
|
|
43
43
|
|
|
44
44
|
validates = true;
|
|
45
45
|
}
|
|
@@ -128,7 +128,7 @@ export default define(class Combinator extends Element {
|
|
|
128
128
|
|
|
129
129
|
context = ephemeralContext; ///
|
|
130
130
|
|
|
131
|
-
const combinator =
|
|
131
|
+
const combinator = instantiate((context) => {
|
|
132
132
|
const { string } = json,
|
|
133
133
|
combinatorNode = instantiateCombinator(string, context),
|
|
134
134
|
node = combinatorNode, ///
|
|
@@ -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, ///
|
|
@@ -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,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 { instantiateDeduction } from "../process/instantiate";
|
|
8
8
|
import { ephemeralContextFromJSON, ephemeralContextToEphemeralContextJSON } from "../utilities/json";
|
|
9
9
|
|
|
@@ -62,7 +62,7 @@ export default define(class Deduction extends Element {
|
|
|
62
62
|
const statementValidates = this.validateStatement(context);
|
|
63
63
|
|
|
64
64
|
if (statementValidates) {
|
|
65
|
-
|
|
65
|
+
context.commit(this);
|
|
66
66
|
|
|
67
67
|
validates = true;
|
|
68
68
|
}
|
|
@@ -174,7 +174,7 @@ export default define(class Deduction extends Element {
|
|
|
174
174
|
|
|
175
175
|
context = ephemeralContext; ///
|
|
176
176
|
|
|
177
|
-
const duduction =
|
|
177
|
+
const duduction = instantiate((context) => {
|
|
178
178
|
const { string } = json,
|
|
179
179
|
deductionNode = instantiateDeduction(string, context),
|
|
180
180
|
node = deductionNode, ///
|
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;
|
|
200
198
|
|
|
201
|
-
|
|
202
|
-
|
|
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;
|
|
218
|
+
|
|
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
|
-
|
|
217
|
-
|
|
259
|
+
const metavariableString = this.getString(); ///
|
|
260
|
+
|
|
261
|
+
context.trace(`Validating the '${metavariableString}' metavariable's type...`);
|
|
218
262
|
|
|
219
|
-
|
|
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
|
|
|
@@ -545,7 +596,7 @@ export default define(class Metavariable extends Element {
|
|
|
545
596
|
static name = "Metavariable";
|
|
546
597
|
|
|
547
598
|
static fromJSON(json, context) {
|
|
548
|
-
const metavariable =
|
|
599
|
+
const metavariable = instantiate((context) => {
|
|
549
600
|
const { string } = json,
|
|
550
601
|
metavariableNode = instantiateMetavariable(string, context),
|
|
551
602
|
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, ///
|
|
@@ -4,7 +4,7 @@ import { Element } from "occam-languages";
|
|
|
4
4
|
import { termsUtilities } from "occam-furtle";
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
|
-
import {
|
|
7
|
+
import { instantiate } from "../utilities/context";
|
|
8
8
|
import { instantiateProcedureCall } from "../process/instantiate";
|
|
9
9
|
import { parametersFromProcedureCallNode, procedureReferenceFromProcedureCallNode } from "../utilities/element";
|
|
10
10
|
|
|
@@ -125,7 +125,7 @@ export default define(class ProcedureCall extends Element {
|
|
|
125
125
|
static name = "ProcedureCall";
|
|
126
126
|
|
|
127
127
|
static fromJSON(json, context) {
|
|
128
|
-
const procedureCall =
|
|
128
|
+
const procedureCall = instantiate((context) => {
|
|
129
129
|
const { string } = json,
|
|
130
130
|
procedureCallNode = instantiateProcedureCall(string, context),
|
|
131
131
|
node = procedureCallNode, ///
|
|
@@ -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 { instantiateProcedureReference } from "../process/instantiate";
|
|
8
8
|
import { nameFromProcedureReferenceNode } from "../utilities/element";
|
|
9
9
|
|
|
@@ -43,7 +43,7 @@ export default define(class ProcedureReference extends Element {
|
|
|
43
43
|
static name = "ProcedureReference";
|
|
44
44
|
|
|
45
45
|
static fromJSON(json, context) {
|
|
46
|
-
const procedureReference =
|
|
46
|
+
const procedureReference = instantiate((context) => {
|
|
47
47
|
const { string } = json,
|
|
48
48
|
procedureReferenceNode = instantiateProcedureReference(string, context),
|
|
49
49
|
node = procedureReferenceNode, ///
|
package/src/element/proof.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 { asyncRestrict } from "../utilities/context";
|
|
7
7
|
|
|
8
8
|
export default define(class Proof extends Element {
|
|
9
9
|
constructor(context, string, node, derivation) {
|
|
@@ -36,7 +36,7 @@ export default define(class Proof extends Element {
|
|
|
36
36
|
async verify(statement, context) {
|
|
37
37
|
let verifies = false;
|
|
38
38
|
|
|
39
|
-
await
|
|
39
|
+
await asyncRestrict(async (context) => {
|
|
40
40
|
const derivationVerifies = await this.derivation.verify(context);
|
|
41
41
|
|
|
42
42
|
if (derivationVerifies) {
|
|
@@ -5,7 +5,7 @@ import ProofAssertion from "../proofAssertion";
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
6
|
import { instantiatePremise } from "../../process/instantiate";
|
|
7
7
|
import { procedureCallFromPremiseNode } from "../../utilities/element";
|
|
8
|
-
import { attempt,
|
|
8
|
+
import { attempt, reconcile, instantiate } from "../../utilities/context";
|
|
9
9
|
import { ephemeralContextFromJSON, ephemeralContextToEphemeralContextJSON } from "../../utilities/json";
|
|
10
10
|
|
|
11
11
|
export default define(class Premise extends ProofAssertion {
|
|
@@ -72,7 +72,7 @@ export default define(class Premise extends ProofAssertion {
|
|
|
72
72
|
const statementValidates = this.validateStatement(context);
|
|
73
73
|
|
|
74
74
|
if (statementValidates) {
|
|
75
|
-
|
|
75
|
+
context.commit(this);
|
|
76
76
|
|
|
77
77
|
validates = true;
|
|
78
78
|
}
|
|
@@ -82,7 +82,7 @@ export default define(class Premise extends ProofAssertion {
|
|
|
82
82
|
const procedureCallValidates = this.validateProcedureCall(context);
|
|
83
83
|
|
|
84
84
|
if (procedureCallValidates) {
|
|
85
|
-
|
|
85
|
+
context.commit(this);
|
|
86
86
|
|
|
87
87
|
validates = true;
|
|
88
88
|
}
|
|
@@ -168,7 +168,7 @@ export default define(class Premise extends ProofAssertion {
|
|
|
168
168
|
premiseContext = this.getContext(), ///
|
|
169
169
|
generalContext = premiseContext, ///
|
|
170
170
|
specificContext = proofAssertionContext,
|
|
171
|
-
statementUnifies =
|
|
171
|
+
statementUnifies = reconcile((specificContext) => {
|
|
172
172
|
const statement = proofAssertion.getStatement(),
|
|
173
173
|
statementUnifies = this.unifyStatement(statement, generalContext, specificContext);
|
|
174
174
|
|
|
@@ -300,7 +300,7 @@ export default define(class Premise extends ProofAssertion {
|
|
|
300
300
|
|
|
301
301
|
context = ephemeralContext; ///
|
|
302
302
|
|
|
303
|
-
const premise =
|
|
303
|
+
const premise = instantiate((context) => {
|
|
304
304
|
const { string } = json,
|
|
305
305
|
premiseNode = instantiatePremise(string, context),
|
|
306
306
|
node = premiseNode, ///
|