occam-verify-cli 1.0.405 → 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.
Files changed (122) hide show
  1. package/lib/context/file.js +3 -3
  2. package/lib/context/local.js +3 -3
  3. package/lib/context/release.js +2 -2
  4. package/lib/context/temporary.js +103 -54
  5. package/lib/mixins/statement/verify.js +2 -2
  6. package/lib/mixins/step/unify.js +2 -2
  7. package/lib/node/argument.js +2 -2
  8. package/lib/node/assumption.js +6 -6
  9. package/lib/node/frame.js +19 -7
  10. package/lib/node/judgement.js +8 -1
  11. package/lib/node/statement.js +34 -15
  12. package/lib/node/substitution/term.js +3 -11
  13. package/lib/node/term.js +20 -8
  14. package/lib/nonTerminalNode.js +3 -3
  15. package/lib/ontology/assertion/contained.js +7 -7
  16. package/lib/ontology/assertion/defined.js +8 -8
  17. package/lib/ontology/assertion/subproof.js +3 -3
  18. package/lib/ontology/assumption.js +49 -45
  19. package/lib/ontology/combinator.js +3 -3
  20. package/lib/ontology/constructor.js +3 -3
  21. package/lib/ontology/equality.js +4 -4
  22. package/lib/ontology/equivalence.js +2 -2
  23. package/lib/ontology/frame.js +37 -12
  24. package/lib/ontology/judgement.js +13 -6
  25. package/lib/ontology/metavariable.js +75 -76
  26. package/lib/ontology/propertyRelation.js +2 -2
  27. package/lib/ontology/reference.js +33 -4
  28. package/lib/ontology/signature.js +2 -2
  29. package/lib/ontology/statement.js +33 -8
  30. package/lib/ontology/step.js +4 -4
  31. package/lib/ontology/substitution/frame.js +13 -15
  32. package/lib/ontology/substitution/statement.js +31 -32
  33. package/lib/ontology/substitution/term.js +26 -25
  34. package/lib/ontology/substitution.js +2 -2
  35. package/lib/ontology/substitutions.js +4 -4
  36. package/lib/ontology/term.js +26 -12
  37. package/lib/ontology/variable.js +2 -2
  38. package/lib/process/equate.js +322 -0
  39. package/lib/process/unify.js +623 -0
  40. package/lib/process/verify.js +332 -0
  41. package/lib/utilities/brackets.js +3 -8
  42. package/lib/utilities/context.js +4 -14
  43. package/lib/utilities/json.js +18 -1
  44. package/lib/utilities/pass.js +68 -0
  45. package/lib/utilities/substitutions.js +11 -16
  46. package/package.json +2 -2
  47. package/src/context/file.js +2 -2
  48. package/src/context/local.js +2 -2
  49. package/src/context/release.js +1 -1
  50. package/src/context/temporary.js +124 -54
  51. package/src/mixins/statement/verify.js +3 -1
  52. package/src/mixins/step/unify.js +0 -1
  53. package/src/node/argument.js +1 -1
  54. package/src/node/assumption.js +4 -4
  55. package/src/node/frame.js +19 -5
  56. package/src/node/judgement.js +7 -0
  57. package/src/node/statement.js +35 -13
  58. package/src/node/substitution/term.js +4 -14
  59. package/src/node/term.js +20 -6
  60. package/src/nonTerminalNode.js +1 -1
  61. package/src/ontology/assertion/contained.js +6 -6
  62. package/src/ontology/assertion/defined.js +7 -7
  63. package/src/ontology/assertion/subproof.js +1 -1
  64. package/src/ontology/assumption.js +52 -57
  65. package/src/ontology/combinator.js +1 -1
  66. package/src/ontology/constructor.js +1 -1
  67. package/src/ontology/equality.js +3 -3
  68. package/src/ontology/equivalence.js +1 -1
  69. package/src/ontology/frame.js +44 -10
  70. package/src/ontology/judgement.js +8 -3
  71. package/src/ontology/metavariable.js +108 -102
  72. package/src/ontology/propertyRelation.js +3 -2
  73. package/src/ontology/reference.js +39 -1
  74. package/src/ontology/signature.js +3 -3
  75. package/src/ontology/statement.js +38 -4
  76. package/src/ontology/step.js +7 -7
  77. package/src/ontology/substitution/frame.js +13 -17
  78. package/src/ontology/substitution/statement.js +45 -48
  79. package/src/ontology/substitution/term.js +19 -19
  80. package/src/ontology/substitution.js +3 -2
  81. package/src/ontology/substitutions.js +3 -3
  82. package/src/ontology/term.js +26 -5
  83. package/src/ontology/variable.js +3 -2
  84. package/src/process/equate.js +212 -0
  85. package/src/process/unify.js +634 -0
  86. package/src/process/verify.js +204 -0
  87. package/src/utilities/brackets.js +2 -11
  88. package/src/utilities/context.js +1 -21
  89. package/src/utilities/json.js +19 -0
  90. package/src/utilities/{unifier.js → pass.js} +17 -1
  91. package/src/utilities/substitutions.js +10 -20
  92. package/lib/unifier/equantional.js +0 -170
  93. package/lib/unifier/intrinsicLevel.js +0 -144
  94. package/lib/unifier/metaLevel.js +0 -197
  95. package/lib/unifier/metavariable.js +0 -140
  96. package/lib/unifier/statementWithCombinator.js +0 -177
  97. package/lib/unifier/termWithConstructor.js +0 -145
  98. package/lib/unifier.js +0 -241
  99. package/lib/utilities/arguments.js +0 -28
  100. package/lib/utilities/frame.js +0 -18
  101. package/lib/utilities/metavariable.js +0 -18
  102. package/lib/utilities/statement.js +0 -18
  103. package/lib/utilities/unification.js +0 -109
  104. package/lib/utilities/unifier.js +0 -51
  105. package/lib/utilities/variable.js +0 -18
  106. package/lib/verifier/combinator.js +0 -158
  107. package/lib/verifier.js +0 -219
  108. package/src/unifier/equantional.js +0 -90
  109. package/src/unifier/intrinsicLevel.js +0 -52
  110. package/src/unifier/metaLevel.js +0 -151
  111. package/src/unifier/metavariable.js +0 -50
  112. package/src/unifier/statementWithCombinator.js +0 -114
  113. package/src/unifier/termWithConstructor.js +0 -56
  114. package/src/unifier.js +0 -183
  115. package/src/utilities/arguments.js +0 -21
  116. package/src/utilities/frame.js +0 -13
  117. package/src/utilities/metavariable.js +0 -13
  118. package/src/utilities/statement.js +0 -13
  119. package/src/utilities/unification.js +0 -136
  120. package/src/utilities/variable.js +0 -13
  121. package/src/verifier/combinator.js +0 -72
  122. package/src/verifier.js +0 -150
