Zulip Chat Archive
Stream: lean4
Topic: Duplicate `Subtype.ext_val_iff` in Mathlib
Thomas Zhu (Nov 02 2024 at 21:22):
Both Mathlib.Algebra.Category.Grp.Images
and Mathlib.Algebra.Category.ModuleCat.Images
have a constant called Subtype.ext_val_iff
. They are both introduced by this line:
attribute [local ext] Subtype.ext_val
They are shown in generated documentations for both modules: https://leanprover-community.github.io/mathlib4_docs/Mathlib/Algebra/Category/ModuleCat/Images.html and https://leanprover-community.github.io/mathlib4_docs/Mathlib/Algebra/Category/Grp/Images.html, although the former is not (easily?) accessible. (Moreover, it seems neither of them are actually used by the two modules, but that is beside the point).
Is this intended behavior? I think this should be a bug of @[ext]
. This problem came up in an extraction of all constants defined in Mathlib, identified by their names.
Ruben Van de Velde (Nov 02 2024 at 21:24):
Sort of, the attribute is supposed to create an ext_iff lemma
Yaël Dillies (Nov 02 2024 at 21:26):
but maybe the local attribute shouldn't
Thomas Zhu (Nov 02 2024 at 21:29):
Yes, here because of this line, even if Mathlib.Algebra.Category.Grp.Images
is imported in a separate file, you can still access the lemma Subtype.ext_val_iff
:
import Mathlib.Algebra.Category.Grp.Images
#check Subtype.ext_val_iff
Thomas Zhu (Nov 02 2024 at 21:32):
I guess this still conforms to what the ext attribute description says, but I find it quite weird
Thomas Zhu (Nov 02 2024 at 21:44):
Also, I don't quite understand why
import Mathlib.Algebra.Category.Grp.Images
import Mathlib.Algebra.Category.ModuleCat.Images
doesn't trigger a name clash ("import failed, environment already contains ...")?
Kim Morrison (Nov 03 2024 at 23:37):
Identical theorems no longer cause clashes!
Kim Morrison (Nov 03 2024 at 23:38):
Yaël Dillies said:
but maybe the local attribute shouldn't
This seems like a good idea. Issue or PR welcome?
Eric Wieser (Nov 04 2024 at 07:35):
Kim Morrison said:
Identical theorems no longer cause clashes!
But are still banned within modules that import each other?
Kim Morrison (Nov 04 2024 at 07:52):
Sorry, I got this wrong. This is only for (some class of?) automatically generated lemmas.
Thomas Zhu (Nov 04 2024 at 21:29):
I dug around the code and found the PR that introduces this behavior is lean4#3668
Thomas Zhu (Nov 04 2024 at 21:30):
Importing two different files containing proofs of the same theorem is no longer considered an error. This feature is particularly useful for theorems that are automatically generated on demand (e.g., equational theorems).
Yaël Dillies (Nov 06 2024 at 16:17):
Kim Morrison said:
Yaël Dillies said:
but maybe the local attribute shouldn't
This seems like a good idea. Issue or PR welcome?
Damiano Testa (Nov 06 2024 at 16:27):
I commented about lean4#3643 on GitHub, but linkfiers do not work there and I'm on mobile!
Damiano Testa (Nov 06 2024 at 16:28):
Is this a resurgence of the issue or a new one?
Last updated: May 02 2025 at 03:31 UTC