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

Commit e43d964

Browse files
urkuderic-wieser
andcommitted
chore(data/pi,algebra/group/pi): reorganize proofs (#6869)
Add `pi.single_op` and `pi.single_binop` and use them in the proofs. Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
1 parent 3566cbb commit e43d964

File tree

3 files changed

+28
-34
lines changed

3 files changed

+28
-34
lines changed

src/algebra/group/pi.lean

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -154,38 +154,27 @@ into a dependent family of values, as functions supported at a point.
154154
This is the `zero_hom` version of `pi.single`. -/
155155
@[simps] def zero_hom.single [Π i, has_zero $ f i] (i : I) : zero_hom (f i) (Π i, f i) :=
156156
{ to_fun := single i,
157-
map_zero' := function.update_eq_self i 0 }
157+
map_zero' := single_zero i }
158158

159159
/-- The additive monoid homomorphism including a single additive monoid
160160
into a dependent family of additive monoids, as functions supported at a point.
161161
162162
This is the `add_monoid_hom` version of `pi.single`. -/
163163
@[simps] def add_monoid_hom.single [Π i, add_monoid $ f i] (i : I) : f i →+ Π i, f i :=
164164
{ to_fun := single i,
165-
map_add' := λ x y, funext $ λ j, begin
166-
refine (apply_single₂ _ (λ _, _) i x y j).symm,
167-
exact zero_add 0,
168-
end,
165+
map_add' := single_op₂ (λ _, (+)) (λ _, zero_add _) _,
169166
.. (zero_hom.single f i) }
170167

171-
/-- The multiplicative homomorphism including a single `monoid_with_zero`
172-
into a dependent family of monoid_with_zeros, as functions supported at a point.
168+
/-- The multiplicative homomorphism including a single `mul_zero_class`
169+
into a dependent family of `mul_zero_class`es, as functions supported at a point.
173170
174171
This is the `mul_hom` version of `pi.single`. -/
175-
@[simps] def mul_hom.single [Π i, monoid_with_zero $ f i] (i : I) : mul_hom (f i) (Π i, f i) :=
172+
@[simps] def mul_hom.single [Π i, mul_zero_class $ f i] (i : I) : mul_hom (f i) (Π i, f i) :=
176173
{ to_fun := single i,
177-
map_mul' := λ x y, funext $ λ j, begin
178-
refine (apply_single₂ _ (λ _, _) i x y j).symm,
179-
exact zero_mul 0,
180-
end, }
174+
map_mul' := single_op₂ (λ _, (*)) (λ _, zero_mul _) _, }
181175

182176
variables {f}
183177

184-
@[simp]
185-
lemma pi.single_zero [Π i, has_zero $ f i] (i : I) :
186-
single i (0 : f i) = 0 :=
187-
(zero_hom.single f i).map_zero
188-
189178
lemma pi.single_add [Π i, add_monoid $ f i] (i : I) (x y : f i) :
190179
single i (x + y) = single i x + single i y :=
191180
(add_monoid_hom.single f i).map_add x y
@@ -198,7 +187,7 @@ lemma pi.single_sub [Π i, add_group $ f i] (i : I) (x y : f i) :
198187
single i (x - y) = single i x - single i y :=
199188
(add_monoid_hom.single f i).map_sub x y
200189

201-
lemma pi.single_mul [Π i, monoid_with_zero $ f i] (i : I) (x y : f i) :
190+
lemma pi.single_mul [Π i, mul_zero_class $ f i] (i : I) (x y : f i) :
202191
single i (x * y) = single i x * single i y :=
203192
(mul_hom.single f i).map_mul x y
204193

src/algebra/module/pi.lean

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,12 @@ instance distrib_mul_action' {g : I → Type*} {m : Π i, monoid (f i)} {n : Π
9191
lemma single_smul {α} [monoid α] [Π i, add_monoid $ f i]
9292
[Π i, distrib_mul_action α $ f i] [decidable_eq I] (i : I) (r : α) (x : f i) :
9393
single i (r • x) = r • single i x :=
94-
begin
95-
ext j,
96-
refine (apply_single _ (λ _, _) i x j).symm,
97-
exact smul_zero _,
98-
end
94+
single_op (λ i : I, ((•) r : f i → f i)) (λ j, smul_zero _) _ _
9995

10096
lemma single_smul' {g : I → Type*} [Π i, monoid_with_zero (f i)] [Π i, add_monoid (g i)]
10197
[Π i, distrib_mul_action (f i) (g i)] [decidable_eq I] (i : I) (r : f i) (x : g i) :
10298
single i (r • x) = single i r • single i x :=
103-
begin
104-
ext j,
105-
refine (apply_single₂ _ (λ _, _) i r x j).symm,
106-
exact smul_zero _,
107-
end
99+
single_op₂ (λ i : I, ((•) : f i → g i → g i)) (λ j, smul_zero _) _ _ _
108100

109101
variables (I f)
110102

src/data/pi.lean

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ instance has_mul [∀ i, has_mul $ f i] :
3838
⟨λ f g i, f i * g i⟩
3939
@[simp, to_additive] lemma mul_apply [∀ i, has_mul $ f i] : (x * y) i = x i * y i := rfl
4040

41+
@[to_additive] lemma mul_def [Π i, has_mul $ f i] : x * y = λ i, x i * y i := rfl
42+
4143
@[to_additive] instance has_inv [∀ i, has_inv $ f i] :
4244
has_inv (Π i : I, f i) :=
4345
⟨λ f i, (f i)⁻¹⟩
@@ -58,14 +60,15 @@ variables [Π i, has_zero (f i)] [Π i, has_zero (g i)] [Π i, has_zero (h i)]
5860
def single (i : I) (x : f i) : Π i, f i :=
5961
function.update 0 i x
6062

61-
@[simp]
62-
lemma single_eq_same (i : I) (x : f i) : single i x i = x :=
63+
@[simp] lemma single_eq_same (i : I) (x : f i) : single i x i = x :=
6364
function.update_same i x _
6465

65-
@[simp]
66-
lemma single_eq_of_ne {i i' : I} (h : i' ≠ i) (x : f i) : single i x i' = 0 :=
66+
@[simp] lemma single_eq_of_ne {i i' : I} (h : i' ≠ i) (x : f i) : single i x i' = 0 :=
6767
function.update_noteq h x _
6868

69+
@[simp] lemma single_zero (i : I) : single i (0 : f i) = 0 :=
70+
function.update_eq_self _ _
71+
6972
lemma apply_single (f' : Π i, f i → g i) (hf' : ∀ i, f' i 0 = 0) (i : I) (x : f i) (j : I):
7073
f' j (single i x j) = single i (f' i x) j :=
7174
by simpa only [pi.zero_apply, hf', single] using function.apply_update f' 0 i x j
@@ -75,10 +78,20 @@ lemma apply_single₂ (f' : Π i, f i → g i → h i) (hf' : ∀ i, f' i 0 0 =
7578
f' j (single i x j) (single i y j) = single i (f' i x y) j :=
7679
begin
7780
by_cases h : j = i,
78-
{ subst h, simp only [single_eq_same], },
79-
{ simp only [h, single_eq_of_ne, ne.def, not_false_iff, hf'], },
81+
{ subst h, simp only [single_eq_same] },
82+
{ simp only [single_eq_of_ne h, hf'] },
8083
end
8184

85+
lemma single_op {g : I → Type*} [Π i, has_zero (g i)] (op : Π i, f i → g i) (h : ∀ i, op i 0 = 0)
86+
(i : I) (x : f i) :
87+
single i (op i x) = λ j, op j (single i x j) :=
88+
eq.symm $ funext $ apply_single op h i x
89+
90+
lemma single_op₂ {g₁ g₂ : I → Type*} [Π i, has_zero (g₁ i)] [Π i, has_zero (g₂ i)]
91+
(op : Π i, g₁ i → g₂ i → f i) (h : ∀ i, op i 0 0 = 0) (i : I) (x₁ : g₁ i) (x₂ : g₂ i) :
92+
single i (op i x₁ x₂) = λ j, op j (single i x₁ j) (single i x₂ j) :=
93+
eq.symm $ funext $ apply_single₂ op h i x₁ x₂
94+
8295
variables (f)
8396

8497
lemma single_injective (i : I) : function.injective (single i : f i → Π i, f i) :=

0 commit comments

Comments
 (0)