Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property function: is_symmetric_in. #55

Merged
merged 1 commit into from
Jun 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ v0.5 (not yet released)
* Assignment operator for truth tables
`#54 <https://github.com/msoeken/kitty/pull/54>`_

* Function properties: ``is_symmetric_in``
`#55 <https://github.com/msoeken/kitty/pull/55>`_

v0.4 (May 4, 2018)
------------------

Expand Down
1 change: 1 addition & 0 deletions docs/properties.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ properties.
is_canalizing
is_horn
is_krom
is_symmetric_in
16 changes: 16 additions & 0 deletions include/kitty/properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include <vector>

#include "bit_operations.hpp"
#include "operations.hpp"
#include "operators.hpp"

namespace kitty
{
Expand Down Expand Up @@ -158,4 +160,18 @@ bool is_krom( const TT& tt )
return true;
}

/*! \brief Checks whether a function is symmetric in a pair of variables

A function is symmetric in two variables, if it is invariant to swapping them.

\param tt Truth table
\param var_index1 Index of first variable
\param var_index2 Index of second variable
*/
template<typename TT>
bool is_symmetric_in( const TT& tt, uint8_t var_index1, uint8_t var_index2 )
{
return tt == swap( tt, var_index1, var_index2 );
}

} // namespace kitty