On 5/28/07, Yu Liu <hydra at shao.ac.cn> wrote:
> P[n1](x) * P[n2](x) = sum( H(l) * P[l](x), l, 0,n2), where H() are
> coefficients
Here is a start.
Pp (e) := not atom (e) and subvarp (op (e)) and op (op (e)) = P;
not_Pp (e) := not Pp (e);
matchdeclare (p%, Pp, q%, not_Pp);
tellsimpafter (p% * q%, FOO (p%, q%));
%pi * sin(1) * P[n](x) * P[m](x) * P[o](x) * 12 * a * (b + x);
=> FOO (P[m](x) * P[n](x) * P[o](x), 12 * %pi * sin(1) * a * (x + b))
Notes. (1) Right-hand side of the rule is incomplete. You'll have to
write the FOO function to do something appropriate.
The args and op functions could be useful here.
args(a * b * c) => [a, b, c], op(P[n](x)) => P[n], args(op(P[n](x)))
=> [n], etc.
(2) tellsimpafter (and defrule) constructs rules which gather up
multiple similar arguments (as decided by the matchdeclare
predicates). So p% in this example matches ALL the arguments
which pass Pp, and q% matches ALL the arguments which pass
not_Pp.
(3) I would prefer to write a rule like this via defrule, but this
example seems to tickle a bug. I'll make a bug report.
Maybe if this seems to help you can tell us more about the
problem and we'll go from there.
best
Robert Dodier