Commutativity detection