and(1,1).
not(0).
or(1,1).
or(1,0).
or(0,1).
xor(1,0).
xor(0,1).
xnor(0,0).
xnor(1,1).
correto(1).
sum(P,Q,Cin):-xor(P,Q),not(Cin).
sum(P,Q,Cin):-xnor(P,Q),correto(Cin).
carryOut(P,Q,Cin):-and(P,Q),not(Cin).
carryOut(P,Q,Cin):-or(P,Q),correto(Cin).
not(0).
or(1,1).
or(1,0).
or(0,1).
xor(1,0).
xor(0,1).
xnor(0,0).
xnor(1,1).
correto(1).
sum(P,Q,Cin):-xor(P,Q),not(Cin).
sum(P,Q,Cin):-xnor(P,Q),correto(Cin).
carryOut(P,Q,Cin):-and(P,Q),not(Cin).
carryOut(P,Q,Cin):-or(P,Q),correto(Cin).
