18 template<
typename Pol>
39 CARL_LOG_ERROR(
"carl.dimacs",
"Formula is not in pure-boolean CNF: " << f);
46 if (lit == 0)
return false;
51 std::vector<long long> clause;
52 for (
const auto& sub: f) {
53 if (sub.type() ==
BOOL || sub.type() ==
NOT) {
55 if (lit == 0)
return false;
56 clause.push_back(lit);
58 CARL_LOG_ERROR(
"carl.dimacs",
"Added formula to DIMACSExporter has a clause that is not pure-boolean: " << f);
62 mClauses.push_back(std::move(clause));
65 CARL_LOG_ERROR(
"carl.dimacs",
"Added formula to DIMACSExporter has a clause that is not pure-boolean: " << f);
73 CARL_LOG_INFO(
"carl.dimacs",
"Added TRUE to DIMACSExporter. Skipping...");
77 CARL_LOG_WARN(
"carl.dimacs",
"Added FALSE to DIMACSExporter. Skipping...");
84 for (
const auto& sub: f) {
89 CARL_LOG_ERROR(
"carl.dimacs",
"Added formula to DIMACSExporter that is not convertible to pure-boolean cnf: " << formula);
99 for (
const auto& clause: de.
mClauses) {
100 for (
const auto& l: clause) os << l <<
" ";
101 os <<
"0" << std::endl;
A small wrapper that configures logging for carl.
#define CARL_LOG_WARN(channel, msg)
#define CARL_LOG_ERROR(channel, msg)
#define CARL_LOG_INFO(channel, msg)
Formula< Poly > to_cnf(const Formula< Poly > &f, bool keep_constraints=true, bool simplify_combinations=false, bool tseitin_equivalence=true)
Converts the given formula to CNF.
A Variable represents an algebraic variable that can be used throughout carl.
Represent an SMT formula, which can be an atom for some background theory or a boolean combination of...
const Formula & subformula() const
carl::Variable::Arg boolean() const
Write formulas to the DIMAS format.
std::size_t id(carl::Variable::Arg v)
std::map< carl::Variable, std::size_t > mVariables
std::vector< std::vector< long long > > mClauses
friend std::ostream & operator<<(std::ostream &os, const DIMACSExporter< P > &de)
bool addDisjunction(const Formula< Pol > &f)
long long getLiteral(const Formula< Pol > &f)
bool operator()(const Formula< Pol > &formula)