Skip to content

Commit

Permalink
multiplication is variadic (stanford-centaur#341)
Browse files Browse the repository at this point in the history
This allows for creating multiplication-terms with more than two arguments.
  • Loading branch information
ffrohn authored and CyanoKobalamyne committed May 15, 2024
1 parent 60f9389 commit 61ff06a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ namespace std
namespace smt {
// ops that can be applied to n arguments
const std::unordered_set<PrimOp> variadic_ops(
{ And, Or, Xor, Plus, BVAnd, BVOr, BVAdd });
{ And, Or, Xor, Plus, Mult, BVAnd, BVOr, BVAdd });

bool is_variadic(PrimOp po);
} // namespace smt
21 changes: 21 additions & 0 deletions tests/test-int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@ class IntTests : public ::testing::Test,
Sort intsort;
};

// test for creating variadic mult-terms
TEST_P(IntTests, Mult)
{
Term two = s->make_term(2, intsort);
Term three = s->make_term(3, intsort);
Term four = s->make_term(4, intsort);
Term twentyfour = s->make_term(24, intsort);
Term mult;
try
{
mult = s->make_term(Mult, {two, three, four});
}
catch (const IncorrectUsageException &e)
{
FAIL() << "creating mult-term failed: " << e.what();
}
s->assert_formula(s->make_term(Equal, twentyfour, mult));
auto res = s->check_sat();
assert(res.is_sat());
}

TEST_P(IntTests, IntDiv)
{
Term five = s->make_term(5, intsort);
Expand Down

0 comments on commit 61ff06a

Please sign in to comment.