Generalized rewriting

Source:https://coq.inria.fr/distrib/current/refman/setoid.html
Converted by:Maxime Dénès