occam-verify-cli 0.0.902 → 0.0.904

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 (51) hide show
  1. package/lib/axiomLemmaTheoremConjecture.js +18 -34
  2. package/lib/conclusion.js +3 -3
  3. package/lib/constants.js +1 -9
  4. package/lib/metaLemmaMetatheorem.js +22 -40
  5. package/lib/rule.js +45 -83
  6. package/lib/ruleNames.js +1 -21
  7. package/lib/utilities/array.js +49 -42
  8. package/lib/utilities/verifier.js +4 -10
  9. package/lib/verifier/node/metastatement.js +31 -6
  10. package/lib/verifier/node/statementAsCombinator.js +31 -6
  11. package/lib/verifier/node/termAsConstructor.js +25 -5
  12. package/lib/verifier/nodes/equality.js +13 -3
  13. package/lib/verifier/nodes/intrinsicLevel.js +13 -3
  14. package/lib/verifier/nodes/intrinsicLevelAgainstMetaLevel.js +13 -3
  15. package/lib/verifier/nodes/metaLevel.js +13 -3
  16. package/lib/verifier/nodes/statementAgainstCombinator.js +13 -3
  17. package/lib/verifier/nodes/termAgainstConstructor.js +13 -3
  18. package/lib/verify/containedAssertion.js +2 -2
  19. package/lib/verify/premise.js +1 -3
  20. package/lib/verify/statement/qualified.js +4 -7
  21. package/lib/verify/statement/unqualified.js +2 -5
  22. package/lib/verify/statement.js +34 -19
  23. package/lib/verify/statementAsCombinator.js +1 -2
  24. package/package.json +1 -1
  25. package/src/axiomLemmaTheoremConjecture.js +27 -47
  26. package/src/conclusion.js +2 -2
  27. package/src/constants.js +0 -2
  28. package/src/metaLemmaMetatheorem.js +33 -54
  29. package/src/rule.js +58 -101
  30. package/src/ruleNames.js +0 -5
  31. package/src/utilities/array.js +22 -42
  32. package/src/utilities/verifier.js +3 -11
  33. package/src/verifier/node/metastatement.js +46 -6
  34. package/src/verifier/node/statementAsCombinator.js +50 -10
  35. package/src/verifier/node/termAsConstructor.js +37 -6
  36. package/src/verifier/nodes/equality.js +19 -4
  37. package/src/verifier/nodes/intrinsicLevel.js +18 -3
  38. package/src/verifier/nodes/intrinsicLevelAgainstMetaLevel.js +18 -3
  39. package/src/verifier/nodes/metaLevel.js +19 -4
  40. package/src/verifier/nodes/statementAgainstCombinator.js +18 -3
  41. package/src/verifier/nodes/termAgainstConstructor.js +19 -4
  42. package/src/verify/containedAssertion.js +1 -1
  43. package/src/verify/premise.js +0 -2
  44. package/src/verify/statement/qualified.js +3 -7
  45. package/src/verify/statement/unqualified.js +1 -5
  46. package/src/verify/statement.js +38 -18
  47. package/src/verify/statementAsCombinator.js +0 -1
  48. package/lib/permutationsMatrix.js +0 -466136
  49. package/lib/utilities/permutations.js +0 -114
  50. package/src/permutationsMatrix.js +0 -6
  51. package/src/utilities/permutations.js +0 -148
@@ -5,8 +5,7 @@ import Consequent from "./consequent";
5
5
  import Supposition from "./supposition";
6
6
  import LocalContext from "./context/local";
7
7
 
8
- import { extract } from "./utilities/array";
9
- import { someSubArray } from "./utilities/array";
8
+ import { reverse, correlate } from "./utilities/array";
10
9
 
