Substituting product of functions with function of several arguments
I have expressions of the general form as in an example below
Here T[n] is an undefined function with integer arguments. I use this function as an intermediate step in calculation. In the end of calculations I need to substitute products of these functions by another known functions t[k][n1,n2,n3,...], where k is number of the arguments n1,n2,n3,.... Couple of examples of the substitution rule that should clarify the general structure are below:
Since in my expressions I have a fixed maximal number of terms in the product I was thinking to perform everything with a set of simple substitution rules (here assuming at most product of three T's are present)
The problem with this approach is that it treats powers T[n]^k incorrectly. Also it would be great if there can be a way to do this substitution for an arbitrary length of product without specifying rule for each length.
or, if the arguments to t should be in canonical order
You can put the T-to-t[k] rule as part of the definition of expandT[] if you wish. I'd probably like to keep them separated out, just in case I need to troubleshoot. In fact, I think I'd just define T[] as it is in Block[] above, and let the expression update itself as the calculation proceeds. Then replace T by t[k]. However, I don't know your full use-case, and there may be reasons why that would not work.
Include the attribute OneIdentity if T[] can occur. According to the catenate-the-arguments rule, multiplying by T[] is the same as multiplying by 1. This is the effect that including OneIdentity would have. (A different behavior was not specified, so probably T[] just doesn't come up.)
Gratuitous bonus: You can factor T[n1,...] back into a product of T[n] as follows (if T is undefined):
It also works on the t[k][n1,...] forms: