My question is quite simple and iI understand what I have to do, but it seems like I can't represent my understanding. How to write predicates to define gates such as XOR or NOR in terms of a NAND gate rules?
for example :
nand(t,t,f).
nand(t,f,t).
nand(f,t,t).
nand(f,f,t).
Above is a truth table for nand gate. Now if I want to define XOR gate using the above terms in Prolog, for example I need to ask Prolog about XOR(X,Y,Z) , it would give me three possible answers, how should I build a predicate to define it?
Thank You
NOT(A AND B). NOR isNOT(A OR B). Use logical rules such asNOT(A OR B)is equivalent to(NOT A) AND (NOT B). How do you getNOT Afrom NAND? Easy:NOT A = NAND(A, A). Do a little work from there to figure outnor(A, B, C). - lurker