Skip to content

Commit 779f2e3

Browse files
authored
Property function: is_symmetric_in. (#55)
1 parent fdc336e commit 779f2e3

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

docs/changelog.rst

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ v0.5 (not yet released)
1313
* Assignment operator for truth tables
1414
`#54 <https://github.com/msoeken/kitty/pull/54>`_
1515

16+
* Function properties: ``is_symmetric_in``
17+
`#55 <https://github.com/msoeken/kitty/pull/55>`_
18+
1619
v0.4 (May 4, 2018)
1720
------------------
1821

docs/properties.rst

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ properties.
99
is_canalizing
1010
is_horn
1111
is_krom
12+
is_symmetric_in

include/kitty/properties.hpp

+16
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#include <vector>
3838

3939
#include "bit_operations.hpp"
40+
#include "operations.hpp"
41+
#include "operators.hpp"
4042

4143
namespace kitty
4244
{
@@ -158,4 +160,18 @@ bool is_krom( const TT& tt )
158160
return true;
159161
}
160162

163+
/*! \brief Checks whether a function is symmetric in a pair of variables
164+
165+
A function is symmetric in two variables, if it is invariant to swapping them.
166+
167+
\param tt Truth table
168+
\param var_index1 Index of first variable
169+
\param var_index2 Index of second variable
170+
*/
171+
template<typename TT>
172+
bool is_symmetric_in( const TT& tt, uint8_t var_index1, uint8_t var_index2 )
173+
{
174+
return tt == swap( tt, var_index1, var_index2 );
175+
}
176+
161177
} // namespace kitty

0 commit comments

Comments
 (0)