Currently not possible, but it's a good suggestion to include this feature. I'm thinking of adding a once
flag to algorithms, which when True
, will stop the algorithm as soon as it has applied somewhere once. That would be relatively quick to add.
A more powerful thing to have would be to allow a replacement list on the right-hand side of the substitution rule, such that subsequent replacements get handled differently. Something like
substitute(ex, $\partial_{\mu}{\phi} -> -i { p_{\mu}, k_{\mu } } \phi$);
Or something like that. This needs more thinking.