occam-verify-cli 1.0.405 → 1.0.415

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 (132) hide show
  1. package/lib/constants.js +1 -5
  2. package/lib/context/file.js +7 -8
  3. package/lib/context/local.js +3 -3
  4. package/lib/context/release.js +2 -2
  5. package/lib/context/temporary.js +103 -54
  6. package/lib/mixins/statement/verify.js +2 -2
  7. package/lib/mixins/step/unify.js +2 -2
  8. package/lib/node/argument.js +2 -2
  9. package/lib/node/assumption.js +6 -6
  10. package/lib/node/frame.js +19 -7
  11. package/lib/node/judgement.js +8 -1
  12. package/lib/node/statement.js +34 -15
  13. package/lib/node/substitution/term.js +3 -11
  14. package/lib/node/term.js +20 -8
  15. package/lib/nonTerminalNode.js +3 -3
  16. package/lib/ontology/assertion/contained.js +7 -7
  17. package/lib/ontology/assertion/defined.js +8 -8
  18. package/lib/ontology/assertion/subproof.js +3 -3
  19. package/lib/ontology/assumption.js +49 -45
  20. package/lib/ontology/combinator.js +3 -3
  21. package/lib/ontology/constructor.js +3 -3
  22. package/lib/ontology/declaration/combinator.js +3 -3
  23. package/lib/ontology/declaration/constructor.js +3 -3
  24. package/lib/ontology/equality.js +4 -4
  25. package/lib/ontology/equivalence.js +2 -2
  26. package/lib/ontology/frame.js +37 -12
  27. package/lib/ontology/judgement.js +13 -6
  28. package/lib/ontology/metavariable.js +75 -76
  29. package/lib/ontology/propertyRelation.js +2 -2
  30. package/lib/ontology/reference.js +33 -4
  31. package/lib/ontology/signature.js +2 -2
  32. package/lib/ontology/statement.js +33 -8
  33. package/lib/ontology/step.js +4 -4
  34. package/lib/ontology/substitution/frame.js +13 -15
  35. package/lib/ontology/substitution/statement.js +31 -32
  36. package/lib/ontology/substitution/term.js +26 -25
  37. package/lib/ontology/substitution.js +2 -2
  38. package/lib/ontology/substitutions.js +4 -4
  39. package/lib/ontology/term.js +26 -12
  40. package/lib/ontology/variable.js +2 -2
  41. package/lib/process/equate.js +322 -0
  42. package/lib/process/unify.js +623 -0
  43. package/lib/process/verify.js +612 -0
  44. package/lib/utilities/brackets.js +3 -8
  45. package/lib/utilities/context.js +4 -14
  46. package/lib/utilities/json.js +18 -1
  47. package/lib/utilities/pass.js +68 -0
  48. package/lib/utilities/substitutions.js +11 -16
  49. package/package.json +11 -11
  50. package/src/constants.js +0 -1
  51. package/src/context/file.js +8 -8
  52. package/src/context/local.js +2 -2
  53. package/src/context/release.js +1 -1
  54. package/src/context/temporary.js +124 -54
  55. package/src/mixins/statement/verify.js +3 -1
  56. package/src/mixins/step/unify.js +0 -1
  57. package/src/node/argument.js +1 -1
  58. package/src/node/assumption.js +4 -4
  59. package/src/node/frame.js +19 -5
  60. package/src/node/judgement.js +7 -0
  61. package/src/node/statement.js +35 -13
  62. package/src/node/substitution/term.js +4 -14
  63. package/src/node/term.js +20 -6
  64. package/src/nonTerminalNode.js +1 -1
  65. package/src/ontology/assertion/contained.js +6 -6
  66. package/src/ontology/assertion/defined.js +7 -7
  67. package/src/ontology/assertion/subproof.js +1 -1
  68. package/src/ontology/assumption.js +52 -57
  69. package/src/ontology/combinator.js +1 -1
  70. package/src/ontology/constructor.js +1 -1
  71. package/src/ontology/declaration/combinator.js +2 -3
  72. package/src/ontology/declaration/constructor.js +2 -2
  73. package/src/ontology/equality.js +3 -3
  74. package/src/ontology/equivalence.js +1 -1
  75. package/src/ontology/frame.js +44 -10
  76. package/src/ontology/judgement.js +8 -3
  77. package/src/ontology/metavariable.js +108 -102
  78. package/src/ontology/propertyRelation.js +3 -2
  79. package/src/ontology/reference.js +39 -1
  80. package/src/ontology/signature.js +3 -3
  81. package/src/ontology/statement.js +38 -4
  82. package/src/ontology/step.js +7 -7
  83. package/src/ontology/substitution/frame.js +13 -17
  84. package/src/ontology/substitution/statement.js +45 -48
  85. package/src/ontology/substitution/term.js +19 -19
  86. package/src/ontology/substitution.js +3 -2
  87. package/src/ontology/substitutions.js +3 -3
  88. package/src/ontology/term.js +26 -5
  89. package/src/ontology/variable.js +3 -2
  90. package/src/process/equate.js +212 -0
  91. package/src/process/unify.js +634 -0
  92. package/src/process/verify.js +584 -0
  93. package/src/utilities/brackets.js +2 -11
  94. package/src/utilities/context.js +1 -21
  95. package/src/utilities/json.js +19 -0
  96. package/src/utilities/{unifier.js → pass.js} +17 -1
  97. package/src/utilities/substitutions.js +10 -20
  98. package/lib/unifier/equantional.js +0 -170
  99. package/lib/unifier/intrinsicLevel.js +0 -144
  100. package/lib/unifier/metaLevel.js +0 -197
  101. package/lib/unifier/metavariable.js +0 -140
  102. package/lib/unifier/statementWithCombinator.js +0 -177
  103. package/lib/unifier/termWithConstructor.js +0 -145
  104. package/lib/unifier.js +0 -241
  105. package/lib/utilities/arguments.js +0 -28
  106. package/lib/utilities/frame.js +0 -18
  107. package/lib/utilities/metavariable.js +0 -18
  108. package/lib/utilities/statement.js +0 -18
  109. package/lib/utilities/unification.js +0 -109
  110. package/lib/utilities/unifier.js +0 -51
  111. package/lib/utilities/variable.js +0 -18
  112. package/lib/verifier/combinator.js +0 -158
  113. package/lib/verifier/constructor.js +0 -230
  114. package/lib/verifier/topLevel.js +0 -242
  115. package/lib/verifier.js +0 -219
  116. package/src/unifier/equantional.js +0 -90
  117. package/src/unifier/intrinsicLevel.js +0 -52
  118. package/src/unifier/metaLevel.js +0 -151
  119. package/src/unifier/metavariable.js +0 -50
  120. package/src/unifier/statementWithCombinator.js +0 -114
  121. package/src/unifier/termWithConstructor.js +0 -56
  122. package/src/unifier.js +0 -183
  123. package/src/utilities/arguments.js +0 -21
  124. package/src/utilities/frame.js +0 -13
  125. package/src/utilities/metavariable.js +0 -13
  126. package/src/utilities/statement.js +0 -13
  127. package/src/utilities/unification.js +0 -136
  128. package/src/utilities/variable.js +0 -13
  129. package/src/verifier/combinator.js +0 -72
  130. package/src/verifier/constructor.js +0 -96
  131. package/src/verifier/topLevel.js +0 -204
  132. package/src/verifier.js +0 -150
@@ -0,0 +1,584 @@
1
+ "use strict";
2
+
3
+ import { nodeQuery } from "../utilities/query";
4
+ import { isLastRemainingArgumentFunction } from "../utilities/pass";
5
+ import statement from "../ontology/statement";
6
+ import ontology from "../ontology";
7
+
8
+ const nonTerminalNodeQuery = nodeQuery("/*");
9
+
10
+ const termNodeQuery = nodeQuery("/term"),
11
+ typeNodeQuery = nodeQuery("/type"),
12
+ statementNodeQuery = nodeQuery("/statement");
13
+
14
+ const errorNodeQuery = nodeQuery("/error"),
15
+ ruleNodeQuery = nodeQuery("/rule"),
16
+ axiomNodeQuery = nodeQuery("/axiom"),
17
+ lemmaNodeQuery = nodeQuery("/lemma"),
18
+ sectionNodeQuery = nodeQuery("/section"),
19
+ theoremNodeQuery = nodeQuery("/theorem"),
20
+ metaLemmaNodeQuery = nodeQuery("/metaLemma"),
21
+ conjectureNodeQuery = nodeQuery("/conjecture"),
22
+ metatheoremNodeQuery = nodeQuery("/metatheorem"),
23
+ variableDeclarationNodeQuery = nodeQuery("/variableDeclaration"),
24
+ combinatorDeclarationNodeQuery = nodeQuery("/combinatorDeclaration"),
25
+ simpleTypeDeclarationNodeQuery = nodeQuery("/simpleTypeDeclaration"),
26
+ typePrefixDeclarationNodeQuery = nodeQuery("/typePrefixDeclaration"),
27
+ constructorDeclarationNodeQuery = nodeQuery("/constructorDeclaration"),
28
+ complexTypeDeclarationNodeQuery = nodeQuery("/complexTypeDeclaration"),
29
+ metavariableDeclarationNodeQuery = nodeQuery("/metavariableDeclaration");
30
+
31
+ export default class Pass {
32
+ run(node, ...remainingArguments) {
33
+ let success;
34
+
35
+ const visited = this.visitNode(node, ...remainingArguments);
36
+
37
+ success = visited; ///
38
+
39
+ return success;
40
+ }
41
+
42
+ descend(childNodes, ...remainingArguments) {
43
+ let descendedAhead = false;
44
+
45
+ const lastRemainingArgumentFunction = isLastRemainingArgumentFunction(remainingArguments);
46
+
47
+ if (lastRemainingArgumentFunction) {
48
+ const index = 0;
49
+
50
+ descendedAhead = this.descendAhead(index, childNodes, ...remainingArguments); ///
51
+ } else {
52
+ const visited = childNodes.every((childNode) => {
53
+ const node = childNode, ///
54
+ visited = this.visitNode(node, ...remainingArguments);
55
+
56
+ if (visited) {
57
+ return true;
58
+ }
59
+ });
60
+
61
+ if (visited) {
62
+ descendedAhead = true;
63
+ }
64
+ }
65
+
66
+ return descendedAhead;
67
+ }
68
+
69
+ descendAhead(index, childNodes, ...remainingArguments) {
70
+ let descendedAhead = false;
71
+
72
+ const descendAhead = remainingArguments.pop(), ///
73
+ childNodesLength = childNodes.length;
74
+
75
+ if (index === childNodesLength) {
76
+ descendedAhead = descendAhead();
77
+ } else {
78
+ const childNode = childNodes[index],
79
+ node = childNode, ///
80
+ visited = this.visitNode(node, ...remainingArguments, () => {
81
+ remainingArguments.push(descendAhead);
82
+
83
+ const aheadIndex = index + 1,
84
+ descendedAhead = this.descendAhead(aheadIndex, childNodes, ...remainingArguments);
85
+
86
+ return descendedAhead;
87
+ });
88
+
89
+ if (visited) {
90
+ descendedAhead = true;
91
+ }
92
+ }
93
+
94
+ return descendedAhead;
95
+ }
96
+
97
+ visitNode(node, ...remainingArguments) {
98
+ let visited;
99
+
100
+ const nodeTerminalNode = node.isTerminalNode();
101
+
102
+ if (nodeTerminalNode) {
103
+ const terminalNode = node; ///
104
+
105
+ visited = this.visitTerminalNode(terminalNode, ...remainingArguments);
106
+ } else {
107
+ const nonTerminalNode = node; ///
108
+
109
+ visited = this.visitNonTerminalNode(nonTerminalNode, ...remainingArguments);
110
+ }
111
+
112
+ return visited;
113
+ }
114
+
115
+ visitTerminalNode(terminalNode, ...remainingArguments) {
116
+ let visited = false;
117
+
118
+ const lastRemainingArgumentFunction = isLastRemainingArgumentFunction(remainingArguments);
119
+
120
+ if (lastRemainingArgumentFunction) {
121
+ const descendAhead = remainingArguments.pop(), ///
122
+ descendedAhead = descendAhead();
123
+
124
+ if (descendedAhead) {
125
+ visited = true;
126
+ }
127
+
128
+ remainingArguments.push(descendAhead);
129
+ } else {
130
+ visited = true;
131
+ }
132
+
133
+ return visited;
134
+ }
135
+
136
+ visitNonTerminalNode(nonTerminalNode, ...remainingArguments) {
137
+ let visited = false;
138
+
139
+ let { maps } = this.constructor;
140
+
141
+ maps = [ ///
142
+ ...maps,
143
+ {
144
+ nodeQuery: nonTerminalNodeQuery,
145
+ run: (node, ...remainingArguments) => {
146
+ let visited = false;
147
+
148
+ const childNodes = nonTerminalNode.getChildNodes(), ///
149
+ descended = this.descend(childNodes, ...remainingArguments);
150
+
151
+ if (descended) {
152
+ visited = true;
153
+ }
154
+
155
+ return visited;
156
+ }
157
+ }
158
+ ]
159
+
160
+ maps.some((map) => {
161
+ const { nodeQuery, run } = map;
162
+
163
+ const node = nodeQuery(nonTerminalNode);
164
+
165
+ if (node !== null) {
166
+ const success = run(node, ...remainingArguments);
167
+
168
+ visited = success;
169
+
170
+ return true;
171
+ }
172
+ });
173
+
174
+ return visited;
175
+ }
176
+ }
177
+
178
+ class TopLevelPass extends Pass {
179
+ static maps = [
180
+ {
181
+ nodeQuery: errorNodeQuery,
182
+ run: (errorNode, context) => {
183
+ let success = false;
184
+
185
+ const { Error } = ontology,
186
+ error = Error.fromErrorNode(errorNode, context),
187
+ errorVerifies = error.verify();
188
+
189
+ if (errorVerifies) {
190
+ success = true;
191
+ }
192
+
193
+ return success;
194
+ }
195
+ },
196
+ {
197
+ nodeQuery: ruleNodeQuery,
198
+ run: (ruleNode, context) => {
199
+ let success = false;
200
+
201
+ const { Rule } = ontology,
202
+ rule = Rule.fromRuleNode(ruleNode, context),
203
+ ruleVerifies = rule.verify();
204
+
205
+ if (ruleVerifies) {
206
+ success = true;
207
+ }
208
+
209
+ return success;
210
+ }
211
+ },
212
+ {
213
+ nodeQuery: axiomNodeQuery,
214
+ run: (axiomNode, context) => {
215
+ let success = false;
216
+
217
+ const { Axiom } = ontology,
218
+ axiom = Axiom.fromAxiomNode(axiomNode, context),
219
+ axiomVerifies = axiom.verify();
220
+
221
+ if (axiomVerifies) {
222
+ success = true;
223
+ }
224
+
225
+ return success;
226
+ }
227
+ },
228
+ {
229
+ nodeQuery: lemmaNodeQuery,
230
+ run: (lemmaNode, context) => {
231
+ let success = false;
232
+
233
+ const { Lemma } = ontology,
234
+ lemma = Lemma.fromLemmaNode(lemmaNode, context),
235
+ lemmaVerifies = lemma.verify();
236
+
237
+ if (lemmaVerifies) {
238
+ success = true;
239
+ }
240
+
241
+ return success;
242
+ }
243
+ },
244
+ {
245
+ nodeQuery: sectionNodeQuery,
246
+ run: (sectionNode, context) => {
247
+ let success = false;
248
+
249
+ const { Section } = ontology,
250
+ section = Section.fromSectionNode(sectionNode, context),
251
+ sectionVerifies = section.verify();
252
+
253
+ if (sectionVerifies) {
254
+ success = true;
255
+ }
256
+
257
+ return success;
258
+ }
259
+ },
260
+ {
261
+ nodeQuery: theoremNodeQuery,
262
+ run: (theoremNode, context) => {
263
+ let success = false;
264
+
265
+ const { Theorem } = ontology,
266
+ theorem = Theorem.fromTheoremNode(theoremNode, context),
267
+ theoremVerifies = theorem.verify();
268
+
269
+ if (theoremVerifies) {
270
+ success = true;
271
+ }
272
+
273
+ return success;
274
+ }
275
+ },
276
+ {
277
+ nodeQuery: metaLemmaNodeQuery,
278
+ run: (metaLemmaNode, context) => {
279
+ let success = false;
280
+
281
+ const { MetaLemma } = ontology,
282
+ metaLemma = MetaLemma.fromMetaLemmaNode(metaLemmaNode, context),
283
+ metaLemmaVerifies = metaLemma.verify();
284
+
285
+ if (metaLemmaVerifies) {
286
+ success = true;
287
+ }
288
+
289
+ return success;
290
+ }
291
+ },
292
+ {
293
+ nodeQuery: conjectureNodeQuery,
294
+ run: (conjectureNode, context) => {
295
+ let success = false;
296
+
297
+ const { Conjecture } = ontology,
298
+ conjecture = Conjecture.fromConjectureNode(conjectureNode, context),
299
+ conjectureVerifies = conjecture.verify();
300
+
301
+ if (conjectureVerifies) {
302
+ success = true;
303
+ }
304
+
305
+ return success;
306
+ }
307
+ },
308
+ {
309
+ nodeQuery: metatheoremNodeQuery,
310
+ run: (metatheoremNode, context) => {
311
+ let success = false;
312
+
313
+ const { Metatheorem } = ontology,
314
+ metatheorem = Metatheorem.fromMetatheoremNode(metatheoremNode, context),
315
+ metatheoremVerifies = metatheorem.verify();
316
+
317
+ if (metatheoremVerifies) {
318
+ success = true;
319
+ }
320
+
321
+ return success;
322
+ }
323
+ },
324
+ {
325
+ nodeQuery: variableDeclarationNodeQuery,
326
+ run: (variableDeclarationNode, context) => {
327
+ let success = false;
328
+
329
+ const { VariableDeclaration } = ontology,
330
+ variableDeclaration = VariableDeclaration.fromVariableDeclarationNode(variableDeclarationNode, context),
331
+ variableDeclarationVerifies = variableDeclaration.verify();
332
+
333
+ if (variableDeclarationVerifies) {
334
+ success = true;
335
+ }
336
+
337
+ return success;
338
+ }
339
+ },
340
+ {
341
+ nodeQuery: simpleTypeDeclarationNodeQuery,
342
+ run: (simpleTypeDeclarationNode, context) => {
343
+ let success = false;
344
+
345
+ const { SimpleTypeDeclaration } = ontology,
346
+ simpleTypeDeclaration = SimpleTypeDeclaration.fromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, context),
347
+ simpleTypeDeclarationVerifies = simpleTypeDeclaration.verify();
348
+
349
+ if (simpleTypeDeclarationVerifies) {
350
+ success = true;
351
+ }
352
+
353
+ return success;
354
+ }
355
+ },
356
+ {
357
+ nodeQuery: typePrefixDeclarationNodeQuery,
358
+ run: (typePrefixDeclarationNode, context) => {
359
+ let success = false;
360
+
361
+ const { TypePrefixDeclaration } = ontology,
362
+ typePrefixDeclaration = TypePrefixDeclaration.fromTypePrefixDeclarationNode(typePrefixDeclarationNode, context),
363
+ typePrefixDeclarationVerifies = typePrefixDeclaration.verify();
364
+
365
+ if (typePrefixDeclarationVerifies) {
366
+ success = true;
367
+ }
368
+
369
+ return success;
370
+ }
371
+ },
372
+ {
373
+ nodeQuery: combinatorDeclarationNodeQuery,
374
+ run: (combinatorDeclarationNode, context) => {
375
+ let success = false;
376
+
377
+ const { CombinatorDeclaration } = ontology,
378
+ combinatorDeclaration = CombinatorDeclaration.fromCombinatorDeclarationNode(combinatorDeclarationNode, context),
379
+ combinatorDeclarationVerifies = combinatorDeclaration.verify();
380
+
381
+ if (combinatorDeclarationVerifies) {
382
+ success = true;
383
+ }
384
+
385
+ return success;
386
+ }
387
+ },
388
+ {
389
+ nodeQuery: constructorDeclarationNodeQuery,
390
+ run: (constructorDeclarationNode, context) => {
391
+ let success = false;
392
+
393
+ const { ConstructorDeclaration } = ontology,
394
+ constructorDeclaration = ConstructorDeclaration.fromConstructorDeclarationNode(constructorDeclarationNode, context),
395
+ constructorDeclarationVerifies = constructorDeclaration.verify();
396
+
397
+ if (constructorDeclarationVerifies) {
398
+ success = true;
399
+ }
400
+
401
+ return success;
402
+ }
403
+ },
404
+ {
405
+ nodeQuery: complexTypeDeclarationNodeQuery,
406
+ run: (complexTypeDeclarationNode, context) => {
407
+ let success = false;
408
+
409
+ const { ComplexTypeDeclaration } = ontology,
410
+ complexTypeDeclaration = ComplexTypeDeclaration.fromComplexTypeDeclarationNode(complexTypeDeclarationNode, context),
411
+ complexTypeDeclarationVerifies = complexTypeDeclaration.verify();
412
+
413
+ if (complexTypeDeclarationVerifies) {
414
+ success = true;
415
+ }
416
+
417
+ return success;
418
+ }
419
+ },
420
+ {
421
+ nodeQuery: metavariableDeclarationNodeQuery,
422
+ run: (metavariableDeclarationNode, context) => {
423
+ let success = false;
424
+
425
+ const { MetavariableDeclaration } = ontology,
426
+ metavariableDeclaration = MetavariableDeclaration.fromMetavariableDeclarationNode(metavariableDeclarationNode, context),
427
+ metavariableDeclarationVerifies = metavariableDeclaration.verify();
428
+
429
+ if (metavariableDeclarationVerifies) {
430
+ success = true;
431
+ }
432
+
433
+ return success;
434
+ }
435
+ }
436
+ ];
437
+ }
438
+
439
+ class CombinatorPass extends Pass {
440
+ static maps = [
441
+ {
442
+ nodeQuery: statementNodeQuery,
443
+ run: (statementNode, context) => {
444
+ let success = false;
445
+
446
+ const { Statement } = ontology,
447
+ statement = Statement.fromStatementNode(statementNode, context),
448
+ assignments = null,
449
+ stated = false,
450
+ statementVerifies = statement.verify(assignments, stated, context);
451
+
452
+ if (statementVerifies) {
453
+ success = true;
454
+ }
455
+
456
+ return success;
457
+ }
458
+ },
459
+ {
460
+ nodeQuery: termNodeQuery,
461
+ run: (termNode, context) => {
462
+ let success = false;
463
+
464
+ const { Term } = ontology,
465
+ term = Term.fromTermNode(termNode, context),
466
+ termVerifies = term.verify(context, () => {
467
+ const verifiesAhead = true;
468
+
469
+ return verifiesAhead;
470
+ });
471
+
472
+ if (termVerifies) {
473
+ success = true;
474
+ }
475
+
476
+ return success;
477
+ }
478
+ },
479
+ {
480
+ nodeQuery: typeNodeQuery,
481
+ run: (typeNode, context) => {
482
+ let success = false;
483
+
484
+ const nominalTypeName = typeNode.getNominalTypeName(),
485
+ typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
486
+
487
+ if (typePresent) {
488
+ success = true;
489
+ }
490
+
491
+ return success;
492
+ }
493
+ }
494
+ ];
495
+ }
496
+
497
+ class ConstructorPass extends Pass {
498
+ static maps = [
499
+ {
500
+ nodeQuery: termNodeQuery,
501
+ run: (termNode, context, verifyAhead) => {
502
+ let success = false;
503
+
504
+ const { Term } = ontology,
505
+ term = Term.fromTermNode(termNode, context),
506
+ termVerifies = term.verify(context, verifyAhead);
507
+
508
+ if (termVerifies) {
509
+ success = true;
510
+ }
511
+
512
+ return success;
513
+ }
514
+ },
515
+ {
516
+ nodeQuery: typeNodeQuery,
517
+ run: (typeNode, context, verifyAhead) => {
518
+ let success = false;
519
+
520
+ const nominalTypeName = typeNode.getNominalTypeName(),
521
+ typePresent = context.isTypePresentByNominalTypeName(nominalTypeName);
522
+
523
+ if (typePresent) {
524
+ const verifiesAhead = verifyAhead();
525
+
526
+ if (verifiesAhead) {
527
+ success = true;
528
+ }
529
+ } else {
530
+ const typeString = nominalTypeName; ///
531
+
532
+ context.debug(`The '${typeString}' type is not present.`);
533
+
534
+ success = false;
535
+ }
536
+
537
+ return success;
538
+ }
539
+ }
540
+ ];
541
+ }
542
+
543
+ const topLevelPass = new TopLevelPass(),
544
+ combinatorPass = new CombinatorPass(),
545
+ constructorPass = new ConstructorPass();
546
+
547
+ export function verifyFile(fileNode, context) {
548
+ let fileVerifies = false;
549
+
550
+ const node = fileNode, ///
551
+ sucess = topLevelPass.run(node, context);
552
+
553
+ if (sucess) {
554
+ fileVerifies = true;
555
+ }
556
+
557
+ return fileVerifies;
558
+ }
559
+
560
+ export function verifyTerm(termNode, context) {
561
+ let termVerifies = false;
562
+
563
+ const node = termNode, ///
564
+ sucess = constructorPass.run(node, context);
565
+
566
+ if (sucess) {
567
+ termVerifies = true;
568
+ }
569
+
570
+ return termVerifies;
571
+ }
572
+
573
+ export function verifyStatement(statementNode, context) {
574
+ let statementVerifies = false;
575
+
576
+ const node = statementNode, ///
577
+ sucess = combinatorPass.run(node, context);
578
+
579
+ if (sucess) {
580
+ statementVerifies = true;
581
+ }
582
+
583
+ return statementVerifies;
584
+ }
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  import ontology from "../ontology";
4
- import TemporaryContext from "../context/temporary";
5
4
  import combinatorBracketedContext from "../context/bracketed/combinator";
