38 if (terms.size() == 0) {
39 throw std::invalid_argument(
"Empty vector occured during STuple initialization");
41 this->solver = terms[0].
solver;
44 terms_.reserve(terms.size());
45 auto map = [](
const STerm& t) -> cvc5::Term {
return t.term; };
56 cvc5::Term eq = this->solver->
term_manager.mkTerm(cvc5::Kind::EQUAL, { this->
term, other.
term });
66 cvc5::Term eq = this->solver->
term_manager.mkTerm(cvc5::Kind::EQUAL, { this->
term, other.
term });
67 eq = this->solver->
term_manager.mkTerm(cvc5::Kind::NOT, { eq });
76 cvc5::Sort
get_sort()
const {
return this->term.getSort(); }
79 operator cvc5::Term()
const {
return term; };
83 return out << static_cast<std::string>(
term);
108template <
typename sym_index, ConstructibleFromTerm sym_entry>
class SymArray {
130 throw std::logic_error(
"You have to enable lookups during Solver initialization");
149 const std::string& name =
"")
155 throw std::logic_error(
"You have to enable lookups during Solver initialization");
162 this->term = this->solver->
term_manager.mkConst(Array, name);
175 const std::string& name =
"")
177 if (entries.size() == 0 ||
indicies.size() == 0) {
178 throw std::invalid_argument(
"Empty vector occured during SymArray initialization");
181 if (entries.size() !=
indicies.size()) {
182 throw std::invalid_argument(
"Indicies must have the same dimension as entries.");
185 this->solver = entries[0].
solver;
188 throw std::logic_error(
"You have to enable lookups during Solver initialization");
192 this->entry_type = entries[0].type;
195 cvc5::Sort
entry_sort = entries[0].term.getSort();
200 this->term = this->solver->
term_manager.mkConst(Array, name);
205 this->solver->
term_manager.mkTerm(cvc5::Kind::STORE, { this->
term, indicies[
i].term, entries[
i].term });
221 if (entries.size() == 0) {
222 throw std::invalid_argument(
"Empty vector occured during SymArray initialization");
224 this->solver = entries[0].
solver;
227 throw std::logic_error(
"You have to enable lookups during Solver initialization");
230 this->entry_type = entries[0].type;
233 cvc5::Sort
entry_sort = entries[0].term.getSort();
238 this->term = this->solver->
term_manager.mkConst(Array, name);
241 for (
size_t i = 0;
i < entries.size();
i++) {
243 this->term = this->solver->
term_manager.mkTerm(cvc5::Kind::STORE, { this->
term,
idx, entries[
i] });
257 this->term = this->solver->
term_manager.mkTerm(cvc5::Kind::STORE, { this->
term, ind.term,
entry.term });
261 operator cvc5::Term()
const {
return term; };
289template <ConstructibleFromTerm sym_entry>
class SymSet {
321 throw std::logic_error(
"You have to enable lookups during Solver initialization");
324 cvc5::Sort Array = this->solver->
term_manager.mkSetSort(entry_sort);
328 this->term = this->solver->
term_manager.mkConst(Array, name);
340 if (entries.size() == 0) {
341 throw std::invalid_argument(
"Empty vector occured during SymSet initialization");
344 this->solver = entries[0].
solver;
346 throw std::logic_error(
"You have to enable lookups during Solver initialization");
349 this->entry_type = entries[0].type;
351 cvc5::Sort entry_sort = entries[0].term.getSort();
352 cvc5::Sort SET = this->solver->
term_manager.mkSetSort(entry_sort);
356 this->term = this->solver->
term_manager.mkConst(SET, name);
360 terms_.reserve(entries.size() + 1);
361 auto map = [](
const sym_entry& t) -> cvc5::Term {
return t.term; };
364 terms_.push_back(this->term);
365 this->term = this->solver->
term_manager.mkTerm(cvc5::Kind::SET_INSERT, terms_);
370 this->term = this->solver->
term_manager.mkTerm(cvc5::Kind::SET_INSERT, { entry.term, this->term });
383 sym_entry left = entry;
384 cvc5::Term inclusion = this->solver->
term_manager.mkTerm(cvc5::Kind::SET_MEMBER, { entry.term, this->term });
397 sym_entry left = entry;
398 cvc5::Term inclusion = this->solver->
term_manager.mkTerm(cvc5::Kind::SET_MEMBER, { entry.term, this->term });
399 cvc5::Term not_inclusion = this->solver->
term_manager.mkTerm(cvc5::Kind::NOT, { inclusion });
404 operator cvc5::Term()
const {
return term; };
410 return out << static_cast<std::string>(
term);
std::pair< std::string, size_t > print_set_trace(const cvc5::Term &term, bool is_head=true)
print the trace of SET insertions up to previously printed ones
void assertFormula(const cvc5::Term &term) const
std::pair< std::string, size_t > print_array_trace(const cvc5::Term &term, bool is_head=true)
print the trace of array assigments up to previously printed ones
cvc5::TermManager term_manager
std::string stringify_term(const cvc5::Term &term, bool parenthesis=false)
Symbolic term element class.
static STerm Const(const std::string &val, Solver *slv, uint32_t base=16, TermType type=TermType::FFTerm)
STuple & operator=(STuple &&right)=default
STuple(const std::vector< STerm > &terms)
Construct a new STuple object.
friend std::ostream & operator<<(std::ostream &out, const STuple &term)
void operator!=(const STuple &other) const
STuple & operator=(const STuple &right)=default
STuple(STuple &&other)=default
void operator==(const STuple &other) const
cvc5::Sort get_sort() const
Get the obtained tuple sort.
operator cvc5::Term() const
STuple(const cvc5::Term &term, Solver *s, TermType type=TermType::STuple)
STuple(const STuple &other)=default
void put(const sym_index &ind, const sym_entry &entry)
SymArray & operator=(SymArray &&right)=default
SymArray(const cvc5::Term &term, Solver *s, TermType type=TermType::SymArray)
sym_entry get(const sym_index &ind) const
SymArray(const cvc5::Sort &index_sort, const TermType &index_type, const cvc5::Sort &entry_sort, const TermType &entry_type, Solver *s, const std::string &name="")
Construct an empty Symbolic Array object.
operator cvc5::Term() const
SymArray & operator=(const SymArray &right)=default
SymArray(const std::vector< sym_entry > &entries, const STerm &index_base, const std::string &name="")
Construct a new Symbolic Array object.
sym_entry operator[](const sym_index &ind) const
SymArray(const SymArray &other)=default
friend std::ostream & operator<<(std::ostream &out, const SymArray &term)
SymArray(const std::vector< sym_index > &indicies, const std::vector< sym_entry > &entries, const std::string &name="")
Construct a new Symbolic Array object.
SymArray(SymArray &&other)=default
void insert(const sym_entry &entry)
SymSet(const std::vector< sym_entry > &entries, const std::string &name="")
Construct a new Symbolic Set object.
SymSet & operator=(const SymSet &right)=default
SymSet(SymSet &&other)=default
SymSet(const SymSet &other)=default
void not_contains(const sym_entry &entry) const
Create an inclusion constraint.
operator cvc5::Term() const
SymSet(const cvc5::Term &term, Solver *s, TermType type=TermType::SymSet)
SymSet(const cvc5::Sort &entry_sort, TermType entry_type, Solver *s, const std::string &name="")
Construct a new empty Symbolic Set object.
friend std::ostream & operator<<(std::ostream &out, const SymSet &term)
SymSet & operator=(SymSet &&right)=default
void contains(const sym_entry &entry) const
Create an inclusion constraint.
TermType
Allows to define three types of symbolic terms STerm - Symbolic Variables acting like a Finte Field e...
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept