Zulip Chat Archive
Stream: Is there code for X?
Topic: submodule of a submodule
Scott Morrison (May 21 2021 at 06:39):
import algebra.module.submodule
example (R M : Type) [ring R] [add_comm_group M] [module R M]
(A : submodule R M) (B : submodule R A) :
submodule R M := sorry -- B as a submodule of M?
Johan Commelin (May 21 2021 at 06:45):
Is it something like B.map A.incl
?
Kevin Buzzard (May 21 2021 at 06:58):
For subgroups the morphism is A.subtype
Eric Wieser (May 21 2021 at 08:15):
That seems to be the preferred spelling, given how docs#submodule.equiv_subtype_map is stated
Terence Tao (Dec 30 2023 at 19:28):
Reviving this thread after two years because I exactly need this construction, but now in Lean4 rather than Lean3. Here I discovered a weird quirk. While the general construction
import Mathlib
example (R M : Type) [Ring R] [AddCommGroup M] [Module R M]
(A : Submodule R M) (B : Submodule R A) : Submodule R M := B.map A.subtype
works fine, the specialization to the integers does not:
import Mathlib
example (M : Type) [AddCommGroup M] [Module ℤ M]
(A : Submodule ℤ M) (B : Submodule ℤ A) : Submodule ℤ M := B.map A.subtype
-- failed to synthesize instance SemilinearMapClass (↥A →ₗ[ℤ] M) ?m.2597 (↥A) M
I can fix it, but only with a weird empty application of convert
:
import Mathlib
example (M : Type) [AddCommGroup M] [Module ℤ M]
(A : Submodule ℤ M) (B : Submodule ℤ A) : Submodule ℤ M := by
convert B.map (σ₁₂ := RingHom.id ℤ) A.subtype
convert
What is going on here??
Yury G. Kudryashov (Dec 30 2023 at 19:29):
My guess (not tested): Lean fails to unify universes.
Yury G. Kudryashov (Dec 30 2023 at 19:29):
I'll try to test it now.
Terence Tao (Dec 30 2023 at 19:33):
My guess is there is an instance diamond with the SemilinearMapClass
on the integers. (Based on recent experience I am inclined to blame almost all weird behavior on instance diamonds.)
Yury G. Kudryashov (Dec 30 2023 at 19:33):
It looks like there is an instance diamond for Module Int _
Yury G. Kudryashov (Dec 30 2023 at 19:33):
But convert
fixes it because of a Subsingleton
instance.
Terence Tao (Dec 30 2023 at 19:35):
Ugh. Is there a workaround that allows me to express Submodule ℤ M
as a term, as opposed to merely giving a proof of existence? Otherwise I can't proceed with my application.
Yaël Dillies (Dec 30 2023 at 19:35):
You should not be assuming [Module ℤ M]
. Lean can already derive it from [AddCommGroup M]
.
Terence Tao (Dec 30 2023 at 19:36):
Ah! I got caught in this trap once before.
Terence Tao (Dec 30 2023 at 19:38):
But wait, there is still a diamond issue here:
import Mathlib
example (M : Type) [AddCommGroup M]
(A : AddSubgroup M) (B : Submodule ℤ A) : Submodule ℤ M := B.map A.subtype
-- failed to synthesize instance SemilinearMapClass (↥A →+ M) ?m.2315 (↥A) M
Yury G. Kudryashov (Dec 30 2023 at 19:39):
You need (A : Submodule Int M)
Yaël Dillies (Dec 30 2023 at 19:40):
You can get one from docs#AddSubgroup.toIntSubmodule, eg B.map A.toIntSubmodule.subtype
Yury G. Kudryashov (Dec 30 2023 at 19:42):
Or A.subtype.toIntLinearMap
Yury G. Kudryashov (Dec 30 2023 at 19:43):
The latter may work a bit better with Lean 4 simp
.
Terence Tao (Dec 30 2023 at 19:53):
OK, to close my argument, I think I need
import Mathlib
example (M : Type) [AddCommGroup M] (A : AddSubgroup M) (B : Submodule ℤ A) : (B:Type) = B.map A.subtype.toIntLinearMap := by
sorry
but simp
didn't offer an obvious way out here.
Terence Tao (Dec 30 2023 at 19:54):
(or I need some equivalence betweenB
and B.map A.subtype.toIntLinearMap
, if they aren't identical types).
Eric Wieser (Dec 30 2023 at 19:55):
That's an equality of types, which is almost never a good idea
Terence Tao (Dec 30 2023 at 19:55):
Yeah, ignore what I just said, I applied congr
way too deep.
Terence Tao (Dec 30 2023 at 19:59):
What I actually need is
import Mathlib
example (M : Type) [AddCommGroup M] (A : AddSubgroup M) (B : Submodule ℤ A) : B ≃ₗ[ℤ] B.map A.subtype.toIntLinearMap := by
sorry
but I might be able to do this one on my own.
Eric Wieser (Dec 30 2023 at 19:59):
This works:
import Mathlib
noncomputable example
(M : Type) [AddCommGroup M] (A : AddSubgroup M) (B : Submodule ℤ A) :
(B:Type) ≃ₗ[ℤ] B.map A.subtype.toIntLinearMap :=
Submodule.equivMapOfInjective _ (by simpa using Subtype.val_injective) _
Terence Tao (Dec 30 2023 at 20:01):
OK, that worked, and closes my use case. Thanks!
Eric Wieser (Dec 30 2023 at 20:13):
Or computably:
example
(M : Type) [AddCommGroup M] (A : AddSubgroup M) (B : Submodule ℤ A) :
(B:Type) ≃ₗ[ℤ] B.map A.subtype.toIntLinearMap where
toFun b := ⟨b, b, b.prop, rfl⟩
map_add' b₁ b₂ := rfl
map_smul' c b := rfl
invFun a := ⟨
⟨a.val, by obtain ⟨-, a, ha, rfl⟩ := a; exact a.prop⟩,
by obtain ⟨-, a, ha, rfl⟩ := a; exact ha⟩
left_inv b := rfl
right_inv b := rfl
Last updated: May 02 2025 at 03:31 UTC