occam-verify-cli 1.0.955 → 1.0.972
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/bounded.js +11 -7
- package/lib/context.js +17 -5
- package/lib/element/assertion/signature.js +17 -19
- package/lib/element/assertion/subproof.js +36 -39
- package/lib/element/assertion/type.js +20 -1
- package/lib/element/assumption/metaLevel.js +18 -17
- package/lib/element/assumption.js +52 -3
- package/lib/element/combinator.js +10 -12
- package/lib/element/conclusion.js +33 -33
- package/lib/element/constructor.js +8 -12
- package/lib/element/deduction.js +33 -33
- package/lib/element/equivalence.js +11 -7
- package/lib/element/hypothesis.js +45 -19
- package/lib/element/judgement.js +1 -1
- package/lib/element/label.js +9 -11
- package/lib/element/parameter.js +2 -2
- package/lib/element/procedureCall.js +1 -1
- package/lib/element/proofAssertion/premise.js +98 -87
- package/lib/element/proofAssertion/step.js +27 -27
- package/lib/element/proofAssertion/supposition.js +99 -88
- package/lib/element/proofAssertion.js +3 -3
- package/lib/element/property.js +1 -2
- package/lib/element/reference.js +30 -38
- package/lib/element/section.js +1 -1
- package/lib/element/signature.js +38 -47
- package/lib/element/statement.js +18 -58
- package/lib/element/substitution/frame.js +33 -38
- package/lib/element/substitution/reference.js +12 -13
- package/lib/element/substitution/statement.js +26 -31
- package/lib/element/substitution/term.js +32 -37
- package/lib/element/term.js +2 -2
- package/lib/element/topLevelAssertion/axiom.js +33 -34
- package/lib/element/topLevelAssertion.js +30 -7
- package/lib/element/topLevelMetaAssertion.js +2 -2
- package/lib/process/discharge.js +38 -0
- package/lib/process/unification.js +228 -0
- package/lib/process/unify.js +9 -5
- package/lib/process/validation.js +291 -0
- package/lib/utilities/context.js +69 -101
- package/lib/utilities/element.js +2 -4
- package/lib/utilities/string.js +4 -4
- package/package.json +4 -4
- package/src/context/bounded.js +19 -7
- package/src/context.js +26 -6
- package/src/element/assertion/signature.js +21 -26
- package/src/element/assertion/subproof.js +43 -46
- package/src/element/assertion/type.js +30 -1
- package/src/element/assumption/metaLevel.js +26 -22
- package/src/element/assumption.js +80 -2
- package/src/element/combinator.js +11 -14
- package/src/element/conclusion.js +38 -37
- package/src/element/constructor.js +9 -14
- package/src/element/deduction.js +38 -37
- package/src/element/equivalence.js +17 -13
- package/src/element/hypothesis.js +59 -19
- package/src/element/judgement.js +1 -1
- package/src/element/label.js +10 -12
- package/src/element/parameter.js +1 -1
- package/src/element/procedureCall.js +1 -1
- package/src/element/proofAssertion/premise.js +123 -107
- package/src/element/proofAssertion/step.js +29 -29
- package/src/element/proofAssertion/supposition.js +124 -108
- package/src/element/proofAssertion.js +2 -2
- package/src/element/property.js +0 -1
- package/src/element/reference.js +36 -47
- package/src/element/section.js +1 -1
- package/src/element/signature.js +42 -53
- package/src/element/statement.js +18 -89
- package/src/element/substitution/frame.js +37 -47
- package/src/element/substitution/reference.js +13 -16
- package/src/element/substitution/statement.js +27 -34
- package/src/element/substitution/term.js +37 -46
- package/src/element/term.js +1 -1
- package/src/element/topLevelAssertion/axiom.js +43 -45
- package/src/element/topLevelAssertion.js +42 -6
- package/src/element/topLevelMetaAssertion.js +2 -2
- package/src/process/discharge.js +33 -0
- package/src/{utilities → process}/unification.js +21 -27
- package/src/process/unify.js +9 -5
- package/src/{utilities → process}/validation.js +2 -2
- package/src/utilities/context.js +78 -123
- package/src/utilities/element.js +2 -5
- package/src/utilities/string.js +6 -6
- package/lib/context/ephemeral.js +0 -28
- package/lib/context/synoptic.js +0 -255
- package/lib/utilities/unification.js +0 -233
- package/lib/utilities/validation.js +0 -291
- package/src/context/ephemeral.js +0 -17
- package/src/context/synoptic.js +0 -361
|
@@ -9,7 +9,7 @@ import { instantiateMetaLevelAssumption } from "../../process/instantiate";
|
|
|
9
9
|
import { breakPointFromJSON, breakPointToBreakPointJSON } from "../../utilities/breakPoint";
|
|
10
10
|
import { metaLevelAssumptionFromMetaLevelAssumptionNode } from "../../utilities/element";
|
|
11
11
|
import { metaLevelAssumptionStringFromReferenceAndStatement } from "../../utilities/string";
|
|
12
|
-
import {
|
|
12
|
+
import { ablate, attempt, descend, reconcile, serialise, unserialise, instantiate } from "../../utilities/context";
|
|
13
13
|
|
|
14
14
|
export default define(class MetaLevelAssumption extends Element {
|
|
15
15
|
constructor(context, string, node, breakPoint, reference, statement) {
|
|
@@ -80,6 +80,10 @@ export default define(class MetaLevelAssumption extends Element {
|
|
|
80
80
|
|
|
81
81
|
context.debug(`...the '${metaLevelAssumptionString}' meta-level assumption is already valid.`);
|
|
82
82
|
} else {
|
|
83
|
+
const temporaryContext = context; ///
|
|
84
|
+
|
|
85
|
+
context = this.getContext();
|
|
86
|
+
|
|
83
87
|
attempt((context) => {
|
|
84
88
|
const statementValidates = this.validateStatement(context);
|
|
85
89
|
|
|
@@ -90,7 +94,7 @@ export default define(class MetaLevelAssumption extends Element {
|
|
|
90
94
|
const stated = context.isStated();
|
|
91
95
|
|
|
92
96
|
let validatesWhenStated = false,
|
|
93
|
-
|
|
97
|
+
validatesWhenDerived = false;
|
|
94
98
|
|
|
95
99
|
if (stated) {
|
|
96
100
|
validatesWhenStated = this.validateWhenStated(context);
|
|
@@ -109,6 +113,8 @@ export default define(class MetaLevelAssumption extends Element {
|
|
|
109
113
|
}
|
|
110
114
|
}, context);
|
|
111
115
|
|
|
116
|
+
context = temporaryContext; ///
|
|
117
|
+
|
|
112
118
|
if (validates) {
|
|
113
119
|
metaLevelAssumption = this; ///
|
|
114
120
|
|
|
@@ -214,27 +220,25 @@ export default define(class MetaLevelAssumption extends Element {
|
|
|
214
220
|
context.trace(`Unifying the '${assumptionString}' assumption with the '${metaLevelAssumptionString}' meta-level assumption...`);
|
|
215
221
|
|
|
216
222
|
const metaLevelAssumptionContext = this.getContext(), ///
|
|
217
|
-
assumptionContext = assumption.getContext(),
|
|
218
|
-
|
|
219
|
-
|
|
223
|
+
assumptionContext = assumption.getContext(), ///
|
|
224
|
+
generalContext = metaLevelAssumptionContext,
|
|
225
|
+
specificContext = assumptionContext; ///
|
|
220
226
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
referneceUnifies = this.unifyReference(reference, generalContext, specificContext);
|
|
227
|
+
reconcile((specificContext) => {
|
|
228
|
+
const reference = assumption.getReference(),
|
|
229
|
+
referneceUnifies = this.unifyReference(reference, generalContext, specificContext);
|
|
225
230
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
231
|
+
if (referneceUnifies) {
|
|
232
|
+
const statement = assumption.getStatement(),
|
|
233
|
+
statementUnifieds = this.unifyStatement(statement, generalContext, specificContext);
|
|
229
234
|
|
|
230
|
-
|
|
231
|
-
|
|
235
|
+
if (statementUnifieds) {
|
|
236
|
+
specificContext.commit(context);
|
|
232
237
|
|
|
233
|
-
|
|
234
|
-
}
|
|
238
|
+
assumptionUnifies = true;
|
|
235
239
|
}
|
|
236
|
-
}
|
|
237
|
-
}, specificContext
|
|
240
|
+
}
|
|
241
|
+
}, specificContext);
|
|
238
242
|
|
|
239
243
|
if (assumptionUnifies) {
|
|
240
244
|
context.debug(`...unified the '${assumptionString}' assumption with the '${metaLevelAssumptionString}' meta-level assumption...`);
|
|
@@ -313,8 +317,8 @@ export default define(class MetaLevelAssumption extends Element {
|
|
|
313
317
|
static fromJSON(json, context) {
|
|
314
318
|
let metaLevelAssumption;
|
|
315
319
|
|
|
316
|
-
|
|
317
|
-
|
|
320
|
+
instantiate((context) => {
|
|
321
|
+
unserialise((json, context) => {
|
|
318
322
|
const { string } = json,
|
|
319
323
|
metaLevelAssumptionNode = instantiateMetaLevelAssumption(string, context),
|
|
320
324
|
node = metaLevelAssumptionNode, ///
|
|
@@ -323,8 +327,8 @@ export default define(class MetaLevelAssumption extends Element {
|
|
|
323
327
|
statement = statementFromMetaLevelAssumptionNode(metaLevelAssumptionNode, context);
|
|
324
328
|
|
|
325
329
|
metaLevelAssumption = new MetaLevelAssumption(context, string, node, breakPoint, reference, statement);
|
|
326
|
-
}, context);
|
|
327
|
-
},
|
|
330
|
+
}, json, context);
|
|
331
|
+
}, context);
|
|
328
332
|
|
|
329
333
|
return metaLevelAssumption;
|
|
330
334
|
}
|
|
@@ -30,6 +30,8 @@ export default define(class Assumption extends Element {
|
|
|
30
30
|
return assumptionNode;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
getStatementNode() { return this.statement.getStatementNode(); }
|
|
34
|
+
|
|
33
35
|
getMetavariable() { return this.reference.getMetavariable(); }
|
|
34
36
|
|
|
35
37
|
getTopLevelMetaAssertion() { return this.reference.getTopLevelMetaAssertion(); }
|
|
@@ -50,6 +52,19 @@ export default define(class Assumption extends Element {
|
|
|
50
52
|
return assumptionNodeMatches;
|
|
51
53
|
}
|
|
52
54
|
|
|
55
|
+
findSubproofAssertion(context) {
|
|
56
|
+
let subproofAssertion = null;
|
|
57
|
+
|
|
58
|
+
const statementNode = this.getStatementNode(),
|
|
59
|
+
subproofAssertionNode = statementNode.getSubproofAssertionNode();
|
|
60
|
+
|
|
61
|
+
if (subproofAssertionNode !== null) {
|
|
62
|
+
subproofAssertion = context.findAssertionByAssertionNode(subproofAssertionNode);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return subproofAssertion;
|
|
66
|
+
}
|
|
67
|
+
|
|
53
68
|
findValidAssumption(context) {
|
|
54
69
|
const assumptionNode = this.getAssumptionNode(),
|
|
55
70
|
assumption = context.findAssumptionByAssumptionNode(assumptionNode),
|
|
@@ -206,8 +221,56 @@ export default define(class Assumption extends Element {
|
|
|
206
221
|
return validatesWhenDerived;
|
|
207
222
|
}
|
|
208
223
|
|
|
224
|
+
unifyStatement(statement, generalContext, specificContext) {
|
|
225
|
+
let statementUnifies;
|
|
226
|
+
|
|
227
|
+
const context = specificContext, ///
|
|
228
|
+
statementString = statement.getString(),
|
|
229
|
+
proofAssertionString = this.getString(); ///
|
|
230
|
+
|
|
231
|
+
context.trace(`Unifying the '${statementString}' statement with the '${proofAssertionString}' assumption's statement...`);
|
|
232
|
+
|
|
233
|
+
statementUnifies = this.statement.unifyStatement(statement, generalContext, specificContext);
|
|
234
|
+
|
|
235
|
+
if (statementUnifies) {
|
|
236
|
+
context.debug(`...unified the '${statementString}' statement with the '${proofAssertionString}' assumption's statement.`);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return statementUnifies;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
unifyDeduction(deduction, context) {
|
|
243
|
+
let deductionUnifies = false;
|
|
244
|
+
|
|
245
|
+
const deductionString = deduction.getString(),
|
|
246
|
+
assumptionString = this.getString(); ///
|
|
247
|
+
|
|
248
|
+
context.trace(`Unifying the '${deductionString}' deduction with the '${assumptionString}' assumption's statement...`);
|
|
249
|
+
|
|
250
|
+
const deductionContext = deduction.getContext(),
|
|
251
|
+
generalContext = context, ///
|
|
252
|
+
specificContext = deductionContext; ///
|
|
253
|
+
|
|
254
|
+
reconcile((specificContext) => {
|
|
255
|
+
const statement = deduction.getStatement(),
|
|
256
|
+
statementUnifies = this.unifyStatement(statement, generalContext, specificContext);
|
|
257
|
+
|
|
258
|
+
if (statementUnifies) {
|
|
259
|
+
specificContext.commit(context);
|
|
260
|
+
|
|
261
|
+
deductionUnifies = true;
|
|
262
|
+
}
|
|
263
|
+
}, specificContext);
|
|
264
|
+
|
|
265
|
+
if (deductionUnifies) {
|
|
266
|
+
context.debug(`...unified the '${deductionString}' deduction with the '${assumptionString}' assumption's statement.`);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return deductionUnifies;
|
|
270
|
+
}
|
|
271
|
+
|
|
209
272
|
unifyTopLevelMetaAssertion(topLevelMetaAssertion, context) {
|
|
210
|
-
let topLevelMetaAssertionUnifies;
|
|
273
|
+
let topLevelMetaAssertionUnifies = false;
|
|
211
274
|
|
|
212
275
|
const assumptionString = this.getString(), ///
|
|
213
276
|
topLevelMetaAssertionString = topLevelMetaAssertion.getString();
|
|
@@ -218,7 +281,22 @@ export default define(class Assumption extends Element {
|
|
|
218
281
|
topLevelMetaAssertionUnifies = this.reference.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
|
|
219
282
|
|
|
220
283
|
if (topLevelMetaAssertionUnifies) {
|
|
221
|
-
|
|
284
|
+
const subproofAssertion = this.findSubproofAssertion(context);
|
|
285
|
+
|
|
286
|
+
if (subproofAssertion !== null) {
|
|
287
|
+
topLevelMetaAssertionUnifies = subproofAssertion.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
|
|
288
|
+
} else {
|
|
289
|
+
const unconditional = topLevelMetaAssertion.isUnconditional();
|
|
290
|
+
|
|
291
|
+
if (unconditional) {
|
|
292
|
+
const deduction = topLevelMetaAssertion.getDeduction(),
|
|
293
|
+
deductionUnifies = this.unifyDeduction(deduction, context);
|
|
294
|
+
|
|
295
|
+
if (deductionUnifies) {
|
|
296
|
+
topLevelMetaAssertionUnifies = true;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
222
300
|
}
|
|
223
301
|
}, context);
|
|
224
302
|
|
|
@@ -75,25 +75,22 @@ export default define(class Combinator extends Element {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
unifyStatement(statement, context) {
|
|
78
|
-
let statementUnifies;
|
|
78
|
+
let statementUnifies = false;
|
|
79
79
|
|
|
80
80
|
const statementString = statement.getString(),
|
|
81
81
|
combinatorString = this.getString(); ///
|
|
82
82
|
|
|
83
83
|
context.trace(`Unifying the '${statementString}' statement with the '${combinatorString}' combinator...`);
|
|
84
84
|
|
|
85
|
-
const specifiContext = context; ///
|
|
86
|
-
|
|
87
|
-
context = this.getContext();
|
|
88
|
-
|
|
89
|
-
const generalContext = context; ///
|
|
90
|
-
|
|
91
|
-
context = specifiContext; ///
|
|
92
|
-
|
|
93
85
|
const combinator = this, ///
|
|
86
|
+
combinatorContext = combinator.getContext(),
|
|
87
|
+
generalContext = combinatorContext, ///
|
|
88
|
+
specifiContext = context, ///
|
|
94
89
|
statementUnifiesWithCombinator = unifyStatementWithCombinator(statement, combinator, generalContext, specifiContext);
|
|
95
90
|
|
|
96
|
-
|
|
91
|
+
if (statementUnifiesWithCombinator) {
|
|
92
|
+
statementUnifies = true;
|
|
93
|
+
}
|
|
97
94
|
|
|
98
95
|
if (statementUnifies) {
|
|
99
96
|
context.debug(`...unified the '${statementString}' statement with the '${combinatorString}' combinator.`);
|
|
@@ -131,8 +128,8 @@ export default define(class Combinator extends Element {
|
|
|
131
128
|
static fromJSON(json, context) {
|
|
132
129
|
let combinator;
|
|
133
130
|
|
|
134
|
-
|
|
135
|
-
|
|
131
|
+
instantiate((context) => {
|
|
132
|
+
unserialise((json, context) => {
|
|
136
133
|
const { string } = json,
|
|
137
134
|
combinatorNode = instantiateCombinator(string, context),
|
|
138
135
|
node = combinatorNode, ///
|
|
@@ -140,8 +137,8 @@ export default define(class Combinator extends Element {
|
|
|
140
137
|
statement = statementFromCombinatorNode(combinatorNode, context);
|
|
141
138
|
|
|
142
139
|
combinator = new Combinator(context, string, node, breakPoint, statement);
|
|
143
|
-
}, context);
|
|
144
|
-
},
|
|
140
|
+
}, json, context);
|
|
141
|
+
}, context);
|
|
145
142
|
|
|
146
143
|
return combinator;
|
|
147
144
|
}
|
|
@@ -5,7 +5,7 @@ import { Element } from "occam-languages";
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
import { instantiateConclusion } from "../process/instantiate";
|
|
7
7
|
import { breakPointFromJSON, breakPointToBreakPointJSON } from "../utilities/breakPoint";
|
|
8
|
-
import { declare, attempt,
|
|
8
|
+
import { elide, declare, attempt, reconcile, serialise, unserialise, instantiate } from "../utilities/context";
|
|
9
9
|
|
|
10
10
|
export default define(class Conclusion extends Element {
|
|
11
11
|
constructor(context, string, node, breakPoint, statement) {
|
|
@@ -35,11 +35,15 @@ export default define(class Conclusion extends Element {
|
|
|
35
35
|
context.trace(`Verifying the '${conclusionString}' conclusion...`);
|
|
36
36
|
|
|
37
37
|
if (this.statement !== null) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
declare((context) => {
|
|
39
|
+
elide((context) => {
|
|
40
|
+
const validates = this.validate(context);
|
|
41
|
+
|
|
42
|
+
if (validates) {
|
|
43
|
+
verifies = true;
|
|
44
|
+
}
|
|
45
|
+
}, context);
|
|
46
|
+
}, context);
|
|
43
47
|
} else {
|
|
44
48
|
context.debug(`Unable to verify the '${conclusionString}' conclusion because it is nonsense.`);
|
|
45
49
|
}
|
|
@@ -58,18 +62,16 @@ export default define(class Conclusion extends Element {
|
|
|
58
62
|
|
|
59
63
|
context.trace(`Validating the '${conclusionString}' conclusion...`);
|
|
60
64
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const statementValidates = this.validateStatement(context);
|
|
65
|
+
attempt((context) => {
|
|
66
|
+
const statementValidates = this.validateStatement(context);
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
if (statementValidates) {
|
|
69
|
+
validates = true;
|
|
70
|
+
}
|
|
68
71
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}, context);
|
|
72
|
+
if (validates) {
|
|
73
|
+
this.commit(context);
|
|
74
|
+
}
|
|
73
75
|
}, context);
|
|
74
76
|
|
|
75
77
|
if (validates) {
|
|
@@ -86,13 +88,11 @@ export default define(class Conclusion extends Element {
|
|
|
86
88
|
|
|
87
89
|
context.trace(`Validating the '${conclusionString}' conclusion's statement...`);
|
|
88
90
|
|
|
89
|
-
|
|
90
|
-
const statement = this.statement.validate(context);
|
|
91
|
+
const statement = this.statement.validate(context);
|
|
91
92
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}, context);
|
|
93
|
+
if (statement !== null) {
|
|
94
|
+
statementValidates = true;
|
|
95
|
+
}
|
|
96
96
|
|
|
97
97
|
if (statementValidates) {
|
|
98
98
|
context.trace(`...validated the '${conclusionString}' conclusion's statement.`);
|
|
@@ -109,20 +109,21 @@ export default define(class Conclusion extends Element {
|
|
|
109
109
|
|
|
110
110
|
context.trace(`Unifying the '${stepString}' step with the '${conclusionString}' conclusion...`);
|
|
111
111
|
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const generalContext = context; ///
|
|
112
|
+
const stepContext = step.getContext(),
|
|
113
|
+
conclusionContext = this.getContext(),
|
|
114
|
+
generalContext = conclusionContext, ///
|
|
115
|
+
specificContext = stepContext; ///
|
|
117
116
|
|
|
118
|
-
|
|
117
|
+
reconcile((specificContext) => {
|
|
118
|
+
const statement = step.getStatement(),
|
|
119
|
+
statementUnifies = this.statement.unifyStatement(statement, generalContext, specificContext);
|
|
119
120
|
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
if (statementUnifies) {
|
|
122
|
+
specificContext.commit(context);
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
124
|
+
stepUnifies = true;
|
|
125
|
+
}
|
|
126
|
+
}, specificContext);
|
|
126
127
|
|
|
127
128
|
if (stepUnifies) {
|
|
128
129
|
context.debug(`...unified the '${stepString}' step with the '${conclusionString}' conclusion.`);
|
|
@@ -160,8 +161,8 @@ export default define(class Conclusion extends Element {
|
|
|
160
161
|
static fromJSON(json, context) {
|
|
161
162
|
let conclusion;
|
|
162
163
|
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
instantiate((context) => {
|
|
165
|
+
unserialise((json, context) => {
|
|
165
166
|
const { string } = json,
|
|
166
167
|
conclusionNode = instantiateConclusion(string, context),
|
|
167
168
|
node = conclusionNode, ///
|
|
@@ -169,8 +170,8 @@ export default define(class Conclusion extends Element {
|
|
|
169
170
|
statement = statementFromConclusionNode(conclusionNode, context);
|
|
170
171
|
|
|
171
172
|
conclusion = new Conclusion(context, string, node, breakPoint, statement);
|
|
172
|
-
}, context);
|
|
173
|
-
},
|
|
173
|
+
}, json, context);
|
|
174
|
+
}, context);
|
|
174
175
|
|
|
175
176
|
return conclusion;
|
|
176
177
|
}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
|
|
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";
|
|
10
|
+
import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
|
|
11
11
|
import { attempt, serialise, unserialise, instantiate } from "../utilities/context";
|
|
12
12
|
import { breakPointFromJSON, breakPointToBreakPointJSON } from "../utilities/breakPoint";
|
|
13
13
|
|
|
@@ -106,19 +106,14 @@ export default define(class Constructor extends Element {
|
|
|
106
106
|
|
|
107
107
|
const termString = term.getString(),
|
|
108
108
|
includeType = false,
|
|
109
|
-
constructorString = this.getString(includeType);
|
|
109
|
+
constructorString = this.getString(includeType); ///
|
|
110
110
|
|
|
111
111
|
context.trace(`Unifying the '${termString}' term with the '${constructorString}' constructor...`);
|
|
112
112
|
|
|
113
|
-
const specifiContext = context; ///
|
|
114
|
-
|
|
115
|
-
context = this.getContext();
|
|
116
|
-
|
|
117
|
-
const generalContext = context; ///
|
|
118
|
-
|
|
119
|
-
context = specifiContext; ///
|
|
120
|
-
|
|
121
113
|
const constructor = this, ///
|
|
114
|
+
constructorContext = constructor.getContext(),
|
|
115
|
+
generalContext = constructorContext, ///
|
|
116
|
+
specifiContext = context, ///
|
|
122
117
|
termUnifiesWithConstructor = unifyTermWithConstructor(term, constructor, generalContext, specifiContext);
|
|
123
118
|
|
|
124
119
|
if (termUnifiesWithConstructor) {
|
|
@@ -175,8 +170,8 @@ export default define(class Constructor extends Element {
|
|
|
175
170
|
static fromJSON(json, context) {
|
|
176
171
|
let constructor;
|
|
177
172
|
|
|
178
|
-
|
|
179
|
-
|
|
173
|
+
instantiate((context) => {
|
|
174
|
+
unserialise((json, context) => {
|
|
180
175
|
const { string } = json,
|
|
181
176
|
constructorNode = instantiateConstructor(string, context),
|
|
182
177
|
node = constructorNode, ///
|
|
@@ -185,8 +180,8 @@ export default define(class Constructor extends Element {
|
|
|
185
180
|
type = typeFromJSON(json, context);
|
|
186
181
|
|
|
187
182
|
constructor = new Constructor(context, string, node, breakPoint, term, type);
|
|
188
|
-
}, context);
|
|
189
|
-
},
|
|
183
|
+
}, json, context);
|
|
184
|
+
}, context);
|
|
190
185
|
|
|
191
186
|
return constructor;
|
|
192
187
|
}
|
package/src/element/deduction.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Element } from "occam-languages";
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
import { instantiateDeduction } from "../process/instantiate";
|
|
7
7
|
import { breakPointFromJSON, breakPointToBreakPointJSON } from "../utilities/breakPoint";
|
|
8
|
-
import { declare, attempt,
|
|
8
|
+
import { elide, declare, attempt, serialise, unserialise, instantiate, reconcile } from "../utilities/context";
|
|
9
9
|
|
|
10
10
|
export default define(class Deduction extends Element {
|
|
11
11
|
constructor(context, string, node, breakPoint, statement) {
|
|
@@ -35,11 +35,15 @@ export default define(class Deduction extends Element {
|
|
|
35
35
|
context.trace(`Verifying the '${deductionString}' deduction...`);
|
|
36
36
|
|
|
37
37
|
if (this.statement !== null) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
declare((context) => {
|
|
39
|
+
elide((context) => {
|
|
40
|
+
const validates = this.validate(context);
|
|
41
|
+
|
|
42
|
+
if (validates) {
|
|
43
|
+
verifies = true;
|
|
44
|
+
}
|
|
45
|
+
}, context);
|
|
46
|
+
}, context);
|
|
43
47
|
} else {
|
|
44
48
|
context.debug(`Unable to verify the '${deductionString}' deduction because it is nonsense.`);
|
|
45
49
|
}
|
|
@@ -58,18 +62,16 @@ export default define(class Deduction extends Element {
|
|
|
58
62
|
|
|
59
63
|
context.trace(`Validating the '${deductionString}' deduction...`);
|
|
60
64
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const statementValidates = this.validateStatement(context);
|
|
65
|
+
attempt((context) => {
|
|
66
|
+
const statementValidates = this.validateStatement(context);
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
if (statementValidates) {
|
|
69
|
+
validates = true;
|
|
70
|
+
}
|
|
68
71
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}, context);
|
|
72
|
+
if (validates) {
|
|
73
|
+
this.commit(context);
|
|
74
|
+
}
|
|
73
75
|
}, context);
|
|
74
76
|
|
|
75
77
|
if (validates) {
|
|
@@ -86,13 +88,11 @@ export default define(class Deduction extends Element {
|
|
|
86
88
|
|
|
87
89
|
context.trace(`Validating the '${deductionnString}' deductionn's statement...`);
|
|
88
90
|
|
|
89
|
-
|
|
90
|
-
const statement = this.statement.validate(context);
|
|
91
|
+
const statement = this.statement.validate(context);
|
|
91
92
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}, context);
|
|
93
|
+
if (statement !== null) {
|
|
94
|
+
statementValidates = true;
|
|
95
|
+
}
|
|
96
96
|
|
|
97
97
|
if (statementValidates) {
|
|
98
98
|
context.trace(`...validated the '${deductionnString}' deductionn's statement.`);
|
|
@@ -109,20 +109,21 @@ export default define(class Deduction extends Element {
|
|
|
109
109
|
|
|
110
110
|
context.trace(`Unifying the '${stepString}' step with the '${deductionString}' deduction...`);
|
|
111
111
|
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const generalContext = context; ///
|
|
112
|
+
const stepContext = step.getContext(),
|
|
113
|
+
deductionContext = this.getContext(),
|
|
114
|
+
generalContext = deductionContext, ///
|
|
115
|
+
specificContext = stepContext; ///
|
|
117
116
|
|
|
118
|
-
|
|
117
|
+
reconcile((specificContext) => {
|
|
118
|
+
const statement = step.getStatement(),
|
|
119
|
+
statementUnifies = this.statement.unifyStatement(statement, generalContext, specificContext);
|
|
119
120
|
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
if (statementUnifies) {
|
|
122
|
+
specificContext.commit(context);
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
124
|
+
stepUnifies = true;
|
|
125
|
+
}
|
|
126
|
+
}, specificContext);
|
|
126
127
|
|
|
127
128
|
if (stepUnifies) {
|
|
128
129
|
context.debug(`...unified the '${stepString}' step with the '${deductionString}' deduction.`);
|
|
@@ -160,8 +161,8 @@ export default define(class Deduction extends Element {
|
|
|
160
161
|
static fromJSON(json, context) {
|
|
161
162
|
let deduction;
|
|
162
163
|
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
instantiate((context) => {
|
|
165
|
+
unserialise((json, context) => {
|
|
165
166
|
const { string } = json,
|
|
166
167
|
deductionNode = instantiateDeduction(string, context),
|
|
167
168
|
node = deductionNode, ///
|
|
@@ -169,8 +170,8 @@ export default define(class Deduction extends Element {
|
|
|
169
170
|
statement = statementFromDeductionNode(deductionNode, context);
|
|
170
171
|
|
|
171
172
|
deduction = new Deduction(context, string, node, breakPoint, statement);
|
|
172
|
-
}, context);
|
|
173
|
-
},
|
|
173
|
+
}, json, context);
|
|
174
|
+
}, context);
|
|
174
175
|
|
|
175
176
|
return deduction;
|
|
176
177
|
}
|
|
@@ -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 { instantiate } from "../utilities/context";
|
|
7
|
+
import { ablate, 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";
|
|
@@ -217,13 +217,15 @@ export default define(class Equivalence extends Element {
|
|
|
217
217
|
|
|
218
218
|
type = combinedType; ///
|
|
219
219
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
220
|
+
ablate((context) => {
|
|
221
|
+
instantiate((context) => {
|
|
222
|
+
const terms = combinedTerms, ///
|
|
223
|
+
equivalenceString = equivalenceStringFromTerms(terms),
|
|
224
|
+
string = equivalenceString, ///
|
|
225
|
+
equivalenceNode = instantiateEquivalence(string, context);
|
|
225
226
|
|
|
226
|
-
|
|
227
|
+
equivalence = equivalenceFromEquivalenceNode(equivalenceNode, context);
|
|
228
|
+
}, context);
|
|
227
229
|
}, context);
|
|
228
230
|
|
|
229
231
|
equivalence.setType(type);
|
|
@@ -238,13 +240,15 @@ export default define(class Equivalence extends Element {
|
|
|
238
240
|
|
|
239
241
|
const type = equality.getType();
|
|
240
242
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
243
|
+
ablate((context) => {
|
|
244
|
+
instantiate((context) => {
|
|
245
|
+
const terms = equality.getTerms(),
|
|
246
|
+
equivalenceString = equivalenceStringFromTerms(terms),
|
|
247
|
+
string = equivalenceString, ///
|
|
248
|
+
equivalenceNode = instantiateEquivalence(string, context);
|
|
246
249
|
|
|
247
|
-
|
|
250
|
+
equivalence = equivalenceFromEquivalenceNode(equivalenceNode, context);
|
|
251
|
+
}, context);
|
|
248
252
|
}, context);
|
|
249
253
|
|
|
250
254
|
equivalence.setType(type);
|