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
package/src/context/proof.js
CHANGED
|
@@ -5,18 +5,22 @@ import { arrayUtilities } from "necessary";
|
|
|
5
5
|
import Context from "../context";
|
|
6
6
|
import elements from "../elements";
|
|
7
7
|
|
|
8
|
-
const { last } = arrayUtilities;
|
|
8
|
+
const { last, filter } = arrayUtilities;
|
|
9
9
|
|
|
10
10
|
class ProofContext extends Context {
|
|
11
|
-
constructor(context, variables, judgements, assignments, equivalences, subproofOrProofAssertions
|
|
11
|
+
constructor(context, assumptions, variables, judgements, assignments, equivalences, subproofOrProofAssertions) {
|
|
12
12
|
super(context);
|
|
13
13
|
|
|
14
|
+
this.assumptions = assumptions;
|
|
14
15
|
this.variables = variables;
|
|
15
16
|
this.judgements = judgements;
|
|
16
17
|
this.assignments = assignments;
|
|
17
18
|
this.equivalences = equivalences;
|
|
18
19
|
this.subproofOrProofAssertions = subproofOrProofAssertions;
|
|
19
|
-
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getAssumptions() {
|
|
23
|
+
return this.assumptions;
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
getVariables() {
|
|
@@ -84,10 +88,6 @@ class ProofContext extends Context {
|
|
|
84
88
|
return subproofOrProofAssertions;
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
getMetaLevelSubstitutions() {
|
|
88
|
-
return this.metaLevelSubstitutions;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
91
|
getProofAssertions() {
|
|
92
92
|
const subproofOrProofAssertions = this.getSubproofOrProofAssertions(),
|
|
93
93
|
proofAssertions = subproofOrProofAssertions.filter((subproofOrProofAssertion) => {
|
|
@@ -116,18 +116,18 @@ class ProofContext extends Context {
|
|
|
116
116
|
return lastStep;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
let
|
|
119
|
+
isMetaLevel() {
|
|
120
|
+
let metaLevel = false;
|
|
121
121
|
|
|
122
|
-
if (this.
|
|
123
|
-
|
|
122
|
+
if (this.assumptions !== null) {
|
|
123
|
+
metaLevel = true;
|
|
124
124
|
} else {
|
|
125
125
|
const context = this.getContext();
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
metaLevel = context.isMetaLevel();
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
return
|
|
130
|
+
return metaLevel;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
addEquality(equality) {
|
|
@@ -184,34 +184,38 @@ class ProofContext extends Context {
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
|
|
188
|
-
if (
|
|
189
|
-
|
|
187
|
+
addAssumption(assumption, metaLevel = true) {
|
|
188
|
+
if (!metaLevel) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (this.assumptions === null) {
|
|
193
|
+
super.addAssumption(assumption, metaLevel);
|
|
190
194
|
|
|
191
195
|
return;
|
|
192
196
|
}
|
|
193
197
|
|
|
194
198
|
const context = this, ///
|
|
195
|
-
|
|
196
|
-
|
|
199
|
+
assumptionA = assumption, ///
|
|
200
|
+
assumptionString = assumption.getString();
|
|
197
201
|
|
|
198
|
-
context.trace(`Adding the '${
|
|
202
|
+
context.trace(`Adding the '${assumptionString}' assumption to the proof context...`);
|
|
199
203
|
|
|
200
|
-
const
|
|
201
|
-
const
|
|
202
|
-
|
|
204
|
+
const assumptionB = this.assumptions.find((assumption) => {
|
|
205
|
+
const assumptionB = assumption, ///
|
|
206
|
+
assumptionAEqualToAssumptionB = assumptionA.isEqualTo(assumptionB);
|
|
203
207
|
|
|
204
|
-
if (
|
|
208
|
+
if (assumptionAEqualToAssumptionB) {
|
|
205
209
|
return true;
|
|
206
210
|
}
|
|
207
211
|
}) || null;
|
|
208
212
|
|
|
209
|
-
if (
|
|
210
|
-
context.debug(`The '${
|
|
213
|
+
if (assumptionB !== null) {
|
|
214
|
+
context.debug(`The '${assumptionString}' assumption has already been added to the proof context.`);
|
|
211
215
|
} else {
|
|
212
|
-
this.
|
|
216
|
+
this.assumptions.push(assumption);
|
|
213
217
|
|
|
214
|
-
context.debug(`...added the '${
|
|
218
|
+
context.debug(`...added the '${assumptionString}' substitution to the proof context.`);
|
|
215
219
|
}
|
|
216
220
|
}
|
|
217
221
|
|
|
@@ -240,43 +244,28 @@ class ProofContext extends Context {
|
|
|
240
244
|
return comparesToTermAndPropertyRelation;
|
|
241
245
|
}
|
|
242
246
|
|
|
243
|
-
|
|
244
|
-
const context = this, ///
|
|
245
|
-
equivalences = this.getEquivalences(),
|
|
246
|
-
groundedTerms = [],
|
|
247
|
-
definedVariables = [];
|
|
248
|
-
|
|
249
|
-
equivalences.separateGroundedTermsAndDefinedVariables(groundedTerms, definedVariables, context);
|
|
250
|
-
|
|
251
|
-
const termMatchesGroundedTerm = groundedTerms.some((groundedTerm) => {
|
|
252
|
-
const groundedTermNode = groundedTerm.getNode(),
|
|
253
|
-
groundedTermNodeMatches = term.matchTermNode(groundedTermNode);
|
|
254
|
-
|
|
255
|
-
if (groundedTermNodeMatches) {
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
|
-
}),
|
|
259
|
-
termGrounded = termMatchesGroundedTerm; ///
|
|
247
|
+
findEquivalenceByTerm(term) { return this.equivalences.findEquivalenceByTerm(term); }
|
|
260
248
|
|
|
261
|
-
|
|
262
|
-
|
|
249
|
+
findAssumptionByAssumptionNode(assumptionNode, metaLevel = true) {
|
|
250
|
+
let assumption = null;
|
|
263
251
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
252
|
+
if (metaLevel) {
|
|
253
|
+
if (this.assumptions === null) {
|
|
254
|
+
assumption = super.findAssumptionByAssumptionNode(assumptionNode, metaLevel);
|
|
255
|
+
} else {
|
|
256
|
+
assumption = this.assumptions.find((assumption) => {
|
|
257
|
+
const assumptionNodeMatches = assumption.matchAssumptionNode(assumptionNode);
|
|
267
258
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
259
|
+
if (assumptionNodeMatches) {
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
}) || null;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
274
265
|
|
|
275
|
-
return
|
|
266
|
+
return assumption;
|
|
276
267
|
}
|
|
277
268
|
|
|
278
|
-
findEquivalenceByTerm(term) { return this.equivalences.findEquivalenceByTerm(term); }
|
|
279
|
-
|
|
280
269
|
findJudgementByMetavariableName(metavariableName) {
|
|
281
270
|
const judgements = this.getJudgements(),
|
|
282
271
|
judgement = judgements.find((judgement) => {
|
|
@@ -303,32 +292,63 @@ class ProofContext extends Context {
|
|
|
303
292
|
return variable;
|
|
304
293
|
}
|
|
305
294
|
|
|
306
|
-
|
|
307
|
-
|
|
295
|
+
findJudgementsByMetavariableNode(metavariableNode) {
|
|
296
|
+
const judgements = this.getJudgements();
|
|
308
297
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
} else {
|
|
312
|
-
metaLevelSubstitution = this.metaLevelSubstitutions.find((metaLevelSubstitution) => {
|
|
313
|
-
const metaLevelSubstitutionNodeMatches = metaLevelSubstitution.matchMetaLevelSubstitutionNode(metaLevelSubstitutionNode);
|
|
298
|
+
filter(judgements, (judgement) => {
|
|
299
|
+
const metavariableNodeMatches = judgement.matchMetavariableNode(metavariableNode);
|
|
314
300
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
301
|
+
if (metavariableNodeMatches) {
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
return judgements;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
isJudgementPresentByMetavariableName(metavariableName) {
|
|
310
|
+
const judgement = this.findJudgementByMetavariableName(metavariableName),
|
|
311
|
+
judgementPresent = (judgement !== null);
|
|
312
|
+
|
|
313
|
+
return judgementPresent;
|
|
314
|
+
}
|
|
320
315
|
|
|
321
|
-
|
|
316
|
+
isVariablePresentByVariableIdentifier(variableIdentifier) {
|
|
317
|
+
const variable = this.findVariableByVariableIdentifier(variableIdentifier),
|
|
318
|
+
variablePresent = (variable !== null);
|
|
319
|
+
|
|
320
|
+
return variablePresent;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
isTermGrounded(term) {
|
|
324
|
+
const context = this, ///
|
|
325
|
+
equivalences = this.getEquivalences(),
|
|
326
|
+
groundedTerms = [],
|
|
327
|
+
definedVariables = [];
|
|
328
|
+
|
|
329
|
+
equivalences.separateGroundedTermsAndDefinedVariables(groundedTerms, definedVariables, context);
|
|
330
|
+
|
|
331
|
+
const termMatchesGroundedTerm = groundedTerms.some((groundedTerm) => {
|
|
332
|
+
const groundedTermNode = groundedTerm.getNode(),
|
|
333
|
+
groundedTermNodeMatches = term.matchTermNode(groundedTermNode);
|
|
334
|
+
|
|
335
|
+
if (groundedTermNodeMatches) {
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
}),
|
|
339
|
+
termGrounded = termMatchesGroundedTerm; ///
|
|
340
|
+
|
|
341
|
+
return termGrounded;
|
|
322
342
|
}
|
|
323
343
|
|
|
324
|
-
static
|
|
344
|
+
static fromAssumptions(assumptions, context) {
|
|
325
345
|
const { Equivalences } = elements,
|
|
326
346
|
variables = [],
|
|
327
347
|
judgements = [],
|
|
328
348
|
assignments = [],
|
|
329
349
|
equivalences = Equivalences.fromNothing(context),
|
|
330
350
|
subproofOrProofAssertions = [],
|
|
331
|
-
proofContext = new ProofContext(context, variables, judgements, assignments, equivalences, subproofOrProofAssertions
|
|
351
|
+
proofContext = new ProofContext(context, assumptions, variables, judgements, assignments, equivalences, subproofOrProofAssertions);
|
|
332
352
|
|
|
333
353
|
return proofContext;
|
|
334
354
|
}
|
package/src/context.js
CHANGED
|
@@ -129,13 +129,6 @@ export default class Context extends ContextBase {
|
|
|
129
129
|
return subproofOrProofAssertions;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
retrieveEphemeralContext() {
|
|
133
|
-
const context = this.getContext(),
|
|
134
|
-
ephemeralContext = context.retrieveEphemeralContext();
|
|
135
|
-
|
|
136
|
-
return ephemeralContext;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
132
|
findMetavariable(metavariable, context) {
|
|
140
133
|
const childContext = context; ///
|
|
141
134
|
|
|
@@ -232,9 +225,9 @@ export default class Context extends ContextBase {
|
|
|
232
225
|
return statement;
|
|
233
226
|
}
|
|
234
227
|
|
|
235
|
-
findAssumptionByAssumptionNode(assumptionNode) {
|
|
228
|
+
findAssumptionByAssumptionNode(assumptionNode, metaLevel = false) {
|
|
236
229
|
const context = this.getContext(),
|
|
237
|
-
assumption = context.findAssumptionByAssumptionNode(assumptionNode);
|
|
230
|
+
assumption = context.findAssumptionByAssumptionNode(assumptionNode, metaLevel);
|
|
238
231
|
|
|
239
232
|
return assumption;
|
|
240
233
|
}
|
|
@@ -246,18 +239,18 @@ export default class Context extends ContextBase {
|
|
|
246
239
|
return reference;
|
|
247
240
|
}
|
|
248
241
|
|
|
249
|
-
|
|
242
|
+
findJudgementsByMetavariableNode(metavariableNode) {
|
|
250
243
|
const context = this.getContext(),
|
|
251
|
-
|
|
244
|
+
judgement = context.findJudgementsByMetavariableNode(metavariableNode);
|
|
252
245
|
|
|
253
|
-
return
|
|
246
|
+
return judgement;
|
|
254
247
|
}
|
|
255
248
|
|
|
256
|
-
|
|
249
|
+
findSubstitutionBySubstitutionNode(substitutionNode) {
|
|
257
250
|
const context = this.getContext(),
|
|
258
|
-
|
|
251
|
+
substitution = context.findSubstitutionBySubstitutionNode(substitutionNode);
|
|
259
252
|
|
|
260
|
-
return
|
|
253
|
+
return substitution;
|
|
261
254
|
}
|
|
262
255
|
|
|
263
256
|
findTypeByNominalTypeName(nominalTypeName) {
|
|
@@ -433,6 +426,20 @@ export default class Context extends ContextBase {
|
|
|
433
426
|
return substitutionPresent;
|
|
434
427
|
}
|
|
435
428
|
|
|
429
|
+
isSubstitutionPresentByMetavariableNameAndSubstitution(metavariableName, substitution) {
|
|
430
|
+
const context = this.getContext(),
|
|
431
|
+
substitutionPresent = context.isSubstitutionPresentByMetavariableNameAndSubstitution(metavariableName, substitution);
|
|
432
|
+
|
|
433
|
+
return substitutionPresent;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
isSubstitutionPresentByMetavariableName(metavariableName) {
|
|
437
|
+
const context = this.getContext(),
|
|
438
|
+
substitutionPresent = context.isSubstitutionPresentByMetavariableName(metavariableName);
|
|
439
|
+
|
|
440
|
+
return substitutionPresent;
|
|
441
|
+
}
|
|
442
|
+
|
|
436
443
|
isProcedurePresentByProcedureName(procedureName) {
|
|
437
444
|
const context = this.getContext(),
|
|
438
445
|
procedurePresent = context.isProcedurePresentByProcedureName(procedureName);
|
|
@@ -440,11 +447,11 @@ export default class Context extends ContextBase {
|
|
|
440
447
|
return procedurePresent;
|
|
441
448
|
}
|
|
442
449
|
|
|
443
|
-
|
|
450
|
+
isMetaLevel() {
|
|
444
451
|
const context = this.getContext(),
|
|
445
|
-
|
|
452
|
+
metaLevel = context.isMetaLevel();
|
|
446
453
|
|
|
447
|
-
return
|
|
454
|
+
return metaLevel;
|
|
448
455
|
}
|
|
449
456
|
|
|
450
457
|
isStated() {
|
|
@@ -502,10 +509,10 @@ export default class Context extends ContextBase {
|
|
|
502
509
|
context.addReference(reference);
|
|
503
510
|
}
|
|
504
511
|
|
|
505
|
-
addAssumption(assumption) {
|
|
512
|
+
addAssumption(assumption, metaLevel = false) {
|
|
506
513
|
const context = this.getContext();
|
|
507
514
|
|
|
508
|
-
context.addAssumption(assumption);
|
|
515
|
+
context.addAssumption(assumption, metaLevel);
|
|
509
516
|
}
|
|
510
517
|
|
|
511
518
|
addAssignment(assignment) {
|
|
@@ -520,12 +527,6 @@ export default class Context extends ContextBase {
|
|
|
520
527
|
context.addSubstitution(substitution);
|
|
521
528
|
}
|
|
522
529
|
|
|
523
|
-
addMetaLevelSubstitution(metaLevelSubstitution) {
|
|
524
|
-
const context = this.getContext();
|
|
525
|
-
|
|
526
|
-
context.addMetaLevelSubstitution(metaLevelSubstitution);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
530
|
addSubproofOrProofAssertion(subproofOrProofAssertion) {
|
|
530
531
|
const context = this.getContext();
|
|
531
532
|
|
|
@@ -6,7 +6,11 @@ import { define } from "../../elements";
|
|
|
6
6
|
import { descend, instantiate } from "../../utilities/context";
|
|
7
7
|
import { instantiateContainedAssertion } from "../../process/instantiate";
|
|
8
8
|
import { termFromTermAndSubstitutions, frameFromFrameAndSubstitutions, statementFromStatementAndSubstitutions } from "../../utilities/substitutions";
|
|
9
|
-
import { termFromContainedAssertionNode,
|
|
9
|
+
import { termFromContainedAssertionNode,
|
|
10
|
+
frameFromContainedAssertionNode,
|
|
11
|
+
negatedFromContainedAssertionNode,
|
|
12
|
+
statementFromContainedAssertionNode,
|
|
13
|
+
containedAssertionFromStatementNode } from "../../utilities/element";
|
|
10
14
|
|
|
11
15
|
export default define(class ContainedAssertion extends Assertion {
|
|
12
16
|
constructor(context, string, node, term, frame, negated, statement) {
|
|
@@ -220,7 +224,7 @@ export default define(class ContainedAssertion extends Assertion {
|
|
|
220
224
|
}
|
|
221
225
|
|
|
222
226
|
unifyIndependently(generalContext, specificContext) {
|
|
223
|
-
let unifiesIndependently;
|
|
227
|
+
let unifiesIndependently = false;
|
|
224
228
|
|
|
225
229
|
const context = specificContext, ///
|
|
226
230
|
containedAssertionString = this.getString(); ///
|
|
@@ -232,7 +236,9 @@ export default define(class ContainedAssertion extends Assertion {
|
|
|
232
236
|
statement = statementFromStatementAndSubstitutions(this.statement, generalContext, specificContext),
|
|
233
237
|
validatesWhenDerived = validateWhenDerived(term, frame, statement, this.negated, generalContext, specificContext);
|
|
234
238
|
|
|
235
|
-
|
|
239
|
+
if (validatesWhenDerived) {
|
|
240
|
+
unifiesIndependently = true;
|
|
241
|
+
}
|
|
236
242
|
|
|
237
243
|
if (unifiesIndependently) {
|
|
238
244
|
context.debug(`...unified the '${containedAssertionString}' contained assertion independently.`);
|
|
@@ -266,6 +272,13 @@ export default define(class ContainedAssertion extends Assertion {
|
|
|
266
272
|
|
|
267
273
|
return containedAssertion;
|
|
268
274
|
}
|
|
275
|
+
|
|
276
|
+
static fromStatement(statement, context) {
|
|
277
|
+
const statementNode = statement.getNode(),
|
|
278
|
+
containedAssertion = containedAssertionFromStatementNode(statementNode, context);
|
|
279
|
+
|
|
280
|
+
return containedAssertion;
|
|
281
|
+
}
|
|
269
282
|
});
|
|
270
283
|
|
|
271
284
|
function validateWhenDerived(term, frame, statement, negated, generalContext, specificContext) {
|
|
@@ -6,7 +6,7 @@ import { define } from "../../elements";
|
|
|
6
6
|
import { descend, instantiate } from "../../utilities/context";
|
|
7
7
|
import { instantiateDefinedAssertion } from "../../process/instantiate";
|
|
8
8
|
import { termFromTermAndSubstitutions, frameFromFrameAndSubstitutions } from "../../utilities/substitutions";
|
|
9
|
-
import { termFromJDefinedAssertionNode, frameFromJDefinedAssertionNode, negatedFromJDefinedAssertionNode } from "../../utilities/element";
|
|
9
|
+
import { termFromJDefinedAssertionNode, frameFromJDefinedAssertionNode, negatedFromJDefinedAssertionNode, definedAssertionFromStatementNode } from "../../utilities/element";
|
|
10
10
|
|
|
11
11
|
export default define(class DefinedAssertion extends Assertion {
|
|
12
12
|
constructor(context, string, node, term, frame, negated) {
|
|
@@ -58,16 +58,16 @@ export default define(class DefinedAssertion extends Assertion {
|
|
|
58
58
|
if (termValidates || frameValidates) {
|
|
59
59
|
const stated = context.isStated();
|
|
60
60
|
|
|
61
|
-
let
|
|
62
|
-
|
|
61
|
+
let validatesWhenStated = false,
|
|
62
|
+
validatesWhenDerived = false;
|
|
63
63
|
|
|
64
64
|
if (stated) {
|
|
65
|
-
|
|
65
|
+
validatesWhenStated = this.validateWhenStated(context);
|
|
66
66
|
} else {
|
|
67
|
-
|
|
67
|
+
validatesWhenDerived = this.validateWhenDerived(context);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
if (
|
|
70
|
+
if (validatesWhenStated || validatesWhenDerived) {
|
|
71
71
|
validates = true;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -155,23 +155,23 @@ export default define(class DefinedAssertion extends Assertion {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
validateWhenStated(context) {
|
|
158
|
-
let
|
|
158
|
+
let validatesWhenStated;
|
|
159
159
|
|
|
160
160
|
const definedAssertionString = this.getString(); ///
|
|
161
161
|
|
|
162
162
|
context.trace(`Validating the '${definedAssertionString}' stated defined assertion...`);
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
validatesWhenStated = true;
|
|
165
165
|
|
|
166
|
-
if (
|
|
166
|
+
if (validatesWhenStated) {
|
|
167
167
|
context.debug(`...validates the '${definedAssertionString}' stated defined assertion.`);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
return
|
|
170
|
+
return validatesWhenStated;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
validateWhenDerived(context) {
|
|
174
|
-
let
|
|
174
|
+
let validatesWhenDerived;
|
|
175
175
|
|
|
176
176
|
const definedAssertionString = this.getString(); ///
|
|
177
177
|
|
|
@@ -180,17 +180,17 @@ export default define(class DefinedAssertion extends Assertion {
|
|
|
180
180
|
const generalContext = null,
|
|
181
181
|
specificContext = context; ///
|
|
182
182
|
|
|
183
|
-
|
|
183
|
+
validatesWhenDerived = validateWhenDerived(this.term, this.frame, this.negated, generalContext, specificContext);
|
|
184
184
|
|
|
185
|
-
if (
|
|
185
|
+
if (validatesWhenDerived) {
|
|
186
186
|
context.debug(`...validates the '${definedAssertionString}' derived defined assertion.`);
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
return
|
|
189
|
+
return validatesWhenDerived;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
unifyIndependently(generalContext, specificContext) {
|
|
193
|
-
let unifiesIndependently;
|
|
193
|
+
let unifiesIndependently = false;
|
|
194
194
|
|
|
195
195
|
const context = specificContext, ///
|
|
196
196
|
definedAssertionString = this.getString(); ///
|
|
@@ -199,9 +199,11 @@ export default define(class DefinedAssertion extends Assertion {
|
|
|
199
199
|
|
|
200
200
|
const term = termFromTermAndSubstitutions(this.term, generalContext, specificContext),
|
|
201
201
|
frame = frameFromFrameAndSubstitutions(this.frame, generalContext, specificContext),
|
|
202
|
-
|
|
202
|
+
validatesWhenDerived = validateWhenDerived(term, frame, this.negated, generalContext, specificContext);
|
|
203
203
|
|
|
204
|
-
|
|
204
|
+
if (validatesWhenDerived) {
|
|
205
|
+
unifiesIndependently = true;
|
|
206
|
+
}
|
|
205
207
|
|
|
206
208
|
if (unifiesIndependently) {
|
|
207
209
|
context.debug(`...unified the '${definedAssertionString}' defined assertion independently.`);
|
|
@@ -234,10 +236,17 @@ export default define(class DefinedAssertion extends Assertion {
|
|
|
234
236
|
|
|
235
237
|
return definedAssertion;
|
|
236
238
|
}
|
|
239
|
+
|
|
240
|
+
static fromStatement(statement, context) {
|
|
241
|
+
const statementNode = statement.getNode(),
|
|
242
|
+
definedAssertion = definedAssertionFromStatementNode(statementNode, context);
|
|
243
|
+
|
|
244
|
+
return definedAssertion;
|
|
245
|
+
}
|
|
237
246
|
});
|
|
238
247
|
|
|
239
248
|
function validateWhenDerived(term, frame, negated, generalContext, specificContext) {
|
|
240
|
-
let
|
|
249
|
+
let validatesWhenDerived = false;
|
|
241
250
|
|
|
242
251
|
const context = specificContext; ///
|
|
243
252
|
|
|
@@ -247,11 +256,11 @@ function validateWhenDerived(term, frame, negated, generalContext, specificConte
|
|
|
247
256
|
variableDefined = isVariableDefined(variable, context);
|
|
248
257
|
|
|
249
258
|
if (!negated && variableDefined) {
|
|
250
|
-
|
|
259
|
+
validatesWhenDerived = true;
|
|
251
260
|
}
|
|
252
261
|
|
|
253
262
|
if (negated && !variableDefined) {
|
|
254
|
-
|
|
263
|
+
validatesWhenDerived = true;
|
|
255
264
|
}
|
|
256
265
|
}
|
|
257
266
|
|
|
@@ -261,15 +270,15 @@ function validateWhenDerived(term, frame, negated, generalContext, specificConte
|
|
|
261
270
|
metavariableDefined = isMetavariableDefined(metavariable, context);
|
|
262
271
|
|
|
263
272
|
if (!negated && metavariableDefined) {
|
|
264
|
-
|
|
273
|
+
validatesWhenDerived = true;
|
|
265
274
|
}
|
|
266
275
|
|
|
267
276
|
if (negated && !metavariableDefined) {
|
|
268
|
-
|
|
277
|
+
validatesWhenDerived = true;
|
|
269
278
|
}
|
|
270
279
|
}
|
|
271
280
|
|
|
272
|
-
return
|
|
281
|
+
return validatesWhenDerived;
|
|
273
282
|
}
|
|
274
283
|
|
|
275
284
|
function isVariableDefined(variable, context) {
|
|
@@ -6,7 +6,7 @@ import { define } from "../../elements";
|
|
|
6
6
|
import { instantiate } from "../../utilities/context";
|
|
7
7
|
import { instantiatePropertyAssertion } from "../../process/instantiate";
|
|
8
8
|
import { variableAssignmentFromPrepertyAssertion } from "../../process/assign";
|
|
9
|
-
import { termFromPropertyAssertionNode, propertyRelationFromPropertyAssertionNode } from "../../utilities/element";
|
|
9
|
+
import { termFromPropertyAssertionNode, propertyAssertionFromStatementNode, propertyRelationFromPropertyAssertionNode } from "../../utilities/element";
|
|
10
10
|
|
|
11
11
|
export default define(class PropertyAssertion extends Assertion {
|
|
12
12
|
constructor(context, string, node, term, propertyRelation) {
|
|
@@ -226,4 +226,11 @@ export default define(class PropertyAssertion extends Assertion {
|
|
|
226
226
|
|
|
227
227
|
return propertyAssertion;
|
|
228
228
|
}
|
|
229
|
+
|
|
230
|
+
static fromStatement(statement, context) {
|
|
231
|
+
const statementNode = statement.getNode(),
|
|
232
|
+
propertyAssertion = propertyAssertionFromStatementNode(statementNode, context);
|
|
233
|
+
|
|
234
|
+
return propertyAssertion;
|
|
235
|
+
}
|
|
229
236
|
});
|
|
@@ -5,7 +5,7 @@ import Assertion from "../assertion";
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
6
|
import { instantiate } from "../../utilities/context";
|
|
7
7
|
import { instantiateSatisfiesAssertion } from "../../process/instantiate";
|
|
8
|
-
import { signatureFromJSatisfiesAssertionNode, referenceFromJSatisfiesAssertionNode } from "../../utilities/element";
|
|
8
|
+
import { signatureFromJSatisfiesAssertionNode, referenceFromJSatisfiesAssertionNode, satisfiesAssertionFromStatementNode } from "../../utilities/element";
|
|
9
9
|
|
|
10
10
|
export default define(class SatisfiesAssertion extends Assertion {
|
|
11
11
|
constructor(context, string, node, signature, reference) {
|
|
@@ -179,4 +179,11 @@ export default define(class SatisfiesAssertion extends Assertion {
|
|
|
179
179
|
|
|
180
180
|
return satisfiesAssertion;
|
|
181
181
|
}
|
|
182
|
+
|
|
183
|
+
static fromStatement(statement, context) {
|
|
184
|
+
const statementNode = statement.getNode(),
|
|
185
|
+
satisfiesAssertion = satisfiesAssertionFromStatementNode(statementNode, context);
|
|
186
|
+
|
|
187
|
+
return satisfiesAssertion;
|
|
188
|
+
}
|
|
182
189
|
});
|
|
@@ -8,6 +8,7 @@ import { define } from "../../elements";
|
|
|
8
8
|
import { reconcile } from "../../utilities/context";
|
|
9
9
|
import { join, descend, instantiate } from "../../utilities/context";
|
|
10
10
|
import { instantiateSubproofAssertion } from "../../process/instantiate";
|
|
11
|
+
import { subproofAssertionFromStatementNode } from "../../utilities/element";
|
|
11
12
|
|
|
12
13
|
const { last, front, backwardsEvery } = arrayUtilities;
|
|
13
14
|
|
|
@@ -310,6 +311,13 @@ export default define(class SubproofAssertion extends Assertion {
|
|
|
310
311
|
|
|
311
312
|
return subproorAssertion;
|
|
312
313
|
}
|
|
314
|
+
|
|
315
|
+
static fromStatement(statement, context) {
|
|
316
|
+
const statementNode = statement.getNode(),
|
|
317
|
+
subproofAssertion = subproofAssertionFromStatementNode(statementNode, context);
|
|
318
|
+
|
|
319
|
+
return subproofAssertion;
|
|
320
|
+
}
|
|
313
321
|
});
|
|
314
322
|
|
|
315
323
|
function statementsFromSubproofAssertionNode(subproofAssertionNode, context) {
|
|
@@ -5,9 +5,9 @@ import Assertion from "../assertion";
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
6
|
import { instantiate } from "../../utilities/context";
|
|
7
7
|
import { instantiateTypeAssertion } from "../../process/instantiate";
|
|
8
|
-
import { termFromTypeAssertionNode } from "../../utilities/element";
|
|
9
8
|
import { typeFromJSON, typeToTypeJSON } from "../../utilities/json";
|
|
10
9
|
import { variableAssignmentFromTypeAssertion } from "../../process/assign";
|
|
10
|
+
import { termFromTypeAssertionNode, typeAssertionFromStatementNode } from "../../utilities/element";
|
|
11
11
|
|
|
12
12
|
export default define(class TypeAssertion extends Assertion {
|
|
13
13
|
constructor(context, string, node, term, type) {
|
|
@@ -229,4 +229,11 @@ export default define(class TypeAssertion extends Assertion {
|
|
|
229
229
|
|
|
230
230
|
return typeAssertion;
|
|
231
231
|
}
|
|
232
|
+
|
|
233
|
+
static fromStatement(statement, context) {
|
|
234
|
+
const statementNode = statement.getNode(),
|
|
235
|
+
typeAssertion = typeAssertionFromStatementNode(statementNode, context);
|
|
236
|
+
|
|
237
|
+
return typeAssertion;
|
|
238
|
+
}
|
|
232
239
|
});
|