Is there a dif with occurs check? This here works:
Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.7)
?- set_prolog_flag(occurs_check, true).
true.
?- dif(X,f(Y)), X = Y.
X = Y.
But the above is not feasible, since occurs check is a global flag, I get the following:
SWI-Prolog console for thread 3
?- X=f(X).
false.