Skip to content

Commit 3899098

Browse files
committed
chore(Data/Finsupp): make mapDomain_congr congr
1 parent 4f97290 commit 3899098

10 files changed

Lines changed: 27 additions & 36 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: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -285,19 +285,15 @@ theorem mapDomain_notin_range {f : α → β} (x : α →₀ M) (a : β) (h : a
285285
mapDomain f x a = 0 :=
286286
mapDomain_of_not_mem_image_support <| by grw [Set.image_subset_range]; exact h
287287

288-
@[simp]
289-
theorem mapDomain_id : mapDomain id v = v :=
290-
sum_single _
288+
@[simp high] lemma mapDomain_id : mapDomain id v = v := sum_single _
289+
@[simp] lemma mapDomain_fun_id : mapDomain (fun x ↦ x) v = v := sum_single _
290+
291+
lemma mapDomain_fun_comp (f : α → β) (g : β → γ) :
292+
mapDomain (fun a ↦ g (f a)) v = mapDomain g (mapDomain f v) := by
293+
simp [mapDomain, sum_sum_index]
291294

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

302298
@[simp]
303299
theorem mapDomain_single {f : α → β} {a : α} {b : M} : mapDomain f (single a b) = single (f a) b :=
@@ -307,7 +303,7 @@ theorem mapDomain_single {f : α → β} {a : α} {b : M} : mapDomain f (single
307303
theorem mapDomain_zero {f : α → β} : mapDomain f (0 : α →₀ M) = (0 : β →₀ M) :=
308304
sum_zero_index
309305

310-
theorem mapDomain_congr {f g : α → β} (h : ∀ x ∈ v.support, f x = g x) :
306+
@[congr] theorem mapDomain_congr {f g : α → β} (h : ∀ x ∈ v.support, f x = g x) :
311307
v.mapDomain f = v.mapDomain g :=
312308
Finset.sum_congr rfl fun _ H => by simp only [h _ H]
313309

@@ -1057,7 +1053,7 @@ lemma sumElim_eq_add [AddCommMonoid M] (f : α →₀ M) (g : β →₀ M) :
10571053

10581054
@[simp] lemma mapDomain_swap_sumElim [AddCommMonoid M] (f : α →₀ M) (g : β →₀ M) :
10591055
mapDomain Sum.swap (sumElim f g) = sumElim g f := by
1060-
simp [sumElim_eq_add, mapDomain_add, ← mapDomain_comp, Function.comp_def, add_comm]
1056+
simp [sumElim_eq_add, mapDomain_add, ← mapDomain_comp, add_comm]
10611057

10621058
@[to_additive]
10631059
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
@@ -197,7 +197,7 @@ theorem repr_reindex_apply (i' : ι') : (b.reindex e).repr x i' = b.repr x (e.sy
197197
show (Finsupp.domLCongr e : _ ≃ₗ[R] _) (b.repr x) i' = _ by simp
198198

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

203203
@[simp]
@@ -477,8 +477,7 @@ theorem reindexFinsetRange_repr_self (i : ι) :
477477
b.reindexFinsetRange.repr (b i) =
478478
Finsupp.single ⟨b i, Finset.mem_image_of_mem b (Finset.mem_univ i)⟩ 1 := by
479479
ext ⟨bi, hbi⟩
480-
rw [reindexFinsetRange, repr_reindex, Finsupp.mapDomain_equiv_apply, reindexRange_repr_self]
481-
simp [Finsupp.single_apply]
480+
simp [reindexFinsetRange, reindexRange_repr_self]
482481

483482
@[simp]
484483
theorem reindexFinsetRange_repr (x : M) (i : ι)
@@ -708,8 +707,7 @@ variable (e : ι ≃ ι')
708707
@[simp]
709708
theorem sumCoords_reindex : (b.reindex e).sumCoords = b.sumCoords := by
710709
ext x
711-
simp only [coe_sumCoords, repr_reindex]
712-
exact Finsupp.sum_mapDomain_index (fun _ => rfl) fun _ _ _ => rfl
710+
simp [Function.id_def]
713711

714712
variable (S : Type*) [Semiring S] [Module S M']
715713
variable [SMulCommClass R S M']

Mathlib/LinearAlgebra/Finsupp/Pi.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ lemma map_id [Finite X] : map (_root_.id : X → X) (M := M) = _root_.id := by
265265
lemma map_comp [Finite X] [Finite Y] [Finite Z] (g : Y → Z) (f : X → Y) :
266266
map (g.comp f) (M := M) = (map g).comp (map f) := by
267267
ext s
268-
simp [map, Finsupp.mapDomain_comp]
268+
simp [map, Finsupp.mapDomain_fun_comp]
269269

270270
end
271271

Mathlib/LinearAlgebra/Matrix/Basis.lean

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,7 @@ theorem toMatrix_reindex' [DecidableEq ι] [DecidableEq ι'] (b : Basis ι R M)
227227
(e : ι ≃ ι') : (b.reindex e).toMatrix v =
228228
Matrix.reindexAlgEquiv R R e (b.toMatrix (v ∘ e)) := by
229229
ext
230-
simp only [Basis.toMatrix_apply, Basis.repr_reindex, Matrix.reindexAlgEquiv_apply,
231-
Matrix.reindex_apply, Matrix.submatrix_apply, Function.comp_apply, e.apply_symm_apply,
232-
Finsupp.mapDomain_equiv_apply]
230+
simp [Basis.toMatrix_apply]
233231

234232
omit [Fintype ι'] in
235233
@[simp]
@@ -267,8 +265,7 @@ def invertibleToMatrix [DecidableEq ι] [Fintype ι] (b b' : Basis ι R₂ M₂)
267265
theorem toMatrix_reindex (b : Basis ι R M) (v : ι' → M) (e : ι ≃ ι') :
268266
(b.reindex e).toMatrix v = (b.toMatrix v).submatrix e.symm _root_.id := by
269267
ext
270-
simp only [toMatrix_apply, repr_reindex, Matrix.submatrix_apply, _root_.id,
271-
Finsupp.mapDomain_equiv_apply]
268+
simp [toMatrix_apply]
272269

273270
@[simp]
274271
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
@@ -69,9 +69,7 @@ theorem canonicalEmbedding_eq_basisMatrix_mulVec (α : K) :
6969
(fun i ↦ (((integralBasis K).reindex (equivReindex K).symm).repr α i : ℂ)) := by
7070
ext i
7171
rw [← (latticeBasis K).sum_repr (canonicalEmbedding K α), ← Equiv.sum_comp (equivReindex K)]
72-
simp only [canonicalEmbedding.integralBasis_repr_apply, mulVec, dotProduct,
73-
transpose_apply, of_apply, Fintype.sum_apply, mul_comm, Basis.repr_reindex,
74-
Finsupp.mapDomain_equiv_apply, Equiv.symm_symm, Pi.smul_apply, smul_eq_mul]
72+
simp [canonicalEmbedding.integralBasis_repr_apply, mulVec, dotProduct, mul_comm]
7573

7674
theorem inverse_basisMatrix_mulVec_eq_repr [DecidableEq (K →+* ℂ)] (α : 𝓞 K) :
7775
∀ 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
@@ -401,9 +401,8 @@ instance mapCycles₁_quotientGroupMk'_epi :
401401
rw [ModuleCat.epi_iff_surjective]
402402
rintro ⟨x, hx⟩
403403
choose! s hs using QuotientGroup.mk_surjective (s := S)
404-
have hs₁ : QuotientGroup.mk ∘ s = id := funext hs
405404
refine ⟨⟨mapDomain s x, ?_⟩, Subtype.ext <| by
406-
simp [mapCycles₁_hom, ← mapDomain_comp, hs, res, Rep.hom_id (of _)]⟩
405+
simp [mapCycles₁_hom, ← mapDomain_comp, hs, res, Rep.hom_id (of _)]⟩
407406
simpa [mem_cycles₁_iff, ← (mem_cycles₁_iff _).1 hx, sum_mapDomain_index_inj (f := s)
408407
(fun x y h => by rw [← hs x, ← hs y, h])]
409408
using Finsupp.sum_congr fun a b => QuotientGroup.induction_on a fun a => by
@@ -460,7 +459,9 @@ theorem H1CoresCoinfOfTrivial_exact :
460459
(d₂₁ (A.ofQuotient S)).hom y := by
461460
have := congr($((mapShortComplexH1 (QuotientGroup.mk' S)
462461
(resOfQuotientIso A S).inv).comm₁₂.symm) z)
463-
simp_all [shortComplexH1, z, ← mapDomain_comp, Prod.map_comp_map, Rep.hom_id (res _ _)]
462+
simp_all [shortComplexH1, z, ← mapDomain_comp, Prod.map_map]
463+
erw [Rep.hom_id] at this
464+
simp_all
464465
let v := x - (d₂₁ _).hom z
465466
/- We have `C₁(s ∘ π)(v) = ∑ v(g)·s(π(g)) = 0`, since `C₁(π)(v) = dC₁(π)(z) - C₁(π)(dz) = 0` by
466467
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)