Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 5fd3186

Browse files
committed
lint(*/finsupp/*): use finite instead of fintype (#17553)
Also golf some proofs.
1 parent 6b3325c commit 5fd3186

File tree

14 files changed

+62
-72
lines changed

14 files changed

+62
-72
lines changed

src/data/finsupp/defs.lean

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -174,24 +174,24 @@ lemma support_subset_iff {s : set α} {f : α →₀ M} :
174174
by simp only [set.subset_def, mem_coe, mem_support_iff];
175175
exact forall_congr (assume a, not_imp_comm)
176176

177-
/-- Given `fintype α`, `equiv_fun_on_fintype` is the `equiv` between `α →₀ β` and `α → β`.
177+
/-- Given `finite α`, `equiv_fun_on_finite` is the `equiv` between `α →₀ β` and `α → β`.
178178
(All functions on a finite type are finitely supported.) -/
179-
@[simps] def equiv_fun_on_fintype [fintype α] : (α →₀ M) ≃ (α → M) :=
180-
⟨λf a, f a, λf, mk (finset.univ.filter $ λa, f a ≠ 0) f (by simp only [true_and, finset.mem_univ,
181-
iff_self, finset.mem_filter, finset.filter_congr_decidable, forall_true_iff]),
182-
begin intro f, ext a, refl end,
183-
begin intro f, ext a, refl end
179+
@[simps] def equiv_fun_on_finite [finite α] : (α →₀ M) ≃ (α → M) :=
180+
{ to_fun := coe_fn,
181+
inv_fun := λ f, mk (function.support f).to_finite.to_finset f (λ a, set.finite.mem_to_finset _),
182+
left_inv := λ f, ext $ λ x, rfl,
183+
right_inv := λ f, rfl }
184184

185-
@[simp] lemma equiv_fun_on_fintype_symm_coe {α} [fintype α] (f : α →₀ M) :
186-
equiv_fun_on_fintype.symm f = f :=
187-
by { ext, simp [equiv_fun_on_fintype], }
185+
@[simp] lemma equiv_fun_on_finite_symm_coe {α} [finite α] (f : α →₀ M) :
186+
equiv_fun_on_finite.symm f = f :=
187+
equiv_fun_on_finite.symm_apply_apply f
188188

189189
/--
190190
If `α` has a unique term, the type of finitely supported functions `α →₀ β` is equivalent to `β`.
191191
-/
192192
@[simps] noncomputable
193193
def _root_.equiv.finsupp_unique {ι : Type*} [unique ι] : (ι →₀ M) ≃ M :=
194-
finsupp.equiv_fun_on_fintype.trans (equiv.fun_unique ι M)
194+
finsupp.equiv_fun_on_finite.trans (equiv.fun_unique ι M)
195195

196196
end basic
197197

@@ -380,13 +380,13 @@ lemma card_support_le_one' [nonempty α] {f : α →₀ M} :
380380
card f.support ≤ 1 ↔ ∃ a b, f = single a b :=
381381
by simp only [card_le_one_iff_subset_singleton, support_subset_singleton']
382382

383-
@[simp] lemma equiv_fun_on_fintype_single [decidable_eq α] [fintype α] (x : α) (m : M) :
384-
(@finsupp.equiv_fun_on_fintype α M _ _) (finsupp.single x m) = pi.single x m :=
385-
by { ext, simp [finsupp.single_eq_pi_single, finsupp.equiv_fun_on_fintype], }
383+
@[simp] lemma equiv_fun_on_finite_single [decidable_eq α] [finite α] (x : α) (m : M) :
384+
finsupp.equiv_fun_on_finite (finsupp.single x m) = pi.single x m :=
385+
by { ext, simp [finsupp.single_eq_pi_single], }
386386

387-
@[simp] lemma equiv_fun_on_fintype_symm_single [decidable_eq α] [fintype α] (x : α) (m : M) :
388-
(@finsupp.equiv_fun_on_fintype α M _ _).symm (pi.single x m) = finsupp.single x m :=
389-
by { ext, simp [finsupp.single_eq_pi_single, finsupp.equiv_fun_on_fintype], }
387+
@[simp] lemma equiv_fun_on_finite_symm_single [decidable_eq α] [finite α] (x : α) (m : M) :
388+
finsupp.equiv_fun_on_finite.symm (pi.single x m) = finsupp.single x m :=
389+
by rw [← equiv_fun_on_finite_single, equiv.symm_apply_apply]
390390

391391
end single
392392

src/data/finsupp/fin.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ variables {n : ℕ} (i : fin n) {M : Type*} [has_zero M] (y : M)
2626

2727
/-- `tail` for maps `fin (n + 1) →₀ M`. See `fin.tail` for more details. -/
2828
def tail (s : fin (n + 1) →₀ M) : fin n →₀ M :=
29-
finsupp.equiv_fun_on_fintype.symm (fin.tail s)
29+
finsupp.equiv_fun_on_finite.symm (fin.tail s)
3030

3131
/-- `cons` for maps `fin n →₀ M`. See `fin.cons` for more details. -/
3232
def cons (y : M) (s : fin n →₀ M) : fin (n + 1) →₀ M :=
33-
finsupp.equiv_fun_on_fintype.symm (fin.cons y s : fin (n + 1) → M)
33+
finsupp.equiv_fun_on_finite.symm (fin.cons y s : fin (n + 1) → M)
3434

3535
lemma tail_apply : tail t i = t i.succ := rfl
3636

src/data/finsupp/fintype.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Some lemmas on the combination of `finsupp`, `fintype` and `infinite`.
1717
noncomputable instance finsupp.fintype {ι π : Sort*} [decidable_eq ι] [has_zero π]
1818
[fintype ι] [fintype π] :
1919
fintype (ι →₀ π) :=
20-
fintype.of_equiv _ finsupp.equiv_fun_on_fintype.symm
20+
fintype.of_equiv _ finsupp.equiv_fun_on_finite.symm
2121

2222
instance finsupp.infinite_of_left {ι π : Sort*} [nontrivial π] [has_zero π] [infinite ι] :
2323
infinite (ι →₀ π) :=

src/data/finsupp/pwo.lean

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Authors: Alex J. Best
66
import data.finsupp.order
77
import order.well_founded_set
88

9-
109
/-!
1110
# Partial well ordering on finsupps
1211
@@ -24,14 +23,11 @@ It is in a separate file for now so as to not add imports to the file `order.wel
2423
Dickson, order, partial well order
2524
-/
2625

27-
2826
/-- A version of **Dickson's lemma** any subset of functions `σ →₀ α` is partially well
29-
ordered, when `σ` is a `fintype` and `α` is a linear well order.
30-
This version uses finsupps on a fintype as it is intended for use with `mv_power_series`.
27+
ordered, when `σ` is `finite` and `α` is a linear well order.
28+
This version uses finsupps on a finite type as it is intended for use with `mv_power_series`.
3129
-/
32-
lemma finsupp.is_pwo {α σ : Type*} [has_zero α] [linear_order α] [is_well_order α (<)] [fintype σ]
30+
lemma finsupp.is_pwo {α σ : Type*} [has_zero α] [linear_order α] [is_well_order α (<)] [finite σ]
3331
(S : set (σ →₀ α)) : S.is_pwo :=
34-
begin
35-
rw ← finsupp.equiv_fun_on_fintype.symm.image_preimage S,
36-
refine set.partially_well_ordered_on.image_of_monotone_on (pi.is_pwo _) (λ a b ha hb, id),
37-
end
32+
finsupp.equiv_fun_on_finite.symm_image_image S ▸
33+
set.partially_well_ordered_on.image_of_monotone_on (pi.is_pwo _) (λ a b ha hb, id)

src/data/finsupp/well_founded.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ variable (r)
5757

5858
theorem lex.well_founded_of_finite [is_strict_total_order α r] [finite α] [has_zero N]
5959
(hs : well_founded s) : well_founded (finsupp.lex r s) :=
60-
have _ := fintype.of_finite α,
61-
by exactI inv_image.wf (@equiv_fun_on_fintype α N _ _) (pi.lex.well_founded r $ λ a, hs)
60+
inv_image.wf (@equiv_fun_on_finite α N _ _) (pi.lex.well_founded r $ λ a, hs)
6261

6362
theorem lex.well_founded_lt_of_finite [linear_order α] [finite α] [has_zero N] [has_lt N]
6463
[hwf : well_founded_lt N] : well_founded_lt (lex (α →₀ N)) :=
@@ -74,7 +73,6 @@ finsupp.well_founded_lt $ λ a, (zero_le a).not_lt
7473

7574
instance well_founded_lt_of_finite [finite α] [has_zero N] [preorder N]
7675
[well_founded_lt N] : well_founded_lt (α →₀ N) :=
77-
have _ := fintype.of_finite α,
78-
by exactI ⟨inv_image.wf equiv_fun_on_fintype function.well_founded_lt.wf⟩
76+
⟨inv_image.wf equiv_fun_on_finite function.well_founded_lt.wf⟩
7977

8078
end finsupp

src/field_theory/finite/polynomial.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ calc module.rank K (R σ K) =
186186
by rw [finsupp.dim_eq, dim_self, mul_one]
187187
... = #{s : σ → ℕ | ∀ (n : σ), s n < fintype.card K } :
188188
begin
189-
refine quotient.sound ⟨equiv.subtype_equiv finsupp.equiv_fun_on_fintype $ assume f, _⟩,
189+
refine quotient.sound ⟨equiv.subtype_equiv finsupp.equiv_fun_on_finite $ assume f, _⟩,
190190
refine forall_congr (assume n, le_tsub_iff_right _),
191191
exact fintype.card_pos_iff.20
192192
end

src/linear_algebra/basic.lean

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,36 +84,36 @@ begin
8484
{ intro i, exact (h i).map_zero },
8585
end
8686

87-
variables (α : Type*) [fintype α]
87+
variables (α : Type*) [finite α]
8888
variables (R M) [add_comm_monoid M] [semiring R] [module R M]
8989

90-
/-- Given `fintype α`, `linear_equiv_fun_on_fintype R` is the natural `R`-linear equivalence between
90+
/-- Given `finite α`, `linear_equiv_fun_on_finite R` is the natural `R`-linear equivalence between
9191
`α →₀ β` and `α → β`. -/
92-
@[simps apply] noncomputable def linear_equiv_fun_on_fintype :
92+
@[simps apply] noncomputable def linear_equiv_fun_on_finite :
9393
(α →₀ M) ≃ₗ[R] (α → M) :=
9494
{ to_fun := coe_fn,
95-
map_add' := λ f g, by { ext, refl },
96-
map_smul' := λ c f, by { ext, refl },
97-
.. equiv_fun_on_fintype }
95+
map_add' := λ f g, rfl,
96+
map_smul' := λ c f, rfl,
97+
.. equiv_fun_on_finite }
9898

99-
@[simp] lemma linear_equiv_fun_on_fintype_single [decidable_eq α] (x : α) (m : M) :
100-
(linear_equiv_fun_on_fintype R M α) (single x m) = pi.single x m :=
101-
equiv_fun_on_fintype_single x m
99+
@[simp] lemma linear_equiv_fun_on_finite_single [decidable_eq α] (x : α) (m : M) :
100+
(linear_equiv_fun_on_finite R M α) (single x m) = pi.single x m :=
101+
equiv_fun_on_finite_single x m
102102

103-
@[simp] lemma linear_equiv_fun_on_fintype_symm_single [decidable_eq α]
104-
(x : α) (m : M) : (linear_equiv_fun_on_fintype R M α).symm (pi.single x m) = single x m :=
105-
equiv_fun_on_fintype_symm_single x m
103+
@[simp] lemma linear_equiv_fun_on_finite_symm_single [decidable_eq α]
104+
(x : α) (m : M) : (linear_equiv_fun_on_finite R M α).symm (pi.single x m) = single x m :=
105+
equiv_fun_on_finite_symm_single x m
106106

107-
@[simp] lemma linear_equiv_fun_on_fintype_symm_coe (f : α →₀ M) :
108-
(linear_equiv_fun_on_fintype R M α).symm f = f :=
109-
by { ext, simp [linear_equiv_fun_on_fintype], }
107+
@[simp] lemma linear_equiv_fun_on_finite_symm_coe (f : α →₀ M) :
108+
(linear_equiv_fun_on_finite R M α).symm f = f :=
109+
(linear_equiv_fun_on_finite R M α).symm_apply_apply f
110110

111111
/-- If `α` has a unique term, then the type of finitely supported functions `α →₀ M` is
112112
`R`-linearly equivalent to `M`. -/
113113
noncomputable def linear_equiv.finsupp_unique (α : Type*) [unique α] : (α →₀ M) ≃ₗ[R] M :=
114114
{ map_add' := λ x y, rfl,
115115
map_smul' := λ r x, rfl,
116-
..finsupp.equiv_fun_on_fintype.trans (equiv.fun_unique α M) }
116+
..finsupp.equiv_fun_on_finite.trans (equiv.fun_unique α M) }
117117

118118
variables {R M α}
119119

src/linear_algebra/basis.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ linear_equiv.trans b.repr
742742
({ to_fun := coe_fn,
743743
map_add' := finsupp.coe_add,
744744
map_smul' := finsupp.coe_smul,
745-
..finsupp.equiv_fun_on_fintype } : (ι →₀ R) ≃ₗ[R] (ι → R))
745+
..finsupp.equiv_fun_on_finite } : (ι →₀ R) ≃ₗ[R] (ι → R))
746746

747747
/-- A module over a finite ring that admits a finite basis is finite. -/
748748
def module.fintype_of_fintype [fintype R] : fintype M :=
@@ -792,7 +792,7 @@ end
792792
/-- Define a basis by mapping each vector `x : M` to its coordinates `e x : ι → R`,
793793
as long as `ι` is finite. -/
794794
def basis.of_equiv_fun (e : M ≃ₗ[R] (ι → R)) : basis ι R M :=
795-
basis.of_repr $ e.trans $ linear_equiv.symm $ finsupp.linear_equiv_fun_on_fintype R R ι
795+
basis.of_repr $ e.trans $ linear_equiv.symm $ finsupp.linear_equiv_fun_on_finite R R ι
796796

797797
@[simp] lemma basis.of_equiv_fun_repr_apply (e : M ≃ₗ[R] (ι → R)) (x : M) (i : ι) :
798798
(basis.of_equiv_fun e).repr x i = e x i := rfl
@@ -822,11 +822,11 @@ by simp [b.constr_apply, b.equiv_fun_apply, finsupp.sum_fintype]
822822
`x ∈ P` iff it is a linear combination of basis vectors. -/
823823
lemma basis.mem_submodule_iff' {P : submodule R M} (b : basis ι R P) {x : M} :
824824
x ∈ P ↔ ∃ (c : ι → R), x = ∑ i, c i • b i :=
825-
b.mem_submodule_iff.trans $ finsupp.equiv_fun_on_fintype.exists_congr_left.trans $ exists_congr $
825+
b.mem_submodule_iff.trans $ finsupp.equiv_fun_on_finite.exists_congr_left.trans $ exists_congr $
826826
λ c, by simp [finsupp.sum_fintype]
827827

828828
lemma basis.coord_equiv_fun_symm (i : ι) (f : ι → R) : b.coord i (b.equiv_fun.symm f) = f i :=
829-
b.coord_repr_symm i (finsupp.equiv_fun_on_fintype.symm f)
829+
b.coord_repr_symm i (finsupp.equiv_fun_on_finite.symm f)
830830

831831
end fintype
832832

src/linear_algebra/dimension.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,8 @@ begin
514514
simp only [cardinal.lift_nat_cast, cardinal.nat_cast_inj],
515515
-- Now we can use invariant basis number to show they have the same cardinality.
516516
apply card_eq_of_lequiv R,
517-
exact (((finsupp.linear_equiv_fun_on_fintype R R ι).symm.trans v.repr.symm) ≪≫ₗ
518-
v'.repr) ≪≫ₗ (finsupp.linear_equiv_fun_on_fintype R R ι'), },
517+
exact (((finsupp.linear_equiv_fun_on_finite R R ι).symm.trans v.repr.symm) ≪≫ₗ
518+
v'.repr) ≪≫ₗ (finsupp.linear_equiv_fun_on_finite R R ι'), },
519519
{ -- `v` is an infinite basis,
520520
-- so by `infinite_basis_le_maximal_linear_independent`, `v'` is at least as big,
521521
-- and then applying `infinite_basis_le_maximal_linear_independent` again

src/linear_algebra/dual.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ begin
176176
casesI nonempty_fintype ι,
177177
refine eq_top_iff'.2 (λ f, _),
178178
rw linear_map.mem_range,
179-
let lin_comb : ι →₀ R := finsupp.equiv_fun_on_fintype.2 (λ i, f.to_fun (b i)),
179+
let lin_comb : ι →₀ R := finsupp.equiv_fun_on_finite.symm (λ i, f.to_fun (b i)),
180180
refine ⟨finsupp.total ι M R b lin_comb, b.ext $ λ i, _⟩,
181181
rw [b.to_dual_eq_repr _ i, repr_total b],
182182
refl,

0 commit comments

Comments
 (0)