forked from leanprover-community/mathlib4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaps.lean
More file actions
826 lines (634 loc) · 33.1 KB
/
Maps.lean
File metadata and controls
826 lines (634 loc) · 33.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
/-
Copyright (c) 2020 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison, Johan Commelin
-/
module
public import Mathlib.Algebra.Algebra.RestrictScalars
public import Mathlib.Algebra.Algebra.Subalgebra.Lattice
public import Mathlib.Algebra.Module.Rat
public import Mathlib.RingTheory.TensorProduct.Basic
/-!
# Maps between tensor products of R-algebras
This file provides results about maps between tensor products of `R`-algebras.
## Main declarations
- the structure isomorphisms
* `Algebra.TensorProduct.lid : R ⊗[R] A ≃ₐ[R] A`
* `Algebra.TensorProduct.rid : A ⊗[R] R ≃ₐ[S] A` (usually used with `S = R` or `S = A`)
* `Algebra.TensorProduct.comm : A ⊗[R] B ≃ₐ[R] B ⊗[R] A`
* `Algebra.TensorProduct.assoc : ((A ⊗[S] C) ⊗[R] D) ≃ₐ[T] (A ⊗[S] (C ⊗[R] D))`
- `Algebra.TensorProduct.liftEquiv`: a universal property for the tensor product of algebras.
## References
* [C. Kassel, *Quantum Groups* (§II.4)][Kassel1995]
-/
@[expose] public section
assert_not_exists Equiv.Perm.cycleType
open scoped TensorProduct
open TensorProduct
namespace Module.End
open LinearMap
variable (R M N : Type*)
[CommSemiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N]
/-- The map `LinearMap.lTensorHom` which sends `f ↦ 1 ⊗ f` as a morphism of algebras. -/
@[simps!]
def lTensorAlgHom : Module.End R M →ₐ[R] Module.End R (N ⊗[R] M) :=
.ofLinearMap (lTensorHom (M := N)) (lTensor_id N M) (lTensor_mul N)
/-- The map `LinearMap.rTensorHom` which sends `f ↦ f ⊗ 1` as a morphism of algebras. -/
@[simps!]
def rTensorAlgHom : Module.End R M →ₐ[R] Module.End R (M ⊗[R] N) :=
.ofLinearMap (rTensorHom (M := N)) (rTensor_id N M) (rTensor_mul N)
end Module.End
namespace Algebra
namespace TensorProduct
universe uR uS uA uB uC uD uE uF
variable {R : Type uR} {R' : Type*} {S : Type uS} {T : Type*}
variable {A : Type uA} {B : Type uB} {C : Type uC} {D : Type uD} {E : Type uE} {F : Type uF}
/-!
We build the structure maps for the symmetric monoidal category of `R`-algebras.
-/
section Monoidal
section
variable [CommSemiring R] [CommSemiring S] [Algebra R S]
variable [Semiring A] [Algebra R A] [Algebra S A] [IsScalarTower R S A]
variable [Semiring B] [Algebra R B]
variable [Semiring C] [Algebra S C]
variable [Semiring D] [Algebra R D]
/-- To check a linear map preserves multiplication, it suffices to check it on pure tensors. See
`algHomOfLinearMapTensorProduct` for a bundled version. -/
lemma _root_.LinearMap.map_mul_of_map_mul_tmul {f : A ⊗[R] B →ₗ[S] C}
(hf : ∀ (a₁ a₂ : A) (b₁ b₂ : B), f ((a₁ * a₂) ⊗ₜ (b₁ * b₂)) = f (a₁ ⊗ₜ b₁) * f (a₂ ⊗ₜ b₂))
(x y : A ⊗[R] B) : f (x * y) = f x * f y :=
f.map_mul_iff.2 (by
-- these instances are needed by the statement of `ext`, but not by the current definition.
letI : Algebra R C := RestrictScalars.algebra R S C
letI : IsScalarTower R S C := RestrictScalars.isScalarTower R S C
ext
dsimp
exact hf _ _ _ _) x y
/-- Build an algebra morphism from a linear map out of a tensor product, and evidence that on pure
tensors, it preserves multiplication and the identity.
Note that we state `h_one` using `1 ⊗ₜ[R] 1` instead of `1` so that lemmas about `f` applied to pure
tensors can be directly applied by the caller (without needing `TensorProduct.one_def`).
-/
def algHomOfLinearMapTensorProduct (f : A ⊗[R] B →ₗ[S] C)
(h_mul : ∀ (a₁ a₂ : A) (b₁ b₂ : B), f ((a₁ * a₂) ⊗ₜ (b₁ * b₂)) = f (a₁ ⊗ₜ b₁) * f (a₂ ⊗ₜ b₂))
(h_one : f (1 ⊗ₜ[R] 1) = 1) : A ⊗[R] B →ₐ[S] C :=
AlgHom.ofLinearMap f h_one (f.map_mul_of_map_mul_tmul h_mul)
@[simp]
theorem algHomOfLinearMapTensorProduct_apply (f h_mul h_one x) :
(algHomOfLinearMapTensorProduct f h_mul h_one : A ⊗[R] B →ₐ[S] C) x = f x :=
rfl
/-- Build an algebra equivalence from a linear equivalence out of a tensor product, and evidence
that on pure tensors, it preserves multiplication and the identity.
Note that we state `h_one` using `1 ⊗ₜ[R] 1` instead of `1` so that lemmas about `f` applied to pure
tensors can be directly applied by the caller (without needing `TensorProduct.one_def`).
-/
def algEquivOfLinearEquivTensorProduct (f : A ⊗[R] B ≃ₗ[S] C)
(h_mul : ∀ (a₁ a₂ : A) (b₁ b₂ : B), f ((a₁ * a₂) ⊗ₜ (b₁ * b₂)) = f (a₁ ⊗ₜ b₁) * f (a₂ ⊗ₜ b₂))
(h_one : f (1 ⊗ₜ[R] 1) = 1) : A ⊗[R] B ≃ₐ[S] C :=
{ algHomOfLinearMapTensorProduct (f : A ⊗[R] B →ₗ[S] C) h_mul h_one, f with }
@[simp]
theorem algEquivOfLinearEquivTensorProduct_apply (f h_mul h_one x) :
(algEquivOfLinearEquivTensorProduct f h_mul h_one : A ⊗[R] B ≃ₐ[S] C) x = f x :=
rfl
variable [Algebra R C]
/-- Build an algebra equivalence from a linear equivalence out of a triple tensor product,
and evidence of multiplicativity on pure tensors.
-/
def algEquivOfLinearEquivTripleTensorProduct (f : A ⊗[R] B ⊗[R] C ≃ₗ[R] D)
(h_mul :
∀ (a₁ a₂ : A) (b₁ b₂ : B) (c₁ c₂ : C),
f ((a₁ * a₂) ⊗ₜ (b₁ * b₂) ⊗ₜ (c₁ * c₂)) = f (a₁ ⊗ₜ b₁ ⊗ₜ c₁) * f (a₂ ⊗ₜ b₂ ⊗ₜ c₂))
(h_one : f (((1 : A) ⊗ₜ[R] (1 : B)) ⊗ₜ[R] (1 : C)) = 1) :
A ⊗[R] B ⊗[R] C ≃ₐ[R] D :=
AlgEquiv.ofLinearEquiv f h_one <| f.map_mul_iff.2 <| by
ext
dsimp
exact h_mul _ _ _ _ _ _
@[simp]
theorem algEquivOfLinearEquivTripleTensorProduct_apply (f h_mul h_one x) :
(algEquivOfLinearEquivTripleTensorProduct f h_mul h_one : A ⊗[R] B ⊗[R] C ≃ₐ[R] D) x = f x :=
rfl
section lift
variable [IsScalarTower R S C]
/-- The forward direction of the universal property of tensor products of algebras; any algebra
morphism from the tensor product can be factored as the product of two algebra morphisms that
commute.
See `Algebra.TensorProduct.liftEquiv` for the fact that every morphism factors this way. -/
def lift (f : A →ₐ[S] C) (g : B →ₐ[R] C) (hfg : ∀ x y, Commute (f x) (g y)) : (A ⊗[R] B) →ₐ[S] C :=
algHomOfLinearMapTensorProduct
(AlgebraTensorModule.lift <|
letI restr : (C →ₗ[S] C) →ₗ[S] _ :=
{ toFun := (·.restrictScalars R)
map_add' := fun _ _ => LinearMap.ext fun _ => rfl
map_smul' := fun _ _ => LinearMap.ext fun _ => rfl }
LinearMap.flip <| (restr ∘ₗ LinearMap.mul S C ∘ₗ f.toLinearMap).flip ∘ₗ g)
(fun a₁ a₂ b₁ b₂ => show f (a₁ * a₂) * g (b₁ * b₂) = f a₁ * g b₁ * (f a₂ * g b₂) by
rw [map_mul, map_mul, (hfg a₂ b₁).mul_mul_mul_comm])
(show f 1 * g 1 = 1 by rw [map_one, map_one, one_mul])
@[simp]
theorem lift_tmul (f : A →ₐ[S] C) (g : B →ₐ[R] C) (hfg : ∀ x y, Commute (f x) (g y))
(a : A) (b : B) :
lift f g hfg (a ⊗ₜ b) = f a * g b :=
rfl
@[simp]
theorem lift_includeLeft_includeRight :
lift includeLeft includeRight (fun _ _ => (Commute.one_right _).tmul (Commute.one_left _)) =
.id S (A ⊗[R] B) := by
ext <;> simp
@[simp]
theorem lift_comp_includeLeft (f : A →ₐ[S] C) (g : B →ₐ[R] C) (hfg : ∀ x y, Commute (f x) (g y)) :
(lift f g hfg).comp includeLeft = f :=
AlgHom.ext <| by simp
@[simp]
theorem lift_comp_includeRight (f : A →ₐ[S] C) (g : B →ₐ[R] C) (hfg : ∀ x y, Commute (f x) (g y)) :
((lift f g hfg).restrictScalars R).comp includeRight = g :=
AlgHom.ext <| by simp
/-- Variant with the same base that doesn't need `restrictScalars`. -/
@[simp]
theorem lift_comp_includeRight' (f : A →ₐ[R] C) (g : B →ₐ[R] C) (hfg : ∀ x y, Commute (f x) (g y)) :
(lift f g hfg).comp includeRight = g :=
AlgHom.ext <| by simp
/-- The universal property of the tensor product of algebras.
Pairs of algebra morphisms that commute are equivalent to algebra morphisms from the tensor product.
This is `Algebra.TensorProduct.lift` as an equivalence.
See also `GradedTensorProduct.liftEquiv` for an alternative commutativity requirement for graded
algebra. -/
@[simps]
def liftEquiv : {fg : (A →ₐ[S] C) × (B →ₐ[R] C) // ∀ x y, Commute (fg.1 x) (fg.2 y)}
≃ ((A ⊗[R] B) →ₐ[S] C) where
toFun fg := lift fg.val.1 fg.val.2 fg.prop
invFun f' := ⟨(f'.comp includeLeft, (f'.restrictScalars R).comp includeRight), fun _ _ =>
((Commute.one_right _).tmul (Commute.one_left _)).map f'⟩
left_inv fg := by ext <;> simp
right_inv f' := by ext <;> simp
end lift
end
variable [CommSemiring R] [CommSemiring S] [Algebra R S]
variable [Semiring A] [Algebra R A] [Algebra S A] [IsScalarTower R S A]
variable [Semiring B] [Algebra R B]
variable [Semiring C] [Algebra R C] [Algebra S C] [IsScalarTower R S C]
variable [Semiring D] [Algebra R D]
variable [Semiring E] [Algebra R E] [Algebra S E] [IsScalarTower R S E]
variable [Semiring F] [Algebra R F]
section
variable (R A)
/-- The base ring is a left identity for the tensor product of algebra, up to algebra isomorphism.
-/
protected nonrec def lid : R ⊗[R] A ≃ₐ[R] A :=
algEquivOfLinearEquivTensorProduct (TensorProduct.lid R A) (by
simp only [mul_smul, lid_tmul, Algebra.smul_mul_assoc, Algebra.mul_smul_comm]
simp_rw [← mul_smul, mul_comm]
simp)
(by simp [Algebra.smul_def])
@[simp] theorem lid_toLinearEquiv :
(TensorProduct.lid R A).toLinearEquiv = _root_.TensorProduct.lid R A := rfl
variable {R} {A} in
@[simp]
theorem lid_tmul (r : R) (a : A) : TensorProduct.lid R A (r ⊗ₜ a) = r • a := rfl
variable {A} in
@[simp]
theorem lid_symm_apply (a : A) : (TensorProduct.lid R A).symm a = 1 ⊗ₜ a := rfl
variable (S)
/-- The base ring is a right identity for the tensor product of algebra, up to algebra isomorphism.
Note that if `A` is commutative this can be instantiated with `S = A`.
-/
protected nonrec def rid : A ⊗[R] R ≃ₐ[S] A :=
algEquivOfLinearEquivTensorProduct (AlgebraTensorModule.rid R S A)
(fun a₁ a₂ r₁ r₂ => smul_mul_smul_comm r₁ a₁ r₂ a₂ |>.symm)
(one_smul R _)
@[simp] theorem rid_toLinearEquiv :
(TensorProduct.rid R S A).toLinearEquiv = AlgebraTensorModule.rid R S A := rfl
variable {R A} in
@[simp]
theorem rid_tmul (r : R) (a : A) : TensorProduct.rid R S A (a ⊗ₜ r) = r • a := rfl
variable {A} in
@[simp]
theorem rid_symm_apply (a : A) : (TensorProduct.rid R S A).symm a = a ⊗ₜ 1 := rfl
section CompatibleSMul
variable (R S A B : Type*) [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]
variable [Algebra R A] [Algebra R B] [Algebra S A] [Algebra S B]
variable [SMulCommClass R S A] [CompatibleSMul R S A B]
/-- If A and B are both R- and S-algebras and their actions on them commute,
and if the S-action on `A ⊗[R] B` can switch between the two factors, then there is a
canonical S-algebra homomorphism from `A ⊗[S] B` to `A ⊗[R] B`. -/
def mapOfCompatibleSMul : A ⊗[S] B →ₐ[S] A ⊗[R] B :=
.ofLinearMap (_root_.TensorProduct.mapOfCompatibleSMul R S A B) rfl fun x ↦
x.induction_on (by simp) (fun _ _ y ↦ y.induction_on (by simp) (by simp)
fun _ _ h h' ↦ by simp only [mul_add, map_add, h, h'])
fun _ _ h h' _ ↦ by simp only [add_mul, map_add, h, h']
@[simp] theorem mapOfCompatibleSMul_tmul (m n) : mapOfCompatibleSMul R S A B (m ⊗ₜ n) = m ⊗ₜ n :=
rfl
theorem mapOfCompatibleSMul_surjective : Function.Surjective (mapOfCompatibleSMul R S A B) :=
_root_.TensorProduct.mapOfCompatibleSMul_surjective R S A B
attribute [local instance] SMulCommClass.symm
/-- `mapOfCompatibleSMul R S A B` is also A-linear. -/
def mapOfCompatibleSMul' : A ⊗[S] B →ₐ[R] A ⊗[R] B :=
.ofLinearMap (_root_.TensorProduct.mapOfCompatibleSMul' R S A B) rfl
(map_mul <| mapOfCompatibleSMul R S A B)
/-- If the R- and S-actions on A and B satisfy `CompatibleSMul` both ways,
then `A ⊗[S] B` is canonically isomorphic to `A ⊗[R] B`. -/
def equivOfCompatibleSMul [CompatibleSMul S R A B] : A ⊗[S] B ≃ₐ[S] A ⊗[R] B where
__ := mapOfCompatibleSMul R S A B
invFun := mapOfCompatibleSMul S R A B
__ := _root_.TensorProduct.equivOfCompatibleSMul R S A B
variable [Algebra R S] [CompatibleSMul R S S A] [CompatibleSMul S R S A]
omit [SMulCommClass R S A]
/-- If the R- and S- action on S and A satisfy `CompatibleSMul` both ways,
then `S ⊗[R] A` is canonically isomorphic to `A`. -/
def lidOfCompatibleSMul : S ⊗[R] A ≃ₐ[S] A :=
(equivOfCompatibleSMul R S S A).symm.trans (TensorProduct.lid _ _)
theorem lidOfCompatibleSMul_tmul (s a) : lidOfCompatibleSMul R S A (s ⊗ₜ[R] a) = s • a := rfl
instance {R M N : Type*} [CommSemiring R] [AddCommGroup M] [AddCommGroup N]
[Module R M] [Module R N] [Module ℚ M] [Module ℚ N] : CompatibleSMul R ℚ M N where
smul_tmul q m n := by
have : IsAddTorsionFree (M ⊗[R] N) := .of_module_rat _
suffices q.den • ((q • m) ⊗ₜ[R] n) = q.den • (m ⊗ₜ[R] (q • n)) from
smul_right_injective (M ⊗[R] N) q.den_nz <| by norm_cast
rw [smul_tmul', ← tmul_smul, ← smul_assoc, ← smul_assoc, nsmul_eq_mul, Rat.den_mul_eq_num]
norm_cast
rw [smul_tmul]
end CompatibleSMul
section
variable (B)
unseal mul in
/-- The tensor product of R-algebras is commutative, up to algebra isomorphism.
-/
protected def comm : A ⊗[R] B ≃ₐ[R] B ⊗[R] A :=
algEquivOfLinearEquivTensorProduct (_root_.TensorProduct.comm R A B) (fun _ _ _ _ => rfl) rfl
@[simp] theorem comm_toLinearEquiv :
(Algebra.TensorProduct.comm R A B).toLinearEquiv = _root_.TensorProduct.comm R A B := rfl
variable {A B} in
@[simp]
theorem comm_tmul (a : A) (b : B) :
TensorProduct.comm R A B (a ⊗ₜ b) = b ⊗ₜ a :=
rfl
variable {A B} in
@[simp]
theorem comm_symm_tmul (a : A) (b : B) :
(TensorProduct.comm R A B).symm (b ⊗ₜ a) = a ⊗ₜ b :=
rfl
theorem comm_symm :
(TensorProduct.comm R A B).symm = TensorProduct.comm R B A := by
ext; rfl
@[simp]
lemma comm_comp_includeLeft :
(TensorProduct.comm R A B : A ⊗[R] B →ₐ[R] B ⊗[R] A).comp includeLeft = includeRight := rfl
@[simp]
lemma comm_comp_includeRight :
(TensorProduct.comm R A B : A ⊗[R] B →ₐ[R] B ⊗[R] A).comp includeRight = includeLeft := rfl
theorem adjoin_tmul_eq_top : adjoin R { t : A ⊗[R] B | ∃ a b, a ⊗ₜ[R] b = t } = ⊤ :=
top_le_iff.mp <| (top_le_iff.mpr <| span_tmul_eq_top R A B).trans (span_le_adjoin R _)
section
omit [Algebra S A] [IsScalarTower R S A]
attribute [local instance] Algebra.TensorProduct.rightAlgebra in
/-- `S`-linear version of `Algebra.TensorProduct.comm` when `A ⊗[R] S`
is viewed as an `S`-algebra via the right component. -/
noncomputable def commRight : S ⊗[R] A ≃ₐ[S] A ⊗[R] S where
__ := Algebra.TensorProduct.comm R S A
commutes' _ := rfl
variable {S A} in
@[simp]
lemma commRight_tmul (s : S) (a : A) : commRight R S A (s ⊗ₜ a) = a ⊗ₜ s := rfl
variable {S A} in
attribute [local instance] Algebra.TensorProduct.rightAlgebra in
@[simp]
lemma Algebra.TensorProduct.commRight_symm_tmul (s : S) (a : A) :
(commRight R S A).symm (a ⊗ₜ[R] s) = s ⊗ₜ a := rfl
end
end
section
variable [CommSemiring T] [Algebra R T] [Algebra S T]
[Algebra T A] [IsScalarTower R T A] [IsScalarTower S T A]
variable (T C D) in
/-- The associator for tensor product of R-algebras, as an algebra isomorphism. -/
protected def assoc : (A ⊗[S] C) ⊗[R] D ≃ₐ[T] A ⊗[S] (C ⊗[R] D) :=
AlgEquiv.ofLinearEquiv
(AlgebraTensorModule.assoc R S T A C D)
(by simp [Algebra.TensorProduct.one_def])
((LinearMap.map_mul_iff _).mpr <| by ext; simp)
variable (T C D) in
@[simp] theorem assoc_toLinearEquiv :
(TensorProduct.assoc R S T A C D).toLinearEquiv = AlgebraTensorModule.assoc R S T A C D := rfl
@[simp]
theorem assoc_tmul (a : A) (b : C) (c : D) :
TensorProduct.assoc R S T A C D ((a ⊗ₜ b) ⊗ₜ c) = a ⊗ₜ (b ⊗ₜ c) := rfl
@[simp]
theorem assoc_symm_tmul (a : A) (b : C) (c : D) :
(TensorProduct.assoc R S T A C D).symm (a ⊗ₜ (b ⊗ₜ c)) = (a ⊗ₜ b) ⊗ₜ c := rfl
end
section
variable (T A B : Type*) [CommSemiring T] [CommSemiring A] [CommSemiring B]
[Algebra R T] [Algebra R A] [Algebra R B] [Algebra T A] [IsScalarTower R T A] [Algebra S A]
[IsScalarTower R S A] [Algebra S T] [IsScalarTower S T A]
/-- The natural isomorphism `A ⊗[S] (S ⊗[R] B) ≃ₐ[T] A ⊗[R] B`. -/
def cancelBaseChange : A ⊗[S] (S ⊗[R] B) ≃ₐ[T] A ⊗[R] B :=
AlgEquiv.symm <| AlgEquiv.ofLinearEquiv
(TensorProduct.AlgebraTensorModule.cancelBaseChange R S T A B).symm
(by simp [Algebra.TensorProduct.one_def]) <|
LinearMap.map_mul_of_map_mul_tmul (fun _ _ _ _ ↦ by simp)
@[simp]
lemma cancelBaseChange_tmul (a : A) (s : S) (b : B) :
Algebra.TensorProduct.cancelBaseChange R S T A B (a ⊗ₜ (s ⊗ₜ b)) = (s • a) ⊗ₜ b :=
TensorProduct.AlgebraTensorModule.cancelBaseChange_tmul R S T a b s
@[simp]
lemma cancelBaseChange_symm_tmul (a : A) (b : B) :
(Algebra.TensorProduct.cancelBaseChange R S T A B).symm (a ⊗ₜ b) = a ⊗ₜ (1 ⊗ₜ b) :=
TensorProduct.AlgebraTensorModule.cancelBaseChange_symm_tmul R S T a b
end
variable {R S A}
/-- The tensor product of a pair of algebra morphisms. -/
def map (f : A →ₐ[S] C) (g : B →ₐ[R] D) : A ⊗[R] B →ₐ[S] C ⊗[R] D :=
algHomOfLinearMapTensorProduct (AlgebraTensorModule.map f.toLinearMap g.toLinearMap) (by simp)
(by simp [one_def])
@[simp] lemma toLinearMap_map (f : A →ₐ[S] C) (g : B →ₐ[R] D) :
(map f g).toLinearMap = TensorProduct.AlgebraTensorModule.map f.toLinearMap g.toLinearMap := rfl
@[simp]
theorem map_tmul (f : A →ₐ[S] C) (g : B →ₐ[R] D) (a : A) (b : B) : map f g (a ⊗ₜ b) = f a ⊗ₜ g b :=
rfl
@[simp]
theorem map_id : map (.id S A) (.id R B) = .id S _ :=
ext (AlgHom.ext fun _ => rfl) (AlgHom.ext fun _ => rfl)
theorem map_comp
(f₂ : C →ₐ[S] E) (f₁ : A →ₐ[S] C) (g₂ : D →ₐ[R] F) (g₁ : B →ₐ[R] D) :
map (f₂.comp f₁) (g₂.comp g₁) = (map f₂ g₂).comp (map f₁ g₁) :=
ext (AlgHom.ext fun _ => rfl) (AlgHom.ext fun _ => rfl)
lemma map_id_comp (g₂ : D →ₐ[R] F) (g₁ : B →ₐ[R] D) :
map (AlgHom.id S A) (g₂.comp g₁) = (map (AlgHom.id S A) g₂).comp (map (AlgHom.id S A) g₁) :=
ext (AlgHom.ext fun _ => rfl) (AlgHom.ext fun _ => rfl)
lemma map_comp_id
(f₂ : C →ₐ[S] E) (f₁ : A →ₐ[S] C) :
map (f₂.comp f₁) (AlgHom.id R E) = (map f₂ (AlgHom.id R E)).comp (map f₁ (AlgHom.id R E)) :=
ext (AlgHom.ext fun _ => rfl) (AlgHom.ext fun _ => rfl)
@[simp]
theorem map_comp_includeLeft (f : A →ₐ[S] C) (g : B →ₐ[R] D) :
(map f g).comp includeLeft = includeLeft.comp f :=
AlgHom.ext <| by simp
@[simp]
theorem map_restrictScalars_comp_includeRight (f : A →ₐ[S] C) (g : B →ₐ[R] D) :
((map f g).restrictScalars R).comp includeRight = includeRight.comp g :=
AlgHom.ext <| by simp
@[simp]
theorem map_comp_includeRight (f : A →ₐ[R] C) (g : B →ₐ[R] D) :
(map f g).comp includeRight = includeRight.comp g :=
map_restrictScalars_comp_includeRight f g
theorem map_range (f : A →ₐ[R] C) (g : B →ₐ[R] D) :
(map f g).range = (includeLeft.comp f).range ⊔ (includeRight.comp g).range := by
apply le_antisymm
· rw [← map_top, ← adjoin_tmul_eq_top, ← adjoin_image, adjoin_le_iff]
rintro _ ⟨_, ⟨a, b, rfl⟩, rfl⟩
rw [map_tmul, ← mul_one (f a), ← one_mul (g b), ← tmul_mul_tmul]
exact mul_mem_sup (AlgHom.mem_range_self _ a) (AlgHom.mem_range_self _ b)
· rw [← map_comp_includeLeft f g, ← map_comp_includeRight f g]
exact sup_le (AlgHom.range_comp_le_range _ _) (AlgHom.range_comp_le_range _ _)
lemma comm_comp_map (f : A →ₐ[R] C) (g : B →ₐ[R] D) :
(TensorProduct.comm R C D : C ⊗[R] D →ₐ[R] D ⊗[R] C).comp (Algebra.TensorProduct.map f g) =
(Algebra.TensorProduct.map g f).comp (TensorProduct.comm R A B).toAlgHom := by
ext <;> rfl
lemma comm_comp_map_apply (f : A →ₐ[R] C) (g : B →ₐ[R] D) (x) :
TensorProduct.comm R C D (Algebra.TensorProduct.map f g x) =
(Algebra.TensorProduct.map g f) (TensorProduct.comm R A B x) :=
congr($(comm_comp_map f g) x)
variable (A) in
/-- `lTensor A g : A ⊗ B →ₐ A ⊗ D` is the natural algebra morphism induced by `g : B →ₐ D`. -/
noncomputable abbrev lTensor (g : B →ₐ[R] D) : (A ⊗[R] B) →ₐ[S] (A ⊗[R] D) := map (.id S A) g
variable (B) in
/-- `rTensor B f : A ⊗ B →ₐ C ⊗ B` is the natural algebra morphism induced by `f : A →ₐ C`. -/
noncomputable abbrev rTensor (f : A →ₐ[S] C) : A ⊗[R] B →ₐ[S] C ⊗[R] B := map f (.id R B)
/-- Construct an isomorphism between tensor products of an S-algebra with an R-algebra
from S- and R- isomorphisms between the tensor factors.
-/
def congr (f : A ≃ₐ[S] C) (g : B ≃ₐ[R] D) : A ⊗[R] B ≃ₐ[S] C ⊗[R] D :=
AlgEquiv.ofAlgHom (map f g) (map f.symm g.symm)
(ext' fun b d => by simp) (ext' fun a c => by simp)
@[simp] theorem congr_toLinearEquiv (f : A ≃ₐ[S] C) (g : B ≃ₐ[R] D) :
(Algebra.TensorProduct.congr f g).toLinearEquiv =
TensorProduct.AlgebraTensorModule.congr f.toLinearEquiv g.toLinearEquiv := rfl
@[simp]
theorem congr_apply (f : A ≃ₐ[S] C) (g : B ≃ₐ[R] D) (x) :
congr f g x = (map (f : A →ₐ[S] C) (g : B →ₐ[R] D)) x :=
rfl
@[simp]
theorem congr_symm_apply (f : A ≃ₐ[S] C) (g : B ≃ₐ[R] D) (x) :
(congr f g).symm x = (map (f.symm : C →ₐ[S] A) (g.symm : D →ₐ[R] B)) x :=
rfl
@[simp]
theorem congr_refl : congr (.refl : A ≃ₐ[S] A) (.refl : B ≃ₐ[R] B) = .refl :=
AlgEquiv.coe_algHom_injective <| map_id
theorem congr_trans
(f₁ : A ≃ₐ[S] C) (f₂ : C ≃ₐ[S] E) (g₁ : B ≃ₐ[R] D) (g₂ : D ≃ₐ[R] F) :
congr (f₁.trans f₂) (g₁.trans g₂) = (congr f₁ g₁).trans (congr f₂ g₂) :=
AlgEquiv.coe_algHom_injective <| map_comp f₂.toAlgHom f₁.toAlgHom g₂.toAlgHom g₁.toAlgHom
theorem congr_symm (f : A ≃ₐ[S] C) (g : B ≃ₐ[R] D) : congr f.symm g.symm = (congr f g).symm := rfl
variable (R A B C) in
/-- Tensor product of algebras analogue of `mul_left_comm`.
This is the algebra version of `TensorProduct.leftComm`. -/
def leftComm : A ⊗[R] (B ⊗[R] C) ≃ₐ[R] B ⊗[R] (A ⊗[R] C) :=
(Algebra.TensorProduct.assoc R R R A B C).symm.trans <|
(congr (Algebra.TensorProduct.comm R A B) .refl).trans <| TensorProduct.assoc R R R B A C
@[simp]
theorem leftComm_tmul (m : A) (n : B) (p : C) :
leftComm R A B C (m ⊗ₜ (n ⊗ₜ p)) = n ⊗ₜ (m ⊗ₜ p) :=
rfl
@[simp]
theorem leftComm_symm_tmul (m : A) (n : B) (p : C) :
(leftComm R A B C).symm (n ⊗ₜ (m ⊗ₜ p)) = m ⊗ₜ (n ⊗ₜ p) :=
rfl
@[simp]
theorem leftComm_toLinearEquiv : ↑(leftComm R A B C) = _root_.TensorProduct.leftComm R A B C :=
LinearEquiv.toLinearMap_injective (by ext; rfl)
variable [CommSemiring T] [Algebra R T] [Algebra T A] [IsScalarTower R T A] [SMulCommClass S T A]
[Algebra S T] [IsScalarTower S T A] [CommSemiring R'] [Algebra R R'] [Algebra R' T] [Algebra R' A]
[Algebra R' B] [IsScalarTower R R' A] [SMulCommClass S R' A] [SMulCommClass R' S A]
[IsScalarTower R' T A] [IsScalarTower R R' B]
variable (R R' S T A B C D) in
/-- Tensor product of algebras analogue of `mul_mul_mul_comm`.
This is the algebra version of `TensorProduct.AlgebraTensorModule.tensorTensorTensorComm`. -/
def tensorTensorTensorComm : A ⊗[R'] B ⊗[S] (C ⊗[R] D) ≃ₐ[T] A ⊗[S] C ⊗[R'] (B ⊗[R] D) :=
AlgEquiv.ofLinearEquiv (TensorProduct.AlgebraTensorModule.tensorTensorTensorComm R R' S T A B C D)
rfl (LinearMap.map_mul_iff _ |>.mpr <| by ext; simp)
@[simp]
theorem tensorTensorTensorComm_tmul (m : A) (n : B) (p : C) (q : D) :
tensorTensorTensorComm R R' S T A B C D (m ⊗ₜ n ⊗ₜ (p ⊗ₜ q)) = m ⊗ₜ p ⊗ₜ (n ⊗ₜ q) :=
rfl
@[simp]
theorem tensorTensorTensorComm_symm_tmul (m : A) (n : C) (p : B) (q : D) :
(tensorTensorTensorComm R R' S T A B C D).symm (m ⊗ₜ n ⊗ₜ (p ⊗ₜ q)) = m ⊗ₜ p ⊗ₜ (n ⊗ₜ q) :=
rfl
theorem tensorTensorTensorComm_symm :
(tensorTensorTensorComm R R' S T A B C D).symm = tensorTensorTensorComm R S R' T A C B D := rfl
theorem tensorTensorTensorComm_toLinearEquiv :
(tensorTensorTensorComm R R' S T A B C D).toLinearEquiv =
TensorProduct.AlgebraTensorModule.tensorTensorTensorComm R R' S T A B C D := rfl
@[simp]
theorem toLinearEquiv_tensorTensorTensorComm :
(tensorTensorTensorComm R R R R A B C D).toLinearEquiv =
_root_.TensorProduct.tensorTensorTensorComm R A B C D := rfl
lemma map_bijective {f : A →ₐ[R] B} {g : C →ₐ[R] D}
(hf : Function.Bijective f) (hg : Function.Bijective g) :
Function.Bijective (map f g) :=
_root_.TensorProduct.map_bijective hf hg
lemma includeLeft_bijective (h : Function.Bijective (algebraMap R B)) :
Function.Bijective (includeLeft : A →ₐ[S] A ⊗[R] B) := by
have : (includeLeft : A →ₐ[S] A ⊗[R] B).comp (TensorProduct.rid R S A).toAlgHom =
map (.id S A) (Algebra.ofId R B) := by ext; simp
rw [← Function.Bijective.of_comp_iff _ (TensorProduct.rid R S A).bijective]
convert_to Function.Bijective (map (.id R A) (Algebra.ofId R B))
· exact DFunLike.coe_fn_eq.mpr this
· exact Algebra.TensorProduct.map_bijective Function.bijective_id h
lemma includeRight_bijective (h : Function.Bijective (algebraMap R A)) :
Function.Bijective (includeRight : B →ₐ[R] A ⊗[R] B) := by
rw [← Function.Bijective.of_comp_iff' (TensorProduct.comm R A B).bijective]
exact Algebra.TensorProduct.includeLeft_bijective (S := R) h
end
end Monoidal
section
variable [CommSemiring R] [CommSemiring S] [Algebra R S]
variable [Semiring A] [Algebra R A] [Algebra S A] [IsScalarTower R S A]
variable [Semiring B] [Algebra R B]
variable [CommSemiring C] [Algebra R C] [Algebra S C] [IsScalarTower R S C]
/-- If `A`, `B`, `C` are `R`-algebras, `A` and `C` are also `S`-algebras (forming a tower as
`·/S/R`), then the product map of `f : A →ₐ[S] C` and `g : B →ₐ[R] C` is an `S`-algebra
homomorphism.
This is just a special case of `Algebra.TensorProduct.lift` for when `C` is commutative. -/
abbrev productLeftAlgHom (f : A →ₐ[S] C) (g : B →ₐ[R] C) : A ⊗[R] B →ₐ[S] C :=
lift f g (fun _ _ => Commute.all _ _)
lemma tmul_one_eq_one_tmul (r : R) : algebraMap R A r ⊗ₜ[R] 1 = 1 ⊗ₜ algebraMap R B r := by
rw [Algebra.algebraMap_eq_smul_one, Algebra.algebraMap_eq_smul_one, smul_tmul]
end
section
variable [CommSemiring R] [Semiring A] [Semiring B] [CommSemiring S]
variable [Algebra R A] [Algebra R B] [Algebra R S]
variable (f : A →ₐ[R] S) (g : B →ₐ[R] S)
variable (R)
/-- `LinearMap.mul'` as an `AlgHom` over the algebra. -/
def lmul'' : S ⊗[R] S →ₐ[S] S :=
algHomOfLinearMapTensorProduct
{ __ := LinearMap.mul' R S
map_smul' := fun s x ↦ x.induction_on (by simp)
(fun _ _ ↦ by simp [TensorProduct.smul_tmul', mul_assoc])
fun x y hx hy ↦ by simp_all [mul_add] }
(fun a₁ a₂ b₁ b₂ => by simp [mul_mul_mul_comm]) <| by simp
theorem lmul''_eq_lid_comp_mapOfCompatibleSMul :
lmul'' R = (TensorProduct.lid S S).toAlgHom.comp (mapOfCompatibleSMul' _ _ _ _) := by
ext; rfl
/-- `LinearMap.mul'` as an `AlgHom` over the base ring. -/
def lmul' : S ⊗[R] S →ₐ[R] S := (lmul'' R).restrictScalars R
variable {R}
theorem lmul'_toLinearMap : (lmul' R : _ →ₐ[R] S).toLinearMap = LinearMap.mul' R S :=
rfl
@[simp]
theorem lmul'_apply_tmul (a b : S) : lmul' (S := S) R (a ⊗ₜ[R] b) = a * b :=
rfl
@[simp]
theorem lmul'_comp_includeLeft : (lmul' R : _ →ₐ[R] S).comp includeLeft = AlgHom.id R S :=
AlgHom.ext <| mul_one
@[simp]
theorem lmul'_comp_includeRight : (lmul' R : _ →ₐ[R] S).comp includeRight = AlgHom.id R S :=
AlgHom.ext <| one_mul
lemma lmul'_comp_map (f : A →ₐ[R] S) (g : B →ₐ[R] S) :
(lmul' R).comp (map f g) = lift f g (fun _ _ ↦ .all _ _) := by ext <;> rfl
variable (R S) in
/-- If multiplication by elements of S can switch between the two factors of `S ⊗[R] S`,
then `lmul''` is an isomorphism. -/
def lmulEquiv [CompatibleSMul R S S S] : S ⊗[R] S ≃ₐ[S] S :=
.ofAlgHom (lmul'' R) includeLeft lmul'_comp_includeLeft <| AlgHom.ext fun x ↦ x.induction_on
(by simp) (fun x y ↦ show (x * y) ⊗ₜ[R] 1 = x ⊗ₜ[R] y by
rw [mul_comm, ← smul_eq_mul, smul_tmul, smul_eq_mul, mul_one])
fun _ _ hx hy ↦ by simp_all [add_tmul]
theorem lmulEquiv_eq_lidOfCompatibleSMul [CompatibleSMul R S S S] :
lmulEquiv R S = lidOfCompatibleSMul R S S :=
AlgEquiv.coe_algHom_injective <| by ext; rfl
/-- If `S` is commutative, for a pair of morphisms `f : A →ₐ[R] S`, `g : B →ₐ[R] S`,
We obtain a map `A ⊗[R] B →ₐ[R] S` that commutes with `f`, `g` via `a ⊗ b ↦ f(a) * g(b)`.
This is a special case of `Algebra.TensorProduct.productLeftAlgHom` for when the two base rings are
the same.
-/
def productMap : A ⊗[R] B →ₐ[R] S := productLeftAlgHom f g
theorem productMap_eq_comp_map : productMap f g = (lmul' R).comp (TensorProduct.map f g) := by
ext <;> rfl
@[simp]
theorem productMap_apply_tmul (a : A) (b : B) : productMap f g (a ⊗ₜ b) = f a * g b := rfl
theorem productMap_left_apply (a : A) : productMap f g (a ⊗ₜ 1) = f a := by
simp
@[simp]
theorem productMap_left : (productMap f g).comp includeLeft = f :=
lift_comp_includeLeft _ _ (fun _ _ => Commute.all _ _)
theorem productMap_right_apply (b : B) :
productMap f g (1 ⊗ₜ b) = g b := by simp
@[simp]
theorem productMap_right : (productMap f g).comp includeRight = g :=
lift_comp_includeRight _ _ (fun _ _ => Commute.all _ _)
theorem productMap_range : (productMap f g).range = f.range ⊔ g.range := by
rw [productMap_eq_comp_map, AlgHom.range_comp, map_range, map_sup, ← AlgHom.range_comp,
← AlgHom.range_comp,
← AlgHom.comp_assoc, ← AlgHom.comp_assoc, lmul'_comp_includeLeft, lmul'_comp_includeRight,
AlgHom.id_comp, AlgHom.id_comp]
end
end TensorProduct
end Algebra
namespace LinearMap
variable (R A M N : Type*) [CommSemiring R] [CommSemiring A] [Algebra R A]
variable [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N]
open Module
open scoped TensorProduct
/-- The natural linear map $A ⊗ \text{Hom}_R(M, N) → \text{Hom}_A (M_A, N_A)$,
where $M_A$ and $N_A$ are the respective modules over $A$ obtained by extension of scalars.
See `LinearMap.tensorProductEnd` for this map specialized to endomorphisms,
and bundled as `A`-algebra homomorphism. -/
@[simps!]
def tensorProduct : A ⊗[R] (M →ₗ[R] N) →ₗ[A] (A ⊗[R] M) →ₗ[A] (A ⊗[R] N) :=
TensorProduct.AlgebraTensorModule.lift <|
{ toFun := fun a ↦ a • baseChangeHom R A M N
map_add' := by simp only [add_smul, forall_true_iff]
map_smul' := by simp only [smul_assoc, RingHom.id_apply, forall_true_iff] }
/-- The natural `A`-algebra homomorphism $A ⊗ (\text{End}_R M) → \text{End}_A (A ⊗ M)$,
where `M` is an `R`-module, and `A` an `R`-algebra. -/
@[simps!]
def tensorProductEnd : A ⊗[R] (End R M) →ₐ[A] End A (A ⊗[R] M) :=
Algebra.TensorProduct.algHomOfLinearMapTensorProduct
(LinearMap.tensorProduct R A M M)
(fun a b f g ↦ by
apply LinearMap.ext
intro x
simp only [tensorProduct, mul_comm a b, Module.End.mul_eq_comp,
TensorProduct.AlgebraTensorModule.lift_apply, TensorProduct.lift.tmul, coe_restrictScalars,
coe_mk, AddHom.coe_mk, mul_smul, smul_apply, baseChangeHom_apply, baseChange_comp,
comp_apply, Algebra.mul_smul_comm, Algebra.smul_mul_assoc])
(by
apply LinearMap.ext
intro x
simp only [tensorProduct, TensorProduct.AlgebraTensorModule.lift_apply,
TensorProduct.lift.tmul, coe_restrictScalars, coe_mk, AddHom.coe_mk, one_smul,
baseChangeHom_apply, baseChange_eq_ltensor, Module.End.one_eq_id,
lTensor_id, LinearMap.id_apply])
end LinearMap
namespace Module
variable {R S A M N : Type*} [CommSemiring R] [CommSemiring S] [Semiring A]
variable [AddCommMonoid M] [AddCommMonoid N]
variable [Algebra R S] [Algebra S A] [Algebra R A]
variable [Module R M] [Module S M] [Module A M] [Module R N]
variable [IsScalarTower R A M] [IsScalarTower S A M] [IsScalarTower R S M]
/-- The algebra homomorphism from `End M ⊗ End N` to `End (M ⊗ N)` sending `f ⊗ₜ g` to
the `TensorProduct.map f g`, the tensor product of the two maps.
This is an `AlgHom` version of `TensorProduct.AlgebraTensorModule.homTensorHomMap`. Like that
definition, this is generalized across many different rings; namely a tower of algebras `A/S/R`. -/
def endTensorEndAlgHom : End A M ⊗[R] End R N →ₐ[S] End A (M ⊗[R] N) :=
Algebra.TensorProduct.algHomOfLinearMapTensorProduct
(AlgebraTensorModule.homTensorHomMap R A S M N M N)
(fun _f₁ _f₂ _g₁ _g₂ => AlgebraTensorModule.ext fun _m _n => rfl)
(AlgebraTensorModule.ext fun _m _n => rfl)
theorem endTensorEndAlgHom_apply (f : End A M) (g : End R N) :
endTensorEndAlgHom (R := R) (S := S) (A := A) (M := M) (N := N) (f ⊗ₜ[R] g)
= AlgebraTensorModule.map f g :=
rfl
end Module
/-- Given a subalgebra `C` of an `R`-algebra `A`, and an `R`-algebra `B`, the base change of `C` to
a subalgebra of `B ⊗[R] A` -/
def Subalgebra.baseChange {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]
(B : Type*) [CommSemiring B] [Algebra R B] (C : Subalgebra R A) : Subalgebra B (B ⊗[R] A) :=
AlgHom.range (Algebra.TensorProduct.map (AlgHom.id B B) C.val)
variable {R A B : Type*} [CommSemiring R] [Semiring A] [CommSemiring B] [Algebra R A] [Algebra R B]
variable {C : Subalgebra R A}
lemma Subalgebra.tmul_mem_baseChange {x : A} (hx : x ∈ C) (b : B) : b ⊗ₜ[R] x ∈ C.baseChange B :=
⟨(b ⊗ₜ[R] ⟨x, hx⟩), rfl⟩