Skip to content

Commit

Permalink
Add 'bdd_top()' and 'bdd_bot()' to API
Browse files Browse the repository at this point in the history
These are mere aliases for 'bdd_true()' and 'bdd_false()', but we add these to
create consistency with the to-be added ZDD versions
  • Loading branch information
SSoelvsten committed Sep 24, 2023
1 parent 155344d commit 61bcee8
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/adiar/bdd.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,23 @@ namespace adiar
//////////////////////////////////////////////////////////////////////////////
bdd bdd_false();

//////////////////////////////////////////////////////////////////////////////
/// \see bdd_false
//////////////////////////////////////////////////////////////////////////////
inline bdd bdd_bot()
{ return bdd_false(); }

//////////////////////////////////////////////////////////////////////////////
/// \brief The BDD representing the constant `true` BDD.
//////////////////////////////////////////////////////////////////////////////
bdd bdd_true();

//////////////////////////////////////////////////////////////////////////////
/// \see bdd_true
//////////////////////////////////////////////////////////////////////////////
inline bdd bdd_top()
{ return bdd_true(); }

//////////////////////////////////////////////////////////////////////////////
/// \brief The BDD representing the i'th variable.
///
Expand Down
58 changes: 58 additions & 0 deletions test/adiar/bdd/test_build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,35 @@ go_bandit([]() {
AssertThat(res->number_of_terminals[true], Is().EqualTo(1u));
});

it("can create true terminal [bdd_top]", [&]() {
bdd res = bdd_top();
node_test_stream ns(res);

AssertThat(ns.can_pull(), Is().True());
AssertThat(ns.pull(), Is().EqualTo(node(true)));
AssertThat(ns.can_pull(), Is().False());

level_info_test_stream ms(res);
AssertThat(ms.can_pull(), Is().False());

AssertThat(res->width, Is().EqualTo(0u));

AssertThat(res->max_1level_cut[cut_type::INTERNAL], Is().EqualTo(0u));
AssertThat(res->max_1level_cut[cut_type::INTERNAL_FALSE], Is().EqualTo(0u));
AssertThat(res->max_1level_cut[cut_type::INTERNAL_TRUE], Is().EqualTo(1u));
AssertThat(res->max_1level_cut[cut_type::ALL], Is().EqualTo(1u));

AssertThat(res->max_2level_cut[cut_type::INTERNAL], Is().EqualTo(0u));
AssertThat(res->max_2level_cut[cut_type::INTERNAL_FALSE], Is().EqualTo(0u));
AssertThat(res->max_2level_cut[cut_type::INTERNAL_TRUE], Is().EqualTo(1u));
AssertThat(res->max_2level_cut[cut_type::ALL], Is().EqualTo(1u));

AssertThat(adiar::is_canonical(res), Is().True());

AssertThat(res->number_of_terminals[false], Is().EqualTo(0u));
AssertThat(res->number_of_terminals[true], Is().EqualTo(1u));
});

it("can create false terminal [bdd_terminal]", [&]() {
bdd res = bdd_terminal(false);
node_test_stream ns(res);
Expand Down Expand Up @@ -121,6 +150,35 @@ go_bandit([]() {
AssertThat(res->number_of_terminals[false], Is().EqualTo(1u));
AssertThat(res->number_of_terminals[true], Is().EqualTo(0u));
});

it("can create false terminal [bdd_bot]", [&]() {
bdd res = bdd_bot();
node_test_stream ns(res);

AssertThat(ns.can_pull(), Is().True());
AssertThat(ns.pull(), Is().EqualTo(node(false)));
AssertThat(ns.can_pull(), Is().False());

level_info_test_stream ms(res);
AssertThat(ms.can_pull(), Is().False());

AssertThat(res->width, Is().EqualTo(0u));

AssertThat(res->max_1level_cut[cut_type::INTERNAL], Is().EqualTo(0u));
AssertThat(res->max_1level_cut[cut_type::INTERNAL_FALSE], Is().EqualTo(1u));
AssertThat(res->max_1level_cut[cut_type::INTERNAL_TRUE], Is().EqualTo(0u));
AssertThat(res->max_1level_cut[cut_type::ALL], Is().EqualTo(1u));

AssertThat(res->max_2level_cut[cut_type::INTERNAL], Is().EqualTo(0u));
AssertThat(res->max_2level_cut[cut_type::INTERNAL_FALSE], Is().EqualTo(1u));
AssertThat(res->max_2level_cut[cut_type::INTERNAL_TRUE], Is().EqualTo(0u));
AssertThat(res->max_2level_cut[cut_type::ALL], Is().EqualTo(1u));

AssertThat(adiar::is_canonical(res), Is().True());

AssertThat(res->number_of_terminals[false], Is().EqualTo(1u));
AssertThat(res->number_of_terminals[true], Is().EqualTo(0u));
});
});

describe("bdd_ithvar(i)", [&]() {
Expand Down

0 comments on commit 61bcee8

Please sign in to comment.