From 85b7cc0d2303caee20fa33e7de316e0a60fe6506 Mon Sep 17 00:00:00 2001 From: Mathias Soeken Date: Sat, 23 Jun 2018 08:23:30 -0700 Subject: [PATCH] Property function: is_symmetric_in. --- docs/changelog.rst | 3 +++ docs/properties.rst | 1 + include/kitty/properties.hpp | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 07246000..5e77ec02 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -13,6 +13,9 @@ v0.5 (not yet released) * Assignment operator for truth tables `#54 `_ +* Function properties: ``is_symmetric_in`` + `#55 `_ + v0.4 (May 4, 2018) ------------------ diff --git a/docs/properties.rst b/docs/properties.rst index bc8108ad..45814b43 100644 --- a/docs/properties.rst +++ b/docs/properties.rst @@ -9,3 +9,4 @@ properties. is_canalizing is_horn is_krom + is_symmetric_in diff --git a/include/kitty/properties.hpp b/include/kitty/properties.hpp index 74f5eef4..4049ca97 100644 --- a/include/kitty/properties.hpp +++ b/include/kitty/properties.hpp @@ -37,6 +37,8 @@ #include #include "bit_operations.hpp" +#include "operations.hpp" +#include "operators.hpp" namespace kitty { @@ -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 +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