Given f(a + b) + f(a + c) + f(b + d) apply transformation
f(a + x_) + f(c + y_) -> p(x, y)
Here to do not use map, since we want to apply pattern on the whole expression. In Maple
restart; expr:=f(a+b)+f(a+c)+f(b+d): if patmatch(expr,f(a+x::anything)+f(c+y::anything)+z::anything,'la') then p(eval(x,la),eval(y,la))+eval(z,la); else expr; fi; p(b, a) + f(b + d)
In Mathematica
f[a+b]+f[a+c]+f[b+d]/. f[a+x_]+f[c+y_]->p[x,y] f[b+d]+p[b,a]