termunify(X,Y) :-
	var(X),!,
	X = Y.

termunify(X,Y) :-
	var(Y),!,
	X = Y.

termunify(X,Y) :-
	X =.. [XFunctor|XArgs],
	Y =.. [YFunctor|YArgs],
	XFunctor=YFunctor,
	unifyArgs(XArgs,YArgs).

unifyArgs([],[]).
unifyArgs([X|Xs],[Y|Ys]) :-
	termunify(X,Y),
	unifyArgs(Xs,Ys).