11
10
  export default class AxiomLemmaTheoremConjecture {
12
11
  constructor(labels, suppositions, consequent, localContext) {
@@ -33,35 +32,16 @@ export default class AxiomLemmaTheoremConjecture {
33
32
  }
34
33
 
35
34
  matchStatement(statementNode, localContext) {
36
- let statementNatches;
35
+ let statementNatches = false;
37
36
 
38
- const suppositionsLength = this.suppositions.length,
39
- statementLocalContext = localContext; ///
37
+ const proofSteps = localContext.getProofSteps(),
38
+ substitutions = [],
39
+ suppositionsMatch = matchSuppositions(this.suppositions, proofSteps, substitutions, this.localContext, localContext);
40
40
 
41
- if (suppositionsLength === 0) {
42
- const substitutions = [],
43
- consequentMatches = matchConsequent(this.consequent, statementNode, substitutions, this.localContext, statementLocalContext);
41
+ if (suppositionsMatch) {
42
+ const consequentMatches = matchConsequent(this.consequent, statementNode, substitutions, this.localContext, localContext);
44
43
 
45
- statementNatches = consequentMatches; ///
46
- } else {
47
- const proofSteps = statementLocalContext.getProofSteps();
48
-
49
- statementNatches = someSubArray(proofSteps, suppositionsLength, (proofSteps) => {
50
- let suppositionsMatchConsequent = false;
51
-
52
- const substitutions = [],
53
- suppositionsMatch = matchSuppositions(this.suppositions, proofSteps, substitutions, this.localContext, statementLocalContext);
54
-
55
- if (suppositionsMatch) {
56
- const consequentMatches = matchConsequent(this.consequent, statementNode, substitutions, this.localContext, statementLocalContext);
57
-
58
- suppositionsMatchConsequent = consequentMatches; ///
59
- }
60
-
61
- if (suppositionsMatchConsequent) {
62
- return true;
63
- }
64
- });
44
+ statementNatches = consequentMatches; ///
65
45
  }
66
46
 
67
47
  return statementNatches;
@@ -147,27 +127,13 @@ export default class AxiomLemmaTheoremConjecture {
147
127
  static fromLabelsSuppositionsConsequentAndLocalContext(Class, labels, suppositions, consequent, localContext) { return new Class(labels, suppositions, consequent, localContext); }
148
128
  }
149
129
 
150
- function matchSupposition(supposition, proofSteps, substitutions, localContext, statementLocalContext) {
151
- const proofStep = extract(proofSteps, (proofStep) => {
152
- const statementNode = proofStep.getStatementNode();
153
-
154
- if (statementNode !== null) {
155
- const statementMatches = supposition.matchStatementNode(statementNode, substitutions, localContext, statementLocalContext);
130
+ function matchSuppositions(suppositions, proofSteps, substitutions, localContext, statementLocalContext) {
131
+ suppositions = reverse(suppositions); ///
156
132
 
157
- if (statementMatches) {
158
- return true;
159
- }
160
- }
161
- }) || null;
133
+ proofSteps = reverse(proofSteps); ///
162
134
 
163
- const suppositionMatches = (proofStep !== null);
164
-
165
- return suppositionMatches;
166
- }
167
-
168
- function matchSuppositions(suppositions, proofSteps, substitutions, localContext, statementLocalContext) {
169
- const suppositionsMatch = suppositions.every((supposition) => {
170
- const suppositionMatches = matchSupposition(supposition, proofSteps, substitutions, localContext, statementLocalContext);
135
+ const suppositionsMatch = correlate(suppositions, proofSteps, (supposition, proofStep) => {
136
+ const suppositionMatches = matchSupposition(supposition, proofStep, substitutions, localContext, statementLocalContext);
171
137
 
172
138
  if (suppositionMatches) {
173
139
  return true;
@@ -177,6 +143,20 @@ function matchSuppositions(suppositions, proofSteps, substitutions, localContext
177
143
  return suppositionsMatch;
178
144
  }
179
145
 
146
+ function matchSupposition(supposition, proofStep, substitutions, localContext, statementLocalContext) {
147
+ let suppositionMatches = false;
148
+
149
+ const statementNode = proofStep.getStatementNode();
150
+
151
+ if (statementNode !== null) {
152
+ const statementMatches = supposition.matchStatementNode(statementNode, substitutions, localContext, statementLocalContext);
153
+
154
+ suppositionMatches = statementMatches; ///
155
+ }
156
+
157
+ return suppositionMatches;
158
+ }
159
+
180
160
  function matchConsequent(consequent, statementNode, substitutions, localContext, statementLocalContext) {
181
161
  const nonTerminalNodeMatches = consequent.matchStatementNode(statementNode, substitutions, localContext, statementLocalContext),
182
162
  consequentMatches = nonTerminalNodeMatches; ///
package/src/conclusion.js CHANGED
@@ -30,9 +30,9 @@ export default class Conclusion {
30
30
  localContextA = localContext, ///
31
31
  localContextB = statementLocalContext, ///
32
32
  nonTerminalNodeVerified = intrinsicLevelAgainstMetaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
33
- const verifyAhead = true;
33
+ const verifiedAhead = true;
34
34
 
35
- return verifyAhead;
35
+ return verifiedAhead;
36
36
  });
37
37
 
38
38
  statementNodeMatches = nonTerminalNodeVerified; ///
package/src/constants.js CHANGED
@@ -3,7 +3,5 @@
3
3
  export const NOT = 'not';
4
4
  export const COMMA = ',';
5
5
  export const EMPTY_STRING = "";
6
- export const MAXIMUM_INDEXES_LENGTH = 10;
7
6
  export const BRACKETED_STATEMENT_DEPTH = 2;
8
- export const MAXIMUM_PERMUTATION_LENGTH = 5;
9
7
  export const BRACKETED_METASTATEMENT_DEPTH = 1;
@@ -5,8 +5,7 @@ import MetaConsequent from "./metaConsequent";
5
5
  import MetaSupposition from "./metaSupposition";
6
6
  import MetastatementForMetavariableSubstitution from "./substitution/metastatementForMetavariable";
7
7
 
8
- import { extract } from "./utilities/array";
9
- import { someSubArray } from "./utilities/array";
8
+ import { reverse, correlate } from "./utilities/array";
10
9
 
11
10
  export default class MetaLemmaMetatheorem {
12
11
  constructor(labels, metaSuppositions, metaConsequent, substitutions, fileContext) {
@@ -38,34 +37,16 @@ export default class MetaLemmaMetatheorem {
38
37
  }
39
38
 
40
39
  matchMetastatement(metastatementNode, localMetaContext) {
41
- let metastatementNatches;
40
+ let metastatementNatches = false;
42
41
 
43
- const metaSuppositionsLength = this.metaSuppositions.length;
42
+ const metaproofSteps = localMetaContext.getProofSteps(),
43
+ substitutions = [],
44
+ metaSuppositionsMatch = matchMetaSuppositions(this.metaSuppositions, metaproofSteps, substitutions, this.fileContext, localMetaContext);
44
45
 
45
- if (metaSuppositionsLength === 0) {
46
- const substitutions = [],
47
- metaConsequentMatches = matchMetaConsequent(this.metaConsequent, metastatementNode, substitutions, this.fileContext, localMetaContext);
46
+ if (metaSuppositionsMatch) {
47
+ const metaConsequentMatches = matchMetaConsequent(this.metaConsequent, metastatementNode, substitutions, this.fileContext, localMetaContext);
48
48
 
49
- metastatementNatches = metaConsequentMatches; ///
50
- } else {
51
- const metaproofSteps = localMetaContext.getProofSteps();
52
-
53
- metastatementNatches = someSubArray(metaproofSteps, metaSuppositionsLength, (metaproofSteps) => {
54
- let metaSuppositionsMatchMetaConsequent = false;
55
-
56
- const substitutions = [],
57
- metaSuppositionsMatch = matchMetaSuppositions(this.metaSuppositions, metaproofSteps, substitutions, this.fileContext, localMetaContext);
58
-
59
- if (metaSuppositionsMatch) {
60
- const metaConsequentMatches = matchMetaConsequent(this.metaConsequent, metastatementNode, substitutions, this.fileContext, localMetaContext);
61
-
62
- metaSuppositionsMatchMetaConsequent = metaConsequentMatches; ///
63
- }
64
-
65
- if (metaSuppositionsMatchMetaConsequent) {
66
- return true;
67
- }
68
- });
49
+ metastatementNatches = metaConsequentMatches; ///
69
50
  }
70
51
 
71
52
  return metastatementNatches;
@@ -162,43 +143,41 @@ export default class MetaLemmaMetatheorem {
162
143
  static fromLabelsMetaSuppositionsMetaConsequentSubstitutionsAndFileContext(Class, labels, metaSuppositions, metaConsequent, substitutions, fileContext) { return new Class(labels, metaSuppositions, metaConsequent, substitutions, fileContext); }
163
144
  }
164
145
 
165
- function matchMetaSupposition(metaSupposition, metaproofSteps, substitutions, fileContext, localMetaContext) {
166
- const metaproofStep = extract(metaproofSteps, (metaproofStep) => {
167
- const metaSubproofNode = metaproofStep.getMetaSubproofNode(),
168
- metastatementNode = metaproofStep.getMetastatementNode();
146
+ function matchMetaSuppositions(metaSuppositions, metaproofSteps, substitutions, fileContext, localMetaContext) {
147
+ metaSuppositions = reverse(metaSuppositions); ///
169
148
 
170
- if (metaSubproofNode !== null) {
171
- const metaSubProofMatches = metaSupposition.matchMetaSubproofNode(metaSubproofNode, substitutions, fileContext, localMetaContext);
149
+ metaproofSteps = reverse(metaproofSteps); ///
172
150
 
173
- if (metaSubProofMatches) {
174
- return true;
175
- }
151
+ const metaSuppositionsMatch = correlate(metaSuppositions, metaproofSteps, (metaSupposition, metaproofStep) => {
152
+ const metaSuppositionMatches = matchMetaSupposition(metaSupposition, metaproofStep, substitutions, fileContext, localMetaContext);
153
+
154
+ if (metaSuppositionMatches) {
155
+ return true;
176
156
  }
157
+ });
177
158
 
178
- if (metastatementNode !== null) {
179
- const metastatementMatches = metaSupposition.matchMetastatementNode(metastatementNode, substitutions, fileContext, localMetaContext);
159
+ return metaSuppositionsMatch;
160
+ }
180
161
 
181
- if (metastatementMatches) {
182
- return true;
183
- }
184
- }
185
- }) || null;
162
+ function matchMetaSupposition(metaSupposition, metaproofStep, substitutions, fileContext, localMetaContext) {
163
+ let suppositionMatches = false;
186
164
 
187
- const metaSuppositionMatches = (metaproofStep !== null);
165
+ const metaSubproofNode = metaproofStep.getMetaSubproofNode(),
166
+ metastatementNode = metaproofStep.getMetastatementNode();
188
167
 
189
- return metaSuppositionMatches;
190
- }
168
+ if (metaSubproofNode !== null) {
169
+ const metaSubProofMatches = metaSupposition.matchMetaSubproofNode(metaSubproofNode, substitutions, fileContext, localMetaContext);
191
170
 
192
- function matchMetaSuppositions(metaSuppositions, metaproofSteps, substitutions, fileContext, localMetaContext) {
193
- const metaSuppositionsMatch = metaSuppositions.every((metaSupposition) => {
194
- const metaSuppositionMatches = matchMetaSupposition(metaSupposition, metaproofSteps, substitutions, fileContext, localMetaContext);
171
+ suppositionMatches - metaSubProofMatches; ///
172
+ }
195
173
 
196
- if (metaSuppositionMatches) {
197
- return true;
198
- }
199
- });
174
+ if (metastatementNode !== null) {
175
+ const metastatementMatches = metaSupposition.matchMetastatementNode(metastatementNode, substitutions, fileContext, localMetaContext);
200
176
 
201
- return metaSuppositionsMatch;
177
+ suppositionMatches - metastatementMatches; ///
178
+ }
179
+
180
+ return suppositionMatches;
202
181
  }
203
182
 
204
183
  function matchMetaConsequent(metaConsequent, metastatementNode, substitutions, fileContext, localMetaContext) {
package/src/rule.js CHANGED
@@ -4,8 +4,7 @@ import Label from "./label";
4
4
  import Premise from "./premise";
5
5
  import Conclusion from "./conclusion";
6
6
 
7
- import { extract } from "./utilities/array";
8
- import { someSubArray } from "./utilities/array";
7
+ import { reverse, correlate } from "./utilities/array";
9
8
 
10
9
  export default class Rule {
11
10
  constructor(labels, premises, conclusion, fileContext) {
@@ -32,68 +31,32 @@ export default class Rule {
32
31
  }
33
32
 
34
33
  matchStatement(statementNode, localContext) {
35
- let statementNatches;
34
+ let statementNatches = false;
36
35
 
37
- const premisesLength = this.premises.length;
36
+ const proofSteps = localContext.getProofSteps(),
37
+ substitutions = [],
38
+ premisesMatch = matchPremises(this.premises, proofSteps, substitutions, this.fileContext, localContext);
38
39
 
39
- if (premisesLength === 0) {
40
- const substitutions = [],
41
- conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, localContext);
40
+ if (premisesMatch) {
41
+ const conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, localContext);
42
42
 
43
- statementNatches = conclusionMatches; ///
44
- } else {
45
- const proofSteps = localContext.getProofSteps();
46
-
47
- statementNatches = someSubArray(proofSteps, premisesLength, (proofSteps) => {
48
- let premisesMatchConclusion = false;
49
-
50
- const substitutions = [],
51
- premisesMatch = matchPremises(this.premises, proofSteps, substitutions, this.fileContext, localContext);
52
-
53
- if (premisesMatch) {
54
- const conclusionMatches = matchConclusion(this.conclusion, statementNode, substitutions, this.fileContext, localContext);
55
-
56
- premisesMatchConclusion = conclusionMatches; ///
57
- }
58
-
59
- if (premisesMatchConclusion) {
60
- return true;
61
- }
62
- });
43
+ statementNatches = conclusionMatches; ///
63
44
  }
64
45
 
65
46
  return statementNatches;
66
47
  }
67
48
 
68
49
  matchMetastatement(metastatementNode, localMetaContext) {
69
- let metastatementNatches;
70
-
71
- const premisesLength = this.premises.length;
72
-
73
- if (premisesLength === 0) {
74
- const substitutions = [],
75
- conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, localMetaContext);
76
-
77
- metastatementNatches = conclusionMatches; ///
78
- } else {
79
- const metaproofSteps = localMetaContext.getMetaproofSteps();
80
-
81
- metastatementNatches = someSubArray(metaproofSteps, premisesLength, (metaproofSteps) => {
82
- let premisesMatchConclusion = false;
50
+ let metastatementNatches = false;
83
51
 
84
- const substitutions = [],
85
- premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions, this.fileContext, localMetaContext);
52
+ const metaproofSteps = localMetaContext.getMetaproofSteps(),
53
+ substitutions = [],
54
+ premisesMatch = metaMatchPremises(this.premises, metaproofSteps, substitutions, this.fileContext, localMetaContext);
86
55
 
87
- if (premisesMatch) {
88
- const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, localMetaContext);
56
+ if (premisesMatch) {
57
+ const conclusionMatches = metaMatchConclusion(this.conclusion, metastatementNode, substitutions, this.fileContext, localMetaContext);
89
58
 
90
- premisesMatchConclusion = conclusionMatches; ///
91
- }
92
-
93
- if (premisesMatchConclusion) {
94
- return true;
95
- }
96
- });
59
+ metastatementNatches = conclusionMatches; ///
97
60
  }
98
61
 
99
62
  return metastatementNatches;
@@ -180,36 +143,34 @@ export default class Rule {
180
143
  }
181
144
  }
182
145
 
183
- function matchPremise(premise, proofSteps, substitutions, fileContext, localContext) {
184
- const proofStep = extract(proofSteps, (proofStep) => {
185
- const subproofNode = proofStep.getSubproofNode(),
186
- statementNode = proofStep.getStatementNode();
146
+ function matchPremise(premise, proofStep, substitutions, fileContext, localContext) {
147
+ let premiseMatches = false;
187
148
 
188
- if (subproofNode !== null) {
189
- const subproofNodeMatches = premise.matchSubproofNode(subproofNode, substitutions, fileContext, localContext);
149
+ const subproofNode = proofStep.getSubproofNode(),
150
+ statementNode = proofStep.getStatementNode();
190
151
 
191
- if (subproofNodeMatches) {
192
- return true;
193
- }
194
- }
152
+ if (subproofNode !== null) {
153
+ const subproofNodeMatches = premise.matchSubproofNode(subproofNode, substitutions, fileContext, localContext);
195
154
 
196
- if (statementNode !== null) {
197
- const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions, fileContext, localContext);
155
+ premiseMatches = subproofNodeMatches; ///
156
+ }
198
157
 
199
- if (statementNodeMatches) {
200
- return true;
201
- }
202
- }
203
- }) || null;
158
+ if (statementNode !== null) {
159
+ const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions, fileContext, localContext);
204
160
 
205
- const premiseMatches = (proofStep !== null);
161
+ premiseMatches = statementNodeMatches; ///
162
+ }
206
163
 
207
164
  return premiseMatches;
208
165
  }
209
166
 
210
- function matchPremises(premise, proofSteps, substitutions, fileContext, localContext) {
211
- const premisesMatch = premise.every((premise) => {
212
- const premiseMatches = matchPremise(premise, proofSteps, substitutions, fileContext, localContext);
167
+ function matchPremises(premises, proofSteps, substitutions, fileContext, localContext) {
168
+ premises = reverse(premises); ///
169
+
170
+ proofSteps = reverse(proofSteps); ///
171
+
172
+ const premisesMatch = correlate(premises, proofSteps, (premise, proofStep) => {
173
+ const premiseMatches = matchPremise(premise, proofStep, substitutions, fileContext, localContext);
213
174
 
214
175
  if (premiseMatches) {
215
176
  return true;
@@ -226,45 +187,41 @@ function matchConclusion(conclusion, statementNode, substitutions, fileContext,
226
187
  return conclusionMatches;
227
188
  }
228
189
 
229
- function metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, localMetaContext) {
230
- const metaproofStep = extract(metaproofSteps, (metaproofStep) => {
231
- const ruleSubproofNode = metaproofStep.getRuleSubproofNode(),
232
- metaSubproofNode = metaproofStep.getMetaSubproofNode(),
233
- metastatementNode = metaproofStep.getMetastatementNode()
190
+ function metaMatchPremise(premise, metaproofStep, substitutions, fileContext, localMetaContext) {
191
+ let premiseMatches = false;
234
192
 
235
- if (ruleSubproofNode !== null) {
236
- const ruleSubProofNodeMatches = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, localMetaContext);
193
+ const ruleSubproofNode = metaproofStep.getRuleSubproofNode(),
194
+ metaSubproofNode = metaproofStep.getMetaSubproofNode(),
195
+ metastatementNode = metaproofStep.getMetastatementNode()
237
196
 
238
- if (ruleSubProofNodeMatches) {
239
- return true;
240
- }
241
- }
197
+ if (ruleSubproofNode !== null) {
198
+ const ruleSubProofNodeMatches = premise.matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, localMetaContext);
242
199
 
243
- if (metaSubproofNode !== null) {
244
- const metaSubProofNodeMatches = premise.matchMetaSubproofNode(metaSubproofNode, substitutions, fileContext, localMetaContext);
200
+ premiseMatches = ruleSubProofNodeMatches; ///
201
+ }
245
202
 
246
- if (metaSubProofNodeMatches) {
247
- return true;
248
- }
249
- }
203
+ if (metaSubproofNode !== null) {
204
+ const metaSubProofNodeMatches = premise.matchMetaSubproofNode(metaSubproofNode, substitutions, fileContext, localMetaContext);
250
205
 
251
- if (metastatementNode !== null) {
252
- const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode, substitutions, fileContext, localMetaContext);
206
+ premiseMatches = metaSubProofNodeMatches; ///
207
+ }
253
208
 
254
- if (metastatementNodeMatches) {
255
- return true;
256
- }
257
- }
258
- }) || null;
209
+ if (metastatementNode !== null) {
210
+ const metastatementNodeMatches = premise.matchMetastatementNode(metastatementNode, substitutions, fileContext, localMetaContext);
259
211
 
260
- const premiseMatches = (metaproofStep !== null);
212
+ premiseMatches = metastatementNodeMatches; ///
213
+ }
261
214
 
262
215
  return premiseMatches;
263
216
  }
264
217
 
265
- function metaMatchPremises(premise, metaproofSteps, substitutions, fileContext, localMetaContext) {
266
- const premisesMatch = premise.every((premise) => {
267
- const premiseMatches = metaMatchPremise(premise, metaproofSteps, substitutions, fileContext, localMetaContext);
218
+ function metaMatchPremises(premises, metaproofSteps, substitutions, fileContext, localMetaContext) {
219
+ premises = reverse(premises); ///
220
+
221
+ metaproofSteps = reverse(metaproofSteps); ///
222
+
223
+ const premisesMatch = correlate(premises, metaproofSteps, (premise, metaproofStep) => {
224
+ const premiseMatches = metaMatchPremise(premise, metaproofStep, substitutions, fileContext, localMetaContext);
268
225
 
269
226
  if (premiseMatches) {
270
227
  return true;
package/src/ruleNames.js CHANGED
@@ -1,13 +1,8 @@
1
1
  "use strict";
2
2
 
3
- export const SUBPROOF_RULE_NAME = "subproof";
4
3
  export const METAVARIABLE_RULE_NAME = "metavariable";
5
- export const RULE_SUBPROOF_RULE_NAME = "ruleSubproof";
6
- export const META_SUBPROOF_RULE_NAME = "metaSubproof";
7
4
  export const META_ARGUMENT_RULE_NAME = "metaArgument";
8
- export const QUALIFIED_STATEMENT_RULE_NAME = "qualifiedStatement";
9
5
  export const VARIABLE_DECLARATION_RULE_NAME = "variableDeclaration";
10
6
  export const UNQUALIFIED_STATEMENT_RULE_NAME = "unqualifiedStatement";
11
7
  export const CONSTRUCTOR_DECLARATION_RULE_NAME = "constructorDeclaration";
12
- export const QUALIFIED_METASTATEMENT_RULE_NAME = "qualifiedMetastatement";
13
8
  export const UNQUALIFIED_METASTATEMENT_RULE_NAME = "unqualifiedMetastatement";
@@ -2,56 +2,36 @@
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
4
 
5
- import permutationsMatrix from "../permutationsMatrix";
5
+ export const { first, second, last, extract, push, match, filter, compress, separate } = arrayUtilities;
6
6
 
7
- import { MAXIMUM_INDEXES_LENGTH, MAXIMUM_PERMUTATION_LENGTH } from "../constants";
7
+ export function reverse(array) {
8
+ array = [ ///
9
+ ...array
10
+ ].reverse();
8
11
 
9
- export const { first, second, last, push, prune, extract, match, filter, compress, separate } = arrayUtilities;
10
-
11
- export function someSubArray(array, subArrayLength, callback) {
12
- let found = false;
13
-
14
- const arrayLength = array.length,
15
- indexesLength = arrayLength, ///
16
- permutationLength = subArrayLength; ///
17
-
18
- if (permutationLength <= MAXIMUM_PERMUTATION_LENGTH) {
19
- let offset,
20
- permutations;
21
-
22
- if (indexesLength > MAXIMUM_INDEXES_LENGTH) {
23
- offset = indexesLength - MAXIMUM_INDEXES_LENGTH;
24
-
25
- permutations = permutationsMatrix[MAXIMUM_INDEXES_LENGTH][permutationLength];
26
- } else {
27
- offset = 0;
28
-
29
- permutations = permutationsMatrix[indexesLength][permutationLength];
30
- }
31
-
32
- if (permutations !== null) {
33
- found = permutations.some((permutation) => {
34
- if (permutation !== null) {
35
- const subArray = [];
12
+ return array;
13
+ }
36
14
 
37
- for (let position = 0; position < permutationLength; position++) {
38
- const index = permutation[position] + offset,
39
- element = array[index];
15
+ export function correlate(arrayA, arrayB, callback) {
16
+ arrayB = [ ///
17
+ ...arrayB
18
+ ];
40
19
 
41
- subArray.push(element);
42
- }
20
+ const correlates = arrayA.every((elementA) => {
21
+ const elementB = extract(arrayB, (elementB) => {
22
+ const result = callback(elementA, elementB);
43
23
 
44
- const passed = callback(subArray);
24
+ if (result) {
25
+ return true;
26
+ }
27
+ }) || null;
45
28
 
46
- if (passed) {
47
- return true;
48
- }
49
- }
50
- });
29
+ if (elementB !== null) {
30
+ return true;
51
31
  }
52
- }
32
+ });
53
33
 
54
- return found;
34
+ return correlates;
55
35
  }
56
36
 
57
37
  export function leftDifference(arrayA, arrayB) {
@@ -1,20 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  export function verifyNode(nodeQueryMaps, nonTerminalNode, ...remainingArguments) {
4
- let nodeVerified;
4
+ let nodeVerified = false;
5
5
 
6
6
  nodeVerified = nodeQueryMaps.some((nodeQueryMap) => {
7
- let nodeVerified = false;
8
-
9
7
  const { nodeQuery, verifyNode } = nodeQueryMap;
10
8
 
11
9
  const node = nodeQuery(nonTerminalNode);
12
10
 
13
11
  if (node !== null) {
14
12
  nodeVerified = verifyNode(node, ...remainingArguments);
15
- }
16
13
 
17
- if (nodeVerified) {
18
14
  return true;
19
15
  }
20
16
  });
@@ -23,11 +19,9 @@ export function verifyNode(nodeQueryMaps, nonTerminalNode, ...remainingArguments
23
19
  }
24
20
 
25
21
  export function verifyNodes(nodeQueryMaps, nonTerminalNodeA, nonTerminalNodeB, ...remainingArguments) {
26
- let nodesVerified;
27
-
28
- nodesVerified = nodeQueryMaps.some((nodeQueryMap) => {
29
- let nodesVerified = false;
22
+ let nodesVerified = false;
30
23
 
24
+ nodeQueryMaps.some((nodeQueryMap) => {
31
25
  const { nodeQueryA, nodeQueryB, verifyNodes } = nodeQueryMap;
32
26
 
33
27
  const nodeA = nodeQueryA(nonTerminalNodeA), ///
@@ -35,9 +29,7 @@ export function verifyNodes(nodeQueryMaps, nonTerminalNodeA, nonTerminalNodeB, .
35
29
 
36
30
  if ((nodeA !== null) && (nodeB !== null)) {
37
31
  nodesVerified = verifyNodes(nodeA, nodeB, ...remainingArguments);
38
- }
39
32
 
40
- if (nodesVerified) {
41
33
  return true;
42
34
  }
43
35
  });