occam-verify-cli 1.0.404 → 1.0.414
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/file.js +3 -3
- package/lib/context/local.js +3 -3
- package/lib/context/release.js +2 -2
- package/lib/context/temporary.js +103 -54
- package/lib/mixins/statement/verify.js +2 -2
- package/lib/mixins/step/unify.js +2 -2
- package/lib/node/argument.js +2 -2
- package/lib/node/assumption.js +6 -6
- package/lib/node/frame.js +19 -7
- package/lib/node/judgement.js +8 -1
- package/lib/node/statement.js +34 -15
- package/lib/node/substitution/term.js +3 -11
- package/lib/node/term.js +20 -8
- package/lib/nonTerminalNode.js +3 -3
- package/lib/ontology/assertion/contained.js +7 -7
- package/lib/ontology/assertion/defined.js +8 -8
- package/lib/ontology/assertion/subproof.js +3 -3
- package/lib/ontology/assumption.js +49 -45
- package/lib/ontology/combinator.js +3 -3
- package/lib/ontology/constructor.js +3 -3
- package/lib/ontology/equality.js +4 -4
- package/lib/ontology/equivalence.js +2 -2
- package/lib/ontology/frame.js +37 -12
- package/lib/ontology/judgement.js +13 -6
- package/lib/ontology/metavariable.js +75 -76
- package/lib/ontology/propertyRelation.js +2 -2
- package/lib/ontology/reference.js +33 -4
- package/lib/ontology/signature.js +2 -2
- package/lib/ontology/statement.js +33 -8
- package/lib/ontology/step.js +4 -4
- package/lib/ontology/substitution/frame.js +13 -15
- package/lib/ontology/substitution/statement.js +31 -32
- package/lib/ontology/substitution/term.js +26 -25
- package/lib/ontology/substitution.js +2 -2
- package/lib/ontology/substitutions.js +4 -4
- package/lib/ontology/term.js +26 -12
- package/lib/ontology/variable.js +2 -2
- package/lib/process/equate.js +322 -0
- package/lib/process/unify.js +623 -0
- package/lib/process/verify.js +332 -0
- package/lib/utilities/brackets.js +3 -8
- package/lib/utilities/context.js +4 -14
- package/lib/utilities/json.js +18 -1
- package/lib/utilities/pass.js +68 -0
- package/lib/utilities/substitutions.js +11 -16
- package/package.json +7 -7
- package/src/context/file.js +2 -2
- package/src/context/local.js +2 -2
- package/src/context/release.js +1 -1
- package/src/context/temporary.js +124 -54
- package/src/mixins/statement/verify.js +3 -1
- package/src/mixins/step/unify.js +0 -1
- package/src/node/argument.js +1 -1
- package/src/node/assumption.js +4 -4
- package/src/node/frame.js +19 -5
- package/src/node/judgement.js +7 -0
- package/src/node/statement.js +35 -13
- package/src/node/substitution/term.js +4 -14
- package/src/node/term.js +20 -6
- package/src/nonTerminalNode.js +1 -1
- package/src/ontology/assertion/contained.js +6 -6
- package/src/ontology/assertion/defined.js +7 -7
- package/src/ontology/assertion/subproof.js +1 -1
- package/src/ontology/assumption.js +52 -57
- package/src/ontology/combinator.js +1 -1
- package/src/ontology/constructor.js +1 -1
- package/src/ontology/equality.js +3 -3
- package/src/ontology/equivalence.js +1 -1
- package/src/ontology/frame.js +44 -10
- package/src/ontology/judgement.js +8 -3
- package/src/ontology/metavariable.js +108 -102
- package/src/ontology/propertyRelation.js +3 -2
- package/src/ontology/reference.js +39 -1
- package/src/ontology/signature.js +3 -3
- package/src/ontology/statement.js +38 -4
- package/src/ontology/step.js +7 -7
- package/src/ontology/substitution/frame.js +13 -17
- package/src/ontology/substitution/statement.js +45 -48
- package/src/ontology/substitution/term.js +19 -19
- package/src/ontology/substitution.js +3 -2
- package/src/ontology/substitutions.js +3 -3
- package/src/ontology/term.js +26 -5
- package/src/ontology/variable.js +3 -2
- package/src/process/equate.js +212 -0
- package/src/process/unify.js +634 -0
- package/src/process/verify.js +204 -0
- package/src/utilities/brackets.js +2 -11
- package/src/utilities/context.js +1 -21
- package/src/utilities/json.js +19 -0
- package/src/utilities/{unifier.js → pass.js} +17 -1
- package/src/utilities/substitutions.js +10 -20
- package/lib/unifier/equantional.js +0 -170
- package/lib/unifier/intrinsicLevel.js +0 -144
- package/lib/unifier/metaLevel.js +0 -197
- package/lib/unifier/metavariable.js +0 -140
- package/lib/unifier/statementWithCombinator.js +0 -177
- package/lib/unifier/termWithConstructor.js +0 -145
- package/lib/unifier.js +0 -241
- package/lib/utilities/arguments.js +0 -28
- package/lib/utilities/frame.js +0 -18
- package/lib/utilities/metavariable.js +0 -18
- package/lib/utilities/statement.js +0 -18
- package/lib/utilities/unification.js +0 -109
- package/lib/utilities/unifier.js +0 -51
- package/lib/utilities/variable.js +0 -18
- package/lib/verifier/combinator.js +0 -158
- package/lib/verifier.js +0 -219
- package/src/unifier/equantional.js +0 -90
- package/src/unifier/intrinsicLevel.js +0 -52
- package/src/unifier/metaLevel.js +0 -151
- package/src/unifier/metavariable.js +0 -50
- package/src/unifier/statementWithCombinator.js +0 -114
- package/src/unifier/termWithConstructor.js +0 -56
- package/src/unifier.js +0 -183
- package/src/utilities/arguments.js +0 -21
- package/src/utilities/frame.js +0 -13
- package/src/utilities/metavariable.js +0 -13
- package/src/utilities/statement.js +0 -13
- package/src/utilities/unification.js +0 -136
- package/src/utilities/variable.js +0 -13
- package/src/verifier/combinator.js +0 -72
- package/src/verifier.js +0 -150
package/src/context/temporary.js
CHANGED
|
@@ -5,15 +5,15 @@ import { arrayUtilities } from "necessary";
|
|
|
5
5
|
const { extract, compress } = arrayUtilities;
|
|
6
6
|
|
|
7
7
|
export default class TemporaryContext {
|
|
8
|
-
constructor(context, tokens, terms, frames, statements, assertions,
|
|
8
|
+
constructor(context, tokens, terms, frames, statements, assertions, references, substitutions) {
|
|
9
9
|
this.context = context;
|
|
10
10
|
this.tokens = tokens;
|
|
11
11
|
this.terms = terms;
|
|
12
12
|
this.frames = frames;
|
|
13
13
|
this.statements = statements;
|
|
14
14
|
this.assertions = assertions;
|
|
15
|
+
this.references = references;
|
|
15
16
|
this.substitutions = substitutions;
|
|
16
|
-
this.reference = reference;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
getContext() {
|
|
@@ -40,111 +40,126 @@ export default class TemporaryContext {
|
|
|
40
40
|
return this.assertions;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
return this.
|
|
43
|
+
getReferences() {
|
|
44
|
+
return this.references;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
return this.
|
|
47
|
+
getSubstitutions() {
|
|
48
|
+
return this.substitutions;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
addTerm(term) {
|
|
52
|
-
const
|
|
53
|
-
|
|
52
|
+
const termA = term, ///
|
|
53
|
+
context = this, ///
|
|
54
54
|
termString = term.getString();
|
|
55
55
|
|
|
56
56
|
extract(this.terms, (term) => {
|
|
57
|
-
const
|
|
57
|
+
const termB = term, ///
|
|
58
|
+
termAEqualToTermB = termA.isEqualTo(termB);
|
|
58
59
|
|
|
59
|
-
if (
|
|
60
|
+
if (termAEqualToTermB) {
|
|
60
61
|
return true;
|
|
61
62
|
}
|
|
62
63
|
});
|
|
63
64
|
|
|
64
|
-
context.trace(`ADded the '${termString}' term.`);
|
|
65
|
+
context.trace(`ADded the '${termString}' term to the context.`);
|
|
65
66
|
|
|
66
67
|
this.terms.push(term);
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
addFrame(frame) {
|
|
70
|
-
const
|
|
71
|
-
|
|
71
|
+
const frameA = frame, ///
|
|
72
|
+
context = this, ///
|
|
72
73
|
frameString = frame.getString();
|
|
73
74
|
|
|
74
75
|
extract(this.frames, (frame) => {
|
|
75
|
-
const
|
|
76
|
+
const frameB = frame, ///
|
|
77
|
+
frameAEqualToFrameB = frameA.isEqualTo(frameB);
|
|
76
78
|
|
|
77
|
-
if (
|
|
79
|
+
if (frameAEqualToFrameB) {
|
|
78
80
|
return true;
|
|
79
81
|
}
|
|
80
82
|
});
|
|
81
83
|
|
|
82
|
-
context.trace(`Added the '${frameString}' frame.`);
|
|
84
|
+
context.trace(`Added the '${frameString}' frame to the context.`);
|
|
83
85
|
|
|
84
86
|
this.frames.push(frame);
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
addStatement(statement) {
|
|
88
90
|
const context = this, ///
|
|
89
|
-
|
|
91
|
+
statementA = statement, ///
|
|
90
92
|
statementString = statement.getString();
|
|
91
93
|
|
|
92
94
|
extract(this.statements, (statement) => {
|
|
93
|
-
const
|
|
95
|
+
const statementB = statement, ///
|
|
96
|
+
statementAEqualToFrameB = statementA.isEqualTo(statementB);
|
|
94
97
|
|
|
95
|
-
if (
|
|
98
|
+
if (statementAEqualToFrameB) {
|
|
96
99
|
return true;
|
|
97
100
|
}
|
|
98
101
|
});
|
|
99
102
|
|
|
100
|
-
context.trace(`Added the '${statementString}' statement.`);
|
|
103
|
+
context.trace(`Added the '${statementString}' statement to the context.`);
|
|
101
104
|
|
|
102
105
|
this.statements.push(statement);
|
|
103
106
|
}
|
|
104
107
|
|
|
105
108
|
addAssertion(assertion) {
|
|
106
109
|
const context = this, ///
|
|
107
|
-
|
|
110
|
+
assertionA = assertion, ///
|
|
108
111
|
assertionString = assertion.getString();
|
|
109
112
|
|
|
110
113
|
extract(this.assertions, (assertion) => {
|
|
111
|
-
const
|
|
114
|
+
const assertionB = assertion, ///
|
|
115
|
+
assertionAEqualToAssertionB = assertionA.isEqualTo(assertionB);
|
|
112
116
|
|
|
113
|
-
if (
|
|
117
|
+
if (assertionAEqualToAssertionB) {
|
|
114
118
|
return true;
|
|
115
119
|
}
|
|
116
120
|
});
|
|
117
121
|
|
|
118
|
-
context.trace(`Added the '${assertionString}' assertion.`);
|
|
122
|
+
context.trace(`Added the '${assertionString}' assertion to the context.`);
|
|
119
123
|
|
|
120
124
|
this.assertions.push(assertion);
|
|
121
125
|
}
|
|
122
126
|
|
|
123
|
-
|
|
127
|
+
addReference(reference) {
|
|
124
128
|
const context = this, ///
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
referenceA = reference, ///
|
|
130
|
+
referenceString = reference.getString();
|
|
127
131
|
|
|
128
|
-
extract(this.
|
|
129
|
-
const
|
|
132
|
+
extract(this.references, (reference) => {
|
|
133
|
+
const referenceB = reference, ///
|
|
134
|
+
referenceAEqualToReferenceB = referenceA.isEqualTo(referenceB);
|
|
130
135
|
|
|
131
|
-
if (
|
|
136
|
+
if (referenceAEqualToReferenceB) {
|
|
132
137
|
return true;
|
|
133
138
|
}
|
|
134
139
|
});
|
|
135
140
|
|
|
136
|
-
context.trace(`Added the '${
|
|
141
|
+
context.trace(`Added the '${referenceString}' reference to the context.`);
|
|
137
142
|
|
|
138
|
-
this.
|
|
143
|
+
this.references.push(reference);
|
|
139
144
|
}
|
|
140
145
|
|
|
141
|
-
|
|
146
|
+
addSubstitution(substitution) {
|
|
142
147
|
const context = this, ///
|
|
143
|
-
|
|
148
|
+
substitutionA = substitution, ///
|
|
149
|
+
substitutionString = substitution.getString();
|
|
144
150
|
|
|
145
|
-
this.
|
|
151
|
+
extract(this.substitutions, (substitution) => {
|
|
152
|
+
const substitutionB = substitution, ///
|
|
153
|
+
substituionAEqualToSubstitutionB = substitutionA.isEqualTo(substitutionB);
|
|
146
154
|
|
|
147
|
-
|
|
155
|
+
if (substituionAEqualToSubstitutionB) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
context.trace(`Added the '${substitutionString}' substitution to the context.`);
|
|
161
|
+
|
|
162
|
+
this.substitutions.push(substitution);
|
|
148
163
|
}
|
|
149
164
|
|
|
150
165
|
findTermByTermNode(termNode) {
|
|
@@ -171,6 +186,18 @@ export default class TemporaryContext {
|
|
|
171
186
|
return frame;
|
|
172
187
|
}
|
|
173
188
|
|
|
189
|
+
findStatementByStatementNode(statementNode) {
|
|
190
|
+
const statement = this.statements.find((statement) => {
|
|
191
|
+
const statementMatchesStatementNode = statement.matchStatementNode(statementNode);
|
|
192
|
+
|
|
193
|
+
if (statementMatchesStatementNode) {
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
}) || null;
|
|
197
|
+
|
|
198
|
+
return statement;
|
|
199
|
+
}
|
|
200
|
+
|
|
174
201
|
findAssertionByAssertionNode(assertionNode) {
|
|
175
202
|
const assertion = this.assertions.find((assertion) => {
|
|
176
203
|
const assertionMatchesAssertionNode = assertion.matchAssertionNode(assertionNode);
|
|
@@ -183,21 +210,21 @@ export default class TemporaryContext {
|
|
|
183
210
|
return assertion;
|
|
184
211
|
}
|
|
185
212
|
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
const
|
|
213
|
+
findReferenceByMetavariableNode(metavariableNode) {
|
|
214
|
+
const reference = this.references.find((reference) => {
|
|
215
|
+
const referenceMatcheMetavariableNode = reference.matchMetavariableNode(metavariableNode);
|
|
189
216
|
|
|
190
|
-
if (
|
|
217
|
+
if (referenceMatcheMetavariableNode) {
|
|
191
218
|
return true;
|
|
192
219
|
}
|
|
193
220
|
}) || null;
|
|
194
221
|
|
|
195
|
-
return
|
|
222
|
+
return reference;
|
|
196
223
|
}
|
|
197
224
|
|
|
198
|
-
|
|
225
|
+
findSubstitutionBySubstitutionNode(substitutionNode) {
|
|
199
226
|
const substitution = this.substitutions.find((substitution) => {
|
|
200
|
-
const substitutionMatchesSubtitutionNode = substitution.
|
|
227
|
+
const substitutionMatchesSubtitutionNode = substitution.matchSubstitutionNode(substitutionNode);
|
|
201
228
|
|
|
202
229
|
if (substitutionMatchesSubtitutionNode) {
|
|
203
230
|
return true;
|
|
@@ -381,11 +408,12 @@ export default class TemporaryContext {
|
|
|
381
408
|
|
|
382
409
|
error(message, node = null) { this.context.error(message, node); }
|
|
383
410
|
|
|
384
|
-
|
|
411
|
+
merge(context) {
|
|
385
412
|
const terms = context.getTerms(),
|
|
386
413
|
frames = context.getFrames(),
|
|
387
414
|
statements = context.getStatements(),
|
|
388
415
|
assertions = context.getAssertions(),
|
|
416
|
+
references = context.getReferences(),
|
|
389
417
|
substitutions = context.getSubstitutions();
|
|
390
418
|
|
|
391
419
|
this.terms = [
|
|
@@ -408,21 +436,63 @@ export default class TemporaryContext {
|
|
|
408
436
|
...assertions
|
|
409
437
|
];
|
|
410
438
|
|
|
439
|
+
this.references = [
|
|
440
|
+
...this.references,
|
|
441
|
+
...references
|
|
442
|
+
];
|
|
443
|
+
|
|
411
444
|
this.substitutions = [
|
|
412
445
|
...this.substitutions,
|
|
413
446
|
...substitutions
|
|
414
447
|
];
|
|
415
448
|
|
|
416
449
|
compress(this.terms, (termA, termB) => {
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
|
|
450
|
+
const termAEqualToTermB = termA.isEqualTo(termB);
|
|
451
|
+
|
|
452
|
+
if (!termAEqualToTermB) {
|
|
453
|
+
return true;
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
compress(this.frames, (frameA, frameB) => {
|
|
458
|
+
const frameAEqualToFrameB = frameA.isEqualTo(frameB);
|
|
459
|
+
|
|
460
|
+
if (!frameAEqualToFrameB) {
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
compress(this.statements, (statementA, statementB) => {
|
|
466
|
+
const statementAEqualToStatementB = statementA.isEqualTo(statementB);
|
|
420
467
|
|
|
421
|
-
if (
|
|
468
|
+
if (!statementAEqualToStatementB) {
|
|
422
469
|
return true;
|
|
423
470
|
}
|
|
424
471
|
});
|
|
425
472
|
|
|
473
|
+
compress(this.assertions, (assertionA, assertionB) => {
|
|
474
|
+
const assertionAEqualToAssertionB = assertionA.isEqualTo(assertionB);
|
|
475
|
+
|
|
476
|
+
if (!assertionAEqualToAssertionB) {
|
|
477
|
+
return true;
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
compress(this.references, (referenceA, referenceB) => {
|
|
482
|
+
const referenceAEqualToReferenceB = referenceA.isEqualTo(referenceB);
|
|
483
|
+
|
|
484
|
+
if (!referenceAEqualToReferenceB) {
|
|
485
|
+
return true;
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
compress(this.substitutions, (substitutionA, substitutionB) => {
|
|
490
|
+
const substitutionAEqualToSubstitutionB = substitutionA.isEqualTo(substitutionB);
|
|
491
|
+
|
|
492
|
+
if (!substitutionAEqualToSubstitutionB) {
|
|
493
|
+
return true;
|
|
494
|
+
}
|
|
495
|
+
});
|
|
426
496
|
}
|
|
427
497
|
|
|
428
498
|
static fromNothing(context) {
|
|
@@ -431,9 +501,9 @@ export default class TemporaryContext {
|
|
|
431
501
|
tokens = null,
|
|
432
502
|
statements = [],
|
|
433
503
|
assertions = [],
|
|
504
|
+
references = [],
|
|
434
505
|
substitutions = [],
|
|
435
|
-
|
|
436
|
-
temporaryContext = new TemporaryContext(context, tokens, terms, frames, statements, assertions, substitutions, reference);
|
|
506
|
+
temporaryContext = new TemporaryContext(context, tokens, terms, frames, statements, assertions, references, substitutions);
|
|
437
507
|
|
|
438
508
|
return temporaryContext;
|
|
439
509
|
}
|
|
@@ -442,9 +512,9 @@ export default class TemporaryContext {
|
|
|
442
512
|
const tokens = null,
|
|
443
513
|
statements = [],
|
|
444
514
|
assertions = [],
|
|
515
|
+
references = [],
|
|
445
516
|
substitutions = [],
|
|
446
|
-
|
|
447
|
-
temporaryContext = new TemporaryContext(context, tokens, terms, frames, statements, assertions, substitutions, reference);
|
|
517
|
+
temporaryContext = new TemporaryContext(context, tokens, terms, frames, statements, assertions, references, substitutions);
|
|
448
518
|
|
|
449
519
|
return temporaryContext;
|
|
450
520
|
}
|
|
@@ -454,9 +524,9 @@ export default class TemporaryContext {
|
|
|
454
524
|
frames = [],
|
|
455
525
|
statements = [],
|
|
456
526
|
assertions = [],
|
|
527
|
+
references = [],
|
|
457
528
|
substitutions = [],
|
|
458
|
-
|
|
459
|
-
temporaryContext = new TemporaryContext(context, tokens, terms, frames, statements, assertions, substitutions, reference);
|
|
529
|
+
temporaryContext = new TemporaryContext(context, tokens, terms, frames, statements, assertions, references, substitutions);
|
|
460
530
|
|
|
461
531
|
return temporaryContext;
|
|
462
532
|
}
|
|
@@ -26,7 +26,9 @@ function verifyAsMetavariableAndSubstitution(statement, assignments, stated, con
|
|
|
26
26
|
|
|
27
27
|
if (metavariableVerifies) {
|
|
28
28
|
const { TermSubstitution, FrameSubstitution } = ontology,
|
|
29
|
-
|
|
29
|
+
frameSubstitution = FrameSubstitution.fromStatement(statement, context),
|
|
30
|
+
termSubstitution = TermSubstitution.fromStatement(statement, context),
|
|
31
|
+
substitution = (termSubstitution || frameSubstitution);
|
|
30
32
|
|
|
31
33
|
if (substitution !== null) {
|
|
32
34
|
const substitutionVerifies = substitution.verify(context);
|
package/src/mixins/step/unify.js
CHANGED
|
@@ -54,7 +54,6 @@ function unifyWithReference(statement, reference, satisfiesAssertion, substituti
|
|
|
54
54
|
|
|
55
55
|
const { StatementSubstitution } = ontology,
|
|
56
56
|
metavariable = reference.getMetavariable(),
|
|
57
|
-
specificContext = context, ///
|
|
58
57
|
statementSubstitution = StatementSubstitution.fromStatementAndMetavariable(statement, metavariable, context),
|
|
59
58
|
substitution = statementSubstitution; ///
|
|
60
59
|
|
package/src/node/argument.js
CHANGED
|
@@ -21,7 +21,7 @@ export default class ArgumentNode extends NonTerminalNode {
|
|
|
21
21
|
|
|
22
22
|
getSingularTermNode() {
|
|
23
23
|
const ruleName = TERM_RULE_NAME,
|
|
24
|
-
singularTermNode = this.
|
|
24
|
+
singularTermNode = this.getSingularNodeByRuleName(ruleName);
|
|
25
25
|
|
|
26
26
|
return singularTermNode;
|
|
27
27
|
}
|
package/src/node/assumption.js
CHANGED
|
@@ -5,16 +5,16 @@ import DocumentNode from "../nonTerminalNode";
|
|
|
5
5
|
import { STATEMENT_RULE_NAME, METAVARIABLE_RULE_NAME } from "../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class AssumptionpNode extends DocumentNode {
|
|
8
|
-
|
|
9
|
-
let
|
|
8
|
+
isSingular() {
|
|
9
|
+
let singular = false;
|
|
10
10
|
|
|
11
11
|
const statementNode = this.getStatementNode();
|
|
12
12
|
|
|
13
13
|
if (statementNode === null) {
|
|
14
|
-
|
|
14
|
+
singular = true;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
return
|
|
17
|
+
return singular;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
getStatementNode() {
|
package/src/node/frame.js
CHANGED
|
@@ -5,16 +5,16 @@ import NonTerminalNode from "../nonTerminalNode";
|
|
|
5
5
|
import { ASSUMPTION_RULE_NAME, METAVARIABLE_RULE_NAME } from "../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class FrameNode extends NonTerminalNode {
|
|
8
|
-
|
|
9
|
-
let
|
|
8
|
+
isSingular() {
|
|
9
|
+
let singular = false;
|
|
10
10
|
|
|
11
11
|
const singularAssumptionNode = this.getSingularAssumptionNode();
|
|
12
12
|
|
|
13
13
|
if (singularAssumptionNode !== null) {
|
|
14
|
-
|
|
14
|
+
singular = singularAssumptionNode.isSingular();
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
return
|
|
17
|
+
return singular;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
getAssumptionNodes() {
|
|
@@ -24,6 +24,20 @@ export default class FrameNode extends NonTerminalNode {
|
|
|
24
24
|
return declarationNodes;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
getMetavariableName() {
|
|
28
|
+
let metavariableName = null;
|
|
29
|
+
|
|
30
|
+
const singular = this.isSingular();
|
|
31
|
+
|
|
32
|
+
if (singular) {
|
|
33
|
+
const singularMetavariableNode = this.getSingularMetavariableNode();
|
|
34
|
+
|
|
35
|
+
metavariableName = singularMetavariableNode.getMetavariableName();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return metavariableName;
|
|
39
|
+
}
|
|
40
|
+
|
|
27
41
|
getMetavariableNodes() {
|
|
28
42
|
const ruleName = METAVARIABLE_RULE_NAME,
|
|
29
43
|
metavariableNodes = this.getNodesByRuleName(ruleName);
|
|
@@ -33,7 +47,7 @@ export default class FrameNode extends NonTerminalNode {
|
|
|
33
47
|
|
|
34
48
|
getSingularAssumptionNode() {
|
|
35
49
|
const ruleName = ASSUMPTION_RULE_NAME,
|
|
36
|
-
singularAssumptionNode = this.
|
|
50
|
+
singularAssumptionNode = this.getSingularNodeByRuleName(ruleName);
|
|
37
51
|
|
|
38
52
|
return singularAssumptionNode;
|
|
39
53
|
}
|
package/src/node/judgement.js
CHANGED
|
@@ -5,6 +5,13 @@ import NonTerminalNode from "../nonTerminalNode";
|
|
|
5
5
|
import { FRAME_RULE_NAME, ASSUMPTION_RULE_NAME } from "../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class JudgementNode extends NonTerminalNode {
|
|
8
|
+
isSingular() {
|
|
9
|
+
const frameNode = this.getFrameNode(),
|
|
10
|
+
singular = frameNode.isSingular();
|
|
11
|
+
|
|
12
|
+
return singular;
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
getFrameNode() {
|
|
9
16
|
const ruleName = FRAME_RULE_NAME,
|
|
10
17
|
frameNode = this.getNodeByRuleName(ruleName);
|
package/src/node/statement.js
CHANGED
|
@@ -19,16 +19,38 @@ import { TERM_RULE_NAME,
|
|
|
19
19
|
STATEMENT_SUBSTITUTION_RULE_NAME } from "../ruleNames";
|
|
20
20
|
|
|
21
21
|
export default class StatementNode extends NonTerminalNode {
|
|
22
|
-
|
|
23
|
-
let
|
|
22
|
+
getMetavariableName() {
|
|
23
|
+
let metavariableName = null;
|
|
24
24
|
|
|
25
|
-
const
|
|
25
|
+
const singular = this.isSingular();
|
|
26
26
|
|
|
27
|
-
if (
|
|
28
|
-
|
|
27
|
+
if (singular) {
|
|
28
|
+
const singularMetavariableNode = this.getSingularMetavariableNode();
|
|
29
|
+
|
|
30
|
+
metavariableName = singularMetavariableNode.getMetavariableName();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return metavariableName;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getSubstitutionNode() {
|
|
37
|
+
const frameSubstitutionNode = this.getFrameSubstitutionNode(),
|
|
38
|
+
termSubstitutionNode = this.getTermSubstitutionNode(),
|
|
39
|
+
substitutionNode = (frameSubstitutionNode || termSubstitutionNode);
|
|
40
|
+
|
|
41
|
+
return substitutionNode;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
isSingular() {
|
|
45
|
+
let singular = false;
|
|
46
|
+
|
|
47
|
+
const singularMetavariableNode = this.getSingularMetavariableNode();
|
|
48
|
+
|
|
49
|
+
if (singularMetavariableNode !== null) {
|
|
50
|
+
singular = true;
|
|
29
51
|
}
|
|
30
52
|
|
|
31
|
-
return
|
|
53
|
+
return singular;
|
|
32
54
|
}
|
|
33
55
|
|
|
34
56
|
getTermNodes() {
|
|
@@ -59,13 +81,6 @@ export default class StatementNode extends NonTerminalNode {
|
|
|
59
81
|
return judgementNode;
|
|
60
82
|
}
|
|
61
83
|
|
|
62
|
-
getMetavariableNode() {
|
|
63
|
-
const ruleName = METAVARIABLE_RULE_NAME,
|
|
64
|
-
metavariableNode = this.getNodeByRuleName(ruleName);
|
|
65
|
-
|
|
66
|
-
return metavariableNode;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
84
|
getTypeAssertionNode() {
|
|
70
85
|
const ruleName = TYPE_ASSERTION_RULE_NAME,
|
|
71
86
|
typeAssertionNode = this.getNodeByRuleName(ruleName);
|
|
@@ -134,6 +149,13 @@ export default class StatementNode extends NonTerminalNode {
|
|
|
134
149
|
return satisfiedAssertionNode;
|
|
135
150
|
}
|
|
136
151
|
|
|
152
|
+
getSingularMetavariableNode() {
|
|
153
|
+
const ruleName = METAVARIABLE_RULE_NAME,
|
|
154
|
+
singularMetavariableNode = this.getSingularNodeByRuleName(ruleName);
|
|
155
|
+
|
|
156
|
+
return singularMetavariableNode;
|
|
157
|
+
}
|
|
158
|
+
|
|
137
159
|
getSingularMetaArgumentNode() {
|
|
138
160
|
const ruleName = META_ARGUMENT_RULE_NAME,
|
|
139
161
|
singularMetaArgumentNode = this.getNodeByRuleName(ruleName);
|
|
@@ -20,27 +20,17 @@ export default class TermSubstitutionNode extends SubstitutionNode {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
getLastVariableNode() {
|
|
23
|
-
let lastVariableNode = null;
|
|
24
|
-
|
|
25
23
|
const lastTermNode = this.getLastTermNode(),
|
|
26
|
-
singularVariableNode = lastTermNode.getSingularVariableNode()
|
|
27
|
-
|
|
28
|
-
if (singularVariableNode !== null) {
|
|
29
|
-
lastVariableNode = singularVariableNode; ///
|
|
30
|
-
}
|
|
24
|
+
singularVariableNode = lastTermNode.getSingularVariableNode(),
|
|
25
|
+
lastVariableNode = singularVariableNode; ///
|
|
31
26
|
|
|
32
27
|
return lastVariableNode;
|
|
33
28
|
}
|
|
34
29
|
|
|
35
30
|
getFirstVariableNode() {
|
|
36
|
-
let firstVariableNode = null;
|
|
37
|
-
|
|
38
31
|
const firstTermNode = this.getFirstTermNode(),
|
|
39
|
-
singularVariableNode = firstTermNode.getSingularVariableNode()
|
|
40
|
-
|
|
41
|
-
if (singularVariableNode !== null) {
|
|
42
|
-
firstVariableNode = singularVariableNode; ///
|
|
43
|
-
}
|
|
32
|
+
singularVariableNode = firstTermNode.getSingularVariableNode(),
|
|
33
|
+
firstVariableNode = singularVariableNode; ///
|
|
44
34
|
|
|
45
35
|
return firstVariableNode;
|
|
46
36
|
}
|
package/src/node/term.js
CHANGED
|
@@ -5,16 +5,30 @@ import NonTerminalNode from "../nonTerminalNode";
|
|
|
5
5
|
import { ARGUMENT_RULE_NAME, VARIABLE_RULE_NAME } from "../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class TermNode extends NonTerminalNode {
|
|
8
|
-
|
|
9
|
-
let
|
|
8
|
+
getVariableIdentifier() {
|
|
9
|
+
let variableIdentifier = null;
|
|
10
|
+
|
|
11
|
+
const singular = this.isSingular();
|
|
12
|
+
|
|
13
|
+
if (singular) {
|
|
14
|
+
const singularVariableNode = this.getSingularVariableNode();
|
|
15
|
+
|
|
16
|
+
variableIdentifier = singularVariableNode.getVariableIdentifier();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return variableIdentifier;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
isSingular() {
|
|
23
|
+
let singular = false;
|
|
10
24
|
|
|
11
25
|
const singularVariableNode = this.getSingularVariableNode();
|
|
12
26
|
|
|
13
27
|
if (singularVariableNode !== null) {
|
|
14
|
-
|
|
28
|
+
singular = true;
|
|
15
29
|
}
|
|
16
30
|
|
|
17
|
-
return
|
|
31
|
+
return singular;
|
|
18
32
|
}
|
|
19
33
|
|
|
20
34
|
getVariableNodes() {
|
|
@@ -38,14 +52,14 @@ export default class TermNode extends NonTerminalNode {
|
|
|
38
52
|
|
|
39
53
|
getSingularArgumentNode() {
|
|
40
54
|
const ruleName = ARGUMENT_RULE_NAME,
|
|
41
|
-
singularArgumentNode = this.
|
|
55
|
+
singularArgumentNode = this.getSingularNodeByRuleName(ruleName);
|
|
42
56
|
|
|
43
57
|
return singularArgumentNode;
|
|
44
58
|
}
|
|
45
59
|
|
|
46
60
|
getSingularVariableNode() {
|
|
47
61
|
const ruleName = VARIABLE_RULE_NAME,
|
|
48
|
-
singularVariableNode = this.
|
|
62
|
+
singularVariableNode = this.getSingularNodeByRuleName(ruleName);
|
|
49
63
|
|
|
50
64
|
return singularVariableNode;
|
|
51
65
|
}
|
package/src/nonTerminalNode.js
CHANGED
|
@@ -87,7 +87,7 @@ export default class NonTerminalNode extends NonTerminalNodeBase {
|
|
|
87
87
|
return firstNode;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
getSingularNodeByRuleName(...ruleNames) {
|
|
91
91
|
let singularNode = null;
|
|
92
92
|
|
|
93
93
|
const nodes = this.filterChildNode((childNode) => {
|
|
@@ -73,10 +73,10 @@ export default define(class ContainedAssertion extends Assertion {
|
|
|
73
73
|
|
|
74
74
|
context.trace(`Verifying the '${termString}' term...`);
|
|
75
75
|
|
|
76
|
-
const
|
|
76
|
+
const termSingular = this.term.isSingular();
|
|
77
77
|
|
|
78
|
-
if (!
|
|
79
|
-
context.debug(`The '${termString}' term is not
|
|
78
|
+
if (!termSingular) {
|
|
79
|
+
context.debug(`The '${termString}' term is not singular.`);
|
|
80
80
|
} else {
|
|
81
81
|
termVerifies = this.term.verify(context, () => {
|
|
82
82
|
const verifiesAhead = true;
|
|
@@ -101,10 +101,10 @@ export default define(class ContainedAssertion extends Assertion {
|
|
|
101
101
|
|
|
102
102
|
context.trace(`Verifying the '${frameString}' frame...`);
|
|
103
103
|
|
|
104
|
-
const
|
|
104
|
+
const frameSingular = this.frame.isSingular();
|
|
105
105
|
|
|
106
|
-
if (!
|
|
107
|
-
context.debug(`The '${frameString}' frame is not
|
|
106
|
+
if (!frameSingular) {
|
|
107
|
+
context.debug(`The '${frameString}' frame is not singular.`);
|
|
108
108
|
} else {
|
|
109
109
|
stated = true; ///
|
|
110
110
|
|