-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathBasic.lean
More file actions
759 lines (572 loc) · 25.1 KB
/
Basic.lean
File metadata and controls
759 lines (572 loc) · 25.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
/-
Copyright (c) 2020 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Nathaniel Thomas, Jeremy Avigad, Johannes Hölzl, Mario Carneiro, Anne Baanen,
Frédéric Dupuis, Heather Macbeth
-/
import Mathlib.Algebra.Field.Defs
import Mathlib.Algebra.GroupWithZero.Action.Basic
import Mathlib.Algebra.GroupWithZero.Action.Units
import Mathlib.Algebra.Module.Equiv.Defs
import Mathlib.Algebra.Module.Hom
import Mathlib.Algebra.Module.LinearMap.Basic
import Mathlib.Algebra.Module.LinearMap.End
import Mathlib.Algebra.Module.Pi
import Mathlib.Algebra.Module.Prod
/-!
# Further results on (semi)linear equivalences.
-/
open Function
variable {R : Type*} {R₂ : Type*}
variable {K : Type*} {S : Type*} {M : Type*} {M₁ : Type*} {M₂ : Type*} {M₃ : Type*}
section AddCommMonoid
namespace LinearEquiv
variable [Semiring R] [Semiring S] [Semiring R₂] [AddCommMonoid M] [AddCommMonoid M₂]
section RestrictScalars
variable (R)
variable [Module R M] [Module R M₂] [Module S M] [Module S M₂]
[LinearMap.CompatibleSMul M M₂ R S]
/-- If `M` and `M₂` are both `R`-semimodules and `S`-semimodules and `R`-semimodule structures
are defined by an action of `R` on `S` (formally, we have two scalar towers), then any `S`-linear
equivalence from `M` to `M₂` is also an `R`-linear equivalence.
See also `LinearMap.restrictScalars`. -/
@[simps]
def restrictScalars (f : M ≃ₗ[S] M₂) : M ≃ₗ[R] M₂ :=
{ f.toLinearMap.restrictScalars R with
toFun := f
invFun := f.symm
left_inv := f.left_inv
right_inv := f.right_inv }
theorem restrictScalars_injective :
Function.Injective (restrictScalars R : (M ≃ₗ[S] M₂) → M ≃ₗ[R] M₂) := fun _ _ h ↦
ext (LinearEquiv.congr_fun h :)
@[simp]
theorem restrictScalars_inj (f g : M ≃ₗ[S] M₂) :
f.restrictScalars R = g.restrictScalars R ↔ f = g :=
(restrictScalars_injective R).eq_iff
end RestrictScalars
theorem _root_.Module.End_isUnit_iff [Module R M] (f : Module.End R M) :
IsUnit f ↔ Function.Bijective f :=
⟨fun h ↦
Function.bijective_iff_has_inverse.mpr <|
⟨h.unit.inv,
⟨Module.End_isUnit_inv_apply_apply_of_isUnit h,
Module.End_isUnit_apply_inv_apply_of_isUnit h⟩⟩,
fun H ↦
let e : M ≃ₗ[R] M := { f, Equiv.ofBijective f H with }
⟨⟨_, e.symm, LinearMap.ext e.right_inv, LinearMap.ext e.left_inv⟩, rfl⟩⟩
section Automorphisms
variable [Module R M]
instance automorphismGroup : Group (M ≃ₗ[R] M) where
mul f g := g.trans f
one := LinearEquiv.refl R M
inv f := f.symm
mul_assoc _ _ _ := rfl
mul_one _ := ext fun _ ↦ rfl
one_mul _ := ext fun _ ↦ rfl
inv_mul_cancel f := ext <| f.left_inv
@[simp]
lemma coe_one : ↑(1 : M ≃ₗ[R] M) = id := rfl
@[simp]
lemma coe_toLinearMap_one : (↑(1 : M ≃ₗ[R] M) : M →ₗ[R] M) = LinearMap.id := rfl
@[simp]
lemma coe_toLinearMap_mul {e₁ e₂ : M ≃ₗ[R] M} :
(↑(e₁ * e₂) : M →ₗ[R] M) = (e₁ : M →ₗ[R] M) * (e₂ : M →ₗ[R] M) :=
rfl
theorem coe_pow (e : M ≃ₗ[R] M) (n : ℕ) : ⇑(e ^ n) = e^[n] := hom_coe_pow _ rfl (fun _ _ ↦ rfl) _ _
theorem pow_apply (e : M ≃ₗ[R] M) (n : ℕ) (m : M) : (e ^ n) m = e^[n] m := congr_fun (coe_pow e n) m
@[simp] lemma mul_apply (f : M ≃ₗ[R] M) (g : M ≃ₗ[R] M) (x : M) : (f * g) x = f (g x) := rfl
/-- Restriction from `R`-linear automorphisms of `M` to `R`-linear endomorphisms of `M`,
promoted to a monoid hom. -/
@[simps]
def automorphismGroup.toLinearMapMonoidHom : (M ≃ₗ[R] M) →* M →ₗ[R] M where
toFun e := e.toLinearMap
map_one' := rfl
map_mul' _ _ := rfl
/-- The tautological action by `M ≃ₗ[R] M` on `M`.
This generalizes `Function.End.applyMulAction`. -/
instance applyDistribMulAction : DistribMulAction (M ≃ₗ[R] M) M where
smul := (· <| ·)
smul_zero := LinearEquiv.map_zero
smul_add := LinearEquiv.map_add
one_smul _ := rfl
mul_smul _ _ _ := rfl
@[simp]
protected theorem smul_def (f : M ≃ₗ[R] M) (a : M) : f • a = f a :=
rfl
/-- `LinearEquiv.applyDistribMulAction` is faithful. -/
instance apply_faithfulSMul : FaithfulSMul (M ≃ₗ[R] M) M :=
⟨LinearEquiv.ext⟩
instance apply_smulCommClass [SMul S R] [SMul S M] [IsScalarTower S R M] :
SMulCommClass S (M ≃ₗ[R] M) M where
smul_comm r e m := (e.map_smul_of_tower r m).symm
instance apply_smulCommClass' [SMul S R] [SMul S M] [IsScalarTower S R M] :
SMulCommClass (M ≃ₗ[R] M) S M :=
SMulCommClass.symm _ _ _
end Automorphisms
section OfSubsingleton
variable (M M₂)
variable [Module R M] [Module R M₂] [Subsingleton M] [Subsingleton M₂]
/-- Any two modules that are subsingletons are isomorphic. -/
@[simps]
def ofSubsingleton : M ≃ₗ[R] M₂ :=
{ (0 : M →ₗ[R] M₂) with
toFun := fun _ ↦ 0
invFun := fun _ ↦ 0
left_inv := fun _ ↦ Subsingleton.elim _ _
right_inv := fun _ ↦ Subsingleton.elim _ _ }
@[simp]
theorem ofSubsingleton_self : ofSubsingleton M M = refl R M := by
ext
simp [eq_iff_true_of_subsingleton]
end OfSubsingleton
end LinearEquiv
namespace Module
/-- `g : R ≃+* S` is `R`-linear when the module structure on `S` is `Module.compHom S g` . -/
@[simps]
def compHom.toLinearEquiv {R S : Type*} [Semiring R] [Semiring S] (g : R ≃+* S) :
haveI := compHom S (↑g : R →+* S)
R ≃ₗ[R] S :=
letI := compHom S (↑g : R →+* S)
{ g with
toFun := (g : R → S)
invFun := (g.symm : S → R)
map_smul' := g.map_mul }
end Module
namespace DistribMulAction
variable (R M) [Semiring R] [AddCommMonoid M] [Module R M]
variable [Group S] [DistribMulAction S M] [SMulCommClass S R M]
/-- Each element of the group defines a linear equivalence.
This is a stronger version of `DistribMulAction.toAddEquiv`. -/
@[simps!]
def toLinearEquiv (s : S) : M ≃ₗ[R] M :=
{ toAddEquiv M s, toLinearMap R M s with }
/-- Each element of the group defines a module automorphism.
This is a stronger version of `DistribMulAction.toAddAut`. -/
@[simps]
def toModuleAut : S →* M ≃ₗ[R] M where
toFun := toLinearEquiv R M
map_one' := LinearEquiv.ext <| one_smul _
map_mul' _ _ := LinearEquiv.ext <| mul_smul _ _
end DistribMulAction
namespace AddEquiv
section AddCommMonoid
variable [Semiring R] [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃]
variable [Module R M] [Module R M₂]
variable (e : M ≃+ M₂)
/-- An additive equivalence whose underlying function preserves `smul` is a linear equivalence. -/
def toLinearEquiv (h : ∀ (c : R) (x), e (c • x) = c • e x) : M ≃ₗ[R] M₂ :=
{ e with map_smul' := h }
@[simp]
theorem coe_toLinearEquiv (h : ∀ (c : R) (x), e (c • x) = c • e x) : ⇑(e.toLinearEquiv h) = e :=
rfl
@[simp]
theorem coe_toLinearEquiv_symm (h : ∀ (c : R) (x), e (c • x) = c • e x) :
⇑(e.toLinearEquiv h).symm = e.symm :=
rfl
/-- An additive equivalence between commutative additive monoids is a linear equivalence between
ℕ-modules -/
def toNatLinearEquiv : M ≃ₗ[ℕ] M₂ :=
e.toLinearEquiv fun c a ↦ by rw [map_nsmul]
@[simp]
theorem coe_toNatLinearEquiv : ⇑e.toNatLinearEquiv = e :=
rfl
@[simp]
theorem toNatLinearEquiv_toAddEquiv : ↑e.toNatLinearEquiv = e :=
rfl
@[simp]
theorem _root_.LinearEquiv.toAddEquiv_toNatLinearEquiv (e : M ≃ₗ[ℕ] M₂) :
AddEquiv.toNatLinearEquiv ↑e = e :=
DFunLike.coe_injective rfl
@[simp]
theorem toNatLinearEquiv_symm : e.toNatLinearEquiv.symm = e.symm.toNatLinearEquiv :=
rfl
@[simp]
theorem toNatLinearEquiv_refl : (AddEquiv.refl M).toNatLinearEquiv = LinearEquiv.refl ℕ M :=
rfl
@[simp]
theorem toNatLinearEquiv_trans (e₂ : M₂ ≃+ M₃) :
e.toNatLinearEquiv.trans e₂.toNatLinearEquiv = (e.trans e₂).toNatLinearEquiv :=
rfl
end AddCommMonoid
section AddCommGroup
variable [AddCommGroup M] [AddCommGroup M₂] [AddCommGroup M₃]
variable (e : M ≃+ M₂)
/-- An additive equivalence between commutative additive groups is a linear
equivalence between ℤ-modules -/
def toIntLinearEquiv : M ≃ₗ[ℤ] M₂ :=
e.toLinearEquiv fun c a ↦ e.toAddMonoidHom.map_zsmul a c
@[simp]
theorem coe_toIntLinearEquiv : ⇑e.toIntLinearEquiv = e :=
rfl
@[simp]
theorem toIntLinearEquiv_toAddEquiv : ↑e.toIntLinearEquiv = e := by
ext
rfl
@[simp]
theorem _root_.LinearEquiv.toAddEquiv_toIntLinearEquiv (e : M ≃ₗ[ℤ] M₂) :
AddEquiv.toIntLinearEquiv (e : M ≃+ M₂) = e :=
DFunLike.coe_injective rfl
@[simp]
theorem toIntLinearEquiv_symm : e.toIntLinearEquiv.symm = e.symm.toIntLinearEquiv :=
rfl
@[simp]
theorem toIntLinearEquiv_refl : (AddEquiv.refl M).toIntLinearEquiv = LinearEquiv.refl ℤ M :=
rfl
@[simp]
theorem toIntLinearEquiv_trans (e₂ : M₂ ≃+ M₃) :
e.toIntLinearEquiv.trans e₂.toIntLinearEquiv = (e.trans e₂).toIntLinearEquiv :=
rfl
end AddCommGroup
end AddEquiv
namespace LinearMap
variable (R S M)
variable [Semiring R] [Semiring S] [AddCommMonoid M] [Module R M]
/-- The equivalence between R-linear maps from `R` to `M`, and points of `M` itself.
This says that the forgetful functor from `R`-modules to types is representable, by `R`.
This is an `S`-linear equivalence, under the assumption that `S` acts on `M` commuting with `R`.
When `R` is commutative, we can take this to be the usual action with `S = R`.
Otherwise, `S = ℕ` shows that the equivalence is additive.
See note [bundled maps over different rings].
-/
@[simps]
def ringLmapEquivSelf [Module S M] [SMulCommClass R S M] : (R →ₗ[R] M) ≃ₗ[S] M :=
{ applyₗ' S (1 : R) with
toFun := fun f ↦ f 1
invFun := smulRight (1 : R →ₗ[R] R)
left_inv := fun f ↦ by
ext
simp only [coe_smulRight, one_apply, smul_eq_mul, ← map_smul f, mul_one]
right_inv := fun x ↦ by simp }
end LinearMap
/--
The `R`-linear equivalence between additive morphisms `A →+ B` and `ℕ`-linear morphisms `A →ₗ[ℕ] B`.
-/
@[simps]
def addMonoidHomLequivNat {A B : Type*} (R : Type*) [Semiring R] [AddCommMonoid A]
[AddCommMonoid B] [Module R B] : (A →+ B) ≃ₗ[R] A →ₗ[ℕ] B where
toFun := AddMonoidHom.toNatLinearMap
invFun := LinearMap.toAddMonoidHom
map_add' _ _ := rfl
map_smul' _ _ := rfl
left_inv _ := rfl
right_inv _ := rfl
/--
The `R`-linear equivalence between additive morphisms `A →+ B` and `ℤ`-linear morphisms `A →ₗ[ℤ] B`.
-/
@[simps]
def addMonoidHomLequivInt {A B : Type*} (R : Type*) [Semiring R] [AddCommGroup A] [AddCommGroup B]
[Module R B] : (A →+ B) ≃ₗ[R] A →ₗ[ℤ] B where
toFun := AddMonoidHom.toIntLinearMap
invFun := LinearMap.toAddMonoidHom
map_add' _ _ := rfl
map_smul' _ _ := rfl
left_inv _ := rfl
right_inv _ := rfl
/-- Ring equivalence between additive group endomorphisms of an `AddCommGroup` `A` and
`ℤ`-module endomorphisms of `A.` -/
@[simps] def addMonoidEndRingEquivInt (A : Type*) [AddCommGroup A] :
AddMonoid.End A ≃+* Module.End ℤ A :=
{ addMonoidHomLequivInt (B := A) ℤ with
map_mul' := fun _ _ ↦ rfl }
namespace LinearEquiv
section AddCommMonoid
section Subsingleton
variable [Semiring R] [Semiring R₂]
variable [AddCommMonoid M] [AddCommMonoid M₂]
variable [Module R M] [Module R₂ M₂]
variable {σ₁₂ : R →+* R₂} {σ₂₁ : R₂ →+* R}
variable [RingHomInvPair σ₁₂ σ₂₁] [RingHomInvPair σ₂₁ σ₁₂]
section Module
variable [Subsingleton M] [Subsingleton M₂]
/-- Between two zero modules, the zero map is an equivalence. -/
instance : Zero (M ≃ₛₗ[σ₁₂] M₂) :=
⟨{ (0 : M →ₛₗ[σ₁₂] M₂) with
toFun := 0
invFun := 0
right_inv := Subsingleton.elim _
left_inv := Subsingleton.elim _ }⟩
-- Even though these are implied by `Subsingleton.elim` via the `Unique` instance below, they're
-- nice to have as `rfl`-lemmas for `dsimp`.
@[simp]
theorem zero_symm : (0 : M ≃ₛₗ[σ₁₂] M₂).symm = 0 :=
rfl
@[simp]
theorem coe_zero : ⇑(0 : M ≃ₛₗ[σ₁₂] M₂) = 0 :=
rfl
theorem zero_apply (x : M) : (0 : M ≃ₛₗ[σ₁₂] M₂) x = 0 :=
rfl
/-- Between two zero modules, the zero map is the only equivalence. -/
instance : Unique (M ≃ₛₗ[σ₁₂] M₂) where
uniq _ := toLinearMap_injective (Subsingleton.elim _ _)
default := 0
end Module
instance uniqueOfSubsingleton [Subsingleton R] [Subsingleton R₂] : Unique (M ≃ₛₗ[σ₁₂] M₂) := by
haveI := Module.subsingleton R M
haveI := Module.subsingleton R₂ M₂
infer_instance
end Subsingleton
section Uncurry
variable [Semiring R]
variable [AddCommMonoid M] [Module R M]
variable (V V₂ R M)
/-- Linear equivalence between a curried and uncurried function.
Differs from `TensorProduct.curry`. -/
protected def curry : (V × V₂ → M) ≃ₗ[R] V → V₂ → M :=
{ Equiv.curry _ _ _ with
map_add' := fun _ _ ↦ rfl
map_smul' := fun _ _ ↦ rfl }
@[simp]
theorem coe_curry : ⇑(LinearEquiv.curry R M V V₂) = curry :=
rfl
@[simp]
theorem coe_curry_symm : ⇑(LinearEquiv.curry R M V V₂).symm = uncurry :=
rfl
end Uncurry
section
variable [Semiring R] [Semiring R₂]
variable [AddCommMonoid M] [AddCommMonoid M₂]
variable {module_M : Module R M} {module_M₂ : Module R₂ M₂}
variable {σ₁₂ : R →+* R₂} {σ₂₁ : R₂ →+* R}
variable {re₁₂ : RingHomInvPair σ₁₂ σ₂₁} {re₂₁ : RingHomInvPair σ₂₁ σ₁₂}
variable (f : M →ₛₗ[σ₁₂] M₂) (g : M₂ →ₛₗ[σ₂₁] M)
/-- If a linear map has an inverse, it is a linear equivalence. -/
def ofLinear (h₁ : f.comp g = LinearMap.id) (h₂ : g.comp f = LinearMap.id) : M ≃ₛₗ[σ₁₂] M₂ :=
{ f with
invFun := g
left_inv := LinearMap.ext_iff.1 h₂
right_inv := LinearMap.ext_iff.1 h₁ }
@[simp]
theorem ofLinear_apply {h₁ h₂} (x : M) : (ofLinear f g h₁ h₂ : M ≃ₛₗ[σ₁₂] M₂) x = f x :=
rfl
@[simp]
theorem ofLinear_symm_apply {h₁ h₂} (x : M₂) : (ofLinear f g h₁ h₂ : M ≃ₛₗ[σ₁₂] M₂).symm x = g x :=
rfl
@[simp]
theorem ofLinear_toLinearMap {h₁ h₂} : (ofLinear f g h₁ h₂ : M ≃ₛₗ[σ₁₂] M₂) = f := rfl
@[simp]
theorem ofLinear_symm_toLinearMap {h₁ h₂} : (ofLinear f g h₁ h₂ : M ≃ₛₗ[σ₁₂] M₂).symm = g := rfl
end
end AddCommMonoid
section Neg
variable (R) [Semiring R] [AddCommGroup M] [Module R M]
/-- `x ↦ -x` as a `LinearEquiv` -/
def neg : M ≃ₗ[R] M :=
{ Equiv.neg M, (-LinearMap.id : M →ₗ[R] M) with }
variable {R}
@[simp]
theorem coe_neg : ⇑(neg R : M ≃ₗ[R] M) = -id :=
rfl
theorem neg_apply (x : M) : neg R x = -x := by simp
@[simp]
theorem symm_neg : (neg R : M ≃ₗ[R] M).symm = neg R :=
rfl
end Neg
section Semiring
open LinearMap
variable {M₂₁ M₂₂ : Type*} [Semiring R] [AddCommMonoid M₁] [AddCommMonoid M₂]
[AddCommMonoid M₂₁] [AddCommMonoid M₂₂] [Module R M₁] [Module R M₂] [Module R M₂₁] [Module R M₂₂]
/-- A linear isomorphism between the domains and codomains of two spaces of linear maps gives an
additive isomorphism between the two function spaces.
See also `LinearEquiv.arrowCongr` for the linear version of this isomorphism. -/
@[simps] def arrowCongrAddEquiv (e₁ : M₁ ≃ₗ[R] M₂) (e₂ : M₂₁ ≃ₗ[R] M₂₂) :
(M₁ →ₗ[R] M₂₁) ≃+ (M₂ →ₗ[R] M₂₂) where
toFun f := e₂.comp (f.comp e₁.symm.toLinearMap)
invFun f := e₂.symm.comp (f.comp e₁.toLinearMap)
left_inv f := by
ext x
simp only [symm_apply_apply, Function.comp_apply, coe_comp, coe_coe]
right_inv f := by
ext x
simp only [Function.comp_apply, apply_symm_apply, coe_comp, coe_coe]
map_add' f g := by
ext x
simp only [map_add, add_apply, Function.comp_apply, coe_comp, coe_coe]
/-- A linear isomorphism between the domains an codomains of two spaces of linear maps gives a
linear isomorphism with respect to an action on the domains. -/
@[simps] def domMulActCongrRight [Semiring S] [Module S M₁] [SMulCommClass R S M₁]
(e₂ : M₂₁ ≃ₗ[R] M₂₂) : (M₁ →ₗ[R] M₂₁) ≃ₗ[Sᵈᵐᵃ] (M₁ →ₗ[R] M₂₂) where
__ := arrowCongrAddEquiv (.refl ..) e₂
map_smul' := DomMulAct.mk.forall_congr_right.mp fun _ _ ↦ by ext; simp
/-- If `M` and `M₂` are linearly isomorphic then the endomorphism rings of `M` and `M₂`
are isomorphic.
See `LinearEquiv.conj` for the linear version of this isomorphism. -/
def conjRingEquiv (e : M₁ ≃ₗ[R] M₂) : Module.End R M₁ ≃+* Module.End R M₂ where
__ := arrowCongrAddEquiv e e
map_mul' _ _ := by ext; simp [arrowCongrAddEquiv]
end Semiring
section CommSemiring
variable [CommSemiring R] [AddCommMonoid M] [AddCommMonoid M₂] [AddCommMonoid M₃]
variable [Module R M] [Module R M₂] [Module R M₃]
open LinearMap
/-- Multiplying by a unit `a` of the ring `R` is a linear equivalence. -/
def smulOfUnit (a : Rˣ) : M ≃ₗ[R] M :=
DistribMulAction.toLinearEquiv R M a
/-- A linear isomorphism between the domains and codomains of two spaces of linear maps gives a
linear isomorphism between the two function spaces.
See `LinearEquiv.arrowCongrAddEquiv` for the additive version of this isomorphism that works
over a not necessarily commutative semiring. -/
def arrowCongr {R M₁ M₂ M₂₁ M₂₂ : Sort _} [CommSemiring R] [AddCommMonoid M₁] [AddCommMonoid M₂]
[AddCommMonoid M₂₁] [AddCommMonoid M₂₂] [Module R M₁] [Module R M₂] [Module R M₂₁]
[Module R M₂₂] (e₁ : M₁ ≃ₗ[R] M₂) (e₂ : M₂₁ ≃ₗ[R] M₂₂) : (M₁ →ₗ[R] M₂₁) ≃ₗ[R] M₂ →ₗ[R] M₂₂ where
__ := arrowCongrAddEquiv e₁ e₂
map_smul' c f := by ext; simp [arrowCongrAddEquiv]
@[simp]
theorem arrowCongr_apply {R M₁ M₂ M₂₁ M₂₂ : Sort _} [CommSemiring R] [AddCommMonoid M₁]
[AddCommMonoid M₂] [AddCommMonoid M₂₁] [AddCommMonoid M₂₂] [Module R M₁] [Module R M₂]
[Module R M₂₁] [Module R M₂₂] (e₁ : M₁ ≃ₗ[R] M₂) (e₂ : M₂₁ ≃ₗ[R] M₂₂) (f : M₁ →ₗ[R] M₂₁)
(x : M₂) : arrowCongr e₁ e₂ f x = e₂ (f (e₁.symm x)) :=
rfl
@[simp]
theorem arrowCongr_symm_apply {R M₁ M₂ M₂₁ M₂₂ : Sort _} [CommSemiring R] [AddCommMonoid M₁]
[AddCommMonoid M₂] [AddCommMonoid M₂₁] [AddCommMonoid M₂₂] [Module R M₁] [Module R M₂]
[Module R M₂₁] [Module R M₂₂] (e₁ : M₁ ≃ₗ[R] M₂) (e₂ : M₂₁ ≃ₗ[R] M₂₂) (f : M₂ →ₗ[R] M₂₂)
(x : M₁) : (arrowCongr e₁ e₂).symm f x = e₂.symm (f (e₁ x)) :=
rfl
theorem arrowCongr_comp {N N₂ N₃ : Sort _} [AddCommMonoid N] [AddCommMonoid N₂] [AddCommMonoid N₃]
[Module R N] [Module R N₂] [Module R N₃] (e₁ : M ≃ₗ[R] N) (e₂ : M₂ ≃ₗ[R] N₂) (e₃ : M₃ ≃ₗ[R] N₃)
(f : M →ₗ[R] M₂) (g : M₂ →ₗ[R] M₃) :
arrowCongr e₁ e₃ (g.comp f) = (arrowCongr e₂ e₃ g).comp (arrowCongr e₁ e₂ f) := by
ext
simp only [symm_apply_apply, arrowCongr_apply, LinearMap.comp_apply]
theorem arrowCongr_trans {M₁ M₂ M₃ N₁ N₂ N₃ : Sort _} [AddCommMonoid M₁] [Module R M₁]
[AddCommMonoid M₂] [Module R M₂] [AddCommMonoid M₃] [Module R M₃] [AddCommMonoid N₁]
[Module R N₁] [AddCommMonoid N₂] [Module R N₂] [AddCommMonoid N₃] [Module R N₃]
(e₁ : M₁ ≃ₗ[R] M₂) (e₂ : N₁ ≃ₗ[R] N₂) (e₃ : M₂ ≃ₗ[R] M₃) (e₄ : N₂ ≃ₗ[R] N₃) :
(arrowCongr e₁ e₂).trans (arrowCongr e₃ e₄) = arrowCongr (e₁.trans e₃) (e₂.trans e₄) :=
rfl
/-- If `M₂` and `M₃` are linearly isomorphic then the two spaces of linear maps from `M` into `M₂`
and `M` into `M₃` are linearly isomorphic. -/
def congrRight (f : M₂ ≃ₗ[R] M₃) : (M →ₗ[R] M₂) ≃ₗ[R] M →ₗ[R] M₃ :=
arrowCongr (LinearEquiv.refl R M) f
/-- If `M` and `M₂` are linearly isomorphic then the two spaces of linear maps from `M` and `M₂` to
themselves are linearly isomorphic.
See `LinearEquiv.conjRingEquiv` for the isomorphism between endomorphism rings,
which works over a not necessarily commutative semiring. -/
-- TODO: upgrade to AlgEquiv (but this file currently cannot import AlgEquiv)
def conj (e : M ≃ₗ[R] M₂) : Module.End R M ≃ₗ[R] Module.End R M₂ :=
arrowCongr e e
theorem conj_apply (e : M ≃ₗ[R] M₂) (f : Module.End R M) :
e.conj f = ((↑e : M →ₗ[R] M₂).comp f).comp (e.symm : M₂ →ₗ[R] M) :=
rfl
theorem conj_apply_apply (e : M ≃ₗ[R] M₂) (f : Module.End R M) (x : M₂) :
e.conj f x = e (f (e.symm x)) :=
rfl
theorem symm_conj_apply (e : M ≃ₗ[R] M₂) (f : Module.End R M₂) :
e.symm.conj f = ((↑e.symm : M₂ →ₗ[R] M).comp f).comp (e : M →ₗ[R] M₂) :=
rfl
theorem conj_comp (e : M ≃ₗ[R] M₂) (f g : Module.End R M) :
e.conj (g.comp f) = (e.conj g).comp (e.conj f) :=
arrowCongr_comp e e e f g
theorem conj_trans (e₁ : M ≃ₗ[R] M₂) (e₂ : M₂ ≃ₗ[R] M₃) :
e₁.conj.trans e₂.conj = (e₁.trans e₂).conj :=
rfl
@[simp]
theorem conj_id (e : M ≃ₗ[R] M₂) : e.conj LinearMap.id = LinearMap.id := by
ext
simp [conj_apply]
@[simp]
theorem conj_refl (f : Module.End R M) : (refl R M).conj f = f := rfl
variable (M) in
/-- An `R`-linear isomorphism between two `R`-modules `M₂` and `M₃` induces an `S`-linear
isomorphism between `M₂ →ₗ[R] M` and `M₃ →ₗ[R] M`, if `M` is both an `R`-module and an
`S`-module and their actions commute. -/
def congrLeft {R} (S) [Semiring R] [Semiring S] [Module R M₂] [Module R M₃] [Module R M]
[Module S M] [SMulCommClass R S M] (e : M₂ ≃ₗ[R] M₃) : (M₂ →ₗ[R] M) ≃ₗ[S] (M₃ →ₗ[R] M) where
__ := e.arrowCongrAddEquiv (.refl ..)
map_smul' _ _ := rfl
end CommSemiring
section Field
variable [Field K] [AddCommGroup M] [Module K M]
variable (K) (M)
open LinearMap
/-- Multiplying by a nonzero element `a` of the field `K` is a linear equivalence. -/
@[simps!]
def smulOfNeZero (a : K) (ha : a ≠ 0) : M ≃ₗ[K] M :=
smulOfUnit <| Units.mk0 a ha
end Field
end LinearEquiv
namespace Equiv
variable [Semiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid M₂] [Module R M₂]
/-- An equivalence whose underlying function is linear is a linear equivalence. -/
def toLinearEquiv (e : M ≃ M₂) (h : IsLinearMap R (e : M → M₂)) : M ≃ₗ[R] M₂ :=
{ e, h.mk' e with }
end Equiv
section FunLeft
variable (R M) [Semiring R] [AddCommMonoid M] [Module R M]
variable {m n p : Type*}
namespace LinearMap
/-- Given an `R`-module `M` and a function `m → n` between arbitrary types,
construct a linear map `(n → M) →ₗ[R] (m → M)` -/
def funLeft (f : m → n) : (n → M) →ₗ[R] m → M where
toFun := (· ∘ f)
map_add' _ _ := rfl
map_smul' _ _ := rfl
@[simp]
theorem funLeft_apply (f : m → n) (g : n → M) (i : m) : funLeft R M f g i = g (f i) :=
rfl
@[simp]
theorem funLeft_id (g : n → M) : funLeft R M _root_.id g = g :=
rfl
theorem funLeft_comp (f₁ : n → p) (f₂ : m → n) :
funLeft R M (f₁ ∘ f₂) = (funLeft R M f₂).comp (funLeft R M f₁) :=
rfl
theorem funLeft_surjective_of_injective (f : m → n) (hf : Injective f) :
Surjective (funLeft R M f) :=
hf.surjective_comp_right
theorem funLeft_injective_of_surjective (f : m → n) (hf : Surjective f) :
Injective (funLeft R M f) :=
hf.injective_comp_right
end LinearMap
namespace LinearEquiv
open LinearMap
/-- Given an `R`-module `M` and an equivalence `m ≃ n` between arbitrary types,
construct a linear equivalence `(n → M) ≃ₗ[R] (m → M)` -/
def funCongrLeft (e : m ≃ n) : (n → M) ≃ₗ[R] m → M :=
LinearEquiv.ofLinear (funLeft R M e) (funLeft R M e.symm)
(LinearMap.ext fun x ↦
funext fun i ↦ by rw [id_apply, ← funLeft_comp, Equiv.symm_comp_self, LinearMap.funLeft_id])
(LinearMap.ext fun x ↦
funext fun i ↦ by rw [id_apply, ← funLeft_comp, Equiv.self_comp_symm, LinearMap.funLeft_id])
@[simp]
theorem funCongrLeft_apply (e : m ≃ n) (x : n → M) : funCongrLeft R M e x = funLeft R M e x :=
rfl
@[simp]
theorem funCongrLeft_id : funCongrLeft R M (Equiv.refl n) = LinearEquiv.refl R (n → M) :=
rfl
@[simp]
theorem funCongrLeft_comp (e₁ : m ≃ n) (e₂ : n ≃ p) :
funCongrLeft R M (Equiv.trans e₁ e₂) =
LinearEquiv.trans (funCongrLeft R M e₂) (funCongrLeft R M e₁) :=
rfl
@[simp]
theorem funCongrLeft_symm (e : m ≃ n) : (funCongrLeft R M e).symm = funCongrLeft R M e.symm :=
rfl
end LinearEquiv
end FunLeft
section Pi
namespace LinearEquiv
/-- The product over `S ⊕ T` of a family of modules is isomorphic to the product of
(the product over `S`) and (the product over `T`).
This is `Equiv.sumPiEquivProdPi` as a `LinearEquiv`.
-/
@[simps -fullyApplied +simpRhs]
def sumPiEquivProdPi (R : Type*) [Semiring R] (S T : Type*) (A : S ⊕ T → Type*)
[∀ st, AddCommMonoid (A st)] [∀ st, Module R (A st)] :
(Π (st : S ⊕ T), A st) ≃ₗ[R] (Π (s : S), A (.inl s)) × (Π (t : T), A (.inr t)) where
__ := Equiv.sumPiEquivProdPi _
map_add' _ _ := rfl
map_smul' _ _ := rfl
/-- The product `Π t : α, f t` of a family of modules is linearly isomorphic to the module
`f ⬝` when `α` only contains `⬝`.
This is `Equiv.piUnique` as a `LinearEquiv`.
-/
@[simps -fullyApplied]
def piUnique {α : Type*} [Unique α] (R : Type*) [Semiring R] (f : α → Type*)
[∀ x, AddCommMonoid (f x)] [∀ x, Module R (f x)] : (Π t : α, f t) ≃ₗ[R] f default where
__ := Equiv.piUnique _
map_add' _ _ := rfl
map_smul' _ _ := rfl
end LinearEquiv
end Pi
end AddCommMonoid