@@ -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, substitutions, reference) {
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
- getSubstitutions() {
44
- return this.substitutions;
43
+ getReferences() {
44
+ return this.references;
45
45
  }
46
46
 
47
- getReference() {
48
- return this.reference;
47
+ getSubstitutions() {
48
+ return this.substitutions;
49
49
  }
50
50
 
51
51
  addTerm(term) {
52
- const context = this, ///
53
- termNode = term.getNode(),
52
+ const termA = term, ///
53
+ context = this, ///
54
54
  termString = term.getString();
55
55
 
56
56
  extract(this.terms, (term) => {
57
- const termMatchesTermNode = term.matchTermNode(termNode);
57
+ const termB = term, ///
58
+ termAEqualToTermB = termA.isEqualTo(termB);
58
59
 
59
- if (termMatchesTermNode) {
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 context = this, ///
71
- frameNode = frame.getNode(),
71
+ const frameA = frame, ///
72
+ context = this, ///
72
73
  frameString = frame.getString();
73
74
 
74
75
  extract(this.frames, (frame) => {
75
- const frameMatchesFrameNode = frame.matchFrameNode(frameNode);
76
+ const frameB = frame, ///
77
+ frameAEqualToFrameB = frameA.isEqualTo(frameB);
76
78
 
77
- if (frameMatchesFrameNode) {
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
- statementNode = statement.getNode(),
91
+ statementA = statement, ///
90
92
  statementString = statement.getString();
91
93
 
92
94
  extract(this.statements, (statement) => {
93
- const statementMatchesFrameNode = statement.matchStatementNode(statementNode);
95
+ const statementB = statement, ///
96
+ statementAEqualToFrameB = statementA.isEqualTo(statementB);
94
97
 
95
- if (statementMatchesFrameNode) {
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
- assertionNode = assertion.getNode(),
110
+ assertionA = assertion, ///
108
111
  assertionString = assertion.getString();
109
112
 
110
113
  extract(this.assertions, (assertion) => {
111
- const assertionMatchesFrameNode = assertion.matchAssertionNode(assertionNode);
114
+ const assertionB = assertion, ///
115
+ assertionAEqualToAssertionB = assertionA.isEqualTo(assertionB);
112
116
 
113
- if (assertionMatchesFrameNode) {
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
- addSubstitution(substitution) {
127
+ addReference(reference) {
124
128
  const context = this, ///
125
- substitutionNode = substitution.getNode(),
126
- substitutionString = substitution.getString();
129
+ referenceA = reference, ///
130
+ referenceString = reference.getString();
127
131
 
128
- extract(this.substitutions, (substitution) => {
129
- const substitutionMatchesFrameNode = substitution.matchSubstitutionNode(substitutionNode);
132
+ extract(this.references, (reference) => {
133
+ const referenceB = reference, ///
134
+ referenceAEqualToReferenceB = referenceA.isEqualTo(referenceB);
130
135
 
131
- if (substitutionMatchesFrameNode) {
136
+ if (referenceAEqualToReferenceB) {
132
137
  return true;
133
138
  }
134
139
  });
135
140
 
136
- context.trace(`Added the '${substitutionString}' substitution.`);
141
+ context.trace(`Added the '${referenceString}' reference to the context.`);
137
142
 
138
- this.substitutions.push(substitution);
143
+ this.references.push(reference);
139
144
  }
140
145
 
141
- addReference(reference) {
146
+ addSubstitution(substitution) {
142
147
  const context = this, ///
143
- referenceString = reference.getString();
148
+ substitutionA = substitution, ///
149
+ substitutionString = substitution.getString();
144
150
 
145
- this.reference = reference;
151
+ extract(this.substitutions, (substitution) => {
152
+ const substitutionB = substitution, ///
153
+ substituionAEqualToSubstitutionB = substitutionA.isEqualTo(substitutionB);
146
154
 
147
- context.trace(`Added the '${referenceString}' reference.`);
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
- findStatementByStatementNode(statementNode) {
187
- const statement = this.statements.find((statement) => {
188
- const statementMatchesStatementNode = statement.matchStatementNode(statementNode);
213
+ findReferenceByMetavariableNode(metavariableNode) {
214
+ const reference = this.references.find((reference) => {
215
+ const referenceMatcheMetavariableNode = reference.matchMetavariableNode(metavariableNode);
189
216
 
190
- if (statementMatchesStatementNode) {
217
+ if (referenceMatcheMetavariableNode) {
191
218
  return true;
192
219
  }
193
220
  }) || null;
194
221
 
195
- return statement;
222
+ return reference;
196
223
  }
197
224
 
198
- findSubtitutionBySubtitutionNode(substitutionNode) {
225
+ findSubstitutionBySubstitutionNode(substitutionNode) {
199
226
  const substitution = this.substitutions.find((substitution) => {
200
- const substitutionMatchesSubtitutionNode = substitution.matchSubtitutionNode(substitutionNode);
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
- marge(context) {
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 termANode = termA.getNode(),
418
- termBNode = termB.getNode(),
419
- termANodeMatchesTermBNode = termANode.match(termBNode);
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 (termAMatchesTermB) {
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
- reference = null,
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
- reference = null,
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
- reference = null,
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
- substitution = TermSubstitution.fromStatement(statement, context) || FrameSubstitution.fromStatement(statement, context);
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);
@@ -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
 
@@ -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.getSingularTNodeByRuleName(ruleName);
24
+ singularTermNode = this.getSingularNodeByRuleName(ruleName);
25
25
 
26
26
  return singularTermNode;
27
27
  }
@@ -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
- isSimple() {
9
- let simple = false;
8
+ isSingular() {
9
+ let singular = false;
10
10
 
11
11
  const statementNode = this.getStatementNode();
12
12
 
13
13
  if (statementNode === null) {
14
- simple = true;
14
+ singular = true;
15
15
  }
16
16
 
17
- return simple;
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
- isSimple() {
9
- let simple = false;
8
+ isSingular() {
9
+ let singular = false;
10
10
 
11
11
  const singularAssumptionNode = this.getSingularAssumptionNode();
12
12
 
13
13
  if (singularAssumptionNode !== null) {
14
- simple = singularAssumptionNode.isSimple();
14
+ singular = singularAssumptionNode.isSingular();
15
15
  }
16
16
 
17
- return simple;
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.getSingularTNodeByRuleName(ruleName);
50
+ singularAssumptionNode = this.getSingularNodeByRuleName(ruleName);
37
51
 
38
52
  return singularAssumptionNode;
39
53
  }
@@ -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);
@@ -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
- isSimple() {
23
- let simple = false;
22
+ getMetavariableName() {
23
+ let metavariableName = null;
24
24
 
25
- const metavariableNode = this.getMetavariableNode();
25
+ const singular = this.isSingular();
26
26
 
27
- if (metavariableNode !== null) {
28
- simple = true;
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 simple;
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
- isSimple() {
9
- let simple = false;
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
- simple = true;
28
+ singular = true;
15
29
  }
16
30
 
17
- return simple;
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.getSingularTNodeByRuleName(ruleName);
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.getSingularTNodeByRuleName(ruleName);
62
+ singularVariableNode = this.getSingularNodeByRuleName(ruleName);
49
63
 
50
64
  return singularVariableNode;
51
65
  }
@@ -87,7 +87,7 @@ export default class NonTerminalNode extends NonTerminalNodeBase {
87
87
  return firstNode;
88
88
  }
89
89
 
90
- getSingularTNodeByRuleName(...ruleNames) {
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 termSimple = this.term.isSimple();
76
+ const termSingular = this.term.isSingular();
77
77
 
78
- if (!termSimple) {
79
- context.debug(`The '${termString}' term is not simple.`);
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 frameSimple = this.frame.isSimple();
104
+ const frameSingular = this.frame.isSingular();
105
105
 
106
- if (!frameSimple) {
107
- context.debug(`The '${frameString}' frame is not simple.`);
106
+ if (!frameSingular) {
107
+ context.debug(`The '${frameString}' frame is not singular.`);
108
108
  } else {
109
109
  stated = true; ///
110
110