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

Commit 9648ce2

Browse files
committed
chore(data/pi): add pi.prod and use elsewhere (#11877)
`pi.prod` is the function that underlies `add_monoid_hom.prod`, `linear_map.prod`, etc. [Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there.20code.20for.20X.3F/topic/Some.20missing.20prod.20stuff/near/270851797)
1 parent ca2450f commit 9648ce2

File tree

11 files changed

+37
-23
lines changed

11 files changed

+37
-23
lines changed

archive/sensitivity.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ lemma f_succ_apply (v : V (n+1)) :
259259
begin
260260
cases v,
261261
rw f,
262-
simp only [linear_map.id_apply, linear_map.prod_apply, prod.mk.inj_iff,
262+
simp only [linear_map.id_apply, linear_map.prod_apply, pi.prod, prod.mk.inj_iff,
263263
linear_map.neg_apply, sub_eq_add_neg, linear_map.coprod_apply],
264264
exact ⟨rfl, rfl⟩
265265
end
@@ -311,7 +311,7 @@ lemma g_injective : injective (g m) :=
311311
begin
312312
rw g,
313313
intros x₁ x₂ h,
314-
simp only [linear_map.prod_apply, linear_map.id_apply, prod.mk.inj_iff] at h,
314+
simp only [linear_map.prod_apply, linear_map.id_apply, prod.mk.inj_iff, pi.prod] at h,
315315
exact h.right
316316
end
317317

src/algebra/big_operators/basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ lemma ring_hom.map_sum [non_assoc_semiring β] [non_assoc_semiring γ]
152152
g.to_add_monoid_hom.map_sum f s
153153

154154
@[to_additive]
155-
lemma monoid_hom.coe_prod [mul_one_class β] [comm_monoid γ] (f : α → β →* γ) (s : finset α) :
155+
lemma monoid_hom.coe_finset_prod [mul_one_class β] [comm_monoid γ] (f : α → β →* γ) (s : finset α) :
156156
⇑(∏ x in s, f x) = ∏ x in s, f x :=
157157
(monoid_hom.coe_fn β γ).map_prod _ _
158158

src/algebra/direct_sum/ring.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ begin
250250
change direct_sum.mul_hom _ a a' = _,
251251
dsimp [direct_sum.mul_hom, direct_sum.to_add_monoid, dfinsupp.lift_add_hom_apply],
252252
simp only [dfinsupp.sum_add_hom_apply, dfinsupp.sum, dfinsupp.finset_sum_apply,
253-
add_monoid_hom.coe_sum, finset.sum_apply, add_monoid_hom.flip_apply,
253+
add_monoid_hom.coe_finset_sum, finset.sum_apply, add_monoid_hom.flip_apply,
254254
add_monoid_hom.comp_hom_apply_apply, add_monoid_hom.comp_apply,
255255
direct_sum.gmul_hom_apply_apply],
256256
rw finset.sum_product,

src/algebra/group/prod.lean

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,17 @@ section prod
219219
variable [mul_one_class P]
220220

221221
/-- Combine two `monoid_hom`s `f : M →* N`, `g : M →* P` into `f.prod g : M →* N × P`
222-
given by `(f.prod g) x = (f x, g x)` -/
222+
given by `(f.prod g) x = (f x, g x)`. -/
223223
@[to_additive prod "Combine two `add_monoid_hom`s `f : M →+ N`, `g : M →+ P` into
224224
`f.prod g : M →+ N × P` given by `(f.prod g) x = (f x, g x)`"]
225225
protected def prod (f : M →* N) (g : M →* P) : M →* N × P :=
226-
{ to_fun := λ x, (f x, g x),
226+
{ to_fun := pi.prod f g,
227227
map_one' := prod.ext f.map_one g.map_one,
228228
map_mul' := λ x y, prod.ext (f.map_mul x y) (g.map_mul x y) }
229229

230+
@[to_additive coe_prod]
231+
lemma coe_prod (f : M →* N) (g : M →* P) : ⇑(f.prod g) = pi.prod f g := rfl
232+
230233
@[simp, to_additive prod_apply]
231234
lemma prod_apply (f : M →* N) (g : M →* P) (x) : f.prod g x = (f x, g x) := rfl
232235

src/algebra/triv_sq_zero_ext.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ variables (R M)
235235
/-- The canonical `R`-linear inclusion `M → triv_sq_zero_ext R M`. -/
236236
@[simps apply]
237237
def inr_hom [semiring R] [add_comm_monoid M] [module R M] : M →ₗ[R] tsze R M :=
238-
{ to_fun := inr, ..linear_map.inr _ _ _ }
238+
{ to_fun := inr, ..linear_map.inr R R M }
239239

240240
/-- The canonical `R`-linear projection `triv_sq_zero_ext R M → M`. -/
241241
@[simps apply]

src/data/dfinsupp/basic.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,8 +1510,9 @@ end dfinsupp
15101510

15111511
/-! ### Product and sum lemmas for bundled morphisms.
15121512
1513-
In this section, we provide analogues of `add_monoid_hom.map_sum`, `add_monoid_hom.coe_sum`, and
1514-
`add_monoid_hom.sum_apply` for `dfinsupp.sum` and `dfinsupp.sum_add_hom` instead of `finset.sum`.
1513+
In this section, we provide analogues of `add_monoid_hom.map_sum`, `add_monoid_hom.coe_finset_sum`,
1514+
and `add_monoid_hom.finset_sum_apply` for `dfinsupp.sum` and `dfinsupp.sum_add_hom` instead of
1515+
`finset.sum`.
15151516
15161517
We provide these for `add_monoid_hom`, `monoid_hom`, `ring_hom`, `add_equiv`, and `mul_equiv`.
15171518
@@ -1533,7 +1534,7 @@ lemma map_dfinsupp_prod [comm_monoid R] [comm_monoid S]
15331534
@[to_additive]
15341535
lemma coe_dfinsupp_prod [monoid R] [comm_monoid S]
15351536
(f : Π₀ i, β i) (g : Π i, β i → R →* S) :
1536-
⇑(f.prod g) = f.prod (λ a b, (g a b)) := coe_prod _ _
1537+
⇑(f.prod g) = f.prod (λ a b, (g a b)) := coe_finset_prod _ _
15371538

15381539
@[simp, to_additive]
15391540
lemma dfinsupp_prod_apply [monoid R] [comm_monoid S]

src/data/finsupp/basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ h.map_prod _ _
10681068
lemma monoid_hom.coe_finsupp_prod [has_zero β] [monoid N] [comm_monoid P]
10691069
(f : α →₀ β) (g : α → β → N →* P) :
10701070
⇑(f.prod g) = f.prod (λ i fi, g i fi) :=
1071-
monoid_hom.coe_prod _ _
1071+
monoid_hom.coe_finset_prod _ _
10721072

10731073
@[simp, to_additive]
10741074
lemma monoid_hom.finsupp_prod_apply [has_zero β] [monoid N] [comm_monoid P]

src/data/pi.lean

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import tactic.split_ifs
77
import tactic.simpa
88
import tactic.congr
99
import algebra.group.to_additive
10+
import data.prod
1011
/-!
1112
# Instances and theorems on pi types
1213
@@ -145,6 +146,16 @@ function.update_injective _ i
145146
(pi.single_injective _ _).eq_iff
146147

147148
end
149+
150+
/-- The mapping into a product type built from maps into each component. -/
151+
@[simp] protected def prod (f' : Π i, f i) (g' : Π i, g i) (i : I) : f i × g i := (f' i, g' i)
152+
153+
@[simp] lemma prod_fst_snd : pi.prod (prod.fst : α × β → α) (prod.snd : α × β → β) = id :=
154+
funext $ λ _, prod.mk.eta
155+
156+
@[simp] lemma prod_snd_fst : pi.prod (prod.snd : α × β → β) (prod.fst : α × β → α) = prod.swap :=
157+
rfl
158+
148159
end pi
149160

150161
namespace function

src/linear_algebra/dimension.lean

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,18 +1067,15 @@ lemma dim_add_dim_split
10671067
(eq₂ : ∀d e, db d = eb e → (∃c, cd c = d ∧ ce c = e)) :
10681068
module.rank K V + module.rank K V₁ = module.rank K V₂ + module.rank K V₃ :=
10691069
have hf : surjective (coprod db eb),
1070-
begin
1071-
refine (range_eq_top.1 $ top_unique $ _),
1072-
rwa [← map_top, ← prod_top, map_coprod_prod, ←range_eq_map, ←range_eq_map]
1073-
end,
1070+
by rwa [←range_eq_top, range_coprod, eq_top_iff],
10741071
begin
10751072
conv {to_rhs, rw [← dim_prod, dim_eq_of_surjective _ hf] },
10761073
congr' 1,
10771074
apply linear_equiv.dim_eq,
10781075
refine linear_equiv.of_bijective _ _ _,
10791076
{ refine cod_restrict _ (prod cd (- ce)) _,
10801077
{ assume c,
1081-
simp only [add_eq_zero_iff_eq_neg, linear_map.prod_apply, mem_ker,
1078+
simp only [add_eq_zero_iff_eq_neg, linear_map.prod_apply, mem_ker, pi.prod,
10821079
coprod_apply, neg_neg, map_neg, neg_apply],
10831080
exact linear_map.ext_iff.1 eq c } },
10841081
{ rw [← ker_eq_bot, ker_cod_restrict, ker_prod, hgd, bot_inf_eq] },
@@ -1087,7 +1084,7 @@ begin
10871084
rintros ⟨d, e⟩,
10881085
have h := eq₂ d (-e),
10891086
simp only [add_eq_zero_iff_eq_neg, linear_map.prod_apply, mem_ker, set_like.mem_coe,
1090-
prod.mk.inj_iff, coprod_apply, map_neg, neg_apply, linear_map.mem_range] at ⊢ h,
1087+
prod.mk.inj_iff, coprod_apply, map_neg, neg_apply, linear_map.mem_range, pi.prod] at ⊢ h,
10911088
assume hde,
10921089
rcases h hde with ⟨c, h₁, h₂⟩,
10931090
refine ⟨c, h₁, _⟩,

src/linear_algebra/prod.lean

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ theorem snd_surjective : function.surjective (snd R M M₂) := λ x, ⟨(0, x),
6262

6363
/-- The prod of two linear maps is a linear map. -/
6464
@[simps] def prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) : (M →ₗ[R] M₂ × M₃) :=
65-
{ to_fun := λ x, (f x, g x),
66-
map_add' := λ x y, by simp only [prod.mk_add_mk, map_add],
67-
map_smul' := λ c x, by simp only [prod.smul_mk, map_smul, ring_hom.id_apply] }
65+
{ to_fun := pi.prod f g,
66+
map_add' := λ x y, by simp only [pi.prod, prod.mk_add_mk, map_add],
67+
map_smul' := λ c x, by simp only [pi.prod, prod.smul_mk, map_smul, ring_hom.id_apply] }
6868

69+
lemma coe_prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) : ⇑(f.prod g) = pi.prod f g := rfl
6970

7071
@[simp] theorem fst_prod (f : M →ₗ[R] M₂) (g : M →ₗ[R] M₃) :
7172
(fst R M₂ M₃).comp (prod f g) = f := by ext; refl
@@ -74,7 +75,7 @@ theorem snd_surjective : function.surjective (snd R M M₂) := λ x, ⟨(0, x),
7475
(snd R M₂ M₃).comp (prod f g) = g := by ext; refl
7576

7677
@[simp] theorem pair_fst_snd : prod (fst R M M₂) (snd R M M₂) = linear_map.id :=
77-
by ext; refl
78+
fun_like.coe_injective pi.prod_fst_snd
7879

7980
/-- Taking the product of two maps with the same domain is equivalent to taking the product of
8081
their codomains.
@@ -552,7 +553,7 @@ lemma range_prod_eq {f : M →ₗ[R] M₂} {g : M →ₗ[R] M₃} (h : ker f ⊔
552553
begin
553554
refine le_antisymm (f.range_prod_le g) _,
554555
simp only [set_like.le_def, prod_apply, mem_range, set_like.mem_coe, mem_prod, exists_imp_distrib,
555-
and_imp, prod.forall],
556+
and_imp, prod.forall, pi.prod],
556557
rintros _ _ x rfl y rfl,
557558
simp only [prod.mk.inj_iff, ← sub_mem_ker_iff],
558559
have : y - x ∈ ker f ⊔ ker g, { simp only [h, mem_top] },

0 commit comments

Comments
 (0)