occam-verify-cli 1.0.768 → 1.0.781
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/context/file/nominal.js +11 -11
- package/lib/context/illative.js +28 -0
- package/lib/context/nested.js +31 -0
- package/lib/context/proof.js +242 -0
- package/lib/context/thetic.js +28 -0
- package/lib/context.js +19 -21
- package/lib/element/assertion/contained.js +32 -24
- package/lib/element/assertion/defined.js +47 -40
- package/lib/element/assertion/property.js +18 -13
- package/lib/element/assertion/satisfies.js +12 -9
- package/lib/element/assertion/subproof.js +28 -26
- package/lib/element/assertion/type.js +14 -12
- package/lib/element/assumption.js +40 -50
- package/lib/element/combinator/bracketed.js +3 -3
- package/lib/element/combinator.js +20 -20
- package/lib/element/conclusion.js +33 -29
- package/lib/element/constructor.js +19 -18
- package/lib/element/deduction.js +33 -29
- package/lib/element/equality.js +13 -15
- package/lib/element/equivalence.js +59 -52
- package/lib/element/equivalences.js +4 -2
- package/lib/element/frame.js +74 -53
- package/lib/element/hypothesis.js +7 -5
- package/lib/element/judgement.js +41 -74
- package/lib/element/label.js +22 -22
- package/lib/element/metavariable.js +31 -11
- package/lib/element/proofAssertion/premise.js +48 -35
- package/lib/element/proofAssertion/step.js +77 -22
- package/lib/element/proofAssertion/supposition.js +48 -34
- package/lib/element/proofAssertion.js +1 -14
- package/lib/element/reference.js +80 -53
- package/lib/element/signature.js +44 -3
- package/lib/element/statement.js +28 -29
- package/lib/element/subproof.js +2 -2
- package/lib/element/substitution/frame.js +24 -19
- package/lib/element/substitution/metaLevel.js +31 -27
- package/lib/element/substitution/reference.js +11 -10
- package/lib/element/substitution/statement.js +30 -23
- package/lib/element/substitution/term.js +11 -10
- package/lib/element/term.js +24 -20
- package/lib/element/topLevelMetaAssertion.js +2 -2
- package/lib/element/variable.js +6 -2
- package/lib/process/assign.js +10 -4
- package/lib/process/unify.js +8 -8
- package/lib/process/validate.js +10 -8
- package/lib/utilities/context.js +68 -23
- package/lib/utilities/element.js +55 -27
- package/lib/utilities/json.js +8 -8
- package/lib/utilities/string.js +12 -1
- package/lib/utilities/unification.js +14 -12
- package/lib/utilities/validation.js +55 -40
- package/package.json +4 -4
- package/src/context/file/nominal.js +14 -16
- package/src/context/illative.js +17 -0
- package/src/context/nested.js +21 -0
- package/src/context/{scoped.js → proof.js} +65 -51
- package/src/context/thetic.js +17 -0
- package/src/context.js +30 -36
- package/src/element/assertion/contained.js +44 -31
- package/src/element/assertion/defined.js +55 -46
- package/src/element/assertion/property.js +23 -15
- package/src/element/assertion/satisfies.js +15 -10
- package/src/element/assertion/subproof.js +34 -31
- package/src/element/assertion/type.js +18 -13
- package/src/element/assumption.js +40 -69
- package/src/element/combinator/bracketed.js +2 -2
- package/src/element/combinator.js +23 -29
- package/src/element/conclusion.js +37 -40
- package/src/element/constructor.js +29 -34
- package/src/element/deduction.js +36 -39
- package/src/element/equality.js +16 -18
- package/src/element/equivalence.js +76 -67
- package/src/element/equivalences.js +5 -2
- package/src/element/frame.js +96 -65
- package/src/element/hypothesis.js +7 -6
- package/src/element/judgement.js +45 -45
- package/src/element/label.js +25 -31
- package/src/element/metavariable.js +48 -21
- package/src/element/proofAssertion/premise.js +63 -49
- package/src/element/proofAssertion/step.js +47 -26
- package/src/element/proofAssertion/supposition.js +64 -50
- package/src/element/proofAssertion.js +0 -22
- package/src/element/reference.js +119 -80
- package/src/element/signature.js +5 -2
- package/src/element/statement.js +30 -35
- package/src/element/subproof.js +1 -1
- package/src/element/substitution/frame.js +27 -26
- package/src/element/substitution/metaLevel.js +38 -42
- package/src/element/substitution/reference.js +13 -14
- package/src/element/substitution/statement.js +35 -33
- package/src/element/substitution/term.js +13 -14
- package/src/element/term.js +42 -34
- package/src/element/topLevelMetaAssertion.js +1 -1
- package/src/element/variable.js +8 -1
- package/src/process/assign.js +9 -3
- package/src/process/unify.js +7 -7
- package/src/process/validate.js +9 -8
- package/src/utilities/context.js +82 -31
- package/src/utilities/element.js +68 -31
- package/src/utilities/json.js +13 -13
- package/src/utilities/string.js +16 -2
- package/src/utilities/unification.js +18 -16
- package/src/utilities/validation.js +73 -53
- package/lib/context/scoped.js +0 -232
- package/lib/utilities/statement.js +0 -78
- package/lib/utilities/term.js +0 -17
- package/src/utilities/statement.js +0 -74
- package/src/utilities/term.js +0 -10
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
+
import { descend, instantiate } from "../utilities/context";
|
|
6
7
|
import { instantiateAssumption } from "../process/instantiate";
|
|
7
|
-
import { instantiate, reconcile } from "../utilities/context";
|
|
8
8
|
|
|
9
9
|
export default define(class Assumption extends Element {
|
|
10
10
|
constructor(context, string, node, reference, statement) {
|
|
@@ -31,6 +31,8 @@ export default define(class Assumption extends Element {
|
|
|
31
31
|
|
|
32
32
|
getMetavariable() { return this.reference.getMetavariable(); }
|
|
33
33
|
|
|
34
|
+
getTopLevelMetaAssertion() { return this.reference.getTopLevelMetaAssertion(); }
|
|
35
|
+
|
|
34
36
|
matchAssumptionNode(assumptionNode) {
|
|
35
37
|
const node = assumptionNode, ///
|
|
36
38
|
nodeMatches = this.matchNode(node),
|
|
@@ -39,28 +41,21 @@ export default define(class Assumption extends Element {
|
|
|
39
41
|
return assumptionNodeMatches;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
let
|
|
44
|
+
compareMetaLevelSubstitution(metaLevelSubstitution, context) {
|
|
45
|
+
let comparesToMetaLevelSubstitution = false;
|
|
44
46
|
|
|
45
47
|
const assumptionString = this.getString(), ///
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
context.trace(`Comparing the '${assumptionString}' assumption to the '${substitutionString}' substitution...`);
|
|
48
|
+
metaLevelSubstitutionString = metaLevelSubstitution.getString();
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
metavariableName = substitution.getMetavariableName(),
|
|
52
|
-
statementEqualToStatement = this.statement.isEqualTo(statement),
|
|
53
|
-
referenceMetavariableComparesToMetavariable = this.reference.compareMetavariableName(metavariableName);
|
|
50
|
+
context.trace(`Comparing the '${assumptionString}' assumption to the '${metaLevelSubstitutionString}' meta-level substitution...`);
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
comparesToSubstituion = true;
|
|
57
|
-
}
|
|
52
|
+
debugger
|
|
58
53
|
|
|
59
|
-
if (
|
|
60
|
-
context.debug(`...compared the '${
|
|
54
|
+
if (comparesToMetaLevelSubstitution) {
|
|
55
|
+
context.debug(`...compared the '${assumptionString}' assumption to the '${metaLevelSubstitutionString}' meta-level substitution.`);
|
|
61
56
|
}
|
|
62
57
|
|
|
63
|
-
return
|
|
58
|
+
return comparesToMetaLevelSubstitution;
|
|
64
59
|
}
|
|
65
60
|
|
|
66
61
|
findValidAssumption(context) {
|
|
@@ -71,7 +66,7 @@ export default define(class Assumption extends Element {
|
|
|
71
66
|
return validAssumption;
|
|
72
67
|
}
|
|
73
68
|
|
|
74
|
-
validate(
|
|
69
|
+
validate(context) {
|
|
75
70
|
let assumption = null;
|
|
76
71
|
|
|
77
72
|
const assumptionString = this.getString(); ///
|
|
@@ -87,12 +82,14 @@ export default define(class Assumption extends Element {
|
|
|
87
82
|
} else {
|
|
88
83
|
let validates = false;
|
|
89
84
|
|
|
90
|
-
const statementValidates = this.validateStatement(
|
|
85
|
+
const statementValidates = this.validateStatement(context);
|
|
91
86
|
|
|
92
87
|
if (statementValidates) {
|
|
93
|
-
const referenceValidates = this.validateReference(
|
|
88
|
+
const referenceValidates = this.validateReference(context);
|
|
94
89
|
|
|
95
90
|
if (referenceValidates) {
|
|
91
|
+
const stated = context.isStated();
|
|
92
|
+
|
|
96
93
|
let validatesWhenStated = false,
|
|
97
94
|
validatesWhenDerived = false;
|
|
98
95
|
|
|
@@ -120,11 +117,11 @@ export default define(class Assumption extends Element {
|
|
|
120
117
|
return assumption;
|
|
121
118
|
}
|
|
122
119
|
|
|
123
|
-
validateReference(
|
|
120
|
+
validateReference(context) {
|
|
124
121
|
let referenceValidates = false;
|
|
125
122
|
|
|
126
|
-
const
|
|
127
|
-
|
|
123
|
+
const referenceString = this.reference.getString(),
|
|
124
|
+
assumptionString = this.getString(); ///
|
|
128
125
|
|
|
129
126
|
context.trace(`Validating the '${assumptionString}' assumption's '${referenceString}' reference...`);
|
|
130
127
|
|
|
@@ -137,7 +134,7 @@ export default define(class Assumption extends Element {
|
|
|
137
134
|
if (metavariablePresent) {
|
|
138
135
|
referenceValidates = true;
|
|
139
136
|
} else {
|
|
140
|
-
const topLevelMetaAssertions = context.findTopLevelMetaAssertionsByReference(this.reference
|
|
137
|
+
const topLevelMetaAssertions = context.findTopLevelMetaAssertionsByReference(this.reference),
|
|
141
138
|
topLevelMetaAssertionsCompare = topLevelMetaAssertions.some((topLevelMetaAssertion) => {
|
|
142
139
|
const topLevelMetaAssertionUnifies = this.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
|
|
143
140
|
|
|
@@ -153,13 +150,13 @@ export default define(class Assumption extends Element {
|
|
|
153
150
|
}
|
|
154
151
|
|
|
155
152
|
if (referenceValidates) {
|
|
156
|
-
context.debug(`...validated the '${assumptionString}' assumption's '${referenceString}'
|
|
153
|
+
context.debug(`...validated the '${assumptionString}' assumption's '${referenceString}' reference.`);
|
|
157
154
|
}
|
|
158
155
|
|
|
159
156
|
return referenceValidates;
|
|
160
157
|
}
|
|
161
158
|
|
|
162
|
-
validateStatement(
|
|
159
|
+
validateStatement(context) {
|
|
163
160
|
let statementValidates = false;
|
|
164
161
|
|
|
165
162
|
const assumptionString = this.getString(), ///
|
|
@@ -167,13 +164,13 @@ export default define(class Assumption extends Element {
|
|
|
167
164
|
|
|
168
165
|
context.trace(`Validating the '${assumptionString}' assumption's '${statementString}' statement...`);
|
|
169
166
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const statement = this.statement.validate(stated, context);
|
|
167
|
+
descend((context) => {
|
|
168
|
+
const statement = this.statement.validate(context);
|
|
173
169
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
if (statement !== null) {
|
|
171
|
+
statementValidates = true;
|
|
172
|
+
}
|
|
173
|
+
}, context);
|
|
177
174
|
|
|
178
175
|
if (statementValidates) {
|
|
179
176
|
context.debug(`...validated the '${assumptionString}' assumption's '${statementString}' statement.`);
|
|
@@ -199,13 +196,18 @@ export default define(class Assumption extends Element {
|
|
|
199
196
|
}
|
|
200
197
|
|
|
201
198
|
validateWhenDerived(context) {
|
|
202
|
-
let validatesWhenDerived;
|
|
199
|
+
let validatesWhenDerived = false;
|
|
203
200
|
|
|
204
201
|
const assumptionString = this.getString(); ///
|
|
205
202
|
|
|
206
203
|
context.trace(`Validating the '${assumptionString}' derived assumption...`);
|
|
204
|
+
const topLevelMetaAssertion = this.getTopLevelMetaAssertion();
|
|
207
205
|
|
|
208
|
-
|
|
206
|
+
if (topLevelMetaAssertion !== null) {
|
|
207
|
+
validatesWhenDerived = true;
|
|
208
|
+
} else {
|
|
209
|
+
context.debug(`The '${assumptionString}' asumption did not unify a top level meta-assumption.`);
|
|
210
|
+
}
|
|
209
211
|
|
|
210
212
|
if (validatesWhenDerived) {
|
|
211
213
|
context.debug(`...validated the '${assumptionString}' derived assumption.`);
|
|
@@ -214,50 +216,19 @@ export default define(class Assumption extends Element {
|
|
|
214
216
|
return validatesWhenDerived;
|
|
215
217
|
}
|
|
216
218
|
|
|
217
|
-
unifyLabel(label, generalContext, specificContext) {
|
|
218
|
-
let labelUnifiesWithReference;
|
|
219
|
-
|
|
220
|
-
const context = generalContext, ///
|
|
221
|
-
labelString = label.getString(),
|
|
222
|
-
assumptionString = this.getString(); //;/
|
|
223
|
-
|
|
224
|
-
context.trace(`Unifying the '${labelString}' label with the '${assumptionString}' assumption...`);
|
|
225
|
-
|
|
226
|
-
const labelUnifies = this.reference.unifyLabel(label, context);
|
|
227
|
-
|
|
228
|
-
labelUnifiesWithReference = labelUnifies; ///
|
|
229
|
-
|
|
230
|
-
if (labelUnifiesWithReference) {
|
|
231
|
-
context.debug(`...unified the '${labelString}' label with the '${assumptionString}' assumption.`);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return labelUnifiesWithReference;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
219
|
unifyTopLevelMetaAssertion(topLevelMetaAssertion, context) {
|
|
238
|
-
let topLevelMetaAssertionUnifies
|
|
220
|
+
let topLevelMetaAssertionUnifies;
|
|
239
221
|
|
|
240
222
|
const assumptionString = this.getString(), ///
|
|
241
223
|
topLevelMetaAssertionString = topLevelMetaAssertion.getString();
|
|
242
224
|
|
|
243
225
|
context.trace(`Unifying the '${topLevelMetaAssertionString}' top level meta-assertion with the '${assumptionString}' assumption...`);
|
|
244
226
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
context = topLevelMetaAssertion.getContext(); ///
|
|
227
|
+
topLevelMetaAssertionUnifies = this.reference.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
|
|
248
228
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
const label = topLevelMetaAssertion.getLabel(),
|
|
253
|
-
labelUnifies = this.unifyLabel(label, generalContext, specificContext);
|
|
254
|
-
|
|
255
|
-
if (labelUnifies) {
|
|
256
|
-
topLevelMetaAssertionUnifies = this.statement.unifyTopLevelMetaAssertion(topLevelMetaAssertion, generalContext, specificContext);
|
|
257
|
-
|
|
258
|
-
specificContext.commit(context);
|
|
259
|
-
}
|
|
260
|
-
}, specificContext);
|
|
229
|
+
if (topLevelMetaAssertionUnifies) {
|
|
230
|
+
topLevelMetaAssertionUnifies = this.statement.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
|
|
231
|
+
}
|
|
261
232
|
|
|
262
233
|
if (topLevelMetaAssertionUnifies) {
|
|
263
234
|
context.trace(`...unified the '${topLevelMetaAssertionString}' top level meta-assertion with the '${assumptionString}' assumption...`);
|
|
@@ -12,14 +12,14 @@ export default define(class BracketedCombinator extends Combinator {
|
|
|
12
12
|
return bracketedCombinatorNode;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
unifyStatement(statement,
|
|
15
|
+
unifyStatement(statement, context) {
|
|
16
16
|
let statementUnifies;
|
|
17
17
|
|
|
18
18
|
const statementString = statement.getString();
|
|
19
19
|
|
|
20
20
|
context.trace(`Unifying the '${statementString}' statement with the bracketed combinator...`);
|
|
21
21
|
|
|
22
|
-
statementUnifies = super.unifyStatement(statement,
|
|
22
|
+
statementUnifies = super.unifyStatement(statement, context);
|
|
23
23
|
|
|
24
24
|
if (statementUnifies) {
|
|
25
25
|
context.debug(`...unified the '${statementString}' statement with the bracketed combinator.`);
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import { attempt, instantiate } from "../utilities/context";
|
|
7
6
|
import { instantiateCombinator } from "../process/instantiate";
|
|
8
7
|
import { statementFromCombinatorNode } from "../utilities/element";
|
|
9
8
|
import { unifyStatementWithCombinator } from "../process/unify";
|
|
10
9
|
import { validateStatementAsCombinator } from "../process/validate";
|
|
11
|
-
import {
|
|
10
|
+
import { attempt, serialise, unserialise, instantiate } from "../utilities/context";
|
|
12
11
|
|
|
13
12
|
export default define(class Combinator extends Element {
|
|
14
13
|
constructor(context, string, node, statement) {
|
|
@@ -73,7 +72,7 @@ export default define(class Combinator extends Element {
|
|
|
73
72
|
return statementValidates;
|
|
74
73
|
}
|
|
75
74
|
|
|
76
|
-
unifyStatement(statement,
|
|
75
|
+
unifyStatement(statement, context) {
|
|
77
76
|
let statementUnifies;
|
|
78
77
|
|
|
79
78
|
const statementString = statement.getString(),
|
|
@@ -90,7 +89,7 @@ export default define(class Combinator extends Element {
|
|
|
90
89
|
context = specifiContext; ///
|
|
91
90
|
|
|
92
91
|
const combinator = this, ///
|
|
93
|
-
statementUnifiesWithCombinator = unifyStatementWithCombinator(statement, combinator,
|
|
92
|
+
statementUnifiesWithCombinator = unifyStatementWithCombinator(statement, combinator, generalContext, specifiContext);
|
|
94
93
|
|
|
95
94
|
statementUnifies = statementUnifiesWithCombinator; ///
|
|
96
95
|
|
|
@@ -102,40 +101,35 @@ export default define(class Combinator extends Element {
|
|
|
102
101
|
}
|
|
103
102
|
|
|
104
103
|
toJSON() {
|
|
105
|
-
|
|
104
|
+
const context = this.getContext();
|
|
106
105
|
|
|
107
|
-
context
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
context = contextJSON; ///
|
|
106
|
+
return serialise((context) => {
|
|
107
|
+
const string = this.getString(),
|
|
108
|
+
json = {
|
|
109
|
+
context,
|
|
110
|
+
string
|
|
111
|
+
};
|
|
114
112
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
context,
|
|
118
|
-
string
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
return json;
|
|
113
|
+
return json;
|
|
114
|
+
}, context);
|
|
122
115
|
}
|
|
123
116
|
|
|
124
117
|
static name = "Combinator";
|
|
125
118
|
|
|
126
119
|
static fromJSON(json, context) {
|
|
127
|
-
|
|
120
|
+
let combinator;
|
|
128
121
|
|
|
129
|
-
context
|
|
122
|
+
unserialise((json, context) => {
|
|
123
|
+
instantiate((context) => {
|
|
124
|
+
const { string } = json,
|
|
125
|
+
combinatorNode = instantiateCombinator(string, context),
|
|
126
|
+
node = combinatorNode, ///
|
|
127
|
+
statement = statementFromCombinatorNode(combinatorNode, context);
|
|
130
128
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
node = combinatorNode, ///
|
|
135
|
-
statement = statementFromCombinatorNode(combinatorNode, context),
|
|
136
|
-
combinator = new Combinator(context, string, node, statement);
|
|
129
|
+
combinator = new Combinator(context, string, node, statement);
|
|
130
|
+
}, context);
|
|
131
|
+
}, json, context);
|
|
137
132
|
|
|
138
|
-
|
|
139
|
-
}, context);
|
|
133
|
+
return combinator;
|
|
140
134
|
}
|
|
141
135
|
});
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import { attempt, instantiate } from "../utilities/context";
|
|
7
6
|
import { instantiateConclusion } from "../process/instantiate";
|
|
8
|
-
import {
|
|
7
|
+
import { declare, attempt, descend, serialise, unserialise, instantiate } from "../utilities/context";
|
|
9
8
|
|
|
10
|
-
export
|
|
9
|
+
export default define(class Conclusion extends Element {
|
|
11
10
|
constructor(context, string, node, statement) {
|
|
12
11
|
super(context, string, node);
|
|
13
12
|
|
|
@@ -58,14 +57,16 @@ export default define(class Conclusion extends Element {
|
|
|
58
57
|
|
|
59
58
|
context.trace(`Validating the '${conclusionString}' conclusion...`);
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
declare((context) => {
|
|
61
|
+
attempt((context) => {
|
|
62
|
+
const statementValidates = this.validateStatement(context);
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
if (statementValidates) {
|
|
65
|
+
context.commit(this);
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
validates = true;
|
|
68
|
+
}
|
|
69
|
+
}, context);
|
|
69
70
|
}, context);
|
|
70
71
|
|
|
71
72
|
if (validates) {
|
|
@@ -76,19 +77,20 @@ export default define(class Conclusion extends Element {
|
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
validateStatement(context) {
|
|
79
|
-
let statementValidates;
|
|
80
|
+
let statementValidates = false;
|
|
80
81
|
|
|
81
82
|
const statementString = this.statement.getString(),
|
|
82
83
|
conclusionString = this.getString(); ///
|
|
83
84
|
|
|
84
85
|
context.trace(`Validating the '${conclusionString}' conclusion's '${statementString}' statement...`);
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
descend((context) => {
|
|
88
|
+
const statement = this.statement.validate(context);
|
|
88
89
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
if (statement !== null) {
|
|
91
|
+
statementValidates = true;
|
|
92
|
+
}
|
|
93
|
+
}, context);
|
|
92
94
|
|
|
93
95
|
if (statementValidates) {
|
|
94
96
|
context.trace(`...validated the '${conclusionString}' conclusion's '${statementString}' statement.`);
|
|
@@ -123,41 +125,36 @@ export default define(class Conclusion extends Element {
|
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
toJSON() {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
context = this.getContext();
|
|
129
|
-
|
|
130
|
-
const ephemeralContext = context, ///
|
|
131
|
-
ephemeralContextJSON = ephemeralContextToEphemeralContextJSON(ephemeralContext),
|
|
132
|
-
contextJSON = ephemeralContextJSON; ///
|
|
133
|
-
|
|
134
|
-
context = contextJSON; ///
|
|
128
|
+
const context = this.getContext();
|
|
135
129
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
130
|
+
return serialise((context) => {
|
|
131
|
+
const string = this.getString(),
|
|
132
|
+
json = {
|
|
133
|
+
context,
|
|
134
|
+
string
|
|
135
|
+
};
|
|
141
136
|
|
|
142
|
-
|
|
137
|
+
return json;
|
|
138
|
+
}, context);
|
|
143
139
|
}
|
|
144
140
|
|
|
145
141
|
static name = "Conclusion";
|
|
146
142
|
|
|
147
143
|
static fromJSON(json, context) {
|
|
148
|
-
|
|
144
|
+
let conclusion;
|
|
149
145
|
|
|
150
|
-
context
|
|
146
|
+
unserialise((json, context) => {
|
|
147
|
+
instantiate((context) => {
|
|
148
|
+
const { string } = json,
|
|
149
|
+
conclusionNode = instantiateConclusion(string, context),
|
|
150
|
+
node = conclusionNode, ///
|
|
151
|
+
statement = statementFromConclusionNode(conclusionNode, context);
|
|
151
152
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
node = conclusionNode, ///
|
|
156
|
-
statement = statementFromConclusionNode(conclusionNode, context),
|
|
157
|
-
conclusion = new Conclusion(context, string, node, statement);
|
|
153
|
+
conclusion = new Conclusion(context, string, node, statement);
|
|
154
|
+
}, context);
|
|
155
|
+
}, json, context);
|
|
158
156
|
|
|
159
|
-
|
|
160
|
-
}, context);
|
|
157
|
+
return conclusion;
|
|
161
158
|
}
|
|
162
159
|
});
|
|
163
160
|
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import { attempt, instantiate } from "../utilities/context";
|
|
7
6
|
import { instantiateConstructor } from "../process/instantiate";
|
|
8
7
|
import { termFromConstructorNode } from "../utilities/element";
|
|
9
8
|
import { unifyTermWithConstructor } from "../process/unify";
|
|
10
9
|
import { validateTermAsConstructor } from "../process/validate";
|
|
11
|
-
import { typeFromJSON, typeToTypeJSON
|
|
10
|
+
import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
|
|
11
|
+
import { attempt, serialise, unserialise, instantiate } from "../utilities/context";
|
|
12
12
|
|
|
13
13
|
export default define(class Constructor extends Element {
|
|
14
14
|
constructor(context, string, node, term, type) {
|
|
@@ -143,45 +143,40 @@ export default define(class Constructor extends Element {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
toJSON() {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
context
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
context,
|
|
162
|
-
string,
|
|
163
|
-
type
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
return json;
|
|
146
|
+
const context = this.getContext();
|
|
147
|
+
|
|
148
|
+
return serialise((context) => {
|
|
149
|
+
const includeType = false,
|
|
150
|
+
typeJSON = typeToTypeJSON(this.type),
|
|
151
|
+
string = this.getString(includeType),
|
|
152
|
+
type = typeJSON, ///
|
|
153
|
+
json = {
|
|
154
|
+
context,
|
|
155
|
+
string,
|
|
156
|
+
type
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
return json;
|
|
160
|
+
}, context);
|
|
167
161
|
}
|
|
168
162
|
|
|
169
163
|
static name = "Constructor";
|
|
170
164
|
|
|
171
165
|
static fromJSON(json, context) {
|
|
172
|
-
|
|
166
|
+
let constructor;
|
|
173
167
|
|
|
174
|
-
context
|
|
168
|
+
unserialise((json, context) => {
|
|
169
|
+
instantiate((context) => {
|
|
170
|
+
const { string } = json,
|
|
171
|
+
constructorNode = instantiateConstructor(string, context),
|
|
172
|
+
node = constructorNode, ///
|
|
173
|
+
term = termFromConstructorNode(constructorNode, context),
|
|
174
|
+
type = typeFromJSON(json, context);
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
node = constructorNode, ///
|
|
180
|
-
term = termFromConstructorNode(constructorNode, context),
|
|
181
|
-
type = typeFromJSON(json, context),
|
|
182
|
-
constructor = new Constructor(context, string, node, term, type);
|
|
176
|
+
constructor = new Constructor(context, string, node, term, type);
|
|
177
|
+
}, context);
|
|
178
|
+
}, json, context);
|
|
183
179
|
|
|
184
|
-
|
|
185
|
-
}, context);
|
|
180
|
+
return constructor;
|
|
186
181
|
}
|
|
187
182
|
});
|
package/src/element/deduction.js
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import { attempt, instantiate } from "../utilities/context";
|
|
7
6
|
import { instantiateDeduction } from "../process/instantiate";
|
|
8
|
-
import {
|
|
7
|
+
import { declare, attempt, descend, serialise, unserialise, instantiate } from "../utilities/context";
|
|
9
8
|
|
|
10
9
|
export default define(class Deduction extends Element {
|
|
11
10
|
constructor(context, string, node, statement) {
|
|
@@ -58,14 +57,16 @@ export default define(class Deduction extends Element {
|
|
|
58
57
|
|
|
59
58
|
context.trace(`Validating the '${deductionString}' deduction...`);
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
declare((context) => {
|
|
61
|
+
attempt((context) => {
|
|
62
|
+
const statementValidates = this.validateStatement(context);
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
if (statementValidates) {
|
|
65
|
+
context.commit(this);
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
validates = true;
|
|
68
|
+
}
|
|
69
|
+
}, context);
|
|
69
70
|
}, context);
|
|
70
71
|
|
|
71
72
|
if (validates) {
|
|
@@ -76,19 +77,20 @@ export default define(class Deduction extends Element {
|
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
validateStatement(context) {
|
|
79
|
-
let statementValidates;
|
|
80
|
+
let statementValidates = false;
|
|
80
81
|
|
|
81
82
|
const statementString = this.statement.getString(),
|
|
82
83
|
deductionnString = this.getString(); ///
|
|
83
84
|
|
|
84
85
|
context.trace(`Validating the '${deductionnString}' deductionn's '${statementString}' statement...`);
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
descend((context) => {
|
|
88
|
+
const statement = this.statement.validate(context);
|
|
88
89
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
if (statement !== null) {
|
|
91
|
+
statementValidates = true;
|
|
92
|
+
}
|
|
93
|
+
}, context);
|
|
92
94
|
|
|
93
95
|
if (statementValidates) {
|
|
94
96
|
context.trace(`...validated the '${deductionnString}' deductionn's '${statementString}' statement.`);
|
|
@@ -148,41 +150,36 @@ export default define(class Deduction extends Element {
|
|
|
148
150
|
}
|
|
149
151
|
|
|
150
152
|
toJSON() {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
context = this.getContext();
|
|
154
|
-
|
|
155
|
-
const ephemeralContext = context, ///
|
|
156
|
-
ephemeralContextJSON = ephemeralContextToEphemeralContextJSON(ephemeralContext),
|
|
157
|
-
contextJSON = ephemeralContextJSON; ///
|
|
158
|
-
|
|
159
|
-
context = contextJSON; ///
|
|
153
|
+
const context = this.getContext();
|
|
160
154
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
155
|
+
return serialise((context) => {
|
|
156
|
+
const string = this.getString(),
|
|
157
|
+
json = {
|
|
158
|
+
context,
|
|
159
|
+
string
|
|
160
|
+
};
|
|
166
161
|
|
|
167
|
-
|
|
162
|
+
return json;
|
|
163
|
+
}, context);
|
|
168
164
|
}
|
|
169
165
|
|
|
170
166
|
static name = "Deduction";
|
|
171
167
|
|
|
172
168
|
static fromJSON(json, context) {
|
|
173
|
-
|
|
169
|
+
let deduction;
|
|
174
170
|
|
|
175
|
-
context
|
|
171
|
+
unserialise((json, context) => {
|
|
172
|
+
instantiate((context) => {
|
|
173
|
+
const { string } = json,
|
|
174
|
+
deductionNode = instantiateDeduction(string, context),
|
|
175
|
+
node = deductionNode, ///
|
|
176
|
+
statement = statementFromDeductionNode(deductionNode, context);
|
|
176
177
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
node = deductionNode, ///
|
|
181
|
-
statement = statementFromDeductionNode(deductionNode, context),
|
|
182
|
-
deduction = new Deduction(context, string, node, statement);
|
|
178
|
+
deduction = new Deduction(context, string, node, statement);
|
|
179
|
+
}, context);
|
|
180
|
+
}, json, context);
|
|
183
181
|
|
|
184
|
-
|
|
185
|
-
}, context);
|
|
182
|
+
return deduction;
|
|
186
183
|
}
|
|
187
184
|
});
|
|
188
185
|
|