Skip to content

Commit 882c618

Browse files
committed
chore(Data/Finsupp): make mapDomain_congr congr
1 parent ae86149 commit 882c618

14 files changed

Lines changed: 33 additions & 37 deletions

File tree

Mathlib/Algebra/MonoidAlgebra/MapDomain.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ lemma mapDomainNonUnitalRingHom_id : mapDomainNonUnitalRingHom R (.id M) = .id R
185185
lemma mapDomainNonUnitalRingHom_comp (f : N →ₙ* O) (g : M →ₙ* N) :
186186
mapDomainNonUnitalRingHom R (f.comp g) =
187187
(mapDomainNonUnitalRingHom R f).comp (mapDomainNonUnitalRingHom R g) := by
188-
ext; simp [Finsupp.mapDomain_comp]
188+
ext; simp [Finsupp.mapDomain_fun_comp]
189189

190190
variable (R) in
191191
/-- Equivalent monoids have additively isomorphic monoid algebras.

Mathlib/Algebra/MonoidAlgebra/Module.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ lemma mapDomainLinearMap_single (f : M → N) (s : S) (m : M) :
9191
@[to_additive (attr := simp)]
9292
lemma mapDomainLinearMap_comp (f : M → N) (g : N → O) :
9393
mapDomainLinearMap R S (g ∘ f) = mapDomainLinearMap R S g ∘ₗ mapDomainLinearMap R S f := by
94-
ext; simp [Finsupp.mapDomain_comp]
94+
ext; simp [Finsupp.mapDomain_fun_comp]
9595

9696
variable (R S) in
9797
/-- `MonoidAlgebra.mapDomain` as a linear equiv. -/

