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

Commit d61f638

Browse files
committed
chore(data/finsupp/defs): redefine finsupp.single as pi.single (#17356)
This also brings it in line with `dfinsupp.single`. Note that the two are still not defeq due to different decidability instances, but things are least more consistent now. In order to make some proofs still unify, this makes some type arguments explicit to `constant_coeff_C` and `constant_coeff_X`. These lemmas should have had these as explicit arguments anyway, as the type can't be inferred from the other arguments.
1 parent c66f2ae commit d61f638

File tree

7 files changed

+25
-26
lines changed

7 files changed

+25
-26
lines changed

src/data/finsupp/defs.lean

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,17 @@ variables [has_zero M] {a a' : α} {b : M}
202202

203203
/-- `single a b` is the finitely supported function with value `b` at `a` and zero otherwise. -/
204204
def single (a : α) (b : M) : α →₀ M :=
205-
if b = 0 thenelse {a}, λ a', if a = a' then b else 0, λ a', begin
206-
by_cases hb : b = 0; by_cases a = a';
207-
simp only [hb, h, if_pos, if_false, mem_singleton],
208-
{ exact ⟨false.elim, λ H, H rfl⟩ },
209-
{ exact ⟨false.elim, λ H, H rfl⟩ },
210-
{ exact ⟨λ _, hb, λ _, rfl⟩ },
211-
{ exact ⟨λ H _, h H.symm, λ H, (H rfl).elim⟩ }
205+
if b = 0 thenelse {a}, pi.single a b, λ a', begin
206+
obtain rfl | hb := eq_or_ne b 0,
207+
{ simp },
208+
rw [if_neg hb, mem_singleton],
209+
obtain rfl | ha := eq_or_ne a' a,
210+
{ simp [hb] },
211+
simp [pi.single_eq_of_ne', ha],
212212
end
213213

214214
lemma single_apply [decidable (a = a')] : single a b a' = if a = a' then b else 0 :=
215-
by convert rfl
215+
by { simp_rw [@eq_comm _ a a'], convert pi.single_apply _ _ _, }
216216

217217
lemma single_apply_left {f : α → β} (hf : function.injective f)
218218
(x z : α) (y : M) :
@@ -223,10 +223,10 @@ lemma single_eq_indicator : ⇑(single a b) = set.indicator {a} (λ _, b) :=
223223
by { ext, simp [single_apply, set.indicator, @eq_comm _ a] }
224224

225225
@[simp] lemma single_eq_same : (single a b : α →₀ M) a = b :=
226-
if_pos rfl
226+
pi.single_eq_same a b
227227

228228
@[simp] lemma single_eq_of_ne (h : a ≠ a') : (single a b : α →₀ M) a' = 0 :=
229-
if_neg h
229+
pi.single_eq_of_ne' h _
230230

231231
lemma single_eq_update [decidable_eq α] (a : α) (b : M) : ⇑(single a b) = function.update 0 a b :=
232232
by rw [single_eq_indicator, ← set.piecewise_eq_indicator, set.piecewise_singleton]
@@ -577,7 +577,7 @@ support_on_finset_subset
577577

578578
@[simp] lemma map_range_single {f : M → N} {hf : f 0 = 0} {a : α} {b : M} :
579579
map_range f hf (single a b) = single a (f b) :=
580-
ext $ λ a', show f (ite _ _ _) = ite _ _ _, by split_ifs; [refl, exact hf]
580+
ext $ λ a', by simpa only [single_eq_pi_single] using pi.apply_single _ (λ _, hf) a _ a'
581581

582582
lemma support_map_range_of_injective
583583
{e : M → N} (he0 : e 0 = 0) (f : ι →₀ M) (he : function.injective e) :

src/data/mv_polynomial/basic.lean

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -657,15 +657,15 @@ def constant_coeff : mv_polynomial σ R →+* R :=
657657

658658
lemma constant_coeff_eq : (constant_coeff : mv_polynomial σ R → R) = coeff 0 := rfl
659659

660-
@[simp]
661-
lemma constant_coeff_C (r : R) :
662-
constant_coeff (C r : mv_polynomial σ R) = r :=
660+
variables (σ)
661+
@[simp] lemma constant_coeff_C (r : R) : constant_coeff (C r : mv_polynomial σ R) = r :=
663662
by simp [constant_coeff_eq]
663+
variables {σ}
664664

665-
@[simp]
666-
lemma constant_coeff_X (i : σ) :
667-
constant_coeff (X i : mv_polynomial σ R) = 0 :=
665+
variables (R)
666+
@[simp] lemma constant_coeff_X (i : σ) : constant_coeff (X i : mv_polynomial σ R) = 0 :=
668667
by simp [constant_coeff_eq]
668+
variables {R}
669669

670670
lemma constant_coeff_monomial [decidable_eq σ] (d : σ →₀ ℕ) (r : R) :
671671
constant_coeff (monomial d r) = if d = 0 then r else 0 :=
@@ -675,7 +675,7 @@ variables (σ R)
675675

676676
@[simp] lemma constant_coeff_comp_C :
677677
constant_coeff.comp (C : R →+* mv_polynomial σ R) = ring_hom.id R :=
678-
by { ext, apply constant_coeff_C }
678+
by { ext x, exact constant_coeff_C σ x }
679679

680680
@[simp] lemma constant_coeff_comp_algebra_map :
681681
constant_coeff.comp (algebra_map R (mv_polynomial σ R)) = ring_hom.id R :=

src/data/mv_polynomial/variables.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,7 @@ begin
487487
congr,
488488
ext,
489489
simp only [single, nat.one_ne_zero, add_right_eq_self, add_right_embedding_apply, coe_mk,
490-
pi.add_apply, comp_app, ite_eq_right_iff, finsupp.coe_add],
491-
cc,
490+
pi.add_apply, comp_app, ite_eq_right_iff, finsupp.coe_add, pi.single_eq_of_ne h],
492491
end
493492

494493
/- TODO in the following we have equality iff f ≠ 0 -/

src/linear_algebra/direct_sum/finsupp.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ begin
5757
{ intros g₁ g₂ hg₁ hg₂, simp [tmul_add, hg₁, hg₂], },
5858
{ intros k' n,
5959
simp only [finsupp_tensor_finsupp_single],
60-
simp only [finsupp.single, finsupp.coe_mk],
60+
simp only [finsupp.single_apply],
6161
-- split_ifs; finish can close the goal from here
6262
by_cases h1 : (i', k') = (i, k),
6363
{ simp only [prod.mk.inj_iff] at h1, simp [h1] },
@@ -89,6 +89,6 @@ by simp [finsupp_tensor_finsupp']
8989
@[simp] lemma finsupp_tensor_finsupp'_single_tmul_single (a : α) (b : β) (r₁ r₂ : S) :
9090
finsupp_tensor_finsupp' S α β (finsupp.single a r₁ ⊗ₜ[S] finsupp.single b r₂) =
9191
finsupp.single (a, b) (r₁ * r₂) :=
92-
by { ext ⟨a', b'⟩, simp [finsupp.single, ite_and] }
92+
by { ext ⟨a', b'⟩, simp [finsupp.single_apply, ite_and] }
9393

9494
end tensor_product

src/linear_algebra/matrix/basis.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ by { ext M i j, refl, }
7272
begin
7373
rw basis.to_matrix,
7474
ext i j,
75-
simp [basis.equiv_fun, matrix.one_apply, finsupp.single, eq_comm]
75+
simp [basis.equiv_fun, matrix.one_apply, finsupp.single_apply, eq_comm]
7676
end
7777

7878
lemma to_matrix_update [decidable_eq ι'] (x : M) :

src/linear_algebra/matrix/to_lin.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ end
444444
lemma linear_map.to_matrix_id : linear_map.to_matrix v₁ v₁ id = 1 :=
445445
begin
446446
ext i j,
447-
simp [linear_map.to_matrix_apply, matrix.one_apply, finsupp.single, eq_comm]
447+
simp [linear_map.to_matrix_apply, matrix.one_apply, finsupp.single_apply, eq_comm]
448448
end
449449

450450
lemma linear_map.to_matrix_one : linear_map.to_matrix v₁ v₁ 1 = 1 :=

src/ring_theory/polynomial/basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,9 @@ begin
745745
end
746746

747747
lemma prime_C_iff : prime (C r : mv_polynomial σ R) ↔ prime r :=
748-
⟨ comap_prime C constant_coeff constant_coeff_C,
748+
⟨ comap_prime C constant_coeff (constant_coeff_C _),
749749
λ hr, ⟨ λ h, hr.1 $ by { rw [← C_inj, h], simp },
750-
λ h, hr.2.1 $ by { rw ← constant_coeff_C r, exact h.map _ },
750+
λ h, hr.2.1 $ by { rw ← constant_coeff_C _ r, exact h.map _ },
751751
λ a b hd, begin
752752
obtain ⟨s,a',b',rfl,rfl⟩ := exists_finset_rename₂ a b,
753753
rw ← algebra_map_eq at hd, have : algebra_map R _ r ∣ a' * b',

0 commit comments

Comments
 (0)