Note that "~" is used in Mathematica for infix form of operators and it isn't the same as Tilde
which could be inputted as [Esc]~[Esc]
ClearAll@TildeTilde /: Tilde[x_, x_] := TrueSetAttributes[Tilde, Orderless]Tilde /: Tilde[x_, y_ ] && Tilde[y_, z_ ] := Tilde[x, z]
I added one more defenition to Tilde for the case when x, y are not the same