Skip to content

Commit f5eb981

Browse files
committed
fix(Mathlib/Algebra/Lie/DirectSum): remove unused R argument from lemmas (#8388)
This made them not actually work as a `simp` lemma. Also extracts a common result that can be used to prove `single_add` for `DFinsupp` and `Finsupp`, and a new `Finsupp.single_mul` lemma.
1 parent 69a0d13 commit f5eb981

File tree

4 files changed

+58
-48
lines changed

4 files changed

+58
-48
lines changed

Mathlib/Algebra/Lie/DirectSum.lean

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,28 @@ theorem bracket_apply (x y : ⨁ i, L i) (i : ι) : ⁅x, y⁆ i = ⁅x i, y i
126126
zipWith_apply _ _ x y i
127127
#align direct_sum.bracket_apply DirectSum.bracket_apply
128128

129+
theorem lie_of_same [DecidableEq ι] {i : ι} (x y : L i) :
130+
⁅of L i x, of L i y⁆ = of L i ⁅x, y⁆ :=
131+
DFinsupp.zipWith_single_single _ _ _ _
132+
#align direct_sum.lie_of_of_eq DirectSum.lie_of_same
133+
134+
theorem lie_of_of_ne [DecidableEq ι] {i j : ι} (hij : i ≠ j) (x : L i) (y : L j) :
135+
⁅of L i x, of L j y⁆ = 0 := by
136+
refine DFinsupp.ext fun k => ?_
137+
rw [bracket_apply]
138+
obtain rfl | hik := Decidable.eq_or_ne i k
139+
· rw [of_eq_of_ne _ _ _ _ hij.symm, lie_zero, zero_apply]
140+
· rw [of_eq_of_ne _ _ _ _ hik, zero_lie, zero_apply]
141+
#align direct_sum.lie_of_of_ne DirectSum.lie_of_of_ne
142+
143+
@[simp]
144+
theorem lie_of [DecidableEq ι] {i j : ι} (x : L i) (y : L j) :
145+
⁅of L i x, of L j y⁆ = if hij : i = j then of L i ⁅x, hij.symm.recOn y⁆ else 0 := by
146+
obtain rfl | hij := Decidable.eq_or_ne i j
147+
· simp only [lie_of_same L x y, dif_pos]
148+
· simp only [lie_of_of_ne L hij x y, hij, dif_neg]
149+
#align direct_sum.lie_of DirectSum.lie_of
150+
129151
instance lieAlgebra : LieAlgebra R (⨁ i, L i) :=
130152
{ (inferInstance : Module R _) with
131153
lie_smul := fun c x y => by
@@ -174,37 +196,6 @@ theorem lieAlgebra_ext {x y : ⨁ i, L i}
174196
DFinsupp.ext h
175197
#align direct_sum.lie_algebra_ext DirectSum.lieAlgebra_ext
176198

177-
theorem lie_of_of_ne [DecidableEq ι] {i j : ι} (hij : j ≠ i) (x : L i) (y : L j) :
178-
⁅of L i x, of L j y⁆ = 0 := by
179-
apply lieAlgebra_ext R ι L; intro k
180-
rw [LieHom.map_lie]
181-
simp only [of, singleAddHom, AddMonoidHom.coe_mk, ZeroHom.coe_mk, lieAlgebraComponent_apply,
182-
component, lapply, LinearMap.coe_mk, AddHom.coe_mk, single_apply, LieHom.map_zero]
183-
-- The next four lines were not needed before leanprover/lean4#2644
184-
erw [AddMonoidHom.coe_mk, AddHom.coe_mk, ZeroHom.coe_mk]
185-
rotate_left
186-
intros; erw [single_add]
187-
erw [single_apply, single_apply]
188-
by_cases hik : i = k
189-
· simp only [dif_neg, not_false_iff, lie_zero, hik.symm, hij]
190-
· simp only [dif_neg, not_false_iff, zero_lie, hik]
191-
#align direct_sum.lie_of_of_ne DirectSum.lie_of_of_ne
192-
193-
theorem lie_of_of_eq [DecidableEq ι] {i j : ι} (hij : j = i) (x : L i) (y : L j) :
194-
⁅of L i x, of L j y⁆ = of L i ⁅x, hij.recOn y⁆ := by
195-
have : of L j y = of L i (hij.recOn y) := Eq.rec (Eq.refl _) hij
196-
rw [this, ← lieAlgebraOf_apply R ι L i ⁅x, hij.recOn y⁆, LieHom.map_lie, lieAlgebraOf_apply,
197-
lieAlgebraOf_apply]
198-
#align direct_sum.lie_of_of_eq DirectSum.lie_of_of_eq
199-
200-
@[simp]
201-
theorem lie_of [DecidableEq ι] {i j : ι} (x : L i) (y : L j) :
202-
⁅of L i x, of L j y⁆ = if hij : j = i then lieAlgebraOf R ι L i ⁅x, hij.recOn y⁆ else 0 := by
203-
by_cases hij : j = i
204-
· simp only [lie_of_of_eq R ι L hij x y, hij, dif_pos, not_false_iff, lieAlgebraOf_apply]
205-
· simp only [lie_of_of_ne R ι L hij x y, hij, dif_neg, not_false_iff]
206-
#align direct_sum.lie_of DirectSum.lie_of
207-
208199
variable {R L ι}
209200

210201
/-- Given a family of Lie algebras `L i`, together with a family of morphisms of Lie algebras
@@ -236,16 +227,14 @@ def toLieAlgebra [DecidableEq ι] (L' : Type w₁) [LieRing L'] [LieAlgebra R L'
236227
simp only [LinearMap.map_neg, neg_inj, ← LieAlgebra.ad_apply R]
237228
rw [← LinearMap.comp_apply, ← LinearMap.comp_apply]
238229
congr; clear x; ext j x; exact this j i x y
239-
-- Tidy up and use `lie_of`.
240230
intro i j y x
241-
simp only [lie_of R, lieAlgebraOf_apply, LieHom.coe_toLinearMap, toAddMonoid_of,
242-
coe_toModule_eq_coe_toAddMonoid, LinearMap.toAddMonoidHom_coe]
231+
simp only [coe_toModule_eq_coe_toAddMonoid, toAddMonoid_of]
243232
-- And finish with trivial case analysis.
244-
rcases eq_or_ne i j with (h | h)
245-
· have h' : f j (h.recOn y) = f i y := Eq.rec (Eq.refl _) h
246-
simp only [h, h', LieHom.coe_toLinearMap, dif_pos, LieHom.map_lie, toAddMonoid_of,
247-
LinearMap.toAddMonoidHom_coe]
248-
· simp only [h, hf j i h.symm x y, dif_neg, not_false_iff, AddMonoidHom.map_zero] }
233+
obtain rfl | hij := Decidable.eq_or_ne i j
234+
· simp_rw [lie_of_same, toAddMonoid_of, LinearMap.toAddMonoidHom_coe, LieHom.coe_toLinearMap,
235+
LieHom.map_lie]
236+
· simp_rw [lie_of_of_ne _ hij.symm, map_zero, LinearMap.toAddMonoidHom_coe,
237+
LieHom.coe_toLinearMap, hf j i hij.symm x y] }
249238
#align direct_sum.to_lie_algebra DirectSum.toLieAlgebra
250239

251240
end Algebras

Mathlib/Data/DFinsupp/Basic.lean

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,21 @@ theorem equivFunOnFintype_symm_single [Fintype ι] (i : ι) (m : β i) :
746746
simp only [← single_eq_pi_single, equivFunOnFintype_symm_coe]
747747
#align dfinsupp.equiv_fun_on_fintype_symm_single DFinsupp.equivFunOnFintype_symm_single
748748

749+
section SingleAndZipWith
750+
751+
variable [∀ i, Zero (β₁ i)] [∀ i, Zero (β₂ i)]
752+
@[simp]
753+
theorem zipWith_single_single (f : ∀ i, β₁ i → β₂ i → β i) (hf : ∀ i, f i 0 0 = 0)
754+
{i} (b₁ : β₁ i) (b₂ : β₂ i) :
755+
zipWith f hf (single i b₁) (single i b₂) = single i (f i b₁ b₂) := by
756+
ext j
757+
rw [zipWith_apply]
758+
obtain rfl | hij := Decidable.eq_or_ne i j
759+
· rw [single_eq_same, single_eq_same, single_eq_same]
760+
· rw [single_eq_of_ne hij, single_eq_of_ne hij, single_eq_of_ne hij, hf]
761+
762+
end SingleAndZipWith
763+
749764
/-- Redefine `f i` to be `0`. -/
750765
def erase (i : ι) (x : Π₀ i, β i) : Π₀ i, β i :=
751766
fun j ↦ if j = i then 0 else x.1 j,
@@ -885,11 +900,7 @@ variable [∀ i, AddZeroClass (β i)]
885900

886901
@[simp]
887902
theorem single_add (i : ι) (b₁ b₂ : β i) : single i (b₁ + b₂) = single i b₁ + single i b₂ :=
888-
ext fun i' => by
889-
by_cases h : i = i'
890-
· subst h
891-
simp only [add_apply, single_eq_same]
892-
· simp only [add_apply, single_eq_of_ne h, zero_add]
903+
(zipWith_single_single (fun _ => (· + ·)) _ b₁ b₂).symm
893904
#align dfinsupp.single_add DFinsupp.single_add
894905

895906
@[simp]

Mathlib/Data/Finsupp/Defs.lean

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,15 @@ theorem support_zipWith [D : DecidableEq α] {f : M → N → P} {hf : f 0 0 = 0
955955
rw [Subsingleton.elim D] <;> exact support_onFinset_subset
956956
#align finsupp.support_zip_with Finsupp.support_zipWith
957957

958+
@[simp]
959+
theorem zipWith_single_single (f : M → N → P) (hf : f 0 0 = 0) (a : α) (m : M) (n : N) :
960+
zipWith f hf (single a m) (single a n) = single a (f m n) := by
961+
ext a'
962+
rw [zipWith_apply]
963+
obtain rfl | ha' := eq_or_ne a a'
964+
· rw [single_eq_same, single_eq_same, single_eq_same]
965+
· rw [single_eq_of_ne ha', single_eq_of_ne ha', single_eq_of_ne ha', hf]
966+
958967
end ZipWith
959968

960969
/-! ### Additive monoid structure on `α →₀ M` -/
@@ -996,10 +1005,7 @@ theorem support_add_eq [DecidableEq α] {g₁ g₂ : α →₀ M} (h : Disjoint
9961005

9971006
@[simp]
9981007
theorem single_add (a : α) (b₁ b₂ : M) : single a (b₁ + b₂) = single a b₁ + single a b₂ :=
999-
ext fun a' => by
1000-
by_cases h : a = a'
1001-
· rw [h, add_apply, single_eq_same, single_eq_same, single_eq_same]
1002-
· rw [add_apply, single_eq_of_ne h, single_eq_of_ne h, single_eq_of_ne h, zero_add]
1008+
(zipWith_single_single _ _ _ _ _).symm
10031009
#align finsupp.single_add Finsupp.single_add
10041010

10051011
instance addZeroClass : AddZeroClass (α →₀ M) :=

Mathlib/Data/Finsupp/Pointwise.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ theorem mul_apply {g₁ g₂ : α →₀ β} {a : α} : (g₁ * g₂) a = g₁ a
4949
rfl
5050
#align finsupp.mul_apply Finsupp.mul_apply
5151

52+
@[simp]
53+
theorem single_mul (a : α) (b₁ b₂ : β) : single a (b₁ * b₂) = single a b₁ * single a b₂ :=
54+
(zipWith_single_single _ _ _ _ _).symm
55+
5256
theorem support_mul [DecidableEq α] {g₁ g₂ : α →₀ β} :
5357
(g₁ * g₂).support ⊆ g₁.support ∩ g₂.support := by
5458
intro a h

0 commit comments

Comments
 (0)