Skip to content

Commit 7cbd368

Browse files
committed
refactor(Algebra/Algebra/Pi): cleanup and renaming
1 parent abcae08 commit 7cbd368

1 file changed

Lines changed: 46 additions & 62 deletions

File tree

Mathlib/Algebra/Algebra/Pi.lean

Lines changed: 46 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Mathlib.Algebra.Algebra.Equiv
88
/-!
99
# The R-algebra structure on families of R-algebras
1010
11-
The R-algebra structure on ` i : I, A i` when each `A i` is an R-algebra.
11+
The R-algebra structure on `Π i : I, A i` when each `A i` is an R-algebra.
1212
1313
## Main definitions
1414
@@ -17,79 +17,66 @@ The R-algebra structure on `∀ i : I, A i` when each `A i` is an R-algebra.
1717
* `Pi.constAlgHom`
1818
-/
1919

20-
21-
universe u v w
22-
2320
namespace Pi
2421

2522
-- The indexing type
26-
variable {I : Type u}
23+
variable : Type*)
2724

2825
-- The scalar type
2926
variable {R : Type*}
3027

3128
-- The family of types already equipped with instances
32-
variable {f : I → Type v}
33-
variable (x y : ∀ i, f i) (i : I)
34-
variable (I f)
29+
variable (A : ι → Type*)
30+
variable [CommSemiring R] [∀ i, Semiring (A i)] [∀ i, Algebra R (A i)]
3531

36-
instance algebra {r : CommSemiring R} [s : ∀ i, Semiring (f i)] [∀ i, Algebra R (f i)] :
37-
Algebra R (∀ i : I, f i) where
38-
algebraMap := (Pi.ringHom fun i => algebraMap R (f i) : R →+* ∀ i : I, f i)
32+
instance algebra : Algebra R (Π i, A i) where
33+
algebraMap := (Pi.ringHom fun i => algebraMap R (A i) : R →+* Π i, A i)
3934
commutes' := fun a f => by ext; simp [Algebra.commutes]
4035
smul_def' := fun a f => by ext; simp [Algebra.smul_def]
4136

42-
theorem algebraMap_def {_ : CommSemiring R} [_s : ∀ i, Semiring (f i)] [∀ i, Algebra R (f i)]
43-
(a : R) : algebraMap R (∀ i, f i) a = fun i => algebraMap R (f i) a :=
37+
theorem algebraMap_def (a : R) : algebraMap R (Π i, A i) a = fun i => algebraMap R (A i) a :=
4438
rfl
4539

4640
@[simp]
47-
theorem algebraMap_apply {_ : CommSemiring R} [_s : ∀ i, Semiring (f i)] [∀ i, Algebra R (f i)]
48-
(a : R) (i : I) : algebraMap R (∀ i, f i) a i = algebraMap R (f i) a :=
41+
theorem algebraMap_apply (a : R) (i : ι) : algebraMap R (Π i, A i) a i = algebraMap R (A i) a :=
4942
rfl
5043

51-
variable {I} in
52-
instance (g : I → Type*) [∀ i, CommSemiring (f i)] [∀ i, Semiring (g i)]
53-
[∀ i, Algebra (f i) (g i)] : Algebra (∀ i, f i) (∀ i, g i) where
54-
algebraMap := Pi.ringHom fun _ ↦ (algebraMap _ _).comp (Pi.evalRingHom f _)
55-
commutes' _ _ := funext fun _ ↦ Algebra.commutes _ _
56-
smul_def' _ _ := funext fun _ ↦ Algebra.smul_def _ _
57-
58-
example [∀ i, CommSemiring (f i)] : Pi.instAlgebraForall f f = Algebra.id _ := rfl
59-
60-
-- One could also build a `∀ i, R i`-algebra structure on `∀ i, A i`,
61-
-- when each `A i` is an `R i`-algebra, although I'm not sure that it's useful.
62-
variable {I} (R)
44+
variable {ι} (R)
6345

64-
/-- A family of algebra homomorphisms `g i : A →ₐ[R] f i` defines a ring homomorphism
65-
`Pi.algHom g : A →ₐ[R] Π i, f i` given by `Pi.algHom g x i = f i x`. -/
46+
/-- A family of algebra homomorphisms `g i : B →ₐ[R] A i` defines a ring homomorphism
47+
`Pi.algHom g : B →ₐ[R] Π i, A i` given by `Pi.algHom g x i = g i x`. -/
6648
@[simps!]
67-
def algHom [CommSemiring R] [s : ∀ i, Semiring (f i)] [∀ i, Algebra R (f i)]
68-
{A : Type*} [Semiring A] [Algebra R A] (g : ∀ i, A →ₐ[R] f i) :
69-
A →ₐ[R] ∀ i, f i where
49+
def algHom {B : Type*} [Semiring B] [Algebra R B] (g : ∀ i, B →ₐ[R] A i) :
50+
B →ₐ[R] Π i, A i where
7051
__ := Pi.ringHom fun i ↦ (g i).toRingHom
7152
commutes' r := by ext; simp
7253

