4 #include <boost/algorithm/string/predicate.hpp>
10 if (boost::get<FormulaT>(&term) !=
nullptr) {
11 result = boost::get<FormulaT>(term);
13 }
else if (boost::get<carl::Variable>(&term) !=
nullptr) {
14 if (boost::get<carl::Variable>(term).
type() == carl::VariableType::VT_BOOL) {
27 for (std::size_t i = 0; i < arguments.size(); i++) {
30 errors.
next() <<
"Arguments are expected to be formulas, but argument " << (i+1) <<
" is not: \"" << arguments[i] <<
"\".";
41 std::vector<FormulaT> args;
42 if (!
convert(arguments, args, errors))
return false;
47 template<carl::FormulaType type>
56 if (arguments.size() != 1) {
57 errors.
next() <<
"Operator \"not\" may only have a single argument.";
66 if (arguments.size() != 2) {
67 errors.
next() <<
"Operator \"implies\" may only have a single argument.";
70 result =
FormulaT(carl::FormulaType::IMPLIES, {arguments[0], arguments[1]});
76 carl::SortManager& sm = carl::SortManager::getInstance();
77 sorts.add(
"Bool", sm.getInterpreted(carl::VariableType::VT_BOOL));
85 carl::SortManager& sm = carl::SortManager::getInstance();
86 sm.addInterpretedSort(
"Bool", carl::VariableType::VT_BOOL);
98 carl::SortManager& sm = carl::SortManager::getInstance();
99 switch (sm.getType(
sort)) {
100 case carl::VariableType::VT_BOOL: {
102 carl::Variable
var = carl::fresh_variable(name, carl::VariableType::VT_BOOL);
108 errors.
next() <<
"The requested sort was not \"Bool\" but \"" <<
sort <<
"\".";
117 errors.
next() <<
"Failed to construct ITE, the then-term \"" << thenterm <<
"\" is unsupported.";
121 errors.
next() <<
"Failed to construct ITE, the else-term \"" << elseterm <<
"\" is unsupported.";
128 std::vector<FormulaT> args;
137 std::vector<FormulaT> args;
140 if (boost::iequals(identifier.
symbol,
"=")) {
void sort(T *array, int size, LessThan lt)
bool convertTerm(const types::TermType &term, FormulaT &result)
bool convertArguments(const std::vector< types::TermType > &arguments, std::vector< FormulaT > &result, TheoryError &errors)
carl::mpl_variant_of< TermTypes >::type TermType
Variant type for all terms.
carl::mpl_variant_of< ConstTypes >::type ConstType
Variant type for all constants.
carl::mpl_variant_of< VariableTypes >::type VariableType
Variant type for all variables.
QuantifierType type(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
carl::Formulas< Poly > FormulasT
Base class for all theories.
FormulaT expandDistinct(const std::vector< T > &values, const Builder &neqBuilder)
virtual bool apply(const std::vector< FormulaT > &arguments, types::TermType &result, TheoryError &errors) const =0
bool operator()(const std::vector< types::TermType > &arguments, types::TermType &result, TheoryError &errors) const
static void addConstants(qi::symbols< char, types::ConstType > &constants)
bool handleITE(const FormulaT &ifterm, const types::TermType &thenterm, const types::TermType &elseterm, types::TermType &result, TheoryError &errors)
Resolve an if-then-else operator.
static void addSimpleSorts(qi::symbols< char, carl::Sort > &sorts)
CoreTheory(ParserState *state)
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 > &arguments, types::TermType &result, TheoryError &errors)
Resolve a distinct operator.
bool functionCall(const Identifier &identifier, const std::vector< types::TermType > &arguments, types::TermType &result, TheoryError &errors)
Resolve another unknown function call.
bool convert(const std::vector< types::TermType > &from, std::vector< T > &to) const
bool apply(const std::vector< FormulaT > &arguments, types::TermType &result, TheoryError &errors) const
bool apply(const std::vector< FormulaT > &arguments, types::TermType &result, TheoryError &) const
bool apply(const std::vector< FormulaT > &arguments, types::TermType &result, TheoryError &errors) const
void registerFunction(const std::string &name, const FunctionInstantiator *fi)
bool isSymbolFree(const std::string &name, bool output=true)
std::map< std::string, types::VariableType > variables