occam-furtle 2.0.342 → 3.0.2

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 (116) hide show
  1. package/example.js +5905 -1786
  2. package/lib/context/block.js +81 -41
  3. package/lib/context/file/furtle.js +260 -0
  4. package/lib/context/file/nominal.js +956 -0
  5. package/lib/context/file.js +146 -271
  6. package/lib/context.js +210 -0
  7. package/lib/element/assignment/array.js +116 -14
  8. package/lib/element/assignment/object.js +116 -14
  9. package/lib/element/assignment/variable.js +121 -14
  10. package/lib/element/assignments/variable.js +120 -13
  11. package/lib/element/declaration/procedure.js +120 -12
  12. package/lib/element/error.js +118 -13
  13. package/lib/element/every.js +116 -13
  14. package/lib/element/expression.js +127 -20
  15. package/lib/element/label.js +119 -12
  16. package/lib/element/nodeQuery.js +116 -14
  17. package/lib/element/nodesQuery.js +116 -14
  18. package/lib/element/parameter/named.js +117 -15
  19. package/lib/element/parameter.js +116 -14
  20. package/lib/element/parameters/named.js +116 -14
  21. package/lib/element/parameters.js +115 -13
  22. package/lib/element/primitive.js +115 -13
  23. package/lib/element/procedure/anonymous.js +118 -16
  24. package/lib/element/procedure.js +118 -16
  25. package/lib/element/procedureCall.js +116 -14
  26. package/lib/element/reduce.js +116 -14
  27. package/lib/element/reference.js +119 -12
  28. package/lib/element/returnBlock.js +116 -14
  29. package/lib/element/some.js +115 -13
  30. package/lib/element/statement/return.js +120 -13
  31. package/lib/element/step.js +121 -14
  32. package/lib/element/term/bracketed.js +120 -13
  33. package/lib/element/term/comparison.js +117 -15
  34. package/lib/element/term/logical.js +118 -16
  35. package/lib/element/term/negated.js +116 -14
  36. package/lib/element/term.js +127 -18
  37. package/lib/element/terms.js +125 -14
  38. package/lib/element/ternary.js +117 -15
  39. package/lib/element/variable.js +127 -19
  40. package/lib/element.js +1 -8
  41. package/lib/index.js +5 -5
  42. package/lib/log.js +13 -12
  43. package/lib/metaTypeNames.js +26 -0
  44. package/lib/metaTypes.js +66 -0
  45. package/lib/nodeProperties.js +17 -21
  46. package/lib/nodeProperty.js +4 -7
  47. package/lib/utilities/context.js +8 -37
  48. package/lib/utilities/customGrammar.js +49 -0
  49. package/lib/utilities/element.js +91 -37
  50. package/lib/utilities/lineIndex.js +26 -0
  51. package/lib/utilities/node.js +1 -8
  52. package/lib/utilities/primitive.js +14 -5
  53. package/lib/utilities/string.js +30 -19
  54. package/lib/utilities/term.js +14 -5
  55. package/lib/utilities/terms.js +7 -3
  56. package/package.json +2 -2
  57. package/src/context/block.js +20 -32
  58. package/src/context/file/furtle.js +141 -0
  59. package/src/context/file/nominal.js +946 -0
  60. package/src/context/file.js +32 -209
  61. package/src/context.js +74 -0
  62. package/src/element/assignment/array.js +6 -8
  63. package/src/element/assignment/object.js +6 -8
  64. package/src/element/assignment/variable.js +7 -8
  65. package/src/element/assignments/variable.js +7 -8
  66. package/src/element/declaration/procedure.js +6 -6
  67. package/src/element/error.js +4 -6
  68. package/src/element/every.js +5 -6
  69. package/src/element/expression.js +6 -7
  70. package/src/element/label.js +6 -7
  71. package/src/element/nodeQuery.js +6 -8
  72. package/src/element/nodesQuery.js +6 -8
  73. package/src/element/parameter/named.js +7 -8
  74. package/src/element/parameter.js +6 -8
  75. package/src/element/parameters/named.js +8 -9
  76. package/src/element/parameters.js +6 -8
  77. package/src/element/primitive.js +5 -7
  78. package/src/element/procedure/anonymous.js +7 -9
  79. package/src/element/procedure.js +6 -8
  80. package/src/element/procedureCall.js +6 -8
  81. package/src/element/reduce.js +5 -7
  82. package/src/element/reference.js +6 -7
  83. package/src/element/returnBlock.js +5 -7
  84. package/src/element/some.js +5 -7
  85. package/src/element/statement/return.js +7 -8
  86. package/src/element/step.js +6 -7
  87. package/src/element/term/bracketed.js +7 -8
  88. package/src/element/term/comparison.js +6 -8
  89. package/src/element/term/logical.js +6 -8
  90. package/src/element/term/negated.js +6 -8
  91. package/src/element/term.js +12 -9
  92. package/src/element/terms.js +16 -9
  93. package/src/element/ternary.js +6 -8
  94. package/src/element/variable.js +24 -14
  95. package/src/element.js +0 -8
  96. package/src/index.js +1 -1
  97. package/src/log.js +11 -11
  98. package/src/metaTypeNames.js +5 -0
  99. package/src/metaTypes.js +71 -0
  100. package/src/nodeProperties.js +23 -32
  101. package/src/nodeProperty.js +5 -10
  102. package/src/utilities/context.js +7 -45
  103. package/src/utilities/customGrammar.js +40 -0
  104. package/src/utilities/element.js +158 -64
  105. package/src/utilities/lineIndex.js +21 -0
  106. package/src/utilities/node.js +0 -5
  107. package/src/utilities/primitive.js +22 -5
  108. package/src/utilities/string.js +33 -19
  109. package/src/utilities/term.js +22 -5
  110. package/src/utilities/terms.js +12 -4
  111. package/test/context/release.js +477 -46
  112. package/test/helpers/furtle.js +1 -1
  113. package/test/helpers/nominal.js +2 -3
  114. package/test/main.js +1 -1
  115. package/test/context/file.js +0 -127
  116. package/test/helpers/constants.js +0 -17
