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.
Files changed (73) hide show
  1. package/lib/context/branching.js +2 -2
  2. package/lib/context/ephemeral.js +186 -69
  3. package/lib/context/file/nominal.js +87 -52
  4. package/lib/context/liminal.js +2 -2
  5. package/lib/context/proof.js +55 -55
  6. package/lib/context/synthetic.js +151 -74
  7. package/lib/context.js +57 -17
  8. package/lib/element/assertion/defined.js +3 -3
  9. package/lib/element/assumption/metaLevel.js +6 -4
  10. package/lib/element/combinator.js +4 -2
  11. package/lib/element/conclusion.js +4 -2
  12. package/lib/element/constructor.js +4 -2
  13. package/lib/element/declaration/metavariable.js +10 -9
  14. package/lib/element/declaration/variable.js +7 -7
  15. package/lib/element/deduction.js +4 -2
  16. package/lib/element/label.js +9 -5
  17. package/lib/element/metavariable.js +34 -34
  18. package/lib/element/proofAssertion/premise.js +4 -3
  19. package/lib/element/proofAssertion/step.js +4 -2
  20. package/lib/element/reference.js +6 -4
  21. package/lib/element/statement.js +9 -1
  22. package/lib/element/substitution/frame.js +43 -29
  23. package/lib/element/substitution/reference.js +38 -28
  24. package/lib/element/substitution/statement.js +46 -38
  25. package/lib/element/substitution/term.js +49 -35
  26. package/lib/element/variable.js +6 -7
  27. package/lib/preamble.js +1 -2
  28. package/lib/process/assign.js +11 -10
  29. package/lib/process/equate.js +3 -2
  30. package/lib/process/unify.js +7 -7
  31. package/lib/utilities/context.js +13 -5
  32. package/lib/utilities/element.js +1 -1
  33. package/lib/utilities/equivalences.js +131 -0
  34. package/lib/utilities/json.js +59 -1
  35. package/lib/utilities/validation.js +4 -3
  36. package/package.json +2 -2
  37. package/src/context/branching.js +2 -2
  38. package/src/context/ephemeral.js +421 -237
  39. package/src/context/file/nominal.js +127 -77
  40. package/src/context/liminal.js +2 -2
  41. package/src/context/proof.js +81 -82
  42. package/src/context/synthetic.js +198 -88
  43. package/src/context.js +81 -20
  44. package/src/element/assertion/defined.js +4 -4
  45. package/src/element/assumption/metaLevel.js +8 -6
  46. package/src/element/combinator.js +4 -2
  47. package/src/element/conclusion.js +4 -2
  48. package/src/element/constructor.js +4 -2
  49. package/src/element/declaration/metavariable.js +10 -8
  50. package/src/element/declaration/variable.js +8 -7
  51. package/src/element/deduction.js +4 -2
  52. package/src/element/label.js +11 -7
  53. package/src/element/metavariable.js +11 -11
  54. package/src/element/proofAssertion/premise.js +4 -4
  55. package/src/element/proofAssertion/step.js +4 -2
  56. package/src/element/reference.js +7 -5
  57. package/src/element/statement.js +14 -0
  58. package/src/element/substitution/frame.js +47 -32
  59. package/src/element/substitution/reference.js +44 -34
  60. package/src/element/substitution/statement.js +63 -54
  61. package/src/element/substitution/term.js +53 -38
  62. package/src/element/variable.js +6 -7
  63. package/src/preamble.js +0 -1
  64. package/src/process/assign.js +17 -14
  65. package/src/process/equate.js +3 -1
  66. package/src/process/unify.js +10 -13
  67. package/src/utilities/context.js +13 -6
  68. package/src/utilities/element.js +1 -0
  69. package/src/utilities/equivalences.js +158 -0
  70. package/src/utilities/json.js +66 -0
  71. package/src/utilities/validation.js +6 -5
  72. package/lib/element/equivalences.js +0 -173
  73. package/src/element/equivalences.js +0 -237
