Dileep:
You have posted what appears to be the same question about 4 times,
about how to use defrule to solve a problem for which it is not suited.
As you repeat the question, you have not changed it,
in spite of having received several suggestions to use a different
approach.
I wrote the defrule system in my PhD research. I am advising you
not to use it. I suggested that you look at tensor manipulation and
the Einstein summation convention. Robert Dodier made what
seems to be a useful suggestion.
Encoding your problem as sum(g(i,j)*d(j,k) etc. IS A BAD IDEA.
I suggest encoding it as something like
DileepForm([[d,i,j],[g,i,j]......], /* the product */
[[j,1,n], [k, 1,m] ....]] /* the index sets*/
Manipulate DileepForms, their products, sums, etc.
If you really really need sum, then at the VERY END, convert
DileepForm to Sums.
And don't use defrule on products a*b*c ....*z or a+b+....+z.
There is a message about "partitioning sums" that is intended to
signal you: YOU ARE LIKELY TO LOSE.
Good luck,
RJF