I want a rule that would transform, for example, And[i,F[j,k],l,G[m,F[j,k],n],p]
into And[i,F[j,k],l,G[m,T,n],p]
, where F
, G
and T
are either just symbols or, say, defined by F[u_,v_]:=Or[F1[Or[Not[u],v],F2[v]]
or G[x_,y_,z_]:=Or[G1[x,y],G2[z,x]]
or T=H[False,True]
or something even more complicated.
I have defined the following rule:
And[u___, x_, v___, y_, w___] :> And[u, x, v, y //. x -> T, w]
It never changes any expression. How should I do it properly?