Nested automatization of type inference of forall elimination
This can be solved as easily as the other problem, as in this solution. It's basically unification. 


Ensure that the variables $X_1,\ldots,X_n$ do not appear in $V$. Replace
any variables that do by fresh ones and perform appropriate substitution into $W$.
Unify $V$ and $W$ using an algorithm that finds the most general unifier (mgu). The essence of this is in the other algorithm, or, for example, page 10 of this.
The resulting mgu $[\bar{X}/\bar{W}]$ is the subtitution you require.