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

Commit 22fdf47

Browse files
committed
chore(linear_algebra/affine_space/affine_map,topology/algebra/continuous_affine_map): generalized scalar instances (#11978)
The main result here is that `distrib_mul_action`s are available on affine maps to a module, inherited from their codomain. This fixes a diamond in the `int`-action that was already present for `int`-affine maps, and prevents the new `nat`-action introducing a diamond. This also removes the requirement for `R` to be a `topological_space` in the scalar action for `continuous_affine_map` by using `has_continuous_const_smul` instead of `has_continuous_smul`.
1 parent 32beebb commit 22fdf47

File tree

2 files changed

+81
-20
lines changed

2 files changed

+81
-20
lines changed

src/linear_algebra/affine_space/affine_map.lean

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,14 @@ instance : add_comm_group (P1 →ᵃ[k] V2) :=
189189
zero_add := λ f, ext $ λ p, zero_add (f p),
190190
add_zero := λ f, ext $ λ p, add_zero (f p),
191191
add_comm := λ f g, ext $ λ p, add_comm (f p) (g p),
192-
add_left_neg := λ f, ext $ λ p, add_left_neg (f p) }
192+
add_left_neg := λ f, ext $ λ p, add_left_neg (f p),
193+
nsmul := λ n f, ⟨n • f, n • f.linear, λ p v, by simp⟩,
194+
nsmul_zero' := λ f, ext $ λ p, add_monoid.nsmul_zero' _,
195+
nsmul_succ' := λ n f, ext $ λ p, add_monoid.nsmul_succ' _ _,
196+
zsmul := λ z f, ⟨z • f, z • f.linear, λ p v, by simp⟩,
197+
zsmul_zero' := λ f, ext $ λ p, sub_neg_monoid.zsmul_zero' _,
198+
zsmul_succ' := λ z f, ext $ λ p, sub_neg_monoid.zsmul_succ' _ _,
199+
zsmul_neg' := λ z f, ext $ λ p, sub_neg_monoid.zsmul_neg' _ _, }
193200

194201
@[simp, norm_cast] lemma coe_zero : ⇑(0 : P1 →ᵃ[k] V2) = 0 := rfl
195202
@[simp] lemma zero_linear : (0 : P1 →ᵃ[k] V2).linear = 0 := rfl
@@ -502,36 +509,69 @@ end affine_map
502509

503510
namespace affine_map
504511

505-
variables {k : Type*} {V1 : Type*} {P1 : Type*} {V2 : Type*} [comm_ring k]
506-
[add_comm_group V1] [module k V1] [affine_space V1 P1] [add_comm_group V2] [module k V2]
512+
variables {R k V1 P1 V2 : Type*}
513+
514+
section ring
515+
variables [ring k] [add_comm_group V1] [affine_space V1 P1] [add_comm_group V2]
516+
variables [module k V1] [module k V2]
507517
include V1
508518

509-
/-- If `k` is a commutative ring, then the set of affine maps with codomain in a `k`-module
510-
is a `k`-module. -/
511-
instance : module k (P1 →ᵃ[k] V2) :=
519+
section distrib_mul_action
520+
variables [monoid R] [distrib_mul_action R V2] [smul_comm_class k R V2]
521+
522+
/-- The space of affine maps to a module inherits an `R`-action from the action on its codomain. -/
523+
instance : distrib_mul_action R (P1 →ᵃ[k] V2) :=
512524
{ smul := λ c f, ⟨c • f, c • f.linear, λ p v, by simp [smul_add]⟩,
513525
one_smul := λ f, ext $ λ p, one_smul _ _,
514526
mul_smul := λ c₁ c₂ f, ext $ λ p, mul_smul _ _ _,
515527
smul_add := λ c f g, ext $ λ p, smul_add _ _ _,
516-
smul_zero := λ c, ext $ λ p, smul_zero _,
517-
add_smul := λ c₁ c₂ f, ext $ λ p, add_smul _ _ _,
518-
zero_smul := λ f, ext $ λ p, zero_smul _ _ }
528+
smul_zero := λ c, ext $ λ p, smul_zero _ }
529+
530+
@[simp] lemma coe_smul (c : R) (f : P1 →ᵃ[k] V2) : ⇑(c • f) = c • f := rfl
531+
532+
@[simp] lemma smul_linear (t : R) (f : P1 →ᵃ[k] V2) : (t • f).linear = t • f.linear := rfl
533+
534+
instance [distrib_mul_action Rᵐᵒᵖ V2] [is_central_scalar R V2] :
535+
is_central_scalar R (P1 →ᵃ[k] V2) :=
536+
{ op_smul_eq_smul := λ r x, ext $ λ _, op_smul_eq_smul _ _ }
537+
538+
end distrib_mul_action
539+
540+
section module
541+
variables [semiring R] [module R V2] [smul_comm_class k R V2]
519542

520-
@[simp] lemma coe_smul (c : k) (f : P1 →ᵃ[k] V2) : ⇑(c • f) = c • f := rfl
543+
/-- The space of affine maps taking values in an `R`-module is an `R`-module. -/
544+
instance : module R (P1 →ᵃ[k] V2) :=
545+
{ smul := (•),
546+
add_smul := λ c₁ c₂ f, ext $ λ p, add_smul _ _ _,
547+
zero_smul := λ f, ext $ λ p, zero_smul _ _,
548+
.. affine_map.distrib_mul_action }
521549

