I’d love a better understanding of what’s happening with that X=Y, and why it doesn’t say X=3. Is SWI-Prolog doing some kind of variable aliasing as an optimization?
SWI-Prolog could have also output X=3,Y=3 and that’s exactly equivalent to X=Y,Y=3 – there is no way that you can distinguish the two. It’s more compact to write it as X=Y if the result is some large complex term.
Put another way, X=Y means that there is no way to distinguish X and Y. These statements produce the same result: