Skip to content

Commit 9e3edf7

Browse files
Merge pull request #6254 from thomasspriggs/tas/smt2_more_logics
Add data structures for setting different smt2 logics in incremental solving
2 parents 7601ad5 + ccfbaee commit 9e3edf7

File tree

5 files changed

+44
-17
lines changed

5 files changed

+44
-17
lines changed

src/solvers/smt2_incremental/smt_logics.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <solvers/smt2_incremental/smt_logics.h>
44

55
// Define the irep_idts for logics.
6-
#define LOGIC_ID(the_id) \
6+
#define LOGIC_ID(the_id, the_name) \
77
const irep_idt ID_smt_logic_##the_id{"smt_logic_" #the_id};
88
#include <solvers/smt2_incremental/smt_logics.def>
99
#undef LOGIC_ID
@@ -21,7 +21,7 @@ bool smt_logict::operator!=(const smt_logict &other) const
2121
template <typename visitort>
2222
void accept(const smt_logict &logic, const irep_idt &id, visitort &&visitor)
2323
{
24-
#define LOGIC_ID(the_id) \
24+
#define LOGIC_ID(the_id, the_name) \
2525
if(id == ID_smt_logic_##the_id) \
2626
return visitor.visit(static_cast<const smt_logic_##the_id##t &>(logic));
2727
// The include below is marked as nolint because including the same file
@@ -41,7 +41,10 @@ void smt_logict::accept(smt_logic_const_downcast_visitort &&visitor) const
4141
::accept(*this, id(), std::move(visitor));
4242
}
4343

44-
smt_logic_quantifier_free_bit_vectorst::smt_logic_quantifier_free_bit_vectorst()
45-
: smt_logict{ID_smt_logic_quantifier_free_bit_vectors}
46-
{
47-
}
44+
#define LOGIC_ID(the_id, the_name) \
45+
smt_logic_##the_id##t::smt_logic_##the_id##t() \
46+
: smt_logict{ID_smt_logic_##the_id} \
47+
{ \
48+
}
49+
#include "smt_logics.def"
50+
#undef LOGIC_ID

src/solvers/smt2_incremental/smt_logics.def

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@
66
/// * The constant `irep_idt`s used to identify each of the logic classes.
77
/// * The member functions of the `smt_logic_const_downcast_visitort` class.
88
/// * The type of option checks required to implement `smt_logict::accept`.
9-
LOGIC_ID(quantifier_free_bit_vectors)
9+
LOGIC_ID(quantifier_free_uninterpreted_functions, QF_UF)
10+
LOGIC_ID(quantifier_free_bit_vectors, QF_BV)
11+
LOGIC_ID(quantifier_free_uninterpreted_functions_bit_vectors, QF_UFBV)
12+
LOGIC_ID(quantifier_free_bit_vectors_arrays, QF_ABV)
13+
LOGIC_ID(quantifier_free_uninterpreted_functions_bit_vectors_arrays, QF_AUFBV)
14+
LOGIC_ID(all, ALL)

src/solvers/smt2_incremental/smt_logics.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,21 @@ const smt_logict &smt_logict::storert<derivedt>::downcast(const irept &irep)
6161
return static_cast<const smt_logict &>(irep);
6262
}
6363

64-
class smt_logic_quantifier_free_bit_vectorst : public smt_logict
65-
{
66-
public:
67-
smt_logic_quantifier_free_bit_vectorst();
68-
};
64+
#define LOGIC_ID(the_id, the_name) \
65+
/* NOLINTNEXTLINE(readability/identifiers) cpplint does not match the ## */ \
66+
class smt_logic_##the_id##t : public smt_logict \
67+
{ \
68+
public: \
69+
smt_logic_##the_id##t(); \
70+
};
71+
#include "smt_logics.def"
72+
#undef LOGIC_ID
6973

7074
class smt_logic_const_downcast_visitort
7175
{
7276
public:
73-
#define LOGIC_ID(the_id) virtual void visit(const smt_logic_##the_id##t &) = 0;
77+
#define LOGIC_ID(the_id, the_name) \
78+
virtual void visit(const smt_logic_##the_id##t &) = 0;
7479
#include "smt_logics.def"
7580
#undef LOGIC_ID
7681
};

src/solvers/smt2_incremental/smt_to_smt2_string.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,13 @@ class smt_logic_to_string_convertert : public smt_logic_const_downcast_visitort
265265
{
266266
}
267267

268-
void visit(const smt_logic_quantifier_free_bit_vectorst &) override
269-
{
270-
os << "QF_BV";
268+
#define LOGIC_ID(the_id, the_name) \
269+
void visit(const smt_logic_##the_id##t &) override \
270+
{ \
271+
os << #the_name; \
271272
}
273+
#include "smt_logics.def"
274+
#undef LOGIC_ID
272275
};
273276

274277
std::ostream &operator<<(std::ostream &os, const smt_logict &logic)

unit/solvers/smt2_incremental/smt_to_smt2_string.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,19 @@ TEST_CASE(
137137
"Test smt_set_logic_commandt to string conversion",
138138
"[core][smt2_incremental]")
139139
{
140-
const smt_logic_quantifier_free_bit_vectorst qf_bv;
140+
const auto qf_uf = smt_logic_quantifier_free_uninterpreted_functionst{};
141+
CHECK(smt_to_smt2_string(qf_uf) == "QF_UF");
142+
const auto qf_bv = smt_logic_quantifier_free_bit_vectorst{};
141143
CHECK(smt_to_smt2_string(qf_bv) == "QF_BV");
144+
const auto qf_ufbv =
145+
smt_logic_quantifier_free_uninterpreted_functions_bit_vectorst{};
146+
CHECK(smt_to_smt2_string(qf_ufbv) == "QF_UFBV");
147+
const auto qf_abv = smt_logic_quantifier_free_bit_vectors_arrayst{};
148+
CHECK(smt_to_smt2_string(qf_abv) == "QF_ABV");
149+
const auto qf_aufbv =
150+
smt_logic_quantifier_free_uninterpreted_functions_bit_vectors_arrayst{};
151+
CHECK(smt_to_smt2_string(qf_aufbv) == "QF_AUFBV");
152+
CHECK(smt_to_smt2_string(smt_logic_allt{}) == "ALL");
142153
CHECK(
143154
smt_to_smt2_string(smt_set_logic_commandt{qf_bv}) == "(set-logic QF_BV)");
144155
}

0 commit comments

Comments
 (0)