522-
@[simp] lemma smul_linear (t : k) (f : P1 →ᵃ[k] V2) : (t • f).linear = t • f.linear := rfl
550+
variables (R)
523551

524552
/-- The space of affine maps between two modules is linearly equivalent to the product of the
525553
domain with the space of linear maps, by taking the value of the affine map at `(0 : V1)` and the
526-
linear part. -/
527-
@[simps] def to_const_prod_linear_map : (V1 →ᵃ[k] V2) ≃ₗ[k] V2 × (V1 →ₗ[k] V2) :=
554+
linear part.
555+
556+
See note [bundled maps over different rings]-/
557+
@[simps] def to_const_prod_linear_map : (V1 →ᵃ[k] V2) ≃ₗ[R] V2 × (V1 →ₗ[k] V2) :=
528558
{ to_fun := λ f, ⟨f 0, f.linear⟩,
529559
inv_fun := λ p, p.2.to_affine_map + const k V1 p.1,
530560
left_inv := λ f, by { ext, rw f.decomp, simp, },
531561
right_inv := by { rintros ⟨v, f⟩, ext; simp, },
532562
map_add' := by simp,
533563
map_smul' := by simp, }
534564

565+
end module
566+
567+
end ring
568+
569+
section comm_ring
570+
571+
variables [comm_ring k] [add_comm_group V1] [affine_space V1 P1] [add_comm_group V2]
572+
variables [module k V1] [module k V2]
573+
include V1
574+
535575
/-- `homothety c r` is the homothety (also known as dilation) about `c` with scale factor `r`. -/
536576
def homothety (c : P1) (r : k) : P1 →ᵃ[k] P1 :=
537577
r • (id k P1 -ᵥ const k P1 c) +ᵥ const k P1 c
@@ -575,4 +615,6 @@ def homothety_affine (c : P1) : k →ᵃ[k] (P1 →ᵃ[k] P1) :=
575615
⇑(homothety_affine c : k →ᵃ[k] _) = homothety c :=
576616
rfl
577617

618+
end comm_ring
619+
578620
end affine_map

src/topology/algebra/continuous_affine_map.lean

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,33 @@ omit W₂
154154

155155
section module_valued_maps
156156

157-
variables {S : Type*} [comm_ring S] [module S V] [module S W]
158-
variables [topological_space W] [topological_space S] [has_continuous_smul S W]
157+
variables {S : Type*}
158+
variables [topological_space W]
159159

160160
instance : has_zero (P →A[R] W) := ⟨continuous_affine_map.const R P 0
161161

162162
@[norm_cast, simp] lemma coe_zero : ((0 : P →A[R] W) : P → W) = 0 := rfl
163163

164164
lemma zero_apply (x : P) : (0 : P →A[R] W) x = 0 := rfl
165165

166-
instance : has_scalar S (P →A[S] W) :=
167-
{ smul := λ t f, { cont := f.continuous.const_smul t, .. (t • (f : P →ᵃ[S] W)) } }
166+
section mul_action
167+
variables [monoid S] [distrib_mul_action S W] [smul_comm_class R S W]
168+
variables [has_continuous_const_smul S W]
168169

169-
@[norm_cast, simp] lemma coe_smul (t : S) (f : P →A[S] W) : ⇑(t • f) = t • f := rfl
170+
instance : has_scalar S (P →A[R] W) :=
171+
{ smul := λ t f, { cont := f.continuous.const_smul t, .. (t • (f : P →ᵃ[R] W)) } }
170172

171-
lemma smul_apply (t : S) (f : P →A[S] W) (x : P) : (t • f) x = t • (f x) := rfl
173+
@[norm_cast, simp] lemma coe_smul (t : S) (f : P →A[R] W) : ⇑(t • f) = t • f := rfl
174+
175+
lemma smul_apply (t : S) (f : P →A[R] W) (x : P) : (t • f) x = t • (f x) := rfl
176+
177+
instance [distrib_mul_action Sᵐᵒᵖ W] [is_central_scalar S W] : is_central_scalar S (P →A[R] W) :=
178+
{ op_smul_eq_smul := λ t f, ext $ λ _, op_smul_eq_smul _ _ }
179+
180+
instance : mul_action S (P →A[R] W) :=
181+
function.injective.mul_action _ coe_injective coe_smul
182+
183+
end mul_action
172184

173185
variables [topological_add_group W]
174186

@@ -201,7 +213,14 @@ instance : add_comm_group (P →A[R] W) :=
201213
.. (coe_injective.add_comm_group _ coe_zero coe_add coe_neg coe_sub :
202214
add_comm_group (P →A[R] W)) }
203215

204-
instance : module S (P →A[S] W) :=
216+
instance [monoid S] [distrib_mul_action S W] [smul_comm_class R S W]
217+
[has_continuous_const_smul S W] :
218+
distrib_mul_action S (P →A[R] W) :=
219+
function.injective.distrib_mul_action ⟨λ f, f.to_affine_map.to_fun, rfl, coe_add⟩
220+
coe_injective coe_smul
221+
222+
instance [semiring S] [module S W] [smul_comm_class R S W] [has_continuous_const_smul S W] :
223+
module S (P →A[R] W) :=
205224
function.injective.module S ⟨λ f, f.to_affine_map.to_fun, rfl, coe_add⟩ coe_injective coe_smul
206225

207226
end module_valued_maps

0 commit comments

Comments
 (0)