Suppose I have a polynomial like this: $$a=x_{j_1} + x_{j_1}x_{j_2} + x_{j_1}x_{j_2}x_{j_3} + ...+x_{j_1}x_{j_2}x_{j_3}...x_{j_n}$$
I want to create a function that takes this polynomial and does the following: $$f[a]=\sum_{j_1}^px_{j_1}+\sum_{j_1}^p\sum_{j_2}^{j_1}x_{j_1}x_{j_2}+\sum_{j_1}^p\sum_{j_2}^{j_1}\sum_{j_3}^{j_2}x_{j_1}x_{j_2}x_{j_3}+...+\sum_{j_1}^p\sum_{j_2}^{j_1}\sum_{j_3}^{j_2}...\sum_{j_n}^{j_{n-1}}x_{j_1}x_{j_2}x_{j_3}...x_{j_{n-1}}x_{j_n}$$ where $p$ is a fixed number.
In practice, my polynomials are not limited to those three variables. The $x$'s are labelled by a unique index $j_i$. That is what I mean by variable terms to sum over. I am not sure how to make the code 1. recognize that it has $n$ factors in a term (corresponding to $\sum_{j_1>j_2>...>j_n}x_{j_1}x_{j_2}...x_{j_n}$), and 2. sum over those terms.
I looked at a similar question here where it was for $n$ number of terms but I have not been able to successfully adapt that solution.
f[a]
doesn't seem to match either one of those restrictions. $\endgroup$