FullForm derivative in your expression
In[145]:= D[f[x,y],x]//FullForm Out[145]//FullForm= Derivative[1,0][f][x,y]
This should explain why the first rule failed - f[x,y] is no longer in your expression. The second rule failed because Derivative considers f function, while you substitute it with an expression. What you can do is:
In[146]:= D[f[x,y],x]/.f->(
Note that parentheses around a pure function are needed to avoid priority-related errors.
Alternatively, you can define your rhs templates:
In[148]:= fn[x_,y_]:=x*y; D[f[x,y],x]/.f->fn Out[149]= y
NTN
Leonid Shifrin
source share