Discrete mathematics to find the truth table of the appropriate formula (Java implementation)