3 #include "../ParserSettings.h"
5 #include <carl-formula/uninterpreted/UFInstanceManager.h>
9 namespace uninterpreted {
12 if (boost::get<carl::UTerm>(&term) !=
nullptr) {
13 result = boost::get<carl::UTerm>(term);
15 }
else if (boost::get<carl::UVariable>(&term) !=
nullptr) {
25 for (std::size_t i = 0; i < arguments.size(); i++) {
28 errors.
next() <<
"Arguments are expected to be uninterpreted, but argument " << (i+1) <<
" is not: \"" << arguments[i] <<
"\".";
39 mBoolSort(
carl::SortManager::getInstance().addSort(
"UF_Bool",
carl::
VariableType::VT_UNINTERPRETED)),
48 carl::SortManager& sm = carl::SortManager::getInstance();
49 if (sm.isInterpreted(
sort)) {
50 errors.
next() <<
"The request sort is not uninterpreted but \"" <<
sort <<
"\".";
54 carl::Variable v = carl::fresh_variable(name, carl::VariableType::VT_UNINTERPRETED);
55 carl::UVariable uv(v,
sort);
65 errors.
next() <<
"Failed to construct ITE, the then-term \"" << thenterm <<
"\" is unsupported.";
69 errors.
next() <<
"Failed to construct ITE, the else-term \"" << elseterm <<
"\" is unsupported.";
72 if (thent.domain() != elset.domain()) {
73 errors.
next() <<
"Failed to construct ITE, the domains of \"" << thent <<
"\" (" << thent.domain() <<
") and \"" << elset <<
"\" (" << elset.domain() <<
") are different.";
77 carl::Variable
var = carl::fresh_uninterpreted_variable();
79 carl::UVariable uvar(
var, thent.domain());
94 std::vector<carl::UTerm>
vars;
95 for (
const auto& v: arguments) {
98 vars.push_back(it->second);
100 }
else if (
const carl::Variable*
var = boost::get<carl::Variable>(&v)) {
101 carl::Variable tmp = carl::fresh_uninterpreted_variable();
104 }
else if (
const FormulaT* formula = boost::get<FormulaT>(&v)) {
105 carl::Variable tmp = carl::fresh_boolean_variable();
108 }
else if (
const Poly* p = boost::get<Poly>(&v)) {
109 carl::Variable tmp = carl::fresh_real_variable();
112 }
else if (
const carl::UTerm* ut = boost::get<carl::UTerm>(&v)) {
114 carl::Variable tmp = carl::fresh_uninterpreted_variable();
115 vars.emplace_back(carl::UVariable(tmp, ut->asUFInstance().uninterpretedFunction().codomain()));
120 }
else if (
const carl::UVariable* uv = boost::get<carl::UVariable>(&v)) {
123 SMTRAT_LOG_ERROR(
"smtrat.parser",
"The function argument type of " << v <<
" for function " << f <<
" was invalid.");
128 carl::UFInstance ufi = carl::newUFInstance(f,
vars);
129 carl::SortManager& sm = carl::SortManager::getInstance();
130 if (sm.isInterpreted(f.codomain())) {
132 if (
type == carl::VariableType::VT_BOOL) {
135 carl::Variable
var = carl::fresh_variable(
type);
140 carl::UVariable uvar(carl::fresh_variable(carl::VariableType::VT_UNINTERPRETED),
mBoolSort);
153 std::vector<types::UTerm> args;
156 return carl::UEquality(a, b,
true);
166 if (identifier.
symbol ==
"=") {
167 std::vector<types::UTerm> args;
170 for (std::size_t i = 0; i < args.size() - 1; i++) {
171 subformulas.emplace_back(carl::UEquality(args[i], args[i+1],
false));
176 errors.
next() <<
"Invalid operator \"" << identifier <<
"\".";
void sort(T *array, int size, LessThan lt)
carl::mpl_variant_of< TermTypes >::type TermType
Variant type for all terms.
carl::mpl_variant_of< VariableTypes >::type VariableType
Variant type for all variables.
bool convertTerm(const types::TermType &term, types::UTerm &result)
bool convertArguments(const std::vector< types::TermType > &arguments, std::vector< types::UTerm > &result, TheoryError &errors)
QuantifierType type(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
std::vector< carl::Variable > vars(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
carl::MultivariatePolynomial< Rational > Poly
carl::Formulas< Poly > FormulasT
const auto & settings_parser()
#define SMTRAT_LOG_ERROR(channel, msg)
Base class for all theories.
FormulaT expandDistinct(const std::vector< T > &values, const Builder &neqBuilder)
FormulasT global_formulas
bool isSymbolFree(const std::string &name, bool output=true)
std::map< std::string, types::VariableType > variables
std::set< types::VariableType > auxiliary_variables
std::vector< smtrat::ModelVariable > artificialVariables
std::map< std::string, carl::UninterpretedFunction > declared_functions
bool declareVariable(const std::string &name, const carl::Sort &sort, types::VariableType &result, TheoryError &errors)
Declare a new variable with the given name and the given sort.
bool handleDistinct(const std::vector< types::TermType > &, types::TermType &, TheoryError &errors)
Resolve a distinct operator.
bool handleFunctionInstantiation(const carl::UninterpretedFunction &f, const std::vector< types::TermType > &arguments, types::TermType &result, TheoryError &errors)
UninterpretedTheory(ParserState *state)
bool functionCall(const Identifier &identifier, const std::vector< types::TermType > &arguments, types::TermType &result, TheoryError &errors)
Resolve another unknown function call.
std::map< types::TermType, carl::UTerm > mInstantiatedArguments
bool handleITE(const FormulaT &ifterm, const types::TermType &thenterm, const types::TermType &elseterm, types::TermType &result, TheoryError &errors)
Resolve an if-then-else operator.
FormulaT coupleBooleanVariables(carl::Variable v, carl::UVariable uv)