3 * @author Gereon Kremer <gereon.kremer@cs.rwth-aachen.de>
4 * @author Florian Corzilius <corzilius@cs.rwth-aachen.de>
7 * Created on 2015-09-10.
14 template<class Settings>
15 EMModule<Settings>::EMModule( const ModuleInput* _formula, Conditionals& _conditionals, Manager* _manager ):
16 PModule( _formula, _conditionals, _manager, Settings::moduleName )
18 eliminateEquationFunction = std::bind(&EMModule<Settings>::eliminateEquation, this, std::placeholders::_1);
21 template<class Settings>
22 EMModule<Settings>::~EMModule()
25 template<class Settings>
26 Answer EMModule<Settings>::checkCore()
28 auto receivedFormula = firstUncheckedReceivedSubformula();
29 while (receivedFormula != rReceivedFormula().end()) {
30 FormulaT formula = receivedFormula->formula();
31 if (receivedFormula->formula().property_holds(carl::PROP_CONTAINS_NONLINEAR_POLYNOMIAL)) {
32 formula = carl::visit_result(receivedFormula->formula(), eliminateEquationFunction);
34 if (formula.is_false()) {
35 receivedFormulasAsInfeasibleSubset(receivedFormula);
38 if (!formula.is_true()) {
39 addSubformulaToPassedFormula(formula, receivedFormula->formula());
43 Answer ans = runBackends();
45 getInfeasibleSubsets();
49 template<typename Settings>
50 FormulaT EMModule<Settings>::eliminateEquation(const FormulaT& formula) {
51 if (formula.type() != carl::FormulaType::CONSTRAINT) return formula;
52 carl::Relation rel = formula.constraint().relation();
54 case carl::Relation::EQ:
55 case carl::Relation::NEQ: {
56 auto& factors = formula.constraint().lhs_factorization();
58 for (const auto& factor: factors) {
59 res.emplace_back(factor.first, rel);
61 carl::FormulaType ft = (rel == carl::Relation::EQ) ? carl::FormulaType::OR : carl::FormulaType::AND;
62 FormulaT result(ft, std::move(res));
63 if (result != formula) {
64 SMTRAT_LOG_INFO("smtrat.em", "Translated\n\t" << formula << "\nto\n\t" << result);