Simplifying a polynomial Let $f(x_1,\ldots, x_n)\in\Bbbk [x_1,\ldots,x_n]$ be a given polynomial (assume $\Bbbk$ algebraically closed if you want). Suppose that we are given $n$ polynomials $v_1,\ldots v_n \in\Bbbk[x_1,\ldots, x_n]$. Suppose that we know that there exists a polynomial $P(t_1,\ldots,t_n)\in\Bbbk[t_1,\ldots,t_n]$ such that 
$$f(x_1,\ldots,x_n)=P(v_1(x_1,\ldots,x_n),\ldots,v_n(x_1,\ldots,x_n))\in\Bbbk[x_1,\ldots,x_n]$$

How to find $P$ explicitely? Is there a computer program that can easily solve this problem?

I'm also interested in answers under the hypothesis that $v_1,\ldots, v_n$ are homogeneus of degrees $d_1,\ldots, d_n$ (and possibly some symplifying assumptions on $d_i$), and/or $f$ is itself homogeneus.
To me this is just a practical question which is natural enough to be asked on MO; I apologize if it is totally trivial for some people more knowledgeable in computational matters.
 A: This is the (multivariate) functional decomposition problem.  It has a long history, going back to 1922 work by Ritt and 1941 work by Engstrom.  See the introduction to Algorithms for the Functional Decomposition of Laurent Polynomials by Stephen Watt for a nice historical overview.  You will also be interested in references 1-8 in that paper.
The most recent work (on the multivariate) case that I am aware of is that of Faugère and Perret (see also the slides for the talk and a journal version).  Their algorithm is non-trivial, and trying to explain it here would amount to reproducing their paper, so I won't do that.
EDIT: Note that most of these algorithms are in two pieces.  As was pointed out, just one of these pieces is really needed here.  And while GB can be used, the good thing about the functional decomposition algorithms is that they are able to use all of the structure present in the problem, which is really too much to ask for from a generic GB.
A: It is a standard problem for Groebner basis theory, see for example Ideals, varieties, and algorithms by David Cox, John Little, Donal O'Shea.
In the polynomial ring $k[x_1,x_2,\ldots,x_n,y_1,\ldots,y_n,f]$  consider the ideal $I=(f-f(x_1,\ldots,x_n), y_1-v_1(x_1,\ldots,x_n),\ldots,y_n-v_n(x_1,\ldots,x_n))$.If we  eliminate the variables $x_1,x_2,\ldots,x_n$ by using Groebner basis and  if  we  get a elimination relation  of the following  form $f-F(y_1,\ldots,y_n)$  for some polynomial $F$, then $F$  is the looking polynomial and we  obtain  that $f(x_1,\ldots,x_n)=F(v_1,v_2,\ldots,v_n).$
