and
, or
and xor
in CHRs and, as a separate exercise, in Propia.
The constraints are specified as follows:
All boolean variables have domain {0,1}: 0 for 'false' and 1
for 'true'.
and(X,Y,Z) =def (X & Y) = ZSuppose your constraints are called
or(X,Y,Z) =def (X or Y) = Z
xor(X,Y,Z) =def ((X & -Y) or (-X & Y)) = Z
cons_and
, cons_or
and cons_xor
Now write enter the following procedure:
full_adder(I1,I2,I3,O1,O2) :- cons_xor(I1,I2,X1), cons_and(I1,I2,Y1), cons_xor(X1,I3,O1), cons_and(I3,X1,Y2), cons_or(Y1,Y2,O2). |
and get the correct answer.?- full_adder(I1,I2,0,O1,1).