occam-verify-cli 1.0.781 → 1.0.785
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 +1 -1
- package/lib/context/ephemeral.js +22 -11
- package/lib/context/file/nominal.js +4 -4
- package/lib/context/proof.js +45 -40
- package/lib/context.js +16 -20
- package/lib/element/assumption.js +47 -17
- package/lib/element/frame.js +1 -39
- package/lib/element/judgement.js +33 -5
- package/lib/element/metavariable.js +7 -7
- package/lib/element/topLevelMetaAssertion.js +9 -9
- package/lib/nonTerminalNodeMap.js +1 -3
- package/lib/preamble.js +1 -2
- package/lib/process/instantiate.js +2 -8
- package/lib/process/unify.js +72 -5
- package/lib/ruleNames.js +1 -5
- package/lib/utilities/context.js +30 -10
- package/lib/utilities/element.js +18 -41
- package/lib/utilities/json.js +1 -23
- package/lib/utilities/string.js +8 -19
- package/lib/utilities/unification.js +8 -6
- package/package.json +4 -4
- package/src/context/branching.js +1 -1
- package/src/context/ephemeral.js +26 -10
- package/src/context/file/nominal.js +3 -3
- package/src/context/proof.js +52 -46
- package/src/context.js +21 -27
- package/src/element/assumption.js +72 -23
- package/src/element/frame.js +1 -61
- package/src/element/judgement.js +45 -5
- package/src/element/metavariable.js +6 -9
- package/src/element/topLevelMetaAssertion.js +13 -13
- package/src/nonTerminalNodeMap.js +0 -3
- package/src/preamble.js +0 -1
- package/src/process/instantiate.js +2 -6
- package/src/process/unify.js +117 -7
- package/src/ruleNames.js +0 -1
- package/src/utilities/context.js +43 -11
- package/src/utilities/element.js +26 -56
- package/src/utilities/json.js +0 -26
- package/src/utilities/string.js +8 -22
- package/src/utilities/unification.js +8 -8
- package/lib/element/substitution/metaLevel.js +0 -148
- package/lib/node/substitution/metaLevel.js +0 -40
- package/src/element/substitution/metaLevel.js +0 -212
- package/src/node/substitution/metaLevel.js +0 -37
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
|
-
import {
|
|
6
|
+
import { unifyAssumption } from "../process/unify";
|
|
7
7
|
import { instantiateAssumption } from "../process/instantiate";
|
|
8
|
+
import { assumptionFromAssumptionNode } from "../utilities/element";
|
|
9
|
+
import { assumptionStringFromStatementAndReference } from "../utilities/string";
|
|
10
|
+
import { join, descend, simplify, reconcile, instantiate } from "../utilities/context";
|
|
8
11
|
|
|
9
12
|
export default define(class Assumption extends Element {
|
|
10
13
|
constructor(context, string, node, reference, statement) {
|
|
@@ -33,6 +36,14 @@ export default define(class Assumption extends Element {
|
|
|
33
36
|
|
|
34
37
|
getTopLevelMetaAssertion() { return this.reference.getTopLevelMetaAssertion(); }
|
|
35
38
|
|
|
39
|
+
isEqualTo(assumption) {
|
|
40
|
+
const assumptionNode = assumption.getNode(),
|
|
41
|
+
assumptionNodeMatches = this.matchAssumptionNode(assumptionNode),
|
|
42
|
+
equalTo = assumptionNodeMatches; ///
|
|
43
|
+
|
|
44
|
+
return equalTo;
|
|
45
|
+
}
|
|
46
|
+
|
|
36
47
|
matchAssumptionNode(assumptionNode) {
|
|
37
48
|
const node = assumptionNode, ///
|
|
38
49
|
nodeMatches = this.matchNode(node),
|
|
@@ -41,39 +52,26 @@ export default define(class Assumption extends Element {
|
|
|
41
52
|
return assumptionNodeMatches;
|
|
42
53
|
}
|
|
43
54
|
|
|
44
|
-
|
|
45
|
-
let comparesToMetaLevelSubstitution = false;
|
|
46
|
-
|
|
47
|
-
const assumptionString = this.getString(), ///
|
|
48
|
-
metaLevelSubstitutionString = metaLevelSubstitution.getString();
|
|
49
|
-
|
|
50
|
-
context.trace(`Comparing the '${assumptionString}' assumption to the '${metaLevelSubstitutionString}' meta-level substitution...`);
|
|
51
|
-
|
|
52
|
-
debugger
|
|
53
|
-
|
|
54
|
-
if (comparesToMetaLevelSubstitution) {
|
|
55
|
-
context.debug(`...compared the '${assumptionString}' assumption to the '${metaLevelSubstitutionString}' meta-level substitution.`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return comparesToMetaLevelSubstitution;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
findValidAssumption(context) {
|
|
55
|
+
findValidAssumption(context, metaLevel = false) {
|
|
62
56
|
const assumptionNode = this.getAssumptionNode(),
|
|
63
|
-
assumption = context.findAssumptionByAssumptionNode(assumptionNode),
|
|
57
|
+
assumption = context.findAssumptionByAssumptionNode(assumptionNode, metaLevel),
|
|
64
58
|
validAssumption = assumption; ///
|
|
65
59
|
|
|
66
60
|
return validAssumption;
|
|
67
61
|
}
|
|
68
62
|
|
|
69
|
-
validate(context) {
|
|
63
|
+
validate(context, metaLevel = false) {
|
|
70
64
|
let assumption = null;
|
|
71
65
|
|
|
66
|
+
if (metaLevel) {
|
|
67
|
+
context = this.getContext();
|
|
68
|
+
}
|
|
69
|
+
|
|
72
70
|
const assumptionString = this.getString(); ///
|
|
73
71
|
|
|
74
72
|
context.trace(`Validating the '${assumptionString}' assumption...`);
|
|
75
73
|
|
|
76
|
-
const validAssumption = this.findValidAssumption(context);
|
|
74
|
+
const validAssumption = this.findValidAssumption(context, metaLevel);
|
|
77
75
|
|
|
78
76
|
if (validAssumption) {
|
|
79
77
|
assumption = validAssumption; ///
|
|
@@ -108,7 +106,7 @@ export default define(class Assumption extends Element {
|
|
|
108
106
|
if (validates) {
|
|
109
107
|
assumption = this; ///
|
|
110
108
|
|
|
111
|
-
context.addAssumption(assumption);
|
|
109
|
+
context.addAssumption(assumption, metaLevel);
|
|
112
110
|
|
|
113
111
|
context.debug(`...validated the '${assumptionString}' assumption.`);
|
|
114
112
|
}
|
|
@@ -216,6 +214,39 @@ export default define(class Assumption extends Element {
|
|
|
216
214
|
return validatesWhenDerived;
|
|
217
215
|
}
|
|
218
216
|
|
|
217
|
+
unifyAssumption(assumption, generalContext, specificContext) {
|
|
218
|
+
let assumptionUnifies;
|
|
219
|
+
|
|
220
|
+
const context = specificContext, ///
|
|
221
|
+
generalAssumption = this, ///
|
|
222
|
+
specificAssumption = assumption, ///
|
|
223
|
+
generalAssumptionString = generalAssumption.getString(),
|
|
224
|
+
specificAssumptionString = specificAssumption.getString();
|
|
225
|
+
|
|
226
|
+
context.trace(`Unifying the '${specificAssumptionString}' assumption with the '${generalAssumptionString}' assumption...`);
|
|
227
|
+
|
|
228
|
+
const assumptionContext = assumption.getContext();
|
|
229
|
+
|
|
230
|
+
specificContext = assumptionContext; ///
|
|
231
|
+
|
|
232
|
+
join((specificContext) => {
|
|
233
|
+
reconcile((specificContext) => {
|
|
234
|
+
assumptionUnifies = unifyAssumption(generalAssumption, specificAssumption, generalContext, specificContext);
|
|
235
|
+
|
|
236
|
+
if (assumptionUnifies) {
|
|
237
|
+
specificContext.commit(context);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
}, specificContext);
|
|
241
|
+
}, specificContext, context);
|
|
242
|
+
|
|
243
|
+
if (assumptionUnifies) {
|
|
244
|
+
context.debug(`...unified the '${specificAssumptionString}' assumption with the '${generalAssumptionString}' assumption.`);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return assumptionUnifies;
|
|
248
|
+
}
|
|
249
|
+
|
|
219
250
|
unifyTopLevelMetaAssertion(topLevelMetaAssertion, context) {
|
|
220
251
|
let topLevelMetaAssertionUnifies;
|
|
221
252
|
|
|
@@ -265,6 +296,24 @@ export default define(class Assumption extends Element {
|
|
|
265
296
|
|
|
266
297
|
return assumption;
|
|
267
298
|
}
|
|
299
|
+
|
|
300
|
+
static fromStatementAndReference(statement, reference, context) {
|
|
301
|
+
let assumption;
|
|
302
|
+
|
|
303
|
+
simplify((context) => {
|
|
304
|
+
instantiate((context) => {
|
|
305
|
+
const assumptionString = assumptionStringFromStatementAndReference(statement, reference),
|
|
306
|
+
string = assumptionString, ///
|
|
307
|
+
assumptionNode = instantiateAssumption(string, context);
|
|
308
|
+
|
|
309
|
+
assumption = assumptionFromAssumptionNode(assumptionNode, context);
|
|
310
|
+
|
|
311
|
+
assumption.setContext(context);
|
|
312
|
+
}, context);
|
|
313
|
+
}, context);
|
|
314
|
+
|
|
315
|
+
return assumption;
|
|
316
|
+
}
|
|
268
317
|
});
|
|
269
318
|
|
|
270
319
|
function referenceFromAssumptionNode(assumptionNode, context) {
|
package/src/element/frame.js
CHANGED
|
@@ -7,7 +7,7 @@ import { instantiateFrame } from "../process/instantiate";
|
|
|
7
7
|
import { FRAME_META_TYPE_NAME } from "../metaTypeNames";
|
|
8
8
|
import { metavariableFromFrameNode } from "../utilities/element";
|
|
9
9
|
import { descend, reconcile, instantiate } from "../utilities/context";
|
|
10
|
-
import { assumptionsStringFromAssumptions
|
|
10
|
+
import { assumptionsStringFromAssumptions } from "../utilities/string";
|
|
11
11
|
|
|
12
12
|
export default define(class Frame extends Element {
|
|
13
13
|
constructor(context, string, node, assumptions, metavariable) {
|
|
@@ -119,56 +119,6 @@ export default define(class Frame extends Element {
|
|
|
119
119
|
return comparesToMetavariableName;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
compareMetaLevelSubstitution(metaLevelSubstitution, context) {
|
|
123
|
-
let comparesToMetaLevelSubstitution;
|
|
124
|
-
|
|
125
|
-
const frameString = this.getString(), ///
|
|
126
|
-
metaLevelSubstitutionString = metaLevelSubstitution.getString();
|
|
127
|
-
|
|
128
|
-
context.trace(`Comparing the '${frameString}' frame to the '${metaLevelSubstitutionString}' meta-level substitution...`);
|
|
129
|
-
|
|
130
|
-
const metavariableNode = this.metavariable.getNode(),
|
|
131
|
-
judgements = context.findJudgementsByMetavariableNode(metavariableNode),
|
|
132
|
-
assumptions = assumptionsFromJudgements(judgements);
|
|
133
|
-
|
|
134
|
-
comparesToMetaLevelSubstitution = assumptions.some((assumption) => {
|
|
135
|
-
const assumptionComparesToSubstitution = assumption.compareMetaLevelSubstitution(metaLevelSubstitution, context);
|
|
136
|
-
|
|
137
|
-
if (assumptionComparesToSubstitution) {
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
if (comparesToMetaLevelSubstitution) {
|
|
143
|
-
context.debug(`...compared the '${frameString}' frame to the '${metaLevelSubstitutionString}' meta-level substitution.`);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return comparesToMetaLevelSubstitution;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
compareMetaLevelSubstitutions(metaLevelSubstitutions, context) {
|
|
150
|
-
let comparesToMetaLevelSubstitutions;
|
|
151
|
-
|
|
152
|
-
const frameString = this.getString(), ///
|
|
153
|
-
metaLevelSubstitutionsString = metaLevelSubstitutionsStringFromMetaLevelSubstitutions(metaLevelSubstitutions);
|
|
154
|
-
|
|
155
|
-
context.trace(`Comparing the '${frameString}' frame to the '${metaLevelSubstitutionsString}' meta-level substitution...`);
|
|
156
|
-
|
|
157
|
-
comparesToMetaLevelSubstitutions = metaLevelSubstitutions.every((metaLevelSubstitution) => {
|
|
158
|
-
const compaaresToMetaLevelSubstitution = this.compareMetaLevelSubstitution(metaLevelSubstitution, context);
|
|
159
|
-
|
|
160
|
-
if (compaaresToMetaLevelSubstitution) {
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
if (comparesToMetaLevelSubstitutions) {
|
|
166
|
-
context.debug(`...compared the '${frameString}' frame to the '${metaLevelSubstitutionsString}' metaLevelSubstitutions.`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return comparesToMetaLevelSubstitutions;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
122
|
findValidFrame(context) {
|
|
173
123
|
const frameNode = this.getFrameNode(),
|
|
174
124
|
frame = context.findFrameByFrameNode(frameNode),
|
|
@@ -391,13 +341,3 @@ function assumptionsFromFrameNode(frameNode, context) {
|
|
|
391
341
|
|
|
392
342
|
return assumptions;
|
|
393
343
|
}
|
|
394
|
-
|
|
395
|
-
function assumptionsFromJudgements(judgements) {
|
|
396
|
-
const assumptions = judgements.map((judgement) => {
|
|
397
|
-
const assumption = judgement.getAssumption();
|
|
398
|
-
|
|
399
|
-
return assumption;
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
return assumptions;
|
|
403
|
-
}
|
package/src/element/judgement.js
CHANGED
|
@@ -40,6 +40,8 @@ export default define(class Judgement extends Element {
|
|
|
40
40
|
|
|
41
41
|
getMetavariable() { return this.frame.getMetavariable(); }
|
|
42
42
|
|
|
43
|
+
getMetavariableNode() { return this.frame.getMetavariableNode(); }
|
|
44
|
+
|
|
43
45
|
matchJudgementNode(judgementNode) {
|
|
44
46
|
const node = judgementNode, ///
|
|
45
47
|
nodeMatches = this.matchNode(node),
|
|
@@ -185,12 +187,40 @@ export default define(class Judgement extends Element {
|
|
|
185
187
|
context.trace(`Validating the '${judgementString}' derived judgement...`);
|
|
186
188
|
|
|
187
189
|
const topLevelMetaAssertion = this.assumption.getTopLevelMetaAssertion(),
|
|
188
|
-
|
|
189
|
-
|
|
190
|
+
metavariableNode = this.getMetavariableNode(),
|
|
191
|
+
judgements = context.findJudgementsByMetavariableNode(metavariableNode);
|
|
190
192
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
193
|
+
let assumptions;
|
|
194
|
+
|
|
195
|
+
assumptions = topLevelMetaAssertion.getAssumptions();
|
|
196
|
+
|
|
197
|
+
const specificAssumptions = assumptions; ///
|
|
198
|
+
|
|
199
|
+
assumptions = assumptionsFromJudgements(judgements);
|
|
200
|
+
|
|
201
|
+
const generalAssumptions = assumptions; ///
|
|
202
|
+
|
|
203
|
+
reconcile((context) => {
|
|
204
|
+
const specificAssumptionsUnify = specificAssumptions.every((specificAssumption) => {
|
|
205
|
+
const specificAssumptionUnifies = generalAssumptions.some((generalAssumption) => {
|
|
206
|
+
const generalContext = context, ///
|
|
207
|
+
specificContext = context, ///
|
|
208
|
+
specificAssumptionUnifies = generalAssumption.unifyAssumption(specificAssumption, generalContext, specificContext);
|
|
209
|
+
|
|
210
|
+
if (specificAssumptionUnifies) {
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
if (specificAssumptionUnifies) {
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
if (specificAssumptionsUnify) {
|
|
221
|
+
validatesWhenDerived = true;
|
|
222
|
+
}
|
|
223
|
+
}, context);
|
|
194
224
|
|
|
195
225
|
if (validatesWhenDerived) {
|
|
196
226
|
context.debug(`...validated the '${judgementString}' derived judgement.`);
|
|
@@ -254,6 +284,16 @@ function frameFromJudgementNode(judgementNode, context) {
|
|
|
254
284
|
return frame;
|
|
255
285
|
}
|
|
256
286
|
|
|
287
|
+
function assumptionsFromJudgements(judgements) {
|
|
288
|
+
const assumptions = judgements.map((judgement) => {
|
|
289
|
+
const assumption = judgement.getAssumption();
|
|
290
|
+
|
|
291
|
+
return assumption;
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
return assumptions;
|
|
295
|
+
}
|
|
296
|
+
|
|
257
297
|
function assumptionFromJudgementNode(judgementNode, context) {
|
|
258
298
|
const assumptionNode = judgementNode.getAssumptionNode(),
|
|
259
299
|
assumption = context.findAssumptionByAssumptionNode(assumptionNode);
|
|
@@ -290,11 +290,10 @@ export default define(class Metavariable extends Element {
|
|
|
290
290
|
frameUnifies = true;
|
|
291
291
|
} else {
|
|
292
292
|
const metavariableName = this.getMetavariableName(),
|
|
293
|
-
|
|
293
|
+
substitution = context.findSimpleSubstitutionByMetavariableName(metavariableName);
|
|
294
294
|
|
|
295
|
-
if (
|
|
296
|
-
const
|
|
297
|
-
substitutionFrameComparesToFrame = substitution.compareFrame(frame, context);
|
|
295
|
+
if (substitution !== null) {
|
|
296
|
+
const substitutionFrameComparesToFrame = substitution.compareFrame(frame, context);
|
|
298
297
|
|
|
299
298
|
if (substitutionFrameComparesToFrame) {
|
|
300
299
|
const frameSubstitution = substitution, ///
|
|
@@ -402,12 +401,10 @@ export default define(class Metavariable extends Element {
|
|
|
402
401
|
referenceUnifies = true;
|
|
403
402
|
} else {
|
|
404
403
|
const metavariableName = this.getMetavariableName(),
|
|
405
|
-
|
|
404
|
+
substitution = context.findSubstitutionByMetavariableName(metavariableName);
|
|
406
405
|
|
|
407
|
-
if (
|
|
408
|
-
const
|
|
409
|
-
substitution = simpleSubstitution, ///
|
|
410
|
-
substitutionReferenceComparesToReference = substitution.compareReference(reference, context);
|
|
406
|
+
if (substitution !== null) {
|
|
407
|
+
const substitutionReferenceComparesToReference = substitution.compareReference(reference, context);
|
|
411
408
|
|
|
412
409
|
if (substitutionReferenceComparesToReference) {
|
|
413
410
|
const referenceSubstitution = substitution, ///
|
|
@@ -7,23 +7,23 @@ import { topLevelMetaAssertionStringFromLabelSuppositionsAndDeduction } from "..
|
|
|
7
7
|
import { labelFromJSON,
|
|
8
8
|
labelToLabelJSON,
|
|
9
9
|
deductionFromJSON,
|
|
10
|
+
assumptionsFromJSON,
|
|
10
11
|
suppositionsFromJSON,
|
|
11
12
|
deductionToDeductionJSON,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
metaLevelSubstitutionsToMetaLevelSubstitutionsJSON } from "../utilities/json";
|
|
13
|
+
assumptionsToAssumptionsJSON,
|
|
14
|
+
suppositionsToSuppositionsJSON } from "../utilities/json";
|
|
15
15
|
|
|
16
16
|
const { asyncForwardsEvery } = asynchronousUtilities;
|
|
17
17
|
|
|
18
18
|
export default class TopLevelMetaAssertion extends Element {
|
|
19
|
-
constructor(context, string, node, label, suppositions, deduction, proof,
|
|
19
|
+
constructor(context, string, node, label, suppositions, deduction, proof, assumptions) {
|
|
20
20
|
super(context, string, node);
|
|
21
21
|
|
|
22
22
|
this.label = label;
|
|
23
23
|
this.suppositions = suppositions;
|
|
24
24
|
this.deduction = deduction;
|
|
25
25
|
this.proof = proof;
|
|
26
|
-
this.
|
|
26
|
+
this.assumptions = assumptions;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
getLabel() {
|
|
@@ -42,8 +42,8 @@ export default class TopLevelMetaAssertion extends Element {
|
|
|
42
42
|
return this.proof;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
return this.
|
|
45
|
+
getAssumptions() {
|
|
46
|
+
return this.assumptions;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
getStatement() {
|
|
@@ -121,7 +121,7 @@ export default class TopLevelMetaAssertion extends Element {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
}, this.
|
|
124
|
+
}, this.assumptions, context);
|
|
125
125
|
|
|
126
126
|
if (verifies) {
|
|
127
127
|
context.debug(`...verified the '${topLevelMetaAssertionString}' top level meta assertion.`);
|
|
@@ -234,16 +234,16 @@ export default class TopLevelMetaAssertion extends Element {
|
|
|
234
234
|
const labelJSON = labelToLabelJSON(this.label),
|
|
235
235
|
deductionJSON = deductionToDeductionJSON(this.deduction),
|
|
236
236
|
suppositionsJSON = suppositionsToSuppositionsJSON(this.suppositions),
|
|
237
|
-
|
|
237
|
+
assumptionsJSON = assumptionsToAssumptionsJSON(this.assumptions),
|
|
238
238
|
label = labelJSON, ///
|
|
239
239
|
deduction = deductionJSON, ///
|
|
240
240
|
suppositions = suppositionsJSON, ///
|
|
241
|
-
|
|
241
|
+
assumptions = assumptionsJSON, ///
|
|
242
242
|
json = {
|
|
243
243
|
label,
|
|
244
244
|
deduction,
|
|
245
245
|
suppositions,
|
|
246
|
-
|
|
246
|
+
assumptions
|
|
247
247
|
};
|
|
248
248
|
|
|
249
249
|
return json;
|
|
@@ -253,11 +253,11 @@ export default class TopLevelMetaAssertion extends Element {
|
|
|
253
253
|
const label = labelFromJSON(json, context),
|
|
254
254
|
deduction = deductionFromJSON(json, context),
|
|
255
255
|
suppositions = suppositionsFromJSON(json, context),
|
|
256
|
-
|
|
256
|
+
assumptions = assumptionsFromJSON(json, context),
|
|
257
257
|
node = null,
|
|
258
258
|
proof = null,
|
|
259
259
|
string = topLevelMetaAssertionStringFromLabelSuppositionsAndDeduction(label, suppositions, deduction),
|
|
260
|
-
topLevelMetaAssertion = new Class(context, string, node, label, suppositions, deduction, proof,
|
|
260
|
+
topLevelMetaAssertion = new Class(context, string, node, label, suppositions, deduction, proof, assumptions);
|
|
261
261
|
|
|
262
262
|
return topLevelMetaAssertion;
|
|
263
263
|
}
|
|
@@ -79,7 +79,6 @@ import SimpleTypeDeclarationNode from "./node/declaration/simpleType";
|
|
|
79
79
|
import CombinatorDeclarationNode from "./node/declaration/combinator";
|
|
80
80
|
import ReferenceSubstitutionNode from "./node/substitution/reference";
|
|
81
81
|
import StatementSubstitutionNode from "./node/substitution/statement";
|
|
82
|
-
import MetaLevelSubstitutionNode from "./node/substitution/metaLevel";
|
|
83
82
|
import TypePrefixDeclarationNode from "./node/declaration/typePrefix";
|
|
84
83
|
import ComplexTypeDeclarationNode from "./node/declaration/complexType";
|
|
85
84
|
import DonstructorDeclarationNode from "./node/declaration/constructor";
|
|
@@ -164,7 +163,6 @@ import {
|
|
|
164
163
|
COMBINATOR_DECLARATION_RULE_NAME,
|
|
165
164
|
REFERENCE_SUBSTITUTION_RULE_NAME,
|
|
166
165
|
STATEMENT_SUBSTITUTION_RULE_NAME,
|
|
167
|
-
META_LEVEL_SUBSTITUTION_RULE_NAME,
|
|
168
166
|
SIMPLE_TYPE_DECLARATION_RULE_NAME,
|
|
169
167
|
CONSTRUCTOR_DECLARATION_RULE_NAME,
|
|
170
168
|
TYPE_PREFIX_DECLARATION_RULE_NAME,
|
|
@@ -250,7 +248,6 @@ const NonTerminalNodeMap = {
|
|
|
250
248
|
[COMBINATOR_DECLARATION_RULE_NAME]: CombinatorDeclarationNode,
|
|
251
249
|
[STATEMENT_SUBSTITUTION_RULE_NAME]: StatementSubstitutionNode,
|
|
252
250
|
[REFERENCE_SUBSTITUTION_RULE_NAME]: ReferenceSubstitutionNode,
|
|
253
|
-
[META_LEVEL_SUBSTITUTION_RULE_NAME]: MetaLevelSubstitutionNode,
|
|
254
251
|
[SIMPLE_TYPE_DECLARATION_RULE_NAME]: SimpleTypeDeclarationNode,
|
|
255
252
|
[TYPE_PREFIX_DECLARATION_RULE_NAME]: TypePrefixDeclarationNode,
|
|
256
253
|
[CONSTRUCTOR_DECLARATION_RULE_NAME]: DonstructorDeclarationNode,
|
package/src/preamble.js
CHANGED
|
@@ -57,7 +57,6 @@ import SimpleTypeDeclaration from "./element/declaration/simpleType";
|
|
|
57
57
|
import StatementSubstitution from "./element/substitution/statement";
|
|
58
58
|
import ReferenceSubstitution from "./element/substitution/reference";
|
|
59
59
|
import CombinatorDeclaration from "./element/declaration/combinator";
|
|
60
|
-
import MetaLevelSubstitution from "./element/substitution/metaLevel";
|
|
61
60
|
import TypePrefixDeclaration from "./element/declaration/typePrefix";
|
|
62
61
|
import ConstructorDeclaration from "./element/declaration/constructor";
|
|
63
62
|
import ComplexTypeDeclaration from "./element/declaration/complexType";
|
|
@@ -34,8 +34,7 @@ import { TERM_RULE_NAME,
|
|
|
34
34
|
CONTAINED_ASSERTION_RULE_NAME,
|
|
35
35
|
SATISFIES_ASSERTION_RULE_NAME,
|
|
36
36
|
STATEMENT_SUBSTITUTION_RULE_NAME,
|
|
37
|
-
REFERENCE_SUBSTITUTION_RULE_NAME
|
|
38
|
-
META_LEVEL_SUBSTITUTION_RULE_NAME } from "../ruleNames";
|
|
37
|
+
REFERENCE_SUBSTITUTION_RULE_NAME } from "../ruleNames";
|
|
39
38
|
|
|
40
39
|
const termPlaceholderRule = ruleFromRuleName(TERM_RULE_NAME),
|
|
41
40
|
typePlaceholderRule = ruleFromRuleName(TYPE_RULE_NAME),
|
|
@@ -70,8 +69,7 @@ const termPlaceholderRule = ruleFromRuleName(TERM_RULE_NAME),
|
|
|
70
69
|
containedAssertionPlaceholderRule = ruleFromRuleName(CONTAINED_ASSERTION_RULE_NAME),
|
|
71
70
|
satisfiesAssertionPlaceholderRule = ruleFromRuleName(SATISFIES_ASSERTION_RULE_NAME),
|
|
72
71
|
statementSubstitutionPlaceholderRule = ruleFromRuleName(STATEMENT_SUBSTITUTION_RULE_NAME),
|
|
73
|
-
referenceSubstitutionPlaceholderRule = ruleFromRuleName(REFERENCE_SUBSTITUTION_RULE_NAME)
|
|
74
|
-
metaLevelSubstitutionPlaceholderRule = ruleFromRuleName(META_LEVEL_SUBSTITUTION_RULE_NAME);
|
|
72
|
+
referenceSubstitutionPlaceholderRule = ruleFromRuleName(REFERENCE_SUBSTITUTION_RULE_NAME);
|
|
75
73
|
|
|
76
74
|
export function instantiatePremise(string, context) {
|
|
77
75
|
string = `${string}
|
|
@@ -161,8 +159,6 @@ export function instantiateStatementSubstitution(string, context) { return insta
|
|
|
161
159
|
|
|
162
160
|
export function instantiateReferenceSubstitution(string, context) { return instantiate(referenceSubstitutionPlaceholderRule, string, context); }
|
|
163
161
|
|
|
164
|
-
export function instantiateMetaLevelSubstitution(string, context) { return instantiate(metaLevelSubstitutionPlaceholderRule, string, context); }
|
|
165
|
-
|
|
166
162
|
function instantiate(placeholderRule, string, context) {
|
|
167
163
|
let node;
|
|
168
164
|
|
package/src/process/unify.js
CHANGED
|
@@ -14,8 +14,9 @@ const typeNodeQuery = nodeQuery("/type"),
|
|
|
14
14
|
frameNodeQuery = nodeQuery("/frame"),
|
|
15
15
|
metaTypeNodeQuery = nodeQuery("/metaType"),
|
|
16
16
|
statementNodeQuery = nodeQuery("/statement"),
|
|
17
|
+
metavariableNodeQuery = nodeQuery("/metavariable"),
|
|
17
18
|
termVariableNodeQuery = nodeQuery("/term/variable!"),
|
|
18
|
-
|
|
19
|
+
frameMetavariableNodeQuery = nodeQuery("/frame/metavariable!"),
|
|
19
20
|
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!"),
|
|
20
21
|
assumptionMetavariableNodeQuery = nodeQuery("/assumption/metavariable!");
|
|
21
22
|
|
|
@@ -89,7 +90,7 @@ class MetaLevelPass extends ZipPassBase {
|
|
|
89
90
|
}
|
|
90
91
|
},
|
|
91
92
|
{
|
|
92
|
-
generalNodeQuery:
|
|
93
|
+
generalNodeQuery: frameMetavariableNodeQuery,
|
|
93
94
|
specificNodeQuery: frameNodeQuery,
|
|
94
95
|
run: (generalFrameMetavariableNode, specificFrameNode, generalContext, specificContext) => {
|
|
95
96
|
let success = false;
|
|
@@ -147,6 +148,98 @@ class MetaLevelPass extends ZipPassBase {
|
|
|
147
148
|
];
|
|
148
149
|
}
|
|
149
150
|
|
|
151
|
+
class AssumptionPass extends ZipPass {
|
|
152
|
+
static maps = [
|
|
153
|
+
{
|
|
154
|
+
generalNodeQuery: statementMetavariableNodeQuery,
|
|
155
|
+
specificNodeQuery: statementNodeQuery,
|
|
156
|
+
run: (generalStatementMetavariableNode, specificStatementNode, generalContext, specificContext) => {
|
|
157
|
+
let success = false;
|
|
158
|
+
|
|
159
|
+
const statementNode = specificStatementNode, ///
|
|
160
|
+
metavariableNode = generalStatementMetavariableNode, ///
|
|
161
|
+
metavariableName = metavariableNode.getMetavariableName();
|
|
162
|
+
|
|
163
|
+
let context;
|
|
164
|
+
|
|
165
|
+
context = generalContext; ///
|
|
166
|
+
|
|
167
|
+
const metavariable = context.findMetavariableByMetavariableName(metavariableName);
|
|
168
|
+
|
|
169
|
+
context = specificContext; ///
|
|
170
|
+
|
|
171
|
+
const statement = context.findStatementByStatementNode(statementNode),
|
|
172
|
+
substitution = null,
|
|
173
|
+
statementUnifies = metavariable.unifyStatement(statement, substitution, generalContext, specificContext);
|
|
174
|
+
|
|
175
|
+
if (statementUnifies) {
|
|
176
|
+
success = true;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return success;
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
generalNodeQuery: metavariableNodeQuery,
|
|
184
|
+
specificNodeQuery: metavariableNodeQuery,
|
|
185
|
+
run: (generalMetavariableNode, specificMetavariableNode, generalContext, specificContext) => {
|
|
186
|
+
let success = false;
|
|
187
|
+
|
|
188
|
+
let context,
|
|
189
|
+
metavariableNode;
|
|
190
|
+
|
|
191
|
+
context = generalContext; ///
|
|
192
|
+
|
|
193
|
+
metavariableNode = generalMetavariableNode; ///
|
|
194
|
+
|
|
195
|
+
const metavariableName = metavariableNode.getMetavariableName(),
|
|
196
|
+
metavariable = context.findMetavariableByMetavariableName(metavariableName);
|
|
197
|
+
|
|
198
|
+
context = specificContext; ///
|
|
199
|
+
|
|
200
|
+
metavariableNode = specificMetavariableNode; ///
|
|
201
|
+
|
|
202
|
+
const reference = context.findReferenceByMetavariableNode(metavariableNode),
|
|
203
|
+
referenceUnifies = metavariable.unifyReference(reference, generalContext, specificContext);
|
|
204
|
+
|
|
205
|
+
if (referenceUnifies) {
|
|
206
|
+
success = true;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return success;
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
generalNodeQuery: termVariableNodeQuery,
|
|
214
|
+
specificNodeQuery: termNodeQuery,
|
|
215
|
+
run: (generalTermVariableNode, specificTermNode, generalContext, specificContext) => {
|
|
216
|
+
let success = false;
|
|
217
|
+
|
|
218
|
+
const termNode = specificTermNode, ///
|
|
219
|
+
variableNode = generalTermVariableNode, ///
|
|
220
|
+
variableIdentifier = variableNode.getVariableIdentifier();
|
|
221
|
+
|
|
222
|
+
let context;
|
|
223
|
+
|
|
224
|
+
context = generalContext; ///
|
|
225
|
+
|
|
226
|
+
const variable = context.findVariableByVariableIdentifier(variableIdentifier);
|
|
227
|
+
|
|
228
|
+
context = specificContext; ///
|
|
229
|
+
|
|
230
|
+
const term = context.findTermByTermNode(termNode),
|
|
231
|
+
termUnifies = variable.unifyTerm(term, generalContext, specificContext);
|
|
232
|
+
|
|
233
|
+
if (termUnifies) {
|
|
234
|
+
success = true;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return success;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
|
|
150
243
|
class CombinatorPass extends ZipPass {
|
|
151
244
|
static maps = [
|
|
152
245
|
{
|
|
@@ -307,7 +400,7 @@ class MetavariablePass extends ZipPass {
|
|
|
307
400
|
class SubstitutionPass extends ZipPass {
|
|
308
401
|
static maps = [
|
|
309
402
|
{
|
|
310
|
-
generalNodeQuery:
|
|
403
|
+
generalNodeQuery: frameMetavariableNodeQuery,
|
|
311
404
|
specificNodeQuery: frameNodeQuery,
|
|
312
405
|
run: (generalFrameMetavariableNode, specificFrameNode, generalContext, specificContext) => {
|
|
313
406
|
let success = false;
|
|
@@ -399,6 +492,7 @@ class IntrinsicLevelPass extends ZipPass {
|
|
|
399
492
|
}
|
|
400
493
|
|
|
401
494
|
const metaLevelPass = new MetaLevelPass(),
|
|
495
|
+
assumptionPass = new AssumptionPass(),
|
|
402
496
|
combinatorPass = new CombinatorPass(),
|
|
403
497
|
constructorPass = new ConstructorPass(),
|
|
404
498
|
metavariablePass = new MetavariablePass(),
|
|
@@ -421,14 +515,30 @@ export function unifyStatement(generalStatement, specificStatement, generalConte
|
|
|
421
515
|
return statementUnifies;
|
|
422
516
|
}
|
|
423
517
|
|
|
518
|
+
export function unifyAssumption(generalAssumption, specificAssumption, generalContext, specificContext) {
|
|
519
|
+
let assumptionUnifies = false;
|
|
520
|
+
|
|
521
|
+
const generalAssumptionNode = generalAssumption.getNode(),
|
|
522
|
+
specificAssumptionNode = specificAssumption.getNode(),
|
|
523
|
+
generalNode = generalAssumptionNode, ///
|
|
524
|
+
specificNode = specificAssumptionNode, ///
|
|
525
|
+
success = assumptionPass.run(generalNode, specificNode, generalContext, specificContext);
|
|
526
|
+
|
|
527
|
+
if (success) {
|
|
528
|
+
assumptionUnifies = true;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
return assumptionUnifies;
|
|
532
|
+
}
|
|
533
|
+
|
|
424
534
|
export function unifySubstitution(generalSubstitution, specificSubstitution, generalContext, specificContext) {
|
|
425
535
|
let substitutionUnifies = false;
|
|
426
536
|
|
|
427
537
|
const generalSubstitutionNode = generalSubstitution.getNode(),
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
538
|
+
specificSubstitutionNode = specificSubstitution.getNode(),
|
|
539
|
+
generalNode = generalSubstitutionNode, ///
|
|
540
|
+
specificNode = specificSubstitutionNode, ///
|
|
541
|
+
success = substitutionPass.run(generalNode, specificNode, generalContext, specificContext);
|
|
432
542
|
|
|
433
543
|
if (success) {
|
|
434
544
|
substitutionUnifies = true;
|
package/src/ruleNames.js
CHANGED
|
@@ -78,7 +78,6 @@ export const VARIABLE_DECLARATION_RULE_NAME = "variableDeclaration";
|
|
|
78
78
|
export const COMBINATOR_DECLARATION_RULE_NAME = "combinatorDeclaration";
|
|
79
79
|
export const STATEMENT_SUBSTITUTION_RULE_NAME = "statementSubstitution";
|
|
80
80
|
export const REFERENCE_SUBSTITUTION_RULE_NAME = "referenceSubstitution";
|
|
81
|
-
export const META_LEVEL_SUBSTITUTION_RULE_NAME = "metaLevelSubstitution";
|
|
82
81
|
export const TYPE_PREFIX_DECLARATION_RULE_NAME = "typePrefixDeclaration";
|
|
83
82
|
export const SIMPLE_TYPE_DECLARATION_RULE_NAME = "simpleTypeDeclaration";
|
|
84
83
|
export const CONSTRUCTOR_DECLARATION_RULE_NAME = "constructorDeclaration";
|