Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
File size: 37,785 Bytes
4365a98 fc5e983 4365a98 fc5e983 4365a98 fc5e983 4365a98 fc5e983 4365a98 |
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 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 |
/-
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 algebra.hom.group
import algebra.hom.group_action
import algebra.module.basic
import algebra.module.pi
import algebra.ring.comp_typeclasses
import algebra.star.basic
/-!
# (Semi)linear maps
In this file we define
* `linear_map Ο M Mβ`, `M βββ[Ο] Mβ` : a semilinear map between two `module`s. Here,
`Ο` is a `ring_hom` from `R` to `Rβ` and an `f : M βββ[Ο] Mβ` satisfies
`f (c β’ x) = (Ο c) β’ (f x)`. We recover plain linear maps by choosing `Ο` to be `ring_hom.id R`.
This is denoted by `M ββ[R] Mβ`. We also add the notation `M βββ[R] Mβ` for star-linear maps.
* `is_linear_map R f` : predicate saying that `f : M β Mβ` is a linear map. (Note that this
was not generalized to semilinear maps.)
We then provide `linear_map` with the following instances:
* `linear_map.add_comm_monoid` and `linear_map.add_comm_group`: the elementwise addition structures
corresponding to addition in the codomain
* `linear_map.distrib_mul_action` and `linear_map.module`: the elementwise scalar action structures
corresponding to applying the action in the codomain.
* `module.End.semiring` and `module.End.ring`: the (semi)ring of endomorphisms formed by taking the
additive structure above with composition as multiplication.
## Implementation notes
To ensure that composition works smoothly for semilinear maps, we use the typeclasses
`ring_hom_comp_triple`, `ring_hom_inv_pair` and `ring_hom_surjective` from
`algebra/ring/comp_typeclasses`.
## Notation
* Throughout the file, we denote regular linear maps by `fβ`, `gβ`, etc, and semilinear maps
by `f`, `g`, etc.
## TODO
* Parts of this file have not yet been generalized to semilinear maps (i.e. `compatible_smul`)
## Tags
linear map
-/
open function
open_locale big_operators
universes u u' v w x y z
variables {R : Type*} {Rβ : Type*} {Rβ : Type*} {Rβ : Type*}
variables {k : Type*} {S : Type*} {Sβ : Type*} {T : Type*}
variables {M : Type*} {Mβ : Type*} {Mβ : Type*} {Mβ : Type*}
variables {Nβ : Type*} {Nβ : Type*} {Nβ : Type*} {ΞΉ : Type*}
/-- A map `f` between modules over a semiring is linear if it satisfies the two properties
`f (x + y) = f x + f y` and `f (c β’ x) = c β’ f x`. The predicate `is_linear_map R f` asserts this
property. A bundled version is available with `linear_map`, and should be favored over
`is_linear_map` most of the time. -/
structure is_linear_map (R : Type u) {M : Type v} {Mβ : Type w}
[semiring R] [add_comm_monoid M] [add_comm_monoid Mβ] [module R M] [module R Mβ]
(f : M β Mβ) : Prop :=
(map_add : β x y, f (x + y) = f x + f y)
(map_smul : β (c : R) x, f (c β’ x) = c β’ f x)
section
set_option old_structure_cmd true
/-- A map `f` between an `R`-module and an `S`-module over a ring homomorphism `Ο : R β+* S`
is semilinear if it satisfies the two properties `f (x + y) = f x + f y` and
`f (c β’ x) = (Ο c) β’ f x`. Elements of `linear_map Ο M Mβ` (available under the notation
`M βββ[Ο] Mβ`) are bundled versions of such maps. For plain linear maps (i.e. for which
`Ο = ring_hom.id R`), the notation `M ββ[R] Mβ` is available. An unbundled version of plain linear
maps is available with the predicate `is_linear_map`, but it should be avoided most of the time. -/
structure linear_map {R : Type*} {S : Type*} [semiring R] [semiring S] (Ο : R β+* S)
(M : Type*) (Mβ : Type*)
[add_comm_monoid M] [add_comm_monoid Mβ] [module R M] [module S Mβ]
extends add_hom M Mβ :=
(map_smul' : β (r : R) (x : M), to_fun (r β’ x) = (Ο r) β’ to_fun x)
/-- The `add_hom` underlying a `linear_map`. -/
add_decl_doc linear_map.to_add_hom
notation M ` βββ[`:25 Ο:25 `] `:0 Mβ:0 := linear_map Ο M Mβ
notation M ` ββ[`:25 R:25 `] `:0 Mβ:0 := linear_map (ring_hom.id R) M Mβ
notation M ` βββ[`:25 R:25 `] `:0 Mβ:0 := linear_map (star_ring_end R) M Mβ
/-- `semilinear_map_class F Ο M Mβ` asserts `F` is a type of bundled `Ο`-semilinear maps `M β Mβ`.
See also `linear_map_class F R M Mβ` for the case where `Ο` is the identity map on `R`.
A map `f` between an `R`-module and an `S`-module over a ring homomorphism `Ο : R β+* S`
is semilinear if it satisfies the two properties `f (x + y) = f x + f y` and
`f (c β’ x) = (Ο c) β’ f x`. -/
class semilinear_map_class (F : Type*) {R S : out_param Type*} [semiring R] [semiring S]
(Ο : out_param $ R β+* S) (M Mβ : out_param Type*)
[add_comm_monoid M] [add_comm_monoid Mβ] [module R M] [module S Mβ]
extends add_hom_class F M Mβ :=
(map_smulββ : β (f : F) (r : R) (x : M), f (r β’ x) = (Ο r) β’ f x)
end
-- `Ο` becomes a metavariable but that's fine because it's an `out_param`
attribute [nolint dangerous_instance] semilinear_map_class.to_add_hom_class
export semilinear_map_class (map_smulββ)
attribute [simp] map_smulββ
/-- `linear_map_class F R M Mβ` asserts `F` is a type of bundled `R`-linear maps `M β Mβ`.
This is an abbreviation for `semilinear_map_class F (ring_hom.id R) M Mβ`.
-/
abbreviation linear_map_class (F : Type*) (R M Mβ : out_param Type*)
[semiring R] [add_comm_monoid M] [add_comm_monoid Mβ] [module R M] [module R Mβ] :=
semilinear_map_class F (ring_hom.id R) M Mβ
namespace semilinear_map_class
variables (F : Type*)
variables [semiring R] [semiring S]
variables [add_comm_monoid M] [add_comm_monoid Mβ] [add_comm_monoid Mβ] [add_comm_monoid Mβ]
variables [add_comm_monoid Nβ] [add_comm_monoid Nβ] [add_comm_monoid Nβ]
variables [module R M] [module R Mβ] [module S Mβ]
variables {Ο : R β+* S}
@[priority 100, nolint dangerous_instance] -- `Ο` is an `out_param` so it's not dangerous
instance [semilinear_map_class F Ο M Mβ] : add_monoid_hom_class F M Mβ :=
{ coe := Ξ» f, (f : M β Mβ),
map_zero := Ξ» f, show f 0 = 0, by { rw [β zero_smul R (0 : M), map_smulββ], simp },
.. semilinear_map_class.to_add_hom_class F Ο M Mβ }
@[priority 100, nolint dangerous_instance] -- `R` is an `out_param` so it's not dangerous
instance [linear_map_class F R M Mβ] : distrib_mul_action_hom_class F R M Mβ :=
{ coe := Ξ» f, (f : M β Mβ),
map_smul := Ξ» f c x, by rw [map_smulββ, ring_hom.id_apply],
.. semilinear_map_class.add_monoid_hom_class F }
variables {F} (f : F) [i : semilinear_map_class F Ο M Mβ]
include i
lemma map_smul_inv {Ο' : S β+* R} [ring_hom_inv_pair Ο Ο'] (c : S) (x : M) :
c β’ f x = f (Ο' c β’ x) :=
by simp
end semilinear_map_class
namespace linear_map
section add_comm_monoid
variables [semiring R] [semiring S]
section
variables [add_comm_monoid M] [add_comm_monoid Mβ] [add_comm_monoid Mβ] [add_comm_monoid Mβ]
variables [add_comm_monoid Nβ] [add_comm_monoid Nβ] [add_comm_monoid Nβ]
variables [module R M] [module R Mβ] [module S Mβ]
variables {Ο : R β+* S}
instance : semilinear_map_class (M βββ[Ο] Mβ) Ο M Mβ :=
{ coe := linear_map.to_fun,
coe_injective' := Ξ» f g h, by cases f; cases g; congr',
map_add := linear_map.map_add',
map_smulββ := linear_map.map_smul' }
/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
directly.
-/
instance : has_coe_to_fun (M βββ[Ο] Mβ) (Ξ» _, M β Mβ) := β¨Ξ» f, fβ©
/-- The `distrib_mul_action_hom` underlying a `linear_map`. -/
def to_distrib_mul_action_hom (f : M ββ[R] Mβ) : distrib_mul_action_hom R M Mβ :=
{ map_zero' := show f 0 = 0, from map_zero f, ..f }
@[simp] lemma to_fun_eq_coe {f : M βββ[Ο] Mβ} : f.to_fun = (f : M β Mβ) := rfl
@[ext] theorem ext {f g : M βββ[Ο] Mβ} (h : β x, f x = g x) : f = g := fun_like.ext f g h
/-- Copy of a `linear_map` with a new `to_fun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (f : M βββ[Ο] Mβ) (f' : M β Mβ) (h : f' = βf) : M βββ[Ο] Mβ :=
{ to_fun := f',
map_add' := h.symm βΈ f.map_add',
map_smul' := h.symm βΈ f.map_smul' }
/-- See Note [custom simps projection]. -/
protected def simps.apply {R S : Type*} [semiring R] [semiring S] (Ο : R β+* S)
(M Mβ : Type*) [add_comm_monoid M] [add_comm_monoid Mβ] [module R M] [module S Mβ]
(f : M βββ[Ο] Mβ) : M β Mβ := f
initialize_simps_projections linear_map (to_fun β apply)
@[simp] lemma coe_mk {Ο : R β+* S} (f : M β Mβ) (hβ hβ) :
((linear_map.mk f hβ hβ : M βββ[Ο] Mβ) : M β Mβ) = f := rfl
/-- Identity map as a `linear_map` -/
def id : M ββ[R] M :=
{ to_fun := id, ..distrib_mul_action_hom.id R }
lemma id_apply (x : M) :
@id R M _ _ _ x = x := rfl
@[simp, norm_cast] lemma id_coe : ((linear_map.id : M ββ[R] M) : M β M) = _root_.id := rfl
end
section
variables [add_comm_monoid M] [add_comm_monoid Mβ] [add_comm_monoid Mβ] [add_comm_monoid Mβ]
variables [add_comm_monoid Nβ] [add_comm_monoid Nβ] [add_comm_monoid Nβ]
variables [module R M] [module R Mβ] [module S Mβ]
variables (Ο : R β+* S)
variables (fβ gβ : M ββ[R] Mβ) (f g : M βββ[Ο] Mβ)
theorem is_linear : is_linear_map R fβ := β¨fβ.map_add', fβ.map_smul'β©
variables {fβ gβ f g Ο}
theorem coe_injective : @injective (M βββ[Ο] Mβ) (M β Mβ) coe_fn :=
fun_like.coe_injective
protected lemma congr_arg {x x' : M} : x = x' β f x = f x' :=
fun_like.congr_arg f
/-- If two linear maps are equal, they are equal at each point. -/
protected lemma congr_fun (h : f = g) (x : M) : f x = g x :=
fun_like.congr_fun h x
theorem ext_iff : f = g β β x, f x = g x :=
fun_like.ext_iff
@[simp] lemma mk_coe (f : M βββ[Ο] Mβ) (hβ hβ) :
(linear_map.mk f hβ hβ : M βββ[Ο] Mβ) = f := ext $ Ξ» _, rfl
variables (fβ gβ f g)
protected lemma map_add (x y : M) : f (x + y) = f x + f y := map_add f x y
protected lemma map_zero : f 0 = 0 := map_zero f
-- TODO: `simp` isn't picking up `map_smulββ` for `linear_map`s without specifying `map_smulββ f`
@[simp] protected lemma map_smulββ (c : R) (x : M) : f (c β’ x) = (Ο c) β’ f x := map_smulββ f c x
protected lemma map_smul (c : R) (x : M) : fβ (c β’ x) = c β’ fβ x := map_smul fβ c x
protected lemma map_smul_inv {Ο' : S β+* R} [ring_hom_inv_pair Ο Ο'] (c : S) (x : M) :
c β’ f x = f (Ο' c β’ x) :=
by simp
-- TODO: generalize to `zero_hom_class`
@[simp] lemma map_eq_zero_iff (h : function.injective f) {x : M} : f x = 0 β x = 0 :=
β¨Ξ» w, by { apply h, simp [w], }, Ξ» w, by { subst w, simp, }β©
section pointwise
open_locale pointwise
variables (M Mβ Ο) {F : Type*} (h : F)
@[simp] lemma _root_.image_smul_setββ [semilinear_map_class F Ο M Mβ] (c : R) (s : set M) :
h '' (c β’ s) = (Ο c) β’ h '' s :=
begin
apply set.subset.antisymm,
{ rintros x β¨y, β¨z, zs, rflβ©, rflβ©,
exact β¨h z, set.mem_image_of_mem _ zs, (map_smulββ _ _ _).symm β© },
{ rintros x β¨y, β¨z, hz, rflβ©, rflβ©,
exact (set.mem_image _ _ _).2 β¨c β’ z, set.smul_mem_smul_set hz, map_smulββ _ _ _β© }
end
lemma _root_.preimage_smul_setββ [semilinear_map_class F Ο M Mβ] {c : R} (hc : is_unit c)
(s : set Mβ) : h β»ΒΉ' (Ο c β’ s) = c β’ h β»ΒΉ' s :=
begin
apply set.subset.antisymm,
{ rintros x β¨y, ys, hyβ©,
refine β¨(hc.unit.inv : R) β’ x, _, _β©,
{ simp only [βhy, smul_smul, set.mem_preimage, units.inv_eq_coe_inv, map_smulββ h, β map_mul,
is_unit.coe_inv_mul, one_smul, map_one, ys] },
{ simp only [smul_smul, is_unit.mul_coe_inv, one_smul, units.inv_eq_coe_inv] } },
{ rintros x β¨y, hy, rflβ©,
refine β¨h y, hy, by simp only [ring_hom.id_apply, map_smulββ h]β© }
end
variables (R Mβ)
lemma _root_.image_smul_set [linear_map_class F R M Mβ] (c : R) (s : set M) :
h '' (c β’ s) = c β’ h '' s :=
image_smul_setββ _ _ _ h c s
lemma _root_.preimage_smul_set [linear_map_class F R M Mβ] {c : R} (hc : is_unit c) (s : set Mβ) :
h β»ΒΉ' (c β’ s) = c β’ h β»ΒΉ' s :=
preimage_smul_setββ _ _ _ h hc s
end pointwise
variables (M Mβ)
/--
A typeclass for `has_smul` structures which can be moved through a `linear_map`.
This typeclass is generated automatically from a `is_scalar_tower` instance, but exists so that
we can also add an instance for `add_comm_group.int_module`, allowing `z β’` to be moved even if
`R` does not support negation.
-/
class compatible_smul (R S : Type*) [semiring S] [has_smul R M]
[module S M] [has_smul R Mβ] [module S Mβ] :=
(map_smul : β (fβ : M ββ[S] Mβ) (c : R) (x : M), fβ (c β’ x) = c β’ fβ x)
variables {M Mβ}
@[priority 100]
instance is_scalar_tower.compatible_smul
{R S : Type*} [semiring S] [has_smul R S]
[has_smul R M] [module S M] [is_scalar_tower R S M]
[has_smul R Mβ] [module S Mβ] [is_scalar_tower R S Mβ] : compatible_smul M Mβ R S :=
β¨Ξ» fβ c x, by rw [β smul_one_smul S c x, β smul_one_smul S c (fβ x), map_smul]β©
@[simp, priority 900]
lemma map_smul_of_tower {R S : Type*} [semiring S] [has_smul R M]
[module S M] [has_smul R Mβ] [module S Mβ]
[compatible_smul M Mβ R S] (fβ : M ββ[S] Mβ) (c : R) (x : M) :
fβ (c β’ x) = c β’ fβ x :=
compatible_smul.map_smul fβ c x
/-- convert a linear map to an additive map -/
def to_add_monoid_hom : M β+ Mβ :=
{ to_fun := f,
map_zero' := f.map_zero,
map_add' := f.map_add }
@[simp] lemma to_add_monoid_hom_coe : βf.to_add_monoid_hom = f := rfl
section restrict_scalars
variables (R) [module S M] [module S Mβ] [compatible_smul M Mβ R S]
/-- If `M` and `Mβ` are both `R`-modules and `S`-modules and `R`-module structures
are defined by an action of `R` on `S` (formally, we have two scalar towers), then any `S`-linear
map from `M` to `Mβ` is `R`-linear.
See also `linear_map.map_smul_of_tower`. -/
def restrict_scalars (fβ : M ββ[S] Mβ) : M ββ[R] Mβ :=
{ to_fun := fβ,
map_add' := fβ.map_add,
map_smul' := fβ.map_smul_of_tower }
@[simp] lemma coe_restrict_scalars (fβ : M ββ[S] Mβ) : β(restrict_scalars R fβ) = fβ :=
rfl
lemma restrict_scalars_apply (fβ : M ββ[S] Mβ) (x) : restrict_scalars R fβ x = fβ x :=
rfl
lemma restrict_scalars_injective :
function.injective (restrict_scalars R : (M ββ[S] Mβ) β (M ββ[R] Mβ)) :=
Ξ» fβ gβ h, ext (linear_map.congr_fun h : _)
@[simp]
lemma restrict_scalars_inj (fβ gβ : M ββ[S] Mβ) :
fβ.restrict_scalars R = gβ.restrict_scalars R β fβ = gβ :=
(restrict_scalars_injective R).eq_iff
end restrict_scalars
variable {R}
@[simp] lemma map_sum {ΞΉ} {t : finset ΞΉ} {g : ΞΉ β M} :
f (β i in t, g i) = (β i in t, f (g i)) :=
f.to_add_monoid_hom.map_sum _ _
theorem to_add_monoid_hom_injective :
function.injective (to_add_monoid_hom : (M βββ[Ο] Mβ) β (M β+ Mβ)) :=
Ξ» f g h, ext $ add_monoid_hom.congr_fun h
/-- If two `Ο`-linear maps from `R` are equal on `1`, then they are equal. -/
@[ext] theorem ext_ring {f g : R βββ[Ο] Mβ} (h : f 1 = g 1) : f = g :=
ext $ Ξ» x, by rw [β mul_one x, β smul_eq_mul, f.map_smulββ, g.map_smulββ, h]
theorem ext_ring_iff {Ο : R β+* R} {f g : R βββ[Ο] M} : f = g β f 1 = g 1 :=
β¨Ξ» h, h βΈ rfl, ext_ringβ©
@[ext] theorem ext_ring_op {Ο : Rα΅α΅α΅ β+* S} {f g : R βββ[Ο] Mβ} (h : f 1 = g 1) : f = g :=
ext $ Ξ» x, by rw [β one_mul x, β op_smul_eq_mul, f.map_smulββ, g.map_smulββ, h]
end
/-- Interpret a `ring_hom` `f` as an `f`-semilinear map. -/
@[simps]
def _root_.ring_hom.to_semilinear_map (f : R β+* S) : R βββ[f] S :=
{ to_fun := f,
map_smul' := f.map_mul,
.. f}
section
variables [semiring Rβ] [semiring Rβ] [semiring Rβ]
variables [add_comm_monoid M] [add_comm_monoid Mβ] [add_comm_monoid Mβ] [add_comm_monoid Mβ]
variables {module_Mβ : module Rβ Mβ} {module_Mβ : module Rβ Mβ} {module_Mβ : module Rβ Mβ}
variables {Οββ : Rβ β+* Rβ} {Οββ : Rβ β+* Rβ} {Οββ : Rβ β+* Rβ}
variables [ring_hom_comp_triple Οββ Οββ Οββ]
variables (f : Mβ βββ[Οββ] Mβ) (g : Mβ βββ[Οββ] Mβ)
include module_Mβ module_Mβ module_Mβ
/-- Composition of two linear maps is a linear map -/
def comp : Mβ βββ[Οββ] Mβ :=
{ to_fun := f β g,
map_add' := by simp only [map_add, forall_const, eq_self_iff_true, comp_app],
map_smul' := Ξ» r x, by rw [comp_app, map_smulββ, map_smulββ, ring_hom_comp_triple.comp_apply] }
omit module_Mβ module_Mβ module_Mβ
infixr ` ββ `:80 := @linear_map.comp _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
(ring_hom.id _) (ring_hom.id _) (ring_hom.id _) ring_hom_comp_triple.ids
include Οββ
lemma comp_apply (x : Mβ) : f.comp g x = f (g x) := rfl
omit Οββ
include Οββ
@[simp, norm_cast] lemma coe_comp : (f.comp g : Mβ β Mβ) = f β g := rfl
omit Οββ
@[simp] theorem comp_id : f.comp id = f :=
linear_map.ext $ Ξ» x, rfl
@[simp] theorem id_comp : id.comp f = f :=
linear_map.ext $ Ξ» x, rfl
variables {f g} {f' : Mβ βββ[Οββ] Mβ} {g' : Mβ βββ[Οββ] Mβ}
include Οββ
theorem cancel_right (hg : function.surjective g) :
f.comp g = f'.comp g β f = f' :=
β¨Ξ» h, ext $ hg.forall.2 (ext_iff.1 h), Ξ» h, h βΈ rflβ©
theorem cancel_left (hf : function.injective f) :
f.comp g = f.comp g' β g = g' :=
β¨Ξ» h, ext $ Ξ» x, hf $ by rw [β comp_apply, h, comp_apply], Ξ» h, h βΈ rflβ©
omit Οββ
end
variables [add_comm_monoid M] [add_comm_monoid Mβ] [add_comm_monoid Mβ] [add_comm_monoid Mβ]
/-- If a function `g` is a left and right inverse of a linear map `f`, then `g` is linear itself. -/
def inverse [module R M] [module S Mβ] {Ο : R β+* S} {Ο' : S β+* R} [ring_hom_inv_pair Ο Ο']
(f : M βββ[Ο] Mβ) (g : Mβ β M) (hβ : left_inverse g f) (hβ : right_inverse g f) :
Mβ βββ[Ο'] M :=
by dsimp [left_inverse, function.right_inverse] at hβ hβ; exact
{ to_fun := g,
map_add' := Ξ» x y, by { rw [β hβ (g (x + y)), β hβ (g x + g y)]; simp [hβ] },
map_smul' := Ξ» a b, by { rw [β hβ (g (a β’ b)), β hβ ((Ο' a) β’ g b)], simp [hβ] } }
end add_comm_monoid
section add_comm_group
variables [semiring R] [semiring S] [add_comm_group M] [add_comm_group Mβ]
variables {module_M : module R M} {module_Mβ : module S Mβ} {Ο : R β+* S}
variables (f : M βββ[Ο] Mβ)
protected lemma map_neg (x : M) : f (- x) = - f x := map_neg f x
protected lemma map_sub (x y : M) : f (x - y) = f x - f y := map_sub f x y
instance compatible_smul.int_module
{S : Type*} [semiring S] [module S M] [module S Mβ] : compatible_smul M Mβ β€ S :=
β¨Ξ» fβ c x, begin
induction c using int.induction_on,
case hz : { simp },
case hp : n ih { simp [add_smul, ih] },
case hn : n ih { simp [sub_smul, ih] }
endβ©
instance compatible_smul.units {R S : Type*}
[monoid R] [mul_action R M] [mul_action R Mβ] [semiring S] [module S M] [module S Mβ]
[compatible_smul M Mβ R S] :
compatible_smul M Mβ RΛ£ S :=
β¨Ξ» fβ c x, (compatible_smul.map_smul fβ (c : R) x : _)β©
end add_comm_group
end linear_map
namespace module
/-- `g : R β+* S` is `R`-linear when the module structure on `S` is `module.comp_hom S g` . -/
@[simps]
def comp_hom.to_linear_map {R S : Type*} [semiring R] [semiring S] (g : R β+* S) :
(by haveI := comp_hom S g; exact (R ββ[R] S)) :=
by exact
{ to_fun := (g : R β S),
map_add' := g.map_add,
map_smul' := g.map_mul }
end module
namespace distrib_mul_action_hom
variables [semiring R] [add_comm_monoid M] [add_comm_monoid Mβ] [module R M] [module R Mβ]
/-- A `distrib_mul_action_hom` between two modules is a linear map. -/
def to_linear_map (fβ : M β+[R] Mβ) : M ββ[R] Mβ := { ..fβ }
instance : has_coe (M β+[R] Mβ) (M ββ[R] Mβ) := β¨to_linear_mapβ©
@[simp] lemma to_linear_map_eq_coe (f : M β+[R] Mβ) :
f.to_linear_map = βf :=
rfl
@[simp, norm_cast] lemma coe_to_linear_map (f : M β+[R] Mβ) :
((f : M ββ[R] Mβ) : M β Mβ) = f :=
rfl
lemma to_linear_map_injective {f g : M β+[R] Mβ} (h : (f : M ββ[R] Mβ) = (g : M ββ[R] Mβ)) :
f = g :=
by { ext m, exact linear_map.congr_fun h m, }
end distrib_mul_action_hom
namespace is_linear_map
section add_comm_monoid
variables [semiring R] [add_comm_monoid M] [add_comm_monoid Mβ]
variables [module R M] [module R Mβ]
include R
/-- Convert an `is_linear_map` predicate to a `linear_map` -/
def mk' (f : M β Mβ) (H : is_linear_map R f) : M ββ[R] Mβ :=
{ to_fun := f, map_add' := H.1, map_smul' := H.2 }
@[simp] theorem mk'_apply {f : M β Mβ} (H : is_linear_map R f) (x : M) :
mk' f H x = f x := rfl
lemma is_linear_map_smul {R M : Type*} [comm_semiring R] [add_comm_monoid M] [module R M]
(c : R) :
is_linear_map R (Ξ» (z : M), c β’ z) :=
begin
refine is_linear_map.mk (smul_add c) _,
intros _ _,
simp only [smul_smul, mul_comm]
end
lemma is_linear_map_smul' {R M : Type*} [semiring R] [add_comm_monoid M] [module R M] (a : M) :
is_linear_map R (Ξ» (c : R), c β’ a) :=
is_linear_map.mk (Ξ» x y, add_smul x y a) (Ξ» x y, mul_smul x y a)
variables {f : M β Mβ} (lin : is_linear_map R f)
include M Mβ lin
lemma map_zero : f (0 : M) = (0 : Mβ) := (lin.mk' f).map_zero
end add_comm_monoid
section add_comm_group
variables [semiring R] [add_comm_group M] [add_comm_group Mβ]
variables [module R M] [module R Mβ]
include R
lemma is_linear_map_neg :
is_linear_map R (Ξ» (z : M), -z) :=
is_linear_map.mk neg_add (Ξ» x y, (smul_neg x y).symm)
variables {f : M β Mβ} (lin : is_linear_map R f)
include M Mβ lin
lemma map_neg (x : M) : f (- x) = - f x := (lin.mk' f).map_neg x
lemma map_sub (x y) : f (x - y) = f x - f y := (lin.mk' f).map_sub x y
end add_comm_group
end is_linear_map
/-- Linear endomorphisms of a module, with associated ring structure
`module.End.semiring` and algebra structure `module.End.algebra`. -/
abbreviation module.End (R : Type u) (M : Type v)
[semiring R] [add_comm_monoid M] [module R M] := M ββ[R] M
/-- Reinterpret an additive homomorphism as a `β`-linear map. -/
def add_monoid_hom.to_nat_linear_map [add_comm_monoid M] [add_comm_monoid Mβ] (f : M β+ Mβ) :
M ββ[β] Mβ :=
{ to_fun := f, map_add' := f.map_add, map_smul' := map_nsmul f }
lemma add_monoid_hom.to_nat_linear_map_injective [add_comm_monoid M] [add_comm_monoid Mβ] :
function.injective (@add_monoid_hom.to_nat_linear_map M Mβ _ _) :=
by { intros f g h, ext, exact linear_map.congr_fun h x }
/-- Reinterpret an additive homomorphism as a `β€`-linear map. -/
def add_monoid_hom.to_int_linear_map [add_comm_group M] [add_comm_group Mβ] (f : M β+ Mβ) :
M ββ[β€] Mβ :=
{ to_fun := f, map_add' := f.map_add, map_smul' := map_zsmul f }
lemma add_monoid_hom.to_int_linear_map_injective [add_comm_group M] [add_comm_group Mβ] :
function.injective (@add_monoid_hom.to_int_linear_map M Mβ _ _) :=
by { intros f g h, ext, exact linear_map.congr_fun h x }
@[simp] lemma add_monoid_hom.coe_to_int_linear_map [add_comm_group M] [add_comm_group Mβ]
(f : M β+ Mβ) :
βf.to_int_linear_map = f := rfl
/-- Reinterpret an additive homomorphism as a `β`-linear map. -/
def add_monoid_hom.to_rat_linear_map [add_comm_group M] [module β M]
[add_comm_group Mβ] [module β Mβ] (f : M β+ Mβ) :
M ββ[β] Mβ :=
{ map_smul' := map_rat_smul f, ..f }
lemma add_monoid_hom.to_rat_linear_map_injective
[add_comm_group M] [module β M] [add_comm_group Mβ] [module β Mβ] :
function.injective (@add_monoid_hom.to_rat_linear_map M Mβ _ _ _ _) :=
by { intros f g h, ext, exact linear_map.congr_fun h x }
@[simp] lemma add_monoid_hom.coe_to_rat_linear_map [add_comm_group M] [module β M]
[add_comm_group Mβ] [module β Mβ] (f : M β+ Mβ) :
βf.to_rat_linear_map = f := rfl
namespace linear_map
section has_smul
variables [semiring R] [semiring Rβ] [semiring Rβ]
variables [add_comm_monoid M] [add_comm_monoid Mβ] [add_comm_monoid Mβ]
variables [module R M] [module Rβ Mβ] [module Rβ Mβ]
variables {Οββ : R β+* Rβ} {Οββ : Rβ β+* Rβ} {Οββ : R β+* Rβ} [ring_hom_comp_triple Οββ Οββ Οββ]
variables [monoid S] [distrib_mul_action S Mβ] [smul_comm_class Rβ S Mβ]
variables [monoid Sβ] [distrib_mul_action Sβ Mβ] [smul_comm_class Rβ Sβ Mβ]
variables [monoid T] [distrib_mul_action T Mβ] [smul_comm_class Rβ T Mβ]
instance : has_smul S (M βββ[Οββ] Mβ) :=
β¨Ξ» a f, { to_fun := a β’ f,
map_add' := Ξ» x y, by simp only [pi.smul_apply, f.map_add, smul_add],
map_smul' := Ξ» c x, by simp [pi.smul_apply, smul_comm (Οββ c)] }β©
@[simp] lemma smul_apply (a : S) (f : M βββ[Οββ] Mβ) (x : M) : (a β’ f) x = a β’ f x := rfl
lemma coe_smul (a : S) (f : M βββ[Οββ] Mβ) : β(a β’ f) = a β’ f := rfl
instance [smul_comm_class S T Mβ] : smul_comm_class S T (M βββ[Οββ] Mβ) :=
β¨Ξ» a b f, ext $ Ξ» x, smul_comm _ _ _β©
-- example application of this instance: if S -> T -> R are homomorphisms of commutative rings and
-- M and Mβ are R-modules then the S-module and T-module structures on Hom_R(M,Mβ) are compatible.
instance [has_smul S T] [is_scalar_tower S T Mβ] : is_scalar_tower S T (M βββ[Οββ] Mβ) :=
{ smul_assoc := Ξ» _ _ _, ext $ Ξ» _, smul_assoc _ _ _ }
instance [distrib_mul_action Sα΅α΅α΅ Mβ] [smul_comm_class Rβ Sα΅α΅α΅ Mβ] [is_central_scalar S Mβ] :
is_central_scalar S (M βββ[Οββ] Mβ) :=
{ op_smul_eq_smul := Ξ» a b, ext $ Ξ» x, op_smul_eq_smul _ _ }
end has_smul
/-! ### Arithmetic on the codomain -/
section arithmetic
variables [semiring Rβ] [semiring Rβ] [semiring Rβ]
variables [add_comm_monoid M] [add_comm_monoid Mβ] [add_comm_monoid Mβ]
variables [add_comm_group Nβ] [add_comm_group Nβ] [add_comm_group Nβ]
variables [module Rβ M] [module Rβ Mβ] [module Rβ Mβ]
variables [module Rβ Nβ] [module Rβ Nβ] [module Rβ Nβ]
variables {Οββ : Rβ β+* Rβ} {Οββ : Rβ β+* Rβ} {Οββ : Rβ β+* Rβ} [ring_hom_comp_triple Οββ Οββ Οββ]
/-- The constant 0 map is linear. -/
instance : has_zero (M βββ[Οββ] Mβ) :=
β¨{ to_fun := 0, map_add' := by simp, map_smul' := by simp }β©
@[simp] lemma zero_apply (x : M) : (0 : M βββ[Οββ] Mβ) x = 0 := rfl
@[simp] theorem comp_zero (g : Mβ βββ[Οββ] Mβ) : (g.comp (0 : M βββ[Οββ] Mβ) : M βββ[Οββ] Mβ) = 0 :=
ext $ assume c, by rw [comp_apply, zero_apply, zero_apply, g.map_zero]
@[simp] theorem zero_comp (f : M βββ[Οββ] Mβ) : ((0 : Mβ βββ[Οββ] Mβ).comp f : M βββ[Οββ] Mβ) = 0 :=
rfl
instance : inhabited (M βββ[Οββ] Mβ) := β¨0β©
@[simp] lemma default_def : (default : (M βββ[Οββ] Mβ)) = 0 := rfl
/-- The sum of two linear maps is linear. -/
instance : has_add (M βββ[Οββ] Mβ) :=
β¨Ξ» f g, { to_fun := f + g,
map_add' := by simp [add_comm, add_left_comm],
map_smul' := by simp [smul_add] }β©
@[simp] lemma add_apply (f g : M βββ[Οββ] Mβ) (x : M) : (f + g) x = f x + g x := rfl
lemma add_comp (f : M βββ[Οββ] Mβ) (g h : Mβ βββ[Οββ] Mβ) :
((h + g).comp f : M βββ[Οββ] Mβ) = h.comp f + g.comp f := rfl
lemma comp_add (f g : M βββ[Οββ] Mβ) (h : Mβ βββ[Οββ] Mβ) :
(h.comp (f + g) : M βββ[Οββ] Mβ) = h.comp f + h.comp g :=
ext $ Ξ» _, h.map_add _ _
/-- The type of linear maps is an additive monoid. -/
instance : add_comm_monoid (M βββ[Οββ] Mβ) :=
fun_like.coe_injective.add_comm_monoid _ rfl (Ξ» _ _, rfl) (Ξ» _ _, rfl)
/-- The negation of a linear map is linear. -/
instance : has_neg (M βββ[Οββ] Nβ) :=
β¨Ξ» f, { to_fun := -f, map_add' := by simp [add_comm], map_smul' := by simp }β©
@[simp] lemma neg_apply (f : M βββ[Οββ] Nβ) (x : M) : (- f) x = - f x := rfl
include Οββ
@[simp] lemma neg_comp (f : M βββ[Οββ] Mβ) (g : Mβ βββ[Οββ] Nβ) : (- g).comp f = - g.comp f := rfl
@[simp] lemma comp_neg (f : M βββ[Οββ] Nβ) (g : Nβ βββ[Οββ] Nβ) : g.comp (- f) = - g.comp f :=
ext $ Ξ» _, g.map_neg _
omit Οββ
/-- The negation of a linear map is linear. -/
instance : has_sub (M βββ[Οββ] Nβ) :=
β¨Ξ» f g, { to_fun := f - g,
map_add' := Ξ» x y, by simp only [pi.sub_apply, map_add, add_sub_add_comm],
map_smul' := Ξ» r x, by simp [pi.sub_apply, map_smul, smul_sub] }β©
@[simp] lemma sub_apply (f g : M βββ[Οββ] Nβ) (x : M) : (f - g) x = f x - g x := rfl
include Οββ
lemma sub_comp (f : M βββ[Οββ] Mβ) (g h : Mβ βββ[Οββ] Nβ) :
(g - h).comp f = g.comp f - h.comp f := rfl
lemma comp_sub (f g : M βββ[Οββ] Nβ) (h : Nβ βββ[Οββ] Nβ) :
h.comp (g - f) = h.comp g - h.comp f :=
ext $ Ξ» _, h.map_sub _ _
omit Οββ
/-- The type of linear maps is an additive group. -/
instance : add_comm_group (M βββ[Οββ] Nβ) :=
fun_like.coe_injective.add_comm_group _
rfl (Ξ» _ _, rfl) (Ξ» _, rfl) (Ξ» _ _, rfl) (Ξ» _ _, rfl) (Ξ» _ _, rfl)
end arithmetic
section actions
variables [semiring R] [semiring Rβ] [semiring Rβ]
variables [add_comm_monoid M] [add_comm_monoid Mβ] [add_comm_monoid Mβ]
variables [module R M] [module Rβ Mβ] [module Rβ Mβ]
variables {Οββ : R β+* Rβ} {Οββ : Rβ β+* Rβ} {Οββ : R β+* Rβ} [ring_hom_comp_triple Οββ Οββ Οββ]
section has_smul
variables [monoid S] [distrib_mul_action S Mβ] [smul_comm_class Rβ S Mβ]
variables [monoid Sβ] [distrib_mul_action Sβ Mβ] [smul_comm_class Rβ Sβ Mβ]
variables [monoid T] [distrib_mul_action T Mβ] [smul_comm_class Rβ T Mβ]
instance : distrib_mul_action S (M βββ[Οββ] Mβ) :=
{ one_smul := Ξ» f, ext $ Ξ» _, one_smul _ _,
mul_smul := Ξ» c c' f, ext $ Ξ» _, mul_smul _ _ _,
smul_add := Ξ» c f g, ext $ Ξ» x, smul_add _ _ _,
smul_zero := Ξ» c, ext $ Ξ» x, smul_zero _ }
include Οββ
theorem smul_comp (a : Sβ) (g : Mβ βββ[Οββ] Mβ) (f : M βββ[Οββ] Mβ) :
(a β’ g).comp f = a β’ (g.comp f) := rfl
omit Οββ
-- TODO: generalize this to semilinear maps
theorem comp_smul [module R Mβ] [module R Mβ] [smul_comm_class R S Mβ] [distrib_mul_action S Mβ]
[smul_comm_class R S Mβ] [compatible_smul Mβ Mβ S R]
(g : Mβ ββ[R] Mβ) (a : S) (f : M ββ[R] Mβ) : g.comp (a β’ f) = a β’ (g.comp f) :=
ext $ Ξ» x, g.map_smul_of_tower _ _
end has_smul
section module
variables [semiring S] [module S Mβ] [smul_comm_class Rβ S Mβ]
instance : module S (M βββ[Οββ] Mβ) :=
{ add_smul := Ξ» a b f, ext $ Ξ» x, add_smul _ _ _,
zero_smul := Ξ» f, ext $ Ξ» x, zero_smul _ _ }
instance [no_zero_smul_divisors S Mβ] : no_zero_smul_divisors S (M βββ[Οββ] Mβ) :=
coe_injective.no_zero_smul_divisors _ rfl coe_smul
end module
end actions
/-!
### Monoid structure of endomorphisms
Lemmas about `pow` such as `linear_map.pow_apply` appear in later files.
-/
section endomorphisms
variables [semiring R] [add_comm_monoid M] [add_comm_group Nβ] [module R M] [module R Nβ]
instance : has_one (module.End R M) := β¨linear_map.idβ©
instance : has_mul (module.End R M) := β¨linear_map.compβ©
lemma one_eq_id : (1 : module.End R M) = id := rfl
lemma mul_eq_comp (f g : module.End R M) : f * g = f.comp g := rfl
@[simp] lemma one_apply (x : M) : (1 : module.End R M) x = x := rfl
@[simp] lemma mul_apply (f g : module.End R M) (x : M) : (f * g) x = f (g x) := rfl
lemma coe_one : β(1 : module.End R M) = _root_.id := rfl
lemma coe_mul (f g : module.End R M) : β(f * g) = f β g := rfl
instance _root_.module.End.monoid : monoid (module.End R M) :=
{ mul := (*),
one := (1 : M ββ[R] M),
mul_assoc := Ξ» f g h, linear_map.ext $ Ξ» x, rfl,
mul_one := comp_id,
one_mul := id_comp }
instance _root_.module.End.semiring : semiring (module.End R M) :=
{ mul := (*),
one := (1 : M ββ[R] M),
zero := 0,
add := (+),
mul_zero := comp_zero,
zero_mul := zero_comp,
left_distrib := Ξ» f g h, comp_add _ _ _,
right_distrib := Ξ» f g h, add_comp _ _ _,
nat_cast := Ξ» n, n β’ 1,
nat_cast_zero := add_monoid.nsmul_zero' _,
nat_cast_succ := Ξ» n, (add_monoid.nsmul_succ' n 1).trans (add_comm _ _),
.. add_monoid_with_one.unary,
.. _root_.module.End.monoid,
.. linear_map.add_comm_monoid }
/-- See also `module.End.nat_cast_def`. -/
@[simp] lemma _root_.module.End.nat_cast_apply (n : β) (m : M) :
(βn : module.End R M) m = n β’ m := rfl
instance _root_.module.End.ring : ring (module.End R Nβ) :=
{ int_cast := Ξ» z, z β’ 1,
int_cast_of_nat := of_nat_zsmul _,
int_cast_neg_succ_of_nat := zsmul_neg_succ_of_nat _,
..module.End.semiring, ..linear_map.add_comm_group }
/-- See also `module.End.int_cast_def`. -/
@[simp] lemma _root_.module.End.int_cast_apply (z : β€) (m : Nβ) :
(βz : module.End R Nβ) m = z β’ m := rfl
section
variables [monoid S] [distrib_mul_action S M] [smul_comm_class R S M]
instance _root_.module.End.is_scalar_tower :
is_scalar_tower S (module.End R M) (module.End R M) := β¨smul_compβ©
instance _root_.module.End.smul_comm_class [has_smul S R] [is_scalar_tower S R M] :
smul_comm_class S (module.End R M) (module.End R M) :=
β¨Ξ» s _ _, (comp_smul _ s _).symmβ©
instance _root_.module.End.smul_comm_class' [has_smul S R] [is_scalar_tower S R M] :
smul_comm_class (module.End R M) S (module.End R M) :=
smul_comm_class.symm _ _ _
end
/-! ### Action by a module endomorphism. -/
/-- The tautological action by `module.End R M` (aka `M ββ[R] M`) on `M`.
This generalizes `function.End.apply_mul_action`. -/
instance apply_module : module (module.End R M) M :=
{ smul := ($),
smul_zero := linear_map.map_zero,
smul_add := linear_map.map_add,
add_smul := linear_map.add_apply,
zero_smul := (linear_map.zero_apply : β m, (0 : M ββ[R] M) m = 0),
one_smul := Ξ» _, rfl,
mul_smul := Ξ» _ _ _, rfl }
@[simp] protected lemma smul_def (f : module.End R M) (a : M) : f β’ a = f a := rfl
/-- `linear_map.apply_module` is faithful. -/
instance apply_has_faithful_smul : has_faithful_smul (module.End R M) M :=
β¨Ξ» _ _, linear_map.extβ©
instance apply_smul_comm_class : smul_comm_class R (module.End R M) M :=
{ smul_comm := Ξ» r e m, (e.map_smul r m).symm }
instance apply_smul_comm_class' : smul_comm_class (module.End R M) R M :=
{ smul_comm := linear_map.map_smul }
instance apply_is_scalar_tower {R M : Type*} [comm_semiring R] [add_comm_monoid M] [module R M] :
is_scalar_tower R (module.End R M) M :=
β¨Ξ» t f m, rflβ©
end endomorphisms
end linear_map
/-! ### Actions as module endomorphisms -/
namespace distrib_mul_action
variables (R M) [semiring R] [add_comm_monoid M] [module R M]
variables [monoid S] [distrib_mul_action S M] [smul_comm_class S R M]
/-- Each element of the monoid defines a linear map.
This is a stronger version of `distrib_mul_action.to_add_monoid_hom`. -/
@[simps]
def to_linear_map (s : S) : M ββ[R] M :=
{ to_fun := has_smul.smul s,
map_add' := smul_add s,
map_smul' := Ξ» a b, smul_comm _ _ _ }
/-- Each element of the monoid defines a module endomorphism.
This is a stronger version of `distrib_mul_action.to_add_monoid_End`. -/
@[simps]
def to_module_End : S β* module.End R M :=
{ to_fun := to_linear_map R M,
map_one' := linear_map.ext $ one_smul _,
map_mul' := Ξ» a b, linear_map.ext $ mul_smul _ _ }
end distrib_mul_action
namespace module
variables (R M) [semiring R] [add_comm_monoid M] [module R M]
variables [semiring S] [module S M] [smul_comm_class S R M]
/-- Each element of the semiring defines a module endomorphism.
This is a stronger version of `distrib_mul_action.to_module_End`. -/
@[simps]
def to_module_End : S β+* module.End R M :=
{ to_fun := distrib_mul_action.to_linear_map R M,
map_zero' := linear_map.ext $ zero_smul _,
map_add' := Ξ» f g, linear_map.ext $ add_smul _ _,
..distrib_mul_action.to_module_End R M }
/-- The canonical (semi)ring isomorphism from `Rα΅α΅α΅` to `module.End R R` induced by the right
multiplication. -/
@[simps]
def module_End_self : Rα΅α΅α΅ β+* module.End R R :=
{ to_fun := distrib_mul_action.to_linear_map R R,
inv_fun := Ξ» f, mul_opposite.op (f 1),
left_inv := mul_one,
right_inv := Ξ» f, linear_map.ext_ring $ one_mul _,
..module.to_module_End R R }
/-- The canonical (semi)ring isomorphism from `R` to `module.End Rα΅α΅α΅ R` induced by the left
multiplication. -/
@[simps]
def module_End_self_op : R β+* module.End Rα΅α΅α΅ R :=
{ to_fun := distrib_mul_action.to_linear_map _ _,
inv_fun := Ξ» f, f 1,
left_inv := mul_one,
right_inv := Ξ» f, linear_map.ext_ring_op $ mul_one _,
..module.to_module_End _ _ }
lemma End.nat_cast_def (n : β) [add_comm_monoid Nβ] [module R Nβ] :
(βn : module.End R Nβ) = module.to_module_End R Nβ n := rfl
lemma End.int_cast_def (z : β€) [add_comm_group Nβ] [module R Nβ] :
(βz : module.End R Nβ) = module.to_module_End R Nβ z := rfl
end module
|