# Issues with 'integrate_by_parts'

I want to implement the following integration by parts

\nabla{#}::Derivative.
{A,B,C}::Depends(\nabla{#}).
tr{#}::Trace.
ex:=\int{\tr{A}\tr{B\nabla{C}}};
integrate_by_parts(_,$C$);


I have a try

substitute(_,$\tr{A??}\tr{B?? \nabla{C??}}->-\tr{\nabla{A??}}\tr{B?? C??}-\tr{A??}\tr{\nabla{B??} C??}$);


Is there is any simpler way to implement it?

For now you will have to do this 'by hand' like you did with the substitute. Once you allow for derivative operators to be taken out of traces like this, there are potentially many edge cases which you have to be aware of, and integrate_by_parts therefore does not do this.

If I substitute 'tr' into '\int', for example,

\nabla{#}::Derivative.
{A,B,C}::Depends(\nabla{#}).
tr{#}::Trace.
ex:=tr{A} tr{B\nabla{C}};
substitute(_,$tr{A??}->\int{A??}$);


Is there possible to find a more direct solution of this question? As you know, sometimes it is very tedious to do this all "by hand" with the substitute, because the actual situation may be very complicated.