src/Util/Tactics/ClearFree.v
raw| 1 | (** [clear_free term] clears all hypotheses which are not required for typing [term] *) |
| 2 | Ltac clear_free term := |
| 3 | idtac; |
| 4 | let H := fresh in |
| 5 | let T := lazymatch goal with |- ?T => T end in |
| 6 | simple notypeclasses refine (match term return T with H => _ end); |
| 7 | repeat match goal with |
| 8 | | [ H' : _ |- _ ] => tryif constr_eq H H' then fail else clear H' |
| 9 | end; |
| 10 | clear H. |