Is it a bug or am I missing something? (Rules & Patterns)



Hi,
I am trying to apply rule s2 as follows:

(%i1) matchdeclare([_x,_n,_f,_p,_g,_q],all);
(%o1) done
(%i2) apply(defrule,[s2,sum(_f(_x)*_g(_x),_x,1,_n),S(_f*_g)]);
(%o2) s2:sum(_f(_x)*_g(_x),_x,1,_n)->S(_f*_g)
(%i3) apply1(sum(f(i1064)*g(i1064),i1064,1,N),s2);
(%o3) sum(f(i1064)*g(i1064),i1064,1,N)
But it does not do replacement.

While following rule s4 runs:

(%i4) apply(defrule,[s4,sum(_f(_x)^_p*_g(_x)^_q,_x,1,_n),S(_f^_p*_g^_q)]);
(%o4) s4:sum(_f(_x)^_p*_g(_x)^_q,_x,1,_n)->S(_f^_p*_g^_q)
(%i6) apply1(sum(f(i1064)^2*g(i1064)^3,i1064,1,N),s4);
(%o6) S(f^2*g^3)

Is it something that I am missing or can anybody explain how are rules
working here?

Thanks,
Dileep