I'm a beginner in Mathematica, so please forgive me if the following question turns out to be completely trivial.
My situation is that I'd like to rename certain terms of polynomials. Say I have a polynomial, which I've factorized in a certain way already so that it looks something like this (just an example): $$p=(a_1+a_2+a_3)(b_1+b_2)^2-(c_1-c_2)(d_1 d_2 + d_3 - d_4)$$ Now I'd like to call $$a := a_1+a_2+a_3, \hspace{2mm} b := b_1+b_2, \hspace{2mm} c := c_1+c_2, \hspace{2mm} d := d_1 d_2 + d_3 - d_4$$ so that the polynomial $p$ is then written as $$ p= a b^2 - c d. $$
This seems like a functionality that Mathematica could already have but I don't know about...
I'm grateful for any help!
EDIT: In the above case a simple "/." replacement seems to work. However, can someone tell me why it doesn't in the following case:
z1 z2 z3 z4 (z1 z2 + z1 z3 + z2 z3 + z1 z4 + z2 z4 + z3 z4) (z1 z2 z3 + z1 z2 z4 + z1 z3 z4 + z2 z3 z4) /. {z1 z2 + z1 z3 + z2 z3 + z1 z4 + z2 z4 + z3 z4 -> a1, z1 z2 z3 + z1 z2 z4 + z1 z3 z4 + z2 z3 z4 -> a2, z1 z2 z3 z4 -> a3}
which evaluates to
a3 (z1 z2 + z1 z3 + z2 z3 + z1 z4 + z2 z4 + z3 z4) (z1 z2 z3 + z1 z2 z4 + z1 z3 z4 + z2 z3 z4)