Skip to content

Commit 458cedf

Browse files
committed
chore(Data/Finsupp): make mapDomain_congr congr
1 parent bb577fa commit 458cedf

10 files changed

Lines changed: 28 additions & 33 deletions

File tree

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/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 =>

Mathlib/NumberTheory/NumberField/House.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,9 @@ private theorem asiegel_remark : ‖asiegel K a‖ ≤ c₂ K * A := by
282282
_ ≤ c₂ K * A := ?_
283283
· simp only [Int.cast_abs, ← Real.norm_eq_abs (asiegel K a kr lu)]; rfl
284284
· have remark := basis_repr_norm_le_const_mul_house K
285-
simp only [Basis.repr_reindex, Finsupp.mapDomain_equiv_apply,
286-
integralBasis_repr_apply, eq_intCast, Rat.cast_intCast,
287-
Complex.norm_intCast] at remark
285+
simp only [Basis.repr_reindex, Finsupp.equivMapDomain_apply, Equiv.symm_symm,
286+
integralBasis_repr_apply, algebraMap_int_eq, eq_intCast, Rat.cast_intCast,
287+
Complex.norm_intCast] at remark
288288
exact mod_cast remark ((a kr.1 lu.1 * ((newBasis K) lu.2))) kr.2
289289
· simp only [house, map_mul, mul_assoc]
290290
gcongr

Mathlib/RepresentationTheory/Homological/GroupHomology/Functoriality.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,8 @@ instance mapCycles₁_quotientGroupMk'_epi :
429429
rw [ModuleCat.epi_iff_surjective]
430430
rintro ⟨x, hx⟩
431431
choose! s hs using QuotientGroup.mk_surjective (s := S)
432-
have hs₁ : QuotientGroup.mk ∘ s = id := funext hs
433432
refine ⟨⟨mapDomain s x, ?_⟩, Subtype.ext <| by
434-
simp [mapCycles₁_hom, ← mapDomain_comp, hs, res, Rep.hom_id (of _)]⟩
433+
simp [mapCycles₁_hom, ← mapDomain_comp, hs, res, Rep.hom_id (of _)]⟩
435434
simpa [mem_cycles₁_iff, ← (mem_cycles₁_iff _).1 hx, sum_mapDomain_index_inj (f := s)
436435
(fun x y h => by rw [← hs x, ← hs y, h])]
437436
using Finsupp.sum_congr fun a b => QuotientGroup.induction_on a fun a => by
@@ -489,7 +488,9 @@ theorem H1CoresCoinfOfTrivial_exact :
489488
(d₂₁ (A.ofQuotient S)).hom y := by
490489
have := congr($((mapShortComplexH1 (QuotientGroup.mk' S)
491490
(resOfQuotientIso A S).inv).comm₁₂.symm) z)
492-
simp_all [shortComplexH1, z, ← mapDomain_comp, Prod.map_comp_map, Rep.hom_id (res _ _)]
491+
simp_all [shortComplexH1, z, ← mapDomain_comp, Prod.map_map]
492+
erw [Rep.hom_id] at this
493+
simp_all
493494
let v := x - (d₂₁ _).hom z
494495
/- We have `C₁(s ∘ π)(v) = ∑ v(g)·s(π(g)) = 0`, since `C₁(π)(v) = dC₁(π)(z) - C₁(π)(dz) = 0` by
495496
previous assumptions. -/

Mathlib/RepresentationTheory/Intertwining.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ def id : IntertwiningMap ρ ρ where
201201
@[simp]
202202
lemma toLinearMap_id : (id ρ).toLinearMap = LinearMap.id := rfl
203203

204-
@[simp]
204+
@[simp] lemma coe_id : ⇑(id ρ) = _root_.id := rfl
205+
205206
lemma id_apply (v : V) : id ρ v = v := rfl
206207

207208
variable {ρ σ τ} in

0 commit comments

Comments
 (0)