Zulip Chat Archive

Stream: new members

Topic: apply function to both sides of equation


Vasily Ilin (Mar 31 2022 at 23:11):

If I have h: a=b and f: X \to Y with a b: X, how do I prove f a = f b?

Stuart Presnell (Mar 31 2022 at 23:14):

example (X Y : Type*) (a b: X) (h: a = b) (f: X  Y) : f a = f b :=
begin
  library_search,   -- suggests   refine congr_arg f h
end

Vasily Ilin (Mar 31 2022 at 23:16):

Thank you!

Kyle Miller (Apr 01 2022 at 00:07):

There's also a tactic for this:

example (X Y : Type*) (a b: X) (h: a = b) (f: X  Y) : f a = f b :=
begin
  apply_fun f at h,
  exact h,
end

Vasily Ilin (Apr 05 2022 at 03:37):

Thanks, Kyle! That's more of what I expected!

Adam Topaz (Apr 05 2022 at 19:41):

apply_fun can also be used on the goal itself, which will introduce an obligation to prove injectivity (if the tactic can't do it automatically). This is one of my favorite tactics!


Last updated: Dec 20 2023 at 11:08 UTC