?- happy(X)=sad(jim). [-5pt]---fails, because we know that it is necessary that the principal functors and their arities are the same for unification to succeed.
?- data(X,salary(10000))=data(name(fred),Y). [-5pt]---succeeds, because, having matched the principal functors (and checked that the arities are the same) we recursively try to match corresponding arguments. This generates two subgoals:
X = name(fred)which both succeed.
salary(10000) = Y [-5pt]