-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
1150 lines (1138 loc) · 84.2 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "helper/FctHelper.h"
#include "helper/Version.h"
#include "metamath/DRuleReducer.h"
#include "logic/DlProofEnumerator.h"
#include <boost/algorithm/string.hpp>
#include <cstring>
#include <ctime>
#ifdef _MSC_VER
#include <process.h>
#else
#include <unistd.h>
#endif
using namespace std;
using namespace xamidi::helper;
using namespace xamidi::metamath;
using namespace xamidi::logic;
struct A {
string myTime() {
time_t time = chrono::system_clock::to_time_t(chrono::system_clock::now());
return strtok(ctime(&time), "\n");
}
string myInfo() {
stringstream ss;
ss << "[pid: " << getpid() << ", tid:" << this_thread::get_id() << "]";
return ss.str();
}
A() { cout << myTime() << ": Process started. " << myInfo() << endl; }
~A() { cout << myTime() << ": Process terminated. " << myInfo() << endl; }
} a;
enum class Task {
Invalid,
Customize, // -c
Generate, // -g
CreateReplacements, // -r
ApplyReplacements, // -a
ParseAndPrintProofs, // --parse
TransformProofSummary, // --transform
UnfoldProofSummary, // --unfold
SearchProofFiles, // --search
ExtractFromProofFiles, // --extract
AssessGeneration, // --assess
IterateProofCandidates, // --iterate
FileConversion, // --variate
ConclusionLengthPlot, // --plot
MpiFilter // -m
};
static const map<Task, string>& cmdInfo() {
static const map<Task, string> _ = []() {
map<Task, string> _;
_[Task::Customize] =
" -c [-i <file>] [-s <string>] [-n] [-N <limit or -1>] [-l] [-e <id>] [-d]\n"
" Proof system customization ; Generates a SHA-512/224 hash to identify the system, sets the effective data location to \"<data location>/<hash>\", and (if nonexisting) creates the !.def file.\n"
" -i: specify axioms by input file path (where a LF-separated string of axioms is stored), ignoring lines that are empty or starting with '%'\n"
" -s: specify axioms by comma-separated string ; used only when '-i' unspecified ; default: \"C0C1.0,CC0C1.2CC0.1C0.2,CCN0N1C1.0\"\n"
" -n: specify formulas in normal Polish notation (e.g. \"CpCqp\"), not with numeric variables (e.g. \"C0C1.0\")\n"
" -N: enable necessitation rule \"N\" for the given system with unlimited (-N 0) or limited (-N <positive amount>) consecutive necessitation steps allowed\n"
" -l: disable lazy N-rule parsing ; parse proofs Nα:Lβ despite knowing α:β (requires more time but less memory)\n"
" -e: specify extracted system with the given identifier\n"
" -d: default system ; ignore all other arguments except '-e'\n";
_[Task::Generate] =
" -g <limit or -1> [-u] [-q <limit or -1>] [-l <limit or -1>] [-k <limit or -1>] [-b] [-f] [-s]\n"
" Generate proof files ; at ./data/[<hash>/]/dProofs-withConclusions/ when '-s' unspecified ; otherwise at ./data/[<hash>/]/dProofs-withoutConclusions/\n"
" -u: unfiltered (significantly faster, but generates redundant proofs)\n"
" -q: limit number of proof candidate strings queued per worker thread (may lower memory requirements for systems with low acceptance rates) ; default: 50\n"
" -l: limit symbolic length of generated conclusions to at most the given number ; works only in extracted environments ; recommended to use in combination with '-q' to save memory\n"
" -k: similar to '-l' ; limit symbolic length of consequents in generated conclusions, i.e. antecedents in conditionals are not limited (but non-conditionals are limited in full length)\n"
" -b: brief parsing ; append conclusion structures to D-proof processing and use them for rule evaluation (collects faster, but requires significantly more memory)\n"
" -f: full parsing ; parse entire D-proofs rather than using conclusion strings for rule evaluation ; used only when '-b' unspecified\n"
" -s: proof files without conclusions, requires additional parsing ; entails '-f' ; used only when '-b' unspecified\n";
_[Task::CreateReplacements] =
" -r <D-proof database> <output file> [-l <path>] [-i <prefix>] [-s] [-d]\n"
" Replacements file creation based on proof files\n"
" -l: customize data location path ; default: \"data\"\n"
" -i: customize input file path prefix in data location ; default: \"dProofs-withConclusions/dProofs\"\n"
" -s: proof files without conclusions, requires additional parsing ; sets default input file path prefix to \"dProofs-withoutConclusions/dProofs\"\n"
" -d: print debug information\n";
_[Task::ApplyReplacements] =
" -a <initials> <replacements file> <D-proof database> <output file> [-s] [-l] [-w] [-d]\n"
" Apply replacements file\n"
" -s: style all proofs (replace proofs with alphanumerically smaller variants)\n"
" -l: list all proofs (i.e. not only modified proofs)\n"
" -w: wrap results\n"
" -d: print debug information\n";
_[Task::ParseAndPrintProofs] =
" --parse <string> [-n] [-u] [-j <limit or -1>] [-b] [-s] [-e] [-f] [-o <output file>] [-d]\n"
" Parse and print proofs given by a comma-separated string\n"
" -n: print formulas in normal Polish notation (e.g. \"CpCqp\"), not with numeric variables (e.g. \"C0C1.0\")\n"
" -u: print formulas in infix notation with operators as Unicode characters ; used only when '-n' unspecified\n"
" -j: join common subproofs together when they are used at least a given amount of times ; default: 2\n"
" -b: only print conclusions of the given proofs ; sets default of '-j' to 1\n"
" -s: only print summary with conclusions and abstract condensed detachment proofs ; used only when '-b' unspecified\n"
" -e: keep expanded proof strings ; show fully detailed condensed detachment proofs rather than allowing them to contain references ; used only when '-b' unspecified\n"
" -f: proofs are given by input file path (where a comma-separated string is stored), ignoring all CR, LF, whitespace, and lines starting with '%'\n"
" -o: redirect the result's output to the specified file\n"
" -d: print debug information\n";
_[Task::TransformProofSummary] =
" --transform <string> [-s <string>] [-j <limit or -1>] [-p <limit or -1>] [-n] [-u] [-t <string>] [-e] [-i <limit or -1>] [-l <limit or -1>] [-b] [-w] [-z] [-y] [-f] [-o <output file>] [-d]\n"
" Transform proof summary (as by '--parse [...] -s') into recombined variant ; ignores configured system (proof summaries provide their own axioms) ; \",\" represents LF\n"
" -s: list a subproof with its conclusion if it occurs in the given comma-separated list of conclusions\n"
" -j: join common subproofs together when they are used at least a given amount of times ; default: 2\n"
" -p: only keep subproofs with primitive lengths not exceeding the given limit ; default: -1\n"
" -n: specify and print formulas in normal Polish notation (e.g. \"CpCqp\"), not with numeric variables (e.g. \"C0C1.0\")\n"
" -u: print formulas in infix notation with operators as Unicode characters ; does not affect input format (for which '-n' can still be specified)\n"
" -t: only transform proofs of specified theorems (proven by subsequences of the input), given by a comma-separated string ; \".\" to keep all conclusions ; default: final theorem only\n"
" -e: keep expanded proof strings ; show fully detailed condensed detachment proofs rather than allowing them to contain references\n"
" -i: decrease memory requirements but increase time consumption by not storing intermediate unfoldings that exceed a certain length ; default: -1\n"
" -l: abort computation when combined requested proof sequences exceed the given limit in bytes ; default: 134217728 (i.e. 128 MiB)\n"
" -b: duplicate conclusion removal ; replace each given subproof that has a redundant conclusion with its first shortest alternative and remove duplicates ; beneficial in preparing '-z'\n"
" -w: read input without conclusions given\n"
" -z: proof compression ; find and remove internal redundancies (e.g. non-trivial parts not affecting intermediate theorems) by attempting to use shorter owned subproofs at all positions\n"
" -y: disable multi-threaded D-rule replacement search in case proof compression is performed (enables deterministic solution procedure)\n"
" -f: proof summary is given by input file path ; ignores lines that are empty or starting with '%'\n"
" -o: redirect the result's output to the specified file\n"
" -d: print debug information\n";
_[Task::UnfoldProofSummary] =
" --unfold <string> [-n] [-t <string>] [-i <limit or -1>] [-l <limit or -1>] [-w] [-v] [-f] [-o <output file>] [-d]\n"
" Break down proof summary (as by '--parse [...] -s') into primitive steps ; ignores configured system (proof summaries provide their own axioms) ; \",\" represents LF\n"
" -n: specify formulas in normal Polish notation (e.g. \"CpCqp\"), not with numeric variables (e.g. \"C0C1.0\")\n"
" -t: obtain proofs of specified theorems (proven by subsequences of the input), given by a comma-separated string ; \".\" to obtain a proof for each conclusion ; default: final theorem only\n"
" -i: decrease memory requirements but increase time consumption by not storing intermediate unfoldings that exceed a certain length ; default: -1\n"
" -l: abort computation when combined requested proof sequences exceed the given limit in bytes ; default: 134217728 (i.e. 128 MiB)\n"
" -w: wrap results\n"
" -v: read input without conclusions given\n"
" -f: proof summary is given by input file path ; ignores lines that are empty or starting with '%'\n"
" -o: redirect the result's output to the specified file\n"
" -d: print debug information\n";
_[Task::SearchProofFiles] =
" --search <string> [-n] [-s] [-w] [-t] [-p] [-f] [-d]\n"
" Search in proof files at ./data/[<hash>/]/dProofs-withConclusions/ via comma-separated string of full formulas or full proofs ; [Hint: Generate missing files with '--variate 1 -s'.]\n"
" -n: specify formulas in normal Polish notation (e.g. \"CpCqp\"), not with numeric variables (e.g. \"C0C1.0\")\n"
" -s: search for schemas of the given formulas\n"
" -w: search whole collections of schemas (i.e. enable multiple results per term) ; entails '-s'\n"
" -t: search for formulas of the given schemas (allows multiple results per term) ; used only when '-s' unspecified\n"
" -p: search proofs (rather than conclusions) ; used only when '-n', '-s' and '-t' unspecified\n"
" -f: search terms are given by input file path (where a comma-separated string is stored), ignoring all CR, LF, whitespace, and lines starting with '%'\n"
" -d: print debug information\n";
_[Task::ExtractFromProofFiles] =
" --extract [-t <limit or -1>] [-o <output file>] [-s] [-z] [-# <amount up to 35>] [-h <string>] [-l <limit or -1>] [-k <limit or -1>] [-f] [-d]\n"
" Various options to extract information from proof files ; [Hint: Generate missing files with '--variate 1 -s'.]\n"
" -t: compose file with up to the given amount of smallest conclusions that occur in proof files ; includes origins, symbolic lengths, proofs, and formulas in normal Polish notation\n"
" -o: specify output file path for '-t' ; relative to effective data location ; default: \"top<amount>SmallestConclusions_<min proof length>to<max proof length>Steps<unfiltered info>.txt\"\n"
" -s: redundant schema removal for '-t' ; very time-intensive for requesting huge collections from unfiltered proof files - better pre-filter via '-g' or '-m' instead ; default: false\n"
" -z: force redundant schema removal for '-t' ; like '-s', but also filter proof files not declared as unfiltered (which might be useful for non-standard procedures)\n"
" -#: initialize proof system at ./data/[<hash>/]/extraction-<id>/ with the given amount of smallest filtered conclusions that occur in proof files ; specify with '-c <parent system> -e <id>'\n"
" -h: similar to '-#' ; hand-pick conclusions with a comma-separated string of proofs ; \".\" to not modify axioms\n"
" -l: similar to '-#' (but creates identical system with prebuilt proof files) ; copy proofs with conclusions that have symbolic lengths of at most the given number\n"
" -k: similar to '-l' ; copy proofs with conclusions that have consequents or are non-conditionals of symbolic lengths of at most the given number ; can be combined with '-l'\n"
" -f: proofs for '-h' are given by input file path (where a comma-separated string is stored), ignoring all CR, LF, whitespace, and lines starting with '%'\n"
" -d: print debug information\n";
_[Task::AssessGeneration] =
" --assess [-u] [-s] [-d]\n"
" Print proof file cardinalities, numbers of proof candidates for all generation steps up to the next one, and all stored and estimated next removal amounts (to assess generation expenditures)\n"
" -u: use unfiltered proof files\n"
" -s: use proof files without conclusions\n"
" -d: print debug information\n";
_[Task::IterateProofCandidates] =
" --iterate [-u] [-s]\n"
" Iterate proof candidates currently next up for generation and print their amount (for resource consumption measurements)\n"
" -u: use unfiltered proof files\n"
" -s: use proof files without conclusions\n";
_[Task::FileConversion] =
" --variate ( 0 | 1 ) [-l <path>] [-i <prefix>] [-o <prefix>] [-s] [-d]\n"
" Create proof files with removed (--variate 0) or added (--variate 1) conclusions from in-memory data and proof files of the other variant\n"
" -l: customize data location path ; default: \"data\"\n"
" -i: customize input file path prefix in data location ; default: \"dProofs-withConclusions/dProofs\" or \"dProofs-withoutConclusions/dProofs\"\n"
" -o: customize output file path prefix in data location ; default: \"dProofs-withoutConclusions/dProofs\" or \"dProofs-withConclusions/dProofs\"\n"
" -s: only use data stored in-memory\n"
" -d: print debug information\n";
_[Task::ConclusionLengthPlot] =
" --plot [-l <path>] [-i <prefix>] [-s] [-t] [-x <limit or -1>] [-y <limit or -1>] [-o <output file>] [-d]\n"
" Print conclusion length plot data\n"
" -l: customize data location path ; default: \"data\"\n"
" -i: customize input file path prefix in data location ; requires files with conclusions ; default: \"dProofs-withConclusions/dProofs\"\n"
" -s: measure symbolic length (in contrast to conclusion representation length)\n"
" -u: include unfiltered proof files\n"
" -t: table arrangement, one data point per row\n"
" -x: upper horizontal limit\n"
" -y: upper vertical limit\n"
" -o: print to given output file\n"
" -d: print debug information\n";
_[Task::MpiFilter] =
" -m <limit> [-s]\n"
" MPI-based multi-node filtering (-m <n>) of a first unfiltered proof file (with conclusions) at ./data/[<hash>/]dProofs-withConclusions/dProofs<n>-unfiltered<n>+.txt. Creates dProofs<n>.txt.\n"
" -s: disable smooth progress mode (lowers memory requirements, but makes terrible progress predictions)\n";
return _;
}();
return _;
}
int main(int argc, char* argv[]) { // argc = 1 + N, argv = { <command>, <arg1>, ..., <argN> }
// Custom tools' code - (v1.2.1) : https://github.com/xamidi/pmGenerator/commit/55c31a5f3dd951a72097393ba3d213980303dfe4
#if 0 //### entropy calculation
// NOTE: Requires '#include <cmath>'.
map<char, size_t> m;
uint32_t num = 57;
ifstream fin("data/0df075acc552c62513b49b6ed674bfcde1c1b018e532c665be229314/dProofs-withConclusions/dProofs" + to_string(num) + ".txt", fstream::in | fstream::binary);
if (!fin.is_open()) {
cerr << "Failed to read the data file. Aborting." << endl;
return 0;
}
char c;
while (fin.get(c))
m[c]++;
size_t len = 0;
for (pair<char, size_t> p : m)
len += p.second;
double result = 0.0;
for (const pair<char, size_t> p : m) {
double frequency = static_cast<double>(p.second) / static_cast<double>(len);
result -= frequency * log2(frequency);
}
cout << "Shannon entropy: " << result << " bits of information per byte" << endl; // e.g. 3.3841 for data/0df075acc552c62513b49b6ed674bfcde1c1b018e532c665be229314/dProofs-withConclusions/dProofs57.txt
cout << "Length: " << len << endl;
cout << "Amounts: " << FctHelper::mapStringF(m, [](const pair<char, size_t>& p) { return "'" + (p.first == '\n' ? "\\n" : string { p.first }) + "':" + to_string(p.second); }) << endl;
return 0;
#endif //###
//#cout << "argc = " << argc << ", argv = { " << [&]() { string s; for (int i = 0; i < argc; i++) { if (i) s += ", "; s += string { argv[i] }; } return s; }() << " }" << endl;
auto printUsage = [&](const string& error = "", Task task = Task::Invalid) {
if (!error.empty())
cerr << error << endl;
switch (task) {
case Task::Invalid:
cout << "\n" << xamidi::version << " ; repository at " << xamidi::repository;
cout << "\nUsage:\n"
" pmGenerator ( <configuring command> | <composable command> )+ | <configuring command>* <standalone command>\n"
"Configuring:\n";
cout << cmdInfo().at(Task::Customize);
cout << "Composable:\n";
cout << cmdInfo().at(Task::Generate);
cout << cmdInfo().at(Task::CreateReplacements);
cout << cmdInfo().at(Task::ApplyReplacements);
cout << cmdInfo().at(Task::ParseAndPrintProofs);
cout << cmdInfo().at(Task::TransformProofSummary);
cout << cmdInfo().at(Task::UnfoldProofSummary);
cout << cmdInfo().at(Task::SearchProofFiles);
cout << cmdInfo().at(Task::ExtractFromProofFiles);
cout << cmdInfo().at(Task::AssessGeneration);
cout << cmdInfo().at(Task::IterateProofCandidates);
cout << cmdInfo().at(Task::FileConversion);
cout << cmdInfo().at(Task::ConclusionLengthPlot);
cout << "Standalone:\n";
cout << cmdInfo().at(Task::MpiFilter);
cout << "Examples:\n"
" pmGenerator -g -1 -q 50\n"
" pmGenerator -g 19 -g 21 -u -r data/pmproofs-old.txt data/pmproofs-reducer.txt -d -a SD data/pmproofs-reducer.txt data/pmproofs-old.txt data/pmproofs-result-styleAll-modifiedOnly.txt -s -w -d\n"
" pmGenerator --variate 0 -l data/ -o \"dProofs-withoutConclusions (all)/dProofs\" -d\n"
" pmGenerator --variate 1 -s --search CNpCCNpqNp -n -d --search CNpCCNpqNp -n -s\n"
" pmGenerator --variate 1 -s --search CCNpCpqCNpCpq,CCCCppCppCCCppCppCNCCqqCqqCCCqqCqqCCqqCqqCCCppCppCNCCqqCqqCCCqqCqqCCqqCqq -n -w -d\n"
" pmGenerator --plot -s -d --plot -s -t -x 50 -y 100 -o data/plot_data_x50_y100.txt\n"
" pmGenerator -c -N -1 -n -s CpCqp,CCpCqrCCpqCpr,CCNpNqCqp,CLpp,CLCpqCLpLq,CNLNpLNLNp --parse DD2D16DD2DD2D13DD2D1D2DD2D1D2D1DD2DD2D13D1DD2DD2D13DD2D13114DD2D13DD2D1311D3DD2DD2D13DD2D1311 -j 2 -n\n"
" pmGenerator --parse DD2D11DD2D13DD2D1DD22D11DD2D11DD2D131 -n -s -o data/CNCpNqCrCsq.txt --transform data/CNCpNqCrCsq.txt -f -n -j 1 -e --transform data/CNCpNqCrCsq.txt -f -n -t CNCpNqCrq -d\n"
" pmGenerator --unfold CpCqp=1,CCpCqrCCpqCpr=2,CCNpNqCqp=3,[0]CCpCNqNrCpCrq:D2D13,[1]Cpp:DD211,[2]NCCppNCqq:DD3DD2DD2D[0]D[0]11D1[1][1] -n -t CNNpp,NCCppNCqq\n"
" pmGenerator --transform data/m.txt -f -n -t CpCqp,CCpCqrCCpqCpr,CCNpNqCqp,Cpp,CCpqCCqrCpr,CCNppp,CpCNpq -j -1 -p -2 -d\n"
" pmGenerator -c -s CCCCC0.1CN2N3.2.4CC4.0C3.0 -g 35 --plot -s -t -x 50 -y 100 -o data/478804cd4793bc7f87041d99326aff4595662146d8a68175dda22bed/plot_data_x50_y100.txt\n"
" pmGenerator -c -n -s CCCCCpqCNrNsrtCCtpCsp --search CpCqp,CCpCqrCCpqCpr,CCNpNqCqp -n\n"
" pmGenerator --variate 1 -s --extract -t 1000 -s -d\n"
" pmGenerator --variate 1 -s --extract -# 35 -d -c -d -e 0\n"
" pmGenerator -m 17 -s\n" << endl;
break;
default:
cout << "\n" << cmdInfo().at(task) << endl;
break;
}
return 0;
};
#if 0 // default command
if (argc <= 1) {
//for (unsigned i = 0; i < 26; i++) cout << ", { \"" << i << "\", \"" << string { (char) ('p' + i <= 'z' ? 'p' + i : 'a' + i - 'z' + 'p' - 1) } << "\" }" << flush; cout << endl; return 0;
//#DlProofEnumerator::sampleCombinations();
//#for (unsigned knownLimit = 1; knownLimit < 100; knownLimit++)
//# cout << knownLimit << ":" << DlProofEnumerator::proofLengthCombinationsD_allLengths(knownLimit, false).size() << endl;
//#return 0;
//#static vector<string> customCmd = FctHelper::stringSplit("pmGenerator -g 19 -g 21 -u -r data/pmproofs-old.txt data/pmproofs-reducer.txt -a SD data/pmproofs-reducer.txt data/pmproofs-old.txt data/pmproofs-result-all.txt -l -w", " ");
//#static vector<string> customCmd = FctHelper::stringSplit("pmGenerator -g 19 -g 21 -u -r data/pmproofs-old.txt data/pmproofs-reducer.txt -a SD data/pmproofs-reducer.txt data/pmproofs-old.txt data/pmproofs-result-styleAll-all.txt -s -l -w", " ");
//#static vector<string> customCmd = FctHelper::stringSplit("pmGenerator -g 19 -g 21 -u -r data/pmproofs-old.txt data/pmproofs-reducer.txt -a SD data/pmproofs-reducer.txt data/pmproofs-old.txt data/pmproofs-result-modifiedOnly.txt -w", " ");
//#static vector<string> customCmd = FctHelper::stringSplit("pmGenerator -g 19 -g 21 -u -r data/pmproofs-old.txt data/pmproofs-reducer.txt -a SD data/pmproofs-reducer.txt data/pmproofs-old.txt data/pmproofs-result-styleAll-modifiedOnly.txt -s -w", " ");
//#static vector<string> customCmd = FctHelper::stringSplit("pmGenerator -g 19 -g 21 -u -r data/pmproofs-old.txt data/pmproofs-reducer.txt -a SD data/pmproofs-reducer.txt data/pmproofs-old.txt data/pmproofs-result-styleAll-modifiedOnly-noWrap.txt -s", " ");
//static vector<string> customCmd = FctHelper::stringSplit("pmGenerator --plot -s -d --plot -s -t -x 50 -y 100 -o data/plot_data_x50_y100.txt", " ");
//static vector<string> customCmd = FctHelper::stringSplit("pmGenerator -r data/pmproofs-unified.txt data/pmproofs-reducer33.txt -d", " ");
//static vector<string> customCmd = FctHelper::stringSplit("pmGenerator -a SD data/pmproofs-reducer33.txt data/pmproofs-unified.txt data/pmproofs-unified33-modifiedOnly-noWrap.txt -s", " ");
//static vector<string> customCmd = FctHelper::stringSplit("pmGenerator -a SD data/pmproofs-reducer33.txt data/pmproofs-unified.txt data/pmproofs-unified33.txt -s -l -w -d", " ");
//static vector<string> customCmd = FctHelper::stringSplit("pmGenerator -g 35 -u", " ");
//static vector<string> customCmd = FctHelper::stringSplit("pmGenerator -m 17", " ");
// Redundancy check ; generates ./data/bf8f05b7537814a14fca0790dab97644033d9ca0ba5293063831124f/{!.def, dProofs-withConclusions/dProofs1.txt}, with "#removals;1:4" in !.def, and "4:C0C1.1" as only representative.
static vector<string> customCmd = FctHelper::stringSplit("pmGenerator -c -s CN0C1.1,C0CN1N1,C0CN1N1,C0C1.1,C0C1.1 --variate 1", " ");
argc = static_cast<int>(customCmd.size());
argv = new char*[customCmd.size()];
for (size_t i = 0; i < customCmd.size(); i++)
argv[i] = const_cast<char*>(customCmd[i].c_str());
}
#endif
if (argc <= 1)
return printUsage();
struct TaskInfo {
Task task;
map<string, string> str;
map<string, int64_t> num;
map<string, bool> bln;
TaskInfo(Task task, const map<string, string>& str, const map<string, int64_t>& num, const map<string, bool>& bln) :
task(task), str(str), num(num), bln(bln) {
}
};
vector<TaskInfo> tasks;
auto lastTask = [&]() -> Task { return tasks.empty() ? Task::Invalid : tasks.back().task; };
string mpiArg;
size_t mpiIgnoreCount = 0;
bool extractedEnv = false;
for (int i = 1; i < argc; i++) {
auto recent = [&](const string& s = "?") {
if (s == "c")
return Task::Customize;
else if (s == "g")
return Task::Generate;
else if (s == "r")
return Task::CreateReplacements;
else if (s == "a")
return Task::ApplyReplacements;
else if (s == "parse")
return Task::ParseAndPrintProofs;
else if (s == "search")
return Task::SearchProofFiles;
else if (s == "iterate")
return Task::IterateProofCandidates;
else if (s == "variate")
return Task::FileConversion;
else if (s == "plot")
return Task::ConclusionLengthPlot;
else if (s == "m")
return Task::MpiFilter;
else
return tasks.empty() ? Task::Invalid : tasks.back().task;
};
if (argv[i][0] != '-' || argv[i][1] == '\0' || (argv[i][2] != '\0' && argv[i][1] != '-') || (argv[i][1] == '-' && argv[i][2] == '\0'))
return printUsage("Invalid argument \"" + string { argv[i] } + "\".", recent());
const char c = argv[i][1];
switch (c) {
// Commands
case 'c': // -c [-i <file>] [-s <string>] [-n] [-N <limit or -1>] [-l] [-e <id>] [-d]
if (!mpiArg.empty())
return printUsage("Invalid argument \"-" + string { c } + "\": Cannot configure after \"" + mpiArg + "\".");
tasks.emplace_back(Task::Customize, map<string, string> { { "axiomString", "C0C1.0,CC0C1.2CC0.1C0.2,CCN0N1C1.0" }, { "axiomFilePath", "" }, { "extractedSystemId", "" } }, map<string, int64_t> { { "necessitationLimit", 0 } }, map<string, bool> { { "useInputFile", false }, { "normalPolishNotation", false }, { "speedupN", true }, { "extractedSystem", false }, { "defaultSystem", false } });
mpiIgnoreCount++;
extractedEnv = false;
break;
case 'g': // -g <limit or -1> [-u] [-q <limit>] [-l <limit or -1>] [-k <limit or -1>] [-b] [-f] [-s]
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
tasks.emplace_back(Task::Generate, map<string, string> { }, map<string, int64_t> { { "limit", stoi(argv[++i]) }, { "candidateQueueCapacities", 0 }, { "maxSymbolicConclusionLength", -1 }, { "maxSymbolicConsequentLength", -1 } }, map<string, bool> { { "redundantSchemaRemoval", true }, { "withConclusions", true }, { "useConclusionStrings", true }, { "useConclusionTrees", false }, { "whether -q was called", false } });
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
break;
case 'r': // -r <D-proof database> <output file> [-l <path>] [-i <prefix>] [-s] [-d]
if (i + 2 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
tasks.emplace_back(Task::CreateReplacements, map<string, string> { { "dProofDB", argv[i + 1] }, { "outputFile", argv[i + 2] }, { "dataLocation", "data" }, { "inputFilePrefix", "dProofs-withConclusions/dProofs" } }, map<string, int64_t> { }, map<string, bool> { { "withConclusions", true }, { "debug", false }, { "whether -i was called", false } });
i += 2;
break;
case 'a': // -a <initials> <replacements file> <D-proof database> <output file> [-s] [-l] [-w] [-d]
if (i + 4 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
tasks.emplace_back(Task::ApplyReplacements, map<string, string> { { "initials", argv[i + 1] }, { "replacementsFile", argv[i + 2] }, { "dProofDB", argv[i + 3] }, { "outputFile", argv[i + 4] } }, map<string, int64_t> { }, map<string, bool> { { "styleAll", false }, { "listAll", false }, { "wrap", false }, { "debug", false } });
i += 4;
break;
case 'm': // -m <limit> [-s]
if (tasks.size() > mpiIgnoreCount)
return printUsage("Invalid argument \"-" + string { c } + "\": Can only be combined with preceding configuring commands.");
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
else {
string param = string(argv[++i]);
unsigned value;
from_chars_result result = FctHelper::toUInt(param, value);
if (result.ec != errc())
return printUsage("Invalid parameter \"" + param + "\" for \"-" + string { c } + "\".", recent(string { c }));
tasks.emplace_back(Task::MpiFilter, map<string, string> { }, map<string, int64_t> { { "wordLengthLimit", value } }, map<string, bool> { { "smoothProgress", true } });
mpiArg = "-m";
}
break;
case '-': { // "--<command>"
string command { argv[i] + 2 };
if (command == "parse") { // --parse <string> [-n] [-u] [-j <limit or -1>] [-b] [-s] [-e] [-f] [-o <output file>] [-d]
if (i + 1 >= argc)
return printUsage("Missing parameter for \"--" + command + "\".", recent(command));
tasks.emplace_back(Task::ParseAndPrintProofs, map<string, string> { { "string", argv[++i] }, { "outputFile", "" } }, map<string, int64_t> { { "minUseAmountToCreateHelperProof", 2 } }, map<string, bool> { { "useInputFile", false }, { "useOutputFile", false }, { "normalPolishNotation", false }, { "unicodeInfixNotation", false }, { "conclusionsOnly", false }, { "summaryMode", false }, { "abstractProofStrings", true }, { "debug", false }, { "whether -j was called", false } });
} else if (command == "transform") { // --transform <string> [-s <string>] [-j <limit or -1>] [-p <limit or -1>] [-n] [-u] [-t <string>] [-e] [-i <limit or -1>] [-l <limit or -1>] [-b] [-w] [-z] [-y] [-f] [-o <output file>] [-d]
if (i + 1 >= argc)
return printUsage("Missing parameter for \"--" + command + "\".", recent(command));
tasks.emplace_back(Task::TransformProofSummary, map<string, string> { { "string", argv[++i] }, { "conclusionsWithHelperProofs", "" }, { "filterForTheorems", "" }, { "outputFile", "" } }, map<string, int64_t> { { "minUseAmountToCreateHelperProof", 2 }, { "maxLengthToKeepProof", -1 }, { "storeIntermediateUnfoldingLimit", -1 }, { "maxLengthToComputeDProof", 134217728 } }, map<string, bool> { { "useInputFile", false }, { "useOutputFile", false }, { "normalPolishNotation", false }, { "printInfixUnicode", false }, { "abstractProofStrings", true }, { "removeDuplicateConclusions", false }, { "compress", false }, { "noInputConclusions", false }, { "debug", false }, { "compress_concurrent", true }, { "whether -s was called", false }, { "whether -t was called", false } });
} else if (command == "unfold") { // --unfold <string> [-n] [-t <string>] [-i <limit or -1>] [-l <limit or -1>] [-w] [-v] [-f] [-o <output file>] [-d]
if (i + 1 >= argc)
return printUsage("Missing parameter for \"--" + command + "\".", recent(command));
tasks.emplace_back(Task::UnfoldProofSummary, map<string, string> { { "string", argv[++i] }, { "filterForTheorems", "" }, { "outputFile", "" } }, map<string, int64_t> { { "storeIntermediateUnfoldingLimit", -1 }, { "maxLengthToComputeDProof", 134217728 } }, map<string, bool> { { "useInputFile", false }, { "useOutputFile", false }, { "normalPolishNotation", false }, { "wrap", false }, { "noInputConclusions", false }, { "debug", false }, { "whether -t was called", false } });
} else if (command == "search") { // --search <string> [-n] [-s] [-w] [-t] [-p] [-f] [-d]
if (i + 1 >= argc)
return printUsage("Missing parameter for \"--" + command + "\".", recent(command));
tasks.emplace_back(Task::SearchProofFiles, map<string, string> { { "string", argv[++i] } }, map<string, int64_t> { }, map<string, bool> { { "useInputFile", false }, { "normalPolishNotation", false }, { "searchProofs", false }, { "schemaSearch", false }, { "multiSchemaSearch", false }, { "abstractSearch", false }, { "debug", false } });
} else if (command == "extract") // --extract [-t <limit or -1>] [-o <output file>] [-s] [-z] [-# <amount up to 35>] [-h <string>] [-l <limit or -1>] [-k <limit or -1>] [-f] [-d]
tasks.emplace_back(Task::ExtractFromProofFiles, map<string, string> { { "proofs", "" }, { "outputFile", "" } }, map<string, int64_t> { { "extractToFileAmount", 0 }, { "extractToSystemAmount", 0 }, { "maxConclusionLength", 0 }, { "maxConsequentLength", 0 } }, map<string, bool> { { "useInputFile", false }, { "useOutputFile", false }, { "allowRedundantSchemaRemoval", false }, { "forceRedundantSchemaRemoval", false }, { "debug", false }, { "whether -t was called", false }, { "whether -# was called", false }, { "whether -h was called", false }, { "whether -l was called", false }, { "whether -k was called", false } });
else if (command == "assess") // --assess [-u] [-s] [-d]
tasks.emplace_back(Task::AssessGeneration, map<string, string> { }, map<string, int64_t> { }, map<string, bool> { { "redundantSchemaRemoval", true }, { "withConclusions", true }, { "debug", false } });
else if (command == "iterate") // --iterate [-u] [-s]
tasks.emplace_back(Task::IterateProofCandidates, map<string, string> { }, map<string, int64_t> { }, map<string, bool> { { "redundantSchemaRemoval", true }, { "withConclusions", true } });
else if (command == "variate") { // --variate ( 0 | 1 ) [-l <path>] [-i <prefix>] [-o <prefix>] [-s] [-d]
if (i + 1 >= argc)
return printUsage("Missing parameter for \"--" + command + "\".", recent(command));
else {
string param = string(argv[++i]);
if (param != "0" && param != "1")
return printUsage("Invalid parameter \"" + param + "\" for \"--" + command + "\".", recent(command));
bool with = param == "1";
tasks.emplace_back(Task::FileConversion, map<string, string> { { "dataLocation", "data" }, { "inputFilePrefix", with ? "dProofs-withoutConclusions/dProofs" : "dProofs-withConclusions/dProofs" }, { "outputFilePrefix", with ? "dProofs-withConclusions/dProofs" : "dProofs-withoutConclusions/dProofs" } }, map<string, int64_t> { }, map<string, bool> { { "memoryOnly", false }, { "debug", false }, { "with", with } });
}
break;
} else if (command == "plot") // --plot [-l <path>] [-i <prefix>] [-s] [-t] [-x <limit or -1>] [-y <limit or -1>] [-o <output file>] [-d]
tasks.emplace_back(Task::ConclusionLengthPlot, map<string, string> { { "dataLocation", "data" }, { "inputFilePrefix", "dProofs-withConclusions/dProofs" }, { "mout", "" } }, map<string, int64_t> { { "cutX", -1 }, { "cutY", -1 } }, map<string, bool> { { "measureSymbolicLength", false }, { "table", false }, { "includeUnfiltered", false }, { "debug", false } });
else
return printUsage("Invalid argument \"--" + command + "\".", recent(command));
break;
}
// Arguments
case '#':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::ExtractFromProofFiles: // --extract -# <amount up to 35> (initialize proof system at ./data/[<hash>/]/extraction-<id>/ with the given amount [...])
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
unsigned num = stoi(argv[++i]);
if (num > 35)
throw "";
tasks.back().num["extractToSystemAmount"] = num;
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
tasks.back().bln["whether -# was called"] = true;
break;
}
break;
case 'b':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::Generate: // -g -b (brief parsing)
tasks.back().bln["useConclusionTrees"] = true;
break;
case Task::ParseAndPrintProofs: // --parse -b (only print conclusions of the given proofs)
tasks.back().bln["conclusionsOnly"] = true;
if (!tasks.back().bln["whether -j was called"])
tasks.back().num["minUseAmountToCreateHelperProof"] = 1;
break;
case Task::TransformProofSummary: // --transform -b (duplicate conclusion removal)
tasks.back().bln["removeDuplicateConclusions"] = true;
break;
}
break;
case 'd':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::Customize: // -c -d (default system)
tasks.back().bln["defaultSystem"] = true;
break;
case Task::CreateReplacements: // -r -d (print debug information)
case Task::ApplyReplacements: // -a -d (print debug information)
case Task::ParseAndPrintProofs: // --parse -d (print debug information)
case Task::TransformProofSummary: // --transform -d (print debug information)
case Task::UnfoldProofSummary: // --unfold -d (print debug information)
case Task::SearchProofFiles: // --search -d (print debug information)
case Task::ExtractFromProofFiles: // --extract -d (print debug information)
case Task::AssessGeneration: // --assess -d (print debug information)
case Task::FileConversion: // --variate -d (print debug information)
case Task::ConclusionLengthPlot: // --plot -d (print debug information)
tasks.back().bln["debug"] = true;
break;
}
break;
case 'e':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::Customize: // -c -e <id> (specify extracted system with the given identifie)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
tasks.back().str["extractedSystemId"] = argv[++i];
tasks.back().bln["extractedSystem"] = true;
extractedEnv = true;
break;
case Task::ParseAndPrintProofs: // --parse -e (keep expanded proof strings)
case Task::TransformProofSummary: // --transform -e (keep expanded proof strings)
tasks.back().bln["abstractProofStrings"] = false;
break;
}
break;
case 'f':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::Generate: // -g -f (full parsing)
tasks.back().bln["useConclusionStrings"] = false;
break;
case Task::ParseAndPrintProofs: // --parse -f (proofs are given by input file path)
case Task::TransformProofSummary: // --transform -f (proof summary is given by input file path)
case Task::UnfoldProofSummary: // --unfold -f (proof summary is given by input file path)
case Task::SearchProofFiles: // --search -f (search terms are given by input file path)
case Task::ExtractFromProofFiles: // --extract -f (proofs for '-h' are given by input file path)
tasks.back().bln["useInputFile"] = true;
break;
}
break;
case 'h':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::ExtractFromProofFiles: // --extract -h <string> (similar to '-#' ; hand-pick conclusions with a comma-separated string of proofs)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
tasks.back().str["proofs"] = argv[++i];
tasks.back().bln["whether -h was called"] = true;
break;
}
break;
case 'i':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::Customize: // -c -i <file> (specify axioms by input file path)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
tasks.back().str["axiomFilePath"] = argv[++i];
tasks.back().bln["useInputFile"] = true;
break;
case Task::CreateReplacements: // -r -i <prefix> (customize input file path prefix in data location)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
tasks.back().str["inputFilePrefix"] = argv[++i];
tasks.back().bln["whether -i was called"] = true;
break;
case Task::TransformProofSummary: // --transform -i <limit or -1> (decrease memory requirements but increase time consumption by not storing intermediate unfoldings that exceed a certain length)
case Task::UnfoldProofSummary: // --unfold -i <limit or -1> (decrease memory requirements but increase time consumption by not storing intermediate unfoldings that exceed a certain length)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
tasks.back().num["storeIntermediateUnfoldingLimit"] = stoi(argv[++i]);
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
break;
case Task::FileConversion: // --variate -i <prefix> (customize input file path prefix in data location)
case Task::ConclusionLengthPlot: // --plot -i <prefix> (customize input file path prefix in data location)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
tasks.back().str["inputFilePrefix"] = argv[++i];
break;
}
break;
case 'j':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::ParseAndPrintProofs: // --parse -j <limit or -1> (join common subproofs together when they are used at least a given amount of times)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
tasks.back().num["minUseAmountToCreateHelperProof"] = stoi(argv[++i]);
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
tasks.back().bln["whether -j was called"] = true;
break;
case Task::TransformProofSummary: // --transform -j <limit or -1> (join common subproofs together when they are used at least a given amount of times)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
tasks.back().num["minUseAmountToCreateHelperProof"] = stoi(argv[++i]);
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
break;
}
break;
case 'k':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::Generate: // -g -k <limit or -1> (similar to '-l' ; limit symbolic length of consequents in generated conclusions)
if (!extractedEnv)
return printUsage("Invalid argument \"-" + string { c } + "\" for \"-g\": Specific filters can only be used in extracted environments. [Hint: '--extract -h .' extracts a system with all axioms unmodified that can be specified with '-c <parent system> -e <id>'.]", recent(string { c }));
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
tasks.back().num["maxSymbolicConsequentLength"] = stoi(argv[++i]);
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
break;
case Task::ExtractFromProofFiles: // --extract -k <limit or -1> (similar to '-l' ; copy proofs with conclusions that have consequents or are non-conditionals of symbolic lengths of at most the given number)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
tasks.back().num["maxConsequentLength"] = stoi(argv[++i]);
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
tasks.back().bln["whether -k was called"] = true;
break;
}
break;
case 'l':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::Generate: // -g -l <limit or -1> (limit symbolic length of generated conclusions to at most the given number)
if (!extractedEnv)
return printUsage("Invalid argument \"-" + string { c } + "\" for \"-g\": Specific filters can only be used in extracted environments. [Hint: '--extract -h .' extracts a system with all axioms unmodified that can be specified with '-c <parent system> -e <id>'.]", recent(string { c }));
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
tasks.back().num["maxSymbolicConclusionLength"] = stoi(argv[++i]);
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
break;
case Task::Customize: // -c -l (disable lazy N-rule parsing)
tasks.back().bln["speedupN"] = false;
break;
case Task::CreateReplacements: // -r -l <path> (customize data location path)
case Task::FileConversion: // --variate -l <path> (customize data location path)
case Task::ConclusionLengthPlot: // --plot -l <path> (customize data location path)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
tasks.back().str["dataLocation"] = argv[++i];
break;
case Task::ApplyReplacements: // -a -l (list all proofs)
tasks.back().bln["listAll"] = true;
break;
case Task::TransformProofSummary: // --transform -l <limit or -1> (abort computation when combined requested proof sequences exceed the given limit in bytes)
case Task::UnfoldProofSummary: // --unfold -l <limit or -1> (abort computation when combined requested proof sequences exceed the given limit in bytes)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
tasks.back().num["maxLengthToComputeDProof"] = stoi(argv[++i]);
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
break;
case Task::ExtractFromProofFiles: // --extract -l <limit or -1> (similar to '-#' ; copy proofs with conclusions that have symbolic lengths of at most the given number)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
tasks.back().num["maxConclusionLength"] = stoi(argv[++i]);
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
tasks.back().bln["whether -l was called"] = true;
break;
}
break;
case 'n':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::Customize: // -c -n (specify formulas in normal Polish notation)
case Task::ParseAndPrintProofs: // --parse -n (print formulas in normal Polish notation)
case Task::TransformProofSummary: // --transform -n (specify and print formulas in normal Polish notation)
case Task::UnfoldProofSummary: // --unfold -n (specify formulas in normal Polish notation)
case Task::SearchProofFiles: // --search -n (specify formulas in normal Polish notation)
tasks.back().bln["normalPolishNotation"] = true;
break;
}
break;
case 'N':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::Customize: // -c -N <limit or -1> (enable necessitation rule)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
tasks.back().num["necessitationLimit"] = stoi(argv[++i]);
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
break;
}
break;
case 'o':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::ParseAndPrintProofs: // --parse -o <output file> (redirect the result's output to the specified file)
case Task::TransformProofSummary: // --transform -o <output file> (redirect the result's output to the specified file)
case Task::UnfoldProofSummary: // --unfold -o <output file> (redirect the result's output to the specified file)
case Task::ExtractFromProofFiles: // --extract -o <output file> (specify output file path for '-t')
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
tasks.back().str["outputFile"] = argv[++i];
tasks.back().bln["useOutputFile"] = true;
break;
case Task::FileConversion: // --variate -o <prefix> (customize output file path prefix in data location)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
tasks.back().str["outputFilePrefix"] = argv[++i];
break;
case Task::ConclusionLengthPlot: // --plot -o <output file> (print to given output file)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
tasks.back().str["mout"] = argv[++i];
break;
}
break;
case 'p':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::TransformProofSummary: // --transform -p <limit or -1> (only keep subproofs with primitive lengths not exceeding the given limit)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
tasks.back().num["maxLengthToKeepProof"] = stoi(argv[++i]);
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
break;
case Task::SearchProofFiles: // --search -p (search proofs)
tasks.back().bln["searchProofs"] = true;
break;
}
break;
case 'q':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::Generate: // -g -q <limit> (limit number of proof candidate strings queued per worker thread)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
tasks.back().num["candidateQueueCapacities"] = stoi(argv[++i]);
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
tasks.back().bln["whether -q was called"] = true;
break;
}
break;
case 's':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::Customize: // -c -s <string> (specify axioms by comma-separated string)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
tasks.back().str["axiomString"] = argv[++i];
break;
case Task::Generate: // -g -s (proof files without conclusions)
case Task::AssessGeneration: // --assess -s (use proof files without conclusions)
case Task::IterateProofCandidates: // --iterate -s (use proof files without conclusions)
tasks.back().bln["withConclusions"] = false;
break;
case Task::CreateReplacements: // -r -s (proof files without conclusions)
tasks.back().bln["withConclusions"] = false;
if (!tasks.back().bln["whether -i was called"])
tasks.back().str["inputFilePrefix"] = "dProofs-withoutConclusions/dProofs";
break;
case Task::ApplyReplacements: // -a -s (style all proofs)
tasks.back().bln["styleAll"] = true;
break;
case Task::ParseAndPrintProofs: // --parse -s (only print summary with conclusions and abstract condensed detachment proofs)
tasks.back().bln["summaryMode"] = true;
break;
case Task::TransformProofSummary: // --transform -s <string> (list a subproof with its conclusion if it occurs in the given comma-separated list of conclusions)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
tasks.back().str["conclusionsWithHelperProofs"] = argv[++i];
tasks.back().bln["whether -s was called"] = true;
break;
case Task::SearchProofFiles: // --search -s (search for schemas of the given formulas)
tasks.back().bln["schemaSearch"] = true;
break;
case Task::ExtractFromProofFiles: // --extract -s (redundant schema removal for '-t')
tasks.back().bln["allowRedundantSchemaRemoval"] = true;
break;
case Task::FileConversion: // --variate -s (only use data stored in-memory)
tasks.back().bln["memoryOnly"] = true;
break;
case Task::ConclusionLengthPlot: // --plot -s (measure symbolic length)
tasks.back().bln["measureSymbolicLength"] = true;
break;
case Task::MpiFilter: // -m -s (disable smooth progress mode)
tasks.back().bln["smoothProgress"] = false;
break;
}
break;
case 't':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::TransformProofSummary: // --transform -t <string> (only transform proofs of specified theorems)
case Task::UnfoldProofSummary: // --unfold -t <string> (obtain proofs of specified theorems)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
tasks.back().str["filterForTheorems"] = argv[++i];
tasks.back().bln["whether -t was called"] = true;
break;
case Task::SearchProofFiles: // --search -t (search for formulas of the given schemas)
tasks.back().bln["abstractSearch"] = true;
break;
case Task::ExtractFromProofFiles: // --extract -t <limit or -1> (compose file with up to the given amount of smallest conclusions that occur in proof files)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
tasks.back().num["extractToFileAmount"] = stoi(argv[++i]);
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
tasks.back().bln["whether -t was called"] = true;
break;
case Task::ConclusionLengthPlot: // --plot -t (table arrangement)
tasks.back().bln["table"] = true;
break;
}
break;
case 'u':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::Generate: // -g -u (unfiltered)
case Task::AssessGeneration: // --assess -u (use unfiltered proof files)
case Task::IterateProofCandidates: // --iterate -u (use unfiltered proof files)
tasks.back().bln["redundantSchemaRemoval"] = false;
break;
case Task::ParseAndPrintProofs: // --parse -u (print formulas in infix notation with operators as Unicode characters)
tasks.back().bln["unicodeInfixNotation"] = true;
break;
case Task::TransformProofSummary: // --transform -u (print formulas in infix notation with operators as Unicode characters)
tasks.back().bln["printInfixUnicode"] = true;
break;
case Task::ConclusionLengthPlot: // --plot -u (include unfiltered proof files)
tasks.back().bln["includeUnfiltered"] = true;
break;
}
break;
case 'v':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::UnfoldProofSummary: // --unfold -v (read input without conclusions given)
tasks.back().bln["noInputConclusions"] = true;
break;
}
break;
case 'w':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::ApplyReplacements: // -a -w (wrap results)
case Task::UnfoldProofSummary: // --unfold -w (wrap results)
tasks.back().bln["wrap"] = true;
break;
case Task::TransformProofSummary: // --transform -w (read input without conclusions given)
tasks.back().bln["noInputConclusions"] = true;
break;
case Task::SearchProofFiles: // --search -w (search whole collections of schemas)
tasks.back().bln["multiSchemaSearch"] = true;
break;
}
break;
case 'x':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::ConclusionLengthPlot: // --plot -x <limit or -1> (upper horizontal limit)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
tasks.back().num["cutX"] = stoll(argv[++i]);
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
break;
}
break;
case 'y':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::TransformProofSummary: // --transform -y (disable multi-threaded D-rule replacement search in case proof compression is performed)
tasks.back().bln["compress_concurrent"] = false;
break;
case Task::ConclusionLengthPlot: // --plot -y <limit or -1> (upper vertical limit)
if (i + 1 >= argc)
return printUsage("Missing parameter for \"-" + string { c } + "\".", recent(string { c }));
try {
tasks.back().num["cutY"] = stoll(argv[++i]);
} catch (...) {
return printUsage("Invalid parameter \"" + string(argv[i]) + "\" for \"-" + string { c } + "\".", recent(string { c }));
}
break;
}
break;
case 'z':
switch (lastTask()) {
default:
return printUsage("Invalid argument \"-" + string { c } + "\".", recent());
case Task::TransformProofSummary: // --transform -z (proof compression)
tasks.back().bln["compress"] = true;
break;
case Task::ExtractFromProofFiles: // --extract -z (force redundant schema removal for '-t')
tasks.back().bln["forceRedundantSchemaRemoval"] = true;
}
break;
default:
return printUsage("Invalid argument \"" + string { argv[i] } + "\".", recent());
}
}
int mpi_size;
int mpi_rank;
if (!mpiArg.empty()) {
if (tasks.size() > 1 + mpiIgnoreCount)
return printUsage("Invalid argument \"" + mpiArg + "\": Can only be combined with preceding configuring commands.");
// Initialize the MPI library.
int provided;
MPI_Init_thread(&argc, &argv, MPI_THREAD_FUNNELED, &provided);
if (provided < MPI_THREAD_FUNNELED) {
cerr << "Missing MPI support. (provided: " << provided << ", requested: " << MPI_THREAD_FUNNELED << ") Aborting." << endl;
MPI_Finalize(); // Finalize the MPI library.
return 0;
}
// Obtain the process ID and the number of processes
MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
}
auto bstr = [](bool b) { return b ? "true" : "false"; };
try {
if (mpiArg.empty() || mpi_rank == 0) {
stringstream ss;
size_t index = 0;
for (TaskInfo& t : tasks)
switch (t.task) {
default:
throw logic_error("Invalid task.");
case Task::Customize: // -c
ss << ++index << ". resetRepresentativesFor(" << (t.bln["defaultSystem"] ? "null" : "\"" + (t.bln["useInputFile"] ? t.str["axiomFilePath"] : t.str["axiomString"]) + "\"") << ", " << bstr(t.bln["normalPolishNotation"]) << ", " << (unsigned) t.num["necessitationLimit"] << ", " << bstr(t.bln["speedupN"]) << (t.bln["extractedSystem"] ? ", \"" + t.str["extractedSystemId"] + "\"" : "") << ")\n";
break;
case Task::Generate: { // -g
unsigned optParams = t.bln["useConclusionTrees"] ? 5 : t.bln["useConclusionStrings"] ? 4 : t.num["maxSymbolicConsequentLength"] != -1 ? 3 : t.num["maxSymbolicConclusionLength"] != -1 ? 2 : t.bln["whether -q was called"] ? 1 : 0;
ss << ++index << ". generateDProofRepresentativeFiles(" << (unsigned) t.num["limit"] << ", " << bstr(t.bln["redundantSchemaRemoval"]) << ", " << bstr(t.bln["withConclusions"]) << (t.bln["whether -q was called"] ? string(", ") + to_string(size_t(t.num["candidateQueueCapacities"])) : optParams > 1 ? ", null" : "") << (t.num["maxSymbolicConclusionLength"] != -1 ? string(", ") + to_string(size_t(t.num["maxSymbolicConclusionLength"])) : optParams > 2 ? ", -1" : "") << (t.num["maxSymbolicConsequentLength"] != -1 ? string(", ") + to_string(size_t(t.num["maxSymbolicConsequentLength"])) : optParams > 3 ? ", -1" : "") << (t.bln["useConclusionStrings"] || optParams > 4 ? string(", ") + bstr(t.bln["useConclusionStrings"]) : "") << (t.bln["useConclusionTrees"] || optParams > 5 ? string(", ") + bstr(t.bln["useConclusionTrees"]) : "") << ")\n";
break;
}
case Task::CreateReplacements: // -r
ss << ++index << ". createReplacementsFile(\"" << t.str["dProofDB"] << "\", \"" << t.str["outputFile"] << "\", \"" << t.str["dataLocation"] << "\", \"" << t.str["inputFilePrefix"] << "\", " << bstr(t.bln["withConclusions"]) << ", " << bstr(t.bln["debug"]) << ")\n";
break;
case Task::ApplyReplacements: // -a
ss << ++index << ". applyReplacements(\"" << t.str["initials"] << "\", \"" << t.str["replacementsFile"] << "\", \"" << t.str["dProofDB"] << "\", \"" << t.str["outputFile"] << "\", " << bstr(t.bln["styleAll"]) << ", " << bstr(t.bln["listAll"]) << ", " << bstr(t.bln["wrap"]) << ", " << bstr(t.bln["debug"]) << ")\n";
break;
case Task::ParseAndPrintProofs: // --parse
ss << ++index << ". printProofs(" << (t.bln["useInputFile"] ? "{ }" : "\"" + t.str["string"] + "\"") << ", " << (t.bln["normalPolishNotation"] ? "DlFormulaStyle::PolishStandard" : t.bln["unicodeInfixNotation"] ? "DlFormulaStyle::InfixUnicode" : "DlFormulaStyle::PolishNumeric") << ", " << bstr(t.bln["conclusionsOnly"]) << ", " << bstr(t.bln["summaryMode"]) << ", " << (unsigned) t.num["minUseAmountToCreateHelperProof"] << ", " << bstr(t.bln["abstractProofStrings"]) << ", " << (t.bln["useInputFile"] ? "\"" + t.str["string"] + "\"" : "null") << ", " << (t.bln["useOutputFile"] ? "\"" + t.str["outputFile"] + "\"" : "null") << ", " << bstr(t.bln["debug"]) << ")\n";
break;
case Task::TransformProofSummary: // --transform
ss << ++index << ". recombineProofSummary(\"" << t.str["string"] << "\", " << bstr(t.bln["useInputFile"]) << ", " << (t.bln["whether -s was called"] ? "\"" + t.str["conclusionsWithHelperProofs"] + "\"" : "null") << ", " << (unsigned) t.num["minUseAmountToCreateHelperProof"] << ", " << (size_t) t.num["maxLengthToKeepProof"] << ", " << bstr(t.bln["normalPolishNotation"]) << ", " << bstr(t.bln["printInfixUnicode"]) << ", " << (t.bln["whether -t was called"] ? "\"" + t.str["filterForTheorems"] + "\"" : "null") << ", " << bstr(t.bln["abstractProofStrings"]) << ", " << (size_t) t.num["storeIntermediateUnfoldingLimit"] << ", " << (size_t) t.num["maxLengthToComputeDProof"] << ", " << bstr(t.bln["removeDuplicateConclusions"]) << ", " << bstr(t.bln["compress"]) << ", " << bstr(t.bln["noInputConclusions"]) << ", " << (t.bln["useOutputFile"] ? "\"" + t.str["outputFile"] + "\"" : "null") << ", " << bstr(t.bln["debug"]) << ", " << bstr(t.bln["compress_concurrent"]) << ")\n";
break;
case Task::UnfoldProofSummary: // --unfold
ss << ++index << ". unfoldProofSummary(\"" << t.str["string"] << "\", " << bstr(t.bln["useInputFile"]) << ", " << bstr(t.bln["normalPolishNotation"]) << ", " << (t.bln["whether -t was called"] ? "\"" + t.str["filterForTheorems"] + "\"" : "null") << ", " << (size_t) t.num["storeIntermediateUnfoldingLimit"] << ", " << (size_t) t.num["maxLengthToComputeDProof"] << ", " << bstr(t.bln["wrap"]) << ", " << bstr(t.bln["noInputConclusions"]) << ", " << (t.bln["useOutputFile"] ? "\"" + t.str["outputFile"] + "\"" : "null") << ", " << bstr(t.bln["debug"]) << ")\n";
break;
case Task::SearchProofFiles: // --search
ss << ++index << ". searchProofFiles(" << (t.bln["useInputFile"] ? "{ }" : "\"" + t.str["string"] + "\"") << ", " << bstr(t.bln["normalPolishNotation"]) << ", " << bstr(t.bln["searchProofs"]) << ", " << (t.bln["multiSchemaSearch"] ? 2 : t.bln["schemaSearch"] ? 1 : t.bln["abstractSearch"] ? 3 : 0) << ", " << (t.bln["useInputFile"] ? "\"" + t.str["string"] + "\"" : "null") << ", " << bstr(t.bln["debug"]) << ")\n";
break;
case Task::ExtractFromProofFiles: // --extract
if (t.bln["whether -t was called"])
ss << ++index << ". extractConclusions(ExtractionMethod::TopListFile, " << (unsigned) t.num["extractToFileAmount"] << ", " << (t.bln["useOutputFile"] ? "\"" + t.str["outputFile"] + "\"" : "null") << ", " << bstr(t.bln["allowRedundantSchemaRemoval"]) << ", " << bstr(t.bln["forceRedundantSchemaRemoval"]) << ", 0, 0, " << bstr(t.bln["debug"]) << ")\n";
if (t.bln["whether -# was called"])
ss << ++index << ". extractConclusions(ExtractionMethod::ProofSystemFromTopList, " << (unsigned) t.num["extractToSystemAmount"] << ", null, true, false, 0, 0, " << bstr(t.bln["debug"]) << ")\n";
if (t.bln["whether -h was called"])
ss << ++index << ". extractConclusions(" << (t.bln["useInputFile"] ? "ExtractionMethod::ProofSystemFromFile" : "ExtractionMethod::ProofSystemFromString") << ", 0, \"" << t.str["proofs"] << "\", true, false, 0, 0, " << bstr(t.bln["debug"]) << ")\n";
if (t.bln["whether -l was called"] || t.bln["whether -k was called"])
ss << ++index << ". extractConclusions(ExtractionMethod::CopyWithLimitedConclusions" << ", 0, null, true, false, " << (t.bln["whether -l was called"] ? to_string((size_t) t.num["maxConclusionLength"]) : "-1") << ", " << (t.bln["whether -k was called"] ? to_string((size_t) t.num["maxConsequentLength"]) : "-1") << ", " << bstr(t.bln["debug"]) << ")\n";
break;
case Task::AssessGeneration: // --assess
ss << ++index << ". printGenerationExpenditures(" << bstr(t.bln["redundantSchemaRemoval"]) << ", " << bstr(t.bln["withConclusions"]) << ", " << bstr(t.bln["debug"]) << ")\n";
break;
case Task::IterateProofCandidates: // --iterate
ss << ++index << ". countNextIterationAmount(" << bstr(t.bln["redundantSchemaRemoval"]) << ", " << bstr(t.bln["withConclusions"]) << ")\n";
break;
case Task::FileConversion: // --variate
if (t.bln["with"])
ss << ++index << ". createGeneratorFilesWithConclusions(\"" << t.str["dataLocation"] << "\", \"" << t.str["inputFilePrefix"] << "\", \"" << t.str["outputFilePrefix"] << "\", " << bstr(t.bln["memoryOnly"]) << ", " << bstr(t.bln["debug"]) << ")\n";
else