SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
parser_dimacs.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "config.h"
5 
6 #ifdef CLI_ENABLE_DIMACS_PARSER
7 #include <carl-io/DIMACSImporter.h>
8 
9 namespace smtrat {
10 
11 template<typename Strategy>
12 int run_dimacs_file(Strategy& strategy, const std::string& filename) {
13  carl::io::DIMACSImporter<Poly> dimacs(filename);
14  int exitCode = 0;
15  while (dimacs.hasNext()) {
16  strategy.add(dimacs.next());
17  switch (strategy.check()) {
18  case Answer::SAT: {
19  std::cout << "sat" << std::endl;
20  exitCode = SMTRAT_EXIT_SAT;
21  break;
22  }
23  case Answer::UNSAT: {
24  std::cout << "unsat" << std::endl;
25  exitCode = SMTRAT_EXIT_UNSAT;
26  break;
27  }
28  case Answer::UNKNOWN: {
29  std::cout << "unknown" << std::endl;
30  exitCode = SMTRAT_EXIT_UNKNOWN;
31  break;
32  }
33  default: {
34  std::cerr << "unexpected output!";
36  break;
37  }
38  }
39  if (dimacs.hasNext()) strategy.reset();
40  }
41  return exitCode;
42 }
43 
44 }
45 
46 #else
47 
48 namespace smtrat {
49 
50 template<typename Strategy>
51 int run_dimacs_file(Strategy&, const std::string&) {
52  SMTRAT_LOG_ERROR("smtrat", "This version of SMT-RAT was compiled without support for DIMACS parsing. Please enable it by setting the corresponding CMake option.");
53  return 0;
54 }
55 
56 }
57 
58 #endif
constexpr int SMTRAT_EXIT_UNEXPECTED_ANSWER
Definition: ExitCodes.h:18
constexpr int SMTRAT_EXIT_UNKNOWN
Definition: ExitCodes.h:15
constexpr int SMTRAT_EXIT_SAT
Definition: ExitCodes.h:13
constexpr int SMTRAT_EXIT_UNSAT
Definition: ExitCodes.h:14
Class to create the formulas for axioms.
@ UNKNOWN
Definition: types.h:57
int run_dimacs_file(Strategy &, const std::string &)
Definition: parser_dimacs.h:51
#define SMTRAT_LOG_ERROR(channel, msg)
Definition: logging.h:32