// // true = 1 // false = 0 // // Using only +,-,*, Math.max, Math.min define the following functions // not, and, or, xor, implies, ifOnlyIf // public class Logic { public static int not(int p){return -999;} public static int and(int p, int q){return -999;} public static int or(int p, int q){return -999;} public static int xor(int p, int q){return -999;} public static int implies(int p, int q){return -999;} public static int ifOnlyIf(int p, int q){return -999;} public static void truthTable(){ System.out.println("P Q & | xor -> <->"); for (int p=0;p<2;p++) for (int q=0;q<2;q++) System.out.println(p + " " + q + " " + and(p,q) + " " + or(p,q) + " " + xor(p,q) + " " + implies(p,q) + " " + ifOnlyIf(p,q)); } public static void obfuscate2(){ for (int p=0;p<2;p++) for (int q=0;q<2;q++) System.out.println(p + " " + q + " " + implies(and(q,implies(p,not(q))),not(p))); } public static void obfuscate3(){ for (int p=0;p<2;p++) for (int q=0;q<2;q++) for (int r=0;q<2;q++) System.out.println(p + " " + q + " " + r + " " + and(p,and(not(q),or(implies(p,r),ifOnlyIf(q,r))))); } public static void main(String[] args) { truthTable(); System.out.println(); obfuscate2(); obfuscate3(); } }