7354
/-- `Function.eval` as an `AlgHom`. The name matches `Pi.evalRingHom`, `Pi.evalMonoidHom`,
7455
etc. -/
7556
@[simps]
76-
def evalAlgHom {_ : CommSemiring R} [∀ i, Semiring (f i)] [∀ i, Algebra R (f i)] (i : I) :
77-
(∀ i, f i) →ₐ[R] f i :=
78-
{ Pi.evalRingHom f i with
57+
def evalAlgHom (i : ι) : (Π i, A i) →ₐ[R] A i :=
58+
{ Pi.evalRingHom A i with
7959
toFun := fun f => f i
8060
commutes' := fun _ => rfl }
8161

8262
@[simp]
83-
theorem algHom_evalAlgHom [CommSemiring R] [s : ∀ i, Semiring (f i)] [∀ i, Algebra R (f i)] :
84-
algHom R f (evalAlgHom R f) = AlgHom.id R (Π i, f i) := rfl
63+
theorem algHom_evalAlgHom : algHom R A (evalAlgHom R A) = AlgHom.id R (Π i, A i) := rfl
8564

8665
/-- `Pi.algHom` commutes with composition. -/
87-
theorem algHom_comp [CommSemiring R] [∀ i, Semiring (f i)] [∀ i, Algebra R (f i)]
88-
{A B : Type*} [Semiring A] [Algebra R A] [Semiring B] [Algebra R B]
89-
(g : ∀ i, B →ₐ[R] f i) (h : A →ₐ[R] B) :
90-
(algHom R f g).comp h = algHom R f (fun i ↦ (g i).comp h) := rfl
66+
theorem algHom_comp {B C : Type*} [Semiring B] [Algebra R B] [Semiring C] [Algebra R C]
67+
(g : ∀ i, C →ₐ[R] A i) (h : B →ₐ[R] C) :
68+
(algHom R A g).comp h = algHom R A (fun i ↦ (g i).comp h) := rfl
9169

92-
variable (A B : Type*) [CommSemiring R] [Semiring B] [Algebra R B]
70+
variable (S : ι → Type*) [∀ i, CommSemiring (S i)]
71+
72+
instance [∀ i, Algebra (S i) (A i)] : Algebra (Π i, S i) (Π i, A i) where
73+
algebraMap := Pi.ringHom fun _ ↦ (algebraMap _ _).comp (Pi.evalRingHom S _)
74+
commutes' _ _ := funext fun _ ↦ Algebra.commutes _ _
75+
smul_def' _ _ := funext fun _ ↦ Algebra.smul_def _ _
76+
77+
example : Pi.instAlgebraForall S S = Algebra.id _ := rfl
78+
79+
variable (A B : Type*) [Semiring B] [Algebra R B]
9380

9481
/-- `Function.const` as an `AlgHom`. The name matches `Pi.constRingHom`, `Pi.constMonoidHom`,
9582
etc. -/
@@ -113,21 +100,21 @@ end Pi
113100

114101
/-- A special case of `Pi.algebra` for non-dependent types. Lean struggles to elaborate
115102
definitions elsewhere in the library without this, -/
116-
instance Function.algebra {R : Type*} (I : Type*) (A : Type*) [CommSemiring R] [Semiring A]
117-
[Algebra R A] : Algebra R (I → A) :=
103+
instance Function.algebra {R : Type*} (ι : Type*) (A : Type*) [CommSemiring R] [Semiring A]
104+
[Algebra R A] : Algebra R (ι → A) :=
118105
Pi.algebra _ _
119106

120107
namespace AlgHom
121108

122-
variable {R : Type u} {A : Type v} {B : Type w} {I : Type*}
109+
variable {R A B : Type*}
123110
variable [CommSemiring R] [Semiring A] [Semiring B]
124111
variable [Algebra R A] [Algebra R B]
125112

126-
/-- `R`-algebra homomorphism between the function spaces `I → A` and `I → B`, induced by an
113+
/-- `R`-algebra homomorphism between the function spaces `ι → A` and `ι → B`, induced by an
127114
`R`-algebra homomorphism `f` between `A` and `B`. -/
128115
@[simps]
129-
protected def compLeft (f : A →ₐ[R] B) (I : Type*) : (I → A) →ₐ[R] I → B :=
130-
{ f.toRingHom.compLeft I with
116+
protected def compLeft (f : A →ₐ[R] B) (ι : Type*) : (ι → A) →ₐ[R] ι → B :=
117+
{ f.toRingHom.compLeft ι with
131118
toFun := fun h => f ∘ h
132119
commutes' := fun c => by
133120
ext
@@ -137,16 +124,18 @@ end AlgHom
137124

138125
namespace AlgEquiv
139126

127+
variable {R ι : Type*} {A₁ A₂ A₃ : ι → Type*}
128+
variable [CommSemiring R] [∀ i, Semiring (A₁ i)] [∀ i, Semiring (A₂ i)] [∀ i, Semiring (A₃ i)]
129+
variable [∀ i, Algebra R (A₁ i)] [∀ i, Algebra R (A₂ i)] [∀ i, Algebra R (A₃ i)]
130+
140131
/-- A family of algebra equivalences `∀ i, (A₁ i ≃ₐ A₂ i)` generates a
141-
multiplicative equivalence between ` i, A₁ i` and ` i, A₂ i`.
132+
multiplicative equivalence between `Π i, A₁ i` and `Π i, A₂ i`.
142133
143134
This is the `AlgEquiv` version of `Equiv.piCongrRight`, and the dependent version of
144135
`AlgEquiv.arrowCongr`.
145136
-/
146137
@[simps apply]
147-
def piCongrRight {R ι : Type*} {A₁ A₂ : ι → Type*} [CommSemiring R] [∀ i, Semiring (A₁ i)]
148-
[∀ i, Semiring (A₂ i)] [∀ i, Algebra R (A₁ i)] [∀ i, Algebra R (A₂ i)]
149-
(e : ∀ i, A₁ i ≃ₐ[R] A₂ i) : (∀ i, A₁ i) ≃ₐ[R] ∀ i, A₂ i :=
138+
def piCongrRight (e : ∀ i, A₁ i ≃ₐ[R] A₂ i) : (Π i, A₁ i) ≃ₐ[R] Π i, A₂ i :=
150139
{ @RingEquiv.piCongrRight ι A₁ A₂ _ _ fun i => (e i).toRingEquiv with
151140
toFun := fun x j => e j (x j)
152141
invFun := fun x j => (e j).symm (x j)
@@ -155,22 +144,17 @@ def piCongrRight {R ι : Type*} {A₁ A₂ : ι → Type*} [CommSemiring R] [∀
155144
simp }
156145

157146
@[simp]
158-
theorem piCongrRight_refl {R ι : Type*} {A : ι → Type*} [CommSemiring R] [∀ i, Semiring (A i)]
159-
[∀ i, Algebra R (A i)] :
160-
(piCongrRight fun i => (AlgEquiv.refl : A i ≃ₐ[R] A i)) = AlgEquiv.refl :=
147+
theorem piCongrRight_refl :
148+
(piCongrRight fun i => (AlgEquiv.refl : A₁ i ≃ₐ[R] A₁ i)) = AlgEquiv.refl :=
161149
rfl
162150

163151
@[simp]
164-
theorem piCongrRight_symm {R ι : Type*} {A₁ A₂ : ι → Type*} [CommSemiring R]
165-
[∀ i, Semiring (A₁ i)] [∀ i, Semiring (A₂ i)] [∀ i, Algebra R (A₁ i)] [∀ i, Algebra R (A₂ i)]
166-
(e : ∀ i, A₁ i ≃ₐ[R] A₂ i) : (piCongrRight e).symm = piCongrRight fun i => (e i).symm :=
152+
theorem piCongrRight_symm (e : ∀ i, A₁ i ≃ₐ[R] A₂ i) :
153+
(piCongrRight e).symm = piCongrRight fun i => (e i).symm :=
167154
rfl
168155

169156
@[simp]
170-
theorem piCongrRight_trans {R ι : Type*} {A₁ A₂ A₃ : ι → Type*} [CommSemiring R]
171-
[∀ i, Semiring (A₁ i)] [∀ i, Semiring (A₂ i)] [∀ i, Semiring (A₃ i)] [∀ i, Algebra R (A₁ i)]
172-
[∀ i, Algebra R (A₂ i)] [∀ i, Algebra R (A₃ i)] (e₁ : ∀ i, A₁ i ≃ₐ[R] A₂ i)
173-
(e₂ : ∀ i, A₂ i ≃ₐ[R] A₃ i) :
157+
theorem piCongrRight_trans (e₁ : ∀ i, A₁ i ≃ₐ[R] A₂ i) (e₂ : ∀ i, A₂ i ≃ₐ[R] A₃ i) :
174158
(piCongrRight e₁).trans (piCongrRight e₂) = piCongrRight fun i => (e₁ i).trans (e₂ i) :=
175159
rfl
176160

0 commit comments

Comments
 (0)