Refactoring for automatic truth table generation