SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
Arithmetic.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Common.h"
4 #include "AbstractTheory.h"
5 #include "ParserState.h"
6 
7 namespace smtrat {
8 namespace parser {
9 
10 namespace arithmetic {
11  using OperatorType = boost::variant<Poly::ConstructorOperation, carl::Relation>;
12 }
13 /**
14  * Implements the theory of arithmetic, including LRA, LIA, NRA and NIA.
15  */
17  static void addSimpleSorts(qi::symbols<char, carl::Sort>& sorts);
18 
19  std::map<std::string, arithmetic::OperatorType> ops;
20  std::map<carl::Variable, std::tuple<FormulaT, Poly, Poly>> mITEs;
21  std::map<carl::Variable, std::tuple<Poly, Poly>> mKnownDivisions;
22  std::map<carl::Variable, std::tuple<Poly, Poly>> mNewDivisions;
23 
25 
26  bool declareVariable(const std::string& name, const carl::Sort& sort, types::VariableType& result, TheoryError& errors);
27 
28  bool handleITE(const FormulaT& ifterm, const types::TermType& thenterm, const types::TermType& elseterm, types::TermType& result, TheoryError& errors);
29  bool handleDistinct(const std::vector<types::TermType>& arguments, types::TermType& result, TheoryError& errors);
30 
31  bool instantiate(const types::VariableType& var, const types::TermType& replacement, types::TermType& result, TheoryError& errors);
32  bool functionCall(const Identifier& identifier, const std::vector<types::TermType>& arguments, types::TermType& result, TheoryError& errors);
33 
34  bool declareQuantifiedTerm(const std::vector<std::pair<std::string, carl::Sort>>& vars, const carl::FormulaType& type, const types::TermType& term, types::TermType& result, TheoryError& errors);
35 
37 
38 private:
39  std::map<FormulaT, carl::Variable> mappedFormulas;
40 
41  bool convertArguments(const arithmetic::OperatorType& op, const std::vector<types::TermType>& arguments, std::vector<Poly>& result, TheoryError& errors);
42  bool convertTerm(const types::TermType& term, Poly& result, bool allow_bool = false);
43 
45 
46 };
47 
48 }
49 }
void sort(T *array, int size, LessThan lt)
Definition: Sort.h:67
int var(Lit p)
Definition: SolverTypes.h:64
boost::variant< Poly::ConstructorOperation, carl::Relation > OperatorType
Definition: Arithmetic.h:11
carl::mpl_variant_of< TermTypes >::type TermType
Variant type for all terms.
Definition: TheoryTypes.h:160
carl::mpl_variant_of< VariableTypes >::type VariableType
Variant type for all variables.
Definition: TheoryTypes.h:132
QuantifierType type(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
Definition: QEQuery.h:39
std::vector< carl::Variable > vars(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
Definition: QEQuery.h:43
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
Definition: types.h:37
carl::MultivariatePolynomial< Rational > Poly
Definition: types.h:25
Base class for all theories.
Implements the theory of arithmetic, including LRA, LIA, NRA and NIA.
Definition: Arithmetic.h:16
bool handleDistinct(const std::vector< types::TermType > &arguments, types::TermType &result, TheoryError &errors)
Resolve a distinct operator.
Definition: Arithmetic.cpp:249
std::map< carl::Variable, std::tuple< FormulaT, Poly, Poly > > mITEs
Definition: Arithmetic.h:20
bool instantiate(const types::VariableType &var, const types::TermType &replacement, types::TermType &result, TheoryError &errors)
Instantiate a variable within a term.
Definition: Arithmetic.cpp:259
void addQuantifierToFormula(FormulaT &f)
std::map< carl::Variable, std::tuple< Poly, Poly > > mKnownDivisions
Definition: Arithmetic.h:21
bool functionCall(const Identifier &identifier, const std::vector< types::TermType > &arguments, types::TermType &result, TheoryError &errors)
Resolve another unknown function call.
Definition: Arithmetic.cpp:279
std::map< FormulaT, carl::Variable > mappedFormulas
Definition: Arithmetic.h:39
bool convertTerm(const types::TermType &term, Poly &result, bool allow_bool=false)
Definition: Arithmetic.cpp:8
ArithmeticTheory(ParserState *state)
Definition: Arithmetic.cpp:165
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.
Definition: Arithmetic.cpp:186
bool convertArguments(const arithmetic::OperatorType &op, const std::vector< types::TermType > &arguments, std::vector< Poly > &result, TheoryError &errors)
Definition: Arithmetic.cpp:53
std::map< std::string, arithmetic::OperatorType > ops
Definition: Arithmetic.h:19
bool declareQuantifiedTerm(const std::vector< std::pair< std::string, carl::Sort >> &vars, const carl::FormulaType &type, const types::TermType &term, types::TermType &result, TheoryError &errors)
Resolve a quantified term.
Definition: Arithmetic.cpp:451
bool handleITE(const FormulaT &ifterm, const types::TermType &thenterm, const types::TermType &elseterm, types::TermType &result, TheoryError &errors)
Resolve an if-then-else operator.
Definition: Arithmetic.cpp:203
std::map< carl::Variable, std::tuple< Poly, Poly > > mNewDivisions
Definition: Arithmetic.h:22
static void addSimpleSorts(qi::symbols< char, carl::Sort > &sorts)
Definition: Arithmetic.cpp:159