コード例 #1
0
ファイル: Bitvector.cpp プロジェクト: shabesoglu/smtrat
	bool BitvectorTheory::handleITE(const FormulaT& ifterm, const types::TermType& thenterm, const types::TermType& elseterm, types::TermType& result, TheoryError& errors) {
		types::BVTerm thent;
		types::BVTerm elset;
		if (!termConverter(thenterm, thent)) {
			errors.next() << "Failed to construct ITE, the then-term \"" << thenterm << "\" is unsupported.";
			return false;
		}
		if (!termConverter(elseterm, elset)) {
			errors.next() << "Failed to construct ITE, the else-term \"" << elseterm << "\" is unsupported.";
			return false;
		}
		if (thent.width() != elset.width()) {
			errors.next() << "Failed to construct ITE, the then-term \"" << thent << "\" and the else-term \"" << elset << "\" have different widths.";
			return false;
		}
		if (ifterm.isTrue()) { result = thent; return true; }
		if (ifterm.isFalse()) { result = elset; return true; }
		carl::SortManager& sm = carl::SortManager::getInstance();
		carl::Variable var = carl::freshVariable(carl::VariableType::VT_BITVECTOR);
		state->artificialVariables.emplace_back(var);
		carl::BVVariable bvvar(var, sm.index(this->bvSort, {thent.width()}));
		state->auxiliary_variables.insert(bvvar);
		types::BVTerm vart = types::BVTerm(carl::BVTermType::VARIABLE, bvvar);

		FormulaT consThen = FormulaT(types::BVConstraint::create(carl::BVCompareRelation::EQ, vart, thent));
		FormulaT consElse = FormulaT(types::BVConstraint::create(carl::BVCompareRelation::EQ, vart, elset));

		state->global_formulas.emplace_back(FormulaT(carl::FormulaType::IMPLIES, {ifterm, consThen}));
		state->global_formulas.emplace_back(FormulaT(carl::FormulaType::IMPLIES, {FormulaT(carl::FormulaType::NOT,ifterm), consElse}));
		result = vart;
		return true;
	}
コード例 #2
0
ファイル: EMModule.cpp プロジェクト: smtrat/smtrat
 Answer EMModule<Settings>::checkCore()
 {
     auto receivedFormula = firstUncheckedReceivedSubformula();
     while (receivedFormula != rReceivedFormula().end()) {
         FormulaT formula = receivedFormula->formula();
         if (receivedFormula->formula().propertyHolds(carl::PROP_CONTAINS_NONLINEAR_POLYNOMIAL)) {
             formula = mVisitor.visitResult(receivedFormula->formula(), eliminateEquationFunction);
         }
         if (formula.isFalse()) {
             receivedFormulasAsInfeasibleSubset(receivedFormula);
             return UNSAT;
         }
         if (!formula.isTrue()) {
             addSubformulaToPassedFormula(formula, receivedFormula->formula());
         }
         ++receivedFormula;
     }
     Answer ans = runBackends();
     if (ans == UNSAT)
         getInfeasibleSubsets();
     return ans;
 }