My feeling is that with trace, you don't get detailed information why a unification fails, but you get information which goals fail.
If the latter information is what you want, you can do this by yourself, in that you instrument your code. Just replace every goal
.. A ..
By the following code:
.. in(A), A, out(A) ..
With the following definitions:
in(A) :- write('call '), write(A), nl.
in(A) :- write('fail '), write(A), nl, fail.
out(A) :- write('exit '), write(A), nl.
out(A) :- write('redo '), write(A), nl, fail.
Of course you can replace the write/1 and nl/0 statements with what ever suits you. Here is an example. First the instrumented Prolog text:
?- [user].
mem(X,[X|_]).
mem(X,[_|Y]) :- in(mem(X,Y)), mem(X,Y), out(mem(X,Y)).
^D
And now the instrumented query:
?- in(mem(X,[1,2])), mem(X,[1,2]), out(mem(X,[1,2])).
call mem(_G1479,[1,2])
exit mem(1,[1,2])
X = 1 ;
redo mem(1,[1,2])
call mem(_G1479,[2])
exit mem(2,[2])
exit mem(2,[1,2])
X = 2 ;
redo mem(2,[1,2])
redo mem(2,[2])
call mem(_G1479,[])
fail mem(_G1479,[])
fail mem(_G1479,[2])
fail mem(_G1479,[1,2])
false.
Bye