Zulip Chat Archive

Stream: mathlib4

Topic: exact? in term mode


Bhavik Mehta (Oct 24 2023 at 16:49):

Sometimes I'm trying to use exact? to find a term to close the goal (often because I can't remember its name), so I write something like

example {A : Finset } : A  A := by exact?

It gives me back exact Subset.rfl (correctly), but the Try this: turns the proof into := by exact Subset.rfl. I remember that Lean 3 library_search and similar could detect this kind of thing and make the proof := Subset.rfl. Is this something we can easily do with exact? and apply??

Alex J. Best (Oct 24 2023 at 16:58):

Sure you can do

import Mathlib.Tactic

example : x < x + 1 := exact?%

this isn't exactly answering your question of course, but hopefully its useful enough anyway :wink:

Bhavik Mehta (Oct 24 2023 at 16:59):

It is! You solved the #xy problem I didn't know I had :)

Eric Rodriguez (Oct 25 2023 at 18:13):

how does this magic work?

Adam Topaz (Oct 25 2023 at 18:24):

@Eric Rodriguez the exact?% term elaborator is defined here: https://github.com/leanprover-community/mathlib4/blob/7f885ee905fe01646967a99b54028c3270cce975/Mathlib/Tactic/LibrarySearch.lean#L289


Last updated: Dec 20 2023 at 11:08 UTC