6
5
  import constructorBracketedContext from "../context/bracketed/constructor";
7
6
 
7
+ import { contextFromStatement } from "../utilities/context";
8
+
8
9
  import { BRACKETED_TERM_DEPTH, BRACKETED_STATEMENT_DEPTH } from "../constants";
9
10
 
10
11
  export function stripBracketsFromTerm(term, context) {
@@ -88,13 +89,3 @@ export function bracketedStatementChildNodeFromStatementNode(statementNode) {
88
89
 
89
90
  return bracketedStatementChildNode;
90
91
  }
91
-
92
- function contextFromStatement(statement, context) {
93
- const statementTokens = statement.getTokens(),
94
- tokens = statementTokens, ///
95
- temporaryContext = TemporaryContext.fromContextAndTokens(context, tokens);
96
-
97
- context = temporaryContext; ///
98
-
99
- return context;
100
- }
@@ -3,16 +3,6 @@
3
3
  import ontology from "../ontology";
4
4
  import TemporaryContext from "../context/temporary";
5
5
 
6
- export function metavariableFromFrame(frame, context) {
7
- context = contextFromFrame(frame, context); ///
8
-
9
- const { Metavariable } = ontology,
10
- frameNode = frame.getNode(),
11
- metavariable = Metavariable.fromFrameNode(frameNode, context);
12
-
13
- return metavariable;
14
- }
15
-
16
6
  export function equalityFromStatement(statement, context) {
17
7
  context = contextFromStatement(statement, context); ///
18
8
 
@@ -103,17 +93,7 @@ export function satisfiesAssertionFromStatement(statement, context) {
103
93
  return satisfiesAssertion;
104
94
  }
105
95
 
106
- function contextFromFrame(frame, context) {
107
- const frameTokens = frame.getTokens(),
108
- tokens = frameTokens, ///
109
- temporaryContext = TemporaryContext.fromContextAndTokens(context, tokens);
110
-
111
- context = temporaryContext; ///
112
-
113
- return context;
114
- }
115
-
116
- function contextFromStatement(statement, context) {
96
+ export function contextFromStatement(statement, context) {
117
97
  const statementTokens = statement.getTokens(),
118
98
  tokens = statementTokens, ///
119
99
  temporaryContext = TemporaryContext.fromContextAndTokens(context, tokens);
@@ -91,6 +91,19 @@ export function signatureFromJSON(json, context) {
91
91
  return signature;
92
92
  }
93
93
 
94
+ export function referenceFromJSON(json, context) {
95
+ let { reference } = json;
96
+
97
+ const { Reference } = ontology,
98
+ referenceJSON = reference; ///
99
+
100
+ json = referenceJSON; ///
101
+
102
+ reference = Reference.fromJSON(json, context);
103
+
104
+ return reference;
105
+ }
106
+
94
107
  export function conclusionFromJSON(json, context) {
95
108
  let { conclusion } = json;
96
109
 
@@ -532,6 +545,12 @@ export function metaTypeToMetaTypeJSON(metaType) {
532
545
  return metaTypeJSON;
533
546
  }
534
547
 
548
+ export function referenceToReferenceJSON(reference) {
549
+ const referenceJSON = reference.toJSON();
550
+
551
+ return referenceJSON;
552
+ }
553
+
535
554
  export function statementToStatementJSON(statement) {
536
555
  const statementJSON = (statement !== null) ?
537
556
  statement.toJSON() :
@@ -2,7 +2,9 @@
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
4
 
5
- const { match } = arrayUtilities;
5
+ import { FUNCTION } from "../constants";
6
+
7
+ const { match, last } = arrayUtilities;
6
8
 
7
9
  export function terminalNodeMapFromNodes(nodes) {
8
10
  const terminalNodeMap = {};
@@ -47,3 +49,17 @@ export function areTerminalNodeMapsEqual(generalTerminalNodeMap, specificTermina
47
49
 
48
50
  return terminalNodeMapsEqual;
49
51
  }
52
+
53
+ export function isLastRemainingArgumentFunction(remainingArguments) {
54
+ let lastRemainingArgumentFunction = false;
55
+
56
+ const remainingArgumentsLength = remainingArguments.length;
57
+
58
+ if (remainingArgumentsLength > 0) {
59
+ const lastRemainingArgument = last(remainingArguments);
60
+
61
+ lastRemainingArgumentFunction = (typeof lastRemainingArgument === FUNCTION);
62
+ }
63
+
64
+ return lastRemainingArgumentFunction;
65
+ }