I'm confused by the following three different results involving pattern matching and condition.
aa[p]/(2 bb[p]) /. {((f_ /; (D[f, kk] == 0))/bb[kk_]) :> kk}
--> p
aa[p]/(2 bb[p]) /. {(f_/bb[kk_]) /; (D[f, kk] == 0) :> kk}
--> p aa[p]
aa[p]/(2 bb[p]) /. {(f_/bb[kk_]) /; (D[f, kk] == 0) :> cc[kk]}
--> aa[p] cc[p]
Intuitively I expect the first result, where one first check if the factor besides bb[p]
depends on p
, and if it doesn't, then extract the argument p
.
However, I have completely no idea how the second and the third results arise (where from 1st to the 2nd the location of the condition is changed). Moreover, in the 2nd kk
is matched with p aa[p]
, why on earth in the 3rd cc[kk]
spits out NOT cc[p aa[p]]
, but instead a product aa[p] cc[p]
?