Generalize congruence handling for HO in eq proofs (#6883)