occam-verify-cli 1.0.320 → 1.0.326

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 (49) hide show
  1. package/lib/context/file.js +97 -109
  2. package/lib/context/local.js +21 -9
  3. package/lib/context/release.js +58 -7
  4. package/lib/dom/assertion/type.js +3 -3
  5. package/lib/dom/declaration/complexType.js +106 -92
  6. package/lib/dom/declaration/constructor.js +5 -5
  7. package/lib/dom/declaration/metavariable.js +3 -3
  8. package/lib/dom/declaration/simpleType.js +37 -41
  9. package/lib/dom/declaration/typePrefix.js +11 -6
  10. package/lib/dom/declaration/variable.js +5 -5
  11. package/lib/dom/metavariable.js +3 -3
  12. package/lib/dom/property.js +4 -4
  13. package/lib/dom/type.js +100 -50
  14. package/lib/dom/variable.js +3 -3
  15. package/lib/node/declaration/complexType.js +8 -1
  16. package/lib/node/declaration/simpleType.js +8 -1
  17. package/lib/node/type.js +15 -1
  18. package/lib/unifier/metavariable.js +2 -2
  19. package/lib/unifier/statementWithCombinator.js +3 -3
  20. package/lib/unifier/termWithConstructor.js +2 -2
  21. package/lib/utilities/json.js +8 -6
  22. package/lib/utilities/node.js +3 -9
  23. package/lib/verifier/combinator.js +2 -2
  24. package/lib/verifier/constructor.js +3 -3
  25. package/package.json +1 -1
  26. package/src/context/file.js +136 -155
  27. package/src/context/local.js +7 -3
  28. package/src/context/release.js +54 -8
  29. package/src/dom/assertion/type.js +3 -3
  30. package/src/dom/declaration/complexType.js +135 -118
  31. package/src/dom/declaration/constructor.js +6 -6
  32. package/src/dom/declaration/metavariable.js +3 -3
  33. package/src/dom/declaration/simpleType.js +48 -51
  34. package/src/dom/declaration/typePrefix.js +15 -6
  35. package/src/dom/declaration/variable.js +6 -6
  36. package/src/dom/metavariable.js +2 -2
  37. package/src/dom/property.js +1 -1
  38. package/src/dom/type.js +114 -61
  39. package/src/dom/variable.js +3 -3
  40. package/src/node/declaration/complexType.js +7 -0
  41. package/src/node/declaration/simpleType.js +7 -0
  42. package/src/node/type.js +17 -0
  43. package/src/unifier/metavariable.js +2 -2
  44. package/src/unifier/statementWithCombinator.js +2 -2
  45. package/src/unifier/termWithConstructor.js +2 -2
  46. package/src/utilities/json.js +18 -10
  47. package/src/utilities/node.js +6 -12
  48. package/src/verifier/combinator.js +2 -2
  49. package/src/verifier/constructor.js +3 -3
@@ -33,7 +33,7 @@ import { typesFromJSON,
33
33
  metatheoremsToMetatheoremsJSON,
34
34
  metavariablesToMetavariablesJSON } from "../utilities/json";
35
35
 
36
- const { push, first, filter } = arrayUtilities;
36
+ const { push, filter } = arrayUtilities;
37
37
 
