>>166
% Prolog

?- 'A'(A,'X'),'B'(A,B),(retract('C'(B,_)),fail;assertz('C'(B,'Y'))).