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

Commit 7803884

Browse files
committed
feat(data/pi): Composition of addition/subtraction/... of functions (#10305)
1 parent 43ef578 commit 7803884

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

src/algebra/group/pi.lean

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,6 @@ instance comm_monoid_with_zero [∀ i, comm_monoid_with_zero $ f i] :
124124
by refine_struct { zero := (0 : Π i, f i), one := (1 : Π i, f i), mul := (*),
125125
npow := monoid.npow }; tactic.pi_instance_derive_field
126126

127-
section instance_lemmas
128-
open function
129-
130-
variables {α β γ : Type*}
131-
132-
@[simp, to_additive] lemma const_one [has_one β] : const α (1 : β) = 1 := rfl
133-
134-
@[simp, to_additive] lemma comp_one [has_one β] {f : β → γ} : f ∘ 1 = const α (f 1) := rfl
135-
136-
@[simp, to_additive] lemma one_comp [has_one γ] {f : α → β} : (1 : β → γ) ∘ f = 1 := rfl
137-
138-
end instance_lemmas
139-
140127
end pi
141128

142129
section monoid_hom

src/data/pi.lean

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ This file provides basic definitions and notation instances for Pi types.
1515
Instances of more sophisticated classes are defined in `pi.lean` files elsewhere.
1616
-/
1717

18+
open function
19+
1820
universes u v₁ v₂ v₃
1921
variable {I : Type u} -- The indexing type
22+
variables {α β γ : Type*}
2023
-- The families of types already equipped with instances
2124
variables {f : I → Type v₁} {g : I → Type v₂} {h : I → Type v₃}
2225
variables (x y : Π i, f i) (i : I)
@@ -32,6 +35,12 @@ namespace pi
3235

3336
@[to_additive] lemma one_def [Π i, has_one $ f i] : (1 : Π i, f i) = λ i, 1 := rfl
3437

38+
@[simp, to_additive] lemma const_one [has_one β] : const α (1 : β) = 1 := rfl
39+
40+
@[simp, to_additive] lemma one_comp [has_one γ] (x : α → β) : (1 : β → γ) ∘ x = 1 := rfl
41+
42+
@[simp, to_additive] lemma comp_one [has_one β] (x : β → γ) : x ∘ 1 = const α (x 1) := rfl
43+
3544
@[to_additive]
3645
instance has_mul [∀ i, has_mul $ f i] :
3746
has_mul (Π i : I, f i) :=
@@ -40,18 +49,34 @@ instance has_mul [∀ i, has_mul $ f i] :
4049

4150
@[to_additive] lemma mul_def [Π i, has_mul $ f i] : x * y = λ i, x i * y i := rfl
4251

52+
@[simp, to_additive] lemma const_mul [has_mul β] (a b : β) :
53+
const α a * const α b = const α (a * b) := rfl
54+
55+
@[to_additive] lemma mul_comp [has_mul γ] (x y : β → γ) (z : α → β) :
56+
(x * y) ∘ z = x ∘ z * y ∘ z := rfl
57+
4358
@[to_additive] instance has_inv [∀ i, has_inv $ f i] :
4459
has_inv (Π i : I, f i) :=
4560
⟨λ f i, (f i)⁻¹⟩
4661
@[simp, to_additive] lemma inv_apply [∀ i, has_inv $ f i] : x⁻¹ i = (x i)⁻¹ := rfl
4762
@[to_additive] lemma inv_def [Π i, has_inv $ f i] : x⁻¹ = λ i, (x i)⁻¹ := rfl
4863

64+
@[to_additive] lemma const_inv [has_inv β] (a : β) : (const α a)⁻¹ = const α a⁻¹ := rfl
65+
66+
@[to_additive] lemma inv_comp [has_inv γ] (x : β → γ) (y : α → β) : x⁻¹ ∘ y = (x ∘ y)⁻¹ := rfl
67+
4968
@[to_additive] instance has_div [Π i, has_div $ f i] :
5069
has_div (Π i : I, f i) :=
5170
⟨λ f g i, f i / g i⟩
5271
@[simp, to_additive] lemma div_apply [Π i, has_div $ f i] : (x / y) i = x i / y i := rfl
5372
@[to_additive] lemma div_def [Π i, has_div $ f i] : x / y = λ i, x i / y i := rfl
5473

74+
@[to_additive] lemma div_comp [has_div γ] (x y : β → γ) (z : α → β) :
75+
(x / y) ∘ z = x ∘ z / y ∘ z := rfl
76+
77+
@[simp, to_additive] lemma const_div [has_div β] (a b : β) :
78+
const α a / const α b = const α (a / b) := rfl
79+
5580
section
5681

5782
variables [decidable_eq I]
@@ -116,11 +141,8 @@ end
116141
end pi
117142

118143
section extend
119-
120144
namespace function
121145

122-
variables {α β γ : Type*}
123-
124146
@[to_additive]
125147
lemma extend_one [has_one γ] (f : α → β) :
126148
function.extend f (1 : α → γ) (1 : β → γ) = 1 :=

0 commit comments

Comments
 (0)