diff --git "a/Extracted/Mathlib/TacticPrediction/Mathlib_Algebra_Algebra_Tower.jsonl" "b/Extracted/Mathlib/TacticPrediction/Mathlib_Algebra_Algebra_Tower.jsonl" deleted file mode 100644--- "a/Extracted/Mathlib/TacticPrediction/Mathlib_Algebra_Algebra_Tower.jsonl" +++ /dev/null @@ -1,44 +0,0 @@ -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁵ : CommSemiring R\ninst✝⁴ : Semiring A\ninst✝³ : Algebra R A\ninst✝² : SMul R M\ninst✝¹ : MulAction A M\ninst✝ : IsScalarTower R A M\nr : R\nx : M\n⊢ (algebraMap R A) r • x = r • x","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n ","nextTactic":"rw [Algebra.algebraMap_eq_smul_one]","declUpToTactic":"theorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.91_0.zHGuLDwqTOS7xd8","decl":"theorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁵ : CommSemiring R\ninst✝⁴ : Semiring A\ninst✝³ : Algebra R A\ninst✝² : SMul R M\ninst✝¹ : MulAction A M\ninst✝ : IsScalarTower R A M\nr : R\nx : M\n⊢ (r • 1) • x = r • x","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n ","nextTactic":"rw [smul_assoc]","declUpToTactic":"theorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.91_0.zHGuLDwqTOS7xd8","decl":"theorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁵ : CommSemiring R\ninst✝⁴ : Semiring A\ninst✝³ : Algebra R A\ninst✝² : SMul R M\ninst✝¹ : MulAction A M\ninst✝ : IsScalarTower R A M\nr : R\nx : M\n⊢ r • 1 • x = r • x","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n ","nextTactic":"rw [one_smul]","declUpToTactic":"theorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.91_0.zHGuLDwqTOS7xd8","decl":"theorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁷ : CommSemiring R\ninst✝⁶ : CommSemiring S\ninst✝⁵ : Semiring A\ninst✝⁴ : Semiring B\ninst✝³ : Algebra R S\ninst✝² : Algebra S A\ninst✝¹ : Algebra S B\ninst✝ : Algebra R A\nh : ∀ (x : R), (algebraMap R A) x = (algebraMap S A) ((algebraMap R S) x)\nx : R\ny : S\nz : A\n⊢ (x • y) • z = x • y • z","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by ","nextTactic":"simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]","declUpToTactic":"theorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.107_0.zHGuLDwqTOS7xd8","decl":"theorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹⁰ : CommSemiring R\ninst✝⁹ : CommSemiring S\ninst✝⁸ : Semiring A\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra R S\ninst✝⁵ : Algebra S A\ninst✝⁴ : Algebra S B\ninst✝³ : Algebra R A\ninst✝² : Algebra R B\ninst✝¹ : IsScalarTower R S A\ninst✝ : IsScalarTower R S B\nx : R\n⊢ (algebraMap R A) x = (RingHom.comp (algebraMap S A) (algebraMap R S)) x","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n ","nextTactic":"simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]","declUpToTactic":"theorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.124_0.zHGuLDwqTOS7xd8","decl":"theorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹⁰ : CommSemiring R\ninst✝⁹ : CommSemiring S\ninst✝⁸ : Semiring A\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra R S\ninst✝⁵ : Algebra S A\ninst✝⁴ : Algebra S B\ninst✝³ : Algebra R A\ninst✝² : Algebra R B\ninst✝¹ : IsScalarTower R S A\ninst✝ : IsScalarTower R S B\nx : R\n⊢ (algebraMap R A) x = (algebraMap S A) ((algebraMap R S) x)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n ","nextTactic":"rw [algebraMap_eq R S A]","declUpToTactic":"theorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.129_0.zHGuLDwqTOS7xd8","decl":"theorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹⁰ : CommSemiring R\ninst✝⁹ : CommSemiring S\ninst✝⁸ : Semiring A\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra R S\ninst✝⁵ : Algebra S A\ninst✝⁴ : Algebra S B\ninst✝³ : Algebra R A\ninst✝² : Algebra R B\ninst✝¹ : IsScalarTower R S A\ninst✝ : IsScalarTower R S B\nx : R\n⊢ (RingHom.comp (algebraMap S A) (algebraMap R S)) x = (algebraMap S A) ((algebraMap R S) x)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n ","nextTactic":"rw [RingHom.comp_apply]","declUpToTactic":"theorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.129_0.zHGuLDwqTOS7xd8","decl":"theorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) "} -{"state":"R : Type u\nS✝ : Type v\nA✝ : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹² : CommSemiring R\ninst✝¹¹ : CommSemiring S✝\ninst✝¹⁰ : Semiring A✝\ninst✝⁹ : Semiring B\ninst✝⁸ : Algebra R S✝\ninst✝⁷ : Algebra S✝ A✝\ninst✝⁶ : Algebra S✝ B\ninst✝⁵ : Algebra R A✝\ninst✝⁴ : Algebra R B\ninst✝³ : IsScalarTower R S✝ A✝\ninst✝² : IsScalarTower R S✝ B\nS : Type u\nA : Type v\ninst✝¹ : CommSemiring S\ninst✝ : Semiring A\nh1 h2 : Algebra S A\nr : S\nx : A\n⊢ A","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by ","nextTactic":"have I := h1","declUpToTactic":"@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.134_0.zHGuLDwqTOS7xd8","decl":"@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I "} -{"state":"R : Type u\nS✝ : Type v\nA✝ : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹² : CommSemiring R\ninst✝¹¹ : CommSemiring S✝\ninst✝¹⁰ : Semiring A✝\ninst✝⁹ : Semiring B\ninst✝⁸ : Algebra R S✝\ninst✝⁷ : Algebra S✝ A✝\ninst✝⁶ : Algebra S✝ B\ninst✝⁵ : Algebra R A✝\ninst✝⁴ : Algebra R B\ninst✝³ : IsScalarTower R S✝ A✝\ninst✝² : IsScalarTower R S✝ B\nS : Type u\nA : Type v\ninst✝¹ : CommSemiring S\ninst✝ : Semiring A\nh1 h2 : Algebra S A\nr : S\nx : A\nI : Algebra S A\n⊢ A","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; ","nextTactic":"exact r • x","declUpToTactic":"@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.134_0.zHGuLDwqTOS7xd8","decl":"@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I "} -{"state":"R : Type u\nS✝ : Type v\nA✝ : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹² : CommSemiring R\ninst✝¹¹ : CommSemiring S✝\ninst✝¹⁰ : Semiring A✝\ninst✝⁹ : Semiring B\ninst✝⁸ : Algebra R S✝\ninst✝⁷ : Algebra S✝ A✝\ninst✝⁶ : Algebra S✝ B\ninst✝⁵ : Algebra R A✝\ninst✝⁴ : Algebra R B\ninst✝³ : IsScalarTower R S✝ A✝\ninst✝² : IsScalarTower R S✝ B\nS : Type u\nA : Type v\ninst✝¹ : CommSemiring S\ninst✝ : Semiring A\nh1 h2 : Algebra S A\nh :\n ∀ (r : S) (x : A),\n (let_fun I := h1;\n r • x) =\n r • x\nr : S\n⊢ (algebraMap S A) r = (algebraMap S A) r","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n ","nextTactic":"simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1","declUpToTactic":"@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.134_0.zHGuLDwqTOS7xd8","decl":"@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹⁰ : CommSemiring R\ninst✝⁹ : CommSemiring S\ninst✝⁸ : Semiring A\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra R S\ninst✝⁵ : Algebra S A\ninst✝⁴ : Algebra S B\ninst✝³ : Algebra R A\ninst✝² : Algebra R B\ninst✝¹ : IsScalarTower R S A\ninst✝ : IsScalarTower R S B\nf : A →ₐ[S] B\nr : R\n⊢ f ((algebraMap R A) r) = (algebraMap R B) r","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n ","nextTactic":"rw [algebraMap_apply R S A r]","declUpToTactic":"@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.161_0.zHGuLDwqTOS7xd8","decl":"@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹⁰ : CommSemiring R\ninst✝⁹ : CommSemiring S\ninst✝⁸ : Semiring A\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra R S\ninst✝⁵ : Algebra S A\ninst✝⁴ : Algebra S B\ninst✝³ : Algebra R A\ninst✝² : Algebra R B\ninst✝¹ : IsScalarTower R S A\ninst✝ : IsScalarTower R S B\nf : A →ₐ[S] B\nr : R\n⊢ f ((algebraMap S A) ((algebraMap R S) r)) = (algebraMap R B) r","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n ","nextTactic":"rw [f.commutes]","declUpToTactic":"@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.161_0.zHGuLDwqTOS7xd8","decl":"@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹⁰ : CommSemiring R\ninst✝⁹ : CommSemiring S\ninst✝⁸ : Semiring A\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra R S\ninst✝⁵ : Algebra S A\ninst✝⁴ : Algebra S B\ninst✝³ : Algebra R A\ninst✝² : Algebra R B\ninst✝¹ : IsScalarTower R S A\ninst✝ : IsScalarTower R S B\nf : A →ₐ[S] B\nr : R\n⊢ (algebraMap S B) ((algebraMap R S) r) = (algebraMap R B) r","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n ","nextTactic":"rw [← algebraMap_apply R S B]","declUpToTactic":"@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.161_0.zHGuLDwqTOS7xd8","decl":"@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹⁰ : CommSemiring R\ninst✝⁹ : CommSemiring S\ninst✝⁸ : Semiring A\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra R S\ninst✝⁵ : Algebra S A\ninst✝⁴ : Algebra S B\ninst✝³ : Algebra R A\ninst✝² : Algebra R B\ninst✝¹ : IsScalarTower R S A\ninst✝ : IsScalarTower R S B\nf : A →ₐ[S] B\nsrc✝ : A →+* B := ↑f\nr : R\n⊢ OneHom.toFun\n (↑↑{ toMonoidHom := ↑src✝, map_zero' := (_ : OneHom.toFun (↑↑src✝) 0 = 0),\n map_add' :=\n (_ : ∀ (x y : A), OneHom.toFun (↑↑src✝) (x + y) = OneHom.toFun (↑↑src✝) x + OneHom.toFun (↑↑src✝) y) })\n ((algebraMap R A) r) =\n (algebraMap R B) r","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ��� S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n ","nextTactic":"rw [algebraMap_apply R S A]","declUpToTactic":"/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.210_0.zHGuLDwqTOS7xd8","decl":"/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹⁰ : CommSemiring R\ninst✝⁹ : CommSemiring S\ninst✝⁸ : Semiring A\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra R S\ninst✝⁵ : Algebra S A\ninst✝⁴ : Algebra S B\ninst✝³ : Algebra R A\ninst✝² : Algebra R B\ninst✝¹ : IsScalarTower R S A\ninst✝ : IsScalarTower R S B\nf : A →ₐ[S] B\nsrc✝ : A →+* B := ↑f\nr : R\n⊢ OneHom.toFun\n (↑↑{ toMonoidHom := ↑src✝, map_zero' := (_ : OneHom.toFun (↑↑src✝) 0 = 0),\n map_add' :=\n (_ : ∀ (x y : A), OneHom.toFun (↑↑src✝) (x + y) = OneHom.toFun (↑↑src✝) x + OneHom.toFun (↑↑src✝) y) })\n ((algebraMap S A) ((algebraMap R S) r)) =\n (algebraMap R B) r","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n ","nextTactic":"rw [algebraMap_apply R S B]","declUpToTactic":"/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.210_0.zHGuLDwqTOS7xd8","decl":"/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹⁰ : CommSemiring R\ninst✝⁹ : CommSemiring S\ninst✝⁸ : Semiring A\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra R S\ninst✝⁵ : Algebra S A\ninst✝⁴ : Algebra S B\ninst✝³ : Algebra R A\ninst✝² : Algebra R B\ninst✝¹ : IsScalarTower R S A\ninst✝ : IsScalarTower R S B\nf : A →ₐ[S] B\nsrc✝ : A →+* B := ↑f\nr : R\n⊢ OneHom.toFun\n (↑↑{ toMonoidHom := ↑src✝, map_zero' := (_ : OneHom.toFun (↑↑src✝) 0 = 0),\n map_add' :=\n (_ : ∀ (x y : A), OneHom.toFun (↑↑src✝) (x + y) = OneHom.toFun (↑↑src✝) x + OneHom.toFun (↑↑src✝) y) })\n ((algebraMap S A) ((algebraMap R S) r)) =\n (algebraMap S B) ((algebraMap R S) r)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n ","nextTactic":"exact f.commutes (algebraMap R S r)","declUpToTactic":"/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.210_0.zHGuLDwqTOS7xd8","decl":"/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹⁰ : CommSemiring R\ninst✝⁹ : CommSemiring S\ninst✝⁸ : Semiring A\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra R S\ninst✝⁵ : Algebra S A\ninst✝⁴ : Algebra S B\ninst✝³ : Algebra R A\ninst✝² : Algebra R B\ninst✝¹ : IsScalarTower R S A\ninst✝ : IsScalarTower R S B\nf : A ≃ₐ[S] B\nsrc✝ : A ≃+* B := ↑f\nr : R\n⊢ Equiv.toFun src✝.toEquiv ((algebraMap R A) r) = (algebraMap R B) r","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n ","nextTactic":"rw [algebraMap_apply R S A]","declUpToTactic":"/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.239_0.zHGuLDwqTOS7xd8","decl":"/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹⁰ : CommSemiring R\ninst✝⁹ : CommSemiring S\ninst✝⁸ : Semiring A\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra R S\ninst✝⁵ : Algebra S A\ninst✝⁴ : Algebra S B\ninst✝³ : Algebra R A\ninst✝² : Algebra R B\ninst✝¹ : IsScalarTower R S A\ninst✝ : IsScalarTower R S B\nf : A ≃ₐ[S] B\nsrc✝ : A ≃+* B := ↑f\nr : R\n⊢ Equiv.toFun src✝.toEquiv ((algebraMap S A) ((algebraMap R S) r)) = (algebraMap R B) r","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n ","nextTactic":"rw [algebraMap_apply R S B]","declUpToTactic":"/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.239_0.zHGuLDwqTOS7xd8","decl":"/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹⁰ : CommSemiring R\ninst✝⁹ : CommSemiring S\ninst✝⁸ : Semiring A\ninst✝⁷ : Semiring B\ninst✝⁶ : Algebra R S\ninst✝⁵ : Algebra S A\ninst✝⁴ : Algebra S B\ninst✝³ : Algebra R A\ninst✝² : Algebra R B\ninst✝¹ : IsScalarTower R S A\ninst✝ : IsScalarTower R S B\nf : A ≃ₐ[S] B\nsrc✝ : A ≃+* B := ↑f\nr : R\n⊢ Equiv.toFun src✝.toEquiv ((algebraMap S A) ((algebraMap R S) r)) = (algebraMap S B) ((algebraMap R S) r)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ��� S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n ","nextTactic":"exact f.commutes (algebraMap R S r)","declUpToTactic":"/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.239_0.zHGuLDwqTOS7xd8","decl":"/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁶ : CommSemiring R\ninst✝⁵ : Semiring A\ninst✝⁴ : Algebra R A\ninst✝³ : AddCommMonoid M\ninst✝² : Module R M\ninst✝¹ : Module A M\ninst✝ : IsScalarTower R A M\nhsur : Function.Surjective ⇑(algebraMap R A)\nX : Set M\n⊢ restrictScalars R (span A X) = span R X","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n ","nextTactic":"refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm","declUpToTactic":"/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.276_0.zHGuLDwqTOS7xd8","decl":"/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁶ : CommSemiring R\ninst✝⁵ : Semiring A\ninst✝⁴ : Algebra R A\ninst✝³ : AddCommMonoid M\ninst✝² : Module R M\ninst✝¹ : Module A M\ninst✝ : IsScalarTower R A M\nhsur : Function.Surjective ⇑(algebraMap R A)\nX : Set M\nm : M\nhm : m ∈ restrictScalars R (span A X)\n⊢ m ∈ span R X","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n ","nextTactic":"refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _","declUpToTactic":"/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.276_0.zHGuLDwqTOS7xd8","decl":"/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁶ : CommSemiring R\ninst✝⁵ : Semiring A\ninst✝⁴ : Algebra R A\ninst✝³ : AddCommMonoid M\ninst✝² : Module R M\ninst✝¹ : Module A M\ninst✝ : IsScalarTower R A M\nhsur : Function.Surjective ⇑(algebraMap R A)\nX : Set M\nm✝ : M\nhm✝ : m✝ ∈ restrictScalars R (span A X)\na : A\nm : M\nhm : m ∈ span R X\n⊢ a • m ∈ span R X","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n ","nextTactic":"obtain ⟨r, rfl⟩ := hsur a","declUpToTactic":"/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.276_0.zHGuLDwqTOS7xd8","decl":"/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X "} -{"state":"case intro\nR : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁶ : CommSemiring R\ninst✝⁵ : Semiring A\ninst✝⁴ : Algebra R A\ninst✝³ : AddCommMonoid M\ninst✝² : Module R M\ninst✝¹ : Module A M\ninst✝ : IsScalarTower R A M\nhsur : Function.Surjective ⇑(algebraMap R A)\nX : Set M\nm✝ : M\nhm✝ : m✝ ∈ restrictScalars R (span A X)\nm : M\nhm : m ∈ span R X\nr : R\n⊢ (algebraMap R A) r • m ∈ span R X","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n ","nextTactic":"simpa [algebraMap_smul] using smul_mem _ r hm","declUpToTactic":"/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.276_0.zHGuLDwqTOS7xd8","decl":"/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁶ : Semiring R\ninst✝⁵ : Semiring S\ninst✝⁴ : AddCommMonoid A\ninst✝³ : Module R S\ninst✝² : Module S A\ninst✝¹ : Module R A\ninst✝ : IsScalarTower R S A\ns : Set S\nt : Set A\nk : S\nhks : k ∈ span R s\nx : A\nhx : x ∈ t\n⊢ 0 • x ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by ","nextTactic":"rw [zero_smul]","declUpToTactic":"theorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.307_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁶ : Semiring R\ninst✝⁵ : Semiring S\ninst✝⁴ : AddCommMonoid A\ninst✝³ : Module R S\ninst✝² : Module S A\ninst✝¹ : Module R A\ninst✝ : IsScalarTower R S A\ns : Set S\nt : Set A\nk : S\nhks : k ∈ span R s\nx : A\nhx : x ∈ t\n⊢ 0 ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; ","nextTactic":"exact zero_mem _","declUpToTactic":"theorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.307_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁶ : Semiring R\ninst✝⁵ : Semiring S\ninst✝⁴ : AddCommMonoid A\ninst✝³ : Module R S\ninst✝² : Module S A\ninst✝¹ : Module R A\ninst✝ : IsScalarTower R S A\ns : Set S\nt : Set A\nk : S\nhks : k ∈ span R s\nx : A\nhx : x ∈ t\nc₁ c₂ : S\nih₁ : c₁ • x ∈ span R (s • t)\nih₂ : c₂ • x ∈ span R (s • t)\n⊢ (c₁ + c₂) • x ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by ","nextTactic":"rw [add_smul]","declUpToTactic":"theorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.307_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁶ : Semiring R\ninst✝⁵ : Semiring S\ninst✝⁴ : AddCommMonoid A\ninst✝³ : Module R S\ninst✝² : Module S A\ninst✝¹ : Module R A\ninst✝ : IsScalarTower R S A\ns : Set S\nt : Set A\nk : S\nhks : k ∈ span R s\nx : A\nhx : x ∈ t\nc₁ c₂ : S\nih₁ : c₁ • x ∈ span R (s • t)\nih₂ : c₂ • x ∈ span R (s • t)\n⊢ c₁ • x + c₂ • x ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; ","nextTactic":"exact add_mem ih₁ ih₂","declUpToTactic":"theorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.307_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁶ : Semiring R\ninst✝⁵ : Semiring S\ninst✝⁴ : AddCommMonoid A\ninst✝³ : Module R S\ninst✝² : Module S A\ninst✝¹ : Module R A\ninst✝ : IsScalarTower R S A\ns : Set S\nt : Set A\nk : S\nhks : k ∈ span R s\nx : A\nhx : x ∈ t\nb : R\nc : S\nhc : c • x ∈ span R (s • t)\n⊢ (b • c) • x ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by ","nextTactic":"rw [IsScalarTower.smul_assoc]","declUpToTactic":"theorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.307_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁶ : Semiring R\ninst✝⁵ : Semiring S\ninst✝⁴ : AddCommMonoid A\ninst✝³ : Module R S\ninst✝² : Module S A\ninst✝¹ : Module R A\ninst✝ : IsScalarTower R S A\ns : Set S\nt : Set A\nk : S\nhks : k ∈ span R s\nx : A\nhx : x ∈ t\nb : R\nc : S\nhc : c • x ∈ span R (s • t)\n⊢ b • c • x ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; ","nextTactic":"exact smul_mem _ _ hc","declUpToTactic":"theorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.307_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁷ : Semiring R\ninst✝⁶ : Semiring S\ninst✝⁵ : AddCommMonoid A\ninst✝⁴ : Module R S\ninst✝³ : Module S A\ninst✝² : Module R A\ninst✝¹ : IsScalarTower R S A\ninst✝ : SMulCommClass R S A\ns : Set S\nhs : span R s = ⊤\nt : Set A\nk : S\nx : A\nhx : x ∈ span R t\n⊢ k • 0 ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n\nvariable [SMulCommClass R S A]\n\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by ","nextTactic":"rw [smul_zero]","declUpToTactic":"theorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.317_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁷ : Semiring R\ninst✝⁶ : Semiring S\ninst✝⁵ : AddCommMonoid A\ninst✝⁴ : Module R S\ninst✝³ : Module S A\ninst✝² : Module R A\ninst✝¹ : IsScalarTower R S A\ninst✝ : SMulCommClass R S A\ns : Set S\nhs : span R s = ⊤\nt : Set A\nk : S\nx : A\nhx : x ∈ span R t\n⊢ 0 ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n\nvariable [SMulCommClass R S A]\n\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; ","nextTactic":"exact zero_mem _","declUpToTactic":"theorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.317_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁷ : Semiring R\ninst✝⁶ : Semiring S\ninst✝⁵ : AddCommMonoid A\ninst✝⁴ : Module R S\ninst✝³ : Module S A\ninst✝² : Module R A\ninst✝¹ : IsScalarTower R S A\ninst✝ : SMulCommClass R S A\ns : Set S\nhs : span R s = ⊤\nt : Set A\nk : S\nx✝ : A\nhx : x✝ ∈ span R t\nx y : A\nihx : k • x ∈ span R (s • t)\nihy : k • y ∈ span R (s • t)\n⊢ k • (x + y) ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n\nvariable [SMulCommClass R S A]\n\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by ","nextTactic":"rw [smul_add]","declUpToTactic":"theorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.317_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁷ : Semiring R\ninst✝⁶ : Semiring S\ninst✝⁵ : AddCommMonoid A\ninst✝⁴ : Module R S\ninst✝³ : Module S A\ninst✝² : Module R A\ninst✝¹ : IsScalarTower R S A\ninst✝ : SMulCommClass R S A\ns : Set S\nhs : span R s = ⊤\nt : Set A\nk : S\nx✝ : A\nhx : x✝ ∈ span R t\nx y : A\nihx : k • x ∈ span R (s • t)\nihy : k • y ∈ span R (s • t)\n⊢ k • x + k • y ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n\nvariable [SMulCommClass R S A]\n\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; ","nextTactic":"exact add_mem ihx ihy","declUpToTactic":"theorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.317_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁷ : Semiring R\ninst✝⁶ : Semiring S\ninst✝⁵ : AddCommMonoid A\ninst✝⁴ : Module R S\ninst✝³ : Module S A\ninst✝² : Module R A\ninst✝¹ : IsScalarTower R S A\ninst✝ : SMulCommClass R S A\ns : Set S\nhs : span R s = ⊤\nt : Set A\nk : S\nx✝ : A\nhx✝ : x✝ ∈ span R (s • t)\nx : A\nhx : x ∈ s • t\n⊢ k • x ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n\nvariable [SMulCommClass R S A]\n\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; exact add_mem ihx ihy)\n fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul Submodule.smul_mem_span_smul\n\ntheorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n ","nextTactic":"let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx","declUpToTactic":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.325_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁷ : Semiring R\ninst✝⁶ : Semiring S\ninst✝⁵ : AddCommMonoid A\ninst✝⁴ : Module R S\ninst✝³ : Module S A\ninst✝² : Module R A\ninst✝¹ : IsScalarTower R S A\ninst✝ : SMulCommClass R S A\ns : Set S\nhs : span R s = ⊤\nt : Set A\nk : S\nx✝ : A\nhx✝ : x✝ ∈ span R (s • t)\nx : A\nhx : x ∈ s • t\np : S\nq : A\n_hp : p ∈ s\nhq : q ∈ t\nhpq : p • q = x\n⊢ k • x ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n\nvariable [SMulCommClass R S A]\n\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; exact add_mem ihx ihy)\n fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul Submodule.smul_mem_span_smul\n\ntheorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n ","nextTactic":"rw [← hpq]","declUpToTactic":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.325_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁷ : Semiring R\ninst✝⁶ : Semiring S\ninst✝⁵ : AddCommMonoid A\ninst✝⁴ : Module R S\ninst✝³ : Module S A\ninst✝² : Module R A\ninst✝¹ : IsScalarTower R S A\ninst✝ : SMulCommClass R S A\ns : Set S\nhs : span R s = ⊤\nt : Set A\nk : S\nx✝ : A\nhx✝ : x✝ ∈ span R (s • t)\nx : A\nhx : x ∈ s • t\np : S\nq : A\n_hp : p ∈ s\nhq : q ∈ t\nhpq : p • q = x\n⊢ k • p • q ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n\nvariable [SMulCommClass R S A]\n\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; exact add_mem ihx ihy)\n fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul Submodule.smul_mem_span_smul\n\ntheorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n rw [← hpq]\n ","nextTactic":"rw [smul_smul]","declUpToTactic":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n rw [← hpq]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.325_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁷ : Semiring R\ninst✝⁶ : Semiring S\ninst✝⁵ : AddCommMonoid A\ninst✝⁴ : Module R S\ninst✝³ : Module S A\ninst✝² : Module R A\ninst✝¹ : IsScalarTower R S A\ninst✝ : SMulCommClass R S A\ns : Set S\nhs : span R s = ⊤\nt : Set A\nk : S\nx✝ : A\nhx✝ : x✝ ∈ span R (s • t)\nx : A\nhx : x ∈ s • t\np : S\nq : A\n_hp : p ∈ s\nhq : q ∈ t\nhpq : p • q = x\n⊢ (k * p) • q ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n\nvariable [SMulCommClass R S A]\n\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; exact add_mem ihx ihy)\n fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul Submodule.smul_mem_span_smul\n\ntheorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n rw [← hpq]\n rw [smul_smul]\n ","nextTactic":"exact smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hq","declUpToTactic":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n rw [← hpq]\n rw [smul_smul]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.325_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁷ : Semiring R\ninst✝⁶ : Semiring S\ninst✝⁵ : AddCommMonoid A\ninst✝⁴ : Module R S\ninst✝³ : Module S A\ninst✝² : Module R A\ninst✝¹ : IsScalarTower R S A\ninst✝ : SMulCommClass R S A\ns : Set S\nhs : span R s = ⊤\nt : Set A\nk : S\nx : A\nhx : x ∈ span R (s • t)\n⊢ k • 0 ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n\nvariable [SMulCommClass R S A]\n\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; exact add_mem ihx ihy)\n fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul Submodule.smul_mem_span_smul\n\ntheorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n rw [← hpq]\n rw [smul_smul]\n exact smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hq)\n (by ","nextTactic":"rw [smul_zero]","declUpToTactic":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n rw [← hpq]\n rw [smul_smul]\n exact smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hq)\n (by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.325_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁷ : Semiring R\ninst✝⁶ : Semiring S\ninst✝⁵ : AddCommMonoid A\ninst✝⁴ : Module R S\ninst✝³ : Module S A\ninst✝² : Module R A\ninst✝¹ : IsScalarTower R S A\ninst✝ : SMulCommClass R S A\ns : Set S\nhs : span R s = ⊤\nt : Set A\nk : S\nx : A\nhx : x ∈ span R (s • t)\n⊢ 0 ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n\nvariable [SMulCommClass R S A]\n\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; exact add_mem ihx ihy)\n fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul Submodule.smul_mem_span_smul\n\ntheorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n rw [← hpq]\n rw [smul_smul]\n exact smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hq)\n (by rw [smul_zero]; ","nextTactic":"exact zero_mem _","declUpToTactic":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n rw [← hpq]\n rw [smul_smul]\n exact smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hq)\n (by rw [smul_zero]; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.325_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁷ : Semiring R\ninst✝⁶ : Semiring S\ninst✝⁵ : AddCommMonoid A\ninst✝⁴ : Module R S\ninst✝³ : Module S A\ninst✝² : Module R A\ninst✝¹ : IsScalarTower R S A\ninst✝ : SMulCommClass R S A\ns : Set S\nhs : span R s = ⊤\nt : Set A\nk : S\nx✝ : A\nhx : x✝ ∈ span R (s • t)\nx y : A\nihx : k • x ∈ span R (s • t)\nihy : k • y ∈ span R (s • t)\n⊢ k • (x + y) ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n\nvariable [SMulCommClass R S A]\n\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; exact add_mem ihx ihy)\n fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul Submodule.smul_mem_span_smul\n\ntheorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n rw [← hpq]\n rw [smul_smul]\n exact smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hq)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by ","nextTactic":"rw [smul_add]","declUpToTactic":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n rw [← hpq]\n rw [smul_smul]\n exact smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hq)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.325_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝⁷ : Semiring R\ninst✝⁶ : Semiring S\ninst✝⁵ : AddCommMonoid A\ninst✝⁴ : Module R S\ninst✝³ : Module S A\ninst✝² : Module R A\ninst✝¹ : IsScalarTower R S A\ninst✝ : SMulCommClass R S A\ns : Set S\nhs : span R s = ⊤\nt : Set A\nk : S\nx✝ : A\nhx : x✝ ∈ span R (s • t)\nx y : A\nihx : k • x ∈ span R (s • t)\nihy : k • y ∈ span R (s • t)\n⊢ k • x + k • y ∈ span R (s • t)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n\nvariable [SMulCommClass R S A]\n\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; exact add_mem ihx ihy)\n fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul Submodule.smul_mem_span_smul\n\ntheorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n rw [← hpq]\n rw [smul_smul]\n exact smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hq)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; ","nextTactic":"exact add_mem ihx ihy","declUpToTactic":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n rw [← hpq]\n rw [smul_smul]\n exact smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hq)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.325_0.zHGuLDwqTOS7xd8","decl":"theorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) "} -{"state":"R : Type u\nS✝ : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹² : CommSemiring R\ninst✝¹¹ : Semiring S✝\ninst✝¹⁰ : AddCommMonoid A\ninst✝⁹ : Algebra R S✝\ninst✝⁸ : Module S✝ A\ninst✝⁷ : Module R A\ninst✝⁶ : IsScalarTower R S✝ A\nS : Type u_1\nT : Type u_2\ninst✝⁵ : CommSemiring S\ninst✝⁴ : Semiring T\ninst✝³ : Algebra R S\ninst✝² : Algebra R T\ninst✝¹ : Algebra S T\ninst✝ : IsScalarTower R S T\nx : S\na : Set S\nhx : x ∈ span R a\n⊢ (algebraMap S T) x ∈ span R (⇑(algebraMap S T) '' a)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n\nvariable [SMulCommClass R S A]\n\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; exact add_mem ihx ihy)\n fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul Submodule.smul_mem_span_smul\n\ntheorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n rw [← hpq]\n rw [smul_smul]\n exact smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hq)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; exact add_mem ihx ihy)\n fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul' Submodule.smul_mem_span_smul'\n\ntheorem span_smul_of_span_eq_top {s : Set S} (hs : span R s = ⊤) (t : Set A) :\n span R (s • t) = (span S t).restrictScalars R :=\n le_antisymm\n (span_le.2 fun _x hx =>\n let ⟨p, _q, _hps, hqt, hpqx⟩ := Set.mem_smul.1 hx\n hpqx ▸ (span S t).smul_mem p (subset_span hqt))\n fun _p hp =>\n span_induction hp (fun x hx => one_smul S x ▸ smul_mem_span_smul hs (subset_span hx))\n (zero_mem _) (fun _ _ => add_mem) fun _k _x hx => smul_mem_span_smul' hs hx\n#align submodule.span_smul_of_span_eq_top Submodule.span_smul_of_span_eq_top\n\nend Module\n\nsection Algebra\n\nvariable [CommSemiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Algebra R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\n/-- A variant of `Submodule.span_image` for `algebraMap`. -/\ntheorem span_algebraMap_image (a : Set R) :\n Submodule.span R (algebraMap R S '' a) = (Submodule.span R a).map (Algebra.linearMap R S) :=\n (Submodule.span_image <| Algebra.linearMap R S).trans rfl\n#align submodule.span_algebra_map_image Submodule.span_algebraMap_image\n\ntheorem span_algebraMap_image_of_tower {S T : Type*} [CommSemiring S] [Semiring T] [Module R S]\n [IsScalarTower R S S] [Algebra R T] [Algebra S T] [IsScalarTower R S T] (a : Set S) :\n Submodule.span R (algebraMap S T '' a) =\n (Submodule.span R a).map ((Algebra.linearMap S T).restrictScalars R) :=\n (Submodule.span_image <| (Algebra.linearMap S T).restrictScalars R).trans rfl\n#align submodule.span_algebra_map_image_of_tower Submodule.span_algebraMap_image_of_tower\n\ntheorem map_mem_span_algebraMap_image {S T : Type*} [CommSemiring S] [Semiring T] [Algebra R S]\n [Algebra R T] [Algebra S T] [IsScalarTower R S T] (x : S) (a : Set S)\n (hx : x ∈ Submodule.span R a) : algebraMap S T x ∈ Submodule.span R (algebraMap S T '' a) := by\n ","nextTactic":"rw [span_algebraMap_image_of_tower]","declUpToTactic":"theorem map_mem_span_algebraMap_image {S T : Type*} [CommSemiring S] [Semiring T] [Algebra R S]\n [Algebra R T] [Algebra S T] [IsScalarTower R S T] (x : S) (a : Set S)\n (hx : x ∈ Submodule.span R a) : algebraMap S T x ∈ Submodule.span R (algebraMap S T '' a) := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.370_0.zHGuLDwqTOS7xd8","decl":"theorem map_mem_span_algebraMap_image {S T : Type*} [CommSemiring S] [Semiring T] [Algebra R S]\n [Algebra R T] [Algebra S T] [IsScalarTower R S T] (x : S) (a : Set S)\n (hx : x ∈ Submodule.span R a) : algebraMap S T x ∈ Submodule.span R (algebraMap S T '' a) "} -{"state":"R : Type u\nS✝ : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹² : CommSemiring R\ninst✝¹¹ : Semiring S✝\ninst✝¹⁰ : AddCommMonoid A\ninst✝⁹ : Algebra R S✝\ninst✝⁸ : Module S✝ A\ninst✝⁷ : Module R A\ninst✝⁶ : IsScalarTower R S✝ A\nS : Type u_1\nT : Type u_2\ninst✝⁵ : CommSemiring S\ninst✝⁴ : Semiring T\ninst✝³ : Algebra R S\ninst✝² : Algebra R T\ninst✝¹ : Algebra S T\ninst✝ : IsScalarTower R S T\nx : S\na : Set S\nhx : x ∈ span R a\n⊢ (algebraMap S T) x ∈ map (↑R (Algebra.linearMap S T)) (span R a)","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n\nvariable [SMulCommClass R S A]\n\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; exact add_mem ihx ihy)\n fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul Submodule.smul_mem_span_smul\n\ntheorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n rw [← hpq]\n rw [smul_smul]\n exact smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hq)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; exact add_mem ihx ihy)\n fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul' Submodule.smul_mem_span_smul'\n\ntheorem span_smul_of_span_eq_top {s : Set S} (hs : span R s = ⊤) (t : Set A) :\n span R (s • t) = (span S t).restrictScalars R :=\n le_antisymm\n (span_le.2 fun _x hx =>\n let ⟨p, _q, _hps, hqt, hpqx⟩ := Set.mem_smul.1 hx\n hpqx ▸ (span S t).smul_mem p (subset_span hqt))\n fun _p hp =>\n span_induction hp (fun x hx => one_smul S x ▸ smul_mem_span_smul hs (subset_span hx))\n (zero_mem _) (fun _ _ => add_mem) fun _k _x hx => smul_mem_span_smul' hs hx\n#align submodule.span_smul_of_span_eq_top Submodule.span_smul_of_span_eq_top\n\nend Module\n\nsection Algebra\n\nvariable [CommSemiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Algebra R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\n/-- A variant of `Submodule.span_image` for `algebraMap`. -/\ntheorem span_algebraMap_image (a : Set R) :\n Submodule.span R (algebraMap R S '' a) = (Submodule.span R a).map (Algebra.linearMap R S) :=\n (Submodule.span_image <| Algebra.linearMap R S).trans rfl\n#align submodule.span_algebra_map_image Submodule.span_algebraMap_image\n\ntheorem span_algebraMap_image_of_tower {S T : Type*} [CommSemiring S] [Semiring T] [Module R S]\n [IsScalarTower R S S] [Algebra R T] [Algebra S T] [IsScalarTower R S T] (a : Set S) :\n Submodule.span R (algebraMap S T '' a) =\n (Submodule.span R a).map ((Algebra.linearMap S T).restrictScalars R) :=\n (Submodule.span_image <| (Algebra.linearMap S T).restrictScalars R).trans rfl\n#align submodule.span_algebra_map_image_of_tower Submodule.span_algebraMap_image_of_tower\n\ntheorem map_mem_span_algebraMap_image {S T : Type*} [CommSemiring S] [Semiring T] [Algebra R S]\n [Algebra R T] [Algebra S T] [IsScalarTower R S T] (x : S) (a : Set S)\n (hx : x ∈ Submodule.span R a) : algebraMap S T x ∈ Submodule.span R (algebraMap S T '' a) := by\n rw [span_algebraMap_image_of_tower]\n ","nextTactic":"rw [mem_map]","declUpToTactic":"theorem map_mem_span_algebraMap_image {S T : Type*} [CommSemiring S] [Semiring T] [Algebra R S]\n [Algebra R T] [Algebra S T] [IsScalarTower R S T] (x : S) (a : Set S)\n (hx : x ∈ Submodule.span R a) : algebraMap S T x ∈ Submodule.span R (algebraMap S T '' a) := by\n rw [span_algebraMap_image_of_tower]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.370_0.zHGuLDwqTOS7xd8","decl":"theorem map_mem_span_algebraMap_image {S T : Type*} [CommSemiring S] [Semiring T] [Algebra R S]\n [Algebra R T] [Algebra S T] [IsScalarTower R S T] (x : S) (a : Set S)\n (hx : x ∈ Submodule.span R a) : algebraMap S T x ∈ Submodule.span R (algebraMap S T '' a) "} -{"state":"R : Type u\nS✝ : Type v\nA : Type w\nB : Type u₁\nM : Type v₁\ninst✝¹² : CommSemiring R\ninst✝¹¹ : Semiring S✝\ninst✝¹⁰ : AddCommMonoid A\ninst✝⁹ : Algebra R S✝\ninst✝⁸ : Module S✝ A\ninst✝⁷ : Module R A\ninst✝⁶ : IsScalarTower R S✝ A\nS : Type u_1\nT : Type u_2\ninst✝⁵ : CommSemiring S\ninst✝⁴ : Semiring T\ninst✝³ : Algebra R S\ninst✝² : Algebra R T\ninst✝¹ : Algebra S T\ninst✝ : IsScalarTower R S T\nx : S\na : Set S\nhx : x ∈ span R a\n⊢ ∃ y ∈ span R a, (↑R (Algebra.linearMap S T)) y = (algebraMap S T) x","srcUpToTactic":"/-\nCopyright (c) 2020 Kenny Lau. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kenny Lau, Anne Baanen\n-/\nimport Mathlib.Algebra.Algebra.Equiv\nimport Mathlib.LinearAlgebra.Span\n\n#align_import algebra.algebra.tower from \"leanprover-community/mathlib\"@\"71150516f28d9826c7341f8815b31f7d8770c212\"\n\n/-!\n# Towers of algebras\n\nIn this file we prove basic facts about towers of algebra.\n\nAn algebra tower A/S/R is expressed by having instances of `Algebra A S`,\n`Algebra R S`, `Algebra R A` and `IsScalarTower R S A`, the later asserting the\ncompatibility condition `(r • s) • a = r • (s • a)`.\n\nAn important definition is `toAlgHom R S A`, the canonical `R`-algebra homomorphism `S →ₐ[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u₁ v₁\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u₁) (M : Type v₁)\n\nnamespace Algebra\n\nvariable [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B]\nvariable [AddCommMonoid M] [Module R M] [Module A M] [Module B M]\nvariable [IsScalarTower R A M] [IsScalarTower R B M] [SMulCommClass A B M]\n\nvariable {A}\n\n\n/-- The `R`-algebra morphism `A → End (M)` corresponding to the representation of the algebra `A`\non the `B`-module `M`.\n\nThis is a stronger version of `DistribMulAction.toLinearMap`, and could also have been\ncalled `Algebra.toModuleEnd`.\n\nThe typeclasses correspond to the situation where the types act on each other as\n```\nR ----→ B\n| ⟍ |\n| ⟍ |\n↓ ↘ ↓\nA ----→ M\n```\nwhere the diagram commutes, the action by `R` commutes with everything, and the action by `A` and\n`B` on `M` commute.\n\nTypically this is most useful with `B = R` as `Algebra.lsmul R R A : A →ₐ[R] Module.End R M`.\nHowever this can be used to get the fact that left-multiplication by `A` is right `A`-linear, and\nvice versa, as\n```lean\nexample : A →ₐ[R] Module.End Aᵐᵒᵖ A := Algebra.lsmul R Aᵐᵒᵖ A\nexample : Aᵐᵒᵖ →ₐ[R] Module.End A A := Algebra.lsmul R A A\n```\nrespectively; though `LinearMap.mulLeft` and `LinearMap.mulRight` can also be used here.\n-/\ndef lsmul : A →ₐ[R] Module.End B M where\n toFun := DistribMulAction.toLinearMap B M\n map_one' := LinearMap.ext fun _ => one_smul A _\n map_mul' a b := LinearMap.ext <| smul_assoc a b\n map_zero' := LinearMap.ext fun _ => zero_smul A _\n map_add' _a _b := LinearMap.ext fun _ => add_smul _ _ _\n commutes' r := LinearMap.ext <| algebraMap_smul A r\n#align algebra.lsmul Algebra.lsmulₓ\n\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R B M a : M → M) = (a • ·) := rfl\n#align algebra.lsmul_coe Algebra.lsmul_coe\n\nend Algebra\n\nnamespace IsScalarTower\n\nsection Module\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SMul R M] [MulAction A M] [IsScalarTower R A M]\n\nvariable {R} {M}\n\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r • x = r • x := by\n rw [Algebra.algebraMap_eq_smul_one]\n rw [smul_assoc]\n rw [one_smul]\n#align is_scalar_tower.algebra_map_smul IsScalarTower.algebraMap_smul\n\nend Module\n\nsection Semiring\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable {R S A}\n\ntheorem of_algebraMap_eq [Algebra R A]\n (h : ∀ x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n ⟨fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]⟩\n#align is_scalar_tower.of_algebra_map_eq IsScalarTower.of_algebraMap_eq\n\n/-- See note [partially-applied ext lemmas]. -/\ntheorem of_algebraMap_eq' [Algebra R A]\n (h : algebraMap R A = (algebraMap S A).comp (algebraMap R S)) : IsScalarTower R S A :=\n of_algebraMap_eq <| RingHom.ext_iff.1 h\n#align is_scalar_tower.of_algebra_map_eq' IsScalarTower.of_algebraMap_eq'\n\nvariable (R S A)\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\ntheorem algebraMap_eq : algebraMap R A = (algebraMap S A).comp (algebraMap R S) :=\n RingHom.ext fun x => by\n simp_rw [RingHom.comp_apply, Algebra.algebraMap_eq_smul_one, smul_assoc, one_smul]\n#align is_scalar_tower.algebra_map_eq IsScalarTower.algebraMap_eq\n\ntheorem algebraMap_apply (x : R) : algebraMap R A x = algebraMap S A (algebraMap R S x) := by\n rw [algebraMap_eq R S A]\n rw [RingHom.comp_apply]\n#align is_scalar_tower.algebra_map_apply IsScalarTower.algebraMap_apply\n\n@[ext]\ntheorem Algebra.ext {S : Type u} {A : Type v} [CommSemiring S] [Semiring A] (h1 h2 : Algebra S A)\n (h : ∀ (r : S) (x : A), (by have I := h1; exact r • x) = r • x) : h1 = h2 :=\n Algebra.algebra_ext _ _ fun r => by\n simpa only [@Algebra.smul_def _ _ _ _ h1, @Algebra.smul_def _ _ _ _ h2, mul_one] using h r 1\n#align is_scalar_tower.algebra.ext IsScalarTower.Algebra.ext\n\n/-- In a tower, the canonical map from the middle element to the top element is an\nalgebra homomorphism over the bottom element. -/\ndef toAlgHom : S →ₐ[R] A :=\n { algebraMap S A with commutes' := fun _ => (algebraMap_apply _ _ _ _).symm }\n#align is_scalar_tower.to_alg_hom IsScalarTower.toAlgHom\n\ntheorem toAlgHom_apply (y : S) : toAlgHom R S A y = algebraMap S A y := rfl\n#align is_scalar_tower.to_alg_hom_apply IsScalarTower.toAlgHom_apply\n\n@[simp]\ntheorem coe_toAlgHom : ↑(toAlgHom R S A) = algebraMap S A :=\n RingHom.ext fun _ => rfl\n#align is_scalar_tower.coe_to_alg_hom IsScalarTower.coe_toAlgHom\n\n@[simp]\ntheorem coe_toAlgHom' : (toAlgHom R S A : S → A) = algebraMap S A := rfl\n#align is_scalar_tower.coe_to_alg_hom' IsScalarTower.coe_toAlgHom'\n\nvariable {R S A B}\n\n@[simp]\ntheorem _root_.AlgHom.map_algebraMap (f : A →ₐ[S] B) (r : R) :\n f (algebraMap R A r) = algebraMap R B r := by\n rw [algebraMap_apply R S A r]\n rw [f.commutes]\n rw [← algebraMap_apply R S B]\n#align alg_hom.map_algebra_map AlgHom.map_algebraMap\n\nvariable (R)\n\n@[simp]\ntheorem _root_.AlgHom.comp_algebraMap_of_tower (f : A →ₐ[S] B) :\n (f : A →+* B).comp (algebraMap R A) = algebraMap R B :=\n RingHom.ext (AlgHom.map_algebraMap f)\n#align alg_hom.comp_algebra_map_of_tower AlgHom.comp_algebraMap_of_tower\n\n-- conflicts with IsScalarTower.Subalgebra\ninstance (priority := 999) subsemiring (U : Subsemiring S) : IsScalarTower U S A :=\n of_algebraMap_eq fun _x => rfl\n#align is_scalar_tower.subsemiring IsScalarTower.subsemiring\n\n-- Porting note: @[nolint instance_priority]\ninstance (priority := 999) of_ring_hom {R A B : Type*} [CommSemiring R] [CommSemiring A]\n [CommSemiring B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) :\n @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n letI := (f : A →+* B).toAlgebra\n of_algebraMap_eq fun x => (f.commutes x).symm\n#align is_scalar_tower.of_ring_hom IsScalarTower.of_ring_hom\n\nend Semiring\n\nend IsScalarTower\n\nsection Homs\n\nvariable [CommSemiring R] [CommSemiring S] [Semiring A] [Semiring B]\n\nvariable [Algebra R S] [Algebra S A] [Algebra S B]\n\nvariable [Algebra R A] [Algebra R B]\n\nvariable [IsScalarTower R S A] [IsScalarTower R S B]\n\nvariable {A S B}\n\nopen IsScalarTower\n\nnamespace AlgHom\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A →ₐ[S] B) : A →ₐ[R] B :=\n { (f : A →+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_hom.restrict_scalars AlgHom.restrictScalars\n\ntheorem restrictScalars_apply (f : A →ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_hom.restrict_scalars_apply AlgHom.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A →ₐ[S] B) : (f.restrictScalars R : A →+* B) = f := rfl\n#align alg_hom.coe_restrict_scalars AlgHom.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A →ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_hom.coe_restrict_scalars' AlgHom.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A →ₐ[S] B) → A →ₐ[R] B) := fun _ _ h =>\n AlgHom.ext (AlgHom.congr_fun h : _)\n#align alg_hom.restrict_scalars_injective AlgHom.restrictScalars_injective\n\nend AlgHom\n\nnamespace AlgEquiv\n\n/-- R ⟶ S induces S-Alg ⥤ R-Alg -/\ndef restrictScalars (f : A ≃ₐ[S] B) : A ≃ₐ[R] B :=\n { (f : A ≃+* B) with\n commutes' := fun r => by\n rw [algebraMap_apply R S A]\n rw [algebraMap_apply R S B]\n exact f.commutes (algebraMap R S r) }\n#align alg_equiv.restrict_scalars AlgEquiv.restrictScalars\n\ntheorem restrictScalars_apply (f : A ≃ₐ[S] B) (x : A) : f.restrictScalars R x = f x := rfl\n#align alg_equiv.restrict_scalars_apply AlgEquiv.restrictScalars_apply\n\n@[simp]\ntheorem coe_restrictScalars (f : A ≃ₐ[S] B) : (f.restrictScalars R : A ≃+* B) = f := rfl\n#align alg_equiv.coe_restrict_scalars AlgEquiv.coe_restrictScalars\n\n@[simp]\ntheorem coe_restrictScalars' (f : A ≃ₐ[S] B) : (restrictScalars R f : A → B) = f := rfl\n#align alg_equiv.coe_restrict_scalars' AlgEquiv.coe_restrictScalars'\n\ntheorem restrictScalars_injective :\n Function.Injective (restrictScalars R : (A ≃ₐ[S] B) → A ≃ₐ[R] B) := fun _ _ h =>\n AlgEquiv.ext (AlgEquiv.congr_fun h : _)\n#align alg_equiv.restrict_scalars_injective AlgEquiv.restrictScalars_injective\n\nend AlgEquiv\n\nend Homs\n\nnamespace Submodule\n\nvariable {M}\n\nvariable [CommSemiring R] [Semiring A] [Algebra R A] [AddCommMonoid M]\n\nvariable [Module R M] [Module A M] [IsScalarTower R A M]\n\n/-- If `A` is an `R`-algebra such that the induced morphism `R →+* A` is surjective, then the\n`R`-module generated by a set `X` equals the `A`-module generated by `X`. -/\ntheorem restrictScalars_span (hsur : Function.Surjective (algebraMap R A)) (X : Set M) :\n restrictScalars R (span A X) = span R X := by\n refine' ((span_le_restrictScalars R A X).antisymm fun m hm => _).symm\n refine' span_induction hm subset_span (zero_mem _) (fun _ _ => add_mem) fun a m hm => _\n obtain ⟨r, rfl⟩ := hsur a\n simpa [algebraMap_smul] using smul_mem _ r hm\n#align submodule.restrict_scalars_span Submodule.restrictScalars_span\n\ntheorem coe_span_eq_span_of_surjective (h : Function.Surjective (algebraMap R A)) (s : Set M) :\n (Submodule.span A s : Set M) = Submodule.span R s :=\n congr_arg ((↑) : Submodule R M → Set M) (Submodule.restrictScalars_span R A h s)\n#align submodule.coe_span_eq_span_of_surjective Submodule.coe_span_eq_span_of_surjective\n\nend Submodule\n\nsection Semiring\n\nvariable {R S A}\n\nnamespace Submodule\n\nsection Module\n\nvariable [Semiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Module R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\nopen IsScalarTower\n\ntheorem smul_mem_span_smul_of_mem {s : Set S} {t : Set A} {k : S} (hks : k ∈ span R s) {x : A}\n (hx : x ∈ t) : k • x ∈ span R (s • t) :=\n span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 ⟨c, x, hc, hx, rfl⟩)\n (by rw [zero_smul]; exact zero_mem _)\n (fun c₁ c₂ ih₁ ih₂ => by rw [add_smul]; exact add_mem ih₁ ih₂)\n fun b c hc => by rw [IsScalarTower.smul_assoc]; exact smul_mem _ _ hc\n#align submodule.smul_mem_span_smul_of_mem Submodule.smul_mem_span_smul_of_mem\n\nvariable [SMulCommClass R S A]\n\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R t) : k • x ∈ span R (s • t) :=\n span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hx)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; exact add_mem ihx ihy)\n fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul Submodule.smul_mem_span_smul\n\ntheorem smul_mem_span_smul' {s : Set S} (hs : span R s = ⊤) {t : Set A} {k : S} {x : A}\n (hx : x ∈ span R (s • t)) : k • x ∈ span R (s • t) :=\n span_induction hx\n (fun x hx => by\n let ⟨p, q, _hp, hq, hpq⟩ := Set.mem_smul.1 hx\n rw [← hpq]\n rw [smul_smul]\n exact smul_mem_span_smul_of_mem (hs.symm ▸ mem_top) hq)\n (by rw [smul_zero]; exact zero_mem _)\n (fun x y ihx ihy => by rw [smul_add]; exact add_mem ihx ihy)\n fun c x hx => smul_comm c k x ▸ smul_mem _ _ hx\n#align submodule.smul_mem_span_smul' Submodule.smul_mem_span_smul'\n\ntheorem span_smul_of_span_eq_top {s : Set S} (hs : span R s = ⊤) (t : Set A) :\n span R (s • t) = (span S t).restrictScalars R :=\n le_antisymm\n (span_le.2 fun _x hx =>\n let ⟨p, _q, _hps, hqt, hpqx⟩ := Set.mem_smul.1 hx\n hpqx ▸ (span S t).smul_mem p (subset_span hqt))\n fun _p hp =>\n span_induction hp (fun x hx => one_smul S x ▸ smul_mem_span_smul hs (subset_span hx))\n (zero_mem _) (fun _ _ => add_mem) fun _k _x hx => smul_mem_span_smul' hs hx\n#align submodule.span_smul_of_span_eq_top Submodule.span_smul_of_span_eq_top\n\nend Module\n\nsection Algebra\n\nvariable [CommSemiring R] [Semiring S] [AddCommMonoid A]\n\nvariable [Algebra R S] [Module S A] [Module R A] [IsScalarTower R S A]\n\n/-- A variant of `Submodule.span_image` for `algebraMap`. -/\ntheorem span_algebraMap_image (a : Set R) :\n Submodule.span R (algebraMap R S '' a) = (Submodule.span R a).map (Algebra.linearMap R S) :=\n (Submodule.span_image <| Algebra.linearMap R S).trans rfl\n#align submodule.span_algebra_map_image Submodule.span_algebraMap_image\n\ntheorem span_algebraMap_image_of_tower {S T : Type*} [CommSemiring S] [Semiring T] [Module R S]\n [IsScalarTower R S S] [Algebra R T] [Algebra S T] [IsScalarTower R S T] (a : Set S) :\n Submodule.span R (algebraMap S T '' a) =\n (Submodule.span R a).map ((Algebra.linearMap S T).restrictScalars R) :=\n (Submodule.span_image <| (Algebra.linearMap S T).restrictScalars R).trans rfl\n#align submodule.span_algebra_map_image_of_tower Submodule.span_algebraMap_image_of_tower\n\ntheorem map_mem_span_algebraMap_image {S T : Type*} [CommSemiring S] [Semiring T] [Algebra R S]\n [Algebra R T] [Algebra S T] [IsScalarTower R S T] (x : S) (a : Set S)\n (hx : x ∈ Submodule.span R a) : algebraMap S T x ∈ Submodule.span R (algebraMap S T '' a) := by\n rw [span_algebraMap_image_of_tower]\n rw [mem_map]\n ","nextTactic":"exact ⟨x, hx, rfl⟩","declUpToTactic":"theorem map_mem_span_algebraMap_image {S T : Type*} [CommSemiring S] [Semiring T] [Algebra R S]\n [Algebra R T] [Algebra S T] [IsScalarTower R S T] (x : S) (a : Set S)\n (hx : x ∈ Submodule.span R a) : algebraMap S T x ∈ Submodule.span R (algebraMap S T '' a) := by\n rw [span_algebraMap_image_of_tower]\n rw [mem_map]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_Algebra_Tower.370_0.zHGuLDwqTOS7xd8","decl":"theorem map_mem_span_algebraMap_image {S T : Type*} [CommSemiring S] [Semiring T] [Algebra R S]\n [Algebra R T] [Algebra S T] [IsScalarTower R S T] (x : S) (a : Set S)\n (hx : x ∈ Submodule.span R a) : algebraMap S T x ∈ Submodule.span R (algebraMap S T '' a) "}