Rewriting by eta-equivalence

Is there a built-in tactic that would reduce fun x => f x to f or the other way around? cbv doesn’t do that. I guess you can rewrite eta, where eta is the lemma below, but maybe I’m missing something even simpler.

Lemma eta {A B} (f : A -> B) : (fun x => f x) = f.
cbv. (* I would like to see f = f now *)
reflexivity. (* this proof works in any case, but sometimes syntax matters (rewriting, match...) *)

I thought there were situations where fun x => f x is directly transformed into f but I can’t seem to find an example of that.

1 Like

What about change (fun x => f x) with f?


change understands patterns, so if you’d like to eta-reduce all things in your goal, you could use something like this:

repeat change (fun x => ?h x) with h.

I hadn’t thought about change and didn’t know it supports patterns!
Thanks a lot @mwuttke97 and @anton-trunov!

1 Like

I just found the section in the Coq manual about conversion:

It has some relevant comments about eta:

We deliberately do not define η-reduction (…) This is because, in general, the type of t need not to be convertible to the type of fun x => t x.