added disequality constraints to ensure only legal terms are constructed when running backwards