33#include <boost/program_options.hpp>
35#include "connect++-version.hpp"
37#include "StackProver.hpp"
38#include "Schedule.hpp"
39#include "ProofChecker.hpp"
45namespace fs = std::filesystem;
46namespace chrono = std::chrono;
47namespace po = boost::program_options;
49using namespace verbose_print;
50using namespace boost::spirit;
56void memory_allocation_failed() {
57 cout << endl <<
"% SZS status MemoryOut for "
58 << params::problem_name
59 <<
" : unable to allocate memory." << endl;
66void SIGINT_handler(
int p) {
67 cout << endl <<
"% SZS status Error for "
68 << params::problem_name
69 <<
" : terminated by SIGINT." << endl;
72void SIGXCPU_handler(
int p) {
73 cout << endl <<
"% SZS status Timeout for "
74 << params::problem_name
75 <<
" : terminated by SIGXCPU." << endl;
78void SIGALRM_handler(
int p) {
79 cout << endl <<
"% SZS status Timeout for "
80 << params::problem_name
81 <<
" : terminated by SIGALRM." << endl;
85int main(
int argc,
char** argv) {
89 chrono::steady_clock::time_point startTime;
90 startTime = chrono::steady_clock::now();
94 std::signal(SIGINT, SIGINT_handler);
95 std::signal(SIGXCPU, SIGXCPU_handler);
96 std::signal(SIGALRM, SIGALRM_handler);
102 char* tptp_env = getenv(
"TPTP");
103 if (tptp_env !=
nullptr) {
104 params::tptp_path = fs::path(tptp_env);
106 char* pwd_env = getenv(
"PWD");
107 if (pwd_env !=
nullptr) {
108 params::pwd_path = fs::path(pwd_env);
110 char* path_env = getenv(
"CONNECTPP_PATH");
111 if (path_env !=
nullptr) {
112 params::connectpp_path = fs::path(path_env);
115 params::connectpp_path = params::pwd_path;
121 po::options_description main_options(
"Basic options");
122 main_options.add_options()
124 "Show this message.")
126 "Show version number.")
127 (
"input,i", po::value<string>(),
129 (
"output,o", po::value<string>()->implicit_value(
string(
"default")),
130 "Write a short output summary (file, status, outcome, time etc) to the specified file. Default value: \"./output_summary.txt\".")
132 "Don't add equality axioms. (For example, if they were added elsewhere.) NOTE: also inhibits adding of distinct object axioms.")
134 "Place equality axioms at the end of the matrix, not the beginning")
135 (
"all-distinct-objects",
136 "By default Connect++ follows the TPTP convention of considering \"foobar\" to be a distinct object. This option makes *all* constants distinct.")
137 (
"no-distinct-objects",
138 "By default Connect++ follows the TPTP convention of considering \"foobar\" to be a distinct object. This option disables that behaviour, so constants can be equal to others.")
139 (
"timeout,t", po::value<int>(),
140 "Timeout in seconds. (Default UINT32_MAX).")
141 (
"show-default-schedule",
142 "Display the built-in default schedule and halt.")
143 (
"schedule,s", po::value<string>(),
144 "Instead of running with fixed parameters, use a schedule from the specified file. Use value \"default\" for the default schedule. If no --timeout is specified use 600s.")
145 (
"random-seed", po::value<int>(),
146 "Specify the (non-negative, integer) seed to use for random number generation. Default 0.")
148 "Use the alternative, polynomial-time unification algorithm.")
149 (
"tptp", po::value<string>(),
150 "Specify a path for the TPTP. Alternative to using the TPTP environment variable.")
151 (
"path", po::value<string>(),
152 "Specify the path for output files other than the one produced by --output. Alternative to using the CONNECTPP_PATH environment variable.");
154 po::options_description conversion_options(
"Clause conversion");
155 conversion_options.add_options()
157 "Don't apply definitional transformation for any formula.")
159 "Apply definitional transformation to all formulas.")
160 (
"reorder,r", po::value<int>(),
161 "Reorder the clauses a specified number of times.")
163 "Randomly reorder the clauses.")
164 (
"random-reorder-literals",
165 "Randomly reorder the literals in each clause in the matrix.")
167 "Don't miniscope when converting to CNF.")
169 "Show translation of first-order formulas to clauses and halt.");
171 po::options_description output_options(
"Output formatting");
172 output_options.add_options()
173 (
"verbosity,v", po::value<int>(),
174 "Set verbosity level (0-3). Default is 2.")
176 "Don't use colour to highlight output.")
178 "Include substitutions when writing output.")
179 (
"indent", po::value<int>(),
180 "Set indentation size. (Default 4.)")
181 (
"out-int", po::value<int>(),
182 "Interval for updating output (default 50,000).");
184 po::options_description search_options(
"Search control");
185 search_options.add_options()
187 "Use all start clauses. (Overides other start clause options.)")
189 "Use all positive/negative start clauses, according to representation (currently always negative). (Interacts with other start clause options.)")
191 "Use all conjecture clauses as start clauses. (Interacts with other start clause options.)")
193 "Only use one start clause. (Interacts with other start clause options.)")
195 "Don't use the regularity test.")
197 "Compute reductions for all literals in the clause, not just the first one. (Currently not enabled.)")
199 "Compute extensions for all literals in the clause, not just the first one. (Currently not enabled.)")
201 "When using lemmas, consider all literals in the clause, not just the first one. (Currently not enabled.)")
203 "Do not use lemmas.");
205 po::options_description backtrack_options(
"Backtracking");
206 backtrack_options.add_options()
208 "Do not limit any backtracking.")
209 (
"lemmata-backtrack",
210 "Do not limit backtracking for lemmata.")
211 (
"reduction-backtrack",
212 "Do not limit backtracking for reductions.")
213 (
"extension-backtrack",
214 "Do not limit backtracking for extensions.")
215 (
"explore-left-trees",
216 "Apply backtracking within left extension trees.")
217 (
"complete,c", po::value<int>(),
218 "Start again with a complete search on reaching the specified depth. (Default UINT32_MAX.)");
220 po::options_description depth_options(
"Depth limiting");
221 depth_options.add_options()
222 (
"depth-limit,d", po::value<int>(),
223 "Maximum depth/path length. (Default UINT32_MAX.)")
224 (
"start-depth", po::value<int>(),
225 "Initial depth/path length. (Default 1.)")
226 (
"depth-increment", po::value<int>(),
227 "Increment for iterative deepening. (Default 1.)");
229 po::options_description tptp_proof_output(
"TPTP proof output");
230 tptp_proof_output.add_options()
231 (
"tptp-proof", po::value<string>()->implicit_value(
string(
"default")),
232 "Generate a proof compatible with the TPTP tableau format. See tptp.org/Proposals/TableauxFormatProofs/index.shtml. Output is to stdout by default. Specify a filename if you want it in a file instead.")
233 (
"tptp-proof-no-subs",
234 "Don't apply substitutions in the tableau when displaying clauses or literals.")
235 (
"tptp-proof-show-paths",
236 "Show path(...) with full paths rather than parent(...).")
237 (
"tptp-proof-show-all",
238 "By default only material actually used in the proof is shown. Setting this will give you everything.")
239 (
"tptp-proof-show-subs",
240 "Add bind(...) annotations to the output.");
242 po::options_description sc_tptp_proof_output(
"SC-TPTP proof output");
243 sc_tptp_proof_output.add_options()
245 "Generate a proof in the SC-TPTP format. See github.com/SC-TPTP/sc-tptp. Output is to stdout. (Not currently implemented.)");
247 po::options_description proof_verification(
"Proof verification");
248 proof_verification.add_options()
250 "Generate Prolog format files proof.pl and matrix.pl and store in the $CONNECTPP_PATH directory. You can check these using the check_proof utility.")
252 "Verify any proof found using the internal proof checker. Use this version to get a detailed description of the verification sent to stdout.")
254 "Verify any proof found using the internal proof checker. Use this version for a quiet verification that only adds \"Verified\" or \"FaliedVerification\" to the output string.");
256 po::options_description latex_options(
"LaTeX output");
257 latex_options.add_options()
258 (
"latex", po::value<string>()->implicit_value(
string(
"default")),
259 "Make a LaTeX file containing a typeset proof in the (clausal) connection calculus format. Default value: \"./latex_proof.tex\".")
260 (
"latex-tableau", po::value<string>()->implicit_value(
string(
"default")),
261 "Make a LaTeX file containing a typeset proof in the tableau format. Default value \"./latex_tableau_proof.tex\".")
262 (
"latex-tableau-subs",
263 "Show lists of substitutions in the tableau nodes.")
265 "Include substitutions in the LaTeX proof. That is, apply them in clauses and so on.")
266 (
"latex-height", po::value<string>(),
267 "Page height for LaTeX output. Specify as a LaTex-compatible string. Default \"500mm\".")
268 (
"latex-width", po::value<string>(),
269 "Page width for LaTeX output. Specify as a LaTex-compatible string. Default \"500mm\".")
271 "Only generate LaTeX for the diagram. Don't include \\documentclass... and so on.")
273 "Typeset the latex proof in a tiny font.")
275 "Don't include the matrix in the LaTeX proof.");
277 po::options_description graphviz_options(
"Graphviz output");
278 graphviz_options.add_options()
279 (
"graphviz-tableau", po::value<string>()->implicit_value(
string(
"default")),
280 "Produce a .dot file that can be displayed using Graphviz. Default value \"./graphviz_tableau_proof.dot\".")
281 (
"graphviz-tableau-subs",
282 "Show lists of substitutions in the tableau nodes.")
284 "Include substitutions in the proof. That is, apply them in clauses and so on.")
285 (
"graphviz-height", po::value<string>(),
286 "Page height for Graphviz output. Specify in inches. Default 11.69 (A4 paper).")
287 (
"graphviz-width", po::value<string>(),
288 "Page width for Graphviz output. Specify in inches. Default 8.27 (A4 paper).");
291 po::options_description all_options(
"Options");
292 all_options.add(main_options)
293 .add(conversion_options)
296 .add(backtrack_options)
298 .add(tptp_proof_output)
299 .add(sc_tptp_proof_output)
300 .add(proof_verification)
302 .add(graphviz_options);
304 po::positional_options_description pos_opts;
305 pos_opts.add(
"input", -1);
306 po::variables_map vars_map;
308 po::store(po::command_line_parser(argc, argv).
309 options(all_options).
310 positional(pos_opts).
316 catch (boost::program_options::error& err) {
317 cout <<
"% SZS status Error for "
318 << params::problem_name <<
" : " << err.what() << endl;
321 po::notify(vars_map);
326 if (vars_map.count(
"help")) {
327 cout << all_options << endl;
328 cout <<
"If you wish to report a bug, please supply:" << endl << endl;
329 cout <<
"1. A description of the claimed bug." << endl;
330 cout <<
"2. The input file used." << endl;
331 cout <<
"3. The exact command-line used, including all options." << endl;
332 cout <<
"4. The output from \"connect++ --version\"." << endl << endl;
333 cout <<
"The author can be contacted at: sbh11@cl.cam.ac.uk" << endl;
336 if (vars_map.count(
"version")) {
337 cout <<
"Connect++ Version V" << VERSION <<
"." << endl;
338 cout <<
"Copyright © 2021-26 Sean Holden. All rights reserved." << endl;
341 if (vars_map.count(
"verbosity")) {
342 int v = vars_map[
"verbosity"].as<
int>();
343 if (v >= 0 && v <= 3)
344 params::verbosity = v;
346 cerr <<
"Verbosity should be between 0 and 3. Using default (2)." << endl;
351 VPrint show(params::verbosity);
355 if (vars_map.count(
"sub-output")) {
356 params::output_terms_with_substitution =
true;
358 if (vars_map.count(
"indent")) {
359 int i = vars_map[
"indent"].as<
int>();
360 if (i >= 0 && i <= UINT8_MAX)
361 params::indent_size = i;
363 cerr <<
"Indent size is negative or too large. Using default." << endl;
365 if (vars_map.count(
"out-int")) {
366 int i = vars_map[
"out-int"].as<
int>();
367 if (i > 0 && i <= UINT32_MAX)
368 params::output_frequency = i;
370 cerr <<
"Interval is negative or too large. Using default." << endl;
372 if (vars_map.count(
"no-equality")) {
373 params::add_equality_axioms =
false;
375 if (vars_map.count(
"equality-last")) {
376 params::equality_axioms_at_start =
false;
378 if (vars_map.count(
"all-distinct-objects")) {
379 params::all_distinct_objects =
true;
381 if (vars_map.count(
"no-distinct-objects")) {
382 if (params::all_distinct_objects) {
383 cerr <<
"Cancelled --all-distinct-objects." << endl;
384 params::all_distinct_objects =
false;
386 params::no_distinct_objects =
true;
388 if (vars_map.count(
"timeout")) {
389 params::timeout =
true;
390 int t = vars_map[
"timeout"].as<
int>();
393 params::timeout_value = t;
395 cerr <<
"Timeout is too small. Using 10 seconds." << endl;
396 params::timeout_value = 10;
400 cerr <<
"Timeout should be positive. Using default." << endl;
402 params::global_timeout += chrono::seconds(params::timeout_value);
404 if (vars_map.count(
"show-default-schedule")) {
405 params::set_default_schedule();
406 cout << params::default_schedule << endl;
409 if (vars_map.count(
"path")) {
410 params::connectpp_path = vars_map[
"path"].as<
string>();
416 params::LaTeX_proof_path
417 = params::pwd_path / params::LaTeX_proof_path;
418 params::LaTeX_tableau_proof_path
419 = params::pwd_path / params::LaTeX_tableau_proof_path;
420 params::Prolog_matrix_path
421 = params::connectpp_path / params::Prolog_matrix_path;
422 params::Prolog_proof_path
423 = params::connectpp_path / params::Prolog_proof_path;
424 params::output_summary_path
425 = params::pwd_path / params::output_summary_path;
429 if (vars_map.count(
"output")) {
430 params::write_output_summary =
true;
431 string op = vars_map[
"output"].as<
string>();
433 params::output_summary_path = op;
435 if (vars_map.count(
"all-definitional")) {
436 params::all_definitional =
true;
438 if (vars_map.count(
"no-definitional")) {
439 params::no_definitional =
true;
440 if (params::all_definitional) {
441 cerr <<
"Setting --no-definitional has cancelled --all-definitional." << endl;
442 params::all_definitional =
false;
446 if (vars_map.count(
"schedule")) {
447 params::use_schedule =
true;
448 if (!params::timeout) {
449 params::timeout =
true;
450 params::timeout_value = 600;
452 params::schedule_path = vars_map[
"schedule"].as<
string>();
454 schedule.read_schedule_from_file(params::schedule_path);
456 catch (std::exception& err) {
457 cout <<
"% SZS status Error for "
458 << params::problem_name <<
" : " << err.what() << endl;
466 if (vars_map.count(
"tptp")) {
467 params::tptp_path = vars_map[
"tptp"].as<
string>();
469 if (vars_map.count(
"reorder")) {
470 int n = vars_map[
"reorder"].as<
int>();
472 params::deterministic_reorder =
true;
473 params::number_of_reorders = n;
476 cerr <<
"Number of re-orders should be positive. Skipping." << endl;
478 if (vars_map.count(
"random-seed")) {
479 int seed = vars_map[
"random-seed"].as<
int>();
481 params::random_seed =
static_cast<unsigned>(seed);
482 params::boost_random_seed =
static_cast<uint32_t
>(seed);
485 cerr <<
"Error: random seed must be a non-negative integer. Using default of 0." << endl;
488 if (vars_map.count(
"random-reorder")) {
489 params::random_reorder =
true;
491 if (vars_map.count(
"random-reorder-literals")) {
492 params::random_reorder_literals =
true;
494 if (vars_map.count(
"no-miniscope")) {
495 params::miniscope =
false;
497 if (vars_map.count(
"show-clauses")) {
498 params::show_clauses =
true;
500 if (vars_map.count(
"no-colour")) {
501 params::use_colours =
false;
503 if (vars_map.count(
"poly-unification")) {
504 params::poly_unification =
true;
524 fs::path initial_path;
525 bool found_file =
false;
526 if (vars_map.count(
"input")) {
528 initial_path = vars_map[
"input"].as<
string>();
531 if (initial_path.is_relative()) {
533 if (fs::exists(initial_path)) {
537 initial_path = fs::canonical(initial_path);
539 catch (std::filesystem::filesystem_error& err) {
540 cout <<
"% SZS status Error for "
541 << params::problem_name <<
" : "
542 << err.what() << endl;
550 fs::path tptp_path(params::tptp_path);
551 initial_path = tptp_path / initial_path;
553 if (fs::exists(initial_path)) {
556 initial_path = fs::canonical(initial_path);
558 catch (std::filesystem::filesystem_error& err) {
559 cout <<
"% SZS status Error for "
560 << params::problem_name <<
" : "
561 << err.what() << endl;
570 if (initial_path.is_absolute() && fs::exists(initial_path)) {
573 initial_path = fs::canonical(initial_path);
575 catch (std::filesystem::filesystem_error& err) {
576 cout <<
"% SZS status Error for "
577 << params::problem_name <<
" : "
578 << err.what() << endl;
586 cout <<
"% SZS status Error for "
587 << params::problem_name <<
" : no problem specified." << endl;
592 cout <<
"% SZS status Error for "
593 << params::problem_name <<
" : the specified file does not exist." << endl;
597 params::full_problem_path = initial_path;
598 params::full_problem_path.remove_filename();
599 params::problem_name = initial_path.stem().string();
600 fs::path path = initial_path;
605 if (vars_map.count(
"depth-limit")) {
606 int l = vars_map[
"depth-limit"].as<
int>();
608 params::depth_limit = l;
610 cerr <<
"Depth limit should be positive. Using default." << endl;
612 if (vars_map.count(
"start-depth")) {
613 int l = vars_map[
"start-depth"].as<
int>();
614 if (l > 1 && l <= params::depth_limit)
615 params::start_depth = l;
617 cerr <<
"Start depth should be positive and bounded by the maximum depth. Using default." << endl;
619 if (vars_map.count(
"depth-increment")) {
620 int l = vars_map[
"depth-increment"].as<
int>();
622 params::depth_increment = l;
624 cerr <<
"Depth increment should be positive. Using default." << endl;
638 if (vars_map.count(
"restrict-start")) {
639 params::restrict_start =
true;
641 if (vars_map.count(
"pos-neg-start")) {
642 params::all_pos_neg_start =
true;
644 if (vars_map.count(
"conjecture-start")) {
645 params::conjecture_start =
true;
647 if (vars_map.count(
"all-start")) {
648 show(2,
string(
"--all-start set. This cancels all other start options."),
true);
661 if (vars_map.count(
"no-regularity")) {
662 params::use_regularity_test =
false;
664 if (vars_map.count(
"lemmata-backtrack")) {
665 params::limit_bt_lemmas =
false;
667 if (vars_map.count(
"reduction-backtrack")) {
668 params::limit_bt_reductions =
false;
670 if (vars_map.count(
"extension-backtrack")) {
671 params::limit_bt_extensions =
false;
673 if (vars_map.count(
"explore-left-trees")) {
674 params::limit_bt_extensions_left_tree =
false;
676 if (vars_map.count(
"all-backtrack")) {
677 show(2,
string(
"--all-backtrack set. This prevails over all other backtracking options."),
true);
680 if (vars_map.count(
"all-reductions")) {
681 params::limit_reductions =
false;
683 if (vars_map.count(
"all-extensions")) {
684 params::limit_extensions =
false;
686 if (vars_map.count(
"all-lemmas")) {
687 params::limit_lemmata =
false;
689 if (vars_map.count(
"no-lemmas")) {
690 params::use_lemmata =
false;
692 if (vars_map.count(
"complete")) {
693 int d = vars_map[
"complete"].as<
int>();
694 if (d >= params::start_depth)
695 params::switch_to_complete = d;
697 cerr <<
"Switch to complete search must happen after start depth. Using start depth." << endl;
698 params::switch_to_complete = params::start_depth;
701 if (vars_map.count(
"latex")) {
702 params::generate_LaTeX_proof =
true;
703 params::build_proof =
true;
704 string lp = vars_map[
"latex"].as<
string>();
706 params::LaTeX_proof_path = lp;
708 if (vars_map.count(
"latex-tableau")) {
709 params::generate_LaTeX_tableau_proof =
true;
710 params::build_proof =
true;
711 string lp = vars_map[
"latex-tableau"].as<
string>();
713 params::LaTeX_tableau_proof_path = lp;
715 if (vars_map.count(
"graphviz-tableau")) {
716 params::generate_graphviz_tableau_proof =
true;
717 params::build_proof =
true;
718 string lp = vars_map[
"graphviz-tableau"].as<
string>();
720 params::graphviz_tableau_proof_path = lp;
722 if (vars_map.count(
"latex-tableau-subs")) {
723 params::latex_tableau_subs =
true;
725 if (vars_map.count(
"graphviz-tableau-subs")) {
726 params::graphviz_tableau_subs =
true;
728 if (vars_map.count(
"sub-latex")) {
729 params::sub_LaTeX_proof =
true;
731 if (vars_map.count(
"sub-graphviz")) {
732 params::sub_Graphviz_proof =
true;
734 if (vars_map.count(
"latex-height")) {
735 string s = vars_map[
"latex-height"].as<
string>();
736 params::latex_height = s;
738 if (vars_map.count(
"latex-width")) {
739 string s = vars_map[
"latex-width"].as<
string>();
740 params::latex_width = s;
742 if (vars_map.count(
"graphviz-height")) {
743 float h = std::stof(vars_map[
"graphviz-height"].as<string>());
745 params::graphviz_height = h;
747 if (vars_map.count(
"graphviz-width")) {
748 float w = std::stof(vars_map[
"graphviz-width"].as<string>());
750 params::graphviz_width = w;
752 if (vars_map.count(
"latex-body-only")) {
753 params::latex_body_only =
true;
755 if (vars_map.count(
"tiny-latex")) {
756 params::latex_tiny_proof =
true;
758 if (vars_map.count(
"latex-no-matrix")) {
759 params::latex_include_matrix =
false;
761 if (vars_map.count(
"tptp-proof")) {
762 params::generate_tptp_proof =
true;
763 params::build_proof =
true;
765 if (vars_map.count(
"tptp-proof")) {
766 params::generate_tptp_proof =
true;
767 params::build_proof =
true;
768 string tptp_p = vars_map[
"tptp-proof"].as<
string>();
769 if (tptp_p !=
"default") {
770 params::tptp_proof_path = tptp_p;
771 params::tptp_proof_to_file =
true;
774 if (vars_map.count(
"tptp-proof-no-subs")) {
775 params::tptp_proof_no_subs =
true;
777 if (vars_map.count(
"tptp-proof-show-paths")) {
778 params::tptp_proof_show_paths =
true;
780 if (vars_map.count(
"tptp-proof-show-all")) {
781 params::all_tptp_records =
true;
783 if (vars_map.count(
"tptp-proof-show-subs")) {
784 params::tptp_proof_show_subs =
true;
786 if (vars_map.count(
"sc-tptp-proof")) {
787 params::generate_sc_tptp_proof =
true;
788 params::build_proof =
true;
790 if (vars_map.count(
"prolog-proof")) {
791 params::generate_Prolog_proof =
true;
792 params::build_proof =
true;
794 if (vars_map.count(
"verify")) {
795 params::verify_proof =
true;
796 params::build_proof =
true;
798 if (vars_map.count(
"full-verify")) {
799 params::verify_proof =
true;
800 params::verify_proof_verbose =
true;
801 params::build_proof =
true;
815 show(1,
string(
"Connect++ V"));
816 show(1,
string(VERSION));
817 show(1,
string(
" started at: "));
818 time_t date_and_time;
819 time(&date_and_time);
820 show(1, asctime(localtime(&date_and_time)));
844 if (params::use_schedule) {
845 params::no_definitional =
false;
846 params::all_definitional =
false;
848 show(1,
string(
"Reading from: "));
849 show(1, path.c_str(),
true);
850 bool found_conjecture =
false;
855 catch (std::exception& err) {
856 cout <<
"% SZS status Error for "
857 << params::problem_name <<
" : "
858 << err.what() << endl;
865 if (params::use_schedule) {
866 params::all_definitional =
true;
870 catch (std::exception& err) {
871 cout <<
"% SZS status Error for "
872 << params::problem_name <<
" : "
873 << err.what() << endl;
876 params::all_definitional =
false;
877 params::no_definitional =
true;
881 catch (std::exception& err) {
882 cout <<
"% SZS status Error for "
883 << params::problem_name <<
" : "
884 << err.what() << endl;
892 chrono::milliseconds parse_time =
893 chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - startTime);
894 show(1,
string(
"Total parse and conversion time: "));
895 show(1, std::to_string(parse_time.count()));
896 show(1,
string(
" milliseconds."),
true);
902 show(2,
string(
"Starting proof attempt for: "),
false);
903 show(2, params::problem_name,
true);
907 ProverOutcome prover_outcome;
908 ProverOutcome final_outcome;
909 final_outcome = ProverOutcome::TimeOut;
919 if (!params::use_schedule) {
920 if (params::verbosity > 2) {
930 if (params::timeout) {
931 chrono::seconds timeout_duration(params::timeout_value);
932 prover_standard.
set_timeout(startTime + timeout_duration);
937 prover_outcome = prover_standard.
prove();
938 final_outcome = prover_outcome;
953 if (!params::timeout) {
954 params::timeout =
true;
955 params::timeout_value = 600;
960 chrono::milliseconds time_chunk((params::timeout_value * 1000) / 100);
961 chrono::steady_clock::time_point start_time = startTime;
962 chrono::milliseconds chunk_time;
967 size_t schedule_step_number = 1;
968 pair<bool, unsigned int> next_schedule =
schedule.set_next_schedule();
969 if (params::verbosity > 0)
974 while (next_schedule.first) {
975 show(1,
string(
"Schedule step "));
976 show(1, std::to_string(schedule_step_number));
977 show(1,
string(
": "));
978 show(1,
schedule.step_to_string(schedule_step_number - 1),
true);
979 if (params::verbosity > 2) {
985 if (params::all_definitional) {
986 prover = &prover_all_definitional;
988 else if (params::no_definitional) {
989 prover = &prover_no_definitional;
992 prover = &prover_standard;
997 if (next_schedule.second == 0) {
998 prover->
set_timeout(startTime + chrono::seconds(params::timeout_value));
1000 else if (schedule_step_number == 1) {
1001 prover->
set_timeout(startTime + (next_schedule.second * time_chunk));
1004 prover->
set_timeout(start_time + (next_schedule.second * time_chunk));
1007 prover_outcome = prover->
prove();
1009 if (prover_outcome == ProverOutcome::Valid ||
1010 prover_outcome == ProverOutcome::Error ||
1011 prover_outcome == ProverOutcome::False) {
1012 final_outcome = prover_outcome;
1016 chunk_time = chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - start_time);
1019 show(1,
string(
"Timeout after "));
1020 show(1, std::to_string(chunk_time.count()));
1021 show(1,
string(
" milliseconds"),
true);
1023 start_time = chrono::steady_clock::now();
1024 schedule_step_number++;
1025 next_schedule =
schedule.set_next_schedule();
1038 chrono::milliseconds runTime =
1039 chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - startTime);
1040 show(1,
string(
"Total run time: "));
1041 show(1, std::to_string(runTime.count()));
1042 show(1,
string(
" milliseconds."),
true);
1044 if (params::verbosity > 0) {
1045 if (params::show_full_stats) {
1075 cout <<
"% SZS status ";
1076 switch (final_outcome) {
1077 case ProverOutcome::Valid:
1080 outcome =
"Unsatisfiable";
1084 if (simplified_has_axioms) {
1087 outcome =
"ContradictoryAxioms";
1090 else if (conj_false || neg_conj_removed) {
1091 outcome =
"ContradictoryAxioms";
1095 else if (conj_missing) {
1096 outcome =
"Unsatisfiable";
1100 outcome =
"Theorem";
1110 if (neg_conj_removed) {
1115 outcome =
"Theorem";
1119 case ProverOutcome::False:
1122 outcome =
"Satisfiable";
1125 if (simplified_has_axioms) {
1129 else if (conj_false || neg_conj_removed) {
1130 outcome =
"CounterSatisfiable";
1132 else if (conj_missing) {
1133 outcome =
"Satisfiable";
1136 outcome =
"CounterSatisfiable";
1142 outcome =
"Theorem";
1144 else if (neg_conj_removed) {
1149 outcome =
"CounterSatisfiable";
1153 case ProverOutcome::PathLenLimit:
1156 case ProverOutcome::Error:
1159 case ProverOutcome::TimeOut:
1163 if (chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - startTime).count() < (params::timeout_value * 1000))
1166 outcome =
"Timeout";
1172 cout << outcome <<
" for " << params::problem_name;
1176 bool verified =
false;
1177 if (params::verify_proof && final_outcome == ProverOutcome::Valid) {
1184 vector<pair<string, vector<size_t>>>
1189 get<0>(inds), get<3>(inds));
1191 bool verification_outcome;
1192 string outcome_string;
1193 if (params::verify_proof_verbose) {
1194 pair<bool, string> outcome = checker.check_proof_verbose();
1195 verification_outcome = outcome.first;
1196 outcome_string = outcome.second;
1199 verification_outcome = checker.check_proof();
1202 if (verification_outcome) {
1204 cout <<
" : Verified";
1207 cout <<
" : FailedVerification";
1210 if (params::verify_proof_verbose) {
1211 cout << endl <<
"% SZS output start Proof for " << params::problem_name << endl << endl;
1212 cout << outcome_string << endl;
1213 cout <<
"% SZS output end Proof for " << params::problem_name << endl;
1220 if (params::write_output_summary) {
1222 std::ofstream out_file(params::output_summary_path);
1223 out_file <<
"ProblemName: " << params::problem_name << endl;
1224 if (found_conjecture)
1225 out_file <<
"ConjectureFound" << endl;
1227 out_file <<
"NoConjectureFound" << endl;
1229 status =
"NoStatus";
1230 out_file <<
"ProblemStatus: " << status << endl;
1231 out_file <<
"ProverOutcome: " << outcome << endl;
1232 if (params::verify_proof && final_outcome == ProverOutcome::Valid) {
1234 out_file <<
"Verified" << endl;
1236 out_file <<
"FailedVerification" << endl;
1239 out_file <<
"NoVerify" << endl;
1240 out_file <<
"Time: " << runTime.count() << endl;
1243 catch (std::exception& err) {
1244 cerr <<
"Error: can't write output summary." << endl;
1250 if (params::generate_tptp_proof && (final_outcome == ProverOutcome::Valid)) {
1251 if (!params::tptp_proof_to_file) {
1252 cout <<
"% SZS output start Proof for " << params::problem_name << endl;
1254 cout <<
"% SZS output end Proof for " << params::problem_name << endl;
1258 std::ofstream out_file(params::tptp_proof_path);
1262 catch (std::exception& err) {
1263 cerr <<
"Error: can't write TPTP proof to file." << endl;
1267 return EXIT_SUCCESS;
Mechanism for looking after functions.
Management of Predicate objects.
Prover using a pair of stacks to conduct the proof search.
void read_from_tptp_file(const string &, bool &, size_t &)
Obviously, reads a problem from a TPTP file.
void show_full_statistics(size_t) const
Display counts of number of extensions tried and so on, as well as numbers per second.
bool problem_has_true_conjecture() const
Find out whether the problem's conjecture is $true.
bool problem_is_cnf_only() const
Find out whether the problem is CNF only.
void set_problem_path(fs::path &p)
Set the path for the problem being solved.
void show_statistics() const
Display counts of number of extensions tried and so on.
void show_matrix()
Show a nicely formatted matrix.
bool problem_has_missing_conjecture() const
Find out whether the problem's conjecture is missing, in the sense that it didn't appear in the inp...
bool problem_has_negated_conjecture_removed() const
Find out whether the problem's negated conjecture was simplified out.
void set_timeout(chrono::steady_clock::time_point time)
Set a timeout.
bool simplified_problem_has_fof_axioms() const
Find out from the parser whether the problem had axioms after simplification.
string get_status() const
Straightforward get method.
bool problem_has_fof_axioms() const
Find out from the parser whether the problem had axioms before simplification.
std::tuple< VariableIndex *, FunctionIndex *, PredicateIndex *, TermIndex * > get_indexes()
Straightforward get method.
string proof_to_tptp()
Show the TPTP-formatted conversion to CNF.
vector< pair< string, vector< size_t > > > get_internal_proof() const
Get an internal representation of the proof stack.
Matrix & get_matrix()
Get a reference to the matrix.
bool problem_has_false_conjecture() const
Find out whether the problem's conjecture is $false.
ProverOutcome prove()
Show a TPTP-formatted proof without the conversion info.
Look after terms, using hash consing to avoid storing copies of terms.
Storage of named variables, and management of new, anonymous and unique variables.
Wrap up the parsing process and the operation of a schedule in a single class.
Hide all the global stuff in this namespace.
static void set_all_backtrack()
Self-explanatory.
static void set_all_start()
Self-explanatory.
static bool no_start_options()
Self-explanatory.
static void correct_missing_start_options()
Self-explanatory.
static void show_search_parameter_settings()
Give a detailed indication of what the parameters affecting the search are currently set to.