@@ -3,52 +3,23 @@
3
3
  import { arrayUtilities } from "necessary";
4
4
 
5
5
  import Context from "../context";
6
- import elements from "../elements";
6
+
7
+ import { mergeEquivalences, findEquivalenceByTerm, equivalencesFromEquality, separateGroundedTermsAndDefinedVariables } from "../utilities/equivalences";
7
8
 
8
9
  const { last, filter } = arrayUtilities;
9
10
 
10
11
  class ProofContext extends Context {
11
- constructor(context, variables, judgements, assignments, equivalences, metaLevelAssumptions, subproofOrProofAssertions) {
12
+ constructor(context, assignments, equivalences, declaredVariables, declaredJudgements, metaLevelAssumptions, subproofOrProofAssertions) {
12
13
  super(context);
13
14
 
14
- this.variables = variables;
15
- this.judgements = judgements;
16
15
  this.assignments = assignments;
17
16
  this.equivalences = equivalences;
17
+ this.declaredVariables = declaredVariables;
18
+ this.declaredJudgements = declaredJudgements;
18
19
  this.metaLevelAssumptions = metaLevelAssumptions;
19
20
  this.subproofOrProofAssertions = subproofOrProofAssertions;
20
21
  }
21
22
 
22
- getVariables() {
23
- let variables;
24
-
25
- const context = this.getContext();
26
-
27
- variables = context.getVariables();
28
-
29
- variables = [
30
- ...this.variables,
31
- ...variables
32
- ];
33
-
34
- return variables;
35
- }
36
-
37
- getJudgements() {
38
- let judgements;
39
-
40
- const context = this.getContext();
41
-
42
- judgements = context.getJudgements();
43
-
44
- judgements = [ ///
45
- ...this.judgements,
46
- ...judgements
47
- ]
48
-
49
- return judgements;
50
- }
51
-
52
23
  getAssignments() {
53
24
  return this.assignments;
54
25
  }
@@ -64,11 +35,41 @@ class ProofContext extends Context {
64
35
 
65
36
  context = this; ///
66
37
 
67
- equivalences = this.equivalences.mergedWith(equivalences, context); ///
38
+ equivalences = mergeEquivalences(this.equivalences, equivalences, context); ///
68
39
 
69
40
  return equivalences;
70
41
  }
71
42
 
43
+ getDeclaredVariables() {
44
+ let declaredVariables;
45
+
46
+ const context = this.getContext();
47
+
48
+ declaredVariables = context.getDeclaredVariables();
49
+
50
+ declaredVariables = [
51
+ ...this.declaredVariables,
52
+ ...declaredVariables
53
+ ];
54
+
55
+ return declaredVariables;
56
+ }
57
+
58
+ getDeclaredJudgements() {
59
+ let declaredJudgements;
60
+
61
+ const context = this.getContext();
62
+
63
+ declaredJudgements = context.getDeclaredJudgements();
64
+
65
+ declaredJudgements = [ ///
66
+ ...this.declaredJudgements,
67
+ ...declaredJudgements
68
+ ]
69
+
70
+ return declaredJudgements;
71
+ }
72
+
72
73
  getMetaLevelAssumptions() {
73
74
  return this.metaLevelAssumptions;
74
75
  }
@@ -139,10 +140,9 @@ class ProofContext extends Context {
139
140
  const equalityRelfexive = equality.isReflexive();
140
141
 
141
142
  if (!equalityRelfexive) {
142
- const { Equivalence } = elements,
143
- equivalence = Equivalence.fromEquality(equality, context);
143
+ const equivalence = equivalencesFromEquality(equality, context);
144
144
 
145
- this.equivalences = this.equivalences.mergedWithEquivalence(equivalence, context);
145
+ this.equivalences = mergeEquivalences(this.equivalences, equivalence, context);
146
146
 
147
147
  context.debug(`...added the '${equalityString}' equality to the proof context.`);
148
148
  } else {
@@ -150,38 +150,38 @@ class ProofContext extends Context {
150
150
  }
151
151
  }
152
152
 
153
- addVariable(variable) {
154
- const context = this, ///
155
- variableString = variable.getString();
156
-
157
- context.trace(`Adding the '${variableString}' variable to the proof context...`);
153
+ addAssignment(assignment) {
154
+ this.assignments.push(assignment);
155
+ }
158
156
 
159
- this.variables.push(variable);
157
+ assignAssignments() {
158
+ const context = this; ///
160
159
 
161
- context.debug(`...added the '${variableString}' variable to the proof context.`);
160
+ this.assignments.forEach((assignment) => {
161
+ assignment(context);
162
+ });
162
163
  }
163
164
 
164
- addJudgement(judgement) {
165
+ addDEclaredVariable(declaredVariable) {
165
166
  const context = this, ///
166
- judgementString = judgement.getString();
167
+ declaredVariableString = declaredVariable.getString();
167
168
 
168
- context.trace(`Adding the '${judgementString}' judgement to the proof context...`);
169
+ context.trace(`Adding the '${declaredVariableString}' declared variable to the proof context...`);
169
170
 
170
- this.judgements.push(judgement);
171
+ this.declaredVariables.push(declaredVariable);
171
172
 
172
- context.debug(`...added the '${judgementString}' judgement to the proof context.`);
173
+ context.debug(`...added the '${declaredVariableString}' declared variable to the proof context.`);
173
174
  }
174
175
 
175
- addAssignment(assignment) {
176
- this.assignments.push(assignment);
177
- }
176
+ addDeclaredJudgement(declaredJudgement) {
177
+ const context = this, ///
178
+ declaredJudgementString = declaredJudgement.getString();
178
179
 
179
- assignAssignments() {
180
- const context = this; ///
180
+ context.trace(`Adding the '${declaredJudgementString}' declared judgement to the proof context...`);
181
181
 
182
- this.assignments.forEach((assignment) => {
183
- assignment(context);
184
- });
182
+ this.declaredJudgements.push(declaredJudgement);
183
+
184
+ context.debug(`...added the '${declaredJudgementString}' declared judgement to the proof context.`);
185
185
  }
186
186
 
187
187
  addMetaLevelAssumption(metaLevelAssumption) {
@@ -210,9 +210,9 @@ class ProofContext extends Context {
210
210
  context.debug(`The '${metaLevelAssumptionString}' metaLevelAssumption has already been added to the proof context.`);
211
211
  } else {
212
212
  this.metaLevelAssumptions.push(metaLevelAssumption);
213
-
214
- context.debug(`...added the '${metaLevelAssumptionString}' meta-level assumption to the proof context.`);
215
213
  }
214
+
215
+ context.debug(`...added the '${metaLevelAssumptionString}' meta-level assumption to the proof context.`);
216
216
  }
217
217
 
218
218
  addSubproofOrProofAssertion(subproofOrProofAssertion) {
@@ -240,11 +240,11 @@ class ProofContext extends Context {
240
240
  return comparesToTermAndPropertyRelation;
241
241
  }
242
242
 
243
- findEquivalenceByTerm(term) { return this.equivalences.findEquivalenceByTerm(term); }
243
+ findEquivalenceByTerm(term) { return findEquivalenceByTerm(this.equivalences, term); }
244
244
 
245
245
  findJudgementByMetavariableName(metavariableName) {
246
- const judgements = this.getJudgements(),
247
- judgement = judgements.find((judgement) => {
246
+ const declaredJudgements = this.getJudgements(),
247
+ judgement = declaredJudgements.find((judgement) => {
248
248
  const judgementMetavariableComparesToMetavariable = judgement.compareMetavariableName(metavariableName);
249
249
 
250
250
  if (judgementMetavariableComparesToMetavariable) {
@@ -255,23 +255,23 @@ class ProofContext extends Context {
255
255
  return judgement;
256
256
  }
257
257
 
258
- findVariableByVariableIdentifier(variableIdentifier) {
259
- const variables = this.getVariables(),
260
- variable = variables.find((variable) => {
261
- const variableComparesToVariableIdentifier = variable.compareVariableIdentifier(variableIdentifier);
258
+ findDeclaredVariableByVariableIdentifier(variableIdentifier) {
259
+ const declaredVariables = this.getDeclaredVariables(),
260
+ declaredVariable = declaredVariables.find((declaredVariable) => {
261
+ const variableComparesToVariableIdentifier = declaredVariable.compareVariableIdentifier(variableIdentifier);
262
262
 
263
263
  if (variableComparesToVariableIdentifier) {
264
264
  return true;
265
265
  }
266
266
  }) || null;
267
267
 
268
- return variable;
268
+ return declaredVariable;
269
269
  }
270
270
 
271
271
  findJudgementsByMetavariableNode(metavariableNode) {
272
- const judgements = this.getJudgements();
272
+ const declaredJudgements = this.getJudgements();
273
273
 
274
- filter(judgements, (judgement) => {
274
+ filter(declaredJudgements, (judgement) => {
275
275
  const metavariableNodeMatches = judgement.matchMetavariableNode(metavariableNode);
276
276
 
277
277
  if (metavariableNodeMatches) {
@@ -279,7 +279,7 @@ class ProofContext extends Context {
279
279
  }
280
280
  });
281
281
 
282
- return judgements;
282
+ return declaredJudgements;
283
283
  }
284
284
 
285
285
  findMetaLevelAssumptionByMetaLevelAssumptionNode(metaLevelAssumptionNode) {
@@ -307,11 +307,11 @@ class ProofContext extends Context {
307
307
  return judgementPresent;
308
308
  }
309
309
 
310
- isVariablePresentByVariableIdentifier(variableIdentifier) {
311
- const variable = this.findVariableByVariableIdentifier(variableIdentifier),
312
- variablePresent = (variable !== null);
310
+ isDeclaredVariablePresentByVariableIdentifier(variableIdentifier) {
311
+ const declaredVariable = this.findDeclaredVariableByVariableIdentifier(variableIdentifier),
312
+ declaredVariablePresent = (declaredVariable !== null);
313
313
 
314
- return variablePresent;
314
+ return declaredVariablePresent;
315
315
  }
316
316
 
317
317
  isTermGrounded(term) {
@@ -320,7 +320,7 @@ class ProofContext extends Context {
320
320
  groundedTerms = [],
321
321
  definedVariables = [];
322
322
 
323
- equivalences.separateGroundedTermsAndDefinedVariables(groundedTerms, definedVariables, context);
323
+ separateGroundedTermsAndDefinedVariables(equivalences, groundedTerms, definedVariables, context);
324
324
 
325
325
  const termMatchesGroundedTerm = groundedTerms.some((groundedTerm) => {
326
326
  const groundedTermNode = groundedTerm.getNode(),
@@ -336,13 +336,12 @@ class ProofContext extends Context {
336
336
  }
337
337
 
338
338
  static fromMetaLevelAssumptions(metaLevelAssumptions, context) {
339
- const { Equivalences } = elements,
340
- variables = [],
341
- judgements = [],
342
- assignments = [],
343
- equivalences = Equivalences.fromNothing(context),
339
+ const assignments = [],
340
+ equivalences = [],
341
+ declaredVariables = [],
342
+ declaredJudgements = [],
344
343
  subproofOrProofAssertions = [],
345
- proofContext = new ProofContext(context, variables, judgements, assignments, equivalences, metaLevelAssumptions, subproofOrProofAssertions);
344
+ proofContext = new ProofContext(context, assignments, equivalences, declaredVariables, declaredJudgements, metaLevelAssumptions, subproofOrProofAssertions);
346
345
 
347
346
  return proofContext;
348
347
  }
@@ -4,7 +4,7 @@ import { arrayUtilities } from "necessary";
4
4
 
5
5
  import Context from "../context";
6
6
 
7
- const { last } = arrayUtilities;
7
+ const { push, last } = arrayUtilities;
8
8
 
9
9
  export default class SyntheticContext extends Context {
10
10
  constructor(context, contexts) {
@@ -17,157 +17,267 @@ export default class SyntheticContext extends Context {
17
17
  return this.contexts;
18
18
  }
19
19
 
20
- addSubstitutions(substitutions) {
21
- const context = this.getContext();
20
+ getTerms() {
21
+ const terms = [];
22
22
 
23
- context.addSubstitutions(substitutions);
23
+ this.contexts.forEach((context) => {
24
+ const contextTerms = context.getTerms();
25
+
26
+ push(terms, contextTerms);
27
+ });
28
+
29
+ return terms;
24
30
  }
25
31
 
26
- findTermByTermNode(termNode) {
27
- let term = null;
32
+ getFrames() {
33
+ const frames = [];
28
34
 
29
- this.contexts.some((context) => {
30
- term = context.findTermByTermNode(termNode);
35
+ this.contexts.forEach((context) => {
36
+ const contextFrames = context.getFrames();
31
37
 
32
- if (term !== null) {
33
- return true;
34
- }
38
+ push(frames, contextFrames);
35
39
  });
36
40
 
37
- return term;
41
+ return frames;
38
42
  }
39
43
 
40
- findFrameByFrameNode(frameNode) {
41
- let frame = null;
44
+ getEqualities() {
45
+ const equalities = [];
42
46
 
43
- this.contexts.some((context) => {
44
- frame = context.findFrameByFrameNode(frameNode);
47
+ this.contexts.forEach((context) => {
48
+ const contextEqualities = context.getEqualities();
45
49
 
46
- if (frame !== null) {
47
- return true;
48
- }
50
+ push(equalities, contextEqualities);
49
51
  });
50
52
 
51
- return frame;
53
+ return equalities;
52
54
  }
53
55
 
54
- findStatementByStatementNode(statementNode) {
55
- let statement = null;
56
+ getJudgements() {
57
+ const judgements = [];
56
58
 
57
- this.contexts.some((context) => {
58
- statement = context.findStatementByStatementNode(statementNode);
59
+ this.contexts.forEach((context) => {
60
+ const contextJudgements = context.getJudgements();
59
61
 
60
- if (statement !== null) {
61
- return true;
62
- }
62
+ push(judgements, contextJudgements);
63
63
  });
64
64
 
65
- return statement;
65
+ return judgements;
66
66
  }
67
67
 
68
- findSubstitutionBySubstitutionNode(substitutionNode) {
69
- let substitution = null;
68
+ getStatements() {
69
+ const statements = [];
70
70
 
71
- this.contexts.some((context) => {
72
- substitution = context.findSubstitutionBySubstitutionNode(substitutionNode);
71
+ this.contexts.forEach((context) => {
72
+ const contextStatements = context.getStatements();
73
73
 
74
- if (substitution !== null) {
75
- return true;
76
- }
74
+ push(statements, contextStatements);
77
75
  });
78
76
 
79
- return substitution;
77
+ return statements;
80
78
  }
81
79
 
82
- findReferenceByMetavariableNode(metavariableNode) {
83
- let reference = null;
80
+ getAssertions() {
81
+ const assertions = [];
84
82
 
85
- this.contexts.some((context) => {
86
- reference = context.findReferenceByMetavariableNode(metavariableNode);
83
+ this.contexts.forEach((context) => {
84
+ const contextAssertions = context.getAssertions();
87
85
 
88
- if (reference !== null) {
89
- return true;
90
- }
86
+ push(assertions, contextAssertions);
91
87
  });
92
88
 
93
- return reference;
89
+ return assertions;
94
90
  }
95
91
 
96
- findVariableByVariableIdentifier(variableIdentifier) {
97
- let variable = null;
92
+ getReferences() {
93
+ const references = [];
98
94
 
99
- this.contexts.some((context) => {
100
- variable = context.findVariableByVariableIdentifier(variableIdentifier);
95
+ this.contexts.forEach((context) => {
96
+ const contextReferences = context.getReferences();
101
97
 
102
- if (variable !== null) {
103
- return true;
104
- }
98
+ push(references, contextReferences);
105
99
  });
106
100
 
107
- return variable;
101
+ return references;
108
102
  }
109
103
 
110
- findMetavariableByMetavariableName(metavariableName) {
111
- let metavariable = null;
104
+ getAssumptions() {
105
+ const assumptions = [];
112
106
 
113
- this.contexts.some((context) => {
114
- metavariable = context.findMetavariableByMetavariableName(metavariableName);
107
+ this.contexts.forEach((context) => {
108
+ const contextAssumptions = context.getAssumptions();
115
109
 
116
- if (metavariable !== null) {
117
- return true;
118
- }
110
+ push(assumptions, contextAssumptions);
119
111
  });
120
112
 
121
- return metavariable;
113
+ return assumptions;
122
114
  }
123
115
 
124
- isTermPresentByTermNode(termNode) {
125
- const term = this.findTermByTermNode(termNode),
126
- termPresent = (term !== null);
116
+ getMetavariables() {
117
+ const metavariables = [];
127
118
 
128
- return termPresent;
119
+ this.contexts.forEach((context) => {
120
+ const contextMetavariables = context.getMetavariables();
121
+
122
+ push(metavariables, contextMetavariables);
123
+ });
124
+
125
+ return metavariables;
129
126
  }
130
127
 
131
- isFramePresentByFrameNode(frameNode) {
132
- const frame = this.findFrameByFrameNode(frameNode),
133
- framePresent = (frame !== null);
128
+ getSubstitutions() {
129
+ const substitutions = [];
130
+
131
+ this.contexts.forEach((context) => {
132
+ const contextSubstitutions = context.getSubstitutions();
133
+
134
+ push(substitutions, contextSubstitutions);
135
+ });
134
136
 
135
- return framePresent;
137
+ return substitutions;
136
138
  }
137
139
 
138
- isStatementPresentByStatementNode(statementNode) {
139
- const statement = this.findStatementByStatementNode(statementNode),
140
- statementPresent = (statement !== null);
140
+ findTermByTermNode(termNode) {
141
+ const terms = this.getTerms(),
142
+ term = terms.find((term) => {
143
+ const termNodeMatches = term.matchTermNode(termNode);
144
+
145
+ if (termNodeMatches) {
146
+ return true;
147
+ }
148
+ }) || null;
141
149
 
142
- return statementPresent;
150
+ return term;
143
151
  }
144
152
 
145
- isSubstitutionPresentBySubstitutionNode(substitutionNode) {
146
- const substitution = this.findSubstitutionBySubstitutionNode(substitutionNode),
147
- substitutionPresent = (substitution !== null);
153
+ findFrameByFrameNode(frameNode) {
154
+ const frames = this.getFrames(),
155
+ frame = frames.find((frame) => {
156
+ const frameNodeMatches = frame.matchFrameNode(frameNode);
148
157
 
149
- return substitutionPresent;
158
+ if (frameNodeMatches) {
159
+ return true;
160
+ }
161
+ }) || null;
162
+
163
+ return frame;
150
164
  }
151
165
 
152
- isReferencePresentByMetavariableNode(metavariableNode) {
153
- const reference = this.findReferenceByMetavariableNode(metavariableNode),
154
- referencePresent = (reference !== null);
166
+ findEqualityByEqualityNode(equalityNode) {
167
+ const equalities = this.getEqualities(),
168
+ equality = equalities.find((equality) => {
169
+ const equalityNodeMatches = equality.matchEqualityNode(equalityNode);
155
170
 
156
- return referencePresent;
171
+ if (equalityNodeMatches) {
172
+ return true;
173
+ }
174
+ }) || null;
175
+
176
+ return equality;
157
177
  }
158
178
 
159
- isVariablePresentByVariableIdentifier(variableIdentifier) {
160
- const variable = this.findVariableByVariableIdentifier(variableIdentifier),
161
- variablePresent = (variable !== null);
179
+ findJudgementByJudgementNode(judgementNode) {
180
+ const judgements = this.getJudgements(),
181
+ judgement = judgements.find((judgement) => {
182
+ const judgementNodeMatches = judgement.matchJudgementNode(judgementNode);
183
+
184
+ if (judgementNodeMatches) {
185
+ return true;
186
+ }
187
+ }) || null;
162
188
 
163
- return variablePresent;
189
+ return judgement;
164
190
  }
165
191
 
166
- isMetavariablePresentByMetavariableName(metavariableName) {
167
- const metavariable = this.findMetavariableByMetavariableName(metavariableName),
168
- metavariablePresent = (metavariable !== null);
192
+ findStatementByStatementNode(statementNode) {
193
+ const statements = this.getStatements(),
194
+ statement = statements.find((statement) => {
195
+ const statementNodeMatches = statement.matchStatementNode(statementNode);
196
+
197
+ if (statementNodeMatches) {
198
+ return true;
199
+ }
200
+ }) || null;
169
201
 
170
- return metavariablePresent;
202
+ return statement;
203
+ }
204
+
205
+ findReferenceByReferenceNode(referenceNode) {
206
+ const references = this.getReferences(),
207
+ reference = references.find((reference) => {
208
+ const referenceMatcheReferenceNode = reference.matchReferenceNode(referenceNode);
209
+
210
+ if (referenceMatcheReferenceNode) {
211
+ return true;
212
+ }
213
+ }) || null;
214
+
215
+ return reference;
216
+ }
217
+
218
+ findAssertionByAssertionNode(assertionNode) {
219
+ const assertions = this.getAssertions(),
220
+ assertion = assertions.find((assertion) => {
221
+ const assertionNodeMatches = assertion.matchAssertionNode(assertionNode);
222
+
223
+ if (assertionNodeMatches) {
224
+ return true;
225
+ }
226
+ }) || null;
227
+
228
+ return assertion;
229
+ }
230
+
231
+ findAssumptionByAssumptionNode(assumptionNode) {
232
+ const assumptions = this.getAssumptions(),
233
+ assumption = assumptions.find((assumption) => {
234
+ const assumptionNodeMatches = assumption.matchAssumptionNode(assumptionNode);
235
+
236
+ if (assumptionNodeMatches) {
237
+ return true;
238
+ }
239
+ }) || null;
240
+
241
+ return assumption;
242
+ }
243
+
244
+ findReferenceByMetavariableNode(metavariableNode) {
245
+ const references = this.getReferences(),
246
+ reference = references.find((reference) => {
247
+ const referenceMatcheMetavariableNode = reference.matchMetavariableNode(metavariableNode);
248
+
249
+ if (referenceMatcheMetavariableNode) {
250
+ return true;
251
+ }
252
+ }) || null;
253
+
254
+ return reference;
255
+ }
256
+
257
+ findMetavariableByMetavariableNode(metavariableNode) {
258
+ const metavariables = this.getMetavariables(),
259
+ metavariable = metavariables.find((metavariable) => {
260
+ const metavariableNodeMatches = metavariable.matchMetavariableNode(metavariableNode);
261
+
262
+ if (metavariableNodeMatches) {
263
+ return true;
264
+ }
265
+ }) || null;
266
+
267
+ return metavariable;
268
+ }
269
+
270
+ findSubstitutionBySubstitutionNode(substitutionNode) {
271
+ const substitutions = this.getSubstitutions(),
272
+ substitution = substitutions.find((substitution) => {
273
+ const substitutionNodeMatches = substitution.matchSubstitutionNode(substitutionNode);
274
+
275
+ if (substitutionNodeMatches) {
276
+ return true;
277
+ }
278
+ }) || null;
279
+
280
+ return substitution;
171
281
  }
172
282
 
173
283
  static fromContexts(...contexts) {