38
38
  export default class FileContext {
39
39
  constructor(releaseContext, filePath, lineIndex, tokens, node, types, rules, axioms, lemmas, theorems, variables, metaLemmas, conjectures, combinators, typePrefixes, constructors, metatheorems, metavariables) {
@@ -106,117 +106,87 @@ export default class FileContext {
106
106
  getLabels(includeRelease = true) {
107
107
  const labels = [];
108
108
 
109
- this.rules.forEach((rule) => {
110
- const ruleLabels = rule.getLabels();
109
+ if (includeRelease) {
110
+ const releaseContextLabels = this.releaseContext.getLabels();
111
111
 
112
- push(labels, ruleLabels);
113
- });
112
+ push(labels, releaseContextLabels);
113
+ } else {
114
+ this.rules.forEach((rule) => {
115
+ const ruleLabels = rule.getLabels();
114
116
 
115
- this.axioms.forEach((axiom) => {
116
- const axiomLabels = axiom.getLabels();
117
+ push(labels, ruleLabels);
118
+ });
117
119
 
118
- push(labels, axiomLabels);
119
- });
120
+ this.axioms.forEach((axiom) => {
121
+ const axiomLabels = axiom.getLabels();
120
122
 
121
- this.lemmas.forEach((lemma) => {
122
- const lemmaLabels = lemma.getLabels();
123
+ push(labels, axiomLabels);
124
+ });
123
125
 
124
- push(labels, lemmaLabels);
125
- });
126
+ this.lemmas.forEach((lemma) => {
127
+ const lemmaLabels = lemma.getLabels();
126
128
 
127
- this.theorems.forEach((theorem) => {
128
- const theoremLabels = theorem.getLabels();
129
+ push(labels, lemmaLabels);
130
+ });
129
131
 
130
- push(labels, theoremLabels);
131
- });
132
+ this.theorems.forEach((theorem) => {
133
+ const theoremLabels = theorem.getLabels();
132
134
 
133
- this.conjectures.forEach((conjecture) => {
134
- const conjectureLabels = conjecture.getLabels();
135
+ push(labels, theoremLabels);
136
+ });
135
137
 
136
- push(labels, conjectureLabels);
137
- });
138
+ this.conjectures.forEach((conjecture) => {
139
+ const conjectureLabels = conjecture.getLabels();
138
140
 
139
- this.metatheorems.forEach((metatheorem) => {
140
- const metatheoremLabel = metatheorem.getLabel();
141
+ push(labels, conjectureLabels);
142
+ });
141
143
 
142
- labels.push(metatheoremLabel);
143
- });
144
-
145
- if (includeRelease) {
146
- const releaseContextLabels = this.releaseContext.getLabels();
144
+ this.metatheorems.forEach((metatheorem) => {
145
+ const metatheoremLabel = metatheorem.getLabel();
147
146
 
148
- push(labels, releaseContextLabels);
147
+ labels.push(metatheoremLabel);
148
+ });
149
149
  }
150
150
 
151
151
  return labels;
152
152
  }
153
153
 
154
- getTypes(includeRelease = true) {
155
- const types = [];
156
-
157
- push(types, this.types);
158
-
159
- if (includeRelease) {
160
- const releaseContextTypes = this.releaseContext.getTypes();
161
-
162
- push(types, releaseContextTypes);
163
- }
154
+ getTypes(includeRelease = true, includeDependencies = true) {
155
+ const types = includeRelease ?
156
+ this.releaseContext.getTypes(includeDependencies) :
157
+ this.types;
164
158
 
165
159
  return types;
166
160
  }
167
161
 
168
162
  getRules(includeRelease = true) {
169
- const rules = []
170
-
171
- push(rules, this.rules);
172
-
173
- if (includeRelease) {
174
- const releaseContextRules = this.releaseContext.getRules();
175
-
176
- push(rules, releaseContextRules);
177
- }
163
+ const rules = includeRelease ?
164
+ this.releaseContext.getRules() :
165
+ this.rules;
178
166
 
179
167
  return rules;
180
168
  }
181
169
 
182
170
  getAxioms(includeRelease = true) {
183
- const axioms = [];
184
-
185
- push(axioms, this.axioms);
186
-
187
- if (includeRelease) {
188
- const releaseContextAxioms = this.releaseContext.getAxioms();
189
-
190
- push(axioms, releaseContextAxioms);
191
- }
171
+ const axioms = includeRelease ?
172
+ this.releaseContext.getAxioms() :
173
+ this.axioms;
192
174
 
193
175
  return axioms;
194
176
  }
195
177
 
196
178
  getLemmas(includeRelease = true) {
197
- const lemmas = [];
198
-
199
- push(lemmas, this.lemmas);
200
-
201
- if (includeRelease) {
202
- const releaseContextLemmas = this.releaseContext.getLemmas();
203
-
204
- push(lemmas, releaseContextLemmas);
205
- }
179
+ const lemmas = includeRelease ?
180
+ this.releaseContext.getLemmas() :
181
+ this.lemmas;
206
182
 
207
183
  return lemmas;
208
184
  }
209
185
 
210
186
  getTheorems(includeRelease = true) {
211
- const theorems = [];
212
-
213
- push(theorems, this.theorems);
214
-
215
- if (includeRelease) {
216
- const releaseContextTheorems = this.releaseContext.getTheorems();
217
-
218
- push(theorems, releaseContextTheorems);
219
- }
187
+ const theorems = includeRelease ?
188
+ this.releaseContext.getTheorems() :
189
+ this.theorems;
220
190
 
221
191
  return theorems;
222
192
  }
@@ -226,97 +196,57 @@ export default class FileContext {
226
196
  }
227
197
 
228
198
  getProcedures(includeRelease = true) {
229
- const procedures = [];
230
-
231
- if (includeRelease) {
232
- const releaseContextProcedures = this.releaseContext.getProcedures();
233
-
234
- push(procedures, releaseContextProcedures);
235
- }
199
+ const procedures = includeRelease ?
200
+ this.releaseContext.getProcedures() :
201
+ null; ///
236
202
 
237
203
  return procedures;
238
204
  }
239
205
 
240
206
  getMetaLemmas(includeRelease = true) {
241
- const metaLemmas = [];
242
-
243
- push(metaLemmas, this.metaLemmas);
244
-
245
- if (includeRelease) {
246
- const releaseContextMetaLemmas = this.releaseContext.getMetaLemmas();
247
-
248
- push(metaLemmas, releaseContextMetaLemmas);
249
- }
207
+ const metaLemmas = includeRelease ?
208
+ this.releaseContext.getMetaLemmas() :
209
+ this.metaLemmas;
250
210
 
251
211
  return metaLemmas;
252
212
  }
253
213
 
254
214
  getConjectures(includeRelease = true) {
255
- const conjectures = [];
256
-
257
- push(conjectures, this.conjectures);
258
-
259
- if (includeRelease) {
260
- const releaseContextConjectures = this.releaseContext.getConjectures();
261
-
262
- push(conjectures, releaseContextConjectures);
263
- }
215
+ const conjectures = includeRelease ?
216
+ this.releaseContext.getConjectures() :
217
+ this.conjectures;
264
218
 
265
219
  return conjectures;
266
220
  }
267
221
 
268
222
  getCombinators(includeRelease = true) {
269
- const combinators = [];
270
-
271
- push(combinators, this.combinators);
272
-
273
- if (includeRelease) {
274
- const releaseContextCombinators = this.releaseContext.getCombinators();
275
-
276
- push(combinators, releaseContextCombinators);
277
- }
223
+ const combinators = includeRelease ?
224
+ this.releaseContext.getCombinators() :
225
+ this.combinators;
278
226
 
279
227
  return combinators;
280
228
  }
281
229
 
282
230
  getTypePrefixes(includeRelease = true) {
283
- const typePrefixes = [];
284
-
285
- push(typePrefixes, this.typePrefixes);
286
-
287
- if (includeRelease) {
288
- const releaseContextTypePrefixes = this.releaseContext.getTypePrefixes();
289
-
290
- push(typePrefixes, releaseContextTypePrefixes);
291
- }
231
+ const typePrefixes = includeRelease ?
232
+ this.releaseContext.getTypePrefixes() :
233
+ this.typePrefixes;
292
234
 
293
235
  return typePrefixes;
294
236
  }
295
237
 
296
238
  getConstructors(includeRelease = true) {
297
- const constructors = [];
298
-
299
- push(constructors, this.constructors);
300
-
301
- if (includeRelease) {
302
- const releaseContextConstructors = this.releaseContext.getConstructors();
303
-
304
- push(constructors, releaseContextConstructors);
305
- }
239
+ const constructors = includeRelease ?
240
+ this.releaseContext.getConstructors() :
241
+ this.constructors;
306
242
 
307
243
  return constructors;
308
244
  }
309
245
 
310
246
  getMetatheorems(includeRelease = true) {
311
- const metatheorems = [];
312
-
313
- push(metatheorems, this.metatheorems);
314
-
315
- if (includeRelease) {
316
- const releaseContextMetatheorems = this.releaseContext.getMetatheorems();
317
-
318
- push(metatheorems, releaseContextMetatheorems);
319
- }
247
+ const metatheorems = includeRelease ?
248
+ this.releaseContext.getMetatheorems() :
249
+ this.metatheorems;
320
250
 
321
251
  return metatheorems;
322
252
  }
@@ -586,7 +516,26 @@ export default class FileContext {
586
516
  return metavariable;
587
517
  }
588
518
 
589
- findTypeByTypeName(typeName, prefixed = true) {
519
+ findTypeByTypeName(typeName, includeRelease = true, includeDependencies = true) {
520
+ let types = this.getTypes(includeRelease, includeDependencies);
521
+
522
+ types = [
523
+ ...types,
524
+ objectType
525
+ ];
526
+
527
+ const type = types.find((type) => {
528
+ const typeNameMatches = type.matchTypeName(typeName);
529
+
530
+ if (typeNameMatches) {
531
+ return true;
532
+ }
533
+ }) || null;
534
+
535
+ return type;
536
+ }
537
+
538
+ findTypeByNominalTypeName(nominalTypeName) {
590
539
  let types = this.getTypes();
591
540
 
592
541
  types = [
@@ -594,29 +543,34 @@ export default class FileContext {
594
543
  objectType
595
544
  ];
596
545
 
597
- const context = this, ///
598
- type = types.find((type) => {
599
- const typeNameMatches = type.matchTypeName(typeName, prefixed, context);
546
+ const type = types.find((type) => {
547
+ const typeNameMatches = type.matchNominalTypeName(nominalTypeName);
600
548
 
601
- if (typeNameMatches) {
602
- return true;
603
- }
604
- }) || null;
549
+ if (typeNameMatches) {
550
+ return true;
551
+ }
552
+ }) || null;
605
553
 
606
554
  return type;
607
555
  }
608
556
 
609
- findTypePrefixByTypePrefixName(typePrefixName) {
610
- const typePrefixes = this.getTypePrefixes(),
611
- typePrefix = typePrefixes.find((typePrefix) => {
612
- const typePrefixNameMatches = typePrefix.matchTypePrefixName(typePrefixName);
557
+ findTypeByPrefixedTypeName(prefixedTypeName) {
558
+ let types = this.getTypes();
613
559
 
614
- if (typePrefixNameMatches) {
615
- return true;
616
- }
617
- }) || null;
560
+ types = [
561
+ ...types,
562
+ objectType
563
+ ];
618
564
 
619
- return typePrefix;
565
+ const type = types.find((type) => {
566
+ const typeNameMatches = type.matchPrefixedTypeName(prefixedTypeName);
567
+
568
+ if (typeNameMatches) {
569
+ return true;
570
+ }
571
+ }) || null;
572
+
573
+ return type;
620
574
  }
621
575
 
622
576
  findMetaTypeByMetaTypeName(metaTypeName) {
@@ -632,6 +586,19 @@ export default class FileContext {
632
586
  return metaType;
633
587
  }
634
588
 
589
+ findTypePrefixByTypePrefixName(typePrefixName) {
590
+ const typePrefixes = this.getTypePrefixes(),
591
+ typePrefix = typePrefixes.find((typePrefix) => {
592
+ const typePrefixNameMatches = typePrefix.matchTypePrefixName(typePrefixName);
593
+
594
+ if (typePrefixNameMatches) {
595
+ return true;
596
+ }
597
+ }) || null;
598
+
599
+ return typePrefix;
600
+ }
601
+
635
602
  findVariableByVariableIdentifier(variableIdentifier) {
636
603
  const variables = this.getVariables(),
637
604
  variable = variables.find((variable) => {
@@ -710,8 +677,22 @@ export default class FileContext {
710
677
  return metavariablePresent;
711
678
  }
712
679
 
713
- isTypePresentByTypeName(typeName, prefixed = true) {
714
- const type = this.findTypeByTypeName(typeName, prefixed),
680
+ isTypePresentByTypeName(typeName, includeRelease = true, includeDependencies = true) {
681
+ const type = this.findTypeByTypeName(typeName, includeRelease, includeDependencies),
682
+ typePresent = (type !== null);
683
+
684
+ return typePresent;
685
+ }
686
+
687
+ isTypePresentByNominalTypeName(nominalTypeName) {
688
+ const type = this.findTypeByNominalTypeName(nominalTypeName),
689
+ typePresent = (type !== null);
690
+
691
+ return typePresent;
692
+ }
693
+
694
+ isTypePresentByPrefixedTypeName(prefixedTypeName) {
695
+ const type = this.findTypeByPrefixedTypeName(prefixedTypeName),
715
696
  typePresent = (type !== null);
716
697
 
717
698
  return typePresent;
@@ -231,10 +231,10 @@ class LocalContext {
231
231
 
232
232
  findMetavariable(metavariable, generalContext, specificContext) { return this.context.findMetavariable(metavariable, generalContext, specificContext); }
233
233
 
234
- findTypeByTypeName(typeName) { return this.context.findTypeByTypeName(typeName); }
235
-
236
234
  findLabelByMetavariable(metavariable) { return this.context.findLabelByMetavariable(metavariable); }
237
235
 
236
+ findTypeByNominalTypeName(nominalTypeName) { return this.context.findTypeByNominalTypeName(nominalTypeName); }
237
+
238
238
  findMetaTypeByMetaTypeName(metaTypeName) { return this.context.findMetaTypeByMetaTypeName(metaTypeName); }
239
239
 
240
240
  findMetavariableByMetavariableName(metavariableName) { return this.context.findMetavariableByMetavariableName(metavariableName); }
@@ -251,7 +251,11 @@ class LocalContext {
251
251
 
252
252
  isMetavariablePresent(metavariable, generalContext, specificContext) { return this.context.isMetavariablePresent(metavariable, generalContext, specificContext); }
253
253
 
254
- isTypePresentByTypeName(typeName, prefixed = true) { return this.context.isTypePresentByTypeName(typeName, prefixed); }
254
+ isTypePresentByTypeName(typeName, includeRelease = true, includeDependencies = true) { return this.context.isTypePresentByTypeName(typeName, includeRelease, includeDependencies); }
255
+
256
+ isTypePresentByNominalTypeName(nominalTypeName) { return this.context.isTypePresentByNominalTypeName(nominalTypeName); }
257
+
258
+ isTypePresentByPrefixedTypeName(prefixedTypeName) { return this.context.isTypePresentByPrefixedTypeName(prefixedTypeName); }
255
259
 
256
260
  isTypePrefixPresentByTypePrefixName(typePrefixName) { return this.context.isTypePrefixPresentByTypePrefixName(typePrefixName); }
257
261
 
@@ -13,9 +13,9 @@ import NominalParser from "../nominal/parser";
13
13
  import { frameMetaType, referenceMetaType, statementMetaType } from "../dom/metaType";
14
14
  import { customGrammarFromNameAndEntries, combinedCustomGrammarFromReleaseContexts } from "../utilities/customGrammar";
15
15
 
16
- const { tail, push, first, clear, resolve } = arrayUtilities,
17
- { nominalLexerFromCombinedCustomGrammar } = lexersUtilities,
16
+ const { nominalLexerFromCombinedCustomGrammar } = lexersUtilities,
18
17
  { nominalParserFromCombinedCustomGrammar } = parsersUtilities,
18
+ { tail, push, first, clear, filter, resolve, compress } = arrayUtilities,
19
19
  { isFilePathFurtleFilePath, isFilePathNominalFilePath } = filePathUtilities;
20
20
 
21
21
  export default class ReleaseContext {
@@ -469,15 +469,21 @@ export default class ReleaseContext {
469
469
  verify() {
470
470
  let verifies = false;
471
471
 
472
- const verifiedFileContexts = [],
473
- fileContextsVerify = verifyFileContexts(this.fileContexts, verifiedFileContexts);
472
+ const typePrefixes = this.getTypePrefixes(),
473
+ releaseContext = this, ///
474
+ typePrefixesVerify = verifyTypePrefixes(typePrefixes, releaseContext);
474
475
 
475
- if (fileContextsVerify) {
476
- this.fileContexts = verifiedFileContexts; ///
476
+ if (typePrefixesVerify) {
477
+ const verifiedFileContexts = [],
478
+ fileContextsVerify = verifyFileContexts(this.fileContexts, verifiedFileContexts, releaseContext);
477
479
 
478
- this.verified = true;
480
+ if (fileContextsVerify) {
481
+ this.fileContexts = verifiedFileContexts; ///
479
482
 
480
- verifies = true;
483
+ this.verified = true;
484
+
485
+ verifies = true;
486
+ }
481
487
  }
482
488
 
483
489
  return verifies;
@@ -508,6 +514,46 @@ export default class ReleaseContext {
508
514
  }
509
515
  }
510
516
 
517
+ function verifyTypePrefixes(typePrefixes, releaseContext) {
518
+ let typePrefixesVerify = true;
519
+
520
+ const typePrefixesLength = typePrefixes.length,
521
+ compressedTypePrefixes = [ ///
522
+ ...typePrefixes,
523
+ ];
524
+
525
+ compress(compressedTypePrefixes, (typePrefixA, typePrefixB) => {
526
+ const typePrefixAName = typePrefixA.getName(),
527
+ typePrefixBName = typePrefixB.getName();
528
+
529
+ if (typePrefixAName === typePrefixBName) {
530
+ return true;
531
+ }
532
+ });
533
+
534
+ const compressTypePrefixesLength = compressedTypePrefixes.length;
535
+
536
+ if (typePrefixesLength > compressTypePrefixesLength) {
537
+ filter(compressedTypePrefixes, (typePrefix) => {
538
+ const typePrefixesIncludesTypePrefix = typePrefixes.includes(typePrefix);
539
+
540
+ if (!typePrefixesIncludesTypePrefix) {
541
+ return true;
542
+ }
543
+ });
544
+
545
+ const firstTypePrefix = first(typePrefixes),
546
+ typePrefix = firstTypePrefix, ///
547
+ typePrefixString = typePrefix.getString();
548
+
549
+ releaseContext.info(`The '${typePrefixString}' type prefix is duplicated at least once, possibly among others.`)
550
+
551
+ typePrefixesVerify = false;
552
+ }
553
+
554
+ return typePrefixesVerify;
555
+ }
556
+
511
557
  function verifyFileContexts(fileContexts, verifiedFileContexts) {
512
558
  const resolved = resolve(fileContexts, verifiedFileContexts, (fileContext) => {
513
559
  const fileContextVerifies = fileContext.verify();
@@ -64,12 +64,12 @@ export default domAssigned(class TypeAssertion {
64
64
  verifyType(context) {
65
65
  let typeVerifies;
66
66
 
67
- const typeName = this.type.getName(),
68
- typeString = this.type.getString();
67
+ const typeString = this.type.getString();
69
68
 
70
69
  context.trace(`Verifying the '${typeString}' type...`);
71
70
 
72
- const type = context.findTypeByTypeName(typeName);
71
+ const nominalTypeName = this.type.getNominalTypeName(),
72
+ type = context.findTypeByNominalTypeName(nominalTypeName);
73
73
 
74
74
  if (type !== null) {
75
75
  this.type = type;