12 size_t nVars = constraint.variables().size();
14 return 4 * (nVars * (nVars + 1))/2 + 1;
21 for (
const auto &term : constraint.lhs()) {
22 if (term.is_constant())
continue;
29 return constraint.lhs().constant_part() ==
Rational(-1);
36 std::map<carl::Variable, std::vector<carl::Variable>> commanderPartitions =
partition(constraint.variables().as_set());
39 std::vector<carl::Variable> commanders;
40 for (
const auto& entry : commanderPartitions) {
41 carl::Variable commander = entry.first;
42 commanders.push_back(commander);
43 std::vector<carl::Variable> group = entry.second;
46 for (
size_t i = 0; i < group.size(); i++) {
47 for (
size_t j = 0; j < i; j++) {
53 carl::Variables groupVarSet(group.begin(), group.end());
58 for (
size_t i = 0; i < group.size(); i++) {
64 Poly commanderConstraintPoly;
65 commanderConstraintPoly +=
Rational(-1);
66 for (
const auto& cmdVar : commanders) {
67 commanderConstraintPoly +=
Poly(cmdVar);
77 std::map<carl::Variable, std::vector<carl::Variable>>
result;
79 std::vector<carl::Variable> varVector;
83 std::vector<carl::Variable> commanders;
85 carl::Variable commander = carl::fresh_boolean_variable();
86 commanders.push_back(commander);
87 result[commander] = std::vector<carl::Variable>();
91 for (
size_t i = 0; i < varVector.size(); i++) {
93 result[commander].push_back(varVector[i]);
std::optional< FormulaT > doEncode(const ConstraintT &constraint)
CardinalityEncoder mCardinalityEncoder
std::map< carl::Variable, std::vector< carl::Variable > > partition(carl::Variables)
bool canEncode(const ConstraintT &constraint)
Rational encodingSize(const ConstraintT &constraint)
virtual Rational encodingSize(const ConstraintT &constraint)
std::optional< FormulaT > encode(const ConstraintT &constraint)
Encodes an arbitrary constraint.
FormulaT generateVarChain(const std::set< carl::Variable > &vars, carl::FormulaType type)
static void copy(const T &from, T &to)
std::vector< carl::Variable > vars(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
Class to create the formulas for axioms.
static constexpr int COMMANDER_GROUP_SIZE
carl::Formula< Poly > FormulaT
carl::MultivariatePolynomial< Rational > Poly
carl::Constraint< Poly > ConstraintT
carl::Formulas< Poly > FormulasT