Mathlib/Algebra/MvPolynomial/Nilpotent.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ theorem isUnit_iff : IsUnit P ↔ IsUnit (P.coeff 0) ∧ ∀ i ≠ 0, IsNilpoten
6565
simp only [ne_eq, isNilpotent_iff] at H
6666
convert! ← H (n.equivMapDomain (Equiv.optionSubtypeNe i).symm).some
6767
refine (optionEquivLeft_coeff_some_coeff_none _ _ _ _).trans ?_
68-
simp [Finsupp.equivMapDomain_eq_mapDomain,
68+
simp [Finsupp.equivMapDomain_eq_mapDomain, -Equiv.optionSubtypeNe_symm_apply,
6969
coeff_rename_mapDomain _ (Equiv.optionSubtypeNe i).symm.injective]
7070
· have : IsNilpotent (P - C (P.coeff 0)) := by
7171
simp +contextual [isNilpotent_iff, apply_ite, eq_comm, h₂]

Mathlib/Algebra/Polynomial/Laurent.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ alias support_C_mul_T_of_ne_zero := support_coeff_C_mul_T_of_ne_zero
390390
shows that the support of `f.toLaurent` is the same finset, but viewed in `ℤ` under the natural
391391
inclusion `ℕ ↪ ℤ`. -/
392392
theorem support_coeff_toLaurent (f : R[X]) :
393-
f.toLaurent.coeff.support = f.support.map Nat.castEmbedding := by simp [Polynomial.support]
393+
f.toLaurent.coeff.support = f.support.map Nat.castEmbedding := by
394+
simp [-Nat.castEmbedding_apply, Polynomial.support]
394395

395396
@[deprecated (since := "2026-06-18")] alias toLaurent_support := support_coeff_toLaurent
396397

Mathlib/Data/Finsupp/Basic.lean

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -288,19 +288,17 @@ theorem mapDomain_notin_range {f : α → β} (x : α →₀ M) (a : β) (h : a
288288
lemma mem_range_of_mapDomain_ne_zero {f : α → β} {x : α →₀ M} {b : β} (h : mapDomain f x b ≠ 0) :
289289
b ∈ Set.range f := by contrapose! h; exact mapDomain_notin_range _ _ h
290290

291-
@[simp]
292-
theorem mapDomain_id : mapDomain id v = v :=
293-
sum_single _
291+
-- The linter complains that `mapDomain_id` can be proved from `mapDomain_fun_id` and `id_eq`
292+
-- but this isn't true (at least within most of mathlib)
293+
@[to_fun (attr := simp) mapDomain_fun_id, nolint simpNF]
294+
lemma mapDomain_id : mapDomain id v = v := sum_single _
295+
296+
lemma mapDomain_fun_comp (f : α → β) (g : β → γ) :
297+
mapDomain (fun a ↦ g (f a)) v = mapDomain g (mapDomain f v) := by
298+
simp [mapDomain, sum_sum_index]
294299

295300
theorem mapDomain_comp {f : α → β} {g : β → γ} :
296-
mapDomain (g ∘ f) v = mapDomain g (mapDomain f v) := by
297-
refine ((sum_sum_index ?_ ?_).trans ?_).symm
298-
· intro
299-
exact single_zero _
300-
· intro
301-
exact single_add _
302-
refine sum_congr fun _ _ => sum_single_index ?_
303-
exact single_zero _
301+
mapDomain (g ∘ f) v = mapDomain g (mapDomain f v) := mapDomain_fun_comp f g
304302

305303
@[simp]
306304
theorem mapDomain_single {f : α → β} {a : α} {b : M} : mapDomain f (single a b) = single (f a) b :=
@@ -310,7 +308,7 @@ theorem mapDomain_single {f : α → β} {a : α} {b : M} : mapDomain f (single
310308
theorem mapDomain_zero {f : α → β} : mapDomain f (0 : α →₀ M) = (0 : β →₀ M) :=
311309
sum_zero_index
312310

313-
theorem mapDomain_congr {f g : α → β} (h : ∀ x ∈ v.support, f x = g x) :
311+
@[congr] theorem mapDomain_congr {f g : α → β} (h : ∀ x ∈ v.support, f x = g x) :
314312
v.mapDomain f = v.mapDomain g :=
315313
Finset.sum_congr rfl fun _ H => by simp only [h _ H]
316314

@@ -1070,7 +1068,7 @@ lemma sumElim_eq_add [AddCommMonoid M] (f : α →₀ M) (g : β →₀ M) :
10701068

10711069
@[simp] lemma mapDomain_swap_sumElim [AddCommMonoid M] (f : α →₀ M) (g : β →₀ M) :
10721070
mapDomain Sum.swap (sumElim f g) = sumElim g f := by
1073-
simp [sumElim_eq_add, mapDomain_add, ← mapDomain_comp, Function.comp_def, add_comm]
1071+
simp [sumElim_eq_add, mapDomain_add, ← mapDomain_comp, add_comm]
10741072

10751073
@[to_additive]
10761074
lemma prod_sumElim {ι₁ ι₂ α M : Type*} [Zero α] [CommMonoid M]

Mathlib/Geometry/Convex/ConvexSpace/Defs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ lemma map_id (f : StdSimplex R M) : f.map id = f := by
139139

140140
lemma map_comp (f : StdSimplex R M) (g₁ : M → N) (g₂ : N → P) :
141141
f.map (g₂ ∘ g₁) = (f.map g₁).map g₂ := by
142-
ext; simp [mapDomain_comp]
142+
ext; simp [mapDomain_comp]
143143

144144
lemma map_map (f : StdSimplex R M) (g₁ : M → N) (g₂ : N → P) :
145145
(f.map g₁).map g₂ = f.map (fun x ↦ g₂ (g₁ x)) :=

Mathlib/LinearAlgebra/Basis/Defs.lean

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ theorem repr_reindex_apply (i' : ι') : (b.reindex e).repr x i' = b.repr x (e.sy
199199
show (Finsupp.domLCongr e : _ ≃ₗ[R] _) (b.repr x) i' = _ by simp
200200

201201
@[simp]
202-
theorem repr_reindex : (b.reindex e).repr x = (b.repr x).mapDomain e :=
202+
theorem repr_reindex : (b.reindex e).repr x = (b.repr x).equivMapDomain e :=
203203
DFunLike.ext _ _ <| by simp [repr_reindex_apply]
204204

205205
@[simp]
@@ -479,8 +479,7 @@ theorem reindexFinsetRange_repr_self (i : ι) :
479479
b.reindexFinsetRange.repr (b i) =
480480
Finsupp.single ⟨b i, Finset.mem_image_of_mem b (Finset.mem_univ i)⟩ 1 := by
481481
ext ⟨bi, hbi⟩
482-
rw [reindexFinsetRange, repr_reindex, Finsupp.mapDomain_equiv_apply, reindexRange_repr_self]
483-
simp [Finsupp.single_apply]
482+
simp [reindexFinsetRange, reindexRange_repr_self]
484483

485484
@[simp]
486485
theorem reindexFinsetRange_repr (x : M) (i : ι)
@@ -710,8 +709,7 @@ variable (e : ι ≃ ι')
710709
@[simp]
711710
theorem sumCoords_reindex : (b.reindex e).sumCoords = b.sumCoords := by
712711
ext x
713-
simp only [coe_sumCoords, repr_reindex]
714-
exact Finsupp.sum_mapDomain_index (fun _ => rfl) fun _ _ _ => rfl
712+
simp [Function.id_def]
715713

716714
variable (S : Type*) [Semiring S] [Module S M']
717715
variable [SMulCommClass R S M']

Mathlib/LinearAlgebra/Finsupp/Pi.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ lemma map_id [Finite X] : map (_root_.id : X → X) (M := M) = _root_.id := by
284284
lemma map_comp [Finite X] [Finite Y] [Finite Z] (g : Y → Z) (f : X → Y) :
285285
map (g.comp f) (M := M) = (map g).comp (map f) := by
286286
ext s
287-
simp [map, Finsupp.mapDomain_comp]
287+
simp [map, Finsupp.mapDomain_fun_comp]
288288

289289
end
290290

Mathlib/LinearAlgebra/Matrix/Basis.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ def invertibleToMatrix [DecidableEq ι] [Fintype ι] (b b' : Basis ι R₂ M₂)
264264
theorem toMatrix_reindex (b : Basis ι R M) (v : ι' → M) (e : ι ≃ ι') :
265265
(b.reindex e).toMatrix v = (b.toMatrix v).submatrix e.symm _root_.id := by
266266
ext
267-
simp only [toMatrix_apply, repr_reindex, Matrix.submatrix_apply, _root_.id,
268-
Finsupp.mapDomain_equiv_apply]
267+
simp [toMatrix_apply]
269268

270269
@[simp]
271270
theorem toMatrix_map (b : Basis ι R M) (f : M ≃ₗ[R] N) (v : ι → N) :

Mathlib/NumberTheory/NumberField/EquivReindex.lean

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ theorem canonicalEmbedding_eq_basisMatrix_mulVec (α : K) :
7070
(fun i ↦ (((integralBasis K).reindex (equivReindex K).symm).repr α i : ℂ)) := by
7171
ext i
7272
rw [← (latticeBasis K).sum_repr (canonicalEmbedding K α), ← Equiv.sum_comp (equivReindex K)]
73-
simp only [canonicalEmbedding.integralBasis_repr_apply, mulVec, dotProduct,
74-
transpose_apply, of_apply, Fintype.sum_apply, mul_comm, Basis.repr_reindex,
75-
Finsupp.mapDomain_equiv_apply, Equiv.symm_symm, Pi.smul_apply, smul_eq_mul]
73+
simp [canonicalEmbedding.integralBasis_repr_apply, mulVec, dotProduct, mul_comm]
7674

7775
theorem inverse_basisMatrix_mulVec_eq_repr [DecidableEq (K →+* ℂ)] (α : 𝓞 K) :
7876
∀ i, ((basisMatrix K).transpose)⁻¹.mulVec (fun j =>

0 commit comments

Comments
 (0)