@@ -0,0 +1,946 @@
1
+ "use strict";
2
+
3
+ import { arrayUtilities } from "necessary";
4
+
5
+ import FileContext from "../../context/file";
6
+
7
+ import { verifyFile } from "../process/verify";
8
+ import { chainContext } from "../../utilities/context";
9
+ import { baseTypeFromNothing } from "../types";
10
+ import { typesFromJSON,
11
+ rulesFromJSON,
12
+ axiomsFromJSON,
13
+ typesToTypesJSON,
14
+ rulesToRulesJSON,
15
+ theoremsFromJSON,
16
+ variablesFromJSON,
17
+ lemmasFromNothing,
18
+ axiomsToAxiomsJSON,
19
+ conjecturesFromJSON,
20
+ combinatorsFromJSON,
21
+ typePrefixesFromJSON,
22
+ constructorsFromJSON,
23
+ metatheoremsFromJSON,
24
+ metavariablesFromJSON,
25
+ metaLemmasFromNothing,
26
+ theoremsToTheoremsJSON,
27
+ variablesToVariablesJSON,
28
+ conjecturesToConjecturesJSON,
29
+ combinatorsToCombinatorsJSON,
30
+ typePrefixesToTypePrefixesJSON,
31
+ constructorsToConstructorsJSON,
32
+ metatheoremsToMetatheoremsJSON,
33
+ metavariablesToMetavariablesJSON } from "../utilities/json";
34
+
35
+ const { push, filter } = arrayUtilities;
36
+
37
+ export default class NominalFileContext extends FileContext {
38
+ constructor(context, filePath, tokens, node, types, rules, axioms, lemmas, theorems, variables, metaLemmas, conjectures, combinators, typePrefixes, constructors, metatheorems, metavariables) {
39
+ super(context, filePath, node, tokens)
40
+ this.context = context;
41
+ this.filePath = filePath;
42
+ this.tokens = tokens;
43
+ this.node = node;
44
+ this.types = types;
45
+ this.rules = rules;
46
+ this.axioms = axioms;
47
+ this.lemmas = lemmas;
48
+ this.theorems = theorems;
49
+ this.variables = variables;
50
+ this.metaLemmas = metaLemmas;
51
+ this.conjectures = conjectures;
52
+ this.combinators = combinators;
53
+ this.typePrefixes = typePrefixes;
54
+ this.constructors = constructors;
55
+ this.metatheorems = metatheorems;
56
+ this.metavariables = metavariables;
57
+
58
+ return chainContext(this);
59
+ }
60
+
61
+ getContext() {
62
+ return this.context;
63
+ }
64
+
65
+ getFilePath() {
66
+ return this.filePath;
67
+ }
68
+
69
+ getLineIndex() {
70
+ return this.lineIndex;
71
+ }
72
+
73
+ getTokens() {
74
+ return this.tokens;
75
+ }
76
+
77
+ getNode() {
78
+ return this.node;
79
+ }
80
+
81
+ getJudgements() {
82
+ const judgements = [];
83
+
84
+ return judgements;
85
+ }
86
+
87
+ getEquivalences() {
88
+ debugger
89
+ }
90
+
91
+ getSubproofOrProofAssertions() {
92
+ const subproofOrProofAssertions = [];
93
+
94
+ return subproofOrProofAssertions;
95
+ }
96
+
97
+ getLabels(includeRelease = true) {
98
+ const labels = [];
99
+
100
+ if (includeRelease) {
101
+ const releaseContextLabels = this.context.getLabels();
102
+
103
+ push(labels, releaseContextLabels);
104
+ } else {
105
+ this.rules.forEach((rule) => {
106
+ const ruleLabels = rule.getLabels();
107
+
108
+ push(labels, ruleLabels);
109
+ });
110
+
111
+ this.axioms.forEach((axiom) => {
112
+ const axiomLabels = axiom.getLabels();
113
+
114
+ push(labels, axiomLabels);
115
+ });
116
+
117
+ this.lemmas.forEach((lemma) => {
118
+ const lemmaLabels = lemma.getLabels();
119
+
120
+ push(labels, lemmaLabels);
121
+ });
122
+
123
+ this.theorems.forEach((theorem) => {
124
+ const theoremLabels = theorem.getLabels();
125
+
126
+ push(labels, theoremLabels);
127
+ });
128
+
129
+ this.conjectures.forEach((conjecture) => {
130
+ const conjectureLabels = conjecture.getLabels();
131
+
132
+ push(labels, conjectureLabels);
133
+ });
134
+
135
+ this.metatheorems.forEach((metatheorem) => {
136
+ const metatheoremLabel = metatheorem.getLabel();
137
+
138
+ labels.push(metatheoremLabel);
139
+ });
140
+ }
141
+
142
+ return labels;
143
+ }
144
+
145
+ getTypes(includeRelease = true, includeDependencies = true) {
146
+ const types = includeRelease ?
147
+ this.context.getTypes(includeDependencies) :
148
+ this.types;
149
+
150
+ return types;
151
+ }
152
+
153
+ getRules(includeRelease = true) {
154
+ const rules = includeRelease ?
155
+ this.context.getRules() :
156
+ this.rules;
157
+
158
+ return rules;
159
+ }
160
+
161
+ getAxioms(includeRelease = true) {
162
+ const axioms = includeRelease ?
163
+ this.context.getAxioms() :
164
+ this.axioms;
165
+
166
+ return axioms;
167
+ }
168
+
169
+ getLemmas(includeRelease = true) {
170
+ const lemmas = includeRelease ?
171
+ this.context.getLemmas() :
172
+ this.lemmas;
173
+
174
+ return lemmas;
175
+ }
176
+
177
+ getTheorems(includeRelease = true) {
178
+ const theorems = includeRelease ?
179
+ this.context.getTheorems() :
180
+ this.theorems;
181
+
182
+ return theorems;
183
+ }
184
+
185
+ getVariables(includeRelease = true) {
186
+ return this.variables;
187
+ }
188
+
189
+ getProcedures(includeRelease = true) {
190
+ const procedures = includeRelease ?
191
+ this.context.getProcedures() :
192
+ null; ///
193
+
194
+ return procedures;
195
+ }
196
+
197
+ getMetaLemmas(includeRelease = true) {
198
+ const metaLemmas = includeRelease ?
199
+ this.context.getMetaLemmas() :
200
+ this.metaLemmas;
201
+
202
+ return metaLemmas;
203
+ }
204
+
205
+ getConjectures(includeRelease = true) {
206
+ const conjectures = includeRelease ?
207
+ this.context.getConjectures() :
208
+ this.conjectures;
209
+
210
+ return conjectures;
211
+ }
212
+
213
+ getCombinators(includeRelease = true) {
214
+ const combinators = includeRelease ?
215
+ this.context.getCombinators() :
216
+ this.combinators;
217
+
218
+ return combinators;
219
+ }
220
+
221
+ getTypePrefixes(includeRelease = true) {
222
+ const typePrefixes = includeRelease ?
223
+ this.context.getTypePrefixes() :
224
+ this.typePrefixes;
225
+
226
+ return typePrefixes;
227
+ }
228
+
229
+ getConstructors(includeRelease = true) {
230
+ const constructors = includeRelease ?
231
+ this.context.getConstructors() :
232
+ this.constructors;
233
+
234
+ return constructors;
235
+ }
236
+
237
+ getMetatheorems(includeRelease = true) {
238
+ const metatheorems = includeRelease ?
239
+ this.context.getMetatheorems() :
240
+ this.metatheorems;
241
+
242
+ return metatheorems;
243
+ }
244
+
245
+ getMetavariables(includeRelease = true) {
246
+ return this.metavariables;
247
+ }
248
+
249
+ addType(type) {
250
+ this.types.push(type);
251
+ }
252
+
253
+ addRule(rule) {
254
+ this.rules.push(rule);
255
+ }
256
+
257
+ addAxiom(axiom) {
258
+ this.axioms.push(axiom);
259
+ }
260
+
261
+ addLemma(lemma) {
262
+ this.lemmas.push(lemma);
263
+ }
264
+
265
+ addTheorem(theorem) {
266
+ this.theorems.push(theorem);
267
+ }
268
+
269
+ addVariable(variable) {
270
+ this.variables.push(variable);
271
+ }
272
+
273
+ addMetaLemma(metaLemma) {
274
+ this.metaLemmas.push(metaLemma);
275
+ }
276
+
277
+ addConjecture(conjecture) {
278
+ this.conjectures.push(conjecture);
279
+ }
280
+
281
+ addCombinator(combinator) {
282
+ this.combinators.push(combinator);
283
+ }
284
+
285
+ addTypePrefix(typePrefix) {
286
+ this.typePrefixes.push(typePrefix);
287
+ }
288
+
289
+ addConstructor(constructor) {
290
+ this.constructors.push(constructor);
291
+ }
292
+
293
+ addMetatheorem(metatheorem) {
294
+ this.metatheorems.push(metatheorem);
295
+ }
296
+
297
+ addMetavariable(metavariable) {
298
+ this.metavariables.push(metavariable);
299
+ }
300
+
301
+ findLabelByReference(reference, context) {
302
+ const labels = this.getLabels(),
303
+ label = labels.find((label) => {
304
+ const metavariableUnifies = label.unifyReference(reference, context);
305
+
306
+ if (metavariableUnifies) {
307
+ return true;
308
+ }
309
+ }) || null;
310
+
311
+ return label;
312
+ }
313
+
314
+ findMetaLemmaByReference(reference) {
315
+ const metaLemmas = this.getMetaLemmas(),
316
+ metaLemma = metaLemmas.find((metaLemma) => {
317
+ const metaLemmaComparesToReference = metaLemma.compareReference(reference);
318
+
319
+ if (metaLemmaComparesToReference) {
320
+ return true;
321
+ }
322
+ }) || null;
323
+
324
+ return metaLemma;
325
+ }
326
+
327
+ findMetatheoremByReference(reference) {
328
+ const metatheorems = this.getMetatheorems(),
329
+ metatheorem = metatheorems.find((metatheorem) => {
330
+ const metatheoremComparesToReference = metatheorem.compareReference(reference);
331
+
332
+ if (metatheoremComparesToReference) {
333
+ return true;
334
+ }
335
+ }) || null;
336
+
337
+ return metatheorem;
338
+ }
339
+
340
+ findRuleByReference(reference) {
341
+ const rules = this.getRules(),
342
+ metavariableName = reference.getMetavariableName(),
343
+ rule = rules.find((rule) => {
344
+ const ruleComparesToMetavariableName = rule.compareMetavariableName(metavariableName);
345
+
346
+ if (ruleComparesToMetavariableName) {
347
+ return true;
348
+ }
349
+ }) || null;
350
+
351
+ return rule;
352
+ }
353
+
354
+ findAxiomByReference(reference) {
355
+ const axioms = this.getAxioms(),
356
+ metavariableName = reference.getMetavariableName(),
357
+ axiom = axioms.find((axiom) => {
358
+ const axiomComparesToMetavariableName = axiom.compareMetavariableName(metavariableName);
359
+
360
+ if (axiomComparesToMetavariableName) {
361
+ return true;
362
+ }
363
+ }) || null;
364
+
365
+ return axiom;
366
+ }
367
+
368
+ findLemmaByReference(reference) {
369
+ const lemmas = this.getLemmas(),
370
+ metavariableName = reference.getMetavariableName(),
371
+ lemma = lemmas.find((lemma) => {
372
+ const lemmaComparesToMetavariableName = lemma.compareMetavariableName(metavariableName);
373
+
374
+ if (lemmaComparesToMetavariableName) {
375
+ return true;
376
+ }
377
+ }) || null;
378
+
379
+ return lemma;
380
+ }
381
+
382
+ findTheoremByReference(reference) {
383
+ const theorems = this.getTheorems(),
384
+ metavariableName = reference.getMetavariableName(),
385
+ theorem = theorems.find((theorem) => {
386
+ const theoremComparesToMetavariableName = theorem.compareMetavariableName(metavariableName);
387
+
388
+ if (theoremComparesToMetavariableName) {
389
+ return true;
390
+ }
391
+ }) || null;
392
+
393
+ return theorem;
394
+ }
395
+
396
+ findProcedureByName(name) {
397
+ const procedures = this.getProcedures(),
398
+ procedure = procedures.find((procedure) => {
399
+ const nameMatches = procedure.matchName(name);
400
+
401
+ if (nameMatches) {
402
+ return true;
403
+ }
404
+ }) || null;
405
+
406
+ return procedure;
407
+ }
408
+
409
+ findConjectureByReference(reference) {
410
+ const conjectures = this.getConjectures(),
411
+ metavariableName = reference.getMetavariableName(),
412
+ conjecture = conjectures.find((conjecture) => {
413
+ const conjectureComparesToMetavariableName = conjecture.compareMetavariableName(metavariableName);
414
+
415
+ if (conjectureComparesToMetavariableName) {
416
+ return true;
417
+ }
418
+ }) || null;
419
+
420
+ return conjecture;
421
+ }
422
+
423
+ findMetaLemmasByReference(reference) {
424
+ const metaLemmas = this.getMetaLemmas();
425
+
426
+ filter(metaLemmas, (metaLemma) => {
427
+ const context = this, ///
428
+ topLevelMetaAssertion = metaLemma, ///
429
+ topLevelMetaAssertionUnifies = reference.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
430
+
431
+ if (topLevelMetaAssertionUnifies) {
432
+ return true;
433
+ }
434
+ });
435
+
436
+ return metaLemmas;
437
+ }
438
+
439
+ findMetatheoremsByReference(reference) {
440
+ const metatheorems = this.getMetatheorems();
441
+
442
+ filter(metatheorems, (metatheorem) => {
443
+ const context = this, ///
444
+ topLevelMetaAssertion = metatheorem, ///
445
+ topLevelMetaAssertionUnifies = reference.unifyTopLevelMetaAssertion(topLevelMetaAssertion, context);
446
+
447
+ if (topLevelMetaAssertionUnifies) {
448
+ return true;
449
+ }
450
+ });
451
+
452
+ return metatheorems;
453
+ }
454
+
455
+ findTopLevelMetaAssertionByReference(reference) {
456
+ const metaLemma = this.findMetaLemmaByReference(reference),
457
+ metatheorem = this.findMetatheoremByReference(reference),
458
+ topLevelMetaAssertion = (metaLemma || metatheorem); ///
459
+
460
+ return topLevelMetaAssertion;
461
+ }
462
+
463
+ findTopLevelMetaAssertionsByReference(reference) {
464
+ const metaLemmas = this.findMetaLemmasByReference(reference),
465
+ metatheorems = this.findMetatheoremsByReference(reference),
466
+ topLevelMetaAssertions = [
467
+ ...metaLemmas,
468
+ ...metatheorems
469
+ ];
470
+
471
+ return topLevelMetaAssertions;
472
+ }
473
+
474
+ findTopLevelAssertionByReference(reference) {
475
+ const axiom = this.findAxiomByReference(reference),
476
+ lemma = this.findLemmaByReference(reference),
477
+ theorem = this.findTheoremByReference(reference),
478
+ conjecture = this.findConjectureByReference(reference),
479
+ topLevelAssertion = (axiom || lemma || theorem || conjecture);
480
+
481
+ return topLevelAssertion;
482
+ }
483
+
484
+ findMetavariable(metavariable) {
485
+ const metavariables = this.getMetavariables(),
486
+ specificMetavariable = metavariable; ///
487
+
488
+ metavariable = metavariables.find((metavariable) => {
489
+ const context = this, ///
490
+ generalMetavariable = metavariable, ///
491
+ metavariableUnifies = generalMetavariable.unifyMetavariable(specificMetavariable, context);
492
+
493
+ if (metavariableUnifies) {
494
+ return true;
495
+ }
496
+ }) || null;
497
+
498
+ return metavariable;
499
+ }
500
+
501
+ findTypeByTypeName(typeName, includeRelease = true, includeDependencies = true) {
502
+ let types = this.getTypes(includeRelease, includeDependencies);
503
+
504
+ const baseType = baseTypeFromNothing();
505
+
506
+ types = [
507
+ ...types,
508
+ baseType
509
+ ];
510
+
511
+ const type = types.find((type) => {
512
+ const typeComparesToTypeName = type.compareTypeName(typeName);
513
+
514
+ if (typeComparesToTypeName) {
515
+ return true;
516
+ }
517
+ }) || null;
518
+
519
+ return type;
520
+ }
521
+
522
+ findTypeByNominalTypeName(nominalTypeName) {
523
+ let types = this.getTypes();
524
+
525
+ const baseType = baseTypeFromNothing();
526
+
527
+ types = [
528
+ ...types,
529
+ baseType
530
+ ];
531
+
532
+ const type = types.find((type) => {
533
+ const typeComparesToNominalTypeName = type.compareNominalTypeName(nominalTypeName);
534
+
535
+ if (typeComparesToNominalTypeName) {
536
+ return true;
537
+ }
538
+ }) || null;
539
+
540
+ return type;
541
+ }
542
+
543
+ findTypeByPrefixedTypeName(prefixedTypeName) {
544
+ let types = this.getTypes();
545
+
546
+ const baseType = baseTypeFromNothing();
547
+
548
+ types = [
549
+ ...types,
550
+ baseType
551
+ ];
552
+
553
+ const type = types.find((type) => {
554
+ const typeComparesToPrefixedTypeName = type.comparePrefixedTypeName(prefixedTypeName);
555
+
556
+ if (typeComparesToPrefixedTypeName) {
557
+ return true;
558
+ }
559
+ }) || null;
560
+
561
+ return type;
562
+ }
563
+
564
+ findMetaTypeByMetaTypeName(metaTypeName) {
565
+ const metaTypes = this.getMetaTypes(),
566
+ metaType = metaTypes.find((metaType) => {
567
+ const metaTypeComparesToMetaTypeName = metaType.compareMetaTypeName(metaTypeName);
568
+
569
+ if (metaTypeComparesToMetaTypeName) {
570
+ return true;
571
+ }
572
+ }) || null;
573
+
574
+ return metaType;
575
+ }
576
+
577
+ findTypePrefixByTypePrefixName(typePrefixName) {
578
+ const typePrefixes = this.getTypePrefixes(),
579
+ typePrefix = typePrefixes.find((typePrefix) => {
580
+ const typePrefixComparesToTypePrefixName = typePrefix.compareTypePrefixName(typePrefixName);
581
+
582
+ if (typePrefixComparesToTypePrefixName) {
583
+ return true;
584
+ }
585
+ }) || null;
586
+
587
+ return typePrefix;
588
+ }
589
+
590
+ findVariableByVariableIdentifier(variableIdentifier) {
591
+ const variables = this.getVariables(),
592
+ variable = variables.find((variable) => {
593
+ const variableComparesToVariableIdentifier = variable.compareVariableIdentifier(variableIdentifier);
594
+
595
+ if (variableComparesToVariableIdentifier) {
596
+ return true;
597
+ }
598
+ }) || null;
599
+
600
+ return variable;
601
+ }
602
+
603
+ findLabelByMetavariableName(metavariableName) {
604
+ const labels = this.getLabels(),
605
+ label = labels.find((label) => {
606
+ const labelComparesToMetavariableName = label.compareMetavariableName(metavariableName);
607
+
608
+ if (labelComparesToMetavariableName) {
609
+ return true;
610
+ }
611
+ }) || null;
612
+
613
+ return label;
614
+ }
615
+
616
+ findLabelByMetavariable(metavariable) {
617
+ const labels = this.getLabels(),
618
+ label = labels.find((label) => {
619
+ const metavariableEqualToLabelMetavariable = label.isMetavariableEqualToMetavariable(metavariable);
620
+
621
+ if (metavariableEqualToLabelMetavariable) {
622
+ return true;
623
+ }
624
+ }) || null;
625
+
626
+ return label;
627
+ }
628
+
629
+ findJudgementByMetavariable(metavariable) {
630
+ const judgements = this.getJudgements(),
631
+ judgement = judgements.find((judgement) => {
632
+ const judgementSingular = judgement.isSingular();
633
+
634
+ if (judgementSingular) {
635
+ const judgementMetavariable = judgement.getMetavariable(),
636
+ judgementMetavariableEqualToMetavariable = judgementMetavariable.isEqualTo(metavariable);
637
+
638
+ if (judgementMetavariableEqualToMetavariable) {
639
+ return true;
640
+ }
641
+ }
642
+ }) || null;
643
+
644
+ return judgement;
645
+ }
646
+
647
+ findMetavariableByMetavariableName(metavariableName) {
648
+ const metavariables = this.getMetavariables(),
649
+ metavariable = metavariables.find((metavariable) => {
650
+ const metavariableComparesToMetavariableName = metavariable.compareMetavariableName(metavariableName);
651
+
652
+ if (metavariableComparesToMetavariableName) {
653
+ return true;
654
+ }
655
+ }) || null;
656
+
657
+ return metavariable;
658
+ }
659
+
660
+ isMetavariablePresent(metavariable) {
661
+ metavariable = this.findMetavariable(metavariable);
662
+
663
+ const metavariablePresent = (metavariable !== null);
664
+
665
+ return metavariablePresent;
666
+ }
667
+
668
+ isTypePresentByTypeName(typeName, includeRelease = true, includeDependencies = true) {
669
+ const type = this.findTypeByTypeName(typeName, includeRelease, includeDependencies),
670
+ typePresent = (type !== null);
671
+
672
+ return typePresent;
673
+ }
674
+
675
+ isTypePresentByNominalTypeName(nominalTypeName) {
676
+ const type = this.findTypeByNominalTypeName(nominalTypeName),
677
+ typePresent = (type !== null);
678
+
679
+ return typePresent;
680
+ }
681
+
682
+ isTypePresentByPrefixedTypeName(prefixedTypeName) {
683
+ const type = this.findTypeByPrefixedTypeName(prefixedTypeName),
684
+ typePresent = (type !== null);
685
+
686
+ return typePresent;
687
+ }
688
+
689
+ isTypePrefixPresentByTypePrefixName(typePrefixName) {
690
+ const typePrefix = this.findTypePrefixByTypePrefixName(typePrefixName),
691
+ typePrefixPresent = (typePrefix !== null);
692
+
693
+ return typePrefixPresent;
694
+ }
695
+
696
+ isVariablePresentByVariableIdentifier(variableIdentifier) {
697
+ const variable = this.findVariableByVariableIdentifier(variableIdentifier),
698
+ variablePresent = (variable !== null);
699
+
700
+ return variablePresent;
701
+ }
702
+
703
+ isLabelPresentByMetavariableName(metavariableName) {
704
+ const label = this.findLabelByMetavariableName(metavariableName),
705
+ labelPresent = (label !== null);
706
+
707
+ return labelPresent;
708
+ }
709
+
710
+ isLabelPresentByMetavariable(metavariable) {
711
+ const label = this.findLabelByMetavariable(metavariable),
712
+ labelPresent = (label !== null);
713
+
714
+ return labelPresent;
715
+ }
716
+
717
+ isMetavariablePresentByMetavariableName(metavariableName) {
718
+ const metavariable = this.findMetavariableByMetavariableName(metavariableName),
719
+ metavariablePresent = (metavariable !== null);
720
+
721
+ return metavariablePresent;
722
+ }
723
+
724
+ isLabelPresentByReference(reference) {
725
+ const labels = this.getLabels(),
726
+ labelPresent = labels.some((label) => {
727
+ const context = this, ///
728
+ labelUnifies = reference.unifyLabel(label, context);
729
+
730
+ if (labelUnifies) {
731
+ return true;
732
+ }
733
+ });
734
+
735
+ return labelPresent;
736
+ }
737
+
738
+ isProcedurePresentByName(name) {
739
+ const procedure = this.findProcedureByName(name),
740
+ procedurePresent = (procedure !== null);
741
+
742
+ return procedurePresent;
743
+ }
744
+
745
+ isMetavariablePresentByReference(reference) {
746
+ const metavariables = this.getMetavariables(),
747
+ metavariablePresent = metavariables.some((metavariable) => {
748
+ const context = this, ///
749
+ metavariableUnifies = reference.unifyMetavariable(metavariable, context);
750
+
751
+ if (metavariableUnifies) {
752
+ return true;
753
+ }
754
+ });
755
+
756
+ return metavariablePresent;
757
+ }
758
+
759
+ isTopLevelMetaAssertionPresentByReference(reference) {
760
+ const topLevelMetaAssertion = this.findTopLevelMetaAssertionByReference(reference),
761
+ topLevelMetaAssertionPresent = (topLevelMetaAssertion !== null);
762
+
763
+ return topLevelMetaAssertionPresent;
764
+ }
765
+
766
+ verify() {
767
+ let verifies = false;
768
+
769
+ this.prepare();
770
+
771
+ if (this.node === null) {
772
+ this.warning(`Unable to verify the '${this.filePath}' file because it cannot be parsed.`);
773
+ } else {
774
+ this.debug(`Verifying the '${this.filePath}' file...`);
775
+
776
+ const context = this, ///
777
+ fileNode = this.node; ///
778
+
779
+ verifies = verifyFile(fileNode, context);
780
+
781
+ verifies ?
782
+ this.complete() :
783
+ this.clear();
784
+
785
+ if (verifies) {
786
+ this.info(`...verified the '${this.filePath}' file.`);
787
+ }
788
+ }
789
+
790
+ return verifies;
791
+ }
792
+
793
+ prepare() {
794
+ if (this.tokens !== null) {
795
+ return;
796
+ }
797
+
798
+ const file = this.findFile(this.filePath),
799
+ lexer = this.getLexer(),
800
+ parser = this.getParser(),
801
+ content = file.getContent();
802
+
803
+ this.tokens = lexer.tokenise(content);
804
+
805
+ this.node = parser.parse(this.tokens);
806
+ }
807
+
808
+ clear() {
809
+ this.lineIndex = null;
810
+
811
+ this.types = [];
812
+ this.rules = [];
813
+ this.axioms = [];
814
+ this.lemmas = [];
815
+ this.theorems = [];
816
+ this.variables = [];
817
+ this.metaLemmas = [];
818
+ this.conjectures = [];
819
+ this.combinators = [];
820
+ this.typePrefixes = [];
821
+ this.constructors = [];
822
+ this.metatheorems = [];
823
+ this.metavariables = [];
824
+ }
825
+
826
+ complete() {
827
+ this.lineIndex = null;
828
+ }
829
+
830
+ initialise(json) {
831
+ const fileContext = this; ///
832
+
833
+ this.types = [];
834
+
835
+ typesFromJSON(json, this.types, fileContext);
836
+
837
+ this.rules = rulesFromJSON(json, fileContext);
838
+
839
+ this.axioms = axiomsFromJSON(json, fileContext);
840
+
841
+ this.lemmas = lemmasFromNothing();
842
+
843
+ this.theorems = theoremsFromJSON(json, fileContext);
844
+
845
+ this.variables = variablesFromJSON(json, fileContext);
846
+
847
+ this.metaLemmas = metaLemmasFromNothing();
848
+
849
+ this.conjectures = conjecturesFromJSON(json, fileContext);
850
+
851
+ this.combinators = combinatorsFromJSON(json, fileContext);
852
+
853
+ this.typePrefixes = typePrefixesFromJSON(json, fileContext);
854
+
855
+ this.constructors = constructorsFromJSON(json, fileContext);
856
+
857
+ this.metatheorems = metatheoremsFromJSON(json, fileContext);
858
+
859
+ this.metavariables = metavariablesFromJSON(json, fileContext);
860
+ }
861
+
862
+ toJSON() {
863
+ const typesJSON = typesToTypesJSON(this.types),
864
+ rulesJSON = rulesToRulesJSON(this.rules),
865
+ axiomsJSON = axiomsToAxiomsJSON(this.axioms),
866
+ theoremsJSON = theoremsToTheoremsJSON(this.theorems),
867
+ variablesJSON = variablesToVariablesJSON(this.variables),
868
+ conjecturesJSON = conjecturesToConjecturesJSON(this.conjectures),
869
+ combinatorsJSON = combinatorsToCombinatorsJSON(this.combinators),
870
+ typePrefixesJSON = typePrefixesToTypePrefixesJSON(this.typePrefixes),
871
+ constructorsJSON = constructorsToConstructorsJSON(this.constructors),
872
+ metatheoremsJSON = metatheoremsToMetatheoremsJSON(this.metatheorems),
873
+ metavariablesJSON = metavariablesToMetavariablesJSON(this.metavariables),
874
+ filePath = this.filePath,
875
+ types = typesJSON, ///
876
+ rules = rulesJSON, ///
877
+ axioms = axiomsJSON, ///
878
+ theorems = theoremsJSON, ///
879
+ variables = variablesJSON, ///
880
+ conjectures = conjecturesJSON, ///
881
+ combinators = combinatorsJSON, ///
882
+ typePrefixes = typePrefixesJSON, ///
883
+ constructors = constructorsJSON, ///
884
+ metatheorems = metatheoremsJSON, ///
885
+ metavariables = metavariablesJSON, ///
886
+ json = {
887
+ filePath,
888
+ types,
889
+ rules,
890
+ axioms,
891
+ theorems,
892
+ variables,
893
+ conjectures,
894
+ combinators,
895
+ typePrefixes,
896
+ constructors,
897
+ metatheorems,
898
+ metavariables
899
+ };
900
+
901
+ return json;
902
+ }
903
+
904
+ static fromFile(file, context) {
905
+ const filePath = file.getPath(),
906
+ tokens = null,
907
+ node = null,
908
+ types = [],
909
+ rules = [],
910
+ axioms = [],
911
+ lemmas = [],
912
+ theorems = [],
913
+ variables = [],
914
+ metaLemmas = [],
915
+ conjectures = [],
916
+ combinators = [],
917
+ typePrefixes = [],
918
+ constructors = [],
919
+ metatheorems = [],
920
+ metavariables = [],
921
+ fileContext = new NominalFileContext(context, filePath, tokens, node, types, rules, axioms, lemmas, theorems, variables, metaLemmas, conjectures, combinators, typePrefixes, constructors, metatheorems, metavariables);
922
+
923
+ return fileContext;
924
+ }
925
+
926
+ static fromFilePath(filePath, context) {
927
+ const tokens = null,
928
+ node = null,
929
+ types = null,
930
+ rules = null,
931
+ axioms = null,
932
+ lemmas = null,
933
+ theorems = null,
934
+ variables = null,
935
+ metaLemmas = null,
936
+ conjectures = null,
937
+ combinators = null,
938
+ typePrefixes = null,
939
+ constructors = null,
940
+ metatheorems = null,
941
+ metavariables = null,
942
+ fileContext = new NominalFileContext(context, filePath, tokens, node, types, rules, axioms, lemmas, theorems, variables, metaLemmas, conjectures, combinators, typePrefixes, constructors, metatheorems, metavariables);
943
+
944
+ return fileContext;
945
+ }
946
+ }