occam-verify-cli 1.0.800 → 1.0.806
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 +2 -2
- package/lib/context/ephemeral.js +186 -69
- package/lib/context/file/nominal.js +87 -52
- package/lib/context/liminal.js +2 -2
- package/lib/context/proof.js +55 -55
- package/lib/context/synthetic.js +151 -74
- package/lib/context.js +57 -17
- package/lib/element/assertion/defined.js +3 -3
- package/lib/element/assumption/metaLevel.js +6 -4
- package/lib/element/combinator.js +4 -2
- package/lib/element/conclusion.js +4 -2
- package/lib/element/constructor.js +4 -2
- package/lib/element/declaration/metavariable.js +10 -9
- package/lib/element/declaration/variable.js +7 -7
- package/lib/element/deduction.js +4 -2
- package/lib/element/label.js +9 -5
- package/lib/element/metavariable.js +34 -34
- package/lib/element/proofAssertion/premise.js +4 -3
- package/lib/element/proofAssertion/step.js +4 -2
- package/lib/element/reference.js +6 -4
- package/lib/element/statement.js +9 -1
- package/lib/element/substitution/frame.js +43 -29
- package/lib/element/substitution/reference.js +38 -28
- package/lib/element/substitution/statement.js +46 -38
- package/lib/element/substitution/term.js +49 -35
- package/lib/element/variable.js +6 -7
- package/lib/preamble.js +1 -2
- package/lib/process/assign.js +11 -10
- package/lib/process/equate.js +3 -2
- package/lib/process/unify.js +7 -7
- package/lib/utilities/context.js +13 -5
- package/lib/utilities/element.js +1 -1
- package/lib/utilities/equivalences.js +131 -0
- package/lib/utilities/json.js +59 -1
- package/lib/utilities/validation.js +4 -3
- package/package.json +2 -2
- package/src/context/branching.js +2 -2
- package/src/context/ephemeral.js +421 -237
- package/src/context/file/nominal.js +127 -77
- package/src/context/liminal.js +2 -2
- package/src/context/proof.js +81 -82
- package/src/context/synthetic.js +198 -88
- package/src/context.js +81 -20
- package/src/element/assertion/defined.js +4 -4
- package/src/element/assumption/metaLevel.js +8 -6
- package/src/element/combinator.js +4 -2
- package/src/element/conclusion.js +4 -2
- package/src/element/constructor.js +4 -2
- package/src/element/declaration/metavariable.js +10 -8
- package/src/element/declaration/variable.js +8 -7
- package/src/element/deduction.js +4 -2
- package/src/element/label.js +11 -7
- package/src/element/metavariable.js +11 -11
- package/src/element/proofAssertion/premise.js +4 -4
- package/src/element/proofAssertion/step.js +4 -2
- package/src/element/reference.js +7 -5
- package/src/element/statement.js +14 -0
- package/src/element/substitution/frame.js +47 -32
- package/src/element/substitution/reference.js +44 -34
- package/src/element/substitution/statement.js +63 -54
- package/src/element/substitution/term.js +53 -38
- package/src/element/variable.js +6 -7
- package/src/preamble.js +0 -1
- package/src/process/assign.js +17 -14
- package/src/process/equate.js +3 -1
- package/src/process/unify.js +10 -13
- package/src/utilities/context.js +13 -6
- package/src/utilities/element.js +1 -0
- package/src/utilities/equivalences.js +158 -0
- package/src/utilities/json.js +66 -0
- package/src/utilities/validation.js +6 -5
- package/lib/element/equivalences.js +0 -173
- package/src/element/equivalences.js +0 -237
package/src/context/ephemeral.js
CHANGED
|
@@ -40,149 +40,257 @@ export default class EphemeralContext extends Context {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
getTerms() {
|
|
43
|
-
|
|
43
|
+
let terms;
|
|
44
|
+
|
|
45
|
+
const context = this.getContext();
|
|
46
|
+
|
|
47
|
+
terms = context.getTerms();
|
|
48
|
+
|
|
49
|
+
terms = [ ///
|
|
50
|
+
...this.terms,
|
|
51
|
+
...terms
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
return terms;
|
|
44
55
|
}
|
|
45
56
|
|
|
46
57
|
getFrames() {
|
|
47
|
-
|
|
58
|
+
let frames;
|
|
59
|
+
|
|
60
|
+
const context = this.getContext();
|
|
61
|
+
|
|
62
|
+
frames = context.getFrames();
|
|
63
|
+
|
|
64
|
+
frames = [ ///
|
|
65
|
+
...this.frames,
|
|
66
|
+
...frames
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
return frames;
|
|
48
70
|
}
|
|
49
71
|
|
|
50
72
|
getEqualities() {
|
|
51
|
-
|
|
73
|
+
let equalities;
|
|
74
|
+
|
|
75
|
+
const context = this.getContext();
|
|
76
|
+
|
|
77
|
+
equalities = context.getEqualities();
|
|
78
|
+
|
|
79
|
+
equalities = [ ///
|
|
80
|
+
...this.equalities,
|
|
81
|
+
...equalities
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
return equalities;
|
|
52
85
|
}
|
|
53
86
|
|
|
54
87
|
getJudgements() {
|
|
55
|
-
|
|
88
|
+
let judgements;
|
|
89
|
+
|
|
90
|
+
const context = this.getContext();
|
|
91
|
+
|
|
92
|
+
judgements = context.getJudgements();
|
|
93
|
+
|
|
94
|
+
judgements = [ ///
|
|
95
|
+
...this.judgements,
|
|
96
|
+
...judgements
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
return judgements;
|
|
56
100
|
}
|
|
57
101
|
|
|
58
102
|
getStatements() {
|
|
59
|
-
|
|
103
|
+
let statements;
|
|
104
|
+
|
|
105
|
+
const context = this.getContext();
|
|
106
|
+
|
|
107
|
+
statements = context.getStatements();
|
|
108
|
+
|
|
109
|
+
statements = [ ///
|
|
110
|
+
...this.statements,
|
|
111
|
+
...statements
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
return statements;
|
|
60
115
|
}
|
|
61
116
|
|
|
62
117
|
getAssertions() {
|
|
63
|
-
|
|
118
|
+
let assertions;
|
|
119
|
+
|
|
120
|
+
const context = this.getContext();
|
|
121
|
+
|
|
122
|
+
assertions = context.getAssertions();
|
|
123
|
+
|
|
124
|
+
assertions = [ ///
|
|
125
|
+
...this.assertions,
|
|
126
|
+
...assertions
|
|
127
|
+
];
|
|
128
|
+
|
|
129
|
+
return assertions;
|
|
64
130
|
}
|
|
65
131
|
|
|
66
132
|
getReferences() {
|
|
67
|
-
|
|
133
|
+
let references;
|
|
134
|
+
|
|
135
|
+
const context = this.getContext();
|
|
136
|
+
|
|
137
|
+
references = context.getReferences();
|
|
138
|
+
|
|
139
|
+
references = [ ///
|
|
140
|
+
...this.references,
|
|
141
|
+
...references
|
|
142
|
+
];
|
|
143
|
+
|
|
144
|
+
return references;
|
|
68
145
|
}
|
|
69
146
|
|
|
70
147
|
getAssumptions() {
|
|
71
|
-
|
|
148
|
+
let assumptions;
|
|
149
|
+
|
|
150
|
+
const context = this.getContext();
|
|
151
|
+
|
|
152
|
+
assumptions = context.getAssumptions();
|
|
153
|
+
|
|
154
|
+
assumptions = [ ///
|
|
155
|
+
...this.assumptions,
|
|
156
|
+
...assumptions
|
|
157
|
+
];
|
|
158
|
+
|
|
159
|
+
return assumptions;
|
|
72
160
|
}
|
|
73
161
|
|
|
74
162
|
getMetavariables() {
|
|
75
|
-
|
|
163
|
+
let metavariables;
|
|
164
|
+
|
|
165
|
+
const context = this.getContext();
|
|
166
|
+
|
|
167
|
+
metavariables = context.getMetavariables();
|
|
168
|
+
|
|
169
|
+
metavariables = [ ///
|
|
170
|
+
...this.metavariables,
|
|
171
|
+
...metavariables
|
|
172
|
+
];
|
|
173
|
+
|
|
174
|
+
return metavariables;
|
|
76
175
|
}
|
|
77
176
|
|
|
78
177
|
getSubstitutions() {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
178
|
+
let substitutions;
|
|
179
|
+
|
|
180
|
+
const context = this.getContext();
|
|
181
|
+
|
|
182
|
+
substitutions = context.getSubstitutions();
|
|
183
|
+
|
|
184
|
+
substitutions = [ ///
|
|
185
|
+
...this.substitutions,
|
|
186
|
+
...substitutions
|
|
187
|
+
];
|
|
188
|
+
|
|
189
|
+
return substitutions;
|
|
86
190
|
}
|
|
87
191
|
|
|
88
192
|
addTerm(term) {
|
|
89
|
-
const
|
|
90
|
-
|
|
193
|
+
const context = this, ///
|
|
194
|
+
termA = term, ///
|
|
91
195
|
termString = term.getString();
|
|
92
196
|
|
|
93
197
|
context.trace(`Adding the '${termString}' term to the ephemeral context...`);
|
|
94
198
|
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
199
|
+
const terms = this.getTerms(),
|
|
200
|
+
termB = terms.find((term) => {
|
|
201
|
+
const termB = term, ///
|
|
202
|
+
termAEqualToTermB = termA.isEqualTo(termB);
|
|
203
|
+
|
|
204
|
+
if (termAEqualToTermB) {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
}) || null;
|
|
103
208
|
|
|
104
209
|
if (termB !== null) {
|
|
105
210
|
context.trace(`The '${termString}' term has already been added to the ephemeral context.`);
|
|
106
211
|
} else {
|
|
107
212
|
this.terms.push(term);
|
|
108
|
-
|
|
109
|
-
context.debug(`...added the '${termString}' term to the ephemeral context.`);
|
|
110
213
|
}
|
|
214
|
+
|
|
215
|
+
context.debug(`...added the '${termString}' term to the ephemeral context.`);
|
|
111
216
|
}
|
|
112
217
|
|
|
113
218
|
addFrame(frame) {
|
|
114
|
-
const
|
|
115
|
-
|
|
219
|
+
const context = this, ///
|
|
220
|
+
frameA = frame, ///
|
|
116
221
|
frameString = frame.getString();
|
|
117
222
|
|
|
118
223
|
context.trace(`Adding the '${frameString}' frame to the ephemeral context...`);
|
|
119
224
|
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
225
|
+
const frames = this.getFrames(),
|
|
226
|
+
frameB = frames.find((frame) => {
|
|
227
|
+
const frameB = frame, ///
|
|
228
|
+
frameAEqualToFrameB = frameA.isEqualTo(frameB);
|
|
229
|
+
|
|
230
|
+
if (frameAEqualToFrameB) {
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
}) || null;
|
|
128
234
|
|
|
129
235
|
if (frameB !== null) {
|
|
130
236
|
context.trace(`The '${frameString}' frame has already been added to the ephemeral context.`);
|
|
131
237
|
} else {
|
|
132
238
|
this.frames.push(frame);
|
|
133
|
-
|
|
134
|
-
context.debug(`...added the '${frameString}' frame to the ephemeral context.`);
|
|
135
239
|
}
|
|
240
|
+
|
|
241
|
+
context.debug(`...added the '${frameString}' frame to the ephemeral context.`);
|
|
136
242
|
}
|
|
137
243
|
|
|
138
244
|
addEquality(equality) {
|
|
139
|
-
const
|
|
140
|
-
|
|
245
|
+
const context = this, ///
|
|
246
|
+
equalityA = equality, ///
|
|
141
247
|
equalityString = equality.getString();
|
|
142
248
|
|
|
143
249
|
context.trace(`Adding the '${equalityString}' equality to the ephemeral context...`);
|
|
144
250
|
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
251
|
+
const equalities = this.getEqualities(),
|
|
252
|
+
equalityB = equalities.find((equality) => {
|
|
253
|
+
const equalityB = equality, ///
|
|
254
|
+
equalityAEqualToEqualityB = equalityA.isEqualTo(equalityB);
|
|
255
|
+
|
|
256
|
+
if (equalityAEqualToEqualityB) {
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
}) || null;
|
|
153
260
|
|
|
154
261
|
if (equalityB !== null) {
|
|
155
262
|
context.trace(`The '${equalityString}' equality has already been added to the ephemeral context.`);
|
|
156
263
|
} else {
|
|
157
264
|
this.equalities.push(equality);
|
|
158
|
-
|
|
159
|
-
context.debug(`...added the '${equalityString}' equality to the ephemeral context.`);
|
|
160
265
|
}
|
|
266
|
+
|
|
267
|
+
context.debug(`...added the '${equalityString}' equality to the ephemeral context.`);
|
|
161
268
|
}
|
|
162
269
|
|
|
163
270
|
addJudgement(judgement) {
|
|
164
|
-
const
|
|
165
|
-
|
|
271
|
+
const context = this, ///
|
|
272
|
+
judgementA = judgement, ///
|
|
166
273
|
judgementString = judgement.getString();
|
|
167
274
|
|
|
168
275
|
context.trace(`Adding the '${judgementString}' judgement to the ephemeral context...`);
|
|
169
276
|
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
277
|
+
const judgements = this.getJudgements(),
|
|
278
|
+
judgementB = judgements.find((judgement) => {
|
|
279
|
+
const judgementB = judgement, ///
|
|
280
|
+
judgementAEqualToEqualityB = judgementA.isEqualTo(judgementB);
|
|
281
|
+
|
|
282
|
+
if (judgementAEqualToEqualityB) {
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
}) || null;
|
|
178
286
|
|
|
179
287
|
if (judgementB !== null) {
|
|
180
288
|
context.trace(`The '${judgementString}' judgement has already been added to the ephemeral context.`);
|
|
181
289
|
} else {
|
|
182
290
|
this.judgements.push(judgement);
|
|
183
|
-
|
|
184
|
-
context.debug(`...added the '${judgementString}' judgement to the ephemeral context.`);
|
|
185
291
|
}
|
|
292
|
+
|
|
293
|
+
context.debug(`...added the '${judgementString}' judgement to the ephemeral context.`);
|
|
186
294
|
}
|
|
187
295
|
|
|
188
296
|
addStatement(statement) {
|
|
@@ -192,22 +300,23 @@ export default class EphemeralContext extends Context {
|
|
|
192
300
|
|
|
193
301
|
context.trace(`Adding the '${statementString}' statement to the ephemeral context...`);
|
|
194
302
|
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
303
|
+
const statements = this.getStatements(),
|
|
304
|
+
statementB = statements.find((statement) => {
|
|
305
|
+
const statementB = statement, ///
|
|
306
|
+
statementAEqualToStatementB = statementA.isEqualTo(statementB);
|
|
307
|
+
|
|
308
|
+
if (statementAEqualToStatementB) {
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
}) || null;
|
|
203
312
|
|
|
204
313
|
if (statementB !== null) {
|
|
205
314
|
context.trace(`The '${statementString}' statement has already been added to the ephemeral context.`);
|
|
206
315
|
} else {
|
|
207
316
|
this.statements.push(statement);
|
|
208
|
-
|
|
209
|
-
context.debug(`...added the '${statementString}' statement to the ephemeral context.`);
|
|
210
317
|
}
|
|
318
|
+
|
|
319
|
+
context.debug(`...added the '${statementString}' statement to the ephemeral context.`);
|
|
211
320
|
}
|
|
212
321
|
|
|
213
322
|
addAssertion(assertion) {
|
|
@@ -217,22 +326,23 @@ export default class EphemeralContext extends Context {
|
|
|
217
326
|
|
|
218
327
|
context.trace(`Adding the '${assertionString}' assertion to the ephemeral context...`);
|
|
219
328
|
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
329
|
+
const assertions = this.getAssumptions(),
|
|
330
|
+
assertionB = assertions.find((assertion) => {
|
|
331
|
+
const assertionB = assertion, ///
|
|
332
|
+
assertionAEqualToAssertionB = assertionA.isEqualTo(assertionB);
|
|
333
|
+
|
|
334
|
+
if (assertionAEqualToAssertionB) {
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
}) || null;
|
|
228
338
|
|
|
229
339
|
if (assertionB !== null) {
|
|
230
340
|
context.trace(`The '${assertionString}' assertion has already been added to the ephemeral context.`);
|
|
231
341
|
} else {
|
|
232
342
|
this.assertions.push(assertion);
|
|
233
|
-
|
|
234
|
-
context.debug(`...added the '${assertionString}' assertion to the ephemeral context.`);
|
|
235
343
|
}
|
|
344
|
+
|
|
345
|
+
context.debug(`...added the '${assertionString}' assertion to the ephemeral context.`);
|
|
236
346
|
}
|
|
237
347
|
|
|
238
348
|
addReference(reference) {
|
|
@@ -242,22 +352,23 @@ export default class EphemeralContext extends Context {
|
|
|
242
352
|
|
|
243
353
|
context.trace(`Adding the '${referenceString}' reference to the ephemeral context...`);
|
|
244
354
|
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
355
|
+
const references = this.getReferences(),
|
|
356
|
+
referenceB = references.find((reference) => {
|
|
357
|
+
const referenceB = reference, ///
|
|
358
|
+
referenceAEqualToReferenceB = referenceA.isEqualTo(referenceB);
|
|
359
|
+
|
|
360
|
+
if (referenceAEqualToReferenceB) {
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
}) || null;
|
|
253
364
|
|
|
254
365
|
if (referenceB !== null) {
|
|
255
366
|
context.trace(`The '${referenceString}' reference has already been added to the ephemeral context.`);
|
|
256
367
|
} else {
|
|
257
368
|
this.references.push(reference);
|
|
258
|
-
|
|
259
|
-
context.debug(`...added the '${referenceString}' reference to the ephemeral context.`);
|
|
260
369
|
}
|
|
370
|
+
|
|
371
|
+
context.debug(`...added the '${referenceString}' reference to the ephemeral context.`);
|
|
261
372
|
}
|
|
262
373
|
|
|
263
374
|
addAssumption(assumption) {
|
|
@@ -267,22 +378,23 @@ export default class EphemeralContext extends Context {
|
|
|
267
378
|
|
|
268
379
|
context.trace(`Adding the '${assumptionString}' assumption to the ephemeral context...`);
|
|
269
380
|
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
381
|
+
const assumptions = this.getAssumptions(),
|
|
382
|
+
assumptionB = assumptions.find((assumption) => {
|
|
383
|
+
const assumptionB = assumption, ///
|
|
384
|
+
assumptionAEqualToAssumptionB = assumptionA.isEqualTo(assumptionB);
|
|
385
|
+
|
|
386
|
+
if (assumptionAEqualToAssumptionB) {
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
}) || null;
|
|
278
390
|
|
|
279
391
|
if (assumptionB !== null) {
|
|
280
392
|
context.trace(`The '${assumptionString}' assumption has already been added to the ephemeral context.`);
|
|
281
393
|
} else {
|
|
282
394
|
this.assumptions.push(assumption);
|
|
283
|
-
|
|
284
|
-
context.debug(`...added the '${assumptionString}' assumption to the ephemeral context.`);
|
|
285
395
|
}
|
|
396
|
+
|
|
397
|
+
context.debug(`...added the '${assumptionString}' assumption to the ephemeral context.`);
|
|
286
398
|
}
|
|
287
399
|
|
|
288
400
|
addMetavariable(metavariable) {
|
|
@@ -292,22 +404,23 @@ export default class EphemeralContext extends Context {
|
|
|
292
404
|
|
|
293
405
|
context.trace(`Adding the '${metavariableString}' metavariable to the ephemeral context...`);
|
|
294
406
|
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
407
|
+
const metavariables = this.getMetavariables(),
|
|
408
|
+
metavariableB = metavariables.find((metavariable) => {
|
|
409
|
+
const metavariableB = metavariable, ///
|
|
410
|
+
metavariableAEqualToSubstitutionB = metavariableA.isEqualTo(metavariableB);
|
|
411
|
+
|
|
412
|
+
if (metavariableAEqualToSubstitutionB) {
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
415
|
+
}) || null;
|
|
303
416
|
|
|
304
417
|
if (metavariableB !== null) {
|
|
305
418
|
context.trace(`The '${metavariableString}' metavariable has already been added to the ephemeral context.`);
|
|
306
419
|
} else {
|
|
307
420
|
this.metavariables.push(metavariable);
|
|
308
|
-
|
|
309
|
-
context.debug(`...added the '${metavariableString}' metavariable to the ephemeral context.`);
|
|
310
421
|
}
|
|
422
|
+
|
|
423
|
+
context.debug(`...added the '${metavariableString}' metavariable to the ephemeral context.`);
|
|
311
424
|
}
|
|
312
425
|
|
|
313
426
|
addSubstitution(substitution) {
|
|
@@ -317,166 +430,224 @@ export default class EphemeralContext extends Context {
|
|
|
317
430
|
|
|
318
431
|
context.trace(`Adding the '${substitutionString}' substitution to the ephemeral context...`);
|
|
319
432
|
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
433
|
+
const substitutions = this.getSubstitutions(),
|
|
434
|
+
substitutionB = substitutions.find((substitution) => {
|
|
435
|
+
const substitutionB = substitution, ///
|
|
436
|
+
substitutionAEqualToSubstitutionB = substitutionA.isEqualTo(substitutionB);
|
|
437
|
+
|
|
438
|
+
if (substitutionAEqualToSubstitutionB) {
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
}) || null;
|
|
328
442
|
|
|
329
443
|
if (substitutionB !== null) {
|
|
330
444
|
context.trace(`The '${substitutionString}' substitution has already been added to the ephemeral context.`);
|
|
331
445
|
} else {
|
|
332
446
|
this.substitutions.push(substitution);
|
|
333
|
-
|
|
334
|
-
context.debug(`...added the '${substitutionString}' substitution to the ephemeral context.`);
|
|
335
447
|
}
|
|
448
|
+
|
|
449
|
+
context.debug(`...added the '${substitutionString}' substitution to the ephemeral context.`);
|
|
336
450
|
}
|
|
337
451
|
|
|
338
|
-
|
|
339
|
-
|
|
452
|
+
addTerms(terms) {
|
|
453
|
+
terms.forEach((term) => {
|
|
454
|
+
this.addTerm(term);
|
|
455
|
+
});
|
|
456
|
+
}
|
|
340
457
|
|
|
341
|
-
|
|
458
|
+
addFrames(frames) {
|
|
459
|
+
frames.forEach((frame) => {
|
|
460
|
+
this.addFrame(frame);
|
|
461
|
+
});
|
|
342
462
|
}
|
|
343
463
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
464
|
+
addEqualities(equalities) {
|
|
465
|
+
equalities.forEach((equality) => {
|
|
466
|
+
this.addEquality(equality);
|
|
467
|
+
});
|
|
468
|
+
}
|
|
347
469
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
})
|
|
470
|
+
addJudgements(judgements) {
|
|
471
|
+
judgements.forEach((judgement) => {
|
|
472
|
+
this.addJudgement(judgement);
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
addAssertions(assertions) {
|
|
477
|
+
assertions.forEach((assertion) => {
|
|
478
|
+
this.addAssertion(assertion);
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
addStatements(statements) {
|
|
483
|
+
statements.forEach((statement) => {
|
|
484
|
+
this.addStatement(statement);
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
addReferences(references) {
|
|
489
|
+
references.forEach((reference) => {
|
|
490
|
+
this.addReference(reference);
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
addAssumptions(assumptions) {
|
|
495
|
+
assumptions.forEach((assumption) => {
|
|
496
|
+
this.addAssumption(assumption);
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
addMetavariables(metavariables) {
|
|
501
|
+
metavariables.forEach((metavariable) => {
|
|
502
|
+
this.addMetavariable(metavariable);
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
addSubstitutions(substitutions) {
|
|
507
|
+
substitutions.forEach((substitution) => {
|
|
508
|
+
this.addSubstitution(substitution);
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
findTermByTermNode(termNode) {
|
|
513
|
+
const terms = this.getTerms(),
|
|
514
|
+
term = terms.find((term) => {
|
|
515
|
+
const termNodeMatches = term.matchTermNode(termNode);
|
|
516
|
+
|
|
517
|
+
if (termNodeMatches) {
|
|
518
|
+
return true;
|
|
519
|
+
}
|
|
520
|
+
}) || null;
|
|
352
521
|
|
|
353
522
|
return term;
|
|
354
523
|
}
|
|
355
524
|
|
|
356
525
|
findFrameByFrameNode(frameNode) {
|
|
357
|
-
const
|
|
358
|
-
|
|
526
|
+
const frames = this.getFrames(),
|
|
527
|
+
frame = frames.find((frame) => {
|
|
528
|
+
const frameNodeMatches = frame.matchFrameNode(frameNode);
|
|
359
529
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
530
|
+
if (frameNodeMatches) {
|
|
531
|
+
return true;
|
|
532
|
+
}
|
|
533
|
+
}) || null;
|
|
364
534
|
|
|
365
535
|
return frame;
|
|
366
536
|
}
|
|
367
537
|
|
|
368
538
|
findEqualityByEqualityNode(equalityNode) {
|
|
369
|
-
const
|
|
370
|
-
|
|
539
|
+
const equalities = this.getEqualities(),
|
|
540
|
+
equality = equalities.find((equality) => {
|
|
541
|
+
const equalityNodeMatches = equality.matchEqualityNode(equalityNode);
|
|
371
542
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
543
|
+
if (equalityNodeMatches) {
|
|
544
|
+
return true;
|
|
545
|
+
}
|
|
546
|
+
}) || null;
|
|
376
547
|
|
|
377
548
|
return equality;
|
|
378
549
|
}
|
|
379
550
|
|
|
380
551
|
findJudgementByJudgementNode(judgementNode) {
|
|
381
|
-
const
|
|
382
|
-
|
|
552
|
+
const judgements = this.getJudgements(),
|
|
553
|
+
judgement = judgements.find((judgement) => {
|
|
554
|
+
const judgementNodeMatches = judgement.matchJudgementNode(judgementNode);
|
|
383
555
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
556
|
+
if (judgementNodeMatches) {
|
|
557
|
+
return true;
|
|
558
|
+
}
|
|
559
|
+
}) || null;
|
|
388
560
|
|
|
389
561
|
return judgement;
|
|
390
562
|
}
|
|
391
563
|
|
|
392
564
|
findStatementByStatementNode(statementNode) {
|
|
393
|
-
const
|
|
394
|
-
|
|
565
|
+
const statements = this.getStatements(),
|
|
566
|
+
statement = statements.find((statement) => {
|
|
567
|
+
const statementNodeMatches = statement.matchStatementNode(statementNode);
|
|
395
568
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
569
|
+
if (statementNodeMatches) {
|
|
570
|
+
return true;
|
|
571
|
+
}
|
|
572
|
+
}) || null;
|
|
400
573
|
|
|
401
574
|
return statement;
|
|
402
575
|
}
|
|
403
576
|
|
|
404
577
|
findReferenceByReferenceNode(referenceNode) {
|
|
405
|
-
const
|
|
406
|
-
|
|
578
|
+
const references = this.getReferences(),
|
|
579
|
+
reference = references.find((reference) => {
|
|
580
|
+
const referenceMatcheReferenceNode = reference.matchReferenceNode(referenceNode);
|
|
407
581
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
582
|
+
if (referenceMatcheReferenceNode) {
|
|
583
|
+
return true;
|
|
584
|
+
}
|
|
585
|
+
}) || null;
|
|
412
586
|
|
|
413
587
|
return reference;
|
|
414
588
|
}
|
|
415
589
|
|
|
416
590
|
findAssertionByAssertionNode(assertionNode) {
|
|
417
|
-
const
|
|
418
|
-
|
|
591
|
+
const assertions = this.getAssertions(),
|
|
592
|
+
assertion = assertions.find((assertion) => {
|
|
593
|
+
const assertionNodeMatches = assertion.matchAssertionNode(assertionNode);
|
|
419
594
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
595
|
+
if (assertionNodeMatches) {
|
|
596
|
+
return true;
|
|
597
|
+
}
|
|
598
|
+
}) || null;
|
|
424
599
|
|
|
425
600
|
return assertion;
|
|
426
601
|
}
|
|
427
602
|
|
|
428
|
-
findAssumptionByAssumptionNode(assumptionNode
|
|
429
|
-
|
|
603
|
+
findAssumptionByAssumptionNode(assumptionNode) {
|
|
604
|
+
const assumptions = this.getAssumptions(),
|
|
605
|
+
assumption = assumptions.find((assumption) => {
|
|
606
|
+
const assumptionNodeMatches = assumption.matchAssumptionNode(assumptionNode);
|
|
430
607
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
} else {
|
|
436
|
-
assumption = this.assumptions.find((assumption) => {
|
|
437
|
-
const assumptionNodeMatches = assumption.matchAssumptionNode(assumptionNode);
|
|
438
|
-
|
|
439
|
-
if (assumptionNodeMatches) {
|
|
440
|
-
return true;
|
|
441
|
-
}
|
|
442
|
-
}) || null;
|
|
443
|
-
}
|
|
608
|
+
if (assumptionNodeMatches) {
|
|
609
|
+
return true;
|
|
610
|
+
}
|
|
611
|
+
}) || null;
|
|
444
612
|
|
|
445
613
|
return assumption;
|
|
446
614
|
}
|
|
447
615
|
|
|
448
616
|
findReferenceByMetavariableNode(metavariableNode) {
|
|
449
|
-
const
|
|
450
|
-
|
|
617
|
+
const references = this.getReferences(),
|
|
618
|
+
reference = references.find((reference) => {
|
|
619
|
+
const referenceMatcheMetavariableNode = reference.matchMetavariableNode(metavariableNode);
|
|
451
620
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
621
|
+
if (referenceMatcheMetavariableNode) {
|
|
622
|
+
return true;
|
|
623
|
+
}
|
|
624
|
+
}) || null;
|
|
456
625
|
|
|
457
626
|
return reference;
|
|
458
627
|
}
|
|
459
628
|
|
|
460
629
|
findMetavariableByMetavariableNode(metavariableNode) {
|
|
461
|
-
const
|
|
462
|
-
|
|
630
|
+
const metavariables = this.getMetavariables(),
|
|
631
|
+
metavariable = metavariables.find((metavariable) => {
|
|
632
|
+
const metavariableNodeMatches = metavariable.matchMetavariableNode(metavariableNode);
|
|
463
633
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
634
|
+
if (metavariableNodeMatches) {
|
|
635
|
+
return true;
|
|
636
|
+
}
|
|
637
|
+
}) || null;
|
|
468
638
|
|
|
469
639
|
return metavariable;
|
|
470
640
|
}
|
|
471
641
|
|
|
472
642
|
findSubstitutionBySubstitutionNode(substitutionNode) {
|
|
473
|
-
const
|
|
474
|
-
|
|
643
|
+
const substitutions = this.getSubstitutions(),
|
|
644
|
+
substitution = substitutions.find((substitution) => {
|
|
645
|
+
const substitutionNodeMatches = substitution.matchSubstitutionNode(substitutionNode);
|
|
475
646
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
647
|
+
if (substitutionNodeMatches) {
|
|
648
|
+
return true;
|
|
649
|
+
}
|
|
650
|
+
}) || null;
|
|
480
651
|
|
|
481
652
|
return substitution;
|
|
482
653
|
}
|
|
@@ -523,8 +694,8 @@ export default class EphemeralContext extends Context {
|
|
|
523
694
|
return assertionPresent;
|
|
524
695
|
}
|
|
525
696
|
|
|
526
|
-
isAssumptionPresentByAssumptionNode(assumptionNode
|
|
527
|
-
const assumption = this.findAssumptionByAssumptionNode(assumptionNode
|
|
697
|
+
isAssumptionPresentByAssumptionNode(assumptionNode) {
|
|
698
|
+
const assumption = this.findAssumptionByAssumptionNode(assumptionNode),
|
|
528
699
|
assumptionPresent = (assumption !== null);
|
|
529
700
|
|
|
530
701
|
return assumptionPresent;
|
|
@@ -578,38 +749,51 @@ export default class EphemeralContext extends Context {
|
|
|
578
749
|
}
|
|
579
750
|
|
|
580
751
|
toJSON() {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
752
|
+
let terms = this.getTerms(),
|
|
753
|
+
frames = this.getFrames(),
|
|
754
|
+
judgements = this.getJudgements(),
|
|
755
|
+
equalities = this.getEqualities(),
|
|
756
|
+
statements = this.getStatements(),
|
|
757
|
+
assertions = this.getAssertions(),
|
|
758
|
+
references = this.getReferences(),
|
|
759
|
+
assumptions = this.getAssumptions(),
|
|
760
|
+
metavariables = this.getMetavariables(),
|
|
761
|
+
substitutions = this.getSubstitutions();
|
|
762
|
+
|
|
763
|
+
const termsJSON = termsToTermsJSON(terms),
|
|
764
|
+
framesJSON = framesToFramesJSON(frames),
|
|
765
|
+
judgementsJSON = judgementsToJudgementsJSON(judgements),
|
|
766
|
+
equalitiesJSON = equalitiesToEqualitiesJSON(equalities),
|
|
767
|
+
statementsJSON = statementsToStatementsJSON(statements),
|
|
768
|
+
assertionsJSON = assertionsToAssertionsJSON(assertions),
|
|
769
|
+
referencesJSON = referencesToReferencesJSON(references),
|
|
770
|
+
assumptionsJSON = assumptionsToAssumptionsJSON(assumptions),
|
|
771
|
+
metavariablesJSON = metavariablesToMetavariablesJSON(metavariables),
|
|
772
|
+
substitutionsJSON = substitutionsToSubstitutionsJSON(substitutions);
|
|
773
|
+
|
|
774
|
+
terms = termsJSON; ///
|
|
775
|
+
frames = framesJSON; ///
|
|
776
|
+
judgements = judgementsJSON; ///
|
|
777
|
+
equalities = equalitiesJSON; ///
|
|
778
|
+
statements = statementsJSON; ///
|
|
779
|
+
assertions = assertionsJSON; ///
|
|
780
|
+
references = referencesJSON; ///
|
|
781
|
+
assumptions = assumptionsJSON; ///
|
|
782
|
+
metavariables = metavariablesJSON; //
|
|
783
|
+
substitutions = substitutionsJSON; ///
|
|
784
|
+
|
|
785
|
+
const json = {
|
|
786
|
+
terms,
|
|
787
|
+
frames,
|
|
788
|
+
judgements,
|
|
789
|
+
equalities,
|
|
790
|
+
statements,
|
|
791
|
+
assertions,
|
|
792
|
+
references,
|
|
793
|
+
assumptions,
|
|
794
|
+
metavariables,
|
|
795
|
+
substitutions
|
|
796
|
+
};
|
|
613
797
|
|
|
614
798
|
return json;
|
|
615
799
|
}
|