occam-verify-cli 1.0.776 → 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/nested.js +5 -1
- package/lib/context/proof.js +74 -59
- package/lib/context.js +20 -20
- package/lib/element/assertion/contained.js +9 -3
- package/lib/element/assertion/defined.js +28 -22
- package/lib/element/assertion/property.js +5 -1
- package/lib/element/assertion/satisfies.js +5 -1
- package/lib/element/assertion/subproof.js +6 -1
- package/lib/element/assertion/type.js +6 -2
- package/lib/element/assumption.js +47 -20
- package/lib/element/equivalences.js +4 -2
- package/lib/element/frame.js +17 -41
- package/lib/element/judgement.js +42 -6
- package/lib/element/metavariable.js +15 -11
- package/lib/element/proofAssertion/step.js +44 -4
- 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 +13 -11
- package/lib/utilities/validation.js +17 -10
- 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/nested.js +6 -0
- package/src/context/proof.js +93 -73
- package/src/context.js +27 -26
- package/src/element/assertion/contained.js +16 -3
- package/src/element/assertion/defined.js +32 -23
- package/src/element/assertion/property.js +8 -1
- package/src/element/assertion/satisfies.js +8 -1
- package/src/element/assertion/subproof.js +8 -0
- package/src/element/assertion/type.js +8 -1
- package/src/element/assumption.js +72 -31
- package/src/element/equivalences.js +5 -2
- package/src/element/frame.js +29 -66
- package/src/element/judgement.js +56 -6
- package/src/element/metavariable.js +22 -18
- package/src/element/proofAssertion/step.js +4 -3
- 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 +17 -16
- package/src/utilities/validation.js +24 -16
- package/lib/element/substitution/metaLevel.js +0 -148
- package/lib/node/substitution/metaLevel.js +0 -40
- package/lib/utilities/statement.js +0 -71
- package/src/element/substitution/metaLevel.js +0 -212
- package/src/node/substitution/metaLevel.js +0 -37
- package/src/utilities/statement.js +0 -66
|
@@ -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,46 +52,26 @@ export default define(class Assumption extends Element {
|
|
|
41
52
|
return assumptionNodeMatches;
|
|
42
53
|
}
|
|
43
54
|
|
|
44
|
-
|
|
45
|
-
let comparesToSubstituion = false;
|
|
46
|
-
|
|
47
|
-
const assumptionString = this.getString(), ///
|
|
48
|
-
substitutionString = substitution.getString();
|
|
49
|
-
|
|
50
|
-
context.trace(`Comparing the '${assumptionString}' assumption to the '${substitutionString}' substitution...`);
|
|
51
|
-
|
|
52
|
-
const statement = substitution.getStatement(),
|
|
53
|
-
metavariableName = substitution.getMetavariableName(),
|
|
54
|
-
statementEqualToStatement = this.statement.isEqualTo(statement),
|
|
55
|
-
referenceMetavariableComparesToMetavariable = this.reference.compareMetavariableName(metavariableName);
|
|
56
|
-
|
|
57
|
-
if (statementEqualToStatement && referenceMetavariableComparesToMetavariable) {
|
|
58
|
-
comparesToSubstituion = true;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (comparesToSubstituion) {
|
|
62
|
-
context.debug(`...compared the '${substitutionString}' assumption to the '${assumptionString}' substitution.`);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return comparesToSubstituion;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
findValidAssumption(context) {
|
|
55
|
+
findValidAssumption(context, metaLevel = false) {
|
|
69
56
|
const assumptionNode = this.getAssumptionNode(),
|
|
70
|
-
assumption = context.findAssumptionByAssumptionNode(assumptionNode),
|
|
57
|
+
assumption = context.findAssumptionByAssumptionNode(assumptionNode, metaLevel),
|
|
71
58
|
validAssumption = assumption; ///
|
|
72
59
|
|
|
73
60
|
return validAssumption;
|
|
74
61
|
}
|
|
75
62
|
|
|
76
|
-
validate(context) {
|
|
63
|
+
validate(context, metaLevel = false) {
|
|
77
64
|
let assumption = null;
|
|
78
65
|
|
|
66
|
+
if (metaLevel) {
|
|
67
|
+
context = this.getContext();
|
|
68
|
+
}
|
|
69
|
+
|
|
79
70
|
const assumptionString = this.getString(); ///
|
|
80
71
|
|
|
81
72
|
context.trace(`Validating the '${assumptionString}' assumption...`);
|
|
82
73
|
|
|
83
|
-
const validAssumption = this.findValidAssumption(context);
|
|
74
|
+
const validAssumption = this.findValidAssumption(context, metaLevel);
|
|
84
75
|
|
|
85
76
|
if (validAssumption) {
|
|
86
77
|
assumption = validAssumption; ///
|
|
@@ -115,7 +106,7 @@ export default define(class Assumption extends Element {
|
|
|
115
106
|
if (validates) {
|
|
116
107
|
assumption = this; ///
|
|
117
108
|
|
|
118
|
-
context.addAssumption(assumption);
|
|
109
|
+
context.addAssumption(assumption, metaLevel);
|
|
119
110
|
|
|
120
111
|
context.debug(`...validated the '${assumptionString}' assumption.`);
|
|
121
112
|
}
|
|
@@ -208,7 +199,6 @@ export default define(class Assumption extends Element {
|
|
|
208
199
|
const assumptionString = this.getString(); ///
|
|
209
200
|
|
|
210
201
|
context.trace(`Validating the '${assumptionString}' derived assumption...`);
|
|
211
|
-
|
|
212
202
|
const topLevelMetaAssertion = this.getTopLevelMetaAssertion();
|
|
213
203
|
|
|
214
204
|
if (topLevelMetaAssertion !== null) {
|
|
@@ -224,6 +214,39 @@ export default define(class Assumption extends Element {
|
|
|
224
214
|
return validatesWhenDerived;
|
|
225
215
|
}
|
|
226
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
|
+
|
|
227
250
|
unifyTopLevelMetaAssertion(topLevelMetaAssertion, context) {
|
|
228
251
|
let topLevelMetaAssertionUnifies;
|
|
229
252
|
|
|
@@ -273,6 +296,24 @@ export default define(class Assumption extends Element {
|
|
|
273
296
|
|
|
274
297
|
return assumption;
|
|
275
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
|
+
}
|
|
276
317
|
});
|
|
277
318
|
|
|
278
319
|
function referenceFromAssumptionNode(assumptionNode, context) {
|
|
@@ -203,8 +203,11 @@ export default define(class Equivalences extends Element {
|
|
|
203
203
|
static fromNothing(context) {
|
|
204
204
|
const string = EMPTY_STRING,
|
|
205
205
|
node = null,
|
|
206
|
-
array = []
|
|
207
|
-
|
|
206
|
+
array = [];
|
|
207
|
+
|
|
208
|
+
context = null;
|
|
209
|
+
|
|
210
|
+
const equivalences = new Equivalences(context, string, node, array);
|
|
208
211
|
|
|
209
212
|
return equivalences;
|
|
210
213
|
}
|
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) {
|
|
@@ -46,22 +46,6 @@ export default define(class Frame extends Element {
|
|
|
46
46
|
return metavariableName;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
matchFrameNode(frameNode) {
|
|
50
|
-
const node = frameNode, ///
|
|
51
|
-
nodeMatches = this.matchNode(node),
|
|
52
|
-
frameNodeMatches = nodeMatches; ///
|
|
53
|
-
|
|
54
|
-
return frameNodeMatches;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
findValidFrame(context) {
|
|
58
|
-
const frameNode = this.getFrameNode(),
|
|
59
|
-
frame = context.findFrameByFrameNode(frameNode),
|
|
60
|
-
validFrame = frame; ///
|
|
61
|
-
|
|
62
|
-
return validFrame;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
49
|
isEqualTo(frame) {
|
|
66
50
|
const frameNode = frame.getNode(),
|
|
67
51
|
frameNodeMatches = this.matchFrameNode(frameNode),
|
|
@@ -77,6 +61,26 @@ export default define(class Frame extends Element {
|
|
|
77
61
|
return singular;
|
|
78
62
|
}
|
|
79
63
|
|
|
64
|
+
matchFrameNode(frameNode) {
|
|
65
|
+
const node = frameNode, ///
|
|
66
|
+
nodeMatches = this.matchNode(node),
|
|
67
|
+
frameNodeMatches = nodeMatches; ///
|
|
68
|
+
|
|
69
|
+
return frameNodeMatches;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
matchMetavariableNode(metavariableNode) {
|
|
73
|
+
let metavariableNodeMatches = false;
|
|
74
|
+
|
|
75
|
+
const singular = this.isSingular();
|
|
76
|
+
|
|
77
|
+
if (singular) {
|
|
78
|
+
metavariableNodeMatches = this.metavariable.matchMetavariableNode(metavariableNode);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return metavariableNodeMatches;
|
|
82
|
+
}
|
|
83
|
+
|
|
80
84
|
compareParameter(parameter) {
|
|
81
85
|
let comparesToParamter = false;
|
|
82
86
|
|
|
@@ -97,54 +101,6 @@ export default define(class Frame extends Element {
|
|
|
97
101
|
return comparesToParamter;
|
|
98
102
|
}
|
|
99
103
|
|
|
100
|
-
compareMetaLevelSubstitution(metaLevelSubstitution, context) {
|
|
101
|
-
let comparesToMetaLevelSubstitution = false;
|
|
102
|
-
|
|
103
|
-
const frameString = this.getString(), ///
|
|
104
|
-
metaLevelSubstitutioString = metaLevelSubstitution.getString();
|
|
105
|
-
|
|
106
|
-
context.trace(`Comparing the '${frameString}' frame to the '${metaLevelSubstitutioString}' meta-level substitutio...`);
|
|
107
|
-
|
|
108
|
-
if (!comparesToMetaLevelSubstitution) {
|
|
109
|
-
comparesToMetaLevelSubstitution = this.assumptions.some((assumption) => {
|
|
110
|
-
const assumptionComparesToSubstitution = assumption.compareMetaLevelSubstitution(metaLevelSubstitution, context);
|
|
111
|
-
|
|
112
|
-
if (assumptionComparesToSubstitution) {
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (comparesToMetaLevelSubstitution) {
|
|
119
|
-
context.debug(`...compared the the '${frameString}' frame to the '${metaLevelSubstitutioString}' meta-Level-substituution.`);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return comparesToMetaLevelSubstitution;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
compareMetaLevelSubstitutions(metaLevelSubstitutions, context) {
|
|
126
|
-
let comparesToMetaLevelSubstitutions;
|
|
127
|
-
|
|
128
|
-
const frameString = this.getString(), ///
|
|
129
|
-
metaLevelSubstitutionsString = metaLevelSubstitutionsStringFromMetaLevelSubstitutions(metaLevelSubstitutions);
|
|
130
|
-
|
|
131
|
-
context.trace(`Comparing the '${frameString}' frame to the '${metaLevelSubstitutionsString}' meta-level substitutio...`);
|
|
132
|
-
|
|
133
|
-
comparesToMetaLevelSubstitutions = metaLevelSubstitutions.every((metaLevelSubstitution) => {
|
|
134
|
-
const compaaresToMetaLevelSubstitution = this.compareMetaLevelSubstitution(metaLevelSubstitution, context);
|
|
135
|
-
|
|
136
|
-
if (compaaresToMetaLevelSubstitution) {
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
if (comparesToMetaLevelSubstitutions) {
|
|
142
|
-
context.debug(`...compared the '${frameString}' frame to the '${metaLevelSubstitutionsString}' metaLevelSubstitutions.`);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return comparesToMetaLevelSubstitutions;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
104
|
compareMetavariableName(metavariableName) {
|
|
149
105
|
let comparesToMetavariableName = false;
|
|
150
106
|
|
|
@@ -163,6 +119,14 @@ export default define(class Frame extends Element {
|
|
|
163
119
|
return comparesToMetavariableName;
|
|
164
120
|
}
|
|
165
121
|
|
|
122
|
+
findValidFrame(context) {
|
|
123
|
+
const frameNode = this.getFrameNode(),
|
|
124
|
+
frame = context.findFrameByFrameNode(frameNode),
|
|
125
|
+
validFrame = frame; ///
|
|
126
|
+
|
|
127
|
+
return validFrame;
|
|
128
|
+
}
|
|
129
|
+
|
|
166
130
|
validate(context) {
|
|
167
131
|
let frame = null;
|
|
168
132
|
|
|
@@ -377,4 +341,3 @@ function assumptionsFromFrameNode(frameNode, context) {
|
|
|
377
341
|
|
|
378
342
|
return assumptions;
|
|
379
343
|
}
|
|
380
|
-
|
package/src/element/judgement.js
CHANGED
|
@@ -5,6 +5,7 @@ import { Element } from "occam-languages";
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
import { instantiateJudgement } from "../process/instantiate";
|
|
7
7
|
import { reconcile, instantiate } from "../utilities/context";
|
|
8
|
+
import { judgementFromStatementNode } from "../utilities/element";
|
|
8
9
|
import { judgementAssignmentFromJudgement } from "../process/assign";
|
|
9
10
|
|
|
10
11
|
export default define(class Judgement extends Element {
|
|
@@ -19,7 +20,7 @@ export default define(class Judgement extends Element {
|
|
|
19
20
|
return this.frame;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
getAssumption() {
|
|
23
24
|
return this.assumption;
|
|
24
25
|
}
|
|
25
26
|
|
|
@@ -39,6 +40,8 @@ export default define(class Judgement extends Element {
|
|
|
39
40
|
|
|
40
41
|
getMetavariable() { return this.frame.getMetavariable(); }
|
|
41
42
|
|
|
43
|
+
getMetavariableNode() { return this.frame.getMetavariableNode(); }
|
|
44
|
+
|
|
42
45
|
matchJudgementNode(judgementNode) {
|
|
43
46
|
const node = judgementNode, ///
|
|
44
47
|
nodeMatches = this.matchNode(node),
|
|
@@ -47,6 +50,8 @@ export default define(class Judgement extends Element {
|
|
|
47
50
|
return judgementNodeMatches;
|
|
48
51
|
}
|
|
49
52
|
|
|
53
|
+
matchMetavariableNode(metavariableNode) { return this.frame.matchMetavariableNode(metavariableNode); }
|
|
54
|
+
|
|
50
55
|
compareMetavariableName(metavariableName) { return this.frame.compareMetavariableName(metavariableName); }
|
|
51
56
|
|
|
52
57
|
findValidJudgement(context) {
|
|
@@ -182,12 +187,40 @@ export default define(class Judgement extends Element {
|
|
|
182
187
|
context.trace(`Validating the '${judgementString}' derived judgement...`);
|
|
183
188
|
|
|
184
189
|
const topLevelMetaAssertion = this.assumption.getTopLevelMetaAssertion(),
|
|
185
|
-
|
|
186
|
-
|
|
190
|
+
metavariableNode = this.getMetavariableNode(),
|
|
191
|
+
judgements = context.findJudgementsByMetavariableNode(metavariableNode);
|
|
187
192
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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);
|
|
191
224
|
|
|
192
225
|
if (validatesWhenDerived) {
|
|
193
226
|
context.debug(`...validated the '${judgementString}' derived judgement.`);
|
|
@@ -235,6 +268,13 @@ export default define(class Judgement extends Element {
|
|
|
235
268
|
return judgement;
|
|
236
269
|
}, context);
|
|
237
270
|
}
|
|
271
|
+
|
|
272
|
+
static fromStatement(statement, context) {
|
|
273
|
+
const statementNode = statement.getNode(),
|
|
274
|
+
judgement = judgementFromStatementNode(statementNode, context);
|
|
275
|
+
|
|
276
|
+
return judgement;
|
|
277
|
+
}
|
|
238
278
|
});
|
|
239
279
|
|
|
240
280
|
function frameFromJudgementNode(judgementNode, context) {
|
|
@@ -244,6 +284,16 @@ function frameFromJudgementNode(judgementNode, context) {
|
|
|
244
284
|
return frame;
|
|
245
285
|
}
|
|
246
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
|
+
|
|
247
297
|
function assumptionFromJudgementNode(judgementNode, context) {
|
|
248
298
|
const assumptionNode = judgementNode.getAssumptionNode(),
|
|
249
299
|
assumption = context.findAssumptionByAssumptionNode(assumptionNode);
|
|
@@ -10,7 +10,7 @@ import { EMPTY_STRING } from "../constants";
|
|
|
10
10
|
import { instantiateMetavariable } from "../process/instantiate";
|
|
11
11
|
import { metaTypeFromJSON, metaTypeToMetaTypeJSON } from "../utilities/json";
|
|
12
12
|
import { unifyMetavariable, unifyMetavariableIntrinsically } from "../process/unify";
|
|
13
|
-
import { nameFromMetavariableNode, termFromMetavariableNode, typeFromMetavariableNode } from "../utilities/element";
|
|
13
|
+
import { nameFromMetavariableNode, termFromMetavariableNode, typeFromMetavariableNode, metavariableFromStatementNode } from "../utilities/element";
|
|
14
14
|
|
|
15
15
|
export default define(class Metavariable extends Element {
|
|
16
16
|
constructor(context, string, node, name, term, type, metaType) {
|
|
@@ -58,6 +58,14 @@ export default define(class Metavariable extends Element {
|
|
|
58
58
|
|
|
59
59
|
isMetaTypeEqualTo(metaType) { return this.metaType.isEqualTo(metaType); }
|
|
60
60
|
|
|
61
|
+
matchMetavariableNode(metavariableNode) {
|
|
62
|
+
const node = metavariableNode, ///
|
|
63
|
+
nodeMatches = this.matchNode(node),
|
|
64
|
+
metavariableNodeMatches = nodeMatches; ///
|
|
65
|
+
|
|
66
|
+
return metavariableNodeMatches;
|
|
67
|
+
}
|
|
68
|
+
|
|
61
69
|
compare(metavariable) {
|
|
62
70
|
const metavariableName = metavariable.getName(),
|
|
63
71
|
comparesToMetavariableName = this.compareMetavariableName(metavariableName),
|
|
@@ -73,14 +81,6 @@ export default define(class Metavariable extends Element {
|
|
|
73
81
|
return comparesToMetavariableName;
|
|
74
82
|
}
|
|
75
83
|
|
|
76
|
-
matchMetavariableNode(metavariableNode) {
|
|
77
|
-
const node = metavariableNode, ///
|
|
78
|
-
nodeMatches = this.matchNode(node),
|
|
79
|
-
metavariableNodeMatches = nodeMatches; ///
|
|
80
|
-
|
|
81
|
-
return metavariableNodeMatches;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
84
|
verify(context) {
|
|
85
85
|
let verifies = false;
|
|
86
86
|
|
|
@@ -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, ///
|
|
@@ -625,4 +622,11 @@ export default define(class Metavariable extends Element {
|
|
|
625
622
|
return metavariable;
|
|
626
623
|
}, context);
|
|
627
624
|
}
|
|
625
|
+
|
|
626
|
+
static fromStatement(statement, context) {
|
|
627
|
+
const statementNode = statement.getNode(),
|
|
628
|
+
metavariable = metavariableFromStatementNode(statementNode, context);
|
|
629
|
+
|
|
630
|
+
return metavariable;
|
|
631
|
+
}
|
|
628
632
|
});
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import { asynchronousUtilities } from "occam-languages";
|
|
4
4
|
|
|
5
|
+
import elements from "../../elements";
|
|
5
6
|
import ProofAssertion from "../proofAssertion";
|
|
6
7
|
|
|
7
8
|
import { define } from "../../elements";
|
|
8
9
|
import { unifyStatements } from "../../utilities/unification";
|
|
9
|
-
import { propertyAssertionFromStatement } from "../../utilities/statement";
|
|
10
10
|
import { derive, attempt, descend, asyncReconcile } from "../../utilities/context";
|
|
11
11
|
|
|
12
12
|
const { asyncSome } = asynchronousUtilities;
|
|
@@ -49,8 +49,9 @@ export default define(class Step extends ProofAssertion {
|
|
|
49
49
|
compareTermAndPropertyRelation(term, propertyRelation, context) {
|
|
50
50
|
let comparesToTermAndPropertyRelation = false;
|
|
51
51
|
|
|
52
|
-
const
|
|
53
|
-
|
|
52
|
+
const { PropertyAssertion } = elements,
|
|
53
|
+
statement = this.getStatement(),
|
|
54
|
+
propertyAssertion = PropertyAssertion.fromStatement(statement, context);
|
|
54
55
|
|
|
55
56
|
if (propertyAssertion !== null) {
|
|
56
57
|
comparesToTermAndPropertyRelation = propertyAssertion.compareTermAndPropertyRelation(term, propertyRelation, context);
|
|
@@ -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
|
|