Zulip Chat Archive
Stream: Is there code for X?
Topic: monoid_hom for units
Bolton Bailey (Aug 27 2021 at 05:26):
I would like to be able to access the monoid_hom structure for the coercion of units M
to M
. Does this exist?
Johan Commelin (Aug 27 2021 at 05:40):
src/algebra/group/units_hom.lean:def coe_hom : units M →* M := ⟨coe, coe_one, coe_mul⟩
Johan Commelin (Aug 27 2021 at 05:41):
Just search for units.*→[*]
. The output isn't too long.
Bolton Bailey (Aug 27 2021 at 05:43):
Johan Commelin said:
Just search for
units.*→[*]
. The output isn't too long.
Can you explain what you mean by this?
Bolton Bailey (Aug 27 2021 at 05:45):
Is this some search technique I can use to find things more easily in the future? Where do I enter that search term?
Scott Morrison (Aug 27 2021 at 05:51):
Johan is just suggesting you use the search functionality in VSCode. It accepts regular expressions.
Scott Morrison (Aug 27 2021 at 05:52):
Thus units.*→[*]
will find any line in mathlib which contains units
, then any string of characters, then →*
.
Scott Morrison (Aug 27 2021 at 05:52):
(He's used the brackets to create a character range, so the last *
is literally an asterisk, rather than a regex modifier.)
Johan Commelin (Aug 27 2021 at 05:53):
@Bolton Bailey https://xkcd.com/208/
Bolton Bailey (Aug 27 2021 at 05:57):
I see, I am not too familiar with regex, and I didn't recognize the above as a regex with an escaped asterisk. Thanks very much!
Scott Morrison (Aug 27 2021 at 06:04):
Another potential solution:
import algebra.group.units_hom
example (M : Type) [monoid M] : units M →* M := by library_search
Note that you have to have the right imports open for this to work! But often you're lucky as the relevant file has already been imported because of the definitions you're working with.
Bolton Bailey (Aug 27 2021 at 06:12):
Indeed, I tried using library_search, but didn't find it that way. I don't think it was because of a missing import though, because hom_coe
itself was found just fine. Let me investigate.
Bolton Bailey (Aug 27 2021 at 06:17):
I think I wrote it without the by
actually. My bad.
Last updated: Dec 20 2023 at 11:08 UTC