# Operations¶

The header `<kitty/operations.hpp>` implements several operations on truth tables.

## Predicates¶

Function
Description

`equal(first, second)`

Checks whether two truth tables are equal.

`less_than(first, second)`

Checks whether a truth table is lexicographically smaller than another.

`has_var(tt, var_index)`

Checks whether truth table depends on given variable index.

`is_const0(tt)`

Checks whether truth table is contant 0.

`implies(first, second)`

Checks if first truth table implies a second truth table.

`intersection_is_empty(first, second)`

Checks whether the intersection of two truth tables is empty.

`intersection_is_empty(first, second, third)`

Checks whether the intersection of three truth tables is empty.

## Combination and manipulation¶

Function
Description

`unary_not(tt)`

Inverts all bits in a truth table.

`binary_and(first, second)`

Bitwise AND of two truth tables.

`binary_or(first, second)`

Bitwise OR of two truth tables.

`binary_xor(first, second)`

Bitwise XOR of two truth tables.

`ternary_ite(first, second, third)`

Performs ternary if-then-else of three truth tables.

`ternary_majority(first, second, third)`

Ternary majority of three truth tables.

`mux_var(var_index, then_, else_)`

Muxes two truth tables based on a variable.

`next_inplace(tt)`

Computes the next lexicographically larger truth table.

`next(tt)`

Returns the next lexicographically larger truth table.

`cofactor0_inplace(tt, var_index)`

Computes co-factor with respect to 0.

`cofactor0(tt, var_index)`

Returns co-factor with respect to 0.

`cofactor1_inplace(tt, var_index)`

Computes co-factor with respect to 1.

`cofactor1(tt, var_index)`

Returns co-factor with respect to 1.

`swap_inplace(tt, var_index1, var_index2)`

Swaps two variables in a truth table.

`swap(tt, var_index1, var_index2)`

Swaps two adjacent variables in a truth table.

`swap_adjacent_inplace(tt, var_index)`

Swaps two adjacent variables in a truth table.

`swap_adjacent(tt, var_index)`

Swaps two adjacent variables in a truth table.

`flip_inplace(tt, var_index)`

Flips a variable in a truth table.

`flip(tt, var_index)`

Flips a variable in a truth table.

`min_base_inplace(tt)`

Reorders truth table to have minimum base.

`expand_inplace(tt, support)`

Expands truth table from minimum base to original based on support.

`extend_to_inplace(tt, from)`

Extends smaller truth table to larger one.

`extend_to(from)`

Extends smaller truth table to larger static one.

`extend_to(from, num_vars)`

Extends smaller truth table to larger dynamic one.

`shrink_to_inplace(tt, from)`

Shrinks larger truth table to smaller one.

`shrink_to(from)`

Shrinks larger truth table to smaller static one.

`shrink_to(from, num_vars)`

Shrinks larger truth table to smaller dynamic one.

`shift_left_inplace(tt, shift)`

Left-shift truth table.

`shift_left(tt, shift)`

Left-shift truth table.

`shift_right_inplace(tt, shift)`

Right-shift truth table.

`shift_right(tt, shift)`

Right-shift truth table.

`shift_with_mask_inplace(f, mask)`

Shifts a small truth table with respect to a mask.

`shift_with_mask(f, mask)`

Shifts a small truth table with respect to a mask.